@plures/pluresdb 1.6.10 → 2.9.7

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 (93) hide show
  1. package/README.md +97 -289
  2. package/crates/README.md +99 -0
  3. package/crates/pluresdb-node/README.md +181 -0
  4. package/crates/pluresdb-node/index.d.ts +0 -0
  5. package/crates/pluresdb-node/index.js +265 -0
  6. package/crates/pluresdb-node/package.json +35 -0
  7. package/dist/.tsbuildinfo +1 -1
  8. package/dist/napi/index.d.ts +38 -0
  9. package/dist/napi/index.d.ts.map +1 -0
  10. package/dist/napi/index.js +60 -0
  11. package/dist/napi/index.js.map +1 -0
  12. package/dist/node-index.d.ts +32 -0
  13. package/dist/node-index.d.ts.map +1 -1
  14. package/dist/node-index.js +52 -0
  15. package/dist/node-index.js.map +1 -1
  16. package/embedded.d.ts +1 -0
  17. package/embedded.js +46 -0
  18. package/package.json +21 -8
  19. package/examples/basic-usage.d.ts +0 -2
  20. package/examples/basic-usage.d.ts.map +0 -1
  21. package/examples/basic-usage.js +0 -26
  22. package/examples/basic-usage.js.map +0 -1
  23. package/examples/basic-usage.ts +0 -29
  24. package/examples/browser-demo/README.md +0 -204
  25. package/examples/browser-demo/index.html +0 -466
  26. package/examples/browser-wasm-integration.md +0 -411
  27. package/examples/ipc-demo/README.md +0 -127
  28. package/examples/local-first-usage.ts +0 -138
  29. package/examples/native-ipc-integration.md +0 -526
  30. package/examples/tauri-demo/README.md +0 -240
  31. package/examples/tauri-integration.md +0 -260
  32. package/examples/vscode-extension-example/README.md +0 -95
  33. package/examples/vscode-extension-example/package.json +0 -49
  34. package/examples/vscode-extension-example/src/extension.ts +0 -172
  35. package/examples/vscode-extension-example/tsconfig.json +0 -12
  36. package/examples/vscode-extension-integration.d.ts +0 -31
  37. package/examples/vscode-extension-integration.d.ts.map +0 -1
  38. package/examples/vscode-extension-integration.js +0 -319
  39. package/examples/vscode-extension-integration.js.map +0 -1
  40. package/examples/vscode-extension-integration.ts +0 -41
  41. package/legacy/benchmarks/memory-benchmarks.ts +0 -350
  42. package/legacy/benchmarks/run-benchmarks.ts +0 -315
  43. package/legacy/better-sqlite3-shared.ts +0 -157
  44. package/legacy/better-sqlite3.ts +0 -4
  45. package/legacy/cli.ts +0 -241
  46. package/legacy/config.ts +0 -50
  47. package/legacy/core/crdt.ts +0 -107
  48. package/legacy/core/database.ts +0 -529
  49. package/legacy/healthcheck.ts +0 -162
  50. package/legacy/http/api-server.ts +0 -569
  51. package/legacy/index.ts +0 -31
  52. package/legacy/local-first/unified-api.ts +0 -449
  53. package/legacy/logic/rules.ts +0 -46
  54. package/legacy/main.rs +0 -3
  55. package/legacy/main.ts +0 -197
  56. package/legacy/network/websocket-server.ts +0 -115
  57. package/legacy/node-index.ts +0 -827
  58. package/legacy/node-wrapper.ts +0 -329
  59. package/legacy/plugins/README.md +0 -181
  60. package/legacy/plugins/example-embedding-plugin.ts +0 -56
  61. package/legacy/plugins/plugin-system.ts +0 -315
  62. package/legacy/sqlite-compat.ts +0 -633
  63. package/legacy/sqlite3-compat.ts +0 -55
  64. package/legacy/storage/kv-storage.ts +0 -73
  65. package/legacy/tests/core.test.ts +0 -305
  66. package/legacy/tests/fixtures/performance-data.json +0 -71
  67. package/legacy/tests/fixtures/test-data.json +0 -129
  68. package/legacy/tests/integration/api-server.test.ts +0 -334
  69. package/legacy/tests/integration/mesh-network.test.ts +0 -303
  70. package/legacy/tests/logic.test.ts +0 -34
  71. package/legacy/tests/performance/load.test.ts +0 -290
  72. package/legacy/tests/security/input-validation.test.ts +0 -286
  73. package/legacy/tests/unit/core.test.ts +0 -226
  74. package/legacy/tests/unit/local-first-api.test.ts +0 -65
  75. package/legacy/tests/unit/plugin-system.test.ts +0 -388
  76. package/legacy/tests/unit/subscriptions.test.ts +0 -135
  77. package/legacy/tests/unit/vector-search.test.ts +0 -173
  78. package/legacy/tests/vscode_extension_test.ts +0 -281
  79. package/legacy/types/index.ts +0 -32
  80. package/legacy/types/node-types.ts +0 -80
  81. package/legacy/util/debug.ts +0 -27
  82. package/legacy/vector/index.ts +0 -59
  83. package/legacy/vscode/extension.ts +0 -387
  84. package/scripts/compiled-crud-verify.ts +0 -30
  85. package/scripts/dogfood.ts +0 -297
  86. package/scripts/publish-crates.sh +0 -95
  87. package/scripts/release-check.js +0 -224
  88. package/scripts/run-tests.ts +0 -178
  89. package/scripts/setup-libclang.ps1 +0 -209
  90. package/scripts/update-changelog.js +0 -214
  91. package/scripts/validate-npm-publish.js +0 -228
  92. package/web/README.md +0 -27
  93. package/web/svelte/package.json +0 -31
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@plures/pluresdb",
3
- "version": "1.6.10",
3
+ "version": "2.9.7",
4
4
  "description": "P2P Graph Database with SQLite Compatibility - Local-first, offline-first database for modern applications",
