github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/appviewguestinternal/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/appviewguestinternal", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "has_AttachFrame": (): heap.Ref<boolean> => { 8 if (WEBEXT?.appViewGuestInternal && "attachFrame" in WEBEXT?.appViewGuestInternal) { 9 return A.H.TRUE; 10 } 11 return A.H.FALSE; 12 }, 13 "func_AttachFrame": (fn: Pointer): void => { 14 A.store.Ref(fn, WEBEXT.appViewGuestInternal.attachFrame); 15 }, 16 "call_AttachFrame": (retPtr: Pointer, url: heap.Ref<object>, guestInstanceId: number): void => { 17 const _ret = WEBEXT.appViewGuestInternal.attachFrame(A.H.get<object>(url), guestInstanceId); 18 A.store.Ref(retPtr, _ret); 19 }, 20 "try_AttachFrame": ( 21 retPtr: Pointer, 22 errPtr: Pointer, 23 url: heap.Ref<object>, 24 guestInstanceId: number 25 ): heap.Ref<boolean> => { 26 try { 27 const _ret = WEBEXT.appViewGuestInternal.attachFrame(A.H.get<object>(url), guestInstanceId); 28 A.store.Ref(retPtr, _ret); 29 return A.H.TRUE; 30 } catch (err: any) { 31 A.store.Ref(errPtr, err); 32 return A.H.FALSE; 33 } 34 }, 35 "has_DenyRequest": (): heap.Ref<boolean> => { 36 if (WEBEXT?.appViewGuestInternal && "denyRequest" in WEBEXT?.appViewGuestInternal) { 37 return A.H.TRUE; 38 } 39 return A.H.FALSE; 40 }, 41 "func_DenyRequest": (fn: Pointer): void => { 42 A.store.Ref(fn, WEBEXT.appViewGuestInternal.denyRequest); 43 }, 44 "call_DenyRequest": (retPtr: Pointer, guestInstanceId: number): void => { 45 const _ret = WEBEXT.appViewGuestInternal.denyRequest(guestInstanceId); 46 }, 47 "try_DenyRequest": (retPtr: Pointer, errPtr: Pointer, guestInstanceId: number): heap.Ref<boolean> => { 48 try { 49 const _ret = WEBEXT.appViewGuestInternal.denyRequest(guestInstanceId); 50 return A.H.TRUE; 51 } catch (err: any) { 52 A.store.Ref(errPtr, err); 53 return A.H.FALSE; 54 } 55 }, 56 }; 57 });