@aztec/native 3.0.0-nightly.20251002 → 3.0.0-nightly.20251004

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.
@@ -1 +1 @@
1
- {"version":3,"file":"native_module.d.ts","sourceRoot":"","sources":["../src/native_module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,UAAU,eAAe;IACvB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;CAC3C;AAID,eAAO,MAAM,gBAAgB,EAAE,eAAyC,CAAC;AACzE,eAAO,MAAM,eAAe,EAAE,eAAwC,CAAC"}
1
+ {"version":3,"file":"native_module.d.ts","sourceRoot":"","sources":["../src/native_module.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,UAAU,eAAe;IACvB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;CAC3C;AA2BD,eAAO,MAAM,gBAAgB,EAAE,eAAyC,CAAC;AACzE,eAAO,MAAM,eAAe,EAAE,eAAwC,CAAC"}
@@ -1,4 +1,21 @@
1
- import bindings from 'bindings';
2
- const nativeModule = bindings('nodejs_module');
1
+ import { createRequire } from 'module';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ function loadNativeModule() {
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = dirname(__filename);
7
+ // Map Node.js platform/arch to build directory names
8
+ const arch = process.arch === 'x64' ? 'amd64' : process.arch;
9
+ const platform = process.platform === 'darwin' ? 'macos' : process.platform;
10
+ const variant = `${arch}-${platform}`;
11
+ const modulePath = join(__dirname, '..', 'build', variant, 'nodejs_module.node');
12
+ try {
13
+ const require = createRequire(import.meta.url);
14
+ return require(modulePath);
15
+ } catch (error) {
16
+ throw new Error(`Failed to load native module for ${variant} from ${modulePath}. ` + `Supported: amd64-linux, arm64-linux, amd64-macos, arm64-macos. ` + `Error: ${error}`);
17
+ }
18
+ }
19
+ const nativeModule = loadNativeModule();
3
20
  export const NativeWorldState = nativeModule.WorldState;
4
21
  export const NativeLMDBStore = nativeModule.LMDBStore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/native",
3
- "version": "3.0.0-nightly.20251002",
3
+ "version": "3.0.0-nightly.20251004",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js"
@@ -12,20 +12,18 @@
12
12
  "clean:cpp": "rm -rf $(git rev-parse --show-toplevel)/barretenberg/cpp/build-pic",
13
13
  "clean": "rm -rf ./dest .tsbuildinfo",
14
14
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
15
- "generate": "mkdir -p build && cp -v $(git rev-parse --show-toplevel)/barretenberg/cpp/build-pic/lib/nodejs_module.node build"
15
+ "generate": "bash scripts/copy-modules.sh"
16
16
  },
17
17
  "inherits": [
18
18
  "../package.common.json",
19
19
  "./package.local.json"
20
20
  ],
21
21
  "dependencies": {
22
- "@aztec/foundation": "3.0.0-nightly.20251002",
23
- "bindings": "^1.5.0",
22
+ "@aztec/foundation": "3.0.0-nightly.20251004",
24
23
  "msgpackr": "^1.11.2"
25
24
  },
26
25
  "devDependencies": {
27
26
  "@jest/globals": "^30.0.0",
28
- "@types/bindings": "^1.5.5",
29
27
  "@types/jest": "^30.0.0",
30
28
  "@types/node": "^22.15.17",
31
29
  "jest": "^30.0.0",
@@ -35,6 +33,7 @@
35
33
  "files": [
36
34
  "dest",
37
35
  "src",
36
+ "build",
38
37
  "!*.test.*"
39
38
  ],
40
39
  "engines": {
@@ -1,4 +1,6 @@
1
- import bindings from 'bindings';
1
+ import { createRequire } from 'module';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
2
4
 
3
5
  import type { MessageReceiver } from './msgpack_channel.js';
4
6
 
@@ -6,7 +8,30 @@ interface NativeClassCtor {
6
8
  new (...args: unknown[]): MessageReceiver;
7
9
  }
8
10
 
9
- const nativeModule: Record<string, NativeClassCtor> = bindings('nodejs_module');
11
+ function loadNativeModule(): Record<string, NativeClassCtor> {
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ // Map Node.js platform/arch to build directory names
16
+ const arch = process.arch === 'x64' ? 'amd64' : process.arch;
17
+ const platform = process.platform === 'darwin' ? 'macos' : process.platform;
18
+ const variant = `${arch}-${platform}`;
19
+
20
+ const modulePath = join(__dirname, '..', 'build', variant, 'nodejs_module.node');
21
+
22
+ try {
23
+ const require = createRequire(import.meta.url);
24
+ return require(modulePath);
25
+ } catch (error) {
26
+ throw new Error(
27
+ `Failed to load native module for ${variant} from ${modulePath}. ` +
28
+ `Supported: amd64-linux, arm64-linux, amd64-macos, arm64-macos. ` +
29
+ `Error: ${error}`,
30
+ );
31
+ }
32
+ }
33
+
34
+ const nativeModule: Record<string, NativeClassCtor> = loadNativeModule();
10
35
 
11
36
  export const NativeWorldState: NativeClassCtor = nativeModule.WorldState;
12
37
  export const NativeLMDBStore: NativeClassCtor = nativeModule.LMDBStore;