@delight-rpc/electron 6.0.4 → 6.0.5

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/lib/client.d.ts CHANGED
@@ -1,23 +1,23 @@
1
- import * as DelightRPC from 'delight-rpc';
2
- import Electron from 'electron';
3
- import { CustomError } from '@blackglory/errors';
4
- export declare function createClientInMain<IAPI extends object>(port: Electron.MessagePortMain, { parameterValidators, expectedVersion, channel }?: {
5
- parameterValidators?: DelightRPC.ParameterValidators<IAPI>;
6
- expectedVersion?: string;
7
- channel?: string;
8
- }): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
9
- export declare function createClientInRenderer<IAPI extends object>(port: MessagePort, { parameterValidators, expectedVersion, channel }?: {
10
- parameterValidators?: DelightRPC.ParameterValidators<IAPI>;
11
- expectedVersion?: string;
12
- channel?: string;
13
- }): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
14
- export declare function createBatchClientInMain<DataType>(port: Electron.MessagePortMain, { expectedVersion, channel }?: {
15
- expectedVersion?: string;
16
- channel?: string;
17
- }): [client: DelightRPC.BatchClient<DataType>, close: () => void];
18
- export declare function createBatchClientInRenderer<DataType>(port: MessagePort, { expectedVersion, channel }?: {
19
- expectedVersion?: string;
20
- channel?: string;
21
- }): [client: DelightRPC.BatchClient<DataType>, close: () => void];
22
- export declare class ClientClosed extends CustomError {
23
- }
1
+ import * as DelightRPC from 'delight-rpc';
2
+ import Electron from 'electron';
3
+ import { CustomError } from '@blackglory/errors';
4
+ export declare function createClientInMain<IAPI extends object>(port: Electron.MessagePortMain, { parameterValidators, expectedVersion, channel }?: {
5
+ parameterValidators?: DelightRPC.ParameterValidators<IAPI>;
6
+ expectedVersion?: string;
7
+ channel?: string;
8
+ }): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
9
+ export declare function createClientInRenderer<IAPI extends object>(port: MessagePort, { parameterValidators, expectedVersion, channel }?: {
10
+ parameterValidators?: DelightRPC.ParameterValidators<IAPI>;
11
+ expectedVersion?: string;
12
+ channel?: string;
13
+ }): [client: DelightRPC.ClientProxy<IAPI>, close: () => void];
14
+ export declare function createBatchClientInMain<DataType>(port: Electron.MessagePortMain, { expectedVersion, channel }?: {
15
+ expectedVersion?: string;
16
+ channel?: string;
17
+ }): [client: DelightRPC.BatchClient<DataType>, close: () => void];
18
+ export declare function createBatchClientInRenderer<DataType>(port: MessagePort, { expectedVersion, channel }?: {
19
+ expectedVersion?: string;
20
+ channel?: string;
21
+ }): [client: DelightRPC.BatchClient<DataType>, close: () => void];
22
+ export declare class ClientClosed extends CustomError {
23
+ }
package/lib/client.js CHANGED
@@ -1,140 +1,140 @@
1
- import * as DelightRPC from 'delight-rpc';
2
- import { Deferred } from 'extra-promise';
3
- import { CustomError } from '@blackglory/errors';
4
- export function createClientInMain(port, { parameterValidators, expectedVersion, channel } = {}) {
5
- const pendings = {};
6
- port.addListener('message', handler);
7
- const client = DelightRPC.createClient(async function send(request) {
8
- const res = new Deferred();
9
- pendings[request.id] = res;
10
- try {
11
- port.postMessage(request);
12
- return await res;
13
- }
14
- finally {
15
- delete pendings[request.id];
16
- }
17
- }, {
18
- parameterValidators,
19
- expectedVersion,
20
- channel
21
- });
22
- return [client, close];
23
- function close() {
24
- port.removeListener('message', handler);
25
- for (const [key, deferred] of Object.entries(pendings)) {
26
- deferred.reject(new ClientClosed());
27
- delete pendings[key];
28
- }
29
- }
30
- function handler(event) {
31
- var _a;
32
- const res = event.data;
33
- if (DelightRPC.isResult(res) || DelightRPC.isError(res)) {
34
- (_a = pendings[res.id]) === null || _a === void 0 ? void 0 : _a.resolve(res);
35
- }
36
- }
37
- }
38
- export function createClientInRenderer(port, { parameterValidators, expectedVersion, channel } = {}) {
39
- const pendings = {};
40
- port.addEventListener('message', handler);
41
- const client = DelightRPC.createClient(async function send(request) {
42
- const res = new Deferred();
43
- pendings[request.id] = res;
44
- try {
45
- port.postMessage(request);
46
- return await res;
47
- }
48
- finally {
49
- delete pendings[request.id];
50
- }
51
- }, {
52
- parameterValidators,
53
- expectedVersion,
54
- channel
55
- });
56
- return [client, close];
57
- function close() {
58
- port.removeEventListener('message', handler);
59
- for (const [key, deferred] of Object.entries(pendings)) {
60
- deferred.reject(new ClientClosed());
61
- delete pendings[key];
62
- }
63
- }
64
- function handler(event) {
65
- var _a;
66
- const res = event.data;
67
- if (DelightRPC.isResult(res) || DelightRPC.isError(res)) {
68
- (_a = pendings[res.id]) === null || _a === void 0 ? void 0 : _a.resolve(res);
69
- }
70
- }
71
- }
72
- export function createBatchClientInMain(port, { expectedVersion, channel } = {}) {
73
- const pendings = {};
74
- port.addListener('message', handler);
75
- const client = new DelightRPC.BatchClient(async function send(request) {
76
- const res = new Deferred();
77
- pendings[request.id] = res;
78
- try {
79
- port.postMessage(request);
80
- return await res;
81
- }
82
- finally {
83
- delete pendings[request.id];
84
- }
85
- }, {
86
- expectedVersion,
87
- channel
88
- });
89
- return [client, close];
90
- function close() {
91
- port.removeListener('message', handler);
92
- for (const [key, deferred] of Object.entries(pendings)) {
93
- deferred.reject(new ClientClosed());
94
- delete pendings[key];
95
- }
96
- }
97
- function handler(event) {
98
- var _a;
99
- const res = event.data;
100
- if (DelightRPC.isError(res) || DelightRPC.isBatchResponse(res)) {
101
- (_a = pendings[res.id]) === null || _a === void 0 ? void 0 : _a.resolve(res);
102
- }
103
- }
104
- }
105
- export function createBatchClientInRenderer(port, { expectedVersion, channel } = {}) {
106
- const pendings = {};
107
- port.addEventListener('message', handler);
108
- const client = new DelightRPC.BatchClient(async function send(request) {
109
- const res = new Deferred();
110
- pendings[request.id] = res;
111
- try {
112
- port.postMessage(request);
113
- return await res;
114
- }
115
- finally {
116
- delete pendings[request.id];
117
- }
118
- }, {
119
- expectedVersion,
120
- channel
121
- });
122
- return [client, close];
123
- function close() {
124
- port.removeEventListener('message', handler);
125
- for (const [key, deferred] of Object.entries(pendings)) {
126
- deferred.reject(new ClientClosed());
127
- delete pendings[key];
128
- }
129
- }
130
- function handler(event) {
131
- var _a;
132
- const res = event.data;
133
- if (DelightRPC.isError(res) || DelightRPC.isBatchResponse(res)) {
134
- (_a = pendings[res.id]) === null || _a === void 0 ? void 0 : _a.resolve(res);
135
- }
136
- }
137
- }
138
- export class ClientClosed extends CustomError {
139
- }
1
+ import * as DelightRPC from 'delight-rpc';
2
+ import { Deferred } from 'extra-promise';
3
+ import { CustomError } from '@blackglory/errors';
4
+ export function createClientInMain(port, { parameterValidators, expectedVersion, channel } = {}) {
5
+ const pendings = {};
6
+ port.addListener('message', handler);
7
+ const client = DelightRPC.createClient(async function send(request) {
8
+ const res = new Deferred();
9
+ pendings[request.id] = res;
10
+ try {
11
+ port.postMessage(request);
12
+ return await res;
13
+ }
14
+ finally {
15
+ delete pendings[request.id];
16
+ }
17
+ }, {
18
+ parameterValidators,
19
+ expectedVersion,
20
+ channel
21
+ });
22
+ return [client, close];
23
+ function close() {
24
+ port.removeListener('message', handler);
25
+ for (const [key, deferred] of Object.entries(pendings)) {
26
+ deferred.reject(new ClientClosed());
27
+ delete pendings[key];
28
+ }
29
+ }
30
+ function handler(event) {
31
+ var _a;
32
+ const res = event.data;
33
+ if (DelightRPC.isResult(res) || DelightRPC.isError(res)) {
34
+ (_a = pendings[res.id]) === null || _a === void 0 ? void 0 : _a.resolve(res);
35
+ }
36
+ }
37
+ }
38
+ export function createClientInRenderer(port, { parameterValidators, expectedVersion, channel } = {}) {
39
+ const pendings = {};
40
+ port.addEventListener('message', handler);
41
+ const client = DelightRPC.createClient(async function send(request) {
42
+ const res = new Deferred();
43
+ pendings[request.id] = res;
44
+ try {
45
+ port.postMessage(request);
46
+ return await res;
47
+ }
48
+ finally {
49
+ delete pendings[request.id];
50
+ }
51
+ }, {
52
+ parameterValidators,
53
+ expectedVersion,
54
+ channel
55
+ });
56
+ return [client, close];
57
+ function close() {
58
+ port.removeEventListener('message', handler);
59
+ for (const [key, deferred] of Object.entries(pendings)) {
60
+ deferred.reject(new ClientClosed());
61
+ delete pendings[key];
62
+ }
63
+ }
64
+ function handler(event) {
65
+ var _a;
66
+ const res = event.data;
67
+ if (DelightRPC.isResult(res) || DelightRPC.isError(res)) {
68
+ (_a = pendings[res.id]) === null || _a === void 0 ? void 0 : _a.resolve(res);
69
+ }
70
+ }
71
+ }
72
+ export function createBatchClientInMain(port, { expectedVersion, channel } = {}) {
73
+ const pendings = {};
74
+ port.addListener('message', handler);
75
+ const client = new DelightRPC.BatchClient(async function send(request) {
76
+ const res = new Deferred();
77
+ pendings[request.id] = res;
78
+ try {
79
+ port.postMessage(request);
80
+ return await res;
81
+ }
82
+ finally {
83
+ delete pendings[request.id];
84
+ }
85
+ }, {
86
+ expectedVersion,
87
+ channel
88
+ });
89
+ return [client, close];
90
+ function close() {
91
+ port.removeListener('message', handler);
92
+ for (const [key, deferred] of Object.entries(pendings)) {
93
+ deferred.reject(new ClientClosed());
94
+ delete pendings[key];
95
+ }
96
+ }
97
+ function handler(event) {
98
+ var _a;
99
+ const res = event.data;
100
+ if (DelightRPC.isError(res) || DelightRPC.isBatchResponse(res)) {
101
+ (_a = pendings[res.id]) === null || _a === void 0 ? void 0 : _a.resolve(res);
102
+ }
103
+ }
104
+ }
105
+ export function createBatchClientInRenderer(port, { expectedVersion, channel } = {}) {
106
+ const pendings = {};
107
+ port.addEventListener('message', handler);
108
+ const client = new DelightRPC.BatchClient(async function send(request) {
109
+ const res = new Deferred();
110
+ pendings[request.id] = res;
111
+ try {
112
+ port.postMessage(request);
113
+ return await res;
114
+ }
115
+ finally {
116
+ delete pendings[request.id];
117
+ }
118
+ }, {
119
+ expectedVersion,
120
+ channel
121
+ });
122
+ return [client, close];
123
+ function close() {
124
+ port.removeEventListener('message', handler);
125
+ for (const [key, deferred] of Object.entries(pendings)) {
126
+ deferred.reject(new ClientClosed());
127
+ delete pendings[key];
128
+ }
129
+ }
130
+ function handler(event) {
131
+ var _a;
132
+ const res = event.data;
133
+ if (DelightRPC.isError(res) || DelightRPC.isBatchResponse(res)) {
134
+ (_a = pendings[res.id]) === null || _a === void 0 ? void 0 : _a.resolve(res);
135
+ }
136
+ }
137
+ }
138
+ export class ClientClosed extends CustomError {
139
+ }
140
140
  //# sourceMappingURL=client.js.map
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './client.js';
2
- export * from './server.js';
1
+ export * from './client.js';
2
+ export * from './server.js';
package/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './client.js';
2
- export * from './server.js';
1
+ export * from './client.js';
2
+ export * from './server.js';
3
3
  //# sourceMappingURL=index.js.map
