@orpc/standard-server-peer 0.0.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/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/index.d.mts +91 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.mjs +571 -0
- package/package.json +34 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 oRPC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<h1></h1>
|
6
|
+
|
7
|
+
<div align="center">
|
8
|
+
<a href="https://codecov.io/gh/unnoq/orpc">
|
9
|
+
<img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
|
10
|
+
</a>
|
11
|
+
<a href="https://www.npmjs.com/package/@orpc/standard-server-peer">
|
12
|
+
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fstandard-server-peer?logo=npm" />
|
13
|
+
</a>
|
14
|
+
<a href="https://github.com/unnoq/orpc/blob/main/LICENSE">
|
15
|
+
<img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
|
16
|
+
</a>
|
17
|
+
<a href="https://discord.gg/TXEbwRBvQn">
|
18
|
+
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
19
|
+
</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
23
|
+
|
24
|
+
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
|
25
|
+
|
26
|
+
---
|
27
|
+
|
28
|
+
## Highlights
|
29
|
+
|
30
|
+
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
31
|
+
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
32
|
+
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
33
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
34
|
+
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
35
|
+
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
36
|
+
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
37
|
+
- **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
|
38
|
+
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
39
|
+
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
40
|
+
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
41
|
+
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
42
|
+
|
43
|
+
## Documentation
|
44
|
+
|
45
|
+
You can find the full documentation [here](https://orpc.unnoq.com).
|
46
|
+
|
47
|
+
## Packages
|
48
|
+
|
49
|
+
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
50
|
+
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
51
|
+
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
52
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
53
|
+
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
54
|
+
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
55
|
+
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
56
|
+
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
57
|
+
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
58
|
+
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
59
|
+
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
60
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
61
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
62
|
+
|
63
|
+
## `@orpc/standard-server-peer`
|
64
|
+
|
65
|
+
Provides a standard interface for oRPC server adapters to interact with connected peers across various transports (e.g., WebSocket, IPC).
|
66
|
+
|
67
|
+
## Sponsors
|
68
|
+
|
69
|
+
<p align="center">
|
70
|
+
<a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
|
71
|
+
<img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
|
72
|
+
</a>
|
73
|
+
</p>
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
package/dist/index.d.mts
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
import { EventMeta, StandardRequest, StandardResponse, StandardHeaders } from '@orpc/standard-server';
|
2
|
+
import { CreateAsyncIteratorObjectOptions } from '@orpc/shared';
|
3
|
+
|
4
|
+
declare enum MessageType {
|
5
|
+
REQUEST = 1,
|
6
|
+
RESPONSE = 2,
|
7
|
+
EVENT_ITERATOR = 3,
|
8
|
+
ABORT_SIGNAL = 4
|
9
|
+
}
|
10
|
+
type RawMessage = string | ArrayBufferLike | Blob;
|
11
|
+
type EventIteratorEvent = 'message' | 'error' | 'done';
|
12
|
+
interface EventIteratorPayload {
|
13
|
+
event: EventIteratorEvent;
|
14
|
+
data: unknown;
|
15
|
+
meta?: EventMeta;
|
16
|
+
}
|
17
|
+
interface RequestMessageMap {
|
18
|
+
[MessageType.REQUEST]: Omit<StandardRequest, 'signal'>;
|
19
|
+
[MessageType.EVENT_ITERATOR]: EventIteratorPayload;
|
20
|
+
[MessageType.ABORT_SIGNAL]: void;
|
21
|
+
}
|
22
|
+
interface ResponseMessageMap {
|
23
|
+
[MessageType.RESPONSE]: StandardResponse;
|
24
|
+
[MessageType.EVENT_ITERATOR]: EventIteratorPayload;
|
25
|
+
[MessageType.ABORT_SIGNAL]: void;
|
26
|
+
}
|
27
|
+
type DecodedMessageUnion<TMap extends RequestMessageMap | ResponseMessageMap> = {
|
28
|
+
[K in keyof TMap]: [id: number, type: K, payload: TMap[K]];
|
29
|
+
}[keyof TMap];
|
30
|
+
type DecodedRequestMessage = DecodedMessageUnion<RequestMessageMap>;
|
31
|
+
type DecodedResponseMessage = DecodedMessageUnion<ResponseMessageMap>;
|
32
|
+
declare function encodeRequestMessage<T extends keyof RequestMessageMap>(id: number, type: T, payload: RequestMessageMap[T]): Promise<RawMessage>;
|
33
|
+
declare function decodeRequestMessage(raw: RawMessage): Promise<DecodedRequestMessage>;
|
34
|
+
declare function encodeResponseMessage<T extends keyof ResponseMessageMap>(id: number, type: T, payload: ResponseMessageMap[T]): Promise<RawMessage>;
|
35
|
+
declare function decodeResponseMessage(raw: RawMessage): Promise<DecodedResponseMessage>;
|
36
|
+
declare function isEventIteratorHeaders(headers: StandardHeaders): boolean;
|
37
|
+
|
38
|
+
declare class ClientPeer {
|
39
|
+
private readonly idGenerator;
|
40
|
+
private readonly clientRequestQueue;
|
41
|
+
private readonly clientEventIteratorQueue;
|
42
|
+
private readonly clientSignalQueue;
|
43
|
+
private readonly serverResponseQueue;
|
44
|
+
private readonly serverEventIterator;
|
45
|
+
private readonly serverSignalQueue;
|
46
|
+
constructor(send: (message: RawMessage) => void);
|
47
|
+
request(request: StandardRequest): Promise<StandardResponse>;
|
48
|
+
message(raw: RawMessage): Promise<void>;
|
49
|
+
open(id: number): void;
|
50
|
+
close(id?: number, reason?: any): void;
|
51
|
+
}
|
52
|
+
|
53
|
+
declare abstract class AsyncIdQueue<T> {
|
54
|
+
private readonly openIds;
|
55
|
+
abstract push(id: number, item: T): void;
|
56
|
+
open(id: number): void;
|
57
|
+
close(id: number): void;
|
58
|
+
closeAll(): void;
|
59
|
+
isOpen(id: number): boolean;
|
60
|
+
assertOpen(id: number): void;
|
61
|
+
}
|
62
|
+
declare class PullableAsyncIdQueue<T> extends AsyncIdQueue<T> {
|
63
|
+
private readonly items;
|
64
|
+
private readonly pendingPulls;
|
65
|
+
push(id: number, item: T): void;
|
66
|
+
pull(id: number): Promise<T>;
|
67
|
+
close(id: number, reason?: any): void;
|
68
|
+
}
|
69
|
+
|
70
|
+
declare function toEventIterator(queue: PullableAsyncIdQueue<EventIteratorPayload>, id: number, options?: CreateAsyncIteratorObjectOptions): AsyncGenerator;
|
71
|
+
declare function sendEventIterator(queue: AsyncIdQueue<EventIteratorPayload>, id: number, iterator: AsyncIterator<any>, options?: {
|
72
|
+
onComplete?: () => void;
|
73
|
+
}): Promise<void>;
|
74
|
+
|
75
|
+
declare class ServerPeer {
|
76
|
+
private readonly serverResponseQueue;
|
77
|
+
private readonly serverEventIteratorQueue;
|
78
|
+
private readonly serverSignalQueue;
|
79
|
+
private readonly clientEventIteratorQueue;
|
80
|
+
private readonly clientSignalQueue;
|
81
|
+
constructor(send: (message: RawMessage) => void);
|
82
|
+
message(raw: RawMessage): Promise<[id: number, StandardRequest | undefined]>;
|
83
|
+
response(id: number, response: StandardResponse): Promise<void>;
|
84
|
+
open(id: number): void;
|
85
|
+
close(id?: number, reason?: any): void;
|
86
|
+
}
|
87
|
+
|
88
|
+
declare function toAbortSignal(queue: PullableAsyncIdQueue<void>, id: number): AbortSignal;
|
89
|
+
|
90
|
+
export { ClientPeer, MessageType, ServerPeer, decodeRequestMessage, decodeResponseMessage, encodeRequestMessage, encodeResponseMessage, isEventIteratorHeaders, sendEventIterator, toAbortSignal, toEventIterator };
|
91
|
+
export type { DecodedRequestMessage, DecodedResponseMessage, EventIteratorEvent, EventIteratorPayload, RawMessage, RequestMessageMap, ResponseMessageMap };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
import { EventMeta, StandardRequest, StandardResponse, StandardHeaders } from '@orpc/standard-server';
|
2
|
+
import { CreateAsyncIteratorObjectOptions } from '@orpc/shared';
|
3
|
+
|
4
|
+
declare enum MessageType {
|
5
|
+
REQUEST = 1,
|
6
|
+
RESPONSE = 2,
|
7
|
+
EVENT_ITERATOR = 3,
|
8
|
+
ABORT_SIGNAL = 4
|
9
|
+
}
|
10
|
+
type RawMessage = string | ArrayBufferLike | Blob;
|
11
|
+
type EventIteratorEvent = 'message' | 'error' | 'done';
|
12
|
+
interface EventIteratorPayload {
|
13
|
+
event: EventIteratorEvent;
|
14
|
+
data: unknown;
|
15
|
+
meta?: EventMeta;
|
16
|
+
}
|
17
|
+
interface RequestMessageMap {
|
18
|
+
[MessageType.REQUEST]: Omit<StandardRequest, 'signal'>;
|
19
|
+
[MessageType.EVENT_ITERATOR]: EventIteratorPayload;
|
20
|
+
[MessageType.ABORT_SIGNAL]: void;
|
21
|
+
}
|
22
|
+
interface ResponseMessageMap {
|
23
|
+
[MessageType.RESPONSE]: StandardResponse;
|
24
|
+
[MessageType.EVENT_ITERATOR]: EventIteratorPayload;
|
25
|
+
[MessageType.ABORT_SIGNAL]: void;
|
26
|
+
}
|
27
|
+
type DecodedMessageUnion<TMap extends RequestMessageMap | ResponseMessageMap> = {
|
28
|
+
[K in keyof TMap]: [id: number, type: K, payload: TMap[K]];
|
29
|
+
}[keyof TMap];
|
30
|
+
type DecodedRequestMessage = DecodedMessageUnion<RequestMessageMap>;
|
31
|
+
type DecodedResponseMessage = DecodedMessageUnion<ResponseMessageMap>;
|
32
|
+
declare function encodeRequestMessage<T extends keyof RequestMessageMap>(id: number, type: T, payload: RequestMessageMap[T]): Promise<RawMessage>;
|
33
|
+
declare function decodeRequestMessage(raw: RawMessage): Promise<DecodedRequestMessage>;
|
34
|
+
declare function encodeResponseMessage<T extends keyof ResponseMessageMap>(id: number, type: T, payload: ResponseMessageMap[T]): Promise<RawMessage>;
|
35
|
+
declare function decodeResponseMessage(raw: RawMessage): Promise<DecodedResponseMessage>;
|
36
|
+
declare function isEventIteratorHeaders(headers: StandardHeaders): boolean;
|
37
|
+
|
38
|
+
declare class ClientPeer {
|
39
|
+
private readonly idGenerator;
|
40
|
+
private readonly clientRequestQueue;
|
41
|
+
private readonly clientEventIteratorQueue;
|
42
|
+
private readonly clientSignalQueue;
|
43
|
+
private readonly serverResponseQueue;
|
44
|
+
private readonly serverEventIterator;
|
45
|
+
private readonly serverSignalQueue;
|
46
|
+
constructor(send: (message: RawMessage) => void);
|
47
|
+
request(request: StandardRequest): Promise<StandardResponse>;
|
48
|
+
message(raw: RawMessage): Promise<void>;
|
49
|
+
open(id: number): void;
|
50
|
+
close(id?: number, reason?: any): void;
|
51
|
+
}
|
52
|
+
|
53
|
+
declare abstract class AsyncIdQueue<T> {
|
54
|
+
private readonly openIds;
|
55
|
+
abstract push(id: number, item: T): void;
|
56
|
+
open(id: number): void;
|
57
|
+
close(id: number): void;
|
58
|
+
closeAll(): void;
|
59
|
+
isOpen(id: number): boolean;
|
60
|
+
assertOpen(id: number): void;
|
61
|
+
}
|
62
|
+
declare class PullableAsyncIdQueue<T> extends AsyncIdQueue<T> {
|
63
|
+
private readonly items;
|
64
|
+
private readonly pendingPulls;
|
65
|
+
push(id: number, item: T): void;
|
66
|
+
pull(id: number): Promise<T>;
|
67
|
+
close(id: number, reason?: any): void;
|
68
|
+
}
|
69
|
+
|
70
|
+
declare function toEventIterator(queue: PullableAsyncIdQueue<EventIteratorPayload>, id: number, options?: CreateAsyncIteratorObjectOptions): AsyncGenerator;
|
71
|
+
declare function sendEventIterator(queue: AsyncIdQueue<EventIteratorPayload>, id: number, iterator: AsyncIterator<any>, options?: {
|
72
|
+
onComplete?: () => void;
|
73
|
+
}): Promise<void>;
|
74
|
+
|
75
|
+
declare class ServerPeer {
|
76
|
+
private readonly serverResponseQueue;
|
77
|
+
private readonly serverEventIteratorQueue;
|
78
|
+
private readonly serverSignalQueue;
|
79
|
+
private readonly clientEventIteratorQueue;
|
80
|
+
private readonly clientSignalQueue;
|
81
|
+
constructor(send: (message: RawMessage) => void);
|
82
|
+
message(raw: RawMessage): Promise<[id: number, StandardRequest | undefined]>;
|
83
|
+
response(id: number, response: StandardResponse): Promise<void>;
|
84
|
+
open(id: number): void;
|
85
|
+
close(id?: number, reason?: any): void;
|
86
|
+
}
|
87
|
+
|
88
|
+
declare function toAbortSignal(queue: PullableAsyncIdQueue<void>, id: number): AbortSignal;
|
89
|
+
|
90
|
+
export { ClientPeer, MessageType, ServerPeer, decodeRequestMessage, decodeResponseMessage, encodeRequestMessage, encodeResponseMessage, isEventIteratorHeaders, sendEventIterator, toAbortSignal, toEventIterator };
|
91
|
+
export type { DecodedRequestMessage, DecodedResponseMessage, EventIteratorEvent, EventIteratorPayload, RawMessage, RequestMessageMap, ResponseMessageMap };
|
package/dist/index.mjs
ADDED
@@ -0,0 +1,571 @@
|
|
1
|
+
import { toArray, stringifyJSON, isAsyncIteratorObject, createAsyncIteratorObject, isTypescriptObject, SequentialIdGenerator, PullableAsyncIdQueue as PullableAsyncIdQueue$1, ConsumableAsyncIdQueue as ConsumableAsyncIdQueue$1 } from '@orpc/shared';
|
2
|
+
import { getFilenameFromContentDisposition, generateContentDisposition, withEventMeta, ErrorEvent, getEventMeta } from '@orpc/standard-server';
|
3
|
+
|
4
|
+
class AsyncIdQueue {
|
5
|
+
openIds = /* @__PURE__ */ new Set();
|
6
|
+
open(id) {
|
7
|
+
this.openIds.add(id);
|
8
|
+
}
|
9
|
+
close(id) {
|
10
|
+
this.openIds.delete(id);
|
11
|
+
}
|
12
|
+
closeAll() {
|
13
|
+
this.openIds.forEach((id) => this.close(id));
|
14
|
+
}
|
15
|
+
isOpen(id) {
|
16
|
+
return this.openIds.has(id);
|
17
|
+
}
|
18
|
+
assertOpen(id) {
|
19
|
+
if (!this.isOpen(id)) {
|
20
|
+
throw new Error(`[AsyncIdQueue] Cannot access queue[${id}] because it is not open.`);
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
class PullableAsyncIdQueue extends AsyncIdQueue {
|
25
|
+
items = /* @__PURE__ */ new Map();
|
26
|
+
pendingPulls = /* @__PURE__ */ new Map();
|
27
|
+
push(id, item) {
|
28
|
+
this.assertOpen(id);
|
29
|
+
const pending = this.pendingPulls.get(id);
|
30
|
+
if (pending?.length) {
|
31
|
+
pending.shift()[0](item);
|
32
|
+
if (pending.length === 0) {
|
33
|
+
this.pendingPulls.delete(id);
|
34
|
+
}
|
35
|
+
} else {
|
36
|
+
const items = this.items.get(id);
|
37
|
+
if (items) {
|
38
|
+
items.push(item);
|
39
|
+
} else {
|
40
|
+
this.items.set(id, [item]);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
async pull(id) {
|
45
|
+
this.assertOpen(id);
|
46
|
+
const items = this.items.get(id);
|
47
|
+
if (items?.length) {
|
48
|
+
const item = items.shift();
|
49
|
+
if (items.length === 0) {
|
50
|
+
this.items.delete(id);
|
51
|
+
}
|
52
|
+
return item;
|
53
|
+
}
|
54
|
+
return new Promise((resolve, reject) => {
|
55
|
+
const waitingPulls = this.pendingPulls.get(id);
|
56
|
+
const pending = [resolve, reject];
|
57
|
+
if (waitingPulls) {
|
58
|
+
waitingPulls.push(pending);
|
59
|
+
} else {
|
60
|
+
this.pendingPulls.set(id, [pending]);
|
61
|
+
}
|
62
|
+
});
|
63
|
+
}
|
64
|
+
close(id, reason) {
|
65
|
+
const pendingPulls = this.pendingPulls.get(id);
|
66
|
+
if (pendingPulls) {
|
67
|
+
pendingPulls.forEach(([, reject]) => {
|
68
|
+
reject(reason ?? new Error(`[PullableAsyncIdQueue] Queue[${id}] was closed while waiting for pulling.`));
|
69
|
+
});
|
70
|
+
this.pendingPulls.delete(id);
|
71
|
+
}
|
72
|
+
super.close(id);
|
73
|
+
this.items.delete(id);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
class ConsumableAsyncIdQueue extends AsyncIdQueue {
|
77
|
+
constructor(consume) {
|
78
|
+
super();
|
79
|
+
this.consume = consume;
|
80
|
+
}
|
81
|
+
push(id, item) {
|
82
|
+
this.assertOpen(id);
|
83
|
+
this.consume(id, item);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
88
|
+
MessageType2[MessageType2["REQUEST"] = 1] = "REQUEST";
|
89
|
+
MessageType2[MessageType2["RESPONSE"] = 2] = "RESPONSE";
|
90
|
+
MessageType2[MessageType2["EVENT_ITERATOR"] = 3] = "EVENT_ITERATOR";
|
91
|
+
MessageType2[MessageType2["ABORT_SIGNAL"] = 4] = "ABORT_SIGNAL";
|
92
|
+
return MessageType2;
|
93
|
+
})(MessageType || {});
|
94
|
+
async function encodeRequestMessage(id, type, payload) {
|
95
|
+
if (type === 3 /* EVENT_ITERATOR */) {
|
96
|
+
const eventPayload = payload;
|
97
|
+
const serializedPayload2 = {
|
98
|
+
e: eventPayload.event,
|
99
|
+
d: eventPayload.data,
|
100
|
+
m: eventPayload.meta
|
101
|
+
};
|
102
|
+
return encodeRawMessage({ i: id, t: type, p: serializedPayload2 });
|
103
|
+
}
|
104
|
+
if (type === 4 /* ABORT_SIGNAL */) {
|
105
|
+
return encodeRawMessage({ i: id, t: type, p: payload });
|
106
|
+
}
|
107
|
+
const request = payload;
|
108
|
+
const { body: processedBody, headers: processedHeaders } = await prepareBodyAndHeadersForSerialization(
|
109
|
+
request.body,
|
110
|
+
request.headers
|
111
|
+
);
|
112
|
+
const serializedPayload = {
|
113
|
+
u: request.url.toString().replace(/^orpc:\//, "/"),
|
114
|
+
b: processedBody instanceof Blob ? void 0 : processedBody,
|
115
|
+
h: Object.keys(processedHeaders).length > 0 ? processedHeaders : void 0,
|
116
|
+
m: request.method === "POST" ? void 0 : request.method
|
117
|
+
};
|
118
|
+
const baseMessage = {
|
119
|
+
i: id,
|
120
|
+
p: serializedPayload
|
121
|
+
};
|
122
|
+
if (processedBody instanceof Blob) {
|
123
|
+
return encodeRawMessage(baseMessage, processedBody);
|
124
|
+
}
|
125
|
+
return encodeRawMessage(baseMessage);
|
126
|
+
}
|
127
|
+
async function decodeRequestMessage(raw) {
|
128
|
+
const { json: message, blobData } = await decodeRawMessage(raw);
|
129
|
+
const id = message.i;
|
130
|
+
const type = message.t;
|
131
|
+
if (type === 3 /* EVENT_ITERATOR */) {
|
132
|
+
const payload2 = message.p;
|
133
|
+
return [id, type, { event: payload2.e, data: payload2.d, meta: payload2.m }];
|
134
|
+
}
|
135
|
+
if (type === 4 /* ABORT_SIGNAL */) {
|
136
|
+
return [id, type, message.p];
|
137
|
+
}
|
138
|
+
const payload = message.p;
|
139
|
+
const headers = payload.h ?? {};
|
140
|
+
let body = payload.b;
|
141
|
+
const contentType = toArray(headers["content-type"])[0];
|
142
|
+
if (blobData) {
|
143
|
+
const contentDisposition = toArray(headers["content-disposition"])[0];
|
144
|
+
if (contentDisposition === void 0 && contentType?.startsWith("multipart/form-data")) {
|
145
|
+
const tempRes = new Response(blobData, { headers: { "content-type": contentType } });
|
146
|
+
body = await tempRes.formData();
|
147
|
+
} else {
|
148
|
+
const filename = getFilenameFromContentDisposition(contentDisposition) ?? "blob";
|
149
|
+
body = new File([blobData], filename, { type: contentType });
|
150
|
+
}
|
151
|
+
} else if (contentType?.startsWith("application/x-www-form-urlencoded") && typeof body === "string") {
|
152
|
+
body = new URLSearchParams(body);
|
153
|
+
}
|
154
|
+
return [id, 1 /* REQUEST */, { url: new URL(payload.u, "orpc:/"), headers, method: payload.m ?? "POST", body }];
|
155
|
+
}
|
156
|
+
async function encodeResponseMessage(id, type, payload) {
|
157
|
+
if (type === 3 /* EVENT_ITERATOR */) {
|
158
|
+
const eventPayload = payload;
|
159
|
+
const serializedPayload2 = {
|
160
|
+
e: eventPayload.event,
|
161
|
+
d: eventPayload.data,
|
162
|
+
m: eventPayload.meta
|
163
|
+
};
|
164
|
+
return encodeRawMessage({ i: id, t: type, p: serializedPayload2 });
|
165
|
+
}
|
166
|
+
if (type === 4 /* ABORT_SIGNAL */) {
|
167
|
+
return encodeRawMessage({ i: id, t: type, p: void 0 });
|
168
|
+
}
|
169
|
+
const response = payload;
|
170
|
+
const { body: processedBody, headers: processedHeaders } = await prepareBodyAndHeadersForSerialization(
|
171
|
+
response.body,
|
172
|
+
response.headers
|
173
|
+
);
|
174
|
+
const serializedPayload = {
|
175
|
+
s: response.status === 200 ? void 0 : response.status,
|
176
|
+
h: Object.keys(processedHeaders).length > 0 ? processedHeaders : void 0,
|
177
|
+
b: processedBody instanceof Blob ? void 0 : processedBody
|
178
|
+
};
|
179
|
+
const baseMessage = {
|
180
|
+
i: id,
|
181
|
+
p: serializedPayload
|
182
|
+
};
|
183
|
+
if (processedBody instanceof Blob) {
|
184
|
+
return encodeRawMessage(baseMessage, processedBody);
|
185
|
+
}
|
186
|
+
return encodeRawMessage(baseMessage);
|
187
|
+
}
|
188
|
+
async function decodeResponseMessage(raw) {
|
189
|
+
const { json: message, blobData } = await decodeRawMessage(raw);
|
190
|
+
const id = message.i;
|
191
|
+
const type = message.t;
|
192
|
+
if (type === 3 /* EVENT_ITERATOR */) {
|
193
|
+
const payload2 = message.p;
|
194
|
+
return [id, type, { event: payload2.e, data: payload2.d, meta: payload2.m }];
|
195
|
+
}
|
196
|
+
if (type === 4 /* ABORT_SIGNAL */) {
|
197
|
+
return [id, type, message.p];
|
198
|
+
}
|
199
|
+
const payload = message.p;
|
200
|
+
const headers = payload.h ?? {};
|
201
|
+
let body = payload.b;
|
202
|
+
const contentType = toArray(headers["content-type"])[0];
|
203
|
+
if (blobData) {
|
204
|
+
const contentDisposition = toArray(headers["content-disposition"])[0];
|
205
|
+
if (contentDisposition === void 0 && contentType?.startsWith("multipart/form-data")) {
|
206
|
+
const tempRes = new Response(blobData, { headers: { "content-type": contentType } });
|
207
|
+
body = await tempRes.formData();
|
208
|
+
} else {
|
209
|
+
const filename = getFilenameFromContentDisposition(contentDisposition) ?? "blob";
|
210
|
+
body = new File([blobData], filename, { type: contentType });
|
211
|
+
}
|
212
|
+
} else if (contentType?.startsWith("application/x-www-form-urlencoded") && typeof body === "string") {
|
213
|
+
body = new URLSearchParams(body);
|
214
|
+
}
|
215
|
+
return [id, 2 /* RESPONSE */, { status: payload.s ?? 200, headers, body }];
|
216
|
+
}
|
217
|
+
async function prepareBodyAndHeadersForSerialization(body, originalHeaders) {
|
218
|
+
const headers = { ...originalHeaders };
|
219
|
+
const originalContentDisposition = headers["content-disposition"];
|
220
|
+
delete headers["content-type"];
|
221
|
+
delete headers["content-disposition"];
|
222
|
+
if (body instanceof Blob) {
|
223
|
+
headers["content-type"] = body.type;
|
224
|
+
headers["content-disposition"] = originalContentDisposition ?? generateContentDisposition(
|
225
|
+
body instanceof File ? body.name : "blob"
|
226
|
+
);
|
227
|
+
return { body, headers };
|
228
|
+
}
|
229
|
+
if (body instanceof FormData) {
|
230
|
+
const tempRes = new Response(body);
|
231
|
+
const formDataBlob = await tempRes.blob();
|
232
|
+
headers["content-type"] = tempRes.headers.get("content-type");
|
233
|
+
return { body: formDataBlob, headers };
|
234
|
+
}
|
235
|
+
if (body instanceof URLSearchParams) {
|
236
|
+
headers["content-type"] = "application/x-www-form-urlencoded";
|
237
|
+
return { body: body.toString(), headers };
|
238
|
+
}
|
239
|
+
if (isAsyncIteratorObject(body)) {
|
240
|
+
headers["content-type"] = "text/event-stream";
|
241
|
+
return { body: void 0, headers };
|
242
|
+
}
|
243
|
+
return { body, headers };
|
244
|
+
}
|
245
|
+
function isEventIteratorHeaders(headers) {
|
246
|
+
return Boolean(toArray(headers["content-type"])[0]?.startsWith("text/event-stream") && headers["content-disposition"] === void 0);
|
247
|
+
}
|
248
|
+
const JSON_AND_BINARY_DELIMITER = 255;
|
249
|
+
async function encodeRawMessage(data, blobData) {
|
250
|
+
const json = stringifyJSON(data);
|
251
|
+
if (blobData === void 0) {
|
252
|
+
return json;
|
253
|
+
}
|
254
|
+
return new Blob([
|
255
|
+
new TextEncoder().encode(json),
|
256
|
+
new Uint8Array([JSON_AND_BINARY_DELIMITER]),
|
257
|
+
blobData
|
258
|
+
]);
|
259
|
+
}
|
260
|
+
async function decodeRawMessage(raw) {
|
261
|
+
if (typeof raw === "string") {
|
262
|
+
return { json: JSON.parse(raw) };
|
263
|
+
}
|
264
|
+
const buffer = new Uint8Array(raw instanceof Blob ? await raw.arrayBuffer() : raw);
|
265
|
+
const delimiterIndex = buffer.indexOf(JSON_AND_BINARY_DELIMITER);
|
266
|
+
if (delimiterIndex === -1) {
|
267
|
+
const jsonPart2 = new TextDecoder().decode(buffer);
|
268
|
+
return { json: JSON.parse(jsonPart2) };
|
269
|
+
}
|
270
|
+
const jsonPart = new TextDecoder().decode(buffer.slice(0, delimiterIndex));
|
271
|
+
const blobData = buffer.slice(delimiterIndex + 1);
|
272
|
+
return {
|
273
|
+
json: JSON.parse(jsonPart),
|
274
|
+
blobData
|
275
|
+
};
|
276
|
+
}
|
277
|
+
|
278
|
+
function toEventIterator(queue, id, options = {}) {
|
279
|
+
return createAsyncIteratorObject(async () => {
|
280
|
+
const item = await queue.pull(id);
|
281
|
+
switch (item.event) {
|
282
|
+
case "message": {
|
283
|
+
let data = item.data;
|
284
|
+
if (item.meta && isTypescriptObject(data)) {
|
285
|
+
data = withEventMeta(data, item.meta);
|
286
|
+
}
|
287
|
+
return { value: data, done: false };
|
288
|
+
}
|
289
|
+
case "error": {
|
290
|
+
let error = new ErrorEvent({
|
291
|
+
data: item.data
|
292
|
+
});
|
293
|
+
if (item.meta) {
|
294
|
+
error = withEventMeta(error, item.meta);
|
295
|
+
}
|
296
|
+
throw error;
|
297
|
+
}
|
298
|
+
case "done": {
|
299
|
+
let data = item.data;
|
300
|
+
if (item.meta && isTypescriptObject(data)) {
|
301
|
+
data = withEventMeta(data, item.meta);
|
302
|
+
}
|
303
|
+
return { value: data, done: true };
|
304
|
+
}
|
305
|
+
}
|
306
|
+
}, options);
|
307
|
+
}
|
308
|
+
async function sendEventIterator(queue, id, iterator, options = {}) {
|
309
|
+
let isInternal = false;
|
310
|
+
try {
|
311
|
+
while (true) {
|
312
|
+
isInternal = false;
|
313
|
+
const { value, done } = await iterator.next();
|
314
|
+
isInternal = true;
|
315
|
+
if (!queue.isOpen(id)) {
|
316
|
+
if (!done) {
|
317
|
+
isInternal = false;
|
318
|
+
await iterator.return?.();
|
319
|
+
isInternal = true;
|
320
|
+
}
|
321
|
+
return;
|
322
|
+
}
|
323
|
+
queue.push(id, {
|
324
|
+
event: done ? "done" : "message",
|
325
|
+
data: value,
|
326
|
+
meta: getEventMeta(value)
|
327
|
+
});
|
328
|
+
if (done) {
|
329
|
+
return;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
} catch (err) {
|
333
|
+
let currentError = err;
|
334
|
+
if (isInternal) {
|
335
|
+
try {
|
336
|
+
await iterator.throw?.(currentError);
|
337
|
+
} catch (err2) {
|
338
|
+
currentError = err2;
|
339
|
+
}
|
340
|
+
}
|
341
|
+
if (queue.isOpen(id)) {
|
342
|
+
queue.push(id, {
|
343
|
+
meta: getEventMeta(currentError),
|
344
|
+
event: "error",
|
345
|
+
data: currentError instanceof ErrorEvent ? currentError.data : void 0
|
346
|
+
});
|
347
|
+
}
|
348
|
+
} finally {
|
349
|
+
options.onComplete?.();
|
350
|
+
}
|
351
|
+
}
|
352
|
+
|
353
|
+
function toAbortSignal(queue, id) {
|
354
|
+
const controller = new AbortController();
|
355
|
+
queue.pull(id).then(() => {
|
356
|
+
controller.abort();
|
357
|
+
}).catch(() => {
|
358
|
+
});
|
359
|
+
return controller.signal;
|
360
|
+
}
|
361
|
+
|
362
|
+
class ClientPeer {
|
363
|
+
idGenerator = new SequentialIdGenerator();
|
364
|
+
clientRequestQueue;
|
365
|
+
clientEventIteratorQueue;
|
366
|
+
clientSignalQueue;
|
367
|
+
serverResponseQueue = new PullableAsyncIdQueue();
|
368
|
+
serverEventIterator = new PullableAsyncIdQueue();
|
369
|
+
serverSignalQueue = new PullableAsyncIdQueue();
|
370
|
+
constructor(send) {
|
371
|
+
this.clientRequestQueue = new ConsumableAsyncIdQueue((id, { signal, ...request }) => {
|
372
|
+
encodeRequestMessage(id, MessageType.REQUEST, request).then((raw) => {
|
373
|
+
send(raw);
|
374
|
+
if (signal) {
|
375
|
+
if (signal.aborted) {
|
376
|
+
this.clientSignalQueue.push(id);
|
377
|
+
this.close(id, signal.reason);
|
378
|
+
}
|
379
|
+
signal.addEventListener("abort", () => {
|
380
|
+
this.clientSignalQueue.push(id);
|
381
|
+
this.close(id, signal.reason);
|
382
|
+
}, { once: true });
|
383
|
+
}
|
384
|
+
if (isAsyncIteratorObject(request.body)) {
|
385
|
+
sendEventIterator(this.clientEventIteratorQueue, id, request.body);
|
386
|
+
const serverSignal = toAbortSignal(this.serverSignalQueue, id);
|
387
|
+
serverSignal.addEventListener("abort", () => {
|
388
|
+
this.clientEventIteratorQueue.close(id);
|
389
|
+
}, { once: true });
|
390
|
+
}
|
391
|
+
}).catch((err) => {
|
392
|
+
this.close(id, err);
|
393
|
+
});
|
394
|
+
});
|
395
|
+
this.clientEventIteratorQueue = new ConsumableAsyncIdQueue((id, payload) => {
|
396
|
+
encodeRequestMessage(id, MessageType.EVENT_ITERATOR, payload).then(send).catch((err) => {
|
397
|
+
this.close(id, err);
|
398
|
+
});
|
399
|
+
});
|
400
|
+
this.clientSignalQueue = new ConsumableAsyncIdQueue((id, payload) => {
|
401
|
+
encodeRequestMessage(id, MessageType.ABORT_SIGNAL, payload).then(send).catch((err) => {
|
402
|
+
this.close(id, err);
|
403
|
+
});
|
404
|
+
});
|
405
|
+
}
|
406
|
+
async request(request) {
|
407
|
+
const signal = request.signal;
|
408
|
+
if (signal?.aborted) {
|
409
|
+
throw signal.reason;
|
410
|
+
}
|
411
|
+
const id = this.idGenerator.generate();
|
412
|
+
this.open(id);
|
413
|
+
this.clientRequestQueue.push(id, request);
|
414
|
+
return new Promise((resolve, reject) => {
|
415
|
+
this.serverResponseQueue.pull(id).then(resolve).catch(reject);
|
416
|
+
});
|
417
|
+
}
|
418
|
+
async message(raw) {
|
419
|
+
const [id, type, payload] = await decodeResponseMessage(raw);
|
420
|
+
if (type === MessageType.EVENT_ITERATOR) {
|
421
|
+
if (this.serverEventIterator.isOpen(id)) {
|
422
|
+
this.serverEventIterator.push(id, payload);
|
423
|
+
}
|
424
|
+
return;
|
425
|
+
}
|
426
|
+
if (type === MessageType.ABORT_SIGNAL) {
|
427
|
+
if (this.serverSignalQueue.isOpen(id)) {
|
428
|
+
this.serverSignalQueue.push(id, payload);
|
429
|
+
}
|
430
|
+
return;
|
431
|
+
}
|
432
|
+
if (isEventIteratorHeaders(payload.headers)) {
|
433
|
+
this.serverResponseQueue.push(id, {
|
434
|
+
...payload,
|
435
|
+
body: toEventIterator(this.serverEventIterator, id, {
|
436
|
+
onComplete: (reason) => {
|
437
|
+
if (reason !== "next") {
|
438
|
+
this.clientSignalQueue.push(id);
|
439
|
+
}
|
440
|
+
this.close(id);
|
441
|
+
}
|
442
|
+
})
|
443
|
+
});
|
444
|
+
} else {
|
445
|
+
this.serverResponseQueue.push(id, payload);
|
446
|
+
this.close(id);
|
447
|
+
}
|
448
|
+
}
|
449
|
+
open(id) {
|
450
|
+
this.clientSignalQueue.open(id);
|
451
|
+
this.clientEventIteratorQueue.open(id);
|
452
|
+
this.clientRequestQueue.open(id);
|
453
|
+
this.serverSignalQueue.open(id);
|
454
|
+
this.serverEventIterator.open(id);
|
455
|
+
this.serverResponseQueue.open(id);
|
456
|
+
}
|
457
|
+
close(id, reason) {
|
458
|
+
if (id !== void 0) {
|
459
|
+
this.clientRequestQueue.close(id);
|
460
|
+
this.clientEventIteratorQueue.close(id);
|
461
|
+
this.clientSignalQueue.close(id);
|
462
|
+
this.serverResponseQueue.close(id, reason);
|
463
|
+
this.serverEventIterator.close(id, reason);
|
464
|
+
this.serverResponseQueue.close(id, reason);
|
465
|
+
} else {
|
466
|
+
this.clientRequestQueue.closeAll();
|
467
|
+
this.clientEventIteratorQueue.closeAll();
|
468
|
+
this.clientSignalQueue.closeAll();
|
469
|
+
this.serverResponseQueue.closeAll();
|
470
|
+
this.serverEventIterator.closeAll();
|
471
|
+
this.serverResponseQueue.closeAll();
|
472
|
+
}
|
473
|
+
}
|
474
|
+
}
|
475
|
+
|
476
|
+
class ServerPeer {
|
477
|
+
serverResponseQueue;
|
478
|
+
serverEventIteratorQueue;
|
479
|
+
serverSignalQueue;
|
480
|
+
clientEventIteratorQueue = new PullableAsyncIdQueue$1();
|
481
|
+
clientSignalQueue = new PullableAsyncIdQueue$1();
|
482
|
+
constructor(send) {
|
483
|
+
this.serverResponseQueue = new ConsumableAsyncIdQueue$1((id, response) => {
|
484
|
+
encodeResponseMessage(id, MessageType.RESPONSE, response).then(async (raw) => {
|
485
|
+
send(raw);
|
486
|
+
if (isAsyncIteratorObject(response.body)) {
|
487
|
+
await sendEventIterator(this.serverEventIteratorQueue, id, response.body, {
|
488
|
+
onComplete: () => {
|
489
|
+
this.close(id);
|
490
|
+
}
|
491
|
+
});
|
492
|
+
} else {
|
493
|
+
this.close(id);
|
494
|
+
}
|
495
|
+
}).catch((err) => {
|
496
|
+
this.close(id, err);
|
497
|
+
});
|
498
|
+
});
|
499
|
+
this.serverEventIteratorQueue = new ConsumableAsyncIdQueue$1((id, payload) => {
|
500
|
+
encodeResponseMessage(id, MessageType.EVENT_ITERATOR, payload).then(send).catch((err) => {
|
501
|
+
this.close(id, err);
|
502
|
+
});
|
503
|
+
});
|
504
|
+
this.serverSignalQueue = new ConsumableAsyncIdQueue$1((id, payload) => {
|
505
|
+
encodeResponseMessage(id, MessageType.ABORT_SIGNAL, payload).then(send).catch((err) => {
|
506
|
+
this.close(id, err);
|
507
|
+
});
|
508
|
+
});
|
509
|
+
}
|
510
|
+
async message(raw) {
|
511
|
+
const [id, type, payload] = await decodeRequestMessage(raw);
|
512
|
+
if (type === MessageType.ABORT_SIGNAL) {
|
513
|
+
if (this.clientSignalQueue.isOpen(id)) {
|
514
|
+
this.clientSignalQueue.push(id, payload);
|
515
|
+
}
|
516
|
+
return [id, void 0];
|
517
|
+
}
|
518
|
+
if (type === MessageType.EVENT_ITERATOR) {
|
519
|
+
if (this.clientEventIteratorQueue.isOpen(id)) {
|
520
|
+
this.clientEventIteratorQueue.push(id, payload);
|
521
|
+
}
|
522
|
+
return [id, void 0];
|
523
|
+
}
|
524
|
+
this.open(id);
|
525
|
+
const clientSignal = toAbortSignal(this.clientSignalQueue, id);
|
526
|
+
clientSignal.addEventListener("abort", () => {
|
527
|
+
this.close(id, clientSignal.reason);
|
528
|
+
}, { once: true });
|
529
|
+
const request = {
|
530
|
+
...payload,
|
531
|
+
signal: clientSignal,
|
532
|
+
body: isEventIteratorHeaders(payload.headers) ? toEventIterator(this.clientEventIteratorQueue, id, {
|
533
|
+
onComplete: (reason) => {
|
534
|
+
if (reason !== "next") {
|
535
|
+
this.serverSignalQueue.push(id);
|
536
|
+
}
|
537
|
+
}
|
538
|
+
}) : payload.body
|
539
|
+
};
|
540
|
+
return [id, request];
|
541
|
+
}
|
542
|
+
async response(id, response) {
|
543
|
+
if (this.serverResponseQueue.isOpen(id)) {
|
544
|
+
this.serverResponseQueue.push(id, response);
|
545
|
+
}
|
546
|
+
}
|
547
|
+
open(id) {
|
548
|
+
this.serverSignalQueue.open(id);
|
549
|
+
this.serverEventIteratorQueue.open(id);
|
550
|
+
this.serverResponseQueue.open(id);
|
551
|
+
this.clientEventIteratorQueue.open(id);
|
552
|
+
this.clientSignalQueue.open(id);
|
553
|
+
}
|
554
|
+
close(id, reason) {
|
555
|
+
if (id !== void 0) {
|
556
|
+
this.serverResponseQueue.close(id);
|
557
|
+
this.serverEventIteratorQueue.close(id);
|
558
|
+
this.serverResponseQueue.close(id);
|
559
|
+
this.clientEventIteratorQueue.close(id, reason);
|
560
|
+
this.clientSignalQueue.close(id, reason);
|
561
|
+
} else {
|
562
|
+
this.serverResponseQueue.closeAll();
|
563
|
+
this.serverEventIteratorQueue.closeAll();
|
564
|
+
this.serverResponseQueue.closeAll();
|
565
|
+
this.clientEventIteratorQueue.closeAll();
|
566
|
+
this.clientSignalQueue.closeAll();
|
567
|
+
}
|
568
|
+
}
|
569
|
+
}
|
570
|
+
|
571
|
+
export { ClientPeer, MessageType, ServerPeer, decodeRequestMessage, decodeResponseMessage, encodeRequestMessage, encodeResponseMessage, isEventIteratorHeaders, sendEventIterator, toAbortSignal, toEventIterator };
|
package/package.json
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"name": "@orpc/standard-server-peer",
|
3
|
+
"type": "module",
|
4
|
+
"version": "0.0.0",
|
5
|
+
"license": "MIT",
|
6
|
+
"homepage": "https://unnoq.com",
|
7
|
+
"repository": {
|
8
|
+
"type": "git",
|
9
|
+
"url": "git+https://github.com/unnoq/orpc.git",
|
10
|
+
"directory": "packages/standard-server-peer"
|
11
|
+
},
|
12
|
+
"keywords": [
|
13
|
+
"orpc"
|
14
|
+
],
|
15
|
+
"exports": {
|
16
|
+
".": {
|
17
|
+
"types": "./dist/index.d.mts",
|
18
|
+
"import": "./dist/index.mjs",
|
19
|
+
"default": "./dist/index.mjs"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"files": [
|
23
|
+
"dist"
|
24
|
+
],
|
25
|
+
"dependencies": {
|
26
|
+
"@orpc/shared": "1.1.1",
|
27
|
+
"@orpc/standard-server": "1.1.1"
|
28
|
+
},
|
29
|
+
"scripts": {
|
30
|
+
"build": "unbuild",
|
31
|
+
"build:watch": "pnpm run build --watch",
|
32
|
+
"type:check": "tsc -b"
|
33
|
+
}
|
34
|
+
}
|