UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

34 lines (33 loc) 1.15 kB
import BaseRpcDriver from "./BaseRpcDriver.js"; class DummyHandle { destroy() { } async call(_functionName, _filteredArgs, _options = {}) { return undefined; } } export default class MainThreadRpcDriver extends BaseRpcDriver { name = 'MainThreadRpcDriver'; makeWorker; constructor(args) { super(args); this.makeWorker = async () => new DummyHandle(); } async call(pm, sessionId, funcName, args) { if (!sessionId) { throw new TypeError('sessionId is required'); } const rpcMethod = pm.getRpcMethodType(funcName); if (!rpcMethod) { throw new Error(`unknown RPC method ${funcName}`); } if (rpcMethod.supportsDirectExecution()) { const result = await rpcMethod.executeDirect(args); if (result !== undefined) { return result; } } const serializedArgs = await rpcMethod.serializeArguments(args, this.name); const result = await rpcMethod.execute(serializedArgs, this.name); return rpcMethod.deserializeReturn(result, args, this.name); } }