pcbjam/wasm
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Balint Ipkovich d735779e23 feat: pl_editor WASM port + browser file dialog fixes
Brings up KiCad's pagelayout_editor (drawing-sheet editor) in the
browser, to roughly the same "boots, canvas visible, partially usable
in-session" level as the existing pcbnew/eeschema/calculator ports.

Build:
- docker/build.sh: add pl_editor to the unified app dispatch (case,
  subdir map, all-loop).
- scripts/kicad/build-kicad-target.sh: add pl_editor to the case;
  upstream target name pl_editor under source subdir pagelayout_editor.
- scripts/kicad/build-pl_editor.sh: 7-line thin wrapper matching the
  pcbnew/eeschema/calculator pattern.
- tests/scripts/setup-kicad-wasm.sh: copy_app pl_editor.

App glue:
- wasm/stubs/nl_pl_editor_plugin_stub.cpp: no-op SpaceMouse plugin so
  pl_editor_frame.cpp's NL_PL_EDITOR_PLUGIN symbols resolve. Mirrors
  nl_pcbnew_plugin_stub.cpp.
- tests/apps/kicad/pl_editor.html: browser shell. preRun creates
  /home/kicad and FS.chdir there so file dialogs land somewhere
  friendly instead of MEMFS root (/dev/, /proc/, etc.).

E2E coverage:
- tests/kicad/pl_editor.spec.ts: 5 tests — smoke (canvas, no abort),
  wizard, File menu has Open/Save As, file-dialog folder-navigation
  regression, canvas + toolbar metrics.
- tests/e2e/filedialog-folder-nav.spec.ts: wxWidgets-level twin of
  the regression test (exercises the underlying widget directly via
  the standalone filedialog_test app).

Submodule bumps:
- kicad → feature/pl-editor (WASM gating in pagelayout_editor's
  CMakeLists + navlib stub).
- wxwidgets → feature/pl-editor (wxGenericFileDialog::OnOk navigates
  into selected directories; wasm/mouse.cpp emits wxEVT_LEFT_DCLICK
  via timestamp-based double-click detection — the latter benefits
  every wxWidgets-WASM app).

See features/pl-editor/ for the design doc + per-repo diff patches.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 10:30:56 +02:00
..
bindings add calculator build 2026-05-28 17:28:17 +02:00
cmake feat(schematic): eeschema WASM build + e2e harness 2026-05-29 16:01:17 +02:00
kiplatform wasm: validate kicad hi-dpi scaling 2026-03-22 12:48:05 +01:00
libcontext Add KiCad WASM build infrastructure and dependency scripts 2025-12-04 13:15:04 +01:00
shims feat(webgl): Fix GL initialization and add GLSL ES shader conversion 2026-01-07 21:59:21 +01:00
stubs feat: pl_editor WASM port + browser file dialog fixes 2026-06-01 10:30:56 +02:00
CMakeLists.txt Add KiCad WASM build infrastructure and dependency scripts 2025-12-04 13:15:04 +01:00
README.md Add KiCad WASM build infrastructure and dependency scripts 2025-12-04 13:15:04 +01:00

WASM Compatibility Layer

This directory contains WASM-specific implementations that allow KiCad to run in a web browser without modifying KiCad's source code.

Principle

Instead of patching KiCad source files, we:

  1. Override include paths to use our headers first
  2. Provide alternative implementations for platform-specific code
  3. Link our libraries instead of system libraries

Directory Structure

wasm/
├── CMakeLists.txt          # Master CMake for compatibility layer
├── README.md               # This file
├── kiplatform/             # Platform abstraction implementations
│   ├── CMakeLists.txt
│   ├── app.cpp             # App lifecycle (paths, startup)
│   ├── drivers.cpp         # GPU detection (returns "WebGL")
│   ├── environment.cpp     # Environment variables (localStorage)
│   ├── io.cpp              # File I/O (WASM virtual filesystem)
│   ├── policy.cpp          # Security policy (always permissive)
│   ├── secrets.cpp         # Credential storage (localStorage)
│   ├── sysinfo.cpp         # System information
│   └── printing.cpp        # Print support (browser print())
├── libcontext/             # Coroutine/fiber implementation
│   ├── CMakeLists.txt
│   └── fcontext_wasm.cpp   # Emscripten Asyncify fibers
├── shims/                  # Header overrides
│   └── *.h                 # Headers that redirect to our impls
└── config/                 # Build configuration
    ├── kicad_wasm_config.h # Version and feature config
    └── setup.h             # Platform setup

How It Works

Include Path Override

When building KiCad for WASM, we add our directories first in the include path:

-I$PROJECT_ROOT/wasm/shims
-I$PROJECT_ROOT/wasm/kiplatform
-I$PROJECT_ROOT/stubs/include

This means when KiCad includes <kiplatform/app.h>, it finds our version first.

Library Override

We build libkiplatform_wasm.a and link it instead of the native kiplatform:

-L$BUILD_ROOT/wasm -lkiplatform_wasm

CMake Integration

The main KiCad build is configured to find our implementations:

-DCMAKE_MODULE_PATH="$PROJECT_ROOT/cmake"
-DKIPLATFORM_LIBRARY="$BUILD_ROOT/wasm/libkiplatform_wasm.a"

Adding New Implementations

  1. Create the implementation file in the appropriate directory
  2. Add it to the CMakeLists.txt
  3. Ensure the header interface matches KiCad's expected interface
  4. Test with a minimal build before full integration