Electron desktop application for the WE platform. This launcher uses the @we/app-framework package to provide a cross-platform AD4M-powered interface, with Electron-specific platform adapters.
# Install dependencies (Electron binary downloads automatically via postinstall script)
pnpm installNote: The .npmrc file in the workspace root enables lifecycle scripts for Electron binary download. The postinstall script in package.json ensures this works correctly in pnpm workspaces.
The WE Electron launcher:
- Spawns and manages the AD4M executor as a child process
- Provides a SolidJS-based interface using
@we/app-framework - Supports embedding external apps via iframe (e.g., Flux, custom apps)
- Handles platform-specific concerns like IPC, screen sharing, and process management
- Main Process (
electron/main.js):- Starts the AD4M executor as a child process
- Manages HTTP servers for launcher and embedded apps
- Handles IPC for AD4M connection details (port/token)
- Implements screen sharing polyfill for embedded apps
- Preload Script (
electron/preload.js): Exposes secure IPC bridge viawindow.electron - Renderer (
src/): SolidJS app using the shared@we/app-framework - Platform Adapter (
src/platform/electronAdapter.ts): Implements AD4M connection using Electron IPC
Unlike the Tauri app which embeds the Rust executor as a library, the Electron app:
- Spawns the
ad4m-executorbinary as a separate child process - Passes configuration via command-line arguments (port, token, data path)
- Communicates with the frontend via IPC to provide connection details
- The renderer uses these details to connect to the executor's GraphQL API
This launcher can embed external apps (like Flux) via iframe. The embedded apps receive AD4M credentials through a postMessage protocol.
See: EMBEDDING.md for the generic integration pattern.
Screen Sharing: Electron requires a polyfill for getDisplayMedia() to work in iframes:
- The polyfill is injected into embedded apps' HTML at runtime
- Uses Electron's
desktopCapturerAPI under the hood - Requires
webSecurity: falseto allow iframe access to parent's Electron API - See
electron/main.jsfor implementation details
HTTP Servers: In production, both the launcher and embedded apps are served via Express:
- Launcher:
http://localhost:9080 - Embedded apps (e.g., Flux):
http://localhost:8080 - This avoids cross-origin issues between iframe and parent
The Electron app requires the AD4M executor binary to be built. Build it from the ad4m repo:
cd ../../ad4m/cli
cargo build --releaseThis will create the ad4m-executor binary at ad4m/cli/target/release/ad4m-executor.
See DEVELOPMENT.md for setup instructions and optional Flux integration example.