@celljs/rpc 4.2.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -1
- package/cell.schema.json +100 -0
- package/cell.yml +12 -8
- package/esm/common/annotation/index.d.ts +2 -0
- package/esm/common/annotation/index.js +2 -0
- package/esm/common/annotation/index.js.map +1 -1
- package/esm/common/annotation/rpc-client.d.ts +7 -0
- package/esm/common/annotation/rpc-client.js +18 -0
- package/esm/common/annotation/rpc-client.js.map +1 -0
- package/esm/common/annotation/rpc-protocol.d.ts +7 -0
- package/esm/common/annotation/rpc-protocol.js +2 -0
- package/esm/common/annotation/rpc-protocol.js.map +1 -0
- package/esm/common/annotation/rpc.d.ts +4 -0
- package/esm/common/annotation/rpc.js +14 -18
- package/esm/common/annotation/rpc.js.map +1 -1
- package/esm/common/client/client-protocol.d.ts +6 -0
- package/esm/common/client/client-protocol.js +2 -0
- package/esm/common/client/client-protocol.js.map +1 -0
- package/esm/common/client/index.d.ts +2 -0
- package/esm/common/client/index.js +3 -0
- package/esm/common/client/index.js.map +1 -0
- package/esm/common/client/rpc-client-registry.d.ts +14 -0
- package/esm/common/client/rpc-client-registry.js +51 -0
- package/esm/common/client/rpc-client-registry.js.map +1 -0
- package/esm/common/constants.d.ts +3 -1
- package/esm/common/constants.js +3 -1
- package/esm/common/constants.js.map +1 -1
- package/esm/common/converter/converter-protocol.d.ts +6 -2
- package/esm/common/converter/converter-protocol.js +1 -0
- package/esm/common/converter/converter-protocol.js.map +1 -1
- package/esm/common/endpoint/endpoint-protocol.d.ts +3 -0
- package/esm/common/endpoint/endpoint-resolver.d.ts +2 -0
- package/esm/common/endpoint/endpoint-resolver.js +17 -3
- package/esm/common/endpoint/endpoint-resolver.js.map +1 -1
- package/esm/common/error/error.d.ts +23 -0
- package/esm/common/error/error.js +34 -2
- package/esm/common/error/error.js.map +1 -1
- package/esm/common/index.d.ts +6 -6
- package/esm/common/index.js +6 -6
- package/esm/common/index.js.map +1 -1
- package/esm/common/module.js +5 -4
- package/esm/common/module.js.map +1 -1
- package/esm/common/processor/client-config-processor.d.ts +2 -2
- package/esm/common/processor/client-config-processor.js.map +1 -1
- package/esm/common/processor/processor-protocol.d.ts +2 -2
- package/esm/common/protocol/index.d.ts +1 -0
- package/esm/common/protocol/index.js +2 -0
- package/esm/common/protocol/index.js.map +1 -0
- package/esm/common/protocol/json-rpc.d.ts +42 -0
- package/esm/common/protocol/json-rpc.js +48 -0
- package/esm/common/protocol/json-rpc.js.map +1 -0
- package/esm/common/proxy/index.d.ts +1 -4
- package/esm/common/proxy/index.js +1 -4
- package/esm/common/proxy/index.js.map +1 -1
- package/esm/common/proxy/rpc-proxy.d.ts +6 -0
- package/esm/common/proxy/rpc-proxy.js +40 -0
- package/esm/common/proxy/rpc-proxy.js.map +1 -0
- package/esm/common/transport/http-transport.d.ts +50 -0
- package/esm/common/transport/http-transport.js +98 -0
- package/esm/common/transport/http-transport.js.map +1 -0
- package/esm/common/transport/index.d.ts +4 -0
- package/esm/common/transport/index.js +5 -0
- package/esm/common/transport/index.js.map +1 -0
- package/esm/common/transport/transport-protocol.d.ts +12 -0
- package/esm/common/transport/transport-protocol.js +2 -0
- package/esm/common/transport/transport-protocol.js.map +1 -0
- package/esm/common/transport/transport-provider.d.ts +34 -0
- package/esm/common/transport/transport-provider.js +103 -0
- package/esm/common/transport/transport-provider.js.map +1 -0
- package/esm/common/transport/websocket-transport.d.ts +54 -0
- package/esm/common/transport/websocket-transport.js +144 -0
- package/esm/common/transport/websocket-transport.js.map +1 -0
- package/esm/common/utils/index.d.ts +1 -1
- package/esm/common/utils/index.js +1 -1
- package/esm/common/utils/index.js.map +1 -1
- package/esm/common/utils/rpc-method-util.d.ts +10 -0
- package/esm/common/utils/rpc-method-util.js +28 -0
- package/esm/common/utils/rpc-method-util.js.map +1 -0
- package/esm/common/utils/rpc-util.d.ts +9 -9
- package/esm/common/utils/rpc-util.js +24 -30
- package/esm/common/utils/rpc-util.js.map +1 -1
- package/esm/node/connection/connection-protocol.d.ts +26 -0
- package/esm/node/connection/connection-protocol.js +3 -0
- package/esm/node/connection/connection-protocol.js.map +1 -0
- package/esm/node/connection/index.d.ts +4 -0
- package/esm/node/connection/index.js +5 -0
- package/esm/node/connection/index.js.map +1 -0
- package/esm/node/connection/rpc-connection-manager.d.ts +10 -0
- package/esm/node/connection/rpc-connection-manager.js +35 -0
- package/esm/node/connection/rpc-connection-manager.js.map +1 -0
- package/esm/node/connection/rpc-connection.d.ts +33 -0
- package/esm/node/connection/rpc-connection.js +106 -0
- package/esm/node/connection/rpc-connection.js.map +1 -0
- package/esm/node/connection/rpc-context.d.ts +14 -0
- package/esm/node/connection/rpc-context.js +29 -0
- package/esm/node/connection/rpc-context.js.map +1 -0
- package/esm/node/index.d.ts +3 -2
- package/esm/node/index.js +3 -2
- package/esm/node/index.js.map +1 -1
- package/esm/node/server/index.d.ts +2 -0
- package/esm/node/server/index.js +3 -0
- package/esm/node/server/index.js.map +1 -0
- package/esm/node/server/rpc-handler-adapter.d.ts +15 -0
- package/esm/node/server/rpc-handler-adapter.js +74 -0
- package/esm/node/server/rpc-handler-adapter.js.map +1 -0
- package/esm/node/server/rpc-invoker.d.ts +28 -0
- package/esm/node/server/rpc-invoker.js +113 -0
- package/esm/node/server/rpc-invoker.js.map +1 -0
- package/esm/node/test/websocket-fixture-protocol.d.ts +36 -0
- package/esm/node/test/websocket-fixture-protocol.js +7 -0
- package/esm/node/test/websocket-fixture-protocol.js.map +1 -0
- package/esm/node/test/websocket-fixture.d.ts +40 -0
- package/esm/node/test/websocket-fixture.js +128 -0
- package/esm/node/test/websocket-fixture.js.map +1 -0
- package/esm/node/websocket/index.d.ts +4 -0
- package/esm/node/websocket/index.js +5 -0
- package/esm/node/websocket/index.js.map +1 -0
- package/esm/node/websocket/rpc-websocket-server.d.ts +45 -0
- package/esm/node/websocket/rpc-websocket-server.js +167 -0
- package/esm/node/websocket/rpc-websocket-server.js.map +1 -0
- package/esm/node/websocket/websocket-connection.d.ts +55 -0
- package/esm/node/websocket/websocket-connection.js +181 -0
- package/esm/node/websocket/websocket-connection.js.map +1 -0
- package/esm/node/websocket/websocket-exchange.d.ts +38 -0
- package/esm/node/websocket/websocket-exchange.js +124 -0
- package/esm/node/websocket/websocket-exchange.js.map +1 -0
- package/esm/node/websocket/websocket-frames.d.ts +31 -0
- package/esm/node/websocket/websocket-frames.js +119 -0
- package/esm/node/websocket/websocket-frames.js.map +1 -0
- package/lib/common/annotation/index.d.ts +2 -0
- package/lib/common/annotation/index.d.ts.map +1 -1
- package/lib/common/annotation/index.js +2 -0
- package/lib/common/annotation/index.js.map +1 -1
- package/lib/common/annotation/rpc-client.d.ts +8 -0
- package/lib/common/annotation/rpc-client.d.ts.map +1 -0
- package/lib/common/annotation/rpc-client.js +21 -0
- package/lib/common/annotation/rpc-client.js.map +1 -0
- package/lib/common/annotation/rpc-protocol.d.ts +8 -0
- package/lib/common/annotation/rpc-protocol.d.ts.map +1 -0
- package/lib/common/annotation/rpc-protocol.js +5 -0
- package/lib/common/annotation/rpc-protocol.js.map +1 -0
- package/lib/common/annotation/rpc.d.ts +4 -0
- package/lib/common/annotation/rpc.d.ts.map +1 -1
- package/lib/common/annotation/rpc.js +12 -16
- package/lib/common/annotation/rpc.js.map +1 -1
- package/lib/common/client/client-protocol.d.ts +7 -0
- package/lib/common/client/client-protocol.d.ts.map +1 -0
- package/lib/common/client/client-protocol.js +5 -0
- package/lib/common/client/client-protocol.js.map +1 -0
- package/lib/common/client/index.d.ts +3 -0
- package/lib/common/client/index.d.ts.map +1 -0
- package/lib/common/{handler → client}/index.js +2 -2
- package/lib/common/client/index.js.map +1 -0
- package/lib/common/client/rpc-client-registry.d.ts +15 -0
- package/lib/common/client/rpc-client-registry.d.ts.map +1 -0
- package/lib/common/client/rpc-client-registry.js +54 -0
- package/lib/common/client/rpc-client-registry.js.map +1 -0
- package/lib/common/constants.d.ts +3 -1
- package/lib/common/constants.d.ts.map +1 -1
- package/lib/common/constants.js +4 -2
- package/lib/common/constants.js.map +1 -1
- package/lib/common/converter/converter-protocol.d.ts +6 -2
- package/lib/common/converter/converter-protocol.d.ts.map +1 -1
- package/lib/common/converter/converter-protocol.js +1 -0
- package/lib/common/converter/converter-protocol.js.map +1 -1
- package/lib/common/endpoint/endpoint-protocol.d.ts +3 -0
- package/lib/common/endpoint/endpoint-protocol.d.ts.map +1 -1
- package/lib/common/endpoint/endpoint-resolver.d.ts +2 -0
- package/lib/common/endpoint/endpoint-resolver.d.ts.map +1 -1
- package/lib/common/endpoint/endpoint-resolver.js +16 -2
- package/lib/common/endpoint/endpoint-resolver.js.map +1 -1
- package/lib/common/error/error.d.ts +23 -0
- package/lib/common/error/error.d.ts.map +1 -1
- package/lib/common/error/error.js +35 -2
- package/lib/common/error/error.js.map +1 -1
- package/lib/common/index.d.ts +6 -6
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +6 -6
- package/lib/common/index.js.map +1 -1
- package/lib/common/module.d.ts.map +1 -1
- package/lib/common/module.js +4 -3
- package/lib/common/module.js.map +1 -1
- package/lib/common/processor/client-config-processor.d.ts +2 -2
- package/lib/common/processor/client-config-processor.d.ts.map +1 -1
- package/lib/common/processor/client-config-processor.js.map +1 -1
- package/lib/common/processor/processor-protocol.d.ts +2 -2
- package/lib/common/processor/processor-protocol.d.ts.map +1 -1
- package/lib/common/protocol/index.d.ts +2 -0
- package/lib/common/protocol/index.d.ts.map +1 -0
- package/lib/common/{channal → protocol}/index.js +1 -2
- package/lib/common/protocol/index.js.map +1 -0
- package/lib/common/protocol/json-rpc.d.ts +43 -0
- package/lib/common/protocol/json-rpc.d.ts.map +1 -0
- package/lib/common/protocol/json-rpc.js +51 -0
- package/lib/common/protocol/json-rpc.js.map +1 -0
- package/lib/common/proxy/index.d.ts +1 -4
- package/lib/common/proxy/index.d.ts.map +1 -1
- package/lib/common/proxy/index.js +1 -4
- package/lib/common/proxy/index.js.map +1 -1
- package/lib/common/proxy/rpc-proxy.d.ts +7 -0
- package/lib/common/proxy/rpc-proxy.d.ts.map +1 -0
- package/lib/common/proxy/rpc-proxy.js +43 -0
- package/lib/common/proxy/rpc-proxy.js.map +1 -0
- package/lib/common/transport/http-transport.d.ts +51 -0
- package/lib/common/transport/http-transport.d.ts.map +1 -0
- package/lib/common/transport/http-transport.js +102 -0
- package/lib/common/transport/http-transport.js.map +1 -0
- package/lib/common/transport/index.d.ts +5 -0
- package/lib/common/transport/index.d.ts.map +1 -0
- package/lib/common/{factory → transport}/index.js +4 -4
- package/lib/common/transport/index.js.map +1 -0
- package/lib/common/transport/transport-protocol.d.ts +13 -0
- package/lib/common/transport/transport-protocol.d.ts.map +1 -0
- package/lib/common/transport/transport-protocol.js +5 -0
- package/lib/common/transport/transport-protocol.js.map +1 -0
- package/lib/common/transport/transport-provider.d.ts +35 -0
- package/lib/common/transport/transport-provider.d.ts.map +1 -0
- package/lib/common/transport/transport-provider.js +106 -0
- package/lib/common/transport/transport-provider.js.map +1 -0
- package/lib/common/transport/websocket-transport.d.ts +55 -0
- package/lib/common/transport/websocket-transport.d.ts.map +1 -0
- package/lib/common/transport/websocket-transport.js +148 -0
- package/lib/common/transport/websocket-transport.js.map +1 -0
- package/lib/common/utils/index.d.ts +1 -1
- package/lib/common/utils/index.d.ts.map +1 -1
- package/lib/common/utils/index.js +1 -1
- package/lib/common/utils/index.js.map +1 -1
- package/lib/common/utils/rpc-method-util.d.ts +11 -0
- package/lib/common/utils/rpc-method-util.d.ts.map +1 -0
- package/lib/common/utils/rpc-method-util.js +31 -0
- package/lib/common/utils/rpc-method-util.js.map +1 -0
- package/lib/common/utils/rpc-util.d.ts +9 -9
- package/lib/common/utils/rpc-util.d.ts.map +1 -1
- package/lib/common/utils/rpc-util.js +24 -30
- package/lib/common/utils/rpc-util.js.map +1 -1
- package/lib/node/connection/connection-protocol.d.ts +27 -0
- package/lib/node/connection/connection-protocol.d.ts.map +1 -0
- package/lib/node/connection/connection-protocol.js +6 -0
- package/lib/node/connection/connection-protocol.js.map +1 -0
- package/lib/node/connection/index.d.ts +5 -0
- package/lib/node/connection/index.d.ts.map +1 -0
- package/lib/node/{channel → connection}/index.js +4 -4
- package/lib/node/connection/index.js.map +1 -0
- package/lib/node/connection/rpc-connection-manager.d.ts +11 -0
- package/lib/node/connection/rpc-connection-manager.d.ts.map +1 -0
- package/lib/node/connection/rpc-connection-manager.js +38 -0
- package/lib/node/connection/rpc-connection-manager.js.map +1 -0
- package/lib/node/connection/rpc-connection.d.ts +34 -0
- package/lib/node/connection/rpc-connection.d.ts.map +1 -0
- package/lib/node/connection/rpc-connection.js +110 -0
- package/lib/node/connection/rpc-connection.js.map +1 -0
- package/lib/node/connection/rpc-context.d.ts +15 -0
- package/lib/node/connection/rpc-context.d.ts.map +1 -0
- package/lib/node/connection/rpc-context.js +33 -0
- package/lib/node/connection/rpc-context.js.map +1 -0
- package/lib/node/index.d.ts +3 -2
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +3 -2
- package/lib/node/index.js.map +1 -1
- package/lib/node/rpc-http.spec.d.ts +2 -0
- package/lib/node/rpc-http.spec.d.ts.map +1 -0
- package/lib/node/rpc-http.spec.js +121 -0
- package/lib/node/rpc-http.spec.js.map +1 -0
- package/lib/node/rpc-websocket.spec.d.ts +6 -0
- package/lib/node/rpc-websocket.spec.d.ts.map +1 -0
- package/lib/node/rpc-websocket.spec.js +196 -0
- package/lib/node/rpc-websocket.spec.js.map +1 -0
- package/lib/node/server/index.d.ts +3 -0
- package/lib/node/server/index.d.ts.map +1 -0
- package/lib/node/{handler → server}/index.js +2 -2
- package/lib/node/server/index.js.map +1 -0
- package/lib/node/server/rpc-handler-adapter.d.ts +16 -0
- package/lib/node/server/rpc-handler-adapter.d.ts.map +1 -0
- package/lib/node/{handler/handler-adapter.js → server/rpc-handler-adapter.js} +40 -18
- package/lib/node/server/rpc-handler-adapter.js.map +1 -0
- package/lib/node/server/rpc-invoker.d.ts +29 -0
- package/lib/node/server/rpc-invoker.d.ts.map +1 -0
- package/lib/node/server/rpc-invoker.js +116 -0
- package/lib/node/server/rpc-invoker.js.map +1 -0
- package/lib/node/test/websocket-fixture-protocol.d.ts +37 -0
- package/lib/node/test/websocket-fixture-protocol.d.ts.map +1 -0
- package/lib/node/test/websocket-fixture-protocol.js +10 -0
- package/lib/node/test/websocket-fixture-protocol.js.map +1 -0
- package/lib/node/test/websocket-fixture.d.ts +41 -0
- package/lib/node/test/websocket-fixture.d.ts.map +1 -0
- package/lib/node/test/websocket-fixture.js +135 -0
- package/lib/node/test/websocket-fixture.js.map +1 -0
- package/lib/node/websocket/index.d.ts +5 -0
- package/lib/node/websocket/index.d.ts.map +1 -0
- package/lib/node/websocket/index.js +21 -0
- package/lib/node/websocket/index.js.map +1 -0
- package/lib/node/websocket/rpc-websocket-server.d.ts +46 -0
- package/lib/node/websocket/rpc-websocket-server.d.ts.map +1 -0
- package/lib/node/websocket/rpc-websocket-server.js +170 -0
- package/lib/node/websocket/rpc-websocket-server.js.map +1 -0
- package/lib/node/websocket/websocket-connection.d.ts +56 -0
- package/lib/node/websocket/websocket-connection.d.ts.map +1 -0
- package/lib/node/websocket/websocket-connection.js +185 -0
- package/lib/node/websocket/websocket-connection.js.map +1 -0
- package/lib/node/websocket/websocket-exchange.d.ts +39 -0
- package/lib/node/websocket/websocket-exchange.d.ts.map +1 -0
- package/lib/node/websocket/websocket-exchange.js +128 -0
- package/lib/node/websocket/websocket-exchange.js.map +1 -0
- package/lib/node/websocket/websocket-frames.d.ts +32 -0
- package/lib/node/websocket/websocket-frames.d.ts.map +1 -0
- package/lib/node/websocket/websocket-frames.js +124 -0
- package/lib/node/websocket/websocket-frames.js.map +1 -0
- package/lib/node/websocket/websocket-frames.spec.d.ts +2 -0
- package/lib/node/websocket/websocket-frames.spec.d.ts.map +1 -0
- package/lib/node/websocket/websocket-frames.spec.js +59 -0
- package/lib/node/websocket/websocket-frames.spec.js.map +1 -0
- package/package.json +28 -25
- package/src/common/annotation/index.ts +2 -0
- package/src/common/annotation/rpc-client.ts +17 -0
- package/src/common/annotation/rpc-protocol.ts +8 -0
- package/src/common/annotation/rpc.ts +13 -21
- package/src/common/client/client-protocol.ts +7 -0
- package/src/common/client/index.ts +2 -0
- package/src/common/client/rpc-client-registry.ts +42 -0
- package/src/common/constants.ts +4 -1
- package/src/common/converter/converter-protocol.ts +7 -2
- package/src/common/endpoint/endpoint-protocol.ts +3 -0
- package/src/common/endpoint/endpoint-resolver.ts +18 -4
- package/src/common/error/error.ts +41 -2
- package/src/common/index.ts +6 -6
- package/src/common/module.ts +7 -8
- package/src/common/processor/client-config-processor.ts +2 -2
- package/src/common/processor/processor-protocol.ts +2 -2
- package/src/common/protocol/index.ts +1 -0
- package/src/common/protocol/json-rpc.ts +74 -0
- package/src/common/proxy/index.ts +1 -5
- package/src/common/proxy/rpc-proxy.ts +42 -0
- package/src/common/transport/http-transport.ts +134 -0
- package/src/common/transport/index.ts +4 -0
- package/src/common/transport/transport-protocol.ts +16 -0
- package/src/common/transport/transport-provider.ts +86 -0
- package/src/common/transport/websocket-transport.ts +171 -0
- package/src/common/utils/index.ts +1 -1
- package/src/common/utils/rpc-method-util.ts +26 -0
- package/src/common/utils/rpc-util.ts +24 -35
- package/src/node/connection/connection-protocol.ts +30 -0
- package/src/node/connection/index.ts +3 -0
- package/src/node/connection/rpc-connection-manager.ts +29 -0
- package/src/node/connection/rpc-connection.ts +122 -0
- package/src/node/connection/rpc-context.ts +29 -0
- package/src/node/index.ts +3 -2
- package/src/node/rpc-http.spec.ts +126 -0
- package/src/node/rpc-websocket.spec.ts +196 -0
- package/src/node/server/index.ts +2 -0
- package/src/node/server/rpc-handler-adapter.ts +60 -0
- package/src/node/server/rpc-invoker.ts +104 -0
- package/src/node/test/websocket-fixture-protocol.ts +32 -0
- package/src/node/test/websocket-fixture.ts +122 -0
- package/src/node/websocket/index.ts +4 -0
- package/src/node/websocket/rpc-websocket-server.ts +163 -0
- package/src/node/websocket/websocket-connection.ts +198 -0
- package/src/node/websocket/websocket-exchange.ts +138 -0
- package/src/node/websocket/websocket-frames.spec.ts +62 -0
- package/src/node/websocket/websocket-frames.ts +122 -0
- package/esm/common/channal/channel-protocol.d.ts +0 -51
- package/esm/common/channal/channel-protocol.js +0 -34
- package/esm/common/channal/channel-protocol.js.map +0 -1
- package/esm/common/channal/http-channel.d.ts +0 -8
- package/esm/common/channal/http-channel.js +0 -22
- package/esm/common/channal/http-channel.js.map +0 -1
- package/esm/common/channal/index.d.ts +0 -2
- package/esm/common/channal/index.js +0 -3
- package/esm/common/channal/index.js.map +0 -1
- package/esm/common/factory/connection-factory.d.ts +0 -9
- package/esm/common/factory/connection-factory.js +0 -25
- package/esm/common/factory/connection-factory.js.map +0 -1
- package/esm/common/factory/index.d.ts +0 -4
- package/esm/common/factory/index.js +0 -5
- package/esm/common/factory/index.js.map +0 -1
- package/esm/common/factory/proxy-factory.d.ts +0 -56
- package/esm/common/factory/proxy-factory.js +0 -177
- package/esm/common/factory/proxy-factory.js.map +0 -1
- package/esm/common/factory/reader.d.ts +0 -15
- package/esm/common/factory/reader.js +0 -44
- package/esm/common/factory/reader.js.map +0 -1
- package/esm/common/factory/writer.d.ts +0 -9
- package/esm/common/factory/writer.js +0 -21
- package/esm/common/factory/writer.js.map +0 -1
- package/esm/common/handler/connection-handler.d.ts +0 -6
- package/esm/common/handler/connection-handler.js +0 -4
- package/esm/common/handler/connection-handler.js.map +0 -1
- package/esm/common/handler/handler-protocol.d.ts +0 -6
- package/esm/common/handler/handler-protocol.js +0 -2
- package/esm/common/handler/handler-protocol.js.map +0 -1
- package/esm/common/handler/index.d.ts +0 -2
- package/esm/common/handler/index.js +0 -3
- package/esm/common/handler/index.js.map +0 -1
- package/esm/common/proxy/delegating-http-proxy-creator.d.ts +0 -23
- package/esm/common/proxy/delegating-http-proxy-creator.js +0 -86
- package/esm/common/proxy/delegating-http-proxy-creator.js.map +0 -1
- package/esm/common/proxy/http-proxy-creator.d.ts +0 -42
- package/esm/common/proxy/http-proxy-creator.js +0 -139
- package/esm/common/proxy/http-proxy-creator.js.map +0 -1
- package/esm/common/proxy/proxy-protocol.d.ts +0 -20
- package/esm/common/proxy/proxy-protocol.js +0 -3
- package/esm/common/proxy/proxy-protocol.js.map +0 -1
- package/esm/common/proxy/proxy-provider.d.ts +0 -9
- package/esm/common/proxy/proxy-provider.js +0 -40
- package/esm/common/proxy/proxy-provider.js.map +0 -1
- package/esm/common/utils/logger.d.ts +0 -8
- package/esm/common/utils/logger.js +0 -18
- package/esm/common/utils/logger.js.map +0 -1
- package/esm/node/channel/channel-manager.d.ts +0 -9
- package/esm/node/channel/channel-manager.js +0 -56
- package/esm/node/channel/channel-manager.js.map +0 -1
- package/esm/node/channel/channel-middleware.d.ts +0 -7
- package/esm/node/channel/channel-middleware.js +0 -37
- package/esm/node/channel/channel-middleware.js.map +0 -1
- package/esm/node/channel/channel-protocol.d.ts +0 -12
- package/esm/node/channel/channel-protocol.js +0 -6
- package/esm/node/channel/channel-protocol.js.map +0 -1
- package/esm/node/channel/channel-strategy.d.ts +0 -9
- package/esm/node/channel/channel-strategy.js +0 -61
- package/esm/node/channel/channel-strategy.js.map +0 -1
- package/esm/node/channel/index.d.ts +0 -4
- package/esm/node/channel/index.js +0 -5
- package/esm/node/channel/index.js.map +0 -1
- package/esm/node/handler/handler-adapter.d.ts +0 -13
- package/esm/node/handler/handler-adapter.js +0 -52
- package/esm/node/handler/handler-adapter.js.map +0 -1
- package/esm/node/handler/handler-protocol.d.ts +0 -1
- package/esm/node/handler/handler-protocol.js +0 -2
- package/esm/node/handler/handler-protocol.js.map +0 -1
- package/esm/node/handler/index.d.ts +0 -2
- package/esm/node/handler/index.js +0 -3
- package/esm/node/handler/index.js.map +0 -1
- package/lib/common/channal/channel-protocol.d.ts +0 -52
- package/lib/common/channal/channel-protocol.d.ts.map +0 -1
- package/lib/common/channal/channel-protocol.js +0 -38
- package/lib/common/channal/channel-protocol.js.map +0 -1
- package/lib/common/channal/http-channel.d.ts +0 -9
- package/lib/common/channal/http-channel.d.ts.map +0 -1
- package/lib/common/channal/http-channel.js +0 -26
- package/lib/common/channal/http-channel.js.map +0 -1
- package/lib/common/channal/index.d.ts +0 -3
- package/lib/common/channal/index.d.ts.map +0 -1
- package/lib/common/channal/index.js.map +0 -1
- package/lib/common/factory/connection-factory.d.ts +0 -10
- package/lib/common/factory/connection-factory.d.ts.map +0 -1
- package/lib/common/factory/connection-factory.js +0 -28
- package/lib/common/factory/connection-factory.js.map +0 -1
- package/lib/common/factory/index.d.ts +0 -5
- package/lib/common/factory/index.d.ts.map +0 -1
- package/lib/common/factory/index.js.map +0 -1
- package/lib/common/factory/proxy-factory.d.ts +0 -57
- package/lib/common/factory/proxy-factory.d.ts.map +0 -1
- package/lib/common/factory/proxy-factory.js +0 -182
- package/lib/common/factory/proxy-factory.js.map +0 -1
- package/lib/common/factory/reader.d.ts +0 -16
- package/lib/common/factory/reader.d.ts.map +0 -1
- package/lib/common/factory/reader.js +0 -48
- package/lib/common/factory/reader.js.map +0 -1
- package/lib/common/factory/writer.d.ts +0 -10
- package/lib/common/factory/writer.d.ts.map +0 -1
- package/lib/common/factory/writer.js +0 -25
- package/lib/common/factory/writer.js.map +0 -1
- package/lib/common/handler/connection-handler.d.ts +0 -7
- package/lib/common/handler/connection-handler.d.ts.map +0 -1
- package/lib/common/handler/connection-handler.js +0 -8
- package/lib/common/handler/connection-handler.js.map +0 -1
- package/lib/common/handler/handler-protocol.d.ts +0 -7
- package/lib/common/handler/handler-protocol.d.ts.map +0 -1
- package/lib/common/handler/handler-protocol.js +0 -5
- package/lib/common/handler/handler-protocol.js.map +0 -1
- package/lib/common/handler/index.d.ts +0 -3
- package/lib/common/handler/index.d.ts.map +0 -1
- package/lib/common/handler/index.js.map +0 -1
- package/lib/common/proxy/delegating-http-proxy-creator.d.ts +0 -24
- package/lib/common/proxy/delegating-http-proxy-creator.d.ts.map +0 -1
- package/lib/common/proxy/delegating-http-proxy-creator.js +0 -89
- package/lib/common/proxy/delegating-http-proxy-creator.js.map +0 -1
- package/lib/common/proxy/http-proxy-creator.d.ts +0 -43
- package/lib/common/proxy/http-proxy-creator.d.ts.map +0 -1
- package/lib/common/proxy/http-proxy-creator.js +0 -143
- package/lib/common/proxy/http-proxy-creator.js.map +0 -1
- package/lib/common/proxy/proxy-protocol.d.ts +0 -21
- package/lib/common/proxy/proxy-protocol.d.ts.map +0 -1
- package/lib/common/proxy/proxy-protocol.js +0 -6
- package/lib/common/proxy/proxy-protocol.js.map +0 -1
- package/lib/common/proxy/proxy-provider.d.ts +0 -10
- package/lib/common/proxy/proxy-provider.d.ts.map +0 -1
- package/lib/common/proxy/proxy-provider.js +0 -43
- package/lib/common/proxy/proxy-provider.js.map +0 -1
- package/lib/common/utils/logger.d.ts +0 -9
- package/lib/common/utils/logger.d.ts.map +0 -1
- package/lib/common/utils/logger.js +0 -22
- package/lib/common/utils/logger.js.map +0 -1
- package/lib/node/channel/channel-manager.d.ts +0 -10
- package/lib/node/channel/channel-manager.d.ts.map +0 -1
- package/lib/node/channel/channel-manager.js +0 -59
- package/lib/node/channel/channel-manager.js.map +0 -1
- package/lib/node/channel/channel-middleware.d.ts +0 -8
- package/lib/node/channel/channel-middleware.d.ts.map +0 -1
- package/lib/node/channel/channel-middleware.js +0 -40
- package/lib/node/channel/channel-middleware.js.map +0 -1
- package/lib/node/channel/channel-protocol.d.ts +0 -13
- package/lib/node/channel/channel-protocol.d.ts.map +0 -1
- package/lib/node/channel/channel-protocol.js +0 -9
- package/lib/node/channel/channel-protocol.js.map +0 -1
- package/lib/node/channel/channel-strategy.d.ts +0 -10
- package/lib/node/channel/channel-strategy.d.ts.map +0 -1
- package/lib/node/channel/channel-strategy.js +0 -64
- package/lib/node/channel/channel-strategy.js.map +0 -1
- package/lib/node/channel/index.d.ts +0 -5
- package/lib/node/channel/index.d.ts.map +0 -1
- package/lib/node/channel/index.js.map +0 -1
- package/lib/node/handler/handler-adapter.d.ts +0 -14
- package/lib/node/handler/handler-adapter.d.ts.map +0 -1
- package/lib/node/handler/handler-adapter.js.map +0 -1
- package/lib/node/handler/handler-protocol.d.ts +0 -2
- package/lib/node/handler/handler-protocol.d.ts.map +0 -1
- package/lib/node/handler/handler-protocol.js +0 -5
- package/lib/node/handler/handler-protocol.js.map +0 -1
- package/lib/node/handler/index.d.ts +0 -3
- package/lib/node/handler/index.d.ts.map +0 -1
- package/lib/node/handler/index.js.map +0 -1
- package/src/common/channal/channel-protocol.ts +0 -82
- package/src/common/channal/http-channel.ts +0 -30
- package/src/common/channal/index.ts +0 -2
- package/src/common/factory/connection-factory.ts +0 -21
- package/src/common/factory/index.ts +0 -4
- package/src/common/factory/proxy-factory.ts +0 -219
- package/src/common/factory/reader.ts +0 -50
- package/src/common/factory/writer.ts +0 -26
- package/src/common/handler/connection-handler.ts +0 -7
- package/src/common/handler/handler-protocol.ts +0 -8
- package/src/common/handler/index.ts +0 -2
- package/src/common/proxy/delegating-http-proxy-creator.ts +0 -68
- package/src/common/proxy/http-proxy-creator.ts +0 -179
- package/src/common/proxy/proxy-protocol.ts +0 -26
- package/src/common/proxy/proxy-provider.ts +0 -29
- package/src/common/utils/logger.ts +0 -23
- package/src/node/channel/channel-manager.ts +0 -44
- package/src/node/channel/channel-middleware.ts +0 -27
- package/src/node/channel/channel-protocol.ts +0 -21
- package/src/node/channel/channel-strategy.ts +0 -56
- package/src/node/channel/index.ts +0 -4
- package/src/node/handler/handler-adapter.ts +0 -38
- package/src/node/handler/handler-protocol.ts +0 -1
- package/src/node/handler/index.ts +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/handler/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Disposable } from 'vscode-jsonrpc';
|
|
2
|
-
import { DisposableCollection } from '@celljs/core';
|
|
3
|
-
|
|
4
|
-
export interface Channel {
|
|
5
|
-
handleMessage(message: Channel.Message): void;
|
|
6
|
-
send(content: string): void;
|
|
7
|
-
onMessage(cb: (data: any) => void): void;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export namespace Channel {
|
|
11
|
-
export interface OpenMessage {
|
|
12
|
-
kind: 'open'
|
|
13
|
-
id: number
|
|
14
|
-
path: string
|
|
15
|
-
}
|
|
16
|
-
export interface ReadyMessage {
|
|
17
|
-
kind: 'ready'
|
|
18
|
-
id: number
|
|
19
|
-
}
|
|
20
|
-
export interface DataMessage {
|
|
21
|
-
kind: 'data'
|
|
22
|
-
id: number
|
|
23
|
-
content: string
|
|
24
|
-
}
|
|
25
|
-
export interface CloseMessage {
|
|
26
|
-
kind: 'close'
|
|
27
|
-
id: number
|
|
28
|
-
code: number
|
|
29
|
-
reason: string
|
|
30
|
-
}
|
|
31
|
-
export interface HttpMessage {
|
|
32
|
-
kind: 'http'
|
|
33
|
-
id: number
|
|
34
|
-
path?: string
|
|
35
|
-
content: string
|
|
36
|
-
}
|
|
37
|
-
export type Message = OpenMessage | ReadyMessage | DataMessage | CloseMessage | HttpMessage;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export abstract class AbstractChannel implements Channel, Disposable {
|
|
41
|
-
|
|
42
|
-
protected readonly toDispose = new DisposableCollection();
|
|
43
|
-
|
|
44
|
-
constructor(
|
|
45
|
-
readonly id: number,
|
|
46
|
-
protected readonly doSend: (content: string) => Promise<void>
|
|
47
|
-
) { }
|
|
48
|
-
|
|
49
|
-
dispose(): void {
|
|
50
|
-
this.toDispose.dispose();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
protected checkNotDisposed(): void {
|
|
54
|
-
if (this.toDispose.disposed) {
|
|
55
|
-
throw new Error('The channel has been disposed.');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
abstract handleMessage(message: Channel.Message): void;
|
|
60
|
-
|
|
61
|
-
abstract doGetMessage(content: string): Channel.Message;
|
|
62
|
-
|
|
63
|
-
send(content: string): void {
|
|
64
|
-
this.checkNotDisposed();
|
|
65
|
-
this.doSend(JSON.stringify(this.doGetMessage(content)));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
protected fireMessage: (data: any) => void = () => { };
|
|
69
|
-
onMessage(cb: (data: any) => void): void {
|
|
70
|
-
this.checkNotDisposed();
|
|
71
|
-
this.fireMessage = cb;
|
|
72
|
-
this.toDispose.push(Disposable.create(() => this.fireMessage = () => { }));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
fireError: (reason: any) => void = () => { };
|
|
76
|
-
onError(cb: (reason: any) => void): void {
|
|
77
|
-
this.checkNotDisposed();
|
|
78
|
-
this.fireError = cb;
|
|
79
|
-
this.toDispose.push(Disposable.create(() => this.fireError = () => { }));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Channel, AbstractChannel } from './channel-protocol';
|
|
2
|
-
|
|
3
|
-
export class HttpChannel extends AbstractChannel {
|
|
4
|
-
|
|
5
|
-
constructor(
|
|
6
|
-
id: number,
|
|
7
|
-
doSend: (content: string) => Promise<void>,
|
|
8
|
-
protected readonly path?: string
|
|
9
|
-
) {
|
|
10
|
-
super(id, doSend);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
protected override checkNotDisposed(): void {
|
|
14
|
-
// noop
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
handleMessage(message: Channel.HttpMessage) {
|
|
18
|
-
this.fireMessage(message.content);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
doGetMessage(content: string): Channel.Message {
|
|
22
|
-
return <Channel.HttpMessage>{
|
|
23
|
-
kind: 'http',
|
|
24
|
-
id: this.id,
|
|
25
|
-
path: this.path,
|
|
26
|
-
content
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { MessageConnection, createMessageConnection, Logger } from 'vscode-jsonrpc';
|
|
2
|
-
import { Channel } from '../channal/channel-protocol';
|
|
3
|
-
import { ChannelMessageReader } from './reader';
|
|
4
|
-
import { ChannelMessageWriter } from './writer';
|
|
5
|
-
import { Component } from '@celljs/core';
|
|
6
|
-
|
|
7
|
-
export const ConnnectionFactory = Symbol('ConnnectionFactory');
|
|
8
|
-
|
|
9
|
-
export interface ConnnectionFactory<T> {
|
|
10
|
-
create(t: T, logger: Logger): MessageConnection;
|
|
11
|
-
}
|
|
12
|
-
@Component(ConnnectionFactory)
|
|
13
|
-
export class ConnnectionFactoryImpl implements ConnnectionFactory<Channel> {
|
|
14
|
-
create(channel: Channel, logger: Logger): MessageConnection {
|
|
15
|
-
const messageReader = new ChannelMessageReader(channel);
|
|
16
|
-
const messageWriter = new ChannelMessageWriter(channel);
|
|
17
|
-
const connection = createMessageConnection(messageReader, messageWriter, logger);
|
|
18
|
-
connection.onClose(() => connection.dispose());
|
|
19
|
-
return connection;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { MessageConnection, ResponseError, Emitter, Event } from 'vscode-jsonrpc';
|
|
2
|
-
import { ApplicationError, Disposable, Logger, getTargetClass, getPropertyNames } from '@celljs/core';
|
|
3
|
-
import { ErrorConverter } from '../converter';
|
|
4
|
-
import { ConnectionHandler } from '../handler';
|
|
5
|
-
import { PipeManager } from '@celljs/web';
|
|
6
|
-
|
|
7
|
-
export type JsonRpcServer<Client> = Disposable & {
|
|
8
|
-
/**
|
|
9
|
-
* If this server is a proxy to a remote server then
|
|
10
|
-
* a client is used as a local object
|
|
11
|
-
* to handle JSON-RPC messages from the remote server.
|
|
12
|
-
*/
|
|
13
|
-
setClient(client: Client | undefined): void;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export interface JsonRpcConnectionEventEmitter {
|
|
17
|
-
readonly onDidOpenConnection: Event<void> ;
|
|
18
|
-
readonly onDidCloseConnection: Event<void>;
|
|
19
|
-
}
|
|
20
|
-
export type JsonRpcProxy<T> = T & JsonRpcConnectionEventEmitter;
|
|
21
|
-
|
|
22
|
-
export class JsonRpcConnectionHandler<T extends object> implements ConnectionHandler {
|
|
23
|
-
constructor(
|
|
24
|
-
readonly path: string,
|
|
25
|
-
readonly targetFactory: (proxy: JsonRpcProxy<T>) => any,
|
|
26
|
-
readonly errorConverters: ErrorConverter[],
|
|
27
|
-
readonly pipeManager: PipeManager,
|
|
28
|
-
readonly logger: Logger
|
|
29
|
-
) { }
|
|
30
|
-
|
|
31
|
-
onConnection(connection: MessageConnection): void {
|
|
32
|
-
const factory = new JsonRpcProxyFactory<T>(undefined, this.errorConverters, this.pipeManager, this.logger);
|
|
33
|
-
const proxy = factory.createProxy();
|
|
34
|
-
factory.target = this.targetFactory(proxy);
|
|
35
|
-
factory.listen(connection);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
|
|
40
|
-
|
|
41
|
-
private static SET_CLIENT = 'setClient';
|
|
42
|
-
private static ON_DID_OPEN_CONNECTION = 'onDidOpenConnection';
|
|
43
|
-
private static ON_DID_CLOSE_CONNECTION = 'onDidCloseConnection';
|
|
44
|
-
private readonly onDidOpenConnectionEmitter = new Emitter<void>();
|
|
45
|
-
private readonly onDidCloseConnectionEmitter = new Emitter<void>();
|
|
46
|
-
protected internalMethods: Map<string, () => any>;
|
|
47
|
-
|
|
48
|
-
protected connectionPromiseResolve: (connection: MessageConnection) => void;
|
|
49
|
-
protected connectionPromise: Promise<MessageConnection>;
|
|
50
|
-
|
|
51
|
-
constructor(
|
|
52
|
-
public target?: any,
|
|
53
|
-
protected errorConverters?: ErrorConverter[],
|
|
54
|
-
protected pipeManager?: PipeManager,
|
|
55
|
-
protected logger?: Logger) {
|
|
56
|
-
this.waitForConnection();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
protected waitForConnection(): void {
|
|
60
|
-
this.connectionPromise = new Promise(resolve =>
|
|
61
|
-
this.connectionPromiseResolve = resolve
|
|
62
|
-
);
|
|
63
|
-
this.connectionPromise.then(connection => {
|
|
64
|
-
connection.onClose(() =>
|
|
65
|
-
this.onDidCloseConnectionEmitter.fire(undefined)
|
|
66
|
-
);
|
|
67
|
-
this.onDidOpenConnectionEmitter.fire(undefined);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
protected getRequestHandler(prop: string) {
|
|
72
|
-
return (...args: any[]) => this.onRequest(prop, ...args);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
protected getNotificationHandler(prop: string) {
|
|
76
|
-
return (...args: any[]) => this.onNotification(prop, ...args);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
protected registerMethods(connection: MessageConnection) {
|
|
80
|
-
if (this.target) {
|
|
81
|
-
for (const prop of getPropertyNames(this.target)) {
|
|
82
|
-
if (typeof this.target[prop] === 'function') {
|
|
83
|
-
connection.onRequest(prop, this.getRequestHandler(prop));
|
|
84
|
-
connection.onNotification(prop, this.getNotificationHandler(prop));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
listen(connection: MessageConnection) {
|
|
91
|
-
this.registerMethods(connection);
|
|
92
|
-
connection.onDispose(() => this.waitForConnection());
|
|
93
|
-
connection.listen();
|
|
94
|
-
this.connectionPromiseResolve(connection);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
protected async onRequest(method: string, ...args: any[]): Promise<any> {
|
|
98
|
-
const now = Date.now();
|
|
99
|
-
const message = `${getTargetClass(this.target).name}.${method}`;
|
|
100
|
-
// eslint-disable-next-line no-unused-expressions
|
|
101
|
-
this.logger?.info(`starting ${message}`);
|
|
102
|
-
try {
|
|
103
|
-
// eslint-disable-next-line no-unused-expressions
|
|
104
|
-
await this.pipeManager?.apply({ target: this.target, method: method }, args);
|
|
105
|
-
|
|
106
|
-
return await this.target[method](...args);
|
|
107
|
-
} catch (error) {
|
|
108
|
-
const e = this.serializeError(error);
|
|
109
|
-
if (e instanceof ResponseError) {
|
|
110
|
-
throw e;
|
|
111
|
-
}
|
|
112
|
-
const reason = e.message || '';
|
|
113
|
-
const stack = e.stack || '';
|
|
114
|
-
// eslint-disable-next-line no-unused-expressions
|
|
115
|
-
this.logger?.error(`Request ${method} failed with error: ${reason}`, stack);
|
|
116
|
-
throw e;
|
|
117
|
-
} finally {
|
|
118
|
-
// eslint-disable-next-line no-unused-expressions
|
|
119
|
-
this.logger?.info(`ending ${message}, cost ${Date.now() - now}ms`);
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
protected onNotification(method: string, ...args: any[]): void {
|
|
125
|
-
this.target[method](...args);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
createProxy(): JsonRpcProxy<T> {
|
|
129
|
-
const proxy = new Proxy<T>(this as any, this);
|
|
130
|
-
return proxy as any;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
get(target: T, p: PropertyKey, receiver: any): any {
|
|
134
|
-
const method = this.getInternalMethod(p.toString());
|
|
135
|
-
if (method) {
|
|
136
|
-
return method;
|
|
137
|
-
}
|
|
138
|
-
return this.createProxyMethod(p.toString());
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
protected getInternalMethod(method: string) {
|
|
142
|
-
if (method === JsonRpcProxyFactory.SET_CLIENT) {
|
|
143
|
-
return (client: any) => this.target = client;
|
|
144
|
-
}
|
|
145
|
-
if (method === JsonRpcProxyFactory.ON_DID_OPEN_CONNECTION) {
|
|
146
|
-
return this.onDidOpenConnectionEmitter.event;
|
|
147
|
-
}
|
|
148
|
-
if (method === JsonRpcProxyFactory.ON_DID_CLOSE_CONNECTION) {
|
|
149
|
-
return this.onDidCloseConnectionEmitter.event;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
protected createProxyMethod(method: string) {
|
|
154
|
-
if (method === 'then') {
|
|
155
|
-
return undefined;
|
|
156
|
-
}
|
|
157
|
-
const isNotify = this.isNotification(method);
|
|
158
|
-
return async (...args: any[]) => {
|
|
159
|
-
const capturedError = new Error(`Request '${method}' failed`);
|
|
160
|
-
const connection = await this.connectionPromise;
|
|
161
|
-
if (isNotify) {
|
|
162
|
-
connection.sendNotification(method, ...args);
|
|
163
|
-
} else {
|
|
164
|
-
try {
|
|
165
|
-
return await connection.sendRequest(method, ...args) as Promise<any>;
|
|
166
|
-
} catch (err) {
|
|
167
|
-
throw this.deserializeError(capturedError, err);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
protected isNotification(p: PropertyKey): boolean {
|
|
174
|
-
return p.toString().startsWith('notify') || p.toString().startsWith('on');
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
protected serializeError(e: any): any {
|
|
178
|
-
if (this.errorConverters) {
|
|
179
|
-
for (const converter of this.errorConverters) {
|
|
180
|
-
const serialized = converter.serialize(e);
|
|
181
|
-
if (serialized) {
|
|
182
|
-
e = serialized;
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
if (ApplicationError.is(e)) {
|
|
188
|
-
return new ResponseError(e.code, '',
|
|
189
|
-
Object.assign({ kind: 'application' }, e.toJson())
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
return e;
|
|
193
|
-
}
|
|
194
|
-
protected deserializeError(capturedError: Error, e: any): any {
|
|
195
|
-
if (e instanceof ResponseError) {
|
|
196
|
-
const capturedStack = capturedError.stack || '';
|
|
197
|
-
if (e.data && e.data.kind === 'application') {
|
|
198
|
-
const { stack, data, message } = e.data;
|
|
199
|
-
e = ApplicationError.fromJson(e.code, {
|
|
200
|
-
message: message || capturedError.message,
|
|
201
|
-
data,
|
|
202
|
-
stack: `${capturedStack}\nCaused by: ${stack}`
|
|
203
|
-
});
|
|
204
|
-
} else {
|
|
205
|
-
e.stack = capturedStack;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (this.errorConverters) {
|
|
209
|
-
for (const converter of this.errorConverters) {
|
|
210
|
-
const deserialized = converter.deserialize(e);
|
|
211
|
-
if (deserialized) {
|
|
212
|
-
return deserialized;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return e;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { DataCallback, AbstractMessageReader, Disposable } from 'vscode-jsonrpc';
|
|
2
|
-
import { Channel } from '../channal/channel-protocol';
|
|
3
|
-
|
|
4
|
-
export class ChannelMessageReader extends AbstractMessageReader {
|
|
5
|
-
|
|
6
|
-
protected state: 'initial' | 'listening' | 'closed' = 'initial';
|
|
7
|
-
protected callback: DataCallback | undefined;
|
|
8
|
-
protected readonly events: { message?: any, error?: any }[] = [];
|
|
9
|
-
|
|
10
|
-
constructor(protected readonly channel: Channel) {
|
|
11
|
-
super();
|
|
12
|
-
this.channel.onMessage(message =>
|
|
13
|
-
this.readMessage(message)
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
listen(callback: DataCallback): Disposable {
|
|
18
|
-
if (this.state === 'initial') {
|
|
19
|
-
this.state = 'listening';
|
|
20
|
-
this.callback = callback;
|
|
21
|
-
while (this.events.length !== 0) {
|
|
22
|
-
const event = this.events.pop()!;
|
|
23
|
-
if (event.message) {
|
|
24
|
-
this.readMessage(event.message);
|
|
25
|
-
} else if (event.error) {
|
|
26
|
-
this.fireError(event.error);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return Disposable.create(() => {});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
protected readMessage(message: any): void {
|
|
34
|
-
if (this.state === 'initial') {
|
|
35
|
-
this.events.splice(0, 0, { message });
|
|
36
|
-
} else if (this.state === 'listening') {
|
|
37
|
-
const data = JSON.parse(message);
|
|
38
|
-
this.callback!(data);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected override fireError(error: any): void {
|
|
43
|
-
if (this.state === 'initial') {
|
|
44
|
-
this.events.splice(0, 0, { error });
|
|
45
|
-
} else if (this.state === 'listening') {
|
|
46
|
-
super.fireError(error);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Message, AbstractMessageWriter } from 'vscode-jsonrpc';
|
|
2
|
-
import { Channel } from '../channal';
|
|
3
|
-
|
|
4
|
-
export class ChannelMessageWriter extends AbstractMessageWriter {
|
|
5
|
-
|
|
6
|
-
protected errorCount = 0;
|
|
7
|
-
|
|
8
|
-
constructor(protected readonly channel: Channel) {
|
|
9
|
-
super();
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async write(msg: Message): Promise<void> {
|
|
13
|
-
try {
|
|
14
|
-
const content = JSON.stringify(msg);
|
|
15
|
-
this.channel.send(content);
|
|
16
|
-
} catch (e) {
|
|
17
|
-
this.errorCount++;
|
|
18
|
-
this.fireError(e, msg, this.errorCount);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
end() {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Component, Autowired, Value, PostConstruct } from '@celljs/core';
|
|
2
|
-
import { RestOperations } from '@celljs/http';
|
|
3
|
-
import { ProxyCreator } from './proxy-protocol';
|
|
4
|
-
import { EndpointResolver } from '../endpoint';
|
|
5
|
-
import { ConnnectionFactory, JsonRpcProxy } from '../factory';
|
|
6
|
-
import { Channel } from '../channal';
|
|
7
|
-
import { ErrorConverter } from '../converter';
|
|
8
|
-
import { AxiosRequestConfig } from 'axios';
|
|
9
|
-
import { ClientConfigProcessor } from '../processor';
|
|
10
|
-
import { HttpProxyCreator } from './http-proxy-creator';
|
|
11
|
-
|
|
12
|
-
@Component(ProxyCreator)
|
|
13
|
-
export class DelegatingHttpProxyCreator implements ProxyCreator {
|
|
14
|
-
|
|
15
|
-
@Autowired(ConnnectionFactory)
|
|
16
|
-
protected connnectionFactory: ConnnectionFactory<Channel>;
|
|
17
|
-
|
|
18
|
-
@Autowired(EndpointResolver)
|
|
19
|
-
protected endpointResolver: EndpointResolver;
|
|
20
|
-
|
|
21
|
-
@Autowired(RestOperations)
|
|
22
|
-
protected restOperations: RestOperations;
|
|
23
|
-
|
|
24
|
-
@Autowired(ClientConfigProcessor)
|
|
25
|
-
protected clientConfigProcessor: ClientConfigProcessor;
|
|
26
|
-
|
|
27
|
-
@Value('cell.rpc.client.config')
|
|
28
|
-
protected readonly clientConfig: AxiosRequestConfig;
|
|
29
|
-
|
|
30
|
-
@Value('cell.rpc.merge.maxCount')
|
|
31
|
-
protected readonly maxCount: number;
|
|
32
|
-
|
|
33
|
-
@Value('cell.rpc.merge.maxLength')
|
|
34
|
-
protected readonly maxLength: number;
|
|
35
|
-
|
|
36
|
-
@Value('cell.rpc.merge.timerDelay')
|
|
37
|
-
protected readonly timerDelay: number;
|
|
38
|
-
|
|
39
|
-
@Value('cell.rpc.merge.enabled')
|
|
40
|
-
protected readonly enabled: boolean;
|
|
41
|
-
|
|
42
|
-
protected delegate: ProxyCreator;
|
|
43
|
-
|
|
44
|
-
@PostConstruct()
|
|
45
|
-
protected init() {
|
|
46
|
-
this.delegate = new HttpProxyCreator({
|
|
47
|
-
connnectionFactory: this.connnectionFactory,
|
|
48
|
-
endpointResolver: this.endpointResolver,
|
|
49
|
-
restOperations: this.restOperations,
|
|
50
|
-
clientConfigProcessor: this.clientConfigProcessor,
|
|
51
|
-
clientConfig: this.clientConfig,
|
|
52
|
-
merge: {
|
|
53
|
-
maxCount: this.maxCount,
|
|
54
|
-
maxLength: this.maxLength,
|
|
55
|
-
timerDelay: this.timerDelay,
|
|
56
|
-
enabled: this.enabled
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
create<T extends object>(path: string, errorConverters?: ErrorConverter[], target?: object | undefined): JsonRpcProxy<T> {
|
|
62
|
-
return this.delegate.create(path, errorConverters, target);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
support(path: string): number {
|
|
66
|
-
return this.delegate.support(path);
|
|
67
|
-
}
|
|
68
|
-
}
|