github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/accessibilityserviceprivate/bindings/ffi_bindings.ts (about)

     1  import { importModule, Application, heap, Pointer } from "@ffi";
     2  
     3  importModule("plat/js/webext/accessibilityserviceprivate", (A: Application) => {
     4    const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser;
     5  
     6    return {
     7      "has_SpeakSelectedText": (): heap.Ref<boolean> => {
     8        if (WEBEXT?.accessibilityServicePrivate && "speakSelectedText" in WEBEXT?.accessibilityServicePrivate) {
     9          return A.H.TRUE;
    10        }
    11        return A.H.FALSE;
    12      },
    13      "func_SpeakSelectedText": (fn: Pointer): void => {
    14        A.store.Ref(fn, WEBEXT.accessibilityServicePrivate.speakSelectedText);
    15      },
    16      "call_SpeakSelectedText": (retPtr: Pointer): void => {
    17        const _ret = WEBEXT.accessibilityServicePrivate.speakSelectedText();
    18        A.store.Ref(retPtr, _ret);
    19      },
    20      "try_SpeakSelectedText": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
    21        try {
    22          const _ret = WEBEXT.accessibilityServicePrivate.speakSelectedText();
    23          A.store.Ref(retPtr, _ret);
    24          return A.H.TRUE;
    25        } catch (err: any) {
    26          A.store.Ref(errPtr, err);
    27          return A.H.FALSE;
    28        }
    29      },
    30    };
    31  });