@celljs/rpc 3.7.8 → 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.
- package/esm/common/annotation/autorpc.d.ts +5 -0
- package/esm/common/annotation/autorpc.js +14 -0
- package/esm/common/annotation/autorpc.js.map +1 -0
- package/esm/common/annotation/detached/autorpc.d.ts +2 -0
- package/esm/common/annotation/detached/autorpc.js +11 -0
- package/esm/common/annotation/detached/autorpc.js.map +1 -0
- package/esm/common/annotation/detached/index.d.ts +1 -0
- package/esm/common/annotation/detached/index.js +2 -0
- package/esm/common/annotation/detached/index.js.map +1 -0
- package/esm/common/annotation/index.d.ts +2 -0
- package/esm/common/annotation/index.js +3 -0
- package/esm/common/annotation/index.js.map +1 -0
- package/esm/common/annotation/rpc.d.ts +19 -0
- package/esm/common/annotation/rpc.js +36 -0
- package/esm/common/annotation/rpc.js.map +1 -0
- package/esm/common/channal/channel-protocol.d.ts +51 -0
- package/esm/common/channal/channel-protocol.js +34 -0
- package/esm/common/channal/channel-protocol.js.map +1 -0
- package/esm/common/channal/http-channel.d.ts +8 -0
- package/esm/common/channal/http-channel.js +22 -0
- package/esm/common/channal/http-channel.js.map +1 -0
- package/esm/common/channal/index.d.ts +2 -0
- package/esm/common/channal/index.js +3 -0
- package/esm/common/channal/index.js.map +1 -0
- package/esm/common/constants.d.ts +1 -0
- package/esm/common/constants.js +2 -0
- package/esm/common/constants.js.map +1 -0
- package/esm/common/converter/converter-protocol.d.ts +6 -0
- package/esm/common/converter/converter-protocol.js +3 -0
- package/esm/common/converter/converter-protocol.js.map +1 -0
- package/esm/common/converter/index.d.ts +1 -0
- package/esm/common/converter/index.js +2 -0
- package/esm/common/converter/index.js.map +1 -0
- package/esm/common/endpoint/endpoint-protocol.d.ts +4 -0
- package/esm/common/endpoint/endpoint-protocol.js +2 -0
- package/esm/common/endpoint/endpoint-protocol.js.map +1 -0
- package/esm/common/endpoint/endpoint-resolver.d.ts +12 -0
- package/esm/common/endpoint/endpoint-resolver.js +58 -0
- package/esm/common/endpoint/endpoint-resolver.js.map +1 -0
- package/esm/common/endpoint/index.d.ts +2 -0
- package/esm/common/endpoint/index.js +3 -0
- package/esm/common/endpoint/index.js.map +1 -0
- package/esm/common/error/error.d.ts +5 -0
- package/esm/common/error/error.js +8 -0
- package/esm/common/error/error.js.map +1 -0
- package/esm/common/error/index.d.ts +1 -0
- package/esm/common/error/index.js +2 -0
- package/esm/common/error/index.js.map +1 -0
- package/esm/common/factory/connection-factory.d.ts +9 -0
- package/esm/common/factory/connection-factory.js +25 -0
- package/esm/common/factory/connection-factory.js.map +1 -0
- package/esm/common/factory/index.d.ts +4 -0
- package/esm/common/factory/index.js +5 -0
- package/esm/common/factory/index.js.map +1 -0
- package/esm/common/factory/proxy-factory.d.ts +56 -0
- package/esm/common/factory/proxy-factory.js +177 -0
- package/esm/common/factory/proxy-factory.js.map +1 -0
- package/esm/common/factory/reader.d.ts +15 -0
- package/esm/common/factory/reader.js +44 -0
- package/esm/common/factory/reader.js.map +1 -0
- package/esm/common/factory/writer.d.ts +9 -0
- package/esm/common/factory/writer.js +21 -0
- package/esm/common/factory/writer.js.map +1 -0
- package/esm/common/handler/connection-handler.d.ts +6 -0
- package/esm/common/handler/connection-handler.js +4 -0
- package/esm/common/handler/connection-handler.js.map +1 -0
- package/esm/common/handler/handler-protocol.d.ts +6 -0
- package/esm/common/handler/handler-protocol.js +2 -0
- package/esm/common/handler/handler-protocol.js.map +1 -0
- package/esm/common/handler/index.d.ts +2 -0
- package/esm/common/handler/index.js +3 -0
- package/esm/common/handler/index.js.map +1 -0
- package/esm/common/index.d.ts +11 -0
- package/esm/common/index.js +12 -0
- package/esm/common/index.js.map +1 -0
- package/esm/common/module.d.ts +3 -0
- package/esm/common/module.js +20 -0
- package/esm/common/module.js.map +1 -0
- package/esm/common/processor/client-config-processor.d.ts +5 -0
- package/esm/common/processor/client-config-processor.js +17 -0
- package/esm/common/processor/client-config-processor.js.map +1 -0
- package/esm/common/processor/index.d.ts +2 -0
- package/esm/common/processor/index.js +3 -0
- package/esm/common/processor/index.js.map +1 -0
- package/esm/common/processor/processor-protocol.d.ts +5 -0
- package/esm/common/processor/processor-protocol.js +2 -0
- package/esm/common/processor/processor-protocol.js.map +1 -0
- package/esm/common/proxy/delegating-http-proxy-creator.d.ts +23 -0
- package/esm/common/proxy/delegating-http-proxy-creator.js +86 -0
- package/esm/common/proxy/delegating-http-proxy-creator.js.map +1 -0
- package/esm/common/proxy/http-proxy-creator.d.ts +42 -0
- package/esm/common/proxy/http-proxy-creator.js +139 -0
- package/esm/common/proxy/http-proxy-creator.js.map +1 -0
- package/esm/common/proxy/index.d.ts +4 -0
- package/esm/common/proxy/index.js +5 -0
- package/esm/common/proxy/index.js.map +1 -0
- package/esm/common/proxy/proxy-protocol.d.ts +20 -0
- package/esm/common/proxy/proxy-protocol.js +3 -0
- package/esm/common/proxy/proxy-protocol.js.map +1 -0
- package/esm/common/proxy/proxy-provider.d.ts +9 -0
- package/esm/common/proxy/proxy-provider.js +40 -0
- package/esm/common/proxy/proxy-provider.js.map +1 -0
- package/esm/common/utils/converter-util.d.ts +7 -0
- package/esm/common/utils/converter-util.js +29 -0
- package/esm/common/utils/converter-util.js.map +1 -0
- package/esm/common/utils/index.d.ts +3 -0
- package/esm/common/utils/index.js +4 -0
- package/esm/common/utils/index.js.map +1 -0
- package/esm/common/utils/logger.d.ts +8 -0
- package/esm/common/utils/logger.js +18 -0
- package/esm/common/utils/logger.js.map +1 -0
- package/esm/common/utils/rpc-util.d.ts +12 -0
- package/esm/common/utils/rpc-util.js +43 -0
- package/esm/common/utils/rpc-util.js.map +1 -0
- package/esm/node/channel/channel-manager.d.ts +9 -0
- package/esm/node/channel/channel-manager.js +56 -0
- package/esm/node/channel/channel-manager.js.map +1 -0
- package/esm/node/channel/channel-middleware.d.ts +7 -0
- package/esm/node/channel/channel-middleware.js +37 -0
- package/esm/node/channel/channel-middleware.js.map +1 -0
- package/esm/node/channel/channel-protocol.d.ts +12 -0
- package/esm/node/channel/channel-protocol.js +6 -0
- package/esm/node/channel/channel-protocol.js.map +1 -0
- package/esm/node/channel/channel-strategy.d.ts +9 -0
- package/esm/node/channel/channel-strategy.js +61 -0
- package/esm/node/channel/channel-strategy.js.map +1 -0
- package/esm/node/channel/index.d.ts +4 -0
- package/esm/node/channel/index.js +5 -0
- package/esm/node/channel/index.js.map +1 -0
- package/esm/node/handler/handler-adapter.d.ts +13 -0
- package/esm/node/handler/handler-adapter.js +52 -0
- package/esm/node/handler/handler-adapter.js.map +1 -0
- package/esm/node/handler/handler-protocol.d.ts +1 -0
- package/esm/node/handler/handler-protocol.js +2 -0
- package/esm/node/handler/handler-protocol.js.map +1 -0
- package/esm/node/handler/index.d.ts +2 -0
- package/esm/node/handler/index.js +3 -0
- package/esm/node/handler/index.js.map +1 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +3 -0
- package/esm/node/index.js.map +1 -0
- package/esm/node/module.d.ts +3 -0
- package/esm/node/module.js +4 -0
- package/esm/node/module.js.map +1 -0
- package/esm/package.json +3 -0
- package/lib/common/annotation/autorpc.d.ts.map +1 -1
- package/lib/common/annotation/autorpc.js.map +1 -1
- package/lib/common/annotation/detached/autorpc.d.ts.map +1 -1
- package/lib/common/annotation/detached/autorpc.js.map +1 -1
- package/lib/common/annotation/rpc.js.map +1 -1
- package/lib/common/channal/channel-protocol.d.ts.map +1 -1
- package/lib/common/channal/channel-protocol.js.map +1 -1
- package/lib/common/channal/http-channel.d.ts.map +1 -1
- package/lib/common/channal/http-channel.js.map +1 -1
- package/lib/common/endpoint/endpoint-resolver.d.ts.map +1 -1
- package/lib/common/endpoint/endpoint-resolver.js.map +1 -1
- package/lib/common/error/error.d.ts.map +1 -1
- package/lib/common/error/error.js.map +1 -1
- package/lib/common/factory/connection-factory.d.ts.map +1 -1
- package/lib/common/factory/connection-factory.js.map +1 -1
- package/lib/common/factory/proxy-factory.d.ts +2 -2
- package/lib/common/factory/proxy-factory.d.ts.map +1 -1
- package/lib/common/factory/proxy-factory.js.map +1 -1
- package/lib/common/factory/reader.d.ts.map +1 -1
- package/lib/common/factory/reader.js.map +1 -1
- package/lib/common/factory/writer.d.ts.map +1 -1
- package/lib/common/factory/writer.js.map +1 -1
- package/lib/common/handler/connection-handler.d.ts.map +1 -1
- package/lib/common/handler/connection-handler.js.map +1 -1
- package/lib/common/module.d.ts.map +1 -1
- package/lib/common/module.js.map +1 -1
- 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/proxy/delegating-http-proxy-creator.d.ts.map +1 -1
- package/lib/common/proxy/delegating-http-proxy-creator.js.map +1 -1
- package/lib/common/proxy/http-proxy-creator.d.ts.map +1 -1
- package/lib/common/proxy/http-proxy-creator.js.map +1 -1
- package/lib/common/proxy/proxy-provider.d.ts.map +1 -1
- package/lib/common/proxy/proxy-provider.js.map +1 -1
- package/lib/common/utils/converter-util.js.map +1 -1
- package/lib/common/utils/logger.d.ts.map +1 -1
- package/lib/common/utils/logger.js.map +1 -1
- package/lib/common/utils/rpc-util.js.map +1 -1
- package/lib/node/channel/channel-manager.d.ts.map +1 -1
- package/lib/node/channel/channel-manager.js.map +1 -1
- package/lib/node/channel/channel-middleware.d.ts.map +1 -1
- package/lib/node/channel/channel-middleware.js.map +1 -1
- package/lib/node/channel/channel-strategy.d.ts.map +1 -1
- package/lib/node/channel/channel-strategy.js.map +1 -1
- package/lib/node/handler/handler-adapter.d.ts.map +1 -1
- package/lib/node/handler/handler-adapter.js.map +1 -1
- package/lib/node/module.d.ts.map +1 -1
- package/lib/node/module.js.map +1 -1
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.js +5 -2
- package/lib/package.spec.js.map +1 -1
- package/package.json +103 -13
- package/src/package.spec.ts +1 -0
- package/LICENSE +0 -21
|
@@ -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,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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/common/annotation/detached/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -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;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC;AAE7B,MAAM,CAAC,MAAM,GAAG,GAAuB,UAAU,GAAG,UAAe;IAC/D,OAAO,MAAM,CAAC,EAAE;QACZ,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAClD,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,MAAW,EAAE,UAAe;IACvD,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAExD,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACxB,CAAC;IACD,MAAM,CAAC,OAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAuB,EAAE,MAAW;IAClE,MAAM,EAAE,GAAG,EAAE,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxD,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,uBAAuB,CAAC,EAAE,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE;YAC5E,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpC,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,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;QACA,WAAM,GAAN,MAAM,CAAoC;QAJ9C,cAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QA0BhD,gBAAW,GAAwB,GAAG,EAAE,GAAG,CAAC,CAAC;QAOvD,cAAS,GAA0B,GAAG,EAAE,GAAG,CAAC,CAAC;IA5BzC,CAAC;IAEL,OAAO;QACH,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAES,gBAAgB;QACtB,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;IAMD,IAAI,CAAC,OAAe;QAChB,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;IAGD,SAAS,CAAC,EAAuB;QAC7B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC;IAGD,OAAO,CAAC,EAAyB;QAC7B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;CAEJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Channel, AbstractChannel } from './channel-protocol.js';
|
|
2
|
+
export declare class HttpChannel extends AbstractChannel {
|
|
3
|
+
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/converter/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -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,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGhD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAgB7B,KAAK,CAAC,OAAO,CAAC,iBAAyB;QACnC,IAAI,MAA0B,CAAC;QAC/B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACtC,MAAM,GAAG,iBAAiB,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,MAAM,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC7C,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,IAAI,+BAA+B,CAAC;QACnF,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,MAAM;aACR,OAAO,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACpE,OAAO,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC;IAC5D,CAAC;CAEJ,CAAA;AAnCsB;IADlB,KAAK,CAAC,mBAAmB,CAAC;;sDAC4B;AAGpC;IADlB,KAAK,CAAC,0BAA0B,CAAC;;6DACU;AAGzB;IADlB,KAAK,CAAC,QAAQ,CAAC;;qDACmB;AAGzB;IADT,SAAS,CAAC,YAAY,CAAC;;0DACa;AAZ5B,oBAAoB;IADhC,SAAS,CAAC,gBAAgB,CAAC;GACf,oBAAoB,CAsChC"}
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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
|
+
}
|