@celljs/rpc 3.8.0 → 3.9.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 (146) hide show
  1. package/esm/common/annotation/autorpc.d.ts +5 -0
  2. package/esm/common/annotation/autorpc.js +14 -0
  3. package/esm/common/annotation/autorpc.js.map +1 -0
  4. package/esm/common/annotation/detached/autorpc.d.ts +2 -0
  5. package/esm/common/annotation/detached/autorpc.js +11 -0
  6. package/esm/common/annotation/detached/autorpc.js.map +1 -0
  7. package/esm/common/annotation/detached/index.d.ts +1 -0
  8. package/esm/common/annotation/detached/index.js +2 -0
  9. package/esm/common/annotation/detached/index.js.map +1 -0
  10. package/esm/common/annotation/index.d.ts +2 -0
  11. package/esm/common/annotation/index.js +3 -0
  12. package/esm/common/annotation/index.js.map +1 -0
  13. package/esm/common/annotation/rpc.d.ts +19 -0
  14. package/esm/common/annotation/rpc.js +36 -0
  15. package/esm/common/annotation/rpc.js.map +1 -0
  16. package/esm/common/channal/channel-protocol.d.ts +51 -0
  17. package/esm/common/channal/channel-protocol.js +34 -0
  18. package/esm/common/channal/channel-protocol.js.map +1 -0
  19. package/esm/common/channal/http-channel.d.ts +8 -0
  20. package/esm/common/channal/http-channel.js +22 -0
  21. package/esm/common/channal/http-channel.js.map +1 -0
  22. package/esm/common/channal/index.d.ts +2 -0
  23. package/esm/common/channal/index.js +3 -0
  24. package/esm/common/channal/index.js.map +1 -0
  25. package/esm/common/constants.d.ts +1 -0
  26. package/esm/common/constants.js +2 -0
  27. package/esm/common/constants.js.map +1 -0
  28. package/esm/common/converter/converter-protocol.d.ts +6 -0
  29. package/esm/common/converter/converter-protocol.js +3 -0
  30. package/esm/common/converter/converter-protocol.js.map +1 -0
  31. package/esm/common/converter/index.d.ts +1 -0
  32. package/esm/common/converter/index.js +2 -0
  33. package/esm/common/converter/index.js.map +1 -0
  34. package/esm/common/endpoint/endpoint-protocol.d.ts +4 -0
  35. package/esm/common/endpoint/endpoint-protocol.js +2 -0
  36. package/esm/common/endpoint/endpoint-protocol.js.map +1 -0
  37. package/esm/common/endpoint/endpoint-resolver.d.ts +12 -0
  38. package/esm/common/endpoint/endpoint-resolver.js +58 -0
  39. package/esm/common/endpoint/endpoint-resolver.js.map +1 -0
  40. package/esm/common/endpoint/index.d.ts +2 -0
  41. package/esm/common/endpoint/index.js +3 -0
  42. package/esm/common/endpoint/index.js.map +1 -0
  43. package/esm/common/error/error.d.ts +5 -0
  44. package/esm/common/error/error.js +8 -0
  45. package/esm/common/error/error.js.map +1 -0
  46. package/esm/common/error/index.d.ts +1 -0
  47. package/esm/common/error/index.js +2 -0
  48. package/esm/common/error/index.js.map +1 -0
  49. package/esm/common/factory/connection-factory.d.ts +9 -0
  50. package/esm/common/factory/connection-factory.js +25 -0
  51. package/esm/common/factory/connection-factory.js.map +1 -0
  52. package/esm/common/factory/index.d.ts +4 -0
  53. package/esm/common/factory/index.js +5 -0
  54. package/esm/common/factory/index.js.map +1 -0
  55. package/esm/common/factory/proxy-factory.d.ts +56 -0
  56. package/esm/common/factory/proxy-factory.js +177 -0
  57. package/esm/common/factory/proxy-factory.js.map +1 -0
  58. package/esm/common/factory/reader.d.ts +15 -0
  59. package/esm/common/factory/reader.js +44 -0
  60. package/esm/common/factory/reader.js.map +1 -0
  61. package/esm/common/factory/writer.d.ts +9 -0
  62. package/esm/common/factory/writer.js +21 -0
  63. package/esm/common/factory/writer.js.map +1 -0
  64. package/esm/common/handler/connection-handler.d.ts +6 -0
  65. package/esm/common/handler/connection-handler.js +4 -0
  66. package/esm/common/handler/connection-handler.js.map +1 -0
  67. package/esm/common/handler/handler-protocol.d.ts +6 -0
  68. package/esm/common/handler/handler-protocol.js +2 -0
  69. package/esm/common/handler/handler-protocol.js.map +1 -0
  70. package/esm/common/handler/index.d.ts +2 -0
  71. package/esm/common/handler/index.js +3 -0
  72. package/esm/common/handler/index.js.map +1 -0
  73. package/esm/common/index.d.ts +11 -0
  74. package/esm/common/index.js +12 -0
  75. package/esm/common/index.js.map +1 -0
  76. package/esm/common/module.d.ts +3 -0
  77. package/esm/common/module.js +20 -0
  78. package/esm/common/module.js.map +1 -0
  79. package/esm/common/processor/client-config-processor.d.ts +5 -0
  80. package/esm/common/processor/client-config-processor.js +17 -0
  81. package/esm/common/processor/client-config-processor.js.map +1 -0
  82. package/esm/common/processor/index.d.ts +2 -0
  83. package/esm/common/processor/index.js +3 -0
  84. package/esm/common/processor/index.js.map +1 -0
  85. package/esm/common/processor/processor-protocol.d.ts +5 -0
  86. package/esm/common/processor/processor-protocol.js +2 -0
  87. package/esm/common/processor/processor-protocol.js.map +1 -0
  88. package/esm/common/proxy/delegating-http-proxy-creator.d.ts +23 -0
  89. package/esm/common/proxy/delegating-http-proxy-creator.js +86 -0
  90. package/esm/common/proxy/delegating-http-proxy-creator.js.map +1 -0
  91. package/esm/common/proxy/http-proxy-creator.d.ts +42 -0
  92. package/esm/common/proxy/http-proxy-creator.js +139 -0
  93. package/esm/common/proxy/http-proxy-creator.js.map +1 -0
  94. package/esm/common/proxy/index.d.ts +4 -0
  95. package/esm/common/proxy/index.js +5 -0
  96. package/esm/common/proxy/index.js.map +1 -0
  97. package/esm/common/proxy/proxy-protocol.d.ts +20 -0
  98. package/esm/common/proxy/proxy-protocol.js +3 -0
  99. package/esm/common/proxy/proxy-protocol.js.map +1 -0
  100. package/esm/common/proxy/proxy-provider.d.ts +9 -0
  101. package/esm/common/proxy/proxy-provider.js +40 -0
  102. package/esm/common/proxy/proxy-provider.js.map +1 -0
  103. package/esm/common/utils/converter-util.d.ts +7 -0
  104. package/esm/common/utils/converter-util.js +29 -0
  105. package/esm/common/utils/converter-util.js.map +1 -0
  106. package/esm/common/utils/index.d.ts +3 -0
  107. package/esm/common/utils/index.js +4 -0
  108. package/esm/common/utils/index.js.map +1 -0
  109. package/esm/common/utils/logger.d.ts +8 -0
  110. package/esm/common/utils/logger.js +18 -0
  111. package/esm/common/utils/logger.js.map +1 -0
  112. package/esm/common/utils/rpc-util.d.ts +12 -0
  113. package/esm/common/utils/rpc-util.js +43 -0
  114. package/esm/common/utils/rpc-util.js.map +1 -0
  115. package/esm/node/channel/channel-manager.d.ts +9 -0
  116. package/esm/node/channel/channel-manager.js +56 -0
  117. package/esm/node/channel/channel-manager.js.map +1 -0
  118. package/esm/node/channel/channel-middleware.d.ts +7 -0
  119. package/esm/node/channel/channel-middleware.js +37 -0
  120. package/esm/node/channel/channel-middleware.js.map +1 -0
  121. package/esm/node/channel/channel-protocol.d.ts +12 -0
  122. package/esm/node/channel/channel-protocol.js +6 -0
  123. package/esm/node/channel/channel-protocol.js.map +1 -0
  124. package/esm/node/channel/channel-strategy.d.ts +9 -0
  125. package/esm/node/channel/channel-strategy.js +61 -0
  126. package/esm/node/channel/channel-strategy.js.map +1 -0
  127. package/esm/node/channel/index.d.ts +4 -0
  128. package/esm/node/channel/index.js +5 -0
  129. package/esm/node/channel/index.js.map +1 -0
  130. package/esm/node/handler/handler-adapter.d.ts +13 -0
  131. package/esm/node/handler/handler-adapter.js +52 -0
  132. package/esm/node/handler/handler-adapter.js.map +1 -0
  133. package/esm/node/handler/handler-protocol.d.ts +1 -0
  134. package/esm/node/handler/handler-protocol.js +2 -0
  135. package/esm/node/handler/handler-protocol.js.map +1 -0
  136. package/esm/node/handler/index.d.ts +2 -0
  137. package/esm/node/handler/index.js +3 -0
  138. package/esm/node/handler/index.js.map +1 -0
  139. package/esm/node/index.d.ts +2 -0
  140. package/esm/node/index.js +3 -0
  141. package/esm/node/index.js.map +1 -0
  142. package/esm/node/module.d.ts +3 -0
  143. package/esm/node/module.js +4 -0
  144. package/esm/node/module.js.map +1 -0
  145. package/esm/package.json +3 -0
  146. package/package.json +101 -6
