@trpc/server 11.0.0-rc.632 → 11.0.0-rc.633
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/adapters/node-http/writeResponse.d.ts.map +1 -1
- package/dist/adapters/node-http/writeResponse.js +0 -5
- package/dist/adapters/node-http/writeResponse.mjs +0 -5
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +82 -82
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +3 -3
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +3 -3
- package/dist/unstable-core-do-not-import/initTRPC.js +2 -2
- package/dist/unstable-core-do-not-import/initTRPC.mjs +2 -2
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +14 -14
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +7 -10
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +11 -1
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.js +129 -65
- package/dist/unstable-core-do-not-import/stream/sse.mjs +129 -65
- package/dist/unstable-core-do-not-import/transformer.d.ts +1 -4
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/node-http/writeResponse.ts +0 -5
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +3 -4
- package/src/unstable-core-do-not-import/initTRPC.ts +1 -1
- package/src/unstable-core-do-not-import/rootConfig.ts +17 -17
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +7 -12
- package/src/unstable-core-do-not-import/stream/sse.ts +155 -67
|
@@ -54,23 +54,23 @@ export interface RootConfig<TTypes extends RootTypes> {
|
|
|
54
54
|
*/
|
|
55
55
|
isDev: boolean;
|
|
56
56
|
defaultMeta?: TTypes['meta'] extends object ? TTypes['meta'] : never;
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Enable support for returning async iterables and returning deferred promises when using `httpBatchStreamLink`
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
iterablesAndDeferreds?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Options for server-sent events (SSE) subscriptions
|
|
64
|
+
* @see https://trpc.io/docs/client/links/httpSubscriptionLink
|
|
65
|
+
*/
|
|
66
|
+
sse?: {
|
|
58
67
|
/**
|
|
59
|
-
* Enable
|
|
68
|
+
* Enable server-sent events (SSE) subscriptions
|
|
60
69
|
* @default true
|
|
61
70
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*/
|
|
66
|
-
sseSubscriptions?: {
|
|
67
|
-
/**
|
|
68
|
-
* Enable server-sent events (SSE) subscriptions
|
|
69
|
-
* @default true
|
|
70
|
-
*/
|
|
71
|
-
enabled?: boolean;
|
|
72
|
-
} & Pick<SSEStreamProducerOptions, 'ping' | 'emitAndEndImmediately' | 'maxDurationMs'>;
|
|
73
|
-
};
|
|
71
|
+
enabled?: boolean;
|
|
72
|
+
} & Pick<SSEStreamProducerOptions, 'ping' | 'emitAndEndImmediately' | 'maxDurationMs'>;
|
|
73
|
+
experimental?: {};
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootConfig.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/rootConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,wBAAwB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,EACR,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACvC,SAAS,CACX,MAAM,SAAS,QAAQ,GAAG,IAAI,GAAG,KAAK,EACtC;IACE;;QAEI;IACJ,aAAa,EAAE,SAAS,CAAC;CAC1B,CACF,CAAC"}
|
|
@@ -45,10 +45,13 @@ export interface TRPCRequest extends JSONRPC2.Request<ProcedureType, {
|
|
|
45
45
|
}
|
|
46
46
|
export interface TRPCResult<TData = unknown> {
|
|
47
47
|
data: TData;
|
|
48
|
-
}
|
|
49
|
-
export interface TRPCSuccessResponse<TData> extends JSONRPC2.ResultResponse<TRPCResult<TData> & {
|
|
50
48
|
type?: 'data';
|
|
51
|
-
|
|
49
|
+
/**
|
|
50
|
+
* The id of the message to keep track of in case of a reconnect
|
|
51
|
+
*/
|
|
52
|
+
id?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface TRPCSuccessResponse<TData> extends JSONRPC2.ResultResponse<TRPCResult<TData>> {
|
|
52
55
|
}
|
|
53
56
|
export interface TRPCErrorResponse<TError extends TRPCErrorShape = TRPCErrorShape> extends JSONRPC2.ErrorResponse<TError> {
|
|
54
57
|
}
|
|
@@ -78,13 +81,7 @@ export interface TRPCResultMessage<TData> extends JSONRPC2.ResultResponse<{
|
|
|
78
81
|
} | {
|
|
79
82
|
type: 'stopped';
|
|
80
83
|
data?: never;
|
|
81
|
-
} |
|
|
82
|
-
type: 'data';
|
|
83
|
-
/**
|
|
84
|
-
* The id of the message to keep track of in case of a reconnect
|
|
85
|
-
*/
|
|
86
|
-
id?: string;
|
|
87
|
-
})> {
|
|
84
|
+
} | TRPCResult<TData>> {
|
|
88
85
|
}
|
|
89
86
|
export type TRPCResponseMessage<TData = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = {
|
|
90
87
|
id: JSONRPC2.RequestId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do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AAE,CAAC,CAAC;AAE7E,MAAM,WAAW,iBAAiB,CAAC,KAAK,CACtC,SAAQ,QAAQ,CAAC,cAAc,CAC3B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GACjC,UAAU,CAAC,KAAK,CAAC,CACpB;CAAG;AAEN,MAAM,MAAM,mBAAmB,CAC7B,KAAK,GAAG,OAAO,EACf,MAAM,SAAS,cAAc,GAAG,cAAc,IAC5C;IAAE,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAA;CAAE,GAAG,CAC7B,iBAAiB,CAAC,MAAM,CAAC,GACzB,iBAAiB,CAAC,KAAK,CAAC,CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,yBACf,SAAQ,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC;IACzC,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,yBAAyB,CACnC,OAAO,GAAG,OAAO,EACjB,MAAM,SAAS,cAAc,GAAG,cAAc,IAC5C,yBAAyB,GAAG,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,2BACf,SAAQ,QAAQ,CAAC,WAAW,CAAC,kBAAkB,CAAC;IAChD,IAAI,EAAE,eAAe,CAAC,kBAAkB,CAAC,CAAC;CAC3C"}
|
|
@@ -63,13 +63,23 @@ interface ConsumerStreamResultConnecting<TConfig extends ConsumerConfig> extends
|
|
|
63
63
|
type: 'connecting';
|
|
64
64
|
event: EventSourceLike.EventOf<TConfig['EventSource']> | null;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
interface ConsumerStreamResultTimeout<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
67
|
+
type: 'timeout';
|
|
68
|
+
}
|
|
69
|
+
interface ConsumerStreamResultPing<TConfig extends ConsumerConfig> extends ConsumerStreamResultBase<TConfig> {
|
|
70
|
+
type: 'ping';
|
|
71
|
+
}
|
|
72
|
+
type ConsumerStreamResult<TConfig extends ConsumerConfig> = ConsumerStreamResultData<TConfig> | ConsumerStreamResultError<TConfig> | ConsumerStreamResultOpened<TConfig> | ConsumerStreamResultConnecting<TConfig> | ConsumerStreamResultTimeout<TConfig> | ConsumerStreamResultPing<TConfig>;
|
|
67
73
|
export interface SSEStreamConsumerOptions<TConfig extends ConsumerConfig> {
|
|
68
74
|
url: () => MaybePromise<string>;
|
|
69
75
|
init: () => MaybePromise<EventSourceLike.InitDictOf<TConfig['EventSource']>> | undefined;
|
|
70
76
|
signal: AbortSignal;
|
|
71
77
|
deserialize?: Deserialize;
|
|
72
78
|
EventSource: TConfig['EventSource'];
|
|
79
|
+
/**
|
|
80
|
+
* Reconnect after inactivity in milliseconds
|
|
81
|
+
*/
|
|
82
|
+
reconnectAfterInactivityMs?: number;
|
|
73
83
|
}
|
|
74
84
|
interface ConsumerConfig {
|
|
75
85
|
data: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/stream/sse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/stream/sse.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAMpD,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AACrC,KAAK,WAAW,GAAG,CAAC,KA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K,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,eAAe,CAAC,cAAc,CAAC;CAC7C;AA2BD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,cAAc,EAC9D,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,GACtC,aAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CA2J9C;AAED,eAAO,MAAM,UAAU;;;;;CAKb,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var unpromise = require('../../vendor/unpromise/unpromise.js');
|
|
3
4
|
var TRPCError = require('../error/TRPCError.js');
|
|
4
5
|
var isAbortError = require('../http/isAbortError.js');
|
|
5
6
|
var utils = require('../utils.js');
|
|
@@ -8,6 +9,7 @@ var asyncIterable = require('./utils/asyncIterable.js');
|
|
|
8
9
|
var createReadableStream = require('./utils/createReadableStream.js');
|
|
9
10
|
var withPing = require('./utils/withPing.js');
|
|
10
11
|
|
|
12
|
+
const PING_EVENT = 'ping';
|
|
11
13
|
const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
12
14
|
/**
|
|
13
15
|
*
|
|
@@ -48,7 +50,8 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
|
48
50
|
for await (value of iterable){
|
|
49
51
|
if (value === withPing.PING_SYM) {
|
|
50
52
|
stream.controller.enqueue({
|
|
51
|
-
|
|
53
|
+
event: PING_EVENT,
|
|
54
|
+
data: ''
|
|
52
55
|
});
|
|
53
56
|
continue;
|
|
54
57
|
}
|
|
@@ -110,97 +113,158 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
|
110
113
|
}
|
|
111
114
|
}));
|
|
112
115
|
}
|
|
116
|
+
async function withTimeout(opts) {
|
|
117
|
+
let timeoutId;
|
|
118
|
+
const timeoutPromise = new Promise((resolve)=>{
|
|
119
|
+
timeoutId = setTimeout(()=>{
|
|
120
|
+
resolve(null);
|
|
121
|
+
}, opts.timeoutMs);
|
|
122
|
+
});
|
|
123
|
+
let res;
|
|
124
|
+
try {
|
|
125
|
+
res = await unpromise.Unpromise.race([
|
|
126
|
+
opts.promise,
|
|
127
|
+
timeoutPromise
|
|
128
|
+
]);
|
|
129
|
+
} finally{
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
131
|
+
clearTimeout(timeoutId);
|
|
132
|
+
}
|
|
133
|
+
if (res === null) {
|
|
134
|
+
return await opts.onTimeout();
|
|
135
|
+
}
|
|
136
|
+
return res;
|
|
137
|
+
}
|
|
113
138
|
/**
|
|
114
139
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
115
140
|
*/ function sseStreamConsumer(opts) {
|
|
116
141
|
const { deserialize = (v)=>v } = opts;
|
|
117
142
|
const signal = opts.signal;
|
|
118
143
|
let _es = null;
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
controller.enqueue({
|
|
127
|
-
type: 'connecting',
|
|
128
|
-
eventSource: _es,
|
|
129
|
-
event: null
|
|
130
|
-
});
|
|
131
|
-
eventSource.addEventListener('open', ()=>{
|
|
144
|
+
const createStream = ()=>new ReadableStream({
|
|
145
|
+
async start (controller) {
|
|
146
|
+
const [url, init] = await Promise.all([
|
|
147
|
+
opts.url(),
|
|
148
|
+
opts.init()
|
|
149
|
+
]);
|
|
150
|
+
const eventSource = _es = new opts.EventSource(url, init);
|
|
132
151
|
controller.enqueue({
|
|
133
|
-
type: '
|
|
134
|
-
eventSource
|
|
152
|
+
type: 'connecting',
|
|
153
|
+
eventSource: _es,
|
|
154
|
+
event: null
|
|
135
155
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
error: deserialize(JSON.parse(msg.data)),
|
|
142
|
-
eventSource
|
|
156
|
+
eventSource.addEventListener('open', ()=>{
|
|
157
|
+
controller.enqueue({
|
|
158
|
+
type: 'opened',
|
|
159
|
+
eventSource
|
|
160
|
+
});
|
|
143
161
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (eventSource.readyState === EventSource.CLOSED) {
|
|
147
|
-
controller.error(event);
|
|
148
|
-
} else {
|
|
162
|
+
eventSource.addEventListener(SERIALIZED_ERROR_EVENT, (_msg)=>{
|
|
163
|
+
const msg = _msg;
|
|
149
164
|
controller.enqueue({
|
|
150
|
-
type: '
|
|
151
|
-
|
|
152
|
-
|
|
165
|
+
type: 'serialized-error',
|
|
166
|
+
error: deserialize(JSON.parse(msg.data)),
|
|
167
|
+
eventSource
|
|
153
168
|
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
169
|
+
});
|
|
170
|
+
eventSource.addEventListener(PING_EVENT, ()=>{
|
|
171
|
+
controller.enqueue({
|
|
172
|
+
type: 'ping',
|
|
173
|
+
eventSource
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
eventSource.addEventListener('error', (event)=>{
|
|
177
|
+
if (eventSource.readyState === EventSource.CLOSED) {
|
|
178
|
+
controller.error(event);
|
|
179
|
+
} else {
|
|
180
|
+
controller.enqueue({
|
|
181
|
+
type: 'connecting',
|
|
182
|
+
eventSource,
|
|
183
|
+
event
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
eventSource.addEventListener('message', (_msg)=>{
|
|
188
|
+
const msg = _msg;
|
|
189
|
+
const chunk = deserialize(JSON.parse(msg.data));
|
|
190
|
+
const def = {
|
|
191
|
+
data: chunk
|
|
192
|
+
};
|
|
193
|
+
if (msg.lastEventId) {
|
|
194
|
+
def.id = msg.lastEventId;
|
|
195
|
+
}
|
|
196
|
+
controller.enqueue({
|
|
197
|
+
type: 'data',
|
|
198
|
+
data: def,
|
|
199
|
+
eventSource
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
const onAbort = ()=>{
|
|
203
|
+
controller.close();
|
|
204
|
+
eventSource.close();
|
|
161
205
|
};
|
|
162
|
-
if (
|
|
163
|
-
|
|
206
|
+
if (signal.aborted) {
|
|
207
|
+
onAbort();
|
|
208
|
+
} else {
|
|
209
|
+
signal.addEventListener('abort', onAbort);
|
|
164
210
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
eventSource
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
const onAbort = ()=>{
|
|
172
|
-
controller.close();
|
|
173
|
-
eventSource.close();
|
|
174
|
-
};
|
|
175
|
-
if (signal.aborted) {
|
|
176
|
-
onAbort();
|
|
177
|
-
} else {
|
|
178
|
-
signal.addEventListener('abort', onAbort);
|
|
211
|
+
},
|
|
212
|
+
cancel () {
|
|
213
|
+
_es?.close();
|
|
179
214
|
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
215
|
+
});
|
|
216
|
+
const getNewStreamAndReader = ()=>{
|
|
217
|
+
const stream = createStream();
|
|
218
|
+
const reader = stream.getReader();
|
|
219
|
+
return {
|
|
220
|
+
reader,
|
|
221
|
+
cancel: ()=>{
|
|
222
|
+
reader.releaseLock();
|
|
223
|
+
return stream.cancel();
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
};
|
|
185
227
|
return {
|
|
186
228
|
[Symbol.asyncIterator] () {
|
|
187
|
-
|
|
229
|
+
let stream = getNewStreamAndReader();
|
|
188
230
|
const iterator = {
|
|
189
231
|
async next () {
|
|
190
|
-
|
|
191
|
-
if (
|
|
232
|
+
let promise = stream.reader.read();
|
|
233
|
+
if (opts.reconnectAfterInactivityMs) {
|
|
234
|
+
promise = withTimeout({
|
|
235
|
+
promise,
|
|
236
|
+
timeoutMs: opts.reconnectAfterInactivityMs,
|
|
237
|
+
onTimeout: async ()=>{
|
|
238
|
+
// Close and release old reader
|
|
239
|
+
await stream.cancel();
|
|
240
|
+
// Create new reader
|
|
241
|
+
stream = getNewStreamAndReader();
|
|
242
|
+
return {
|
|
243
|
+
value: {
|
|
244
|
+
type: 'timeout',
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
246
|
+
eventSource: _es
|
|
247
|
+
},
|
|
248
|
+
done: false
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
const result = await promise;
|
|
254
|
+
// console.debug('result', result, 'done', result.done);
|
|
255
|
+
if (result.done) {
|
|
192
256
|
return {
|
|
193
|
-
value:
|
|
257
|
+
value: result.value,
|
|
194
258
|
done: true
|
|
195
259
|
};
|
|
196
260
|
}
|
|
197
261
|
return {
|
|
198
|
-
value:
|
|
262
|
+
value: result.value,
|
|
199
263
|
done: false
|
|
200
264
|
};
|
|
201
265
|
},
|
|
202
266
|
async return () {
|
|
203
|
-
|
|
267
|
+
await stream.cancel();
|
|
204
268
|
return {
|
|
205
269
|
value: undefined,
|
|
206
270
|
done: true
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Unpromise } from '../../vendor/unpromise/unpromise.mjs';
|
|
1
2
|
import { getTRPCErrorFromUnknown } from '../error/TRPCError.mjs';
|
|
2
3
|
import { isAbortError } from '../http/isAbortError.mjs';
|
|
3
4
|
import { run, identity } from '../utils.mjs';
|
|
@@ -6,6 +7,7 @@ import { takeWithGrace, withMaxDuration } from './utils/asyncIterable.mjs';
|
|
|
6
7
|
import { createReadableStream } from './utils/createReadableStream.mjs';
|
|
7
8
|
import { withPing, PING_SYM } from './utils/withPing.mjs';
|
|
8
9
|
|
|
10
|
+
const PING_EVENT = 'ping';
|
|
9
11
|
const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
10
12
|
/**
|
|
11
13
|
*
|
|
@@ -46,7 +48,8 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
|
46
48
|
for await (value of iterable){
|
|
47
49
|
if (value === PING_SYM) {
|
|
48
50
|
stream.controller.enqueue({
|
|
49
|
-
|
|
51
|
+
event: PING_EVENT,
|
|
52
|
+
data: ''
|
|
50
53
|
});
|
|
51
54
|
continue;
|
|
52
55
|
}
|
|
@@ -108,97 +111,158 @@ const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
|
108
111
|
}
|
|
109
112
|
}));
|
|
110
113
|
}
|
|
114
|
+
async function withTimeout(opts) {
|
|
115
|
+
let timeoutId;
|
|
116
|
+
const timeoutPromise = new Promise((resolve)=>{
|
|
117
|
+
timeoutId = setTimeout(()=>{
|
|
118
|
+
resolve(null);
|
|
119
|
+
}, opts.timeoutMs);
|
|
120
|
+
});
|
|
121
|
+
let res;
|
|
122
|
+
try {
|
|
123
|
+
res = await Unpromise.race([
|
|
124
|
+
opts.promise,
|
|
125
|
+
timeoutPromise
|
|
126
|
+
]);
|
|
127
|
+
} finally{
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
129
|
+
clearTimeout(timeoutId);
|
|
130
|
+
}
|
|
131
|
+
if (res === null) {
|
|
132
|
+
return await opts.onTimeout();
|
|
133
|
+
}
|
|
134
|
+
return res;
|
|
135
|
+
}
|
|
111
136
|
/**
|
|
112
137
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
113
138
|
*/ function sseStreamConsumer(opts) {
|
|
114
139
|
const { deserialize = (v)=>v } = opts;
|
|
115
140
|
const signal = opts.signal;
|
|
116
141
|
let _es = null;
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
controller.enqueue({
|
|
125
|
-
type: 'connecting',
|
|
126
|
-
eventSource: _es,
|
|
127
|
-
event: null
|
|
128
|
-
});
|
|
129
|
-
eventSource.addEventListener('open', ()=>{
|
|
142
|
+
const createStream = ()=>new ReadableStream({
|
|
143
|
+
async start (controller) {
|
|
144
|
+
const [url, init] = await Promise.all([
|
|
145
|
+
opts.url(),
|
|
146
|
+
opts.init()
|
|
147
|
+
]);
|
|
148
|
+
const eventSource = _es = new opts.EventSource(url, init);
|
|
130
149
|
controller.enqueue({
|
|
131
|
-
type: '
|
|
132
|
-
eventSource
|
|
150
|
+
type: 'connecting',
|
|
151
|
+
eventSource: _es,
|
|
152
|
+
event: null
|
|
133
153
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
error: deserialize(JSON.parse(msg.data)),
|
|
140
|
-
eventSource
|
|
154
|
+
eventSource.addEventListener('open', ()=>{
|
|
155
|
+
controller.enqueue({
|
|
156
|
+
type: 'opened',
|
|
157
|
+
eventSource
|
|
158
|
+
});
|
|
141
159
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (eventSource.readyState === EventSource.CLOSED) {
|
|
145
|
-
controller.error(event);
|
|
146
|
-
} else {
|
|
160
|
+
eventSource.addEventListener(SERIALIZED_ERROR_EVENT, (_msg)=>{
|
|
161
|
+
const msg = _msg;
|
|
147
162
|
controller.enqueue({
|
|
148
|
-
type: '
|
|
149
|
-
|
|
150
|
-
|
|
163
|
+
type: 'serialized-error',
|
|
164
|
+
error: deserialize(JSON.parse(msg.data)),
|
|
165
|
+
eventSource
|
|
151
166
|
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
});
|
|
168
|
+
eventSource.addEventListener(PING_EVENT, ()=>{
|
|
169
|
+
controller.enqueue({
|
|
170
|
+
type: 'ping',
|
|
171
|
+
eventSource
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
eventSource.addEventListener('error', (event)=>{
|
|
175
|
+
if (eventSource.readyState === EventSource.CLOSED) {
|
|
176
|
+
controller.error(event);
|
|
177
|
+
} else {
|
|
178
|
+
controller.enqueue({
|
|
179
|
+
type: 'connecting',
|
|
180
|
+
eventSource,
|
|
181
|
+
event
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
eventSource.addEventListener('message', (_msg)=>{
|
|
186
|
+
const msg = _msg;
|
|
187
|
+
const chunk = deserialize(JSON.parse(msg.data));
|
|
188
|
+
const def = {
|
|
189
|
+
data: chunk
|
|
190
|
+
};
|
|
191
|
+
if (msg.lastEventId) {
|
|
192
|
+
def.id = msg.lastEventId;
|
|
193
|
+
}
|
|
194
|
+
controller.enqueue({
|
|
195
|
+
type: 'data',
|
|
196
|
+
data: def,
|
|
197
|
+
eventSource
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
const onAbort = ()=>{
|
|
201
|
+
controller.close();
|
|
202
|
+
eventSource.close();
|
|
159
203
|
};
|
|
160
|
-
if (
|
|
161
|
-
|
|
204
|
+
if (signal.aborted) {
|
|
205
|
+
onAbort();
|
|
206
|
+
} else {
|
|
207
|
+
signal.addEventListener('abort', onAbort);
|
|
162
208
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
eventSource
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
const onAbort = ()=>{
|
|
170
|
-
controller.close();
|
|
171
|
-
eventSource.close();
|
|
172
|
-
};
|
|
173
|
-
if (signal.aborted) {
|
|
174
|
-
onAbort();
|
|
175
|
-
} else {
|
|
176
|
-
signal.addEventListener('abort', onAbort);
|
|
209
|
+
},
|
|
210
|
+
cancel () {
|
|
211
|
+
_es?.close();
|
|
177
212
|
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
213
|
+
});
|
|
214
|
+
const getNewStreamAndReader = ()=>{
|
|
215
|
+
const stream = createStream();
|
|
216
|
+
const reader = stream.getReader();
|
|
217
|
+
return {
|
|
218
|
+
reader,
|
|
219
|
+
cancel: ()=>{
|
|
220
|
+
reader.releaseLock();
|
|
221
|
+
return stream.cancel();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
};
|
|
183
225
|
return {
|
|
184
226
|
[Symbol.asyncIterator] () {
|
|
185
|
-
|
|
227
|
+
let stream = getNewStreamAndReader();
|
|
186
228
|
const iterator = {
|
|
187
229
|
async next () {
|
|
188
|
-
|
|
189
|
-
if (
|
|
230
|
+
let promise = stream.reader.read();
|
|
231
|
+
if (opts.reconnectAfterInactivityMs) {
|
|
232
|
+
promise = withTimeout({
|
|
233
|
+
promise,
|
|
234
|
+
timeoutMs: opts.reconnectAfterInactivityMs,
|
|
235
|
+
onTimeout: async ()=>{
|
|
236
|
+
// Close and release old reader
|
|
237
|
+
await stream.cancel();
|
|
238
|
+
// Create new reader
|
|
239
|
+
stream = getNewStreamAndReader();
|
|
240
|
+
return {
|
|
241
|
+
value: {
|
|
242
|
+
type: 'timeout',
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
244
|
+
eventSource: _es
|
|
245
|
+
},
|
|
246
|
+
done: false
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
const result = await promise;
|
|
252
|
+
// console.debug('result', result, 'done', result.done);
|
|
253
|
+
if (result.done) {
|
|
190
254
|
return {
|
|
191
|
-
value:
|
|
255
|
+
value: result.value,
|
|
192
256
|
done: true
|
|
193
257
|
};
|
|
194
258
|
}
|
|
195
259
|
return {
|
|
196
|
-
value:
|
|
260
|
+
value: result.value,
|
|
197
261
|
done: false
|
|
198
262
|
};
|
|
199
263
|
},
|
|
200
264
|
async return () {
|
|
201
|
-
|
|
265
|
+
await stream.cancel();
|
|
202
266
|
return {
|
|
203
267
|
value: undefined,
|
|
204
268
|
done: true
|
|
@@ -87,10 +87,7 @@ declare function transformResultInner<TRouter extends AnyRouter, TOutput>(respon
|
|
|
87
87
|
} | {
|
|
88
88
|
type: "stopped";
|
|
89
89
|
data?: never;
|
|
90
|
-
} |
|
|
91
|
-
type: "data";
|
|
92
|
-
id?: string;
|
|
93
|
-
});
|
|
90
|
+
} | import("./rpc").TRPCResult<TOutput>;
|
|
94
91
|
readonly error?: undefined;
|
|
95
92
|
};
|
|
96
93
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAGf;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC,WAAW,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;CACnC;AAED,UAAU,oBAAqB,SAAQ,eAAe;IACpD;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC;;OAEG;IACH,WAAW,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;CACnC;AAED,UAAU,qBAAsB,SAAQ,eAAe;IACrD;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;IAChC;;OAEG;IACH,WAAW,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,EAAE,oBAAoB,CAAC;IAC5B;;OAEG;IACH,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,KAAK,EAAE,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;IAC3D,MAAM,EAAE,IAAI,CAAC,uBAAuB,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