ogi-addon 2.2.0 → 2.3.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.
Files changed (34) hide show
  1. package/README.md +25 -17
  2. package/build/EventResponse.d.cts +41 -2
  3. package/build/EventResponse.d.mts +43 -2
  4. package/build/SearchEngine.d.cts +31 -2
  5. package/build/SearchEngine.d.mts +31 -2
  6. package/build/chunk-C0xms8kb.cjs +34 -0
  7. package/build/config/Configuration.cjs +12 -11
  8. package/build/config/Configuration.cjs.map +1 -1
  9. package/build/config/Configuration.d.cts +21 -3
  10. package/build/config/Configuration.d.mts +21 -3
  11. package/build/config/ConfigurationBuilder.cjs +318 -11
  12. package/build/config/ConfigurationBuilder.cjs.map +1 -0
  13. package/build/config/ConfigurationBuilder.d.cts +192 -2
  14. package/build/config/ConfigurationBuilder.d.mts +192 -2
  15. package/build/main.cjs +12 -11
  16. package/build/main.cjs.map +1 -1
  17. package/build/main.d.cts +476 -5
  18. package/build/main.d.mts +476 -5
  19. package/build/main.mjs +3 -3
  20. package/build/main.mjs.map +1 -1
  21. package/package.json +2 -1
  22. package/src/SearchEngine.ts +6 -0
  23. package/src/main.ts +26 -14
  24. package/tsconfig.json +1 -0
  25. package/build/Configuration-DdkCGFMU.d.cts +0 -21
  26. package/build/Configuration-fDtr2bmH.d.mts +0 -21
  27. package/build/ConfigurationBuilder-C83EP5v2.d.cts +0 -192
  28. package/build/ConfigurationBuilder-CFXi6UwU.cjs +0 -400
  29. package/build/ConfigurationBuilder-CFXi6UwU.cjs.map +0 -1
  30. package/build/ConfigurationBuilder-lzKf9gHw.d.mts +0 -192
  31. package/build/EventResponse-BJ8gWjdT.d.mts +0 -499
  32. package/build/EventResponse-DrBsB9tW.d.cts +0 -499
  33. package/build/SearchEngine-Cn_-M-at.d.cts +0 -25
  34. package/build/SearchEngine-lZioNunY.d.mts +0 -25
