@celljs/rpc 4.3.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.
Files changed (545) hide show
  1. package/README.md +117 -1
  2. package/cell.schema.json +100 -0
  3. package/cell.yml +12 -8
  4. package/esm/common/annotation/index.d.ts +2 -0
  5. package/esm/common/annotation/index.js +2 -0
  6. package/esm/common/annotation/index.js.map +1 -1
  7. package/esm/common/annotation/rpc-client.d.ts +7 -0
  8. package/esm/common/annotation/rpc-client.js +18 -0
  9. package/esm/common/annotation/rpc-client.js.map +1 -0
  10. package/esm/common/annotation/rpc-protocol.d.ts +7 -0
  11. package/esm/common/annotation/rpc-protocol.js +2 -0
  12. package/esm/common/annotation/rpc-protocol.js.map +1 -0
  13. package/esm/common/annotation/rpc.d.ts +4 -0
  14. package/esm/common/annotation/rpc.js +14 -18
  15. package/esm/common/annotation/rpc.js.map +1 -1
  16. package/esm/common/client/client-protocol.d.ts +6 -0
  17. package/esm/common/client/client-protocol.js +2 -0
  18. package/esm/common/client/client-protocol.js.map +1 -0
  19. package/esm/common/client/index.d.ts +2 -0
  20. package/esm/common/client/index.js +3 -0
  21. package/esm/common/client/index.js.map +1 -0
  22. package/esm/common/client/rpc-client-registry.d.ts +14 -0
  23. package/esm/common/client/rpc-client-registry.js +51 -0
  24. package/esm/common/client/rpc-client-registry.js.map +1 -0
  25. package/esm/common/constants.d.ts +3 -1
  26. package/esm/common/constants.js +3 -1
  27. package/esm/common/constants.js.map +1 -1
  28. package/esm/common/converter/converter-protocol.d.ts +6 -2
  29. package/esm/common/converter/converter-protocol.js +1 -0
  30. package/esm/common/converter/converter-protocol.js.map +1 -1
  31. package/esm/common/endpoint/endpoint-protocol.d.ts +3 -0
  32. package/esm/common/endpoint/endpoint-resolver.d.ts +2 -0
  33. package/esm/common/endpoint/endpoint-resolver.js +17 -3
  34. package/esm/common/endpoint/endpoint-resolver.js.map +1 -1
  35. package/esm/common/error/error.d.ts +23 -0
  36. package/esm/common/error/error.js +34 -2
  37. package/esm/common/error/error.js.map +1 -1
  38. package/esm/common/index.d.ts +6 -6
  39. package/esm/common/index.js +6 -6
  40. package/esm/common/index.js.map +1 -1
  41. package/esm/common/module.js +5 -4
  42. package/esm/common/module.js.map +1 -1
  43. package/esm/common/processor/client-config-processor.d.ts +2 -2
  44. package/esm/common/processor/client-config-processor.js.map +1 -1
  45. package/esm/common/processor/processor-protocol.d.ts +2 -2
  46. package/esm/common/protocol/index.d.ts +1 -0
  47. package/esm/common/protocol/index.js +2 -0
  48. package/esm/common/protocol/index.js.map +1 -0
  49. package/esm/common/protocol/json-rpc.d.ts +42 -0
  50. package/esm/common/protocol/json-rpc.js +48 -0
  51. package/esm/common/protocol/json-rpc.js.map +1 -0
  52. package/esm/common/proxy/index.d.ts +1 -4
  53. package/esm/common/proxy/index.js +1 -4
  54. package/esm/common/proxy/index.js.map +1 -1
  55. package/esm/common/proxy/rpc-proxy.d.ts +6 -0
  56. package/esm/common/proxy/rpc-proxy.js +40 -0
  57. package/esm/common/proxy/rpc-proxy.js.map +1 -0
  58. package/esm/common/transport/http-transport.d.ts +50 -0
  59. package/esm/common/transport/http-transport.js +98 -0
  60. package/esm/common/transport/http-transport.js.map +1 -0
  61. package/esm/common/transport/index.d.ts +4 -0
  62. package/esm/common/transport/index.js +5 -0
  63. package/esm/common/transport/index.js.map +1 -0
  64. package/esm/common/transport/transport-protocol.d.ts +12 -0
  65. package/esm/common/transport/transport-protocol.js +2 -0
  66. package/esm/common/transport/transport-protocol.js.map +1 -0
  67. package/esm/common/transport/transport-provider.d.ts +34 -0
  68. package/esm/common/transport/transport-provider.js +103 -0
  69. package/esm/common/transport/transport-provider.js.map +1 -0
  70. package/esm/common/transport/websocket-transport.d.ts +54 -0
  71. package/esm/common/transport/websocket-transport.js +144 -0
  72. package/esm/common/transport/websocket-transport.js.map +1 -0
  73. package/esm/common/utils/index.d.ts +1 -1
  74. package/esm/common/utils/index.js +1 -1
  75. package/esm/common/utils/index.js.map +1 -1
  76. package/esm/common/utils/rpc-method-util.d.ts +10 -0
  77. package/esm/common/utils/rpc-method-util.js +28 -0
  78. package/esm/common/utils/rpc-method-util.js.map +1 -0
  79. package/esm/common/utils/rpc-util.d.ts +9 -9
  80. package/esm/common/utils/rpc-util.js +24 -30
  81. package/esm/common/utils/rpc-util.js.map +1 -1
  82. package/esm/node/connection/connection-protocol.d.ts +26 -0
  83. package/esm/node/connection/connection-protocol.js +3 -0
  84. package/esm/node/connection/connection-protocol.js.map +1 -0
  85. package/esm/node/connection/index.d.ts +4 -0
  86. package/esm/node/connection/index.js +5 -0
  87. package/esm/node/connection/index.js.map +1 -0
  88. package/esm/node/connection/rpc-connection-manager.d.ts +10 -0
  89. package/esm/node/connection/rpc-connection-manager.js +35 -0
  90. package/esm/node/connection/rpc-connection-manager.js.map +1 -0
  91. package/esm/node/connection/rpc-connection.d.ts +33 -0
  92. package/esm/node/connection/rpc-connection.js +106 -0
  93. package/esm/node/connection/rpc-connection.js.map +1 -0
  94. package/esm/node/connection/rpc-context.d.ts +14 -0
  95. package/esm/node/connection/rpc-context.js +29 -0
  96. package/esm/node/connection/rpc-context.js.map +1 -0
  97. package/esm/node/index.d.ts +3 -2
  98. package/esm/node/index.js +3 -2
  99. package/esm/node/index.js.map +1 -1
  100. package/esm/node/server/index.d.ts +2 -0
  101. package/esm/node/server/index.js +3 -0
  102. package/esm/node/server/index.js.map +1 -0
  103. package/esm/node/server/rpc-handler-adapter.d.ts +15 -0
  104. package/esm/node/server/rpc-handler-adapter.js +74 -0
  105. package/esm/node/server/rpc-handler-adapter.js.map +1 -0
  106. package/esm/node/server/rpc-invoker.d.ts +28 -0
  107. package/esm/node/server/rpc-invoker.js +113 -0
  108. package/esm/node/server/rpc-invoker.js.map +1 -0
  109. package/esm/node/test/websocket-fixture-protocol.d.ts +36 -0
  110. package/esm/node/test/websocket-fixture-protocol.js +7 -0
  111. package/esm/node/test/websocket-fixture-protocol.js.map +1 -0
  112. package/esm/node/test/websocket-fixture.d.ts +40 -0
  113. package/esm/node/test/websocket-fixture.js +128 -0
  114. package/esm/node/test/websocket-fixture.js.map +1 -0
  115. package/esm/node/websocket/index.d.ts +4 -0
  116. package/esm/node/websocket/index.js +5 -0
  117. package/esm/node/websocket/index.js.map +1 -0
  118. package/esm/node/websocket/rpc-websocket-server.d.ts +45 -0
  119. package/esm/node/websocket/rpc-websocket-server.js +167 -0
  120. package/esm/node/websocket/rpc-websocket-server.js.map +1 -0
  121. package/esm/node/websocket/websocket-connection.d.ts +55 -0
  122. package/esm/node/websocket/websocket-connection.js +181 -0
  123. package/esm/node/websocket/websocket-connection.js.map +1 -0
  124. package/esm/node/websocket/websocket-exchange.d.ts +38 -0
  125. package/esm/node/websocket/websocket-exchange.js +124 -0
  126. package/esm/node/websocket/websocket-exchange.js.map +1 -0
  127. package/esm/node/websocket/websocket-frames.d.ts +31 -0
  128. package/esm/node/websocket/websocket-frames.js +119 -0
  129. package/esm/node/websocket/websocket-frames.js.map +1 -0
  130. package/lib/common/annotation/index.d.ts +2 -0
  131. package/lib/common/annotation/index.d.ts.map +1 -1
  132. package/lib/common/annotation/index.js +2 -0
  133. package/lib/common/annotation/index.js.map +1 -1
  134. package/lib/common/annotation/rpc-client.d.ts +8 -0
  135. package/lib/common/annotation/rpc-client.d.ts.map +1 -0
  136. package/lib/common/annotation/rpc-client.js +21 -0
  137. package/lib/common/annotation/rpc-client.js.map +1 -0
  138. package/lib/common/annotation/rpc-protocol.d.ts +8 -0
  139. package/lib/common/annotation/rpc-protocol.d.ts.map +1 -0
  140. package/lib/common/annotation/rpc-protocol.js +5 -0
  141. package/lib/common/annotation/rpc-protocol.js.map +1 -0
  142. package/lib/common/annotation/rpc.d.ts +4 -0
  143. package/lib/common/annotation/rpc.d.ts.map +1 -1
  144. package/lib/common/annotation/rpc.js +12 -16
  145. package/lib/common/annotation/rpc.js.map +1 -1
  146. package/lib/common/client/client-protocol.d.ts +7 -0
  147. package/lib/common/client/client-protocol.d.ts.map +1 -0
  148. package/lib/common/client/client-protocol.js +5 -0
  149. package/lib/common/client/client-protocol.js.map +1 -0
  150. package/lib/common/client/index.d.ts +3 -0
  151. package/lib/common/client/index.d.ts.map +1 -0
  152. package/lib/common/{handler → client}/index.js +2 -2
  153. package/lib/common/client/index.js.map +1 -0
  154. package/lib/common/client/rpc-client-registry.d.ts +15 -0
  155. package/lib/common/client/rpc-client-registry.d.ts.map +1 -0
  156. package/lib/common/client/rpc-client-registry.js +54 -0
  157. package/lib/common/client/rpc-client-registry.js.map +1 -0
  158. package/lib/common/constants.d.ts +3 -1
  159. package/lib/common/constants.d.ts.map +1 -1
  160. package/lib/common/constants.js +4 -2
  161. package/lib/common/constants.js.map +1 -1
  162. package/lib/common/converter/converter-protocol.d.ts +6 -2
  163. package/lib/common/converter/converter-protocol.d.ts.map +1 -1
  164. package/lib/common/converter/converter-protocol.js +1 -0
  165. package/lib/common/converter/converter-protocol.js.map +1 -1
  166. package/lib/common/endpoint/endpoint-protocol.d.ts +3 -0
  167. package/lib/common/endpoint/endpoint-protocol.d.ts.map +1 -1
  168. package/lib/common/endpoint/endpoint-resolver.d.ts +2 -0
  169. package/lib/common/endpoint/endpoint-resolver.d.ts.map +1 -1
  170. package/lib/common/endpoint/endpoint-resolver.js +16 -2
  171. package/lib/common/endpoint/endpoint-resolver.js.map +1 -1
  172. package/lib/common/error/error.d.ts +23 -0
  173. package/lib/common/error/error.d.ts.map +1 -1
  174. package/lib/common/error/error.js +35 -2
  175. package/lib/common/error/error.js.map +1 -1
  176. package/lib/common/index.d.ts +6 -6
  177. package/lib/common/index.d.ts.map +1 -1
  178. package/lib/common/index.js +6 -6
  179. package/lib/common/index.js.map +1 -1
  180. package/lib/common/module.d.ts.map +1 -1
  181. package/lib/common/module.js +4 -3
  182. package/lib/common/module.js.map +1 -1
  183. package/lib/common/processor/client-config-processor.d.ts +2 -2
  184. package/lib/common/processor/client-config-processor.d.ts.map +1 -1
  185. package/lib/common/processor/client-config-processor.js.map +1 -1
  186. package/lib/common/processor/processor-protocol.d.ts +2 -2
  187. package/lib/common/processor/processor-protocol.d.ts.map +1 -1
  188. package/lib/common/protocol/index.d.ts +2 -0
  189. package/lib/common/protocol/index.d.ts.map +1 -0
  190. package/lib/common/{channal → protocol}/index.js +1 -2
  191. package/lib/common/protocol/index.js.map +1 -0
  192. package/lib/common/protocol/json-rpc.d.ts +43 -0
  193. package/lib/common/protocol/json-rpc.d.ts.map +1 -0
  194. package/lib/common/protocol/json-rpc.js +51 -0
  195. package/lib/common/protocol/json-rpc.js.map +1 -0
  196. package/lib/common/proxy/index.d.ts +1 -4
  197. package/lib/common/proxy/index.d.ts.map +1 -1
  198. package/lib/common/proxy/index.js +1 -4
  199. package/lib/common/proxy/index.js.map +1 -1
  200. package/lib/common/proxy/rpc-proxy.d.ts +7 -0
  201. package/lib/common/proxy/rpc-proxy.d.ts.map +1 -0
  202. package/lib/common/proxy/rpc-proxy.js +43 -0
  203. package/lib/common/proxy/rpc-proxy.js.map +1 -0
  204. package/lib/common/transport/http-transport.d.ts +51 -0
  205. package/lib/common/transport/http-transport.d.ts.map +1 -0
  206. package/lib/common/transport/http-transport.js +102 -0
  207. package/lib/common/transport/http-transport.js.map +1 -0
  208. package/lib/common/transport/index.d.ts +5 -0
  209. package/lib/common/transport/index.d.ts.map +1 -0
  210. package/lib/common/{factory → transport}/index.js +4 -4
  211. package/lib/common/transport/index.js.map +1 -0
  212. package/lib/common/transport/transport-protocol.d.ts +13 -0
  213. package/lib/common/transport/transport-protocol.d.ts.map +1 -0
  214. package/lib/common/transport/transport-protocol.js +5 -0
  215. package/lib/common/transport/transport-protocol.js.map +1 -0
  216. package/lib/common/transport/transport-provider.d.ts +35 -0
  217. package/lib/common/transport/transport-provider.d.ts.map +1 -0
  218. package/lib/common/transport/transport-provider.js +106 -0
  219. package/lib/common/transport/transport-provider.js.map +1 -0
  220. package/lib/common/transport/websocket-transport.d.ts +55 -0
  221. package/lib/common/transport/websocket-transport.d.ts.map +1 -0
  222. package/lib/common/transport/websocket-transport.js +148 -0
  223. package/lib/common/transport/websocket-transport.js.map +1 -0
  224. package/lib/common/utils/index.d.ts +1 -1
  225. package/lib/common/utils/index.d.ts.map +1 -1
  226. package/lib/common/utils/index.js +1 -1
  227. package/lib/common/utils/index.js.map +1 -1
  228. package/lib/common/utils/rpc-method-util.d.ts +11 -0
  229. package/lib/common/utils/rpc-method-util.d.ts.map +1 -0
  230. package/lib/common/utils/rpc-method-util.js +31 -0
  231. package/lib/common/utils/rpc-method-util.js.map +1 -0
  232. package/lib/common/utils/rpc-util.d.ts +9 -9
  233. package/lib/common/utils/rpc-util.d.ts.map +1 -1
  234. package/lib/common/utils/rpc-util.js +24 -30
  235. package/lib/common/utils/rpc-util.js.map +1 -1
  236. package/lib/node/connection/connection-protocol.d.ts +27 -0
  237. package/lib/node/connection/connection-protocol.d.ts.map +1 -0
  238. package/lib/node/connection/connection-protocol.js +6 -0
  239. package/lib/node/connection/connection-protocol.js.map +1 -0
  240. package/lib/node/connection/index.d.ts +5 -0
  241. package/lib/node/connection/index.d.ts.map +1 -0
  242. package/lib/node/{channel → connection}/index.js +4 -4
  243. package/lib/node/connection/index.js.map +1 -0
  244. package/lib/node/connection/rpc-connection-manager.d.ts +11 -0
  245. package/lib/node/connection/rpc-connection-manager.d.ts.map +1 -0
  246. package/lib/node/connection/rpc-connection-manager.js +38 -0
  247. package/lib/node/connection/rpc-connection-manager.js.map +1 -0
  248. package/lib/node/connection/rpc-connection.d.ts +34 -0
  249. package/lib/node/connection/rpc-connection.d.ts.map +1 -0
  250. package/lib/node/connection/rpc-connection.js +110 -0
  251. package/lib/node/connection/rpc-connection.js.map +1 -0
  252. package/lib/node/connection/rpc-context.d.ts +15 -0
  253. package/lib/node/connection/rpc-context.d.ts.map +1 -0
  254. package/lib/node/connection/rpc-context.js +33 -0
  255. package/lib/node/connection/rpc-context.js.map +1 -0
  256. package/lib/node/index.d.ts +3 -2
  257. package/lib/node/index.d.ts.map +1 -1
  258. package/lib/node/index.js +3 -2
  259. package/lib/node/index.js.map +1 -1
  260. package/lib/node/rpc-http.spec.d.ts +2 -0
  261. package/lib/node/rpc-http.spec.d.ts.map +1 -0
  262. package/lib/node/rpc-http.spec.js +121 -0
  263. package/lib/node/rpc-http.spec.js.map +1 -0
  264. package/lib/node/rpc-websocket.spec.d.ts +6 -0
  265. package/lib/node/rpc-websocket.spec.d.ts.map +1 -0
  266. package/lib/node/rpc-websocket.spec.js +196 -0
  267. package/lib/node/rpc-websocket.spec.js.map +1 -0
  268. package/lib/node/server/index.d.ts +3 -0
  269. package/lib/node/server/index.d.ts.map +1 -0
  270. package/lib/node/{handler → server}/index.js +2 -2
  271. package/lib/node/server/index.js.map +1 -0
  272. package/lib/node/server/rpc-handler-adapter.d.ts +16 -0
  273. package/lib/node/server/rpc-handler-adapter.d.ts.map +1 -0
  274. package/lib/node/{handler/handler-adapter.js → server/rpc-handler-adapter.js} +40 -18
  275. package/lib/node/server/rpc-handler-adapter.js.map +1 -0
  276. package/lib/node/server/rpc-invoker.d.ts +29 -0
  277. package/lib/node/server/rpc-invoker.d.ts.map +1 -0
  278. package/lib/node/server/rpc-invoker.js +116 -0
  279. package/lib/node/server/rpc-invoker.js.map +1 -0
  280. package/lib/node/test/websocket-fixture-protocol.d.ts +37 -0
  281. package/lib/node/test/websocket-fixture-protocol.d.ts.map +1 -0
  282. package/lib/node/test/websocket-fixture-protocol.js +10 -0
  283. package/lib/node/test/websocket-fixture-protocol.js.map +1 -0
  284. package/lib/node/test/websocket-fixture.d.ts +41 -0
  285. package/lib/node/test/websocket-fixture.d.ts.map +1 -0
  286. package/lib/node/test/websocket-fixture.js +135 -0
  287. package/lib/node/test/websocket-fixture.js.map +1 -0
  288. package/lib/node/websocket/index.d.ts +5 -0
  289. package/lib/node/websocket/index.d.ts.map +1 -0
  290. package/lib/node/websocket/index.js +21 -0
  291. package/lib/node/websocket/index.js.map +1 -0
  292. package/lib/node/websocket/rpc-websocket-server.d.ts +46 -0
  293. package/lib/node/websocket/rpc-websocket-server.d.ts.map +1 -0
  294. package/lib/node/websocket/rpc-websocket-server.js +170 -0
  295. package/lib/node/websocket/rpc-websocket-server.js.map +1 -0
  296. package/lib/node/websocket/websocket-connection.d.ts +56 -0
  297. package/lib/node/websocket/websocket-connection.d.ts.map +1 -0
  298. package/lib/node/websocket/websocket-connection.js +185 -0
  299. package/lib/node/websocket/websocket-connection.js.map +1 -0
  300. package/lib/node/websocket/websocket-exchange.d.ts +39 -0
  301. package/lib/node/websocket/websocket-exchange.d.ts.map +1 -0
  302. package/lib/node/websocket/websocket-exchange.js +128 -0
  303. package/lib/node/websocket/websocket-exchange.js.map +1 -0
  304. package/lib/node/websocket/websocket-frames.d.ts +32 -0
  305. package/lib/node/websocket/websocket-frames.d.ts.map +1 -0
  306. package/lib/node/websocket/websocket-frames.js +124 -0
  307. package/lib/node/websocket/websocket-frames.js.map +1 -0
  308. package/lib/node/websocket/websocket-frames.spec.d.ts +2 -0
  309. package/lib/node/websocket/websocket-frames.spec.d.ts.map +1 -0
  310. package/lib/node/websocket/websocket-frames.spec.js +59 -0
  311. package/lib/node/websocket/websocket-frames.spec.js.map +1 -0
  312. package/package.json +28 -25
  313. package/src/common/annotation/index.ts +2 -0
  314. package/src/common/annotation/rpc-client.ts +17 -0
  315. package/src/common/annotation/rpc-protocol.ts +8 -0
  316. package/src/common/annotation/rpc.ts +13 -21
  317. package/src/common/client/client-protocol.ts +7 -0
  318. package/src/common/client/index.ts +2 -0
  319. package/src/common/client/rpc-client-registry.ts +42 -0
  320. package/src/common/constants.ts +4 -1
  321. package/src/common/converter/converter-protocol.ts +7 -2
  322. package/src/common/endpoint/endpoint-protocol.ts +3 -0
  323. package/src/common/endpoint/endpoint-resolver.ts +18 -4
  324. package/src/common/error/error.ts +41 -2
  325. package/src/common/index.ts +6 -6
  326. package/src/common/module.ts +7 -8
  327. package/src/common/processor/client-config-processor.ts +2 -2
  328. package/src/common/processor/processor-protocol.ts +2 -2
  329. package/src/common/protocol/index.ts +1 -0
  330. package/src/common/protocol/json-rpc.ts +74 -0
  331. package/src/common/proxy/index.ts +1 -5
  332. package/src/common/proxy/rpc-proxy.ts +42 -0
  333. package/src/common/transport/http-transport.ts +134 -0
  334. package/src/common/transport/index.ts +4 -0
  335. package/src/common/transport/transport-protocol.ts +16 -0
  336. package/src/common/transport/transport-provider.ts +86 -0
  337. package/src/common/transport/websocket-transport.ts +171 -0
  338. package/src/common/utils/index.ts +1 -1
  339. package/src/common/utils/rpc-method-util.ts +26 -0
  340. package/src/common/utils/rpc-util.ts +24 -35
  341. package/src/node/connection/connection-protocol.ts +30 -0
  342. package/src/node/connection/index.ts +3 -0
  343. package/src/node/connection/rpc-connection-manager.ts +29 -0
  344. package/src/node/connection/rpc-connection.ts +122 -0
  345. package/src/node/connection/rpc-context.ts +29 -0
  346. package/src/node/index.ts +3 -2
  347. package/src/node/rpc-http.spec.ts +126 -0
  348. package/src/node/rpc-websocket.spec.ts +196 -0
  349. package/src/node/server/index.ts +2 -0
  350. package/src/node/server/rpc-handler-adapter.ts +60 -0
  351. package/src/node/server/rpc-invoker.ts +104 -0
  352. package/src/node/test/websocket-fixture-protocol.ts +32 -0
  353. package/src/node/test/websocket-fixture.ts +122 -0
  354. package/src/node/websocket/index.ts +4 -0
  355. package/src/node/websocket/rpc-websocket-server.ts +163 -0
  356. package/src/node/websocket/websocket-connection.ts +198 -0
  357. package/src/node/websocket/websocket-exchange.ts +138 -0
  358. package/src/node/websocket/websocket-frames.spec.ts +62 -0
  359. package/src/node/websocket/websocket-frames.ts +122 -0
  360. package/esm/common/channal/channel-protocol.d.ts +0 -51
  361. package/esm/common/channal/channel-protocol.js +0 -34
  362. package/esm/common/channal/channel-protocol.js.map +0 -1
  363. package/esm/common/channal/http-channel.d.ts +0 -8
  364. package/esm/common/channal/http-channel.js +0 -22
  365. package/esm/common/channal/http-channel.js.map +0 -1
  366. package/esm/common/channal/index.d.ts +0 -2
  367. package/esm/common/channal/index.js +0 -3
  368. package/esm/common/channal/index.js.map +0 -1
  369. package/esm/common/factory/connection-factory.d.ts +0 -9
  370. package/esm/common/factory/connection-factory.js +0 -25
  371. package/esm/common/factory/connection-factory.js.map +0 -1
  372. package/esm/common/factory/index.d.ts +0 -4
  373. package/esm/common/factory/index.js +0 -5
  374. package/esm/common/factory/index.js.map +0 -1
  375. package/esm/common/factory/proxy-factory.d.ts +0 -56
  376. package/esm/common/factory/proxy-factory.js +0 -177
  377. package/esm/common/factory/proxy-factory.js.map +0 -1
  378. package/esm/common/factory/reader.d.ts +0 -15
  379. package/esm/common/factory/reader.js +0 -44
  380. package/esm/common/factory/reader.js.map +0 -1
  381. package/esm/common/factory/writer.d.ts +0 -9
  382. package/esm/common/factory/writer.js +0 -21
  383. package/esm/common/factory/writer.js.map +0 -1
  384. package/esm/common/handler/connection-handler.d.ts +0 -6
  385. package/esm/common/handler/connection-handler.js +0 -4
  386. package/esm/common/handler/connection-handler.js.map +0 -1
  387. package/esm/common/handler/handler-protocol.d.ts +0 -6
  388. package/esm/common/handler/handler-protocol.js +0 -2
  389. package/esm/common/handler/handler-protocol.js.map +0 -1
  390. package/esm/common/handler/index.d.ts +0 -2
  391. package/esm/common/handler/index.js +0 -3
  392. package/esm/common/handler/index.js.map +0 -1
  393. package/esm/common/proxy/delegating-http-proxy-creator.d.ts +0 -23
  394. package/esm/common/proxy/delegating-http-proxy-creator.js +0 -86
  395. package/esm/common/proxy/delegating-http-proxy-creator.js.map +0 -1
  396. package/esm/common/proxy/http-proxy-creator.d.ts +0 -42
  397. package/esm/common/proxy/http-proxy-creator.js +0 -139
  398. package/esm/common/proxy/http-proxy-creator.js.map +0 -1
  399. package/esm/common/proxy/proxy-protocol.d.ts +0 -20
  400. package/esm/common/proxy/proxy-protocol.js +0 -3
  401. package/esm/common/proxy/proxy-protocol.js.map +0 -1
  402. package/esm/common/proxy/proxy-provider.d.ts +0 -9
  403. package/esm/common/proxy/proxy-provider.js +0 -40
  404. package/esm/common/proxy/proxy-provider.js.map +0 -1
  405. package/esm/common/utils/logger.d.ts +0 -8
  406. package/esm/common/utils/logger.js +0 -18
  407. package/esm/common/utils/logger.js.map +0 -1
  408. package/esm/node/channel/channel-manager.d.ts +0 -9
  409. package/esm/node/channel/channel-manager.js +0 -56
  410. package/esm/node/channel/channel-manager.js.map +0 -1
  411. package/esm/node/channel/channel-middleware.d.ts +0 -7
  412. package/esm/node/channel/channel-middleware.js +0 -37
  413. package/esm/node/channel/channel-middleware.js.map +0 -1
  414. package/esm/node/channel/channel-protocol.d.ts +0 -12
  415. package/esm/node/channel/channel-protocol.js +0 -6
  416. package/esm/node/channel/channel-protocol.js.map +0 -1
  417. package/esm/node/channel/channel-strategy.d.ts +0 -9
  418. package/esm/node/channel/channel-strategy.js +0 -61
  419. package/esm/node/channel/channel-strategy.js.map +0 -1
  420. package/esm/node/channel/index.d.ts +0 -4
  421. package/esm/node/channel/index.js +0 -5
  422. package/esm/node/channel/index.js.map +0 -1
  423. package/esm/node/handler/handler-adapter.d.ts +0 -13
  424. package/esm/node/handler/handler-adapter.js +0 -52
  425. package/esm/node/handler/handler-adapter.js.map +0 -1
  426. package/esm/node/handler/handler-protocol.d.ts +0 -1
  427. package/esm/node/handler/handler-protocol.js +0 -2
  428. package/esm/node/handler/handler-protocol.js.map +0 -1
  429. package/esm/node/handler/index.d.ts +0 -2
  430. package/esm/node/handler/index.js +0 -3
  431. package/esm/node/handler/index.js.map +0 -1
  432. package/lib/common/channal/channel-protocol.d.ts +0 -52
  433. package/lib/common/channal/channel-protocol.d.ts.map +0 -1
  434. package/lib/common/channal/channel-protocol.js +0 -38
  435. package/lib/common/channal/channel-protocol.js.map +0 -1
  436. package/lib/common/channal/http-channel.d.ts +0 -9
  437. package/lib/common/channal/http-channel.d.ts.map +0 -1
  438. package/lib/common/channal/http-channel.js +0 -26
  439. package/lib/common/channal/http-channel.js.map +0 -1
  440. package/lib/common/channal/index.d.ts +0 -3
  441. package/lib/common/channal/index.d.ts.map +0 -1
  442. package/lib/common/channal/index.js.map +0 -1
  443. package/lib/common/factory/connection-factory.d.ts +0 -10
  444. package/lib/common/factory/connection-factory.d.ts.map +0 -1
  445. package/lib/common/factory/connection-factory.js +0 -28
  446. package/lib/common/factory/connection-factory.js.map +0 -1
  447. package/lib/common/factory/index.d.ts +0 -5
  448. package/lib/common/factory/index.d.ts.map +0 -1
  449. package/lib/common/factory/index.js.map +0 -1
  450. package/lib/common/factory/proxy-factory.d.ts +0 -57
  451. package/lib/common/factory/proxy-factory.d.ts.map +0 -1
  452. package/lib/common/factory/proxy-factory.js +0 -182
  453. package/lib/common/factory/proxy-factory.js.map +0 -1
  454. package/lib/common/factory/reader.d.ts +0 -16
  455. package/lib/common/factory/reader.d.ts.map +0 -1
  456. package/lib/common/factory/reader.js +0 -48
  457. package/lib/common/factory/reader.js.map +0 -1
  458. package/lib/common/factory/writer.d.ts +0 -10
  459. package/lib/common/factory/writer.d.ts.map +0 -1
  460. package/lib/common/factory/writer.js +0 -25
  461. package/lib/common/factory/writer.js.map +0 -1
  462. package/lib/common/handler/connection-handler.d.ts +0 -7
  463. package/lib/common/handler/connection-handler.d.ts.map +0 -1
  464. package/lib/common/handler/connection-handler.js +0 -8
  465. package/lib/common/handler/connection-handler.js.map +0 -1
  466. package/lib/common/handler/handler-protocol.d.ts +0 -7
  467. package/lib/common/handler/handler-protocol.d.ts.map +0 -1
  468. package/lib/common/handler/handler-protocol.js +0 -5
  469. package/lib/common/handler/handler-protocol.js.map +0 -1
  470. package/lib/common/handler/index.d.ts +0 -3
  471. package/lib/common/handler/index.d.ts.map +0 -1
  472. package/lib/common/handler/index.js.map +0 -1
  473. package/lib/common/proxy/delegating-http-proxy-creator.d.ts +0 -24
  474. package/lib/common/proxy/delegating-http-proxy-creator.d.ts.map +0 -1
  475. package/lib/common/proxy/delegating-http-proxy-creator.js +0 -89
  476. package/lib/common/proxy/delegating-http-proxy-creator.js.map +0 -1
  477. package/lib/common/proxy/http-proxy-creator.d.ts +0 -43
  478. package/lib/common/proxy/http-proxy-creator.d.ts.map +0 -1
  479. package/lib/common/proxy/http-proxy-creator.js +0 -143
  480. package/lib/common/proxy/http-proxy-creator.js.map +0 -1
  481. package/lib/common/proxy/proxy-protocol.d.ts +0 -21
  482. package/lib/common/proxy/proxy-protocol.d.ts.map +0 -1
  483. package/lib/common/proxy/proxy-protocol.js +0 -6
  484. package/lib/common/proxy/proxy-protocol.js.map +0 -1
  485. package/lib/common/proxy/proxy-provider.d.ts +0 -10
  486. package/lib/common/proxy/proxy-provider.d.ts.map +0 -1
  487. package/lib/common/proxy/proxy-provider.js +0 -43
  488. package/lib/common/proxy/proxy-provider.js.map +0 -1
  489. package/lib/common/utils/logger.d.ts +0 -9
  490. package/lib/common/utils/logger.d.ts.map +0 -1
  491. package/lib/common/utils/logger.js +0 -22
  492. package/lib/common/utils/logger.js.map +0 -1
  493. package/lib/node/channel/channel-manager.d.ts +0 -10
  494. package/lib/node/channel/channel-manager.d.ts.map +0 -1
  495. package/lib/node/channel/channel-manager.js +0 -59
  496. package/lib/node/channel/channel-manager.js.map +0 -1
  497. package/lib/node/channel/channel-middleware.d.ts +0 -8
  498. package/lib/node/channel/channel-middleware.d.ts.map +0 -1
  499. package/lib/node/channel/channel-middleware.js +0 -40
  500. package/lib/node/channel/channel-middleware.js.map +0 -1
  501. package/lib/node/channel/channel-protocol.d.ts +0 -13
  502. package/lib/node/channel/channel-protocol.d.ts.map +0 -1
  503. package/lib/node/channel/channel-protocol.js +0 -9
  504. package/lib/node/channel/channel-protocol.js.map +0 -1
  505. package/lib/node/channel/channel-strategy.d.ts +0 -10
  506. package/lib/node/channel/channel-strategy.d.ts.map +0 -1
  507. package/lib/node/channel/channel-strategy.js +0 -64
  508. package/lib/node/channel/channel-strategy.js.map +0 -1
  509. package/lib/node/channel/index.d.ts +0 -5
  510. package/lib/node/channel/index.d.ts.map +0 -1
  511. package/lib/node/channel/index.js.map +0 -1
  512. package/lib/node/handler/handler-adapter.d.ts +0 -14
  513. package/lib/node/handler/handler-adapter.d.ts.map +0 -1
  514. package/lib/node/handler/handler-adapter.js.map +0 -1
  515. package/lib/node/handler/handler-protocol.d.ts +0 -2
  516. package/lib/node/handler/handler-protocol.d.ts.map +0 -1
  517. package/lib/node/handler/handler-protocol.js +0 -5
  518. package/lib/node/handler/handler-protocol.js.map +0 -1
  519. package/lib/node/handler/index.d.ts +0 -3
  520. package/lib/node/handler/index.d.ts.map +0 -1
  521. package/lib/node/handler/index.js.map +0 -1
  522. package/src/common/channal/channel-protocol.ts +0 -82
  523. package/src/common/channal/http-channel.ts +0 -30
  524. package/src/common/channal/index.ts +0 -2
  525. package/src/common/factory/connection-factory.ts +0 -21
  526. package/src/common/factory/index.ts +0 -4
  527. package/src/common/factory/proxy-factory.ts +0 -219
  528. package/src/common/factory/reader.ts +0 -50
  529. package/src/common/factory/writer.ts +0 -26
  530. package/src/common/handler/connection-handler.ts +0 -7
  531. package/src/common/handler/handler-protocol.ts +0 -8
  532. package/src/common/handler/index.ts +0 -2
  533. package/src/common/proxy/delegating-http-proxy-creator.ts +0 -68
  534. package/src/common/proxy/http-proxy-creator.ts +0 -179
  535. package/src/common/proxy/proxy-protocol.ts +0 -26
  536. package/src/common/proxy/proxy-provider.ts +0 -29
  537. package/src/common/utils/logger.ts +0 -23
  538. package/src/node/channel/channel-manager.ts +0 -44
  539. package/src/node/channel/channel-middleware.ts +0 -27
  540. package/src/node/channel/channel-protocol.ts +0 -21
  541. package/src/node/channel/channel-strategy.ts +0 -56
  542. package/src/node/channel/index.ts +0 -4
  543. package/src/node/handler/handler-adapter.ts +0 -38
  544. package/src/node/handler/handler-protocol.ts +0 -1
  545. 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,2 +0,0 @@
1
- export * from './http-channel';
2
- export * from './channel-protocol';
@@ -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,4 +0,0 @@
1
- export * from './proxy-factory';
2
- export * from './connection-factory';
3
- export * from './reader';
4
- export * from './writer';
@@ -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,7 +0,0 @@
1
- import { MessageConnection } from 'vscode-jsonrpc';
2
- import { ConnectionHandler } from './handler-protocol';
3
-
4
- export class NoOpConnectionHandler implements ConnectionHandler {
5
- readonly path: string;
6
- onConnection(connection: MessageConnection): void {}
7
- }
@@ -1,8 +0,0 @@
1
- import { MessageConnection } from 'vscode-jsonrpc';
2
-
3
- export const ConnectionHandler = Symbol('ConnectionHandler');
4
-
5
- export interface ConnectionHandler {
6
- readonly path: string;
7
- onConnection(connection: MessageConnection): void;
8
- }
@@ -1,2 +0,0 @@
1
- export * from './connection-handler';
2
- export * from './handler-protocol';
@@ -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
- }