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

     1  import { importModule, Application, heap, Pointer } from "@ffi";
     2  
     3  importModule("plat/js/webext/windows", (A: Application) => {
     4    const WEBEXT = typeof globalThis.browser === "undefined" ? globalThis.chrome : globalThis.browser;
     5  
     6    return {
     7      "constof_WindowState": (ref: heap.Ref<string>): number => {
     8        const idx = ["normal", "minimized", "maximized", "fullscreen", "locked-fullscreen"].indexOf(A.H.get(ref));
     9        return idx < 0 ? 0 : idx + 1;
    10      },
    11      "constof_CreateType": (ref: heap.Ref<string>): number => {
    12        const idx = ["normal", "popup", "panel"].indexOf(A.H.get(ref));
    13        return idx < 0 ? 0 : idx + 1;
    14      },
    15  
    16      "store_CreateArgCreateData": (ptr: Pointer, ref: heap.Ref<any>) => {
    17        const x = A.H.get<any>(ref);
    18  
    19        if (typeof x === "undefined") {
    20          A.store.Bool(ptr + 80, false);
    21          A.store.Bool(ptr + 72, false);
    22          A.store.Bool(ptr + 0, false);
    23          A.store.Bool(ptr + 73, false);
    24          A.store.Int64(ptr + 8, 0);
    25          A.store.Bool(ptr + 74, false);
    26          A.store.Bool(ptr + 16, false);
    27          A.store.Bool(ptr + 75, false);
    28          A.store.Int64(ptr + 24, 0);
    29          A.store.Bool(ptr + 76, false);
    30          A.store.Bool(ptr + 32, false);
    31          A.store.Enum(ptr + 36, -1);
    32          A.store.Bool(ptr + 77, false);
    33          A.store.Int64(ptr + 40, 0);
    34          A.store.Bool(ptr + 78, false);
    35          A.store.Int64(ptr + 48, 0);
    36          A.store.Enum(ptr + 56, -1);
    37          A.store.Ref(ptr + 60, undefined);
    38          A.store.Bool(ptr + 79, false);
    39          A.store.Int64(ptr + 64, 0);
    40        } else {
    41          A.store.Bool(ptr + 80, true);
    42          A.store.Bool(ptr + 72, "focused" in x ? true : false);
    43          A.store.Bool(ptr + 0, x["focused"] ? true : false);
    44          A.store.Bool(ptr + 73, "height" in x ? true : false);
    45          A.store.Int64(ptr + 8, x["height"] === undefined ? 0 : (x["height"] as number));
    46          A.store.Bool(ptr + 74, "incognito" in x ? true : false);
    47          A.store.Bool(ptr + 16, x["incognito"] ? true : false);
    48          A.store.Bool(ptr + 75, "left" in x ? true : false);
    49          A.store.Int64(ptr + 24, x["left"] === undefined ? 0 : (x["left"] as number));
    50          A.store.Bool(ptr + 76, "setSelfAsOpener" in x ? true : false);
    51          A.store.Bool(ptr + 32, x["setSelfAsOpener"] ? true : false);
    52          A.store.Enum(
    53            ptr + 36,
    54            ["normal", "minimized", "maximized", "fullscreen", "locked-fullscreen"].indexOf(x["state"] as string)
    55          );
    56          A.store.Bool(ptr + 77, "tabId" in x ? true : false);
    57          A.store.Int64(ptr + 40, x["tabId"] === undefined ? 0 : (x["tabId"] as number));
    58          A.store.Bool(ptr + 78, "top" in x ? true : false);
    59          A.store.Int64(ptr + 48, x["top"] === undefined ? 0 : (x["top"] as number));
    60          A.store.Enum(ptr + 56, ["normal", "popup", "panel"].indexOf(x["type"] as string));
    61          A.store.Ref(ptr + 60, x["url"]);
    62          A.store.Bool(ptr + 79, "width" in x ? true : false);
    63          A.store.Int64(ptr + 64, x["width"] === undefined ? 0 : (x["width"] as number));
    64        }
    65      },
    66      "load_CreateArgCreateData": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
    67        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
    68  
    69        if (A.load.Bool(ptr + 72)) {
    70          x["focused"] = A.load.Bool(ptr + 0);
    71        } else {
    72          delete x["focused"];
    73        }
    74        if (A.load.Bool(ptr + 73)) {
    75          x["height"] = A.load.Int64(ptr + 8);
    76        } else {
    77          delete x["height"];
    78        }
    79        if (A.load.Bool(ptr + 74)) {
    80          x["incognito"] = A.load.Bool(ptr + 16);
    81        } else {
    82          delete x["incognito"];
    83        }
    84        if (A.load.Bool(ptr + 75)) {
    85          x["left"] = A.load.Int64(ptr + 24);
    86        } else {
    87          delete x["left"];
    88        }
    89        if (A.load.Bool(ptr + 76)) {
    90          x["setSelfAsOpener"] = A.load.Bool(ptr + 32);
    91        } else {
    92          delete x["setSelfAsOpener"];
    93        }
    94        x["state"] = A.load.Enum(ptr + 36, ["normal", "minimized", "maximized", "fullscreen", "locked-fullscreen"]);
    95        if (A.load.Bool(ptr + 77)) {
    96          x["tabId"] = A.load.Int64(ptr + 40);
    97        } else {
    98          delete x["tabId"];
    99        }
   100        if (A.load.Bool(ptr + 78)) {
   101          x["top"] = A.load.Int64(ptr + 48);
   102        } else {
   103          delete x["top"];
   104        }
   105        x["type"] = A.load.Enum(ptr + 56, ["normal", "popup", "panel"]);
   106        x["url"] = A.load.Ref(ptr + 60, undefined);
   107        if (A.load.Bool(ptr + 79)) {
   108          x["width"] = A.load.Int64(ptr + 64);
   109        } else {
   110          delete x["width"];
   111        }
   112        return create === A.H.TRUE ? A.H.push(x) : ref;
   113      },
   114      "constof_WindowType": (ref: heap.Ref<string>): number => {
   115        const idx = ["normal", "popup", "panel", "app", "devtools"].indexOf(A.H.get(ref));
   116        return idx < 0 ? 0 : idx + 1;
   117      },
   118  
   119      "store_Window": (ptr: Pointer, ref: heap.Ref<any>) => {
   120        const x = A.H.get<any>(ref);
   121  
   122        if (typeof x === "undefined") {
   123          A.store.Bool(ptr + 85, false);
   124          A.store.Bool(ptr + 0, false);
   125          A.store.Bool(ptr + 1, false);
   126          A.store.Bool(ptr + 80, false);
   127          A.store.Int64(ptr + 8, 0);
   128          A.store.Bool(ptr + 81, false);
   129          A.store.Int64(ptr + 16, 0);
   130          A.store.Bool(ptr + 24, false);
   131          A.store.Bool(ptr + 82, false);
   132          A.store.Int64(ptr + 32, 0);
   133          A.store.Ref(ptr + 40, undefined);
   134          A.store.Enum(ptr + 44, -1);
   135          A.store.Ref(ptr + 48, undefined);
   136          A.store.Bool(ptr + 83, false);
   137          A.store.Int64(ptr + 56, 0);
   138          A.store.Enum(ptr + 64, -1);
   139          A.store.Bool(ptr + 84, false);
   140          A.store.Int64(ptr + 72, 0);
   141        } else {
   142          A.store.Bool(ptr + 85, true);
   143          A.store.Bool(ptr + 0, x["alwaysOnTop"] ? true : false);
   144          A.store.Bool(ptr + 1, x["focused"] ? true : false);
   145          A.store.Bool(ptr + 80, "height" in x ? true : false);
   146          A.store.Int64(ptr + 8, x["height"] === undefined ? 0 : (x["height"] as number));
   147          A.store.Bool(ptr + 81, "id" in x ? true : false);
   148          A.store.Int64(ptr + 16, x["id"] === undefined ? 0 : (x["id"] as number));
   149          A.store.Bool(ptr + 24, x["incognito"] ? true : false);
   150          A.store.Bool(ptr + 82, "left" in x ? true : false);
   151          A.store.Int64(ptr + 32, x["left"] === undefined ? 0 : (x["left"] as number));
   152          A.store.Ref(ptr + 40, x["sessionId"]);
   153          A.store.Enum(
   154            ptr + 44,
   155            ["normal", "minimized", "maximized", "fullscreen", "locked-fullscreen"].indexOf(x["state"] as string)
   156          );
   157          A.store.Ref(ptr + 48, x["tabs"]);
   158          A.store.Bool(ptr + 83, "top" in x ? true : false);
   159          A.store.Int64(ptr + 56, x["top"] === undefined ? 0 : (x["top"] as number));
   160          A.store.Enum(ptr + 64, ["normal", "popup", "panel", "app", "devtools"].indexOf(x["type"] as string));
   161          A.store.Bool(ptr + 84, "width" in x ? true : false);
   162          A.store.Int64(ptr + 72, x["width"] === undefined ? 0 : (x["width"] as number));
   163        }
   164      },
   165      "load_Window": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
   166        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
   167  
   168        x["alwaysOnTop"] = A.load.Bool(ptr + 0);
   169        x["focused"] = A.load.Bool(ptr + 1);
   170        if (A.load.Bool(ptr + 80)) {
   171          x["height"] = A.load.Int64(ptr + 8);
   172        } else {
   173          delete x["height"];
   174        }
   175        if (A.load.Bool(ptr + 81)) {
   176          x["id"] = A.load.Int64(ptr + 16);
   177        } else {
   178          delete x["id"];
   179        }
   180        x["incognito"] = A.load.Bool(ptr + 24);
   181        if (A.load.Bool(ptr + 82)) {
   182          x["left"] = A.load.Int64(ptr + 32);
   183        } else {
   184          delete x["left"];
   185        }
   186        x["sessionId"] = A.load.Ref(ptr + 40, undefined);
   187        x["state"] = A.load.Enum(ptr + 44, ["normal", "minimized", "maximized", "fullscreen", "locked-fullscreen"]);
   188        x["tabs"] = A.load.Ref(ptr + 48, undefined);
   189        if (A.load.Bool(ptr + 83)) {
   190          x["top"] = A.load.Int64(ptr + 56);
   191        } else {
   192          delete x["top"];
   193        }
   194        x["type"] = A.load.Enum(ptr + 64, ["normal", "popup", "panel", "app", "devtools"]);
   195        if (A.load.Bool(ptr + 84)) {
   196          x["width"] = A.load.Int64(ptr + 72);
   197        } else {
   198          delete x["width"];
   199        }
   200        return create === A.H.TRUE ? A.H.push(x) : ref;
   201      },
   202  
   203      "store_QueryOptions": (ptr: Pointer, ref: heap.Ref<any>) => {
   204        const x = A.H.get<any>(ref);
   205  
   206        if (typeof x === "undefined") {
   207          A.store.Bool(ptr + 9, false);
   208          A.store.Bool(ptr + 8, false);
   209          A.store.Bool(ptr + 0, false);
   210          A.store.Ref(ptr + 4, undefined);
   211        } else {
   212          A.store.Bool(ptr + 9, true);
   213          A.store.Bool(ptr + 8, "populate" in x ? true : false);
   214          A.store.Bool(ptr + 0, x["populate"] ? true : false);
   215          A.store.Ref(ptr + 4, x["windowTypes"]);
   216        }
   217      },
   218      "load_QueryOptions": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
   219        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
   220  
   221        if (A.load.Bool(ptr + 8)) {
   222          x["populate"] = A.load.Bool(ptr + 0);
   223        } else {
   224          delete x["populate"];
   225        }
   226        x["windowTypes"] = A.load.Ref(ptr + 4, undefined);
   227        return create === A.H.TRUE ? A.H.push(x) : ref;
   228      },
   229  
   230      "store_UpdateArgUpdateInfo": (ptr: Pointer, ref: heap.Ref<any>) => {
   231        const x = A.H.get<any>(ref);
   232  
   233        if (typeof x === "undefined") {
   234          A.store.Bool(ptr + 54, false);
   235          A.store.Bool(ptr + 48, false);
   236          A.store.Bool(ptr + 0, false);
   237          A.store.Bool(ptr + 49, false);
   238          A.store.Bool(ptr + 1, false);
   239          A.store.Bool(ptr + 50, false);
   240          A.store.Int64(ptr + 8, 0);
   241          A.store.Bool(ptr + 51, false);
   242          A.store.Int64(ptr + 16, 0);
   243          A.store.Enum(ptr + 24, -1);
   244          A.store.Bool(ptr + 52, false);
   245          A.store.Int64(ptr + 32, 0);
   246          A.store.Bool(ptr + 53, false);
   247          A.store.Int64(ptr + 40, 0);
   248        } else {
   249          A.store.Bool(ptr + 54, true);
   250          A.store.Bool(ptr + 48, "drawAttention" in x ? true : false);
   251          A.store.Bool(ptr + 0, x["drawAttention"] ? true : false);
   252          A.store.Bool(ptr + 49, "focused" in x ? true : false);
   253          A.store.Bool(ptr + 1, x["focused"] ? true : false);
   254          A.store.Bool(ptr + 50, "height" in x ? true : false);
   255          A.store.Int64(ptr + 8, x["height"] === undefined ? 0 : (x["height"] as number));
   256          A.store.Bool(ptr + 51, "left" in x ? true : false);
   257          A.store.Int64(ptr + 16, x["left"] === undefined ? 0 : (x["left"] as number));
   258          A.store.Enum(
   259            ptr + 24,
   260            ["normal", "minimized", "maximized", "fullscreen", "locked-fullscreen"].indexOf(x["state"] as string)
   261          );
   262          A.store.Bool(ptr + 52, "top" in x ? true : false);
   263          A.store.Int64(ptr + 32, x["top"] === undefined ? 0 : (x["top"] as number));
   264          A.store.Bool(ptr + 53, "width" in x ? true : false);
   265          A.store.Int64(ptr + 40, x["width"] === undefined ? 0 : (x["width"] as number));
   266        }
   267      },
   268      "load_UpdateArgUpdateInfo": (ptr: Pointer, create: heap.Ref<boolean>, ref: heap.Ref<any>): heap.Ref<any> => {
   269        const x = create === A.H.TRUE ? {} : A.H.get<any>(ref);
   270  
   271        if (A.load.Bool(ptr + 48)) {
   272          x["drawAttention"] = A.load.Bool(ptr + 0);
   273        } else {
   274          delete x["drawAttention"];
   275        }
   276        if (A.load.Bool(ptr + 49)) {
   277          x["focused"] = A.load.Bool(ptr + 1);
   278        } else {
   279          delete x["focused"];
   280        }
   281        if (A.load.Bool(ptr + 50)) {
   282          x["height"] = A.load.Int64(ptr + 8);
   283        } else {
   284          delete x["height"];
   285        }
   286        if (A.load.Bool(ptr + 51)) {
   287          x["left"] = A.load.Int64(ptr + 16);
   288        } else {
   289          delete x["left"];
   290        }
   291        x["state"] = A.load.Enum(ptr + 24, ["normal", "minimized", "maximized", "fullscreen", "locked-fullscreen"]);
   292        if (A.load.Bool(ptr + 52)) {
   293          x["top"] = A.load.Int64(ptr + 32);
   294        } else {
   295          delete x["top"];
   296        }
   297        if (A.load.Bool(ptr + 53)) {
   298          x["width"] = A.load.Int64(ptr + 40);
   299        } else {
   300          delete x["width"];
   301        }
   302        return create === A.H.TRUE ? A.H.push(x) : ref;
   303      },
   304      "get_WINDOW_ID_CURRENT": (retPtr: Pointer): heap.Ref<boolean> => {
   305        if (WEBEXT?.windows && "WINDOW_ID_CURRENT" in WEBEXT?.windows) {
   306          const val = WEBEXT.windows.WINDOW_ID_CURRENT;
   307          A.store.Ref(retPtr, val);
   308          return A.H.TRUE;
   309        }
   310  
   311        return A.H.FALSE;
   312      },
   313      "set_WINDOW_ID_CURRENT": (val: heap.Ref<object>): heap.Ref<boolean> => {
   314        return Reflect.set(WEBEXT.windows, "WINDOW_ID_CURRENT", A.H.get<object>(val), WEBEXT.windows)
   315          ? A.H.TRUE
   316          : A.H.FALSE;
   317      },
   318      "get_WINDOW_ID_NONE": (retPtr: Pointer): heap.Ref<boolean> => {
   319        if (WEBEXT?.windows && "WINDOW_ID_NONE" in WEBEXT?.windows) {
   320          const val = WEBEXT.windows.WINDOW_ID_NONE;
   321          A.store.Ref(retPtr, val);
   322          return A.H.TRUE;
   323        }
   324  
   325        return A.H.FALSE;
   326      },
   327      "set_WINDOW_ID_NONE": (val: heap.Ref<object>): heap.Ref<boolean> => {
   328        return Reflect.set(WEBEXT.windows, "WINDOW_ID_NONE", A.H.get<object>(val), WEBEXT.windows) ? A.H.TRUE : A.H.FALSE;
   329      },
   330      "has_Create": (): heap.Ref<boolean> => {
   331        if (WEBEXT?.windows && "create" in WEBEXT?.windows) {
   332          return A.H.TRUE;
   333        }
   334        return A.H.FALSE;
   335      },
   336      "func_Create": (fn: Pointer): void => {
   337        A.store.Ref(fn, WEBEXT.windows.create);
   338      },
   339      "call_Create": (retPtr: Pointer, createData: Pointer): void => {
   340        const createData_ffi = {};
   341  
   342        if (A.load.Bool(createData + 72)) {
   343          createData_ffi["focused"] = A.load.Bool(createData + 0);
   344        }
   345        if (A.load.Bool(createData + 73)) {
   346          createData_ffi["height"] = A.load.Int64(createData + 8);
   347        }
   348        if (A.load.Bool(createData + 74)) {
   349          createData_ffi["incognito"] = A.load.Bool(createData + 16);
   350        }
   351        if (A.load.Bool(createData + 75)) {
   352          createData_ffi["left"] = A.load.Int64(createData + 24);
   353        }
   354        if (A.load.Bool(createData + 76)) {
   355          createData_ffi["setSelfAsOpener"] = A.load.Bool(createData + 32);
   356        }
   357        createData_ffi["state"] = A.load.Enum(createData + 36, [
   358          "normal",
   359          "minimized",
   360          "maximized",
   361          "fullscreen",
   362          "locked-fullscreen",
   363        ]);
   364        if (A.load.Bool(createData + 77)) {
   365          createData_ffi["tabId"] = A.load.Int64(createData + 40);
   366        }
   367        if (A.load.Bool(createData + 78)) {
   368          createData_ffi["top"] = A.load.Int64(createData + 48);
   369        }
   370        createData_ffi["type"] = A.load.Enum(createData + 56, ["normal", "popup", "panel"]);
   371        createData_ffi["url"] = A.load.Ref(createData + 60, undefined);
   372        if (A.load.Bool(createData + 79)) {
   373          createData_ffi["width"] = A.load.Int64(createData + 64);
   374        }
   375  
   376        const _ret = WEBEXT.windows.create(createData_ffi);
   377        A.store.Ref(retPtr, _ret);
   378      },
   379      "try_Create": (retPtr: Pointer, errPtr: Pointer, createData: Pointer): heap.Ref<boolean> => {
   380        try {
   381          const createData_ffi = {};
   382  
   383          if (A.load.Bool(createData + 72)) {
   384            createData_ffi["focused"] = A.load.Bool(createData + 0);
   385          }
   386          if (A.load.Bool(createData + 73)) {
   387            createData_ffi["height"] = A.load.Int64(createData + 8);
   388          }
   389          if (A.load.Bool(createData + 74)) {
   390            createData_ffi["incognito"] = A.load.Bool(createData + 16);
   391          }
   392          if (A.load.Bool(createData + 75)) {
   393            createData_ffi["left"] = A.load.Int64(createData + 24);
   394          }
   395          if (A.load.Bool(createData + 76)) {
   396            createData_ffi["setSelfAsOpener"] = A.load.Bool(createData + 32);
   397          }
   398          createData_ffi["state"] = A.load.Enum(createData + 36, [
   399            "normal",
   400            "minimized",
   401            "maximized",
   402            "fullscreen",
   403            "locked-fullscreen",
   404          ]);
   405          if (A.load.Bool(createData + 77)) {
   406            createData_ffi["tabId"] = A.load.Int64(createData + 40);
   407          }
   408          if (A.load.Bool(createData + 78)) {
   409            createData_ffi["top"] = A.load.Int64(createData + 48);
   410          }
   411          createData_ffi["type"] = A.load.Enum(createData + 56, ["normal", "popup", "panel"]);
   412          createData_ffi["url"] = A.load.Ref(createData + 60, undefined);
   413          if (A.load.Bool(createData + 79)) {
   414            createData_ffi["width"] = A.load.Int64(createData + 64);
   415          }
   416  
   417          const _ret = WEBEXT.windows.create(createData_ffi);
   418          A.store.Ref(retPtr, _ret);
   419          return A.H.TRUE;
   420        } catch (err: any) {
   421          A.store.Ref(errPtr, err);
   422          return A.H.FALSE;
   423        }
   424      },
   425      "has_Get": (): heap.Ref<boolean> => {
   426        if (WEBEXT?.windows && "get" in WEBEXT?.windows) {
   427          return A.H.TRUE;
   428        }
   429        return A.H.FALSE;
   430      },
   431      "func_Get": (fn: Pointer): void => {
   432        A.store.Ref(fn, WEBEXT.windows.get);
   433      },
   434      "call_Get": (retPtr: Pointer, windowId: number, queryOptions: Pointer): void => {
   435        const queryOptions_ffi = {};
   436  
   437        if (A.load.Bool(queryOptions + 8)) {
   438          queryOptions_ffi["populate"] = A.load.Bool(queryOptions + 0);
   439        }
   440        queryOptions_ffi["windowTypes"] = A.load.Ref(queryOptions + 4, undefined);
   441  
   442        const _ret = WEBEXT.windows.get(windowId, queryOptions_ffi);
   443        A.store.Ref(retPtr, _ret);
   444      },
   445      "try_Get": (retPtr: Pointer, errPtr: Pointer, windowId: number, queryOptions: Pointer): heap.Ref<boolean> => {
   446        try {
   447          const queryOptions_ffi = {};
   448  
   449          if (A.load.Bool(queryOptions + 8)) {
   450            queryOptions_ffi["populate"] = A.load.Bool(queryOptions + 0);
   451          }
   452          queryOptions_ffi["windowTypes"] = A.load.Ref(queryOptions + 4, undefined);
   453  
   454          const _ret = WEBEXT.windows.get(windowId, queryOptions_ffi);
   455          A.store.Ref(retPtr, _ret);
   456          return A.H.TRUE;
   457        } catch (err: any) {
   458          A.store.Ref(errPtr, err);
   459          return A.H.FALSE;
   460        }
   461      },
   462      "has_GetAll": (): heap.Ref<boolean> => {
   463        if (WEBEXT?.windows && "getAll" in WEBEXT?.windows) {
   464          return A.H.TRUE;
   465        }
   466        return A.H.FALSE;
   467      },
   468      "func_GetAll": (fn: Pointer): void => {
   469        A.store.Ref(fn, WEBEXT.windows.getAll);
   470      },
   471      "call_GetAll": (retPtr: Pointer, queryOptions: Pointer): void => {
   472        const queryOptions_ffi = {};
   473  
   474        if (A.load.Bool(queryOptions + 8)) {
   475          queryOptions_ffi["populate"] = A.load.Bool(queryOptions + 0);
   476        }
   477        queryOptions_ffi["windowTypes"] = A.load.Ref(queryOptions + 4, undefined);
   478  
   479        const _ret = WEBEXT.windows.getAll(queryOptions_ffi);
   480        A.store.Ref(retPtr, _ret);
   481      },
   482      "try_GetAll": (retPtr: Pointer, errPtr: Pointer, queryOptions: Pointer): heap.Ref<boolean> => {
   483        try {
   484          const queryOptions_ffi = {};
   485  
   486          if (A.load.Bool(queryOptions + 8)) {
   487            queryOptions_ffi["populate"] = A.load.Bool(queryOptions + 0);
   488          }
   489          queryOptions_ffi["windowTypes"] = A.load.Ref(queryOptions + 4, undefined);
   490  
   491          const _ret = WEBEXT.windows.getAll(queryOptions_ffi);
   492          A.store.Ref(retPtr, _ret);
   493          return A.H.TRUE;
   494        } catch (err: any) {
   495          A.store.Ref(errPtr, err);
   496          return A.H.FALSE;
   497        }
   498      },
   499      "has_GetCurrent": (): heap.Ref<boolean> => {
   500        if (WEBEXT?.windows && "getCurrent" in WEBEXT?.windows) {
   501          return A.H.TRUE;
   502        }
   503        return A.H.FALSE;
   504      },
   505      "func_GetCurrent": (fn: Pointer): void => {
   506        A.store.Ref(fn, WEBEXT.windows.getCurrent);
   507      },
   508      "call_GetCurrent": (retPtr: Pointer, queryOptions: Pointer): void => {
   509        const queryOptions_ffi = {};
   510  
   511        if (A.load.Bool(queryOptions + 8)) {
   512          queryOptions_ffi["populate"] = A.load.Bool(queryOptions + 0);
   513        }
   514        queryOptions_ffi["windowTypes"] = A.load.Ref(queryOptions + 4, undefined);
   515  
   516        const _ret = WEBEXT.windows.getCurrent(queryOptions_ffi);
   517        A.store.Ref(retPtr, _ret);
   518      },
   519      "try_GetCurrent": (retPtr: Pointer, errPtr: Pointer, queryOptions: Pointer): heap.Ref<boolean> => {
   520        try {
   521          const queryOptions_ffi = {};
   522  
   523          if (A.load.Bool(queryOptions + 8)) {
   524            queryOptions_ffi["populate"] = A.load.Bool(queryOptions + 0);
   525          }
   526          queryOptions_ffi["windowTypes"] = A.load.Ref(queryOptions + 4, undefined);
   527  
   528          const _ret = WEBEXT.windows.getCurrent(queryOptions_ffi);
   529          A.store.Ref(retPtr, _ret);
   530          return A.H.TRUE;
   531        } catch (err: any) {
   532          A.store.Ref(errPtr, err);
   533          return A.H.FALSE;
   534        }
   535      },
   536      "has_GetLastFocused": (): heap.Ref<boolean> => {
   537        if (WEBEXT?.windows && "getLastFocused" in WEBEXT?.windows) {
   538          return A.H.TRUE;
   539        }
   540        return A.H.FALSE;
   541      },
   542      "func_GetLastFocused": (fn: Pointer): void => {
   543        A.store.Ref(fn, WEBEXT.windows.getLastFocused);
   544      },
   545      "call_GetLastFocused": (retPtr: Pointer, queryOptions: Pointer): void => {
   546        const queryOptions_ffi = {};
   547  
   548        if (A.load.Bool(queryOptions + 8)) {
   549          queryOptions_ffi["populate"] = A.load.Bool(queryOptions + 0);
   550        }
   551        queryOptions_ffi["windowTypes"] = A.load.Ref(queryOptions + 4, undefined);
   552  
   553        const _ret = WEBEXT.windows.getLastFocused(queryOptions_ffi);
   554        A.store.Ref(retPtr, _ret);
   555      },
   556      "try_GetLastFocused": (retPtr: Pointer, errPtr: Pointer, queryOptions: Pointer): heap.Ref<boolean> => {
   557        try {
   558          const queryOptions_ffi = {};
   559  
   560          if (A.load.Bool(queryOptions + 8)) {
   561            queryOptions_ffi["populate"] = A.load.Bool(queryOptions + 0);
   562          }
   563          queryOptions_ffi["windowTypes"] = A.load.Ref(queryOptions + 4, undefined);
   564  
   565          const _ret = WEBEXT.windows.getLastFocused(queryOptions_ffi);
   566          A.store.Ref(retPtr, _ret);
   567          return A.H.TRUE;
   568        } catch (err: any) {
   569          A.store.Ref(errPtr, err);
   570          return A.H.FALSE;
   571        }
   572      },
   573      "has_OnBoundsChanged": (): heap.Ref<boolean> => {
   574        if (WEBEXT?.windows?.onBoundsChanged && "addListener" in WEBEXT?.windows?.onBoundsChanged) {
   575          return A.H.TRUE;
   576        }
   577        return A.H.FALSE;
   578      },
   579      "func_OnBoundsChanged": (fn: Pointer): void => {
   580        A.store.Ref(fn, WEBEXT.windows.onBoundsChanged.addListener);
   581      },
   582      "call_OnBoundsChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   583        const _ret = WEBEXT.windows.onBoundsChanged.addListener(A.H.get<object>(callback));
   584      },
   585      "try_OnBoundsChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   586        try {
   587          const _ret = WEBEXT.windows.onBoundsChanged.addListener(A.H.get<object>(callback));
   588          return A.H.TRUE;
   589        } catch (err: any) {
   590          A.store.Ref(errPtr, err);
   591          return A.H.FALSE;
   592        }
   593      },
   594      "has_OffBoundsChanged": (): heap.Ref<boolean> => {
   595        if (WEBEXT?.windows?.onBoundsChanged && "removeListener" in WEBEXT?.windows?.onBoundsChanged) {
   596          return A.H.TRUE;
   597        }
   598        return A.H.FALSE;
   599      },
   600      "func_OffBoundsChanged": (fn: Pointer): void => {
   601        A.store.Ref(fn, WEBEXT.windows.onBoundsChanged.removeListener);
   602      },
   603      "call_OffBoundsChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   604        const _ret = WEBEXT.windows.onBoundsChanged.removeListener(A.H.get<object>(callback));
   605      },
   606      "try_OffBoundsChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   607        try {
   608          const _ret = WEBEXT.windows.onBoundsChanged.removeListener(A.H.get<object>(callback));
   609          return A.H.TRUE;
   610        } catch (err: any) {
   611          A.store.Ref(errPtr, err);
   612          return A.H.FALSE;
   613        }
   614      },
   615      "has_HasOnBoundsChanged": (): heap.Ref<boolean> => {
   616        if (WEBEXT?.windows?.onBoundsChanged && "hasListener" in WEBEXT?.windows?.onBoundsChanged) {
   617          return A.H.TRUE;
   618        }
   619        return A.H.FALSE;
   620      },
   621      "func_HasOnBoundsChanged": (fn: Pointer): void => {
   622        A.store.Ref(fn, WEBEXT.windows.onBoundsChanged.hasListener);
   623      },
   624      "call_HasOnBoundsChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   625        const _ret = WEBEXT.windows.onBoundsChanged.hasListener(A.H.get<object>(callback));
   626        A.store.Bool(retPtr, _ret);
   627      },
   628      "try_HasOnBoundsChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   629        try {
   630          const _ret = WEBEXT.windows.onBoundsChanged.hasListener(A.H.get<object>(callback));
   631          A.store.Bool(retPtr, _ret);
   632          return A.H.TRUE;
   633        } catch (err: any) {
   634          A.store.Ref(errPtr, err);
   635          return A.H.FALSE;
   636        }
   637      },
   638      "has_OnCreated": (): heap.Ref<boolean> => {
   639        if (WEBEXT?.windows?.onCreated && "addListener" in WEBEXT?.windows?.onCreated) {
   640          return A.H.TRUE;
   641        }
   642        return A.H.FALSE;
   643      },
   644      "func_OnCreated": (fn: Pointer): void => {
   645        A.store.Ref(fn, WEBEXT.windows.onCreated.addListener);
   646      },
   647      "call_OnCreated": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   648        const _ret = WEBEXT.windows.onCreated.addListener(A.H.get<object>(callback));
   649      },
   650      "try_OnCreated": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   651        try {
   652          const _ret = WEBEXT.windows.onCreated.addListener(A.H.get<object>(callback));
   653          return A.H.TRUE;
   654        } catch (err: any) {
   655          A.store.Ref(errPtr, err);
   656          return A.H.FALSE;
   657        }
   658      },
   659      "has_OffCreated": (): heap.Ref<boolean> => {
   660        if (WEBEXT?.windows?.onCreated && "removeListener" in WEBEXT?.windows?.onCreated) {
   661          return A.H.TRUE;
   662        }
   663        return A.H.FALSE;
   664      },
   665      "func_OffCreated": (fn: Pointer): void => {
   666        A.store.Ref(fn, WEBEXT.windows.onCreated.removeListener);
   667      },
   668      "call_OffCreated": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   669        const _ret = WEBEXT.windows.onCreated.removeListener(A.H.get<object>(callback));
   670      },
   671      "try_OffCreated": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   672        try {
   673          const _ret = WEBEXT.windows.onCreated.removeListener(A.H.get<object>(callback));
   674          return A.H.TRUE;
   675        } catch (err: any) {
   676          A.store.Ref(errPtr, err);
   677          return A.H.FALSE;
   678        }
   679      },
   680      "has_HasOnCreated": (): heap.Ref<boolean> => {
   681        if (WEBEXT?.windows?.onCreated && "hasListener" in WEBEXT?.windows?.onCreated) {
   682          return A.H.TRUE;
   683        }
   684        return A.H.FALSE;
   685      },
   686      "func_HasOnCreated": (fn: Pointer): void => {
   687        A.store.Ref(fn, WEBEXT.windows.onCreated.hasListener);
   688      },
   689      "call_HasOnCreated": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   690        const _ret = WEBEXT.windows.onCreated.hasListener(A.H.get<object>(callback));
   691        A.store.Bool(retPtr, _ret);
   692      },
   693      "try_HasOnCreated": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   694        try {
   695          const _ret = WEBEXT.windows.onCreated.hasListener(A.H.get<object>(callback));
   696          A.store.Bool(retPtr, _ret);
   697          return A.H.TRUE;
   698        } catch (err: any) {
   699          A.store.Ref(errPtr, err);
   700          return A.H.FALSE;
   701        }
   702      },
   703      "has_OnFocusChanged": (): heap.Ref<boolean> => {
   704        if (WEBEXT?.windows?.onFocusChanged && "addListener" in WEBEXT?.windows?.onFocusChanged) {
   705          return A.H.TRUE;
   706        }
   707        return A.H.FALSE;
   708      },
   709      "func_OnFocusChanged": (fn: Pointer): void => {
   710        A.store.Ref(fn, WEBEXT.windows.onFocusChanged.addListener);
   711      },
   712      "call_OnFocusChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   713        const _ret = WEBEXT.windows.onFocusChanged.addListener(A.H.get<object>(callback));
   714      },
   715      "try_OnFocusChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   716        try {
   717          const _ret = WEBEXT.windows.onFocusChanged.addListener(A.H.get<object>(callback));
   718          return A.H.TRUE;
   719        } catch (err: any) {
   720          A.store.Ref(errPtr, err);
   721          return A.H.FALSE;
   722        }
   723      },
   724      "has_OffFocusChanged": (): heap.Ref<boolean> => {
   725        if (WEBEXT?.windows?.onFocusChanged && "removeListener" in WEBEXT?.windows?.onFocusChanged) {
   726          return A.H.TRUE;
   727        }
   728        return A.H.FALSE;
   729      },
   730      "func_OffFocusChanged": (fn: Pointer): void => {
   731        A.store.Ref(fn, WEBEXT.windows.onFocusChanged.removeListener);
   732      },
   733      "call_OffFocusChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   734        const _ret = WEBEXT.windows.onFocusChanged.removeListener(A.H.get<object>(callback));
   735      },
   736      "try_OffFocusChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   737        try {
   738          const _ret = WEBEXT.windows.onFocusChanged.removeListener(A.H.get<object>(callback));
   739          return A.H.TRUE;
   740        } catch (err: any) {
   741          A.store.Ref(errPtr, err);
   742          return A.H.FALSE;
   743        }
   744      },
   745      "has_HasOnFocusChanged": (): heap.Ref<boolean> => {
   746        if (WEBEXT?.windows?.onFocusChanged && "hasListener" in WEBEXT?.windows?.onFocusChanged) {
   747          return A.H.TRUE;
   748        }
   749        return A.H.FALSE;
   750      },
   751      "func_HasOnFocusChanged": (fn: Pointer): void => {
   752        A.store.Ref(fn, WEBEXT.windows.onFocusChanged.hasListener);
   753      },
   754      "call_HasOnFocusChanged": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   755        const _ret = WEBEXT.windows.onFocusChanged.hasListener(A.H.get<object>(callback));
   756        A.store.Bool(retPtr, _ret);
   757      },
   758      "try_HasOnFocusChanged": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   759        try {
   760          const _ret = WEBEXT.windows.onFocusChanged.hasListener(A.H.get<object>(callback));
   761          A.store.Bool(retPtr, _ret);
   762          return A.H.TRUE;
   763        } catch (err: any) {
   764          A.store.Ref(errPtr, err);
   765          return A.H.FALSE;
   766        }
   767      },
   768      "has_OnRemoved": (): heap.Ref<boolean> => {
   769        if (WEBEXT?.windows?.onRemoved && "addListener" in WEBEXT?.windows?.onRemoved) {
   770          return A.H.TRUE;
   771        }
   772        return A.H.FALSE;
   773      },
   774      "func_OnRemoved": (fn: Pointer): void => {
   775        A.store.Ref(fn, WEBEXT.windows.onRemoved.addListener);
   776      },
   777      "call_OnRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   778        const _ret = WEBEXT.windows.onRemoved.addListener(A.H.get<object>(callback));
   779      },
   780      "try_OnRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   781        try {
   782          const _ret = WEBEXT.windows.onRemoved.addListener(A.H.get<object>(callback));
   783          return A.H.TRUE;
   784        } catch (err: any) {
   785          A.store.Ref(errPtr, err);
   786          return A.H.FALSE;
   787        }
   788      },
   789      "has_OffRemoved": (): heap.Ref<boolean> => {
   790        if (WEBEXT?.windows?.onRemoved && "removeListener" in WEBEXT?.windows?.onRemoved) {
   791          return A.H.TRUE;
   792        }
   793        return A.H.FALSE;
   794      },
   795      "func_OffRemoved": (fn: Pointer): void => {
   796        A.store.Ref(fn, WEBEXT.windows.onRemoved.removeListener);
   797      },
   798      "call_OffRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   799        const _ret = WEBEXT.windows.onRemoved.removeListener(A.H.get<object>(callback));
   800      },
   801      "try_OffRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   802        try {
   803          const _ret = WEBEXT.windows.onRemoved.removeListener(A.H.get<object>(callback));
   804          return A.H.TRUE;
   805        } catch (err: any) {
   806          A.store.Ref(errPtr, err);
   807          return A.H.FALSE;
   808        }
   809      },
   810      "has_HasOnRemoved": (): heap.Ref<boolean> => {
   811        if (WEBEXT?.windows?.onRemoved && "hasListener" in WEBEXT?.windows?.onRemoved) {
   812          return A.H.TRUE;
   813        }
   814        return A.H.FALSE;
   815      },
   816      "func_HasOnRemoved": (fn: Pointer): void => {
   817        A.store.Ref(fn, WEBEXT.windows.onRemoved.hasListener);
   818      },
   819      "call_HasOnRemoved": (retPtr: Pointer, callback: heap.Ref<object>): void => {
   820        const _ret = WEBEXT.windows.onRemoved.hasListener(A.H.get<object>(callback));
   821        A.store.Bool(retPtr, _ret);
   822      },
   823      "try_HasOnRemoved": (retPtr: Pointer, errPtr: Pointer, callback: heap.Ref<object>): heap.Ref<boolean> => {
   824        try {
   825          const _ret = WEBEXT.windows.onRemoved.hasListener(A.H.get<object>(callback));
   826          A.store.Bool(retPtr, _ret);
   827          return A.H.TRUE;
   828        } catch (err: any) {
   829          A.store.Ref(errPtr, err);
   830          return A.H.FALSE;
   831        }
   832      },
   833      "has_Remove": (): heap.Ref<boolean> => {
   834        if (WEBEXT?.windows && "remove" in WEBEXT?.windows) {
   835          return A.H.TRUE;
   836        }
   837        return A.H.FALSE;
   838      },
   839      "func_Remove": (fn: Pointer): void => {
   840        A.store.Ref(fn, WEBEXT.windows.remove);
   841      },
   842      "call_Remove": (retPtr: Pointer, windowId: number): void => {
   843        const _ret = WEBEXT.windows.remove(windowId);
   844        A.store.Ref(retPtr, _ret);
   845      },
   846      "try_Remove": (retPtr: Pointer, errPtr: Pointer, windowId: number): heap.Ref<boolean> => {
   847        try {
   848          const _ret = WEBEXT.windows.remove(windowId);
   849          A.store.Ref(retPtr, _ret);
   850          return A.H.TRUE;
   851        } catch (err: any) {
   852          A.store.Ref(errPtr, err);
   853          return A.H.FALSE;
   854        }
   855      },
   856      "has_Update": (): heap.Ref<boolean> => {
   857        if (WEBEXT?.windows && "update" in WEBEXT?.windows) {
   858          return A.H.TRUE;
   859        }
   860        return A.H.FALSE;
   861      },
   862      "func_Update": (fn: Pointer): void => {
   863        A.store.Ref(fn, WEBEXT.windows.update);
   864      },
   865      "call_Update": (retPtr: Pointer, windowId: number, updateInfo: Pointer): void => {
   866        const updateInfo_ffi = {};
   867  
   868        if (A.load.Bool(updateInfo + 48)) {
   869          updateInfo_ffi["drawAttention"] = A.load.Bool(updateInfo + 0);
   870        }
   871        if (A.load.Bool(updateInfo + 49)) {
   872          updateInfo_ffi["focused"] = A.load.Bool(updateInfo + 1);
   873        }
   874        if (A.load.Bool(updateInfo + 50)) {
   875          updateInfo_ffi["height"] = A.load.Int64(updateInfo + 8);
   876        }
   877        if (A.load.Bool(updateInfo + 51)) {
   878          updateInfo_ffi["left"] = A.load.Int64(updateInfo + 16);
   879        }
   880        updateInfo_ffi["state"] = A.load.Enum(updateInfo + 24, [
   881          "normal",
   882          "minimized",
   883          "maximized",
   884          "fullscreen",
   885          "locked-fullscreen",
   886        ]);
   887        if (A.load.Bool(updateInfo + 52)) {
   888          updateInfo_ffi["top"] = A.load.Int64(updateInfo + 32);
   889        }
   890        if (A.load.Bool(updateInfo + 53)) {
   891          updateInfo_ffi["width"] = A.load.Int64(updateInfo + 40);
   892        }
   893  
   894        const _ret = WEBEXT.windows.update(windowId, updateInfo_ffi);
   895        A.store.Ref(retPtr, _ret);
   896      },
   897      "try_Update": (retPtr: Pointer, errPtr: Pointer, windowId: number, updateInfo: Pointer): heap.Ref<boolean> => {
   898        try {
   899          const updateInfo_ffi = {};
   900  
   901          if (A.load.Bool(updateInfo + 48)) {
   902            updateInfo_ffi["drawAttention"] = A.load.Bool(updateInfo + 0);
   903          }
   904          if (A.load.Bool(updateInfo + 49)) {
   905            updateInfo_ffi["focused"] = A.load.Bool(updateInfo + 1);
   906          }
   907          if (A.load.Bool(updateInfo + 50)) {
   908            updateInfo_ffi["height"] = A.load.Int64(updateInfo + 8);
   909          }
   910          if (A.load.Bool(updateInfo + 51)) {
   911            updateInfo_ffi["left"] = A.load.Int64(updateInfo + 16);
   912          }
   913          updateInfo_ffi["state"] = A.load.Enum(updateInfo + 24, [
   914            "normal",
   915            "minimized",
   916            "maximized",
   917            "fullscreen",
   918            "locked-fullscreen",
   919          ]);
   920          if (A.load.Bool(updateInfo + 52)) {
   921            updateInfo_ffi["top"] = A.load.Int64(updateInfo + 32);
   922          }
   923          if (A.load.Bool(updateInfo + 53)) {
   924            updateInfo_ffi["width"] = A.load.Int64(updateInfo + 40);
   925          }
   926  
   927          const _ret = WEBEXT.windows.update(windowId, updateInfo_ffi);
   928          A.store.Ref(retPtr, _ret);
   929          return A.H.TRUE;
   930        } catch (err: any) {
   931          A.store.Ref(errPtr, err);
   932          return A.H.FALSE;
   933        }
   934      },
   935    };
   936  });