Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"semi": true,
"singleQuote": false,
"printWidth": 100,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always",
"tabWidth": 4,
"sortPackageJson": false,
"ignorePatterns": []
}
44 changes: 44 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["typescript", "unicorn", "oxc"],
"categories": {
"correctness": "error",
"suspicious": "warn"
},
"env": {
"builtin": true,
"browser": true
},
"ignorePatterns": [
"dist/**",
"assets/**",
"node_modules/**",
"dependency_sources/**",
"drivers/**",
"async-engine/**",
"webendpoint-cpp/**",
"emsdk/**"
],
"overrides": [
{
"files": ["**/*.test.ts", "**/__tests__/**", "**/__mocks__/**"],
"plugins": ["jest"],
"rules": {
"jest/expect-expect": "off",
"jest/require-to-throw-message": "off"
}
}
],
"rules": {
"no-console": "off",
"no-shadow": "off",
"no-useless-constructor": "off",
"preserve-caught-error": "off",
"typescript/no-extraneous-class": "off",
"unicorn/prefer-query-selector": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-array-reduce": "off",
"unicorn/prefer-add-event-listener": "off",
"unicorn/require-post-message-target-origin": "off"
}
}
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,41 @@ The project uses a combined pipeline to compile the C++ core to Wasm and bundle

| Command | Description |
| --- | --- |
| `npm run build` | Runs the full pipeline: Clean -> Build Wasm -> Compile TS -> Bundle Webpack. |
| `npm run build:wasm` | Compiles the C++ source code to WebAssembly using `scripts/pipeline.sh`. |
| `npm run build` | Full release build: Clean → Build Wasm → Compile TS → Bundle Webpack. |
| `npm run build:debug` | Full debug build (see below). |
| `npm run build:wasm` | Compiles the C++ source to WebAssembly (release flags). |
| `npm run build:wasm:debug` | Compiles the C++ source to WebAssembly (debug flags). |
| `npm run build:js` | Compiles TypeScript (`tsc`) and bundles assets (`webpack`). |
| `npm run watch:types` | Watches for TypeScript changes. |

### Release vs Debug builds

By default all builds are **release** builds: `-O3`, LTO enabled, `ASSERTIONS=0`, `SAFE_HEAP=0`.

A **debug** build swaps in the following flags for the WASM module:

| Flag | Release | Debug |
| --- | --- | --- |
| Optimisation | `-O3` + `-flto` | `-O0 -g` |
| Emscripten assertions | `ASSERTIONS=0` | `ASSERTIONS=2` |
| Heap safety checks | `SAFE_HEAP=0` | `SAFE_HEAP=1` |
| Stack overflow check | off | `STACK_OVERFLOW_CHECK=2` |
| Demangled stack traces | off | `DEMANGLE_SUPPORT=1` |
| C++ `DEBUG` macro | not defined | defined |

```bash
# Full debug build (WASM + JS)
npm run build:debug

# WASM only (faster iteration)
npm run build:wasm:debug

# Or pass the env variable directly to the pipeline script
PRIVMX_BUILD_TYPE=debug npm run build:wasm
```

> **Note:** Debug builds are significantly larger and slower than release builds. Use them only for local development and troubleshooting.

## Testing

The project employs a dual testing strategy: **Jest** for unit logic and **Playwright** for End-to-End (E2E) integration testing.
Expand Down
26 changes: 21 additions & 5 deletions async-engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,27 @@ Threads::Threads
Pson
)

target_compile_options(asyncengine PUBLIC
-O3
-pthread
-fexceptions # Ensure exceptions are enabled for async logic
)
# ---------------------------------------------------------------------------
# Build variant: release (default) or debug
# ---------------------------------------------------------------------------
set(PRIVMX_BUILD_TYPE "release" CACHE STRING "Build variant: release or debug")

if(PRIVMX_BUILD_TYPE STREQUAL "debug")
message(STATUS "Building asyncengine: DEBUG")
target_compile_options(asyncengine PUBLIC
-O0 -g
-pthread
-fexceptions
-DDEBUG
)
else()
message(STATUS "Building asyncengine: RELEASE")
target_compile_options(asyncengine PUBLIC
-O3
-pthread
-fexceptions
)
endif()

