@celljs/rpc 3.0.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/LICENSE +21 -0
- package/README.md +1 -0
- package/cell.yml +8 -0
- package/lib/common/annotation/autorpc.d.ts +6 -0
- package/lib/common/annotation/autorpc.d.ts.map +1 -0
- package/lib/common/annotation/autorpc.js +19 -0
- package/lib/common/annotation/autorpc.js.map +1 -0
- package/lib/common/annotation/detached/autorpc.d.ts +3 -0
- package/lib/common/annotation/detached/autorpc.d.ts.map +1 -0
- package/lib/common/annotation/detached/autorpc.js +15 -0
- package/lib/common/annotation/detached/autorpc.js.map +1 -0
- package/lib/common/annotation/detached/index.d.ts +2 -0
- package/lib/common/annotation/detached/index.d.ts.map +1 -0
- package/lib/common/annotation/detached/index.js +18 -0
- package/lib/common/annotation/detached/index.js.map +1 -0
- package/lib/common/annotation/index.d.ts +3 -0
- package/lib/common/annotation/index.d.ts.map +1 -0
- package/lib/common/annotation/index.js +19 -0
- package/lib/common/annotation/index.js.map +1 -0
- package/lib/common/annotation/rpc.d.ts +20 -0
- package/lib/common/annotation/rpc.d.ts.map +1 -0
- package/lib/common/annotation/rpc.js +41 -0
- package/lib/common/annotation/rpc.js.map +1 -0
- package/lib/common/channal/channel-protocol.d.ts +52 -0
- package/lib/common/channal/channel-protocol.d.ts.map +1 -0
- package/lib/common/channal/channel-protocol.js +38 -0
- package/lib/common/channal/channel-protocol.js.map +1 -0
- package/lib/common/channal/http-channel.d.ts +9 -0
- package/lib/common/channal/http-channel.d.ts.map +1 -0
- package/lib/common/channal/http-channel.js +26 -0
- package/lib/common/channal/http-channel.js.map +1 -0
- package/lib/common/channal/index.d.ts +3 -0
- package/lib/common/channal/index.d.ts.map +1 -0
- package/lib/common/channal/index.js +19 -0
- package/lib/common/channal/index.js.map +1 -0
- package/lib/common/constants.d.ts +2 -0
- package/lib/common/constants.d.ts.map +1 -0
- package/lib/common/constants.js +5 -0
- package/lib/common/constants.js.map +1 -0
- package/lib/common/converter/converter-protocol.d.ts +7 -0
- package/lib/common/converter/converter-protocol.d.ts.map +1 -0
- package/lib/common/converter/converter-protocol.js +6 -0
- package/lib/common/converter/converter-protocol.js.map +1 -0
- package/lib/common/converter/index.d.ts +2 -0
- package/lib/common/converter/index.d.ts.map +1 -0
- package/lib/common/converter/index.js +18 -0
- package/lib/common/converter/index.js.map +1 -0
- package/lib/common/endpoint/endpoint-protocol.d.ts +5 -0
- package/lib/common/endpoint/endpoint-protocol.d.ts.map +1 -0
- package/lib/common/endpoint/endpoint-protocol.js +5 -0
- package/lib/common/endpoint/endpoint-protocol.js.map +1 -0
- package/lib/common/endpoint/endpoint-resolver.d.ts +13 -0
- package/lib/common/endpoint/endpoint-resolver.d.ts.map +1 -0
- package/lib/common/endpoint/endpoint-resolver.js +61 -0
- package/lib/common/endpoint/endpoint-resolver.js.map +1 -0
- package/lib/common/endpoint/index.d.ts +3 -0
- package/lib/common/endpoint/index.d.ts.map +1 -0
- package/lib/common/endpoint/index.js +19 -0
- package/lib/common/endpoint/index.js.map +1 -0
- package/lib/common/error/error.d.ts +6 -0
- package/lib/common/error/error.d.ts.map +1 -0
- package/lib/common/error/error.js +12 -0
- package/lib/common/error/error.js.map +1 -0
- package/lib/common/error/index.d.ts +2 -0
- package/lib/common/error/index.d.ts.map +1 -0
- package/lib/common/error/index.js +18 -0
- package/lib/common/error/index.js.map +1 -0
- package/lib/common/factory/connection-factory.d.ts +10 -0
- package/lib/common/factory/connection-factory.d.ts.map +1 -0
- package/lib/common/factory/connection-factory.js +28 -0
- package/lib/common/factory/connection-factory.js.map +1 -0
- package/lib/common/factory/index.d.ts +5 -0
- package/lib/common/factory/index.d.ts.map +1 -0
- package/lib/common/factory/index.js +21 -0
- package/lib/common/factory/index.js.map +1 -0
- package/lib/common/factory/proxy-factory.d.ts +57 -0
- package/lib/common/factory/proxy-factory.d.ts.map +1 -0
- package/lib/common/factory/proxy-factory.js +182 -0
- package/lib/common/factory/proxy-factory.js.map +1 -0
- package/lib/common/factory/reader.d.ts +16 -0
- package/lib/common/factory/reader.d.ts.map +1 -0
- package/lib/common/factory/reader.js +48 -0
- package/lib/common/factory/reader.js.map +1 -0
- package/lib/common/factory/writer.d.ts +10 -0
- package/lib/common/factory/writer.d.ts.map +1 -0
- package/lib/common/factory/writer.js +25 -0
- package/lib/common/factory/writer.js.map +1 -0
- package/lib/common/handler/connection-handler.d.ts +7 -0
- package/lib/common/handler/connection-handler.d.ts.map +1 -0
- package/lib/common/handler/connection-handler.js +8 -0
- package/lib/common/handler/connection-handler.js.map +1 -0
- package/lib/common/handler/handler-protocol.d.ts +7 -0
- package/lib/common/handler/handler-protocol.d.ts.map +1 -0
- package/lib/common/handler/handler-protocol.js +5 -0
- package/lib/common/handler/handler-protocol.js.map +1 -0
- package/lib/common/handler/index.d.ts +3 -0
- package/lib/common/handler/index.d.ts.map +1 -0
- package/lib/common/handler/index.js +19 -0
- package/lib/common/handler/index.js.map +1 -0
- package/lib/common/index.d.ts +12 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +28 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/module.d.ts +4 -0
- package/lib/common/module.d.ts.map +1 -0
- package/lib/common/module.js +22 -0
- package/lib/common/module.js.map +1 -0
- package/lib/common/processor/client-config-processor.d.ts +6 -0
- package/lib/common/processor/client-config-processor.d.ts.map +1 -0
- package/lib/common/processor/client-config-processor.js +20 -0
- package/lib/common/processor/client-config-processor.js.map +1 -0
- package/lib/common/processor/index.d.ts +3 -0
- package/lib/common/processor/index.d.ts.map +1 -0
- package/lib/common/processor/index.js +19 -0
- package/lib/common/processor/index.js.map +1 -0
- package/lib/common/processor/processor-protocol.d.ts +6 -0
- package/lib/common/processor/processor-protocol.d.ts.map +1 -0
- package/lib/common/processor/processor-protocol.js +5 -0
- package/lib/common/processor/processor-protocol.js.map +1 -0
- package/lib/common/proxy/delegating-http-proxy-creator.d.ts +24 -0
- package/lib/common/proxy/delegating-http-proxy-creator.d.ts.map +1 -0
- package/lib/common/proxy/delegating-http-proxy-creator.js +89 -0
- package/lib/common/proxy/delegating-http-proxy-creator.js.map +1 -0
- package/lib/common/proxy/http-proxy-creator.d.ts +43 -0
- package/lib/common/proxy/http-proxy-creator.d.ts.map +1 -0
- package/lib/common/proxy/http-proxy-creator.js +137 -0
- package/lib/common/proxy/http-proxy-creator.js.map +1 -0
- package/lib/common/proxy/index.d.ts +5 -0
- package/lib/common/proxy/index.d.ts.map +1 -0
- package/lib/common/proxy/index.js +21 -0
- package/lib/common/proxy/index.js.map +1 -0
- package/lib/common/proxy/proxy-protocol.d.ts +22 -0
- package/lib/common/proxy/proxy-protocol.d.ts.map +1 -0
- package/lib/common/proxy/proxy-protocol.js +6 -0
- package/lib/common/proxy/proxy-protocol.js.map +1 -0
- package/lib/common/proxy/proxy-provider.d.ts +10 -0
- package/lib/common/proxy/proxy-provider.d.ts.map +1 -0
- package/lib/common/proxy/proxy-provider.js +43 -0
- package/lib/common/proxy/proxy-provider.js.map +1 -0
- package/lib/common/utils/converter-util.d.ts +8 -0
- package/lib/common/utils/converter-util.d.ts.map +1 -0
- package/lib/common/utils/converter-util.js +32 -0
- package/lib/common/utils/converter-util.js.map +1 -0
- package/lib/common/utils/index.d.ts +4 -0
- package/lib/common/utils/index.d.ts.map +1 -0
- package/lib/common/utils/index.js +20 -0
- package/lib/common/utils/index.js.map +1 -0
- package/lib/common/utils/logger.d.ts +9 -0
- package/lib/common/utils/logger.d.ts.map +1 -0
- package/lib/common/utils/logger.js +22 -0
- package/lib/common/utils/logger.js.map +1 -0
- package/lib/common/utils/rpc-util.d.ts +13 -0
- package/lib/common/utils/rpc-util.d.ts.map +1 -0
- package/lib/common/utils/rpc-util.js +46 -0
- package/lib/common/utils/rpc-util.js.map +1 -0
- package/lib/node/channel/channel-manager.d.ts +10 -0
- package/lib/node/channel/channel-manager.d.ts.map +1 -0
- package/lib/node/channel/channel-manager.js +59 -0
- package/lib/node/channel/channel-manager.js.map +1 -0
- package/lib/node/channel/channel-middleware.d.ts +8 -0
- package/lib/node/channel/channel-middleware.d.ts.map +1 -0
- package/lib/node/channel/channel-middleware.js +40 -0
- package/lib/node/channel/channel-middleware.js.map +1 -0
- package/lib/node/channel/channel-protocol.d.ts +13 -0
- package/lib/node/channel/channel-protocol.d.ts.map +1 -0
- package/lib/node/channel/channel-protocol.js +9 -0
- package/lib/node/channel/channel-protocol.js.map +1 -0
- package/lib/node/channel/channel-strategy.d.ts +10 -0
- package/lib/node/channel/channel-strategy.d.ts.map +1 -0
- package/lib/node/channel/channel-strategy.js +64 -0
- package/lib/node/channel/channel-strategy.js.map +1 -0
- package/lib/node/channel/index.d.ts +5 -0
- package/lib/node/channel/index.d.ts.map +1 -0
- package/lib/node/channel/index.js +21 -0
- package/lib/node/channel/index.js.map +1 -0
- package/lib/node/handler/handler-adapter.d.ts +14 -0
- package/lib/node/handler/handler-adapter.d.ts.map +1 -0
- package/lib/node/handler/handler-adapter.js +55 -0
- package/lib/node/handler/handler-adapter.js.map +1 -0
- package/lib/node/handler/handler-protocol.d.ts +2 -0
- package/lib/node/handler/handler-protocol.d.ts.map +1 -0
- package/lib/node/handler/handler-protocol.js +5 -0
- package/lib/node/handler/handler-protocol.js.map +1 -0
- package/lib/node/handler/index.d.ts +3 -0
- package/lib/node/handler/index.d.ts.map +1 -0
- package/lib/node/handler/index.js +19 -0
- package/lib/node/handler/index.js.map +1 -0
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +19 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/module.d.ts +4 -0
- package/lib/node/module.d.ts.map +1 -0
- package/lib/node/module.js +6 -0
- package/lib/node/module.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +4 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +45 -0
- package/src/common/annotation/autorpc.ts +17 -0
- package/src/common/annotation/detached/autorpc.ts +12 -0
- package/src/common/annotation/detached/index.ts +1 -0
- package/src/common/annotation/index.ts +2 -0
- package/src/common/annotation/rpc.ts +41 -0
- package/src/common/channal/channel-protocol.ts +82 -0
- package/src/common/channal/http-channel.ts +30 -0
- package/src/common/channal/index.ts +2 -0
- package/src/common/constants.ts +1 -0
- package/src/common/converter/converter-protocol.ts +8 -0
- package/src/common/converter/index.ts +1 -0
- package/src/common/endpoint/endpoint-protocol.ts +5 -0
- package/src/common/endpoint/endpoint-resolver.ts +46 -0
- package/src/common/endpoint/index.ts +2 -0
- package/src/common/error/error.ts +7 -0
- package/src/common/error/index.ts +1 -0
- package/src/common/factory/connection-factory.ts +21 -0
- package/src/common/factory/index.ts +4 -0
- package/src/common/factory/proxy-factory.ts +219 -0
- package/src/common/factory/reader.ts +50 -0
- package/src/common/factory/writer.ts +26 -0
- package/src/common/handler/connection-handler.ts +7 -0
- package/src/common/handler/handler-protocol.ts +8 -0
- package/src/common/handler/index.ts +2 -0
- package/src/common/index.ts +11 -0
- package/src/common/module.ts +21 -0
- package/src/common/processor/client-config-processor.ts +12 -0
- package/src/common/processor/index.ts +2 -0
- package/src/common/processor/processor-protocol.ts +7 -0
- package/src/common/proxy/delegating-http-proxy-creator.ts +68 -0
- package/src/common/proxy/http-proxy-creator.ts +179 -0
- package/src/common/proxy/index.ts +5 -0
- package/src/common/proxy/proxy-protocol.ts +26 -0
- package/src/common/proxy/proxy-provider.ts +29 -0
- package/src/common/utils/converter-util.ts +29 -0
- package/src/common/utils/index.ts +3 -0
- package/src/common/utils/logger.ts +23 -0
- package/src/common/utils/rpc-util.ts +46 -0
- package/src/node/channel/channel-manager.ts +44 -0
- package/src/node/channel/channel-middleware.ts +27 -0
- package/src/node/channel/channel-protocol.ts +21 -0
- package/src/node/channel/channel-strategy.ts +56 -0
- package/src/node/channel/index.ts +4 -0
- package/src/node/handler/handler-adapter.ts +38 -0
- package/src/node/handler/handler-protocol.ts +1 -0
- package/src/node/handler/index.ts +2 -0
- package/src/node/index.ts +2 -0
- package/src/node/module.ts +4 -0
- package/src/package.spec.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-adapter.js","sourceRoot":"","sources":["../../../src/node/handler/handler-adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAqE;AACrE,wCAA4C;AAC5C,yDAAkE;AAClE,+CAA+E;AAC/E,qCAA2C;AAC3C,yCAAwC;AAE3B,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAAvB;QACM,aAAQ,GAAG,+CAA4B,CAAC;IA0BrD,CAAC;IAZG,KAAK,CAAC,MAAM;QACR,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,cAAO,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,QAAQ,CAAC,IAAI,YAAY,eAAQ,EAAE;YACnC,QAAQ,CAAC,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;SAC/C;IACL,CAAC;IAED,KAAK,CAAC,SAAS;QACX,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACpF,CAAC;CAEJ,CAAA;AAxBG;IAAC,IAAA,gBAAS,EAAC,wBAAc,CAAC;8BACS,wBAAc;yDAAC;AAElD;IAAC,IAAA,gBAAS,EAAC,qBAAc,CAAC;;yDACwB;AAElD;IAAC,IAAA,gBAAS,EAAC,kBAAY,CAAC;;uDACsB;AAE9C;IAAC,IAAA,YAAK,EAAC,iBAAQ,CAAC;;kDACmB;AAb1B,iBAAiB;IAD7B,IAAA,gBAAS,EAAC,qBAAc,CAAC;GACb,iBAAiB,CA2B7B;AA3BY,8CAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/handler/handler-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-protocol.js","sourceRoot":"","sources":["../../../src/node/handler/handler-protocol.ts"],"names":[],"mappings":";;;AAAa,QAAA,4BAA4B,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/handler/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./handler-adapter"), exports);
|
|
18
|
+
__exportStar(require("./handler-protocol"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/handler/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./channel"), exports);
|
|
18
|
+
__exportStar(require("./handler"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,CAAC;;AAEjB,wBAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AACxC,mBAAiB;AAEjB,kBAAe,IAAA,eAAQ,GAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=package.spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAEzB,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@celljs/rpc",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/common/index.js",
|
|
6
|
+
"typings": "lib/common/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@celljs/core": "3.0.0",
|
|
9
|
+
"@celljs/http": "3.0.0",
|
|
10
|
+
"@celljs/web": "3.0.0",
|
|
11
|
+
"axios": "^0.26.1",
|
|
12
|
+
"vscode-jsonrpc": "^6.0.0"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"cell-component"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/cellbang/cell.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/cellbang/cell/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/cellbang/cell",
|
|
29
|
+
"files": [
|
|
30
|
+
"lib",
|
|
31
|
+
"src",
|
|
32
|
+
"cell.yml"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"lint": "cell-component lint",
|
|
36
|
+
"build": "cell-component build",
|
|
37
|
+
"watch": "cell-component watch",
|
|
38
|
+
"clean": "cell-component clean",
|
|
39
|
+
"test": "cell-component test:js"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@celljs/component": "3.0.0"
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "c0ef8d269e33a795406bcbb240cac4b845c6c24c"
|
|
45
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { applyAutowiredDecorator, IdOrAutowiredOptionWithoutMulti, DoInject, parseAutowiredOption, Tagged, Inject } from '@celljs/core';
|
|
2
|
+
|
|
3
|
+
export const RPC = Symbol('RPC');
|
|
4
|
+
export const ID_KEY = Symbol('ID_KEY');
|
|
5
|
+
|
|
6
|
+
export const Autorpc = function (idOrOption?: IdOrAutowiredOptionWithoutMulti): PropertyDecorator & ParameterDecorator {
|
|
7
|
+
return (target: any, targetKey: string, index?: number) => {
|
|
8
|
+
const option = parseAutowiredOption(target, targetKey, index, idOrOption);
|
|
9
|
+
applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutorpc);
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const doInjectForAutorpc: DoInject = (option, t, k, i) => {
|
|
14
|
+
Inject(RPC)(t, k, i);
|
|
15
|
+
Tagged(ID_KEY, option.id!)(t, k, i);
|
|
16
|
+
};
|
|
17
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { applyAutowiredDecorator, ContainerUtil, DoGetValue, IdOrAutowiredOptionWithoutMulti, parseAutowiredOption } from '@celljs/core';
|
|
2
|
+
import { RPC, ID_KEY, doInjectForAutorpc } from '../autorpc';
|
|
3
|
+
|
|
4
|
+
export const Autorpc = function (idOrOption?: IdOrAutowiredOptionWithoutMulti): PropertyDecorator & ParameterDecorator {
|
|
5
|
+
return (target: any, targetKey: string, index?: number) => {
|
|
6
|
+
const option = parseAutowiredOption(target, targetKey, index, idOrOption);
|
|
7
|
+
option.detached = true;
|
|
8
|
+
applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutorpc, doGetValueForAutorpc);
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const doGetValueForAutorpc: DoGetValue = (option, t, property) => ContainerUtil.getTagged(RPC, ID_KEY, option.id!);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './autorpc';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ComponentDecorator, applyComponentDecorator, ComponentOption, parseComponentOption, Logger, Container } from '@celljs/core';
|
|
2
|
+
import { AOP_POINTCUT, PipeManager } from '@celljs/web';
|
|
3
|
+
import { ConnectionHandler } from '../handler';
|
|
4
|
+
import { JsonRpcConnectionHandler } from '../factory';
|
|
5
|
+
import { RpcUtil, ConverterUtil } from '../utils';
|
|
6
|
+
|
|
7
|
+
export const RPC_TAG = 'Rpc';
|
|
8
|
+
|
|
9
|
+
export const Rpc = <ComponentDecorator>function (...idOrOption: any): ClassDecorator {
|
|
10
|
+
return target => {
|
|
11
|
+
const option = parseRpcOption(target, idOrOption);
|
|
12
|
+
applyRpcDecorator(option, target);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function parseRpcOption(target: any, idOrOption: any) {
|
|
17
|
+
const parsed = parseComponentOption(target, idOrOption);
|
|
18
|
+
|
|
19
|
+
if (idOrOption[0].proxy === undefined) {
|
|
20
|
+
parsed.proxy = true;
|
|
21
|
+
}
|
|
22
|
+
parsed.sysTags!.push(AOP_POINTCUT, RPC_TAG);
|
|
23
|
+
return parsed;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function applyRpcDecorator(option: ComponentOption, target: any) {
|
|
27
|
+
const { ids } = applyComponentDecorator(option, target);
|
|
28
|
+
const id = ids[1] || ids[0];
|
|
29
|
+
return applyComponentDecorator({ id: ConnectionHandler, onActivation: context => {
|
|
30
|
+
const t = context.container.get(id);
|
|
31
|
+
const pipeManager = context.container.get<PipeManager>(PipeManager);
|
|
32
|
+
const logger = context.container.get<Logger>(Logger);
|
|
33
|
+
const errorConverters = ConverterUtil.getGlobalErrorConverters(context.container as Container);
|
|
34
|
+
const errorConverter = ConverterUtil.getErrorConverters(id, context.container as Container);
|
|
35
|
+
if (errorConverter) {
|
|
36
|
+
errorConverters.push(errorConverter);
|
|
37
|
+
}
|
|
38
|
+
return new JsonRpcConnectionHandler(RpcUtil.toPath(id), () => t, errorConverters, pipeManager, logger);
|
|
39
|
+
}}, target);
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const RPC_PATH = 'cell.rpc.path';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './converter-protocol';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Autowired, Component, Value } from '@celljs/core';
|
|
2
|
+
import { RPC_PATH } from '../constants';
|
|
3
|
+
import { PathResolver } from '@celljs/web';
|
|
4
|
+
import { EndpointNotFoundError } from '../error';
|
|
5
|
+
import { EndpointResolver } from './endpoint-protocol';
|
|
6
|
+
|
|
7
|
+
@Component(EndpointResolver)
|
|
8
|
+
export class EndpointResolverImpl implements EndpointResolver {
|
|
9
|
+
|
|
10
|
+
@Value('cell.rpc.endpoint')
|
|
11
|
+
protected readonly endpoint?: { [id: string]: string };
|
|
12
|
+
|
|
13
|
+
@Value('cell.rpc.defaultEndpoint')
|
|
14
|
+
protected readonly defaultEndpoint?: string;
|
|
15
|
+
|
|
16
|
+
@Value(RPC_PATH)
|
|
17
|
+
protected readonly rpcPath: string;
|
|
18
|
+
|
|
19
|
+
@Autowired(PathResolver)
|
|
20
|
+
protected pathResolver: PathResolver;
|
|
21
|
+
|
|
22
|
+
protected parsed: Map<string, string>;
|
|
23
|
+
|
|
24
|
+
async resolve(serviceIdentifier: string): Promise<string> {
|
|
25
|
+
let result: string | undefined;
|
|
26
|
+
if (this.endpoint) {
|
|
27
|
+
result = this.endpoint[serviceIdentifier];
|
|
28
|
+
}
|
|
29
|
+
if (/^https?:/i.test(serviceIdentifier)) {
|
|
30
|
+
result = serviceIdentifier;
|
|
31
|
+
}
|
|
32
|
+
if (!result) {
|
|
33
|
+
result = this.defaultEndpoint;
|
|
34
|
+
}
|
|
35
|
+
if (!result && typeof location !== 'undefined') {
|
|
36
|
+
result = `${location.protocol}//${location.host}{rpcPath}/{serviceIdentifier}`;
|
|
37
|
+
}
|
|
38
|
+
if (!result) {
|
|
39
|
+
throw new EndpointNotFoundError(serviceIdentifier);
|
|
40
|
+
}
|
|
41
|
+
return result
|
|
42
|
+
.replace(/{rpcPath}/g, await this.pathResolver.resolve(this.rpcPath))
|
|
43
|
+
.replace(/{serviceIdentifier}/g, serviceIdentifier);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './error';
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|