ogi-addon 1.1.6 → 1.2.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 +1 @@
1
- {"version":3,"sources":["../src/SearchEngine.ts"],"sourcesContent":["export type SearchResult = {\n name: string;\n description: string;\n coverURL: string;\n downloadType: 'torrent' | 'direct' | 'magnet' | 'request';\n downloadSize: number;\n appID: number;\n storefront: 'steam' | 'internal';\n filename?: string;\n downloadURL?: string;\n files?: {\n name: string;\n downloadURL: string;\n }[];\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/SearchEngine.ts"],"sourcesContent":["export type SearchResult = {\n name: string;\n downloadType: 'torrent' | 'direct' | 'magnet' | 'request';\n storefront: 'steam' | 'internal';\n filename?: string;\n downloadURL?: string;\n files?: {\n name: string;\n downloadURL: string;\n }[];\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,10 +1,6 @@
1
1
  type SearchResult = {
2
2
  name: string;
3
- description: string;
4
- coverURL: string;
5
3
  downloadType: 'torrent' | 'direct' | 'magnet' | 'request';
6
- downloadSize: number;
7
- appID: number;
8
4
  storefront: 'steam' | 'internal';
9
5
  filename?: string;
10
6
  downloadURL?: string;
@@ -1,10 +1,6 @@
1
1
  type SearchResult = {
2
2
  name: string;
3
- description: string;
4
- coverURL: string;
5
3
  downloadType: 'torrent' | 'direct' | 'magnet' | 'request';
6
- downloadSize: number;
7
- appID: number;
8
4
  storefront: 'steam' | 'internal';
9
5
  filename?: string;
10
6
  downloadURL?: string;
package/build/main.cjs CHANGED
@@ -395,7 +395,7 @@ var package_default = {
395
395
  module: "./build/main.js",
396
396
  type: "module",
397
397
  main: "./build/main.cjs",
398
- version: "1.1.6",
398
+ version: "1.2.0",
399
399
  exports: {
400
400
  ".": {
401
401
  import: {
@@ -432,7 +432,8 @@ var package_default = {
432
432
  scripts: {
433
433
  "auto-build": "tsc -w",
434
434
  build: "tsup --config tsup.config.js",
435
- release: "bun run build && npm publish"
435
+ release: "bun run build && npm publish",
436
+ "release-beta": "bun run build && npm publish --tag future"
436
437
  },
437
438
  devDependencies: {
438
439
  "@types/node": "^20.14.12",
@@ -526,11 +527,10 @@ var CustomTask = class {
526
527
  };
527
528
  var SearchTool = class {
528
529
  fuse;
529
- constructor(items, keys) {
530
+ constructor(items, keys, options = { threshold: 0.3, includeScore: true }) {
530
531
  this.fuse = new import_fuse.default(items, {
531
532
  keys,
532
- threshold: 0.3,
533
- includeScore: true
533
+ ...options
534
534
  });
535
535
  }
536
536
  search(query, limit = 10) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.ts","../src/config/ConfigurationBuilder.ts","../src/config/Configuration.ts","../src/EventResponse.ts","../package.json"],"sourcesContent":["import ws, { WebSocket } from 'ws';\nimport events from 'node:events';\nimport { ConfigurationBuilder, ConfigurationFile } from './config/ConfigurationBuilder';\nimport { Configuration } from './config/Configuration';\nimport EventResponse from './EventResponse';\nimport { SearchResult } from './SearchEngine';\nimport Fuse from 'fuse.js';\n\nexport type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'request-dl';\nexport type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'steam-search' | 'task-update';\n\nexport type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup' | 'response' | 'library-search' | 'game-details' | 'request-dl';\nexport { ConfigurationBuilder, Configuration, EventResponse, SearchResult };\nconst defaultPort = 7654;\nimport pjson from '../package.json';\nexport const VERSION = pjson.version;\n\nexport interface ClientSentEventTypes {\n response: any;\n authenticate: {\n name: string;\n id: string;\n description: string;\n version: string;\n author: string;\n };\n configure: ConfigurationFile;\n 'defer-update': {\n logs: string[],\n progress: number\n };\n notification: Notification;\n 'input-asked': ConfigurationBuilder;\n 'steam-search': {\n query: string;\n strict: boolean;\n };\n 'task-update': {\n id: string;\n progress: number;\n logs: string[];\n finished: boolean;\n };\n}\n\nexport type BasicLibraryInfo = {\n name: string;\n capsuleImage: string;\n appID: number;\n}\n\nexport interface EventListenerTypes {\n /**\n * This event is emitted when the addon connects to the OGI Addon Server. Addon does not need to resolve anything.\n * @param socket \n * @returns \n */\n connect: (socket: ws) => void;\n\n /**\n * 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.\n * @param reason \n * @returns \n */\n disconnect: (reason: string) => void;\n /**\n * 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) \n * @param config \n * @returns \n */\n configure: (config: ConfigurationBuilder) => ConfigurationBuilder;\n /**\n * This event is called when the client provides a response to any event. This should be treated as middleware. \n * @param response \n * @returns \n */\n response: (response: any) => void;\n\n /**\n * This event is called when the client requests for the addon to authenticate itself. You don't need to provide any info. \n * @param config \n * @returns \n */\n authenticate: (config: any) => void;\n /**\n * 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) \n * @param query \n * @param event \n * @returns \n */\n search: (query: { type: 'steamapp' | 'internal', text: string }, event: EventResponse<SearchResult[]>) => void;\n /**\n * 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)\n * @param data \n * @param event \n * @returns \n */\n setup: (\n data: {\n path: string,\n type: 'direct' | 'torrent' | 'magnet',\n name: string,\n usedRealDebrid: boolean,\n multiPartFiles?: {\n name: string,\n downloadURL: string\n }[],\n appID: number,\n storefront: 'steam' | 'internal'\n }, event: EventResponse<LibraryInfo>\n ) => void;\n\n /**\n * This event is emitted when the client requires for a search to be performed. Input is the search query. \n * @param query \n * @param event \n * @returns \n */\n 'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;\n 'game-details': (appID: number, event: EventResponse<StoreData>) => void;\n exit: () => void;\n 'request-dl': (appID: number, info: SearchResult, event: EventResponse<SearchResult>) => void;\n}\n\nexport interface StoreData {\n name: string;\n publishers: string[];\n developers: string[];\n appID: number;\n releaseDate: string;\n capsuleImage: string;\n coverImage: string;\n basicDescription: string;\n description: string;\n headerImage: string;\n}\nexport interface WebsocketMessageClient {\n event: OGIAddonClientSentEvent;\n id?: string;\n args: any;\n}\nexport interface WebsocketMessageServer {\n event: OGIAddonServerSentEvent;\n id?: string;\n args: any;\n}\nexport interface OGIAddonConfiguration {\n name: string;\n id: string;\n description: string;\n version: string;\n\n author: string;\n repository: string;\n}\n\n/**\n * 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.\n * @example \n * ```typescript\n * const addon = new OGIAddon({\n * name: 'Test Addon',\n* id: 'test-addon',\n * description: 'A test addon',\n * version: '1.0.0',\n * author: 'OGI Developers',\n * repository: ''\n * });\n * ```\n * \n */\nexport default class OGIAddon {\n public eventEmitter = new events.EventEmitter();\n public addonWSListener: OGIAddonWSListener;\n public addonInfo: OGIAddonConfiguration;\n public config: Configuration = new Configuration({});\n\n constructor(addonInfo: OGIAddonConfiguration) {\n this.addonInfo = addonInfo;\n this.addonWSListener = new OGIAddonWSListener(this, this.eventEmitter);\n }\n\n /**\n * Register an event listener for the addon. (See EventListenerTypes) \n * @param event {OGIAddonEvent}\n * @param listener {EventListenerTypes[OGIAddonEvent]} \n */\n public on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]) {\n this.eventEmitter.on(event, listener);\n }\n\n public emit<T extends OGIAddonEvent>(event: T, ...args: Parameters<EventListenerTypes[T]>) {\n this.eventEmitter.emit(event, ...args);\n }\n\n /**\n * Notify the client using a notification. Provide the type of notification, the message, and an ID. \n * @param notification {Notification}\n */\n public notify(notification: Notification) {\n this.addonWSListener.send('notification', [notification]);\n }\n\n /**\n * Search for items in the OGI Steam-Synced Library. Query can either be a Steam AppID or a Steam Game Name.\n * @param query {string}\n * @param event {EventResponse<BasicLibraryInfo[]>}\n */\n public async steamSearch(query: string, strict: boolean = false) {\n const id = this.addonWSListener.send('steam-search', { query, strict });\n return await this.addonWSListener.waitForResponseFromServer<Omit<BasicLibraryInfo, 'capsuleImage'>[]>(id);\n }\n\n /**\n * 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.\n * @param id {string}\n * @param progress {number}\n * @param logs {string[]}\n */\n public async task() {\n const id = Math.random().toString(36).substring(7);\n const progress = 0;\n const logs: string[] = [];\n const task = new CustomTask(this.addonWSListener, id, progress, logs);\n this.addonWSListener.send('task-update', { id, progress, logs, finished: false });\n return task;\n }\n}\n\nexport class CustomTask {\n public readonly id: string;\n public progress: number;\n public logs: string[];\n public finished: boolean = false;\n public ws: OGIAddonWSListener;\n constructor(ws: OGIAddonWSListener, id: string, progress: number, logs: string[]) {\n this.id = id;\n this.progress = progress;\n this.logs = logs;\n this.ws = ws;\n }\n public log(log: string) {\n this.logs.push(log);\n this.update();\n }\n public finish() {\n this.finished = true;\n this.update();\n }\n public setProgress(progress: number) {\n this.progress = progress;\n this.update();\n }\n public update() {\n this.ws.send('task-update', { id: this.id, progress: this.progress, logs: this.logs, finished: this.finished });\n }\n}\n/**\n * A search tool for the OGI Addon. This tool is used to search for items in the library. Powered by Fuse.js, bundled into OGI.\n * @example\n * ```typescript\n * const searchTool = new SearchTool<LibraryInfo>([], ['name']);\n * const results = searchTool.search('test', 10);\n * ```\n */\nexport class SearchTool<T> {\n private fuse: Fuse<T>;\n constructor(items: T[], keys: string[]) {\n this.fuse = new Fuse(items, {\n keys,\n threshold: 0.3,\n includeScore: true\n });\n }\n public search(query: string, limit: number = 10): T[] {\n return this.fuse.search(query).slice(0, limit).map(result => result.item);\n }\n public addItems(items: T[]) {\n items.map(item => this.fuse.add(item));\n }\n}\n/**\n * Library Info is the metadata for a library entry after setting up a game.\n */\nexport interface LibraryInfo {\n name: string;\n version: string;\n cwd: string;\n appID: number;\n launchExecutable: string;\n launchArguments?: string;\n capsuleImage: string;\n storefront: 'steam' | 'internal';\n addonsource: string;\n coverImage: string;\n titleImage?: string;\n}\ninterface Notification {\n type: 'warning' | 'error' | 'info' | 'success';\n message: string;\n id: string\n}\nclass OGIAddonWSListener {\n private socket: WebSocket;\n public eventEmitter: events.EventEmitter;\n public addon: OGIAddon;\n\n constructor(ogiAddon: OGIAddon, eventEmitter: events.EventEmitter) {\n if (process.argv[process.argv.length - 1].split('=')[0] !== '--addonSecret') {\n throw new Error('No secret provided. This usually happens because the addon was not started by the OGI Addon Server.');\n }\n this.addon = ogiAddon;\n this.eventEmitter = eventEmitter;\n this.socket = new ws('ws://localhost:' + defaultPort);\n this.socket.on('open', () => {\n console.log('Connected to OGI Addon Server');\n console.log('OGI Addon Server Version:', VERSION);\n\n // Authenticate with OGI Addon Server\n this.send('authenticate', {\n ...this.addon.addonInfo,\n secret: process.argv[process.argv.length - 1].split('=')[1],\n ogiVersion: VERSION\n });\n\n this.eventEmitter.emit('connect');\n\n // send a configuration request\n let configBuilder = new ConfigurationBuilder();\n this.eventEmitter.emit('configure', configBuilder);\n this.send('configure', configBuilder.build(false));\n this.addon.config = new Configuration(configBuilder.build(true));\n });\n\n this.socket.on('error', (error) => {\n if (error.message.includes('Failed to connect')) {\n throw new Error('OGI Addon Server is not running/is unreachable. Please start the server and try again.');\n }\n console.error('An error occurred:', error);\n })\n\n this.socket.on('close', (code, reason) => {\n if (code === 1008) {\n console.error('Authentication failed:', reason);\n return;\n }\n this.eventEmitter.emit('disconnect', reason);\n console.log(\"Disconnected from OGI Addon Server\")\n console.error(reason.toString())\n this.eventEmitter.emit('exit');\n this.socket.close();\n });\n\n this.registerMessageReceiver();\n }\n\n private async userInputAsked(configBuilt: ConfigurationBuilder, name: string, description: string, socket: WebSocket): Promise<{ [key: string]: number | boolean | string }> {\n const config = configBuilt.build(false);\n const id = Math.random().toString(36).substring(7);\n if (!socket) {\n return {};\n }\n socket.send(JSON.stringify({\n event: 'input-asked',\n args: {\n config,\n name,\n description\n },\n id: id\n }));\n return await this.waitForResponseFromServer(id);\n }\n\n private registerMessageReceiver() {\n this.socket.on('message', async (data: string) => {\n const message: WebsocketMessageServer = JSON.parse(data);\n switch (message.event) {\n case 'config-update':\n const result = this.addon.config.updateConfig(message.args);\n if (!result[0]) {\n this.respondToMessage(message.id!!, { success: false, error: result[1] });\n }\n else {\n this.respondToMessage(message.id!!, { success: true });\n }\n break\n case 'search':\n let searchResultEvent = new EventResponse<SearchResult[]>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n this.eventEmitter.emit('search', message.args, searchResultEvent);\n const searchResult = await this.waitForEventToRespond(searchResultEvent);\n this.respondToMessage(message.id!!, searchResult.data);\n break\n case 'setup':\n let setupEvent = new EventResponse<LibraryInfo>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n this.eventEmitter.emit('setup', { path: message.args.path, appID: message.args.appID, storefront: message.args.storefront, type: message.args.type, name: message.args.name, usedRealDebrid: message.args.usedRealDebrid, multiPartFiles: message.args.multiPartFiles }, setupEvent);\n const interval = setInterval(() => {\n if (setupEvent.resolved) {\n clearInterval(interval);\n return;\n }\n this.send('defer-update', {\n logs: setupEvent.logs,\n deferID: message.args.deferID,\n progress: setupEvent.progress\n } as any);\n }, 100);\n const setupResult = await this.waitForEventToRespond(setupEvent);\n this.respondToMessage(message.id!!, setupResult.data);\n break\n case 'library-search':\n let librarySearchEvent = new EventResponse<BasicLibraryInfo[]>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('game-details') === 0) {\n this.respondToMessage(message.id!!, []);\n break;\n }\n this.eventEmitter.emit('library-search', message.args, librarySearchEvent);\n const librarySearchResult = await this.waitForEventToRespond(librarySearchEvent);\n this.respondToMessage(message.id!!, librarySearchResult.data);\n break\n case 'game-details':\n let gameDetailsEvent = new EventResponse<StoreData>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('game-details') === 0) {\n this.respondToMessage(message.id!!, { error: 'No event listener for game-details' });\n break;\n }\n this.eventEmitter.emit('game-details', message.args, gameDetailsEvent);\n const gameDetailsResult = await this.waitForEventToRespond(gameDetailsEvent);\n this.respondToMessage(message.id!!, gameDetailsResult.data);\n break\n case 'request-dl':\n let requestDLEvent = new EventResponse<SearchResult>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('request-dl') === 0) {\n this.respondToMessage(message.id!!, { error: 'No event listener for request-dl' });\n break;\n }\n this.eventEmitter.emit('request-dl', message.args.appID, message.args.info, requestDLEvent);\n const requestDLResult = await this.waitForEventToRespond(requestDLEvent);\n if (requestDLEvent.data === null || requestDLEvent.data?.downloadType === 'request') {\n throw new Error('Request DL event did not return a valid result. Please ensure that the event does not resolve with another `request` download type.');\n }\n this.respondToMessage(message.id!!, requestDLResult.data);\n break\n }\n });\n }\n\n private waitForEventToRespond<T>(event: EventResponse<T>): Promise<EventResponse<T>> {\n // check the handlers to see if there even is any\n return new Promise((resolve, reject) => {\n const dataGet = setInterval(() => {\n if (event.resolved) {\n resolve(event);\n clearTimeout(timeout);\n }\n }, 5);\n\n const timeout = setTimeout(() => {\n if (event.deffered) {\n clearInterval(dataGet);\n const interval = setInterval(() => {\n if (event.resolved) {\n clearInterval(interval);\n resolve(event);\n }\n }, 100);\n }\n else {\n reject('Event did not respond in time');\n }\n }, 5000)\n });\n }\n\n public respondToMessage(messageID: string, response: any) {\n this.socket.send(JSON.stringify({\n event: 'response',\n id: messageID,\n args: response\n }));\n console.log(\"dispatched response to \" + messageID)\n }\n\n public waitForResponseFromServer<T>(messageID: string): Promise<T> {\n return new Promise((resolve) => {\n const waiter = (data: string) => {\n const message: WebsocketMessageClient = JSON.parse(data);\n if (message.event !== 'response') {\n this.socket.once('message', waiter);\n return;\n }\n console.log(\"received response from \" + messageID)\n\n if (message.id === messageID) {\n resolve(message.args);\n }\n else {\n this.socket.once('message', waiter);\n }\n }\n this.socket.once('message', waiter);\n });\n }\n\n public send(event: OGIAddonClientSentEvent, args: ClientSentEventTypes[OGIAddonClientSentEvent]): string {\n // generate a random id\n const id = Math.random().toString(36).substring(7);\n this.socket.send(JSON.stringify({\n event,\n args,\n id\n }));\n return id;\n }\n\n public close() {\n this.socket.close();\n }\n\n\n}\n","import z, { ZodError } from \"zod\"\n\nexport interface ConfigurationFile {\n [key: string]: ConfigurationOption\n}\n\nconst configValidation = z.object({\n name: z.string().min(1),\n displayName: z.string().min(1),\n description: z.string().min(1),\n})\n\nexport function isStringOption(option: ConfigurationOption): option is StringOption {\n return option.type === 'string';\n }\n\nexport function isNumberOption(option: ConfigurationOption): option is NumberOption {\n return option.type === 'number';\n}\n\nexport function isBooleanOption(option: ConfigurationOption): option is BooleanOption {\n return option.type === 'boolean';\n}\n\nexport class ConfigurationBuilder {\n private options: ConfigurationOption[] = [];\n\n /**\n * Add a number option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: NumberOption) => NumberOption }\n * @returns \n */\n public addNumberOption(option: (option: NumberOption) => NumberOption): ConfigurationBuilder {\n let newOption = new NumberOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a string option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: StringOption) => StringOption }\n */\n public addStringOption(option: (option: StringOption) => StringOption) {\n let newOption = new StringOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a boolean option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: BooleanOption) => BooleanOption }\n */\n public addBooleanOption(option: (option: BooleanOption) => BooleanOption) {\n let newOption = new BooleanOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n public build(includeFunctions: boolean): ConfigurationFile {\n let config: ConfigurationFile = {};\n this.options.forEach(option => {\n // remove all functions from the option object\n if (!includeFunctions) {\n option = JSON.parse(JSON.stringify(option));\n const optionData = configValidation.safeParse(option)\n if (!optionData.success) {\n throw new ZodError(optionData.error.errors)\n }\n\n config[option.name] = option;\n }\n else {\n config[option.name] = option;\n }\n });\n return config;\n }\n}\n\nexport type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset'\nexport class ConfigurationOption {\n public name: string = '';\n public defaultValue: unknown = '';\n public displayName: string = '';\n public description: string = '';\n public type: ConfigurationOptionType = 'unset'\n \n /**\n * Set the name of the option. **REQUIRED**\n * @param name {string} The name of the option. This is used to reference the option in the configuration file.\n */\n setName(name: string) {\n this.name = name;\n return this;\n }\n\n /**\n * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED** \n * @param displayName {string} The display name of the option. \n * @returns \n */\n setDisplayName(displayName: string) {\n this.displayName = displayName;\n return this;\n }\n\n /**\n * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**\n * @param description {string} The description of the option. \n * @returns \n */\n setDescription(description: string) {\n this.description = description;\n return this;\n }\n\n /**\n * Validation code for the option. This is called when the user provides input to the option. If the validation fails, the user will be prompted to provide input again.\n * @param input {unknown} The input to validate\n */\n validate(input: unknown): [ boolean, string ] {\n throw new Error('Validation code not implemented. Value: ' + input)\n };\n}\n\nexport class StringOption extends ConfigurationOption {\n public allowedValues: string[] = [];\n public minTextLength: number = 0;\n public maxTextLength: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: string = '';\n public inputType: 'text' | 'file' | 'password' | 'folder' = 'text';\n public type: ConfigurationOptionType = 'string'\n\n /**\n * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown. \n * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.\n */\n setAllowedValues(allowedValues: string[]): this {\n this.allowedValues = allowedValues;\n return this;\n }\n\n /**\n * Set the default value for the string. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {string} The default value for the string.\n */\n setDefaultValue(defaultValue: string): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail. \n * @param minTextLength {number} The minimum text length for the string. \n */\n setMinTextLength(minTextLength: number): this {\n this.minTextLength = minTextLength;\n return this;\n }\n\n /**\n * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail. \n * @param maxTextLength {number} The maximum text length for the string.\n */\n setMaxTextLength(maxTextLength: number): this {\n this.maxTextLength = maxTextLength;\n return this;\n }\n\n /**\n * Set the input type for the string. This will change how the client renders the input. \n * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string. \n */\n setInputType(inputType: 'text' | 'file' | 'password' | 'folder'): this {\n this.inputType = inputType;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'string') {\n return [ false, 'Input is not a string' ];\n }\n if (this.allowedValues.length === 0 && input.length !== 0)\n return [ true, '' ];\n if (input.length < this.minTextLength || input.length > this.maxTextLength) {\n return [ false, 'Input is not within the text length ' + this.minTextLength + ' and ' + this.maxTextLength + ' characters (currently ' + input.length + ' characters)' ];\n }\n\n return [ this.allowedValues.includes(input), 'Input is not an allowed value' ];\n }\n}\n\nexport class NumberOption extends ConfigurationOption {\n public min: number = 0;\n public max: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: number = 0;\n public type: ConfigurationOptionType = 'number'\n public inputType: 'range' | 'number' = 'number';\n\n /**\n * Set the minimum value for the number. If the user provides a number that is less than this value, the validation will fail.\n * @param min {number} The minimum value for the number.\n */\n setMin(min: number): this {\n this.min = min;\n return this;\n }\n\n /**\n * Set the input type for the number. This will change how the client renders the input. \n * @param type {'range' | 'number'} The input type for the number. \n */\n setInputType(type: 'range' | 'number'): this {\n this.inputType = type;\n return this;\n }\n\n /**\n * Set the maximum value for the number. If the user provides a number that is greater than this value, the validation will fail.\n * @param max {number} The maximum value for the number.\n */\n setMax(max: number): this {\n this.max = max;\n return this\n }\n\n /**\n * Set the default value for the number. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {number} The default value for the number.\n */\n setDefaultValue(defaultValue: number): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (isNaN(Number(input))) {\n return [ false, 'Input is not a number' ];\n }\n if (Number(input) < this.min || Number(input) > this.max) {\n return [ false, 'Input is not within the range of ' + this.min + ' and ' + this.max ];\n }\n return [ true, '' ];\n }\n\n}\n\nexport class BooleanOption extends ConfigurationOption {\n public type: ConfigurationOptionType = 'boolean'\n public defaultValue: boolean = false;\n\n /**\n * Set the default value for the boolean. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {boolean} The default value for the boolean.\n */\n setDefaultValue(defaultValue: boolean): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'boolean') {\n return [ false, 'Input is not a boolean' ];\n }\n return [ true, '' ];\n }\n\n}","import { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from \"./ConfigurationBuilder\";\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(config: DefiniteConfig, validate: boolean = true): [ boolean, { [key: string]: string } ] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [ true, {} ];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [ boolean, { [key: string]: string } ] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (this.definiteConfig[key] === null || this.definiteConfig[key] === undefined) {\n console.warn('Option ' + key + ' is not defined. Using default value Value: ' + this.definiteConfig[key]);\n this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue as string | number | boolean;\n }\n if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {\n throw new Error('Option ' + key + ' is not of the correct type');\n }\n\n const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);\n if (!result[0]) {\n erroredKeys.set(key, result[1]);\n }\n }\n\n for (const key in this.definiteConfig) {\n if (!this.storedConfigTemplate[key]) {\n throw new Error('Option ' + key + ' is not defined in the configuration template');\n }\n }\n\n if (erroredKeys.size > 0) {\n return [ false, Object.fromEntries(erroredKeys) ];\n }\n\n return [ true, Object.fromEntries(erroredKeys) ];\n }\n\n getStringValue(optionName: string): string {\n if (!this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (!this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };","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 onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>) {\n this.onInputAsked = onInputAsked;\n }\n \n\n public defer() {\n this.deffered = true;\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 /**\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(name: string, description: string, screen: ConfigurationBuilder): 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 \n}","{\n \"name\": \"ogi-addon\",\n \"module\": \"./build/main.js\",\n \"type\": \"module\",\n \"main\": \"./build/main.cjs\",\n \"version\": \"1.1.6\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"default\": \"./build/main.js\",\n \"types\": \"./build/main.d.ts\"\n },\n \"require\": {\n \"default\": \"./build/main.cjs\",\n \"types\": \"./build/main.d.cts\"\n }\n },\n \"./config\": {\n \"import\": {\n \"default\": \"./build/config/Configuration.js\",\n \"types\": \"./build/config/Configuration.d.ts\"\n },\n \"require\": {\n \"default\": \"./build/config/Configuration.cjs\",\n \"types\": \"./build/config/Configuration.d.cts\"\n }\n }\n },\n \"typings\": \"./build/main.d.ts\",\n \"author\": {\n \"name\": \"Nat3z\",\n \"email\": \"me@nat3z.com\",\n \"url\": \"https://nat3z.com/\"\n },\n \"dependencies\": {\n \"fuse.js\": \"^7.1.0\",\n \"ws\": \"^8.4.0\",\n \"zod\": \"^3.23.8\"\n },\n \"scripts\": {\n \"auto-build\": \"tsc -w\",\n \"build\": \"tsup --config tsup.config.js\",\n \"release\": \"bun run build && npm publish\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.14.12\",\n \"@types/ws\": \"^8.4.0\",\n \"tsup\": \"^8.2.3\",\n \"typescript\": \"^5.0.0\"\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA8B;AAC9B,yBAAmB;;;ACDnB,iBAA4B;AAM5B,IAAM,mBAAmB,WAAAA,QAAE,OAAO;AAAA,EAChC,MAAM,WAAAA,QAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,aAAa,WAAAA,QAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC7B,aAAa,WAAAA,QAAE,OAAO,EAAE,IAAI,CAAC;AAC/B,CAAC;AAcM,IAAM,uBAAN,MAA2B;AAAA,EACxB,UAAiC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnC,gBAAgB,QAAsE;AAC3F,QAAI,YAAY,IAAI,aAAa;AACjC,gBAAY,OAAO,SAAS;AAC5B,SAAK,QAAQ,KAAK,SAAS;AAC3B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,gBAAgB,QAAgD;AACrE,QAAI,YAAY,IAAI,aAAa;AACjC,gBAAY,OAAO,SAAS;AAC5B,SAAK,QAAQ,KAAK,SAAS;AAC3B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,iBAAiB,QAAkD;AACxE,QAAI,YAAY,IAAI,cAAc;AAClC,gBAAY,OAAO,SAAS;AAC5B,SAAK,QAAQ,KAAK,SAAS;AAC3B,WAAO;AAAA,EACT;AAAA,EAEO,MAAM,kBAA8C;AACzD,QAAI,SAA4B,CAAC;AACjC,SA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version":3,"sources":["../src/main.ts","../src/config/ConfigurationBuilder.ts","../src/config/Configuration.ts","../src/EventResponse.ts","../package.json"],"sourcesContent":["import ws, { WebSocket } from 'ws';\nimport events from 'node:events';\nimport { ConfigurationBuilder, ConfigurationFile } from './config/ConfigurationBuilder';\nimport { Configuration } from './config/Configuration';\nimport EventResponse from './EventResponse';\nimport { SearchResult } from './SearchEngine';\nimport Fuse, { IFuseOptions } from 'fuse.js';\n\nexport type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'request-dl';\nexport type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'steam-search' | 'task-update';\n\nexport type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup' | 'response' | 'library-search' | 'game-details' | 'request-dl';\nexport { ConfigurationBuilder, Configuration, EventResponse, SearchResult };\nconst defaultPort = 7654;\nimport pjson from '../package.json';\nexport const VERSION = pjson.version;\n\nexport interface ClientSentEventTypes {\n response: any;\n authenticate: {\n name: string;\n id: string;\n description: string;\n version: string;\n author: string;\n };\n configure: ConfigurationFile;\n 'defer-update': {\n logs: string[],\n progress: number\n };\n notification: Notification;\n 'input-asked': ConfigurationBuilder;\n 'steam-search': {\n query: string;\n strict: boolean;\n };\n 'task-update': {\n id: string;\n progress: number;\n logs: string[];\n finished: boolean;\n };\n}\n\nexport type BasicLibraryInfo = {\n name: string;\n capsuleImage: string;\n appID: number;\n}\n\nexport interface EventListenerTypes {\n /**\n * This event is emitted when the addon connects to the OGI Addon Server. Addon does not need to resolve anything.\n * @param socket \n * @returns \n */\n connect: (socket: ws) => void;\n\n /**\n * 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.\n * @param reason \n * @returns \n */\n disconnect: (reason: string) => void;\n /**\n * 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) \n * @param config \n * @returns \n */\n configure: (config: ConfigurationBuilder) => ConfigurationBuilder;\n /**\n * This event is called when the client provides a response to any event. This should be treated as middleware. \n * @param response \n * @returns \n */\n response: (response: any) => void;\n\n /**\n * This event is called when the client requests for the addon to authenticate itself. You don't need to provide any info. \n * @param config \n * @returns \n */\n authenticate: (config: any) => void;\n /**\n * 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) \n * @param query \n * @param event \n * @returns \n */\n search: (query: { type: 'steamapp' | 'internal', text: string }, event: EventResponse<SearchResult[]>) => void;\n /**\n * 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)\n * @param data \n * @param event \n * @returns \n */\n setup: (\n data: {\n path: string,\n type: 'direct' | 'torrent' | 'magnet',\n name: string,\n usedRealDebrid: boolean,\n multiPartFiles?: {\n name: string,\n downloadURL: string\n }[],\n appID: number,\n storefront: 'steam' | 'internal'\n }, event: EventResponse<LibraryInfo>\n ) => void;\n\n /**\n * This event is emitted when the client requires for a search to be performed. Input is the search query. \n * @param query \n * @param event \n * @returns \n */\n 'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;\n 'game-details': (appID: number, event: EventResponse<StoreData>) => void;\n exit: () => void;\n 'request-dl': (appID: number, info: SearchResult, event: EventResponse<SearchResult>) => void;\n}\n\nexport interface StoreData {\n name: string;\n publishers: string[];\n developers: string[];\n appID: number;\n releaseDate: string;\n capsuleImage: string;\n coverImage: string;\n basicDescription: string;\n description: string;\n headerImage: string;\n}\nexport interface WebsocketMessageClient {\n event: OGIAddonClientSentEvent;\n id?: string;\n args: any;\n}\nexport interface WebsocketMessageServer {\n event: OGIAddonServerSentEvent;\n id?: string;\n args: any;\n}\nexport interface OGIAddonConfiguration {\n name: string;\n id: string;\n description: string;\n version: string;\n\n author: string;\n repository: string;\n}\n\n/**\n * 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.\n * @example \n * ```typescript\n * const addon = new OGIAddon({\n * name: 'Test Addon',\n* id: 'test-addon',\n * description: 'A test addon',\n * version: '1.0.0',\n * author: 'OGI Developers',\n * repository: ''\n * });\n * ```\n * \n */\nexport default class OGIAddon {\n public eventEmitter = new events.EventEmitter();\n public addonWSListener: OGIAddonWSListener;\n public addonInfo: OGIAddonConfiguration;\n public config: Configuration = new Configuration({});\n\n constructor(addonInfo: OGIAddonConfiguration) {\n this.addonInfo = addonInfo;\n this.addonWSListener = new OGIAddonWSListener(this, this.eventEmitter);\n }\n\n /**\n * Register an event listener for the addon. (See EventListenerTypes) \n * @param event {OGIAddonEvent}\n * @param listener {EventListenerTypes[OGIAddonEvent]} \n */\n public on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]) {\n this.eventEmitter.on(event, listener);\n }\n\n public emit<T extends OGIAddonEvent>(event: T, ...args: Parameters<EventListenerTypes[T]>) {\n this.eventEmitter.emit(event, ...args);\n }\n\n /**\n * Notify the client using a notification. Provide the type of notification, the message, and an ID. \n * @param notification {Notification}\n */\n public notify(notification: Notification) {\n this.addonWSListener.send('notification', [notification]);\n }\n\n /**\n * Search for items in the OGI Steam-Synced Library. Query can either be a Steam AppID or a Steam Game Name.\n * @param query {string}\n * @param event {EventResponse<BasicLibraryInfo[]>}\n */\n public async steamSearch(query: string, strict: boolean = false) {\n const id = this.addonWSListener.send('steam-search', { query, strict });\n return await this.addonWSListener.waitForResponseFromServer<Omit<BasicLibraryInfo, 'capsuleImage'>[]>(id);\n }\n\n /**\n * 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.\n * @param id {string}\n * @param progress {number}\n * @param logs {string[]}\n */\n public async task() {\n const id = Math.random().toString(36).substring(7);\n const progress = 0;\n const logs: string[] = [];\n const task = new CustomTask(this.addonWSListener, id, progress, logs);\n this.addonWSListener.send('task-update', { id, progress, logs, finished: false });\n return task;\n }\n}\n\nexport class CustomTask {\n public readonly id: string;\n public progress: number;\n public logs: string[];\n public finished: boolean = false;\n public ws: OGIAddonWSListener;\n constructor(ws: OGIAddonWSListener, id: string, progress: number, logs: string[]) {\n this.id = id;\n this.progress = progress;\n this.logs = logs;\n this.ws = ws;\n }\n public log(log: string) {\n this.logs.push(log);\n this.update();\n }\n public finish() {\n this.finished = true;\n this.update();\n }\n public setProgress(progress: number) {\n this.progress = progress;\n this.update();\n }\n public update() {\n this.ws.send('task-update', { id: this.id, progress: this.progress, logs: this.logs, finished: this.finished });\n }\n}\n/**\n * A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.\n * @example\n * ```typescript\n * const searchTool = new SearchTool<LibraryInfo>([{ name: 'test', appID: 123 }, { name: 'test2', appID: 124 }], ['name']);\n * const results = searchTool.search('test', 10);\n * ```\n */\nexport class SearchTool<T> {\n private fuse: Fuse<T>;\n constructor(items: T[], keys: string[], options: Omit<IFuseOptions<T>, 'keys'> = { threshold: 0.3, includeScore: true }) {\n this.fuse = new Fuse(items, {\n keys,\n ...options\n });\n }\n public search(query: string, limit: number = 10): T[] {\n return this.fuse.search(query).slice(0, limit).map(result => result.item);\n }\n public addItems(items: T[]) {\n items.map(item => this.fuse.add(item));\n }\n}\n/**\n * Library Info is the metadata for a library entry after setting up a game.\n */\nexport interface LibraryInfo {\n name: string;\n version: string;\n cwd: string;\n appID: number;\n launchExecutable: string;\n launchArguments?: string;\n capsuleImage: string;\n storefront: 'steam' | 'internal';\n addonsource: string;\n coverImage: string;\n titleImage?: string;\n}\ninterface Notification {\n type: 'warning' | 'error' | 'info' | 'success';\n message: string;\n id: string\n}\nclass OGIAddonWSListener {\n private socket: WebSocket;\n public eventEmitter: events.EventEmitter;\n public addon: OGIAddon;\n\n constructor(ogiAddon: OGIAddon, eventEmitter: events.EventEmitter) {\n if (process.argv[process.argv.length - 1].split('=')[0] !== '--addonSecret') {\n throw new Error('No secret provided. This usually happens because the addon was not started by the OGI Addon Server.');\n }\n this.addon = ogiAddon;\n this.eventEmitter = eventEmitter;\n this.socket = new ws('ws://localhost:' + defaultPort);\n this.socket.on('open', () => {\n console.log('Connected to OGI Addon Server');\n console.log('OGI Addon Server Version:', VERSION);\n\n // Authenticate with OGI Addon Server\n this.send('authenticate', {\n ...this.addon.addonInfo,\n secret: process.argv[process.argv.length - 1].split('=')[1],\n ogiVersion: VERSION\n });\n\n this.eventEmitter.emit('connect');\n\n // send a configuration request\n let configBuilder = new ConfigurationBuilder();\n this.eventEmitter.emit('configure', configBuilder);\n this.send('configure', configBuilder.build(false));\n this.addon.config = new Configuration(configBuilder.build(true));\n });\n\n this.socket.on('error', (error) => {\n if (error.message.includes('Failed to connect')) {\n throw new Error('OGI Addon Server is not running/is unreachable. Please start the server and try again.');\n }\n console.error('An error occurred:', error);\n })\n\n this.socket.on('close', (code, reason) => {\n if (code === 1008) {\n console.error('Authentication failed:', reason);\n return;\n }\n this.eventEmitter.emit('disconnect', reason);\n console.log(\"Disconnected from OGI Addon Server\")\n console.error(reason.toString())\n this.eventEmitter.emit('exit');\n this.socket.close();\n });\n\n this.registerMessageReceiver();\n }\n\n private async userInputAsked(configBuilt: ConfigurationBuilder, name: string, description: string, socket: WebSocket): Promise<{ [key: string]: number | boolean | string }> {\n const config = configBuilt.build(false);\n const id = Math.random().toString(36).substring(7);\n if (!socket) {\n return {};\n }\n socket.send(JSON.stringify({\n event: 'input-asked',\n args: {\n config,\n name,\n description\n },\n id: id\n }));\n return await this.waitForResponseFromServer(id);\n }\n\n private registerMessageReceiver() {\n this.socket.on('message', async (data: string) => {\n const message: WebsocketMessageServer = JSON.parse(data);\n switch (message.event) {\n case 'config-update':\n const result = this.addon.config.updateConfig(message.args);\n if (!result[0]) {\n this.respondToMessage(message.id!!, { success: false, error: result[1] });\n }\n else {\n this.respondToMessage(message.id!!, { success: true });\n }\n break\n case 'search':\n let searchResultEvent = new EventResponse<SearchResult[]>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n this.eventEmitter.emit('search', message.args, searchResultEvent);\n const searchResult = await this.waitForEventToRespond(searchResultEvent);\n this.respondToMessage(message.id!!, searchResult.data);\n break\n case 'setup':\n let setupEvent = new EventResponse<LibraryInfo>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n this.eventEmitter.emit('setup', { path: message.args.path, appID: message.args.appID, storefront: message.args.storefront, type: message.args.type, name: message.args.name, usedRealDebrid: message.args.usedRealDebrid, multiPartFiles: message.args.multiPartFiles }, setupEvent);\n const interval = setInterval(() => {\n if (setupEvent.resolved) {\n clearInterval(interval);\n return;\n }\n this.send('defer-update', {\n logs: setupEvent.logs,\n deferID: message.args.deferID,\n progress: setupEvent.progress\n } as any);\n }, 100);\n const setupResult = await this.waitForEventToRespond(setupEvent);\n this.respondToMessage(message.id!!, setupResult.data);\n break\n case 'library-search':\n let librarySearchEvent = new EventResponse<BasicLibraryInfo[]>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('game-details') === 0) {\n this.respondToMessage(message.id!!, []);\n break;\n }\n this.eventEmitter.emit('library-search', message.args, librarySearchEvent);\n const librarySearchResult = await this.waitForEventToRespond(librarySearchEvent);\n this.respondToMessage(message.id!!, librarySearchResult.data);\n break\n case 'game-details':\n let gameDetailsEvent = new EventResponse<StoreData>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('game-details') === 0) {\n this.respondToMessage(message.id!!, { error: 'No event listener for game-details' });\n break;\n }\n this.eventEmitter.emit('game-details', message.args, gameDetailsEvent);\n const gameDetailsResult = await this.waitForEventToRespond(gameDetailsEvent);\n this.respondToMessage(message.id!!, gameDetailsResult.data);\n break\n case 'request-dl':\n let requestDLEvent = new EventResponse<SearchResult>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('request-dl') === 0) {\n this.respondToMessage(message.id!!, { error: 'No event listener for request-dl' });\n break;\n }\n this.eventEmitter.emit('request-dl', message.args.appID, message.args.info, requestDLEvent);\n const requestDLResult = await this.waitForEventToRespond(requestDLEvent);\n if (requestDLEvent.data === null || requestDLEvent.data?.downloadType === 'request') {\n throw new Error('Request DL event did not return a valid result. Please ensure that the event does not resolve with another `request` download type.');\n }\n this.respondToMessage(message.id!!, requestDLResult.data);\n break\n }\n });\n }\n\n private waitForEventToRespond<T>(event: EventResponse<T>): Promise<EventResponse<T>> {\n // check the handlers to see if there even is any\n return new Promise((resolve, reject) => {\n const dataGet = setInterval(() => {\n if (event.resolved) {\n resolve(event);\n clearTimeout(timeout);\n }\n }, 5);\n\n const timeout = setTimeout(() => {\n if (event.deffered) {\n clearInterval(dataGet);\n const interval = setInterval(() => {\n if (event.resolved) {\n clearInterval(interval);\n resolve(event);\n }\n }, 100);\n }\n else {\n reject('Event did not respond in time');\n }\n }, 5000)\n });\n }\n\n public respondToMessage(messageID: string, response: any) {\n this.socket.send(JSON.stringify({\n event: 'response',\n id: messageID,\n args: response\n }));\n console.log(\"dispatched response to \" + messageID)\n }\n\n public waitForResponseFromServer<T>(messageID: string): Promise<T> {\n return new Promise((resolve) => {\n const waiter = (data: string) => {\n const message: WebsocketMessageClient = JSON.parse(data);\n if (message.event !== 'response') {\n this.socket.once('message', waiter);\n return;\n }\n console.log(\"received response from \" + messageID)\n\n if (message.id === messageID) {\n resolve(message.args);\n }\n else {\n this.socket.once('message', waiter);\n }\n }\n this.socket.once('message', waiter);\n });\n }\n\n public send(event: OGIAddonClientSentEvent, args: ClientSentEventTypes[OGIAddonClientSentEvent]): string {\n // generate a random id\n const id = Math.random().toString(36).substring(7);\n this.socket.send(JSON.stringify({\n event,\n args,\n id\n }));\n return id;\n }\n\n public close() {\n this.socket.close();\n }\n\n\n}\n","import z, { ZodError } from \"zod\"\n\nexport interface ConfigurationFile {\n [key: string]: ConfigurationOption\n}\n\nconst configValidation = z.object({\n name: z.string().min(1),\n displayName: z.string().min(1),\n description: z.string().min(1),\n})\n\nexport function isStringOption(option: ConfigurationOption): option is StringOption {\n return option.type === 'string';\n }\n\nexport function isNumberOption(option: ConfigurationOption): option is NumberOption {\n return option.type === 'number';\n}\n\nexport function isBooleanOption(option: ConfigurationOption): option is BooleanOption {\n return option.type === 'boolean';\n}\n\nexport class ConfigurationBuilder {\n private options: ConfigurationOption[] = [];\n\n /**\n * Add a number option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: NumberOption) => NumberOption }\n * @returns \n */\n public addNumberOption(option: (option: NumberOption) => NumberOption): ConfigurationBuilder {\n let newOption = new NumberOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a string option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: StringOption) => StringOption }\n */\n public addStringOption(option: (option: StringOption) => StringOption) {\n let newOption = new StringOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a boolean option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: BooleanOption) => BooleanOption }\n */\n public addBooleanOption(option: (option: BooleanOption) => BooleanOption) {\n let newOption = new BooleanOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n public build(includeFunctions: boolean): ConfigurationFile {\n let config: ConfigurationFile = {};\n this.options.forEach(option => {\n // remove all functions from the option object\n if (!includeFunctions) {\n option = JSON.parse(JSON.stringify(option));\n const optionData = configValidation.safeParse(option)\n if (!optionData.success) {\n throw new ZodError(optionData.error.errors)\n }\n\n config[option.name] = option;\n }\n else {\n config[option.name] = option;\n }\n });\n return config;\n }\n}\n\nexport type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset'\nexport class ConfigurationOption {\n public name: string = '';\n public defaultValue: unknown = '';\n public displayName: string = '';\n public description: string = '';\n public type: ConfigurationOptionType = 'unset'\n \n /**\n * Set the name of the option. **REQUIRED**\n * @param name {string} The name of the option. This is used to reference the option in the configuration file.\n */\n setName(name: string) {\n this.name = name;\n return this;\n }\n\n /**\n * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED** \n * @param displayName {string} The display name of the option. \n * @returns \n */\n setDisplayName(displayName: string) {\n this.displayName = displayName;\n return this;\n }\n\n /**\n * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**\n * @param description {string} The description of the option. \n * @returns \n */\n setDescription(description: string) {\n this.description = description;\n return this;\n }\n\n /**\n * Validation code for the option. This is called when the user provides input to the option. If the validation fails, the user will be prompted to provide input again.\n * @param input {unknown} The input to validate\n */\n validate(input: unknown): [ boolean, string ] {\n throw new Error('Validation code not implemented. Value: ' + input)\n };\n}\n\nexport class StringOption extends ConfigurationOption {\n public allowedValues: string[] = [];\n public minTextLength: number = 0;\n public maxTextLength: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: string = '';\n public inputType: 'text' | 'file' | 'password' | 'folder' = 'text';\n public type: ConfigurationOptionType = 'string'\n\n /**\n * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown. \n * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.\n */\n setAllowedValues(allowedValues: string[]): this {\n this.allowedValues = allowedValues;\n return this;\n }\n\n /**\n * Set the default value for the string. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {string} The default value for the string.\n */\n setDefaultValue(defaultValue: string): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail. \n * @param minTextLength {number} The minimum text length for the string. \n */\n setMinTextLength(minTextLength: number): this {\n this.minTextLength = minTextLength;\n return this;\n }\n\n /**\n * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail. \n * @param maxTextLength {number} The maximum text length for the string.\n */\n setMaxTextLength(maxTextLength: number): this {\n this.maxTextLength = maxTextLength;\n return this;\n }\n\n /**\n * Set the input type for the string. This will change how the client renders the input. \n * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string. \n */\n setInputType(inputType: 'text' | 'file' | 'password' | 'folder'): this {\n this.inputType = inputType;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'string') {\n return [ false, 'Input is not a string' ];\n }\n if (this.allowedValues.length === 0 && input.length !== 0)\n return [ true, '' ];\n if (input.length < this.minTextLength || input.length > this.maxTextLength) {\n return [ false, 'Input is not within the text length ' + this.minTextLength + ' and ' + this.maxTextLength + ' characters (currently ' + input.length + ' characters)' ];\n }\n\n return [ this.allowedValues.includes(input), 'Input is not an allowed value' ];\n }\n}\n\nexport class NumberOption extends ConfigurationOption {\n public min: number = 0;\n public max: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: number = 0;\n public type: ConfigurationOptionType = 'number'\n public inputType: 'range' | 'number' = 'number';\n\n /**\n * Set the minimum value for the number. If the user provides a number that is less than this value, the validation will fail.\n * @param min {number} The minimum value for the number.\n */\n setMin(min: number): this {\n this.min = min;\n return this;\n }\n\n /**\n * Set the input type for the number. This will change how the client renders the input. \n * @param type {'range' | 'number'} The input type for the number. \n */\n setInputType(type: 'range' | 'number'): this {\n this.inputType = type;\n return this;\n }\n\n /**\n * Set the maximum value for the number. If the user provides a number that is greater than this value, the validation will fail.\n * @param max {number} The maximum value for the number.\n */\n setMax(max: number): this {\n this.max = max;\n return this\n }\n\n /**\n * Set the default value for the number. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {number} The default value for the number.\n */\n setDefaultValue(defaultValue: number): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (isNaN(Number(input))) {\n return [ false, 'Input is not a number' ];\n }\n if (Number(input) < this.min || Number(input) > this.max) {\n return [ false, 'Input is not within the range of ' + this.min + ' and ' + this.max ];\n }\n return [ true, '' ];\n }\n\n}\n\nexport class BooleanOption extends ConfigurationOption {\n public type: ConfigurationOptionType = 'boolean'\n public defaultValue: boolean = false;\n\n /**\n * Set the default value for the boolean. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {boolean} The default value for the boolean.\n */\n setDefaultValue(defaultValue: boolean): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'boolean') {\n return [ false, 'Input is not a boolean' ];\n }\n return [ true, '' ];\n }\n\n}","import { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from \"./ConfigurationBuilder\";\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(config: DefiniteConfig, validate: boolean = true): [ boolean, { [key: string]: string } ] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [ true, {} ];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [ boolean, { [key: string]: string } ] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (this.definiteConfig[key] === null || this.definiteConfig[key] === undefined) {\n console.warn('Option ' + key + ' is not defined. Using default value Value: ' + this.definiteConfig[key]);\n this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue as string | number | boolean;\n }\n if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {\n throw new Error('Option ' + key + ' is not of the correct type');\n }\n\n const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);\n if (!result[0]) {\n erroredKeys.set(key, result[1]);\n }\n }\n\n for (const key in this.definiteConfig) {\n if (!this.storedConfigTemplate[key]) {\n throw new Error('Option ' + key + ' is not defined in the configuration template');\n }\n }\n\n if (erroredKeys.size > 0) {\n return [ false, Object.fromEntries(erroredKeys) ];\n }\n\n return [ true, Object.fromEntries(erroredKeys) ];\n }\n\n getStringValue(optionName: string): string {\n if (!this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (!this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };","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 onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>) {\n this.onInputAsked = onInputAsked;\n }\n \n\n public defer() {\n this.deffered = true;\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 /**\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(name: string, description: string, screen: ConfigurationBuilder): 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 \n}","{\n \"name\": \"ogi-addon\",\n \"module\": \"./build/main.js\",\n \"type\": \"module\",\n \"main\": \"./build/main.cjs\",\n \"version\": \"1.2.0\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"default\": \"./build/main.js\",\n \"types\": \"./build/main.d.ts\"\n },\n \"require\": {\n \"default\": \"./build/main.cjs\",\n \"types\": \"./build/main.d.cts\"\n }\n },\n \"./config\": {\n \"import\": {\n \"default\": \"./build/config/Configuration.js\",\n \"types\": \"./build/config/Configuration.d.ts\"\n },\n \"require\": {\n \"default\": \"./build/config/Configuration.cjs\",\n \"types\": \"./build/config/Configuration.d.cts\"\n }\n }\n },\n \"typings\": \"./build/main.d.ts\",\n \"author\": {\n \"name\": \"Nat3z\",\n \"email\": \"me@nat3z.com\",\n \"url\": \"https://nat3z.com/\"\n },\n \"dependencies\": {\n \"fuse.js\": \"^7.1.0\",\n \"ws\": \"^8.4.0\",\n \"zod\": \"^3.23.8\"\n },\n \"scripts\": {\n \"auto-build\": \"tsc -w\",\n \"build\": \"tsup --config tsup.config.js\",\n \"release\": \"bun run build && npm publish\",\n \"release-beta\": \"bun run build && npm publish --tag future\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.14.12\",\n \"@types/ws\": \"^8.4.0\",\n \"tsup\": \"^8.2.3\",\n \"typescript\": \"^5.0.0\"\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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H;AAAA,EAEO,iBAAiB,WAAmB,UAAe;AACxD,SAAK,OAAO,KAAK,KAAK,UAAU;AAAA,MAC9B,OAAO;AAAA,MACP,IAAI;AAAA,MACJ,MAAM;AAAA,IACR,CAAC,CAAC;AACF,YAAQ,IAAI,4BAA4B,SAAS;AAAA,EACnD;AAAA,EAEO,0BAA6B,WAA+B;AACjE,WAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,YAAM,SAAS,CAAC,SAAiB;AAC/B,cAAM,UAAkC,KAAK,MAAM,IAAI;AACvD,YAAI,QAAQ,UAAU,YAAY;AAChC,eAAK,OAAO,KAAK,WAAW,MAAM;AAClC;AAAA,QACF;AACA,gBAAQ,IAAI,4BAA4B,SAAS;AAEjD,YAAI,QAAQ,OAAO,WAAW;AAC5B,kBAAQ,QAAQ,IAAI;AAAA,QACtB,OACK;AACH,eAAK,OAAO,KAAK,WAAW,MAAM;AAAA,QACpC;AAAA,MACF;AACA,WAAK,OAAO,KAAK,WAAW,MAAM;AAAA,IACpC,CAAC;AAAA,EACH;AAAA,EAEO,KAAK,OAAgC,MAA6D;AAEvG,UAAM,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC;AACjD,SAAK,OAAO,KAAK,KAAK,UAAU;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,CAAC;AACF,WAAO;AAAA,EACT;AAAA,EAEO,QAAQ;AACb,SAAK,OAAO,MAAM;AAAA,EACpB;AAGF;","names":["z","events","ws","Fuse"]}
package/build/main.d.cts CHANGED
@@ -4,6 +4,7 @@ import { ConfigurationFile, ConfigurationBuilder } from './config/ConfigurationB
4
4
  import { Configuration } from './config/Configuration.cjs';
5
5
  import EventResponse from './EventResponse.cjs';
6
6
  import { SearchResult } from './SearchEngine.cjs';
7
+ import { IFuseOptions } from 'fuse.js';
7
8
 
8
9
  type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'request-dl';
9
10
  type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'steam-search' | 'task-update';
@@ -202,16 +203,16 @@ declare class CustomTask {
202
203
  update(): void;
203
204
  }
204
205
  /**
205
- * A search tool for the OGI Addon. This tool is used to search for items in the library. Powered by Fuse.js, bundled into OGI.
206
+ * A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.
206
207
  * @example
207
208
  * ```typescript
208
- * const searchTool = new SearchTool<LibraryInfo>([], ['name']);
209
+ * const searchTool = new SearchTool<LibraryInfo>([{ name: 'test', appID: 123 }, { name: 'test2', appID: 124 }], ['name']);
209
210
  * const results = searchTool.search('test', 10);
210
211
  * ```
211
212
  */
212
213
  declare class SearchTool<T> {
213
214
  private fuse;
214
- constructor(items: T[], keys: string[]);
215
+ constructor(items: T[], keys: string[], options?: Omit<IFuseOptions<T>, 'keys'>);
215
216
  search(query: string, limit?: number): T[];
216
217
  addItems(items: T[]): void;
217
218
  }
package/build/main.d.ts CHANGED
@@ -4,6 +4,7 @@ import { ConfigurationFile, ConfigurationBuilder } from './config/ConfigurationB
4
4
  import { Configuration } from './config/Configuration.js';
5
5
  import EventResponse from './EventResponse.js';
6
6
  import { SearchResult } from './SearchEngine.js';
7
+ import { IFuseOptions } from 'fuse.js';
7
8
 
8
9
  type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'request-dl';
9
10
  type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'steam-search' | 'task-update';
@@ -202,16 +203,16 @@ declare class CustomTask {
202
203
  update(): void;
203
204
  }
204
205
  /**
205
- * A search tool for the OGI Addon. This tool is used to search for items in the library. Powered by Fuse.js, bundled into OGI.
206
+ * A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.
206
207
  * @example
207
208
  * ```typescript
208
- * const searchTool = new SearchTool<LibraryInfo>([], ['name']);
209
+ * const searchTool = new SearchTool<LibraryInfo>([{ name: 'test', appID: 123 }, { name: 'test2', appID: 124 }], ['name']);
209
210
  * const results = searchTool.search('test', 10);
210
211
  * ```
211
212
  */
212
213
  declare class SearchTool<T> {
213
214
  private fuse;
214
- constructor(items: T[], keys: string[]);
215
+ constructor(items: T[], keys: string[], options?: Omit<IFuseOptions<T>, 'keys'>);
215
216
  search(query: string, limit?: number): T[];
216
217
  addItems(items: T[]): void;
217
218
  }
package/build/main.js CHANGED
@@ -355,7 +355,7 @@ var package_default = {
355
355
  module: "./build/main.js",
356
356
  type: "module",
357
357
  main: "./build/main.cjs",
358
- version: "1.1.6",
358
+ version: "1.2.0",
359
359
  exports: {
360
360
  ".": {
361
361
  import: {
@@ -392,7 +392,8 @@ var package_default = {
392
392
  scripts: {
393
393
  "auto-build": "tsc -w",
394
394
  build: "tsup --config tsup.config.js",
395
- release: "bun run build && npm publish"
395
+ release: "bun run build && npm publish",
396
+ "release-beta": "bun run build && npm publish --tag future"
396
397
  },
397
398
  devDependencies: {
398
399
  "@types/node": "^20.14.12",
@@ -486,11 +487,10 @@ var CustomTask = class {
486
487
  };
487
488
  var SearchTool = class {
488
489
  fuse;
489
- constructor(items, keys) {
490
+ constructor(items, keys, options = { threshold: 0.3, includeScore: true }) {
490
491
  this.fuse = new Fuse(items, {
491
492
  keys,
492
- threshold: 0.3,
493
- includeScore: true
493
+ ...options
494
494
  });
495
495
  }
496
496
  search(query, limit = 10) {
package/build/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.ts","../src/config/ConfigurationBuilder.ts","../src/config/Configuration.ts","../src/EventResponse.ts","../package.json"],"sourcesContent":["import ws, { WebSocket } from 'ws';\nimport events from 'node:events';\nimport { ConfigurationBuilder, ConfigurationFile } from './config/ConfigurationBuilder';\nimport { Configuration } from './config/Configuration';\nimport EventResponse from './EventResponse';\nimport { SearchResult } from './SearchEngine';\nimport Fuse from 'fuse.js';\n\nexport type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'request-dl';\nexport type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'steam-search' | 'task-update';\n\nexport type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup' | 'response' | 'library-search' | 'game-details' | 'request-dl';\nexport { ConfigurationBuilder, Configuration, EventResponse, SearchResult };\nconst defaultPort = 7654;\nimport pjson from '../package.json';\nexport const VERSION = pjson.version;\n\nexport interface ClientSentEventTypes {\n response: any;\n authenticate: {\n name: string;\n id: string;\n description: string;\n version: string;\n author: string;\n };\n configure: ConfigurationFile;\n 'defer-update': {\n logs: string[],\n progress: number\n };\n notification: Notification;\n 'input-asked': ConfigurationBuilder;\n 'steam-search': {\n query: string;\n strict: boolean;\n };\n 'task-update': {\n id: string;\n progress: number;\n logs: string[];\n finished: boolean;\n };\n}\n\nexport type BasicLibraryInfo = {\n name: string;\n capsuleImage: string;\n appID: number;\n}\n\nexport interface EventListenerTypes {\n /**\n * This event is emitted when the addon connects to the OGI Addon Server. Addon does not need to resolve anything.\n * @param socket \n * @returns \n */\n connect: (socket: ws) => void;\n\n /**\n * 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.\n * @param reason \n * @returns \n */\n disconnect: (reason: string) => void;\n /**\n * 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) \n * @param config \n * @returns \n */\n configure: (config: ConfigurationBuilder) => ConfigurationBuilder;\n /**\n * This event is called when the client provides a response to any event. This should be treated as middleware. \n * @param response \n * @returns \n */\n response: (response: any) => void;\n\n /**\n * This event is called when the client requests for the addon to authenticate itself. You don't need to provide any info. \n * @param config \n * @returns \n */\n authenticate: (config: any) => void;\n /**\n * 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) \n * @param query \n * @param event \n * @returns \n */\n search: (query: { type: 'steamapp' | 'internal', text: string }, event: EventResponse<SearchResult[]>) => void;\n /**\n * 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)\n * @param data \n * @param event \n * @returns \n */\n setup: (\n data: {\n path: string,\n type: 'direct' | 'torrent' | 'magnet',\n name: string,\n usedRealDebrid: boolean,\n multiPartFiles?: {\n name: string,\n downloadURL: string\n }[],\n appID: number,\n storefront: 'steam' | 'internal'\n }, event: EventResponse<LibraryInfo>\n ) => void;\n\n /**\n * This event is emitted when the client requires for a search to be performed. Input is the search query. \n * @param query \n * @param event \n * @returns \n */\n 'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;\n 'game-details': (appID: number, event: EventResponse<StoreData>) => void;\n exit: () => void;\n 'request-dl': (appID: number, info: SearchResult, event: EventResponse<SearchResult>) => void;\n}\n\nexport interface StoreData {\n name: string;\n publishers: string[];\n developers: string[];\n appID: number;\n releaseDate: string;\n capsuleImage: string;\n coverImage: string;\n basicDescription: string;\n description: string;\n headerImage: string;\n}\nexport interface WebsocketMessageClient {\n event: OGIAddonClientSentEvent;\n id?: string;\n args: any;\n}\nexport interface WebsocketMessageServer {\n event: OGIAddonServerSentEvent;\n id?: string;\n args: any;\n}\nexport interface OGIAddonConfiguration {\n name: string;\n id: string;\n description: string;\n version: string;\n\n author: string;\n repository: string;\n}\n\n/**\n * 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.\n * @example \n * ```typescript\n * const addon = new OGIAddon({\n * name: 'Test Addon',\n* id: 'test-addon',\n * description: 'A test addon',\n * version: '1.0.0',\n * author: 'OGI Developers',\n * repository: ''\n * });\n * ```\n * \n */\nexport default class OGIAddon {\n public eventEmitter = new events.EventEmitter();\n public addonWSListener: OGIAddonWSListener;\n public addonInfo: OGIAddonConfiguration;\n public config: Configuration = new Configuration({});\n\n constructor(addonInfo: OGIAddonConfiguration) {\n this.addonInfo = addonInfo;\n this.addonWSListener = new OGIAddonWSListener(this, this.eventEmitter);\n }\n\n /**\n * Register an event listener for the addon. (See EventListenerTypes) \n * @param event {OGIAddonEvent}\n * @param listener {EventListenerTypes[OGIAddonEvent]} \n */\n public on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]) {\n this.eventEmitter.on(event, listener);\n }\n\n public emit<T extends OGIAddonEvent>(event: T, ...args: Parameters<EventListenerTypes[T]>) {\n this.eventEmitter.emit(event, ...args);\n }\n\n /**\n * Notify the client using a notification. Provide the type of notification, the message, and an ID. \n * @param notification {Notification}\n */\n public notify(notification: Notification) {\n this.addonWSListener.send('notification', [notification]);\n }\n\n /**\n * Search for items in the OGI Steam-Synced Library. Query can either be a Steam AppID or a Steam Game Name.\n * @param query {string}\n * @param event {EventResponse<BasicLibraryInfo[]>}\n */\n public async steamSearch(query: string, strict: boolean = false) {\n const id = this.addonWSListener.send('steam-search', { query, strict });\n return await this.addonWSListener.waitForResponseFromServer<Omit<BasicLibraryInfo, 'capsuleImage'>[]>(id);\n }\n\n /**\n * 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.\n * @param id {string}\n * @param progress {number}\n * @param logs {string[]}\n */\n public async task() {\n const id = Math.random().toString(36).substring(7);\n const progress = 0;\n const logs: string[] = [];\n const task = new CustomTask(this.addonWSListener, id, progress, logs);\n this.addonWSListener.send('task-update', { id, progress, logs, finished: false });\n return task;\n }\n}\n\nexport class CustomTask {\n public readonly id: string;\n public progress: number;\n public logs: string[];\n public finished: boolean = false;\n public ws: OGIAddonWSListener;\n constructor(ws: OGIAddonWSListener, id: string, progress: number, logs: string[]) {\n this.id = id;\n this.progress = progress;\n this.logs = logs;\n this.ws = ws;\n }\n public log(log: string) {\n this.logs.push(log);\n this.update();\n }\n public finish() {\n this.finished = true;\n this.update();\n }\n public setProgress(progress: number) {\n this.progress = progress;\n this.update();\n }\n public update() {\n this.ws.send('task-update', { id: this.id, progress: this.progress, logs: this.logs, finished: this.finished });\n }\n}\n/**\n * A search tool for the OGI Addon. This tool is used to search for items in the library. Powered by Fuse.js, bundled into OGI.\n * @example\n * ```typescript\n * const searchTool = new SearchTool<LibraryInfo>([], ['name']);\n * const results = searchTool.search('test', 10);\n * ```\n */\nexport class SearchTool<T> {\n private fuse: Fuse<T>;\n constructor(items: T[], keys: string[]) {\n this.fuse = new Fuse(items, {\n keys,\n threshold: 0.3,\n includeScore: true\n });\n }\n public search(query: string, limit: number = 10): T[] {\n return this.fuse.search(query).slice(0, limit).map(result => result.item);\n }\n public addItems(items: T[]) {\n items.map(item => this.fuse.add(item));\n }\n}\n/**\n * Library Info is the metadata for a library entry after setting up a game.\n */\nexport interface LibraryInfo {\n name: string;\n version: string;\n cwd: string;\n appID: number;\n launchExecutable: string;\n launchArguments?: string;\n capsuleImage: string;\n storefront: 'steam' | 'internal';\n addonsource: string;\n coverImage: string;\n titleImage?: string;\n}\ninterface Notification {\n type: 'warning' | 'error' | 'info' | 'success';\n message: string;\n id: string\n}\nclass OGIAddonWSListener {\n private socket: WebSocket;\n public eventEmitter: events.EventEmitter;\n public addon: OGIAddon;\n\n constructor(ogiAddon: OGIAddon, eventEmitter: events.EventEmitter) {\n if (process.argv[process.argv.length - 1].split('=')[0] !== '--addonSecret') {\n throw new Error('No secret provided. This usually happens because the addon was not started by the OGI Addon Server.');\n }\n this.addon = ogiAddon;\n this.eventEmitter = eventEmitter;\n this.socket = new ws('ws://localhost:' + defaultPort);\n this.socket.on('open', () => {\n console.log('Connected to OGI Addon Server');\n console.log('OGI Addon Server Version:', VERSION);\n\n // Authenticate with OGI Addon Server\n this.send('authenticate', {\n ...this.addon.addonInfo,\n secret: process.argv[process.argv.length - 1].split('=')[1],\n ogiVersion: VERSION\n });\n\n this.eventEmitter.emit('connect');\n\n // send a configuration request\n let configBuilder = new ConfigurationBuilder();\n this.eventEmitter.emit('configure', configBuilder);\n this.send('configure', configBuilder.build(false));\n this.addon.config = new Configuration(configBuilder.build(true));\n });\n\n this.socket.on('error', (error) => {\n if (error.message.includes('Failed to connect')) {\n throw new Error('OGI Addon Server is not running/is unreachable. Please start the server and try again.');\n }\n console.error('An error occurred:', error);\n })\n\n this.socket.on('close', (code, reason) => {\n if (code === 1008) {\n console.error('Authentication failed:', reason);\n return;\n }\n this.eventEmitter.emit('disconnect', reason);\n console.log(\"Disconnected from OGI Addon Server\")\n console.error(reason.toString())\n this.eventEmitter.emit('exit');\n this.socket.close();\n });\n\n this.registerMessageReceiver();\n }\n\n private async userInputAsked(configBuilt: ConfigurationBuilder, name: string, description: string, socket: WebSocket): Promise<{ [key: string]: number | boolean | string }> {\n const config = configBuilt.build(false);\n const id = Math.random().toString(36).substring(7);\n if (!socket) {\n return {};\n }\n socket.send(JSON.stringify({\n event: 'input-asked',\n args: {\n config,\n name,\n description\n },\n id: id\n }));\n return await this.waitForResponseFromServer(id);\n }\n\n private registerMessageReceiver() {\n this.socket.on('message', async (data: string) => {\n const message: WebsocketMessageServer = JSON.parse(data);\n switch (message.event) {\n case 'config-update':\n const result = this.addon.config.updateConfig(message.args);\n if (!result[0]) {\n this.respondToMessage(message.id!!, { success: false, error: result[1] });\n }\n else {\n this.respondToMessage(message.id!!, { success: true });\n }\n break\n case 'search':\n let searchResultEvent = new EventResponse<SearchResult[]>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n this.eventEmitter.emit('search', message.args, searchResultEvent);\n const searchResult = await this.waitForEventToRespond(searchResultEvent);\n this.respondToMessage(message.id!!, searchResult.data);\n break\n case 'setup':\n let setupEvent = new EventResponse<LibraryInfo>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n this.eventEmitter.emit('setup', { path: message.args.path, appID: message.args.appID, storefront: message.args.storefront, type: message.args.type, name: message.args.name, usedRealDebrid: message.args.usedRealDebrid, multiPartFiles: message.args.multiPartFiles }, setupEvent);\n const interval = setInterval(() => {\n if (setupEvent.resolved) {\n clearInterval(interval);\n return;\n }\n this.send('defer-update', {\n logs: setupEvent.logs,\n deferID: message.args.deferID,\n progress: setupEvent.progress\n } as any);\n }, 100);\n const setupResult = await this.waitForEventToRespond(setupEvent);\n this.respondToMessage(message.id!!, setupResult.data);\n break\n case 'library-search':\n let librarySearchEvent = new EventResponse<BasicLibraryInfo[]>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('game-details') === 0) {\n this.respondToMessage(message.id!!, []);\n break;\n }\n this.eventEmitter.emit('library-search', message.args, librarySearchEvent);\n const librarySearchResult = await this.waitForEventToRespond(librarySearchEvent);\n this.respondToMessage(message.id!!, librarySearchResult.data);\n break\n case 'game-details':\n let gameDetailsEvent = new EventResponse<StoreData>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('game-details') === 0) {\n this.respondToMessage(message.id!!, { error: 'No event listener for game-details' });\n break;\n }\n this.eventEmitter.emit('game-details', message.args, gameDetailsEvent);\n const gameDetailsResult = await this.waitForEventToRespond(gameDetailsEvent);\n this.respondToMessage(message.id!!, gameDetailsResult.data);\n break\n case 'request-dl':\n let requestDLEvent = new EventResponse<SearchResult>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('request-dl') === 0) {\n this.respondToMessage(message.id!!, { error: 'No event listener for request-dl' });\n break;\n }\n this.eventEmitter.emit('request-dl', message.args.appID, message.args.info, requestDLEvent);\n const requestDLResult = await this.waitForEventToRespond(requestDLEvent);\n if (requestDLEvent.data === null || requestDLEvent.data?.downloadType === 'request') {\n throw new Error('Request DL event did not return a valid result. Please ensure that the event does not resolve with another `request` download type.');\n }\n this.respondToMessage(message.id!!, requestDLResult.data);\n break\n }\n });\n }\n\n private waitForEventToRespond<T>(event: EventResponse<T>): Promise<EventResponse<T>> {\n // check the handlers to see if there even is any\n return new Promise((resolve, reject) => {\n const dataGet = setInterval(() => {\n if (event.resolved) {\n resolve(event);\n clearTimeout(timeout);\n }\n }, 5);\n\n const timeout = setTimeout(() => {\n if (event.deffered) {\n clearInterval(dataGet);\n const interval = setInterval(() => {\n if (event.resolved) {\n clearInterval(interval);\n resolve(event);\n }\n }, 100);\n }\n else {\n reject('Event did not respond in time');\n }\n }, 5000)\n });\n }\n\n public respondToMessage(messageID: string, response: any) {\n this.socket.send(JSON.stringify({\n event: 'response',\n id: messageID,\n args: response\n }));\n console.log(\"dispatched response to \" + messageID)\n }\n\n public waitForResponseFromServer<T>(messageID: string): Promise<T> {\n return new Promise((resolve) => {\n const waiter = (data: string) => {\n const message: WebsocketMessageClient = JSON.parse(data);\n if (message.event !== 'response') {\n this.socket.once('message', waiter);\n return;\n }\n console.log(\"received response from \" + messageID)\n\n if (message.id === messageID) {\n resolve(message.args);\n }\n else {\n this.socket.once('message', waiter);\n }\n }\n this.socket.once('message', waiter);\n });\n }\n\n public send(event: OGIAddonClientSentEvent, args: ClientSentEventTypes[OGIAddonClientSentEvent]): string {\n // generate a random id\n const id = Math.random().toString(36).substring(7);\n this.socket.send(JSON.stringify({\n event,\n args,\n id\n }));\n return id;\n }\n\n public close() {\n this.socket.close();\n }\n\n\n}\n","import z, { ZodError } from \"zod\"\n\nexport interface ConfigurationFile {\n [key: string]: ConfigurationOption\n}\n\nconst configValidation = z.object({\n name: z.string().min(1),\n displayName: z.string().min(1),\n description: z.string().min(1),\n})\n\nexport function isStringOption(option: ConfigurationOption): option is StringOption {\n return option.type === 'string';\n }\n\nexport function isNumberOption(option: ConfigurationOption): option is NumberOption {\n return option.type === 'number';\n}\n\nexport function isBooleanOption(option: ConfigurationOption): option is BooleanOption {\n return option.type === 'boolean';\n}\n\nexport class ConfigurationBuilder {\n private options: ConfigurationOption[] = [];\n\n /**\n * Add a number option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: NumberOption) => NumberOption }\n * @returns \n */\n public addNumberOption(option: (option: NumberOption) => NumberOption): ConfigurationBuilder {\n let newOption = new NumberOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a string option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: StringOption) => StringOption }\n */\n public addStringOption(option: (option: StringOption) => StringOption) {\n let newOption = new StringOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a boolean option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: BooleanOption) => BooleanOption }\n */\n public addBooleanOption(option: (option: BooleanOption) => BooleanOption) {\n let newOption = new BooleanOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n public build(includeFunctions: boolean): ConfigurationFile {\n let config: ConfigurationFile = {};\n this.options.forEach(option => {\n // remove all functions from the option object\n if (!includeFunctions) {\n option = JSON.parse(JSON.stringify(option));\n const optionData = configValidation.safeParse(option)\n if (!optionData.success) {\n throw new ZodError(optionData.error.errors)\n }\n\n config[option.name] = option;\n }\n else {\n config[option.name] = option;\n }\n });\n return config;\n }\n}\n\nexport type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset'\nexport class ConfigurationOption {\n public name: string = '';\n public defaultValue: unknown = '';\n public displayName: string = '';\n public description: string = '';\n public type: ConfigurationOptionType = 'unset'\n \n /**\n * Set the name of the option. **REQUIRED**\n * @param name {string} The name of the option. This is used to reference the option in the configuration file.\n */\n setName(name: string) {\n this.name = name;\n return this;\n }\n\n /**\n * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED** \n * @param displayName {string} The display name of the option. \n * @returns \n */\n setDisplayName(displayName: string) {\n this.displayName = displayName;\n return this;\n }\n\n /**\n * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**\n * @param description {string} The description of the option. \n * @returns \n */\n setDescription(description: string) {\n this.description = description;\n return this;\n }\n\n /**\n * Validation code for the option. This is called when the user provides input to the option. If the validation fails, the user will be prompted to provide input again.\n * @param input {unknown} The input to validate\n */\n validate(input: unknown): [ boolean, string ] {\n throw new Error('Validation code not implemented. Value: ' + input)\n };\n}\n\nexport class StringOption extends ConfigurationOption {\n public allowedValues: string[] = [];\n public minTextLength: number = 0;\n public maxTextLength: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: string = '';\n public inputType: 'text' | 'file' | 'password' | 'folder' = 'text';\n public type: ConfigurationOptionType = 'string'\n\n /**\n * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown. \n * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.\n */\n setAllowedValues(allowedValues: string[]): this {\n this.allowedValues = allowedValues;\n return this;\n }\n\n /**\n * Set the default value for the string. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {string} The default value for the string.\n */\n setDefaultValue(defaultValue: string): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail. \n * @param minTextLength {number} The minimum text length for the string. \n */\n setMinTextLength(minTextLength: number): this {\n this.minTextLength = minTextLength;\n return this;\n }\n\n /**\n * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail. \n * @param maxTextLength {number} The maximum text length for the string.\n */\n setMaxTextLength(maxTextLength: number): this {\n this.maxTextLength = maxTextLength;\n return this;\n }\n\n /**\n * Set the input type for the string. This will change how the client renders the input. \n * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string. \n */\n setInputType(inputType: 'text' | 'file' | 'password' | 'folder'): this {\n this.inputType = inputType;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'string') {\n return [ false, 'Input is not a string' ];\n }\n if (this.allowedValues.length === 0 && input.length !== 0)\n return [ true, '' ];\n if (input.length < this.minTextLength || input.length > this.maxTextLength) {\n return [ false, 'Input is not within the text length ' + this.minTextLength + ' and ' + this.maxTextLength + ' characters (currently ' + input.length + ' characters)' ];\n }\n\n return [ this.allowedValues.includes(input), 'Input is not an allowed value' ];\n }\n}\n\nexport class NumberOption extends ConfigurationOption {\n public min: number = 0;\n public max: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: number = 0;\n public type: ConfigurationOptionType = 'number'\n public inputType: 'range' | 'number' = 'number';\n\n /**\n * Set the minimum value for the number. If the user provides a number that is less than this value, the validation will fail.\n * @param min {number} The minimum value for the number.\n */\n setMin(min: number): this {\n this.min = min;\n return this;\n }\n\n /**\n * Set the input type for the number. This will change how the client renders the input. \n * @param type {'range' | 'number'} The input type for the number. \n */\n setInputType(type: 'range' | 'number'): this {\n this.inputType = type;\n return this;\n }\n\n /**\n * Set the maximum value for the number. If the user provides a number that is greater than this value, the validation will fail.\n * @param max {number} The maximum value for the number.\n */\n setMax(max: number): this {\n this.max = max;\n return this\n }\n\n /**\n * Set the default value for the number. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {number} The default value for the number.\n */\n setDefaultValue(defaultValue: number): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (isNaN(Number(input))) {\n return [ false, 'Input is not a number' ];\n }\n if (Number(input) < this.min || Number(input) > this.max) {\n return [ false, 'Input is not within the range of ' + this.min + ' and ' + this.max ];\n }\n return [ true, '' ];\n }\n\n}\n\nexport class BooleanOption extends ConfigurationOption {\n public type: ConfigurationOptionType = 'boolean'\n public defaultValue: boolean = false;\n\n /**\n * Set the default value for the boolean. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {boolean} The default value for the boolean.\n */\n setDefaultValue(defaultValue: boolean): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'boolean') {\n return [ false, 'Input is not a boolean' ];\n }\n return [ true, '' ];\n }\n\n}","import { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from \"./ConfigurationBuilder\";\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(config: DefiniteConfig, validate: boolean = true): [ boolean, { [key: string]: string } ] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [ true, {} ];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [ boolean, { [key: string]: string } ] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (this.definiteConfig[key] === null || this.definiteConfig[key] === undefined) {\n console.warn('Option ' + key + ' is not defined. Using default value Value: ' + this.definiteConfig[key]);\n this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue as string | number | boolean;\n }\n if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {\n throw new Error('Option ' + key + ' is not of the correct type');\n }\n\n const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);\n if (!result[0]) {\n erroredKeys.set(key, result[1]);\n }\n }\n\n for (const key in this.definiteConfig) {\n if (!this.storedConfigTemplate[key]) {\n throw new Error('Option ' + key + ' is not defined in the configuration template');\n }\n }\n\n if (erroredKeys.size > 0) {\n return [ false, Object.fromEntries(erroredKeys) ];\n }\n\n return [ true, Object.fromEntries(erroredKeys) ];\n }\n\n getStringValue(optionName: string): string {\n if (!this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (!this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };","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 onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>) {\n this.onInputAsked = onInputAsked;\n }\n \n\n public defer() {\n this.deffered = true;\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 /**\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(name: string, description: string, screen: ConfigurationBuilder): 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 \n}","{\n \"name\": \"ogi-addon\",\n \"module\": \"./build/main.js\",\n \"type\": \"module\",\n \"main\": \"./build/main.cjs\",\n \"version\": \"1.1.6\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"default\": \"./build/main.js\",\n \"types\": \"./build/main.d.ts\"\n },\n \"require\": {\n \"default\": \"./build/main.cjs\",\n \"types\": \"./build/main.d.cts\"\n }\n },\n \"./config\": {\n \"import\": {\n \"default\": \"./build/config/Configuration.js\",\n \"types\": \"./build/config/Configuration.d.ts\"\n },\n \"require\": {\n \"default\": \"./build/config/Configuration.cjs\",\n \"types\": \"./build/config/Configuration.d.cts\"\n }\n }\n },\n \"typings\": \"./build/main.d.ts\",\n \"author\": {\n \"name\": \"Nat3z\",\n \"email\": \"me@nat3z.com\",\n \"url\": \"https://nat3z.com/\"\n },\n \"dependencies\": {\n \"fuse.js\": \"^7.1.0\",\n \"ws\": \"^8.4.0\",\n \"zod\": \"^3.23.8\"\n },\n \"scripts\": {\n \"auto-build\": \"tsc -w\",\n \"build\": \"tsup --config tsup.config.js\",\n \"release\": \"bun run build && npm publish\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.14.12\",\n \"@types/ws\": \"^8.4.0\",\n \"tsup\": \"^8.2.3\",\n \"typescript\": \"^5.0.0\"\n }\n}"],"mappings":";AAAA,OAAO,QAAuB;AAC9B,OAAO,YAAY;;;ACDnB,OAAO,KAAK,gBAAgB;AAM5B,IAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC7B,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAC/B,CAAC;AAcM,IAAM,uBAAN,MAA2B;AAAA,EACxB,UAAiC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnC,gBAAgB,QAAsE;AAC3F,QAAI,YAAY,IAAI,aAAa;AACjC,gBAAY,OAA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OACK;AACH,eAAK,OAAO,KAAK,WAAW,MAAM;AAAA,QACpC;AAAA,MACF;AACA,WAAK,OAAO,KAAK,WAAW,MAAM;AAAA,IACpC,CAAC;AAAA,EACH;AAAA,EAEO,KAAK,OAAgC,MAA6D;AAEvG,UAAM,KAAK,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,CAAC;AACjD,SAAK,OAAO,KAAK,KAAK,UAAU;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,CAAC;AACF,WAAO;AAAA,EACT;AAAA,EAEO,QAAQ;AACb,SAAK,OAAO,MAAM;AAAA,EACpB;AAGF;","names":["ws"]}
1
+ {"version":3,"sources":["../src/main.ts","../src/config/ConfigurationBuilder.ts","../src/config/Configuration.ts","../src/EventResponse.ts","../package.json"],"sourcesContent":["import ws, { WebSocket } from 'ws';\nimport events from 'node:events';\nimport { ConfigurationBuilder, ConfigurationFile } from './config/ConfigurationBuilder';\nimport { Configuration } from './config/Configuration';\nimport EventResponse from './EventResponse';\nimport { SearchResult } from './SearchEngine';\nimport Fuse, { IFuseOptions } from 'fuse.js';\n\nexport type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'request-dl';\nexport type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'steam-search' | 'task-update';\n\nexport type OGIAddonServerSentEvent = 'authenticate' | 'configure' | 'config-update' | 'search' | 'setup' | 'response' | 'library-search' | 'game-details' | 'request-dl';\nexport { ConfigurationBuilder, Configuration, EventResponse, SearchResult };\nconst defaultPort = 7654;\nimport pjson from '../package.json';\nexport const VERSION = pjson.version;\n\nexport interface ClientSentEventTypes {\n response: any;\n authenticate: {\n name: string;\n id: string;\n description: string;\n version: string;\n author: string;\n };\n configure: ConfigurationFile;\n 'defer-update': {\n logs: string[],\n progress: number\n };\n notification: Notification;\n 'input-asked': ConfigurationBuilder;\n 'steam-search': {\n query: string;\n strict: boolean;\n };\n 'task-update': {\n id: string;\n progress: number;\n logs: string[];\n finished: boolean;\n };\n}\n\nexport type BasicLibraryInfo = {\n name: string;\n capsuleImage: string;\n appID: number;\n}\n\nexport interface EventListenerTypes {\n /**\n * This event is emitted when the addon connects to the OGI Addon Server. Addon does not need to resolve anything.\n * @param socket \n * @returns \n */\n connect: (socket: ws) => void;\n\n /**\n * 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.\n * @param reason \n * @returns \n */\n disconnect: (reason: string) => void;\n /**\n * 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) \n * @param config \n * @returns \n */\n configure: (config: ConfigurationBuilder) => ConfigurationBuilder;\n /**\n * This event is called when the client provides a response to any event. This should be treated as middleware. \n * @param response \n * @returns \n */\n response: (response: any) => void;\n\n /**\n * This event is called when the client requests for the addon to authenticate itself. You don't need to provide any info. \n * @param config \n * @returns \n */\n authenticate: (config: any) => void;\n /**\n * 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) \n * @param query \n * @param event \n * @returns \n */\n search: (query: { type: 'steamapp' | 'internal', text: string }, event: EventResponse<SearchResult[]>) => void;\n /**\n * 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)\n * @param data \n * @param event \n * @returns \n */\n setup: (\n data: {\n path: string,\n type: 'direct' | 'torrent' | 'magnet',\n name: string,\n usedRealDebrid: boolean,\n multiPartFiles?: {\n name: string,\n downloadURL: string\n }[],\n appID: number,\n storefront: 'steam' | 'internal'\n }, event: EventResponse<LibraryInfo>\n ) => void;\n\n /**\n * This event is emitted when the client requires for a search to be performed. Input is the search query. \n * @param query \n * @param event \n * @returns \n */\n 'library-search': (query: string, event: EventResponse<BasicLibraryInfo[]>) => void;\n 'game-details': (appID: number, event: EventResponse<StoreData>) => void;\n exit: () => void;\n 'request-dl': (appID: number, info: SearchResult, event: EventResponse<SearchResult>) => void;\n}\n\nexport interface StoreData {\n name: string;\n publishers: string[];\n developers: string[];\n appID: number;\n releaseDate: string;\n capsuleImage: string;\n coverImage: string;\n basicDescription: string;\n description: string;\n headerImage: string;\n}\nexport interface WebsocketMessageClient {\n event: OGIAddonClientSentEvent;\n id?: string;\n args: any;\n}\nexport interface WebsocketMessageServer {\n event: OGIAddonServerSentEvent;\n id?: string;\n args: any;\n}\nexport interface OGIAddonConfiguration {\n name: string;\n id: string;\n description: string;\n version: string;\n\n author: string;\n repository: string;\n}\n\n/**\n * 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.\n * @example \n * ```typescript\n * const addon = new OGIAddon({\n * name: 'Test Addon',\n* id: 'test-addon',\n * description: 'A test addon',\n * version: '1.0.0',\n * author: 'OGI Developers',\n * repository: ''\n * });\n * ```\n * \n */\nexport default class OGIAddon {\n public eventEmitter = new events.EventEmitter();\n public addonWSListener: OGIAddonWSListener;\n public addonInfo: OGIAddonConfiguration;\n public config: Configuration = new Configuration({});\n\n constructor(addonInfo: OGIAddonConfiguration) {\n this.addonInfo = addonInfo;\n this.addonWSListener = new OGIAddonWSListener(this, this.eventEmitter);\n }\n\n /**\n * Register an event listener for the addon. (See EventListenerTypes) \n * @param event {OGIAddonEvent}\n * @param listener {EventListenerTypes[OGIAddonEvent]} \n */\n public on<T extends OGIAddonEvent>(event: T, listener: EventListenerTypes[T]) {\n this.eventEmitter.on(event, listener);\n }\n\n public emit<T extends OGIAddonEvent>(event: T, ...args: Parameters<EventListenerTypes[T]>) {\n this.eventEmitter.emit(event, ...args);\n }\n\n /**\n * Notify the client using a notification. Provide the type of notification, the message, and an ID. \n * @param notification {Notification}\n */\n public notify(notification: Notification) {\n this.addonWSListener.send('notification', [notification]);\n }\n\n /**\n * Search for items in the OGI Steam-Synced Library. Query can either be a Steam AppID or a Steam Game Name.\n * @param query {string}\n * @param event {EventResponse<BasicLibraryInfo[]>}\n */\n public async steamSearch(query: string, strict: boolean = false) {\n const id = this.addonWSListener.send('steam-search', { query, strict });\n return await this.addonWSListener.waitForResponseFromServer<Omit<BasicLibraryInfo, 'capsuleImage'>[]>(id);\n }\n\n /**\n * 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.\n * @param id {string}\n * @param progress {number}\n * @param logs {string[]}\n */\n public async task() {\n const id = Math.random().toString(36).substring(7);\n const progress = 0;\n const logs: string[] = [];\n const task = new CustomTask(this.addonWSListener, id, progress, logs);\n this.addonWSListener.send('task-update', { id, progress, logs, finished: false });\n return task;\n }\n}\n\nexport class CustomTask {\n public readonly id: string;\n public progress: number;\n public logs: string[];\n public finished: boolean = false;\n public ws: OGIAddonWSListener;\n constructor(ws: OGIAddonWSListener, id: string, progress: number, logs: string[]) {\n this.id = id;\n this.progress = progress;\n this.logs = logs;\n this.ws = ws;\n }\n public log(log: string) {\n this.logs.push(log);\n this.update();\n }\n public finish() {\n this.finished = true;\n this.update();\n }\n public setProgress(progress: number) {\n this.progress = progress;\n this.update();\n }\n public update() {\n this.ws.send('task-update', { id: this.id, progress: this.progress, logs: this.logs, finished: this.finished });\n }\n}\n/**\n * A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.\n * @example\n * ```typescript\n * const searchTool = new SearchTool<LibraryInfo>([{ name: 'test', appID: 123 }, { name: 'test2', appID: 124 }], ['name']);\n * const results = searchTool.search('test', 10);\n * ```\n */\nexport class SearchTool<T> {\n private fuse: Fuse<T>;\n constructor(items: T[], keys: string[], options: Omit<IFuseOptions<T>, 'keys'> = { threshold: 0.3, includeScore: true }) {\n this.fuse = new Fuse(items, {\n keys,\n ...options\n });\n }\n public search(query: string, limit: number = 10): T[] {\n return this.fuse.search(query).slice(0, limit).map(result => result.item);\n }\n public addItems(items: T[]) {\n items.map(item => this.fuse.add(item));\n }\n}\n/**\n * Library Info is the metadata for a library entry after setting up a game.\n */\nexport interface LibraryInfo {\n name: string;\n version: string;\n cwd: string;\n appID: number;\n launchExecutable: string;\n launchArguments?: string;\n capsuleImage: string;\n storefront: 'steam' | 'internal';\n addonsource: string;\n coverImage: string;\n titleImage?: string;\n}\ninterface Notification {\n type: 'warning' | 'error' | 'info' | 'success';\n message: string;\n id: string\n}\nclass OGIAddonWSListener {\n private socket: WebSocket;\n public eventEmitter: events.EventEmitter;\n public addon: OGIAddon;\n\n constructor(ogiAddon: OGIAddon, eventEmitter: events.EventEmitter) {\n if (process.argv[process.argv.length - 1].split('=')[0] !== '--addonSecret') {\n throw new Error('No secret provided. This usually happens because the addon was not started by the OGI Addon Server.');\n }\n this.addon = ogiAddon;\n this.eventEmitter = eventEmitter;\n this.socket = new ws('ws://localhost:' + defaultPort);\n this.socket.on('open', () => {\n console.log('Connected to OGI Addon Server');\n console.log('OGI Addon Server Version:', VERSION);\n\n // Authenticate with OGI Addon Server\n this.send('authenticate', {\n ...this.addon.addonInfo,\n secret: process.argv[process.argv.length - 1].split('=')[1],\n ogiVersion: VERSION\n });\n\n this.eventEmitter.emit('connect');\n\n // send a configuration request\n let configBuilder = new ConfigurationBuilder();\n this.eventEmitter.emit('configure', configBuilder);\n this.send('configure', configBuilder.build(false));\n this.addon.config = new Configuration(configBuilder.build(true));\n });\n\n this.socket.on('error', (error) => {\n if (error.message.includes('Failed to connect')) {\n throw new Error('OGI Addon Server is not running/is unreachable. Please start the server and try again.');\n }\n console.error('An error occurred:', error);\n })\n\n this.socket.on('close', (code, reason) => {\n if (code === 1008) {\n console.error('Authentication failed:', reason);\n return;\n }\n this.eventEmitter.emit('disconnect', reason);\n console.log(\"Disconnected from OGI Addon Server\")\n console.error(reason.toString())\n this.eventEmitter.emit('exit');\n this.socket.close();\n });\n\n this.registerMessageReceiver();\n }\n\n private async userInputAsked(configBuilt: ConfigurationBuilder, name: string, description: string, socket: WebSocket): Promise<{ [key: string]: number | boolean | string }> {\n const config = configBuilt.build(false);\n const id = Math.random().toString(36).substring(7);\n if (!socket) {\n return {};\n }\n socket.send(JSON.stringify({\n event: 'input-asked',\n args: {\n config,\n name,\n description\n },\n id: id\n }));\n return await this.waitForResponseFromServer(id);\n }\n\n private registerMessageReceiver() {\n this.socket.on('message', async (data: string) => {\n const message: WebsocketMessageServer = JSON.parse(data);\n switch (message.event) {\n case 'config-update':\n const result = this.addon.config.updateConfig(message.args);\n if (!result[0]) {\n this.respondToMessage(message.id!!, { success: false, error: result[1] });\n }\n else {\n this.respondToMessage(message.id!!, { success: true });\n }\n break\n case 'search':\n let searchResultEvent = new EventResponse<SearchResult[]>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n this.eventEmitter.emit('search', message.args, searchResultEvent);\n const searchResult = await this.waitForEventToRespond(searchResultEvent);\n this.respondToMessage(message.id!!, searchResult.data);\n break\n case 'setup':\n let setupEvent = new EventResponse<LibraryInfo>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n this.eventEmitter.emit('setup', { path: message.args.path, appID: message.args.appID, storefront: message.args.storefront, type: message.args.type, name: message.args.name, usedRealDebrid: message.args.usedRealDebrid, multiPartFiles: message.args.multiPartFiles }, setupEvent);\n const interval = setInterval(() => {\n if (setupEvent.resolved) {\n clearInterval(interval);\n return;\n }\n this.send('defer-update', {\n logs: setupEvent.logs,\n deferID: message.args.deferID,\n progress: setupEvent.progress\n } as any);\n }, 100);\n const setupResult = await this.waitForEventToRespond(setupEvent);\n this.respondToMessage(message.id!!, setupResult.data);\n break\n case 'library-search':\n let librarySearchEvent = new EventResponse<BasicLibraryInfo[]>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('game-details') === 0) {\n this.respondToMessage(message.id!!, []);\n break;\n }\n this.eventEmitter.emit('library-search', message.args, librarySearchEvent);\n const librarySearchResult = await this.waitForEventToRespond(librarySearchEvent);\n this.respondToMessage(message.id!!, librarySearchResult.data);\n break\n case 'game-details':\n let gameDetailsEvent = new EventResponse<StoreData>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('game-details') === 0) {\n this.respondToMessage(message.id!!, { error: 'No event listener for game-details' });\n break;\n }\n this.eventEmitter.emit('game-details', message.args, gameDetailsEvent);\n const gameDetailsResult = await this.waitForEventToRespond(gameDetailsEvent);\n this.respondToMessage(message.id!!, gameDetailsResult.data);\n break\n case 'request-dl':\n let requestDLEvent = new EventResponse<SearchResult>((screen, name, description) => this.userInputAsked(screen, name, description, this.socket));\n if (this.eventEmitter.listenerCount('request-dl') === 0) {\n this.respondToMessage(message.id!!, { error: 'No event listener for request-dl' });\n break;\n }\n this.eventEmitter.emit('request-dl', message.args.appID, message.args.info, requestDLEvent);\n const requestDLResult = await this.waitForEventToRespond(requestDLEvent);\n if (requestDLEvent.data === null || requestDLEvent.data?.downloadType === 'request') {\n throw new Error('Request DL event did not return a valid result. Please ensure that the event does not resolve with another `request` download type.');\n }\n this.respondToMessage(message.id!!, requestDLResult.data);\n break\n }\n });\n }\n\n private waitForEventToRespond<T>(event: EventResponse<T>): Promise<EventResponse<T>> {\n // check the handlers to see if there even is any\n return new Promise((resolve, reject) => {\n const dataGet = setInterval(() => {\n if (event.resolved) {\n resolve(event);\n clearTimeout(timeout);\n }\n }, 5);\n\n const timeout = setTimeout(() => {\n if (event.deffered) {\n clearInterval(dataGet);\n const interval = setInterval(() => {\n if (event.resolved) {\n clearInterval(interval);\n resolve(event);\n }\n }, 100);\n }\n else {\n reject('Event did not respond in time');\n }\n }, 5000)\n });\n }\n\n public respondToMessage(messageID: string, response: any) {\n this.socket.send(JSON.stringify({\n event: 'response',\n id: messageID,\n args: response\n }));\n console.log(\"dispatched response to \" + messageID)\n }\n\n public waitForResponseFromServer<T>(messageID: string): Promise<T> {\n return new Promise((resolve) => {\n const waiter = (data: string) => {\n const message: WebsocketMessageClient = JSON.parse(data);\n if (message.event !== 'response') {\n this.socket.once('message', waiter);\n return;\n }\n console.log(\"received response from \" + messageID)\n\n if (message.id === messageID) {\n resolve(message.args);\n }\n else {\n this.socket.once('message', waiter);\n }\n }\n this.socket.once('message', waiter);\n });\n }\n\n public send(event: OGIAddonClientSentEvent, args: ClientSentEventTypes[OGIAddonClientSentEvent]): string {\n // generate a random id\n const id = Math.random().toString(36).substring(7);\n this.socket.send(JSON.stringify({\n event,\n args,\n id\n }));\n return id;\n }\n\n public close() {\n this.socket.close();\n }\n\n\n}\n","import z, { ZodError } from \"zod\"\n\nexport interface ConfigurationFile {\n [key: string]: ConfigurationOption\n}\n\nconst configValidation = z.object({\n name: z.string().min(1),\n displayName: z.string().min(1),\n description: z.string().min(1),\n})\n\nexport function isStringOption(option: ConfigurationOption): option is StringOption {\n return option.type === 'string';\n }\n\nexport function isNumberOption(option: ConfigurationOption): option is NumberOption {\n return option.type === 'number';\n}\n\nexport function isBooleanOption(option: ConfigurationOption): option is BooleanOption {\n return option.type === 'boolean';\n}\n\nexport class ConfigurationBuilder {\n private options: ConfigurationOption[] = [];\n\n /**\n * Add a number option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: NumberOption) => NumberOption }\n * @returns \n */\n public addNumberOption(option: (option: NumberOption) => NumberOption): ConfigurationBuilder {\n let newOption = new NumberOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a string option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: StringOption) => StringOption }\n */\n public addStringOption(option: (option: StringOption) => StringOption) {\n let newOption = new StringOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n /**\n * Add a boolean option to the configuration builder and return the builder for chaining. You must provide a name, display name, and description for the option.\n * @param option { (option: BooleanOption) => BooleanOption }\n */\n public addBooleanOption(option: (option: BooleanOption) => BooleanOption) {\n let newOption = new BooleanOption();\n newOption = option(newOption);\n this.options.push(newOption);\n return this;\n }\n\n public build(includeFunctions: boolean): ConfigurationFile {\n let config: ConfigurationFile = {};\n this.options.forEach(option => {\n // remove all functions from the option object\n if (!includeFunctions) {\n option = JSON.parse(JSON.stringify(option));\n const optionData = configValidation.safeParse(option)\n if (!optionData.success) {\n throw new ZodError(optionData.error.errors)\n }\n\n config[option.name] = option;\n }\n else {\n config[option.name] = option;\n }\n });\n return config;\n }\n}\n\nexport type ConfigurationOptionType = 'string' | 'number' | 'boolean' | 'unset'\nexport class ConfigurationOption {\n public name: string = '';\n public defaultValue: unknown = '';\n public displayName: string = '';\n public description: string = '';\n public type: ConfigurationOptionType = 'unset'\n \n /**\n * Set the name of the option. **REQUIRED**\n * @param name {string} The name of the option. This is used to reference the option in the configuration file.\n */\n setName(name: string) {\n this.name = name;\n return this;\n }\n\n /**\n * Set the display name of the option. This is used to show the user a human readable version of what the option is. **REQUIRED** \n * @param displayName {string} The display name of the option. \n * @returns \n */\n setDisplayName(displayName: string) {\n this.displayName = displayName;\n return this;\n }\n\n /**\n * Set the description of the option. This is to show the user a brief description of what this option does. **REQUIRED**\n * @param description {string} The description of the option. \n * @returns \n */\n setDescription(description: string) {\n this.description = description;\n return this;\n }\n\n /**\n * Validation code for the option. This is called when the user provides input to the option. If the validation fails, the user will be prompted to provide input again.\n * @param input {unknown} The input to validate\n */\n validate(input: unknown): [ boolean, string ] {\n throw new Error('Validation code not implemented. Value: ' + input)\n };\n}\n\nexport class StringOption extends ConfigurationOption {\n public allowedValues: string[] = [];\n public minTextLength: number = 0;\n public maxTextLength: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: string = '';\n public inputType: 'text' | 'file' | 'password' | 'folder' = 'text';\n public type: ConfigurationOptionType = 'string'\n\n /**\n * Set the allowed values for the string. If the array is empty, any value is allowed. When provided, the client will act like this option is a dropdown. \n * @param allowedValues {string[]} An array of allowed values for the string. If the array is empty, any value is allowed.\n */\n setAllowedValues(allowedValues: string[]): this {\n this.allowedValues = allowedValues;\n return this;\n }\n\n /**\n * Set the default value for the string. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {string} The default value for the string.\n */\n setDefaultValue(defaultValue: string): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n /**\n * Set the minimum text length for the string. If the user provides a string that is less than this value, the validation will fail. \n * @param minTextLength {number} The minimum text length for the string. \n */\n setMinTextLength(minTextLength: number): this {\n this.minTextLength = minTextLength;\n return this;\n }\n\n /**\n * Set the maximum text length for the string. If the user provides a string that is greater than this value, the validation will fail. \n * @param maxTextLength {number} The maximum text length for the string.\n */\n setMaxTextLength(maxTextLength: number): this {\n this.maxTextLength = maxTextLength;\n return this;\n }\n\n /**\n * Set the input type for the string. This will change how the client renders the input. \n * @param inputType {'text' | 'file' | 'password' | 'folder'} The input type for the string. \n */\n setInputType(inputType: 'text' | 'file' | 'password' | 'folder'): this {\n this.inputType = inputType;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'string') {\n return [ false, 'Input is not a string' ];\n }\n if (this.allowedValues.length === 0 && input.length !== 0)\n return [ true, '' ];\n if (input.length < this.minTextLength || input.length > this.maxTextLength) {\n return [ false, 'Input is not within the text length ' + this.minTextLength + ' and ' + this.maxTextLength + ' characters (currently ' + input.length + ' characters)' ];\n }\n\n return [ this.allowedValues.includes(input), 'Input is not an allowed value' ];\n }\n}\n\nexport class NumberOption extends ConfigurationOption {\n public min: number = 0;\n public max: number = Number.MAX_SAFE_INTEGER;\n public defaultValue: number = 0;\n public type: ConfigurationOptionType = 'number'\n public inputType: 'range' | 'number' = 'number';\n\n /**\n * Set the minimum value for the number. If the user provides a number that is less than this value, the validation will fail.\n * @param min {number} The minimum value for the number.\n */\n setMin(min: number): this {\n this.min = min;\n return this;\n }\n\n /**\n * Set the input type for the number. This will change how the client renders the input. \n * @param type {'range' | 'number'} The input type for the number. \n */\n setInputType(type: 'range' | 'number'): this {\n this.inputType = type;\n return this;\n }\n\n /**\n * Set the maximum value for the number. If the user provides a number that is greater than this value, the validation will fail.\n * @param max {number} The maximum value for the number.\n */\n setMax(max: number): this {\n this.max = max;\n return this\n }\n\n /**\n * Set the default value for the number. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {number} The default value for the number.\n */\n setDefaultValue(defaultValue: number): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (isNaN(Number(input))) {\n return [ false, 'Input is not a number' ];\n }\n if (Number(input) < this.min || Number(input) > this.max) {\n return [ false, 'Input is not within the range of ' + this.min + ' and ' + this.max ];\n }\n return [ true, '' ];\n }\n\n}\n\nexport class BooleanOption extends ConfigurationOption {\n public type: ConfigurationOptionType = 'boolean'\n public defaultValue: boolean = false;\n\n /**\n * Set the default value for the boolean. This value will be used if the user does not provide a value. **HIGHLY RECOMMENDED**\n * @param defaultValue {boolean} The default value for the boolean.\n */\n setDefaultValue(defaultValue: boolean): this {\n this.defaultValue = defaultValue;\n return this;\n }\n\n override validate(input: unknown): [ boolean, string ] {\n if (typeof input !== 'boolean') {\n return [ false, 'Input is not a boolean' ];\n }\n return [ true, '' ];\n }\n\n}","import { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption } from \"./ConfigurationBuilder\";\n\ninterface DefiniteConfig {\n [key: string]: string | number | boolean;\n}\nexport class Configuration {\n readonly storedConfigTemplate: ConfigurationFile;\n definiteConfig: DefiniteConfig = {};\n constructor(configTemplate: ConfigurationFile) {\n this.storedConfigTemplate = configTemplate;\n }\n\n updateConfig(config: DefiniteConfig, validate: boolean = true): [ boolean, { [key: string]: string } ] {\n this.definiteConfig = config;\n if (validate) {\n const result = this.validateConfig();\n return result;\n }\n return [ true, {} ];\n }\n // provides falsey or truthy value, and an error message if falsey\n private validateConfig(): [ boolean, { [key: string]: string } ] {\n const erroredKeys = new Map<string, string>();\n for (const key in this.storedConfigTemplate) {\n if (this.definiteConfig[key] === null || this.definiteConfig[key] === undefined) {\n console.warn('Option ' + key + ' is not defined. Using default value Value: ' + this.definiteConfig[key]);\n this.definiteConfig[key] = this.storedConfigTemplate[key].defaultValue as string | number | boolean;\n }\n if (this.storedConfigTemplate[key].type !== typeof this.definiteConfig[key]) {\n throw new Error('Option ' + key + ' is not of the correct type');\n }\n\n const result = this.storedConfigTemplate[key].validate(this.definiteConfig[key]);\n if (!result[0]) {\n erroredKeys.set(key, result[1]);\n }\n }\n\n for (const key in this.definiteConfig) {\n if (!this.storedConfigTemplate[key]) {\n throw new Error('Option ' + key + ' is not defined in the configuration template');\n }\n }\n\n if (erroredKeys.size > 0) {\n return [ false, Object.fromEntries(erroredKeys) ];\n }\n\n return [ true, Object.fromEntries(erroredKeys) ];\n }\n\n getStringValue(optionName: string): string {\n if (!this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'string') {\n throw new Error('Option ' + optionName + ' is not a string');\n }\n return this.definiteConfig[optionName];\n }\n\n getNumberValue(optionName: string): number {\n if (!this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'number') {\n throw new Error('Option ' + optionName + ' is not a number');\n }\n return this.definiteConfig[optionName];\n }\n\n getBooleanValue(optionName: string): boolean {\n if (this.definiteConfig[optionName] === null) {\n throw new Error('Option ' + optionName + ' is not defined');\n }\n if (typeof this.definiteConfig[optionName] !== 'boolean') {\n throw new Error('Option ' + optionName + ' is not a boolean');\n }\n return this.definiteConfig[optionName];\n }\n}\n\nexport { ConfigurationFile, ConfigurationBuilder, BooleanOption, ConfigurationOption, ConfigurationOptionType, NumberOption, StringOption, isBooleanOption, isNumberOption, isStringOption };","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 onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>;\n\n constructor(onInputAsked?: (screen: ConfigurationBuilder, name: string, description: string) => Promise<{ [key: string]: boolean | string | number }>) {\n this.onInputAsked = onInputAsked;\n }\n \n\n public defer() {\n this.deffered = true;\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 /**\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(name: string, description: string, screen: ConfigurationBuilder): 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 \n}","{\n \"name\": \"ogi-addon\",\n \"module\": \"./build/main.js\",\n \"type\": \"module\",\n \"main\": \"./build/main.cjs\",\n \"version\": \"1.2.0\",\n \"exports\": {\n \".\": {\n \"import\": {\n \"default\": \"./build/main.js\",\n \"types\": \"./build/main.d.ts\"\n },\n \"require\": {\n \"default\": \"./build/main.cjs\",\n \"types\": \"./build/main.d.cts\"\n }\n },\n \"./config\": {\n \"import\": {\n \"default\": \"./build/config/Configuration.js\",\n \"types\": \"./build/config/Configuration.d.ts\"\n },\n \"require\": {\n \"default\": \"./build/config/Configuration.cjs\",\n \"types\": \"./build/config/Configuration.d.cts\"\n }\n }\n },\n \"typings\": \"./build/main.d.ts\",\n \"author\": {\n \"name\": \"Nat3z\",\n \"email\": \"me@nat3z.com\",\n \"url\": \"https://nat3z.com/\"\n },\n \"dependencies\": {\n \"fuse.js\": \"^7.1.0\",\n \"ws\": \"^8.4.0\",\n \"zod\": \"^3.23.8\"\n },\n \"scripts\": {\n \"auto-build\": \"tsc -w\",\n \"build\": \"tsup --config tsup.config.js\",\n \"release\": \"bun run build && npm publish\",\n \"release-beta\": \"bun run build && npm publish --tag future\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.14.12\",\n \"@types/ws\": \"^8.4.0\",\n \"tsup\": \"^8.2.3\",\n \"typescript\": \"^5.0.0\"\n }\n}"],"mappings":";AAAA,OAAO,QAAuB;AAC9B,OAAO,YAAY;;;ACDnB,OAAO,KAAK,gBAAgB;AAM5B,IAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACtB,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC7B,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAC/B,CAAC;AAcM,IAAM,uBAAN,MAA2B;AAAA,EACxB,UAAiC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnC,gBAAgB,QAAsE;AAC3F,QAAI,YAAY,IAAI,aAAa;AACjC,gBAAY,OAAO,SAAS;AAC5B,SAAK,QAAQ,KAAK,SAAS;AAC3B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,gBAAgB,QAAgD;AACrE,QAAI,YAAY,IAAI,aAAa;AACjC,gBAAY,OAAO,SAAS;AAC5B,SAAK,QAAQ,KAAK,SAAS;AAC3B,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,iBAAiB,QAAkD;AACxE,QAAI,YAAY,IAAI,cAAc;AAClC,gBAAY,OAAO,SAAS;AAC5B,SAAK,QAAQ,KAAK,SAAS;AAC3B,WAAO;AAAA,EACT;AAAA,EAEO,MAAM,kBAA8C;AACzD,QAAI,SAA4B,CAAC;AACjC,SAAK,QAAQ,QA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json CHANGED
@@ -3,7 +3,7 @@
3
3
  "module": "./build/main.js",
4
4
  "type": "module",
5
5
  "main": "./build/main.cjs",
6
- "version": "1.1.6",
6
+ "version": "1.2.0",
7
7
  "exports": {
8
8
  ".": {
9
9
  "import": {
@@ -40,7 +40,8 @@
40
40
  "scripts": {
41
41
  "auto-build": "tsc -w",
42
42
  "build": "tsup --config tsup.config.js",
43
- "release": "bun run build && npm publish"
43
+ "release": "bun run build && npm publish",
44
+ "release-beta": "bun run build && npm publish --tag future"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@types/node": "^20.14.12",
@@ -1,10 +1,6 @@
1
1
  export type SearchResult = {
2
2
  name: string;
3
- description: string;
4
- coverURL: string;
5
3
  downloadType: 'torrent' | 'direct' | 'magnet' | 'request';
6
- downloadSize: number;
7
- appID: number;
8
4
  storefront: 'steam' | 'internal';
9
5
  filename?: string;
10
6
  downloadURL?: string;
package/src/main.ts CHANGED
@@ -4,7 +4,7 @@ import { ConfigurationBuilder, ConfigurationFile } from './config/ConfigurationB
4
4
  import { Configuration } from './config/Configuration';
5
5
  import EventResponse from './EventResponse';
6
6
  import { SearchResult } from './SearchEngine';
7
- import Fuse from 'fuse.js';
7
+ import Fuse, { IFuseOptions } from 'fuse.js';
8
8
 
9
9
  export type OGIAddonEvent = 'connect' | 'disconnect' | 'configure' | 'authenticate' | 'search' | 'setup' | 'library-search' | 'game-details' | 'exit' | 'request-dl';
10
10
  export type OGIAddonClientSentEvent = 'response' | 'authenticate' | 'configure' | 'defer-update' | 'notification' | 'input-asked' | 'steam-search' | 'task-update';
@@ -256,20 +256,19 @@ export class CustomTask {
256
256
  }
257
257
  }
258
258
  /**
259
- * A search tool for the OGI Addon. This tool is used to search for items in the library. Powered by Fuse.js, bundled into OGI.
259
+ * A search tool wrapper over Fuse.js for the OGI Addon. This tool is used to search for items in the library.
260
260
  * @example
261
261
  * ```typescript
262
- * const searchTool = new SearchTool<LibraryInfo>([], ['name']);
262
+ * const searchTool = new SearchTool<LibraryInfo>([{ name: 'test', appID: 123 }, { name: 'test2', appID: 124 }], ['name']);
263
263
  * const results = searchTool.search('test', 10);
264
264
  * ```
265
265
  */
266
266
  export class SearchTool<T> {
267
267
  private fuse: Fuse<T>;
268
- constructor(items: T[], keys: string[]) {
268
+ constructor(items: T[], keys: string[], options: Omit<IFuseOptions<T>, 'keys'> = { threshold: 0.3, includeScore: true }) {
269
269
  this.fuse = new Fuse(items, {
270
270
  keys,
271
- threshold: 0.3,
272
- includeScore: true
271
+ ...options
273
272
  });
274
273
  }
275
274
  public search(query: string, limit: number = 10): T[] {