@crawlee/fs-storage-native 0.0.1-placeholder.0 → 0.1.4

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