@taladb/web 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 thinkgrid-labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # @taladb/web
2
+
3
+ Browser WASM bindings for TalaDB — persistent local-first storage via WASM + OPFS.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@taladb/web)](https://www.npmjs.com/package/@taladb/web)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-orange.svg)](LICENSE)
7
+
8
+ > **Note:** Most users should install [`taladb`](https://www.npmjs.com/package/taladb) instead, which auto-selects this package when running in the browser.
9
+
10
+ ## What it provides
11
+
12
+ - Rust core compiled to WebAssembly via `wasm-bindgen`
13
+ - Persistent storage using [OPFS](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system) (`FileSystemSyncAccessHandle`) — runs on a dedicated SharedWorker so the main thread is never blocked
14
+ - In-memory fallback for environments without OPFS support
15
+ - Bundle size target: < 400 KB gzipped
16
+
17
+ ## Browser support
18
+
19
+ | Browser | OPFS (persistent) | In-memory fallback |
20
+ |---------|-------------------|-------------------|
21
+ | Chrome 109+ | ✅ | ✅ |
22
+ | Safari 16.4+ | ✅ | ✅ |
23
+ | Firefox | — | ✅ |
24
+ | Edge 109+ | ✅ | ✅ |
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pnpm add taladb @taladb/web
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ Use through the unified [`taladb`](https://www.npmjs.com/package/taladb) package:
35
+
36
+ ```ts
37
+ import { openDB } from 'taladb';
38
+
39
+ const db = await openDB('myapp.db');
40
+ const col = db.collection('notes');
41
+
42
+ await col.insert({ title: 'Hello', body: 'World' });
43
+ const notes = await col.find();
44
+ ```
45
+
46
+ ### Vite setup
47
+
48
+ ```ts
49
+ // vite.config.ts
50
+ import { defineConfig } from 'vite';
51
+
52
+ export default defineConfig({
53
+ optimizeDeps: {
54
+ exclude: ['@taladb/web'],
55
+ },
56
+ });
57
+ ```
58
+
59
+ ### Web Worker (OPFS)
60
+
61
+ TalaDB spawns a SharedWorker internally to own the OPFS file handle. No extra configuration is required — the worker script is bundled inside this package at `@taladb/web/worker/taladb.worker.js`.
62
+
63
+ ## Direct usage (advanced)
64
+
65
+ If you need to use the WASM bindings directly:
66
+
67
+ ```ts
68
+ import init, { TalaDBWasm } from '@taladb/web';
69
+
70
+ await init();
71
+
72
+ const db = TalaDBWasm.openInMemory();
73
+ const col = db.collection('items');
74
+ col.insert({ x: 1 });
75
+ ```
76
+
77
+ ## Building from source
78
+
79
+ ```bash
80
+ # Install wasm-pack
81
+ cargo install wasm-pack
82
+
83
+ # Build
84
+ pnpm --filter @taladb/web build
85
+ ```
86
+
87
+ ## Full Documentation
88
+
89
+ **[https://thinkgrid-labs.github.io/taladb/guide/web](https://thinkgrid-labs.github.io/taladb/guide/web)**
90
+
91
+ ## License
92
+
93
+ MIT © [ThinkGrid Labs](https://github.com/thinkgrid-labs)
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@taladb/web",
3
+ "version": "0.1.0",
4
+ "description": "TalaDB WASM bindings for browser (wasm-bindgen + OPFS SharedWorker)",
5
+ "main": "pkg/taladb_web.js",
6
+ "types": "pkg/taladb_web.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./pkg/taladb_web.js",
10
+ "types": "./pkg/taladb_web.d.ts"
11
+ },
12
+ "./pkg/*": "./pkg/*",
13
+ "./worker/*": "./worker/*"
14
+ },
15
+ "files": [
16
+ "pkg/",
17
+ "worker/"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/thinkgrid-labs/taladb.git",
22
+ "directory": "packages/taladb-web"
23
+ },
24
+ "homepage": "https://thinkgrid-labs.github.io/taladb/guide/web",
25
+ "bugs": {
26
+ "url": "https://github.com/thinkgrid-labs/taladb/issues"
27
+ },
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "license": "MIT",
32
+ "scripts": {
33
+ "build": "wasm-pack build --target web --out-dir pkg --release",
34
+ "build:dev": "wasm-pack build --target web --out-dir pkg --dev",
35
+ "test": "wasm-pack test --headless --chrome"
36
+ }
37
+ }
package/pkg/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # @taladb/web
2
+
3
+ Browser WASM bindings for TalaDB — persistent local-first storage via WASM + OPFS.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@taladb/web)](https://www.npmjs.com/package/@taladb/web)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-orange.svg)](LICENSE)
7
+
8
+ > **Note:** Most users should install [`taladb`](https://www.npmjs.com/package/taladb) instead, which auto-selects this package when running in the browser.
9
+
10
+ ## What it provides
11
+
12
+ - Rust core compiled to WebAssembly via `wasm-bindgen`
13
+ - Persistent storage using [OPFS](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system) (`FileSystemSyncAccessHandle`) — runs on a dedicated SharedWorker so the main thread is never blocked
14
+ - In-memory fallback for environments without OPFS support
15
+ - Bundle size target: < 400 KB gzipped
16
+
17
+ ## Browser support
18
+
19
+ | Browser | OPFS (persistent) | In-memory fallback |
20
+ |---------|-------------------|-------------------|
21
+ | Chrome 109+ | ✅ | ✅ |
22
+ | Safari 16.4+ | ✅ | ✅ |
23
+ | Firefox | — | ✅ |
24
+ | Edge 109+ | ✅ | ✅ |
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pnpm add taladb @taladb/web
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ Use through the unified [`taladb`](https://www.npmjs.com/package/taladb) package:
35
+
36
+ ```ts
37
+ import { openDB } from 'taladb';
38
+
39
+ const db = await openDB('myapp.db');
40
+ const col = db.collection('notes');
41
+
42
+ await col.insert({ title: 'Hello', body: 'World' });
43
+ const notes = await col.find();
44
+ ```
45
+
46
+ ### Vite setup
47
+
48
+ ```ts
49
+ // vite.config.ts
50
+ import { defineConfig } from 'vite';
51
+
52
+ export default defineConfig({
53
+ optimizeDeps: {
54
+ exclude: ['@taladb/web'],
55
+ },
56
+ });
57
+ ```
58
+
59
+ ### Web Worker (OPFS)
60
+
61
+ TalaDB spawns a SharedWorker internally to own the OPFS file handle. No extra configuration is required — the worker script is bundled inside this package at `@taladb/web/worker/taladb.worker.js`.
62
+
63
+ ## Direct usage (advanced)
64
+
65
+ If you need to use the WASM bindings directly:
66
+
67
+ ```ts
68
+ import init, { TalaDBWasm } from '@taladb/web';
69
+
70
+ await init();
71
+
72
+ const db = TalaDBWasm.openInMemory();
73
+ const col = db.collection('items');
74
+ col.insert({ x: 1 });
75
+ ```
76
+
77
+ ## Building from source
78
+
79
+ ```bash
80
+ # Install wasm-pack
81
+ cargo install wasm-pack
82
+
83
+ # Build
84
+ pnpm --filter @taladb/web build
85
+ ```
86
+
87
+ ## Full Documentation
88
+
89
+ **[https://thinkgrid-labs.github.io/taladb/guide/web](https://thinkgrid-labs.github.io/taladb/guide/web)**
90
+
91
+ ## License
92
+
93
+ MIT © [ThinkGrid Labs](https://github.com/thinkgrid-labs)