@tursodatabase/database 0.1.4-pre.10

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/index.js ADDED
@@ -0,0 +1,398 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ import { createRequire } from 'node:module'
7
+ const require = createRequire(import.meta.url)
8
+ const __dirname = new URL('.', import.meta.url).pathname
9
+
10
+ const { readFileSync } = require('node:fs')
11
+ let nativeBinding = null
12
+ const loadErrors = []
13
+
14
+ const isMusl = () => {
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()
23
+ }
24
+ }
25
+ return musl
26
+ }
27
+
28
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
29
+
30
+ const isMuslFromFilesystem = () => {
31
+ try {
32
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
33
+ } catch {
34
+ return null
35
+ }
36
+ }
37
+
38
+ const isMuslFromReport = () => {
39
+ let report = null
40
+ if (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
53
+ }
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
+ nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
71
+ } catch (err) {
72
+ loadErrors.push(err)
73
+ }
74
+ } else if (process.platform === 'android') {
75
+ if (process.arch === 'arm64') {
76
+ try {
77
+ return require('./turso.android-arm64.node')
78
+ } catch (e) {
79
+ loadErrors.push(e)
80
+ }
81
+ try {
82
+ return require('@tursodatabase/database-android-arm64')
83
+ } catch (e) {
84
+ loadErrors.push(e)
85
+ }
86
+ } else if (process.arch === 'arm') {
87
+ try {
88
+ return require('./turso.android-arm-eabi.node')
89
+ } catch (e) {
90
+ loadErrors.push(e)
91
+ }
92
+ try {
93
+ return require('@tursodatabase/database-android-arm-eabi')
94
+ } catch (e) {
95
+ loadErrors.push(e)
96
+ }
97
+ } else {
98
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
99
+ }
100
+ } else if (process.platform === 'win32') {
101
+ if (process.arch === 'x64') {
102
+ try {
103
+ return require('./turso.win32-x64-msvc.node')
104
+ } catch (e) {
105
+ loadErrors.push(e)
106
+ }
107
+ try {
108
+ return require('@tursodatabase/database-win32-x64-msvc')
109
+ } catch (e) {
110
+ loadErrors.push(e)
111
+ }
112
+ } else if (process.arch === 'ia32') {
113
+ try {
114
+ return require('./turso.win32-ia32-msvc.node')
115
+ } catch (e) {
116
+ loadErrors.push(e)
117
+ }
118
+ try {
119
+ return require('@tursodatabase/database-win32-ia32-msvc')
120
+ } catch (e) {
121
+ loadErrors.push(e)
122
+ }
123
+ } else if (process.arch === 'arm64') {
124
+ try {
125
+ return require('./turso.win32-arm64-msvc.node')
126
+ } catch (e) {
127
+ loadErrors.push(e)
128
+ }
129
+ try {
130
+ return require('@tursodatabase/database-win32-arm64-msvc')
131
+ } catch (e) {
132
+ loadErrors.push(e)
133
+ }
134
+ } else {
135
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
136
+ }
137
+ } else if (process.platform === 'darwin') {
138
+ try {
139
+ return require('./turso.darwin-universal.node')
140
+ } catch (e) {
141
+ loadErrors.push(e)
142
+ }
143
+ try {
144
+ return require('@tursodatabase/database-darwin-universal')
145
+ } catch (e) {
146
+ loadErrors.push(e)
147
+ }
148
+ if (process.arch === 'x64') {
149
+ try {
150
+ return require('./turso.darwin-x64.node')
151
+ } catch (e) {
152
+ loadErrors.push(e)
153
+ }
154
+ try {
155
+ return require('@tursodatabase/database-darwin-x64')
156
+ } catch (e) {
157
+ loadErrors.push(e)
158
+ }
159
+ } else if (process.arch === 'arm64') {
160
+ try {
161
+ return require('./turso.darwin-arm64.node')
162
+ } catch (e) {
163
+ loadErrors.push(e)
164
+ }
165
+ try {
166
+ return require('@tursodatabase/database-darwin-arm64')
167
+ } catch (e) {
168
+ loadErrors.push(e)
169
+ }
170
+ } else {
171
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
172
+ }
173
+ } else if (process.platform === 'freebsd') {
174
+ if (process.arch === 'x64') {
175
+ try {
176
+ return require('./turso.freebsd-x64.node')
177
+ } catch (e) {
178
+ loadErrors.push(e)
179
+ }
180
+ try {
181
+ return require('@tursodatabase/database-freebsd-x64')
182
+ } catch (e) {
183
+ loadErrors.push(e)
184
+ }
185
+ } else if (process.arch === 'arm64') {
186
+ try {
187
+ return require('./turso.freebsd-arm64.node')
188
+ } catch (e) {
189
+ loadErrors.push(e)
190
+ }
191
+ try {
192
+ return require('@tursodatabase/database-freebsd-arm64')
193
+ } catch (e) {
194
+ loadErrors.push(e)
195
+ }
196
+ } else {
197
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
198
+ }
199
+ } else if (process.platform === 'linux') {
200
+ if (process.arch === 'x64') {
201
+ if (isMusl()) {
202
+ try {
203
+ return require('./turso.linux-x64-musl.node')
204
+ } catch (e) {
205
+ loadErrors.push(e)
206
+ }
207
+ try {
208
+ return require('@tursodatabase/database-linux-x64-musl')
209
+ } catch (e) {
210
+ loadErrors.push(e)
211
+ }
212
+ } else {
213
+ try {
214
+ return require('./turso.linux-x64-gnu.node')
215
+ } catch (e) {
216
+ loadErrors.push(e)
217
+ }
218
+ try {
219
+ return require('@tursodatabase/database-linux-x64-gnu')
220
+ } catch (e) {
221
+ loadErrors.push(e)
222
+ }
223
+ }
224
+ } else if (process.arch === 'arm64') {
225
+ if (isMusl()) {
226
+ try {
227
+ return require('./turso.linux-arm64-musl.node')
228
+ } catch (e) {
229
+ loadErrors.push(e)
230
+ }
231
+ try {
232
+ return require('@tursodatabase/database-linux-arm64-musl')
233
+ } catch (e) {
234
+ loadErrors.push(e)
235
+ }
236
+ } else {
237
+ try {
238
+ return require('./turso.linux-arm64-gnu.node')
239
+ } catch (e) {
240
+ loadErrors.push(e)
241
+ }
242
+ try {
243
+ return require('@tursodatabase/database-linux-arm64-gnu')
244
+ } catch (e) {
245
+ loadErrors.push(e)
246
+ }
247
+ }
248
+ } else if (process.arch === 'arm') {
249
+ if (isMusl()) {
250
+ try {
251
+ return require('./turso.linux-arm-musleabihf.node')
252
+ } catch (e) {
253
+ loadErrors.push(e)
254
+ }
255
+ try {
256
+ return require('@tursodatabase/database-linux-arm-musleabihf')
257
+ } catch (e) {
258
+ loadErrors.push(e)
259
+ }
260
+ } else {
261
+ try {
262
+ return require('./turso.linux-arm-gnueabihf.node')
263
+ } catch (e) {
264
+ loadErrors.push(e)
265
+ }
266
+ try {
267
+ return require('@tursodatabase/database-linux-arm-gnueabihf')
268
+ } catch (e) {
269
+ loadErrors.push(e)
270
+ }
271
+ }
272
+ } else if (process.arch === 'riscv64') {
273
+ if (isMusl()) {
274
+ try {
275
+ return require('./turso.linux-riscv64-musl.node')
276
+ } catch (e) {
277
+ loadErrors.push(e)
278
+ }
279
+ try {
280
+ return require('@tursodatabase/database-linux-riscv64-musl')
281
+ } catch (e) {
282
+ loadErrors.push(e)
283
+ }
284
+ } else {
285
+ try {
286
+ return require('./turso.linux-riscv64-gnu.node')
287
+ } catch (e) {
288
+ loadErrors.push(e)
289
+ }
290
+ try {
291
+ return require('@tursodatabase/database-linux-riscv64-gnu')
292
+ } catch (e) {
293
+ loadErrors.push(e)
294
+ }
295
+ }
296
+ } else if (process.arch === 'ppc64') {
297
+ try {
298
+ return require('./turso.linux-ppc64-gnu.node')
299
+ } catch (e) {
300
+ loadErrors.push(e)
301
+ }
302
+ try {
303
+ return require('@tursodatabase/database-linux-ppc64-gnu')
304
+ } catch (e) {
305
+ loadErrors.push(e)
306
+ }
307
+ } else if (process.arch === 's390x') {
308
+ try {
309
+ return require('./turso.linux-s390x-gnu.node')
310
+ } catch (e) {
311
+ loadErrors.push(e)
312
+ }
313
+ try {
314
+ return require('@tursodatabase/database-linux-s390x-gnu')
315
+ } catch (e) {
316
+ loadErrors.push(e)
317
+ }
318
+ } else {
319
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
320
+ }
321
+ } else if (process.platform === 'openharmony') {
322
+ if (process.arch === 'arm64') {
323
+ try {
324
+ return require('./turso.linux-arm64-ohos.node')
325
+ } catch (e) {
326
+ loadErrors.push(e)
327
+ }
328
+ try {
329
+ return require('@tursodatabase/database-linux-arm64-ohos')
330
+ } catch (e) {
331
+ loadErrors.push(e)
332
+ }
333
+ } else if (process.arch === 'x64') {
334
+ try {
335
+ return require('./turso.linux-x64-ohos.node')
336
+ } catch (e) {
337
+ loadErrors.push(e)
338
+ }
339
+ try {
340
+ return require('@tursodatabase/database-linux-x64-ohos')
341
+ } catch (e) {
342
+ loadErrors.push(e)
343
+ }
344
+ } else if (process.arch === 'arm') {
345
+ try {
346
+ return require('./turso.linux-arm-ohos.node')
347
+ } catch (e) {
348
+ loadErrors.push(e)
349
+ }
350
+ try {
351
+ return require('@tursodatabase/database-linux-arm-ohos')
352
+ } catch (e) {
353
+ loadErrors.push(e)
354
+ }
355
+ } else {
356
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
357
+ }
358
+ } else {
359
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
360
+ }
361
+ }
362
+
363
+ nativeBinding = requireNative()
364
+
365
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
366
+ try {
367
+ nativeBinding = require('./turso.wasi.cjs')
368
+ } catch (err) {
369
+ if (process.env.NAPI_RS_FORCE_WASI) {
370
+ loadErrors.push(err)
371
+ }
372
+ }
373
+ if (!nativeBinding) {
374
+ try {
375
+ nativeBinding = require('@tursodatabase/database-wasm32-wasi')
376
+ } catch (err) {
377
+ if (process.env.NAPI_RS_FORCE_WASI) {
378
+ loadErrors.push(err)
379
+ }
380
+ }
381
+ }
382
+ }
383
+
384
+ if (!nativeBinding) {
385
+ if (loadErrors.length > 0) {
386
+ throw new Error(
387
+ `Cannot find native binding. ` +
388
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
389
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
390
+ { cause: loadErrors }
391
+ )
392
+ }
393
+ throw new Error(`Failed to load native binding`)
394
+ }
395
+
396
+ const { Database, Statement } = nativeBinding
397
+ export { Database }
398
+ export { Statement }
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@tursodatabase/database",
3
+ "version": "0.1.4-pre.10",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/tursodatabase/turso"
7
+ },
8
+ "description": "The Turso database library",
9
+ "module": "./dist/promise.js",
10
+ "main": "./dist/promise.js",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": "./dist/promise.js",
14
+ "./compat": "./dist/compat.js"
15
+ },
16
+ "files": [
17
+ "browser.js",
18
+ "index.js",
19
+ "index.d.ts",
20
+ "dist/**"
21
+ ],
22
+ "types": "index.d.ts",
23
+ "napi": {
24
+ "binaryName": "turso",
25
+ "targets": [
26
+ "x86_64-unknown-linux-gnu",
27
+ "x86_64-pc-windows-msvc",
28
+ "universal-apple-darwin",
29
+ "wasm32-wasip1-threads"
30
+ ]
31
+ },
32
+ "license": "MIT",
33
+ "devDependencies": {
34
+ "@napi-rs/cli": "^3.0.4",
35
+ "@napi-rs/wasm-runtime": "^1.0.1",
36
+ "ava": "^6.0.1",
37
+ "better-sqlite3": "^11.9.1",
38
+ "typescript": "^5.9.2"
39
+ },
40
+ "ava": {
41
+ "timeout": "3m"
42
+ },
43
+ "engines": {
44
+ "node": ">= 10"
45
+ },
46
+ "scripts": {
47
+ "artifacts": "napi artifacts",
48
+ "build": "npm exec tsc && napi build --platform --release --esm",
49
+ "build:debug": "npm exec tsc && napi build --platform",
50
+ "prepublishOnly": "npm exec tsc && napi prepublish -t npm",
51
+ "test": "true",
52
+ "universal": "napi universalize",
53
+ "version": "napi version"
54
+ },
55
+ "packageManager": "yarn@4.9.2",
56
+ "imports": {
57
+ "#entry-point": {
58
+ "types": "./index.d.ts",
59
+ "browser": "./browser.js",
60
+ "node": "./index.js"
61
+ }
62
+ },
63
+ "optionalDependencies": {
64
+ "@tursodatabase/database-linux-x64-gnu": "0.1.4-pre.10",
65
+ "@tursodatabase/database-win32-x64-msvc": "0.1.4-pre.10",
66
+ "@tursodatabase/database-darwin-universal": "0.1.4-pre.10",
67
+ "@tursodatabase/database-wasm32-wasi": "0.1.4-pre.10"
68
+ }
69
+ }