@delight-rpc/electron 2.0.0 → 2.2.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 +10 -2
- package/lib/client.d.ts +2 -2
- package/lib/client.js +4 -4
- package/lib/client.js.map +1 -1
- package/lib/server.d.ts +3 -2
- package/lib/server.js +4 -4
- package/lib/server.js.map +1 -1
- package/package.json +16 -19
package/README.md
CHANGED
|
@@ -197,6 +197,8 @@ window.ready()
|
|
|
197
197
|
```ts
|
|
198
198
|
function createClientInMain<IAPI extends object>(
|
|
199
199
|
port: Electron.MessagePortMain
|
|
200
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
201
|
+
, expectedVersion?: `${number}.${number}.${number}`
|
|
200
202
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
201
203
|
```
|
|
202
204
|
|
|
@@ -204,21 +206,27 @@ function createClientInMain<IAPI extends object>(
|
|
|
204
206
|
```ts
|
|
205
207
|
function createClientInRenderer<IAPI extends object>(
|
|
206
208
|
port: MessagePort
|
|
209
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
210
|
+
, expectedVersion?: `${number}.${number}.${number}`
|
|
207
211
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
208
212
|
```
|
|
209
213
|
|
|
210
214
|
### createServerInMain
|
|
211
215
|
```ts
|
|
212
216
|
function createServerInMain<IAPI extends object>(
|
|
213
|
-
api: IAPI
|
|
217
|
+
api: DelightRPC.ImplementationOf<IAPI>
|
|
214
218
|
, port: Electron.MessagePortMain
|
|
219
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
220
|
+
, version?: `${number}.${number}.${number}`
|
|
215
221
|
): () => void
|
|
216
222
|
```
|
|
217
223
|
|
|
218
224
|
### createServerInRenderer
|
|
219
225
|
```ts
|
|
220
226
|
function createServerInRenderer<IAPI extends object>(
|
|
221
|
-
api: IAPI
|
|
227
|
+
api: DelightRPC.ImplementationOf<IAPI>
|
|
222
228
|
, port: MessagePort
|
|
229
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
230
|
+
, version?: `${number}.${number}.${number}`
|
|
223
231
|
): () => void
|
|
224
232
|
```
|
package/lib/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
|
|
5
|
-
export declare function createClientInRenderer<IAPI extends object>(port: MessagePort): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
|
|
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
6
|
export declare class ClientClosed extends CustomError {
|
|
7
7
|
}
|
package/lib/client.js
CHANGED
|
@@ -23,7 +23,7 @@ exports.ClientClosed = exports.createClientInRenderer = exports.createClientInMa
|
|
|
23
23
|
const DelightRPC = __importStar(require("delight-rpc"));
|
|
24
24
|
const extra_promise_1 = require("extra-promise");
|
|
25
25
|
const errors_1 = require("@blackglory/errors");
|
|
26
|
-
function createClientInMain(port) {
|
|
26
|
+
function createClientInMain(port, parameterValidators, expectedVersion) {
|
|
27
27
|
const pendings = {};
|
|
28
28
|
port.addListener('message', handler);
|
|
29
29
|
const client = DelightRPC.createClient(async function send(request) {
|
|
@@ -36,7 +36,7 @@ function createClientInMain(port) {
|
|
|
36
36
|
finally {
|
|
37
37
|
delete pendings[request.id];
|
|
38
38
|
}
|
|
39
|
-
});
|
|
39
|
+
}, parameterValidators, expectedVersion);
|
|
40
40
|
return [client, close];
|
|
41
41
|
function close() {
|
|
42
42
|
port.removeListener('message', handler);
|
|
@@ -53,7 +53,7 @@ function createClientInMain(port) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
exports.createClientInMain = createClientInMain;
|
|
56
|
-
function createClientInRenderer(port) {
|
|
56
|
+
function createClientInRenderer(port, parameterValidators, expectedVersion) {
|
|
57
57
|
const pendings = {};
|
|
58
58
|
port.addEventListener('message', handler);
|
|
59
59
|
const client = DelightRPC.createClient(async function send(request) {
|
|
@@ -66,7 +66,7 @@ function createClientInRenderer(port) {
|
|
|
66
66
|
finally {
|
|
67
67
|
delete pendings[request.id];
|
|
68
68
|
}
|
|
69
|
-
});
|
|
69
|
+
}, parameterValidators, expectedVersion);
|
|
70
70
|
return [client, close];
|
|
71
71
|
function close() {
|
|
72
72
|
port.removeEventListener('message', handler);
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAyC;AACzC,iDAAwC;AAExC,+CAAgD;AAEhD,SAAgB,kBAAkB,CAChC,IAA8B;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAyC;AACzC,iDAAwC;AAExC,+CAAgD;AAEhD,SAAgB,kBAAkB,CAChC,IAA8B,EAC9B,mBAA0D,EAC1D,eAAiD;IAEjD,MAAM,QAAQ,GAA0D,EAAE,CAAA;IAE1E,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAEpC,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CACpC,KAAK,UAAU,IAAI,CA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zB,MAAM,GAAG,GAAG,IAAI,wBAAQ,EAA6B,CAAA;QACrD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,GAAG,CAAA;QAC1B,IAAI;YACF,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;YACzB,OAAO,MAAM,GAAG,CAAA;SACjB;gBAAS;YACR,OAAO,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;SAC5B;IACH,CAAC,EACD,mBAAmB,EACnB,eAAe,CAChB,CAAA;IAED,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAEtB,SAAS,KAAK;QACZ,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAE5C,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACtD,QAAQ,CAAC,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC,CAAA;YACnC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAA;SACrB;IACH,CAAC;IAED,SAAS,OAAO,CAAC,KAAmB;QAClC,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAA;QACtB,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACvD,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;SAC9B;IACH,CAAC;AACH,CAAC;AAzCD,wDAyCC;AAED,MAAa,YAAa,SAAQ,oBAAW;CAAG;AAAhD,oCAAgD"}
|
package/lib/server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as DelightRPC from 'delight-rpc';
|
|
1
2
|
import Electron from 'electron';
|
|
2
|
-
export declare function createServerInMain<IAPI extends object>(api: IAPI
|
|
3
|
-
export declare function createServerInRenderer<IAPI extends object>(api: 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
|
@@ -21,25 +21,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.createServerInRenderer = exports.createServerInMain = void 0;
|
|
23
23
|
const DelightRPC = __importStar(require("delight-rpc"));
|
|
24
|
-
function createServerInMain(api, port) {
|
|
24
|
+
function createServerInMain(api, port, parameterValidators, version) {
|
|
25
25
|
port.addListener('message', handler);
|
|
26
26
|
return () => port.removeListener('message', handler);
|
|
27
27
|
async function handler(event) {
|
|
28
28
|
const req = event.data;
|
|
29
29
|
if (DelightRPC.isRequest(req)) {
|
|
30
|
-
const result = await DelightRPC.createResponse(api, req);
|
|
30
|
+
const result = await DelightRPC.createResponse(api, req, parameterValidators, version);
|
|
31
31
|
port.postMessage(result);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
exports.createServerInMain = createServerInMain;
|
|
36
|
-
function createServerInRenderer(api, port) {
|
|
36
|
+
function createServerInRenderer(api, port, parameterValidators, version) {
|
|
37
37
|
port.addEventListener('message', handler);
|
|
38
38
|
return () => port.removeEventListener('message', handler);
|
|
39
39
|
async function handler(event) {
|
|
40
40
|
const req = event.data;
|
|
41
41
|
if (DelightRPC.isRequest(req)) {
|
|
42
|
-
const result = await DelightRPC.createResponse(api, req);
|
|
42
|
+
const result = await DelightRPC.createResponse(api, req, parameterValidators, version);
|
|
43
43
|
port.postMessage(result);
|
|
44
44
|
}
|
|
45
45
|
}
|
package/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAyC;AAGzC,SAAgB,kBAAkB,CAChC,
|
|
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": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
"repository": "git@github.com:delight-rpc/electron.git",
|
|
12
12
|
"author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"engines": {
|
|
15
|
-
"node": ">=16"
|
|
16
|
-
},
|
|
17
14
|
"scripts": {
|
|
18
15
|
"lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src",
|
|
19
16
|
"test": "jest --no-cache --config jest.config.js",
|
|
@@ -33,31 +30,31 @@
|
|
|
33
30
|
}
|
|
34
31
|
},
|
|
35
32
|
"devDependencies": {
|
|
36
|
-
"@blackglory/jest-matchers": "^0.1
|
|
37
|
-
"@commitlint/cli": "^
|
|
38
|
-
"@commitlint/config-conventional": "^
|
|
39
|
-
"@types/jest": "^27.0
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
41
|
-
"@typescript-eslint/parser": "^5.
|
|
33
|
+
"@blackglory/jest-matchers": "^0.2.1",
|
|
34
|
+
"@commitlint/cli": "^16.1.0",
|
|
35
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
36
|
+
"@types/jest": "^27.4.0",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
38
|
+
"@typescript-eslint/parser": "^5.10.0",
|
|
42
39
|
"cross-env": "^7.0.3",
|
|
43
|
-
"delight-rpc": "^1.
|
|
44
|
-
"electron": "^16.0.
|
|
45
|
-
"eslint": "8.
|
|
40
|
+
"delight-rpc": "^1.3.0",
|
|
41
|
+
"electron": "^16.0.7",
|
|
42
|
+
"eslint": "8.7.0",
|
|
46
43
|
"husky": "4",
|
|
47
|
-
"jest": "^27.4.
|
|
44
|
+
"jest": "^27.4.7",
|
|
48
45
|
"npm-run-all": "^4.1.5",
|
|
49
46
|
"rimraf": "^3.0.2",
|
|
50
47
|
"standard-version": "^9.3.2",
|
|
51
|
-
"ts-jest": "^27.1.
|
|
48
|
+
"ts-jest": "^27.1.3",
|
|
52
49
|
"tscpaths": "^0.0.9",
|
|
53
|
-
"typescript": "^4.5.
|
|
50
|
+
"typescript": "^4.5.5"
|
|
54
51
|
},
|
|
55
52
|
"dependencies": {
|
|
56
|
-
"@blackglory/errors": "^
|
|
57
|
-
"extra-promise": "^0.
|
|
53
|
+
"@blackglory/errors": "^2.0.0",
|
|
54
|
+
"extra-promise": "^0.21.2"
|
|
58
55
|
},
|
|
59
56
|
"peerDependencies": {
|
|
60
|
-
"delight-rpc": "^1.
|
|
57
|
+
"delight-rpc": "^1.3.0",
|
|
61
58
|
"electron": "^16.0.1"
|
|
62
59
|
}
|
|
63
60
|
}
|