@orpc/server 0.0.0-next.fd6982a → 0.0.0-next.fe5c63f
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/README.md +6 -8
- package/dist/adapters/aws-lambda/index.d.mts +7 -6
- package/dist/adapters/aws-lambda/index.d.ts +7 -6
- package/dist/adapters/aws-lambda/index.mjs +6 -6
- package/dist/adapters/bun-ws/index.d.mts +12 -11
- package/dist/adapters/bun-ws/index.d.ts +12 -11
- package/dist/adapters/bun-ws/index.mjs +16 -20
- package/dist/adapters/crossws/index.d.mts +8 -5
- package/dist/adapters/crossws/index.d.ts +8 -5
- package/dist/adapters/crossws/index.mjs +13 -17
- package/dist/adapters/fetch/index.d.mts +5 -4
- package/dist/adapters/fetch/index.d.ts +5 -4
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/message-port/index.d.mts +11 -8
- package/dist/adapters/message-port/index.d.ts +11 -8
- package/dist/adapters/message-port/index.mjs +16 -16
- package/dist/adapters/node/index.d.mts +5 -4
- package/dist/adapters/node/index.d.ts +5 -4
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +8 -13
- package/dist/adapters/standard/index.d.ts +8 -13
- package/dist/adapters/standard/index.mjs +3 -2
- package/dist/adapters/standard-peer/index.d.mts +14 -0
- package/dist/adapters/standard-peer/index.d.ts +14 -0
- package/dist/adapters/standard-peer/index.mjs +7 -0
- package/dist/adapters/websocket/index.d.mts +36 -9
- package/dist/adapters/websocket/index.d.ts +36 -9
- package/dist/adapters/websocket/index.mjs +51 -20
- package/dist/adapters/ws/index.d.mts +11 -8
- package/dist/adapters/ws/index.d.ts +11 -8
- package/dist/adapters/ws/index.mjs +15 -14
- package/dist/hibernation/index.d.mts +44 -0
- package/dist/hibernation/index.d.ts +44 -0
- package/dist/hibernation/index.mjs +65 -0
- package/dist/index.d.mts +21 -47
- package/dist/index.d.ts +21 -47
- package/dist/index.mjs +22 -8
- package/dist/plugins/index.d.mts +4 -4
- package/dist/plugins/index.d.ts +4 -4
- package/dist/plugins/index.mjs +14 -6
- package/dist/shared/server.C6Q5sqYw.mjs +20 -0
- package/dist/shared/server.CC8z0B3U.d.mts +32 -0
- package/dist/shared/{server.4FnxLwwr.mjs → server.CIL9uKTN.mjs} +13 -5
- package/dist/shared/server.CNZgPgce.d.ts +12 -0
- package/dist/shared/server.Cu-7se50.d.mts +12 -0
- package/dist/shared/server.Cwq7K86l.d.mts +42 -0
- package/dist/shared/{server.Dq8xr7PQ.d.mts → server.DHgXKx3q.d.mts} +3 -3
- package/dist/shared/server.DOwaI1le.d.ts +32 -0
- package/dist/shared/{server.-ACo36I0.d.ts → server.DVBSOxWU.d.ts} +3 -3
- package/dist/shared/{server.BVwwTHyO.mjs → server.DZ5BIITo.mjs} +1 -1
- package/dist/shared/{server.DG7Tamti.mjs → server.NeumLVdS.mjs} +13 -10
- package/dist/shared/server.a_VzWVCm.d.ts +42 -0
- package/dist/shared/{server.DD2C4ujN.d.mts → server.wMv480px.d.mts} +3 -3
- package/dist/shared/{server.DD2C4ujN.d.ts → server.wMv480px.d.ts} +3 -3
- package/package.json +23 -13
- package/dist/shared/server.BPAWobQg.d.ts +0 -12
- package/dist/shared/server.Bd52nNaH.d.mts +0 -12
- package/dist/shared/server.BliFSTnG.d.mts +0 -10
- package/dist/shared/server.IG2MjhrD.d.ts +0 -10
@@ -1,13 +1,14 @@
|
|
1
|
-
import { C as Context, R as Router } from '../../shared/server.
|
1
|
+
import { C as Context, R as Router } from '../../shared/server.wMv480px.js';
|
2
2
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
|
4
|
-
import {
|
5
|
-
import { F as FriendlyStandardHandleOptions } from '../../shared/server.
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
4
|
+
import { g as StandardHandlerPlugin, C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.DVBSOxWU.js';
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.CNZgPgce.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DOwaI1le.js';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
10
|
import '@orpc/client/standard';
|
11
|
+
import '../../shared/server.a_VzWVCm.js';
|
11
12
|
|
12
13
|
interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
|
13
14
|
initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { ORPCError } from '@orpc/client';
|
2
2
|
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
4
|
-
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.
|
4
|
+
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
import '@orpc/contract';
|
7
|
-
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.
|
7
|
+
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.CIL9uKTN.mjs';
|
8
8
|
import '@orpc/client/standard';
|
9
9
|
import '@orpc/standard-server/batch';
|
10
10
|
import { S as StrictGetMethodPlugin } from '../../shared/server.BW-nUGgA.mjs';
|
11
|
-
import '../../shared/server.
|
11
|
+
import '../../shared/server.NeumLVdS.mjs';
|
12
12
|
|
13
13
|
class BodyLimitPlugin {
|
14
14
|
maxBodySize;
|
@@ -1,12 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
export { C as CompositeStandardHandlerPlugin,
|
3
|
-
import { ORPCError
|
1
|
+
import { S as StandardCodec, a as StandardParams } from '../../shared/server.DHgXKx3q.mjs';
|
2
|
+
export { C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, c as StandardHandleResult, f as StandardHandler, d as StandardHandlerInterceptorOptions, e as StandardHandlerOptions, g as StandardHandlerPlugin, h as StandardMatchResult, i as StandardMatcher } from '../../shared/server.DHgXKx3q.mjs';
|
3
|
+
import { ORPCError } from '@orpc/client';
|
4
4
|
import { StandardRPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import {
|
7
|
-
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.
|
6
|
+
import { A as AnyProcedure } from '../../shared/server.wMv480px.mjs';
|
7
|
+
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions, c as StandardRPCMatcher, b as StandardRPCMatcherOptions } from '../../shared/server.CC8z0B3U.mjs';
|
8
|
+
export { F as FriendlyStandardHandleOptions, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.Cu-7se50.mjs';
|
8
9
|
import '@orpc/contract';
|
9
10
|
import '@orpc/shared';
|
11
|
+
import '../../shared/server.Cwq7K86l.mjs';
|
10
12
|
|
11
13
|
declare class StandardRPCCodec implements StandardCodec {
|
12
14
|
private readonly serializer;
|
@@ -16,11 +18,4 @@ declare class StandardRPCCodec implements StandardCodec {
|
|
16
18
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
17
19
|
}
|
18
20
|
|
19
|
-
|
20
|
-
private readonly tree;
|
21
|
-
private pendingRouters;
|
22
|
-
init(router: AnyRouter, path?: readonly string[]): void;
|
23
|
-
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
24
|
-
}
|
25
|
-
|
26
|
-
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
21
|
+
export { StandardCodec, StandardParams, StandardRPCCodec };
|
@@ -1,12 +1,14 @@
|
|
1
|
-
import {
|
2
|
-
export { C as CompositeStandardHandlerPlugin,
|
3
|
-
import { ORPCError
|
1
|
+
import { S as StandardCodec, a as StandardParams } from '../../shared/server.DVBSOxWU.js';
|
2
|
+
export { C as CompositeStandardHandlerPlugin, b as StandardHandleOptions, c as StandardHandleResult, f as StandardHandler, d as StandardHandlerInterceptorOptions, e as StandardHandlerOptions, g as StandardHandlerPlugin, h as StandardMatchResult, i as StandardMatcher } from '../../shared/server.DVBSOxWU.js';
|
3
|
+
import { ORPCError } from '@orpc/client';
|
4
4
|
import { StandardRPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import {
|
7
|
-
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions } from '../../shared/server.
|
6
|
+
import { A as AnyProcedure } from '../../shared/server.wMv480px.js';
|
7
|
+
export { a as StandardRPCHandler, S as StandardRPCHandlerOptions, c as StandardRPCMatcher, b as StandardRPCMatcherOptions } from '../../shared/server.DOwaI1le.js';
|
8
|
+
export { F as FriendlyStandardHandleOptions, r as resolveFriendlyStandardHandleOptions } from '../../shared/server.CNZgPgce.js';
|
8
9
|
import '@orpc/contract';
|
9
10
|
import '@orpc/shared';
|
11
|
+
import '../../shared/server.a_VzWVCm.js';
|
10
12
|
|
11
13
|
declare class StandardRPCCodec implements StandardCodec {
|
12
14
|
private readonly serializer;
|
@@ -16,11 +18,4 @@ declare class StandardRPCCodec implements StandardCodec {
|
|
16
18
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
17
19
|
}
|
18
20
|
|
19
|
-
|
20
|
-
private readonly tree;
|
21
|
-
private pendingRouters;
|
22
|
-
init(router: AnyRouter, path?: readonly string[]): void;
|
23
|
-
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
24
|
-
}
|
25
|
-
|
26
|
-
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
21
|
+
export { StandardCodec, StandardParams, StandardRPCCodec };
|
@@ -1,7 +1,8 @@
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.
|
1
|
+
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.CIL9uKTN.mjs';
|
2
|
+
export { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
2
3
|
import '@orpc/client/standard';
|
3
4
|
import '@orpc/client';
|
4
5
|
import '@orpc/shared';
|
5
6
|
import '@orpc/standard-server';
|
6
|
-
import '../../shared/server.
|
7
|
+
import '../../shared/server.NeumLVdS.mjs';
|
7
8
|
import '@orpc/contract';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ServerPeer, EncodedMessage } from '@orpc/standard-server-peer';
|
2
|
+
import { C as Context } from '../../shared/server.wMv480px.mjs';
|
3
|
+
import { f as StandardHandler } from '../../shared/server.DHgXKx3q.mjs';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.Cu-7se50.mjs';
|
5
|
+
import '@orpc/client';
|
6
|
+
import '@orpc/contract';
|
7
|
+
import '@orpc/shared';
|
8
|
+
import '@orpc/standard-server';
|
9
|
+
|
10
|
+
type HandleStandardServerPeerMessageOptions<T extends Context> = Omit<FriendlyStandardHandleOptions<T>, 'prefix'>;
|
11
|
+
declare function handleStandardServerPeerMessage<T extends Context>(handler: StandardHandler<T>, peer: ServerPeer, message: EncodedMessage, options: HandleStandardServerPeerMessageOptions<T>): Promise<void>;
|
12
|
+
|
13
|
+
export { handleStandardServerPeerMessage };
|
14
|
+
export type { HandleStandardServerPeerMessageOptions };
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ServerPeer, EncodedMessage } from '@orpc/standard-server-peer';
|
2
|
+
import { C as Context } from '../../shared/server.wMv480px.js';
|
3
|
+
import { f as StandardHandler } from '../../shared/server.DVBSOxWU.js';
|
4
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.CNZgPgce.js';
|
5
|
+
import '@orpc/client';
|
6
|
+
import '@orpc/contract';
|
7
|
+
import '@orpc/shared';
|
8
|
+
import '@orpc/standard-server';
|
9
|
+
|
10
|
+
type HandleStandardServerPeerMessageOptions<T extends Context> = Omit<FriendlyStandardHandleOptions<T>, 'prefix'>;
|
11
|
+
declare function handleStandardServerPeerMessage<T extends Context>(handler: StandardHandler<T>, peer: ServerPeer, message: EncodedMessage, options: HandleStandardServerPeerMessageOptions<T>): Promise<void>;
|
12
|
+
|
13
|
+
export { handleStandardServerPeerMessage };
|
14
|
+
export type { HandleStandardServerPeerMessageOptions };
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
2
|
+
import '@orpc/client';
|
3
|
+
import '@orpc/shared';
|
4
|
+
import '@orpc/standard-server';
|
5
|
+
import '@orpc/contract';
|
6
|
+
import '@orpc/client/standard';
|
7
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
@@ -1,17 +1,43 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import { C as Context, R as Router } from '../../shared/server.
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.wMv480px.mjs';
|
3
|
+
import { f as StandardHandler } from '../../shared/server.DHgXKx3q.mjs';
|
4
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.CC8z0B3U.mjs';
|
6
6
|
import '@orpc/client';
|
7
7
|
import '@orpc/contract';
|
8
8
|
import '@orpc/standard-server';
|
9
|
+
import '@orpc/standard-server-peer';
|
10
|
+
import '../../shared/server.Cu-7se50.mjs';
|
9
11
|
import '@orpc/client/standard';
|
12
|
+
import '../../shared/server.Cwq7K86l.mjs';
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
type MinimalWebsocket = Pick<WebSocket, 'addEventListener' | 'send'>;
|
15
|
+
declare class WebsocketHandler<T extends Context> {
|
16
|
+
#private;
|
13
17
|
constructor(standardHandler: StandardHandler<T>);
|
14
|
-
|
18
|
+
/**
|
19
|
+
* Upgrades a WebSocket to enable handling
|
20
|
+
*
|
21
|
+
* This attaches the necessary 'message' and 'close' listeners to the WebSocket
|
22
|
+
*
|
23
|
+
* @warning Do not use this method if you're using `.message()` or `.close()`
|
24
|
+
*/
|
25
|
+
upgrade(ws: MinimalWebsocket, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
26
|
+
/**
|
27
|
+
* Handles a single message received from a WebSocket.
|
28
|
+
*
|
29
|
+
* @warning Avoid calling this directly if `.upgrade()` is used.
|
30
|
+
*
|
31
|
+
* @param ws The WebSocket instance
|
32
|
+
* @param data The message payload, usually place in `event.data`
|
33
|
+
*/
|
34
|
+
message(ws: MinimalWebsocket, data: string | ArrayBuffer | Blob, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
35
|
+
/**
|
36
|
+
* Closes the WebSocket peer and cleans up.
|
37
|
+
*
|
38
|
+
* @warning Avoid calling this directly if `.upgrade()` is used.
|
39
|
+
*/
|
40
|
+
close(ws: MinimalWebsocket): void;
|
15
41
|
}
|
16
42
|
|
17
43
|
/**
|
@@ -20,8 +46,9 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
20
46
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
21
47
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
22
48
|
*/
|
23
|
-
declare class
|
49
|
+
declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
|
24
50
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
25
51
|
}
|
26
52
|
|
27
|
-
export {
|
53
|
+
export { RPCHandler, WebsocketHandler };
|
54
|
+
export type { MinimalWebsocket };
|
@@ -1,17 +1,43 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import { C as Context, R as Router } from '../../shared/server.
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.wMv480px.js';
|
3
|
+
import { f as StandardHandler } from '../../shared/server.DVBSOxWU.js';
|
4
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DOwaI1le.js';
|
6
6
|
import '@orpc/client';
|
7
7
|
import '@orpc/contract';
|
8
8
|
import '@orpc/standard-server';
|
9
|
+
import '@orpc/standard-server-peer';
|
10
|
+
import '../../shared/server.CNZgPgce.js';
|
9
11
|
import '@orpc/client/standard';
|
12
|
+
import '../../shared/server.a_VzWVCm.js';
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
type MinimalWebsocket = Pick<WebSocket, 'addEventListener' | 'send'>;
|
15
|
+
declare class WebsocketHandler<T extends Context> {
|
16
|
+
#private;
|
13
17
|
constructor(standardHandler: StandardHandler<T>);
|
14
|
-
|
18
|
+
/**
|
19
|
+
* Upgrades a WebSocket to enable handling
|
20
|
+
*
|
21
|
+
* This attaches the necessary 'message' and 'close' listeners to the WebSocket
|
22
|
+
*
|
23
|
+
* @warning Do not use this method if you're using `.message()` or `.close()`
|
24
|
+
*/
|
25
|
+
upgrade(ws: MinimalWebsocket, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
26
|
+
/**
|
27
|
+
* Handles a single message received from a WebSocket.
|
28
|
+
*
|
29
|
+
* @warning Avoid calling this directly if `.upgrade()` is used.
|
30
|
+
*
|
31
|
+
* @param ws The WebSocket instance
|
32
|
+
* @param data The message payload, usually place in `event.data`
|
33
|
+
*/
|
34
|
+
message(ws: MinimalWebsocket, data: string | ArrayBuffer | Blob, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
35
|
+
/**
|
36
|
+
* Closes the WebSocket peer and cleans up.
|
37
|
+
*
|
38
|
+
* @warning Avoid calling this directly if `.upgrade()` is used.
|
39
|
+
*/
|
40
|
+
close(ws: MinimalWebsocket): void;
|
15
41
|
}
|
16
42
|
|
17
43
|
/**
|
@@ -20,8 +46,9 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
20
46
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
21
47
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
22
48
|
*/
|
23
|
-
declare class
|
49
|
+
declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
|
24
50
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
25
51
|
}
|
26
52
|
|
27
|
-
export {
|
53
|
+
export { RPCHandler, WebsocketHandler };
|
54
|
+
export type { MinimalWebsocket };
|
@@ -1,38 +1,69 @@
|
|
1
|
-
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import { readAsBuffer, resolveMaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ServerPeer } from '@orpc/standard-server-peer';
|
3
|
-
import {
|
3
|
+
import { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
import '@orpc/contract';
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.CIL9uKTN.mjs';
|
8
8
|
import '@orpc/client/standard';
|
9
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
10
|
+
import '../../shared/server.NeumLVdS.mjs';
|
10
11
|
|
11
|
-
class
|
12
|
+
class WebsocketHandler {
|
13
|
+
#peers = /* @__PURE__ */ new WeakMap();
|
14
|
+
#handler;
|
12
15
|
constructor(standardHandler) {
|
13
|
-
this
|
16
|
+
this.#handler = standardHandler;
|
14
17
|
}
|
18
|
+
/**
|
19
|
+
* Upgrades a WebSocket to enable handling
|
20
|
+
*
|
21
|
+
* This attaches the necessary 'message' and 'close' listeners to the WebSocket
|
22
|
+
*
|
23
|
+
* @warning Do not use this method if you're using `.message()` or `.close()`
|
24
|
+
*/
|
15
25
|
upgrade(ws, ...rest) {
|
16
|
-
|
17
|
-
ws.addEventListener("
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
ws.addEventListener("message", (event) => this.message(ws, event.data, ...rest));
|
27
|
+
ws.addEventListener("close", () => this.close(ws));
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Handles a single message received from a WebSocket.
|
31
|
+
*
|
32
|
+
* @warning Avoid calling this directly if `.upgrade()` is used.
|
33
|
+
*
|
34
|
+
* @param ws The WebSocket instance
|
35
|
+
* @param data The message payload, usually place in `event.data`
|
36
|
+
*/
|
37
|
+
async message(ws, data, ...rest) {
|
38
|
+
let peer = this.#peers.get(ws);
|
39
|
+
if (!peer) {
|
40
|
+
this.#peers.set(ws, peer = new ServerPeer(ws.send.bind(ws)));
|
41
|
+
}
|
42
|
+
const message = data instanceof Blob ? await readAsBuffer(data) : data;
|
43
|
+
await handleStandardServerPeerMessage(
|
44
|
+
this.#handler,
|
45
|
+
peer,
|
46
|
+
message,
|
47
|
+
resolveMaybeOptionalOptions(rest)
|
48
|
+
);
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* Closes the WebSocket peer and cleans up.
|
52
|
+
*
|
53
|
+
* @warning Avoid calling this directly if `.upgrade()` is used.
|
54
|
+
*/
|
55
|
+
close(ws) {
|
56
|
+
const peer = this.#peers.get(ws);
|
57
|
+
if (peer) {
|
27
58
|
peer.close();
|
28
|
-
}
|
59
|
+
}
|
29
60
|
}
|
30
61
|
}
|
31
62
|
|
32
|
-
class
|
63
|
+
class RPCHandler extends WebsocketHandler {
|
33
64
|
constructor(router, options = {}) {
|
34
65
|
super(new StandardRPCHandler(router, options));
|
35
66
|
}
|
36
67
|
}
|
37
68
|
|
38
|
-
export {
|
69
|
+
export { RPCHandler, WebsocketHandler };
|
@@ -1,18 +1,21 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { WebSocket } from 'ws';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.wMv480px.mjs';
|
4
|
+
import { f as StandardHandler } from '../../shared/server.DHgXKx3q.mjs';
|
5
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.CC8z0B3U.mjs';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/standard-server-peer';
|
11
|
+
import '../../shared/server.Cu-7se50.mjs';
|
10
12
|
import '@orpc/client/standard';
|
13
|
+
import '../../shared/server.Cwq7K86l.mjs';
|
11
14
|
|
12
|
-
declare class
|
15
|
+
declare class WsHandler<T extends Context> {
|
13
16
|
private readonly standardHandler;
|
14
17
|
constructor(standardHandler: StandardHandler<T>);
|
15
|
-
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<
|
18
|
+
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
16
19
|
}
|
17
20
|
|
18
21
|
/**
|
@@ -21,8 +24,8 @@ declare class experimental_WsHandler<T extends Context> {
|
|
21
24
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
22
25
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
23
26
|
*/
|
24
|
-
declare class
|
27
|
+
declare class RPCHandler<T extends Context> extends WsHandler<T> {
|
25
28
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
26
29
|
}
|
27
30
|
|
28
|
-
export {
|
31
|
+
export { RPCHandler, WsHandler };
|
@@ -1,18 +1,21 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { WebSocket } from 'ws';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { S as StandardRPCHandlerOptions } from '../../shared/server.
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.wMv480px.js';
|
4
|
+
import { f as StandardHandler } from '../../shared/server.DVBSOxWU.js';
|
5
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.DOwaI1le.js';
|
7
7
|
import '@orpc/client';
|
8
8
|
import '@orpc/contract';
|
9
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/standard-server-peer';
|
11
|
+
import '../../shared/server.CNZgPgce.js';
|
10
12
|
import '@orpc/client/standard';
|
13
|
+
import '../../shared/server.a_VzWVCm.js';
|
11
14
|
|
12
|
-
declare class
|
15
|
+
declare class WsHandler<T extends Context> {
|
13
16
|
private readonly standardHandler;
|
14
17
|
constructor(standardHandler: StandardHandler<T>);
|
15
|
-
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<
|
18
|
+
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
16
19
|
}
|
17
20
|
|
18
21
|
/**
|
@@ -21,8 +24,8 @@ declare class experimental_WsHandler<T extends Context> {
|
|
21
24
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
22
25
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
23
26
|
*/
|
24
|
-
declare class
|
27
|
+
declare class RPCHandler<T extends Context> extends WsHandler<T> {
|
25
28
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
26
29
|
}
|
27
30
|
|
28
|
-
export {
|
31
|
+
export { RPCHandler, WsHandler };
|
@@ -1,27 +1,28 @@
|
|
1
|
-
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import { readAsBuffer, resolveMaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ServerPeer } from '@orpc/standard-server-peer';
|
3
|
-
import {
|
3
|
+
import { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
import '@orpc/contract';
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.CIL9uKTN.mjs';
|
8
8
|
import '@orpc/client/standard';
|
9
|
-
import '../../shared/server.
|
9
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
10
|
+
import '../../shared/server.NeumLVdS.mjs';
|
10
11
|
|
11
|
-
class
|
12
|
+
class WsHandler {
|
12
13
|
constructor(standardHandler) {
|
13
14
|
this.standardHandler = standardHandler;
|
14
15
|
}
|
15
16
|
async upgrade(ws, ...rest) {
|
16
17
|
const peer = new ServerPeer(ws.send.bind(ws));
|
17
18
|
ws.addEventListener("message", async (event) => {
|
18
|
-
const
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
const message = Array.isArray(event.data) ? await readAsBuffer(new Blob(event.data)) : event.data;
|
20
|
+
await handleStandardServerPeerMessage(
|
21
|
+
this.standardHandler,
|
22
|
+
peer,
|
23
|
+
message,
|
24
|
+
resolveMaybeOptionalOptions(rest)
|
25
|
+
);
|
25
26
|
});
|
26
27
|
ws.addEventListener("close", () => {
|
27
28
|
peer.close();
|
@@ -29,10 +30,10 @@ class experimental_WsHandler {
|
|
29
30
|
}
|
30
31
|
}
|
31
32
|
|
32
|
-
class
|
33
|
+
class RPCHandler extends WsHandler {
|
33
34
|
constructor(router, options = {}) {
|
34
35
|
super(new StandardRPCHandler(router, options));
|
35
36
|
}
|
36
37
|
}
|
37
38
|
|
38
|
-
export {
|
39
|
+
export { RPCHandler, WsHandler };
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
+
import { g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.DHgXKx3q.mjs';
|
3
|
+
import { experimental_HibernationEventIterator } from '@orpc/standard-server';
|
4
|
+
export { experimental_HibernationEventIterator, experimental_HibernationEventIteratorCallback } from '@orpc/standard-server';
|
5
|
+
import { C as Context, R as Router } from '../shared/server.wMv480px.mjs';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/contract';
|
8
|
+
import '@orpc/shared';
|
9
|
+
|
10
|
+
interface experimental_EncodeHibernationRPCEventOptions extends StandardRPCJsonSerializerOptions {
|
11
|
+
/**
|
12
|
+
* The type of event, each type corresponds a different operation
|
13
|
+
*
|
14
|
+
* - 'message' = 'yield'
|
15
|
+
* - 'error' = 'throw'
|
16
|
+
* - 'done' = 'return'
|
17
|
+
*
|
18
|
+
* @default 'message'
|
19
|
+
*/
|
20
|
+
event?: 'message' | 'error' | 'done';
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* Encodes a Hibernation RPC Event
|
24
|
+
*
|
25
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
|
26
|
+
*/
|
27
|
+
declare function experimental_encodeHibernationRPCEvent(id: string, payload: unknown, options?: experimental_EncodeHibernationRPCEventOptions): string;
|
28
|
+
|
29
|
+
interface experimental_HibernationPluginContext {
|
30
|
+
iterator?: experimental_HibernationEventIterator<any>;
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Enable Hibernation APIs
|
34
|
+
*
|
35
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
|
36
|
+
*/
|
37
|
+
declare class experimental_HibernationPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
38
|
+
readonly CONTEXT_SYMBOL: symbol;
|
39
|
+
order: number;
|
40
|
+
init(options: StandardHandlerOptions<T>, _router: Router<any, T>): void;
|
41
|
+
}
|
42
|
+
|
43
|
+
export { experimental_HibernationPlugin, experimental_encodeHibernationRPCEvent };
|
44
|
+
export type { experimental_EncodeHibernationRPCEventOptions, experimental_HibernationPluginContext };
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
+
import { g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.DVBSOxWU.js';
|
3
|
+
import { experimental_HibernationEventIterator } from '@orpc/standard-server';
|
4
|
+
export { experimental_HibernationEventIterator, experimental_HibernationEventIteratorCallback } from '@orpc/standard-server';
|
5
|
+
import { C as Context, R as Router } from '../shared/server.wMv480px.js';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/contract';
|
8
|
+
import '@orpc/shared';
|
9
|
+
|
10
|
+
interface experimental_EncodeHibernationRPCEventOptions extends StandardRPCJsonSerializerOptions {
|
11
|
+
/**
|
12
|
+
* The type of event, each type corresponds a different operation
|
13
|
+
*
|
14
|
+
* - 'message' = 'yield'
|
15
|
+
* - 'error' = 'throw'
|
16
|
+
* - 'done' = 'return'
|
17
|
+
*
|
18
|
+
* @default 'message'
|
19
|
+
*/
|
20
|
+
event?: 'message' | 'error' | 'done';
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* Encodes a Hibernation RPC Event
|
24
|
+
*
|
25
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
|
26
|
+
*/
|
27
|
+
declare function experimental_encodeHibernationRPCEvent(id: string, payload: unknown, options?: experimental_EncodeHibernationRPCEventOptions): string;
|
28
|
+
|
29
|
+
interface experimental_HibernationPluginContext {
|
30
|
+
iterator?: experimental_HibernationEventIterator<any>;
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Enable Hibernation APIs
|
34
|
+
*
|
35
|
+
* @see {@link https://orpc.unnoq.com/docs/plugins/hibernation Hibernation Plugin}
|
36
|
+
*/
|
37
|
+
declare class experimental_HibernationPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
38
|
+
readonly CONTEXT_SYMBOL: symbol;
|
39
|
+
order: number;
|
40
|
+
init(options: StandardHandlerOptions<T>, _router: Router<any, T>): void;
|
41
|
+
}
|
42
|
+
|
43
|
+
export { experimental_HibernationPlugin, experimental_encodeHibernationRPCEvent };
|
44
|
+
export type { experimental_EncodeHibernationRPCEventOptions, experimental_HibernationPluginContext };
|