@trpc/server 11.0.0-alpha-tmp-12-06-react.674 → 11.0.0-alpha-tmp-issues-6374.696
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/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +10 -3
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +8 -6
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +8 -6
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +128 -112
- package/dist/unstable-core-do-not-import/createProxy.d.ts +1 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/createProxy.js +2 -1
- package/dist/unstable-core-do-not-import/createProxy.mjs +2 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.js +154 -188
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +156 -190
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +1 -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 +7 -3
- package/dist/unstable-core-do-not-import/stream/sse.mjs +7 -3
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts +17 -0
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.js +241 -0
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.mjs +239 -0
- package/package.json +7 -7
- package/src/adapters/fastify/fastifyRequestHandler.ts +2 -2
- package/src/adapters/node-http/incomingMessageToRequest.ts +19 -11
- package/src/unstable-core-do-not-import/createProxy.ts +3 -2
- package/src/unstable-core-do-not-import/stream/jsonl.ts +14 -46
- package/src/unstable-core-do-not-import/stream/sse.ts +28 -21
- package/src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts +193 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isObject, isFunction, isAsyncIterable, run } from '../utils.mjs';
|
|
1
|
+
import { isObject, isFunction, run, isAsyncIterable } from '../utils.mjs';
|
|
3
2
|
import { iteratorResource } from './utils/asyncIterable.mjs';
|
|
4
3
|
import { createDeferred } from './utils/createDeferred.mjs';
|
|
5
|
-
import {
|
|
4
|
+
import { makeResource } from './utils/disposable.mjs';
|
|
5
|
+
import { mergeAsyncIterables } from './utils/mergeAsyncIterables.mjs';
|
|
6
6
|
import { readableStreamFrom } from './utils/readableStreamFrom.mjs';
|
|
7
7
|
|
|
8
8
|
function _define_property(obj, key, value) {
|
|
@@ -101,223 +101,189 @@ class MaxDepthError extends Error {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
async function* createBatchStreamProducer(opts) {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
104
|
+
const { data } = opts;
|
|
105
|
+
let counter = 0;
|
|
106
|
+
const placeholder = 0;
|
|
107
|
+
const mergedIterables = mergeAsyncIterables();
|
|
108
|
+
function registerAsync(callback) {
|
|
109
|
+
const idx = counter++;
|
|
110
|
+
const iterable = callback(idx);
|
|
111
|
+
mergedIterables.add(iterable);
|
|
112
|
+
return idx;
|
|
113
|
+
}
|
|
114
|
+
function encodePromise(promise, path) {
|
|
115
|
+
return registerAsync(async function*(idx) {
|
|
116
|
+
const error = checkMaxDepth(path);
|
|
117
|
+
if (error) {
|
|
118
|
+
// Catch any errors from the original promise to ensure they're reported
|
|
119
|
+
promise.catch((cause)=>{
|
|
120
|
+
opts.onError?.({
|
|
121
|
+
error: cause,
|
|
122
|
+
path
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
// Replace the promise with a rejected one containing the max depth error
|
|
126
|
+
promise = Promise.reject(error);
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const next = await promise;
|
|
130
|
+
yield [
|
|
131
|
+
idx,
|
|
132
|
+
PROMISE_STATUS_FULFILLED,
|
|
133
|
+
encode(next, path)
|
|
134
|
+
];
|
|
135
|
+
} catch (cause) {
|
|
136
|
+
opts.onError?.({
|
|
137
|
+
error: cause,
|
|
138
|
+
path
|
|
139
|
+
});
|
|
140
|
+
yield [
|
|
141
|
+
idx,
|
|
142
|
+
PROMISE_STATUS_REJECTED,
|
|
143
|
+
opts.formatError?.({
|
|
144
|
+
error: cause,
|
|
145
|
+
path
|
|
146
|
+
})
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function encodeAsyncIterable(iterable, path) {
|
|
152
|
+
return registerAsync(async function*(idx) {
|
|
153
|
+
const env = {
|
|
154
|
+
stack: [],
|
|
155
|
+
error: void 0,
|
|
156
|
+
hasError: false
|
|
157
|
+
};
|
|
158
|
+
try {
|
|
132
159
|
const error = checkMaxDepth(path);
|
|
133
160
|
if (error) {
|
|
134
|
-
|
|
135
|
-
promise.catch((cause)=>{
|
|
136
|
-
opts.onError?.({
|
|
137
|
-
error: cause,
|
|
138
|
-
path
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
// Replace the promise with a rejected one containing the max depth error
|
|
142
|
-
promise = Promise.reject(error);
|
|
161
|
+
throw error;
|
|
143
162
|
}
|
|
163
|
+
const iterator = _ts_add_disposable_resource(env, iteratorResource(iterable), true);
|
|
164
|
+
;
|
|
144
165
|
try {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
166
|
+
while(true){
|
|
167
|
+
const next = await iterator.next();
|
|
168
|
+
if (next.done) {
|
|
169
|
+
yield [
|
|
170
|
+
idx,
|
|
171
|
+
ASYNC_ITERABLE_STATUS_RETURN,
|
|
172
|
+
encode(next.value, path)
|
|
173
|
+
];
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
yield [
|
|
177
|
+
idx,
|
|
178
|
+
ASYNC_ITERABLE_STATUS_YIELD,
|
|
179
|
+
encode(next.value, path)
|
|
180
|
+
];
|
|
181
|
+
}
|
|
151
182
|
} catch (cause) {
|
|
152
183
|
opts.onError?.({
|
|
153
184
|
error: cause,
|
|
154
185
|
path
|
|
155
186
|
});
|
|
156
|
-
|
|
187
|
+
yield [
|
|
157
188
|
idx,
|
|
158
|
-
|
|
189
|
+
ASYNC_ITERABLE_STATUS_ERROR,
|
|
159
190
|
opts.formatError?.({
|
|
160
191
|
error: cause,
|
|
161
192
|
path
|
|
162
193
|
})
|
|
163
194
|
];
|
|
164
195
|
}
|
|
165
|
-
})
|
|
196
|
+
} catch (e) {
|
|
197
|
+
env.error = e;
|
|
198
|
+
env.hasError = true;
|
|
199
|
+
} finally{
|
|
200
|
+
const result = _ts_dispose_resources(env);
|
|
201
|
+
if (result) await result;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function checkMaxDepth(path) {
|
|
206
|
+
if (opts.maxDepth && path.length > opts.maxDepth) {
|
|
207
|
+
return new MaxDepthError(path);
|
|
166
208
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const error = checkMaxDepth(path);
|
|
176
|
-
if (error) {
|
|
177
|
-
throw error;
|
|
178
|
-
}
|
|
179
|
-
const iterator = _ts_add_disposable_resource(env, iteratorResource(iterable), true);
|
|
180
|
-
;
|
|
181
|
-
try {
|
|
182
|
-
while(true){
|
|
183
|
-
const next = await iterator.next();
|
|
184
|
-
if (next.done) {
|
|
185
|
-
return [
|
|
186
|
-
idx,
|
|
187
|
-
ASYNC_ITERABLE_STATUS_RETURN,
|
|
188
|
-
encode(next.value, path)
|
|
189
|
-
];
|
|
190
|
-
}
|
|
191
|
-
yield [
|
|
192
|
-
idx,
|
|
193
|
-
ASYNC_ITERABLE_STATUS_YIELD,
|
|
194
|
-
encode(next.value, path)
|
|
195
|
-
];
|
|
196
|
-
}
|
|
197
|
-
} catch (cause) {
|
|
198
|
-
opts.onError?.({
|
|
199
|
-
error: cause,
|
|
200
|
-
path
|
|
201
|
-
});
|
|
202
|
-
return [
|
|
203
|
-
idx,
|
|
204
|
-
ASYNC_ITERABLE_STATUS_ERROR,
|
|
205
|
-
opts.formatError?.({
|
|
206
|
-
error: cause,
|
|
207
|
-
path
|
|
208
|
-
})
|
|
209
|
-
];
|
|
210
|
-
}
|
|
211
|
-
} catch (e) {
|
|
212
|
-
env.error = e;
|
|
213
|
-
env.hasError = true;
|
|
214
|
-
} finally{
|
|
215
|
-
const result = _ts_dispose_resources(env);
|
|
216
|
-
if (result) await result;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
function encodeAsync(value, path) {
|
|
212
|
+
if (isPromise(value)) {
|
|
213
|
+
return [
|
|
214
|
+
CHUNK_VALUE_TYPE_PROMISE,
|
|
215
|
+
encodePromise(value, path)
|
|
216
|
+
];
|
|
219
217
|
}
|
|
220
|
-
|
|
221
|
-
if (opts.maxDepth && path.length
|
|
222
|
-
|
|
218
|
+
if (isAsyncIterable(value)) {
|
|
219
|
+
if (opts.maxDepth && path.length >= opts.maxDepth) {
|
|
220
|
+
throw new Error('Max depth reached');
|
|
223
221
|
}
|
|
224
|
-
return
|
|
222
|
+
return [
|
|
223
|
+
CHUNK_VALUE_TYPE_ASYNC_ITERABLE,
|
|
224
|
+
encodeAsyncIterable(value, path)
|
|
225
|
+
];
|
|
225
226
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
]
|
|
232
|
-
|
|
233
|
-
if (isAsyncIterable(value)) {
|
|
234
|
-
if (opts.maxDepth && path.length >= opts.maxDepth) {
|
|
235
|
-
throw new Error('Max depth reached');
|
|
236
|
-
}
|
|
237
|
-
return [
|
|
238
|
-
CHUNK_VALUE_TYPE_ASYNC_ITERABLE,
|
|
239
|
-
encodeAsyncIterable(value, path)
|
|
240
|
-
];
|
|
241
|
-
}
|
|
242
|
-
return null;
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
function encode(value, path) {
|
|
230
|
+
if (value === undefined) {
|
|
231
|
+
return [
|
|
232
|
+
[]
|
|
233
|
+
];
|
|
243
234
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
]
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
value
|
|
254
|
-
]
|
|
255
|
-
];
|
|
256
|
-
}
|
|
257
|
-
const reg = encodeAsync(value, path);
|
|
258
|
-
if (reg) {
|
|
259
|
-
return [
|
|
260
|
-
[
|
|
261
|
-
placeholder
|
|
262
|
-
],
|
|
263
|
-
[
|
|
264
|
-
null,
|
|
265
|
-
...reg
|
|
266
|
-
]
|
|
267
|
-
];
|
|
268
|
-
}
|
|
269
|
-
const newObj = {};
|
|
270
|
-
const asyncValues = [];
|
|
271
|
-
for (const [key, item] of Object.entries(value)){
|
|
272
|
-
const transformed = encodeAsync(item, [
|
|
273
|
-
...path,
|
|
274
|
-
key
|
|
275
|
-
]);
|
|
276
|
-
if (!transformed) {
|
|
277
|
-
newObj[key] = item;
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
newObj[key] = placeholder;
|
|
281
|
-
asyncValues.push([
|
|
282
|
-
key,
|
|
283
|
-
...transformed
|
|
284
|
-
]);
|
|
285
|
-
}
|
|
235
|
+
if (!isObject(value)) {
|
|
236
|
+
return [
|
|
237
|
+
[
|
|
238
|
+
value
|
|
239
|
+
]
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
const reg = encodeAsync(value, path);
|
|
243
|
+
if (reg) {
|
|
286
244
|
return [
|
|
287
245
|
[
|
|
288
|
-
|
|
246
|
+
placeholder
|
|
289
247
|
],
|
|
290
|
-
|
|
248
|
+
[
|
|
249
|
+
null,
|
|
250
|
+
...reg
|
|
251
|
+
]
|
|
291
252
|
];
|
|
292
253
|
}
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
254
|
+
const newObj = {};
|
|
255
|
+
const asyncValues = [];
|
|
256
|
+
for (const [key, item] of Object.entries(value)){
|
|
257
|
+
const transformed = encodeAsync(item, [
|
|
258
|
+
...path,
|
|
296
259
|
key
|
|
297
260
|
]);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
while(queue.size > 0){
|
|
302
|
-
// Race all iterators to get the next value from any of them
|
|
303
|
-
const [entry, res] = await Unpromise.race(Array.from(queue).map(async (it)=>[
|
|
304
|
-
it,
|
|
305
|
-
await it.nextPromise
|
|
306
|
-
]));
|
|
307
|
-
yield res.value;
|
|
308
|
-
// Remove current iterator and re-add if not done
|
|
309
|
-
queue.delete(entry);
|
|
310
|
-
if (!res.done) {
|
|
311
|
-
entry.nextPromise = entry.iterator.next();
|
|
312
|
-
queue.add(entry);
|
|
261
|
+
if (!transformed) {
|
|
262
|
+
newObj[key] = item;
|
|
263
|
+
continue;
|
|
313
264
|
}
|
|
265
|
+
newObj[key] = placeholder;
|
|
266
|
+
asyncValues.push([
|
|
267
|
+
key,
|
|
268
|
+
...transformed
|
|
269
|
+
]);
|
|
314
270
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
271
|
+
return [
|
|
272
|
+
[
|
|
273
|
+
newObj
|
|
274
|
+
],
|
|
275
|
+
...asyncValues
|
|
276
|
+
];
|
|
277
|
+
}
|
|
278
|
+
const newHead = {};
|
|
279
|
+
for (const [key, item] of Object.entries(data)){
|
|
280
|
+
newHead[key] = encode(item, [
|
|
281
|
+
key
|
|
282
|
+
]);
|
|
283
|
+
}
|
|
284
|
+
yield newHead;
|
|
285
|
+
for await (const value of mergedIterables){
|
|
286
|
+
yield value;
|
|
321
287
|
}
|
|
322
288
|
}
|
|
323
289
|
/**
|
|
@@ -54,7 +54,7 @@ export interface SSEStreamProducerOptions<TValue = unknown> {
|
|
|
54
54
|
*
|
|
55
55
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
56
56
|
*/
|
|
57
|
-
export declare function sseStreamProducer<TValue = unknown>(opts: SSEStreamProducerOptions<TValue>): ReadableStream<
|
|
57
|
+
export declare function sseStreamProducer<TValue = unknown>(opts: SSEStreamProducerOptions<TValue>): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
58
58
|
interface ConsumerStreamResultBase<TConfig extends ConsumerConfig> {
|
|
59
59
|
eventSource: InstanceType<TConfig['EventSource']> | null;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
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;AAWpD,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AACrC,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;A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AAU,cAAc;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,eAAe,CAAC,cAAc,CAAC;CAC7C;AAgBD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,cAAc,EAC9D,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,GACtC,aAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAiK9C;AAED,eAAO,MAAM,UAAU;;;;;CAKb,CAAC"}
|
|
@@ -174,7 +174,7 @@ const CONNECTED_EVENT = 'connected';
|
|
|
174
174
|
}
|
|
175
175
|
controller.enqueue('\n\n');
|
|
176
176
|
}
|
|
177
|
-
}));
|
|
177
|
+
})).pipeThrough(new TextEncoderStream());
|
|
178
178
|
}
|
|
179
179
|
async function withTimeout(opts) {
|
|
180
180
|
const env = {
|
|
@@ -270,8 +270,12 @@ async function withTimeout(opts) {
|
|
|
270
270
|
});
|
|
271
271
|
});
|
|
272
272
|
const onAbort = ()=>{
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
try {
|
|
274
|
+
eventSource.close();
|
|
275
|
+
controller.close();
|
|
276
|
+
} catch {
|
|
277
|
+
// ignore errors in case the controller is already closed
|
|
278
|
+
}
|
|
275
279
|
};
|
|
276
280
|
if (signal.aborted) {
|
|
277
281
|
onAbort();
|
|
@@ -172,7 +172,7 @@ const CONNECTED_EVENT = 'connected';
|
|
|
172
172
|
}
|
|
173
173
|
controller.enqueue('\n\n');
|
|
174
174
|
}
|
|
175
|
-
}));
|
|
175
|
+
})).pipeThrough(new TextEncoderStream());
|
|
176
176
|
}
|
|
177
177
|
async function withTimeout(opts) {
|
|
178
178
|
const env = {
|
|
@@ -268,8 +268,12 @@ async function withTimeout(opts) {
|
|
|
268
268
|
});
|
|
269
269
|
});
|
|
270
270
|
const onAbort = ()=>{
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
try {
|
|
272
|
+
eventSource.close();
|
|
273
|
+
controller.close();
|
|
274
|
+
} catch {
|
|
275
|
+
// ignore errors in case the controller is already closed
|
|
276
|
+
}
|
|
273
277
|
};
|
|
274
278
|
if (signal.aborted) {
|
|
275
279
|
onAbort();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface MergedAsyncIterables<TYield> extends AsyncIterable<TYield, void, unknown> {
|
|
2
|
+
add(iterable: AsyncIterable<TYield>): void;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new async iterable that merges multiple async iterables into a single stream.
|
|
6
|
+
* Values from the input iterables are yielded in the order they resolve, similar to Promise.race().
|
|
7
|
+
*
|
|
8
|
+
* New iterables can be added dynamically using the returned {@link MergedAsyncIterables.add} method, even after iteration has started.
|
|
9
|
+
*
|
|
10
|
+
* If any of the input iterables throws an error, that error will be propagated through the merged stream.
|
|
11
|
+
* Other iterables will not continue to be processed.
|
|
12
|
+
*
|
|
13
|
+
* @template TYield The type of values yielded by the input iterables
|
|
14
|
+
*/
|
|
15
|
+
export declare function mergeAsyncIterables<TYield>(): MergedAsyncIterables<TYield>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=mergeAsyncIterables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeAsyncIterables.d.ts","sourceRoot":"","sources":["../../../../src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts"],"names":[],"mappings":"AAyDA,UAAU,oBAAoB,CAAC,MAAM,CACnC,SAAQ,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC;IAC5C,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAC5C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,KAAK,oBAAoB,CAAC,MAAM,CAAC,CAuH1E"}
|