Skip to content

Commit d99a233

Browse files
committed
feat: bump duckdb and use our own wrappers
Signed-off-by: Gordon Smith <[email protected]>
1 parent 39b68e0 commit d99a233

26 files changed

+1674
-415
lines changed

.github/copilot-instructions.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,53 @@ npm run build-ws # 5-10 minutes
5757
npm run lint # 2-3 minutes
5858
```
5959

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):
67+
68+
1. **Remove vcpkg cache**: `rm -rf vcpkg/buildtrees/<package>`
69+
2. **Use VS Code Command Palette** (Ctrl/Cmd+Shift+P):
70+
- **`CMake: Configure`** - Reconfigures CMake and reinstalls vcpkg packages with new patches
71+
- **`CMake: Build`** - Builds the configured targets
72+
- **`CMake: Clean Rebuild`** - Cleans and rebuilds everything
73+
74+
**WHY THIS IS REQUIRED**:
75+
- Sets up Emscripten SDK environment variables correctly
76+
- Configures vcpkg toolchain properly
77+
- Handles WASM-specific build flags
78+
- Provides IntelliSense and debugging integration
79+
80+
**DO NOT use manual cmake commands like:**
81+
-`cmake --preset vcpkg-emscripten-*` (will fail with "emcc compiler not found")
82+
-`cmake --build build --target <target>` (won't work without proper environment)
83+
-`ninja <target>` (missing environment and configuration)
84+
85+
**EXCEPTION**: `npm run build-cpp` scripts are pre-configured with the correct environment and are safe to use for full builds.
86+
87+
## Embind (C++ <-> JS Interop)
88+
89+
This repo uses Emscripten Embind to expose C++ APIs to JavaScript/TypeScript.
90+
91+
Reference: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html
92+
93+
### Guidelines
94+
- 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.
106+
60107
## Working Without Full Build
61108

62109
### What Works with npm ci + npm run lint Only

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ types/
2929
/wasi-sdk*
3030
/wit-bindgen
3131
/vcpkg
32+
__screenshots__/
3233
.coveralls.yml
3334
*.tsbuildinfo
3435

.vscode/settings.json

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,5 @@
11
{
22
"cmake.cmakePath": "${workspaceFolder}/scripts/cmake.sh",
33
"vitest.maximumConfigs": 20,
4-
"vitest.configSearchPatternExclude": "{emsdk/**,node_modules/**}",
5-
6-
// AI Assistant Configuration
7-
"github.copilot.enable": {
8-
"*": true,
9-
"markdown": true,
10-
"typescript": true,
11-
"javascript": true
12-
},
13-
14-
// File associations for better AI context
15-
"files.associations": {
16-
"*.idl": "webidl",
17-
"*.wasm": "wasm",
18-
".copilot-*": "markdown"
19-
},
20-
21-
// Exclude build artifacts from AI context
22-
"files.exclude": {
23-
"**/build/**": true,
24-
"**/dist/**": true,
25-
"**/node_modules/**": true,
26-
"**/emsdk/**": true,
27-
"**/vcpkg/**": true,
28-
"**/.nyc_output/**": true
29-
},
30-
31-
// Include important files for AI context
32-
"search.exclude": {
33-
"**/node_modules": true,
34-
"**/emsdk": true,
35-
"**/vcpkg": true,
36-
"**/build": true,
37-
"**/dist": false,
38-
"**/.copilot-*": false
39-
}
4+
"vitest.configSearchPatternExclude": "{emsdk/**,node_modules/**}"
405
}

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
8282
endif ()
8383

8484
add_subdirectory(packages/base91/src-cpp)
85+
add_subdirectory(packages/duckdb/src-cpp)
8586
add_subdirectory(packages/expat/src-cpp)
8687
add_subdirectory(packages/graphviz/src-cpp)
8788
add_subdirectory(packages/llama/src-cpp)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
This repository contains a collection of useful c++ libraries compiled to WASM for (re)use in Node JS, Web Browsers and JavaScript Libraries:
88
- [base91](https://base91.sourceforge.net/) - v0.6.0
9-
- [duckdb](https://github.com/duckdb/duckdb) - v1.4.0
9+
- [duckdb](https://github.com/duckdb/duckdb) - v1.4.3
1010
- [expat](https://libexpat.github.io/) - v2.7.1
1111
- [graphviz](https://www.graphviz.org/) - 14.1.0
1212
- [llama.cpp](https://github.com/ggerganov/llama.cpp) - b3718

0 commit comments

Comments
 (0)