/** * Versioned envelope shared by every postMessage between a UI plugin * (iframe-mounted or in-process) and its host shell. * * Both sides import these types from this module — there is no other * source of truth for the wire format. Bumping the envelope is a * deliberate breaking-change event; the major version embedded in * `ENVELOPE_VERSION` rides independently of the package's CalVer. */ export declare const ENVELOPE_VERSION: 1; export type EnvelopeVersion = typeof ENVELOPE_VERSION; /** Operations the host sends to the plugin. */ export type HostOp = 'host:init' | 'host:theme-change' | 'host:locale-change' | 'host:feature-flag' | 'host:context-change' | 'host:event' | 'host:rpc-response' | 'host:rpc-progress' | 'host:dispose'; /** Operations the plugin sends to the host. */ export type PluginOp = 'plugin:ready' | 'plugin:rpc-request' | 'plugin:event-emit' | 'plugin:set-badge' | 'plugin:set-title' | 'plugin:resize-request' | 'plugin:error'; export interface HostEnvelope
{ v: EnvelopeVersion; source: 'host'; kind: HostOp; /** Set when this envelope answers (or progresses) a prior plugin RPC. */ requestId?: string; payload: P; } export interface PluginEnvelope
{ v: EnvelopeVersion; source: 'plugin'; kind: PluginOp; /** Set on rpc-request / set on plugin:error when caused by a specific RPC. */ requestId?: string; payload: P; } export type Envelope
= HostEnvelope
| PluginEnvelope
;
/**
* Type guard that an unknown postMessage payload looks like a valid v1
* envelope. Origin and `event.source` checks are *not* performed here —
* the caller must do those *before* trusting the payload, because a
* well-formed envelope from a hostile origin is still hostile.
*/
export declare function isEnvelope(value: unknown): value is Envelope;
/** Convenience: narrow to a HostEnvelope (caller already trusts the origin). */
export declare function isHostEnvelope(value: unknown): value is HostEnvelope;
/** Convenience: narrow to a PluginEnvelope (caller already trusts the origin). */
export declare function isPluginEnvelope(value: unknown): value is PluginEnvelope;
/** Sent in reply to `plugin:ready`. The plugin blocks render until it arrives. */
export interface HostInitPayload {
/** Scoped iframe token. Bounded by manifest capabilities. */
iframeToken: string;
tunnelUrl: string;
mountPoint: string;
context: Record