@delight-rpc/electron 2.0.1 → 2.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 +4 -0
- 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 +8 -8
package/README.md
CHANGED
|
@@ -197,6 +197,7 @@ window.ready()
|
|
|
197
197
|
```ts
|
|
198
198
|
function createClientInMain<IAPI extends object>(
|
|
199
199
|
port: Electron.MessagePortMain
|
|
200
|
+
, parametersValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
200
201
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
201
202
|
```
|
|
202
203
|
|
|
@@ -204,6 +205,7 @@ function createClientInMain<IAPI extends object>(
|
|
|
204
205
|
```ts
|
|
205
206
|
function createClientInRenderer<IAPI extends object>(
|
|
206
207
|
port: MessagePort
|
|
208
|
+
, parametersValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
207
209
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
208
210
|
```
|
|
209
211
|
|
|
@@ -212,6 +214,7 @@ function createClientInRenderer<IAPI extends object>(
|
|
|
212
214
|
function createServerInMain<IAPI extends object>(
|
|
213
215
|
api: IAPI
|
|
214
216
|
, port: Electron.MessagePortMain
|
|
217
|
+
, parametersValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
215
218
|
): () => void
|
|
216
219
|
```
|
|
217
220
|
|
|
@@ -220,5 +223,6 @@ function createServerInMain<IAPI extends object>(
|
|
|
220
223
|
function createServerInRenderer<IAPI extends object>(
|
|
221
224
|
api: IAPI
|
|
222
225
|
, port: MessagePort
|
|
226
|
+
, parametersValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
223
227
|
): () => void
|
|
224
228
|
```
|
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, parametersValidators?: DelightRPC.ParameterValidators<IAPI>): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
|
|
5
|
+
export declare function createClientInRenderer<IAPI extends object>(port: MessagePort, parametersValidators?: DelightRPC.ParameterValidators<IAPI>): [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, parametersValidators) {
|
|
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
|
+
}, parametersValidators);
|
|
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, parametersValidators) {
|
|
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
|
+
}, parametersValidators);
|
|
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,oBAA2D;IAE3D,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,CAAC,OAAO;QACzB,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,oBAA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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;AAvCD,wDAuCC;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, port: Electron.MessagePortMain): () => void;
|
|
3
|
-
export declare function createServerInRenderer<IAPI extends object>(api: IAPI, port: MessagePort): () => void;
|
|
3
|
+
export declare function createServerInMain<IAPI extends object>(api: IAPI, port: Electron.MessagePortMain, parametersValidators?: DelightRPC.ParameterValidators<IAPI>): () => void;
|
|
4
|
+
export declare function createServerInRenderer<IAPI extends object>(api: IAPI, port: MessagePort, parametersValidators?: DelightRPC.ParameterValidators<IAPI>): () => 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, parametersValidators) {
|
|
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, parametersValidators);
|
|
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, parametersValidators) {
|
|
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, parametersValidators);
|
|
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,GAAS,EACT,IAA8B;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAyC;AAGzC,SAAgB,kBAAkB,CAChC,GAAS,EACT,IAA8B,EAC9B,oBAA2D;IAE3D,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,CAAC,GAAG,EAAE,GAAG,EAAE,oBAAoB,CAAC,CAAA;YAE9E,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;SACzB;IACH,CAAC;AACH,CAAC;AAhBD,gDAgBC;AAED,SAAgB,sBAAsB,CACpC,GAAS,EACT,IAAiB,EACjB,oBAA2D;IAE3D,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,CAAC,GAAG,EAAE,GAAG,EAAE,oBAAoB,CAAC,CAAA;YAE9E,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;SACzB;IACH,CAAC;AACH,CAAC;AAhBD,wDAgBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delight-rpc/electron",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@blackglory/jest-matchers": "^0.2.1",
|
|
34
|
-
"@commitlint/cli": "^
|
|
35
|
-
"@commitlint/config-conventional": "^
|
|
34
|
+
"@commitlint/cli": "^16.0.1",
|
|
35
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
36
36
|
"@types/jest": "^27.0.3",
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
38
|
-
"@typescript-eslint/parser": "^5.
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
|
38
|
+
"@typescript-eslint/parser": "^5.8.1",
|
|
39
39
|
"cross-env": "^7.0.3",
|
|
40
|
-
"delight-rpc": "^1.
|
|
40
|
+
"delight-rpc": "^1.2.0",
|
|
41
41
|
"electron": "^16.0.5",
|
|
42
|
-
"eslint": "8.
|
|
42
|
+
"eslint": "8.5.0",
|
|
43
43
|
"husky": "4",
|
|
44
44
|
"jest": "^27.4.5",
|
|
45
45
|
"npm-run-all": "^4.1.5",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"extra-promise": "^0.21.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"delight-rpc": "^1.
|
|
57
|
+
"delight-rpc": "^1.2.0",
|
|
58
58
|
"electron": "^16.0.1"
|
|
59
59
|
}
|
|
60
60
|
}
|