ogi-addon 3.1.0 → 4.0.0

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/build/main.d.cts CHANGED
@@ -1,301 +1,25 @@
1
- import { ConfigurationBuilder, ConfigurationFile } from "./config/ConfigurationBuilder.cjs";
1
+ import { ConfigurationBuilder } from "./config/ConfigurationBuilder.cjs";
2
2
  import { Configuration } from "./config/Configuration.cjs";
3
- import { SearchResult } from "./SearchEngine.cjs";
4
3
  import { extraction } from "./extraction.cjs";
5
4
  import EventResponse from "./EventResponse.cjs";
5
+ import { AddonClientToServerEventArgs, AddonClientToServerEventArgs as AddonClientToServerEventArgs$1, AddonClientToServerEventName, AddonClientToServerEventName as AddonClientToServerEventName$1, AddonClientToServerWebsocketMessage, AddonNotificationMessage, AddonNotificationMessage as AddonNotificationMessage$1, AddonProtocolEventListenerTypes, AddonProtocolEventListenerTypes as AddonProtocolEventListenerTypes$1, AddonSDKLifecycleEventListenerTypes, AddonSDKLifecycleEventListenerTypes as AddonSDKLifecycleEventListenerTypes$1, AddonServerHostEventListeners, AddonServerHostEventName, AddonServerLifecycleEvent, AddonServerToClientEventName, AddonServerToClientWebsocketMessage, AddonTaskRunEventArgs as TaskRunMessageArgs, BasicLibraryInfo as BasicLibraryInfo$1, CatalogCarouselItem, CatalogResponse, CatalogResponse as CatalogResponse$1, CatalogSection, CatalogWithCarousel, ConfigurationFile, ConfigurationOptionType, ConfigurationOptionWire, LibraryInfo, LibraryInfo as LibraryInfo$1, OGIAddonConfiguration, OGIAddonConfiguration as OGIAddonConfiguration$1, OGIAddonSDKEventListener, OGIAddonSDKEventListener as OGIAddonSDKEventListener$1, SearchResult, SetupCommandData, SetupEventResponse, SetupResponse, StoreData, UmuId } from "@ogi-sdk/connect";
6
6
  import events from "node:events";
7
7
  import { IFuseOptions } from "fuse.js";
8
8
  import { z } from "zod";
9
9
 
10
10
  //#region src/main.d.ts
11
- /**
12
- * Exposed events that the programmer can use to listen to and emit events.
13
- */
14
- type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'check-for-updates' | 'request-dl' | 'catalog' | 'launch-app';
15
- /**
16
- * The events that the client can send to the server and are handled by the server.
17
- */
18
- type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'get-app-details' | 'search-app-name' | 'flag' | 'task-update';
19
- /**
20
- * The events that the server sends to the client
21
- * This is the events that the server can send to the client and are handled by the client.
22
- */
23
- type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'launch-app' | 'search' | 'setup' | 'response' | 'library-search' | 'check-for-updates' | 'task-run' | 'game-details' | 'request-dl' | 'catalog';
24
11
  declare const VERSION: string;
