@sqd-pipes/delta-db 0.0.1-alpha.6 → 0.0.1-alpha.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/package.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqd-pipes/delta-db",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.7",
|
|
4
4
|
"description": "Embedded rollback-aware computation engine for blockchain data",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
7
7
|
"napi": {
|
|
8
|
-
"name": "delta-db"
|
|
9
|
-
"triples": {
|
|
10
|
-
"defaults": true
|
|
11
|
-
}
|
|
8
|
+
"name": "delta-db"
|
|
12
9
|
},
|
|
13
10
|
"scripts": {
|
|
14
|
-
"build": "napi build --cargo-cwd ../../.. --features napi --release --dts native.d.ts src",
|
|
15
|
-
"build:debug": "napi build --cargo-cwd ../../.. --features napi --dts native.d.ts src",
|
|
11
|
+
"build": "napi build --cargo-cwd ../../.. --features napi --release --platform --dts native.d.ts --js false src",
|
|
12
|
+
"build:debug": "napi build --cargo-cwd ../../.. --features napi --platform --dts native.d.ts --js false src",
|
|
13
|
+
"artifacts": "napi artifacts",
|
|
16
14
|
"test": "vitest run",
|
|
17
15
|
"test:watch": "vitest"
|
|
18
16
|
},
|
|
@@ -26,7 +24,8 @@
|
|
|
26
24
|
"files": [
|
|
27
25
|
"src/index.js",
|
|
28
26
|
"src/index.d.ts",
|
|
29
|
-
"src/
|
|
27
|
+
"src/native.js",
|
|
28
|
+
"src/*.node"
|
|
30
29
|
],
|
|
31
30
|
"license": "MIT"
|
|
32
31
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/index.js
CHANGED
package/src/native.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* Platform-aware native module loader for @sqd-pipes/delta-db */
|
|
2
|
+
|
|
3
|
+
const { existsSync } = require('fs')
|
|
4
|
+
const { join } = require('path')
|
|
5
|
+
|
|
6
|
+
const { platform, arch } = process
|
|
7
|
+
|
|
8
|
+
let nativeBinding = null
|
|
9
|
+
let loadError = null
|
|
10
|
+
|
|
11
|
+
function getPlatformFile() {
|
|
12
|
+
const suffixes = {
|
|
13
|
+
'darwin-x64': 'darwin-x64',
|
|
14
|
+
'darwin-arm64': 'darwin-arm64',
|
|
15
|
+
'linux-x64': 'linux-x64-gnu',
|
|
16
|
+
'linux-arm64': 'linux-arm64-gnu',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const key = `${platform}-${arch}`
|
|
20
|
+
return suffixes[key] ? `delta-db.${suffixes[key]}.node` : null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Try platform-specific file (e.g. delta-db.linux-x64-gnu.node)
|
|
24
|
+
const platformFile = getPlatformFile()
|
|
25
|
+
if (platformFile) {
|
|
26
|
+
const platformPath = join(__dirname, platformFile)
|
|
27
|
+
if (existsSync(platformPath)) {
|
|
28
|
+
try {
|
|
29
|
+
nativeBinding = require(platformPath)
|
|
30
|
+
} catch (e) {
|
|
31
|
+
loadError = e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Fallback: try unqualified .node file (local dev build)
|
|
37
|
+
if (!nativeBinding) {
|
|
38
|
+
const localFile = join(__dirname, 'delta-db.node')
|
|
39
|
+
if (existsSync(localFile)) {
|
|
40
|
+
try {
|
|
41
|
+
nativeBinding = require(localFile)
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!nativeBinding) {
|
|
49
|
+
const help = [
|
|
50
|
+
`Failed to load native binding for ${platform}-${arch}.`,
|
|
51
|
+
platformFile ? `Looked for: ${platformFile}` : `Unsupported platform: ${platform}-${arch}`,
|
|
52
|
+
'',
|
|
53
|
+
loadError ? `Error: ${loadError.message}` : '',
|
|
54
|
+
'',
|
|
55
|
+
'Build from source: npm run build',
|
|
56
|
+
].join('\n')
|
|
57
|
+
throw new Error(help)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = nativeBinding
|