Skip to content

Commit d849dca

Browse files
authored
fix(parser): scanner drops every entity when HEADER FILE_NAME contains '#' (#654) (#657)
CATIA emits a FILE_NAME with a literal `#` inside the quoted filename (`'…\X0\2#.ifc'`). EntityScanner's `memchr('#')` anchor latched onto the in-string `#`, then find_entity_end started with the wrong quote-parity assumption and skipped every `;` for the rest of the file. The scanner returned 0 entities — IFCLite Viewer showed properties but no geometry. Parser fix: skip past `DATA;` on construction (quote-aware, handles `''` escaped pairs), and require `#` to be followed by a digit before treating it as an entity anchor. Matches the validation already in `build_entity_index` and the TS StepTokenizer. Three regression tests. Build pipeline: stop committing the wasm bundles to git. The original symptom for #654 was stale `.wasm` shipping to production, and during this PR we hit it twice — once when cargo's incremental cache reused stale `ifc-lite-core`, once when a merge-conflict resolution picked the wrong bytes. Pipeline now rebuilds wasm from Rust source on every deploy: turbo wires the wasm packages into the workspace build graph; Vercel install/build scripts bootstrap the Rust toolchain and propagate the env through turbo subprocesses; the Desktop Compatibility CI workflow installs Rust + wasm-pack too. Most deploys are JS-only and hit turbo's content cache, paying ~0 s extra; Rust-touching deploys add ~30-60 s warm. Verified end-to-end against CatiaBuilding.ifc: 0 → 83 375 entities scanned 0 → 769/770 walls with mesh; all doors/slabs/windows with mesh Closes #654.
1 parent 384efaa commit d849dca

21 files changed

Lines changed: 387 additions & 10513 deletions

File tree

.github/workflows/desktop-compat.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ name: Desktop Compatibility
88
on:
99
pull_request:
1010
paths:
11-
# Only run when shared code that the desktop app consumes changes
11+
# Run when shared code the desktop app consumes changes, OR when the
12+
# Rust sources that produce the WASM bundle change (we no longer
13+
# commit the .wasm — see #654 — so the desktop frontend build has to
14+
# rebuild it from source via turbo).
1215
- 'apps/viewer/src/**'
1316
- 'packages/*/src/**'
14-
- 'packages/wasm/pkg/**'
1517
- 'apps/desktop/**'
18+
- 'rust/core/src/**'
19+
- 'rust/geometry/src/**'
20+
- 'rust/wasm-bindings/src/**'
21+
- 'rust/**/Cargo.toml'
22+
- 'Cargo.lock'
23+
- 'rust-toolchain.toml'
24+
- 'scripts/build-wasm.sh'
1625

1726
concurrency:
1827
group: ${{ github.workflow }}-${{ github.ref }}
@@ -42,6 +51,20 @@ jobs:
4251
node-version: 22
4352
cache: pnpm
4453

54+
# WASM bundles are no longer committed (see #654); turbo's wasm
55+
# packages rebuild from source via scripts/build-wasm.sh, which
56+
# needs a Rust toolchain matching rust-toolchain.toml + wasm-pack.
57+
- name: Setup Rust (pinned by rust-toolchain.toml)
58+
run: rustup show
59+
60+
- name: Cargo cache
61+
uses: Swatinem/rust-cache@v2
62+
63+
- name: Install wasm-pack
64+
uses: jetli/wasm-pack-action@v0.4.0
65+
with:
66+
version: latest
67+
4568
- name: Install dependencies
4669
run: pnpm install --frozen-lockfile
4770

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ test_*.sh
4545
# WASM files - use packages/wasm/pkg/ as canonical source
4646
apps/viewer/public/ifc-lite_bg.wasm
4747

48+
# WASM build outputs — not committed; produced from rust/** by
49+
# scripts/build-wasm.sh on every fresh build. CI and Vercel install the
50+
# Rust toolchain and rebuild from source so a stale binary can never
51+
# ship (issue #654 root cause was a stale committed .wasm bundle).
52+
# The README.md and package.json in these dirs stay tracked.
53+
packages/wasm/pkg/ifc-lite_bg.wasm
54+
packages/wasm/pkg/ifc-lite_bg.wasm.d.ts
55+
packages/wasm/pkg/ifc-lite.js
56+
packages/wasm/pkg/ifc-lite.d.ts
57+
packages/wasm-threaded/pkg/ifc-lite_bg.wasm
58+
packages/wasm-threaded/pkg/ifc-lite_bg.wasm.d.ts
59+
packages/wasm-threaded/pkg/ifc-lite.js
60+
packages/wasm-threaded/pkg/ifc-lite.d.ts
61+
packages/wasm-threaded/pkg/snippets/
62+
4863
# Tauri/Claude temp files
4964
tmpclaude*
5065
nul

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,17 @@ Ready-to-run projects in [`examples/`](examples/):
235235

236236
## Contributing
237237

238-
No Rust toolchain needed — WASM comes pre-built.
238+
The WASM bundle is built from `rust/` on every fresh build, so a Rust
239+
toolchain is required. `rust-toolchain.toml` pins the nightly channel
240+
and the `wasm32-unknown-unknown` target — `rustup show` (or the
241+
contributing setup guide) installs everything needed.
239242

240243
```bash
244+
# 1. Rust toolchain (one-time)
245+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
246+
cargo install wasm-pack # or: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
247+
248+
# 2. Clone and build
241249
git clone https://github.com/louistrue/ifc-lite.git
242250
cd ifc-lite
243251
pnpm install && pnpm build && pnpm dev # opens viewer at localhost:5173

apps/viewer-embed/vercel.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://openapi.vercel.sh/vercel.json",
3-
"buildCommand": "cd ../.. && pnpm install --frozen-lockfile && npx turbo build --filter=@ifc-lite/viewer-embed...",
4-
"installCommand": "echo 'handled by buildCommand'",
3+
"installCommand": "cd ../.. && bash scripts/vercel-install.sh",
4+
"buildCommand": "cd ../.. && bash scripts/vercel-build.sh '@ifc-lite/viewer-embed...'",
55
"outputDirectory": "dist",
66
"framework": "vite",
77
"headers": [

packages/wasm-threaded/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
],
99
"description": "Thread-enabled WebAssembly bindings for IFC-Lite (uses wasm-bindgen-rayon for in-WASM parallelism). Requires cross-origin isolation (COOP/COEP). Generated by `THREADED=1 scripts/build-wasm.sh`.",
1010
"version": "0.1.0",
11+
"scripts": {
12+
"build": "THREADED=1 bash ../../scripts/build-wasm.sh"
13+
},
1114
"license": "MPL-2.0",
1215
"repository": {
1316
"type": "git",

0 commit comments

Comments
 (0)