{"version":3,"sources":["../../../packages/core/rpc/rpc-inbound.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,WAAW,EAA8D,mBAAmB,EAAW,MAAM,YAAY,CAAC;AAC5I,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,OAAO;IACnC;;;;;;OAMG;gBACS,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAQhE;;;;OAIG;IACI,WAAW,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAQvD;;;;;OAKG;IACI,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/C;;;;OAIG;IACH,OAAO,CAAC,YAAY;CAGvB","file":"rpc-inbound.d.ts","sourcesContent":["import { NativeQ } from '../data/native-q';\r\nimport { RpcBase, RpcBaseData, rpcCommandVersion, RpcInboundCommands, RpcOutboundCommands, RpcOutboundHandlers, RpcType } from './rpc-base';\r\nimport { RpcChannel } from './rpc-channel';\r\n\r\n/**\r\n * RpcToShell class.\r\n * - Module (tool) uses the instance to communicate to Shell.\r\n */\r\nexport class RpcInbound extends RpcBase {\r\n    /**\r\n     * Initiates a new instance of the RpcToShell class.\r\n     *\r\n     * @param rpcChannel the rpc channel.\r\n     * @param name the public name of the module.\r\n     * @param origin the origin url.\r\n     */\r\n    constructor(rpcChannel: RpcChannel, name: string, origin: string) {\r\n        super(rpcChannel, name, origin, RpcType.Inbound);\r\n        const commands = Object.keys(RpcOutboundCommands);\r\n        commands.forEach((command) => {\r\n            this.register(command, this.emptyHandler);\r\n        });\r\n    }\r\n\r\n    /**\r\n     * Registers all handlers at once.\r\n     *\r\n     * @param handlers the Shell handlers.\r\n     */\r\n    public registerAll(handlers: RpcOutboundHandlers): void {\r\n        const handlerNames = Object.keys(handlers);\r\n        handlerNames.forEach((handlerName) => {\r\n            const command = RpcBase.handlerToCommandName(handlerName);\r\n            this.register(command, handlers[handlerName]);\r\n        });\r\n    }\r\n\r\n    /**\r\n     * The failed command.\r\n     *\r\n     * @param data the RpcBaseData object.\r\n     * @return Promise<void> the promise object.\r\n     */\r\n    public failed(data: RpcBaseData): Promise<void> {\r\n        return this.rpcChannel.post<RpcBaseData, void>(\r\n            this, { command: RpcInboundCommands[RpcInboundCommands.Failed], version: rpcCommandVersion, data: data });\r\n    }\r\n\r\n    /**\r\n     * The empty handler to response always resolved.\r\n     *\r\n     * @return Promise<string> the promise.\r\n     */\r\n    private emptyHandler(_: RpcBaseData): Promise<any> {\r\n        return NativeQ.resolved<any>('emptyHandler');\r\n    }\r\n}\r\n"]}