@bobfrankston/msgapidefs 0.1.35 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -6
- package/msgapi-plan.md +3 -0
- package/msgapidefs.ts +26 -0
- package/package.json +2 -1
- package/tsconfig.json +2 -1
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ TypeScript definitions for the **msgapi** JavaScript API used by msga, msger, an
|
|
|
13
13
|
msgx (workspace root)
|
|
14
14
|
├── msgapidefs - TypeScript type definitions for window.msgapi (this package)
|
|
15
15
|
├── msgcommon - Shared CLI parsing, templates, pinning utilities
|
|
16
|
-
├── msger - Rust/wry webview host (Windows, Linux)
|
|
17
|
-
├── msgview - Electron webview host (
|
|
16
|
+
├── msger - Rust/wry webview host (Windows, Linux, Mac, Pi) — PRIMARY
|
|
17
|
+
├── msgview - Electron webview host (desktop) — SEMI-RETIRED, see below
|
|
18
18
|
├── msga - .NET MAUI webview host (Android, Windows)
|
|
19
19
|
├── build - Release build orchestration script (build/build.ts)
|
|
20
20
|
└── md - Shared documentation
|
|
@@ -61,14 +61,36 @@ window.close(); // Instead of msgapi.close() if not passing result
|
|
|
61
61
|
| **Windows** | ✅ | ✅ | ✅ |
|
|
62
62
|
| **Linux** | ✅ | ✅ | ❌ |
|
|
63
63
|
| **macOS** | 🔧 wry supports it | ✅ | 🔧 Mac Catalyst |
|
|
64
|
-
| **Raspberry Pi** |
|
|
64
|
+
| **Raspberry Pi** | ✅ | ✅ | ❌ |
|
|
65
65
|
| **Android** | ❌ | ❌ | ✅ (primary) |
|
|
66
66
|
| **iOS** | ❌ | ❌ | ❌ |
|
|
67
67
|
|
|
68
|
-
> **msger** uses wry (Rust webview)
|
|
69
|
-
> **msgview**
|
|
68
|
+
> **msger** uses wry (Rust webview) and is the **primary host**. Desktop platforms (Win/Linux/Mac) are mature. The Pi display bug ("runs but renders shredded scanlines") was WebKitGTK's DMABUF renderer on vc4/v3d — msger now sets `WEBKIT_DISABLE_DMABUF_RENDERER=1` automatically on Raspberry Pi hardware (both the JS launcher and the binary), and the Pi renders correctly as of 2026-07-31.
|
|
69
|
+
> **msgview** is **semi-retired** as of 2026-07-31 — see below.
|
|
70
70
|
> **msga** targets Android primarily; Windows for dev/testing. **iOS** would be the most realistic path — MAUI supports iOS natively, so msga could target it with an iOS build profile, Apple developer account, and platform-specific conditional code (`#if IOS`) for permissions and APIs. No current plans.
|
|
71
71
|
|
|
72
|
+
### msgview is semi-retired (2026-07-31)
|
|
73
|
+
|
|
74
|
+
msger + msga cover every platform, so the Electron host has no platform to itself.
|
|
75
|
+
**Do not do feature-parity work on msgview.** New features land in msger (and msga
|
|
76
|
+
where it makes sense); msgview catches up only on demand, if a real need appears.
|
|
77
|
+
|
|
78
|
+
What Electron alone could still do, and why it isn't a reason to keep syncing it:
|
|
79
|
+
|
|
80
|
+
- **Unpacked Chrome extensions** (`-extension`) — wry has no extension API and
|
|
81
|
+
WebKitGTK has none at all. If Chrome features are needed, use Chrome directly.
|
|
82
|
+
- **`-render` off Windows** — msger's capture goes through WebView2 DevTools, so it
|
|
83
|
+
is Windows-only; msgview's `capturePage()` works everywhere. Portable to
|
|
84
|
+
WebKitGTK's snapshot API if it ever matters.
|
|
85
|
+
|
|
86
|
+
Engine currency is *not* a reason: a feature probe on Pi 5 / WebKitGTK 2.50.6
|
|
87
|
+
(2026-07-31) passed 23 of 24 modern checks — `:has()`, CSS nesting, container
|
|
88
|
+
queries, subgrid, `backdrop-filter`, `color-mix`, `oklch`, Popover, View
|
|
89
|
+
Transitions, `Object.groupBy`, `Promise.withResolvers`, `Intl.Segmenter`, WebGL2,
|
|
90
|
+
OffscreenCanvas — failing only the RegExp `v` flag. The WebKitGTK user-agent token
|
|
91
|
+
(`Version/60.5`) is a WebKitGTK version string, not a Safari generation; it says
|
|
92
|
+
nothing about capability.
|
|
93
|
+
|
|
72
94
|
## Implementation Status
|
|
73
95
|
|
|
74
96
|
✅ = Implemented | ⚠️ = Partial | ❌ = Not implemented
|
|
@@ -79,6 +101,8 @@ window.close(); // Instead of msgapi.close() if not passing result
|
|
|
79
101
|
| `version` | ❌ | ❌ | ✅ | `window.msgapi.version` string |
|
|
80
102
|
| `setLogging(value?)` | ❌ | ❌ | ✅ | Returns previous state |
|
|
81
103
|
| `setAutoUpdate(value?)` | ❌ | ❌ | ✅ | `'auto'`/`'check'`/`'off'`; msga Android only |
|
|
104
|
+
| **Diagnostics** | | | | **`window.msgapi.diag.*`** |
|
|
105
|
+
| `diag.getExitReasons(max?)` | ❌ | ❌ | ✅ | Why the previous run exited; msga Android 11+ only, `[]` elsewhere |
|
|
82
106
|
| **Window Control** | | | | **`window.msgapi.*`** |
|
|
83
107
|
| `toggleFullscreen()` | ❌ | ✅ | ✅ | msger: via `window.msgapi` (msger-api.js) |
|
|
84
108
|
| `setFullscreen(bool)` | ✅ | ✅ | ✅ | |
|
|
@@ -124,7 +148,8 @@ window.close(); // Instead of msgapi.close() if not passing result
|
|
|
124
148
|
| **Host Launcher Features** | | | | *Not part of `window.msgapi`; CLI / launcher-side* |
|
|
125
149
|
| Markdown rendering (`.md`/`.markdown` auto-render) | ✅ | ✅ | ❌ | Local `file://` URL → rendered HTML via `msgcommon/markdown` (marked + light/dark CSS). msga could match it in `MainPage.xaml.cs` URL interception — not done yet. |
|
|
126
150
|
| Unpacked Chrome extension loading (`-extension <dir>`) | ✅ | ❌ | ❌ | msgview-only via `session.extensions.loadExtension`. wry has no public extension API; WebKitGTK has none at all. msga would need a separate Android/WebView2 plumbing — not planned. |
|
|
127
|
-
| Headless mode (`-noshow` without `-save`) |
|
|
151
|
+
| Headless mode (`-noshow` without `-save`) | ✅ | ✅ | ❌ | msger creates the WebView invisible (`with_visible(false)`) but still loads HTML and runs scripts — an embedded `<script>` can query the engine and `window.ipc.postMessage` a result back. Combined with `-result <fieldname>` for clean stdout, this lets msger act as a headless CSS/JS resolver (`contrast-color()`, `getComputedStyle()`, `CSS.supports()`). msgview matches with `BrowserWindow({show:false})` + `backgroundThrottling:false`. |
|
|
152
|
+
| Render to bitmap (`-render [file]`, `render` option) | ✅ | ✅ | ❌ | Headless page→image capture: the window is never shown; the page loads, settles (`renderDelay`, default 100ms after `load` + two rAFs), is screenshotted, and the host exits. `-render <file>` writes the image (format from extension: `.png`/`.jpg`/`.bmp`) and the JSON result carries `render: {path, width, height, format}`; bare `-render` (or API `render: true`) returns it as `render: {data (base64), width, height, format}`. Library API: `showMessageBox({render: "shot.png" \| true, renderDelay?, renderFormat?})`; a failed capture rejects (msger) or sets `renderError` in the result. Both hosts fall back to capturing whatever rendered if the page hasn't loaded within the timeout (default 30s in render mode). msger: WebView2 DevTools `Page.captureScreenshot` — **Windows only** for now; msgview: `webContents.capturePage()` — all Electron platforms. Width/height are physical pixels (include DPI scale). |
|
|
128
153
|
|
|
129
154
|
> **msger** now injects `window.msgapi` via `msger-api.js` with window control, UDP, and HTTP. File system and shell are not yet implemented in msger or msgview.
|
|
130
155
|
>
|
|
@@ -154,6 +179,35 @@ See [`msgapi-plan.md`](./msgapi-plan.md) for the full implementation plan and ro
|
|
|
154
179
|
- Default: `'auto'` (configurable via `AUTO_UPDATE` in msga.env)
|
|
155
180
|
- Checks on startup then every `UPDATE_INTERVAL_MINUTES` (default 60)
|
|
156
181
|
|
|
182
|
+
### Diagnostics
|
|
183
|
+
|
|
184
|
+
Why did the previous run exit? Android records the last few process deaths (`ApplicationExitInfo`, Android 11+); the host reads its own history on the next run and exposes it to the web app. This distinguishes crash / ANR / low-memory kill / cached-app freezer — no adb needed. Currently msga Android only; other hosts/platforms return `[]`.
|
|
185
|
+
|
|
186
|
+
- `diag.getExitReasons(max?)` - Previous-run exit records, newest first (default/max clamp: 5/16). Returns `MsgExitInfo[]`:
|
|
187
|
+
- `timestamp` - Exit time, ms since epoch
|
|
188
|
+
- `reason` - `"LowMemory"`, `"Crash"`, `"CrashNative"`, `"Anr"`, `"Freezer"`, `"ExitSelf"`, `"Signaled"`, `"UserRequested"`, `"UserStopped"`, `"DependencyDied"`, `"ExcessiveResourceUsage"`, `"PackageUpdated"`, `"Other"`, ... (Android `ApplicationExitInfo` reason names)
|
|
189
|
+
- `description` - OS-provided detail (may be null), e.g. `"isolated not needed"` = renderer cleanup
|
|
190
|
+
- `importance` - Process state at death (e.g. `"Foreground"`, `"Cached"`) — a `Cached` + `LowMemory` kill is normal Android memory reclaim, not a bug
|
|
191
|
+
- `pss` / `rss` - Memory at exit, KB
|
|
192
|
+
- `processName` - Which process died: the main package name, or `...:sandboxed_process*` = the WebView renderer. **Records cover every process in the package** — renderer deaths are routine cleanup, not the app dying; filter by processName to find real main-process exits
|
|
193
|
+
- `pid` - Process ID at exit
|
|
194
|
+
- `status` - Signal number for `Signaled`, exit code for `ExitSelf`, 0 otherwise
|
|
195
|
+
- `stateSummary` - App-set marker (`ActivityManager.setProcessStateSummary`); msga stamps `start=<ISO time> v=<version>` at each launch so uptime-at-death is computable
|
|
196
|
+
- `trace` - First ~4KB of the ANR/native-crash trace when the OS captured one (`Anr`/`CrashNative` only)
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
// Exit-history tool in a web app (e.g. houser debug panel)
|
|
200
|
+
const exits = await window.msgapi?.diag?.getExitReasons() ?? [];
|
|
201
|
+
for (const e of exits) {
|
|
202
|
+
console.log(`${new Date(e.timestamp).toLocaleString()} ${e.reason}` +
|
|
203
|
+
` (${e.importance ?? '?'}, pss=${e.pss ?? '?'}KB) ${e.description ?? ''}`);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Interpreting common reasons: `LowMemory` = killed by the low-memory killer; `Anr` = main thread hung; `Crash`/`CrashNative` = unhandled exception / native crash; `Freezer` = app was frozen (Android 12+ cached-app freezing — UDP listeners silently suspended, app not actually dead); `UserRequested` = swiped away from recents; `PackageUpdated` = replaced by an APK update; `Signaled` = killed by signal (check `description`).
|
|
208
|
+
|
|
209
|
+
msga also logs new exit records via MsgALog at startup when `LOGGING=true` in msga.env (`Previous exit: ...`), deduplicated across runs via a `lastSeenExitTimestamp` preference. See [msga/exit-diagnostics.md](../msga/exit-diagnostics.md) for the full design notes.
|
|
210
|
+
|
|
157
211
|
### Window Control
|
|
158
212
|
|
|
159
213
|
- `toggleFullscreen()` - Toggle fullscreen mode
|
package/msgapi-plan.md
CHANGED
|
@@ -55,11 +55,14 @@ Shared planning document for msgapi across implementations:
|
|
|
55
55
|
| tcp.close() | ✅ | ✅ | ✅ | Close connection |
|
|
56
56
|
| **HTTP** |
|
|
57
57
|
| http.fetch() | ✅ | ✅ | ✅ | CORS/mixed-content bypass via native HTTP; returns real Response object |
|
|
58
|
+
| **Host Launcher (CLI / library, not `window.msgapi`)** |
|
|
59
|
+
| render to bitmap (`-render [file]` / `render` option) | ✅ | ✅ | ❌ | Headless page→image: hidden window, capture after load + `renderDelay` (100ms default), exit. File (.png/.jpg/.bmp by extension) or base64 object in `result.render`. msger: WebView2 CDP `Page.captureScreenshot`, Windows only; msgview: `webContents.capturePage()`, all platforms. 30s default timeout with best-effort capture fallback. Added 2026-07-03. |
|
|
58
60
|
| **Configuration** |
|
|
59
61
|
| setLogging(value?, name?) | ❌ | ❌ | ✅ | Returns old state; 'msga'/'msgapi'/'on'/'off'/null; name included in log messages/filenames |
|
|
60
62
|
| setAutoUpdate(value?) | ❌ | ❌ | ✅ | 'auto'/'check'/'off'; defaults to 'off' (web app owns policy) |
|
|
61
63
|
| installUpdate(url) | ❌ | ❌ | ✅ | Download + install APK; Android only. Web app calls this. |
|
|
62
64
|
| getNetworkInfo() | ❌ | ❌ | ✅ | Fresh local IP + subnet mask; used by httpudp-client isAddressReachable() |
|
|
65
|
+
| diag.getExitReasons(max?) | ❌ | ❌ | ✅ | Why the previous run exited (Android 11+ ApplicationExitInfo); also MsgALog "Previous exit:" at startup under LOGGING. See [msga/exit-diagnostics.md](../msga/exit-diagnostics.md). Added 2026-07-09 (v1.5.40). |
|
|
63
66
|
| info | ❌ | ❌ | ✅ | `MsgHostInfo`: host, version, platform, updateUrl |
|
|
64
67
|
| updateUrl | ❌ | ❌ | ✅ | URL to versions.json — install source for update checks |
|
|
65
68
|
| version | ❌ | ❌ | ✅ | `window.msgapi.version` = app version string |
|
package/msgapidefs.ts
CHANGED
|
@@ -65,6 +65,24 @@ export interface MsgApkInfo { // One APK entry in versions.json
|
|
|
65
65
|
default?: boolean; // True if this is the default APK
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// Why the previous app process died — from Android ApplicationExitInfo (OS-recorded, survives process death)
|
|
69
|
+
// NOTE: records cover EVERY process in the package, including the sandboxed WebView renderer
|
|
70
|
+
// (processName contains ":sandboxed_process") — renderer deaths like "isolated not needed" are
|
|
71
|
+
// routine cleanup, not the app dying. Filter/dim by processName to find real main-process exits.
|
|
72
|
+
export interface MsgExitInfo {
|
|
73
|
+
timestamp: number; // Exit time, ms since epoch
|
|
74
|
+
reason: string; // "LowMemory" | "Crash" | "CrashNative" | "Anr" | "Freezer" | "ExitSelf" | "Signaled" | "UserRequested" | "UserStopped" | "DependencyDied" | "InitializationFailure" | "PermissionChange" | "ExcessiveResourceUsage" | "PackageStateChange" | "PackageUpdated" | "Other" | "Unknown"
|
|
75
|
+
description?: string; // OS-provided detail (may be null/absent), e.g. "isolated not needed" for renderer cleanup
|
|
76
|
+
importance?: string; // Process state at death (e.g. "Foreground", "Cached") — cached kills are normal memory reclaim
|
|
77
|
+
pss?: number; // Proportional set size at exit, KB
|
|
78
|
+
rss?: number; // Resident set size at exit, KB
|
|
79
|
+
processName?: string; // Which process died — main package name, or ":sandboxed_process..." = WebView renderer
|
|
80
|
+
pid?: number; // Process ID at exit
|
|
81
|
+
status?: number; // Exit status: signal number for "Signaled", exit code for "ExitSelf", 0 otherwise
|
|
82
|
+
stateSummary?: string; // App-set marker (msga stamps "start=<ISO time> v=<version>" each run → compute uptime at death)
|
|
83
|
+
trace?: string; // First ~4KB of ANR/native-crash trace when the OS captured one (reason "Anr"/"CrashNative")
|
|
84
|
+
}
|
|
85
|
+
|
|
68
86
|
export interface MsgVersionInfo { // Structure of versions.json
|
|
69
87
|
version: string; // Latest available version (e.g. "1.5.21") — semver string, compare numerically not lexicographically
|
|
70
88
|
buildDate: string; // Build timestamp (ISO 8601)
|
|
@@ -85,6 +103,14 @@ export interface MsgAPI {
|
|
|
85
103
|
installUpdate?(url: string): Promise<void>; // Download + install APK from url. msga Android only; web app owns update policy.
|
|
86
104
|
getNetworkInfo?(): Promise<{ localIp: string; localMask: string }>; // Current device IP + subnet mask (fresh, not cached)
|
|
87
105
|
|
|
106
|
+
// ── Diagnostics ─────────────────────────────────────────────
|
|
107
|
+
// Why did the previous run exit? OS records the last few process deaths;
|
|
108
|
+
// read them on the next run to distinguish crash / ANR / low-memory kill / freezer.
|
|
109
|
+
|
|
110
|
+
diag?: {
|
|
111
|
+
getExitReasons(max?: number): Promise<MsgExitInfo[]>; // Previous-run exit records, newest first (default max 5). msga Android 11+ only; [] elsewhere.
|
|
112
|
+
};
|
|
113
|
+
|
|
88
114
|
// ── Window Control ──────────────────────────────────────────
|
|
89
115
|
|
|
90
116
|
toggleFullscreen(): void; // Toggle fullscreen mode on/off
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/msgapidefs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "TypeScript definitions for msgapi JavaScript API (msgview/msger)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./msgapidefs.js",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"prerelease:local": "git add -A && (git diff-index --quiet HEAD || git commit -m \"Pre-release commit\")",
|
|
34
34
|
"preversion": "git add -A",
|
|
35
35
|
"release": "npm run prerelease:local && npm version patch && npm publish --quiet",
|
|
36
|
+
"build": "tsc",
|
|
36
37
|
"postversion": "git push && git push --tags"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|