Files
Web_FreeCAD_Bitbybit/native/occt-history

Native OCCT history provider

This provider is compiled from the cached OCCT checkout selected by OCCT_SOURCE_DIR and exposes the native Boolean history API through Emscripten Embind. The provider keeps TopoDS_Shape handles and history queries in one WASM instance. A handle from @bitbybit-dev/occt must never be passed directly to this module because WebAssembly linear memories are independent.

Build and verify it with the project wrapper:

./npmw run build:occt-history
./npmw run test:occt-history

The build also publishes the JS/WASM pair to public/native/occt-history/, which is the default URL used by NativeOcctHistoryWorkerProvider. The generated artifacts remain ignored; a clean checkout must run the build after restoring the pinned OCCT source and Emscripten toolchain.

The exported booleanHistory(object, tool, operation) function supports fuse, cut, and common. It returns the native result shape, per-input modified/generated/deleted records, and capability flags. The provider also exports shapeToStep(shape) and booleanHistoryFromStep(objectStep, toolStep, operation). The latter is the cross-WASM transport: Bitbybit exports STEP text, the native provider reads it with STEPControl_Reader, returns the Boolean result again as resultStep, and no linear-memory pointer crosses the boundary.

The TypeScript boundary mapper is mapNativeOcctHistoryRecords; the reusable createNativeOcctStepHistoryBridge exports Bitbybit ShapeHandles to STEP and converts provider source names into document object IDs before calling captureNativeTopologyHistory. The direct handle API remains for calls that stay inside this single native WASM instance.