ogi-addon 1.9.3 → 1.9.4
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/Configuration-CdRZbO6z.d.mts +21 -0
- package/build/Configuration-WeOm-F0_.d.cts +21 -0
- package/build/ConfigurationBuilder-BSuJ4rSI.cjs +302 -0
- package/build/ConfigurationBuilder-BSuJ4rSI.cjs.map +1 -0
- package/build/ConfigurationBuilder-BbZDA_xx.d.mts +132 -0
- package/build/ConfigurationBuilder-CfHLKMTO.d.cts +132 -0
- package/build/EventResponse-CQhmdz3C.d.mts +430 -0
- package/build/EventResponse-D1c-Df5W.d.cts +430 -0
- package/build/EventResponse.cjs +55 -79
- package/build/EventResponse.cjs.map +1 -1
- package/build/EventResponse.d.cts +2 -45
- package/build/EventResponse.d.mts +2 -0
- package/build/EventResponse.mjs +58 -0
- package/build/EventResponse.mjs.map +1 -0
- package/build/SearchEngine-CRQWXfo6.d.mts +22 -0
- package/build/SearchEngine-DBSUNM4A.d.cts +22 -0
- package/build/SearchEngine.cjs +0 -19
- package/build/SearchEngine.d.cts +2 -20
- package/build/SearchEngine.d.mts +2 -0
- package/build/SearchEngine.mjs +1 -0
- package/build/config/Configuration.cjs +56 -370
- package/build/config/Configuration.cjs.map +1 -1
- package/build/config/Configuration.d.cts +3 -20
- package/build/config/Configuration.d.mts +3 -0
- package/build/config/Configuration.mjs +52 -0
- package/build/config/Configuration.mjs.map +1 -0
- package/build/config/ConfigurationBuilder.cjs +9 -292
- package/build/config/ConfigurationBuilder.d.cts +2 -130
- package/build/config/ConfigurationBuilder.d.mts +2 -0
- package/build/config/ConfigurationBuilder.mjs +221 -0
- package/build/config/ConfigurationBuilder.mjs.map +1 -0
- package/build/main.cjs +510 -1074
- package/build/main.cjs.map +1 -1
- package/build/main.d.cts +5 -387
- package/build/main.d.mts +5 -0
- package/build/main.mjs +510 -0
- package/build/main.mjs.map +1 -0
- package/package.json +9 -9
- package/src/config/Configuration.ts +18 -7
- package/src/main.ts +4 -3
- package/{tsup.config.js → tsdown.config.js} +2 -1
- package/build/EventResponse.d.ts +0 -45
- package/build/EventResponse.js +0 -62
- package/build/EventResponse.js.map +0 -1
- package/build/SearchEngine.cjs.map +0 -1
- package/build/SearchEngine.d.ts +0 -20
- package/build/SearchEngine.js +0 -1
- package/build/SearchEngine.js.map +0 -1
- package/build/config/Configuration.d.ts +0 -20
- package/build/config/Configuration.js +0 -329
- package/build/config/Configuration.js.map +0 -1
- package/build/config/ConfigurationBuilder.cjs.map +0 -1
- package/build/config/ConfigurationBuilder.d.ts +0 -130
- package/build/config/ConfigurationBuilder.js +0 -251
- package/build/config/ConfigurationBuilder.js.map +0 -1
- package/build/main.d.ts +0 -387
- package/build/main.js +0 -1045
- package/build/main.js.map +0 -1
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { n as ConfigurationBuilder, r as ConfigurationFile } from "./ConfigurationBuilder-CfHLKMTO.cjs";
|
|
2
|
+
import { t as Configuration } from "./Configuration-WeOm-F0_.cjs";
|
|
3
|
+
import { t as SearchResult } from "./SearchEngine-DBSUNM4A.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' | 'task-run' | '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;
|
|
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 task to be run. Addon should resolve the event with the task.
|
|
140
|
+
* @param task
|
|
141
|
+
* @param event
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
'task-run': (task: {
|
|
145
|
+
manifest: Record<string, unknown>;
|
|
146
|
+
downloadPath: string;
|
|
147
|
+
name: string;
|
|
148
|
+
}, event: EventResponse<void>) => void;
|
|
149
|
+
/**
|
|
150
|
+
* 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.
|
|
151
|
+
* @param appID
|
|
152
|
+
* @param event
|
|
153
|
+
* @returns
|
|
154
|
+
*/
|
|
155
|
+
'game-details': (details: {
|
|
156
|
+
appID: number;
|
|
157
|
+
storefront: string;
|
|
158
|
+
}, event: EventResponse<StoreData | undefined>) => void;
|
|
159
|
+
/**
|
|
160
|
+
* 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)`.
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
exit: () => void;
|
|
164
|
+
/**
|
|
165
|
+
* 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.
|
|
166
|
+
* @param appID
|
|
167
|
+
* @param info
|
|
168
|
+
* @param event
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
'request-dl': (appID: number, info: SearchResult, event: EventResponse<SearchResult>) => void;
|
|
172
|
+
/**
|
|
173
|
+
* This event is emitted when the client requests for a catalog to be fetched. Addon should resolve the event with the catalog.
|
|
174
|
+
* @param event
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
catalog: (event: Omit<EventResponse<{
|
|
178
|
+
[key: string]: {
|
|
179
|
+
name: string;
|
|
180
|
+
description: string;
|
|
181
|
+
listings: BasicLibraryInfo[];
|
|
182
|
+
};
|
|
183
|
+
}>, 'askForInput'>) => void;
|
|
184
|
+
/**
|
|
185
|
+
* This event is emitted when the client requests for an addon to check for updates. Addon should resolve the event with the update information.
|
|
186
|
+
* @param data
|
|
187
|
+
* @param event
|
|
188
|
+
* @returns
|
|
189
|
+
*/
|
|
190
|
+
'check-for-updates': (data: {
|
|
191
|
+
appID: number;
|
|
192
|
+
storefront: string;
|
|
193
|
+
currentVersion: string;
|
|
194
|
+
}, event: EventResponse<{
|
|
195
|
+
available: true;
|
|
196
|
+
version: string;
|
|
197
|
+
} | {
|
|
198
|
+
available: false;
|
|
199
|
+
}>) => void;
|
|
200
|
+
}
|
|
201
|
+
interface StoreData {
|
|
202
|
+
name: string;
|
|
203
|
+
publishers: string[];
|
|
204
|
+
developers: string[];
|
|
205
|
+
appID: number;
|
|
206
|
+
releaseDate: string;
|
|
207
|
+
capsuleImage: string;
|
|
208
|
+
coverImage: string;
|
|
209
|
+
basicDescription: string;
|
|
210
|
+
description: string;
|
|
211
|
+
headerImage: string;
|
|
212
|
+
latestVersion: string;
|
|
213
|
+
}
|
|
214
|
+
interface WebsocketMessageClient {
|
|
215
|
+
event: OGIAddonClientSentEvent;
|
|
216
|
+
id?: string;
|
|
217
|
+
args: any;
|
|
218
|
+
statusError?: string;
|
|
219
|
+
}
|
|
220
|
+
interface WebsocketMessageServer {
|
|
221
|
+
event: OGIAddonServerSentEvent;
|
|
222
|
+
id?: string;
|
|
223
|
+
args: any;
|
|
224
|
+
statusError?: string;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The configuration for the addon. This is used to identify the addon and provide information about it.
|
|
228
|
+
* Storefronts is an array of names of stores that the addon supports.
|
|
229
|
+
*/
|
|
230
|
+
interface OGIAddonConfiguration {
|
|
231
|
+
name: string;
|
|
232
|
+
id: string;
|
|
233
|
+
description: string;
|
|
234
|
+
version: string;
|
|
235
|
+
author: string;
|
|
236
|
+
repository: string;
|
|
237
|
+
storefronts: string[];
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* 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.
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const addon = new OGIAddon({
|
|
244
|
+
* name: 'Test Addon',
|
|
245
|
+
* id: 'test-addon',
|
|
246
|
+
* description: 'A test addon',
|
|
247
|
+
* version: '1.0.0',
|
|
248
|
+
* author: 'OGI Developers',
|
|
249
|
+
* repository: ''
|
|
250
|
+
* });
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
*/
|
|
254
|
+
declare class OGIAddon {
|
|
255
|
+
eventEmitter: events<[never]>;
|
|
256
|
+
addonWSListener: OGIAddonWSListener;
|
|
257
|
+
addonInfo: OGIAddonConfiguration;
|
|
258
|
+
config: Configuration;
|
|
259
|
+
private eventsAvailable;
|
|
260
|
+
private registeredConnectEvent;
|
|
261
|
+
constructor(addonInfo: OGIAddonConfiguration);
|
|
262
|
+
/**
|
|
263
|
+
* Register an event listener for the addon. (See EventListenerTypes)
|
|
264
|
+
* @param event {OGIAddonEvent}
|
|
265
|
+
* @param listener {EventListenerTypes[OGIAddonEvent]}
|
|
266
|
+
*/
|
|
267
|
+
on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]): void;
|
|
268
|
+
emit<T extends OGIAddonEvent>(event: T, ...args: Parameters<EventListenerTypes[T]>): void;
|
|
269
|
+
/**
|
|
270
|
+
* Notify the client using a notification. Provide the type of notification, the message, and an ID.
|
|
271
|
+
* @param notification {Notification}
|
|
272
|
+
*/
|
|
273
|
+
notify(notification: Notification): void;
|
|
274
|
+
/**
|
|
275
|
+
* Get the app details for a given appID and storefront.
|
|
276
|
+
* @param appID {number}
|
|
277
|
+
* @param storefront {string}
|
|
278
|
+
* @returns {Promise<StoreData>}
|
|
279
|
+
*/
|
|
280
|
+
getAppDetails(appID: number, storefront: string): Promise<StoreData | undefined>;
|
|
281
|
+
searchGame(query: string, storefront: string): Promise<BasicLibraryInfo[]>;
|
|
282
|
+
/**
|
|
283
|
+
* 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.
|
|
284
|
+
* @param id {string}
|
|
285
|
+
* @param progress {number}
|
|
286
|
+
* @param logs {string[]}
|
|
287
|
+
*/
|
|
288
|
+
task(): Promise<CustomTask>;
|
|
289
|
+
/**
|
|
290
|
+
* Extract a file using 7-Zip on Windows, unzip on Linux/Mac.
|
|
291
|
+
* @param path {string}
|
|
292
|
+
* @param outputPath {string}
|
|
293
|
+
* @param type {'unrar' | 'unzip'}
|
|
294
|
+
* @returns {Promise<void>}
|
|
295
|
+
*/
|
|
296
|
+
extractFile(path: string, outputPath: string, type: 'unrar' | 'unzip'): Promise<void>;
|
|
297
|
+
}
|
|
298
|
+
declare class CustomTask {
|
|
299
|
+
readonly id: string;
|
|
300
|
+
progress: number;
|
|
301
|
+
logs: string[];
|
|
302
|
+
finished: boolean;
|
|
303
|
+
ws: OGIAddonWSListener;
|
|
304
|
+
failed: string | undefined;
|
|
305
|
+
constructor(ws: OGIAddonWSListener, id: string, progress: number, logs: string[]);
|
|
306
|
+
log(log: string): void;
|
|
307
|
+
finish(): void;
|
|
308
|
+
fail(message: string): void;
|
|
309
|
+
setProgress(progress: number): void;
|
|
310
|
+
update(): void;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* const searchTool = new SearchTool<LibraryInfo>([{ name: 'test', appID: 123 }, { name: 'test2', appID: 124 }], ['name']);
|
|
317
|
+
* const results = searchTool.search('test', 10);
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
declare class SearchTool<T> {
|
|
321
|
+
private fuse;
|
|
322
|
+
constructor(items: T[], keys: string[], options?: Omit<IFuseOptions<T>, 'keys'>);
|
|
323
|
+
search(query: string, limit?: number): T[];
|
|
324
|
+
addItems(items: T[]): void;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Library Info is the metadata for a library entry after setting up a game.
|
|
328
|
+
*/
|
|
329
|
+
declare const ZodLibraryInfo: z.ZodObject<{
|
|
330
|
+
name: z.ZodString;
|
|
331
|
+
version: z.ZodString;
|
|
332
|
+
cwd: z.ZodString;
|
|
333
|
+
appID: z.ZodNumber;
|
|
334
|
+
launchExecutable: z.ZodString;
|
|
335
|
+
launchArguments: z.ZodOptional<z.ZodString>;
|
|
336
|
+
capsuleImage: z.ZodString;
|
|
337
|
+
storefront: z.ZodString;
|
|
338
|
+
addonsource: z.ZodString;
|
|
339
|
+
coverImage: z.ZodString;
|
|
340
|
+
titleImage: z.ZodOptional<z.ZodString>;
|
|
341
|
+
}, "strip", z.ZodTypeAny, {
|
|
342
|
+
name: string;
|
|
343
|
+
version: string;
|
|
344
|
+
cwd: string;
|
|
345
|
+
appID: number;
|
|
346
|
+
launchExecutable: string;
|
|
347
|
+
capsuleImage: string;
|
|
348
|
+
storefront: string;
|
|
349
|
+
addonsource: string;
|
|
350
|
+
coverImage: string;
|
|
351
|
+
launchArguments?: string | undefined;
|
|
352
|
+
titleImage?: string | undefined;
|
|
353
|
+
}, {
|
|
354
|
+
name: string;
|
|
355
|
+
version: string;
|
|
356
|
+
cwd: string;
|
|
357
|
+
appID: number;
|
|
358
|
+
launchExecutable: string;
|
|
359
|
+
capsuleImage: string;
|
|
360
|
+
storefront: string;
|
|
361
|
+
addonsource: string;
|
|
362
|
+
coverImage: string;
|
|
363
|
+
launchArguments?: string | undefined;
|
|
364
|
+
titleImage?: string | undefined;
|
|
365
|
+
}>;
|
|
366
|
+
type LibraryInfo = z.infer<typeof ZodLibraryInfo>;
|
|
367
|
+
interface Notification {
|
|
368
|
+
type: 'warning' | 'error' | 'info' | 'success';
|
|
369
|
+
message: string;
|
|
370
|
+
id: string;
|
|
371
|
+
}
|
|
372
|
+
declare class OGIAddonWSListener {
|
|
373
|
+
private socket;
|
|
374
|
+
eventEmitter: events.EventEmitter;
|
|
375
|
+
addon: OGIAddon;
|
|
376
|
+
constructor(ogiAddon: OGIAddon, eventEmitter: events.EventEmitter);
|
|
377
|
+
private userInputAsked;
|
|
378
|
+
private registerMessageReceiver;
|
|
379
|
+
private waitForEventToRespond;
|
|
380
|
+
respondToMessage(messageID: string, response: any, originalEvent: EventResponse<any> | undefined): void;
|
|
381
|
+
waitForResponseFromServer<T>(messageID: string): Promise<T>;
|
|
382
|
+
send(event: OGIAddonClientSentEvent, args: ClientSentEventTypes[OGIAddonClientSentEvent]): string;
|
|
383
|
+
close(): void;
|
|
384
|
+
}
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/EventResponse.d.ts
|
|
387
|
+
declare class EventResponse<T> {
|
|
388
|
+
data: T | undefined;
|
|
389
|
+
deffered: boolean;
|
|
390
|
+
resolved: boolean;
|
|
391
|
+
progress: number;
|
|
392
|
+
logs: string[];
|
|
393
|
+
failed: string | undefined;
|
|
394
|
+
onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{
|
|
395
|
+
[key: string]: boolean | string | number;
|
|
396
|
+
}>;
|
|
397
|
+
constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{
|
|
398
|
+
[key: string]: boolean | string | number;
|
|
399
|
+
}>);
|
|
400
|
+
defer(promise?: () => Promise<void>): void;
|
|
401
|
+
/**
|
|
402
|
+
* 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.**
|
|
403
|
+
* @param data {T}
|
|
404
|
+
*/
|
|
405
|
+
resolve(data: T): void;
|
|
406
|
+
/**
|
|
407
|
+
* 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.**
|
|
408
|
+
*/
|
|
409
|
+
complete(): void;
|
|
410
|
+
fail(message: string): void;
|
|
411
|
+
/**
|
|
412
|
+
* Logs a message to the event. This is useful for debugging and logging information to the user.
|
|
413
|
+
* @param message {string}
|
|
414
|
+
*/
|
|
415
|
+
log(message: string): void;
|
|
416
|
+
/**
|
|
417
|
+
* 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.
|
|
418
|
+
* @async
|
|
419
|
+
* @param name {string}
|
|
420
|
+
* @param description {string}
|
|
421
|
+
* @param screen {ConfigurationBuilder}
|
|
422
|
+
* @returns {Promise<{ [key: string]: boolean | string | number }>}
|
|
423
|
+
*/
|
|
424
|
+
askForInput(name: string, description: string, screen: ConfigurationBuilder): Promise<{
|
|
425
|
+
[key: string]: boolean | string | number;
|
|
426
|
+
}>;
|
|
427
|
+
}
|
|
428
|
+
//#endregion
|
|
429
|
+
export { WebsocketMessageServer as _, EventListenerTypes as a, OGIAddonClientSentEvent as c, OGIAddonServerSentEvent as d, SearchTool as f, WebsocketMessageClient as g, VERSION as h, CustomTask as i, OGIAddonConfiguration as l, StoreData as m, BasicLibraryInfo as n, LibraryInfo as o, SetupEventResponse as p, ClientSentEventTypes as r, OGIAddon as s, EventResponse as t, OGIAddonEvent as u, ZodLibraryInfo as v };
|
|
430
|
+
//# sourceMappingURL=EventResponse-D1c-Df5W.d.cts.map
|
package/build/EventResponse.cjs
CHANGED
|
@@ -1,83 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
1
|
|
|
20
|
-
|
|
21
|
-
var EventResponse_exports = {};
|
|
22
|
-
__export(EventResponse_exports, {
|
|
23
|
-
default: () => EventResponse
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(EventResponse_exports);
|
|
2
|
+
//#region src/EventResponse.ts
|
|
26
3
|
var EventResponse = class {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
throw new Error("No input asked callback");
|
|
79
|
-
}
|
|
80
|
-
return await this.onInputAsked(screen, name, description);
|
|
81
|
-
}
|
|
4
|
+
data = void 0;
|
|
5
|
+
deffered = false;
|
|
6
|
+
resolved = false;
|
|
7
|
+
progress = 0;
|
|
8
|
+
logs = [];
|
|
9
|
+
failed = void 0;
|
|
10
|
+
onInputAsked;
|
|
11
|
+
constructor(onInputAsked) {
|
|
12
|
+
this.onInputAsked = onInputAsked;
|
|
13
|
+
}
|
|
14
|
+
defer(promise) {
|
|
15
|
+
this.deffered = true;
|
|
16
|
+
if (promise) promise();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 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.**
|
|
20
|
+
* @param data {T}
|
|
21
|
+
*/
|
|
22
|
+
resolve(data) {
|
|
23
|
+
this.resolved = true;
|
|
24
|
+
this.data = data;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 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.**
|
|
28
|
+
*/
|
|
29
|
+
complete() {
|
|
30
|
+
this.resolved = true;
|
|
31
|
+
}
|
|
32
|
+
fail(message) {
|
|
33
|
+
this.resolved = true;
|
|
34
|
+
this.failed = message;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Logs a message to the event. This is useful for debugging and logging information to the user.
|
|
38
|
+
* @param message {string}
|
|
39
|
+
*/
|
|
40
|
+
log(message) {
|
|
41
|
+
this.logs.push(message);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 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.
|
|
45
|
+
* @async
|
|
46
|
+
* @param name {string}
|
|
47
|
+
* @param description {string}
|
|
48
|
+
* @param screen {ConfigurationBuilder}
|
|
49
|
+
* @returns {Promise<{ [key: string]: boolean | string | number }>}
|
|
50
|
+
*/
|
|
51
|
+
async askForInput(name, description, screen) {
|
|
52
|
+
if (!this.onInputAsked) throw new Error("No input asked callback");
|
|
53
|
+
return await this.onInputAsked(screen, name, description);
|
|
54
|
+
}
|
|
82
55
|
};
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
module.exports = EventResponse;
|
|
83
59
|
//# sourceMappingURL=EventResponse.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/EventResponse.ts"],"sourcesContent":["import { ConfigurationBuilder } from './main';\n\nexport default class EventResponse<T> {\n data: T | undefined = undefined;\n deffered: boolean = false;\n resolved: boolean = false;\n progress: number = 0;\n logs: string[] = [];\n failed: string | undefined = undefined;\n onInputAsked?: (\n screen: ConfigurationBuilder,\n name: string,\n description: string\n ) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(\n onInputAsked?: (\n screen: ConfigurationBuilder,\n name: string,\n description: string\n ) => Promise<{ [key: string]: boolean | string | number }>\n ) {\n this.onInputAsked = onInputAsked;\n }\n\n public defer(promise?: () => Promise<void>) {\n this.deffered = true;\n // include this to make it easier to use the defer method with async functions\n if (promise) {\n promise();\n }\n }\n\n /**\n * 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.**\n * @param data {T}\n */\n public resolve(data: T) {\n this.resolved = true;\n this.data = data;\n }\n\n /**\n * 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.**\n */\n public complete() {\n this.resolved = true;\n }\n\n public fail(message: string) {\n this.resolved = true;\n this.failed = message;\n }\n\n /**\n * Logs a message to the event. This is useful for debugging and logging information to the user.\n * @param message {string}\n */\n public log(message: string) {\n this.logs.push(message);\n }\n\n /**\n * 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.\n * @async\n * @param name {string}\n * @param description {string}\n * @param screen {ConfigurationBuilder}\n * @returns {Promise<{ [key: string]: boolean | string | number }>}\n */\n public async askForInput(\n name: string,\n description: string,\n screen: ConfigurationBuilder\n ): Promise<{ [key: string]: boolean | string | number }> {\n if (!this.onInputAsked) {\n throw new Error('No input asked callback');\n }\n return await this.onInputAsked(screen, name, description);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EventResponse.cjs","names":[],"sources":["../src/EventResponse.ts"],"sourcesContent":["import { ConfigurationBuilder } from './main';\n\nexport default class EventResponse<T> {\n data: T | undefined = undefined;\n deffered: boolean = false;\n resolved: boolean = false;\n progress: number = 0;\n logs: string[] = [];\n failed: string | undefined = undefined;\n onInputAsked?: (\n screen: ConfigurationBuilder,\n name: string,\n description: string\n ) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(\n onInputAsked?: (\n screen: ConfigurationBuilder,\n name: string,\n description: string\n ) => Promise<{ [key: string]: boolean | string | number }>\n ) {\n this.onInputAsked = onInputAsked;\n }\n\n public defer(promise?: () => Promise<void>) {\n this.deffered = true;\n // include this to make it easier to use the defer method with async functions\n if (promise) {\n promise();\n }\n }\n\n /**\n * 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.**\n * @param data {T}\n */\n public resolve(data: T) {\n this.resolved = true;\n this.data = data;\n }\n\n /**\n * 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.**\n */\n public complete() {\n this.resolved = true;\n }\n\n public fail(message: string) {\n this.resolved = true;\n this.failed = message;\n }\n\n /**\n * Logs a message to the event. This is useful for debugging and logging information to the user.\n * @param message {string}\n */\n public log(message: string) {\n this.logs.push(message);\n }\n\n /**\n * 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.\n * @async\n * @param name {string}\n * @param description {string}\n * @param screen {ConfigurationBuilder}\n * @returns {Promise<{ [key: string]: boolean | string | number }>}\n */\n public async askForInput(\n name: string,\n description: string,\n screen: ConfigurationBuilder\n ): Promise<{ [key: string]: boolean | string | number }> {\n if (!this.onInputAsked) {\n throw new Error('No input asked callback');\n }\n return await this.onInputAsked(screen, name, description);\n }\n}\n"],"mappings":";;AAEA,IAAqB,gBAArB,MAAsC;CACpC,OAAsB;CACtB,WAAoB;CACpB,WAAoB;CACpB,WAAmB;CACnB,OAAiB,EAAE;CACnB,SAA6B;CAC7B;CAMA,YACE,cAKA;AACA,OAAK,eAAe;;CAGtB,AAAO,MAAM,SAA+B;AAC1C,OAAK,WAAW;AAEhB,MAAI,QACF,UAAS;;;;;;CAQb,AAAO,QAAQ,MAAS;AACtB,OAAK,WAAW;AAChB,OAAK,OAAO;;;;;CAMd,AAAO,WAAW;AAChB,OAAK,WAAW;;CAGlB,AAAO,KAAK,SAAiB;AAC3B,OAAK,WAAW;AAChB,OAAK,SAAS;;;;;;CAOhB,AAAO,IAAI,SAAiB;AAC1B,OAAK,KAAK,KAAK,QAAQ;;;;;;;;;;CAWzB,MAAa,YACX,MACA,aACA,QACuD;AACvD,MAAI,CAAC,KAAK,aACR,OAAM,IAAI,MAAM,0BAA0B;AAE5C,SAAO,MAAM,KAAK,aAAa,QAAQ,MAAM,YAAY"}
|
|
@@ -1,45 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
declare class EventResponse<T> {
|
|
4
|
-
data: T | undefined;
|
|
5
|
-
deffered: boolean;
|
|
6
|
-
resolved: boolean;
|
|
7
|
-
progress: number;
|
|
8
|
-
logs: string[];
|
|
9
|
-
failed: string | undefined;
|
|
10
|
-
onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{
|
|
11
|
-
[key: string]: boolean | string | number;
|
|
12
|
-
}>;
|
|
13
|
-
constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{
|
|
14
|
-
[key: string]: boolean | string | number;
|
|
15
|
-
}>);
|
|
16
|
-
defer(promise?: () => Promise<void>): void;
|
|
17
|
-
/**
|
|
18
|
-
* 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.**
|
|
19
|
-
* @param data {T}
|
|
20
|
-
*/
|
|
21
|
-
resolve(data: T): void;
|
|
22
|
-
/**
|
|
23
|
-
* 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.**
|
|
24
|
-
*/
|
|
25
|
-
complete(): void;
|
|
26
|
-
fail(message: string): void;
|
|
27
|
-
/**
|
|
28
|
-
* Logs a message to the event. This is useful for debugging and logging information to the user.
|
|
29
|
-
* @param message {string}
|
|
30
|
-
*/
|
|
31
|
-
log(message: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* 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.
|
|
34
|
-
* @async
|
|
35
|
-
* @param name {string}
|
|
36
|
-
* @param description {string}
|
|
37
|
-
* @param screen {ConfigurationBuilder}
|
|
38
|
-
* @returns {Promise<{ [key: string]: boolean | string | number }>}
|
|
39
|
-
*/
|
|
40
|
-
askForInput(name: string, description: string, screen: ConfigurationBuilder): Promise<{
|
|
41
|
-
[key: string]: boolean | string | number;
|
|
42
|
-
}>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { EventResponse as default };
|
|
1
|
+
import { t as EventResponse } from "./EventResponse-D1c-Df5W.cjs";
|
|
2
|
+
export = EventResponse;
|