@kokuin/crypto-napi 0.7.0 → 0.7.1

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/lib/binding.d.ts CHANGED
@@ -27,10 +27,10 @@ export type NapiBinding = {
27
27
  verifyBatch(items: Array<NapiVerifyParams>): Promise<Array<boolean>>;
28
28
  blake3Batch(params: NapiBindingBlake3BatchParams): Promise<Array<Uint8Array>>;
29
29
  };
30
- /** Why no native binding loaded, or `undefined` when one did. */
30
+ /** Why no native binding loaded. `path` is absent when the binary's location did not resolve. */
31
31
  export type NapiLoadFailure = {
32
32
  reason: 'missing' | 'abi' | 'load';
33
- path: string;
33
+ path?: string;
34
34
  cause?: unknown;
35
35
  };
36
36
  /** The platform suffix of the binary file name, such as `linux-x64-gnu` or `darwin-arm64`. */
package/lib/binding.js CHANGED
@@ -36,7 +36,20 @@ function libc() {
36
36
  let cached;
37
37
  /** Load the native binding once per process. Never throws; reports why it could not load. */ export function loadNapiBinding() {
38
38
  if (cached != null) return cached;
39
- const path = napiBindingPath();
39
+ let path;
40
+ try {
41
+ path = napiBindingPath();
42
+ } catch (cause) {
43
+ // A CJS bundle leaves `import.meta.url` undefined.
44
+ cached = {
45
+ binding: null,
46
+ failure: {
47
+ reason: 'load',
48
+ cause
49
+ }
50
+ };
51
+ return cached;
52
+ }
40
53
  if (!existsSync(path)) {
41
54
  cached = {
42
55
  binding: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kokuin/crypto-napi",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Strict asynchronous crypto provider backed by the Rust core through Node-API, falling back to @kokuin/crypto-node",
5
5
  "repository": {
6
6
  "type": "git",