inter-frame-messenger¶
Audience: Agent
Purpose¶
Reusable InterFrameMessenger class: wraps window.postMessage with allowlisted origins, message type enums, and helpers for EliteEvent / Status / EdosFileEventEnvelope (edos-file-event, validated with isEdosFileEventEnvelope) from @howfe/elite-dangerous-event-types.
Tech stack¶
- TypeScript, built with tsup →
dist/(package.jsonmain/module/types). - Published as
@howfe/inter-frame-messenger.
Layout¶
| Path | Role |
|---|---|
src/index.ts |
MessageTypeEnum, InterFrameMessenger class |
tsup.config.ts |
Build output |
Integration points¶
- Remote journal reader — constructs
InterFrameMessengerwithtarget = window.opener, sends game events, listens for remote control message types. - Surface map — constructs with
target = popupfromwindow.open, listens forelite-event/elite-status(edos-file-eventoptional when consumers add it to listen allowlists). - Local journal bridge shell — injects
edos-file-event(+ legacy shorthands) into the embedded document. - See IPC.md for envelope and parent/child setup.
Extension points¶
- New message types: add to
MessageTypeEnum, then update both send and listen allowlists in every consumer. - Stricter origin policy: replace
'*'in EDJR buttons with explicit parent origins when embedders are known. - After changes:
npm run build, publish, bump versions in Quasar apps.
Pitfalls / checks¶
- Constructor ordering:
sendMessageTypes/listenMessageTypesmust include every type yousend/onor the library throws or ignores. sendloops overallowedListenerOrigins— empty list meanspostMessagenever fires.- Duplicate listeners: each
on()registers a newwindowlistener — avoid double-registering the same handler pattern.
Related docs¶
- IPC.md — full protocol
- HOSTED_APP_CONTRACT.md — URL bootstrap and manifests (orthogonal to
MessageTypeEnum) - ARCHITECTURE.md — runtime topology