25
- interface ClientSentEventTypes {
26
- response: any;
27
- authenticate: {
28
- name: string;
29
- id: string;
30
- description: string;
31
- version: string;
32
- author: string;
33
- };
34
- configure: ConfigurationFile;
35
- 'defer-update': {
36
- logs: string[];
37
- progress: number;
38
- };
39
- notification: Notification;
40
- 'input-asked': ConfigurationBuilder<Record<string, string | number | boolean>>;
41
- 'task-update': {
42
- id: string;
43
- progress: number;
44
- logs: string[];
45
- finished: boolean;
46
- failed: string | undefined;
47
- };
48
- 'get-app-details': {
49
- appID: number;
50
- storefront: string;
51
- };
52
- 'search-app-name': {
53
- query: string;
54
- storefront: string;
55
- };
56
- flag: {
57
- flag: string;
58
- value: string | string[];
59
- };
60
- }
61
- type BasicLibraryInfo = {
62
- name: string;
63
- capsuleImage: string;
64
- appID: number;
65
- storefront: string;
66
- };
67
- interface CatalogSection {
68
- name: string;
69
- description: string;
70
- listings: BasicLibraryInfo[];
71
- }
72
- interface CatalogCarouselItem {
73
- name: string;
74
- description: string;
75
- carouselImage: string;
76
- fullBannerImage?: string;
77
- appID?: number;
78
- storefront?: string;
79
- capsuleImage?: string;
80
- }
81
- interface CatalogWithCarousel {
82
- sections: Record<string, CatalogSection>;
83
- carousel?: Record<string, CatalogCarouselItem> | CatalogCarouselItem[];
84
- }
85
- type CatalogResponse = Record<string, CatalogSection> | CatalogWithCarousel;
12
+ /** @deprecated Use {@link AddonNotificationMessage}. */
13
+ type Notification = AddonNotificationMessage$1;
86
14
  /**
87
- * UMU ID format: 'steam:${number}' or 'umu:${string | number}'
88
- * - steam:${number} maps to umu-${number} for Steam games
89
- * - umu:${string | number} → maps to umu-${string | number} for non-Steam games
15
+ * Addon SDK listener signatures. Protocol commands come from `addonProtocol` in
16
+ * `@ogi-sdk/connect`; lifecycle and builder-specific hooks are merged below.
90
17
  */
