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

     1  import { importModule, Application, heap, Pointer } from "@ffi";
     2  
     3  importModule("plat/js/webext/webstoreprivate", (A: Application) => {
     4    const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser;
     5  
     6    return {
     7      "constof_ExtensionInstallStatus": (ref: heap.Ref<string>): number => {
     8        const idx = [
     9          "can_request",
    10          "request_pending",
    11          "blocked_by_policy",
    12          "installable",
    13          "enabled",
    14          "disabled",
    15          "terminated",
    16          "blacklisted",
    17          "custodian_approval_required",
    18          "force_installed",
    19        ].indexOf(A.H.get(ref));
    20        return idx < 0 ? 0 : idx + 1;
    21      },
    22  
    23      "store_GetBrowserLoginReturnType": (ptr: Pointer, ref: heap.Ref<any>) => {
    24        const x = A.H.get<any>(ref);
    25  
    26        if (typeof x === "undefined") {
    27          A.store.Bool(ptr + 4, false);
    28          A.store.Ref(ptr + 0, undefined);
    29        } else {
    30          A.store.Bool(ptr + 4, true);
    31          A.store.Ref(ptr + 0, x["login"]);
    32        }
    33      },
    34      "load_GetBrowserLoginReturnType": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
    35        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
    36  
    37        x["login"] = A.load.Ref(ptr + 0, undefined);
    38        return create === A.H.TRUE ? A.H.push(x) : ref;
    39      },
    40      "constof_Result": (ref: heap.Ref<string>): number => {
    41        const idx = [
    42          "",
    43          "success",
    44          "user_gesture_required",
    45          "unknown_error",
    46          "feature_disabled",
    47          "unsupported_extension_type",
    48          "missing_dependencies",
    49          "install_error",
    50          "user_cancelled",
    51          "invalid_id",
    52          "blacklisted",
    53          "blocked_by_policy",
    54          "install_in_progress",
    55          "launch_in_progress",
    56          "manifest_error",
    57          "icon_error",
    58          "invalid_icon_url",
    59          "already_installed",
    60          "blocked_for_child_account",
    61        ].indexOf(A.H.get(ref));
    62        return idx < 0 ? 0 : idx + 1;
    63      },
    64      "constof_WebGlStatus": (ref: heap.Ref<string>): number => {
    65        const idx = ["webgl_allowed", "webgl_blocked"].indexOf(A.H.get(ref));
    66        return idx < 0 ? 0 : idx + 1;
    67      },
    68      "has_BeginInstallWithManifest3": (): heap.Ref<boolean> => {
    69        if (WEBEXT?.webstorePrivate && "beginInstallWithManifest3" in WEBEXT?.webstorePrivate) {
    70          return A.H.TRUE;
    71        }
    72        return A.H.FALSE;
    73      },
    74      "func_BeginInstallWithManifest3": (fn: Pointer): void => {
    75        A.store.Ref(fn, WEBEXT.webstorePrivate.beginInstallWithManifest3);
    76      },
    77      "call_BeginInstallWithManifest3": (retPtr: Pointer, details: heap.Ref<object>): void => {
    78        const _ret = WEBEXT.webstorePrivate.beginInstallWithManifest3(A.H.get<object>(details));
    79        A.store.Ref(retPtr, _ret);
    80      },
    81      "try_BeginInstallWithManifest3": (
    82        retPtr: Pointer,
    83        errPtr: Pointer,
    84        details: heap.Ref<object>
    85      ): heap.Ref<boolean> => {
    86        try {
    87          const _ret = WEBEXT.webstorePrivate.beginInstallWithManifest3(A.H.get<object>(details));
    88          A.store.Ref(retPtr, _ret);
    89          return A.H.TRUE;
    90        } catch (err: any) {
    91          A.store.Ref(errPtr, err);
    92          return A.H.FALSE;
    93        }
    94      },
    95      "has_CompleteInstall": (): heap.Ref<boolean> => {
    96        if (WEBEXT?.webstorePrivate && "completeInstall" in WEBEXT?.webstorePrivate) {
    97          return A.H.TRUE;
    98        }
    99        return A.H.FALSE;
   100      },
   101      "func_CompleteInstall": (fn: Pointer): void => {
   102        A.store.Ref(fn, WEBEXT.webstorePrivate.completeInstall);
   103      },
   104      "call_CompleteInstall": (retPtr: Pointer, expected_id: heap.Ref<object>): void => {
   105        const _ret = WEBEXT.webstorePrivate.completeInstall(A.H.get<object>(expected_id));
   106        A.store.Ref(retPtr, _ret);
   107      },
   108      "try_CompleteInstall": (retPtr: Pointer, errPtr: Pointer, expected_id: heap.Ref<object>): heap.Ref<boolean> => {
   109        try {
   110          const _ret = WEBEXT.webstorePrivate.completeInstall(A.H.get<object>(expected_id));
   111          A.store.Ref(retPtr, _ret);
   112          return A.H.TRUE;
   113        } catch (err: any) {
   114          A.store.Ref(errPtr, err);
   115          return A.H.FALSE;
   116        }
   117      },
   118      "has_EnableAppLauncher": (): heap.Ref<boolean> => {
   119        if (WEBEXT?.webstorePrivate && "enableAppLauncher" in WEBEXT?.webstorePrivate) {
   120          return A.H.TRUE;
   121        }
   122        return A.H.FALSE;
   123      },
   124      "func_EnableAppLauncher": (fn: Pointer): void => {
   125        A.store.Ref(fn, WEBEXT.webstorePrivate.enableAppLauncher);
   126      },
   127      "call_EnableAppLauncher": (retPtr: Pointer): void => {
   128        const _ret = WEBEXT.webstorePrivate.enableAppLauncher();
   129        A.store.Ref(retPtr, _ret);
   130      },
   131      "try_EnableAppLauncher": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
   132        try {
   133          const _ret = WEBEXT.webstorePrivate.enableAppLauncher();
   134          A.store.Ref(retPtr, _ret);
   135          return A.H.TRUE;
   136        } catch (err: any) {
   137          A.store.Ref(errPtr, err);
   138          return A.H.FALSE;
   139        }
   140      },
   141      "has_GetBrowserLogin": (): heap.Ref<boolean> => {
   142        if (WEBEXT?.webstorePrivate && "getBrowserLogin" in WEBEXT?.webstorePrivate) {
   143          return A.H.TRUE;
   144        }
   145        return A.H.FALSE;
   146      },
   147      "func_GetBrowserLogin": (fn: Pointer): void => {
   148        A.store.Ref(fn, WEBEXT.webstorePrivate.getBrowserLogin);
   149      },
   150      "call_GetBrowserLogin": (retPtr: Pointer): void => {
   151        const _ret = WEBEXT.webstorePrivate.getBrowserLogin();
   152        A.store.Ref(retPtr, _ret);
   153      },
   154      "try_GetBrowserLogin": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
   155        try {
   156          const _ret = WEBEXT.webstorePrivate.getBrowserLogin();
   157          A.store.Ref(retPtr, _ret);
   158          return A.H.TRUE;
   159        } catch (err: any) {
   160          A.store.Ref(errPtr, err);
   161          return A.H.FALSE;
   162        }
   163      },
   164      "has_GetExtensionStatus": (): heap.Ref<boolean> => {
   165        if (WEBEXT?.webstorePrivate && "getExtensionStatus" in WEBEXT?.webstorePrivate) {
   166          return A.H.TRUE;
   167        }
   168        return A.H.FALSE;
   169      },
   170      "func_GetExtensionStatus": (fn: Pointer): void => {
   171        A.store.Ref(fn, WEBEXT.webstorePrivate.getExtensionStatus);
   172      },
   173      "call_GetExtensionStatus": (retPtr: Pointer, id: heap.Ref<object>, manifest: heap.Ref<object>): void => {
   174        const _ret = WEBEXT.webstorePrivate.getExtensionStatus(A.H.get<object>(id), A.H.get<object>(manifest));
   175        A.store.Ref(retPtr, _ret);
   176      },
   177      "try_GetExtensionStatus": (
   178        retPtr: Pointer,
   179        errPtr: Pointer,
   180        id: heap.Ref<object>,
   181        manifest: heap.Ref<object>
   182      ): heap.Ref<boolean> => {
   183        try {
   184          const _ret = WEBEXT.webstorePrivate.getExtensionStatus(A.H.get<object>(id), A.H.get<object>(manifest));
   185          A.store.Ref(retPtr, _ret);
   186          return A.H.TRUE;
   187        } catch (err: any) {
   188          A.store.Ref(errPtr, err);
   189          return A.H.FALSE;
   190        }
   191      },
   192      "has_GetIsLauncherEnabled": (): heap.Ref<boolean> => {
   193        if (WEBEXT?.webstorePrivate && "getIsLauncherEnabled" in WEBEXT?.webstorePrivate) {
   194          return A.H.TRUE;
   195        }
   196        return A.H.FALSE;
   197      },
   198      "func_GetIsLauncherEnabled": (fn: Pointer): void => {
   199        A.store.Ref(fn, WEBEXT.webstorePrivate.getIsLauncherEnabled);
   200      },
   201      "call_GetIsLauncherEnabled": (retPtr: Pointer): void => {
   202        const _ret = WEBEXT.webstorePrivate.getIsLauncherEnabled();
   203        A.store.Ref(retPtr, _ret);
   204      },
   205      "try_GetIsLauncherEnabled": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
   206        try {
   207          const _ret = WEBEXT.webstorePrivate.getIsLauncherEnabled();
   208          A.store.Ref(retPtr, _ret);
   209          return A.H.TRUE;
   210        } catch (err: any) {
   211          A.store.Ref(errPtr, err);
   212          return A.H.FALSE;
   213        }
   214      },
   215      "has_GetReferrerChain": (): heap.Ref<boolean> => {
   216        if (WEBEXT?.webstorePrivate && "getReferrerChain" in WEBEXT?.webstorePrivate) {
   217          return A.H.TRUE;
   218        }
   219        return A.H.FALSE;
   220      },
   221      "func_GetReferrerChain": (fn: Pointer): void => {
   222        A.store.Ref(fn, WEBEXT.webstorePrivate.getReferrerChain);
   223      },
   224      "call_GetReferrerChain": (retPtr: Pointer): void => {
   225        const _ret = WEBEXT.webstorePrivate.getReferrerChain();
   226        A.store.Ref(retPtr, _ret);
   227      },
   228      "try_GetReferrerChain": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
   229        try {
   230          const _ret = WEBEXT.webstorePrivate.getReferrerChain();
   231          A.store.Ref(retPtr, _ret);
   232          return A.H.TRUE;
   233        } catch (err: any) {
   234          A.store.Ref(errPtr, err);
   235          return A.H.FALSE;
   236        }
   237      },
   238      "has_GetStoreLogin": (): heap.Ref<boolean> => {
   239        if (WEBEXT?.webstorePrivate && "getStoreLogin" in WEBEXT?.webstorePrivate) {
   240          return A.H.TRUE;
   241        }
   242        return A.H.FALSE;
   243      },
   244      "func_GetStoreLogin": (fn: Pointer): void => {
   245        A.store.Ref(fn, WEBEXT.webstorePrivate.getStoreLogin);
   246      },
   247      "call_GetStoreLogin": (retPtr: Pointer): void => {
   248        const _ret = WEBEXT.webstorePrivate.getStoreLogin();
   249        A.store.Ref(retPtr, _ret);
   250      },
   251      "try_GetStoreLogin": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
   252        try {
   253          const _ret = WEBEXT.webstorePrivate.getStoreLogin();
   254          A.store.Ref(retPtr, _ret);
   255          return A.H.TRUE;
   256        } catch (err: any) {
   257          A.store.Ref(errPtr, err);
   258          return A.H.FALSE;
   259        }
   260      },
   261      "has_GetWebGLStatus": (): heap.Ref<boolean> => {
   262        if (WEBEXT?.webstorePrivate && "getWebGLStatus" in WEBEXT?.webstorePrivate) {
   263          return A.H.TRUE;
   264        }
   265        return A.H.FALSE;
   266      },
   267      "func_GetWebGLStatus": (fn: Pointer): void => {
   268        A.store.Ref(fn, WEBEXT.webstorePrivate.getWebGLStatus);
   269      },
   270      "call_GetWebGLStatus": (retPtr: Pointer): void => {
   271        const _ret = WEBEXT.webstorePrivate.getWebGLStatus();
   272        A.store.Ref(retPtr, _ret);
   273      },
   274      "try_GetWebGLStatus": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
   275        try {
   276          const _ret = WEBEXT.webstorePrivate.getWebGLStatus();
   277          A.store.Ref(retPtr, _ret);
   278          return A.H.TRUE;
   279        } catch (err: any) {
   280          A.store.Ref(errPtr, err);
   281          return A.H.FALSE;
   282        }
   283      },
   284      "has_Install": (): heap.Ref<boolean> => {
   285        if (WEBEXT?.webstorePrivate && "install" in WEBEXT?.webstorePrivate) {
   286          return A.H.TRUE;
   287        }
   288        return A.H.FALSE;
   289      },
   290      "func_Install": (fn: Pointer): void => {
   291        A.store.Ref(fn, WEBEXT.webstorePrivate.install);
   292      },
   293      "call_Install": (retPtr: Pointer, expected_id: heap.Ref<object>): void => {
   294        const _ret = WEBEXT.webstorePrivate.install(A.H.get<object>(expected_id));
   295        A.store.Ref(retPtr, _ret);
   296      },
   297      "try_Install": (retPtr: Pointer, errPtr: Pointer, expected_id: heap.Ref<object>): heap.Ref<boolean> => {
   298        try {
   299          const _ret = WEBEXT.webstorePrivate.install(A.H.get<object>(expected_id));
   300          A.store.Ref(retPtr, _ret);
   301          return A.H.TRUE;
   302        } catch (err: any) {
   303          A.store.Ref(errPtr, err);
   304          return A.H.FALSE;
   305        }
   306      },
   307      "has_IsInIncognitoMode": (): heap.Ref<boolean> => {
   308        if (WEBEXT?.webstorePrivate && "isInIncognitoMode" in WEBEXT?.webstorePrivate) {
   309          return A.H.TRUE;
   310        }
   311        return A.H.FALSE;
   312      },
   313      "func_IsInIncognitoMode": (fn: Pointer): void => {
   314        A.store.Ref(fn, WEBEXT.webstorePrivate.isInIncognitoMode);
   315      },
   316      "call_IsInIncognitoMode": (retPtr: Pointer): void => {
   317        const _ret = WEBEXT.webstorePrivate.isInIncognitoMode();
   318        A.store.Ref(retPtr, _ret);
   319      },
   320      "try_IsInIncognitoMode": (retPtr: Pointer, errPtr: Pointer): heap.Ref<boolean> => {
   321        try {
   322          const _ret = WEBEXT.webstorePrivate.isInIncognitoMode();
   323          A.store.Ref(retPtr, _ret);
   324          return A.H.TRUE;
   325        } catch (err: any) {
   326          A.store.Ref(errPtr, err);
   327          return A.H.FALSE;
   328        }
   329      },
   330      "has_IsPendingCustodianApproval": (): heap.Ref<boolean> => {
   331        if (WEBEXT?.webstorePrivate && "isPendingCustodianApproval" in WEBEXT?.webstorePrivate) {
   332          return A.H.TRUE;
   333        }
   334        return A.H.FALSE;
   335      },
   336      "func_IsPendingCustodianApproval": (fn: Pointer): void => {
   337        A.store.Ref(fn, WEBEXT.webstorePrivate.isPendingCustodianApproval);
   338      },
   339      "call_IsPendingCustodianApproval": (retPtr: Pointer, id: heap.Ref<object>): void => {
   340        const _ret = WEBEXT.webstorePrivate.isPendingCustodianApproval(A.H.get<object>(id));
   341        A.store.Ref(retPtr, _ret);
   342      },
   343      "try_IsPendingCustodianApproval": (retPtr: Pointer, errPtr: Pointer, id: heap.Ref<object>): heap.Ref<boolean> => {
   344        try {
   345          const _ret = WEBEXT.webstorePrivate.isPendingCustodianApproval(A.H.get<object>(id));
   346          A.store.Ref(retPtr, _ret);
   347          return A.H.TRUE;
   348        } catch (err: any) {
   349          A.store.Ref(errPtr, err);
   350          return A.H.FALSE;
   351        }
   352      },
   353      "has_SetStoreLogin": (): heap.Ref<boolean> => {
   354        if (WEBEXT?.webstorePrivate && "setStoreLogin" in WEBEXT?.webstorePrivate) {
   355          return A.H.TRUE;
   356        }
   357        return A.H.FALSE;
   358      },
   359      "func_SetStoreLogin": (fn: Pointer): void => {
   360        A.store.Ref(fn, WEBEXT.webstorePrivate.setStoreLogin);
   361      },
   362      "call_SetStoreLogin": (retPtr: Pointer, login: heap.Ref<object>): void => {
   363        const _ret = WEBEXT.webstorePrivate.setStoreLogin(A.H.get<object>(login));
   364        A.store.Ref(retPtr, _ret);
   365      },
   366      "try_SetStoreLogin": (retPtr: Pointer, errPtr: Pointer, login: heap.Ref<object>): heap.Ref<boolean> => {
   367        try {
   368          const _ret = WEBEXT.webstorePrivate.setStoreLogin(A.H.get<object>(login));
   369          A.store.Ref(retPtr, _ret);
   370          return A.H.TRUE;
   371        } catch (err: any) {
   372          A.store.Ref(errPtr, err);
   373          return A.H.FALSE;
   374        }
   375      },
   376    };
   377  });