electron-effect-rpc 0.1.1 → 0.3.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/dist/renderer.js CHANGED
@@ -1,81 +1,185 @@
1
1
  import * as S from "@effect/schema/Schema";
2
2
  import { Cause, Exit } from "effect";
3
- import { exitSchemaFor, } from "./contract.js";
3
+ import { exitSchemaFor, isNoErrorSchema, } from "./contract.js";
4
+ import { formatUnknown, parseRpcResponseEnvelope, safelyCall } from "./protocol.js";
4
5
  import { RpcDefectError, } from "./types.js";
5
- const formatCause = (cause) => cause instanceof Error ? cause.message : String(cause);
6
- const requireInvoke = (options) => {
6
+ function requireInvoke(options) {
7
7
  if (!options?.invoke) {
8
8
  throw new Error("RpcClientOptions.invoke is required.");
9
9
  }
10
10
  return options.invoke;
11
- };
12
- const requireSubscribe = (options) => {
11
+ }
12
+ function requireSubscribe(options) {
13
13
  if (!options?.subscribe) {
14
14
  throw new Error("EventSubscriberOptions.subscribe is required.");
15
15
  }
16
16
  return options.subscribe;
17
- };
18
- export const createRpcClient = (contract, options) => {
17
+ }
18
+ function decodeLegacyExit(method, raw) {
19
+ const exitSchema = exitSchemaFor(method);
20
+ const decodeExit = S.decodeUnknownSync(exitSchema);
21
+ const exit = decodeExit(raw);
22
+ if (Exit.isSuccess(exit)) {
23
+ return exit.value;
24
+ }
25
+ const failureOption = Cause.failureOption(exit.cause);
26
+ if (failureOption._tag === "Some") {
27
+ throw failureOption.value;
28
+ }
29
+ const defectOption = Cause.dieOption(exit.cause);
30
+ if (defectOption._tag === "Some") {
31
+ const defect = defectOption.value;
32
+ if (defect instanceof Error) {
33
+ throw new RpcDefectError(defect.message, defect);
34
+ }
35
+ throw new RpcDefectError(String(defect), defect);
36
+ }
37
+ throw new RpcDefectError("RPC call was interrupted or failed unexpectedly", exit.cause);
38
+ }
39
+ export function createRpcClient(contract, options) {
19
40
  const invoke = requireInvoke(options);
41
+ const diagnostics = options?.diagnostics;
42
+ const decodeMode = options?.rpcDecodeMode ?? "envelope";
20
43
  const call = async (method, input) => {
21
44
  let encoded;
22
45
  try {
23
46
  encoded = S.encodeSync(method.req)(input);
24
47
  }
25
48
  catch (cause) {
26
- throw new Error(`RPC ${method.name} request encoding failed: ${formatCause(cause)}`);
49
+ safelyCall(diagnostics?.onDecodeFailure, {
50
+ scope: "rpc-request",
51
+ name: method.name,
52
+ payload: input,
53
+ cause,
54
+ });
55
+ throw new Error(`RPC ${method.name} request encoding failed: ${formatUnknown(cause)}`);
27
56
  }
28
- const raw = await invoke(method.name, encoded);
29
- const exitSchema = exitSchemaFor(method);
30
- const decodeExit = S.decodeUnknownSync(exitSchema);
31
- let exit;
57
+ let raw;
32
58
  try {
33
- exit = decodeExit(raw);
59
+ raw = await invoke(method.name, encoded);
34
60
  }
35
61
  catch (cause) {
36
- throw new Error(`RPC ${method.name} response decoding failed: ${formatCause(cause)}`);
62
+ safelyCall(diagnostics?.onProtocolError, {
63
+ method: method.name,
64
+ response: undefined,
65
+ cause,
66
+ });
67
+ throw new RpcDefectError(`RPC ${method.name} invoke failed: ${formatUnknown(cause)}`, cause);
37
68
  }
38
- if (Exit.isSuccess(exit)) {
39
- return exit.value;
40
- }
41
- const cause = exit.cause;
42
- const failureOption = Cause.failureOption(cause);
43
- if (failureOption._tag === "Some") {
44
- throw failureOption.value;
69
+ const envelope = parseRpcResponseEnvelope(raw);
70
+ if (envelope) {
71
+ switch (envelope.type) {
72
+ case "success":
73
+ try {
74
+ return S.decodeUnknownSync(method.res)(envelope.data);
75
+ }
76
+ catch (cause) {
77
+ safelyCall(diagnostics?.onDecodeFailure, {
78
+ scope: "rpc-response",
79
+ name: method.name,
80
+ payload: envelope.data,
81
+ cause,
82
+ });
83
+ throw new Error(`RPC ${method.name} success payload decoding failed: ${formatUnknown(cause)}`);
84
+ }
85
+ case "failure":
86
+ if (isNoErrorSchema(method.err)) {
87
+ throw new RpcDefectError(`RPC ${method.name} received a failure for a method that declares NoError`, envelope.error);
88
+ }
89
+ let decodedError;
90
+ try {
91
+ decodedError = S.decodeUnknownSync(method.err)(envelope.error.data);
92
+ }
93
+ catch (cause) {
94
+ safelyCall(diagnostics?.onDecodeFailure, {
95
+ scope: "rpc-response",
96
+ name: method.name,
97
+ payload: envelope.error,
98
+ cause,
99
+ });
100
+ throw new Error(`RPC ${method.name} failure payload decoding failed: ${formatUnknown(cause)}`);
101
+ }
102
+ throw decodedError;
103
+ case "defect":
104
+ throw new RpcDefectError(envelope.message, envelope.cause);
105
+ }
45
106
  }
46
- const defectOption = Cause.dieOption(cause);
47
- if (defectOption._tag === "Some") {
48
- const defect = defectOption.value;
49
- if (defect instanceof Error) {
50
- throw new RpcDefectError(defect.message, defect);
107
+ if (decodeMode === "dual") {
108
+ try {
109
+ return decodeLegacyExit(method, raw);
110
+ }
111
+ catch (cause) {
112
+ safelyCall(diagnostics?.onProtocolError, {
113
+ method: method.name,
114
+ response: raw,
115
+ cause,
116
+ });
117
+ throw cause;
51
118
  }
52
- throw new RpcDefectError(String(defect), defect);
53
119
  }
54
- throw new RpcDefectError("RPC call was interrupted or failed unexpectedly", cause);
120
+ const cause = new Error(`RPC ${method.name} response was not a valid envelope.`);
121
+ safelyCall(diagnostics?.onProtocolError, {
122
+ method: method.name,
123
+ response: raw,
124
+ cause,
125
+ });
126
+ throw cause;
55
127
  };
56
128
  const client = Object.create(null);
57
129
  const clientRecord = client;
58
- contract.methods.forEach((method) => {
59
- const caller = (input) => {
60
- const payload = input ?? S.decodeUnknownSync(method.req)({});
130
+ for (const method of contract.methods) {
131
+ const decodeDefaultInput = S.decodeUnknownSync(method.req);
132
+ const caller = (...args) => {
133
+ const payload = args.length === 0
134
+ ? decodeDefaultInput({})
135
+ : args[0];
61
136
  return call(method, payload);
62
137
  };
63
138
  clientRecord[method.name] = caller;
64
- });
139
+ }
65
140
  return client;
66
- };
67
- export const createEventSubscriber = (contract, options) => {
141
+ }
142
+ function reportDecodeFailure(mode, eventName, payload, cause, options) {
143
+ safelyCall(options?.diagnostics?.onDecodeFailure, {
144
+ scope: "event-payload",
145
+ name: eventName,
146
+ payload,
147
+ cause,
148
+ });
149
+ if (mode === "strict") {
150
+ throw cause;
151
+ }
152
+ }
153
+ export function createEventSubscriber(contract, options) {
68
154
  const subscribe = requireSubscribe(options);
155
+ const mode = options?.decodeMode ?? "safe";
69
156
  const eventMap = new Map();
157
+ const subscriptions = new Set();
70
158
  for (const event of contract.events) {
71
159
  eventMap.set(event.name, event);
72
160
  }
161
+ function registerUnsubscribe(unsubscribe) {
162
+ subscriptions.add(unsubscribe);
163
+ return () => {
164
+ if (subscriptions.delete(unsubscribe)) {
165
+ unsubscribe();
166
+ }
167
+ };
168
+ }
73
169
  const subscribeEvent = (event, handler) => {
74
170
  const decoder = S.decodeUnknownSync(event.payload);
75
- return subscribe(event.name, (payload) => {
76
- const decoded = decoder(payload);
171
+ const unsubscribe = subscribe(event.name, (payload) => {
172
+ let decoded;
173
+ try {
174
+ decoded = decoder(payload);
175
+ }
176
+ catch (cause) {
177
+ reportDecodeFailure(mode, event.name, payload, cause, options);
178
+ return;
179
+ }
77
180
  handler(decoded);
78
181
  });
182
+ return registerUnsubscribe(unsubscribe);
79
183
  };
80
184
  const subscribeByName = (name, handler) => {
81
185
  const event = eventMap.get(name);
@@ -83,11 +187,38 @@ export const createEventSubscriber = (contract, options) => {
83
187
  throw new Error(`Unknown event: ${name}`);
84
188
  }
85
189
  const decoder = S.decodeUnknownSync(event.payload);
86
- return subscribe(name, (payload) => handler(decoder(payload)));
190
+ const unsubscribe = subscribe(name, (payload) => {
191
+ let decoded;
192
+ try {
193
+ decoded = decoder(payload);
194
+ }
195
+ catch (cause) {
196
+ reportDecodeFailure(mode, name, payload, cause, options);
197
+ return;
198
+ }
199
+ handler(decoded);
200
+ });
201
+ return registerUnsubscribe(unsubscribe);
87
202
  };
203
+ function dispose() {
204
+ let firstError;
205
+ for (const unsubscribe of subscriptions) {
206
+ try {
207
+ unsubscribe();
208
+ }
209
+ catch (cause) {
210
+ firstError ??= cause;
211
+ }
212
+ }
213
+ subscriptions.clear();
214
+ if (firstError !== undefined) {
215
+ throw firstError;
216
+ }
217
+ }
88
218
  return {
89
219
  subscribe: subscribeEvent,
90
220
  subscribeByName,
221
+ dispose,
91
222
  };
92
- };
223
+ }
93
224
  export { RpcDefectError } from "./types.js";
package/dist/types.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import type * as Effect from "effect/Effect";
2
2
  import type * as Runtime from "effect/Runtime";
3
- import type { BrowserWindow } from "electron";
4
3
  import type { AnyEvent, AnyMethod, ExtractMethod, RpcContract, RpcError, RpcEventPayload, RpcInput, RpcOutput } from "./contract.ts";
5
4
  export type { AnyEvent, AnyMethod, ErrorSchema, ExtractMethod, RpcContract, RpcError, RpcEvent, RpcEventPayload, RpcInput, RpcMethod, RpcOutput, SchemaNoContext, } from "./contract.ts";
6
5
  export type Implementations<C extends RpcContract<readonly AnyMethod[], readonly AnyEvent[]>, R = never> = {
7
6
  readonly [Name in C["methods"][number]["name"]]: (input: RpcInput<ExtractMethod<C["methods"], Name>>) => Effect.Effect<RpcOutput<ExtractMethod<C["methods"], Name>>, RpcError<ExtractMethod<C["methods"], Name>>, R>;
8
7
  };
9
- type IsEmptyObject<T> = keyof T extends never ? true : false;
8
+ type IsEmptyObject<T> = T extends object ? keyof T extends never ? true : false : false;
10
9
  export type RpcCaller<M extends AnyMethod> = IsEmptyObject<RpcInput<M>> extends true ? () => Promise<RpcOutput<M>> : (input: RpcInput<M>) => Promise<RpcOutput<M>>;
11
10
  export type RpcClient<C extends RpcContract<readonly AnyMethod[], readonly AnyEvent[]>> = {
12
11
  readonly [Name in C["methods"][number]["name"]]: RpcCaller<ExtractMethod<C["methods"], Name>>;
@@ -21,32 +20,106 @@ export type ChannelPrefix = {
21
20
  readonly event: string;
22
21
  };
23
22
  export declare const defaultChannelPrefix: ChannelPrefix;
24
- export type IpcMainLike = {
25
- readonly handle: (channel: string, listener: (event: unknown, payload: unknown) => unknown) => unknown;
23
+ export type DecodeFailureScope = "rpc-request" | "rpc-response" | "event-payload";
24
+ export type DecodeFailureContext = {
25
+ readonly scope: DecodeFailureScope;
26
+ readonly name: string;
27
+ readonly payload: unknown;
28
+ readonly cause: unknown;
29
+ };
30
+ export type ProtocolErrorContext = {
31
+ readonly method: string;
32
+ readonly response: unknown;
33
+ readonly cause: unknown;
34
+ };
35
+ export type DispatchFailureContext = {
36
+ readonly event: string;
37
+ readonly payload: unknown;
38
+ readonly cause: unknown;
39
+ };
40
+ export type DroppedEventReason = "queue_full" | "encoding_failed" | "window_unavailable" | "dispatch_failed";
41
+ export type DroppedEventContext = {
42
+ readonly event: string;
43
+ readonly payload: unknown;
44
+ readonly reason: DroppedEventReason;
45
+ readonly queued: number;
46
+ readonly dropped: number;
26
47
  };
27
48
  export type RpcInvoke = (method: string, payload: unknown) => Promise<unknown>;
28
- /** Provide a Runtime when handlers require services (R). */
29
- export type RpcServerOptions<R = never> = {
30
- readonly channelPrefix?: ChannelPrefix;
31
- readonly runtime?: Runtime.Runtime<R>;
49
+ export type RpcResponseDecodeMode = "envelope" | "dual";
50
+ export type RpcClientDiagnostics = {
51
+ readonly onDecodeFailure?: (context: DecodeFailureContext) => void;
52
+ readonly onProtocolError?: (context: ProtocolErrorContext) => void;
32
53
  };
33
54
  export type RpcClientOptions = {
34
- readonly invoke?: RpcInvoke;
35
- readonly channelPrefix?: ChannelPrefix;
55
+ readonly invoke: RpcInvoke;
56
+ readonly diagnostics?: RpcClientDiagnostics;
57
+ readonly rpcDecodeMode?: RpcResponseDecodeMode;
36
58
  };
37
- export type EventBusOptions = {
59
+ export type RpcEndpointDiagnostics = {
60
+ readonly onDecodeFailure?: (context: DecodeFailureContext) => void;
61
+ readonly onProtocolError?: (context: ProtocolErrorContext) => void;
62
+ };
63
+ export type IpcMainLike = {
64
+ readonly handle: (channel: string, listener: (event: unknown, payload: unknown) => unknown) => unknown;
65
+ readonly removeHandler: (channel: string) => unknown;
66
+ };
67
+ export interface RpcEndpoint {
68
+ readonly start: () => void;
69
+ readonly stop: () => void;
70
+ readonly dispose: () => void;
71
+ readonly isRunning: () => boolean;
72
+ }
73
+ /**
74
+ * Runtime used to execute handler effects.
75
+ */
76
+ export type RpcEndpointOptions<R = never> = {
38
77
  readonly channelPrefix?: ChannelPrefix;
39
- readonly getWindow: () => BrowserWindow | null;
78
+ readonly runtime: Runtime.Runtime<R>;
79
+ readonly diagnostics?: RpcEndpointDiagnostics;
40
80
  };
41
- export type EventSubscriberOptions = {
81
+ export type EventPublisherDiagnostics = {
82
+ readonly onDecodeFailure?: (context: DecodeFailureContext) => void;
83
+ readonly onDispatchFailure?: (context: DispatchFailureContext) => void;
84
+ readonly onDroppedEvent?: (context: DroppedEventContext) => void;
85
+ };
86
+ export type RendererWindowLike = {
87
+ readonly isDestroyed: () => boolean;
88
+ readonly webContents: {
89
+ readonly send: (channel: string, payload: unknown) => void;
90
+ };
91
+ };
92
+ export type EventPublisherOptions = {
42
93
  readonly channelPrefix?: ChannelPrefix;
43
- readonly subscribe?: (name: string, handler: (payload: unknown) => void) => () => void;
94
+ readonly getWindow: () => RendererWindowLike | null;
95
+ readonly maxQueueSize?: number;
96
+ readonly diagnostics?: EventPublisherDiagnostics;
44
97
  };
45
- export interface RpcEventBus<C extends RpcContract<readonly AnyMethod[], readonly AnyEvent[]>> {
46
- readonly emit: <E extends C["events"][number]>(event: E, payload: RpcEventPayload<E>) => Effect.Effect<void, never>;
98
+ export interface RpcEventPublisher<C extends RpcContract<readonly AnyMethod[], readonly AnyEvent[]>> {
99
+ readonly publish: <E extends C["events"][number]>(event: E, payload: RpcEventPayload<E>) => Effect.Effect<void, never>;
100
+ readonly start: () => void;
101
+ readonly stop: () => void;
102
+ readonly dispose: () => void;
103
+ readonly isRunning: () => boolean;
104
+ readonly stats: () => {
105
+ readonly queued: number;
106
+ readonly dropped: number;
107
+ };
47
108
  }
109
+ export type EventDecodeMode = "safe" | "strict";
110
+ export type EventSubscribe = (name: string, handler: (payload: unknown) => void) => () => void;
111
+ export type EventSubscriberDiagnostics = {
112
+ readonly onDecodeFailure?: (context: DecodeFailureContext) => void;
113
+ };
114
+ export type EventSubscriberOptions = {
115
+ readonly subscribe: EventSubscribe;
116
+ readonly decodeMode?: EventDecodeMode;
117
+ readonly diagnostics?: EventSubscriberDiagnostics;
118
+ };
48
119
  export interface EventSubscriber<C extends RpcContract<readonly AnyMethod[], readonly AnyEvent[]>> {
49
120
  readonly subscribe: <E extends C["events"][number]>(event: E, handler: (payload: RpcEventPayload<E>) => void) => () => void;
50
- readonly subscribeByName: (name: C["events"][number]["name"], handler: (payload: unknown) => void) => () => void;
121
+ readonly subscribeByName: (name: string, handler: (payload: unknown) => void) => () => void;
122
+ readonly dispose: () => void;
51
123
  }
124
+ export type { IpcBridge, IpcBridgeGlobal, IpcKit, IpcKitOptions, IpcMainHandle, } from "./kit.ts";
52
125
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EAET,aAAa,EACb,WAAW,EACX,QAAQ,EAER,eAAe,EACf,QAAQ,EAER,SAAS,EAEV,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,eAAe,CACzB,CAAC,SAAS,WAAW,CAAC,SAAS,SAAS,EAAE,EAAE,SAAS,QAAQ,EAAE,CAAC,EAChE,CAA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AAC,SAAS,SAAS,EAAE,EAAE,SAAS,QAAQ,EAAE,CAAC;IAEhE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAChD,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,KAC3C,MAAM,IAAI,CAAC;IAChB,QAAQ,CAAC,eAAe,EAAE,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAChC,MAAM,IAAI,CAAC;IAChB,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,YAAY,EACV,SAAS,EACT,eAAe,EACf,MAAM,EACN,aAAa,EACb,aAAa,GACd,MAAM,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "electron-effect-rpc",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "Typed IPC RPC for Electron, built on Effect and @effect/schema",
5
5
  "type": "module",
6
6
  "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
7
11
  "./main": {
8
12
  "types": "./dist/main.d.ts",
9
13
  "default": "./dist/main.js"
@@ -35,6 +39,12 @@
35
39
  "scripts": {
36
40
  "build": "tsc",
37
41
  "prepublishOnly": "bun run build",
42
+ "test:unit": "bun test",
43
+ "test:types": "bun run typecheck && bunx tsc -p tsconfig.type-tests.json --noEmit",
44
+ "test:packaging": "bash ./scripts/run-packaging-checks.sh",
45
+ "test:integration": "bun test __tests__/integration.test.ts",
46
+ "test:stress": "bun test __tests__/stress.test.ts",
47
+ "test:full": "bun run test:unit && bun run test:types && bun run test:packaging && bun run test:integration && bun run test:stress",
38
48
  "test": "bun test",
39
49
  "typecheck": "tsc --noEmit"
40
50
  },