package/build/main.d.cts CHANGED
@@ -1,5 +1,476 @@
1
- import { r as ConfigurationBuilder } from "./ConfigurationBuilder-C83EP5v2.cjs";
2
- import { t as Configuration } from "./Configuration-DdkCGFMU.cjs";
3
- import { t as SearchResult } from "./SearchEngine-Cn_-M-at.cjs";
4
- import { _ as WebsocketMessageServer, a as LibraryInfo, c as OGIAddonConfiguration, d as SearchTool, f as SetupEventResponse, g as WebsocketMessageClient, h as VERSION, i as EventListenerTypes, l as OGIAddonEvent, m as Task, n as BasicLibraryInfo, o as OGIAddon, p as StoreData, r as ClientSentEventTypes, s as OGIAddonClientSentEvent, t as EventResponse, u as OGIAddonServerSentEvent, v as ZodLibraryInfo } from "./EventResponse-DrBsB9tW.cjs";
5
- export { BasicLibraryInfo, ClientSentEventTypes, Configuration, ConfigurationBuilder, EventListenerTypes, EventResponse, LibraryInfo, OGIAddonClientSentEvent, OGIAddonConfiguration, OGIAddonEvent, OGIAddonServerSentEvent, SearchResult, SearchTool, SetupEventResponse, StoreData, Task, VERSION, WebsocketMessageClient, WebsocketMessageServer, ZodLibraryInfo, OGIAddon as default };
1
+ import { ConfigurationBuilder, ConfigurationFile } from "./config/ConfigurationBuilder.cjs";
2
+ import { Configuration } from "./config/Configuration.cjs";
3
+ import { SearchResult } from "./SearchEngine.cjs";
4
+ import EventResponse from "./EventResponse.cjs";
5
+ import events from "node:events";
6
+ import { IFuseOptions } from "fuse.js";
7
+ import { z } from "zod";
8
+
9
+ //#region src/main.d.ts
10
+ type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'check-for-updates' | 'request-dl' | 'catalog';
11
+ type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'get-app-details' | 'search-app-name' | 'flag' | 'task-update';
12
+ type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup' | 'response' | 'library-search' | 'check-for-updates' | 'task-run' | 'game-details' | 'request-dl' | 'catalog';
13
+ declare const VERSION: string;
14
+ interface ClientSentEventTypes {
15
+ response: any;
16
+ authenticate: {
17
+ name: string;
18
+ id: string;
19
+ description: string;
20
+ version: string;
21
+ author: string;
22
+ };
23
+ configure: ConfigurationFile;
24
+ 'defer-update': {
25
+ logs: string[];
26
+ progress: number;
27
+ };
28
+ notification: Notification;
29
+ 'input-asked': ConfigurationBuilder<Record<string, string | number | boolean>>;
30
+ 'task-update': {
31
+ id: string;
32
+ progress: number;
33
+ logs: string[];
34
+ finished: boolean;
35
+ failed: string | undefined;
36
+ };
37
+ 'get-app-details': {
38
+ appID: number;
39
+ storefront: string;
40
+ };
41
+ 'search-app-name': {
42
+ query: string;
43
+ storefront: string;
44
+ };
45
+ flag: {
46
+ flag: string;
47
+ value: string | string[];
48
+ };
49
+ }
50
+ type BasicLibraryInfo = {
51
+ name: string;
52
+ capsuleImage: string;
53
+ appID: number;
54
+ storefront: string;
55
+ };
56
+ interface CatalogSection {
57
+ name: string;
58
+ description: string;
59
+ listings: BasicLibraryInfo[];
60
+ }
61
+ interface CatalogCarouselItem {
62
+ name: string;
63
+ description: string;
64
+ carouselImage: string;
65
+ fullBannerImage?: string;
66
+ appID?: number;
67
+ storefront?: string;
68
+ capsuleImage?: string;
69
+ }
70
+ interface CatalogWithCarousel {
71
+ sections: Record<string, CatalogSection>;
72
+ carousel?: Record<string, CatalogCarouselItem> | CatalogCarouselItem[];
73
+ }
74
+ type CatalogResponse = Record<string, CatalogSection> | CatalogWithCarousel;
75
+ type SetupEventResponse = Omit<LibraryInfo, 'capsuleImage' | 'coverImage' | 'name' | 'appID' | 'storefront' | 'addonsource' | 'titleImage'> & {
76
+ redistributables?: {
77
+ name: string;
78
+ path: string;
79
+ }[];
80
+ };
81
+ interface EventListenerTypes {
82
+ /**
83
+ * This event is emitted when the addon connects to the OGI Addon Server. Addon does not need to resolve anything.
84
+ * @param event
85
+ * @returns
86
+ */
87
+ connect: (event: EventResponse<void>) => void;
88
+ /**
89
+ * 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.
90
+ * @param reason
91
+ * @returns
92
+ */
93
+ disconnect: (reason: string) => void;
94
+ /**
95
+ * 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)
96
+ * @param config
97
+ * @returns
98
+ */
99
+ configure: (config: ConfigurationBuilder) => ConfigurationBuilder;
100
+ /**
101
+ * This event is called when the client provides a response to any event. This should be treated as middleware.
102
+ * @param response
103
+ * @returns
104
+ */
105
+ response: (response: any) => void;
106
+ /**
107
+ * This event is called when the client requests for the addon to authenticate itself. You don't need to provide any info.
108
+ * @param config
109
+ * @returns
110
+ */
111
+ authenticate: (config: any) => void;
112
+ /**
113
+ * 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)
114
+ * @param query
115
+ * @param event
116
+ * @returns
117
+ */
118
+ search: (query: {
119
+ storefront: string;
120
+ appID: number;
121
+ } & ({
122
+ for: 'game' | 'task' | 'all';
123
+ } | {
124
+ for: 'update';
125
+ libraryInfo: LibraryInfo;
126
+ }), event: EventResponse<SearchResult[]>) => void;
127
+ /**
128
+ * 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)
129
+ * @param data
130
+ * @param event
131
+ * @returns
132
+ */
133
+ setup: (data: {
134
+ path: string;
135
+ type: 'direct' | 'torrent' | 'magnet' | 'empty';
136
+ name: string;
137
+ usedRealDebrid: boolean;
138
+ clearOldFilesBeforeUpdate?: boolean;
139
+ multiPartFiles?: {
140
+ name: string;
141
+ downloadURL: string;
142
+ }[];
143
+ appID: number;
144
+ storefront: string;
145
+ manifest?: Record<string, unknown>;
146
+ } & ({
147
+ for: 'game';
148
+ } | {
149
+ for: 'update';
150
+ currentLibraryInfo: LibraryInfo;
151
+ }), event: EventResponse<SetupEventResponse>) => void;
152
+ /**
153
+ * This event is emitted when the client requires for a search to be performed. Input is the search query.
154
+ * @param query
155
+ * @param event
156
+ * @returns
157
+ */
158
+ 'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;
159
+ /**
160
+ * 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.
161
+ * @param appID
162
+ * @param event
163
+ * @returns
164
+ */
165
+ 'game-details': (details: {
166
+ appID: number;
167
+ storefront: string;
168
+ }, event: EventResponse<StoreData | undefined>) => void;
169
+ /**
170
+ * 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)`.
171
+ * @returns
172
+ */
173
+ exit: () => void;
174
+ /**
175
+ * 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.
176
+ * @param appID
177
+ * @param info
178
+ * @param event
179
+ * @returns
180
+ */
181
+ 'request-dl': (appID: number, info: SearchResult, event: EventResponse<SearchResult>) => void;
182
+ /**
183
+ * This event is emitted when the client requests for a catalog to be fetched. Addon should resolve the event with the catalog.
184
+ * @param event
185
+ * @returns
186
+ */
187
+ catalog: (event: Omit<EventResponse<CatalogResponse>, 'askForInput'>) => void;
188
+ /**
189
+ * This event is emitted when the client requests for an addon to check for updates. Addon should resolve the event with the update information.
190
+ * @param data
191
+ * @param event
192
+ * @returns
193
+ */
194
+ 'check-for-updates': (data: {
195
+ appID: number;
196
+ storefront: string;
197
+ currentVersion: string;
198
+ }, event: EventResponse<{
199
+ available: true;
200
+ version: string;
201
+ } | {
202
+ available: false;
203
+ }>) => void;
204
+ }
205
+ interface StoreData {
206
+ name: string;
207
+ publishers: string[];
208
+ developers: string[];
209
+ appID: number;
210
+ releaseDate: string;
211
+ capsuleImage: string;
212
+ coverImage: string;
213
+ basicDescription: string;
214
+ description: string;
215
+ headerImage: string;
216
+ latestVersion: string;
217
+ }
218
+ interface WebsocketMessageClient {
219
+ event: OGIAddonClientSentEvent;
220
+ id?: string;
221
+ args: any;
222
+ statusError?: string;
223
+ }
224
+ interface WebsocketMessageServer {
225
+ event: OGIAddonServerSentEvent;
226
+ id?: string;
227
+ args: any;
228
+ statusError?: string;
229
+ }
230
+ /**
231
+ * The configuration for the addon. This is used to identify the addon and provide information about it.
232
+ * Storefronts is an array of names of stores that the addon supports.
233
+ */
234
+ interface OGIAddonConfiguration {
235
+ name: string;
236
+ id: string;
237
+ description: string;
238
+ version: string;
239
+ author: string;
240
+ repository: string;
241
+ storefronts: string[];
242
+ }
243
+ /**
244
+ * 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.
245
+ * @example
246
+ * ```typescript
247
+ * const addon = new OGIAddon({
248
+ * name: 'Test Addon',
249
+ * id: 'test-addon',
250
+ * description: 'A test addon',
251
+ * version: '1.0.0',
252
+ * author: 'OGI Developers',
253
+ * repository: ''
254
+ * });
255
+ * ```
256
+ *
257
+ */
258
+ declare class OGIAddon {
259
+ eventEmitter: events<[never]>;
260
+ addonWSListener: OGIAddonWSListener;
261
+ addonInfo: OGIAddonConfiguration;
262
+ config: Configuration;
263
+ private eventsAvailable;
264
+ private registeredConnectEvent;
265
+ private taskHandlers;
266
+ constructor(addonInfo: OGIAddonConfiguration);
267
+ /**
268
+ * Register an event listener for the addon. (See EventListenerTypes)
269
+ * @param event {OGIAddonEvent}
270
+ * @param listener {EventListenerTypes[OGIAddonEvent]}
271
+ */
272
+ on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]): void;
273
+ emit<T extends OGIAddonEvent>(event: T, ...args: Parameters<EventListenerTypes[T]>): void;
274
+ /**
275
+ * Notify the client using a notification. Provide the type of notification, the message, and an ID.
276
+ * @param notification {Notification}
277
+ */
278
+ notify(notification: Notification): void;
279
+ /**
280
+ * Get the app details for a given appID and storefront.
281
+ * @param appID {number}
282
+ * @param storefront {string}
283
+ * @returns {Promise<StoreData>}
284
+ */
285
+ getAppDetails(appID: number, storefront: string): Promise<StoreData | undefined>;
286
+ searchGame(query: string, storefront: string): Promise<BasicLibraryInfo[]>;
287
+ /**
288
+ * 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.
289
+ * @returns {Promise<Task>} A Task instance for managing the background task.
290
+ */
291
+ task(): Promise<Task>;
292
+ /**
293
+ * Register a task handler for a specific task name. The task name should match the taskName field in SearchResult or ActionOption.
294
+ * @param taskName {string} The name of the task (should match taskName in SearchResult or ActionOption.setTaskName()).
295
+ * @param handler {(task: Task, data: { manifest: Record<string, unknown>; downloadPath: string; name: string; libraryInfo: LibraryInfo }) => Promise<void> | void} The handler function.
296
+ * @example
297
+ * ```typescript
298
+ * addon.onTask('clearCache', async (task) => {
299
+ * task.log('Clearing cache...');
300
+ * task.setProgress(50);
301
+ * await clearCacheFiles();
302
+ * task.setProgress(100);
303
+ * task.complete();
304
+ * });
305
+ * ```
306
+ */
307
+ onTask(taskName: string, handler: (task: Task, data: {
308
+ manifest: Record<string, unknown>;
309
+ downloadPath: string;
310
+ name: string;
311
+ libraryInfo: LibraryInfo;
312
+ }) => Promise<void> | void): void;
313
+ /**
314
+ * Check if a task handler is registered for the given task name.
315
+ * @param taskName {string} The task name to check.
316
+ * @returns {boolean} True if a handler is registered.
317
+ */
318
+ hasTaskHandler(taskName: string): boolean;
319
+ /**
320
+ * Get a task handler for the given task name.
321
+ * @param taskName {string} The task name.
322
+ * @returns The handler function or undefined if not found.
323
+ */
324
+ getTaskHandler(taskName: string): ((task: Task, data: {
325
+ manifest: Record<string, unknown>;
326
+ downloadPath: string;
327
+ name: string;
328
+ libraryInfo?: LibraryInfo;
329
+ }) => Promise<void> | void) | undefined;
330
+ /**
331
+ * Extract a file using 7-Zip on Windows, unzip on Linux/Mac.
332
+ * @param path {string}
333
+ * @param outputPath {string}
334
+ * @param type {'unrar' | 'unzip'}
335
+ * @returns {Promise<void>}
336
+ */
337
+ extractFile(path: string, outputPath: string, type: 'unrar' | 'unzip'): Promise<void>;
338
+ }
339
+ /**
340
+ * A unified task API for both server-initiated tasks (via onTask handlers)
341
+ * and addon-initiated background tasks (via addon.task()).
342
+ * Provides chainable methods for logging, progress updates, and completion.
343
+ */
344
+ declare class Task {
345
+ private event;
346
+ private ws;
347
+ private readonly id;
348
+ private progress;
349
+ private logs;
350
+ private finished;
351
+ private failed;
352
+ /**
353
+ * Construct a Task from an EventResponse (for onTask handlers).
354
+ * @param event {EventResponse<void>} The event response to wrap.
355
+ */
356
+ constructor(event: EventResponse<void>);
357
+ /**
358
+ * Construct a Task from WebSocket listener (for addon.task()).
359
+ * @param ws {OGIAddonWSListener} The WebSocket listener.
360
+ * @param id {string} The task ID.
361
+ * @param progress {number} Initial progress (0-100).
362
+ * @param logs {string[]} Initial logs array.
363
+ */
364
+ constructor(ws: OGIAddonWSListener, id: string, progress: number, logs: string[]);
365
+ /**
366
+ * Log a message to the task. Returns this for chaining.
367
+ * @param message {string} The message to log.
368
+ */
369
+ log(message: string): this;
370
+ /**
371
+ * Set the progress of the task (0-100). Returns this for chaining.
372
+ * @param progress {number} The progress value (0-100).
373
+ */
374
+ setProgress(progress: number): this;
375
+ /**
376
+ * Complete the task successfully.
377
+ */
378
+ complete(): void;
379
+ /**
380
+ * Fail the task with an error message.
381
+ * @param message {string} The error message.
382
+ */
383
+ fail(message: string): void;
384
+ /**
385
+ * Ask the user for input using a ConfigurationBuilder screen.
386
+ * Only available for EventResponse-based tasks (onTask handlers).
387
+ * The return type is inferred from the ConfigurationBuilder's accumulated option types.
388
+ * @param name {string} The name/title of the input prompt.
389
+ * @param description {string} The description of what input is needed.
390
+ * @param screen {ConfigurationBuilder<U>} The configuration builder for the input form.
391
+ * @returns {Promise<U>} The user's input with types matching the configuration options.
392
+ * @throws {Error} If called on a WebSocket-based task.
393
+ */
394
+ askForInput<U extends Record<string, string | number | boolean>>(name: string, description: string, screen: ConfigurationBuilder<U>): Promise<U>;
395
+ /**
396
+ * Update the task state (for WebSocket-based tasks only).
397
+ * Called automatically when using log(), setProgress(), complete(), or fail().
398
+ */
399
+ private update;
400
+ }
401
+ /**
402
+ * A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.
403
+ * @example
404
+ * ```typescript
405
+ * const searchTool = new SearchTool<LibraryInfo>([{ name: 'test', appID: 123 }, { name: 'test2', appID: 124 }], ['name']);
406
+ * const results = searchTool.search('test', 10);
407
+ * ```
408
+ */
409
+ declare class SearchTool<T> {
410
+ private fuse;
411
+ constructor(items: T[], keys: string[], options?: Omit<IFuseOptions<T>, 'keys'>);
412
+ search(query: string, limit?: number): T[];
413
+ addItems(items: T[]): void;
414
+ }
415
+ /**
416
+ * Library Info is the metadata for a library entry after setting up a game.
417
+ */
418
+ declare const ZodLibraryInfo: z.ZodObject<{
419
+ name: z.ZodString;
420
+ version: z.ZodString;
421
+ cwd: z.ZodString;
422
+ appID: z.ZodNumber;
423
+ launchExecutable: z.ZodString;
424
+ launchArguments: z.ZodOptional<z.ZodString>;
425
+ capsuleImage: z.ZodString;
426
+ storefront: z.ZodString;
427
+ addonsource: z.ZodString;
428
+ coverImage: z.ZodString;
429
+ titleImage: z.ZodOptional<z.ZodString>;
430
+ }, "strip", z.ZodTypeAny, {
431
+ name: string;
432
+ version: string;
433
+ cwd: string;
434
+ appID: number;
435
+ launchExecutable: string;
436
+ capsuleImage: string;
437
+ storefront: string;
438
+ addonsource: string;
439
+ coverImage: string;
440
+ launchArguments?: string | undefined;
441
+ titleImage?: string | undefined;
442
+ }, {
443
+ name: string;
444
+ version: string;
445
+ cwd: string;
446
+ appID: number;
447
+ launchExecutable: string;
448
+ capsuleImage: string;
449
+ storefront: string;
450
+ addonsource: string;
451
+ coverImage: string;
452
+ launchArguments?: string | undefined;
453
+ titleImage?: string | undefined;
454
+ }>;
455
+ type LibraryInfo = z.infer<typeof ZodLibraryInfo>;
456
+ interface Notification {
457
+ type: 'warning' | 'error' | 'info' | 'success';
458
+ message: string;
459
+ id: string;
460
+ }
461
+ declare class OGIAddonWSListener {
462
+ private socket;
463
+ eventEmitter: events.EventEmitter;
464
+ addon: OGIAddon;
465
+ constructor(ogiAddon: OGIAddon, eventEmitter: events.EventEmitter);
466
+ private userInputAsked;
467
+ private registerMessageReceiver;
468
+ private waitForEventToRespond;
469
+ respondToMessage(messageID: string, response: any, originalEvent: EventResponse<any> | undefined): void;
470
+ waitForResponseFromServer<T>(messageID: string): Promise<T>;
471
+ send(event: OGIAddonClientSentEvent, args: ClientSentEventTypes[OGIAddonClientSentEvent]): string;
472
+ close(): void;
473
+ }
474
+ //#endregion
475
+ export { BasicLibraryInfo, CatalogCarouselItem, CatalogResponse, CatalogSection, CatalogWithCarousel, ClientSentEventTypes, Configuration, ConfigurationBuilder, EventListenerTypes, EventResponse, LibraryInfo, OGIAddonClientSentEvent, OGIAddonConfiguration, OGIAddonEvent, OGIAddonServerSentEvent, type SearchResult, SearchTool, SetupEventResponse, StoreData, Task, VERSION, WebsocketMessageClient, WebsocketMessageServer, ZodLibraryInfo, OGIAddon as default };
476
+ //# sourceMappingURL=main.d.cts.map