@tursodatabase/database 0.2.0-pre.10 → 0.2.0-pre.12

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 CHANGED
@@ -23,7 +23,7 @@ This package is the Turso embedded database library for JavaScript in Node.
23
23
  - **SQLite compatible:** SQLite query language and file format support ([status](https://github.com/tursodatabase/turso/blob/main/COMPAT.md)).
24
24
  - **In-process**: No network overhead, runs directly in your Node.js process
25
25
  - **TypeScript support**: Full TypeScript definitions included
26
- - **Cross-platform**: Supports Linux (x86 and arm64), macOS, Windows (browser is supported in the separate package `@tursodatabase/database-browser` package)
26
+ - **Cross-platform**: Supports Linux (x86 and arm64), macOS, Windows (browser is supported in the separate package `@tursodatabase/database-wasm` package)
27
27
 
28
28
  ## Installation
29
29
 
@@ -67,6 +67,20 @@ test('explicit connect', async () => {
67
67
  await db.connect();
68
68
  expect(await db.prepare("SELECT 1 as x").all()).toEqual([{ x: 1 }]);
69
69
  });
70
+ test('zero-limit-bug', async () => {
71
+ const db = await connect(':memory:');
72
+ const create = db.prepare(`CREATE TABLE users (name TEXT NOT NULL);`);
73
+ await create.run();
74
+ const insert = db.prepare(`insert into "users" values (?), (?), (?);`);
75
+ await insert.run('John', 'Jane', 'Jack');
76
+ const stmt1 = db.prepare(`select * from "users" limit ?;`);
77
+ expect(await stmt1.all(0)).toEqual([]);
78
+ let rows = [{ name: 'John' }, { name: 'Jane' }, { name: 'Jack' }, { name: 'John' }, { name: 'Jane' }, { name: 'Jack' }];
79
+ for (const limit of [0, 1, 2, 3, 4, 5, 6, 7]) {
80
+ const stmt2 = db.prepare(`select * from "users" union all select * from "users" limit ?;`);
81
+ expect(await stmt2.all(limit)).toEqual(rows.slice(0, Math.min(limit, 6)));
82
+ }
83
+ });
70
84
  test('avg-bug', async () => {
71
85
  const db = await connect(':memory:');
72
86
  const create = db.prepare(`create table "aggregate_table" (
package/index.js CHANGED
@@ -67,7 +67,7 @@ const isMuslFromChildProcess = () => {
67
67
  function requireNative() {
68
68
  if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
69
69
  try {
70
- nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
70
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
71
71
  } catch (err) {
72
72
  loadErrors.push(err)
73
73
  }
@@ -81,8 +81,8 @@ function requireNative() {
81
81
  try {
82
82
  const binding = require('@tursodatabase/database-android-arm64')
83
83
  const bindingPackageVersion = require('@tursodatabase/database-android-arm64/package.json').version
84
- if (bindingPackageVersion !== '0.2.0-pre.7' && 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.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
84
+ if (bindingPackageVersion !== '0.2.0-pre.10' && 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.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
86
86
  }
87
87
  return binding
88
88
  } catch (e) {
@@ -97,8 +97,8 @@ function requireNative() {
97
97
  try {
98
98
  const binding = require('@tursodatabase/database-android-arm-eabi')
99
99
  const bindingPackageVersion = require('@tursodatabase/database-android-arm-eabi/package.json').version
100
- if (bindingPackageVersion !== '0.2.0-pre.7' && 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.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '0.2.0-pre.10' && 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.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
102
  }
103
103
  return binding
104
104
  } catch (e) {
@@ -117,8 +117,8 @@ function requireNative() {
117
117
  try {
118
118
  const binding = require('@tursodatabase/database-win32-x64-msvc')
119
119
  const bindingPackageVersion = require('@tursodatabase/database-win32-x64-msvc/package.json').version
120
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
121
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
120
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
121
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
122
122
  }
123
123
  return binding
124
124
  } catch (e) {
@@ -133,8 +133,8 @@ function requireNative() {
133
133
  try {
134
134
  const binding = require('@tursodatabase/database-win32-ia32-msvc')
135
135
  const bindingPackageVersion = require('@tursodatabase/database-win32-ia32-msvc/package.json').version
136
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
137
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
136
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
137
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
138
138
  }
139
139
  return binding
140
140
  } catch (e) {
@@ -149,8 +149,8 @@ function requireNative() {
149
149
  try {
150
150
  const binding = require('@tursodatabase/database-win32-arm64-msvc')
151
151
  const bindingPackageVersion = require('@tursodatabase/database-win32-arm64-msvc/package.json').version
152
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
153
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
153
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
154
154
  }
155
155
  return binding
156
156
  } catch (e) {
@@ -168,8 +168,8 @@ function requireNative() {
168
168
  try {
169
169
  const binding = require('@tursodatabase/database-darwin-universal')
170
170
  const bindingPackageVersion = require('@tursodatabase/database-darwin-universal/package.json').version
171
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
172
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
171
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
172
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
173
173
  }
174
174
  return binding
175
175
  } catch (e) {
@@ -184,8 +184,8 @@ function requireNative() {
184
184
  try {
185
185
  const binding = require('@tursodatabase/database-darwin-x64')
186
186
  const bindingPackageVersion = require('@tursodatabase/database-darwin-x64/package.json').version
187
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
188
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
188
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
189
189
  }
190
190
  return binding
191
191
  } catch (e) {
@@ -200,8 +200,8 @@ function requireNative() {
200
200
  try {
201
201
  const binding = require('@tursodatabase/database-darwin-arm64')
202
202
  const bindingPackageVersion = require('@tursodatabase/database-darwin-arm64/package.json').version
203
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
204
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
204
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
205
  }
206
206
  return binding
207
207
  } catch (e) {
@@ -220,8 +220,8 @@ function requireNative() {
220
220
  try {
221
221
  const binding = require('@tursodatabase/database-freebsd-x64')
222
222
  const bindingPackageVersion = require('@tursodatabase/database-freebsd-x64/package.json').version
223
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
224
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
223
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
224
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
225
225
  }
226
226
  return binding
227
227
  } catch (e) {
@@ -236,8 +236,8 @@ function requireNative() {
236
236
  try {
237
237
  const binding = require('@tursodatabase/database-freebsd-arm64')
238
238
  const bindingPackageVersion = require('@tursodatabase/database-freebsd-arm64/package.json').version
239
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
240
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
240
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
241
241
  }
242
242
  return binding
243
243
  } catch (e) {
@@ -257,8 +257,8 @@ function requireNative() {
257
257
  try {
258
258
  const binding = require('@tursodatabase/database-linux-x64-musl')
259
259
  const bindingPackageVersion = require('@tursodatabase/database-linux-x64-musl/package.json').version
260
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
261
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
260
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
261
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
262
262
  }
263
263
  return binding
264
264
  } catch (e) {
@@ -273,8 +273,8 @@ function requireNative() {
273
273
  try {
274
274
  const binding = require('@tursodatabase/database-linux-x64-gnu')
275
275
  const bindingPackageVersion = require('@tursodatabase/database-linux-x64-gnu/package.json').version
276
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
277
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
277
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
278
278
  }
279
279
  return binding
280
280
  } catch (e) {
@@ -291,8 +291,8 @@ function requireNative() {
291
291
  try {
292
292
  const binding = require('@tursodatabase/database-linux-arm64-musl')
293
293
  const bindingPackageVersion = require('@tursodatabase/database-linux-arm64-musl/package.json').version
294
- if (bindingPackageVersion !== '0.2.0-pre.7' && 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.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
294
+ if (bindingPackageVersion !== '0.2.0-pre.10' && 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.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
296
  }
297
297
  return binding
298
298
  } catch (e) {
@@ -307,8 +307,8 @@ function requireNative() {
307
307
  try {
308
308
  const binding = require('@tursodatabase/database-linux-arm64-gnu')
309
309
  const bindingPackageVersion = require('@tursodatabase/database-linux-arm64-gnu/package.json').version
310
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
312
  }
313
313
  return binding
314
314
  } catch (e) {
@@ -325,8 +325,8 @@ function requireNative() {
325
325
  try {
326
326
  const binding = require('@tursodatabase/database-linux-arm-musleabihf')
327
327
  const bindingPackageVersion = require('@tursodatabase/database-linux-arm-musleabihf/package.json').version
328
- if (bindingPackageVersion !== '0.2.0-pre.7' && 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.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
+ if (bindingPackageVersion !== '0.2.0-pre.10' && 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.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
330
330
  }
331
331
  return binding
332
332
  } catch (e) {
@@ -341,8 +341,42 @@ function requireNative() {
341
341
  try {
342
342
  const binding = require('@tursodatabase/database-linux-arm-gnueabihf')
343
343
  const bindingPackageVersion = require('@tursodatabase/database-linux-arm-gnueabihf/package.json').version
344
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
+ }
347
+ return binding
348
+ } catch (e) {
349
+ loadErrors.push(e)
350
+ }
351
+ }
352
+ } else if (process.arch === 'loong64') {
353
+ if (isMusl()) {
354
+ try {
355
+ return require('./turso.linux-loong64-musl.node')
356
+ } catch (e) {
357
+ loadErrors.push(e)
358
+ }
359
+ try {
360
+ const binding = require('@tursodatabase/database-linux-loong64-musl')
361
+ const bindingPackageVersion = require('@tursodatabase/database-linux-loong64-musl/package.json').version
362
+ if (bindingPackageVersion !== '0.2.0-pre.10' && 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.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
+ }
365
+ return binding
366
+ } catch (e) {
367
+ loadErrors.push(e)
368
+ }
369
+ } else {
370
+ try {
371
+ return require('./turso.linux-loong64-gnu.node')
372
+ } catch (e) {
373
+ loadErrors.push(e)
374
+ }
375
+ try {
376
+ const binding = require('@tursodatabase/database-linux-loong64-gnu')
377
+ const bindingPackageVersion = require('@tursodatabase/database-linux-loong64-gnu/package.json').version
378
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
380
  }
347
381
  return binding
348
382
  } catch (e) {
@@ -359,8 +393,8 @@ function requireNative() {
359
393
  try {
360
394
  const binding = require('@tursodatabase/database-linux-riscv64-musl')
361
395
  const bindingPackageVersion = require('@tursodatabase/database-linux-riscv64-musl/package.json').version
362
- if (bindingPackageVersion !== '0.2.0-pre.7' && 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.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
+ if (bindingPackageVersion !== '0.2.0-pre.10' && 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.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
364
398
  }
365
399
  return binding
366
400
  } catch (e) {
@@ -375,8 +409,8 @@ function requireNative() {
375
409
  try {
376
410
  const binding = require('@tursodatabase/database-linux-riscv64-gnu')
377
411
  const bindingPackageVersion = require('@tursodatabase/database-linux-riscv64-gnu/package.json').version
378
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
413
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
414
  }
381
415
  return binding
382
416
  } catch (e) {
@@ -392,8 +426,8 @@ function requireNative() {
392
426
  try {
393
427
  const binding = require('@tursodatabase/database-linux-ppc64-gnu')
394
428
  const bindingPackageVersion = require('@tursodatabase/database-linux-ppc64-gnu/package.json').version
395
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
396
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
429
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
430
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
397
431
  }
398
432
  return binding
399
433
  } catch (e) {
@@ -408,8 +442,8 @@ function requireNative() {
408
442
  try {
409
443
  const binding = require('@tursodatabase/database-linux-s390x-gnu')
410
444
  const bindingPackageVersion = require('@tursodatabase/database-linux-s390x-gnu/package.json').version
411
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
412
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
446
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
413
447
  }
414
448
  return binding
415
449
  } catch (e) {
@@ -428,8 +462,8 @@ function requireNative() {
428
462
  try {
429
463
  const binding = require('@tursodatabase/database-openharmony-arm64')
430
464
  const bindingPackageVersion = require('@tursodatabase/database-openharmony-arm64/package.json').version
431
- if (bindingPackageVersion !== '0.2.0-pre.7' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
432
- throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
465
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
466
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
433
467
  }
434
468
  return binding
435
469
  } catch (e) {
@@ -444,8 +478,8 @@ function requireNative() {
444
478
  try {
445
479
  const binding = require('@tursodatabase/database-openharmony-x64')
446
480
  const bindingPackageVersion = require('@tursodatabase/database-openharmony-x64/package.json').version
447
- if (bindingPackageVersion !== '0.2.0-pre.7' && 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.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
482
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
449
483
  }
450
484
  return binding
451
485
  } catch (e) {
@@ -460,8 +494,8 @@ function requireNative() {
460
494
  try {
461
495
  const binding = require('@tursodatabase/database-openharmony-arm')
462
496
  const bindingPackageVersion = require('@tursodatabase/database-openharmony-arm/package.json').version
463
- if (bindingPackageVersion !== '0.2.0-pre.7' && 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.2.0-pre.7 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
+ if (bindingPackageVersion !== '0.2.0-pre.10' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
498
+ throw new Error(`Native binding package version mismatch, expected 0.2.0-pre.10 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
465
499
  }
466
500
  return binding
467
501
  } catch (e) {
@@ -478,22 +512,32 @@ function requireNative() {
478
512
  nativeBinding = requireNative()
479
513
 
480
514
  if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
515
+ let wasiBinding = null
516
+ let wasiBindingError = null
481
517
  try {
482
- nativeBinding = require('./turso.wasi.cjs')
518
+ wasiBinding = require('./turso.wasi.cjs')
519
+ nativeBinding = wasiBinding
483
520
  } catch (err) {
484
521
  if (process.env.NAPI_RS_FORCE_WASI) {
485
- loadErrors.push(err)
522
+ wasiBindingError = err
486
523
  }
487
524
  }
488
525
  if (!nativeBinding) {
489
526
  try {
490
- nativeBinding = require('@tursodatabase/database-wasm32-wasi')
527
+ wasiBinding = require('@tursodatabase/database-wasm32-wasi')
528
+ nativeBinding = wasiBinding
491
529
  } catch (err) {
492
530
  if (process.env.NAPI_RS_FORCE_WASI) {
531
+ wasiBindingError.cause = err
493
532
  loadErrors.push(err)
494
533
  }
495
534
  }
496
535
  }
536
+ if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
537
+ const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
538
+ error.cause = wasiBindingError
539
+ throw error
540
+ }
497
541
  }
498
542
 
499
543
  if (!nativeBinding) {
@@ -502,7 +546,12 @@ if (!nativeBinding) {
502
546
  `Cannot find native binding. ` +
503
547
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
504
548
  'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
505
- { cause: loadErrors }
549
+ {
550
+ cause: loadErrors.reduce((err, cur) => {
551
+ cur.cause = err
552
+ return cur
553
+ }),
554
+ },
506
555
  )
507
556
  }
508
557
  throw new Error(`Failed to load native binding`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tursodatabase/database",
3
- "version": "0.2.0-pre.10",
3
+ "version": "0.2.0-pre.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tursodatabase/turso"
@@ -47,15 +47,15 @@
47
47
  ]
48
48
  },
49
49
  "dependencies": {
50
- "@tursodatabase/database-common": "^0.2.0-pre.10"
50
+ "@tursodatabase/database-common": "^0.2.0-pre.12"
51
51
  },
52
52
  "imports": {
53
53
  "#index": "./index.js"
54
54
  },
55
55
  "optionalDependencies": {
56
- "@tursodatabase/database-linux-x64-gnu": "0.2.0-pre.10",
57
- "@tursodatabase/database-win32-x64-msvc": "0.2.0-pre.10",
58
- "@tursodatabase/database-darwin-arm64": "0.2.0-pre.10",
59
- "@tursodatabase/database-linux-arm64-gnu": "0.2.0-pre.10"
56
+ "@tursodatabase/database-linux-x64-gnu": "0.2.0-pre.12",
57
+ "@tursodatabase/database-win32-x64-msvc": "0.2.0-pre.12",
58
+ "@tursodatabase/database-darwin-arm64": "0.2.0-pre.12",
59
+ "@tursodatabase/database-linux-arm64-gnu": "0.2.0-pre.12"
60
60
  }
61
61
  }