91
- type UmuId = `steam:${number}` | `umu:${string | number}`;
92
- type SetupEventResponse = Omit<LibraryInfo, 'capsuleImage' | 'coverImage' | 'name' | 'appID' | 'storefront' | 'addonsource' | 'titleImage'> & {
93
- redistributables?: {
94
- name: string;
95
- path: string;
96
- }[];
97
- /**
98
- * UMU Proton integration configuration
99
- */
100
- umu?: {
101
- /**
102
- * UMU ID for the game. Format: 'steam:${number}' or 'umu:${string | number}'
103
- * - steam:${number} → maps to umu-${number} for Steam games
104
- * - umu:${string | number} → maps to umu-${string | number} for non-Steam games
105
- */
106
- umuId: UmuId;
107
- /**
108
- * Optional DLL overrides. Can be WINEDLLOVERRIDES-style (e.g. "dinput8=n,b") or bare DLL names.
109
- * Bare names get "=n,b" inferred; entries that already include "=..." are used as-is.
110
- */
111
- dllOverrides?: string[];
112
- /**
113
- * Optional PROTONPATH override to use for UMU launches.
114
- * Omit this unless you absolutely need a specific Proton build/path.
115
- */
116
- protonVersion?: string;
117
- /**
118
- * Optional store identifier for protonfixes (e.g., 'gog', 'egs', 'none')
119
- */
120
- store?: string;
121
- /**
122
- * Cached Steam shortcut app ID after adding UMU game to Steam (avoids re-adding on each launch)
123
- */
124
- steamShortcutId?: number;
125
- };
126
- };
127
- interface EventListenerTypes {
128
- /**
129
- * This event is emitted when the addon connects to the OGI Addon Server. Addon does not need to resolve anything.
130
- * @param event
131
- * @returns
132
- */
133
- connect: (event: EventResponse<void>) => void;
134
- /**
135
- * This event is emitted when the client requests for the addon to disconnect. Addon does not need to resolve this event, but we recommend `process.exit(0)` so the addon can exit gracefully instead of by force by the addon server.
136
- * @param reason
137
- * @returns
138
- */
139
- disconnect: (reason: string) => void;
140
- /**
141
- * This event is emitted when the client requests for the addon to configure itself. Addon should resolve the event with the internal configuration. (See ConfigurationBuilder)
142
- * @param config
143
- * @returns
144
- */
18
+ type EventListenerTypes = AddonSDKLifecycleEventListenerTypes$1<EventResponse<unknown>> & AddonProtocolEventListenerTypes$1<EventResponse<unknown>, 'authenticate' | 'configure' | 'catalog'> & {
19
+ authenticate: (config: unknown) => void;
145
20
  configure: (config: ConfigurationBuilder) => ConfigurationBuilder;
146
- /**
147
- * This event is called when the client provides a response to any event. This should be treated as middleware.
148
- * @param response
149
- * @returns
150
- */
151
- response: (response: any) => void;
152
- /**
153
- * This event is called when the client requests for the addon to authenticate itself. You don't need to provide any info.
154
- * @param config
155
- * @returns
156
- */
157
- authenticate: (config: any) => void;
158
- /**
159
- * This event is emitted when the client requests for a torrent/direct download search to be performed. Addon is given the gameID (could be a steam appID or custom store appID), along with the storefront type. Addon should resolve the event with the search results. (See SearchResult)
160
- * @param query
161
- * @param event
162
- * @returns
163
- */
164
- search: (query: {
165
- storefront: string;
166
- appID: number;
167
- } & ({
168
- for: 'game' | 'task' | 'all';
169
- } | {
170
- for: 'update';
171
- libraryInfo: LibraryInfo;
172
- }), event: EventResponse<SearchResult[]>) => void;
173
- /**
174
- * This event is emitted when the client requests for app setup to be performed. Addon should resolve the event with the metadata for the library entry. (See LibraryInfo)
175
- * @param data
176
- * @param event
177
- * @returns
178
- */
179
- setup: (data: {
180
- path: string;
181
- type: 'direct' | 'torrent' | 'magnet' | 'empty';
182
- name: string;
183
- usedRealDebrid: boolean;
184
- clearOldFilesBeforeUpdate?: boolean;
185
- multiPartFiles?: {
186
- name: string;
187
- downloadURL: string;
188
- }[];
189
- appID: number;
190
- storefront: string;
191
- manifest?: Record<string, unknown>;
192
- } & ({
193
- for: 'game';
194
- } | {
195
- for: 'update';
196
- currentLibraryInfo: LibraryInfo;
197
- }), event: EventResponse<SetupEventResponse>) => void;
198
- /**
199
- * This event is emitted when the client requires for a search to be performed. Input is the search query.
200
- * @param query
201
- * @param event
202
- * @returns
203
- */
204
- 'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;
205
- /**
206
- * This event is emitted when the client requests for a game details to be fetched. Addon should resolve the event with the game details. This is used to generate a store page for the game.
207
- * @param appID
208
- * @param event
209
- * @returns
210
- */
211
- 'game-details': (details: {
212
- appID: number;
213
- storefront: string;
214
- }, event: EventResponse<StoreData | undefined>) => void;
215
- /**
216
- * This event is emitted when the client requests for the addon to exit. Use this to perform any cleanup tasks, ending with a `process.exit(0)`.
217
- * @returns
218
- */
219
- exit: () => void;
220
- /**
221
- * This event is emitted when the client requests for a download to be performed with the 'request' type. Addon should resolve the event with a SearchResult containing the actual download info.
222
- * @param appID
223
- * @param info
224
- * @param event
225
- * @returns
226
- */
227
- 'request-dl': (appID: number, info: SearchResult, event: EventResponse<SearchResult>) => void;
228
- /**
229
- * This event is emitted when the client requests for a catalog to be fetched. Addon should resolve the event with the catalog.
230
- * @param event
231
- * @returns
232
- */
233
- catalog: (event: Omit<EventResponse<CatalogResponse>, 'askForInput'>) => void;
234
- /**
235
- * This event is emitted when the client requests for an addon to check for updates. Addon should resolve the event with the update information.
236
- * @param data
237
- * @param event
238
- * @returns
239
- */
240
- 'check-for-updates': (data: {
241
- appID: number;
242
- storefront: string;
243
- currentVersion: string;
244
- }, event: EventResponse<{
245
- available: true;
246
- version: string;
247
- } | {
248
- available: false;
249
- }>) => void;
250
- /**
251
- * This event is emitted when the client is going to launch an app. Addon should use this to perform any pre or post launch tasks.
252
- * @param data {LibraryInfo} The library information for the app to be launched.
253
- * @param launchType { 'pre' | 'post' } The type of launch task to perform.
254
- * @param event {EventResponse<void>} The event response from the server.
255
- */
256
- 'launch-app': (data: {
257
- libraryInfo: LibraryInfo;
258
- launchType: 'pre' | 'post';
259
- }, event: EventResponse<void>) => void;
260
- }
261
- interface StoreData {
262
- name: string;
263
- publishers: string[];
264
- developers: string[];
265
- appID: number;
266
- releaseDate: string;
267
- capsuleImage: string;
268
- coverImage: string;
269
- basicDescription: string;
270
- description: string;
271
- headerImage: string;
272
- latestVersion: string;
273
- }
274
- interface WebsocketMessageClient {
275
- event: OGIAddonClientSentEvent;
276
- id?: string;
277
- args: any;
278
- statusError?: string;
279
- }
280
- interface WebsocketMessageServer {
281
- event: OGIAddonServerSentEvent;
282
- id?: string;
283
- args: any;
284
- statusError?: string;
285
- }
286
- /**
287
- * The configuration for the addon. This is used to identify the addon and provide information about it.
288
- * Storefronts is an array of names of stores that the addon supports.
289
- */
290
- interface OGIAddonConfiguration {
291
- name: string;
292
- id: string;
293
- description: string;
294
- version: string;
295
- author: string;
296
- repository: string;
297
- storefronts: string[];
298
- }
21
+ catalog: (event: Omit<EventResponse<CatalogResponse$1>, 'askForInput'>) => void;
22
+ };
299
23
  /**
300
24
  * The main class for the OGI Addon. This class is used to interact with the OGI Addon Server. The OGI Addon Server provides a `--addonSecret` to the addon so it can securely connect.
301
25
  * @example
@@ -314,31 +38,31 @@ interface OGIAddonConfiguration {
314
38
  declare class OGIAddon {
315
39
  eventEmitter: events<[never]>;
316
40
  addonWSListener: OGIAddonWSListener;
317
- addonInfo: OGIAddonConfiguration;
41
+ addonInfo: OGIAddonConfiguration$1;
318
42
  config: Configuration;
319
43
  private eventsAvailable;
320
44
  private registeredConnectEvent;
321
45
  private taskHandlers;
322
- constructor(addonInfo: OGIAddonConfiguration);
46
+ constructor(addonInfo: OGIAddonConfiguration$1);
323
47
  /**
324
48
  * Register an event listener for the addon. (See EventListenerTypes)
325
- * @param event {OGIAddonEvent}
326
- * @param listener {EventListenerTypes[OGIAddonEvent]}
49
+ * @param event {OGIAddonSDKEventListener}
50
+ * @param listener {EventListenerTypes[OGIAddonSDKEventListener]}
327
51
  */
