UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

1 lines 1.99 kB
{"version":3,"sources":["../../../packages/core/rpc/forward/rpc-forward-auto-client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAqB,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGlG,qBAAa,oBAAoB;IAC7B;;OAEG;WACW,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;CAwBjG","file":"rpc-forward-auto-client.d.ts","sourcesContent":["import { from, zip } from 'rxjs';\r\nimport { map } from 'rxjs/operators';\r\nimport { Rpc } from '../rpc';\r\nimport { RpcOutboundClient } from '../rpc-outbound-client';\r\nimport { RpcForwardDownKey, RpcForwardReportData, RpcForwardResponse } from './rpc-forward-model';\r\nimport { RpcForwardUpClient } from './rpc-forward-up-client';\r\n\r\nexport class RpcForwardAutoClient {\r\n /**\r\n * report a forward update from the shell or module\r\n */\r\n public static forward<T>(rpc: Rpc, data: RpcForwardReportData): Promise<RpcForwardResponse<T>> {\r\n if (!rpc.isShell) {\r\n return RpcForwardUpClient.forward<any>(rpc, data);\r\n }\r\n\r\n // If we are the shell, then broadcast forwards to all iframes\r\n // since only gateway, connections, and auth services use this architecture, it should be safe.\r\n return zip(...rpc.rpcManager.getCurrentRpcOutbound()\r\n .map(rpcOutbound =>\r\n from(RpcOutboundClient.callOutbound(\r\n rpc.rpcManager.rpcChannel,\r\n rpcOutbound,\r\n RpcForwardDownKey.command,\r\n RpcForwardDownKey.version,\r\n data)))\r\n )\r\n .pipe(\r\n map(results => {\r\n // TODO: do we care about errors from other frames?\r\n return results.find(rpcOutbound => rpcOutbound === rpc.rpcManager.rpcOutbound) || results[0];\r\n })\r\n )\r\n .toPromise();\r\n }\r\n}\r\n"]}