@plures/pluresdb 1.6.10 → 2.9.6
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 +97 -289
- package/crates/README.md +99 -0
- package/crates/pluresdb-node/README.md +181 -0
- package/crates/pluresdb-node/index.d.ts +0 -0
- package/crates/pluresdb-node/index.js +265 -0
- package/crates/pluresdb-node/package.json +35 -0
- package/dist/napi/index.js +60 -0
- package/embedded.d.ts +1 -0
- package/embedded.js +46 -0
- package/package.json +20 -9
- package/dist/.tsbuildinfo +0 -1
- package/dist/better-sqlite3-shared.d.ts +0 -12
- package/dist/better-sqlite3-shared.d.ts.map +0 -1
- package/dist/better-sqlite3-shared.js +0 -143
- package/dist/better-sqlite3-shared.js.map +0 -1
- package/dist/better-sqlite3.d.ts +0 -4
- package/dist/better-sqlite3.d.ts.map +0 -1
- package/dist/better-sqlite3.js +0 -8
- package/dist/better-sqlite3.js.map +0 -1
- package/dist/cli.d.ts +0 -7
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/local-first/unified-api.d.ts +0 -110
- package/dist/local-first/unified-api.d.ts.map +0 -1
- package/dist/local-first/unified-api.js +0 -348
- package/dist/local-first/unified-api.js.map +0 -1
- package/dist/node-index.d.ts +0 -150
- package/dist/node-index.d.ts.map +0 -1
- package/dist/node-index.js +0 -668
- package/dist/node-index.js.map +0 -1
- package/dist/node-wrapper.d.ts +0 -44
- package/dist/node-wrapper.d.ts.map +0 -1
- package/dist/node-wrapper.js +0 -296
- package/dist/node-wrapper.js.map +0 -1
- package/dist/types/index.d.ts +0 -28
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/types/node-types.d.ts +0 -71
- package/dist/types/node-types.d.ts.map +0 -1
- package/dist/types/node-types.js +0 -6
- package/dist/types/node-types.js.map +0 -1
- package/dist/util/debug.d.ts +0 -3
- package/dist/util/debug.d.ts.map +0 -1
- package/dist/util/debug.js +0 -34
- package/dist/util/debug.js.map +0 -1
- package/dist/vscode/extension.d.ts +0 -81
- package/dist/vscode/extension.d.ts.map +0 -1
- package/dist/vscode/extension.js +0 -309
- package/dist/vscode/extension.js.map +0 -1
- package/examples/basic-usage.d.ts +0 -2
- package/examples/basic-usage.d.ts.map +0 -1
- package/examples/basic-usage.js +0 -26
- package/examples/basic-usage.js.map +0 -1
- package/examples/basic-usage.ts +0 -29
- package/examples/browser-demo/README.md +0 -204
- package/examples/browser-demo/index.html +0 -466
- package/examples/browser-wasm-integration.md +0 -411
- package/examples/ipc-demo/README.md +0 -127
- package/examples/local-first-usage.ts +0 -138
- package/examples/native-ipc-integration.md +0 -526
- package/examples/tauri-demo/README.md +0 -240
- package/examples/tauri-integration.md +0 -260
- package/examples/vscode-extension-example/README.md +0 -95
- package/examples/vscode-extension-example/package.json +0 -49
- package/examples/vscode-extension-example/src/extension.ts +0 -172
- package/examples/vscode-extension-example/tsconfig.json +0 -12
- package/examples/vscode-extension-integration.d.ts +0 -31
- package/examples/vscode-extension-integration.d.ts.map +0 -1
- package/examples/vscode-extension-integration.js +0 -319
- package/examples/vscode-extension-integration.js.map +0 -1
- package/examples/vscode-extension-integration.ts +0 -41
- package/legacy/benchmarks/memory-benchmarks.ts +0 -350
- package/legacy/benchmarks/run-benchmarks.ts +0 -315
- package/legacy/better-sqlite3-shared.ts +0 -157
- package/legacy/better-sqlite3.ts +0 -4
- package/legacy/cli.ts +0 -241
- package/legacy/config.ts +0 -50
- package/legacy/core/crdt.ts +0 -107
- package/legacy/core/database.ts +0 -529
- package/legacy/healthcheck.ts +0 -162
- package/legacy/http/api-server.ts +0 -569
- package/legacy/index.ts +0 -31
- package/legacy/local-first/unified-api.ts +0 -449
- package/legacy/logic/rules.ts +0 -46
- package/legacy/main.rs +0 -3
- package/legacy/main.ts +0 -197
- package/legacy/network/websocket-server.ts +0 -115
- package/legacy/node-index.ts +0 -827
- package/legacy/node-wrapper.ts +0 -329
- package/legacy/plugins/README.md +0 -181
- package/legacy/plugins/example-embedding-plugin.ts +0 -56
- package/legacy/plugins/plugin-system.ts +0 -315
- package/legacy/sqlite-compat.ts +0 -633
- package/legacy/sqlite3-compat.ts +0 -55
- package/legacy/storage/kv-storage.ts +0 -73
- package/legacy/tests/core.test.ts +0 -305
- package/legacy/tests/fixtures/performance-data.json +0 -71
- package/legacy/tests/fixtures/test-data.json +0 -129
- package/legacy/tests/integration/api-server.test.ts +0 -334
- package/legacy/tests/integration/mesh-network.test.ts +0 -303
- package/legacy/tests/logic.test.ts +0 -34
- package/legacy/tests/performance/load.test.ts +0 -290
- package/legacy/tests/security/input-validation.test.ts +0 -286
- package/legacy/tests/unit/core.test.ts +0 -226
- package/legacy/tests/unit/local-first-api.test.ts +0 -65
- package/legacy/tests/unit/plugin-system.test.ts +0 -388
- package/legacy/tests/unit/subscriptions.test.ts +0 -135
- package/legacy/tests/unit/vector-search.test.ts +0 -173
- package/legacy/tests/vscode_extension_test.ts +0 -281
- package/legacy/types/index.ts +0 -32
- package/legacy/types/node-types.ts +0 -80
- package/legacy/util/debug.ts +0 -27
- package/legacy/vector/index.ts +0 -59
- package/legacy/vscode/extension.ts +0 -387
- package/scripts/compiled-crud-verify.ts +0 -30
- package/scripts/dogfood.ts +0 -297
- package/scripts/postinstall.js +0 -156
- package/scripts/publish-crates.sh +0 -95
- package/scripts/release-check.js +0 -224
- package/scripts/run-tests.ts +0 -178
- package/scripts/setup-libclang.ps1 +0 -209
- package/scripts/update-changelog.js +0 -214
- package/scripts/validate-npm-publish.js +0 -228
- package/web/README.md +0 -27
- package/web/svelte/package.json +0 -31
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
# PluresDB Tauri Demo
|
|
2
|
-
|
|
3
|
-
A complete example of integrating PluresDB into a Tauri application for local-first desktop database access.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🚀 **Native Performance**: Direct Rust-to-Rust integration
|
|
8
|
-
- 💾 **Local-First**: All data stored locally with no network dependency
|
|
9
|
-
- 🔒 **Secure**: No exposed ports, OS-level security
|
|
10
|
-
- ⚡ **Fast**: ~0.05ms latency, 200k+ ops/s throughput
|
|
11
|
-
|
|
12
|
-
## Project Structure
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
tauri-demo/
|
|
16
|
-
├── src-tauri/ # Rust backend
|
|
17
|
-
│ ├── src/
|
|
18
|
-
│ │ └── main.rs # Tauri app with PluresDB commands
|
|
19
|
-
│ ├── Cargo.toml # Rust dependencies
|
|
20
|
-
│ └── tauri.conf.json # Tauri configuration
|
|
21
|
-
├── src/ # Frontend (HTML/JS/TS)
|
|
22
|
-
│ ├── index.html
|
|
23
|
-
│ └── main.js
|
|
24
|
-
└── README.md
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Quick Start
|
|
28
|
-
|
|
29
|
-
### Prerequisites
|
|
30
|
-
|
|
31
|
-
- Rust and Cargo installed
|
|
32
|
-
- Node.js and npm (for frontend tooling)
|
|
33
|
-
- Tauri CLI: `cargo install tauri-cli`
|
|
34
|
-
|
|
35
|
-
### Installation
|
|
36
|
-
|
|
37
|
-
1. Navigate to this directory:
|
|
38
|
-
```bash
|
|
39
|
-
cd examples/tauri-demo
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
2. Install dependencies:
|
|
43
|
-
```bash
|
|
44
|
-
npm install
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
3. Run the app:
|
|
48
|
-
```bash
|
|
49
|
-
cargo tauri dev
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Implementation Guide
|
|
53
|
-
|
|
54
|
-
### 1. Add PluresDB to Cargo.toml
|
|
55
|
-
|
|
56
|
-
```toml
|
|
57
|
-
[dependencies]
|
|
58
|
-
pluresdb-core = "1.6"
|
|
59
|
-
tauri = { version = "1.5", features = ["api-all"] }
|
|
60
|
-
serde = { version = "1.0", features = ["derive"] }
|
|
61
|
-
serde_json = "1.0"
|
|
62
|
-
parking_lot = "0.12"
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### 2. Create Tauri Commands (src-tauri/src/main.rs)
|
|
66
|
-
|
|
67
|
-
```rust
|
|
68
|
-
use pluresdb_core::{CrdtStore, CrdtNode};
|
|
69
|
-
use parking_lot::Mutex;
|
|
70
|
-
use std::sync::Arc;
|
|
71
|
-
use tauri::State;
|
|
72
|
-
|
|
73
|
-
struct AppState {
|
|
74
|
-
db: Arc<Mutex<CrdtStore>>,
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
#[tauri::command]
|
|
78
|
-
async fn pluresdb_put(
|
|
79
|
-
state: State<'_, AppState>,
|
|
80
|
-
id: String,
|
|
81
|
-
data: serde_json::Value,
|
|
82
|
-
) -> Result<String, String> {
|
|
83
|
-
let mut db = state.db.lock();
|
|
84
|
-
let node_id = db.put(id, "tauri".to_string(), data);
|
|
85
|
-
Ok(node_id)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
#[tauri::command]
|
|
89
|
-
async fn pluresdb_get(
|
|
90
|
-
state: State<'_, AppState>,
|
|
91
|
-
id: String,
|
|
92
|
-
) -> Result<Option<serde_json::Value>, String> {
|
|
93
|
-
let db = state.db.lock();
|
|
94
|
-
match db.get(id) {
|
|
95
|
-
Some(record) => Ok(Some(record.data)),
|
|
96
|
-
None => Ok(None),
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
#[tauri::command]
|
|
101
|
-
async fn pluresdb_delete(
|
|
102
|
-
state: State<'_, AppState>,
|
|
103
|
-
id: String,
|
|
104
|
-
) -> Result<(), String> {
|
|
105
|
-
let mut db = state.db.lock();
|
|
106
|
-
db.delete(&id).map_err(|e| e.to_string())
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
#[tauri::command]
|
|
110
|
-
async fn pluresdb_list(
|
|
111
|
-
state: State<'_, AppState>,
|
|
112
|
-
) -> Result<Vec<serde_json::Value>, String> {
|
|
113
|
-
let db = state.db.lock();
|
|
114
|
-
let records = db.list();
|
|
115
|
-
let items: Vec<serde_json::Value> = records
|
|
116
|
-
.into_iter()
|
|
117
|
-
.map(|r| serde_json::json!({ "id": r.id, "data": r.data }))
|
|
118
|
-
.collect();
|
|
119
|
-
Ok(items)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
fn main() {
|
|
123
|
-
// Initialize database
|
|
124
|
-
let db = Arc::new(Mutex::new(CrdtStore::default()));
|
|
125
|
-
|
|
126
|
-
tauri::Builder::default()
|
|
127
|
-
.manage(AppState { db })
|
|
128
|
-
.invoke_handler(tauri::generate_handler![
|
|
129
|
-
pluresdb_put,
|
|
130
|
-
pluresdb_get,
|
|
131
|
-
pluresdb_delete,
|
|
132
|
-
pluresdb_list,
|
|
133
|
-
])
|
|
134
|
-
.run(tauri::generate_context!())
|
|
135
|
-
.expect("error while running tauri application");
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### 3. Frontend Integration (src/main.js)
|
|
140
|
-
|
|
141
|
-
```javascript
|
|
142
|
-
const { invoke } = window.__TAURI__.tauri;
|
|
143
|
-
|
|
144
|
-
class PluresDBTauri {
|
|
145
|
-
async put(id, data) {
|
|
146
|
-
return await invoke("pluresdb_put", { id, data });
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
async get(id) {
|
|
150
|
-
return await invoke("pluresdb_get", { id });
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async delete(id) {
|
|
154
|
-
await invoke("pluresdb_delete", { id });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async list() {
|
|
158
|
-
return await invoke("pluresdb_list");
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Usage
|
|
163
|
-
const db = new PluresDBTauri();
|
|
164
|
-
|
|
165
|
-
async function demo() {
|
|
166
|
-
// Insert data
|
|
167
|
-
await db.put("user:1", {
|
|
168
|
-
name: "Alice",
|
|
169
|
-
email: "alice@example.com"
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// Retrieve data
|
|
173
|
-
const user = await db.get("user:1");
|
|
174
|
-
console.log("User:", user);
|
|
175
|
-
|
|
176
|
-
// List all
|
|
177
|
-
const all = await db.list();
|
|
178
|
-
console.log("All records:", all.length);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
demo();
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Building for Production
|
|
185
|
-
|
|
186
|
-
### Development Build
|
|
187
|
-
```bash
|
|
188
|
-
cargo tauri dev
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Production Build
|
|
192
|
-
```bash
|
|
193
|
-
cargo tauri build
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
This creates:
|
|
197
|
-
- **macOS**: `.app` bundle and `.dmg` installer
|
|
198
|
-
- **Windows**: `.exe` installer and `.msi` package
|
|
199
|
-
- **Linux**: `.AppImage` and `.deb` package
|
|
200
|
-
|
|
201
|
-
## Performance Benchmarks
|
|
202
|
-
|
|
203
|
-
| Operation | Latency | Throughput |
|
|
204
|
-
|-----------|---------|------------|
|
|
205
|
-
| PUT | ~0.05ms | ~200k ops/s |
|
|
206
|
-
| GET | ~0.03ms | ~300k ops/s |
|
|
207
|
-
| DELETE | ~0.04ms | ~250k ops/s |
|
|
208
|
-
| LIST | ~1ms | ~20k ops/s |
|
|
209
|
-
|
|
210
|
-
**vs. HTTP REST API**:
|
|
211
|
-
- 100x lower latency
|
|
212
|
-
- 200x higher throughput
|
|
213
|
-
- No network overhead
|
|
214
|
-
- No security risks from exposed ports
|
|
215
|
-
|
|
216
|
-
## Features Demonstrated
|
|
217
|
-
|
|
218
|
-
- ✅ Basic CRUD operations (put, get, delete, list)
|
|
219
|
-
- ✅ Real-time updates (CRDT-based)
|
|
220
|
-
- ✅ Persistent storage (file-based)
|
|
221
|
-
- ✅ TypeScript support (type definitions)
|
|
222
|
-
- ✅ Error handling
|
|
223
|
-
- ✅ Cross-platform builds
|
|
224
|
-
|
|
225
|
-
## Next Steps
|
|
226
|
-
|
|
227
|
-
1. Add vector search: `pluresdb_vector_search` command
|
|
228
|
-
2. Add P2P sync: Connect to remote peers
|
|
229
|
-
3. Add encryption: E2E encrypted data sharing
|
|
230
|
-
4. Add authentication: User management
|
|
231
|
-
|
|
232
|
-
## Resources
|
|
233
|
-
|
|
234
|
-
- [Tauri Documentation](https://tauri.app/v1/guides/)
|
|
235
|
-
- [PluresDB Documentation](../../docs/)
|
|
236
|
-
- [Local-First Integration Guide](../../docs/LOCAL_FIRST_INTEGRATION.md)
|
|
237
|
-
|
|
238
|
-
## License
|
|
239
|
-
|
|
240
|
-
This example is part of PluresDB and is licensed under AGPL-3.0.
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
# Tauri Integration Example
|
|
2
|
-
|
|
3
|
-
This example demonstrates how to integrate PluresDB directly into a Tauri application without any network overhead.
|
|
4
|
-
|
|
5
|
-
## Architecture
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
┌─────────────────────────────────────┐
|
|
9
|
-
│ Tauri Frontend (HTML/JS/TS) │
|
|
10
|
-
│ │
|
|
11
|
-
│ PluresDBLocalFirst (auto-detect) │
|
|
12
|
-
└──────────────┬──────────────────────┘
|
|
13
|
-
│ Tauri IPC
|
|
14
|
-
│ (in-process, no network)
|
|
15
|
-
┌──────────────▼──────────────────────┐
|
|
16
|
-
│ Tauri Backend (Rust) │
|
|
17
|
-
│ │
|
|
18
|
-
│ pluresdb-core │
|
|
19
|
-
│ pluresdb-storage │
|
|
20
|
-
│ pluresdb-sync │
|
|
21
|
-
└─────────────────────────────────────┘
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Setup
|
|
25
|
-
|
|
26
|
-
### 1. Create Tauri App
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm create tauri-app@latest my-pluresdb-app
|
|
30
|
-
cd my-pluresdb-app
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### 2. Add PluresDB Dependencies
|
|
34
|
-
|
|
35
|
-
Add to `src-tauri/Cargo.toml`:
|
|
36
|
-
|
|
37
|
-
```toml
|
|
38
|
-
[dependencies]
|
|
39
|
-
pluresdb-core = "0.1"
|
|
40
|
-
pluresdb-storage = "0.1"
|
|
41
|
-
pluresdb-sync = "0.1"
|
|
42
|
-
serde = { version = "1.0", features = ["derive"] }
|
|
43
|
-
serde_json = "1.0"
|
|
44
|
-
tauri = { version = "1.5", features = ["shell-open"] }
|
|
45
|
-
parking_lot = "0.12"
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### 3. Implement Tauri Commands
|
|
49
|
-
|
|
50
|
-
Edit `src-tauri/src/main.rs`:
|
|
51
|
-
|
|
52
|
-
```rust
|
|
53
|
-
// Prevents additional console window on Windows in release
|
|
54
|
-
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
55
|
-
|
|
56
|
-
use pluresdb_core::{Database, DatabaseOptions, CrdtStore};
|
|
57
|
-
use serde_json::Value;
|
|
58
|
-
use std::sync::Arc;
|
|
59
|
-
use parking_lot::Mutex;
|
|
60
|
-
use tauri::State;
|
|
61
|
-
|
|
62
|
-
// Application state holding the database instance
|
|
63
|
-
struct AppState {
|
|
64
|
-
db: Arc<Mutex<CrdtStore>>,
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
#[tauri::command]
|
|
68
|
-
async fn pluresdb_put(
|
|
69
|
-
state: State<'_, AppState>,
|
|
70
|
-
id: String,
|
|
71
|
-
data: Value,
|
|
72
|
-
) -> Result<String, String> {
|
|
73
|
-
let db = state.db.lock();
|
|
74
|
-
let node_id = db.put(id.clone(), "tauri-app".to_string(), data);
|
|
75
|
-
Ok(node_id)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
#[tauri::command]
|
|
79
|
-
async fn pluresdb_get(
|
|
80
|
-
state: State<'_, AppState>,
|
|
81
|
-
id: String,
|
|
82
|
-
) -> Result<Option<Value>, String> {
|
|
83
|
-
let db = state.db.lock();
|
|
84
|
-
match db.get(id) {
|
|
85
|
-
Some(record) => Ok(Some(record.data)),
|
|
86
|
-
None => Ok(None),
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#[tauri::command]
|
|
91
|
-
async fn pluresdb_delete(
|
|
92
|
-
state: State<'_, AppState>,
|
|
93
|
-
id: String,
|
|
94
|
-
) -> Result<(), String> {
|
|
95
|
-
let db = state.db.lock();
|
|
96
|
-
db.delete(&id).map_err(|e| e.to_string())
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
#[tauri::command]
|
|
100
|
-
async fn pluresdb_list(
|
|
101
|
-
state: State<'_, AppState>,
|
|
102
|
-
) -> Result<Vec<Value>, String> {
|
|
103
|
-
let db = state.db.lock();
|
|
104
|
-
let records = db.list();
|
|
105
|
-
|
|
106
|
-
let result = records
|
|
107
|
-
.into_iter()
|
|
108
|
-
.map(|record| {
|
|
109
|
-
serde_json::json!({
|
|
110
|
-
"id": record.id,
|
|
111
|
-
"data": record.data,
|
|
112
|
-
"timestamp": record.timestamp.to_rfc3339(),
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
.collect();
|
|
116
|
-
|
|
117
|
-
Ok(result)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
#[tauri::command]
|
|
121
|
-
async fn pluresdb_vector_search(
|
|
122
|
-
state: State<'_, AppState>,
|
|
123
|
-
query: String,
|
|
124
|
-
limit: usize,
|
|
125
|
-
) -> Result<Vec<Value>, String> {
|
|
126
|
-
// Vector search implementation will be added in future update
|
|
127
|
-
// For now, return empty results
|
|
128
|
-
Ok(vec![])
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
fn main() {
|
|
132
|
-
// Initialize database
|
|
133
|
-
let db = CrdtStore::default();
|
|
134
|
-
|
|
135
|
-
tauri::Builder::default()
|
|
136
|
-
.manage(AppState {
|
|
137
|
-
db: Arc::new(Mutex::new(db)),
|
|
138
|
-
})
|
|
139
|
-
.invoke_handler(tauri::generate_handler![
|
|
140
|
-
pluresdb_put,
|
|
141
|
-
pluresdb_get,
|
|
142
|
-
pluresdb_delete,
|
|
143
|
-
pluresdb_list,
|
|
144
|
-
pluresdb_vector_search,
|
|
145
|
-
])
|
|
146
|
-
.run(tauri::generate_context!())
|
|
147
|
-
.expect("error while running tauri application");
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### 4. Use in Frontend
|
|
152
|
-
|
|
153
|
-
Install PluresDB in your frontend:
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
npm install @plures/pluresdb
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
Then use it in your frontend code (e.g., `src/App.tsx` or `src/main.js`):
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
import { PluresDBLocalFirst } from "@plures/pluresdb/local-first";
|
|
163
|
-
|
|
164
|
-
// Auto-detects Tauri environment and uses native integration
|
|
165
|
-
const db = new PluresDBLocalFirst({ mode: "auto" });
|
|
166
|
-
|
|
167
|
-
async function main() {
|
|
168
|
-
// Insert data
|
|
169
|
-
await db.put("user:1", {
|
|
170
|
-
name: "Alice",
|
|
171
|
-
email: "alice@example.com",
|
|
172
|
-
role: "admin",
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Retrieve data
|
|
176
|
-
const user = await db.get("user:1");
|
|
177
|
-
console.log("User:", user);
|
|
178
|
-
|
|
179
|
-
// List all nodes
|
|
180
|
-
const allNodes = await db.list();
|
|
181
|
-
console.log("Total nodes:", allNodes.length);
|
|
182
|
-
|
|
183
|
-
// Delete data
|
|
184
|
-
await db.delete("user:1");
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
main().catch(console.error);
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
## Performance Benefits
|
|
191
|
-
|
|
192
|
-
Compared to network-based integration:
|
|
193
|
-
|
|
194
|
-
| Metric | Network Mode | Tauri Mode | Improvement |
|
|
195
|
-
|--------|--------------|------------|-------------|
|
|
196
|
-
| **Latency** | ~5-10ms | ~0.05ms | **100-200x faster** |
|
|
197
|
-
| **Throughput** | ~1k ops/s | ~200k ops/s | **200x faster** |
|
|
198
|
-
| **Memory** | 2 processes | 1 process | **50% reduction** |
|
|
199
|
-
| **Security** | Exposed port | No network | **No attack surface** |
|
|
200
|
-
|
|
201
|
-
## Features
|
|
202
|
-
|
|
203
|
-
✅ **Zero Network Overhead**: Direct in-process communication
|
|
204
|
-
✅ **Native Performance**: Rust speed with JavaScript convenience
|
|
205
|
-
✅ **Type Safety**: Full TypeScript support
|
|
206
|
-
✅ **Offline-First**: No server required
|
|
207
|
-
✅ **Persistent Storage**: Data saved to filesystem
|
|
208
|
-
✅ **Cross-Platform**: Works on Windows, macOS, Linux
|
|
209
|
-
|
|
210
|
-
## Advanced: With Persistent Storage
|
|
211
|
-
|
|
212
|
-
To enable file-based persistence:
|
|
213
|
-
|
|
214
|
-
```rust
|
|
215
|
-
// In main.rs
|
|
216
|
-
use pluresdb_core::DatabaseOptions;
|
|
217
|
-
|
|
218
|
-
fn main() {
|
|
219
|
-
// Use file-based storage instead of in-memory
|
|
220
|
-
let options = DatabaseOptions::with_file("./data/plures.db")
|
|
221
|
-
.create_if_missing(true);
|
|
222
|
-
|
|
223
|
-
let db = Database::open(options)
|
|
224
|
-
.expect("Failed to open database");
|
|
225
|
-
|
|
226
|
-
tauri::Builder::default()
|
|
227
|
-
.manage(AppState {
|
|
228
|
-
db: Arc::new(Mutex::new(db)),
|
|
229
|
-
})
|
|
230
|
-
// ... rest of setup
|
|
231
|
-
}
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
## Next Steps
|
|
235
|
-
|
|
236
|
-
- See [LOCAL_FIRST_INTEGRATION.md](../../docs/LOCAL_FIRST_INTEGRATION.md) for full architecture
|
|
237
|
-
- Check out the [Browser WASM example](./browser-wasm-integration.md) for web apps
|
|
238
|
-
- Explore [IPC integration](./native-ipc-integration.md) for desktop apps
|
|
239
|
-
|
|
240
|
-
## Troubleshooting
|
|
241
|
-
|
|
242
|
-
### "Tauri backend requires Tauri environment" error
|
|
243
|
-
|
|
244
|
-
Make sure you're running the app in Tauri:
|
|
245
|
-
|
|
246
|
-
```bash
|
|
247
|
-
npm run tauri dev
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
Not in a regular browser or Node.js environment.
|
|
251
|
-
|
|
252
|
-
### Build errors with Rust dependencies
|
|
253
|
-
|
|
254
|
-
Ensure you have the Rust toolchain installed:
|
|
255
|
-
|
|
256
|
-
```bash
|
|
257
|
-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
On Windows, you may need to install Visual Studio Build Tools.
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# PluresDB VSCode Extension Example
|
|
2
|
-
|
|
3
|
-
This is an example VSCode extension that demonstrates how to integrate PluresDB into your VSCode extension.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Store Data**: Store key-value pairs in PluresDB
|
|
8
|
-
- **Retrieve Data**: Retrieve data by key
|
|
9
|
-
- **Vector Search**: Perform semantic search across your data
|
|
10
|
-
- **SQLite Compatibility**: Use familiar SQLite API
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
1. Install dependencies:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
2. Compile the extension:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm run compile
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
3. Press F5 to run the extension in a new Extension Development Host window
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
1. Open the Command Palette (Ctrl+Shift+P)
|
|
31
|
-
2. Run one of these commands:
|
|
32
|
-
- `PluresDB Example: Hello World` - Shows a hello world message
|
|
33
|
-
- `PluresDB Example: Store Data` - Store data in PluresDB
|
|
34
|
-
- `PluresDB Example: Retrieve Data` - Retrieve data from PluresDB
|
|
35
|
-
- `PluresDB Example: Search Data` - Search data with vector search
|
|
36
|
-
|
|
37
|
-
## Code Example
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
import { SQLiteCompatibleAPI } from "pluresdb";
|
|
41
|
-
|
|
42
|
-
// Initialize database
|
|
43
|
-
const db = new SQLiteCompatibleAPI({
|
|
44
|
-
config: {
|
|
45
|
-
dataDir: path.join(context.globalStorageUri.fsPath, "pluresdb"),
|
|
46
|
-
port: 34567,
|
|
47
|
-
host: "localhost",
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Start database
|
|
52
|
-
await db.start();
|
|
53
|
-
|
|
54
|
-
// Store data
|
|
55
|
-
await db.put("user:123", { name: "John", email: "john@example.com" });
|
|
56
|
-
|
|
57
|
-
// Retrieve data
|
|
58
|
-
const user = await db.getValue("user:123");
|
|
59
|
-
|
|
60
|
-
// Vector search
|
|
61
|
-
const results = await db.vectorSearch("machine learning", 10);
|
|
62
|
-
|
|
63
|
-
// SQL queries
|
|
64
|
-
await db.exec("CREATE TABLE users (id TEXT, name TEXT)");
|
|
65
|
-
const users = await db.all("SELECT * FROM users");
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Migration from SQLite
|
|
69
|
-
|
|
70
|
-
If you're migrating from SQLite, the API is nearly identical:
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
// Before (SQLite)
|
|
74
|
-
import sqlite3 from "sqlite3";
|
|
75
|
-
const db = new sqlite3.Database("./data.db");
|
|
76
|
-
|
|
77
|
-
// After (PluresDB)
|
|
78
|
-
import { SQLiteCompatibleAPI } from "pluresdb";
|
|
79
|
-
const db = new SQLiteCompatibleAPI();
|
|
80
|
-
await db.start();
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Benefits of PluresDB
|
|
84
|
-
|
|
85
|
-
- **P2P Sync**: Share data across devices
|
|
86
|
-
- **Offline-First**: Work without internet
|
|
87
|
-
- **Vector Search**: Semantic search capabilities
|
|
88
|
-
- **Encrypted Sharing**: Secure data sharing
|
|
89
|
-
- **SQLite Compatibility**: Easy migration
|
|
90
|
-
|
|
91
|
-
## Learn More
|
|
92
|
-
|
|
93
|
-
- [PluresDB Documentation](../../README.md)
|
|
94
|
-
- [VSCode Extension API](https://code.visualstudio.com/api)
|
|
95
|
-
- [Migration Guide](../../docs/VSCODE_MIGRATION.md)
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pluresdb-extension-example",
|
|
3
|
-
"displayName": "PluresDB Extension Example",
|
|
4
|
-
"description": "Example VSCode extension using PluresDB",
|
|
5
|
-
"version": "0.0.1",
|
|
6
|
-
"engines": {
|
|
7
|
-
"vscode": "^1.74.0"
|
|
8
|
-
},
|
|
9
|
-
"categories": [
|
|
10
|
-
"Other"
|
|
11
|
-
],
|
|
12
|
-
"activationEvents": [
|
|
13
|
-
"onCommand:pluresdb-example.helloWorld"
|
|
14
|
-
],
|
|
15
|
-
"main": "./out/extension.js",
|
|
16
|
-
"contributes": {
|
|
17
|
-
"commands": [
|
|
18
|
-
{
|
|
19
|
-
"command": "pluresdb-example.helloWorld",
|
|
20
|
-
"title": "Hello World from PluresDB"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"command": "pluresdb-example.storeData",
|
|
24
|
-
"title": "Store Data in PluresDB"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"command": "pluresdb-example.retrieveData",
|
|
28
|
-
"title": "Retrieve Data from PluresDB"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"command": "pluresdb-example.searchData",
|
|
32
|
-
"title": "Search Data with Vector Search"
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
"scripts": {
|
|
37
|
-
"vscode:prepublish": "npm run compile",
|
|
38
|
-
"compile": "tsc -p ./",
|
|
39
|
-
"watch": "tsc -watch -p ./"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@types/vscode": "^1.74.0",
|
|
43
|
-
"@types/node": "16.x",
|
|
44
|
-
"typescript": "^4.9.4"
|
|
45
|
-
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"pluresdb": "file:../.."
|
|
48
|
-
}
|
|
49
|
-
}
|