5
- "main": "dist/node-index.js",
6
- "types": "dist/node-index.d.ts",
5
+ "main": "dist/napi/index.js",
6
+ "types": "dist/napi/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
+ "types": "./dist/napi/index.d.ts",
10
+ "require": "./dist/napi/index.js",
11
+ "default": "./dist/napi/index.js"
12
+ },
13
+ "./legacy": {
9
14
  "types": "./dist/node-index.d.ts",
10
15
  "require": "./dist/node-index.js",
11
16
  "default": "./dist/node-index.js"
@@ -20,6 +25,11 @@
20
25
  "require": "./dist/better-sqlite3.js",
21
26
  "default": "./dist/better-sqlite3.js"
22
27
  },
28
+ "./embedded": {
29
+ "types": "./embedded.d.ts",
30
+ "require": "./embedded.js",
31
+ "default": "./embedded.js"
32
+ },
23
33
  "./vscode": {
24
34
  "types": "./dist/vscode/extension.d.ts",
25
35
  "require": "./dist/vscode/extension.js",
@@ -98,10 +108,12 @@
98
108
  },
99
109
  "files": [
100
110
  "dist/",
101
- "web/svelte/dist/",
102
- "legacy/",
103
- "examples/",
104
- "scripts/",
111
+ "embedded.js",
112
+ "embedded.d.ts",
113
+ "crates/pluresdb-node/index.d.ts",
114
+ "crates/pluresdb-node/index.js",
115
+ "crates/pluresdb-node/*.node",
116
+ "scripts/postinstall.js",
105
117
  "README.md",
106
118
  "LICENSE",
107
119
  "package.json"
@@ -109,12 +121,13 @@
109
121
  "dependencies": {
110
122
  "cors": "^2.8.5",
111
123
  "express": "^5.1.0",
124
+ "hyperswarm": "^4.8.4",
112
125
  "ws": "^8.18.3"
113
126
  },
114
127
  "devDependencies": {
115
128
  "@types/cors": "^2.8.19",
116
129
  "@types/express": "^5.0.0",
117
- "@types/node": "^22.10.0",
130
+ "@types/node": "^22.19.11",
118
131
  "@types/vscode": "^1.104.0",
119
132
  "@types/ws": "^8.18.1",
120
133
  "@typescript-eslint/eslint-plugin": "^8.46.4",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=basic-usage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic-usage.d.ts","sourceRoot":"","sources":["basic-usage.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const database_ts_1 = require("../src/core/database.ts");
4
- const db = new database_ts_1.GunDB();
5
- await db.ready();
6
- await db.put("user:alice", {
7
- name: "Alice",
8
- age: 30,
9
- city: "London",
10
- vector: undefined,
11
- });
12
- const user = await db.get("user:alice");
13
- console.log("User:", user);
14
- db.on("user:alice", (node) => console.log("Updated user:alice:", node));
15
- await db.put("note:1", { text: "I love visiting museums in London" });
16
- await db.put("note:2", { text: "Best pizza in New York" });
17
- await db.put("note:3", { text: "Parks and galleries around London are great" });
18
- const results = await db.vectorSearch("Find things about London", 5);
19
- console.log(
20
- "Semantic search results:",
21
- results.map((n) => ({
22
- id: n.id,
23
- text: n.data.text,
24
- })),
25
- );
26
- //# sourceMappingURL=basic-usage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic-usage.js","sourceRoot":"","sources":["basic-usage.ts"],"names":[],"mappings":";;AAAA,yDAAgD;AAEhD,MAAM,EAAE,GAAG,IAAI,mBAAK,EAAE,CAAC;AACvB,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;AAEjB,MAAM,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE;IACzB,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AACxC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAE3B,EAAE,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC,CAAC;AAExE,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,mCAAmC,EAAE,CAAC,CAAC;AACtE,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC,CAAC;AAC3D,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,6CAA6C,EAAE,CAAC,CAAC;AAEhF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,YAAY,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC;AACrE,OAAO,CAAC,GAAG,CACT,0BAA0B,EAC1B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClB,EAAE,EAAE,CAAC,CAAC,EAAE;IACR,IAAI,EAAG,CAAC,CAAC,IAAgC,CAAC,IAAI;CAC/C,CAAC,CAAC,CACJ,CAAC"}
@@ -1,29 +0,0 @@
1
- import { GunDB } from "../src/core/database.ts";
2
-
3
- const db = new GunDB();
4
- await db.ready();
5
-
6
- await db.put("user:alice", {
7
- name: "Alice",
8
- age: 30,
9
- city: "London",
10
- vector: undefined,
11
- });
12
-
13
- const user = await db.get("user:alice");
14
- console.log("User:", user);
15
-
16
- db.on("user:alice", (node) => console.log("Updated user:alice:", node));
17
-
18
- await db.put("note:1", { text: "I love visiting museums in London" });
19
- await db.put("note:2", { text: "Best pizza in New York" });
20
- await db.put("note:3", { text: "Parks and galleries around London are great" });
21
-
22
- const results = await db.vectorSearch("Find things about London", 5);
23
- console.log(
24
- "Semantic search results:",
25
- results.map((n) => ({
26
- id: n.id,
27
- text: (n.data as Record<string, unknown>).text,
28
- })),
29
- );
@@ -1,204 +0,0 @@
1
- # PluresDB Browser Demo
2
-
3
- A fully-functional browser-based demo of PluresDB's local-first integration with WebAssembly.
4
-
5
- ## Features
6
-
7
- - 🚀 Local-first database running entirely in the browser
8
- - 📝 Add, list, and delete users
9
- - 💾 Automatic persistence with IndexedDB
10
- - 🎨 Beautiful, modern UI
11
- - ⚡ Real-time updates
12
- - 🔌 Offline-first by default
13
-
14
- ## Running the Demo
15
-
16
- ### Option 1: With WASM (Recommended)
17
-
18
- The WASM bindings are now complete! Run the demo entirely in-browser without any server:
19
-
20
- 1. Build the WASM module:
21
- ```bash
22
- cd crates/pluresdb-wasm
23
- wasm-pack build --target web
24
- ```
25
-
26
- 2. Serve the demo with a local HTTP server:
27
- ```bash
28
- # Using Python
29
- python -m http.server 8000
30
-
31
- # Or using Node.js
32
- npx http-server
33
- ```
34
-
35
- 3. Open `http://localhost:8000/examples/browser-demo/index.html` in your browser
36
-
37
- 4. The demo will automatically use WASM mode with IndexedDB persistence - no server needed!
38
-
39
- ### Option 2: With PluresDB Server (Fallback)
40
-
41
- For testing network mode:
42
-
43
- 1. Start the PluresDB server:
44
- ```bash
45
- npm start
46
- ```
47
-
48
- 2. Open `index.html` in your browser - it will fall back to network mode
49
-
50
- ## What This Demonstrates
51
-
52
- ### Local-First Integration
53
- - **WebAssembly**: Runs PluresDB core directly in the browser
54
- - **IndexedDB**: Automatic data persistence
55
- - **Auto-detection**: Automatically uses WASM when available
56
- - **Network fallback**: Falls back to HTTP REST when needed
57
- - **Unified API**: Same API regardless of backend
58
-
59
- ### Database Operations
60
- - **Put**: Insert or update records with persistence
61
- - **Get**: Retrieve records by ID
62
- - **List**: Query all records
63
- - **Delete**: Remove records from memory and IndexedDB
64
- - **Clear**: Wipe all data
65
-
66
- ### User Interface
67
- - Clean, modern design
68
- - Real-time status updates
69
- - Interactive user management
70
- - Console output for debugging
71
-
72
- ## Architecture
73
-
74
- ### WASM Mode (Default)
75
- ```
76
- ┌─────────────────────────────────┐
77
- │ Browser (index.html) │
78
- │ │
79
- │ PluresDBLocalFirst │
80
- │ (Auto-detection) │
81
- │ │ │
82
- │ ▼ │
83
- │ PluresDBBrowser (WASM) │
84
- │ │ │
85
- │ ▼ │
86
- │ IndexedDB (Persistence) │
87
- │ │
88
- └─────────────────────────────────┘
89
- 100% In-Browser
90
- No Network Required
91
- ```
92
-
93
- ### Network Mode (Fallback)
94
- ```
95
- ┌─────────────────────────────────┐
96
- │ Browser (index.html) │
97
- │ │
98
- │ PluresDBLocalFirst │
99
- │ (Auto-detection) │
100
- │ │ │
101
- │ └─ Network │
102
- │ │ │
103
- └───────────────────┼─────────────┘
104
- │ HTTP
105
- ┌───────────▼──────────┐
106
- │ PluresDB Server │
107
- │ (port 34567) │
108
- └──────────────────────┘
109
- ```
110
-
111
- ## Performance
112
-
113
- With WASM mode enabled:
114
-
115
- | Metric | Network Mode | WASM Mode | Improvement |
116
- |--------|--------------|-----------|-------------|
117
- | **Latency** | ~50-100ms | ~0.1ms | **500-1000x faster** |
118
- | **Throughput** | ~100 ops/s | ~100k ops/s | **1000x faster** |
119
- | **Offline** | ❌ Requires server | ✅ Fully offline | **100% available** |
120
- | **Network** | Required | None | **Zero bandwidth** |
121
- | **Persistence** | Server-side | IndexedDB | **Local storage** |
122
-
123
- ## Development
124
-
125
- To modify the demo:
126
-
127
- 1. Edit `index.html` - all code is in a single file for simplicity
128
- 2. Rebuild WASM if you modified Rust code:
129
- ```bash
130
- cd crates/pluresdb-wasm
131
- wasm-pack build --target web
132
- ```
133
- 3. Refresh the browser to see changes
134
- 4. Use browser DevTools (F12) to debug
135
-
136
- ## Integration with Your App
137
-
138
- To integrate PluresDB local-first into your own application:
139
-
140
- ```javascript
141
- import { PluresDBLocalFirst } from "@plures/pluresdb/local-first";
142
-
143
- // Auto-detects best mode (WASM in browser)
144
- const db = new PluresDBLocalFirst({ mode: "auto" });
145
-
146
- // Or force WASM mode
147
- const db = new PluresDBLocalFirst({ mode: "wasm", dbName: "my-app" });
148
-
149
- // Use the API
150
- await db.put("user:1", { name: "Alice", email: "alice@example.com" });
151
- const user = await db.get("user:1");
152
- ```
153
-
154
- See the [Local-First Integration Guide](../../docs/LOCAL_FIRST_INTEGRATION.md) for complete documentation.
155
-
156
- ## Troubleshooting
157
-
158
- ### WASM not loading
159
-
160
- 1. Make sure you built the WASM module:
161
- ```bash
162
- cd crates/pluresdb-wasm
163
- wasm-pack build --target web
164
- ```
165
-
166
- 2. Check browser console for errors
167
-
168
- 3. Ensure you're using a local HTTP server (not file://)
169
-
170
- ### "Failed to connect" error (network mode)
171
-
172
- Make sure the PluresDB server is running:
173
- ```bash
174
- npm start
175
- ```
176
-
177
- The server should be listening on port 34567.
178
-
179
- ### IndexedDB not persisting data
180
-
181
- 1. Check browser console for IndexedDB errors
182
- 2. Make sure you called `init_persistence()` on the WASM instance
183
- 3. Check browser storage settings (some browsers block IndexedDB in private mode)
184
-
185
- ## Browser Compatibility
186
-
187
- WASM mode is supported in:
188
- - ✅ Chrome/Edge 57+
189
- - ✅ Firefox 52+
190
- - ✅ Safari 11+
191
- - ✅ Opera 44+
192
-
193
- IndexedDB is supported in all modern browsers.
194
-
195
- ## Next Steps
196
-
197
- - [Browser WASM Integration Guide](../browser-wasm-integration.md)
198
- - [Local-First Integration Methodology](../../docs/LOCAL_FIRST_INTEGRATION.md)
199
- - [Tauri Integration Example](../tauri-integration.md)
200
- - [IPC Integration Example](../ipc-demo/README.md)
201
-
202
- ## License
203
-
204
- AGPL-3.0 - see [LICENSE](../../LICENSE)