occt-gltf-addon 0.1.1 → 0.1.3

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/README.md CHANGED
@@ -2,22 +2,25 @@
2
2
 
3
3
  Node.js N-API 原生扩展:使用 OpenCascade (OCCT) 将 **STEP (.step/.stp)** 转换为 **glTF 2.0 (GLB)**。
4
4
 
5
- #### 安装(从 npm 安装会本地编译)
5
+ #### 安装
6
6
 
7
- 这个包默认会在 `npm install` 时执行本地编译(`cmake-js`)。
7
+ - **Linux x64(Ubuntu 等)**:默认会安装预编译包 `occt-gltf-addon-linux-x64`(包含 OCCT runtime),一般 **不需要系统安装 OCCT**。
8
+ - **macOS / 其他平台**:默认会在 `npm install` 时本地编译(`cmake-js`),需要 OCCT 开发文件(headers + libs)。
8
9
 
9
- 你需要:
10
- - **CMake + C++ 编译器 + Python3**
11
- - **OCCT 安装**(共享库 + headers)
12
-
13
- 通过环境变量指定 OCCT 安装前缀:
10
+ 本地编译时通过环境变量指定 OCCT 安装前缀:
14
11
 
15
12
  ```bash
16
13
  export OCCT_ROOT=/path/to/occt/prefix
17
14
  npm i occt-gltf-addon
18
15
  ```
19
16
 
20
- 可选(启用 Draco 压缩需要开发包):
17
+ 如需在 linux-x64 **强制源码编译**(不推荐,且需要你自己装 OCCT):
18
+
19
+ ```bash
20
+ OCCT_GLTF_ADDON_FORCE_BUILD=1 OCCT_ROOT=/path/to/occt/prefix npm i occt-gltf-addon
21
+ ```
22
+
23
+ 可选(仅在 **源码编译** 时用于启用 Draco 支持,需要开发包):
21
24
  - `brew install draco` / `apt-get install libdraco-dev`
22
25
 
23
26
  如需跳过编译(不推荐,运行时会找不到 `.node`):
package/index.js CHANGED
@@ -40,9 +40,10 @@ const msg = [
40
40
  '[occt-gltf-addon] Failed to load native addon (.node).',
41
41
  `Tried: ${candidates.map((p) => JSON.stringify(p)).join(', ')}`,
42
42
  '',
43
- 'If you installed from npm, ensure native build succeeded:',
44
- '- CMake + C++ toolchain are installed',
45
- "- OCCT is installed and OCCT_ROOT points to its install prefix (e.g. '/opt/homebrew', '/usr', '/usr/local', or your custom install)",
43
+ 'If you installed from npm:',
44
+ '- On linux-x64: you should get the prebuilt optional dependency `occt-gltf-addon-linux-x64` (no system OCCT required).',
45
+ ' Ensure optional deps are enabled (do NOT use `--no-optional`).',
46
+ '- Otherwise / if building from source: ensure CMake + C++ toolchain are installed, and OCCT_ROOT points to your OCCT install prefix',
46
47
  '',
47
48
  "You can try: 'npm rebuild occt-gltf-addon' (with OCCT_ROOT exported).",
48
49
  ].join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "occt-gltf-addon",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "STEP (.step/.stp) to glTF (GLB) converter using OpenCascade (OCCT) via a Node.js N-API addon",
5
5
  "type": "commonjs",
6
6
  "main": "index.js",
@@ -63,7 +63,7 @@
63
63
  "docker:image:linux-amd64:nocache": "docker buildx build --no-cache --platform linux/amd64 -f docker/Dockerfile.linux-amd64 -t occt-addon-build:linux-amd64 ../.."
64
64
  },
65
65
  "optionalDependencies": {
66
- "occt-gltf-addon-linux-x64": "0.1.0"
66
+ "occt-gltf-addon-linux-x64": "0.1.3"
67
67
  },
68
68
  "dependencies": {
69
69
  "cmake-js": "^7.3.1",
@@ -43,8 +43,27 @@ function main() {
43
43
  note(`Using prebuilt binary from ${prebuiltName}; skipping local build.`);
44
44
  return;
45
45
  } catch (e) {
46
- // Prebuilt missing or not loadable (e.g. GLIBC mismatch). Fall back to local build.
47
- note(`Prebuilt package ${prebuiltName} not usable; falling back to local build.`);
46
+ // Prebuilt missing or not loadable (e.g. GLIBC mismatch).
47
+ // On Linux, the default expectation is to use the prebuilt package (no system OCCT required).
48
+ // Only fall back to local build when the user explicitly opts in.
49
+ const detail = String(e && (e.stack || e.message || e));
50
+ if (e && e.code === 'MODULE_NOT_FOUND') {
51
+ note(`Prebuilt package ${prebuiltName} is not installed (MODULE_NOT_FOUND).`);
52
+ note('This usually means optional dependencies were skipped, or the prebuilt package was not published for this version yet.');
53
+ } else {
54
+ note(`Prebuilt package ${prebuiltName} failed to load.`);
55
+ note(detail);
56
+ }
57
+ const canBuildFromSource =
58
+ process.env.OCCT_GLTF_ADDON_FORCE_BUILD === '1' || !!process.env.OCCT_ROOT;
59
+ if (!canBuildFromSource) {
60
+ note(`Prebuilt package ${prebuiltName} not usable, and OCCT_ROOT is not set.`);
61
+ note('This package is intended to work on Linux via the prebuilt optional dependency.');
62
+ note('Fix: ensure optional dependencies are installed (do NOT use --no-optional).');
63
+ note('Or: set OCCT_ROOT and re-install to build from source (or set OCCT_GLTF_ADDON_FORCE_BUILD=1).');
64
+ process.exit(1);
65
+ }
66
+ note(`Prebuilt package ${prebuiltName} not usable; attempting local build from source...`);
48
67
  }
49
68
  }
50
69