@@ -0,0 +1,5 @@
1
+ import { IdOrAutowiredOptionWithoutMulti, DoInject } from '@celljs/core';
2
+ export declare const RPC: unique symbol;
3
+ export declare const ID_KEY: unique symbol;
4
+ export declare const Autorpc: (idOrOption?: IdOrAutowiredOptionWithoutMulti) => PropertyDecorator & ParameterDecorator;
5
+ export declare const doInjectForAutorpc: DoInject;
@@ -0,0 +1,14 @@
1
+ import { applyAutowiredDecorator, parseAutowiredOption, Tagged, Inject } from '@celljs/core';
2
+ export const RPC = Symbol('RPC');
3
+ export const ID_KEY = Symbol('ID_KEY');
4
+ export const Autorpc = function (idOrOption) {
5
+ return (target, targetKey, index) => {
6
+ const option = parseAutowiredOption(target, targetKey, index, idOrOption);
7
+ applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutorpc);
8
+ };
9
+ };
10
+ export const doInjectForAutorpc = (option, t, k, i) => {
11
+ Inject(RPC)(t, k, i);
12
+ Tagged(ID_KEY, option.id)(t, k, i);
13
+ };
14
+ //# sourceMappingURL=autorpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autorpc.js","sourceRoot":"","sources":["../../../src/common/annotation/autorpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAA6C,oBAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAExI,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAEvC,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,UAA4C;IACzE,OAAO,CAAC,MAAW,EAAE,SAAiB,EAAE,KAAc,EAAE,EAAE;QACtD,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;QAC1E,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;IAClF,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAa,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;IAC5D,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { IdOrAutowiredOptionWithoutMulti } from '@celljs/core';
2
+ export declare const Autorpc: (idOrOption?: IdOrAutowiredOptionWithoutMulti) => PropertyDecorator & ParameterDecorator;
@@ -0,0 +1,11 @@
1
+ import { applyAutowiredDecorator, ContainerUtil, parseAutowiredOption } from '@celljs/core';
2
+ import { RPC, ID_KEY, doInjectForAutorpc } from '../autorpc.js';
3
+ export const Autorpc = function (idOrOption) {
4
+ return (target, targetKey, index) => {
5
+ const option = parseAutowiredOption(target, targetKey, index, idOrOption);
6
+ option.detached = true;
7
+ applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutorpc, doGetValueForAutorpc);
8
+ };
9
+ };
10
+ const doGetValueForAutorpc = (option, t, property) => ContainerUtil.getTagged(RPC, ID_KEY, option.id);
11
+ //# sourceMappingURL=autorpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autorpc.js","sourceRoot":"","sources":["../../../../src/common/annotation/detached/autorpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAA+C,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzI,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE7D,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,UAA4C;IACzE,OAAO,CAAC,MAAW,EAAE,SAAiB,EAAE,KAAc,EAAE,EAAE;QACtD,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;QAC1E,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;IACxG,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAe,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAG,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './autorpc.js';
@@ -0,0 +1,2 @@
1
+ export * from './autorpc.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/annotation/detached/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './rpc.js';
2
+ export * from './autorpc.js';
@@ -0,0 +1,3 @@
1
+ export * from './rpc.js';
2
+ export * from './autorpc.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/annotation/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ComponentDecorator, ComponentOption } from '@celljs/core';
2
+ export declare const RPC_TAG = "Rpc";
3
+ export declare const Rpc: ComponentDecorator;
4
+ export declare function parseRpcOption(target: any, idOrOption: any): {
5
+ id?: import("@celljs/core").ComponentId | import("@celljs/core").ComponentId[];
6
+ scope?: import("@celljs/core").Scope;
7
+ name?: string | number | symbol;
8
+ tag?: {
9
+ tag: string | number | symbol;
10
+ value: any;
11
+ };
12
+ default?: boolean;
13
+ when?: (request: import("inversify").interfaces.Request) => boolean;
14
+ rebind?: boolean;
15
+ proxy?: boolean;
16
+ sysTags?: string[];
17
+ onActivation?: (context: import("inversify").interfaces.Context, t: any) => any;
18
+ };
19
+ export declare function applyRpcDecorator(option: ComponentOption, target: any): import("@celljs/core").ComponentMetadata;
@@ -0,0 +1,36 @@
1
+ import { applyComponentDecorator, parseComponentOption, Logger } from '@celljs/core';
2
+ import { AOP_POINTCUT, PipeManager } from '@celljs/web';
3
+ import { ConnectionHandler } from '../handler/index.js';
4
+ import { JsonRpcConnectionHandler } from '../factory/index.js';
5
+ import { RpcUtil, ConverterUtil } from '../utils/index.js';
6
+ export const RPC_TAG = 'Rpc';
7
+ export const Rpc = function (...idOrOption) {
8
+ return target => {
9
+ const option = parseRpcOption(target, idOrOption);
10
+ applyRpcDecorator(option, target);
11
+ };
12
+ };
13
+ export function parseRpcOption(target, idOrOption) {
14
+ const parsed = parseComponentOption(target, idOrOption);
15
+ if (idOrOption[0].proxy === undefined) {
16
+ parsed.proxy = true;
17
+ }
18
+ parsed.sysTags.push(AOP_POINTCUT, RPC_TAG);
19
+ return parsed;
20
+ }
21
+ export function applyRpcDecorator(option, target) {
22
+ const { ids } = applyComponentDecorator(option, target);
23
+ const id = ids[1] || ids[0];
24
+ return applyComponentDecorator({ id: ConnectionHandler, onActivation: context => {
25
+ const t = context.container.get(id);
26
+ const pipeManager = context.container.get(PipeManager);
27
+ const logger = context.container.get(Logger);
28
+ const errorConverters = ConverterUtil.getGlobalErrorConverters(context.container);
29
+ const errorConverter = ConverterUtil.getErrorConverters(id, context.container);
30
+ if (errorConverter) {
31
+ errorConverters.push(errorConverter);
32
+ }
33
+ return new JsonRpcConnectionHandler(RpcUtil.toPath(id), () => t, errorConverters, pipeManager, logger);
34
+ } }, target);
35
+ }
36
+ //# sourceMappingURL=rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../../src/common/annotation/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,uBAAuB,EAAmB,oBAAoB,EAAE,MAAM,EAAa,MAAM,cAAc,CAAC;AACrI,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACx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GAAG,CAAc,WAAW,CAAC,CAAC;YACpE,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC;YACrD,MAAM,eAAe,GAAG,aAAa,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAsB,CAAC,CAAC;YAC/F,MAAM,cAAc,GAAG,aAAa,CAAC,kBAAkB,CAAC,EAAE,EAAE,OAAO,CAAC,SAAsB,CAAC,CAAC;YAC5F,IAAI,cAAc,EAAE,CAAC;gBACjB,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC3G,CAAC,EAAC,EAAE,MAAM,CAAC,CAAC;AAChB,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { Disposable } from 'vscode-jsonrpc';
2
+ import { DisposableCollection } from '@celljs/core';
3
+ export interface Channel {
4
+ handleMessage(message: Channel.Message): void;
5
+ send(content: string): void;
6
+ onMessage(cb: (data: any) => void): void;
7
+ }
8
+ export declare namespace Channel {
9
+ interface OpenMessage {
10
+ kind: 'open';
11
+ id: number;
12
+ path: string;
13
+ }
14
+ interface ReadyMessage {
15
+ kind: 'ready';
16
+ id: number;
17
+ }
18
+ interface DataMessage {
19
+ kind: 'data';
20
+ id: number;
21
+ content: string;
22
+ }
23
+ interface CloseMessage {
24
+ kind: 'close';
25
+ id: number;
26
+ code: number;
27
+ reason: string;
28
+ }
29
+ interface HttpMessage {
30
+ kind: 'http';
31
+ id: number;
32
+ path?: string;
33
+ content: string;
34
+ }
35
+ type Message = OpenMessage | ReadyMessage | DataMessage | CloseMessage | HttpMessage;
36
+ }
37
+ export declare abstract class AbstractChannel implements Channel, Disposable {
38
+ readonly id: number;
39
+ protected readonly doSend: (content: string) => Promise<void>;
40
+ protected readonly toDispose: DisposableCollection;
41
+ constructor(id: number, doSend: (content: string) => Promise<void>);
42
+ dispose(): void;
43
+ protected checkNotDisposed(): void;
44
+ abstract handleMessage(message: Channel.Message): void;
45
+ abstract doGetMessage(content: string): Channel.Message;
46
+ send(content: string): void;
47
+ protected fireMessage: (data: any) => void;
48
+ onMessage(cb: (data: any) => void): void;
49
+ fireError: (reason: any) => void;
50
+ onError(cb: (reason: any) => void): void;
51
+ }
@@ -0,0 +1,34 @@
1
+ import { Disposable } from 'vscode-jsonrpc';
2
+ import { DisposableCollection } from '@celljs/core';
3
+ export class AbstractChannel {
4
+ constructor(id, doSend) {
5
+ this.id = id;
6
+ this.doSend = doSend;
7
+ this.toDispose = new DisposableCollection();
8
+ this.fireMessage = () => { };
9
+ this.fireError = () => { };
10
+ }
11
+ dispose() {
12
+ this.toDispose.dispose();
13
+ }
14
+ checkNotDisposed() {
15
+ if (this.toDispose.disposed) {
16
+ throw new Error('The channel has been disposed.');
17
+ }
18
+ }
19
+ send(content) {
20
+ this.checkNotDisposed();
21
+ this.doSend(JSON.stringify(this.doGetMessage(content)));
22
+ }
23
+ onMessage(cb) {
24
+ this.checkNotDisposed();
25
+ this.fireMessage = cb;
26
+ this.toDispose.push(Disposable.create(() => this.fireMessage = () => { }));
27
+ }
28
+ onError(cb) {
29
+ this.checkNotDisposed();
30
+ this.fireError = cb;
31
+ this.toDispose.push(Disposable.create(() => this.fireError = () => { }));
32
+ }
33
+ }
34
+ //# sourceMappingURL=channel-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-protocol.js","sourceRoot":"","sources":["../../../src/common/channal/channel-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAsCpD,MAAM,OAAgB,eAAe;IAIjC,YACa,EAAU,EACA,MAA0C;QADpD,OAAE,GAAF,EAAE,CAAQ;QAC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 protected readonly path?: string | undefined;
4
+ constructor(id: number, doSend: (content: string) => Promise<void>, path?: string | undefined);
5
+ protected checkNotDisposed(): void;
6
+ handleMessage(message: Channel.HttpMessage): void;
7
+ doGetMessage(content: string): Channel.Message;
8
+ }
@@ -0,0 +1,22 @@
1
+ import { AbstractChannel } from './channel-protocol.js';
2
+ export class HttpChannel extends AbstractChannel {
3
+ constructor(id, doSend, path) {
4
+ super(id, doSend);
5
+ this.path = path;
6
+ }
7
+ checkNotDisposed() {
8
+ // noop
9
+ }
10
+ handleMessage(message) {
11
+ this.fireMessage(message.content);
12
+ }
13
+ doGetMessage(content) {
14
+ return {
15
+ kind: 'http',
16
+ id: this.id,
17
+ path: this.path,
18
+ content
19
+ };
20
+ }
21
+ }
22
+ //# sourceMappingURL=http-channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-channel.js","sourceRoot":"","sources":["../../../src/common/channal/http-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE9D,MAAM,OAAO,WAAY,SAAQ,eAAe;IAE5C,YACI,EAAU,EACV,MAA0C,EACvB,IAAa;QAEhC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;oBAFC,IAAI;IAG3B,CAAC;IAEkB,gBAAgB;QAC/B,OAAO;IACX,CAAC;IAED,aAAa,CAAC,OAA4B;QACtC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,YAAY,CAAC,OAAe;QACxB,OAA4B;YACxB,IAAI,EAAE,MAAM;YACZ,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO;SACV,CAAC;IACN,CAAC;CAEJ"}
@@ -0,0 +1,2 @@
1
+ export * from './http-channel.js';
2
+ export * from './channel-protocol.js';
@@ -0,0 +1,3 @@
1
+ export * from './http-channel.js';
2
+ export * from './channel-protocol.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/channal/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const RPC_PATH = "cell.rpc.path";
@@ -0,0 +1,2 @@
1
+ export const RPC_PATH = 'cell.rpc.path';
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const ErrorConverter: unique symbol;
2
+ export declare const GlobalConverter: unique symbol;
3
+ export interface ErrorConverter {
4
+ serialize(e: any): any;
5
+ deserialize(e: any): any;
6
+ }
@@ -0,0 +1,3 @@
1
+ export const ErrorConverter = Symbol('ErrorConverter');
2
+ export const GlobalConverter = Symbol('GlobalConverter');
3
+ //# sourceMappingURL=converter-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter-protocol.js","sourceRoot":"","sources":["../../../src/common/converter/converter-protocol.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './converter-protocol.js';
@@ -0,0 +1,2 @@
1
+ export * from './converter-protocol.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/converter/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const EndpointResolver: unique symbol;
2
+ export interface EndpointResolver {
3
+ resolve(serviceIdentifier: string): Promise<string>;
4
+ }
@@ -0,0 +1,2 @@
1
+ export const EndpointResolver = Symbol('EndpointResolver');
2
+ //# sourceMappingURL=endpoint-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-protocol.js","sourceRoot":"","sources":["../../../src/common/endpoint/endpoint-protocol.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { PathResolver } from '@celljs/web';
2
+ import { EndpointResolver } from './endpoint-protocol.js';
3
+ export declare class EndpointResolverImpl implements EndpointResolver {
4
+ protected readonly endpoint?: {
5
+ [id: string]: string;
6
+ };
7
+ protected readonly defaultEndpoint?: string;
8
+ protected readonly rpcPath: string;
9
+ protected pathResolver: PathResolver;
10
+ protected parsed: Map<string, string>;
11
+ resolve(serviceIdentifier: string): Promise<string>;
12
+ }
@@ -0,0 +1,58 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Autowired, Component, Value } from '@celljs/core';
11
+ import { RPC_PATH } from '../constants.js';
12
+ import { PathResolver } from '@celljs/web';
13
+ import { EndpointNotFoundError } from '../error/index.js';
14
+ import { EndpointResolver } from './endpoint-protocol.js';
15
+ let EndpointResolverImpl = class EndpointResolverImpl {
16
+ async resolve(serviceIdentifier) {
17
+ let result;
18
+ if (this.endpoint) {
19
+ result = this.endpoint[serviceIdentifier];
20
+ }
21
+ if (/^https?:/i.test(serviceIdentifier)) {
22
+ result = serviceIdentifier;
23
+ }
24
+ if (!result) {
25
+ result = this.defaultEndpoint;
26
+ }
27
+ if (!result && typeof location !== 'undefined') {
28
+ result = `${location.protocol}//${location.host}{rpcPath}/{serviceIdentifier}`;
29
+ }
30
+ if (!result) {
31
+ throw new EndpointNotFoundError(serviceIdentifier);
32
+ }
33
+ return result
34
+ .replace(/{rpcPath}/g, await this.pathResolver.resolve(this.rpcPath))
35
+ .replace(/{serviceIdentifier}/g, serviceIdentifier);
36
+ }
37
+ };
38
+ __decorate([
39
+ Value('cell.rpc.endpoint'),
40
+ __metadata("design:type", Object)
41
+ ], EndpointResolverImpl.prototype, "endpoint", void 0);
42
+ __decorate([
43
+ Value('cell.rpc.defaultEndpoint'),
44
+ __metadata("design:type", String)
45
+ ], EndpointResolverImpl.prototype, "defaultEndpoint", void 0);
46
+ __decorate([
47
+ Value(RPC_PATH),
48
+ __metadata("design:type", String)
49
+ ], EndpointResolverImpl.prototype, "rpcPath", void 0);
50
+ __decorate([
51
+ Autowired(PathResolver),
52
+ __metadata("design:type", Object)
53
+ ], EndpointResolverImpl.prototype, "pathResolver", void 0);
54
+ EndpointResolverImpl = __decorate([
55
+ Component(EndpointResolver)
56
+ ], EndpointResolverImpl);
57
+ export { EndpointResolverImpl };
58
+ //# sourceMappingURL=endpoint-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-resolver.js","sourceRoot":"","sources":["../../../src/common/endpoint/endpoint-resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAA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2 @@
1
+ export * from './endpoint-protocol.js';
2
+ export * from './endpoint-resolver.js';
@@ -0,0 +1,3 @@
1
+ export * from './endpoint-protocol.js';
2
+ export * from './endpoint-resolver.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/endpoint/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { CustomError } from '@celljs/core';
2
+ export declare class EndpointNotFoundError extends CustomError {
3
+ serviceId: string;
4
+ constructor(serviceId: string);
5
+ }
@@ -0,0 +1,8 @@
1
+ import { CustomError } from '@celljs/core';
2
+ export class EndpointNotFoundError extends CustomError {
3
+ constructor(serviceId) {
4
+ super(`No endpoint found: ${serviceId}`);
5
+ this.serviceId = serviceId;
6
+ }
7
+ }
8
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/common/error/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,qBAAsB,SAAQ,WAAW;IAClD,YAAmB,SAAiB;QAChC,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;yBAD1B,SAAS;IAE5B,CAAC;CACJ"}
@@ -0,0 +1 @@
1
+ export * from './error.js';
@@ -0,0 +1,2 @@
1
+ export * from './error.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/error/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { MessageConnection, Logger } from 'vscode-jsonrpc';
2
+ import { Channel } from '../channal/channel-protocol.js';
3
+ export declare const ConnnectionFactory: unique symbol;
4
+ export interface ConnnectionFactory<T> {
5
+ create(t: T, logger: Logger): MessageConnection;
6
+ }
7
+ export declare class ConnnectionFactoryImpl implements ConnnectionFactory<Channel> {
8
+ create(channel: Channel, logger: Logger): MessageConnection;
9
+ }
@@ -0,0 +1,25 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { createMessageConnection } from 'vscode-jsonrpc';
8
+ import { ChannelMessageReader } from './reader.js';
9
+ import { ChannelMessageWriter } from './writer.js';
10
+ import { Component } from '@celljs/core';
11
+ export const ConnnectionFactory = Symbol('ConnnectionFactory');
12
+ let ConnnectionFactoryImpl = class ConnnectionFactoryImpl {
13
+ create(channel, logger) {
14
+ const messageReader = new ChannelMessageReader(channel);
15
+ const messageWriter = new ChannelMessageWriter(channel);
16
+ const connection = createMessageConnection(messageReader, messageWriter, logger);
17
+ connection.onClose(() => connection.dispose());
18
+ return connection;
19
+ }
20
+ };
21
+ ConnnectionFactoryImpl = __decorate([
22
+ Component(ConnnectionFactory)
23
+ ], ConnnectionFactoryImpl);
24
+ export { ConnnectionFactoryImpl };
25
+ //# sourceMappingURL=connection-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-factory.js","sourceRoot":"","sources":["../../../src/common/factory/connection-factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAqB,uBAAuB,EAAU,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAMxD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAC/B,MAAM,CAAC,OAAgB,EAAE,MAAc;QACnC,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,UAAU,GAAG,uBAAuB,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QACjF,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/C,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ,CAAA;AARY,sBAAsB;IADlC,SAAS,CAAC,kBAAkB,CAAC;GACjB,sBAAsB,CAQlC"}
@@ -0,0 +1,4 @@
1
+ export * from './proxy-factory.js';
2
+ export * from './connection-factory.js';
3
+ export * from './reader.js';
4
+ export * from './writer.js';
@@ -0,0 +1,5 @@
1
+ export * from './proxy-factory.js';
2
+ export * from './connection-factory.js';
3
+ export * from './reader.js';
4
+ export * from './writer.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/factory/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { MessageConnection, Event } from 'vscode-jsonrpc';
2
+ import { Disposable, Logger } from '@celljs/core';
3
+ import { ErrorConverter } from '../converter/index.js';
4
+ import { ConnectionHandler } from '../handler/index.js';
5
+ import { PipeManager } from '@celljs/web';
6
+ export type JsonRpcServer<Client> = Disposable & {
7
+ /**
8
+ * If this server is a proxy to a remote server then
9
+ * a client is used as a local object
10
+ * to handle JSON-RPC messages from the remote server.
11
+ */
12
+ setClient(client: Client | undefined): void;
13
+ };
14
+ export interface JsonRpcConnectionEventEmitter {
15
+ readonly onDidOpenConnection: Event<void>;
16
+ readonly onDidCloseConnection: Event<void>;
17
+ }
18
+ export type JsonRpcProxy<T> = T & JsonRpcConnectionEventEmitter;
19
+ export declare class JsonRpcConnectionHandler<T extends object> implements ConnectionHandler {
20
+ readonly path: string;
21
+ readonly targetFactory: (proxy: JsonRpcProxy<T>) => any;
22
+ readonly errorConverters: ErrorConverter[];
23
+ readonly pipeManager: PipeManager;
24
+ readonly logger: Logger;
25
+ constructor(path: string, targetFactory: (proxy: JsonRpcProxy<T>) => any, errorConverters: ErrorConverter[], pipeManager: PipeManager, logger: Logger);
26
+ onConnection(connection: MessageConnection): void;
27
+ }
28
+ export declare class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
29
+ target?: any;
30
+ protected errorConverters?: ErrorConverter[] | undefined;
31
+ protected pipeManager?: PipeManager | undefined;
32
+ protected logger?: Logger | undefined;
33
+ private static SET_CLIENT;
34
+ private static ON_DID_OPEN_CONNECTION;
35
+ private static ON_DID_CLOSE_CONNECTION;
36
+ private readonly onDidOpenConnectionEmitter;
37
+ private readonly onDidCloseConnectionEmitter;
38
+ protected internalMethods: Map<string, () => any>;
39
+ protected connectionPromiseResolve: (connection: MessageConnection) => void;
40
+ protected connectionPromise: Promise<MessageConnection>;
41
+ constructor(target?: any, errorConverters?: ErrorConverter[] | undefined, pipeManager?: PipeManager | undefined, logger?: Logger | undefined);
42
+ protected waitForConnection(): void;
43
+ protected getRequestHandler(prop: string): (...args: any[]) => Promise<any>;
44
+ protected getNotificationHandler(prop: string): (...args: any[]) => void;
45
+ protected registerMethods(connection: MessageConnection): void;
46
+ listen(connection: MessageConnection): void;
47
+ protected onRequest(method: string, ...args: any[]): Promise<any>;
48
+ protected onNotification(method: string, ...args: any[]): void;
49
+ createProxy(): JsonRpcProxy<T>;
50
+ get(target: T, p: PropertyKey, receiver: any): any;
51
+ protected getInternalMethod(method: string): Event<void> | ((client: any) => any) | undefined;
52
+ protected createProxyMethod(method: string): ((...args: any[]) => Promise<any>) | undefined;
53
+ protected isNotification(p: PropertyKey): boolean;
54
+ protected serializeError(e: any): any;
55
+ protected deserializeError(capturedError: Error, e: any): any;
56
+ }