You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: document --target web (WebAssembly) build alongside native targets
- README.md: add web/WASM to the cross-platform list and a "Run in the
browser" section with the build/serve commands and a brief description
of what degrades on web (SQLite → in-memory transient store, Hone code
editor's native FFI → no-op, MongoDB driver → needs Mango Server proxy).
- CLAUDE.md:
* Project Overview now mentions the self-contained HTML+WASM build.
* Commands section adds the perry compile --target web invocation
and python3 -m http.server (file:// hits CORS).
* New "Web Target Notes" section explaining what __platform__ === 5
triggers in the source: connection-store falls back to webTransient,
Keychain → localStorage, Hone editor degrades, MongoDB needs a proxy,
and CORS swallows telemetry from non-whitelisted origins.
Mango compiles cleanly with Perry 0.4.65's WASM target and renders its
welcome screen ("Welcome to Mango" + "+ New Connection") matching the
native app.
Copy file name to clipboardExpand all lines: CLAUDE.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
5
5
## Project Overview
6
6
7
-
Mango is a native desktop MongoDB GUI built with Perry (TypeScript-to-native compiler). It produces ~7 MB cross-platform binaries targeting macOS (AppKit), iOS (UIKit), Android (Views), Linux (GTK4), and Windows (Win32) from a single TypeScript codebase.
7
+
Mango is a native MongoDB GUI built with Perry (TypeScript-to-native compiler). It produces ~7 MB cross-platform binaries targeting macOS (AppKit), iOS (UIKit), Android (Views), Linux (GTK4), and Windows (Win32) from a single TypeScript codebase. It also compiles to a single self-contained HTML+WebAssembly file via `--target web` for in-browser use.
8
8
9
9
## Commands
10
10
@@ -21,6 +21,12 @@ npm run build:macos # Platform-specific builds
21
21
npm run build:linux
22
22
npm run build:windows
23
23
24
+
# Web (WebAssembly + DOM bridge in a single self-contained HTML file)
25
+
perry compile src/app.ts --target web -o dist/mango.html
26
+
# Serve over HTTP so fetch() works (file:// hits CORS)
27
+
python3 -m http.server 8765 -d dist
28
+
open http://localhost:8765/mango.html
29
+
24
30
# Testing (uses Bun, not Node)
25
31
npm test# All tests
26
32
npm run test:unit # Unit tests only
@@ -44,8 +50,21 @@ bun test tests/connection-store.test.ts # Run a single test file
44
50
45
51
## Key Conventions
46
52
47
-
-**Perry, not Electron:** UI uses Perry's native bindings, not DOM/HTML. No `document`, `window`, or CSS — use Perry widget types and RGBA colors.
53
+
-**Perry, not Electron:** UI uses Perry's native bindings, not DOM/HTML. No `document`, `window`, or CSS — use Perry widget types and RGBA colors. (On the `--target web` build, Perry's WASM runtime maps every widget to a DOM element under the hood, but the source code stays the same — you never write HTML.)
48
54
-**Path alias:**`@/*` maps to `src/*` in imports.
49
55
-**External editor widget:**`@honeide/editor` is a local dependency (`file:../hone/hone-editor`) used for document editing.
50
56
-**Test mocks:** Perry APIs and MongoDB are mocked in `tests/mocks/`. Tests preload `tests/preload.ts` via bunfig.toml. Use `reset-database.ts` to clear state between tests.
51
57
-**Connection URI building:**`ConnectionStore.buildConnectionUri()` handles auth mechanisms (SCRAM-SHA-256, etc.) and TLS options. Always use this rather than constructing URIs manually.
58
+
59
+
## Web Target Notes
60
+
61
+
`perry compile src/app.ts --target web` produces a single ~4 MB self-contained HTML file with the WebAssembly binary, the JS bridge for DOM widgets, and all string/data sections embedded. It's the same backend as `--target wasm`; both flags produce identical output.
62
+
63
+
Platform branches with `__platform__ === 5` cover the web case:
64
+
65
+
-**Connection storage**: `connection-store.ts` falls back to an in-memory `webTransient` store on web instead of SQLite (which doesn't compile to WASM). Connection profiles are not persisted across reloads in the browser.
66
+
-**Keychain**: maps to `localStorage` (Perry's web bridge). Fine for connection metadata but **not** for production secrets — anything in localStorage is readable by other scripts in the same origin.
67
+
-**Hone code editor**: requires native FFI (`hone_editor_*`) that has no browser implementation. Perry's WASM bridge auto-stubs these to no-ops via a `Proxy`, so the editor area shows up but key/mouse handling is inactive. Document editing works with the plain `<textarea>` fallback.
68
+
-**MongoDB driver**: native MongoDB doesn't run in the browser. The web build needs to talk to a Mango Server proxy (`web-mongo-client.ts` over `fetch`). For local testing, run mongod + mango-server alongside the served HTML and update the connection string.
69
+
-**fetch / CORS**: any third-party URL (telemetry, public APIs) must allow your origin. Mango's `trackEvent` will silently fail with a CORS error from `file://` and from origins not whitelisted by `api.chirp247.com` — this is expected and the catch in `trackEvent` swallows it.
70
+
-**Serving**: must be served over HTTP, not opened directly via `file://` (browsers reject `fetch()` from file URLs). Any static server works (`python3 -m http.server`, `npx serve`, etc.).
Copy file name to clipboardExpand all lines: README.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ Mango is a native desktop MongoDB client written in TypeScript and compiled to n
31
31
-**Document CRUD** — Insert, update, delete, and duplicate documents.
32
32
-**Index listing** — View indexes with key, uniqueness, and size info.
33
33
-**Dark & light mode** — Follows system preference automatically.
34
-
-**Cross-platform** — Targets macOS (AppKit), iOS (UIKit), Android (Views), Linux (GTK4), and Windows (Win32).
34
+
-**Cross-platform** — Targets macOS (AppKit), iOS (UIKit), Android (Views), Linux (GTK4), Windows (Win32), and the **browser** (WebAssembly + DOM via Perry's `--target web`).
35
35
36
36
## Getting Started
37
37
@@ -54,6 +54,19 @@ perry compile src/app.ts --output mango
54
54
./mango
55
55
```
56
56
57
+
### Run in the browser (WebAssembly)
58
+
59
+
```bash
60
+
# Compile to a single self-contained HTML+WASM file (~4 MB)
61
+
perry compile src/app.ts --target web -o dist/mango.html
62
+
63
+
# Serve over HTTP (file:// won't work — fetch() hits CORS errors)
64
+
python3 -m http.server 8765 -d dist
65
+
open http://localhost:8765/mango.html
66
+
```
67
+
68
+
The web build is the same source code, compiled by Perry to WebAssembly with a JavaScript bridge that maps every Perry widget to a DOM element. SQLite-backed connection storage degrades to an in-memory transient store on web; the Hone code editor's native bindings degrade to no-ops; and you'll need to point at a Mango Server proxy if you want to talk to MongoDB from the browser. Everything else (UI, navigation, query builder, document viewer, dark/light mode, i18n) works the same as the native builds.
0 commit comments