@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.
- 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/.tsbuildinfo +1 -1
- package/dist/napi/index.d.ts +38 -0
- package/dist/napi/index.d.ts.map +1 -0
- package/dist/napi/index.js +60 -0
- package/dist/napi/index.js.map +1 -0
- package/dist/node-index.d.ts +32 -0
- package/dist/node-index.d.ts.map +1 -1
- package/dist/node-index.js +52 -0
- package/dist/node-index.js.map +1 -1
- package/embedded.d.ts +1 -0
- package/embedded.js +46 -0
- package/package.json +21 -8
- 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/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
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# @plures/pluresdb-native
|
|
2
|
+
|
|
3
|
+
Native Node.js bindings for PluresDB - a P2P Graph Database with SQLite compatibility.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@plures/pluresdb-native)
|
|
6
|
+
[](../../LICENSE)
|
|
7
|
+
|
|
8
|
+
This package provides high-performance N-API bindings to the PluresDB Rust core, enabling native database operations directly from Node.js.
|
|
9
|
+
|
|
10
|
+
## ✅ Features
|
|
11
|
+
|
|
12
|
+
- **CRUD Operations** - Create, read, update, and delete nodes with CRDT synchronization
|
|
13
|
+
- **SQL Support** - Execute SQL queries with parameterized statements (95% SQLite compatible)
|
|
14
|
+
- **BLOB Support** - Store binary data including embedding vectors
|
|
15
|
+
- **Search** - Text-based and vector similarity search
|
|
16
|
+
- **Type Filtering** - Filter nodes by type
|
|
17
|
+
- **Subscriptions** - Subscribe to database changes
|
|
18
|
+
- **Native Performance** - Rust-powered N-API bindings for maximum speed
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @plures/pluresdb-native
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Pre-built binaries are available for:
|
|
27
|
+
- **Linux**: x86_64, aarch64 (GNU libc)
|
|
28
|
+
- **macOS**: x86_64 (Intel), aarch64 (Apple Silicon)
|
|
29
|
+
- **Windows**: x86_64, aarch64 (MSVC)
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
const { PluresDatabase } = require('@plures/pluresdb-native');
|
|
35
|
+
|
|
36
|
+
// Create a new database instance
|
|
37
|
+
const db = new PluresDatabase('my-actor');
|
|
38
|
+
|
|
39
|
+
// Insert a node
|
|
40
|
+
const id = db.put('user-1', {
|
|
41
|
+
name: 'Alice',
|
|
42
|
+
email: 'alice@example.com',
|
|
43
|
+
type: 'User'
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Retrieve a node
|
|
47
|
+
const user = db.get('user-1');
|
|
48
|
+
console.log(user); // { name: 'Alice', email: 'alice@example.com', type: 'User' }
|
|
49
|
+
|
|
50
|
+
// List all nodes
|
|
51
|
+
const all = db.list();
|
|
52
|
+
|
|
53
|
+
// Delete a node
|
|
54
|
+
db.delete('user-1');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## SQL Support
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
// Create database with SQL support (provide db_path)
|
|
61
|
+
const db = new PluresDatabase('my-actor', './data.db');
|
|
62
|
+
|
|
63
|
+
// Create table
|
|
64
|
+
db.exec(`
|
|
65
|
+
CREATE TABLE IF NOT EXISTS users (
|
|
66
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
67
|
+
name TEXT NOT NULL,
|
|
68
|
+
email TEXT UNIQUE,
|
|
69
|
+
embedding BLOB
|
|
70
|
+
)
|
|
71
|
+
`);
|
|
72
|
+
|
|
73
|
+
// Insert data
|
|
74
|
+
db.exec(`INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com')`);
|
|
75
|
+
|
|
76
|
+
// Query with parameters (supports ? placeholders)
|
|
77
|
+
const result = db.query('SELECT * FROM users WHERE name = ?', ['Alice']);
|
|
78
|
+
console.log(result.rows); // [{ id: 1, name: 'Alice', email: 'alice@example.com', embedding: null }]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API Reference
|
|
82
|
+
|
|
83
|
+
### Constructor
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
new PluresDatabase(actorId?: string, dbPath?: string)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- `actorId` (optional): Unique identifier for this database instance. Default: `"node-actor"`
|
|
90
|
+
- `dbPath` (optional): Path to SQLite database file for SQL support
|
|
91
|
+
|
|
92
|
+
### Methods
|
|
93
|
+
|
|
94
|
+
#### CRUD Operations
|
|
95
|
+
|
|
96
|
+
- `put(id: string, data: any): string` - Insert or update a node
|
|
97
|
+
- `get(id: string): any | null` - Retrieve a node by ID
|
|
98
|
+
- `getWithMetadata(id: string): NodeWithMetadata | null` - Get node with vector clock and timestamp
|
|
99
|
+
- `delete(id: string): void` - Delete a node
|
|
100
|
+
- `list(): Array<{id, data, timestamp}>` - List all nodes
|
|
101
|
+
- `listByType(nodeType: string): Array<{id, data, timestamp}>` - Filter nodes by type
|
|
102
|
+
|
|
103
|
+
#### SQL Operations
|
|
104
|
+
|
|
105
|
+
- `query(sql: string, params?: any[]): QueryResult` - Execute SQL SELECT with parameters
|
|
106
|
+
- `exec(sql: string): ExecutionResult` - Execute SQL statement (INSERT, UPDATE, DELETE, CREATE)
|
|
107
|
+
|
|
108
|
+
**Example:**
|
|
109
|
+
```javascript
|
|
110
|
+
const result = db.query('SELECT * FROM users WHERE age > ?', [25]);
|
|
111
|
+
console.log(result.rows); // Array of matching rows
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### Search
|
|
115
|
+
|
|
116
|
+
- `search(query: string, limit?: number): SearchResult[]` - Text search across node data
|
|
117
|
+
- `vectorSearch(query: string, limit?: number, threshold?: number): SearchResult[]` - Vector similarity search
|
|
118
|
+
|
|
119
|
+
#### Utilities
|
|
120
|
+
|
|
121
|
+
- `subscribe(): string` - Subscribe to database changes
|
|
122
|
+
- `getActorId(): string` - Get the actor ID
|
|
123
|
+
- `stats(): DatabaseStats` - Get database statistics (`{totalNodes, typeCounts}`)
|
|
124
|
+
|
|
125
|
+
## TypeScript Support
|
|
126
|
+
|
|
127
|
+
TypeScript definitions are included in the package.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { PluresDatabase, QueryResult, ExecutionResult } from '@plures/pluresdb-native';
|
|
131
|
+
|
|
132
|
+
const db = new PluresDatabase('my-actor', './data.db');
|
|
133
|
+
const result: QueryResult = db.query('SELECT * FROM users WHERE id = ?', [1]);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## SLM (superlocalmemory) Compatibility
|
|
137
|
+
|
|
138
|
+
This package is designed as a drop-in replacement for better-sqlite3 in the superlocalmemory project:
|
|
139
|
+
|
|
140
|
+
- ✅ Parameterized SQL with `?` placeholders
|
|
141
|
+
- ✅ BLOB column support for embedding vectors
|
|
142
|
+
- ✅ Synchronous API (no async/await required)
|
|
143
|
+
- ✅ 95% SQLite compatibility
|
|
144
|
+
|
|
145
|
+
See the [SLM Migration Guide](https://github.com/plures/development-guide/blob/main/goals/SLM-PLURESDB-MIGRATION.md) for details.
|
|
146
|
+
|
|
147
|
+
## Building from Source
|
|
148
|
+
|
|
149
|
+
If a pre-built binary is not available for your platform:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Clone the repository
|
|
153
|
+
git clone https://github.com/plures/pluresdb.git
|
|
154
|
+
cd pluresdb/crates/pluresdb-node
|
|
155
|
+
|
|
156
|
+
# Install dependencies
|
|
157
|
+
npm install
|
|
158
|
+
|
|
159
|
+
# Build
|
|
160
|
+
npm run build
|
|
161
|
+
|
|
162
|
+
# Test
|
|
163
|
+
npm test
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Requirements
|
|
167
|
+
|
|
168
|
+
- Rust 1.70 or later
|
|
169
|
+
- Node.js 20 or later
|
|
170
|
+
- C compiler (for rusqlite native dependencies)
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
AGPL-3.0 - see [LICENSE](../../LICENSE) for details.
|
|
175
|
+
|
|
176
|
+
## Links
|
|
177
|
+
|
|
178
|
+
- [GitHub Repository](https://github.com/plures/pluresdb)
|
|
179
|
+
- [PluresDB Documentation](https://github.com/plures/pluresdb#readme)
|
|
180
|
+
- [Issue Tracker](https://github.com/plures/pluresdb/issues)
|
|
181
|
+
- [NPM Package](https://www.npmjs.com/package/@plures/pluresdb-native)
|
|
File without changes
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
const { existsSync, readFileSync } = require("fs");
|
|
2
|
+
const { join } = require("path");
|
|
3
|
+
|
|
4
|
+
const { platform, arch } = process;
|
|
5
|
+
|
|
6
|
+
let nativeBinding = null;
|
|
7
|
+
let localFileExisted = false;
|
|
8
|
+
let loadError = null;
|
|
9
|
+
|
|
10
|
+
function isMusl() {
|
|
11
|
+
// For non-glibc Linux systems we must check if musl is used instead
|
|
12
|
+
if (!process.report || typeof process.report.getReport !== "function") {
|
|
13
|
+
try {
|
|
14
|
+
const lddPath = require("child_process")
|
|
15
|
+
.execSync("which ldd")
|
|
16
|
+
.toString()
|
|
17
|
+
.trim();
|
|
18
|
+
return readFileSync(lddPath, "utf8").includes("musl");
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
const { glibcVersionRuntime } = process.report.getReport().header;
|
|
24
|
+
return !glibcVersionRuntime;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
switch (platform) {
|
|
29
|
+
case "android":
|
|
30
|
+
switch (arch) {
|
|
31
|
+
case "arm64":
|
|
32
|
+
localFileExisted = existsSync(
|
|
33
|
+
join(__dirname, "pluresdb-node.android-arm64.node")
|
|
34
|
+
);
|
|
35
|
+
try {
|
|
36
|
+
if (localFileExisted) {
|
|
37
|
+
nativeBinding = require("./pluresdb-node.android-arm64.node");
|
|
38
|
+
} else {
|
|
39
|
+
nativeBinding = require("@plures/pluresdb-native-android-arm64");
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
loadError = e;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case "arm":
|
|
46
|
+
localFileExisted = existsSync(
|
|
47
|
+
join(__dirname, "pluresdb-node.android-arm-eabi.node")
|
|
48
|
+
);
|
|
49
|
+
try {
|
|
50
|
+
if (localFileExisted) {
|
|
51
|
+
nativeBinding = require("./pluresdb-node.android-arm-eabi.node");
|
|
52
|
+
} else {
|
|
53
|
+
nativeBinding = require("@plures/pluresdb-native-android-arm-eabi");
|
|
54
|
+
}
|
|
55
|
+
} catch (e) {
|
|
56
|
+
loadError = e;
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(`Unsupported architecture on Android ${arch}`);
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case "win32":
|
|
64
|
+
switch (arch) {
|
|
65
|
+
case "x64":
|
|
66
|
+
localFileExisted = existsSync(
|
|
67
|
+
join(__dirname, "pluresdb-node.win32-x64-msvc.node")
|
|
68
|
+
);
|
|
69
|
+
try {
|
|
70
|
+
if (localFileExisted) {
|
|
71
|
+
nativeBinding = require("./pluresdb-node.win32-x64-msvc.node");
|
|
72
|
+
} else {
|
|
73
|
+
nativeBinding = require("@plures/pluresdb-native-win32-x64-msvc");
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
loadError = e;
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
case "ia32":
|
|
80
|
+
localFileExisted = existsSync(
|
|
81
|
+
join(__dirname, "pluresdb-node.win32-ia32-msvc.node")
|
|
82
|
+
);
|
|
83
|
+
try {
|
|
84
|
+
if (localFileExisted) {
|
|
85
|
+
nativeBinding = require("./pluresdb-node.win32-ia32-msvc.node");
|
|
86
|
+
} else {
|
|
87
|
+
nativeBinding = require("@plures/pluresdb-native-win32-ia32-msvc");
|
|
88
|
+
}
|
|
89
|
+
} catch (e) {
|
|
90
|
+
loadError = e;
|
|
91
|
+
}
|
|
92
|
+
break;
|
|
93
|
+
case "arm64":
|
|
94
|
+
localFileExisted = existsSync(
|
|
95
|
+
join(__dirname, "pluresdb-node.win32-arm64-msvc.node")
|
|
96
|
+
);
|
|
97
|
+
try {
|
|
98
|
+
if (localFileExisted) {
|
|
99
|
+
nativeBinding = require("./pluresdb-node.win32-arm64-msvc.node");
|
|
100
|
+
} else {
|
|
101
|
+
nativeBinding = require("@plures/pluresdb-native-win32-arm64-msvc");
|
|
102
|
+
}
|
|
103
|
+
} catch (e) {
|
|
104
|
+
loadError = e;
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`);
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case "darwin":
|
|
112
|
+
localFileExisted = existsSync(
|
|
113
|
+
join(__dirname, "pluresdb-node.darwin-universal.node")
|
|
114
|
+
);
|
|
115
|
+
try {
|
|
116
|
+
if (localFileExisted) {
|
|
117
|
+
nativeBinding = require("./pluresdb-node.darwin-universal.node");
|
|
118
|
+
} else {
|
|
119
|
+
nativeBinding = require("@plures/pluresdb-native-darwin-universal");
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
} catch {}
|
|
123
|
+
switch (arch) {
|
|
124
|
+
case "x64":
|
|
125
|
+
localFileExisted = existsSync(
|
|
126
|
+
join(__dirname, "pluresdb-node.darwin-x64.node")
|
|
127
|
+
);
|
|
128
|
+
try {
|
|
129
|
+
if (localFileExisted) {
|
|
130
|
+
nativeBinding = require("./pluresdb-node.darwin-x64.node");
|
|
131
|
+
} else {
|
|
132
|
+
nativeBinding = require("@plures/pluresdb-native-darwin-x64");
|
|
133
|
+
}
|
|
134
|
+
} catch (e) {
|
|
135
|
+
loadError = e;
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case "arm64":
|
|
139
|
+
localFileExisted = existsSync(
|
|
140
|
+
join(__dirname, "pluresdb-node.darwin-arm64.node")
|
|
141
|
+
);
|
|
142
|
+
try {
|
|
143
|
+
if (localFileExisted) {
|
|
144
|
+
nativeBinding = require("./pluresdb-node.darwin-arm64.node");
|
|
145
|
+
} else {
|
|
146
|
+
nativeBinding = require("@plures/pluresdb-native-darwin-arm64");
|
|
147
|
+
}
|
|
148
|
+
} catch (e) {
|
|
149
|
+
loadError = e;
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`);
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case "freebsd":
|
|
157
|
+
if (arch !== "x64") {
|
|
158
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
|
|
159
|
+
}
|
|
160
|
+
localFileExisted = existsSync(
|
|
161
|
+
join(__dirname, "pluresdb-node.freebsd-x64.node")
|
|
162
|
+
);
|
|
163
|
+
try {
|
|
164
|
+
if (localFileExisted) {
|
|
165
|
+
nativeBinding = require("./pluresdb-node.freebsd-x64.node");
|
|
166
|
+
} else {
|
|
167
|
+
nativeBinding = require("@plures/pluresdb-native-freebsd-x64");
|
|
168
|
+
}
|
|
169
|
+
} catch (e) {
|
|
170
|
+
loadError = e;
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
case "linux":
|
|
174
|
+
switch (arch) {
|
|
175
|
+
case "x64":
|
|
176
|
+
if (isMusl()) {
|
|
177
|
+
localFileExisted = existsSync(
|
|
178
|
+
join(__dirname, "pluresdb-node.linux-x64-musl.node")
|
|
179
|
+
);
|
|
180
|
+
try {
|
|
181
|
+
if (localFileExisted) {
|
|
182
|
+
nativeBinding = require("./pluresdb-node.linux-x64-musl.node");
|
|
183
|
+
} else {
|
|
184
|
+
nativeBinding = require("@plures/pluresdb-native-linux-x64-musl");
|
|
185
|
+
}
|
|
186
|
+
} catch (e) {
|
|
187
|
+
loadError = e;
|
|
188
|
+
}
|
|
189
|
+
} else {
|
|
190
|
+
localFileExisted = existsSync(
|
|
191
|
+
join(__dirname, "pluresdb-node.linux-x64-gnu.node")
|
|
192
|
+
);
|
|
193
|
+
try {
|
|
194
|
+
if (localFileExisted) {
|
|
195
|
+
nativeBinding = require("./pluresdb-node.linux-x64-gnu.node");
|
|
196
|
+
} else {
|
|
197
|
+
nativeBinding = require("@plures/pluresdb-native-linux-x64-gnu");
|
|
198
|
+
}
|
|
199
|
+
} catch (e) {
|
|
200
|
+
loadError = e;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case "arm64":
|
|
205
|
+
if (isMusl()) {
|
|
206
|
+
localFileExisted = existsSync(
|
|
207
|
+
join(__dirname, "pluresdb-node.linux-arm64-musl.node")
|
|
208
|
+
);
|
|
209
|
+
try {
|
|
210
|
+
if (localFileExisted) {
|
|
211
|
+
nativeBinding = require("./pluresdb-node.linux-arm64-musl.node");
|
|
212
|
+
} else {
|
|
213
|
+
nativeBinding = require("@plures/pluresdb-native-linux-arm64-musl");
|
|
214
|
+
}
|
|
215
|
+
} catch (e) {
|
|
216
|
+
loadError = e;
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
localFileExisted = existsSync(
|
|
220
|
+
join(__dirname, "pluresdb-node.linux-arm64-gnu.node")
|
|
221
|
+
);
|
|
222
|
+
try {
|
|
223
|
+
if (localFileExisted) {
|
|
224
|
+
nativeBinding = require("./pluresdb-node.linux-arm64-gnu.node");
|
|
225
|
+
} else {
|
|
226
|
+
nativeBinding = require("@plures/pluresdb-native-linux-arm64-gnu");
|
|
227
|
+
}
|
|
228
|
+
} catch (e) {
|
|
229
|
+
loadError = e;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case "arm":
|
|
234
|
+
localFileExisted = existsSync(
|
|
235
|
+
join(__dirname, "pluresdb-node.linux-arm-gnueabihf.node")
|
|
236
|
+
);
|
|
237
|
+
try {
|
|
238
|
+
if (localFileExisted) {
|
|
239
|
+
nativeBinding = require("./pluresdb-node.linux-arm-gnueabihf.node");
|
|
240
|
+
} else {
|
|
241
|
+
nativeBinding = require("@plures/pluresdb-native-linux-arm-gnueabihf");
|
|
242
|
+
}
|
|
243
|
+
} catch (e) {
|
|
244
|
+
loadError = e;
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
default:
|
|
248
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`);
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
default:
|
|
252
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (!nativeBinding) {
|
|
256
|
+
if (loadError) {
|
|
257
|
+
throw loadError;
|
|
258
|
+
}
|
|
259
|
+
throw new Error(`Failed to load native binding`);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const { PluresDatabase, init } = nativeBinding;
|
|
263
|
+
|
|
264
|
+
module.exports.PluresDatabase = PluresDatabase;
|
|
265
|
+
module.exports.init = init;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plures/pluresdb-native",
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
|
+
"description": "Native Node.js bindings for PluresDB",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"napi": {
|
|
8
|
+
"binaryName": "pluresdb-node",
|
|
9
|
+
"targets": [
|
|
10
|
+
"x86_64-unknown-linux-gnu",
|
|
11
|
+
"aarch64-unknown-linux-gnu",
|
|
12
|
+
"x86_64-apple-darwin",
|
|
13
|
+
"aarch64-apple-darwin",
|
|
14
|
+
"x86_64-pc-windows-msvc",
|
|
15
|
+
"aarch64-pc-windows-msvc"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "napi build --platform --release",
|
|
20
|
+
"build:debug": "napi build --platform",
|
|
21
|
+
"test": "node test-node.js",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"database",
|
|
26
|
+
"pluresdb",
|
|
27
|
+
"native",
|
|
28
|
+
"napi"
|
|
29
|
+
],
|
|
30
|
+
"author": "Plures Organization",
|
|
31
|
+
"license": "AGPL-3.0",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@napi-rs/cli": "^3.5.1"
|
|
34
|
+
}
|
|
35
|
+
}
|