@delight-rpc/electron 2.1.0 → 2.1.1
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 +6 -6
- 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 +2 -2
- package/lib/server.js +4 -4
- package/lib/server.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ window.ready()
|
|
|
197
197
|
```ts
|
|
198
198
|
function createClientInMain<IAPI extends object>(
|
|
199
199
|
port: Electron.MessagePortMain
|
|
200
|
-
,
|
|
200
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
201
201
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
202
202
|
```
|
|
203
203
|
|
|
@@ -205,24 +205,24 @@ function createClientInMain<IAPI extends object>(
|
|
|
205
205
|
```ts
|
|
206
206
|
function createClientInRenderer<IAPI extends object>(
|
|
207
207
|
port: MessagePort
|
|
208
|
-
,
|
|
208
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
209
209
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
210
210
|
```
|
|
211
211
|
|
|
212
212
|
### createServerInMain
|
|
213
213
|
```ts
|
|
214
214
|
function createServerInMain<IAPI extends object>(
|
|
215
|
-
api: IAPI
|
|
215
|
+
api: DelightRPC.ImplementationOf<IAPI>
|
|
216
216
|
, port: Electron.MessagePortMain
|
|
217
|
-
,
|
|
217
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
218
218
|
): () => void
|
|
219
219
|
```
|
|
220
220
|
|
|
221
221
|
### createServerInRenderer
|
|
222
222
|
```ts
|
|
223
223
|
function createServerInRenderer<IAPI extends object>(
|
|
224
|
-
api: IAPI
|
|
224
|
+
api: DelightRPC.ImplementationOf<IAPI>
|
|
225
225
|
, port: MessagePort
|
|
226
|
-
,
|
|
226
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
227
227
|
): () => void
|
|
228
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,
|
|
5
|
-
export declare function createClientInRenderer<IAPI extends object>(port: MessagePort,
|
|
4
|
+
export declare function createClientInMain<IAPI extends object>(port: Electron.MessagePortMain, parameterValidators?: DelightRPC.ParameterValidators<IAPI>): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
|
|
5
|
+
export declare function createClientInRenderer<IAPI extends object>(port: MessagePort, parameterValidators?: 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, parameterValidators) {
|
|
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, parametersValidators) {
|
|
|
36
36
|
finally {
|
|
37
37
|
delete pendings[request.id];
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, parameterValidators);
|
|
40
40
|
return [client, close];
|
|
41
41
|
function close() {
|
|
42
42
|
port.removeListener('message', handler);
|
|
@@ -53,7 +53,7 @@ function createClientInMain(port, parametersValidators) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
exports.createClientInMain = createClientInMain;
|
|
56
|
-
function createClientInRenderer(port,
|
|
56
|
+
function createClientInRenderer(port, parameterValidators) {
|
|
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, parametersValidators) {
|
|
|
66
66
|
finally {
|
|
67
67
|
delete pendings[request.id];
|
|
68
68
|
}
|
|
69
|
-
},
|
|
69
|
+
}, parameterValidators);
|
|
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,EAC9B,
|
|
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;IAE1D,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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CAAC,CAAA;SAC5B;IACH,CAAC,EACD,mBAAmB,CACpB,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;AAvCD,wDAuCC;AAED,MAAa,YAAa,SAAQ,oBAAW;CAAG;AAAhD,oCAAgD"}
|
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: IAPI
|
|
4
|
-
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>): () => void;
|
|
4
|
+
export declare function createServerInRenderer<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: MessagePort, parameterValidators?: 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, parameterValidators) {
|
|
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);
|
|
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) {
|
|
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);
|
|
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,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6
|
"files": [
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"@blackglory/jest-matchers": "^0.2.1",
|
|
34
34
|
"@commitlint/cli": "^16.0.1",
|
|
35
35
|
"@commitlint/config-conventional": "^16.0.0",
|
|
36
|
-
"@types/jest": "^27.0
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
38
|
-
"@typescript-eslint/parser": "^5.
|
|
36
|
+
"@types/jest": "^27.4.0",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
|
38
|
+
"@typescript-eslint/parser": "^5.9.0",
|
|
39
39
|
"cross-env": "^7.0.3",
|
|
40
|
-
"delight-rpc": "^1.2.
|
|
41
|
-
"electron": "^16.0.
|
|
42
|
-
"eslint": "8.
|
|
40
|
+
"delight-rpc": "^1.2.1",
|
|
41
|
+
"electron": "^16.0.6",
|
|
42
|
+
"eslint": "8.6.0",
|
|
43
43
|
"husky": "4",
|
|
44
|
-
"jest": "^27.4.
|
|
44
|
+
"jest": "^27.4.7",
|
|
45
45
|
"npm-run-all": "^4.1.5",
|
|
46
46
|
"rimraf": "^3.0.2",
|
|
47
47
|
"standard-version": "^9.3.2",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@blackglory/errors": "^1.1.2",
|
|
54
|
-
"extra-promise": "^0.21.
|
|
54
|
+
"extra-promise": "^0.21.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"delight-rpc": "^1.2.
|
|
57
|
+
"delight-rpc": "^1.2.1",
|
|
58
58
|
"electron": "^16.0.1"
|
|
59
59
|
}
|
|
60
60
|
}
|