@overlayed/app 0.36.3 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2,8 +2,10 @@ import * as arktype0 from "arktype";
2
2
  import { Module, Type } from "arktype";
3
3
  import EventEmitter$1 from "events";
4
4
  import "xior";
5
+ import JSZip from "jszip";
5
6
  import * as electron0 from "electron";
6
7
  import { BrowserWindow, BrowserWindowConstructorOptions } from "electron";
8
+ import { CancellationToken, ProgressInfo, ProgressInfo as ProgressInfo$1, UpdateCheckResult, UpdateCheckResult as UpdateCheckResult$1, UpdateDownloadedEvent, UpdateInfo } from "electron-updater";
7
9
  import * as arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
8
10
  import { KeyboardKeyEvent, MouseButtonEvent, RenderInterface, RenderInterface as RenderInterface$1, RenderWindow, RenderWindow as RenderWindow$1, RenderWindowConstructorOptions, RenderWindowConstructorOptions as RenderWindowConstructorOptions$1, VirtualKey, VirtualKey as VirtualKey$1, WindowEvent } from "@overlayed-gg/render-interface";
9
11
 
@@ -247,11 +249,12 @@ type EventCallback<TEvent extends BaseEvent, TEventType extends EventType<TEvent
247
249
  //#endregion
248
250
  //#region src/managers/manager.d.ts
249
251
  /** This should be kept in sync with EventEmitterManager */