package/lib/server.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import * as DelightRPC from 'delight-rpc';
2
- import Electron from 'electron';
3
- export declare function createServerInMain<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: Electron.MessagePortMain, { parameterValidators, version, channel, ownPropsOnly }?: {
4
- parameterValidators?: DelightRPC.ParameterValidators<IAPI>;
5
- version?: `${number}.${number}.${number}`;
6
- channel?: string | RegExp | typeof DelightRPC.AnyChannel;
7
- ownPropsOnly?: boolean;
8
- }): () => void;
9
- export declare function createServerInRenderer<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: MessagePort, { parameterValidators, version, channel, ownPropsOnly }?: {
10
- parameterValidators?: DelightRPC.ParameterValidators<IAPI>;
11
- version?: `${number}.${number}.${number}`;
12
- channel?: string | RegExp | typeof DelightRPC.AnyChannel;
13
- ownPropsOnly?: boolean;
14
- }): () => void;
1
+ import * as DelightRPC from 'delight-rpc';
2
+ import Electron from 'electron';
3
+ export declare function createServerInMain<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: Electron.MessagePortMain, { parameterValidators, version, channel, ownPropsOnly }?: {
4
+ parameterValidators?: DelightRPC.ParameterValidators<IAPI>;
5
+ version?: `${number}.${number}.${number}`;
6
+ channel?: string | RegExp | typeof DelightRPC.AnyChannel;
7
+ ownPropsOnly?: boolean;
8
+ }): () => void;
9
+ export declare function createServerInRenderer<IAPI extends object>(api: DelightRPC.ImplementationOf<IAPI>, port: MessagePort, { parameterValidators, version, channel, ownPropsOnly }?: {
10
+ parameterValidators?: DelightRPC.ParameterValidators<IAPI>;
11
+ version?: `${number}.${number}.${number}`;
12
+ channel?: string | RegExp | typeof DelightRPC.AnyChannel;
13
+ ownPropsOnly?: boolean;
14
+ }): () => void;
package/lib/server.js CHANGED
@@ -1,39 +1,39 @@
1
- import * as DelightRPC from 'delight-rpc';
2
- import { isntNull } from '@blackglory/prelude';
3
- export function createServerInMain(api, port, { parameterValidators, version, channel, ownPropsOnly } = {}) {
4
- port.addListener('message', handler);
5
- return () => port.removeListener('message', handler);
6
- async function handler(event) {
7
- const req = event.data;
8
- if (DelightRPC.isRequest(req) || DelightRPC.isBatchRequest(req)) {
9
- const result = await DelightRPC.createResponse(api, req, {
10
- parameterValidators,
11
- version,
12
- channel,
13
- ownPropsOnly
14
- });
15
- if (isntNull(result)) {
16
- port.postMessage(result);
17
- }
18
- }
19
- }
20
- }
21
- export function createServerInRenderer(api, port, { parameterValidators, version, channel, ownPropsOnly } = {}) {
22
- port.addEventListener('message', handler);
23
- return () => port.removeEventListener('message', handler);
24
- async function handler(event) {
25
- const req = event.data;
26
- if (DelightRPC.isRequest(req) || DelightRPC.isBatchRequest(req)) {
27
- const result = await DelightRPC.createResponse(api, req, {
28
- parameterValidators,
29
- version,
30
- channel,
31
- ownPropsOnly
32
- });
33
- if (isntNull(result)) {
34
- port.postMessage(result);
35
- }
36
- }
37
- }
38
- }
1
+ import * as DelightRPC from 'delight-rpc';
2
+ import { isntNull } from '@blackglory/prelude';
3
+ export function createServerInMain(api, port, { parameterValidators, version, channel, ownPropsOnly } = {}) {
4
+ port.addListener('message', handler);
5
+ return () => port.removeListener('message', handler);
6
+ async function handler(event) {
7
+ const req = event.data;
8
+ if (DelightRPC.isRequest(req) || DelightRPC.isBatchRequest(req)) {
9
+ const result = await DelightRPC.createResponse(api, req, {
10
+ parameterValidators,
11
+ version,
12
+ channel,
13
+ ownPropsOnly
14
+ });
15
+ if (isntNull(result)) {
16
+ port.postMessage(result);
17
+ }
18
+ }
19
+ }
20
+ }
21
+ export function createServerInRenderer(api, port, { parameterValidators, version, channel, ownPropsOnly } = {}) {
22
+ port.addEventListener('message', handler);
23
+ return () => port.removeEventListener('message', handler);
24
+ async function handler(event) {
25
+ const req = event.data;
26
+ if (DelightRPC.isRequest(req) || DelightRPC.isBatchRequest(req)) {
27
+ const result = await DelightRPC.createResponse(api, req, {
28
+ parameterValidators,
29
+ version,
30
+ channel,
31
+ ownPropsOnly
32
+ });
33
+ if (isntNull(result)) {
34
+ port.postMessage(result);
35
+ }
36
+ }
37
+ }
38
+ }
39
39
  //# sourceMappingURL=server.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delight-rpc/electron",
3
- "version": "6.0.4",
3
+ "version": "6.0.5",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "files": [
@@ -43,7 +43,7 @@
43
43
  "@typescript-eslint/parser": "^5.55.0",
44
44
  "cross-env": "^7.0.3",
45
45
  "delight-rpc": "^6.0.0",
46
- "electron": "^30.0.2",
46
+ "electron": "^34.1.1",
47
47
  "eslint": "8.36.0",
48
48
  "husky": "4",
49
49
  "jest": "^29.5.0",
@@ -65,6 +65,6 @@
65
65
  },
66
66
  "peerDependencies": {
67
67
  "delight-rpc": "^5.0.0 || ^6.0.0",
68
- "electron": ">=16.0.1 <31"
68
+ "electron": ">=16.0.1 <35"
69
69
  }
70
70
  }