328
- on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]): void;
329
- emit<T extends OGIAddonEvent>(event: T, ...args: Parameters<EventListenerTypes[T]>): void;
52
+ on<T extends OGIAddonSDKEventListener$1>(event: T, listener: EventListenerTypes[T]): void;
53
+ emit<T extends OGIAddonSDKEventListener$1>(event: T, ...args: Parameters<EventListenerTypes[T]>): void;
330
54
  /**
331
55
  * Notify the client using a notification. Provide the type of notification, the message, and an ID.
332
56
  * @param notification {Notification}
333
57
  */
334
- notify(notification: Notification): void;
58
+ notify(notification: AddonNotificationMessage$1): void;
335
59
  /**
336
60
  * Get the app details for a given appID and storefront.
337
61
  * @param appID {number}
338
62
  * @param storefront {string}
339
63
  * @returns {Promise<StoreData>}
340
64
  */
341
- getAppDetails(appID: number, storefront: string): Promise<StoreData | undefined>;
65
+ getAppDetails(appID: number, storefront: string): Promise<any>;
342
66
  searchGame(query: string, storefront: string): Promise<BasicLibraryInfo[]>;
343
67
  /**
344
68
  * Notify the OGI Addon Server that you are performing a background task. This can be used to help users understand what is happening in the background.
@@ -364,7 +88,7 @@ declare class OGIAddon {
364
88
  manifest: Record<string, unknown>;
365
89
  downloadPath: string;
366
90
  name: string;
367
- libraryInfo: LibraryInfo;
91
+ libraryInfo: LibraryInfo$1;
368
92
  }) => Promise<void> | void): void;
369
93
  /**
370
94
  * Check if a task handler is registered for the given task name.
@@ -381,7 +105,7 @@ declare class OGIAddon {
381
105
  manifest: Record<string, unknown>;
382
106
  downloadPath: string;
383
107
  name: string;
384
- libraryInfo?: LibraryInfo;
108
+ libraryInfo?: LibraryInfo$1;
385
109
  }) => Promise<void> | void) | undefined;
386
110
  /**
387
111
  * Extract a file using 7-Zip on Windows, unzip on Linux/Mac.
@@ -470,116 +194,10 @@ declare class SearchTool<T> {
470
194
  /**
471
195
  * Library Info is the metadata for a library entry after setting up a game.
472
196
  */
