UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

33 lines (32 loc) 1.2 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const BaseRpcDriver_1 = __importDefault(require("./BaseRpcDriver")); class DummyHandle { destroy() { } async call(_functionName, _filteredArgs, _options = {}) { return undefined; } } class MainThreadRpcDriver extends BaseRpcDriver_1.default { constructor(args) { super(args); this.name = 'MainThreadRpcDriver'; 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}`); } const serializedArgs = await rpcMethod.serializeArguments(args, this.name); const result = await rpcMethod.execute(serializedArgs, this.name); return rpcMethod.deserializeReturn(result, args, this.name); } } exports.default = MainThreadRpcDriver;