@aztec/wsdb 0.0.1-commit.031e54b

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.
@@ -0,0 +1,57 @@
1
+ import { createRequire } from 'node:module';
2
+ import * as fs from 'node:fs';
3
+ import * as path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ const PLATFORM_TO_PACKAGE = {
6
+ 'x86_64-linux': '@aztec/wsdb-linux-x64',
7
+ 'x86_64-darwin': '@aztec/wsdb-darwin-x64',
8
+ 'aarch64-linux': '@aztec/wsdb-linux-arm64',
9
+ 'aarch64-darwin': '@aztec/wsdb-darwin-arm64',
10
+ };
11
+ function currentDir() {
12
+ return path.dirname(fileURLToPath(import.meta.url));
13
+ }
14
+ function detectPlatform() {
15
+ if (process.arch === 'x64' && process.platform === 'linux')
16
+ return 'x86_64-linux';
17
+ if (process.arch === 'x64' && process.platform === 'darwin')
18
+ return 'x86_64-darwin';
19
+ if (process.arch === 'arm64' && process.platform === 'linux')
20
+ return 'aarch64-linux';
21
+ if (process.arch === 'arm64' && process.platform === 'darwin')
22
+ return 'aarch64-darwin';
23
+ return null;
24
+ }
25
+ function findArchPackageDir(platform) {
26
+ const packageName = PLATFORM_TO_PACKAGE[platform];
27
+ try {
28
+ const require = createRequire(import.meta.url);
29
+ return path.dirname(require.resolve(packageName + '/package.json'));
30
+ }
31
+ catch {
32
+ const siblingPackageDir = path.join(currentDir(), '..', 'packages', packageName.split('/').pop());
33
+ return fs.existsSync(path.join(siblingPackageDir, 'package.json')) ? siblingPackageDir : null;
34
+ }
35
+ }
36
+ export function findWsdbBinary(customPath) {
37
+ if (customPath) {
38
+ return fs.existsSync(customPath) ? path.resolve(customPath) : null;
39
+ }
40
+ const envPath = process.env.AZTEC_WSDB_PATH;
41
+ if (envPath) {
42
+ return fs.existsSync(envPath) ? path.resolve(envPath) : null;
43
+ }
44
+ const platform = detectPlatform();
45
+ if (!platform) {
46
+ return null;
47
+ }
48
+ const archDir = findArchPackageDir(platform);
49
+ if (archDir) {
50
+ const candidate = path.join(archDir, 'aztec-wsdb');
51
+ if (fs.existsSync(candidate)) {
52
+ return candidate;
53
+ }
54
+ }
55
+ return null;
56
+ }
57
+ export const ARCH_PACKAGE_STEM = 'wsdb';
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@aztec/wsdb",
3
+ "version": "0.0.1-commit.031e54b",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dest/index.d.ts",
8
+ "default": "./dest/index.js"
9
+ }
10
+ },
11
+ "files": [
12
+ "dest/",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "clean": "rm -rf dest .tsbuildinfo",
17
+ "build": "tsc -p tsconfig.json",
18
+ "prepare_arch_packages": "./scripts/prepare_arch_packages.sh"
19
+ },
20
+ "dependencies": {
21
+ "@aztec/ipc-runtime": "0.0.1-commit.031e54b",
22
+ "msgpackr": "^1.11.2",
23
+ "tslib": "^2.4.0"
24
+ },
25
+ "optionalDependencies": {
26
+ "@aztec/wsdb-linux-x64": "0.0.1-commit.031e54b",
27
+ "@aztec/wsdb-darwin-x64": "0.0.1-commit.031e54b",
28
+ "@aztec/wsdb-linux-arm64": "0.0.1-commit.031e54b",
29
+ "@aztec/wsdb-darwin-arm64": "0.0.1-commit.031e54b"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^22.15.17",
33
+ "typescript": "^5.3.3"
34
+ }
35
+ }