250
- declare class Manager {
252
+ declare class Manager<O extends Record<string, any> = {}> {
253
+ protected options: O | null;
251
254
  protected logger: CustomLoggerScope;
252
255
  initialized: boolean;
253
256
  constructor(name: string);
254
- init(): void;
257
+ init(options?: O): void;
255
258
  destroy(): void;
256
259
  }
257
260
  //#endregion
@@ -273,10 +276,14 @@ declare const KeybindSchema: arktype_internal_variants_object_ts0.ObjectType<{
273
276
  type KeybindSchemaEntry = (typeof KeybindSchema.infer)[string];
274
277
  //#endregion
275
278
  //#region ../api/dist/index.d.ts
279
+
280
+ //#endregion
281
+ //#region src/endpoints/modules/releases.d.ts
282
+ type ReleaseId = Brand<string, "release_id">;
283
+ declare const ReleaseId: Brander<Brand<string, "release_id">>;
276
284
  type FeedbackType = "suggestion" | "bug_report";
277
285
  interface FeedbackRequestDataModel {
278
- app_version: string;
279
- app_channel: string;
286
+ release_id?: ReleaseId;
280
287
  type: FeedbackType;
281
288
  cortex_user_id: string;
282
289
  email?: string;
@@ -318,9 +325,6 @@ interface NoticeModel {
318
325
  }
319
326
  type NoticeId = NoticeModel["id"];
320
327
  //#endregion
321
- //#region src/instances.d.ts
322
- declare function setUpdaterTokenResolver(newTokenResolver: () => string | undefined): void;
323
- //#endregion
324
328
  //#region src/managers/gameLaunchManager.d.ts
325
329
  type GameReadyEvent = {
326
330
  game: string;
@@ -433,6 +437,37 @@ declare function module(): {
433
437
  //#endregion
434
438
  //#region src/events/loggedIn.d.ts
435
439
  //#endregion
440
+ //#region src/managers/updateManager/updateManager.d.ts
441
+ type UpdateManagerEvents = {
442
+ error: {
443
+ error: Error;
444
+ message?: string;
445
+ };
446
+ checkingForUpdates: {};
447
+ updateNotAvailable: {
448
+ info: UpdateInfo;
449
+ };
450
+ updateAvailable: {
451
+ info: UpdateInfo;
452
+ };
453
+ updateDownloaded: {
454
+ event: UpdateDownloadedEvent;
455
+ };
456
+ updateCancelled: {
457
+ info: UpdateInfo;
458
+ };
459
+ downloadProgress: {
460
+ info: ProgressInfo$1;
461
+ };
462
+ /**
463
+ * Emitted when the access token fetcher returns an invalid token.
464
+ *
465
+ * We strongly recommend logging the user out in this case, as it likely means
466
+ * their account no longer has access to the private channel.
467
+ */
468
+ authTokenInvalid: {};
469
+ };
470
+ //#endregion
436
471
  //#region src/utilities/types.d.ts
437
472
  type UniversalGameModule = ReturnType<typeof module>;
438
473
  type OverlayedAppGameModules<TModule extends GameModule> = { [TKey in TModule["key"]]: OverlayedAppGameModuleListeners<TModule, TKey> } & { [TKey in UniversalGameModule["key"]]: OverlayedAppGameModuleListeners<UniversalGameModule, TKey> };
@@ -536,8 +571,31 @@ type ActiveGameInfo = {
536
571
  };
537
572
  };
538
573
  interface OverlayedAppWindowsModule extends Pick<RenderInterface$1, "on" | "off" | "once" | "addListener" | "prependListener" | "prependOnceListener" | "removeListener" | "removeAllListeners"> {
574
+ /**
575
+ * Returns the production site url configured in the [Overlayed Dashboard](https://overlay.dev/settings).
576
+ *
577
+ * @returns The production site url.
578
+ */
579
+ getProductionSiteUrl: () => URL;
580
+ /**
581
+ * Creates a new window. All windows must be created with this method.
582
+ *
583
+ * @param options The options for the window.
584
+ * @returns The created window.
585
+ */
539
586
  createWindow(options: BrowserWindowConstructorOptions): BrowserWindow;
587
+ /**
588
+ * Creates a new in-game window. All in-game windows must be created with this method.
589
+ *
590
+ * @param options The options for the window.
591
+ * @returns The created window.
592
+ */
540
593
  createInGameWindow(options: RenderWindowConstructorOptions$1): RenderWindow$1;
594
+ /**
595
+ * Returns information about the currently active game.
596
+ *
597
+ * @returns The active game info.
598
+ */
541
599
  getActiveGameInfo: () => ActiveGameInfo;
542
600
  }
543
601
  type OverlayedAppInputModuleRaw = {
@@ -607,6 +665,12 @@ interface OverlayedAppLoggingModuleSubmitFeedbackOptions {
607
665
  * The key is the name of the file, and the value is the content of the file.
608
666
  */
609
667
  additionalFiles?: Record<string, string>;
668
+ /**
669
+ * When true, silences logs
670
+ *
671
+ * @default false
672
+ */
673
+ silent?: boolean;
610
674
  }
611
675
  /**
612
676
  * The logging module.
@@ -658,6 +722,20 @@ interface OverlayedAppLoggingModule {
658
722
  * @returns The unique feedback identifier, or undefined if the request fails.
659
723
  */
660
724
  submitFeedback: (type: FeedbackType, info: OverlayedAppLoggingModuleSubmitFeedbackInfo, options?: OverlayedAppLoggingModuleSubmitFeedbackOptions) => Promise<FeedbackId | undefined>;
725
+ /**
726
+ * Get the zip of logs sent via the submitFeedback method.
727
+ *
728
+ * ```ts
729
+ * const zip = overlayed.logger.getLogsZip();
730
+ *
731
+ * // prep to send off to a server
732
+ * const zipBase64 = await zip.generateAsync({ type: "base64" });
733
+ * ```
734
+ *
735
+ * @param options - The options to include in the zip.
736
+ * @returns Returns a zip of app and overlayed logs, and any additional files you provide.
737
+ */
738
+ getLogsZip: (options?: OverlayedAppLoggingModuleSubmitFeedbackOptions) => JSZip;
661
739
  }
662
740
  type OverlayedAppNoticeHandlerMapping = {
663
741
  /**
@@ -702,6 +780,140 @@ interface OverlayedAppNoticesModule {
702
780
  */
703
781
  getNotices: () => NoticeModel[];
704
782
  }
783
+ type OverlayedAppUpdateHandlerMapping = { [K in keyof UpdateManagerEvents]: (data: UpdateManagerEvents[K]) => void };
784
+ interface OverlayedAppUpdateModule {
785
+ site: OverlayedAppSiteModule;
786
+ on: <TEvent extends keyof OverlayedAppUpdateHandlerMapping = keyof OverlayedAppUpdateHandlerMapping>(event: TEvent, cb: OverlayedAppUpdateHandlerMapping[TEvent]) => void;
787
+ off: <TEvent extends keyof OverlayedAppUpdateHandlerMapping = keyof OverlayedAppUpdateHandlerMapping>(event: TEvent, cb: OverlayedAppUpdateHandlerMapping[TEvent]) => void;
788
+ /**
789
+ * Checks for updates.
790
+ * @returns Promise<UpdateCheckResult | null>
791
+ */
792
+ checkForUpdates: () => Promise<UpdateCheckResult$1 | null>;
793
+ /**
794
+ * Sets the function to fetch the access token.
795
+ * This function should return the access token or null if the channel is public.
796
+ *
797
+ * @param accessTokenFetcher - The function to fetch the access token. Optionally pass the new channel to fetch the access token for.
798
+ */
799
+ setAccessTokenFetcher: (accessTokenFetcher: (newChannel: string) => Promise<string | null>) => void;
800
+ /**
801
+ * Switches the channel for the next checkForUpdates call.
802
+ *
803
+ * Example code:
804
+ *
805
+ * ```ts
806
+ * function changeChannel(newChannel: string) {
807
+ * await overlayed.updater.switchChannel(newChannel);
808
+ * await overlayed.updater.checkForUpdates();
809
+ * }
810
+ * ```
811
+ *
812
+ * @param channel - The channel to switch to.
813
+ */
814
+ switchChannel: (channel: string) => Promise<UpdateCheckResult$1 | null>;
815
+ /**
816
+ * Restarts the app and installs the update after it has been downloaded.
817
+ * It should only be called after `update-downloaded` has been emitted.
818
+ *
819
+ * **Note:** `autoUpdater.quitAndInstall()` will close all application windows first and only emit `before-quit` event on `app` after that.
820
+ * This is different from the normal quit event sequence.
821
+ *
822
+ * @param isSilent *windows-only* Runs the installer in silent mode. Defaults to `false`.
823
+ * @param isForceRunAfter Run the app after finish even on silent install. Not applicable for macOS.
824
+ * Ignored if `isSilent` is set to `false`(In this case you can still set `autoRunAppAfterInstall` to `false` to prevent run the app after finish).
825
+ *
826
+ * @throws Error if `canUpdate` is false.
827
+ */
828
+ quitAndInstall: (isSilent?: boolean, isForceRunAfter?: boolean) => void;
829
+ /**
830
+ * Checks if the user can update.
831
+ *
832
+ * @example
833
+ * ```ts
834
+ * const [canUpdate, denialReason] = overlayed.updater.canUpdate();
835
+ * ```
836
+ *
837
+ * @returns `[true, null]` if the user can update, `[false, reason]` if the user cannot update.
838
+ *
839
+ * Reasons:
840
+ * - "User is in game"
841
+ */
842
+ canUpdate: () => [true, null] | [false, string];
843
+ /**
844
+ * Start downloading update manually. Use when `autoDownload` is false or to manually trigger download after `checkForUpdates`.
845
+ *
846
+ * @param cancellationToken - Optional token to cancel the download.
847
+ * @returns Promise resolving to paths of downloaded files.
848
+ */
849
+ downloadUpdate: (cancellationToken?: CancellationToken) => Promise<Array<string>>;
850
+ }
851
+ interface OverlayedAppApplicationModule {
852
+ /**
853
+ * Get the application channel.
854
+ * @returns string
855
+ */
856
+ getChannel: () => string;
857
+ /**
858
+ * Get the application version.
859
+ * @returns string
860
+ */
861
+ getVersion: () => string;
862
+ /**
863
+ * Get the application release id.
864
+ * @returns string | null
865
+ */
866
+ getReleaseId: () => string | null;
867
+ }
868
+ type OverlayedAppSiteHandlerMapping = {
869
+ /**
870
+ * Emitted when a new site version is available.
871
+ *
872
+ * @example
873
+ * ```ts
874
+ * overlayed.site.on("siteUpdateReady", () => {
875
+ * showUserSiteUpdateButton();
876
+ * });
877
+ *
878
+ * onUserClickSiteUpdateButton(() => {
879
+ * overlayed.site.allowSiteUpdateOnNextLoad();
880
+ * allWindows.forEach((window) => {
881
+ * window.webContents.reload();
882
+ * });
883
+ * });
884
+ *
885
+ * @param data - releaseId and version
886
+ * @returns
887
+ */
888
+ siteUpdateReady: (data: {
889
+ releaseId: ReleaseId;
890
+ version: string;
891
+ }) => void;
892
+ };
893
+ interface OverlayedAppSiteModule {
894
+ on: <TEvent extends keyof OverlayedAppSiteHandlerMapping = keyof OverlayedAppSiteHandlerMapping>(event: TEvent, cb: OverlayedAppSiteHandlerMapping[TEvent]) => void;
895
+ off: <TEvent extends keyof OverlayedAppSiteHandlerMapping = keyof OverlayedAppSiteHandlerMapping>(event: TEvent, cb: OverlayedAppSiteHandlerMapping[TEvent]) => void;
896
+ /**
897
+ * If an update is available, the next time BrowserWindow#loadURL is called, the new site version will be used.
898
+ *
899
+ * Must be called only after `siteUpdateReady` has been emitted.
900
+ *
901
+ * @example
902
+ * ```ts
903
+ * overlayed.site.on("siteUpdateReady", () => {
904
+ * showUserSiteUpdateButton();
905
+ * });
906
+ *
907
+ * onUserClickSiteUpdateButton(() => {
908
+ * overlayed.site.allowSiteUpdateOnNextLoad();
909
+ * allWindows.forEach((window) => {
910
+ * window.webContents.reload();
911
+ * });
912
+ * });
913
+ * ```
914
+ */
915
+ allowSiteUpdateOnNextLoad: () => void;
916
+ }
705
917
  type OverlayedApp<TModule extends GameModule, TKeybind extends string> = OverlayedAppGameModules<TModule> & OverlayedAppHandlers & {
706
918
  keybinds: OverlayedAppKeybindModule<TKeybind>;
707
919
  windows: OverlayedAppWindowsModule;
@@ -710,6 +922,8 @@ type OverlayedApp<TModule extends GameModule, TKeybind extends string> = Overlay
710
922
  cortex: OverlayedAppCortexModule;
711
923
  log: OverlayedAppLoggingModule;
712
924
  notices: OverlayedAppNoticesModule;
925
+ updater: OverlayedAppUpdateModule;
926
+ application: OverlayedAppApplicationModule;
713
927
  /**
714
928
  * Returns true if any monitored processes are running.
715
929
  *
@@ -778,16 +992,6 @@ interface OverlayedOptions<TModule extends GameModule, TKeybind extends string>
778
992
  * @default false
779
993
  */
780
994
  universal?: boolean;
781
- /**
782
- * @deprecated
783
- */
784
- channel?: string;
785
- /**
786
- * The version of the app.
787
- *
788
- * @deprecated
789
- */
790
- version?: string;
791
995
  /**
792
996
  * When true, the overlay will be loaded in debug mode.
793
997
  *
@@ -800,12 +1004,23 @@ interface OverlayedOptions<TModule extends GameModule, TKeybind extends string>
800
1004
  * @default true
801
1005
  */
802
1006
  silent?: boolean;
1007
+ /**
1008
+ * Site module configuration.
1009
+ */
1010
+ site?: {
1011
+ /**
1012
+ * When true, users will not update automatically when a new site version is available.
1013
+ *
1014
+ * If you'd prefer users to have to click an "update" button when a new site version,
1015
+ * set this to true.
1016
+ *
1017
+ * @default false
1018
+ */
1019
+ manualUpdates?: boolean;
1020
+ };
803
1021
  }
804
1022
  //#endregion
805
1023
  //#region src/utilities/overlayed.d.ts
806
1024
  declare function overlayed<TModule extends GameModule, TShortcut extends string>(optionsRaw: OverlayedOptions<TModule, TShortcut>): OverlayedApp<TModule, TShortcut>;
807
1025
  //#endregion
808
- //#region src/managers/nativeModuleManager.d.ts
809
- declare function setFetchLatestTokenCallback(newFetchLatestToken: () => Promise<unknown> | undefined): void;
810
- //#endregion
811
- export { type ActiveGameInfo, type BundleAppConfig, type BundleSiteConfig, type ErrorEvents, type FatalEvents, type FeedbackId, type FeedbackType, type GameCloseEvent, type GameLaunchEvent, type GameReadyEvent, type KeybindSchemaEntry as KeybindConfig, type KeyboardKeyEvent, type LoggerScope, type MouseButtonEvent, type NoticeId, type NoticeModel, type NoticeType, type OverlayedApp, type OverlayedConfig, type OverridesManagerScope, RenderInterface, type RenderWindow, type RenderWindowConstructorOptions, VirtualKey, type WarningEvents, type WindowEvent, defineConfig, overlayed, setFetchLatestTokenCallback, setUpdaterTokenResolver };
1026
+ export { type ActiveGameInfo, type BundleAppConfig, type BundleSiteConfig, type ErrorEvents, type FatalEvents, type FeedbackId, type FeedbackType, type GameCloseEvent, type GameLaunchEvent, type GameReadyEvent, type KeybindSchemaEntry as KeybindConfig, type KeyboardKeyEvent, type LoggerScope, type MouseButtonEvent, type NoticeId, type NoticeModel, type NoticeType, type OverlayedApp, type OverlayedConfig, type OverridesManagerScope, type ProgressInfo, RenderInterface, type RenderWindow, type RenderWindowConstructorOptions, type UpdateCheckResult, VirtualKey, type WarningEvents, type WindowEvent, defineConfig, overlayed };