@vitejs/devtools-rpc 0.0.0-alpha.19 → 0.0.0-alpha.20
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/index.d.mts +7 -7
- package/dist/index.mjs +6 -2
- package/dist/presets/index.d.mts +12 -1
- package/dist/presets/index.mjs +8 -1
- package/dist/presets/ws/client.d.mts +3 -7
- package/dist/presets/ws/client.mjs +1 -1
- package/dist/presets/ws/server.d.mts +2 -2
- package/dist/presets/ws/server.mjs +251 -249
- package/package.json +3 -3
- package/dist/index-SH_k2HUP.d.mts +0 -13
- package/dist/presets-DpriP7xc.mjs +0 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { BirpcGroup, BirpcOptions, BirpcReturn, EventOptions } from "birpc";
|
|
2
2
|
|
|
3
3
|
//#region src/client.d.ts
|
|
4
|
-
declare function createRpcClient<ServerFunctions = Record<string, never>, ClientFunctions extends object = Record<string, never>>(functions: ClientFunctions, options: {
|
|
5
|
-
preset: BirpcOptions<ServerFunctions>;
|
|
6
|
-
rpcOptions?: Partial<BirpcOptions<ServerFunctions>>;
|
|
7
|
-
}): BirpcReturn<ServerFunctions, ClientFunctions>;
|
|
4
|
+
declare function createRpcClient<ServerFunctions extends object = Record<string, never>, ClientFunctions extends object = Record<string, never>>(functions: ClientFunctions, options: {
|
|
5
|
+
preset: BirpcOptions<ServerFunctions, ClientFunctions, false>;
|
|
6
|
+
rpcOptions?: Partial<BirpcOptions<ServerFunctions, ClientFunctions, boolean>>;
|
|
7
|
+
}): BirpcReturn<ServerFunctions, ClientFunctions, false>;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/server.d.ts
|
|
10
10
|
declare function createRpcServer<ClientFunctions extends object = Record<string, never>, ServerFunctions extends object = Record<string, never>>(functions: ServerFunctions, options: {
|
|
11
|
-
preset: (rpc: BirpcGroup<ClientFunctions, ServerFunctions>) => void;
|
|
12
|
-
rpcOptions?: EventOptions<ClientFunctions>;
|
|
13
|
-
}): BirpcGroup<ClientFunctions, ServerFunctions>;
|
|
11
|
+
preset: (rpc: BirpcGroup<ClientFunctions, ServerFunctions, false>) => void;
|
|
12
|
+
rpcOptions?: EventOptions<ClientFunctions, ServerFunctions, false>;
|
|
13
|
+
}): BirpcGroup<ClientFunctions, ServerFunctions, false>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { createRpcClient, createRpcServer };
|
package/dist/index.mjs
CHANGED
|
@@ -6,14 +6,18 @@ function createRpcClient(functions, options) {
|
|
|
6
6
|
return createBirpc(functions, {
|
|
7
7
|
...preset,
|
|
8
8
|
timeout: -1,
|
|
9
|
-
...rpcOptions
|
|
9
|
+
...rpcOptions,
|
|
10
|
+
proxify: false
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
//#endregion
|
|
14
15
|
//#region src/server.ts
|
|
15
16
|
function createRpcServer(functions, options) {
|
|
16
|
-
const rpc = createBirpcGroup(functions, [],
|
|
17
|
+
const rpc = createBirpcGroup(functions, [], {
|
|
18
|
+
...options?.rpcOptions,
|
|
19
|
+
proxify: false
|
|
20
|
+
});
|
|
17
21
|
options?.preset(rpc);
|
|
18
22
|
return rpc;
|
|
19
23
|
}
|
package/dist/presets/index.d.mts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BirpcGroup, BirpcOptions, ChannelOptions } from "birpc";
|
|
2
|
+
|
|
3
|
+
//#region src/presets/index.d.ts
|
|
4
|
+
type RpcServerPresetReturnType = <ClientFunctions extends object, ServerFunctions extends object>(rpc: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: Pick<BirpcOptions<ClientFunctions, ServerFunctions, false>, 'serialize' | 'deserialize'>) => void;
|
|
5
|
+
type RpcServerPresetBasicType = (...args: any[]) => RpcServerPresetReturnType;
|
|
6
|
+
type RpcServerPreset<T extends RpcServerPresetBasicType> = (...args: Parameters<T>) => RpcServerPresetReturnType;
|
|
7
|
+
declare function defineRpcServerPreset<T extends RpcServerPresetBasicType>(preset: T): RpcServerPreset<T>;
|
|
8
|
+
type RpcClientPresetReturnType = Omit<ChannelOptions, 'bind'>;
|
|
9
|
+
type RpcClientPresetBasicType = (...args: any[]) => RpcClientPresetReturnType;
|
|
10
|
+
type RpcClientPreset<T extends RpcClientPresetBasicType> = (...args: Parameters<T>) => RpcClientPresetReturnType;
|
|
11
|
+
declare function defineRpcClientPreset<T extends RpcClientPresetBasicType>(preset: T): RpcClientPreset<T>;
|
|
12
|
+
//#endregion
|
|
2
13
|
export { RpcClientPreset, RpcClientPresetBasicType, RpcClientPresetReturnType, RpcServerPreset, RpcServerPresetBasicType, RpcServerPresetReturnType, defineRpcClientPreset, defineRpcServerPreset };
|
package/dist/presets/index.mjs
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/presets/index.ts
|
|
2
|
+
function defineRpcServerPreset(preset) {
|
|
3
|
+
return preset;
|
|
4
|
+
}
|
|
5
|
+
function defineRpcClientPreset(preset) {
|
|
6
|
+
return preset;
|
|
7
|
+
}
|
|
2
8
|
|
|
9
|
+
//#endregion
|
|
3
10
|
export { defineRpcClientPreset, defineRpcServerPreset };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RpcClientPreset } from "../index.mjs";
|
|
2
|
+
import { ChannelOptions } from "birpc";
|
|
2
3
|
|
|
3
4
|
//#region src/presets/ws/client.d.ts
|
|
4
5
|
interface WebSocketRpcClientOptions {
|
|
@@ -7,11 +8,6 @@ interface WebSocketRpcClientOptions {
|
|
|
7
8
|
onError?: (e: Error) => void;
|
|
8
9
|
onDisconnected?: (e: CloseEvent) => void;
|
|
9
10
|
}
|
|
10
|
-
declare const createWsRpcPreset: RpcClientPreset<(options: WebSocketRpcClientOptions) =>
|
|
11
|
-
on: (handler: (data: string) => void) => void;
|
|
12
|
-
post: (data: string) => void;
|
|
13
|
-
serialize: (obj: any) => string;
|
|
14
|
-
deserialize: (str: string) => unknown;
|
|
15
|
-
}>;
|
|
11
|
+
declare const createWsRpcPreset: RpcClientPreset<(options: WebSocketRpcClientOptions) => ChannelOptions>;
|
|
16
12
|
//#endregion
|
|
17
13
|
export { WebSocketRpcClientOptions, createWsRpcPreset };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RpcServerPreset } from "../index.mjs";
|
|
2
2
|
import { BirpcGroup, BirpcOptions } from "birpc";
|
|
3
3
|
import { WebSocket } from "ws";
|
|
4
4
|
|
|
@@ -8,6 +8,6 @@ interface WebSocketRpcServerOptions {
|
|
|
8
8
|
onConnected?: (ws: WebSocket) => void;
|
|
9
9
|
onDisconnected?: (ws: WebSocket) => void;
|
|
10
10
|
}
|
|
11
|
-
declare const createWsRpcPreset: RpcServerPreset<(options: WebSocketRpcServerOptions) => <ClientFunctions, ServerFunctions>(rpc: BirpcGroup<ClientFunctions, ServerFunctions>, options?: Pick<BirpcOptions<ClientFunctions>, 'serialize' | 'deserialize'>) => void>;
|
|
11
|
+
declare const createWsRpcPreset: RpcServerPreset<(options: WebSocketRpcServerOptions) => <ClientFunctions extends object, ServerFunctions extends object>(rpc: BirpcGroup<ClientFunctions, ServerFunctions, false>, options?: Pick<BirpcOptions<ClientFunctions, ServerFunctions, false>, 'serialize' | 'deserialize'>) => void>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { WebSocketRpcServerOptions, createWsRpcPreset };
|