---
epic: 9
story: 9.1
title: "WASM Engine Integration"
status: draft
---

## Epic 9 — Web App (React + WASM)
**Goal:** Zero-install web experience with real-time collaboration.

### Story 9.1: WASM Engine Integration

As a web user,
I want the CalcPad engine running natively in my browser via WebAssembly,
So that I get full calculation fidelity without installing anything.

**Acceptance Criteria:**

**Given** the calcpad-engine Rust crate is configured with wasm-pack targets
**When** the WASM module is compiled with `wasm-pack build --target web`
**Then** a valid `.wasm` binary and JS glue code are produced
**And** the gzipped WASM bundle is less than 500KB

**Given** the web app is loaded in a browser
**When** the WASM engine is initialized
**Then** it is loaded inside a dedicated Web Worker thread
**And** the main UI thread remains unblocked during computation

**Given** the WASM engine is running in a Web Worker
**When** the UI sends an evaluation request
**Then** communication occurs via `postMessage` serialization
**And** the worker returns the computed result back to the main thread via `postMessage`

**Given** the WASM engine is initialized in the worker
**When** a user types a valid CalcPad expression
**Then** the engine evaluates it with identical results to the native Rust engine
**And** all supported operations (arithmetic, units, conversions, variables, functions) produce matching output
