@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
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import AbstractChannelProtocol from '../channel-protocol/AbstractChannelProtocol';
|
|
2
|
+
|
|
3
|
+
// export type IService = {
|
|
4
|
+
// [key: string]: Function
|
|
5
|
+
// }
|
|
6
|
+
export type IService = any;
|
|
7
|
+
|
|
8
|
+
export type ServiceHandlerPath = string;
|
|
9
|
+
export type ProxyRPCClientChannel =
|
|
10
|
+
| AbstractChannelProtocol
|
|
11
|
+
| { (): AbstractChannelProtocol };
|
|
12
|
+
|
|
13
|
+
export type ProxyRPCClientProps = {
|
|
14
|
+
requestPath: string;
|
|
15
|
+
channel: ProxyRPCClientChannel;
|
|
16
|
+
};
|
package/src/types/rpc.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export enum RequestType {
|
|
2
|
+
/**
|
|
3
|
+
* for normal request, wait for return value
|
|
4
|
+
*/
|
|
5
|
+
PromiseRequest = 'pr',
|
|
6
|
+
PromiseAbort = 'pa',
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* send a command
|
|
10
|
+
*/
|
|
11
|
+
SignalRequest = 'sr',
|
|
12
|
+
SignalAbort = 'sa',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type RequestRawSequenceId = number;
|
|
16
|
+
|
|
17
|
+
export type RequestSequenceId = string;
|
|
18
|
+
export type RequestServicePath = string;
|
|
19
|
+
export type RequestFnName = string;
|
|
20
|
+
|
|
21
|
+
export type RequestEntryHeader = [
|
|
22
|
+
RequestType,
|
|
23
|
+
RequestSequenceId,
|
|
24
|
+
RequestServicePath,
|
|
25
|
+
RequestFnName
|
|
26
|
+
];
|
|
27
|
+
export type RequestEntryBody = any;
|
|
28
|
+
export type RequestEntry = [RequestEntryHeader, RequestEntryBody];
|
|
29
|
+
|
|
30
|
+
export enum ResponseType {
|
|
31
|
+
ReturnSuccess = 'rs',
|
|
32
|
+
ReturnFail = 'rf',
|
|
33
|
+
|
|
34
|
+
PortSuccess = 'ps',
|
|
35
|
+
PortFail = 'pf',
|
|
36
|
+
}
|
|
37
|
+
export type ResponseEntryHeader = [ResponseType, RequestSequenceId];
|
|
38
|
+
export type ResponseEntryBody = any;
|
|
39
|
+
|
|
40
|
+
export type HostName = string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 0 RequestType: PromiseRequest, PromiseAbort, SignalRequest, SignalAbort
|
|
44
|
+
* 1 RequestSequenceId: string
|
|
45
|
+
*/
|
|
46
|
+
export type HostRequestEntryHeader = [
|
|
47
|
+
RequestType,
|
|
48
|
+
RequestSequenceId,
|
|
49
|
+
RequestServicePath,
|
|
50
|
+
RequestFnName,
|
|
51
|
+
HostName
|
|
52
|
+
];
|
|
53
|
+
export type HostRequestEntryBody = any;
|
|
54
|
+
export type HostRequestEntry = [HostRequestEntryHeader, HostRequestEntryBody];
|
|
55
|
+
|
|
56
|
+
export type SendingProps = {
|
|
57
|
+
requestPath?: string;
|
|
58
|
+
fnName?: string;
|
|
59
|
+
args?: any;
|
|
60
|
+
isOptionsRequest?: boolean;
|
|
61
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type IRPCProtocolServer = {
|
|
2
|
+
source: any;
|
|
3
|
+
encoder: null;
|
|
4
|
+
decoder: null;
|
|
5
|
+
onRequest: () => {};
|
|
6
|
+
handleRequest: () => {};
|
|
7
|
+
sendReply: () => {};
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type IRPCProtocolClient = {
|
|
11
|
+
source: any;
|
|
12
|
+
encode: () => {};
|
|
13
|
+
decode: () => {};
|
|
14
|
+
sendRequest: () => {};
|
|
15
|
+
onReply: () => {};
|
|
16
|
+
handleReply: () => {};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type IRPCProtocol = {
|
|
20
|
+
encode: Function;
|
|
21
|
+
decode: Function;
|
|
22
|
+
onMessage: Function;
|
|
23
|
+
send: Function;
|
|
24
|
+
};
|