// ---- Event system ---- export type Cancelable = { cancel: () => void; }; export type EventEmitterType = { on: (eventName: string, handler: (...args: any[]) => void) => Cancelable; once: (eventName: string, handler: (...args: any[]) => void) => Cancelable; trigger: (eventName: string, ...args: any[]) => void; off: (eventName: string, handler: (...args: any[]) => void) => void; destroy: () => void; }; // ---- Dimensions ---- export type CssDimensionsType = { width: string; height: string; }; // ---- Computed props ---- export type ComputedPropConfig

= { /** * Produce a computed prop value. Runs AFTER containerTemplate, * so `state` reflects any mutations made by the container template. * Return value is classified by `type`: 'function' → dispatch map, 'value' → data payload. */ factory: (context: {props: P; state: Record}) => any; type: 'function' | 'value'; }; // ---- Penpal dispatch pattern ---- export type ParentMethods = { callParent: (name: string, args: any[]) => any; }; export type ChildMethods = { callChild: (name: string, args: any[]) => any; updateProps: (dataProps: Record, functionNames?: string[]) => void; }; // ---- Container/prerender template options ---- export type RenderOptions

= { uid: string; frame: HTMLIFrameElement; placeholder: HTMLElement | undefined; doc: Document; props: P; event: EventEmitterType; dimensions: CssDimensionsType; state: Record; container?: HTMLElement; }; // ---- Component options (replaces ComponentOptionsType) ---- export type BridgeComponentOptions

= { tag: string; url: string; dimensions?: CssDimensionsType; autoResize?: {width?: boolean; height?: boolean; element?: string}; /** * Build wrapper DOM around the iframe. Runs BEFORE computed prop factories, * so it may mutate `state` (e.g., `state.__container = container`) for factories to read. */ containerTemplate?: (options: RenderOptions

) => HTMLElement | undefined; prerenderTemplate?: (options: RenderOptions

) => HTMLElement | undefined; validate?: (input: {props: P}) => void; defaultProps?: (context: {event: EventEmitterType}) => Partial

; /** Parent-side computed props — factories run at render time */ computedProps?: Record>; /** Alternative input names for props (e.g., merchants can pass innerStyle or style) */ aliases?: Record; /** Optional submit factory — wires instance.submit() on the component (e.g., CardInput) */ submit?: (instance: BridgeComponent

) => (options?: any) => Promise; }; // ---- Component instance (replaces MoneiComponent) ---- export interface BridgeComponent

{ render: (container?: string | HTMLElement) => Promise; updateProps: (props: Partial

) => Promise; close: () => Promise; destroy: () => Promise; submit?: (options?: any) => Promise; state: Record; event: EventEmitterType; props: P; driver: (name: string, deps?: Record) => any; } // ---- Constructor returned by createComponent() ---- export interface BridgeComponentConstructor

{ new (props: P): BridgeComponent

; driver: (name: string, deps?: Record) => any; }