ogi-addon 3.0.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,300 +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";
3
+ import { extraction } from "./extraction.cjs";
4
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";
5
6
  import events from "node:events";
6
7
  import { IFuseOptions } from "fuse.js";
7
8
  import { z } from "zod";
8
9
 
9
10
  //#region src/main.d.ts
10
- /**
11
- * Exposed events that the programmer can use to listen to and emit events.
12
- */
13
- type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'check-for-updates' | 'request-dl' | 'catalog' | 'launch-app';
14
- /**
15
- * The events that the client can send to the server and are handled by the server.
16
- */
17
- type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'get-app-details' | 'search-app-name' | 'flag' | 'task-update';
18
- /**
19
- * The events that the server sends to the client
20
- * This is the events that the server can send to the client and are handled by the client.
21
- */
22
- type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'launch-app' | 'search' | 'setup' | 'response' | 'library-search' | 'check-for-updates' | 'task-run' | 'game-details' | 'request-dl' | 'catalog';
23
11
  declare const VERSION: string;
24
- interface ClientSentEventTypes {
25
- response: any;
26
- authenticate: {
27
- name: string;
28
- id: string;
29
- description: string;
30
- version: string;
31
- author: string;
32
- };
33
- configure: ConfigurationFile;
34
- 'defer-update': {
35
- logs: string[];
36
- progress: number;
37
- };
38
- notification: Notification;
39
- 'input-asked': ConfigurationBuilder<Record<string, string | number | boolean>>;
40
- 'task-update': {
41
- id: string;
42
- progress: number;
43
- logs: string[];
44
- finished: boolean;
45
- failed: string | undefined;
46
- };
47
- 'get-app-details': {
48
- appID: number;
49
- storefront: string;
50
- };
51
- 'search-app-name': {
52
- query: string;
53
- storefront: string;
54
- };
55
- flag: {
56
- flag: string;
57
- value: string | string[];
58
- };
59
- }
60
- type BasicLibraryInfo = {
61
- name: string;
62
- capsuleImage: string;
63
- appID: number;
64
- storefront: string;
65
- };
66
- interface CatalogSection {
67
- name: string;
68
- description: string;
69
- listings: BasicLibraryInfo[];
70
- }
71
- interface CatalogCarouselItem {
72
- name: string;
73
- description: string;
74
- carouselImage: string;
75
- fullBannerImage?: string;
76
- appID?: number;
77
- storefront?: string;
78
- capsuleImage?: string;
79
- }
80
- interface CatalogWithCarousel {
81
- sections: Record<string, CatalogSection>;
82
- carousel?: Record<string, CatalogCarouselItem> | CatalogCarouselItem[];
83
- }
84
- type CatalogResponse = Record<string, CatalogSection> | CatalogWithCarousel;
12
+ /** @deprecated Use {@link AddonNotificationMessage}. */
13
+ type Notification = AddonNotificationMessage$1;
85
14
  /**
86
- * UMU ID format: 'steam:${number}' or 'umu:${string | number}'
87
- * - steam:${number} maps to umu-${number} for Steam games
88
- * - 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.
89
17
  */
