@pid7/ashwa 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -58
- package/browser.js +27 -6
- package/browser.mjs +30 -2
- package/index.d.ts +27 -1
- package/index.js +17 -0
- package/index.mjs +17 -0
- package/native/index.d.ts +31 -1
- package/native/index.darwin-arm64.node +0 -0
- package/native/index.js +643 -361
- package/native/index.linux-arm64-gnu.node +0 -0
- package/native/index.linux-x64-gnu.node +0 -0
- package/native/index.win32-arm64-msvc.node +0 -0
- package/native/index.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/wasm/pkg/ashwa_wasm.d.ts +14 -0
- package/wasm/pkg/ashwa_wasm.js +23 -0
- package/wasm/pkg/ashwa_wasm_bg.wasm +0 -0
- package/wasm/pkg/ashwa_wasm_bg.wasm.d.ts +1 -0
package/native/index.js
CHANGED
|
@@ -3,541 +3,803 @@
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
6
|
+
import { readFileSync } from 'fs'
|
|
7
|
+
import { createRequire } from 'module'
|
|
8
|
+
const require = createRequire(import.meta.url)
|
|
9
|
+
let nativeBinding = null;
|
|
10
|
+
const loadErrors = [];
|
|
9
11
|
|
|
10
12
|
const isMusl = () => {
|
|
11
|
-
let musl = false
|
|
12
|
-
if (process.platform ===
|
|
13
|
-
musl = isMuslFromFilesystem()
|
|
13
|
+
let musl = false;
|
|
14
|
+
if (process.platform === "linux") {
|
|
15
|
+
musl = isMuslFromFilesystem();
|
|
16
|
+
|
|
14
17
|
if (musl === null) {
|
|
15
|
-
musl = isMuslFromReport()
|
|
18
|
+
musl = isMuslFromReport();
|
|
16
19
|
}
|
|
20
|
+
|
|
17
21
|
if (musl === null) {
|
|
18
|
-
musl = isMuslFromChildProcess()
|
|
22
|
+
musl = isMuslFromChildProcess();
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
return musl
|
|
22
|
-
}
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
return musl;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
|
|
25
30
|
|
|
26
31
|
const isMuslFromFilesystem = () => {
|
|
27
32
|
try {
|
|
28
|
-
return readFileSync(
|
|
33
|
+
return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
|
|
29
34
|
} catch {
|
|
30
|
-
return null
|
|
35
|
+
return null;
|
|
31
36
|
}
|
|
32
|
-
}
|
|
37
|
+
};
|
|
33
38
|
|
|
34
39
|
const isMuslFromReport = () => {
|
|
35
|
-
let report = null
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
report =
|
|
40
|
+
let report = null;
|
|
41
|
+
|
|
42
|
+
if (process.report && typeof process.report.getReport === "function") {
|
|
43
|
+
process.report.excludeNetwork = true;
|
|
44
|
+
report = process.report.getReport();
|
|
39
45
|
}
|
|
46
|
+
|
|
40
47
|
if (!report) {
|
|
41
|
-
return null
|
|
48
|
+
return null;
|
|
42
49
|
}
|
|
50
|
+
|
|
43
51
|
if (report.header && report.header.glibcVersionRuntime) {
|
|
44
|
-
return false
|
|
52
|
+
return false;
|
|
45
53
|
}
|
|
54
|
+
|
|
46
55
|
if (Array.isArray(report.sharedObjects)) {
|
|
47
56
|
if (report.sharedObjects.some(isFileMusl)) {
|
|
48
|
-
return true
|
|
57
|
+
return true;
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
53
63
|
|
|
54
64
|
const isMuslFromChildProcess = () => {
|
|
55
65
|
try {
|
|
56
|
-
return require(
|
|
66
|
+
return require("child_process")
|
|
67
|
+
.execSync("ldd --version", { encoding: "utf8" })
|
|
68
|
+
.includes("musl");
|
|
57
69
|
} catch (e) {
|
|
58
70
|
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
59
|
-
return false
|
|
71
|
+
return false;
|
|
60
72
|
}
|
|
61
|
-
}
|
|
73
|
+
};
|
|
62
74
|
|
|
63
75
|
function requireNative() {
|
|
64
76
|
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
65
77
|
try {
|
|
66
78
|
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
67
79
|
} catch (err) {
|
|
68
|
-
loadErrors.push(err)
|
|
80
|
+
loadErrors.push(err);
|
|
69
81
|
}
|
|
70
|
-
} else if (process.platform ===
|
|
71
|
-
if (process.arch ===
|
|
82
|
+
} else if (process.platform === "android") {
|
|
83
|
+
if (process.arch === "arm64") {
|
|
72
84
|
try {
|
|
73
|
-
return require(
|
|
85
|
+
return require("./index.android-arm64.node");
|
|
74
86
|
} catch (e) {
|
|
75
|
-
loadErrors.push(e)
|
|
87
|
+
loadErrors.push(e);
|
|
76
88
|
}
|
|
89
|
+
|
|
77
90
|
try {
|
|
78
|
-
const binding = require(
|
|
79
|
-
const bindingPackageVersion =
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
const binding = require("@pid7/ashwa-native-android-arm64");
|
|
92
|
+
const bindingPackageVersion =
|
|
93
|
+
require("@pid7/ashwa-native-android-arm64/package.json").version;
|
|
94
|
+
|
|
95
|
+
if (
|
|
96
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
97
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
98
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
99
|
+
) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
102
|
+
);
|
|
82
103
|
}
|
|
83
|
-
|
|
104
|
+
|
|
105
|
+
return binding;
|
|
84
106
|
} catch (e) {
|
|
85
|
-
loadErrors.push(e)
|
|
107
|
+
loadErrors.push(e);
|
|
86
108
|
}
|
|
87
|
-
} else if (process.arch ===
|
|
109
|
+
} else if (process.arch === "arm") {
|
|
88
110
|
try {
|
|
89
|
-
return require(
|
|
111
|
+
return require("./index.android-arm-eabi.node");
|
|
90
112
|
} catch (e) {
|
|
91
|
-
loadErrors.push(e)
|
|
113
|
+
loadErrors.push(e);
|
|
92
114
|
}
|
|
115
|
+
|
|
93
116
|
try {
|
|
94
|
-
const binding = require(
|
|
95
|
-
const bindingPackageVersion =
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
const binding = require("@pid7/ashwa-native-android-arm-eabi");
|
|
118
|
+
const bindingPackageVersion =
|
|
119
|
+
require("@pid7/ashwa-native-android-arm-eabi/package.json").version;
|
|
120
|
+
|
|
121
|
+
if (
|
|
122
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
123
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
124
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
125
|
+
) {
|
|
126
|
+
throw new Error(
|
|
127
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
128
|
+
);
|
|
98
129
|
}
|
|
99
|
-
|
|
130
|
+
|
|
131
|
+
return binding;
|
|
100
132
|
} catch (e) {
|
|
101
|
-
loadErrors.push(e)
|
|
133
|
+
loadErrors.push(e);
|
|
102
134
|
}
|
|
103
135
|
} else {
|
|
104
|
-
loadErrors.push(
|
|
136
|
+
loadErrors.push(
|
|
137
|
+
new Error(`Unsupported architecture on Android ${process.arch}`),
|
|
138
|
+
);
|
|
105
139
|
}
|
|
106
|
-
} else if (process.platform ===
|
|
107
|
-
if (process.arch ===
|
|
108
|
-
if (
|
|
140
|
+
} else if (process.platform === "win32") {
|
|
141
|
+
if (process.arch === "x64") {
|
|
142
|
+
if (
|
|
143
|
+
(process.config &&
|
|
144
|
+
process.config.variables &&
|
|
145
|
+
process.config.variables.shlib_suffix === "dll.a") ||
|
|
146
|
+
(process.config &&
|
|
147
|
+
process.config.variables &&
|
|
148
|
+
process.config.variables.node_target_type === "shared_library")
|
|
149
|
+
) {
|
|
109
150
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
151
|
+
return require("./index.win32-x64-gnu.node");
|
|
152
|
+
} catch (e) {
|
|
153
|
+
loadErrors.push(e);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
const binding = require("@pid7/ashwa-native-win32-x64-gnu");
|
|
158
|
+
const bindingPackageVersion =
|
|
159
|
+
require("@pid7/ashwa-native-win32-x64-gnu/package.json").version;
|
|
160
|
+
|
|
161
|
+
if (
|
|
162
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
163
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
164
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
165
|
+
) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return binding;
|
|
172
|
+
} catch (e) {
|
|
173
|
+
loadErrors.push(e);
|
|
119
174
|
}
|
|
120
|
-
return binding
|
|
121
|
-
} catch (e) {
|
|
122
|
-
loadErrors.push(e)
|
|
123
|
-
}
|
|
124
175
|
} else {
|
|
125
176
|
try {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
177
|
+
return require("./index.win32-x64-msvc.node");
|
|
178
|
+
} catch (e) {
|
|
179
|
+
loadErrors.push(e);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
const binding = require("@pid7/ashwa-native-win32-x64-msvc");
|
|
184
|
+
const bindingPackageVersion =
|
|
185
|
+
require("@pid7/ashwa-native-win32-x64-msvc/package.json").version;
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
189
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
190
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
191
|
+
) {
|
|
192
|
+
throw new Error(
|
|
193
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return binding;
|
|
198
|
+
} catch (e) {
|
|
199
|
+
loadErrors.push(e);
|
|
135
200
|
}
|
|
136
|
-
return binding
|
|
137
|
-
} catch (e) {
|
|
138
|
-
loadErrors.push(e)
|
|
139
|
-
}
|
|
140
201
|
}
|
|
141
|
-
} else if (process.arch ===
|
|
202
|
+
} else if (process.arch === "ia32") {
|
|
142
203
|
try {
|
|
143
|
-
return require(
|
|
204
|
+
return require("./index.win32-ia32-msvc.node");
|
|
144
205
|
} catch (e) {
|
|
145
|
-
loadErrors.push(e)
|
|
206
|
+
loadErrors.push(e);
|
|
146
207
|
}
|
|
208
|
+
|
|
147
209
|
try {
|
|
148
|
-
const binding = require(
|
|
149
|
-
const bindingPackageVersion =
|
|
150
|
-
|
|
151
|
-
|
|
210
|
+
const binding = require("@pid7/ashwa-native-win32-ia32-msvc");
|
|
211
|
+
const bindingPackageVersion =
|
|
212
|
+
require("@pid7/ashwa-native-win32-ia32-msvc/package.json").version;
|
|
213
|
+
|
|
214
|
+
if (
|
|
215
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
216
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
217
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
218
|
+
) {
|
|
219
|
+
throw new Error(
|
|
220
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
221
|
+
);
|
|
152
222
|
}
|
|
153
|
-
|
|
223
|
+
|
|
224
|
+
return binding;
|
|
154
225
|
} catch (e) {
|
|
155
|
-
loadErrors.push(e)
|
|
226
|
+
loadErrors.push(e);
|
|
156
227
|
}
|
|
157
|
-
} else if (process.arch ===
|
|
228
|
+
} else if (process.arch === "arm64") {
|
|
158
229
|
try {
|
|
159
|
-
return require(
|
|
230
|
+
return require("./index.win32-arm64-msvc.node");
|
|
160
231
|
} catch (e) {
|
|
161
|
-
loadErrors.push(e)
|
|
232
|
+
loadErrors.push(e);
|
|
162
233
|
}
|
|
234
|
+
|
|
163
235
|
try {
|
|
164
|
-
const binding = require(
|
|
165
|
-
const bindingPackageVersion =
|
|
166
|
-
|
|
167
|
-
|
|
236
|
+
const binding = require("@pid7/ashwa-native-win32-arm64-msvc");
|
|
237
|
+
const bindingPackageVersion =
|
|
238
|
+
require("@pid7/ashwa-native-win32-arm64-msvc/package.json").version;
|
|
239
|
+
|
|
240
|
+
if (
|
|
241
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
242
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
243
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
244
|
+
) {
|
|
245
|
+
throw new Error(
|
|
246
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
247
|
+
);
|
|
168
248
|
}
|
|
169
|
-
|
|
249
|
+
|
|
250
|
+
return binding;
|
|
170
251
|
} catch (e) {
|
|
171
|
-
loadErrors.push(e)
|
|
252
|
+
loadErrors.push(e);
|
|
172
253
|
}
|
|
173
254
|
} else {
|
|
174
|
-
loadErrors.push(
|
|
255
|
+
loadErrors.push(
|
|
256
|
+
new Error(`Unsupported architecture on Windows: ${process.arch}`),
|
|
257
|
+
);
|
|
175
258
|
}
|
|
176
|
-
} else if (process.platform ===
|
|
259
|
+
} else if (process.platform === "darwin") {
|
|
177
260
|
try {
|
|
178
|
-
return require(
|
|
261
|
+
return require("./index.darwin-universal.node");
|
|
179
262
|
} catch (e) {
|
|
180
|
-
loadErrors.push(e)
|
|
263
|
+
loadErrors.push(e);
|
|
181
264
|
}
|
|
265
|
+
|
|
182
266
|
try {
|
|
183
|
-
const binding = require(
|
|
184
|
-
const bindingPackageVersion =
|
|
185
|
-
|
|
186
|
-
|
|
267
|
+
const binding = require("@pid7/ashwa-native-darwin-universal");
|
|
268
|
+
const bindingPackageVersion =
|
|
269
|
+
require("@pid7/ashwa-native-darwin-universal/package.json").version;
|
|
270
|
+
|
|
271
|
+
if (
|
|
272
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
273
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
274
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
275
|
+
) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
278
|
+
);
|
|
187
279
|
}
|
|
188
|
-
|
|
280
|
+
|
|
281
|
+
return binding;
|
|
189
282
|
} catch (e) {
|
|
190
|
-
loadErrors.push(e)
|
|
283
|
+
loadErrors.push(e);
|
|
191
284
|
}
|
|
192
|
-
if (process.arch ===
|
|
285
|
+
if (process.arch === "x64") {
|
|
193
286
|
try {
|
|
194
|
-
return require(
|
|
287
|
+
return require("./index.darwin-x64.node");
|
|
195
288
|
} catch (e) {
|
|
196
|
-
loadErrors.push(e)
|
|
289
|
+
loadErrors.push(e);
|
|
197
290
|
}
|
|
291
|
+
|
|
198
292
|
try {
|
|
199
|
-
const binding = require(
|
|
200
|
-
const bindingPackageVersion =
|
|
201
|
-
|
|
202
|
-
|
|
293
|
+
const binding = require("@pid7/ashwa-native-darwin-x64");
|
|
294
|
+
const bindingPackageVersion =
|
|
295
|
+
require("@pid7/ashwa-native-darwin-x64/package.json").version;
|
|
296
|
+
if (
|
|
297
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
298
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
299
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
300
|
+
) {
|
|
301
|
+
throw new Error(
|
|
302
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
303
|
+
);
|
|
203
304
|
}
|
|
204
|
-
|
|
305
|
+
|
|
306
|
+
return binding;
|
|
205
307
|
} catch (e) {
|
|
206
|
-
loadErrors.push(e)
|
|
308
|
+
loadErrors.push(e);
|
|
207
309
|
}
|
|
208
|
-
} else if (process.arch ===
|
|
310
|
+
} else if (process.arch === "arm64") {
|
|
209
311
|
try {
|
|
210
|
-
return require(
|
|
312
|
+
return require("./index.darwin-arm64.node");
|
|
211
313
|
} catch (e) {
|
|
212
|
-
loadErrors.push(e)
|
|
314
|
+
loadErrors.push(e);
|
|
213
315
|
}
|
|
316
|
+
|
|
214
317
|
try {
|
|
215
|
-
const binding = require(
|
|
216
|
-
const bindingPackageVersion =
|
|
217
|
-
|
|
218
|
-
|
|
318
|
+
const binding = require("@pid7/ashwa-native-darwin-arm64");
|
|
319
|
+
const bindingPackageVersion =
|
|
320
|
+
require("@pid7/ashwa-native-darwin-arm64/package.json").version;
|
|
321
|
+
|
|
322
|
+
if (
|
|
323
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
324
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
325
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
326
|
+
) {
|
|
327
|
+
throw new Error(
|
|
328
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
329
|
+
);
|
|
219
330
|
}
|
|
220
|
-
|
|
331
|
+
|
|
332
|
+
return binding;
|
|
221
333
|
} catch (e) {
|
|
222
|
-
loadErrors.push(e)
|
|
334
|
+
loadErrors.push(e);
|
|
223
335
|
}
|
|
224
336
|
} else {
|
|
225
|
-
loadErrors.push(
|
|
337
|
+
loadErrors.push(
|
|
338
|
+
new Error(`Unsupported architecture on macOS: ${process.arch}`),
|
|
339
|
+
);
|
|
226
340
|
}
|
|
227
|
-
} else if (process.platform ===
|
|
228
|
-
if (process.arch ===
|
|
341
|
+
} else if (process.platform === "freebsd") {
|
|
342
|
+
if (process.arch === "x64") {
|
|
229
343
|
try {
|
|
230
|
-
return require(
|
|
344
|
+
return require("./index.freebsd-x64.node");
|
|
231
345
|
} catch (e) {
|
|
232
|
-
loadErrors.push(e)
|
|
346
|
+
loadErrors.push(e);
|
|
233
347
|
}
|
|
348
|
+
|
|
234
349
|
try {
|
|
235
|
-
const binding = require(
|
|
236
|
-
const bindingPackageVersion =
|
|
237
|
-
|
|
238
|
-
|
|
350
|
+
const binding = require("@pid7/ashwa-native-freebsd-x64");
|
|
351
|
+
const bindingPackageVersion =
|
|
352
|
+
require("@pid7/ashwa-native-freebsd-x64/package.json").version;
|
|
353
|
+
|
|
354
|
+
if (
|
|
355
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
356
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
357
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
358
|
+
) {
|
|
359
|
+
throw new Error(
|
|
360
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
361
|
+
);
|
|
239
362
|
}
|
|
240
|
-
|
|
363
|
+
|
|
364
|
+
return binding;
|
|
241
365
|
} catch (e) {
|
|
242
|
-
loadErrors.push(e)
|
|
366
|
+
loadErrors.push(e);
|
|
243
367
|
}
|
|
244
|
-
} else if (process.arch ===
|
|
368
|
+
} else if (process.arch === "arm64") {
|
|
245
369
|
try {
|
|
246
|
-
return require(
|
|
370
|
+
return require("./index.freebsd-arm64.node");
|
|
247
371
|
} catch (e) {
|
|
248
|
-
loadErrors.push(e)
|
|
372
|
+
loadErrors.push(e);
|
|
249
373
|
}
|
|
374
|
+
|
|
250
375
|
try {
|
|
251
|
-
const binding = require(
|
|
252
|
-
const bindingPackageVersion =
|
|
253
|
-
|
|
254
|
-
|
|
376
|
+
const binding = require("@pid7/ashwa-native-freebsd-arm64");
|
|
377
|
+
const bindingPackageVersion =
|
|
378
|
+
require("@pid7/ashwa-native-freebsd-arm64/package.json").version;
|
|
379
|
+
|
|
380
|
+
if (
|
|
381
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
382
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
383
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
384
|
+
) {
|
|
385
|
+
throw new Error(
|
|
386
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
387
|
+
);
|
|
255
388
|
}
|
|
256
|
-
|
|
389
|
+
|
|
390
|
+
return binding;
|
|
257
391
|
} catch (e) {
|
|
258
|
-
loadErrors.push(e)
|
|
392
|
+
loadErrors.push(e);
|
|
259
393
|
}
|
|
260
394
|
} else {
|
|
261
|
-
loadErrors.push(
|
|
395
|
+
loadErrors.push(
|
|
396
|
+
new Error(`Unsupported architecture on FreeBSD: ${process.arch}`),
|
|
397
|
+
);
|
|
262
398
|
}
|
|
263
|
-
} else if (process.platform ===
|
|
264
|
-
if (process.arch ===
|
|
399
|
+
} else if (process.platform === "linux") {
|
|
400
|
+
if (process.arch === "x64") {
|
|
265
401
|
if (isMusl()) {
|
|
266
402
|
try {
|
|
267
|
-
return require(
|
|
403
|
+
return require("./index.linux-x64-musl.node");
|
|
268
404
|
} catch (e) {
|
|
269
|
-
loadErrors.push(e)
|
|
405
|
+
loadErrors.push(e);
|
|
270
406
|
}
|
|
407
|
+
|
|
271
408
|
try {
|
|
272
|
-
const binding = require(
|
|
273
|
-
const bindingPackageVersion =
|
|
274
|
-
|
|
275
|
-
|
|
409
|
+
const binding = require("@pid7/ashwa-native-linux-x64-musl");
|
|
410
|
+
const bindingPackageVersion =
|
|
411
|
+
require("@pid7/ashwa-native-linux-x64-musl/package.json").version;
|
|
412
|
+
|
|
413
|
+
if (
|
|
414
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
415
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
416
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
417
|
+
) {
|
|
418
|
+
throw new Error(
|
|
419
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
420
|
+
);
|
|
276
421
|
}
|
|
277
|
-
|
|
422
|
+
|
|
423
|
+
return binding;
|
|
278
424
|
} catch (e) {
|
|
279
|
-
loadErrors.push(e)
|
|
425
|
+
loadErrors.push(e);
|
|
280
426
|
}
|
|
281
427
|
} else {
|
|
282
428
|
try {
|
|
283
|
-
return require(
|
|
429
|
+
return require("./index.linux-x64-gnu.node");
|
|
284
430
|
} catch (e) {
|
|
285
|
-
loadErrors.push(e)
|
|
431
|
+
loadErrors.push(e);
|
|
286
432
|
}
|
|
433
|
+
|
|
287
434
|
try {
|
|
288
|
-
const binding = require(
|
|
289
|
-
const bindingPackageVersion =
|
|
290
|
-
|
|
291
|
-
|
|
435
|
+
const binding = require("@pid7/ashwa-native-linux-x64-gnu");
|
|
436
|
+
const bindingPackageVersion =
|
|
437
|
+
require("@pid7/ashwa-native-linux-x64-gnu/package.json").version;
|
|
438
|
+
|
|
439
|
+
if (
|
|
440
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
441
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
442
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
443
|
+
) {
|
|
444
|
+
throw new Error(
|
|
445
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
446
|
+
);
|
|
292
447
|
}
|
|
293
|
-
|
|
448
|
+
|
|
449
|
+
return binding;
|
|
294
450
|
} catch (e) {
|
|
295
|
-
loadErrors.push(e)
|
|
451
|
+
loadErrors.push(e);
|
|
296
452
|
}
|
|
297
453
|
}
|
|
298
|
-
} else if (process.arch ===
|
|
454
|
+
} else if (process.arch === "arm64") {
|
|
299
455
|
if (isMusl()) {
|
|
300
456
|
try {
|
|
301
|
-
return require(
|
|
457
|
+
return require("./index.linux-arm64-musl.node");
|
|
302
458
|
} catch (e) {
|
|
303
|
-
loadErrors.push(e)
|
|
459
|
+
loadErrors.push(e);
|
|
304
460
|
}
|
|
461
|
+
|
|
305
462
|
try {
|
|
306
|
-
const binding = require(
|
|
307
|
-
const bindingPackageVersion =
|
|
308
|
-
|
|
309
|
-
|
|
463
|
+
const binding = require("@pid7/ashwa-native-linux-arm64-musl");
|
|
464
|
+
const bindingPackageVersion =
|
|
465
|
+
require("@pid7/ashwa-native-linux-arm64-musl/package.json").version;
|
|
466
|
+
|
|
467
|
+
if (
|
|
468
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
469
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
470
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
471
|
+
) {
|
|
472
|
+
throw new Error(
|
|
473
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
474
|
+
);
|
|
310
475
|
}
|
|
311
|
-
|
|
476
|
+
|
|
477
|
+
return binding;
|
|
312
478
|
} catch (e) {
|
|
313
|
-
loadErrors.push(e)
|
|
479
|
+
loadErrors.push(e);
|
|
314
480
|
}
|
|
315
481
|
} else {
|
|
316
482
|
try {
|
|
317
|
-
return require(
|
|
483
|
+
return require("./index.linux-arm64-gnu.node");
|
|
318
484
|
} catch (e) {
|
|
319
|
-
loadErrors.push(e)
|
|
485
|
+
loadErrors.push(e);
|
|
320
486
|
}
|
|
487
|
+
|
|
321
488
|
try {
|
|
322
|
-
const binding = require(
|
|
323
|
-
const bindingPackageVersion =
|
|
324
|
-
|
|
325
|
-
|
|
489
|
+
const binding = require("@pid7/ashwa-native-linux-arm64-gnu");
|
|
490
|
+
const bindingPackageVersion =
|
|
491
|
+
require("@pid7/ashwa-native-linux-arm64-gnu/package.json").version;
|
|
492
|
+
|
|
493
|
+
if (
|
|
494
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
495
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
496
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
497
|
+
) {
|
|
498
|
+
throw new Error(
|
|
499
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
500
|
+
);
|
|
326
501
|
}
|
|
327
|
-
|
|
502
|
+
|
|
503
|
+
return binding;
|
|
328
504
|
} catch (e) {
|
|
329
|
-
loadErrors.push(e)
|
|
505
|
+
loadErrors.push(e);
|
|
330
506
|
}
|
|
331
507
|
}
|
|
332
|
-
} else if (process.arch ===
|
|
508
|
+
} else if (process.arch === "arm") {
|
|
333
509
|
if (isMusl()) {
|
|
334
510
|
try {
|
|
335
|
-
return require(
|
|
511
|
+
return require("./index.linux-arm-musleabihf.node");
|
|
336
512
|
} catch (e) {
|
|
337
|
-
loadErrors.push(e)
|
|
513
|
+
loadErrors.push(e);
|
|
338
514
|
}
|
|
515
|
+
|
|
339
516
|
try {
|
|
340
|
-
const binding = require(
|
|
341
|
-
const bindingPackageVersion =
|
|
342
|
-
|
|
343
|
-
|
|
517
|
+
const binding = require("@pid7/ashwa-native-linux-arm-musleabihf");
|
|
518
|
+
const bindingPackageVersion =
|
|
519
|
+
require("@pid7/ashwa-native-linux-arm-musleabihf/package.json").version;
|
|
520
|
+
if (
|
|
521
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
522
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
523
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
524
|
+
) {
|
|
525
|
+
throw new Error(
|
|
526
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
527
|
+
);
|
|
344
528
|
}
|
|
345
|
-
return binding
|
|
529
|
+
return binding;
|
|
346
530
|
} catch (e) {
|
|
347
|
-
loadErrors.push(e)
|
|
531
|
+
loadErrors.push(e);
|
|
348
532
|
}
|
|
349
533
|
} else {
|
|
350
534
|
try {
|
|
351
|
-
return require(
|
|
535
|
+
return require("./index.linux-arm-gnueabihf.node");
|
|
352
536
|
} catch (e) {
|
|
353
|
-
loadErrors.push(e)
|
|
537
|
+
loadErrors.push(e);
|
|
354
538
|
}
|
|
355
539
|
try {
|
|
356
|
-
const binding = require(
|
|
357
|
-
const bindingPackageVersion =
|
|
358
|
-
|
|
359
|
-
|
|
540
|
+
const binding = require("@pid7/ashwa-native-linux-arm-gnueabihf");
|
|
541
|
+
const bindingPackageVersion =
|
|
542
|
+
require("@pid7/ashwa-native-linux-arm-gnueabihf/package.json").version;
|
|
543
|
+
if (
|
|
544
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
545
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
546
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
547
|
+
) {
|
|
548
|
+
throw new Error(
|
|
549
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
550
|
+
);
|
|
360
551
|
}
|
|
361
|
-
return binding
|
|
552
|
+
return binding;
|
|
362
553
|
} catch (e) {
|
|
363
|
-
loadErrors.push(e)
|
|
554
|
+
loadErrors.push(e);
|
|
364
555
|
}
|
|
365
556
|
}
|
|
366
|
-
} else if (process.arch ===
|
|
557
|
+
} else if (process.arch === "loong64") {
|
|
367
558
|
if (isMusl()) {
|
|
368
559
|
try {
|
|
369
|
-
return require(
|
|
560
|
+
return require("./index.linux-loong64-musl.node");
|
|
370
561
|
} catch (e) {
|
|
371
|
-
loadErrors.push(e)
|
|
562
|
+
loadErrors.push(e);
|
|
372
563
|
}
|
|
373
564
|
try {
|
|
374
|
-
const binding = require(
|
|
375
|
-
const bindingPackageVersion =
|
|
376
|
-
|
|
377
|
-
|
|
565
|
+
const binding = require("@pid7/ashwa-native-linux-loong64-musl");
|
|
566
|
+
const bindingPackageVersion =
|
|
567
|
+
require("@pid7/ashwa-native-linux-loong64-musl/package.json").version;
|
|
568
|
+
if (
|
|
569
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
570
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
571
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
572
|
+
) {
|
|
573
|
+
throw new Error(
|
|
574
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
575
|
+
);
|
|
378
576
|
}
|
|
379
|
-
return binding
|
|
577
|
+
return binding;
|
|
380
578
|
} catch (e) {
|
|
381
|
-
loadErrors.push(e)
|
|
579
|
+
loadErrors.push(e);
|
|
382
580
|
}
|
|
383
581
|
} else {
|
|
384
582
|
try {
|
|
385
|
-
return require(
|
|
583
|
+
return require("./index.linux-loong64-gnu.node");
|
|
386
584
|
} catch (e) {
|
|
387
|
-
loadErrors.push(e)
|
|
585
|
+
loadErrors.push(e);
|
|
388
586
|
}
|
|
389
587
|
try {
|
|
390
|
-
const binding = require(
|
|
391
|
-
const bindingPackageVersion =
|
|
392
|
-
|
|
393
|
-
|
|
588
|
+
const binding = require("@pid7/ashwa-native-linux-loong64-gnu");
|
|
589
|
+
const bindingPackageVersion =
|
|
590
|
+
require("@pid7/ashwa-native-linux-loong64-gnu/package.json").version;
|
|
591
|
+
if (
|
|
592
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
593
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
594
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
595
|
+
) {
|
|
596
|
+
throw new Error(
|
|
597
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
598
|
+
);
|
|
394
599
|
}
|
|
395
|
-
return binding
|
|
600
|
+
return binding;
|
|
396
601
|
} catch (e) {
|
|
397
|
-
loadErrors.push(e)
|
|
602
|
+
loadErrors.push(e);
|
|
398
603
|
}
|
|
399
604
|
}
|
|
400
|
-
} else if (process.arch ===
|
|
605
|
+
} else if (process.arch === "riscv64") {
|
|
401
606
|
if (isMusl()) {
|
|
402
607
|
try {
|
|
403
|
-
return require(
|
|
608
|
+
return require("./index.linux-riscv64-musl.node");
|
|
404
609
|
} catch (e) {
|
|
405
|
-
loadErrors.push(e)
|
|
610
|
+
loadErrors.push(e);
|
|
406
611
|
}
|
|
407
612
|
try {
|
|
408
|
-
const binding = require(
|
|
409
|
-
const bindingPackageVersion =
|
|
410
|
-
|
|
411
|
-
|
|
613
|
+
const binding = require("@pid7/ashwa-native-linux-riscv64-musl");
|
|
614
|
+
const bindingPackageVersion =
|
|
615
|
+
require("@pid7/ashwa-native-linux-riscv64-musl/package.json").version;
|
|
616
|
+
if (
|
|
617
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
618
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
619
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
620
|
+
) {
|
|
621
|
+
throw new Error(
|
|
622
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
623
|
+
);
|
|
412
624
|
}
|
|
413
|
-
return binding
|
|
625
|
+
return binding;
|
|
414
626
|
} catch (e) {
|
|
415
|
-
loadErrors.push(e)
|
|
627
|
+
loadErrors.push(e);
|
|
416
628
|
}
|
|
417
629
|
} else {
|
|
418
630
|
try {
|
|
419
|
-
return require(
|
|
631
|
+
return require("./index.linux-riscv64-gnu.node");
|
|
420
632
|
} catch (e) {
|
|
421
|
-
loadErrors.push(e)
|
|
633
|
+
loadErrors.push(e);
|
|
422
634
|
}
|
|
423
635
|
try {
|
|
424
|
-
const binding = require(
|
|
425
|
-
const bindingPackageVersion =
|
|
426
|
-
|
|
427
|
-
|
|
636
|
+
const binding = require("@pid7/ashwa-native-linux-riscv64-gnu");
|
|
637
|
+
const bindingPackageVersion =
|
|
638
|
+
require("@pid7/ashwa-native-linux-riscv64-gnu/package.json").version;
|
|
639
|
+
if (
|
|
640
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
641
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
642
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
643
|
+
) {
|
|
644
|
+
throw new Error(
|
|
645
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
646
|
+
);
|
|
428
647
|
}
|
|
429
|
-
return binding
|
|
648
|
+
return binding;
|
|
430
649
|
} catch (e) {
|
|
431
|
-
loadErrors.push(e)
|
|
650
|
+
loadErrors.push(e);
|
|
432
651
|
}
|
|
433
652
|
}
|
|
434
|
-
} else if (process.arch ===
|
|
653
|
+
} else if (process.arch === "ppc64") {
|
|
435
654
|
try {
|
|
436
|
-
return require(
|
|
655
|
+
return require("./index.linux-ppc64-gnu.node");
|
|
437
656
|
} catch (e) {
|
|
438
|
-
loadErrors.push(e)
|
|
657
|
+
loadErrors.push(e);
|
|
439
658
|
}
|
|
440
659
|
try {
|
|
441
|
-
const binding = require(
|
|
442
|
-
const bindingPackageVersion =
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
660
|
+
const binding = require("@pid7/ashwa-native-linux-ppc64-gnu");
|
|
661
|
+
const bindingPackageVersion =
|
|
662
|
+
require("@pid7/ashwa-native-linux-ppc64-gnu/package.json").version;
|
|
663
|
+
if (
|
|
664
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
665
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
666
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
667
|
+
) {
|
|
668
|
+
throw new Error(
|
|
669
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
return binding;
|
|
447
673
|
} catch (e) {
|
|
448
|
-
loadErrors.push(e)
|
|
674
|
+
loadErrors.push(e);
|
|
449
675
|
}
|
|
450
|
-
} else if (process.arch ===
|
|
676
|
+
} else if (process.arch === "s390x") {
|
|
451
677
|
try {
|
|
452
|
-
return require(
|
|
678
|
+
return require("./index.linux-s390x-gnu.node");
|
|
453
679
|
} catch (e) {
|
|
454
|
-
loadErrors.push(e)
|
|
680
|
+
loadErrors.push(e);
|
|
455
681
|
}
|
|
456
682
|
try {
|
|
457
|
-
const binding = require(
|
|
458
|
-
const bindingPackageVersion =
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
683
|
+
const binding = require("@pid7/ashwa-native-linux-s390x-gnu");
|
|
684
|
+
const bindingPackageVersion =
|
|
685
|
+
require("@pid7/ashwa-native-linux-s390x-gnu/package.json").version;
|
|
686
|
+
if (
|
|
687
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
688
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
689
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
690
|
+
) {
|
|
691
|
+
throw new Error(
|
|
692
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
return binding;
|
|
463
696
|
} catch (e) {
|
|
464
|
-
loadErrors.push(e)
|
|
697
|
+
loadErrors.push(e);
|
|
465
698
|
}
|
|
466
699
|
} else {
|
|
467
|
-
loadErrors.push(
|
|
700
|
+
loadErrors.push(
|
|
701
|
+
new Error(`Unsupported architecture on Linux: ${process.arch}`),
|
|
702
|
+
);
|
|
468
703
|
}
|
|
469
|
-
} else if (process.platform ===
|
|
470
|
-
if (process.arch ===
|
|
704
|
+
} else if (process.platform === "openharmony") {
|
|
705
|
+
if (process.arch === "arm64") {
|
|
471
706
|
try {
|
|
472
|
-
return require(
|
|
707
|
+
return require("./index.openharmony-arm64.node");
|
|
473
708
|
} catch (e) {
|
|
474
|
-
loadErrors.push(e)
|
|
709
|
+
loadErrors.push(e);
|
|
475
710
|
}
|
|
476
711
|
try {
|
|
477
|
-
const binding = require(
|
|
478
|
-
const bindingPackageVersion =
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
712
|
+
const binding = require("@pid7/ashwa-native-openharmony-arm64");
|
|
713
|
+
const bindingPackageVersion =
|
|
714
|
+
require("@pid7/ashwa-native-openharmony-arm64/package.json").version;
|
|
715
|
+
if (
|
|
716
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
717
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
718
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
719
|
+
) {
|
|
720
|
+
throw new Error(
|
|
721
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
return binding;
|
|
483
725
|
} catch (e) {
|
|
484
|
-
loadErrors.push(e)
|
|
726
|
+
loadErrors.push(e);
|
|
485
727
|
}
|
|
486
|
-
} else if (process.arch ===
|
|
728
|
+
} else if (process.arch === "x64") {
|
|
487
729
|
try {
|
|
488
|
-
return require(
|
|
730
|
+
return require("./index.openharmony-x64.node");
|
|
489
731
|
} catch (e) {
|
|
490
|
-
loadErrors.push(e)
|
|
732
|
+
loadErrors.push(e);
|
|
491
733
|
}
|
|
492
734
|
try {
|
|
493
|
-
const binding = require(
|
|
494
|
-
const bindingPackageVersion =
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
735
|
+
const binding = require("@pid7/ashwa-native-openharmony-x64");
|
|
736
|
+
const bindingPackageVersion =
|
|
737
|
+
require("@pid7/ashwa-native-openharmony-x64/package.json").version;
|
|
738
|
+
if (
|
|
739
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
740
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
741
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
742
|
+
) {
|
|
743
|
+
throw new Error(
|
|
744
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
return binding;
|
|
499
748
|
} catch (e) {
|
|
500
|
-
loadErrors.push(e)
|
|
749
|
+
loadErrors.push(e);
|
|
501
750
|
}
|
|
502
|
-
} else if (process.arch ===
|
|
751
|
+
} else if (process.arch === "arm") {
|
|
503
752
|
try {
|
|
504
|
-
return require(
|
|
753
|
+
return require("./index.openharmony-arm.node");
|
|
505
754
|
} catch (e) {
|
|
506
|
-
loadErrors.push(e)
|
|
755
|
+
loadErrors.push(e);
|
|
507
756
|
}
|
|
508
757
|
try {
|
|
509
|
-
const binding = require(
|
|
510
|
-
const bindingPackageVersion =
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
758
|
+
const binding = require("@pid7/ashwa-native-openharmony-arm");
|
|
759
|
+
const bindingPackageVersion =
|
|
760
|
+
require("@pid7/ashwa-native-openharmony-arm/package.json").version;
|
|
761
|
+
if (
|
|
762
|
+
bindingPackageVersion !== "0.2.2" &&
|
|
763
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
764
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
765
|
+
) {
|
|
766
|
+
throw new Error(
|
|
767
|
+
`Native binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
return binding;
|
|
515
771
|
} catch (e) {
|
|
516
|
-
loadErrors.push(e)
|
|
772
|
+
loadErrors.push(e);
|
|
517
773
|
}
|
|
518
774
|
} else {
|
|
519
|
-
loadErrors.push(
|
|
775
|
+
loadErrors.push(
|
|
776
|
+
new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`),
|
|
777
|
+
);
|
|
520
778
|
}
|
|
521
779
|
} else {
|
|
522
|
-
loadErrors.push(
|
|
780
|
+
loadErrors.push(
|
|
781
|
+
new Error(
|
|
782
|
+
`Unsupported OS: ${process.platform}, architecture: ${process.arch}`,
|
|
783
|
+
),
|
|
784
|
+
);
|
|
523
785
|
}
|
|
524
786
|
}
|
|
525
787
|
|
|
526
788
|
function createLoadErrorChain(errors) {
|
|
527
789
|
return errors.reduce((previous, current) => {
|
|
528
|
-
let message
|
|
790
|
+
let message;
|
|
529
791
|
try {
|
|
530
792
|
message =
|
|
531
|
-
current && typeof current.message ===
|
|
793
|
+
current && typeof current.message === "string"
|
|
532
794
|
? current.message
|
|
533
|
-
: String(current)
|
|
795
|
+
: String(current);
|
|
534
796
|
} catch {
|
|
535
|
-
message =
|
|
797
|
+
message = "Unknown error";
|
|
536
798
|
}
|
|
537
|
-
const error = new Error(message)
|
|
538
|
-
error.cause = previous
|
|
539
|
-
return error
|
|
540
|
-
}, null)
|
|
799
|
+
const error = new Error(message);
|
|
800
|
+
error.cause = previous;
|
|
801
|
+
return error;
|
|
802
|
+
}, null);
|
|
541
803
|
}
|
|
542
804
|
|
|
543
805
|
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
@@ -550,10 +812,10 @@ function createLoadErrorChain(errors) {
|
|
|
550
812
|
//
|
|
551
813
|
// NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
|
|
552
814
|
// WASI loading. It never crosses into another flavor or falls back to native.
|
|
553
|
-
const __napiWasiFlavors = ["wasm32-wasi"]
|
|
554
|
-
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
|
|
815
|
+
const __napiWasiFlavors = ["wasm32-wasi"];
|
|
816
|
+
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR;
|
|
555
817
|
const __napiWasiFlavorRequested =
|
|
556
|
-
typeof __napiWasiFlavor ===
|
|
818
|
+
typeof __napiWasiFlavor === "string" && __napiWasiFlavor.length > 0;
|
|
557
819
|
if (
|
|
558
820
|
__napiWasiFlavorRequested &&
|
|
559
821
|
__napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
|
|
@@ -562,107 +824,126 @@ if (
|
|
|
562
824
|
'Unsupported WASI flavor "' +
|
|
563
825
|
__napiWasiFlavor +
|
|
564
826
|
'". Available flavors: ' +
|
|
565
|
-
__napiWasiFlavors.join(
|
|
566
|
-
)
|
|
827
|
+
__napiWasiFlavors.join(", "),
|
|
828
|
+
);
|
|
567
829
|
}
|
|
568
|
-
const forceWasiError = process.env.NAPI_RS_FORCE_WASI ===
|
|
830
|
+
const forceWasiError = process.env.NAPI_RS_FORCE_WASI === "error";
|
|
569
831
|
const forceWasi =
|
|
570
|
-
process.env.NAPI_RS_FORCE_WASI ===
|
|
832
|
+
process.env.NAPI_RS_FORCE_WASI === "true" ||
|
|
571
833
|
forceWasiError ||
|
|
572
|
-
__napiWasiFlavorRequested
|
|
834
|
+
__napiWasiFlavorRequested;
|
|
573
835
|
|
|
574
836
|
if (!forceWasi) {
|
|
575
|
-
nativeBinding = requireNative()
|
|
837
|
+
nativeBinding = requireNative();
|
|
576
838
|
}
|
|
577
839
|
|
|
578
840
|
if (!nativeBinding || forceWasi) {
|
|
579
|
-
let wasiBinding = null
|
|
580
|
-
let wasiBindingLoaded = false
|
|
581
|
-
const wasiBindingErrors = []
|
|
841
|
+
let wasiBinding = null;
|
|
842
|
+
let wasiBindingLoaded = false;
|
|
843
|
+
const wasiBindingErrors = [];
|
|
582
844
|
const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
|
|
583
845
|
try {
|
|
584
|
-
require.resolve(specifier)
|
|
846
|
+
require.resolve(specifier);
|
|
585
847
|
} catch (resolveError) {
|
|
586
|
-
if (!resolveError || resolveError.code !==
|
|
587
|
-
throw resolveError
|
|
848
|
+
if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") {
|
|
849
|
+
throw resolveError;
|
|
588
850
|
}
|
|
589
851
|
if (isPackage) {
|
|
590
852
|
try {
|
|
591
|
-
require.resolve(specifier +
|
|
853
|
+
require.resolve(specifier + "/package.json");
|
|
592
854
|
} catch (packageError) {
|
|
593
|
-
if (packageError && packageError.code ===
|
|
594
|
-
return resolveError
|
|
855
|
+
if (packageError && packageError.code === "MODULE_NOT_FOUND") {
|
|
856
|
+
return resolveError;
|
|
595
857
|
}
|
|
596
858
|
// An exports restriction proves the package exists even when its
|
|
597
859
|
// package.json is not public. Preserve the root resolution failure.
|
|
598
|
-
throw resolveError
|
|
860
|
+
throw resolveError;
|
|
599
861
|
}
|
|
600
862
|
// The package exists but its main/export target is broken.
|
|
601
|
-
throw resolveError
|
|
863
|
+
throw resolveError;
|
|
602
864
|
}
|
|
603
|
-
return resolveError
|
|
865
|
+
return resolveError;
|
|
604
866
|
}
|
|
605
867
|
if (localArtifacts) {
|
|
606
|
-
let artifactError = null
|
|
868
|
+
let artifactError = null;
|
|
607
869
|
for (let i = 0; i < localArtifacts.length; i++) {
|
|
608
870
|
try {
|
|
609
|
-
require.resolve(localArtifacts[i])
|
|
610
|
-
return null
|
|
871
|
+
require.resolve(localArtifacts[i]);
|
|
872
|
+
return null;
|
|
611
873
|
} catch (resolveError) {
|
|
612
|
-
if (!resolveError || resolveError.code !==
|
|
613
|
-
throw resolveError
|
|
874
|
+
if (!resolveError || resolveError.code !== "MODULE_NOT_FOUND") {
|
|
875
|
+
throw resolveError;
|
|
614
876
|
}
|
|
615
|
-
artifactError = resolveError
|
|
877
|
+
artifactError = resolveError;
|
|
616
878
|
}
|
|
617
879
|
}
|
|
618
|
-
return artifactError
|
|
880
|
+
return artifactError;
|
|
619
881
|
}
|
|
620
|
-
return null
|
|
621
|
-
}
|
|
622
|
-
if (
|
|
623
|
-
|
|
624
|
-
|
|
882
|
+
return null;
|
|
883
|
+
};
|
|
884
|
+
if (
|
|
885
|
+
!wasiBindingLoaded &&
|
|
886
|
+
(!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")
|
|
887
|
+
) {
|
|
888
|
+
let candidateError = null;
|
|
889
|
+
let candidateFailed = false;
|
|
625
890
|
try {
|
|
626
|
-
candidateError = __napiWasiResolveCandidate(
|
|
627
|
-
|
|
891
|
+
candidateError = __napiWasiResolveCandidate("./index.wasi.cjs", false, [
|
|
892
|
+
"./index.wasm32-wasi.debug.wasm",
|
|
893
|
+
"./index.wasm32-wasi.wasm",
|
|
894
|
+
]);
|
|
895
|
+
candidateFailed = candidateError !== null;
|
|
628
896
|
if (!candidateFailed) {
|
|
629
|
-
wasiBinding = require(
|
|
630
|
-
nativeBinding = wasiBinding
|
|
631
|
-
wasiBindingLoaded = true
|
|
897
|
+
wasiBinding = require("./index.wasi.cjs");
|
|
898
|
+
nativeBinding = wasiBinding;
|
|
899
|
+
wasiBindingLoaded = true;
|
|
632
900
|
}
|
|
633
901
|
} catch (err) {
|
|
634
|
-
candidateError = err
|
|
635
|
-
candidateFailed = true
|
|
902
|
+
candidateError = err;
|
|
903
|
+
candidateFailed = true;
|
|
636
904
|
}
|
|
637
905
|
if (candidateFailed) {
|
|
638
|
-
wasiBindingErrors.push(candidateError)
|
|
639
|
-
loadErrors.push(candidateError)
|
|
906
|
+
wasiBindingErrors.push(candidateError);
|
|
907
|
+
loadErrors.push(candidateError);
|
|
640
908
|
}
|
|
641
909
|
}
|
|
642
|
-
if (
|
|
643
|
-
|
|
644
|
-
|
|
910
|
+
if (
|
|
911
|
+
!wasiBindingLoaded &&
|
|
912
|
+
(!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")
|
|
913
|
+
) {
|
|
914
|
+
let candidateError = null;
|
|
915
|
+
let candidateFailed = false;
|
|
645
916
|
try {
|
|
646
|
-
candidateError = __napiWasiResolveCandidate(
|
|
647
|
-
|
|
917
|
+
candidateError = __napiWasiResolveCandidate(
|
|
918
|
+
"@pid7/ashwa-native-wasm32-wasi",
|
|
919
|
+
true,
|
|
920
|
+
undefined,
|
|
921
|
+
);
|
|
922
|
+
candidateFailed = candidateError !== null;
|
|
648
923
|
if (!candidateFailed) {
|
|
649
|
-
if (
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
924
|
+
if (
|
|
925
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
926
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0"
|
|
927
|
+
) {
|
|
928
|
+
const bindingPackageVersion =
|
|
929
|
+
require("@pid7/ashwa-native-wasm32-wasi/package.json").version;
|
|
930
|
+
if (bindingPackageVersion !== "0.2.2") {
|
|
931
|
+
throw new Error(
|
|
932
|
+
`WASI binding package version mismatch, expected 0.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
933
|
+
);
|
|
653
934
|
}
|
|
654
935
|
}
|
|
655
|
-
wasiBinding = require(
|
|
656
|
-
nativeBinding = wasiBinding
|
|
657
|
-
wasiBindingLoaded = true
|
|
936
|
+
wasiBinding = require("@pid7/ashwa-native-wasm32-wasi");
|
|
937
|
+
nativeBinding = wasiBinding;
|
|
938
|
+
wasiBindingLoaded = true;
|
|
658
939
|
}
|
|
659
940
|
} catch (err) {
|
|
660
|
-
candidateError = err
|
|
661
|
-
candidateFailed = true
|
|
941
|
+
candidateError = err;
|
|
942
|
+
candidateFailed = true;
|
|
662
943
|
}
|
|
663
944
|
if (candidateFailed) {
|
|
664
|
-
wasiBindingErrors.push(candidateError)
|
|
665
|
-
loadErrors.push(candidateError)
|
|
945
|
+
wasiBindingErrors.push(candidateError);
|
|
946
|
+
loadErrors.push(candidateError);
|
|
666
947
|
}
|
|
667
948
|
}
|
|
668
949
|
if (
|
|
@@ -671,16 +952,16 @@ if (!nativeBinding || forceWasi) {
|
|
|
671
952
|
!forceWasiError &&
|
|
672
953
|
!__napiWasiFlavorRequested
|
|
673
954
|
) {
|
|
674
|
-
nativeBinding = requireNative()
|
|
955
|
+
nativeBinding = requireNative();
|
|
675
956
|
}
|
|
676
957
|
if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
|
|
677
958
|
const error = new Error(
|
|
678
959
|
__napiWasiFlavorRequested
|
|
679
960
|
? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
|
|
680
|
-
:
|
|
681
|
-
)
|
|
682
|
-
error.cause = createLoadErrorChain(wasiBindingErrors)
|
|
683
|
-
throw error
|
|
961
|
+
: "WASI binding not found and NAPI_RS_FORCE_WASI is set to error",
|
|
962
|
+
);
|
|
963
|
+
error.cause = createLoadErrorChain(wasiBindingErrors);
|
|
964
|
+
throw error;
|
|
684
965
|
}
|
|
685
966
|
}
|
|
686
967
|
|
|
@@ -689,15 +970,16 @@ if (!nativeBinding) {
|
|
|
689
970
|
const error = new Error(
|
|
690
971
|
`Cannot find native binding. ` +
|
|
691
972
|
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
692
|
-
|
|
693
|
-
)
|
|
973
|
+
"Please try `npm i` again after removing both package-lock.json and node_modules directory.",
|
|
974
|
+
);
|
|
694
975
|
// assign instead of the `new Error(message, { cause })` options form,
|
|
695
976
|
// which Node < 16.9 silently ignores
|
|
696
|
-
error.cause = createLoadErrorChain(loadErrors)
|
|
697
|
-
throw error
|
|
977
|
+
error.cause = createLoadErrorChain(loadErrors);
|
|
978
|
+
throw error;
|
|
698
979
|
}
|
|
699
|
-
throw new Error(`Failed to load native binding`)
|
|
980
|
+
throw new Error(`Failed to load native binding`);
|
|
700
981
|
}
|
|
701
982
|
|
|
702
|
-
|
|
703
|
-
|
|
983
|
+
export default nativeBinding;
|
|
984
|
+
export const searchOne = nativeBinding.searchOne;
|
|
985
|
+
export const searchTwo = nativeBinding.searchTwo;
|