github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/dashboardprivate/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/dashboardprivate", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "constof_Result": (ref: heap.Ref<string>): number => { 8 const idx = [ 9 "", 10 "unknown_error", 11 "user_cancelled", 12 "invalid_id", 13 "manifest_error", 14 "icon_error", 15 "invalid_icon_url", 16 ].indexOf(A.H.get(ref)); 17 return idx < 0 ? 0 : idx + 1; 18 }, 19 20 "store_ShowPermissionPromptForDelegatedInstallArgDetails": (ptr: Pointer, ref: heap.Ref<any>) => { 21 const x = A.H.get<any>(ref); 22 23 if (typeof x === "undefined") { 24 A.store.Bool(ptr + 20, false); 25 A.store.Ref(ptr + 0, undefined); 26 A.store.Ref(ptr + 4, undefined); 27 A.store.Ref(ptr + 8, undefined); 28 A.store.Ref(ptr + 12, undefined); 29 A.store.Ref(ptr + 16, undefined); 30 } else { 31 A.store.Bool(ptr + 20, true); 32 A.store.Ref(ptr + 0, x["delegatedUser"]); 33 A.store.Ref(ptr + 4, x["iconUrl"]); 34 A.store.Ref(ptr + 8, x["id"]); 35 A.store.Ref(ptr + 12, x["localizedName"]); 36 A.store.Ref(ptr + 16, x["manifest"]); 37 } 38 }, 39 "load_ShowPermissionPromptForDelegatedInstallArgDetails": ( 40 ptr: Pointer, 41 create: heap.Ref<boolean>, 42 ref: heap.Ref<any> 43 ): heap.Ref<any> => { 44 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 45 46 x["delegatedUser"] = A.load.Ref(ptr + 0, undefined); 47 x["iconUrl"] = A.load.Ref(ptr + 4, undefined); 48 x["id"] = A.load.Ref(ptr + 8, undefined); 49 x["localizedName"] = A.load.Ref(ptr + 12, undefined); 50 x["manifest"] = A.load.Ref(ptr + 16, undefined); 51 return create === A.H.TRUE ? A.H.push(x) : ref; 52 }, 53 "has_ShowPermissionPromptForDelegatedInstall": (): heap.Ref<boolean> => { 54 if (WEBEXT?.dashboardPrivate && "showPermissionPromptForDelegatedInstall" in WEBEXT?.dashboardPrivate) { 55 return A.H.TRUE; 56 } 57 return A.H.FALSE; 58 }, 59 "func_ShowPermissionPromptForDelegatedInstall": (fn: Pointer): void => { 60 A.store.Ref(fn, WEBEXT.dashboardPrivate.showPermissionPromptForDelegatedInstall); 61 }, 62 "call_ShowPermissionPromptForDelegatedInstall": (retPtr: Pointer, details: Pointer): void => { 63 const details_ffi = {}; 64 65 details_ffi["delegatedUser"] = A.load.Ref(details + 0, undefined); 66 details_ffi["iconUrl"] = A.load.Ref(details + 4, undefined); 67 details_ffi["id"] = A.load.Ref(details + 8, undefined); 68 details_ffi["localizedName"] = A.load.Ref(details + 12, undefined); 69 details_ffi["manifest"] = A.load.Ref(details + 16, undefined); 70 71 const _ret = WEBEXT.dashboardPrivate.showPermissionPromptForDelegatedInstall(details_ffi); 72 A.store.Ref(retPtr, _ret); 73 }, 74 "try_ShowPermissionPromptForDelegatedInstall": ( 75 retPtr: Pointer, 76 errPtr: Pointer, 77 details: Pointer 78 ): heap.Ref<boolean> => { 79 try { 80 const details_ffi = {}; 81 82 details_ffi["delegatedUser"] = A.load.Ref(details + 0, undefined); 83 details_ffi["iconUrl"] = A.load.Ref(details + 4, undefined); 84 details_ffi["id"] = A.load.Ref(details + 8, undefined); 85 details_ffi["localizedName"] = A.load.Ref(details + 12, undefined); 86 details_ffi["manifest"] = A.load.Ref(details + 16, undefined); 87 88 const _ret = WEBEXT.dashboardPrivate.showPermissionPromptForDelegatedInstall(details_ffi); 89 A.store.Ref(retPtr, _ret); 90 return A.H.TRUE; 91 } catch (err: any) { 92 A.store.Ref(errPtr, err); 93 return A.H.FALSE; 94 } 95 }, 96 }; 97 });