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