@delight-rpc/child-process 0.1.1 → 0.2.3
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 -4
- package/lib/client.d.ts +1 -1
- package/lib/client.js +2 -2
- package/lib/client.js.map +1 -1
- package/lib/server.d.ts +2 -1
- package/lib/server.js +2 -2
- package/lib/server.js.map +1 -1
- package/package.json +12 -16
- package/CHANGELOG.md +0 -17
package/README.md
CHANGED
|
@@ -27,9 +27,9 @@ createServer(api, process)
|
|
|
27
27
|
|
|
28
28
|
// main.ts
|
|
29
29
|
import { fork } from 'child_process'
|
|
30
|
-
import { createClient } from '@delight-rpc/
|
|
30
|
+
import { createClient } from '@delight-rpc/child-process'
|
|
31
31
|
|
|
32
|
-
const childProcess = fork('./child-process.js')
|
|
32
|
+
const childProcess = fork('./child-process.js', { serialization: 'advanced' })
|
|
33
33
|
const [client] = createClient<IAPI>(childProcess)
|
|
34
34
|
|
|
35
35
|
await client.echo('hello world')
|
|
@@ -52,11 +52,11 @@ const api: IAPI = {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const childProcess = fork('./child-process.js')
|
|
55
|
+
const childProcess = fork('./child-process.js', { serialization: 'advanced' })
|
|
56
56
|
createServer(api, childProcess)
|
|
57
57
|
|
|
58
58
|
// child-process.ts
|
|
59
|
-
import { createClient } from '@delight-rpc/
|
|
59
|
+
import { createClient } from '@delight-rpc/child-process'
|
|
60
60
|
|
|
61
61
|
const [client] = createClient<IAPI>(process)
|
|
62
62
|
await client.echo('hello world')
|
|
@@ -67,6 +67,7 @@ await client.echo('hello world')
|
|
|
67
67
|
```ts
|
|
68
68
|
function createClient<IAPI extends object>(
|
|
69
69
|
process: ChildProcess | NodeJS.Process
|
|
70
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
70
71
|
): [client: DelightRPC.ClientProxy<IAPI>, close: () => void]
|
|
71
72
|
```
|
|
72
73
|
|
|
@@ -75,5 +76,6 @@ function createClient<IAPI extends object>(
|
|
|
75
76
|
function createServer<IAPI extends object>(
|
|
76
77
|
api: IAPI
|
|
77
78
|
, process: ChildProcess | NodeJS.Process
|
|
79
|
+
, parameterValidators?: DelightRPC.ParameterValidators<IAPI>
|
|
78
80
|
): () => void
|
|
79
81
|
```
|
package/lib/client.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import * as DelightRPC from 'delight-rpc';
|
|
3
3
|
import { ChildProcess } from 'child_process';
|
|
4
4
|
import { CustomError } from '@blackglory/errors';
|
|
5
|
-
export declare function createClient<IAPI extends object>(process: ChildProcess | NodeJS.Process): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
|
|
5
|
+
export declare function createClient<IAPI extends object>(process: ChildProcess | NodeJS.Process, 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.createClient = void 0;
|
|
|
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 createClient(process) {
|
|
26
|
+
function createClient(process, parameterValidators) {
|
|
27
27
|
const pendings = {};
|
|
28
28
|
process.on('message', handler);
|
|
29
29
|
const client = DelightRPC.createClient(async function send(request) {
|
|
@@ -36,7 +36,7 @@ function createClient(process) {
|
|
|
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
|
process.off('message', handler);
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/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AC,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;AAtCD,oCAsCC;AAED,MAAa,YAAa,SAAQ,oBAAW;CAAG;AAAhD,oCAAgD"}
|
package/lib/server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import * as DelightRPC from 'delight-rpc';
|
|
2
3
|
import { ChildProcess } from 'child_process';
|
|
3
|
-
export declare function createServer<IAPI extends object>(api: IAPI, process: ChildProcess | NodeJS.Process): () => void;
|
|
4
|
+
export declare function createServer<IAPI extends object>(api: IAPI, process: ChildProcess | NodeJS.Process, parameterValidators?: DelightRPC.ParameterValidators<IAPI>): () => void;
|
package/lib/server.js
CHANGED
|
@@ -21,12 +21,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.createServer = void 0;
|
|
23
23
|
const DelightRPC = __importStar(require("delight-rpc"));
|
|
24
|
-
function createServer(api, process) {
|
|
24
|
+
function createServer(api, process, parameterValidators) {
|
|
25
25
|
process.on('message', handler);
|
|
26
26
|
return () => process.off('message', handler);
|
|
27
27
|
async function handler(req) {
|
|
28
28
|
if (DelightRPC.isRequest(req)) {
|
|
29
|
-
const result = await DelightRPC.createResponse(api, req);
|
|
29
|
+
const result = await DelightRPC.createResponse(api, req, parameterValidators);
|
|
30
30
|
process.send(result);
|
|
31
31
|
}
|
|
32
32
|
}
|
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,YAAY,CAC1B,GAAS,EACT,OAAsC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAyC;AAGzC,SAAgB,YAAY,CAC1B,GAAS,EACT,OAAsC,EACtC,mBAA0D;IAE1D,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC9B,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAE5C,KAAK,UAAU,OAAO,CAAC,GAAQ;QAC7B,IAAI,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;YAC7B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAAA;YAE7E,OAAO,CAAC,IAAK,CAAC,MAAM,CAAC,CAAA;SACtB;IACH,CAAC;AACH,CAAC;AAfD,oCAeC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delight-rpc/child-process",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -28,20 +28,17 @@
|
|
|
28
28
|
"commit-msg": "commitlint --env HUSKY_GIT_PARAMS"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
"engines": {
|
|
32
|
-
"node": ">=12"
|
|
33
|
-
},
|
|
34
31
|
"devDependencies": {
|
|
35
|
-
"@blackglory/jest-matchers": "^0.1
|
|
36
|
-
"@commitlint/cli": "^
|
|
37
|
-
"@commitlint/config-conventional": "^
|
|
38
|
-
"@types/jest": "^27.0
|
|
39
|
-
"@types/node": "
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
41
|
-
"@typescript-eslint/parser": "^5.
|
|
32
|
+
"@blackglory/jest-matchers": "^0.2.1",
|
|
33
|
+
"@commitlint/cli": "^16.0.1",
|
|
34
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
35
|
+
"@types/jest": "^27.4.0",
|
|
36
|
+
"@types/node": "14",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
|
38
|
+
"@typescript-eslint/parser": "^5.9.0",
|
|
42
39
|
"cross-env": "^7.0.3",
|
|
43
|
-
"delight-rpc": "^1.
|
|
44
|
-
"eslint": "8.
|
|
40
|
+
"delight-rpc": "^1.2.0",
|
|
41
|
+
"eslint": "8.6.0",
|
|
45
42
|
"husky": "4",
|
|
46
43
|
"jest": "^27.4.3",
|
|
47
44
|
"npm-run-all": "^4.1.5",
|
|
@@ -56,10 +53,9 @@
|
|
|
56
53
|
},
|
|
57
54
|
"dependencies": {
|
|
58
55
|
"@blackglory/errors": "^1.1.2",
|
|
59
|
-
"extra-promise": "^0.
|
|
60
|
-
"justypes": "^0.1.6"
|
|
56
|
+
"extra-promise": "^0.21.0"
|
|
61
57
|
},
|
|
62
58
|
"peerDependencies": {
|
|
63
|
-
"delight-rpc": "^1.
|
|
59
|
+
"delight-rpc": "^1.2.0"
|
|
64
60
|
}
|
|
65
61
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
### [0.1.1](https://github.com/delight-rpc/child-process/compare/v0.1.0...v0.1.1) (2021-12-05)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
* error ([7e489eb](https://github.com/delight-rpc/child-process/commit/7e489ebd0016a4888f18a46f89b3611ed5739404))
|
|
11
|
-
|
|
12
|
-
## 0.1.0 (2021-12-03)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### Features
|
|
16
|
-
|
|
17
|
-
* init ([177ea3a](https://github.com/delight-rpc/child-process/commit/177ea3a81be973c7b91a61cb5b645baf344906af))
|