Class WebkitMessagingTransportImplements
Constructors Propertiesglobals globals : { addEventListener : any ; Arrayfrom : { < T > ( arrayLike : ArrayLike < T > ) : T [] ; < T , U > ( arrayLike : ArrayLike < T > , mapfn : ( v : T , k : number ) => U , thisArg ?: any , ) : U [] ; < T > ( iterable : Iterable < T > | ArrayLike < T > ) : T [] ; < T , U > ( iterable : Iterable < T > | ArrayLike < T > , mapfn : ( v : T , k : number ) => U , thisArg ?: any , ) : U [] ; } ; capturedWebkitHandlers : Record < string , any > ; Error : ErrorConstructor ; getRandomValues : any ; JSONparse : ( text : string , reviver ?: ( this : any , key : string , value : any ) => any , ) => any ; JSONstringify : { ( value : any , replacer ?: ( this : any , key : string , value : any ) => any , space ?: string | number , ) : string ; ( value : any , replacer ?: null | (
string | number )
[] , space ?: string | number , ) : string ; } ; ObjectDefineProperty : < T > ( o : T , p : PropertyKey , attributes : PropertyDescriptor & ThisType < any > , ) => T ; Promise : PromiseConstructor ; ReflectDeleteProperty : any ; TextDecoder : new ( label ?: string , options ?: TextDecoderOptions , ) => TextDecoder ; TextEncoder : new () => TextEncoder ; Uint16Array : Uint16ArrayConstructor ; Uint32Array : Uint32ArrayConstructor ; Uint8Array : Uint8ArrayConstructor ; window : Window & typeof globalThis ; } Type declaration addEventListener : any Arrayfrom : { < T > ( arrayLike : ArrayLike < T > ) : T [] ; < T , U > ( arrayLike : ArrayLike < T > , mapfn : ( v : T , k : number ) => U , thisArg ?: any , ) : U [] ; < T > ( iterable : Iterable < T > | ArrayLike < T > ) : T [] ; < T , U > ( iterable : Iterable < T > | ArrayLike < T > , mapfn : ( v : T , k : number ) => U , thisArg ?: any , ) : U [] ; } capturedWebkitHandlers : Record < string , any > Error : ErrorConstructor getRandomValues : any JSONparse : ( text : string , reviver ?: ( this : any , key : string , value : any ) => any ) => any JSONstringify : { ( value : any , replacer ?: ( this : any , key : string , value : any ) => any , space ?: string | number , ) : string ; ( value : any , replacer ?: null | (string | number )[] , space ?: string | number , ) : string ; } ObjectDefineProperty : < T > ( o : T , p : PropertyKey , attributes : PropertyDescriptor & ThisType < any > ) => T Promise : PromiseConstructor ReflectDeleteProperty : any TextDecoder : new ( label ?: string , options ?: TextDecoderOptions ) => TextDecoder TextEncoder : new () => TextEncoder Uint16Array : Uint16ArrayConstructor Uint32Array : Uint32ArrayConstructor Uint8Array : Uint8ArrayConstructor window : Window & typeof globalThis Methodscapture Webkit Handlers captureWebkitHandlers ( handlerNames : string [] ) : void Returns void request request ( msg : RequestMessage ) : Promise < Record < string , any > > Returns Promise < Record < string , any > > subscribe subscribe ( msg : Subscription , callback : ( value : unknown ) => void ) : () => void Returns () => void
Example
On macOS 11+, this will just call through to
window.webkit.messageHandlers.x.postMessage
Eg: for a
foo
message defined in Swift that accepted the payload{"bar": "baz"}
, the following would occur:Example
On macOS 10 however, the process is a little more involved. A method will be appended to
window
that allows the response to be delivered there instead. It's not exactly this, but you can visualize the flow as being something along the lines of: