@tursodatabase/sync-wasm 0.2.0-pre.11

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 (40) hide show
  1. package/README.md +124 -0
  2. package/bundle/main.es.js +9311 -0
  3. package/dist/index-bundle.d.ts +17 -0
  4. package/dist/index-bundle.d.ts.map +1 -0
  5. package/dist/index-bundle.js +28 -0
  6. package/dist/index-default.d.ts +17 -0
  7. package/dist/index-default.d.ts.map +1 -0
  8. package/dist/index-default.js +26 -0
  9. package/dist/index-turbopack-hack.d.ts +17 -0
  10. package/dist/index-turbopack-hack.d.ts.map +1 -0
  11. package/dist/index-turbopack-hack.js +28 -0
  12. package/dist/index-vite-dev-hack.d.ts +31 -0
  13. package/dist/index-vite-dev-hack.d.ts.map +1 -0
  14. package/dist/index-vite-dev-hack.js +52 -0
  15. package/dist/promise-bundle.d.ts +43 -0
  16. package/dist/promise-bundle.d.ts.map +1 -0
  17. package/dist/promise-bundle.js +153 -0
  18. package/dist/promise-default.d.ts +43 -0
  19. package/dist/promise-default.d.ts.map +1 -0
  20. package/dist/promise-default.js +153 -0
  21. package/dist/promise-turbopack-hack.d.ts +43 -0
  22. package/dist/promise-turbopack-hack.d.ts.map +1 -0
  23. package/dist/promise-turbopack-hack.js +153 -0
  24. package/dist/promise-vite-dev-hack.d.ts +43 -0
  25. package/dist/promise-vite-dev-hack.d.ts.map +1 -0
  26. package/dist/promise-vite-dev-hack.js +153 -0
  27. package/dist/promise.test.d.ts +2 -0
  28. package/dist/promise.test.d.ts.map +1 -0
  29. package/dist/promise.test.js +431 -0
  30. package/dist/sync.wasm32-wasi.wasm +0 -0
  31. package/dist/vitest.config.d.ts +3 -0
  32. package/dist/vitest.config.d.ts.map +1 -0
  33. package/dist/vitest.config.js +22 -0
  34. package/dist/wasm-inline.d.ts +2 -0
  35. package/dist/wasm-inline.d.ts.map +1 -0
  36. package/dist/wasm-inline.js +8 -0
  37. package/dist/worker.d.ts +2 -0
  38. package/dist/worker.d.ts.map +1 -0
  39. package/dist/worker.js +2 -0
  40. package/package.json +61 -0
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ <p align="center">
2
+ <h1 align="center">Turso Database for JavaScript in Browser</h1>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a title="JavaScript" target="_blank" href="https://www.npmjs.com/package/@tursodatabase/database"><img alt="npm" src="https://img.shields.io/npm/v/@tursodatabase/database"></a>
7
+ <a title="MIT" target="_blank" href="https://github.com/tursodatabase/turso/blob/main/LICENSE.md"><img src="http://img.shields.io/badge/license-MIT-orange.svg?style=flat-square"></a>
8
+ </p>
9
+ <p align="center">
10
+ <a title="Users Discord" target="_blank" href="https://tur.so/discord"><img alt="Chat with other users of Turso on Discord" src="https://img.shields.io/discord/933071162680958986?label=Discord&logo=Discord&style=social"></a>
11
+ </p>
12
+
13
+ ---
14
+
15
+ ## About
16
+
17
+ This package is the Turso embedded database library for JavaScript in Browser.
18
+
19
+ > **⚠️ Warning:** This software is ALPHA, only use for development, testing, and experimentation. We are working to make it production ready, but do not use it for critical data right now.
20
+
21
+ ## Features
22
+
23
+ - **SQLite compatible:** SQLite query language and file format support ([status](https://github.com/tursodatabase/turso/blob/main/COMPAT.md)).
24
+ - **In-process**: No network overhead, runs directly in your Node.js process
25
+ - **TypeScript support**: Full TypeScript definitions included
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @tursodatabase/database-wasm
31
+ ```
32
+
33
+ ## Getting Started
34
+
35
+ ### In-Memory Database
36
+
37
+ ```javascript
38
+ import { connect } from '@tursodatabase/database-wasm';
39
+
40
+ // Create an in-memory database
41
+ const db = await connect(':memory:');
42
+
43
+ // Create a table
44
+ await db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');
45
+
46
+ // Insert data
47
+ const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
48
+ await insert.run('Alice', 'alice@example.com');
49
+ await insert.run('Bob', 'bob@example.com');
50
+
51
+ // Query data
52
+ const users = await db.prepare('SELECT * FROM users').all();
53
+ console.log(users);
54
+ // Output: [
55
+ // { id: 1, name: 'Alice', email: 'alice@example.com' },
56
+ // { id: 2, name: 'Bob', email: 'bob@example.com' }
57
+ // ]
58
+ ```
59
+
60
+ ### File-Based Database
61
+
62
+ ```javascript
63
+ import { connect } from '@tursodatabase/database-wasm';
64
+
65
+ // Create or open a database file
66
+ const db = await connect('my-database.db');
67
+
68
+ // Create a table
69
+ await db.exec(`
70
+ CREATE TABLE IF NOT EXISTS posts (
71
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
72
+ title TEXT NOT NULL,
73
+ content TEXT,
74
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
75
+ )
76
+ `);
77
+
78
+ // Insert a post
79
+ const insertPost = db.prepare('INSERT INTO posts (title, content) VALUES (?, ?)');
80
+ const result = await insertPost.run('Hello World', 'This is my first blog post!');
81
+
82
+ console.log(`Inserted post with ID: ${result.lastInsertRowid}`);
83
+ ```
84
+
85
+ ### Transactions
86
+
87
+ ```javascript
88
+ import { connect } from '@tursodatabase/database-wasm';
89
+
90
+ const db = await connect('transactions.db');
91
+
92
+ // Using transactions for atomic operations
93
+ const transaction = db.transaction(async (users) => {
94
+ const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)');
95
+ for (const user of users) {
96
+ await insert.run(user.name, user.email);
97
+ }
98
+ });
99
+
100
+ // Execute transaction
101
+ await transaction([
102
+ { name: 'Alice', email: 'alice@example.com' },
103
+ { name: 'Bob', email: 'bob@example.com' }
104
+ ]);
105
+ ```
106
+
107
+ ## API Reference
108
+
109
+ For complete API documentation, see [JavaScript API Reference](../../../../docs/javascript-api-reference.md).
110
+
111
+ ## Related Packages
112
+
113
+ * The [@tursodatabase/serverless](https://www.npmjs.com/package/@tursodatabase/serverless) package provides a serverless driver with the same API.
114
+ * The [@tursodatabase/sync](https://www.npmjs.com/package/@tursodatabase/sync) package provides bidirectional sync between a local Turso database and Turso Cloud.
115
+
116
+ ## License
117
+
118
+ This project is licensed under the [MIT license](../../LICENSE.md).
119
+
120
+ ## Support
121
+
122
+ - [GitHub Issues](https://github.com/tursodatabase/turso/issues)
123
+ - [Documentation](https://docs.turso.tech)
124
+ - [Discord Community](https://tur.so/discord)