90
- type UmuId = `steam:${number}` | `umu:${string | number}`;
91
- type SetupEventResponse = Omit<LibraryInfo, 'capsuleImage' | 'coverImage' | 'name' | 'appID' | 'storefront' | 'addonsource' | 'titleImage'> & {
92
- redistributables?: {
93
- name: string;
94
- path: string;
95
- }[];
96
- /**
97
- * UMU Proton integration configuration
98
- */
99
- umu?: {
100
- /**
101
- * UMU ID for the game. Format: 'steam:${number}' or 'umu:${string | number}'
102
- * - steam:${number} → maps to umu-${number} for Steam games
103
- * - umu:${string | number} → maps to umu-${string | number} for non-Steam games
104
- */
105
- umuId: UmuId;
106
- /**
107
- * Optional DLL overrides. Can be WINEDLLOVERRIDES-style (e.g. "dinput8=n,b") or bare DLL names.
108
- * Bare names get "=n,b" inferred; entries that already include "=..." are used as-is.
109
- */
110
- dllOverrides?: string[];
111
- /**
112
- * Optional Proton version to use (e.g., 'GE-Proton9-5', 'GE-Proton')
113
- * If not specified, uses latest UMU-Proton
114
- */
115
- protonVersion?: string;
116
- /**
117
- * Optional store identifier for protonfixes (e.g., 'gog', 'egs', 'none')
118
- */
119
- store?: string;
120
- /**
121
- * Cached Steam shortcut app ID after adding UMU game to Steam (avoids re-adding on each launch)
122
- */
123
- steamShortcutId?: number;
124
- };
125
- };
126
- interface EventListenerTypes {
127
- /**
128
- * This event is emitted when the addon connects to the OGI Addon Server. Addon does not need to resolve anything.
129
- * @param event
130
- * @returns
131
- */
132
- connect: (event: EventResponse<void>) => void;
133
- /**
134
- * 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.
135
- * @param reason
136
- * @returns
137
- */
138
- disconnect: (reason: string) => void;
139
- /**
140
- * 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)
141
- * @param config
142
- * @returns
143
- */
18
+ type EventListenerTypes = AddonSDKLifecycleEventListenerTypes$1<EventResponse<unknown>> & AddonProtocolEventListenerTypes$1<EventResponse<unknown>, 'authenticate' | 'configure' | 'catalog'> & {
19
+ authenticate: (config: unknown) => void;
144
20
  configure: (config: ConfigurationBuilder) => ConfigurationBuilder;
145
- /**
146
- * This event is called when the client provides a response to any event. This should be treated as middleware.
147
- * @param response
148
- * @returns
149
- */
150
- response: (response: any) => void;
151
- /**
152
- * This event is called when the client requests for the addon to authenticate itself. You don't need to provide any info.
153
- * @param config
154
- * @returns
155
- */
156
- authenticate: (config: any) => void;
157
- /**
158
- * 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)
159
- * @param query
160
- * @param event
161
- * @returns
162
- */
163
- search: (query: {
164
- storefront: string;
165
- appID: number;
166
- } & ({
167
- for: 'game' | 'task' | 'all';
168
- } | {
169
- for: 'update';
170
- libraryInfo: LibraryInfo;
171
- }), event: EventResponse<SearchResult[]>) => void;
172
- /**
173
- * 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)
174
- * @param data
175
- * @param event
176
- * @returns
177
- */
178
- setup: (data: {
179
- path: string;
180
- type: 'direct' | 'torrent' | 'magnet' | 'empty';
181
- name: string;
182
- usedRealDebrid: boolean;
183
- clearOldFilesBeforeUpdate?: boolean;
184
- multiPartFiles?: {
185
- name: string;
186
- downloadURL: string;
187
- }[];
188
- appID: number;
189
- storefront: string;
190
- manifest?: Record<string, unknown>;
191
- } & ({
192
- for: 'game';
193
- } | {
194
- for: 'update';
195
- currentLibraryInfo: LibraryInfo;
196
- }), event: EventResponse<SetupEventResponse>) => void;
197
- /**
198
- * This event is emitted when the client requires for a search to be performed. Input is the search query.
199
- * @param query
200
- * @param event
201
- * @returns
202
- */
203
- 'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;
204
- /**
205
- * 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.
206
- * @param appID
207
- * @param event
208
- * @returns
209
- */
210
- 'game-details': (details: {
211
- appID: number;
212
- storefront: string;
213
- }, event: EventResponse<StoreData | undefined>) => void;
214
- /**
215
- * 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)`.
216
- * @returns
217
- */
218
- exit: () => void;
219
- /**
220
- * 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.
221
- * @param appID
222
- * @param info
223
- * @param event
224
- * @returns
225
- */
226
- 'request-dl': (appID: number, info: SearchResult, event: EventResponse<SearchResult>) => void;
227
- /**
228
- * This event is emitted when the client requests for a catalog to be fetched. Addon should resolve the event with the catalog.
229
- * @param event
230
- * @returns
231
- */
232
- catalog: (event: Omit<EventResponse<CatalogResponse>, 'askForInput'>) => void;
233
- /**
234
- * This event is emitted when the client requests for an addon to check for updates. Addon should resolve the event with the update information.
235
- * @param data
236
- * @param event
237
- * @returns
238
- */
239
- 'check-for-updates': (data: {
240
- appID: number;
241
- storefront: string;
242
- currentVersion: string;
243
- }, event: EventResponse<{
244
- available: true;
245
- version: string;
246
- } | {
247
- available: false;
248
- }>) => void;
249
- /**
250
- * 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.
251
- * @param data {LibraryInfo} The library information for the app to be launched.
252
- * @param launchType { 'pre' | 'post' } The type of launch task to perform.
253
- * @param event {EventResponse<void>} The event response from the server.
254
- */
255
- 'launch-app': (data: {
256
- libraryInfo: LibraryInfo;
257
- launchType: 'pre' | 'post';
258
- }, event: EventResponse<void>) => void;
259
- }
260
- interface StoreData {
261
- name: string;
262
- publishers: string[];
263
- developers: string[];
264
- appID: number;
265
- releaseDate: string;
266
- capsuleImage: string;
267
- coverImage: string;
268
- basicDescription: string;
269
- description: string;
270
- headerImage: string;
271
- latestVersion: string;
272
- }
273
- interface WebsocketMessageClient {
274
- event: OGIAddonClientSentEvent;
275
- id?: string;
276
- args: any;
277
- statusError?: string;
278
- }
279
- interface WebsocketMessageServer {
280
- event: OGIAddonServerSentEvent;
281
- id?: string;
282
- args: any;
283
- statusError?: string;
284
- }
285
- /**
286
- * The configuration for the addon. This is used to identify the addon and provide information about it.
287
- * Storefronts is an array of names of stores that the addon supports.
288
- */
289
- interface OGIAddonConfiguration {
290
- name: string;
291
- id: string;
292
- description: string;
293
- version: string;
294
- author: string;
295
- repository: string;
296
- storefronts: string[];
297
- }
21
+ catalog: (event: Omit<EventResponse<CatalogResponse$1>, 'askForInput'>) => void;
22
+ };
298
23
  /**
299
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.
300
25
  * @example
@@ -313,31 +38,31 @@ interface OGIAddonConfiguration {
313
38
  declare class OGIAddon {
314
39
  eventEmitter: events<[never]>;
315
40
  addonWSListener: OGIAddonWSListener;
316
- addonInfo: OGIAddonConfiguration;
41
+ addonInfo: OGIAddonConfiguration$1;
317
42
  config: Configuration;
318
43
  private eventsAvailable;
319
44
  private registeredConnectEvent;
320
45
  private taskHandlers;
321
- constructor(addonInfo: OGIAddonConfiguration);
46
+ constructor(addonInfo: OGIAddonConfiguration$1);
322
47
  /**
323
48
  * Register an event listener for the addon. (See EventListenerTypes)
324
- * @param event {OGIAddonEvent}
325
- * @param listener {EventListenerTypes[OGIAddonEvent]}
49
+ * @param event {OGIAddonSDKEventListener}
50
+ * @param listener {EventListenerTypes[OGIAddonSDKEventListener]}
326
51
  */
