@x-oasis/async-call-rpc-misc 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/async-call-rpc-misc.cjs.development.js +221 -0
- package/dist/async-call-rpc-misc.cjs.development.js.map +1 -0
- package/dist/async-call-rpc-misc.cjs.production.min.js +2 -0
- package/dist/async-call-rpc-misc.cjs.production.min.js.map +1 -0
- package/dist/async-call-rpc-misc.esm.js +216 -0
- package/dist/async-call-rpc-misc.esm.js.map +1 -0
- package/dist/buffer/DataBuffer.d.ts +2 -0
- package/dist/buffer/ReadBuffer.d.ts +12 -0
- package/dist/buffer/WriteBuffer.d.ts +3 -0
- package/dist/buffer/index.d.ts +3 -0
- package/dist/channel-protocol/AbstractChannelProtocol.d.ts +51 -0
- package/dist/channel-protocol/Channel.d.ts +16 -0
- package/dist/channel-protocol/DeferredMessageChannelProtocol.d.ts +8 -0
- package/dist/channel-protocol/IPCMainChannelProtocol.d.ts +7 -0
- package/dist/channel-protocol/IPCMainGlobalChannelProtocol.d.ts +7 -0
- package/dist/channel-protocol/IPCRendererChannelProtocol.d.ts +8 -0
- package/dist/channel-protocol/IPCRendererMessageChannelProtocol.d.ts +8 -0
- package/dist/channel-protocol/MessageChannelProtocol.d.ts +7 -0
- package/dist/channel-protocol/ProcessChannelProtocol.d.ts +7 -0
- package/dist/channel-protocol/ProcessClientChannelProtocol.d.ts +7 -0
- package/dist/channel-protocol/middlewares/buffer.d.ts +18 -0
- package/dist/channel-protocol/middlewares/handleDisconnectedRequest.d.ts +7 -0
- package/dist/channel-protocol/middlewares/handlePortRequest.d.ts +3 -0
- package/dist/channel-protocol/middlewares/handleRequest.d.ts +3 -0
- package/dist/channel-protocol/middlewares/handleRequestUtils.d.ts +10 -0
- package/dist/channel-protocol/middlewares/handleResponse.d.ts +3 -0
- package/dist/channel-protocol/middlewares/index.d.ts +10 -0
- package/dist/channel-protocol/middlewares/logger.d.ts +4 -0
- package/dist/channel-protocol/middlewares/normalize.d.ts +12 -0
- package/dist/channel-protocol/middlewares/prepareRequestData.d.ts +28 -0
- package/dist/channel-protocol/middlewares/sendRequest.d.ts +6 -0
- package/dist/channel-protocol/middlewares/updateSeqInfo.d.ts +6 -0
- package/dist/channel-protocol/middlewares/utils.d.ts +3 -0
- package/dist/common.d.ts +4 -0
- package/dist/error.d.ts +12 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -0
- package/dist/rpc-service/ProxyRPCClient.d.ts +9 -0
- package/dist/rpc-service/RPCServiceHost.d.ts +11 -0
- package/dist/rpc-service/RPCServiceProvider.d.ts +9 -0
- package/dist/types/buffer.d.ts +4 -0
- package/dist/types/channel.d.ts +12 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/messageChannel.d.ts +76 -0
- package/dist/types/middleware.d.ts +44 -0
- package/dist/types/proxyChannel.d.ts +3 -0
- package/dist/types/proxyService.d.ts +10 -0
- package/dist/types/rpc.d.ts +31 -0
- package/dist/types/rpcProtocol.d.ts +22 -0
- package/package.json +38 -0
- package/src/buffer/DataBuffer.ts +1 -0
- package/src/buffer/ReadBuffer.ts +41 -0
- package/src/buffer/WriteBuffer.ts +5 -0
- package/src/buffer/index.ts +3 -0
- package/src/channel-protocol/AbstractChannelProtocol.ts +204 -0
- package/src/channel-protocol/Channel.ts +37 -0
- package/src/channel-protocol/DeferredMessageChannelProtocol.ts +85 -0
- package/src/channel-protocol/IPCMainChannelProtocol.ts +65 -0
- package/src/channel-protocol/IPCMainGlobalChannelProtocol.ts +66 -0
- package/src/channel-protocol/IPCRendererChannelProtocol.ts +81 -0
- package/src/channel-protocol/IPCRendererMessageChannelProtocol.ts +79 -0
- package/src/channel-protocol/MessageChannelProtocol.ts +63 -0
- package/src/channel-protocol/ProcessChannelProtocol.ts +60 -0
- package/src/channel-protocol/ProcessClientChannelProtocol.ts +59 -0
- package/src/channel-protocol/middlewares/buffer.ts +33 -0
- package/src/channel-protocol/middlewares/handleDisconnectedRequest.ts +30 -0
- package/src/channel-protocol/middlewares/handlePortRequest.ts +118 -0
- package/src/channel-protocol/middlewares/handleRequest.ts +163 -0
- package/src/channel-protocol/middlewares/handleRequestUtils.ts +42 -0
- package/src/channel-protocol/middlewares/handleResponse.ts +38 -0
- package/src/channel-protocol/middlewares/index.ts +11 -0
- package/src/channel-protocol/middlewares/logger.ts +22 -0
- package/src/channel-protocol/middlewares/normalize.ts +28 -0
- package/src/channel-protocol/middlewares/prepareRequestData.ts +137 -0
- package/src/channel-protocol/middlewares/sendRequest.ts +15 -0
- package/src/channel-protocol/middlewares/updateSeqInfo.ts +27 -0
- package/src/channel-protocol/middlewares/utils.ts +67 -0
- package/src/common.ts +20 -0
- package/src/error.ts +32 -0
- package/src/index.ts +5 -0
- package/src/rpc-service/ProxyRPCClient.ts +82 -0
- package/src/rpc-service/RPCServiceHost.ts +35 -0
- package/src/rpc-service/RPCServiceProvider.ts +22 -0
- package/src/types/buffer.ts +5 -0
- package/src/types/channel.ts +24 -0
- package/src/types/index.ts +6 -0
- package/src/types/messageChannel.ts +134 -0
- package/src/types/middleware.ts +53 -0
- package/src/types/proxyChannel.ts +3 -0
- package/src/types/proxyService.ts +16 -0
- package/src/types/rpc.ts +61 -0
- package/src/types/rpcProtocol.ts +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var isAscii = require('@x-oasis/is-ascii');
|
|
6
|
+
|
|
7
|
+
function _defineProperties(target, props) {
|
|
8
|
+
for (var i = 0; i < props.length; i++) {
|
|
9
|
+
var descriptor = props[i];
|
|
10
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
11
|
+
descriptor.configurable = true;
|
|
12
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
13
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
17
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
18
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
19
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
20
|
+
writable: false
|
|
21
|
+
});
|
|
22
|
+
return Constructor;
|
|
23
|
+
}
|
|
24
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
25
|
+
if (!o) return;
|
|
26
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
27
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
28
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
29
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
30
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
31
|
+
}
|
|
32
|
+
function _arrayLikeToArray(arr, len) {
|
|
33
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
34
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
35
|
+
return arr2;
|
|
36
|
+
}
|
|
37
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
38
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
39
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
40
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
41
|
+
if (it) o = it;
|
|
42
|
+
var i = 0;
|
|
43
|
+
return function () {
|
|
44
|
+
if (i >= o.length) return {
|
|
45
|
+
done: true
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
done: false,
|
|
49
|
+
value: o[i++]
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
54
|
+
}
|
|
55
|
+
function _toPrimitive(input, hint) {
|
|
56
|
+
if (typeof input !== "object" || input === null) return input;
|
|
57
|
+
var prim = input[Symbol.toPrimitive];
|
|
58
|
+
if (prim !== undefined) {
|
|
59
|
+
var res = prim.call(input, hint || "default");
|
|
60
|
+
if (typeof res !== "object") return res;
|
|
61
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
62
|
+
}
|
|
63
|
+
return (hint === "string" ? String : Number)(input);
|
|
64
|
+
}
|
|
65
|
+
function _toPropertyKey(arg) {
|
|
66
|
+
var key = _toPrimitive(arg, "string");
|
|
67
|
+
return typeof key === "symbol" ? key : String(key);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var RPCServiceHost = /*#__PURE__*/function () {
|
|
71
|
+
function RPCServiceHost(hostPath) {
|
|
72
|
+
this.handlersMap = new Map();
|
|
73
|
+
this.hostPath = hostPath;
|
|
74
|
+
}
|
|
75
|
+
var _proto = RPCServiceHost.prototype;
|
|
76
|
+
_proto.registerServiceHandler = function registerServiceHandler(handlerPath, service) {
|
|
77
|
+
this.handlersMap.set(handlerPath, service);
|
|
78
|
+
};
|
|
79
|
+
_proto.getHandlers = function getHandlers(handlerPath) {
|
|
80
|
+
var handlers = this.handlersMap.get(handlerPath);
|
|
81
|
+
return handlers;
|
|
82
|
+
};
|
|
83
|
+
_proto.getHandler = function getHandler(handlerPath, fnName) {
|
|
84
|
+
var handlers = this.handlersMap.get(handlerPath);
|
|
85
|
+
if (handlers && handlers[fnName]) return handlers[fnName].bind(handlers);
|
|
86
|
+
return null;
|
|
87
|
+
};
|
|
88
|
+
_proto.merge = function merge(serviceHost) {
|
|
89
|
+
for (var _iterator = _createForOfIteratorHelperLoose(serviceHost.handlersMap), _step; !(_step = _iterator()).done;) {
|
|
90
|
+
var _step$value = _step.value,
|
|
91
|
+
key = _step$value[0],
|
|
92
|
+
value = _step$value[1];
|
|
93
|
+
this.registerServiceHandler(key, value);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
return RPCServiceHost;
|
|
97
|
+
}();
|
|
98
|
+
|
|
99
|
+
var RPCServiceProvider = /*#__PURE__*/function () {
|
|
100
|
+
function RPCServiceProvider() {
|
|
101
|
+
this.hostMap = new Map();
|
|
102
|
+
}
|
|
103
|
+
var _proto = RPCServiceProvider.prototype;
|
|
104
|
+
_proto.getHost = function getHost(hostPath) {
|
|
105
|
+
return this.hostMap.get(hostPath);
|
|
106
|
+
};
|
|
107
|
+
_proto.registerHost = function registerHost(hostPath) {
|
|
108
|
+
var host = this.hostMap.get(hostPath);
|
|
109
|
+
if (host) return host;
|
|
110
|
+
this.hostMap.set(hostPath, new RPCServiceHost(hostPath));
|
|
111
|
+
return this.hostMap.get(hostPath);
|
|
112
|
+
};
|
|
113
|
+
_proto.resetHost = function resetHost(hostPath) {
|
|
114
|
+
this.hostMap.set(hostPath, new RPCServiceHost(hostPath));
|
|
115
|
+
};
|
|
116
|
+
return RPCServiceProvider;
|
|
117
|
+
}();
|
|
118
|
+
var RPCServiceProvider$1 = /*#__PURE__*/new RPCServiceProvider();
|
|
119
|
+
|
|
120
|
+
var isEventMethod = function isEventMethod(name) {
|
|
121
|
+
if (typeof name !== 'string') return false;
|
|
122
|
+
return name[0] === 'o' && name[1] === 'n' && isAscii.isUpperAsciiLetter(name.charCodeAt(2));
|
|
123
|
+
};
|
|
124
|
+
var isAssignPassingPortMethod = function isAssignPassingPortMethod(name) {
|
|
125
|
+
return /^assignPassingPort$/.test(name);
|
|
126
|
+
};
|
|
127
|
+
var isOptionsMethod = function isOptionsMethod(name) {
|
|
128
|
+
return /Options$/.test(name) || /OptionsRequest$/.test(name);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
var ProxyRPCClient = /*#__PURE__*/function () {
|
|
132
|
+
function ProxyRPCClient(props) {
|
|
133
|
+
this._channelProtocol = props.channel;
|
|
134
|
+
this.requestPath = props.requestPath;
|
|
135
|
+
}
|
|
136
|
+
var _proto = ProxyRPCClient.prototype;
|
|
137
|
+
_proto.createProxy = function createProxy() {
|
|
138
|
+
var _this = this;
|
|
139
|
+
return new Proxy({}, {
|
|
140
|
+
get: function get(target, key) {
|
|
141
|
+
return function () {
|
|
142
|
+
var fnName = key.toString();
|
|
143
|
+
if (!_this.channelProtocol) {
|
|
144
|
+
throw new Error("[ProxyRPCClient error] `this.channelProtocol` is null, when invoke function " + fnName);
|
|
145
|
+
}
|
|
146
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
147
|
+
args[_key] = arguments[_key];
|
|
148
|
+
}
|
|
149
|
+
if (isAssignPassingPortMethod(fnName)) {
|
|
150
|
+
var ports = args.pop();
|
|
151
|
+
_this.channelProtocol.send({
|
|
152
|
+
requestPath: _this.requestPath,
|
|
153
|
+
fnName: fnName,
|
|
154
|
+
args: args
|
|
155
|
+
}, [].concat(ports));
|
|
156
|
+
} else if (isEventMethod(fnName)) {
|
|
157
|
+
_this.channelProtocol.send({
|
|
158
|
+
requestPath: _this.requestPath,
|
|
159
|
+
fnName: fnName,
|
|
160
|
+
args: args
|
|
161
|
+
});
|
|
162
|
+
} else if (isOptionsMethod(fnName)) {
|
|
163
|
+
_this.channelProtocol.send({
|
|
164
|
+
isOptionsRequest: true,
|
|
165
|
+
requestPath: _this.requestPath,
|
|
166
|
+
fnName: fnName,
|
|
167
|
+
args: args
|
|
168
|
+
});
|
|
169
|
+
} else {
|
|
170
|
+
_this.channelProtocol.send({
|
|
171
|
+
requestPath: _this.requestPath,
|
|
172
|
+
fnName: fnName,
|
|
173
|
+
args: args
|
|
174
|
+
}).promise;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
_createClass(ProxyRPCClient, [{
|
|
181
|
+
key: "channelProtocol",
|
|
182
|
+
get: function get() {
|
|
183
|
+
if (typeof this._channelProtocol === 'function') return this._channelProtocol();
|
|
184
|
+
return this._channelProtocol;
|
|
185
|
+
}
|
|
186
|
+
}]);
|
|
187
|
+
return ProxyRPCClient;
|
|
188
|
+
}();
|
|
189
|
+
|
|
190
|
+
function isUtilityProcess(process) {
|
|
191
|
+
return !!process.parentPort;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
(function (RequestType) {
|
|
195
|
+
RequestType["PromiseRequest"] = "pr";
|
|
196
|
+
RequestType["PromiseAbort"] = "pa";
|
|
197
|
+
RequestType["SignalRequest"] = "sr";
|
|
198
|
+
RequestType["SignalAbort"] = "sa";
|
|
199
|
+
})(exports.RequestType || (exports.RequestType = {}));
|
|
200
|
+
(function (ResponseType) {
|
|
201
|
+
ResponseType["ReturnSuccess"] = "rs";
|
|
202
|
+
ResponseType["ReturnFail"] = "rf";
|
|
203
|
+
ResponseType["PortSuccess"] = "ps";
|
|
204
|
+
ResponseType["PortFail"] = "pf";
|
|
205
|
+
})(exports.ResponseType || (exports.ResponseType = {}));
|
|
206
|
+
|
|
207
|
+
(function (SendMiddlewareLifecycle) {
|
|
208
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Initial"] = 0] = "Initial";
|
|
209
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Prepare"] = 10] = "Prepare";
|
|
210
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Transfrom"] = 20] = "Transfrom";
|
|
211
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["DataOperation"] = 30] = "DataOperation";
|
|
212
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Send"] = 40] = "Send";
|
|
213
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Aborted"] = 100] = "Aborted";
|
|
214
|
+
})(exports.SendMiddlewareLifecycle || (exports.SendMiddlewareLifecycle = {}));
|
|
215
|
+
|
|
216
|
+
exports.ProxyRPCClient = ProxyRPCClient;
|
|
217
|
+
exports.RPCServiceHost = RPCServiceHost;
|
|
218
|
+
exports.isEventMethod = isEventMethod;
|
|
219
|
+
exports.isUtilityProcess = isUtilityProcess;
|
|
220
|
+
exports.rpcServiceProvider = RPCServiceProvider$1;
|
|
221
|
+
//# sourceMappingURL=async-call-rpc-misc.cjs.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-call-rpc-misc.cjs.development.js","sources":["../src/rpc-service/RPCServiceHost.ts","../src/rpc-service/RPCServiceProvider.ts","../src/common.ts","../src/rpc-service/ProxyRPCClient.ts","../src/types/messageChannel.ts","../src/types/rpc.ts","../src/types/middleware.ts"],"sourcesContent":["import { IService, ServiceHandlerPath } from '../types';\n\nclass RPCServiceHost {\n protected readonly hostPath: string;\n\n handlersMap = new Map<ServiceHandlerPath, IService>();\n\n constructor(hostPath: string) {\n this.hostPath = hostPath;\n }\n\n registerServiceHandler(handlerPath: ServiceHandlerPath, service: IService) {\n this.handlersMap.set(handlerPath, service);\n }\n\n getHandlers(handlerPath: ServiceHandlerPath) {\n const handlers = this.handlersMap.get(handlerPath);\n return handlers;\n }\n\n getHandler(handlerPath: ServiceHandlerPath, fnName: string) {\n const handlers = this.handlersMap.get(handlerPath);\n // should bind to current service object\n if (handlers && handlers[fnName]) return handlers[fnName].bind(handlers);\n return null;\n }\n\n merge(serviceHost: RPCServiceHost) {\n for (const [key, value] of serviceHost.handlersMap) {\n this.registerServiceHandler(key, value);\n }\n }\n}\n\nexport default RPCServiceHost;\n","import RPCServiceHandler from './RPCServiceHost';\n\nclass RPCServiceProvider {\n private hostMap = new Map<string, RPCServiceHandler>();\n\n getHost(hostPath: string) {\n return this.hostMap.get(hostPath);\n }\n\n registerHost(hostPath: string) {\n const host = this.hostMap.get(hostPath);\n if (host) return host;\n this.hostMap.set(hostPath, new RPCServiceHandler(hostPath));\n return this.hostMap.get(hostPath);\n }\n\n resetHost(hostPath: string) {\n this.hostMap.set(hostPath, new RPCServiceHandler(hostPath));\n }\n}\n\nexport default new RPCServiceProvider();\n","import { isUpperAsciiLetter } from '@x-oasis/is-ascii';\n\nexport const isEventMethod = (name: string) => {\n if (typeof name !== 'string') return false;\n return (\n name[0] === 'o' && name[1] === 'n' && isUpperAsciiLetter(name.charCodeAt(2))\n );\n};\n\nexport const isAssignPassingPortMethod = (name: string) => {\n return /^assignPassingPort$/.test(name);\n};\n\nexport const isAcquirePortMethod = (name: string) => {\n return /^acquire.*Port$/.test(name);\n};\n\nexport const isOptionsMethod = (name: string) => {\n return /Options$/.test(name) || /OptionsRequest$/.test(name);\n};\n","import {\n isEventMethod,\n isAssignPassingPortMethod,\n isOptionsMethod,\n} from '../common';\nimport { ProxyRPCClientProps, ProxyRPCClientChannel } from '../types';\n\nclass ProxyRPCClient {\n private requestPath: string;\n\n private _channelProtocol: ProxyRPCClientChannel;\n\n constructor(props: ProxyRPCClientProps) {\n this._channelProtocol = props.channel;\n this.requestPath = props.requestPath;\n }\n\n get channelProtocol() {\n if (typeof this._channelProtocol === 'function')\n return this._channelProtocol();\n return this._channelProtocol;\n }\n\n createProxy<T = object>(): T {\n return new Proxy(\n {},\n {\n get: (target, key) => {\n return (...args: any[]) => {\n const fnName = key.toString();\n if (!this.channelProtocol) {\n throw new Error(\n `[ProxyRPCClient error] \\`this.channelProtocol\\` is null, when invoke function ${fnName}`\n );\n }\n\n if (isAssignPassingPortMethod(fnName)) {\n const ports = args.pop();\n this.channelProtocol.send(\n {\n requestPath: this.requestPath,\n fnName,\n args,\n },\n [].concat(ports)\n );\n } else if (isEventMethod(fnName)) {\n this.channelProtocol.send({\n requestPath: this.requestPath,\n fnName,\n args,\n });\n } else if (\n /**\n * 主要是为了解决刚开始channel connected状态是待确定,而所有的rpc 原则上都是先\n * 过isConnected的判断;但是想要确保是否通的,这个时候其实还是要发rpc确认的,\n * 那么这个时候这个就不能够受 isConnected约束;否则你就一直没有请求能够发出去了。\n */\n isOptionsMethod(fnName)\n ) {\n this.channelProtocol.send({\n isOptionsRequest: true,\n requestPath: this.requestPath,\n fnName,\n args,\n });\n } else {\n this.channelProtocol.send({\n requestPath: this.requestPath,\n fnName,\n args,\n // @ts-ignore\n }).promise;\n }\n };\n },\n }\n ) as any as T;\n }\n}\n\nexport default ProxyRPCClient;\n","import { IpcRenderer, UtilityProcess, WebContents } from 'electron';\nimport MessageChannelProtocol from '../channel-protocol/MessageChannelProtocol';\nimport RPCServiceHost from '../rpc-service/RPCServiceHost';\n\nexport interface ChannelPort {\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n postMessage(message: any, transfer?: MainPort[]): void;\n}\n\nexport type UtilityMessageChannelPortStoreProps = {\n name: string;\n port: ParentPort;\n masterProcessName: string;\n clientMiddlewares?: ClientMiddleware[];\n senderMiddlewares?: SenderMiddleware[];\n};\n\nexport type OnMessageEntry = {\n data: any;\n ports: any;\n};\nexport type SenderEntry = any;\n\nexport type ClientMiddleware = (\n channel?: MessageChannelProtocol\n) => (v: OnMessageEntry) => OnMessageEntry;\n\nexport type SenderMiddleware = (\n channel?: MessageChannelProtocol\n) => (data: SenderEntry) => SenderEntry;\n\nexport type AbstractChannelProtocolProps = {\n serviceHost?: RPCServiceHost;\n connected?: boolean;\n description?: string;\n masterProcessName?: string;\n clientMiddlewares?: ClientMiddleware[];\n senderMiddlewares?: SenderMiddleware[];\n};\n\nexport type DeferredMessageChannelProtocolProps =\n AbstractChannelProtocolProps & {\n port?: MainPort;\n };\n\nexport type MessageChannelProtocolProps = AbstractChannelProtocolProps & {\n port?: MainPort;\n};\n\nexport type ProcessChannelProtocolProps = {\n process: UtilityProcess;\n} & AbstractChannelProtocolProps;\n\nexport type IPCMainGlobalChannelProtocolProps = AbstractChannelProtocolProps & {\n channelName: string;\n};\n\nexport type IPCMainChannelProtocolProps = {\n channelName: string;\n webContents: WebContents;\n} & AbstractChannelProtocolProps;\n\nexport type IPCRendererChannelProtocolProps = {\n channelName: string;\n ipcRenderer: IpcRenderer;\n projectName: string;\n} & AbstractChannelProtocolProps;\n\nexport interface ParentPort extends NodeJS.EventEmitter {\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n once(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n addListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n postMessage(message: any): void;\n}\n\nexport type UtilityNodeJSProcess = NodeJS.Process;\n\nexport interface MainPort extends NodeJS.EventEmitter {\n // Docs: https://electronjs.org/docs/api/message-port-main\n\n /**\n * Emitted when the remote end of a MessagePortMain object becomes disconnected.\n */\n /**\n * Emitted when a MessagePortMain object receives a message.\n */\n on(event: 'close', listener: Function): this;\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n off(event: 'close', listener: Function): this;\n off(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n once(event: 'close', listener: Function): this;\n once(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n addListener(event: 'close', listener: Function): this;\n addListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n removeListener(event: 'close', listener: Function): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n /**\n * Disconnects the port, so it is no longer active.\n */\n close(): void;\n /**\n * Sends a message from the port, and optionally, transfers ownership of objects to\n * other browsing contexts.\n */\n postMessage(message: any, transfer?: MainPort[]): void;\n /**\n * Starts the sending of messages queued on the port. Messages will be queued until\n * this method is called.\n */\n start(): void;\n}\n\nexport function isUtilityProcess(\n process: NodeJS.Process\n): process is UtilityNodeJSProcess {\n return !!(process as UtilityNodeJSProcess).parentPort;\n}\n","export enum RequestType {\n /**\n * for normal request, wait for return value\n */\n PromiseRequest = 'pr',\n PromiseAbort = 'pa',\n\n /**\n * send a command\n */\n SignalRequest = 'sr',\n SignalAbort = 'sa',\n}\n\nexport type RequestRawSequenceId = number;\n\nexport type RequestSequenceId = string;\nexport type RequestServicePath = string;\nexport type RequestFnName = string;\n\nexport type RequestEntryHeader = [\n RequestType,\n RequestSequenceId,\n RequestServicePath,\n RequestFnName\n];\nexport type RequestEntryBody = any;\nexport type RequestEntry = [RequestEntryHeader, RequestEntryBody];\n\nexport enum ResponseType {\n ReturnSuccess = 'rs',\n ReturnFail = 'rf',\n\n PortSuccess = 'ps',\n PortFail = 'pf',\n}\nexport type ResponseEntryHeader = [ResponseType, RequestSequenceId];\nexport type ResponseEntryBody = any;\n\nexport type HostName = string;\n\n/**\n * 0 RequestType: PromiseRequest, PromiseAbort, SignalRequest, SignalAbort\n * 1 RequestSequenceId: string\n */\nexport type HostRequestEntryHeader = [\n RequestType,\n RequestSequenceId,\n RequestServicePath,\n RequestFnName,\n HostName\n];\nexport type HostRequestEntryBody = any;\nexport type HostRequestEntry = [HostRequestEntryHeader, HostRequestEntryBody];\n\nexport type SendingProps = {\n requestPath?: string;\n fnName?: string;\n args?: any;\n isOptionsRequest?: boolean;\n};\n","import { Deferred } from '@x-oasis/deferred';\n\nimport { HostRequestEntry, RequestEntry } from './rpc';\n\nexport type MiddlewareFunction = {\n (...args: any[]): any;\n displayName?: string;\n lifecycle?: SendMiddlewareLifecycle;\n};\n\nexport type MessageOutput = {\n event: any;\n ports: any;\n};\n\nexport type NormalizedRawMessageOutput = MessageOutput & {\n data: string;\n};\n\nexport type DeserializedMessageOutput = MessageOutput & {\n data: HostRequestEntry | RequestEntry;\n};\n\nexport type SenderMiddlewareOutput = {\n data: any;\n transfer: any;\n seqId: number;\n returnValue: Deferred;\n isOptionsRequest: boolean;\n middlewareContext: MiddlewareContext;\n};\n\nexport type PendingSendEntry = SenderMiddlewareOutput & {\n fnName: string;\n lifecycle: SendMiddlewareLifecycle;\n middlewareContext: MiddlewareContext;\n};\n\nexport type MiddlewareContext = {\n isResumed?: boolean;\n startLifecycle: SendMiddlewareLifecycle;\n minLifecycle: SendMiddlewareLifecycle;\n reserved: PendingSendEntry;\n};\n\nexport enum SendMiddlewareLifecycle {\n Initial = 0,\n Prepare = 10,\n Transfrom = 20,\n DataOperation = 30,\n Send = 40,\n Aborted = 100,\n}\n"],"names":["RPCServiceHost","hostPath","Map","_proto","prototype","registerServiceHandler","handlerPath","service","handlersMap","set","getHandlers","handlers","get","getHandler","fnName","bind","merge","serviceHost","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","value","key","RPCServiceProvider","getHost","hostMap","registerHost","host","RPCServiceHandler","resetHost","isEventMethod","name","isUpperAsciiLetter","charCodeAt","isAssignPassingPortMethod","test","isOptionsMethod","ProxyRPCClient","props","_channelProtocol","channel","requestPath","createProxy","Proxy","target","toString","_this","channelProtocol","Error","_len","arguments","length","args","Array","_key","ports","pop","send","concat","isOptionsRequest","promise","_createClass","isUtilityProcess","process","parentPort","RequestType","ResponseType","SendMiddlewareLifecycle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEMA,cAAc;EAKlB,SAAAA,eAAYC,QAAgB;IAF5B,gBAAW,GAAG,IAAIC,GAAG,EAAgC;IAGnD,IAAI,CAACD,QAAQ,GAAGA,QAAQ;;EACzB,IAAAE,MAAA,GAAAH,cAAA,CAAAI,SAAA;EAAAD,MAAA,CAEDE,sBAAsB,GAAtB,SAAAA,uBAAuBC,WAA+B,EAAEC,OAAiB;IACvE,IAAI,CAACC,WAAW,CAACC,GAAG,CAACH,WAAW,EAAEC,OAAO,CAAC;GAC3C;EAAAJ,MAAA,CAEDO,WAAW,GAAX,SAAAA,YAAYJ,WAA+B;IACzC,IAAMK,QAAQ,GAAG,IAAI,CAACH,WAAW,CAACI,GAAG,CAACN,WAAW,CAAC;IAClD,OAAOK,QAAQ;GAChB;EAAAR,MAAA,CAEDU,UAAU,GAAV,SAAAA,WAAWP,WAA+B,EAAEQ,MAAc;IACxD,IAAMH,QAAQ,GAAG,IAAI,CAACH,WAAW,CAACI,GAAG,CAACN,WAAW,CAAC;IAElD,IAAIK,QAAQ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A;;SC4GayB,gBAAgBA,CAC9BC,OAAuB;EAEvB,OAAO,CAAC,CAAEA,OAAgC,CAACC,UAAU;AACvD;;ACrIA,WAAYC,WAAW;EAIrBA,oCAAqB;EACrBA,kCAAmB;EAKnBA,mCAAoB;EACpBA,iCAAkB;AACpB,CAAC,EAZWA,mBAAW,KAAXA,mBAAW;AA6BvB,AAAA,WAAYC,YAAY;EACtBA,oCAAoB;EACpBA,iCAAiB;EAEjBA,kCAAkB;EAClBA,+BAAe;AACjB,CAAC,EANWA,oBAAY,KAAZA,oBAAY;;ACgBxB,WAAYC,uBAAuB;EACjCA,2EAAW;EACXA,4EAAY;EACZA,gFAAc;EACdA,wFAAkB;EAClBA,sEAAS;EACTA,6EAAa;AACf,CAAC,EAPWA,+BAAuB,KAAvBA,+BAAuB;;;;;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@x-oasis/is-ascii");function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var r,n,o,i=function(){function e(e){this.handlersMap=new Map,this.hostPath=e}var r=e.prototype;return r.registerServiceHandler=function(e,t){this.handlersMap.set(e,t)},r.getHandlers=function(e){return this.handlersMap.get(e)},r.getHandler=function(e,t){var r=this.handlersMap.get(e);return r&&r[t]?r[t].bind(r):null},r.merge=function(e){for(var r,n=function(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,void 0):void 0}}(e))){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e.handlersMap);!(r=n()).done;){var o=r.value;this.registerServiceHandler(o[0],o[1])}},e}(),a=new(function(){function e(){this.hostMap=new Map}var t=e.prototype;return t.getHost=function(e){return this.hostMap.get(e)},t.registerHost=function(e){return this.hostMap.get(e)||(this.hostMap.set(e,new i(e)),this.hostMap.get(e))},t.resetHost=function(e){this.hostMap.set(e,new i(e))},e}()),s=function(t){return"string"==typeof t&&"o"===t[0]&&"n"===t[1]&&e.isUpperAsciiLetter(t.charCodeAt(2))},u=function(e){return/^assignPassingPort$/.test(e)},c=function(e){return/Options$/.test(e)||/OptionsRequest$/.test(e)},l=function(){function e(e){this._channelProtocol=e.channel,this.requestPath=e.requestPath}var t,r;return e.prototype.createProxy=function(){var e=this;return new Proxy({},{get:function(t,r){return function(){var t=r.toString();if(!e.channelProtocol)throw new Error("[ProxyRPCClient error] `this.channelProtocol` is null, when invoke function "+t);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];if(u(t)){var a=o.pop();e.channelProtocol.send({requestPath:e.requestPath,fnName:t,args:o},[].concat(a))}else s(t)?e.channelProtocol.send({requestPath:e.requestPath,fnName:t,args:o}):c(t)?e.channelProtocol.send({isOptionsRequest:!0,requestPath:e.requestPath,fnName:t,args:o}):e.channelProtocol.send({requestPath:e.requestPath,fnName:t,args:o})}}})},t=e,(r=[{key:"channelProtocol",get:function(){return"function"==typeof this._channelProtocol?this._channelProtocol():this._channelProtocol}}])&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?o:String(o),n)}var o}(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();(r=exports.RequestType||(exports.RequestType={})).PromiseRequest="pr",r.PromiseAbort="pa",r.SignalRequest="sr",r.SignalAbort="sa",(n=exports.ResponseType||(exports.ResponseType={})).ReturnSuccess="rs",n.ReturnFail="rf",n.PortSuccess="ps",n.PortFail="pf",(o=exports.SendMiddlewareLifecycle||(exports.SendMiddlewareLifecycle={}))[o.Initial=0]="Initial",o[o.Prepare=10]="Prepare",o[o.Transfrom=20]="Transfrom",o[o.DataOperation=30]="DataOperation",o[o.Send=40]="Send",o[o.Aborted=100]="Aborted",exports.ProxyRPCClient=l,exports.RPCServiceHost=i,exports.isEventMethod=s,exports.isUtilityProcess=function(e){return!!e.parentPort},exports.rpcServiceProvider=a;
|
|
2
|
+
//# sourceMappingURL=async-call-rpc-misc.cjs.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-call-rpc-misc.cjs.production.min.js","sources":["../src/types/rpc.ts","../src/types/middleware.ts","../src/rpc-service/RPCServiceHost.ts","../src/rpc-service/RPCServiceProvider.ts","../src/common.ts","../src/rpc-service/ProxyRPCClient.ts","../src/types/messageChannel.ts"],"sourcesContent":["export enum RequestType {\n /**\n * for normal request, wait for return value\n */\n PromiseRequest = 'pr',\n PromiseAbort = 'pa',\n\n /**\n * send a command\n */\n SignalRequest = 'sr',\n SignalAbort = 'sa',\n}\n\nexport type RequestRawSequenceId = number;\n\nexport type RequestSequenceId = string;\nexport type RequestServicePath = string;\nexport type RequestFnName = string;\n\nexport type RequestEntryHeader = [\n RequestType,\n RequestSequenceId,\n RequestServicePath,\n RequestFnName\n];\nexport type RequestEntryBody = any;\nexport type RequestEntry = [RequestEntryHeader, RequestEntryBody];\n\nexport enum ResponseType {\n ReturnSuccess = 'rs',\n ReturnFail = 'rf',\n\n PortSuccess = 'ps',\n PortFail = 'pf',\n}\nexport type ResponseEntryHeader = [ResponseType, RequestSequenceId];\nexport type ResponseEntryBody = any;\n\nexport type HostName = string;\n\n/**\n * 0 RequestType: PromiseRequest, PromiseAbort, SignalRequest, SignalAbort\n * 1 RequestSequenceId: string\n */\nexport type HostRequestEntryHeader = [\n RequestType,\n RequestSequenceId,\n RequestServicePath,\n RequestFnName,\n HostName\n];\nexport type HostRequestEntryBody = any;\nexport type HostRequestEntry = [HostRequestEntryHeader, HostRequestEntryBody];\n\nexport type SendingProps = {\n requestPath?: string;\n fnName?: string;\n args?: any;\n isOptionsRequest?: boolean;\n};\n","import { Deferred } from '@x-oasis/deferred';\n\nimport { HostRequestEntry, RequestEntry } from './rpc';\n\nexport type MiddlewareFunction = {\n (...args: any[]): any;\n displayName?: string;\n lifecycle?: SendMiddlewareLifecycle;\n};\n\nexport type MessageOutput = {\n event: any;\n ports: any;\n};\n\nexport type NormalizedRawMessageOutput = MessageOutput & {\n data: string;\n};\n\nexport type DeserializedMessageOutput = MessageOutput & {\n data: HostRequestEntry | RequestEntry;\n};\n\nexport type SenderMiddlewareOutput = {\n data: any;\n transfer: any;\n seqId: number;\n returnValue: Deferred;\n isOptionsRequest: boolean;\n middlewareContext: MiddlewareContext;\n};\n\nexport type PendingSendEntry = SenderMiddlewareOutput & {\n fnName: string;\n lifecycle: SendMiddlewareLifecycle;\n middlewareContext: MiddlewareContext;\n};\n\nexport type MiddlewareContext = {\n isResumed?: boolean;\n startLifecycle: SendMiddlewareLifecycle;\n minLifecycle: SendMiddlewareLifecycle;\n reserved: PendingSendEntry;\n};\n\nexport enum SendMiddlewareLifecycle {\n Initial = 0,\n Prepare = 10,\n Transfrom = 20,\n DataOperation = 30,\n Send = 40,\n Aborted = 100,\n}\n","import { IService, ServiceHandlerPath } from '../types';\n\nclass RPCServiceHost {\n protected readonly hostPath: string;\n\n handlersMap = new Map<ServiceHandlerPath, IService>();\n\n constructor(hostPath: string) {\n this.hostPath = hostPath;\n }\n\n registerServiceHandler(handlerPath: ServiceHandlerPath, service: IService) {\n this.handlersMap.set(handlerPath, service);\n }\n\n getHandlers(handlerPath: ServiceHandlerPath) {\n const handlers = this.handlersMap.get(handlerPath);\n return handlers;\n }\n\n getHandler(handlerPath: ServiceHandlerPath, fnName: string) {\n const handlers = this.handlersMap.get(handlerPath);\n // should bind to current service object\n if (handlers && handlers[fnName]) return handlers[fnName].bind(handlers);\n return null;\n }\n\n merge(serviceHost: RPCServiceHost) {\n for (const [key, value] of serviceHost.handlersMap) {\n this.registerServiceHandler(key, value);\n }\n }\n}\n\nexport default RPCServiceHost;\n","import RPCServiceHandler from './RPCServiceHost';\n\nclass RPCServiceProvider {\n private hostMap = new Map<string, RPCServiceHandler>();\n\n getHost(hostPath: string) {\n return this.hostMap.get(hostPath);\n }\n\n registerHost(hostPath: string) {\n const host = this.hostMap.get(hostPath);\n if (host) return host;\n this.hostMap.set(hostPath, new RPCServiceHandler(hostPath));\n return this.hostMap.get(hostPath);\n }\n\n resetHost(hostPath: string) {\n this.hostMap.set(hostPath, new RPCServiceHandler(hostPath));\n }\n}\n\nexport default new RPCServiceProvider();\n","import { isUpperAsciiLetter } from '@x-oasis/is-ascii';\n\nexport const isEventMethod = (name: string) => {\n if (typeof name !== 'string') return false;\n return (\n name[0] === 'o' && name[1] === 'n' && isUpperAsciiLetter(name.charCodeAt(2))\n );\n};\n\nexport const isAssignPassingPortMethod = (name: string) => {\n return /^assignPassingPort$/.test(name);\n};\n\nexport const isAcquirePortMethod = (name: string) => {\n return /^acquire.*Port$/.test(name);\n};\n\nexport const isOptionsMethod = (name: string) => {\n return /Options$/.test(name) || /OptionsRequest$/.test(name);\n};\n","import {\n isEventMethod,\n isAssignPassingPortMethod,\n isOptionsMethod,\n} from '../common';\nimport { ProxyRPCClientProps, ProxyRPCClientChannel } from '../types';\n\nclass ProxyRPCClient {\n private requestPath: string;\n\n private _channelProtocol: ProxyRPCClientChannel;\n\n constructor(props: ProxyRPCClientProps) {\n this._channelProtocol = props.channel;\n this.requestPath = props.requestPath;\n }\n\n get channelProtocol() {\n if (typeof this._channelProtocol === 'function')\n return this._channelProtocol();\n return this._channelProtocol;\n }\n\n createProxy<T = object>(): T {\n return new Proxy(\n {},\n {\n get: (target, key) => {\n return (...args: any[]) => {\n const fnName = key.toString();\n if (!this.channelProtocol) {\n throw new Error(\n `[ProxyRPCClient error] \\`this.channelProtocol\\` is null, when invoke function ${fnName}`\n );\n }\n\n if (isAssignPassingPortMethod(fnName)) {\n const ports = args.pop();\n this.channelProtocol.send(\n {\n requestPath: this.requestPath,\n fnName,\n args,\n },\n [].concat(ports)\n );\n } else if (isEventMethod(fnName)) {\n this.channelProtocol.send({\n requestPath: this.requestPath,\n fnName,\n args,\n });\n } else if (\n /**\n * 主要是为了解决刚开始channel connected状态是待确定,而所有的rpc 原则上都是先\n * 过isConnected的判断;但是想要确保是否通的,这个时候其实还是要发rpc确认的,\n * 那么这个时候这个就不能够受 isConnected约束;否则你就一直没有请求能够发出去了。\n */\n isOptionsMethod(fnName)\n ) {\n this.channelProtocol.send({\n isOptionsRequest: true,\n requestPath: this.requestPath,\n fnName,\n args,\n });\n } else {\n this.channelProtocol.send({\n requestPath: this.requestPath,\n fnName,\n args,\n // @ts-ignore\n }).promise;\n }\n };\n },\n }\n ) as any as T;\n }\n}\n\nexport default ProxyRPCClient;\n","import { IpcRenderer, UtilityProcess, WebContents } from 'electron';\nimport MessageChannelProtocol from '../channel-protocol/MessageChannelProtocol';\nimport RPCServiceHost from '../rpc-service/RPCServiceHost';\n\nexport interface ChannelPort {\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n postMessage(message: any, transfer?: MainPort[]): void;\n}\n\nexport type UtilityMessageChannelPortStoreProps = {\n name: string;\n port: ParentPort;\n masterProcessName: string;\n clientMiddlewares?: ClientMiddleware[];\n senderMiddlewares?: SenderMiddleware[];\n};\n\nexport type OnMessageEntry = {\n data: any;\n ports: any;\n};\nexport type SenderEntry = any;\n\nexport type ClientMiddleware = (\n channel?: MessageChannelProtocol\n) => (v: OnMessageEntry) => OnMessageEntry;\n\nexport type SenderMiddleware = (\n channel?: MessageChannelProtocol\n) => (data: SenderEntry) => SenderEntry;\n\nexport type AbstractChannelProtocolProps = {\n serviceHost?: RPCServiceHost;\n connected?: boolean;\n description?: string;\n masterProcessName?: string;\n clientMiddlewares?: ClientMiddleware[];\n senderMiddlewares?: SenderMiddleware[];\n};\n\nexport type DeferredMessageChannelProtocolProps =\n AbstractChannelProtocolProps & {\n port?: MainPort;\n };\n\nexport type MessageChannelProtocolProps = AbstractChannelProtocolProps & {\n port?: MainPort;\n};\n\nexport type ProcessChannelProtocolProps = {\n process: UtilityProcess;\n} & AbstractChannelProtocolProps;\n\nexport type IPCMainGlobalChannelProtocolProps = AbstractChannelProtocolProps & {\n channelName: string;\n};\n\nexport type IPCMainChannelProtocolProps = {\n channelName: string;\n webContents: WebContents;\n} & AbstractChannelProtocolProps;\n\nexport type IPCRendererChannelProtocolProps = {\n channelName: string;\n ipcRenderer: IpcRenderer;\n projectName: string;\n} & AbstractChannelProtocolProps;\n\nexport interface ParentPort extends NodeJS.EventEmitter {\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n once(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n addListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n postMessage(message: any): void;\n}\n\nexport type UtilityNodeJSProcess = NodeJS.Process;\n\nexport interface MainPort extends NodeJS.EventEmitter {\n // Docs: https://electronjs.org/docs/api/message-port-main\n\n /**\n * Emitted when the remote end of a MessagePortMain object becomes disconnected.\n */\n /**\n * Emitted when a MessagePortMain object receives a message.\n */\n on(event: 'close', listener: Function): this;\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n off(event: 'close', listener: Function): this;\n off(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n once(event: 'close', listener: Function): this;\n once(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n addListener(event: 'close', listener: Function): this;\n addListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n removeListener(event: 'close', listener: Function): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n /**\n * Disconnects the port, so it is no longer active.\n */\n close(): void;\n /**\n * Sends a message from the port, and optionally, transfers ownership of objects to\n * other browsing contexts.\n */\n postMessage(message: any, transfer?: MainPort[]): void;\n /**\n * Starts the sending of messages queued on the port. Messages will be queued until\n * this method is called.\n */\n start(): void;\n}\n\nexport function isUtilityProcess(\n process: NodeJS.Process\n): process is UtilityNodeJSProcess {\n return !!(process as UtilityNodeJSProcess).parentPort;\n}\n"],"names":["RequestType","ResponseType","SendMiddlewareLifecycle","RPCServiceHost","hostPath","this","Map","_proto","prototype","registerServiceHandler","handlerPath","service","handlersMap","set","getHandlers","get","getHandler","fnName","handlers","bind","merge","serviceHost","_step","_iterator","_createForOfIteratorHelperLoose","done","_step$value","value","RPCServiceProvider","getHost","hostMap","registerHost","RPCServiceHandler","resetHost","isEventMethod","name","isUpperAsciiLetter","charCodeAt","isAssignPassingPortMethod","test","isOptionsMethod","ProxyRPCClient","props","_channelProtocol","channel","requestPath","createProxy","Proxy","target","key","toString","_this","channelProtocol","Error","_len","arguments","length","args","Array","_key","ports","pop","send","concat","isOptionsRequest","process","parentPort"],"mappings":"qNAAYA,EA6BAC,ECgBAC,EC3CNC,aAKJ,SAAAA,EAAYC,GAFZC,iBAAc,IAAIC,IAGhBD,KAAKD,SAAWA,EACjB,IAAAG,EAAAJ,EAAAK,UAsBA,OAtBAD,EAEDE,uBAAA,SAAuBC,EAAiCC,GACtDN,KAAKO,YAAYC,IAAIH,EAAaC,IACnCJ,EAEDO,YAAA,SAAYJ,GAEV,OADiBL,KAAKO,YAAYG,IAAIL,IAEvCH,EAEDS,WAAA,SAAWN,EAAiCO,GAC1C,IAAMC,EAAWb,KAAKO,YAAYG,IAAIL,GAE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E,GAAAJ,UAAAI,GAQpB,GAAIrB,EAA0BrB,GAAS,CACrC,IAAM2C,EAAQH,EAAKI,MACnBV,EAAKC,gBAAgBU,KACnB,CACEjB,YAAaM,EAAKN,YAClB5B,OAAAA,EACAwC,KAAAA,GAEF,GAAGM,OAAOH,SAEH1B,EAAcjB,GACvBkC,EAAKC,gBAAgBU,KAAK,CACxBjB,YAAaM,EAAKN,YAClB5B,OAAAA,EACAwC,KAAAA,IAQFjB,EAAgBvB,GAEhBkC,EAAKC,gBAAgBU,KAAK,CACxBE,kBAAkB,EAClBnB,YAAaM,EAAKN,YAClB5B,OAAAA,EACAwC,KAAAA,IAGFN,EAAKC,gBAAgBU,KAAK,CACxBjB,YAAaM,EAAKN,YAClB5B,OAAAA,EACAwC,KAAAA,WAQbhB,OAAAQ,sBAAAlC,IA7DD,WACE,MAAqC,mBAA1BV,KAAKsC,iBACPtC,KAAKsC,mBACPtC,KAAKsC,mhBACbF,MLrBSzC,EAAAA,sBAAAA,6CAKVA,oBAKAA,qBACAA,oBAkBUC,EAAAA,uBAAAA,6CAEVA,kBAEAA,mBACAA,iBCWUC,EAAAA,kCAAAA,4DAEVA,0BACAA,8BACAA,sCACAA,oBACAA,uIK+EA+D,GAEA,QAAUA,EAAiCC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { isUpperAsciiLetter } from '@x-oasis/is-ascii';
|
|
2
|
+
|
|
3
|
+
function _defineProperties(target, props) {
|
|
4
|
+
for (var i = 0; i < props.length; i++) {
|
|
5
|
+
var descriptor = props[i];
|
|
6
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
7
|
+
descriptor.configurable = true;
|
|
8
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
9
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
13
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
14
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
15
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
16
|
+
writable: false
|
|
17
|
+
});
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
21
|
+
if (!o) return;
|
|
22
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
23
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
24
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
25
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
26
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
27
|
+
}
|
|
28
|
+
function _arrayLikeToArray(arr, len) {
|
|
29
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
30
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
31
|
+
return arr2;
|
|
32
|
+
}
|
|
33
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
34
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
35
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
36
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
37
|
+
if (it) o = it;
|
|
38
|
+
var i = 0;
|
|
39
|
+
return function () {
|
|
40
|
+
if (i >= o.length) return {
|
|
41
|
+
done: true
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
done: false,
|
|
45
|
+
value: o[i++]
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50
|
+
}
|
|
51
|
+
function _toPrimitive(input, hint) {
|
|
52
|
+
if (typeof input !== "object" || input === null) return input;
|
|
53
|
+
var prim = input[Symbol.toPrimitive];
|
|
54
|
+
if (prim !== undefined) {
|
|
55
|
+
var res = prim.call(input, hint || "default");
|
|
56
|
+
if (typeof res !== "object") return res;
|
|
57
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
58
|
+
}
|
|
59
|
+
return (hint === "string" ? String : Number)(input);
|
|
60
|
+
}
|
|
61
|
+
function _toPropertyKey(arg) {
|
|
62
|
+
var key = _toPrimitive(arg, "string");
|
|
63
|
+
return typeof key === "symbol" ? key : String(key);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var RPCServiceHost = /*#__PURE__*/function () {
|
|
67
|
+
function RPCServiceHost(hostPath) {
|
|
68
|
+
this.handlersMap = new Map();
|
|
69
|
+
this.hostPath = hostPath;
|
|
70
|
+
}
|
|
71
|
+
var _proto = RPCServiceHost.prototype;
|
|
72
|
+
_proto.registerServiceHandler = function registerServiceHandler(handlerPath, service) {
|
|
73
|
+
this.handlersMap.set(handlerPath, service);
|
|
74
|
+
};
|
|
75
|
+
_proto.getHandlers = function getHandlers(handlerPath) {
|
|
76
|
+
var handlers = this.handlersMap.get(handlerPath);
|
|
77
|
+
return handlers;
|
|
78
|
+
};
|
|
79
|
+
_proto.getHandler = function getHandler(handlerPath, fnName) {
|
|
80
|
+
var handlers = this.handlersMap.get(handlerPath);
|
|
81
|
+
if (handlers && handlers[fnName]) return handlers[fnName].bind(handlers);
|
|
82
|
+
return null;
|
|
83
|
+
};
|
|
84
|
+
_proto.merge = function merge(serviceHost) {
|
|
85
|
+
for (var _iterator = _createForOfIteratorHelperLoose(serviceHost.handlersMap), _step; !(_step = _iterator()).done;) {
|
|
86
|
+
var _step$value = _step.value,
|
|
87
|
+
key = _step$value[0],
|
|
88
|
+
value = _step$value[1];
|
|
89
|
+
this.registerServiceHandler(key, value);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return RPCServiceHost;
|
|
93
|
+
}();
|
|
94
|
+
|
|
95
|
+
var RPCServiceProvider = /*#__PURE__*/function () {
|
|
96
|
+
function RPCServiceProvider() {
|
|
97
|
+
this.hostMap = new Map();
|
|
98
|
+
}
|
|
99
|
+
var _proto = RPCServiceProvider.prototype;
|
|
100
|
+
_proto.getHost = function getHost(hostPath) {
|
|
101
|
+
return this.hostMap.get(hostPath);
|
|
102
|
+
};
|
|
103
|
+
_proto.registerHost = function registerHost(hostPath) {
|
|
104
|
+
var host = this.hostMap.get(hostPath);
|
|
105
|
+
if (host) return host;
|
|
106
|
+
this.hostMap.set(hostPath, new RPCServiceHost(hostPath));
|
|
107
|
+
return this.hostMap.get(hostPath);
|
|
108
|
+
};
|
|
109
|
+
_proto.resetHost = function resetHost(hostPath) {
|
|
110
|
+
this.hostMap.set(hostPath, new RPCServiceHost(hostPath));
|
|
111
|
+
};
|
|
112
|
+
return RPCServiceProvider;
|
|
113
|
+
}();
|
|
114
|
+
var RPCServiceProvider$1 = /*#__PURE__*/new RPCServiceProvider();
|
|
115
|
+
|
|
116
|
+
var isEventMethod = function isEventMethod(name) {
|
|
117
|
+
if (typeof name !== 'string') return false;
|
|
118
|
+
return name[0] === 'o' && name[1] === 'n' && isUpperAsciiLetter(name.charCodeAt(2));
|
|
119
|
+
};
|
|
120
|
+
var isAssignPassingPortMethod = function isAssignPassingPortMethod(name) {
|
|
121
|
+
return /^assignPassingPort$/.test(name);
|
|
122
|
+
};
|
|
123
|
+
var isOptionsMethod = function isOptionsMethod(name) {
|
|
124
|
+
return /Options$/.test(name) || /OptionsRequest$/.test(name);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var ProxyRPCClient = /*#__PURE__*/function () {
|
|
128
|
+
function ProxyRPCClient(props) {
|
|
129
|
+
this._channelProtocol = props.channel;
|
|
130
|
+
this.requestPath = props.requestPath;
|
|
131
|
+
}
|
|
132
|
+
var _proto = ProxyRPCClient.prototype;
|
|
133
|
+
_proto.createProxy = function createProxy() {
|
|
134
|
+
var _this = this;
|
|
135
|
+
return new Proxy({}, {
|
|
136
|
+
get: function get(target, key) {
|
|
137
|
+
return function () {
|
|
138
|
+
var fnName = key.toString();
|
|
139
|
+
if (!_this.channelProtocol) {
|
|
140
|
+
throw new Error("[ProxyRPCClient error] `this.channelProtocol` is null, when invoke function " + fnName);
|
|
141
|
+
}
|
|
142
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
143
|
+
args[_key] = arguments[_key];
|
|
144
|
+
}
|
|
145
|
+
if (isAssignPassingPortMethod(fnName)) {
|
|
146
|
+
var ports = args.pop();
|
|
147
|
+
_this.channelProtocol.send({
|
|
148
|
+
requestPath: _this.requestPath,
|
|
149
|
+
fnName: fnName,
|
|
150
|
+
args: args
|
|
151
|
+
}, [].concat(ports));
|
|
152
|
+
} else if (isEventMethod(fnName)) {
|
|
153
|
+
_this.channelProtocol.send({
|
|
154
|
+
requestPath: _this.requestPath,
|
|
155
|
+
fnName: fnName,
|
|
156
|
+
args: args
|
|
157
|
+
});
|
|
158
|
+
} else if (isOptionsMethod(fnName)) {
|
|
159
|
+
_this.channelProtocol.send({
|
|
160
|
+
isOptionsRequest: true,
|
|
161
|
+
requestPath: _this.requestPath,
|
|
162
|
+
fnName: fnName,
|
|
163
|
+
args: args
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
_this.channelProtocol.send({
|
|
167
|
+
requestPath: _this.requestPath,
|
|
168
|
+
fnName: fnName,
|
|
169
|
+
args: args
|
|
170
|
+
}).promise;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
_createClass(ProxyRPCClient, [{
|
|
177
|
+
key: "channelProtocol",
|
|
178
|
+
get: function get() {
|
|
179
|
+
if (typeof this._channelProtocol === 'function') return this._channelProtocol();
|
|
180
|
+
return this._channelProtocol;
|
|
181
|
+
}
|
|
182
|
+
}]);
|
|
183
|
+
return ProxyRPCClient;
|
|
184
|
+
}();
|
|
185
|
+
|
|
186
|
+
function isUtilityProcess(process) {
|
|
187
|
+
return !!process.parentPort;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var RequestType;
|
|
191
|
+
(function (RequestType) {
|
|
192
|
+
RequestType["PromiseRequest"] = "pr";
|
|
193
|
+
RequestType["PromiseAbort"] = "pa";
|
|
194
|
+
RequestType["SignalRequest"] = "sr";
|
|
195
|
+
RequestType["SignalAbort"] = "sa";
|
|
196
|
+
})(RequestType || (RequestType = {}));
|
|
197
|
+
var ResponseType;
|
|
198
|
+
(function (ResponseType) {
|
|
199
|
+
ResponseType["ReturnSuccess"] = "rs";
|
|
200
|
+
ResponseType["ReturnFail"] = "rf";
|
|
201
|
+
ResponseType["PortSuccess"] = "ps";
|
|
202
|
+
ResponseType["PortFail"] = "pf";
|
|
203
|
+
})(ResponseType || (ResponseType = {}));
|
|
204
|
+
|
|
205
|
+
var SendMiddlewareLifecycle;
|
|
206
|
+
(function (SendMiddlewareLifecycle) {
|
|
207
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Initial"] = 0] = "Initial";
|
|
208
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Prepare"] = 10] = "Prepare";
|
|
209
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Transfrom"] = 20] = "Transfrom";
|
|
210
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["DataOperation"] = 30] = "DataOperation";
|
|
211
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Send"] = 40] = "Send";
|
|
212
|
+
SendMiddlewareLifecycle[SendMiddlewareLifecycle["Aborted"] = 100] = "Aborted";
|
|
213
|
+
})(SendMiddlewareLifecycle || (SendMiddlewareLifecycle = {}));
|
|
214
|
+
|
|
215
|
+
export { ProxyRPCClient, RPCServiceHost, RequestType, ResponseType, SendMiddlewareLifecycle, isEventMethod, isUtilityProcess, RPCServiceProvider$1 as rpcServiceProvider };
|
|
216
|
+
//# sourceMappingURL=async-call-rpc-misc.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-call-rpc-misc.esm.js","sources":["../src/rpc-service/RPCServiceHost.ts","../src/rpc-service/RPCServiceProvider.ts","../src/common.ts","../src/rpc-service/ProxyRPCClient.ts","../src/types/messageChannel.ts","../src/types/rpc.ts","../src/types/middleware.ts"],"sourcesContent":["import { IService, ServiceHandlerPath } from '../types';\n\nclass RPCServiceHost {\n protected readonly hostPath: string;\n\n handlersMap = new Map<ServiceHandlerPath, IService>();\n\n constructor(hostPath: string) {\n this.hostPath = hostPath;\n }\n\n registerServiceHandler(handlerPath: ServiceHandlerPath, service: IService) {\n this.handlersMap.set(handlerPath, service);\n }\n\n getHandlers(handlerPath: ServiceHandlerPath) {\n const handlers = this.handlersMap.get(handlerPath);\n return handlers;\n }\n\n getHandler(handlerPath: ServiceHandlerPath, fnName: string) {\n const handlers = this.handlersMap.get(handlerPath);\n // should bind to current service object\n if (handlers && handlers[fnName]) return handlers[fnName].bind(handlers);\n return null;\n }\n\n merge(serviceHost: RPCServiceHost) {\n for (const [key, value] of serviceHost.handlersMap) {\n this.registerServiceHandler(key, value);\n }\n }\n}\n\nexport default RPCServiceHost;\n","import RPCServiceHandler from './RPCServiceHost';\n\nclass RPCServiceProvider {\n private hostMap = new Map<string, RPCServiceHandler>();\n\n getHost(hostPath: string) {\n return this.hostMap.get(hostPath);\n }\n\n registerHost(hostPath: string) {\n const host = this.hostMap.get(hostPath);\n if (host) return host;\n this.hostMap.set(hostPath, new RPCServiceHandler(hostPath));\n return this.hostMap.get(hostPath);\n }\n\n resetHost(hostPath: string) {\n this.hostMap.set(hostPath, new RPCServiceHandler(hostPath));\n }\n}\n\nexport default new RPCServiceProvider();\n","import { isUpperAsciiLetter } from '@x-oasis/is-ascii';\n\nexport const isEventMethod = (name: string) => {\n if (typeof name !== 'string') return false;\n return (\n name[0] === 'o' && name[1] === 'n' && isUpperAsciiLetter(name.charCodeAt(2))\n );\n};\n\nexport const isAssignPassingPortMethod = (name: string) => {\n return /^assignPassingPort$/.test(name);\n};\n\nexport const isAcquirePortMethod = (name: string) => {\n return /^acquire.*Port$/.test(name);\n};\n\nexport const isOptionsMethod = (name: string) => {\n return /Options$/.test(name) || /OptionsRequest$/.test(name);\n};\n","import {\n isEventMethod,\n isAssignPassingPortMethod,\n isOptionsMethod,\n} from '../common';\nimport { ProxyRPCClientProps, ProxyRPCClientChannel } from '../types';\n\nclass ProxyRPCClient {\n private requestPath: string;\n\n private _channelProtocol: ProxyRPCClientChannel;\n\n constructor(props: ProxyRPCClientProps) {\n this._channelProtocol = props.channel;\n this.requestPath = props.requestPath;\n }\n\n get channelProtocol() {\n if (typeof this._channelProtocol === 'function')\n return this._channelProtocol();\n return this._channelProtocol;\n }\n\n createProxy<T = object>(): T {\n return new Proxy(\n {},\n {\n get: (target, key) => {\n return (...args: any[]) => {\n const fnName = key.toString();\n if (!this.channelProtocol) {\n throw new Error(\n `[ProxyRPCClient error] \\`this.channelProtocol\\` is null, when invoke function ${fnName}`\n );\n }\n\n if (isAssignPassingPortMethod(fnName)) {\n const ports = args.pop();\n this.channelProtocol.send(\n {\n requestPath: this.requestPath,\n fnName,\n args,\n },\n [].concat(ports)\n );\n } else if (isEventMethod(fnName)) {\n this.channelProtocol.send({\n requestPath: this.requestPath,\n fnName,\n args,\n });\n } else if (\n /**\n * 主要是为了解决刚开始channel connected状态是待确定,而所有的rpc 原则上都是先\n * 过isConnected的判断;但是想要确保是否通的,这个时候其实还是要发rpc确认的,\n * 那么这个时候这个就不能够受 isConnected约束;否则你就一直没有请求能够发出去了。\n */\n isOptionsMethod(fnName)\n ) {\n this.channelProtocol.send({\n isOptionsRequest: true,\n requestPath: this.requestPath,\n fnName,\n args,\n });\n } else {\n this.channelProtocol.send({\n requestPath: this.requestPath,\n fnName,\n args,\n // @ts-ignore\n }).promise;\n }\n };\n },\n }\n ) as any as T;\n }\n}\n\nexport default ProxyRPCClient;\n","import { IpcRenderer, UtilityProcess, WebContents } from 'electron';\nimport MessageChannelProtocol from '../channel-protocol/MessageChannelProtocol';\nimport RPCServiceHost from '../rpc-service/RPCServiceHost';\n\nexport interface ChannelPort {\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n postMessage(message: any, transfer?: MainPort[]): void;\n}\n\nexport type UtilityMessageChannelPortStoreProps = {\n name: string;\n port: ParentPort;\n masterProcessName: string;\n clientMiddlewares?: ClientMiddleware[];\n senderMiddlewares?: SenderMiddleware[];\n};\n\nexport type OnMessageEntry = {\n data: any;\n ports: any;\n};\nexport type SenderEntry = any;\n\nexport type ClientMiddleware = (\n channel?: MessageChannelProtocol\n) => (v: OnMessageEntry) => OnMessageEntry;\n\nexport type SenderMiddleware = (\n channel?: MessageChannelProtocol\n) => (data: SenderEntry) => SenderEntry;\n\nexport type AbstractChannelProtocolProps = {\n serviceHost?: RPCServiceHost;\n connected?: boolean;\n description?: string;\n masterProcessName?: string;\n clientMiddlewares?: ClientMiddleware[];\n senderMiddlewares?: SenderMiddleware[];\n};\n\nexport type DeferredMessageChannelProtocolProps =\n AbstractChannelProtocolProps & {\n port?: MainPort;\n };\n\nexport type MessageChannelProtocolProps = AbstractChannelProtocolProps & {\n port?: MainPort;\n};\n\nexport type ProcessChannelProtocolProps = {\n process: UtilityProcess;\n} & AbstractChannelProtocolProps;\n\nexport type IPCMainGlobalChannelProtocolProps = AbstractChannelProtocolProps & {\n channelName: string;\n};\n\nexport type IPCMainChannelProtocolProps = {\n channelName: string;\n webContents: WebContents;\n} & AbstractChannelProtocolProps;\n\nexport type IPCRendererChannelProtocolProps = {\n channelName: string;\n ipcRenderer: IpcRenderer;\n projectName: string;\n} & AbstractChannelProtocolProps;\n\nexport interface ParentPort extends NodeJS.EventEmitter {\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n once(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n addListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n postMessage(message: any): void;\n}\n\nexport type UtilityNodeJSProcess = NodeJS.Process;\n\nexport interface MainPort extends NodeJS.EventEmitter {\n // Docs: https://electronjs.org/docs/api/message-port-main\n\n /**\n * Emitted when the remote end of a MessagePortMain object becomes disconnected.\n */\n /**\n * Emitted when a MessagePortMain object receives a message.\n */\n on(event: 'close', listener: Function): this;\n on(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n off(event: 'close', listener: Function): this;\n off(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n once(event: 'close', listener: Function): this;\n once(event: 'message', listener: (messageEvent: MessageEvent) => void): this;\n addListener(event: 'close', listener: Function): this;\n addListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n removeListener(event: 'close', listener: Function): this;\n removeListener(\n event: 'message',\n listener: (messageEvent: MessageEvent) => void\n ): this;\n /**\n * Disconnects the port, so it is no longer active.\n */\n close(): void;\n /**\n * Sends a message from the port, and optionally, transfers ownership of objects to\n * other browsing contexts.\n */\n postMessage(message: any, transfer?: MainPort[]): void;\n /**\n * Starts the sending of messages queued on the port. Messages will be queued until\n * this method is called.\n */\n start(): void;\n}\n\nexport function isUtilityProcess(\n process: NodeJS.Process\n): process is UtilityNodeJSProcess {\n return !!(process as UtilityNodeJSProcess).parentPort;\n}\n","export enum RequestType {\n /**\n * for normal request, wait for return value\n */\n PromiseRequest = 'pr',\n PromiseAbort = 'pa',\n\n /**\n * send a command\n */\n SignalRequest = 'sr',\n SignalAbort = 'sa',\n}\n\nexport type RequestRawSequenceId = number;\n\nexport type RequestSequenceId = string;\nexport type RequestServicePath = string;\nexport type RequestFnName = string;\n\nexport type RequestEntryHeader = [\n RequestType,\n RequestSequenceId,\n RequestServicePath,\n RequestFnName\n];\nexport type RequestEntryBody = any;\nexport type RequestEntry = [RequestEntryHeader, RequestEntryBody];\n\nexport enum ResponseType {\n ReturnSuccess = 'rs',\n ReturnFail = 'rf',\n\n PortSuccess = 'ps',\n PortFail = 'pf',\n}\nexport type ResponseEntryHeader = [ResponseType, RequestSequenceId];\nexport type ResponseEntryBody = any;\n\nexport type HostName = string;\n\n/**\n * 0 RequestType: PromiseRequest, PromiseAbort, SignalRequest, SignalAbort\n * 1 RequestSequenceId: string\n */\nexport type HostRequestEntryHeader = [\n RequestType,\n RequestSequenceId,\n RequestServicePath,\n RequestFnName,\n HostName\n];\nexport type HostRequestEntryBody = any;\nexport type HostRequestEntry = [HostRequestEntryHeader, HostRequestEntryBody];\n\nexport type SendingProps = {\n requestPath?: string;\n fnName?: string;\n args?: any;\n isOptionsRequest?: boolean;\n};\n","import { Deferred } from '@x-oasis/deferred';\n\nimport { HostRequestEntry, RequestEntry } from './rpc';\n\nexport type MiddlewareFunction = {\n (...args: any[]): any;\n displayName?: string;\n lifecycle?: SendMiddlewareLifecycle;\n};\n\nexport type MessageOutput = {\n event: any;\n ports: any;\n};\n\nexport type NormalizedRawMessageOutput = MessageOutput & {\n data: string;\n};\n\nexport type DeserializedMessageOutput = MessageOutput & {\n data: HostRequestEntry | RequestEntry;\n};\n\nexport type SenderMiddlewareOutput = {\n data: any;\n transfer: any;\n seqId: number;\n returnValue: Deferred;\n isOptionsRequest: boolean;\n middlewareContext: MiddlewareContext;\n};\n\nexport type PendingSendEntry = SenderMiddlewareOutput & {\n fnName: string;\n lifecycle: SendMiddlewareLifecycle;\n middlewareContext: MiddlewareContext;\n};\n\nexport type MiddlewareContext = {\n isResumed?: boolean;\n startLifecycle: SendMiddlewareLifecycle;\n minLifecycle: SendMiddlewareLifecycle;\n reserved: PendingSendEntry;\n};\n\nexport enum SendMiddlewareLifecycle {\n Initial = 0,\n Prepare = 10,\n Transfrom = 20,\n DataOperation = 30,\n Send = 40,\n Aborted = 100,\n}\n"],"names":["RPCServiceHost","hostPath","Map","_proto","prototype","registerServiceHandler","handlerPath","service","handlersMap","set","getHandlers","handlers","get","getHandler","fnName","bind","merge","serviceHost","_iterator","_createForOfIteratorHelperLoose","_step","done","_step$value","value","key","RPCServiceProvider","getHost","hostMap","registerHost","host","RPCServiceHandler","resetHost","isEventMethod","name","isUpperAsciiLetter","charCodeAt","isAssignPassingPortMethod","test","isOptionsMethod","ProxyRPCClient","props","_channelProtocol","channel","requestPath","createProxy","Proxy","target","toString","_this","channelProtocol","Error","_len","arguments","length","args","Array","_key","ports","pop","send","concat","isOptionsRequest","promise","_createClass","isUtilityProcess","process","parentPort","RequestType","ResponseType","SendMiddlewareLifecycle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEMA,cAAc;EAKlB,SAAAA,eAAYC,QAAgB;IAF5B,gBAAW,GAAG,IAAIC,GAAG,EAAgC;IAGnD,IAAI,CAACD,QAAQ,GAAGA,QAAQ;;EACzB,IAAAE,MAAA,GAAAH,cAAA,CAAAI,SAAA;EAAAD,MAAA,CAEDE,sBAAsB,GAAtB,SAAAA,uBAAuBC,WAA+B,EAAEC,OAAiB;IACvE,IAAI,CAACC,WAAW,CAACC,GAAG,CAACH,WAAW,EAAEC,OAAO,CAAC;GAC3C;EAAAJ,MAAA,CAEDO,WAAW,GAAX,SAAAA,YAAYJ,WAA+B;IACzC,IAAMK,QAAQ,GAAG,IAAI,CAACH,WAAW,CAACI,GAAG,CAACN,WAAW,CAAC;IAClD,OAAOK,QAAQ;GAChB;EAAAR,MAAA,CAEDU,UAAU,GAAV,SAAAA,WAAWP,WAA+B,EAAEQ,MAAc;IACxD,IAAMH,QAAQ,GAAG,IAAI,CAACH,WAAW,CAACI,GAAG,CAACN,WAAW,CAAC;IAElD,IAAIK,QAAQ,IAAIA,QAAQ,CAACG,MAAM,CAAC,EAAE,OAAOH,QAAQ,CAACG,MAAM,CAAC,CAACC,IAAI,CAACJ,QAAQ,CAAC;IACxE,OAAO,IAAI;GACZ;EAAAR,MAAA,CAED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