electron-effect-rpc 0.9.0 → 0.11.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/CHANGELOG.md +33 -11
- package/README.md +88 -38
- package/dist/boundary.d.ts +17 -0
- package/dist/boundary.d.ts.map +1 -0
- package/dist/boundary.js +89 -0
- package/dist/contract.d.ts +3 -3
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -7
- package/dist/kit.d.ts +6 -8
- package/dist/kit.d.ts.map +1 -1
- package/dist/kit.js +9 -4
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +64 -59
- package/dist/preload-bridge.d.ts +36 -8
- package/dist/preload-bridge.d.ts.map +1 -1
- package/dist/preload-bridge.js +22 -20
- package/dist/protocol.d.ts +12 -12
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +35 -53
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +185 -121
- package/dist/testing.d.ts +4 -3
- package/dist/testing.d.ts.map +1 -1
- package/dist/types.d.ts +32 -25
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,26 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 0.11.0 - 2026-09-06
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
6
8
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
- Event streams propagate subscription setup defects to consumers instead of
|
|
10
|
+
leaving them waiting indefinitely.
|
|
11
|
+
- Main-side stream chunk encoding and send failures terminate the stream with a
|
|
12
|
+
defect frame instead of silently dropping chunks and reporting success.
|
|
13
|
+
- Failed stream terminal-frame sends report `onProtocolError` diagnostics while
|
|
14
|
+
still releasing the active stream.
|
|
15
|
+
- Failed renderer `stream-cancel` requests report `onProtocolError` diagnostics
|
|
16
|
+
with method `stream-cancel/<method name>` while preserving consumer cleanup.
|
|
17
|
+
Throwing diagnostics callbacks remain isolated from the transport.
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// after
|
|
15
|
-
import * as S from "effect/Schema";
|
|
16
|
-
```
|
|
19
|
+
## 0.10.0 - 2026-08-15
|
|
20
|
+
|
|
21
|
+
### Breaking
|
|
17
22
|
|
|
23
|
+
- The package now requires Effect v4 (`effect@^4.0.0-rc.109`). Effect v3 is no
|
|
24
|
+
longer supported.
|
|
25
|
+
- `RpcEndpointOptions.runtime` and `ipc.main({ runtime })` were replaced by
|
|
26
|
+
`context`, which accepts a v4 `Context.Context<R>`. Use `Context.empty()` when
|
|
27
|
+
handlers require no application services.
|
|
28
|
+
- Renderer streams now use Effect v4's `Stream.callback` and `Queue` APIs.
|
|
29
|
+
- Cause extraction, fiber interruption, legacy `Exit` codecs, and schema
|
|
30
|
+
constraints were migrated to their Effect v4 equivalents.
|
|
18
31
|
- `event()` no longer accepts a third `context` schema argument. It was never
|
|
19
32
|
read by the publisher or subscriber; remove it from any `event(...)` calls.
|
|
20
33
|
- `channelPrefix.rpc` and `channelPrefix.event` must now differ; identical
|
|
21
34
|
prefixes throw at construction time.
|
|
22
35
|
- Providing `streamHandlers` when the contract defines no `streamMethods` now
|
|
23
36
|
throws instead of being silently ignored.
|
|
24
|
-
- Methods whose request schema type is `object` (e.g. `S.
|
|
37
|
+
- Methods whose request schema type is `object` (e.g. `S.ObjectKeyword`) now require
|
|
25
38
|
an argument at the call site; previously the client generated a zero-arg
|
|
26
39
|
caller that always sent `{}`.
|
|
27
40
|
|
|
@@ -34,6 +47,9 @@
|
|
|
34
47
|
- `ipc.renderer(bridge, { diagnostics })` — renderer-side diagnostics hooks for
|
|
35
48
|
RPC, events, and streams in kit mode.
|
|
36
49
|
- `assertValidChannelPrefix` exported from `electron-effect-rpc/types`.
|
|
50
|
+
- Named structured-clone transport types (`IpcEncodedValue`,
|
|
51
|
+
`IpcEncodedRecord`, and `DiagnosticCause`) exported from
|
|
52
|
+
`electron-effect-rpc/types`.
|
|
37
53
|
|
|
38
54
|
### Fixed
|
|
39
55
|
|
|
@@ -46,6 +62,12 @@
|
|
|
46
62
|
schema package instance can't silently turn typed failures into defects.
|
|
47
63
|
- Stream failure-encoding defects now carry the encoding error message instead
|
|
48
64
|
of `[object Object]`.
|
|
65
|
+
- Preload bindings now accept the real Electron module without casts, preserve
|
|
66
|
+
Electron method receivers, and report a descriptive error when synchronous
|
|
67
|
+
loading is unavailable in ESM.
|
|
68
|
+
- Protocol envelopes and stream frames preserve structured-clone payloads such
|
|
69
|
+
as `bigint`, maps, sets, binary values, and cyclic object graphs while leaving
|
|
70
|
+
domain validation to each contract schema.
|
|
49
71
|
|
|
50
72
|
## 0.8.0 and earlier
|
|
51
73
|
|
package/README.md
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
1
|
# electron-effect-rpc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/electron-effect-rpc)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Typed, schema-validated IPC for Electron, built on [Effect](https://effect.website).
|
|
6
|
+
|
|
7
|
+
Define your IPC surface once — methods, events, and streams, each described
|
|
8
|
+
with `effect/Schema` — and get a fully typed client in the renderer, fully
|
|
9
|
+
typed handlers in main, and runtime validation at every process boundary. No
|
|
10
|
+
hand-rolled channel strings, no `any`-typed `invoke` calls, no drift between
|
|
11
|
+
processes.
|
|
12
|
+
|
|
13
|
+
The primary API is a single shared `createIpcKit` configuration reused across
|
|
14
|
+
main, preload, and renderer. Low-level per-piece factories remain available as
|
|
15
|
+
subpath imports.
|
|
8
16
|
|
|
9
17
|
This package is ESM-only. It targets modern Electron runtimes and assumes an
|
|
10
18
|
ESM-capable build pipeline.
|
|
11
19
|
|
|
12
20
|
## Features
|
|
13
21
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- Effect
|
|
18
|
-
- Streaming RPC: handlers return `Stream.Stream`, clients consume `Stream.Stream
|
|
19
|
-
-
|
|
20
|
-
- Explicit lifecycle handles and bounded event queue backpressure.
|
|
22
|
+
- One contract for methods, events, and streaming RPC, shared by all three processes.
|
|
23
|
+
- One kit config, so channel naming can never drift between processes.
|
|
24
|
+
- Schema validation on every IPC crossing, in both directions.
|
|
25
|
+
- Typed domain errors in the Effect error channel; transport problems as `RpcDefectError` with stable codes.
|
|
26
|
+
- Streaming RPC: handlers return `Stream.Stream`, clients consume `Stream.Stream`, cancellation propagates.
|
|
27
|
+
- Main handlers are Effects, run with an injected `Context` (so your services are available).
|
|
28
|
+
- Explicit lifecycle handles (`start`/`stop`/`dispose`) and bounded event queue backpressure.
|
|
21
29
|
- Structured diagnostics hooks for decode/protocol/dispatch failures.
|
|
22
30
|
|
|
23
31
|
## Requirements
|
|
24
32
|
|
|
25
|
-
- Electron with context isolation enabled.
|
|
33
|
+
- Electron >= 28 with context isolation enabled.
|
|
26
34
|
- ESM-capable bundling.
|
|
27
|
-
- Peer dependencies: `effect` (
|
|
35
|
+
- Peer dependencies: `effect` (`^4.0.0-rc.109`), `electron`.
|
|
28
36
|
|
|
29
37
|
## Installation
|
|
30
38
|
|
|
@@ -63,11 +71,19 @@ const contract = defineContract({
|
|
|
63
71
|
streamMethods: [StreamAiGeneration] as const,
|
|
64
72
|
});
|
|
65
73
|
|
|
74
|
+
export const ipc = createIpcKit({ contract });
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`createIpcKit` accepts optional configuration; the values below are the
|
|
78
|
+
defaults, so only set them to deviate:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
66
81
|
export const ipc = createIpcKit({
|
|
67
82
|
contract,
|
|
68
83
|
channelPrefix: { rpc: "rpc/", event: "event/" },
|
|
69
84
|
bridge: { global: "api" },
|
|
70
85
|
decode: { rpc: "envelope", events: "safe" },
|
|
86
|
+
streamBuffer: { bufferSize: "unbounded" },
|
|
71
87
|
});
|
|
72
88
|
```
|
|
73
89
|
|
|
@@ -76,8 +92,7 @@ export const ipc = createIpcKit({
|
|
|
76
92
|
```ts
|
|
77
93
|
import path from "node:path";
|
|
78
94
|
import { app, BrowserWindow, ipcMain } from "electron";
|
|
79
|
-
import { Effect, Stream } from "effect";
|
|
80
|
-
import * as Runtime from "effect/Runtime";
|
|
95
|
+
import { Context, Effect, Stream } from "effect";
|
|
81
96
|
import { ipc, WorkUnitProgress } from "./shared-ipc.ts";
|
|
82
97
|
|
|
83
98
|
const mainWindow = new BrowserWindow({
|
|
@@ -95,11 +110,12 @@ const mainRpc = ipc.main({
|
|
|
95
110
|
StreamAiGeneration: ({ prompt }) =>
|
|
96
111
|
Stream.fromIterable(prompt.split(" ")).pipe(Stream.map((word) => ({ delta: word + " " }))),
|
|
97
112
|
},
|
|
98
|
-
|
|
113
|
+
context: Context.empty(),
|
|
99
114
|
getWindows: () => [mainWindow],
|
|
100
115
|
});
|
|
101
116
|
|
|
102
117
|
mainRpc.start();
|
|
118
|
+
app.on("will-quit", () => mainRpc.dispose());
|
|
103
119
|
|
|
104
120
|
void Effect.runPromise(
|
|
105
121
|
mainRpc.publish(WorkUnitProgress, {
|
|
@@ -192,16 +208,49 @@ For a custom global name, use `IpcBridgeGlobal<"myBridge">`.
|
|
|
192
208
|
|
|
193
209
|
## Error Model
|
|
194
210
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
`
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
211
|
+
A call site sees exactly two kinds of failure in the Effect error channel:
|
|
212
|
+
|
|
213
|
+
- **Domain failures** — the tagged errors you declared in the contract's error
|
|
214
|
+
schema, decoded back into those same tagged values.
|
|
215
|
+
- **`RpcDefectError`** — everything else: transport problems, schema
|
|
216
|
+
mismatches, and unexpected main-process exceptions. It is itself tagged
|
|
217
|
+
(`_tag: "RpcDefectError"`) and carries a stable `code` discriminator.
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import { Effect } from "effect";
|
|
221
|
+
|
|
222
|
+
const result = await Effect.runPromise(
|
|
223
|
+
client.DeleteWorkspace({ id }).pipe(
|
|
224
|
+
// a tagged error you declared in the contract
|
|
225
|
+
Effect.catchTag("AccessDeniedError", (e) =>
|
|
226
|
+
Effect.succeed({ deleted: false, reason: e.message }),
|
|
227
|
+
),
|
|
228
|
+
// transport/contract problems
|
|
229
|
+
Effect.catchTag("RpcDefectError", (defect) =>
|
|
230
|
+
Effect.sync(() => log.error(defect.code, defect.message)).pipe(
|
|
231
|
+
Effect.andThen(Effect.fail(defect)),
|
|
232
|
+
),
|
|
233
|
+
),
|
|
234
|
+
),
|
|
235
|
+
);
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
`RpcDefectError.code` values:
|
|
239
|
+
|
|
240
|
+
| Code | Meaning |
|
|
241
|
+
| --------------------------------- | ------------------------------------------------------------------- |
|
|
242
|
+
| `request_encoding_failed` | Request payload failed schema encoding before leaving the renderer. |
|
|
243
|
+
| `invoke_failed` | The underlying `ipcRenderer.invoke` rejected (transport failure). |
|
|
244
|
+
| `success_payload_decoding_failed` | Main's success payload failed response schema decoding. |
|
|
245
|
+
| `failure_payload_decoding_failed` | Main's typed failure payload failed error schema decoding. |
|
|
246
|
+
| `noerror_contract_violation` | A failure arrived for a method that declares `NoError`. |
|
|
247
|
+
| `invalid_response_envelope` | The response was not a valid envelope. |
|
|
248
|
+
| `legacy_decode_failed` | `dual` decode mode could not parse a legacy `Exit` payload. |
|
|
249
|
+
| `remote_defect` | The main-side handler died, threw, or was interrupted. |
|
|
250
|
+
| `stream_invoke_failed` | The stream handshake invoke rejected (transport failure). |
|
|
251
|
+
| `stream_handshake_invalid` | The stream handshake response had an unexpected shape. |
|
|
252
|
+
| `stream_chunk_decode_failed` | A stream chunk failed schema decoding. |
|
|
253
|
+
| `stream_error_decode_failed` | A stream's typed error frame failed schema decoding. |
|
|
205
254
|
|
|
206
255
|
Defect envelopes carry the main-process error message verbatim across IPC. If
|
|
207
256
|
any window in your app loads remote or less-trusted content, treat that as
|
|
@@ -214,10 +263,10 @@ letting raw exceptions (paths, query fragments) become defects.
|
|
|
214
263
|
handler produces them; there is no acknowledgment across the IPC boundary. The
|
|
215
264
|
renderer buffers with `bufferSize: "unbounded"` by default, which is lossless
|
|
216
265
|
but means a fast producer with a slow consumer grows renderer memory. Bounded
|
|
217
|
-
buffers (`dropping`/`sliding`) are lossy by design
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
266
|
+
buffers (`dropping`/`sliding`) are lossy by design, while completion and failure
|
|
267
|
+
signals remain reliable through Effect v4's `Stream.callback` queue. Rate-limit
|
|
268
|
+
fast producers in the handler (`Stream.throttle`, batching) rather than relying
|
|
269
|
+
on a bounded renderer buffer.
|
|
221
270
|
|
|
222
271
|
**Unary RPC cancellation.** Interrupting the renderer-side Effect of a
|
|
223
272
|
client call (e.g. via `Effect.timeout`) does not abort the main-side handler;
|
|
@@ -239,12 +288,12 @@ See [CHANGELOG.md](./CHANGELOG.md) for breaking changes between versions.
|
|
|
239
288
|
|
|
240
289
|
If you need direct control, keep using subpath entry points:
|
|
241
290
|
|
|
242
|
-
- `electron-effect-rpc/contract`
|
|
243
|
-
- `electron-effect-rpc/main`
|
|
244
|
-
- `electron-effect-rpc/renderer`
|
|
245
|
-
- `electron-effect-rpc/preload`
|
|
246
|
-
- `electron-effect-rpc/types`
|
|
247
|
-
- `electron-effect-rpc/testing`
|
|
291
|
+
- `electron-effect-rpc/contract` — `rpc`, `event`, `streamRpc`, `defineContract`
|
|
292
|
+
- `electron-effect-rpc/main` — `createRpcEndpoint`, `createEventPublisher`
|
|
293
|
+
- `electron-effect-rpc/renderer` — `createRpcClient`, `createEventSubscriber`, `createStreamRpcClient`
|
|
294
|
+
- `electron-effect-rpc/preload` — `exposeIpcBridge`, `createBridgeAdapters`
|
|
295
|
+
- `electron-effect-rpc/types` — shared types, `RpcDefectError`, `assertValidChannelPrefix`
|
|
296
|
+
- `electron-effect-rpc/testing` — `createInvokeStub`, `createDeferred` for unit-testing clients without Electron
|
|
248
297
|
|
|
249
298
|
## Root API Surface
|
|
250
299
|
|
|
@@ -256,7 +305,7 @@ The root entry point exports:
|
|
|
256
305
|
|
|
257
306
|
Low-level factories like `createRpcClient` remain subpath-only by design.
|
|
258
307
|
|
|
259
|
-
##
|
|
308
|
+
## Documentation
|
|
260
309
|
|
|
261
310
|
For deeper walkthroughs and production guidance:
|
|
262
311
|
|
|
@@ -265,8 +314,9 @@ For deeper walkthroughs and production guidance:
|
|
|
265
314
|
- [Typed Errors, Defects, and Diagnostics](./docs/tutorials/02-typed-errors-defects-diagnostics.md)
|
|
266
315
|
- [Events, Lifecycle, and Backpressure](./docs/tutorials/03-events-lifecycle-backpressure.md)
|
|
267
316
|
- [Streaming RPC](./docs/tutorials/04-streaming-rpc.md)
|
|
317
|
+
- [Architecture overview](./docs/architecture.md) and [ADRs](./docs/adr/) for design rationale.
|
|
268
318
|
|
|
269
|
-
## Conventions
|
|
319
|
+
## Repository Conventions
|
|
270
320
|
|
|
271
321
|
- Relative imports use `.ts` extensions.
|
|
272
322
|
- Package imports are extensionless.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Values supported by Electron's structured-clone IPC transport. */
|
|
2
|
+
export type IpcEncodedValue = string | number | bigint | boolean | null | undefined | Date | RegExp | Error | ArrayBuffer | SharedArrayBuffer | ArrayBufferView | ReadonlyArray<IpcEncodedValue> | ReadonlyMap<IpcEncodedValue, IpcEncodedValue> | ReadonlySet<IpcEncodedValue> | IpcEncodedRecord;
|
|
3
|
+
export type IpcEncodedRecord = {
|
|
4
|
+
readonly [key: string]: IpcEncodedValue;
|
|
5
|
+
};
|
|
6
|
+
/** True for non-null, non-array objects. Arrays are not IPC records. */
|
|
7
|
+
export declare function isRecord<T>(value: T): value is T & IpcEncodedRecord;
|
|
8
|
+
export declare function isIpcEncodedValue<T>(value: T): value is T & IpcEncodedValue;
|
|
9
|
+
export declare function isStringValue<T>(value: T): value is T & string;
|
|
10
|
+
export declare function isNumberValue<T>(value: T): value is T & number;
|
|
11
|
+
export declare function isFunctionValue<T>(value: T): boolean;
|
|
12
|
+
export declare function formatUnknown<T>(value: T): string;
|
|
13
|
+
export declare function parseIpcEncodedValue<T>(value: T): IpcEncodedValue | null;
|
|
14
|
+
/** Values reported through diagnostics after transport-safe normalization. */
|
|
15
|
+
export type DiagnosticCause = IpcEncodedValue;
|
|
16
|
+
export declare function toDiagnosticCause<T>(value: T): DiagnosticCause;
|
|
17
|
+
//# sourceMappingURL=boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../src/boundary.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,IAAI,GACJ,MAAM,GACN,KAAK,GACL,WAAW,GACX,iBAAiB,GACjB,eAAe,GACf,aAAa,CAAC,eAAe,CAAC,GAC9B,WAAW,CAAC,eAAe,EAAE,eAAe,CAAC,GAC7C,WAAW,CAAC,eAAe,CAAC,GAC5B,gBAAgB,CAAC;AAErB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;CACzC,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAEnE;AA4ED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,eAAe,CAE3E;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,MAAM,CAE9D;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,MAAM,CAE9D;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAEpD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAEjD;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,eAAe,GAAG,IAAI,CAExE;AAED,8EAA8E;AAC9E,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC;AAE9C,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,eAAe,CAM9D"}
|
package/dist/boundary.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as Predicate from "effect/Predicate";
|
|
2
|
+
/** True for non-null, non-array objects. Arrays are not IPC records. */
|
|
3
|
+
export function isRecord(value) {
|
|
4
|
+
return Predicate.isObject(value);
|
|
5
|
+
}
|
|
6
|
+
function isPrimitiveIpcValue(value) {
|
|
7
|
+
return (Predicate.isString(value) ||
|
|
8
|
+
Predicate.isNumber(value) ||
|
|
9
|
+
Predicate.isBigInt(value) ||
|
|
10
|
+
Predicate.isBoolean(value) ||
|
|
11
|
+
value === null ||
|
|
12
|
+
value === undefined);
|
|
13
|
+
}
|
|
14
|
+
function isIpcEncodedValueInternal(value, visited) {
|
|
15
|
+
if (isPrimitiveIpcValue(value)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (!Predicate.isObjectOrArray(value)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (value instanceof Date ||
|
|
22
|
+
value instanceof RegExp ||
|
|
23
|
+
value instanceof Error ||
|
|
24
|
+
value instanceof ArrayBuffer ||
|
|
25
|
+
value instanceof SharedArrayBuffer ||
|
|
26
|
+
ArrayBuffer.isView(value)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (value instanceof Promise || value instanceof WeakMap || value instanceof WeakSet) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (visited.has(value)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
visited.add(value);
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return value.every((item) => isIpcEncodedValueInternal(item, visited));
|
|
38
|
+
}
|
|
39
|
+
if (value instanceof Map) {
|
|
40
|
+
for (const [key, item] of value) {
|
|
41
|
+
if (!isIpcEncodedValueInternal(key, visited) || !isIpcEncodedValueInternal(item, visited)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (value instanceof Set) {
|
|
48
|
+
for (const item of value) {
|
|
49
|
+
if (!isIpcEncodedValueInternal(item, visited)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
if (!isRecord(value)) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
for (const key of Object.keys(value)) {
|
|
59
|
+
if (!isIpcEncodedValueInternal(value[key], visited)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
export function isIpcEncodedValue(value) {
|
|
66
|
+
return isIpcEncodedValueInternal(value, new WeakSet());
|
|
67
|
+
}
|
|
68
|
+
export function isStringValue(value) {
|
|
69
|
+
return Predicate.isString(value);
|
|
70
|
+
}
|
|
71
|
+
export function isNumberValue(value) {
|
|
72
|
+
return Predicate.isNumber(value);
|
|
73
|
+
}
|
|
74
|
+
export function isFunctionValue(value) {
|
|
75
|
+
return Predicate.isFunction(value);
|
|
76
|
+
}
|
|
77
|
+
export function formatUnknown(value) {
|
|
78
|
+
return value instanceof Error ? value.message : String(value);
|
|
79
|
+
}
|
|
80
|
+
export function parseIpcEncodedValue(value) {
|
|
81
|
+
return isIpcEncodedValue(value) ? value : null;
|
|
82
|
+
}
|
|
83
|
+
export function toDiagnosticCause(value) {
|
|
84
|
+
if (value instanceof Error) {
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
const parsed = parseIpcEncodedValue(value);
|
|
88
|
+
return parsed !== null ? parsed : formatUnknown(value);
|
|
89
|
+
}
|
package/dist/contract.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as S from "effect/Schema";
|
|
2
|
-
export type SchemaNoContext = S.
|
|
3
|
-
export declare const NoError:
|
|
2
|
+
export type SchemaNoContext = S.Codec<any, any, never, never>;
|
|
3
|
+
export declare const NoError: S.Never;
|
|
4
4
|
export type NoError = typeof NoError;
|
|
5
5
|
export type ErrorSchema = SchemaNoContext | NoError;
|
|
6
6
|
export declare function isNoErrorSchema(schema: ErrorSchema): schema is NoError;
|
|
@@ -17,7 +17,7 @@ export interface RpcEvent<Payload extends SchemaNoContext, Name extends string =
|
|
|
17
17
|
readonly payload: Payload;
|
|
18
18
|
}
|
|
19
19
|
export declare function event<const Name extends string, Payload extends SchemaNoContext>(name: Name, payload: Payload): RpcEvent<Payload, Name>;
|
|
20
|
-
export declare const exitSchemaFor: <Name extends string, Req extends SchemaNoContext, Res extends SchemaNoContext, Err extends ErrorSchema>(method: RpcMethod<Name, Req, Res, Err>) => S.Exit<Res, Err,
|
|
20
|
+
export declare const exitSchemaFor: <Name extends string, Req extends SchemaNoContext, Res extends SchemaNoContext, Err extends ErrorSchema>(method: RpcMethod<Name, Req, Res, Err>) => S.toCodecJson<S.Exit<Res, Err, S.Defect>>;
|
|
21
21
|
export interface StreamRpcMethod<Name extends string, Req extends SchemaNoContext, Chunk extends SchemaNoContext, Err extends ErrorSchema = NoError> {
|
|
22
22
|
readonly _tag: "StreamRpcMethod";
|
|
23
23
|
readonly name: Name;
|
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAGnC,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAE9D,eAAO,MAAM,OAAO,SAAU,CAAC;AAC/B,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,OAAO,CAAC;AAEpD,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,IAAI,OAAO,CAItE;AAED,MAAM,WAAW,SAAS,CACxB,IAAI,SAAS,MAAM,EACnB,GAAG,SAAS,eAAe,EAC3B,GAAG,SAAS,eAAe,EAC3B,GAAG,SAAS,WAAW,GAAG,OAAO;IAEjC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;CACnB;AAED,wBAAgB,GAAG,CACjB,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,GAAG,SAAS,eAAe,EAC3B,GAAG,SAAS,eAAe,EAC3B,GAAG,SAAS,WAAW,EACvB,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAE5E,wBAAgB,GAAG,CACjB,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,GAAG,SAA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QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAE9C,wBAAgB,cAAc,CAC5B,KAAK,CAAC,OAAO,SAAS,aAAa,CAAC,SAAS,CAAC,EAC9C,KAAK,CAAC,MAAM,SAAS,aAAa,CAAC,QAAQ,CAAC,EAC5C,KAAK,CAAC,aAAa,SAAS,aAAa,CAAC,eAAe,CAAC,EAC1D,KAAK,EAAE;IACP,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC"}
|
package/dist/contract.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as S from "effect/Schema";
|
|
2
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
2
3
|
export const NoError = S.Never;
|
|
3
4
|
export function isNoErrorSchema(schema) {
|
|
4
5
|
// Also match by AST tag so a Never schema from a second copy of the
|
|
5
6
|
// schema package (npm dedup failure) is still treated as NoError.
|
|
6
|
-
return schema === NoError || schema.ast
|
|
7
|
+
return schema === NoError || SchemaAST.isNever(schema.ast);
|
|
7
8
|
}
|
|
8
9
|
export function rpc(name, req, res, err = NoError) {
|
|
9
10
|
return { name, req, res, err };
|
|
@@ -11,11 +12,7 @@ export function rpc(name, req, res, err = NoError) {
|
|
|
11
12
|
export function event(name, payload) {
|
|
12
13
|
return { name, payload };
|
|
13
14
|
}
|
|
14
|
-
export const exitSchemaFor = (method) => S.Exit(
|
|
15
|
-
success: method.res,
|
|
16
|
-
failure: method.err,
|
|
17
|
-
defect: S.Defect,
|
|
18
|
-
});
|
|
15
|
+
export const exitSchemaFor = (method) => S.toCodecJson(S.Exit(method.res, method.err, S.Defect()));
|
|
19
16
|
export function streamRpc(name, req, chunk, err = NoError) {
|
|
20
17
|
return { _tag: "StreamRpcMethod", name, req, chunk, err };
|
|
21
18
|
}
|
|
@@ -63,7 +60,7 @@ export function defineContract(input) {
|
|
|
63
60
|
if (duplicateMethods.length > 0) {
|
|
64
61
|
throw new Error(`Duplicate RPC method name(s): ${duplicateMethods.join(", ")}`);
|
|
65
62
|
}
|
|
66
|
-
const duplicateEvents = collectDuplicates(events.map((
|
|
63
|
+
const duplicateEvents = collectDuplicates(events.map((rpcEvent) => rpcEvent.name));
|
|
67
64
|
if (duplicateEvents.length > 0) {
|
|
68
65
|
throw new Error(`Duplicate RPC event name(s): ${duplicateEvents.join(", ")}`);
|
|
69
66
|
}
|
package/dist/kit.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import type * as
|
|
2
|
+
import type * as Context from "effect/Context";
|
|
3
3
|
import type { AnyEvent, AnyMethod, AnyStreamMethod, RpcContract, RpcEventPayload } from "./contract.ts";
|
|
4
|
-
import { type
|
|
4
|
+
import { type ElectronModuleCandidate } from "./preload-bridge.ts";
|
|
5
|
+
import { type ChannelPrefix, type EventDecodeMode, type EventPublisherDiagnostics, type EventPublisherStats, type EventSubscribe, type EventSubscriber, type EventSubscriberDiagnostics, type IpcMainLike, type Implementations, type OnStreamFrame, type RendererWindowLike, type RpcClient, type RpcClientDiagnostics, type RpcEndpoint, type RpcEndpointDiagnostics, type RpcEventPublisher, type RpcInvoke, type RpcResponseDecodeMode, type StreamImplementations, type StreamRpcClient, type StreamBufferOptions } from "./types.ts";
|
|
5
6
|
/**
|
|
6
7
|
* Narrow surface the preload script exposes to the renderer.
|
|
7
8
|
*
|
|
@@ -36,7 +37,7 @@ export type IpcKitOptions<C extends RpcContract<readonly AnyMethod[], readonly A
|
|
|
36
37
|
type IpcMainOptions<C extends RpcContract<readonly AnyMethod[], readonly AnyEvent[], readonly AnyStreamMethod[]>, R> = {
|
|
37
38
|
readonly ipcMain: IpcMainLike;
|
|
38
39
|
readonly handlers: Implementations<C, R>;
|
|
39
|
-
readonly
|
|
40
|
+
readonly context: Context.Context<R>;
|
|
40
41
|
readonly getWindows: () => ReadonlyArray<RendererWindowLike>;
|
|
41
42
|
readonly maxQueueSize?: number;
|
|
42
43
|
readonly streamHandlers?: StreamImplementations<C, R>;
|
|
@@ -47,7 +48,7 @@ type IpcMainOptions<C extends RpcContract<readonly AnyMethod[], readonly AnyEven
|
|
|
47
48
|
};
|
|
48
49
|
type IpcPreloadOptions = {
|
|
49
50
|
readonly global?: string;
|
|
50
|
-
readonly electronModule?:
|
|
51
|
+
readonly electronModule?: ElectronModuleCandidate;
|
|
51
52
|
};
|
|
52
53
|
type IpcRendererOptions = {
|
|
53
54
|
readonly diagnostics?: {
|
|
@@ -64,10 +65,7 @@ export type IpcMainHandle<C extends RpcContract<readonly AnyMethod[], readonly A
|
|
|
64
65
|
readonly dispose: () => void;
|
|
65
66
|
readonly isRunning: () => boolean;
|
|
66
67
|
readonly publish: <E extends C["events"][number]>(event: E, payload: RpcEventPayload<E>) => Effect.Effect<void, never>;
|
|
67
|
-
readonly stats: () =>
|
|
68
|
-
readonly queued: number;
|
|
69
|
-
readonly dropped: number;
|
|
70
|
-
};
|
|
68
|
+
readonly stats: () => EventPublisherStats;
|
|
71
69
|
};
|
|
72
70
|
export type IpcKit<C extends RpcContract<readonly AnyMethod[], readonly AnyEvent[], readonly AnyStreamMethod[]>> = {
|
|
73
71
|
readonly contract: C;
|
package/dist/kit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,E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MAAM,EAAE,aAAa,CAAC,CAAC,GAClE,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAgMrD"}
|
package/dist/kit.js
CHANGED
|
@@ -7,11 +7,16 @@ function loadElectronModule(electronModule) {
|
|
|
7
7
|
if (electronModule !== undefined) {
|
|
8
8
|
return electronModule;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
11
|
return require("electron");
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
catch (cause) {
|
|
14
|
+
if (!(cause instanceof ReferenceError)) {
|
|
15
|
+
throw cause;
|
|
16
|
+
}
|
|
17
|
+
throw new Error("ipc.preload() could not load Electron synchronously. " +
|
|
18
|
+
"In ESM preload files, pass it explicitly: ipc.preload({ electronModule: electron }).", { cause });
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
export function createIpcKit(options) {
|
|
17
22
|
const normalizeStreamBuffer = (buffer) => {
|
|
@@ -35,7 +40,7 @@ export function createIpcKit(options) {
|
|
|
35
40
|
const streamBuffer = normalizeStreamBuffer(options.streamBuffer);
|
|
36
41
|
const main = (mainOptions) => {
|
|
37
42
|
const endpoint = createRpcEndpoint(contract, mainOptions.ipcMain, mainOptions.handlers, {
|
|
38
|
-
|
|
43
|
+
context: mainOptions.context,
|
|
39
44
|
channelPrefix,
|
|
40
45
|
diagnostics: mainOptions.diagnostics?.rpc,
|
|
41
46
|
streamHandlers: mainOptions.streamHandlers,
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EAQZ,MAAM,eAAe,CAAC;AAavB,OAAO,EAGL,KAAK,QAAQ,EACb,KA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