bunite-core 0.5.0 → 0.6.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/package.json +1 -1
- package/src/shared/rpc.ts +4 -13
- package/src/shared/webRpcHandler.ts +1 -3
package/package.json
CHANGED
package/src/shared/rpc.ts
CHANGED
|
@@ -374,9 +374,7 @@ function defineSideRpc<
|
|
|
374
374
|
Schema extends BuniteRpcSchema,
|
|
375
375
|
Side extends "bun" | "webview"
|
|
376
376
|
>(
|
|
377
|
-
config: BuniteRpcConfig<Schema, Side>
|
|
378
|
-
extraRequestHandlers?: Record<string, (...args: any[]) => unknown>;
|
|
379
|
-
}
|
|
377
|
+
config: BuniteRpcConfig<Schema, Side>
|
|
380
378
|
) {
|
|
381
379
|
type RemoteSide = Side extends "bun" ? "webview" : "bun";
|
|
382
380
|
type LocalSchema = {
|
|
@@ -390,10 +388,7 @@ function defineSideRpc<
|
|
|
390
388
|
|
|
391
389
|
const rpc = createRpc<LocalSchema, RemoteSchema>({
|
|
392
390
|
maxRequestTime: config.maxRequestTime,
|
|
393
|
-
requestHandler:
|
|
394
|
-
...(config.handlers.requests ?? {}),
|
|
395
|
-
...(config.extraRequestHandlers ?? {})
|
|
396
|
-
} as RpcRequestHandler<LocalSchema["requests"]>,
|
|
391
|
+
requestHandler: config.handlers.requests,
|
|
397
392
|
transport: {
|
|
398
393
|
registerHandler: () => {}
|
|
399
394
|
}
|
|
@@ -417,17 +412,13 @@ function defineSideRpc<
|
|
|
417
412
|
}
|
|
418
413
|
|
|
419
414
|
export function defineBunRpc<Schema extends BuniteRpcSchema>(
|
|
420
|
-
config: BuniteRpcConfig<Schema, "bun">
|
|
421
|
-
extraRequestHandlers?: Record<string, (...args: any[]) => unknown>;
|
|
422
|
-
}
|
|
415
|
+
config: BuniteRpcConfig<Schema, "bun">
|
|
423
416
|
) {
|
|
424
417
|
return defineSideRpc<Schema, "bun">(config);
|
|
425
418
|
}
|
|
426
419
|
|
|
427
420
|
export function defineWebviewRpc<Schema extends BuniteRpcSchema>(
|
|
428
|
-
config: BuniteRpcConfig<Schema, "webview">
|
|
429
|
-
extraRequestHandlers?: Record<string, (...args: any[]) => unknown>;
|
|
430
|
-
}
|
|
421
|
+
config: BuniteRpcConfig<Schema, "webview">
|
|
431
422
|
) {
|
|
432
423
|
return defineSideRpc<Schema, "webview">(config);
|
|
433
424
|
}
|
|
@@ -12,9 +12,7 @@ export type WebRpcClient<Schema extends BuniteRpcSchema = BuniteRpcSchema> = {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export function createWebRpcHandler<Schema extends BuniteRpcSchema>(
|
|
15
|
-
config: BuniteRpcConfig<Schema, "bun">
|
|
16
|
-
extraRequestHandlers?: Record<string, (...args: any[]) => unknown>;
|
|
17
|
-
}
|
|
15
|
+
config: BuniteRpcConfig<Schema, "bun">
|
|
18
16
|
) {
|
|
19
17
|
type Entry = { client: WebRpcClient<Schema>; receive: (raw: ArrayBuffer | Uint8Array) => void };
|
|
20
18
|
|