# STEP preview corresponding-source distribution

This directory is part of the same candidate distribution as the STEP preview
library. Downloads are local to this website; no third-party source download is
required to obtain the supplied source archives. Nothing here is preloaded by
ordinary visitors. No source archive was built or executed for this packaging.

## Included source and identities

- occt-import-js-c2148e54b456b571238d35cac037d304053d64b2.tar.gz: complete wrapper repository snapshot, including C++ source, CMake, tests and build scripts.
- OCCT-d2abb6d844231cb8f29be6894440874a4700e4a5.tar.gz: complete matching Open CASCADE Technology 7.6.1 source snapshot.
- occt-import-js-0.0.23-npm.tgz: exact original published package, including the unmodified JS/WASM and wrapper source.
- cap-wasm-memory.py: Ultra3D's WASM binary modification. Sets maximum linear memory to 4096 pages (256 MiB), leaving minimum457pages and all other sections unchanged.
- integration/: modifiable Ultra3D preview glue source, pinned esbuild build package and generated worker.
- SOURCE-MANIFEST.json and SHA256SUMS.txt: origin records, sizes and local hashes.
- SOURCE-COMPARISON.json: all27 selected C++/header/build/package source files match between npm and the registry gitHead after CR line-ending normalization.

Original library license texts are ../license.occt-import-js.txt and
../license.occt.txt, plus OCCT_LGPL_EXCEPTION.txt. Preserve those notices and applicable upstream copyright
notices when distributing modified versions. The newly authored memory patch, STEP worker, core validator and worker bridge
are provided under LGPL-2.1-or-later. Existing viewer source is included for
rebuilding the integration; its pre-existing copyright/license terms are unchanged.
No Ultra3D restriction on reverse engineering for debugging modifications to
this library component is imposed by these source-distribution instructions.

## Build source layout

Extract the wrapper archive in your own working directory. Extract the OCCT
archive and place its contents in the wrapper's occt/ directory (the gitlink
placeholder is not the OCCT source). The exact source identities above are
pinned, not floating branches. SHA256SUMS.txt verifies downloaded archive bytes.

The wrapper's README.md, CMakeLists.txt, .github/workflows/wasm_build.yml and
 tools/build_wasm_win.bat are the authoritative included build instructions.
The supplied setup script selects Emscripten3.1.69 and mingw7.1.0-64bit. Its CI
uses Windows2022 and Node18.x. Install CMake and these official compiler tools
in your own development environment, then use tools/build_wasm_win.bat Release.
Review scripts before running; this distribution does not automatically install
compilers or run source. Toolchains are separate general-purpose prerequisites.

The GitHub snapshot's committed dist WASM does not byte-match npm's published
WASM. Source/build files compared as above match, but a fresh compiler build has
not been performed or proven byte-for-byte reproducible. Use the included npm
package dist/ files for the exact original binary corresponding to this candidate.
This distinction is disclosed rather than claiming a verified reproducible build.

## Apply or change the memory modification

Run cap-wasm-memory.py on the npm package's dist/occt-import-js.wasm, supplying a
new output filename. The script never overwrites the original or an existing
output. Expected original SHA256:
33391fc9d94ea5c869a6718488bf0a9a464222bac9bdc764dfe1690cef281952
Expected capped candidate SHA256:
ba770b01d8aaa0f079839c6af26645dacf09c36fb4fd01c7cf31b5095faf0279

To modify a freshly built library, inspect its memory declaration and adapt the
provided patch source as needed. Do not claim that256MiB limits total browser
memory: it only limits WASM linear memory, not worker JS allocations.

## Replace/relink in a private copy

The application loads the library separately in a disposable worker. There is
no signature, server-side attestation or remote approval required to replace it
in your own copy. Place your modified JS/WASM at the same vendor paths in that
copy, retaining the exported occtimportjs/ReadStepFile interface or modifying the
glue accordingly. The worker deliberately checks a hardcoded WASM SHA256 to
protect users from unintended runtime substitution, so update that check too:

1. Calculate the SHA256 of your replacement WASM.
2. Edit integration/step-preview-worker-source.js: replace the digest string
   with your new digest. Adjust its runtime path/limits if your build differs.
3. In integration/, install the pinned build dependency from package.json.
4. Run npm run build:worker. Copy the resulting step-preview-worker.js into
   your private site's /quote/ directory. If changing viewer glue, npm run
   build:viewer produces model-preview.bundle.js for that directory.
5. Preserve the worker-only CSP allowing same-origin scripts/connections and
   wasm-unsafe-eval. Serve .wasm as application/wasm over HTTPS or localhost.
6. Re-test your modified model handling and limits. Library changes may alter
   performance, compatibility or safety. No price estimation is added by this
   preview: the unchanged original attachment remains the quote input.

These source files and instructions provide an actual same-site source-delivery
arrangement rather than only third-party links. They do not constitute legal
advice or a claim that every distribution/license obligation has been audited.

## Static JavaScript glue patch (2026-11-11)
Apply patch-embind-static.py to the original npm package dist/occt-import-js.js,
supplying a new output path. It checks the original source hash and replaces
both generated embind/emval invokers with static closures. The unused legacy
global lookup rejects absent globalThis instead of executing strings. This
allows STEP preview without adding unsafe-eval to the worker's CSP. The patch
source is LGPL-2.1-or-later and independently reproducible; it does not execute
the vendor while patching. Source hash identities are in ../NOTICE.md.
When rebuilding a different library version, inspect the compiler-generated
glue and use Emscripten DYNAMIC_EXECUTION=0 where supported, or adapt/review the
static patch for that version. Never apply a hash-guarded patch blindly.

The STEP worker loads its fixed WASM asset only from its own HTTP(S) origin, with same-origin browser credentials and redirects rejected. This permits an already authenticated private preview; cross-origin requests and embedded URL credentials fail before fetch. No authentication data is read by application code.
