github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/pagecapture/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/pagecapture", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "store_SaveAsMHTMLArgDetails": (ptr: Pointer, ref: heap.Ref<any>) => { 8 const x = A.H.get<any>(ref); 9 10 if (typeof x === "undefined") { 11 A.store.Bool(ptr + 8, false); 12 A.store.Int64(ptr + 0, 0); 13 } else { 14 A.store.Bool(ptr + 8, true); 15 A.store.Int64(ptr + 0, x["tabId"] === undefined ? 0 : (x["tabId"] as number)); 16 } 17 }, 18 "load_SaveAsMHTMLArgDetails": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => { 19 const x = create === A.H.TRUE ? {} : A.H.get<any>(ref); 20 21 x["tabId"] = A.load.Int64(ptr + 0); 22 return create === A.H.TRUE ? A.H.push(x) : ref; 23 }, 24 "has_SaveAsMHTML": (): heap.Ref<boolean> => { 25 if (WEBEXT?.pageCapture && "saveAsMHTML" in WEBEXT?.pageCapture) { 26 return A.H.TRUE; 27 } 28 return A.H.FALSE; 29 }, 30 "func_SaveAsMHTML": (fn: Pointer): void => { 31 A.store.Ref(fn, WEBEXT.pageCapture.saveAsMHTML); 32 }, 33 "call_SaveAsMHTML": (retPtr: Pointer, details: Pointer): void => { 34 const details_ffi = {}; 35 36 details_ffi["tabId"] = A.load.Int64(details + 0); 37 38 const _ret = WEBEXT.pageCapture.saveAsMHTML(details_ffi); 39 A.store.Ref(retPtr, _ret); 40 }, 41 "try_SaveAsMHTML": (retPtr: Pointer, errPtr: Pointer, details: Pointer): heap.Ref<boolean> => { 42 try { 43 const details_ffi = {}; 44 45 details_ffi["tabId"] = A.load.Int64(details + 0); 46 47 const _ret = WEBEXT.pageCapture.saveAsMHTML(details_ffi); 48 A.store.Ref(retPtr, _ret); 49 return A.H.TRUE; 50 } catch (err: any) { 51 A.store.Ref(errPtr, err); 52 return A.H.FALSE; 53 } 54 }, 55 }; 56 });