target_link_options(asyncengine PUBLIC
-L $ENV{SDK_DIR}/upstream/emscripten/cache/sysroot/lib
Expand Down
19 changes: 14 additions & 5 deletions drivers/privmx-webendpoint-drv-crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ add_library(privmxdrvcrypto ${SOURCES})
target_include_directories(privmxdrvcrypto PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_target_properties(privmxdrvcrypto PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/privmx/drv/crypto.h)
target_link_libraries(privmxdrvcrypto embind)
target_compile_options(privmxdrvcrypto PUBLIC
-O3
-pthread
)
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
# ---------------------------------------------------------------------------
# Build variant: release (default) or debug
# ---------------------------------------------------------------------------
set(PRIVMX_BUILD_TYPE "release" CACHE STRING "Build variant: release or debug")

if(PRIVMX_BUILD_TYPE STREQUAL "debug")
message(STATUS "Building privmxdrvcrypto: DEBUG")
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
target_compile_options(privmxdrvcrypto PUBLIC -O0 -g -pthread -DDEBUG)
else()
message(STATUS "Building privmxdrvcrypto: RELEASE")
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
target_compile_options(privmxdrvcrypto PUBLIC -O3 -pthread)
endif()
target_link_options(privmxdrvcrypto PUBLIC
-sUSE_PTHREADS
-sEXPORTED_RUNTIME_METHODS=['HEAPU8','ccall']
Expand Down
19 changes: 14 additions & 5 deletions drivers/privmx-webendpoint-drv-ecc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ target_include_directories(privmxdrvecc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/incl
set_target_properties(privmxdrvecc PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/privmx/drv/ecc.h)
target_link_libraries(privmxdrvecc)
target_link_libraries(privmxdrvecc embind)
target_compile_options(privmxdrvecc PUBLIC
-O3
-pthread
)
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
# ---------------------------------------------------------------------------
# Build variant: release (default) or debug
# ---------------------------------------------------------------------------
set(PRIVMX_BUILD_TYPE "release" CACHE STRING "Build variant: release or debug")

if(PRIVMX_BUILD_TYPE STREQUAL "debug")
message(STATUS "Building privmxdrvecc: DEBUG")
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
target_compile_options(privmxdrvecc PUBLIC -O0 -g -pthread -DDEBUG)
else()
message(STATUS "Building privmxdrvecc: RELEASE")
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
target_compile_options(privmxdrvecc PUBLIC -O3 -pthread)
endif()
target_link_options(privmxdrvecc PUBLIC
-L $ENV{SDK_DIR}/upstream/emscripten/cache/sysroot/lib
-sUSE_PTHREADS
Expand Down
19 changes: 14 additions & 5 deletions drivers/privmx-webendpoint-drv-net/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ add_library(privmxdrvnet ${SOURCES})
target_include_directories(privmxdrvnet PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
set_target_properties(privmxdrvnet PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/privmx/drv/net.h)
target_link_libraries(privmxdrvnet PRIVATE embind)
target_compile_options(privmxdrvnet PUBLIC
-O3
-pthread
)
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
# ---------------------------------------------------------------------------
# Build variant: release (default) or debug
# ---------------------------------------------------------------------------
set(PRIVMX_BUILD_TYPE "release" CACHE STRING "Build variant: release or debug")

if(PRIVMX_BUILD_TYPE STREQUAL "debug")
message(STATUS "Building privmxdrvnet: DEBUG")
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
target_compile_options(privmxdrvnet PUBLIC -O0 -g -pthread -DDEBUG)
else()
message(STATUS "Building privmxdrvnet: RELEASE")
set(CMAKE_CXX_FLAGS "-std=c++17 -fexceptions -pthread")
target_compile_options(privmxdrvnet PUBLIC -O3 -pthread)
endif()
target_link_options(privmxdrvnet PUBLIC
-L $ENV{SDK_DIR}/upstream/emscripten/cache/sysroot/lib
-sUSE_PTHREADS
Expand Down
95 changes: 0 additions & 95 deletions eslint.config.mjs

This file was deleted.

Loading
Loading