You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+47Lines changed: 47 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,53 @@ npm run build-ws # 5-10 minutes
57
57
npm run lint # 2-3 minutes
58
58
```
59
59
60
+
## CMake Configuration
61
+
62
+
### **CRITICAL**: ALWAYS Use VS Code CMake Extension
63
+
64
+
**YOU MUST use the VS Code CMake extension for ALL CMake operations.** Manual cmake commands will fail because they don't properly set up the Emscripten environment.
65
+
66
+
**REQUIRED WORKFLOW** when modifying C++ code or vcpkg packages (patches, portfile.cmake):
- Prefer Embind over ad-hoc JS glue when exposing C++ to JS.
95
+
- Avoid throwing across the WASM boundary; catch exceptions in C++ and translate into explicit error results.
96
+
- Be explicit about ownership/lifetime:
97
+
- If you return raw pointers (often created with `new`) via Embind, JS must eventually free them (e.g. via the generated `.delete()` method or `Module.destroy(obj)` depending on how the wrapper is used).
98
+
- If practical, bind smart pointers (e.g. `std::unique_ptr` / `std::shared_ptr`) to make ownership explicit.
99
+
- For JS values, prefer `emscripten::val` and convert at the boundary (e.g. arrays -> `val.isArray()` + `val["length"]`). Validate types and reject non-finite numbers.
100
+
- Keep interop-friendly result types: materialize streaming results where needed for JS access patterns.
101
+
102
+
### Common Patterns Used Here
103
+
-`EMSCRIPTEN_BINDINGS(...)` with `emscripten::class_<T>` and `.function(...)`.
104
+
-`allow_raw_pointers()` is used for functions that accept/return pointer types.
105
+
- Provide small helper conversions (JS `val` -> C++ types) and centralize error messages for predictable JS behavior.
0 commit comments