@query-graph/core 1.1.4 → 1.1.5

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/native.js ADDED
@@ -0,0 +1,714 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ const { createRequire } = require('node:module')
7
+ require = createRequire(__filename)
8
+
9
+ const { readFileSync } = require('node:fs')
10
+ let nativeBinding = null
11
+ const loadErrors = []
12
+
13
+ const isMusl = () => {
14
+ let musl = false
15
+ if (process.platform === 'linux') {
16
+ musl = isMuslFromFilesystem()
17
+ if (musl === null) {
18
+ musl = isMuslFromReport()
19
+ }
20
+ if (musl === null) {
21
+ musl = isMuslFromChildProcess()
22
+ }
23
+ }
24
+ return musl
25
+ }
26
+
27
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
28
+
29
+ const isMuslFromFilesystem = () => {
30
+ try {
31
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
32
+ } catch {
33
+ return null
34
+ }
35
+ }
36
+
37
+ const isMuslFromReport = () => {
38
+ let report = null
39
+ if (typeof process.report?.getReport === 'function') {
40
+ process.report.excludeNetwork = true
41
+ report = process.report.getReport()
42
+ }
43
+ if (!report) {
44
+ return null
45
+ }
46
+ if (report.header && report.header.glibcVersionRuntime) {
47
+ return false
48
+ }
49
+ if (Array.isArray(report.sharedObjects)) {
50
+ if (report.sharedObjects.some(isFileMusl)) {
51
+ return true
52
+ }
53
+ }
54
+ return false
55
+ }
56
+
57
+ const isMuslFromChildProcess = () => {
58
+ try {
59
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
60
+ } catch (e) {
61
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
62
+ return false
63
+ }
64
+ }
65
+
66
+ function requireNative() {
67
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
68
+ try {
69
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
70
+ } catch (err) {
71
+ loadErrors.push(err)
72
+ }
73
+ } else if (process.platform === 'android') {
74
+ if (process.arch === 'arm64') {
75
+ try {
76
+ return require('./query-graph.android-arm64.node')
77
+ } catch (e) {
78
+ loadErrors.push(e)
79
+ }
80
+ try {
81
+ const binding = require('@query-graph/core-android-arm64')
82
+ const bindingPackageVersion = require('@query-graph/core-android-arm64/package.json').version
83
+ if (
84
+ bindingPackageVersion !== '1.1.5' &&
85
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
86
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
87
+ ) {
88
+ throw new Error(
89
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
90
+ )
91
+ }
92
+ return binding
93
+ } catch (e) {
94
+ loadErrors.push(e)
95
+ }
96
+ } else if (process.arch === 'arm') {
97
+ try {
98
+ return require('./query-graph.android-arm-eabi.node')
99
+ } catch (e) {
100
+ loadErrors.push(e)
101
+ }
102
+ try {
103
+ const binding = require('@query-graph/core-android-arm-eabi')
104
+ const bindingPackageVersion = require('@query-graph/core-android-arm-eabi/package.json').version
105
+ if (
106
+ bindingPackageVersion !== '1.1.5' &&
107
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
108
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
109
+ ) {
110
+ throw new Error(
111
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
112
+ )
113
+ }
114
+ return binding
115
+ } catch (e) {
116
+ loadErrors.push(e)
117
+ }
118
+ } else {
119
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
120
+ }
121
+ } else if (process.platform === 'win32') {
122
+ if (process.arch === 'x64') {
123
+ try {
124
+ return require('./query-graph.win32-x64-msvc.node')
125
+ } catch (e) {
126
+ loadErrors.push(e)
127
+ }
128
+ try {
129
+ const binding = require('@query-graph/core-win32-x64-msvc')
130
+ const bindingPackageVersion = require('@query-graph/core-win32-x64-msvc/package.json').version
131
+ if (
132
+ bindingPackageVersion !== '1.1.5' &&
133
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
134
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
135
+ ) {
136
+ throw new Error(
137
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
138
+ )
139
+ }
140
+ return binding
141
+ } catch (e) {
142
+ loadErrors.push(e)
143
+ }
144
+ } else if (process.arch === 'ia32') {
145
+ try {
146
+ return require('./query-graph.win32-ia32-msvc.node')
147
+ } catch (e) {
148
+ loadErrors.push(e)
149
+ }
150
+ try {
151
+ const binding = require('@query-graph/core-win32-ia32-msvc')
152
+ const bindingPackageVersion = require('@query-graph/core-win32-ia32-msvc/package.json').version
153
+ if (
154
+ bindingPackageVersion !== '1.1.5' &&
155
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
156
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
157
+ ) {
158
+ throw new Error(
159
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
160
+ )
161
+ }
162
+ return binding
163
+ } catch (e) {
164
+ loadErrors.push(e)
165
+ }
166
+ } else if (process.arch === 'arm64') {
167
+ try {
168
+ return require('./query-graph.win32-arm64-msvc.node')
169
+ } catch (e) {
170
+ loadErrors.push(e)
171
+ }
172
+ try {
173
+ const binding = require('@query-graph/core-win32-arm64-msvc')
174
+ const bindingPackageVersion = require('@query-graph/core-win32-arm64-msvc/package.json').version
175
+ if (
176
+ bindingPackageVersion !== '1.1.5' &&
177
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
178
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
179
+ ) {
180
+ throw new Error(
181
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
182
+ )
183
+ }
184
+ return binding
185
+ } catch (e) {
186
+ loadErrors.push(e)
187
+ }
188
+ } else {
189
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
190
+ }
191
+ } else if (process.platform === 'darwin') {
192
+ try {
193
+ return require('./query-graph.darwin-universal.node')
194
+ } catch (e) {
195
+ loadErrors.push(e)
196
+ }
197
+ try {
198
+ const binding = require('@query-graph/core-darwin-universal')
199
+ const bindingPackageVersion = require('@query-graph/core-darwin-universal/package.json').version
200
+ if (
201
+ bindingPackageVersion !== '1.1.5' &&
202
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
203
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
204
+ ) {
205
+ throw new Error(
206
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
207
+ )
208
+ }
209
+ return binding
210
+ } catch (e) {
211
+ loadErrors.push(e)
212
+ }
213
+ if (process.arch === 'x64') {
214
+ try {
215
+ return require('./query-graph.darwin-x64.node')
216
+ } catch (e) {
217
+ loadErrors.push(e)
218
+ }
219
+ try {
220
+ const binding = require('@query-graph/core-darwin-x64')
221
+ const bindingPackageVersion = require('@query-graph/core-darwin-x64/package.json').version
222
+ if (
223
+ bindingPackageVersion !== '1.1.5' &&
224
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
225
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
226
+ ) {
227
+ throw new Error(
228
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
229
+ )
230
+ }
231
+ return binding
232
+ } catch (e) {
233
+ loadErrors.push(e)
234
+ }
235
+ } else if (process.arch === 'arm64') {
236
+ try {
237
+ return require('./query-graph.darwin-arm64.node')
238
+ } catch (e) {
239
+ loadErrors.push(e)
240
+ }
241
+ try {
242
+ const binding = require('@query-graph/core-darwin-arm64')
243
+ const bindingPackageVersion = require('@query-graph/core-darwin-arm64/package.json').version
244
+ if (
245
+ bindingPackageVersion !== '1.1.5' &&
246
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
247
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
248
+ ) {
249
+ throw new Error(
250
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
251
+ )
252
+ }
253
+ return binding
254
+ } catch (e) {
255
+ loadErrors.push(e)
256
+ }
257
+ } else {
258
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
259
+ }
260
+ } else if (process.platform === 'freebsd') {
261
+ if (process.arch === 'x64') {
262
+ try {
263
+ return require('./query-graph.freebsd-x64.node')
264
+ } catch (e) {
265
+ loadErrors.push(e)
266
+ }
267
+ try {
268
+ const binding = require('@query-graph/core-freebsd-x64')
269
+ const bindingPackageVersion = require('@query-graph/core-freebsd-x64/package.json').version
270
+ if (
271
+ bindingPackageVersion !== '1.1.5' &&
272
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
273
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
274
+ ) {
275
+ throw new Error(
276
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
277
+ )
278
+ }
279
+ return binding
280
+ } catch (e) {
281
+ loadErrors.push(e)
282
+ }
283
+ } else if (process.arch === 'arm64') {
284
+ try {
285
+ return require('./query-graph.freebsd-arm64.node')
286
+ } catch (e) {
287
+ loadErrors.push(e)
288
+ }
289
+ try {
290
+ const binding = require('@query-graph/core-freebsd-arm64')
291
+ const bindingPackageVersion = require('@query-graph/core-freebsd-arm64/package.json').version
292
+ if (
293
+ bindingPackageVersion !== '1.1.5' &&
294
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
295
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
296
+ ) {
297
+ throw new Error(
298
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
299
+ )
300
+ }
301
+ return binding
302
+ } catch (e) {
303
+ loadErrors.push(e)
304
+ }
305
+ } else {
306
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
307
+ }
308
+ } else if (process.platform === 'linux') {
309
+ if (process.arch === 'x64') {
310
+ if (isMusl()) {
311
+ try {
312
+ return require('./query-graph.linux-x64-musl.node')
313
+ } catch (e) {
314
+ loadErrors.push(e)
315
+ }
316
+ try {
317
+ const binding = require('@query-graph/core-linux-x64-musl')
318
+ const bindingPackageVersion = require('@query-graph/core-linux-x64-musl/package.json').version
319
+ if (
320
+ bindingPackageVersion !== '1.1.5' &&
321
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
322
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
323
+ ) {
324
+ throw new Error(
325
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
326
+ )
327
+ }
328
+ return binding
329
+ } catch (e) {
330
+ loadErrors.push(e)
331
+ }
332
+ } else {
333
+ try {
334
+ return require('./query-graph.linux-x64-gnu.node')
335
+ } catch (e) {
336
+ loadErrors.push(e)
337
+ }
338
+ try {
339
+ const binding = require('@query-graph/core-linux-x64-gnu')
340
+ const bindingPackageVersion = require('@query-graph/core-linux-x64-gnu/package.json').version
341
+ if (
342
+ bindingPackageVersion !== '1.1.5' &&
343
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
344
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
345
+ ) {
346
+ throw new Error(
347
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
348
+ )
349
+ }
350
+ return binding
351
+ } catch (e) {
352
+ loadErrors.push(e)
353
+ }
354
+ }
355
+ } else if (process.arch === 'arm64') {
356
+ if (isMusl()) {
357
+ try {
358
+ return require('./query-graph.linux-arm64-musl.node')
359
+ } catch (e) {
360
+ loadErrors.push(e)
361
+ }
362
+ try {
363
+ const binding = require('@query-graph/core-linux-arm64-musl')
364
+ const bindingPackageVersion = require('@query-graph/core-linux-arm64-musl/package.json').version
365
+ if (
366
+ bindingPackageVersion !== '1.1.5' &&
367
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
368
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
369
+ ) {
370
+ throw new Error(
371
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
372
+ )
373
+ }
374
+ return binding
375
+ } catch (e) {
376
+ loadErrors.push(e)
377
+ }
378
+ } else {
379
+ try {
380
+ return require('./query-graph.linux-arm64-gnu.node')
381
+ } catch (e) {
382
+ loadErrors.push(e)
383
+ }
384
+ try {
385
+ const binding = require('@query-graph/core-linux-arm64-gnu')
386
+ const bindingPackageVersion = require('@query-graph/core-linux-arm64-gnu/package.json').version
387
+ if (
388
+ bindingPackageVersion !== '1.1.5' &&
389
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
390
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
391
+ ) {
392
+ throw new Error(
393
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
394
+ )
395
+ }
396
+ return binding
397
+ } catch (e) {
398
+ loadErrors.push(e)
399
+ }
400
+ }
401
+ } else if (process.arch === 'arm') {
402
+ if (isMusl()) {
403
+ try {
404
+ return require('./query-graph.linux-arm-musleabihf.node')
405
+ } catch (e) {
406
+ loadErrors.push(e)
407
+ }
408
+ try {
409
+ const binding = require('@query-graph/core-linux-arm-musleabihf')
410
+ const bindingPackageVersion = require('@query-graph/core-linux-arm-musleabihf/package.json').version
411
+ if (
412
+ bindingPackageVersion !== '1.1.5' &&
413
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
414
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
415
+ ) {
416
+ throw new Error(
417
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
418
+ )
419
+ }
420
+ return binding
421
+ } catch (e) {
422
+ loadErrors.push(e)
423
+ }
424
+ } else {
425
+ try {
426
+ return require('./query-graph.linux-arm-gnueabihf.node')
427
+ } catch (e) {
428
+ loadErrors.push(e)
429
+ }
430
+ try {
431
+ const binding = require('@query-graph/core-linux-arm-gnueabihf')
432
+ const bindingPackageVersion = require('@query-graph/core-linux-arm-gnueabihf/package.json').version
433
+ if (
434
+ bindingPackageVersion !== '1.1.5' &&
435
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
436
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
437
+ ) {
438
+ throw new Error(
439
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
440
+ )
441
+ }
442
+ return binding
443
+ } catch (e) {
444
+ loadErrors.push(e)
445
+ }
446
+ }
447
+ } else if (process.arch === 'loong64') {
448
+ if (isMusl()) {
449
+ try {
450
+ return require('./query-graph.linux-loong64-musl.node')
451
+ } catch (e) {
452
+ loadErrors.push(e)
453
+ }
454
+ try {
455
+ const binding = require('@query-graph/core-linux-loong64-musl')
456
+ const bindingPackageVersion = require('@query-graph/core-linux-loong64-musl/package.json').version
457
+ if (
458
+ bindingPackageVersion !== '1.1.5' &&
459
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
460
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
461
+ ) {
462
+ throw new Error(
463
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
464
+ )
465
+ }
466
+ return binding
467
+ } catch (e) {
468
+ loadErrors.push(e)
469
+ }
470
+ } else {
471
+ try {
472
+ return require('./query-graph.linux-loong64-gnu.node')
473
+ } catch (e) {
474
+ loadErrors.push(e)
475
+ }
476
+ try {
477
+ const binding = require('@query-graph/core-linux-loong64-gnu')
478
+ const bindingPackageVersion = require('@query-graph/core-linux-loong64-gnu/package.json').version
479
+ if (
480
+ bindingPackageVersion !== '1.1.5' &&
481
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
482
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
483
+ ) {
484
+ throw new Error(
485
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
486
+ )
487
+ }
488
+ return binding
489
+ } catch (e) {
490
+ loadErrors.push(e)
491
+ }
492
+ }
493
+ } else if (process.arch === 'riscv64') {
494
+ if (isMusl()) {
495
+ try {
496
+ return require('./query-graph.linux-riscv64-musl.node')
497
+ } catch (e) {
498
+ loadErrors.push(e)
499
+ }
500
+ try {
501
+ const binding = require('@query-graph/core-linux-riscv64-musl')
502
+ const bindingPackageVersion = require('@query-graph/core-linux-riscv64-musl/package.json').version
503
+ if (
504
+ bindingPackageVersion !== '1.1.5' &&
505
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
506
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
507
+ ) {
508
+ throw new Error(
509
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
510
+ )
511
+ }
512
+ return binding
513
+ } catch (e) {
514
+ loadErrors.push(e)
515
+ }
516
+ } else {
517
+ try {
518
+ return require('./query-graph.linux-riscv64-gnu.node')
519
+ } catch (e) {
520
+ loadErrors.push(e)
521
+ }
522
+ try {
523
+ const binding = require('@query-graph/core-linux-riscv64-gnu')
524
+ const bindingPackageVersion = require('@query-graph/core-linux-riscv64-gnu/package.json').version
525
+ if (
526
+ bindingPackageVersion !== '1.1.5' &&
527
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
528
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
529
+ ) {
530
+ throw new Error(
531
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
532
+ )
533
+ }
534
+ return binding
535
+ } catch (e) {
536
+ loadErrors.push(e)
537
+ }
538
+ }
539
+ } else if (process.arch === 'ppc64') {
540
+ try {
541
+ return require('./query-graph.linux-ppc64-gnu.node')
542
+ } catch (e) {
543
+ loadErrors.push(e)
544
+ }
545
+ try {
546
+ const binding = require('@query-graph/core-linux-ppc64-gnu')
547
+ const bindingPackageVersion = require('@query-graph/core-linux-ppc64-gnu/package.json').version
548
+ if (
549
+ bindingPackageVersion !== '1.1.5' &&
550
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
551
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
552
+ ) {
553
+ throw new Error(
554
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
555
+ )
556
+ }
557
+ return binding
558
+ } catch (e) {
559
+ loadErrors.push(e)
560
+ }
561
+ } else if (process.arch === 's390x') {
562
+ try {
563
+ return require('./query-graph.linux-s390x-gnu.node')
564
+ } catch (e) {
565
+ loadErrors.push(e)
566
+ }
567
+ try {
568
+ const binding = require('@query-graph/core-linux-s390x-gnu')
569
+ const bindingPackageVersion = require('@query-graph/core-linux-s390x-gnu/package.json').version
570
+ if (
571
+ bindingPackageVersion !== '1.1.5' &&
572
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
573
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
574
+ ) {
575
+ throw new Error(
576
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
577
+ )
578
+ }
579
+ return binding
580
+ } catch (e) {
581
+ loadErrors.push(e)
582
+ }
583
+ } else {
584
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
585
+ }
586
+ } else if (process.platform === 'openharmony') {
587
+ if (process.arch === 'arm64') {
588
+ try {
589
+ return require('./query-graph.openharmony-arm64.node')
590
+ } catch (e) {
591
+ loadErrors.push(e)
592
+ }
593
+ try {
594
+ const binding = require('@query-graph/core-openharmony-arm64')
595
+ const bindingPackageVersion = require('@query-graph/core-openharmony-arm64/package.json').version
596
+ if (
597
+ bindingPackageVersion !== '1.1.5' &&
598
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
599
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
600
+ ) {
601
+ throw new Error(
602
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
603
+ )
604
+ }
605
+ return binding
606
+ } catch (e) {
607
+ loadErrors.push(e)
608
+ }
609
+ } else if (process.arch === 'x64') {
610
+ try {
611
+ return require('./query-graph.openharmony-x64.node')
612
+ } catch (e) {
613
+ loadErrors.push(e)
614
+ }
615
+ try {
616
+ const binding = require('@query-graph/core-openharmony-x64')
617
+ const bindingPackageVersion = require('@query-graph/core-openharmony-x64/package.json').version
618
+ if (
619
+ bindingPackageVersion !== '1.1.5' &&
620
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
621
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
622
+ ) {
623
+ throw new Error(
624
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
625
+ )
626
+ }
627
+ return binding
628
+ } catch (e) {
629
+ loadErrors.push(e)
630
+ }
631
+ } else if (process.arch === 'arm') {
632
+ try {
633
+ return require('./query-graph.openharmony-arm.node')
634
+ } catch (e) {
635
+ loadErrors.push(e)
636
+ }
637
+ try {
638
+ const binding = require('@query-graph/core-openharmony-arm')
639
+ const bindingPackageVersion = require('@query-graph/core-openharmony-arm/package.json').version
640
+ if (
641
+ bindingPackageVersion !== '1.1.5' &&
642
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
643
+ process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
644
+ ) {
645
+ throw new Error(
646
+ `Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
647
+ )
648
+ }
649
+ return binding
650
+ } catch (e) {
651
+ loadErrors.push(e)
652
+ }
653
+ } else {
654
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
655
+ }
656
+ } else {
657
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
658
+ }
659
+ }
660
+
661
+ nativeBinding = requireNative()
662
+
663
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
664
+ let wasiBinding = null
665
+ let wasiBindingError = null
666
+ try {
667
+ wasiBinding = require('./query-graph.wasi.cjs')
668
+ nativeBinding = wasiBinding
669
+ } catch (err) {
670
+ if (process.env.NAPI_RS_FORCE_WASI) {
671
+ wasiBindingError = err
672
+ }
673
+ }
674
+ if (!nativeBinding) {
675
+ try {
676
+ wasiBinding = require('@query-graph/core-wasm32-wasi')
677
+ nativeBinding = wasiBinding
678
+ } catch (err) {
679
+ if (process.env.NAPI_RS_FORCE_WASI) {
680
+ wasiBindingError.cause = err
681
+ loadErrors.push(err)
682
+ }
683
+ }
684
+ }
685
+ if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
686
+ const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
687
+ error.cause = wasiBindingError
688
+ throw error
689
+ }
690
+ }
691
+
692
+ if (!nativeBinding) {
693
+ if (loadErrors.length > 0) {
694
+ throw new Error(
695
+ `Cannot find native binding. ` +
696
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
697
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
698
+ {
699
+ cause: loadErrors.reduce((err, cur) => {
700
+ cur.cause = err
701
+ return cur
702
+ }),
703
+ },
704
+ )
705
+ }
706
+ throw new Error(`Failed to load native binding`)
707
+ }
708
+
709
+ module.exports = nativeBinding
710
+ module.exports.CompiledQueryPlan = nativeBinding.CompiledQueryPlan
711
+ module.exports.ComposedQueryGraph = nativeBinding.ComposedQueryGraph
712
+ module.exports.QueryGraph = nativeBinding.QueryGraph
713
+ module.exports.RelationalQueryGraph = nativeBinding.RelationalQueryGraph
714
+ module.exports.registerDefinition = nativeBinding.registerDefinition