@trpc/client 11.3.1 → 11.3.2-canary.4
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/TRPCClientError-CGgRtttT.cjs +67 -0
- package/dist/TRPCClientError-COkhCKf3.mjs +56 -0
- package/dist/TRPCClientError-COkhCKf3.mjs.map +1 -0
- package/dist/chunk-DWy1uDak.cjs +39 -0
- package/dist/httpBatchLink-CIC9PZ_Z.cjs +267 -0
- package/dist/httpBatchLink-DIfnmmcu.mjs +238 -0
- package/dist/httpBatchLink-DIfnmmcu.mjs.map +1 -0
- package/dist/httpBatchLink.d-BN2Iw_cK.d.mts +33 -0
- package/dist/httpBatchLink.d-BN2Iw_cK.d.mts.map +1 -0
- package/dist/httpBatchLink.d-CLAuJKNV.d.cts +33 -0
- package/dist/httpBatchLink.d-CLAuJKNV.d.cts.map +1 -0
- package/dist/httpLink-9bpwQ15c.mjs +90 -0
- package/dist/httpLink-9bpwQ15c.mjs.map +1 -0
- package/dist/httpLink-BbVj_TgM.cjs +113 -0
- package/dist/httpLink.d-CTSOARfE.d.mts +23 -0
- package/dist/httpLink.d-CTSOARfE.d.mts.map +1 -0
- package/dist/httpLink.d-yMKfOlTU.d.cts +23 -0
- package/dist/httpLink.d-yMKfOlTU.d.cts.map +1 -0
- package/dist/httpUtils-3pbQzhUL.mjs +123 -0
- package/dist/httpUtils-3pbQzhUL.mjs.map +1 -0
- package/dist/httpUtils-Buf6jCgh.cjs +163 -0
- package/dist/httpUtils.d-C8wPxU79.d.mts +25 -0
- package/dist/httpUtils.d-C8wPxU79.d.mts.map +1 -0
- package/dist/httpUtils.d-DNRVGNHs.d.cts +25 -0
- package/dist/httpUtils.d-DNRVGNHs.d.cts.map +1 -0
- package/dist/index.cjs +736 -0
- package/dist/index.d.cts +201 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +201 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +737 -16
- package/dist/index.mjs.map +1 -0
- package/dist/links/httpBatchLink.cjs +6 -0
- package/dist/links/httpBatchLink.d.cts +6 -0
- package/dist/links/httpBatchLink.d.mts +6 -0
- package/dist/links/httpBatchLink.mjs +5 -107
- package/dist/links/httpLink.cjs +6 -0
- package/dist/links/httpLink.d.cts +6 -0
- package/dist/links/httpLink.d.mts +6 -0
- package/dist/links/httpLink.mjs +5 -92
- package/dist/links/loggerLink.cjs +3 -0
- package/dist/links/loggerLink.d.cts +4 -0
- package/dist/links/loggerLink.d.mts +4 -0
- package/dist/links/loggerLink.mjs +2 -175
- package/dist/links/splitLink.cjs +3 -0
- package/dist/links/splitLink.d.cts +4 -0
- package/dist/links/splitLink.d.mts +4 -0
- package/dist/links/splitLink.mjs +2 -24
- package/dist/links/wsLink/wsLink.cjs +6 -0
- package/dist/links/wsLink/wsLink.d.cts +5 -0
- package/dist/links/wsLink/wsLink.d.mts +5 -0
- package/dist/links/wsLink/wsLink.mjs +4 -31
- package/dist/loggerLink-CsDfg5Bb.cjs +130 -0
- package/dist/loggerLink-PGBSQFcR.mjs +125 -0
- package/dist/loggerLink-PGBSQFcR.mjs.map +1 -0
- package/dist/loggerLink.d-CZjK1CXm.d.mts +54 -0
- package/dist/loggerLink.d-CZjK1CXm.d.mts.map +1 -0
- package/dist/loggerLink.d-DU855urG.d.cts +54 -0
- package/dist/loggerLink.d-DU855urG.d.cts.map +1 -0
- package/dist/splitLink-BMgxggng.cjs +58 -0
- package/dist/splitLink-BVblHq4n.mjs +47 -0
- package/dist/splitLink-BVblHq4n.mjs.map +1 -0
- package/dist/splitLink.d-BAqgq0NG.d.mts +20 -0
- package/dist/splitLink.d-BAqgq0NG.d.mts.map +1 -0
- package/dist/splitLink.d-GdevSkGW.d.cts +20 -0
- package/dist/splitLink.d-GdevSkGW.d.cts.map +1 -0
- package/dist/subscriptions.d-Ciljg_dH.d.cts +19 -0
- package/dist/subscriptions.d-Ciljg_dH.d.cts.map +1 -0
- package/dist/subscriptions.d-U92STdZl.d.mts +19 -0
- package/dist/subscriptions.d-U92STdZl.d.mts.map +1 -0
- package/dist/types.d-DXbqQLCC.d.mts +182 -0
- package/dist/types.d-DXbqQLCC.d.mts.map +1 -0
- package/dist/types.d-DqGYG6S_.d.cts +182 -0
- package/dist/types.d-DqGYG6S_.d.cts.map +1 -0
- package/dist/unstable-internals-CYBH4jbF.cjs +34 -0
- package/dist/unstable-internals-DU4WecoG.mjs +29 -0
- package/dist/unstable-internals-DU4WecoG.mjs.map +1 -0
- package/dist/unstable-internals.cjs +3 -0
- package/dist/unstable-internals.d-DyLd-B0J.d.mts +46 -0
- package/dist/unstable-internals.d-DyLd-B0J.d.mts.map +1 -0
- package/dist/unstable-internals.d-kWsZTlQq.d.cts +46 -0
- package/dist/unstable-internals.d-kWsZTlQq.d.cts.map +1 -0
- package/dist/unstable-internals.d.cts +3 -0
- package/dist/unstable-internals.d.mts +3 -0
- package/dist/unstable-internals.mjs +3 -1
- package/dist/wsLink-DbSHOzlB.mjs +698 -0
- package/dist/wsLink-DbSHOzlB.mjs.map +1 -0
- package/dist/wsLink-DhJ50EC5.cjs +715 -0
- package/dist/wsLink.d-BqO7ltN_.d.mts +194 -0
- package/dist/wsLink.d-BqO7ltN_.d.mts.map +1 -0
- package/dist/wsLink.d-DtZjg09g.d.cts +194 -0
- package/dist/wsLink.d-DtZjg09g.d.cts.map +1 -0
- package/links/httpBatchLink/package.json +1 -0
- package/links/httpLink/package.json +1 -0
- package/links/loggerLink/package.json +1 -0
- package/links/splitLink/package.json +1 -0
- package/links/wsLink/wsLink/package.json +1 -0
- package/package.json +67 -33
- package/src/links/localLink.ts +6 -1
- package/unstable-internals/package.json +1 -0
- package/dist/TRPCClientError.d.ts +0 -30
- package/dist/TRPCClientError.d.ts.map +0 -1
- package/dist/TRPCClientError.js +0 -79
- package/dist/TRPCClientError.mjs +0 -76
- package/dist/createTRPCClient.d.ts +0 -69
- package/dist/createTRPCClient.d.ts.map +0 -1
- package/dist/createTRPCClient.js +0 -48
- package/dist/createTRPCClient.mjs +0 -43
- package/dist/createTRPCUntypedClient.d.ts +0 -7
- package/dist/createTRPCUntypedClient.d.ts.map +0 -1
- package/dist/createTRPCUntypedClient.js +0 -10
- package/dist/createTRPCUntypedClient.mjs +0 -7
- package/dist/getFetch.d.ts +0 -3
- package/dist/getFetch.d.ts.map +0 -1
- package/dist/getFetch.js +0 -17
- package/dist/getFetch.mjs +0 -15
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -46
- package/dist/internals/TRPCUntypedClient.d.ts +0 -39
- package/dist/internals/TRPCUntypedClient.d.ts.map +0 -1
- package/dist/internals/TRPCUntypedClient.js +0 -115
- package/dist/internals/TRPCUntypedClient.mjs +0 -113
- package/dist/internals/dataLoader.d.ts +0 -13
- package/dist/internals/dataLoader.d.ts.map +0 -1
- package/dist/internals/dataLoader.js +0 -117
- package/dist/internals/dataLoader.mjs +0 -115
- package/dist/internals/inputWithTrackedEventId.d.ts +0 -2
- package/dist/internals/inputWithTrackedEventId.d.ts.map +0 -1
- package/dist/internals/inputWithTrackedEventId.js +0 -16
- package/dist/internals/inputWithTrackedEventId.mjs +0 -14
- package/dist/internals/signals.d.ts +0 -16
- package/dist/internals/signals.d.ts.map +0 -1
- package/dist/internals/signals.js +0 -61
- package/dist/internals/signals.mjs +0 -57
- package/dist/internals/transformer.d.ts +0 -42
- package/dist/internals/transformer.d.ts.map +0 -1
- package/dist/internals/transformer.js +0 -30
- package/dist/internals/transformer.mjs +0 -28
- package/dist/internals/types.d.ts +0 -82
- package/dist/internals/types.d.ts.map +0 -1
- package/dist/links/HTTPBatchLinkOptions.d.ts +0 -20
- package/dist/links/HTTPBatchLinkOptions.d.ts.map +0 -1
- package/dist/links/httpBatchLink.d.ts +0 -8
- package/dist/links/httpBatchLink.d.ts.map +0 -1
- package/dist/links/httpBatchLink.js +0 -110
- package/dist/links/httpBatchStreamLink.d.ts +0 -12
- package/dist/links/httpBatchStreamLink.d.ts.map +0 -1
- package/dist/links/httpBatchStreamLink.js +0 -150
- package/dist/links/httpBatchStreamLink.mjs +0 -147
- package/dist/links/httpLink.d.ts +0 -17
- package/dist/links/httpLink.d.ts.map +0 -1
- package/dist/links/httpLink.js +0 -95
- package/dist/links/httpSubscriptionLink.d.ts +0 -26
- package/dist/links/httpSubscriptionLink.d.ts.map +0 -1
- package/dist/links/httpSubscriptionLink.js +0 -177
- package/dist/links/httpSubscriptionLink.mjs +0 -174
- package/dist/links/internals/contentTypes.d.ts +0 -4
- package/dist/links/internals/contentTypes.d.ts.map +0 -1
- package/dist/links/internals/contentTypes.js +0 -16
- package/dist/links/internals/contentTypes.mjs +0 -12
- package/dist/links/internals/createChain.d.ts +0 -8
- package/dist/links/internals/createChain.d.ts.map +0 -1
- package/dist/links/internals/createChain.js +0 -26
- package/dist/links/internals/createChain.mjs +0 -24
- package/dist/links/internals/dedupeLink.d.ts +0 -7
- package/dist/links/internals/dedupeLink.d.ts.map +0 -1
- package/dist/links/internals/httpUtils.d.ts +0 -68
- package/dist/links/internals/httpUtils.d.ts.map +0 -1
- package/dist/links/internals/httpUtils.js +0 -141
- package/dist/links/internals/httpUtils.mjs +0 -133
- package/dist/links/internals/subscriptions.d.ts +0 -17
- package/dist/links/internals/subscriptions.d.ts.map +0 -1
- package/dist/links/internals/urlWithConnectionParams.d.ts +0 -23
- package/dist/links/internals/urlWithConnectionParams.d.ts.map +0 -1
- package/dist/links/internals/urlWithConnectionParams.js +0 -10
- package/dist/links/internals/urlWithConnectionParams.mjs +0 -8
- package/dist/links/localLink.d.ts +0 -15
- package/dist/links/localLink.d.ts.map +0 -1
- package/dist/links/localLink.js +0 -333
- package/dist/links/localLink.mjs +0 -331
- package/dist/links/loggerLink.d.ts +0 -52
- package/dist/links/loggerLink.d.ts.map +0 -1
- package/dist/links/loggerLink.js +0 -178
- package/dist/links/retryLink.d.ts +0 -33
- package/dist/links/retryLink.d.ts.map +0 -1
- package/dist/links/retryLink.js +0 -72
- package/dist/links/retryLink.mjs +0 -70
- package/dist/links/splitLink.d.ts +0 -14
- package/dist/links/splitLink.d.ts.map +0 -1
- package/dist/links/splitLink.js +0 -27
- package/dist/links/types.d.ts +0 -63
- package/dist/links/types.d.ts.map +0 -1
- package/dist/links/wsLink/createWsClient.d.ts +0 -6
- package/dist/links/wsLink/createWsClient.d.ts.map +0 -1
- package/dist/links/wsLink/createWsClient.js +0 -9
- package/dist/links/wsLink/createWsClient.mjs +0 -7
- package/dist/links/wsLink/wsClient/options.d.ts +0 -79
- package/dist/links/wsLink/wsClient/options.d.ts.map +0 -1
- package/dist/links/wsLink/wsClient/options.js +0 -22
- package/dist/links/wsLink/wsClient/options.mjs +0 -18
- package/dist/links/wsLink/wsClient/requestManager.d.ts +0 -106
- package/dist/links/wsLink/wsClient/requestManager.d.ts.map +0 -1
- package/dist/links/wsLink/wsClient/requestManager.js +0 -143
- package/dist/links/wsLink/wsClient/requestManager.mjs +0 -141
- package/dist/links/wsLink/wsClient/utils.d.ts +0 -38
- package/dist/links/wsLink/wsClient/utils.d.ts.map +0 -1
- package/dist/links/wsLink/wsClient/utils.js +0 -94
- package/dist/links/wsLink/wsClient/utils.mjs +0 -88
- package/dist/links/wsLink/wsClient/wsClient.d.ts +0 -84
- package/dist/links/wsLink/wsClient/wsClient.d.ts.map +0 -1
- package/dist/links/wsLink/wsClient/wsClient.js +0 -325
- package/dist/links/wsLink/wsClient/wsClient.mjs +0 -323
- package/dist/links/wsLink/wsClient/wsConnection.d.ts +0 -79
- package/dist/links/wsLink/wsClient/wsConnection.d.ts.map +0 -1
- package/dist/links/wsLink/wsClient/wsConnection.js +0 -188
- package/dist/links/wsLink/wsClient/wsConnection.mjs +0 -185
- package/dist/links/wsLink/wsLink.d.ts +0 -11
- package/dist/links/wsLink/wsLink.d.ts.map +0 -1
- package/dist/links/wsLink/wsLink.js +0 -35
- package/dist/links.d.ts +0 -12
- package/dist/links.d.ts.map +0 -1
- package/dist/unstable-internals.d.ts +0 -3
- package/dist/unstable-internals.d.ts.map +0 -1
- package/dist/unstable-internals.js +0 -7
- package/links/httpBatchLink/index.d.ts +0 -1
- package/links/httpBatchLink/index.js +0 -1
- package/links/httpLink/index.d.ts +0 -1
- package/links/httpLink/index.js +0 -1
- package/links/loggerLink/index.d.ts +0 -1
- package/links/loggerLink/index.js +0 -1
- package/links/splitLink/index.d.ts +0 -1
- package/links/splitLink/index.js +0 -1
- package/links/wsLink/index.d.ts +0 -1
- package/links/wsLink/index.js +0 -1
- package/links/wsLink/wsLink/index.d.ts +0 -1
- package/links/wsLink/wsLink/index.js +0 -1
- package/unstable-internals/index.d.ts +0 -1
- package/unstable-internals/index.js +0 -1
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { behaviorSubject } from '@trpc/server/observable';
|
|
2
|
-
import { prepareUrl, buildConnectionMessage, withResolvers } from './utils.mjs';
|
|
3
|
-
|
|
4
|
-
function _define_property(obj, key, value) {
|
|
5
|
-
if (key in obj) {
|
|
6
|
-
Object.defineProperty(obj, key, {
|
|
7
|
-
value: value,
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true
|
|
11
|
-
});
|
|
12
|
-
} else {
|
|
13
|
-
obj[key] = value;
|
|
14
|
-
}
|
|
15
|
-
return obj;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Opens a WebSocket connection asynchronously and returns a promise
|
|
19
|
-
* that resolves when the connection is successfully established.
|
|
20
|
-
* The promise rejects if an error occurs during the connection attempt.
|
|
21
|
-
*/ function asyncWsOpen(ws) {
|
|
22
|
-
const { promise, resolve, reject } = withResolvers();
|
|
23
|
-
ws.addEventListener('open', ()=>{
|
|
24
|
-
ws.removeEventListener('error', reject);
|
|
25
|
-
resolve();
|
|
26
|
-
});
|
|
27
|
-
ws.addEventListener('error', reject);
|
|
28
|
-
return promise;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Sets up a periodic ping-pong mechanism to keep the WebSocket connection alive.
|
|
32
|
-
*
|
|
33
|
-
* - Sends "PING" messages at regular intervals defined by `intervalMs`.
|
|
34
|
-
* - If a "PONG" response is not received within the `pongTimeoutMs`, the WebSocket is closed.
|
|
35
|
-
* - The ping timer resets upon receiving any message to maintain activity.
|
|
36
|
-
* - Automatically starts the ping process when the WebSocket connection is opened.
|
|
37
|
-
* - Cleans up timers when the WebSocket is closed.
|
|
38
|
-
*
|
|
39
|
-
* @param ws - The WebSocket instance to manage.
|
|
40
|
-
* @param options - Configuration options for ping-pong intervals and timeouts.
|
|
41
|
-
*/ function setupPingInterval(ws, { intervalMs, pongTimeoutMs }) {
|
|
42
|
-
let pingTimeout;
|
|
43
|
-
let pongTimeout;
|
|
44
|
-
function start() {
|
|
45
|
-
pingTimeout = setTimeout(()=>{
|
|
46
|
-
ws.send('PING');
|
|
47
|
-
pongTimeout = setTimeout(()=>{
|
|
48
|
-
ws.close();
|
|
49
|
-
}, pongTimeoutMs);
|
|
50
|
-
}, intervalMs);
|
|
51
|
-
}
|
|
52
|
-
function reset() {
|
|
53
|
-
clearTimeout(pingTimeout);
|
|
54
|
-
start();
|
|
55
|
-
}
|
|
56
|
-
function pong() {
|
|
57
|
-
clearTimeout(pongTimeout);
|
|
58
|
-
reset();
|
|
59
|
-
}
|
|
60
|
-
ws.addEventListener('open', start);
|
|
61
|
-
ws.addEventListener('message', ({ data })=>{
|
|
62
|
-
clearTimeout(pingTimeout);
|
|
63
|
-
start();
|
|
64
|
-
if (data === 'PONG') {
|
|
65
|
-
pong();
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
ws.addEventListener('close', ()=>{
|
|
69
|
-
clearTimeout(pingTimeout);
|
|
70
|
-
clearTimeout(pongTimeout);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Manages a WebSocket connection with support for reconnection, keep-alive mechanisms,
|
|
75
|
-
* and observable state tracking.
|
|
76
|
-
*/ class WsConnection {
|
|
77
|
-
get ws() {
|
|
78
|
-
return this.wsObservable.get();
|
|
79
|
-
}
|
|
80
|
-
set ws(ws) {
|
|
81
|
-
this.wsObservable.next(ws);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Checks if the WebSocket connection is open and ready to communicate.
|
|
85
|
-
*/ isOpen() {
|
|
86
|
-
return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Checks if the WebSocket connection is closed or in the process of closing.
|
|
90
|
-
*/ isClosed() {
|
|
91
|
-
return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
|
|
92
|
-
}
|
|
93
|
-
async open() {
|
|
94
|
-
if (this.openPromise) return this.openPromise;
|
|
95
|
-
this.id = ++WsConnection.connectCount;
|
|
96
|
-
const wsPromise = prepareUrl(this.urlOptions).then((url)=>new this.WebSocketPonyfill(url));
|
|
97
|
-
this.openPromise = wsPromise.then(async (ws)=>{
|
|
98
|
-
this.ws = ws;
|
|
99
|
-
// Setup ping listener
|
|
100
|
-
ws.addEventListener('message', function({ data }) {
|
|
101
|
-
if (data === 'PING') {
|
|
102
|
-
this.send('PONG');
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
if (this.keepAliveOpts.enabled) {
|
|
106
|
-
setupPingInterval(ws, this.keepAliveOpts);
|
|
107
|
-
}
|
|
108
|
-
ws.addEventListener('close', ()=>{
|
|
109
|
-
if (this.ws === ws) {
|
|
110
|
-
this.ws = null;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
await asyncWsOpen(ws);
|
|
114
|
-
if (this.urlOptions.connectionParams) {
|
|
115
|
-
ws.send(await buildConnectionMessage(this.urlOptions.connectionParams));
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
try {
|
|
119
|
-
await this.openPromise;
|
|
120
|
-
} finally{
|
|
121
|
-
this.openPromise = null;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Closes the WebSocket connection gracefully.
|
|
126
|
-
* Waits for any ongoing open operation to complete before closing.
|
|
127
|
-
*/ async close() {
|
|
128
|
-
try {
|
|
129
|
-
await this.openPromise;
|
|
130
|
-
} finally{
|
|
131
|
-
this.ws?.close();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
constructor(opts){
|
|
135
|
-
_define_property(this, "id", ++WsConnection.connectCount);
|
|
136
|
-
_define_property(this, "WebSocketPonyfill", void 0);
|
|
137
|
-
_define_property(this, "urlOptions", void 0);
|
|
138
|
-
_define_property(this, "keepAliveOpts", void 0);
|
|
139
|
-
_define_property(this, "wsObservable", behaviorSubject(null));
|
|
140
|
-
/**
|
|
141
|
-
* Manages the WebSocket opening process, ensuring that only one open operation
|
|
142
|
-
* occurs at a time. Tracks the ongoing operation with `openPromise` to avoid
|
|
143
|
-
* redundant calls and ensure proper synchronization.
|
|
144
|
-
*
|
|
145
|
-
* Sets up the keep-alive mechanism and necessary event listeners for the connection.
|
|
146
|
-
*
|
|
147
|
-
* @returns A promise that resolves once the WebSocket connection is successfully opened.
|
|
148
|
-
*/ _define_property(this, "openPromise", null);
|
|
149
|
-
this.WebSocketPonyfill = opts.WebSocketPonyfill ?? WebSocket;
|
|
150
|
-
if (!this.WebSocketPonyfill) {
|
|
151
|
-
throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
|
|
152
|
-
}
|
|
153
|
-
this.urlOptions = opts.urlOptions;
|
|
154
|
-
this.keepAliveOpts = opts.keepAlive;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
_define_property(WsConnection, "connectCount", 0);
|
|
158
|
-
/**
|
|
159
|
-
* Provides a backward-compatible representation of the connection state.
|
|
160
|
-
*/ function backwardCompatibility(connection) {
|
|
161
|
-
if (connection.isOpen()) {
|
|
162
|
-
return {
|
|
163
|
-
id: connection.id,
|
|
164
|
-
state: 'open',
|
|
165
|
-
ws: connection.ws
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
if (connection.isClosed()) {
|
|
169
|
-
return {
|
|
170
|
-
id: connection.id,
|
|
171
|
-
state: 'closed',
|
|
172
|
-
ws: connection.ws
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
if (!connection.ws) {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
id: connection.id,
|
|
180
|
-
state: 'connecting',
|
|
181
|
-
ws: connection.ws
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export { WsConnection, backwardCompatibility };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AnyRouter, inferClientTypes } from '@trpc/server/unstable-core-do-not-import';
|
|
2
|
-
import type { TransformerOptions } from '../../unstable-internals';
|
|
3
|
-
import type { TRPCLink } from '../types';
|
|
4
|
-
import type { TRPCWebSocketClient, WebSocketClientOptions } from './createWsClient';
|
|
5
|
-
import { createWSClient } from './createWsClient';
|
|
6
|
-
export type WebSocketLinkOptions<TRouter extends AnyRouter> = {
|
|
7
|
-
client: TRPCWebSocketClient;
|
|
8
|
-
} & TransformerOptions<inferClientTypes<TRouter>>;
|
|
9
|
-
export declare function wsLink<TRouter extends AnyRouter>(opts: WebSocketLinkOptions<TRouter>): TRPCLink<TRouter>;
|
|
10
|
-
export { TRPCWebSocketClient, WebSocketClientOptions, createWSClient };
|
|
11
|
-
//# sourceMappingURL=wsLink.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wsLink.d.ts","sourceRoot":"","sources":["../../../src/links/wsLink/wsLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,SAAS,IAAI;IAC5D,MAAM,EAAE,mBAAmB,CAAC;CAC7B,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAElD,wBAAgB,MAAM,CAAC,OAAO,SAAS,SAAS,EAC9C,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAClC,QAAQ,CAAC,OAAO,CAAC,CAgCnB;AAED,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var observable = require('@trpc/server/observable');
|
|
4
|
-
var transformer = require('../../internals/transformer.js');
|
|
5
|
-
var createWsClient = require('./createWsClient.js');
|
|
6
|
-
|
|
7
|
-
function wsLink(opts) {
|
|
8
|
-
const { client } = opts;
|
|
9
|
-
const transformer$1 = transformer.getTransformer(opts.transformer);
|
|
10
|
-
return ()=>{
|
|
11
|
-
return ({ op })=>{
|
|
12
|
-
return observable.observable((observer)=>{
|
|
13
|
-
const connStateSubscription = op.type === 'subscription' ? client.connectionState.subscribe({
|
|
14
|
-
next (result) {
|
|
15
|
-
observer.next({
|
|
16
|
-
result,
|
|
17
|
-
context: op.context
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}) : null;
|
|
21
|
-
const requestSubscription = client.request({
|
|
22
|
-
op,
|
|
23
|
-
transformer: transformer$1
|
|
24
|
-
}).subscribe(observer);
|
|
25
|
-
return ()=>{
|
|
26
|
-
requestSubscription.unsubscribe();
|
|
27
|
-
connStateSubscription?.unsubscribe();
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
exports.createWSClient = createWsClient.createWSClient;
|
|
35
|
-
exports.wsLink = wsLink;
|
package/dist/links.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './links/types';
|
|
2
|
-
export * from './links/HTTPBatchLinkOptions';
|
|
3
|
-
export * from './links/httpBatchLink';
|
|
4
|
-
export * from './links/httpBatchStreamLink';
|
|
5
|
-
export * from './links/httpLink';
|
|
6
|
-
export * from './links/loggerLink';
|
|
7
|
-
export * from './links/splitLink';
|
|
8
|
-
export * from './links/wsLink/wsLink';
|
|
9
|
-
export * from './links/httpSubscriptionLink';
|
|
10
|
-
export * from './links/retryLink';
|
|
11
|
-
export * from './links/localLink';
|
|
12
|
-
//# sourceMappingURL=links.d.ts.map
|
package/dist/links.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAE9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unstable-internals.d.ts","sourceRoot":"","sources":["../src/unstable-internals.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,iCAAiC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/links/httpBatchLink';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/links/httpBatchLink');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/links/httpLink';
|
package/links/httpLink/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/links/httpLink');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/links/loggerLink';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/links/loggerLink');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/links/splitLink';
|
package/links/splitLink/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/links/splitLink');
|
package/links/wsLink/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/links/wsLink';
|
package/links/wsLink/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../dist/links/wsLink');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../../dist/links/wsLink/wsLink';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../../../dist/links/wsLink/wsLink');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../dist/unstable-internals';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('../dist/unstable-internals');
|