473
- declare const ZodLibraryInfo: z.ZodObject<{
474
- name: z.ZodString;
475
- version: z.ZodString;
476
- cwd: z.ZodString;
477
- appID: z.ZodNumber;
478
- launchExecutable: z.ZodString;
479
- launchArguments: z.ZodOptional<z.ZodString>;
480
- launchEnv: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
481
- capsuleImage: z.ZodString;
482
- storefront: z.ZodString;
483
- addonsource: z.ZodString;
484
- coverImage: z.ZodString;
485
- titleImage: z.ZodOptional<z.ZodString>;
486
- /**
487
- * UMU Proton integration configuration (Linux only)
488
- */
489
- umu: z.ZodOptional<z.ZodObject<{
490
- umuId: z.ZodString;
491
- dllOverrides: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
492
- protonVersion: z.ZodOptional<z.ZodString>;
493
- store: z.ZodOptional<z.ZodString>;
494
- winePrefixPath: z.ZodOptional<z.ZodString>;
495
- steamShortcutId: z.ZodOptional<z.ZodNumber>;
496
- }, "strip", z.ZodTypeAny, {
497
- umuId: string;
498
- dllOverrides?: string[] | undefined;
499
- protonVersion?: string | undefined;
500
- store?: string | undefined;
501
- winePrefixPath?: string | undefined;
502
- steamShortcutId?: number | undefined;
503
- }, {
504
- umuId: string;
505
- dllOverrides?: string[] | undefined;
506
- protonVersion?: string | undefined;
507
- store?: string | undefined;
508
- winePrefixPath?: string | undefined;
509
- steamShortcutId?: number | undefined;
510
- }>>;
511
- /**
512
- * Redistributables to install (for backward compatibility)
513
- */
514
- redistributables: z.ZodOptional<z.ZodArray<z.ZodObject<{
515
- name: z.ZodString;
516
- path: z.ZodString;
517
- }, "strip", z.ZodTypeAny, {
518
- name: string;
519
- path: string;
520
- }, {
521
- name: string;
522
- path: string;
523
- }>, "many">>;
524
- }, "strip", z.ZodTypeAny, {
525
- name: string;
526
- version: string;
527
- cwd: string;
528
- appID: number;
529
- launchExecutable: string;
530
- capsuleImage: string;
531
- storefront: string;
532
- addonsource: string;
533
- coverImage: string;
534
- launchArguments?: string | undefined;
535
- launchEnv?: Record<string, string> | undefined;
536
- titleImage?: string | undefined;
537
- umu?: {
538
- umuId: string;
539
- dllOverrides?: string[] | undefined;
540
- protonVersion?: string | undefined;
541
- store?: string | undefined;
542
- winePrefixPath?: string | undefined;
543
- steamShortcutId?: number | undefined;
544
- } | undefined;
545
- redistributables?: {
546
- name: string;
547
- path: string;
548
- }[] | undefined;
549
- }, {
550
- name: string;
551
- version: string;
552
- cwd: string;
553
- appID: number;
554
- launchExecutable: string;
555
- capsuleImage: string;
556
- storefront: string;
557
- addonsource: string;
558
- coverImage: string;
559
- launchArguments?: string | undefined;
560
- launchEnv?: Record<string, string> | undefined;
561
- titleImage?: string | undefined;
562
- umu?: {
563
- umuId: string;
564
- dllOverrides?: string[] | undefined;
565
- protonVersion?: string | undefined;
566
- store?: string | undefined;
567
- winePrefixPath?: string | undefined;
568
- steamShortcutId?: number | undefined;
569
- } | undefined;
570
- redistributables?: {
571
- name: string;
572
- path: string;
573
- }[] | undefined;
574
- }>;
575
- type LibraryInfo = z.infer<typeof ZodLibraryInfo>;
576
- interface Notification {
577
- type: 'warning' | 'error' | 'info' | 'success';
578
- message: string;
579
- id: string;
580
- }
197
+ declare const ZodLibraryInfo: z.ZodType<LibraryInfo$1>;
581
198
  declare class OGIAddonWSListener {
582
199
  private socket;
200
+ private transport;
583
201
  eventEmitter: events.EventEmitter;
584
202
  addon: OGIAddon;
585
203
  constructor(ogiAddon: OGIAddon, eventEmitter: events.EventEmitter);
@@ -599,10 +217,10 @@ declare class OGIAddonWSListener {
599
217
  */
600
218
  private handleEventWithResponseNoInput;
601
219
  respondToMessage(messageID: string, response: any, originalEvent: EventResponse<any> | undefined): void;
602
- waitForResponseFromServer<T>(messageID: string): Promise<T>;
603
- send(event: OGIAddonClientSentEvent, args: ClientSentEventTypes[OGIAddonClientSentEvent]): string;
220
+ requestResponse<T>(event: AddonClientToServerEventName$1, args: AddonClientToServerEventArgs$1[AddonClientToServerEventName$1]): Promise<T>;
221
+ send(event: AddonClientToServerEventName$1, args: AddonClientToServerEventArgs$1[AddonClientToServerEventName$1]): string;
604
222
  close(): void;
605
223
  }
606
224
  //#endregion
607
- export { BasicLibraryInfo, CatalogCarouselItem, CatalogResponse, CatalogSection, CatalogWithCarousel, ClientSentEventTypes, Configuration, ConfigurationBuilder, EventListenerTypes, EventResponse, LibraryInfo, OGIAddonClientSentEvent, OGIAddonConfiguration, OGIAddonEvent, OGIAddonServerSentEvent, type SearchResult, SearchTool, SetupEventResponse, StoreData, Task, UmuId, VERSION, WebsocketMessageClient, WebsocketMessageServer, ZodLibraryInfo, OGIAddon as default, extraction };
225
+ export { type AddonClientToServerEventArgs, type AddonClientToServerEventName, type AddonClientToServerWebsocketMessage, type AddonNotificationMessage, type AddonProtocolEventListenerTypes, type AddonSDKLifecycleEventListenerTypes, type AddonServerHostEventListeners, type AddonServerHostEventName, type AddonServerLifecycleEvent, type AddonServerToClientEventName, type AddonServerToClientWebsocketMessage, type BasicLibraryInfo$1 as BasicLibraryInfo, type CatalogCarouselItem, type CatalogResponse, type CatalogSection, type CatalogWithCarousel, Configuration, ConfigurationBuilder, type ConfigurationFile, type ConfigurationOptionType, type ConfigurationOptionWire, EventListenerTypes, EventResponse, type LibraryInfo, Notification, type OGIAddonConfiguration, type OGIAddonSDKEventListener, type SearchResult, SearchTool, type SetupCommandData, type SetupEventResponse, type SetupResponse, type StoreData, Task, type TaskRunMessageArgs, type UmuId, VERSION, ZodLibraryInfo, OGIAddon as default, extraction };
608
226
  //# sourceMappingURL=main.d.cts.map