@delight-rpc/electron 2.1.1 → 3.1.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/README.md +20 -0
- package/lib/client.d.ts +4 -2
- package/lib/client.js +70 -6
- package/lib/client.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/server.d.ts +2 -2
- package/lib/server.js +9 -5
- package/lib/server.js.map +1 -1
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -198,6 +198,7 @@ window.ready()
|
|
|
198
198
|
function createClientInMain<IAPI extends object>(
|
|
199
199
|
port: Electron.MessagePortMain
|
|
200
200
|
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
201
|
+
, expectedVersion?: `${number}.${number}.${number}`
|
|
201
202
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
202
203
|
```
|
|
203
204
|
|
|
@@ -206,15 +207,33 @@ function createClientInMain<IAPI extends object>(
|
|
|
206
207
|
function createClientInRenderer<IAPI extends object>(
|
|
207
208
|
port: MessagePort
|
|
208
209
|
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
210
|
+
, expectedVersion?: `${number}.${number}.${number}`
|
|
209
211
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
210
212
|
```
|
|
211
213
|
|
|
214
|
+
### createBatchClientInMain
|
|
215
|
+
```ts
|
|
216
|
+
function createBatchClientInMain(
|
|
217
|
+
port: Electron.MessagePortMain
|
|
218
|
+
, expectedVersion?: `${number}.${number}.${number}`
|
|
219
|
+
): [client: DelightRPC.BatchClient, close: () => void]
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### createBatchClientInRenderer
|
|
223
|
+
```ts
|
|
224
|
+
function createBatchClientInRenderer(
|
|
225
|
+
port: MessagePort
|
|
226
|
+
, expectedVersion?: `${number}.${number}.${number}`
|
|
227
|
+
): [client: DelightRPC.BatchClient, close: () => void]
|
|
228
|
+
```
|
|
229
|
+
|
|
212
230
|
### createServerInMain
|
|
213
231
|
```ts
|
|
214
232
|
function createServerInMain<IAPI extends object>(
|
|
215
233
|
api: DelightRPC.ImplementationOf<IAPI>
|
|
216
234
|
, port: Electron.MessagePortMain
|
|
217
235
|
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
236
|
+
, version?: `${number}.${number}.${number}`
|
|
218
237
|
): () => void
|
|
219
238
|
```
|
|
220
239
|
|
|
@@ -224,5 +243,6 @@ function createServerInRenderer<IAPI extends object>(
|
|
|
224
243
|
api: DelightRPC.ImplementationOf<IAPI>
|
|
225
244
|
, port: MessagePort
|
|
226
245
|
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
246
|
+
, version?: `${number}.${number}.${number}`
|
|
227
247
|
): () => void
|
|
228
248
|
```
|
package/lib/client.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as DelightRPC from 'delight-rpc';
|
|
2
2
|
import Electron from 'electron';
|
|
3
3
|
import { CustomError } from '@blackglory/errors';
|
|
4
|
-
export declare function createClientInMain<IAPI extends object>(port: Electron.MessagePortMain, parameterValidators?: DelightRPC.ParameterValidators<IAPI
|
|
5
|
-
export declare function createClientInRenderer<IAPI extends object>(port: MessagePort, parameterValidators?: DelightRPC.ParameterValidators<IAPI
|
|
4
|
+
export declare function createClientInMain<IAPI extends object>(port: Electron.MessagePortMain, parameterValidators?: DelightRPC.ParameterValidators<IAPI>, expectedVersion?: `${number}.${number}.${number}`): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
|
|
5
|
+
export declare function createClientInRenderer<IAPI extends object>(port: MessagePort, parameterValidators?: DelightRPC.ParameterValidators<IAPI>, expectedVersion?: `${number}.${number}.${number}`): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
|
|
6
|
+
export declare function createBatchClientInMain(port: Electron.MessagePortMain, expectedVersion?: `${number}.${number}.${number}`): [client: DelightRPC.BatchClient, close: () => void];
|
|
7
|
+
export declare function createBatchClientInRenderer(port: MessagePort, expectedVersion?: `${number}.${number}.${number}`): [client: DelightRPC.BatchClient, close: () => void];
|
|
6
8
|
export declare class ClientClosed extends CustomError {
|
|
7
9
|
}
|
package/lib/client.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -19,11 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.ClientClosed = exports.createClientInRenderer = exports.createClientInMain = void 0;
|
|
26
|
+
exports.ClientClosed = exports.createBatchClientInRenderer = exports.createBatchClientInMain = exports.createClientInRenderer = exports.createClientInMain = void 0;
|
|
23
27
|
const DelightRPC = __importStar(require("delight-rpc"));
|
|
24
28
|
const extra_promise_1 = require("extra-promise");
|
|
25
29
|
const errors_1 = require("@blackglory/errors");
|
|
26
|
-
function createClientInMain(port, parameterValidators) {
|
|
30
|
+
function createClientInMain(port, parameterValidators, expectedVersion) {
|
|
27
31
|
const pendings = {};
|
|
28
32
|
port.addListener('message', handler);
|
|
29
33
|
const client = DelightRPC.createClient(async function send(request) {
|
|
@@ -36,7 +40,7 @@ function createClientInMain(port, parameterValidators) {
|
|
|
36
40
|
finally {
|
|
37
41
|
delete pendings[request.id];
|
|
38
42
|
}
|
|
39
|
-
}, parameterValidators);
|
|
43
|
+
}, parameterValidators, expectedVersion);
|
|
40
44
|
return [client, close];
|
|
41
45
|
function close() {
|
|
42
46
|
port.removeListener('message', handler);
|
|
@@ -53,7 +57,7 @@ function createClientInMain(port, parameterValidators) {
|
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
exports.createClientInMain = createClientInMain;
|
|
56
|
-
function createClientInRenderer(port, parameterValidators) {
|
|
60
|
+
function createClientInRenderer(port, parameterValidators, expectedVersion) {
|
|
57
61
|
const pendings = {};
|
|
58
62
|
port.addEventListener('message', handler);
|
|
59
63
|
const client = DelightRPC.createClient(async function send(request) {
|
|
@@ -66,7 +70,7 @@ function createClientInRenderer(port, parameterValidators) {
|
|
|
66
70
|
finally {
|
|
67
71
|
delete pendings[request.id];
|
|
68
72
|
}
|
|
69
|
-
}, parameterValidators);
|
|
73
|
+
}, parameterValidators, expectedVersion);
|
|
70
74
|
return [client, close];
|
|
71
75
|
function close() {
|
|
72
76
|
port.removeEventListener('message', handler);
|
|
@@ -83,6 +87,66 @@ function createClientInRenderer(port, parameterValidators) {
|
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
exports.createClientInRenderer = createClientInRenderer;
|
|
90
|
+
function createBatchClientInMain(port, expectedVersion) {
|
|
91
|
+
const pendings = {};
|
|
92
|
+
port.addListener('message', handler);
|
|
93
|
+
const client = new DelightRPC.BatchClient(async function send(request) {
|
|
94
|
+
const res = new extra_promise_1.Deferred();
|
|
95
|
+
pendings[request.id] = res;
|
|
96
|
+
try {
|
|
97
|
+
port.postMessage(request);
|
|
98
|
+
return await res;
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
delete pendings[request.id];
|
|
102
|
+
}
|
|
103
|
+
}, expectedVersion);
|
|
104
|
+
return [client, close];
|
|
105
|
+
function close() {
|
|
106
|
+
port.removeListener('message', handler);
|
|
107
|
+
for (const [key, deferred] of Object.entries(pendings)) {
|
|
108
|
+
deferred.reject(new ClientClosed());
|
|
109
|
+
delete pendings[key];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function handler(event) {
|
|
113
|
+
const res = event.data;
|
|
114
|
+
if (DelightRPC.isError(res) || DelightRPC.isBatchResponse(res)) {
|
|
115
|
+
pendings[res.id].resolve(res);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.createBatchClientInMain = createBatchClientInMain;
|
|
120
|
+
function createBatchClientInRenderer(port, expectedVersion) {
|
|
121
|
+
const pendings = {};
|
|
122
|
+
port.addEventListener('message', handler);
|
|
123
|
+
const client = new DelightRPC.BatchClient(async function send(request) {
|
|
124
|
+
const res = new extra_promise_1.Deferred();
|
|
125
|
+
pendings[request.id] = res;
|
|
126
|
+
try {
|
|
127
|
+
port.postMessage(request);
|
|
128
|
+
return await res;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
delete pendings[request.id];
|
|
132
|
+
}
|
|
133
|
+
}, expectedVersion);
|
|
134
|
+
return [client, close];
|
|
135
|
+
function close() {
|
|
136
|
+
port.removeEventListener('message', handler);
|
|
137
|
+
for (const [key, deferred] of Object.entries(pendings)) {
|
|
138
|
+
deferred.reject(new ClientClosed());
|
|
139
|
+
delete pendings[key];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function handler(event) {
|
|
143
|
+
const res = event.data;
|
|
144
|
+
if (DelightRPC.isError(res) || DelightRPC.isBatchResponse(res)) {
|
|
145
|
+
pendings[res.id].resolve(res);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.createBatchClientInRenderer = createBatchClientInRenderer;
|
|
86
150
|
class ClientClosed extends errors_1.CustomError {
|
|
87
151
|
}
|
|
88
152
|
exports.ClientClosed = ClientClosed;
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":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AC9B;IACH,CAAC;AACH,CAAC;AA/CD,kEA+CC;AAED,MAAa,YAAa,SAAQ,oBAAW;CAAG;AAAhD,oCAAgD"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,2CAAwB"}
|
package/lib/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as DelightRPC from 'delight-rpc';
|
|
2
2
|
import Electron from 'electron';
|
|
3
|
-
export declare function createServerInMain<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: Electron.MessagePortMain, parameterValidators?: DelightRPC.ParameterValidators<IAPI
|
|
4
|
-
export declare function createServerInRenderer<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: MessagePort, parameterValidators?: DelightRPC.ParameterValidators<IAPI
|
|
3
|
+
export declare function createServerInMain<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: Electron.MessagePortMain, parameterValidators?: DelightRPC.ParameterValidators<IAPI>, version?: `${number}.${number}.${number}`): () => void;
|
|
4
|
+
export declare function createServerInRenderer<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: MessagePort, parameterValidators?: DelightRPC.ParameterValidators<IAPI>, version?: `${number}.${number}.${number}`): () => void;
|
package/lib/server.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -21,25 +25,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
26
|
exports.createServerInRenderer = exports.createServerInMain = void 0;
|
|
23
27
|
const DelightRPC = __importStar(require("delight-rpc"));
|
|
24
|
-
function createServerInMain(api, port, parameterValidators) {
|
|
28
|
+
function createServerInMain(api, port, parameterValidators, version) {
|
|
25
29
|
port.addListener('message', handler);
|
|
26
30
|
return () => port.removeListener('message', handler);
|
|
27
31
|
async function handler(event) {
|
|
28
32
|
const req = event.data;
|
|
29
33
|
if (DelightRPC.isRequest(req)) {
|
|
30
|
-
const result = await DelightRPC.createResponse(api, req, parameterValidators);
|
|
34
|
+
const result = await DelightRPC.createResponse(api, req, parameterValidators, version);
|
|
31
35
|
port.postMessage(result);
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
exports.createServerInMain = createServerInMain;
|
|
36
|
-
function createServerInRenderer(api, port, parameterValidators) {
|
|
40
|
+
function createServerInRenderer(api, port, parameterValidators, version) {
|
|
37
41
|
port.addEventListener('message', handler);
|
|
38
42
|
return () => port.removeEventListener('message', handler);
|
|
39
43
|
async function handler(event) {
|
|
40
44
|
const req = event.data;
|
|
41
45
|
if (DelightRPC.isRequest(req)) {
|
|
42
|
-
const result = await DelightRPC.createResponse(api, req, parameterValidators);
|
|
46
|
+
const result = await DelightRPC.createResponse(api, req, parameterValidators, version);
|
|
43
47
|
port.postMessage(result);
|
|
44
48
|
}
|
|
45
49
|
}
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAyC;AAGzC,SAAgB,kBAAkB,CAChC,GAAsC,EACtC,IAA8B,EAC9B,mBAA0D,EAC1D,OAAyC;IAEzC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACpC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAEpD,KAAK,UAAU,OAAO,CAAC,KAA4B;QACjD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAA;QACtB,IAAI,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YAC7B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,cAAc,CAC5C,GAAG,EACH,GAAG,EACH,mBAAmB,EACnB,OAAO,CACR,CAAA;YAED,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;SACzB;IACH,CAAC;AACH,CAAC;AAtBD,gDAsBC;AAED,SAAgB,sBAAsB,CACpC,GAAsC,EACtC,IAAiB,EACjB,mBAA0D,EAC1D,OAAyC;IAEzC,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACzC,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAEzD,KAAK,UAAU,OAAO,CAAC,KAAmB;QACxC,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAA;QACtB,IAAI,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YAC7B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,cAAc,CAC5C,GAAG,EACH,GAAG,EACH,mBAAmB,EACnB,OAAO,CACR,CAAA;YAED,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;SACzB;IACH,CAAC;AACH,CAAC;AAtBD,wDAsBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delight-rpc/electron",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -30,31 +30,31 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@blackglory/jest-matchers": "^0.
|
|
34
|
-
"@commitlint/cli": "^16.
|
|
35
|
-
"@commitlint/config-conventional": "^16.
|
|
36
|
-
"@types/jest": "^27.4.
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
38
|
-
"@typescript-eslint/parser": "^5.
|
|
33
|
+
"@blackglory/jest-matchers": "^0.3.1",
|
|
34
|
+
"@commitlint/cli": "^16.2.3",
|
|
35
|
+
"@commitlint/config-conventional": "^16.2.1",
|
|
36
|
+
"@types/jest": "^27.4.1",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
38
|
+
"@typescript-eslint/parser": "^5.15.0",
|
|
39
39
|
"cross-env": "^7.0.3",
|
|
40
|
-
"delight-rpc": "^
|
|
41
|
-
"electron": "^16.0.
|
|
42
|
-
"eslint": "8.
|
|
40
|
+
"delight-rpc": "^2.1.1",
|
|
41
|
+
"electron": "^16.0.7",
|
|
42
|
+
"eslint": "8.11.0",
|
|
43
43
|
"husky": "4",
|
|
44
|
-
"jest": "^27.
|
|
44
|
+
"jest": "^27.5.1",
|
|
45
45
|
"npm-run-all": "^4.1.5",
|
|
46
46
|
"rimraf": "^3.0.2",
|
|
47
47
|
"standard-version": "^9.3.2",
|
|
48
|
-
"ts-jest": "^27.1.
|
|
48
|
+
"ts-jest": "^27.1.3",
|
|
49
49
|
"tscpaths": "^0.0.9",
|
|
50
|
-
"typescript": "^4.
|
|
50
|
+
"typescript": "^4.6.2"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@blackglory/errors": "^
|
|
54
|
-
"extra-promise": "^0.
|
|
53
|
+
"@blackglory/errors": "^2.2.0",
|
|
54
|
+
"extra-promise": "^1.0.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"delight-rpc": "^
|
|
57
|
+
"delight-rpc": "^2.1.1",
|
|
58
58
|
"electron": "^16.0.1"
|
|
59
59
|
}
|
|
60
60
|
}
|