UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

123 lines 2.96 kB
export type WorkerStatus = string; /** * @enum {string} */ export const WorkerStatus: Readonly<{ STOPPED: "STOPPED"; RUNNING: "RUNNING"; FAILED: "FAILED"; }>; export default WorkerProxy; declare class WorkerProxy { /** * * @param {string} url * @param {Object} methods */ constructor(url: string, methods: any); /** * * @type {Object<Array<{id:number, parameters:[], resolve: function, reject:function}>>} * @private */ private __pending; /** * @type {WorkerStatus} * @private */ private __status; /** * Error captured when the worker transitions to FAILED. Used to reject any subsequent requests. * @type {Error|null} * @private */ private __failure; /** * * @type {Worker|null} * @private */ private __worker; /** * * @type {number} * @private */ private __id_counter; /** * Created worker will assume this name as well * Useful for debug purposes and reflection * @type {string} * @private */ private __name; url: string; methods: any; /** * Invoke a given method on the worker, as defined by the `WorkerBuilder` * @template T * @param {string} name Method's name * @param {Array} args * @return {Promise<T>} eventual result of the invoked method */ $submitRequest<T>(name: string, args: any[]): Promise<T>; /** * * @param {string} name * @private */ private __makeMethod; /** * * @private */ private __generateAPI; /** * * @param {Event} event * @private */ private __handleMessage; isRunning(): boolean; /** * @returns {WorkerStatus} */ getStatus(): WorkerStatus; /** * Stop the worker. * If the worker is not running, this method does nothing. * A worker in FAILED state cannot be stopped (it has already been terminated). */ stop(): void; /** * * @param {number} id * @param {string} method_name * @returns {boolean} */ cancelRequest(id: number, method_name: string): boolean; sendPendingRequests(): void; /** * Start the worker. * Any requests made while the worker is not running will be queued and sent once the worker is started. * * If the worker is already running, this method does nothing. * */ start(): void; /** * Worker-level error handler. Fires when the worker script itself fails * (e.g. importScripts 404) or when an uncaught error escapes a handler. * Treats the worker as permanently failed: rejects all pending and future requests. * * @param {ErrorEvent} errorEvent * @private */ private __handleError; /** * @param {Error} err * @private */ private __failAllPending; } //# sourceMappingURL=WorkerProxy.d.ts.map