327
- on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]): void;
328
- 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;
329
54
  /**
330
55
  * Notify the client using a notification. Provide the type of notification, the message, and an ID.
331
56
  * @param notification {Notification}
332
57
  */
333
- notify(notification: Notification): void;
58
+ notify(notification: AddonNotificationMessage$1): void;
334
59
  /**
335
60
  * Get the app details for a given appID and storefront.
336
61
  * @param appID {number}
337
62
  * @param storefront {string}
338
63
  * @returns {Promise<StoreData>}
339
64
  */
340
- getAppDetails(appID: number, storefront: string): Promise<StoreData | undefined>;
65
+ getAppDetails(appID: number, storefront: string): Promise<any>;
341
66
  searchGame(query: string, storefront: string): Promise<BasicLibraryInfo[]>;
342
67
  /**
343
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.
@@ -363,7 +88,7 @@ declare class OGIAddon {
363
88
  manifest: Record<string, unknown>;
364
89
  downloadPath: string;
365
90
  name: string;
366
- libraryInfo: LibraryInfo;
91
+ libraryInfo: LibraryInfo$1;
367
92
  }) => Promise<void> | void): void;
368
93
  /**
369
94
  * Check if a task handler is registered for the given task name.
@@ -380,16 +105,15 @@ declare class OGIAddon {
380
105
  manifest: Record<string, unknown>;
381
106
  downloadPath: string;
382
107
  name: string;
383
- libraryInfo?: LibraryInfo;
108
+ libraryInfo?: LibraryInfo$1;
384
109
  }) => Promise<void> | void) | undefined;
385
110
  /**
386
111
  * Extract a file using 7-Zip on Windows, unzip on Linux/Mac.
387
112
  * @param path {string}
388
113
  * @param outputPath {string}
389
- * @param type {'unrar' | 'unzip'}
390
114
  * @returns {Promise<void>}
391
115
  */
392
- extractFile(path: string, outputPath: string, type: 'unrar' | 'unzip'): Promise<void>;
116
+ extractFile(path: string, outputPath: string): Promise<void>;
393
117
  }
394
118
  /**
395
119
  * A unified task API for both server-initiated tasks (via onTask handlers)
@@ -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 };
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