github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/resourcesprivate/bindings/ffi_bindings.ts (about) 1 import { importModule, Application, heap, Pointer } from "@ffi"; 2 3 importModule("plat/js/webext/resourcesprivate", (A: Application) => { 4 const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser; 5 6 return { 7 "constof_Component": (ref: heap.Ref<string>): number => { 8 const idx = ["identity", "pdf"].indexOf(A.H.get(ref)); 9 return idx < 0 ? 0 : idx + 1; 10 }, 11 "has_GetStrings": (): heap.Ref<boolean> => { 12 if (WEBEXT?.resourcesPrivate && "getStrings" in WEBEXT?.resourcesPrivate) { 13 return A.H.TRUE; 14 } 15 return A.H.FALSE; 16 }, 17 "func_GetStrings": (fn: Pointer): void => { 18 A.store.Ref(fn, WEBEXT.resourcesPrivate.getStrings); 19 }, 20 "call_GetStrings": (retPtr: Pointer, component: number): void => { 21 const _ret = WEBEXT.resourcesPrivate.getStrings( 22 component > 0 && component <= 2 ? ["identity", "pdf"][component - 1] : undefined 23 ); 24 A.store.Ref(retPtr, _ret); 25 }, 26 "try_GetStrings": (retPtr: Pointer, errPtr: Pointer, component: number): heap.Ref<boolean> => { 27 try { 28 const _ret = WEBEXT.resourcesPrivate.getStrings( 29 component > 0 && component <= 2 ? ["identity", "pdf"][component - 1] : undefined 30 ); 31 A.store.Ref(retPtr, _ret); 32 return A.H.TRUE; 33 } catch (err: any) { 34 A.store.Ref(errPtr, err); 35 return A.H.FALSE; 36 } 37 }, 38 }; 39 });