@ox-content/napi 2.65.0 → 2.66.0

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.
Files changed (2) hide show
  1. package/index.js +30 -2
  2. package/package.json +6 -6
package/index.js CHANGED
@@ -1,7 +1,28 @@
1
1
  const { existsSync } = require("fs");
2
2
  const path = require("path");
3
3
 
4
+ function getErrorCode(error) {
5
+ if (error && typeof error === "object" && "code" in error) {
6
+ return error.code;
7
+ }
8
+ }
9
+
10
+ function getErrorMessage(error) {
11
+ if (error && typeof error === "object" && "message" in error) {
12
+ return error.message;
13
+ }
14
+ return String(error);
15
+ }
16
+
17
+ function formatLoadError(target, error) {
18
+ const code = getErrorCode(error);
19
+ const suffix = code ? ` [${code}]` : "";
20
+ return ` - ${target}${suffix}: ${getErrorMessage(error)}`;
21
+ }
22
+
4
23
  function loadBinding() {
24
+ const loadErrors = [];
25
+
5
26
  // 1. Try loading the local binary (napi build output)
6
27
  const napiOutput = path.join(__dirname, "ox-content.node");
7
28
  if (existsSync(napiOutput)) {
@@ -56,12 +77,19 @@ function loadBinding() {
56
77
  if (subPackage) {
57
78
  try {
58
79
  return require(subPackage);
59
- } catch {}
80
+ } catch (error) {
81
+ loadErrors.push(formatLoadError(subPackage, error));
82
+ }
60
83
  }
61
84
 
85
+ const details = loadErrors.length
86
+ ? `\n\nNative load attempts failed:\n${loadErrors.join("\n")}`
87
+ : "";
88
+
62
89
  throw new Error(
63
90
  `@ox-content/napi: No compatible binary found for ${platform}-${arch}. ` +
64
- `If you're working from the repository, run 'nix develop -c vp run build:napi' from the repository root.`,
91
+ `If you're working from the repository, run 'nix develop -c vp run build:napi' from the repository root.` +
92
+ details,
65
93
  );
66
94
  }
67
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ox-content/napi",
3
- "version": "2.65.0",
3
+ "version": "2.66.0",
4
4
  "description": "Node.js bindings for Ox Content - High-performance Markdown parser",
5
5
  "keywords": [
6
6
  "markdown",
@@ -45,10 +45,10 @@
45
45
  ]
46
46
  },
47
47
  "optionalDependencies": {
48
- "@ox-content/binding-darwin-x64": "2.65.0",
49
- "@ox-content/binding-darwin-arm64": "2.65.0",
50
- "@ox-content/binding-linux-x64-gnu": "2.65.0",
51
- "@ox-content/binding-linux-arm64-gnu": "2.65.0",
52
- "@ox-content/binding-win32-x64-msvc": "2.65.0"
48
+ "@ox-content/binding-darwin-x64": "2.66.0",
49
+ "@ox-content/binding-darwin-arm64": "2.66.0",
50
+ "@ox-content/binding-linux-x64-gnu": "2.66.0",
51
+ "@ox-content/binding-linux-arm64-gnu": "2.66.0",
52
+ "@ox-content/binding-win32-x64-msvc": "2.66.0"
53
53
  }
54
54
  }