@highstate/designer 0.4.4 → 0.4.6
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/.output/nitro.json +2 -2
- package/.output/public/_nuxt/{DNF_Kfc9.js → CiOkjSfX.js} +1 -1
- package/.output/public/_nuxt/D01t-DsO.js +244 -0
- package/.output/public/_nuxt/{COXQCz2I.js → DoGffnu_.js} +1 -1
- package/.output/public/_nuxt/{B-YqONwZ.js → DtaR4eeX.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/c96427f3-ab77-406f-bb94-426a783445eb.json +1 -0
- package/.output/public/_nuxt/entry.BrXvcFAN.css +5 -0
- package/.output/public/_nuxt/materialdesignicons-webfont.B6OSyW2I.woff2 +0 -0
- package/.output/public/_nuxt/materialdesignicons-webfont.BpRar1d5.ttf +0 -0
- package/.output/public/_nuxt/materialdesignicons-webfont.Bvl3VxMs.woff +0 -0
- package/.output/public/_nuxt/materialdesignicons-webfont.TEmAk13K.eot +0 -0
- package/.output/public/libavoid.wasm +0 -0
- package/.output/server/index.mjs +8395 -8137
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@babel/parser/lib/index.js +71 -40
- package/.output/server/node_modules/@babel/parser/package.json +2 -2
- package/.output/server/node_modules/@trpc/server/dist/index.mjs +3 -2
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/createProxy.mjs +1 -1
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/error/TRPCError.mjs +1 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/abortError.mjs +10 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/contentType.mjs +18 -13
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/resolveResponse.mjs +6 -5
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/initTRPC.mjs +1 -1
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/parser.mjs +12 -1
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs +2 -1
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs +112 -10
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.mjs +50 -44
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.mjs +12 -2
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +5 -7
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/utils/disposable.mjs +10 -8
- package/.output/server/node_modules/@trpc/server/dist/vendor/standard-schema-v1/error.mjs +26 -0
- package/.output/server/node_modules/@trpc/server/package.json +10 -10
- package/.output/server/node_modules/@unhead/dom/package.json +3 -3
- package/.output/server/node_modules/@unhead/shared/package.json +2 -2
- package/.output/server/node_modules/@unhead/ssr/package.json +3 -3
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/index.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/package.json +63 -0
- package/.output/server/node_modules/unhead/package.json +4 -4
- package/.output/server/node_modules/zod/lib/index.mjs +33 -10
- package/.output/server/node_modules/zod/package.json +1 -1
- package/.output/server/package.json +1 -1
- package/package.json +17 -5
- package/.output/public/_nuxt/DYyPqv2f.js +0 -164
- package/.output/public/_nuxt/builds/meta/c81be379-d98f-426f-8eac-c45f3b97a743.json +0 -1
- package/.output/public/_nuxt/entry.BSAdMt6G.css +0 -5
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/isAbortError.mjs +0 -7
package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs
CHANGED
|
@@ -2,10 +2,43 @@ import { createRecursiveProxy } from './createProxy.mjs';
|
|
|
2
2
|
import { defaultFormatter } from './error/formatter.mjs';
|
|
3
3
|
import { TRPCError, getTRPCErrorFromUnknown } from './error/TRPCError.mjs';
|
|
4
4
|
import { defaultTransformer } from './transformer.mjs';
|
|
5
|
-
import { mergeWithoutOverrides, omitPrototype, isFunction } from './utils.mjs';
|
|
5
|
+
import { mergeWithoutOverrides, omitPrototype, isObject, isFunction } from './utils.mjs';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const lazySymbol = Symbol('lazy');
|
|
8
|
+
function once(fn) {
|
|
9
|
+
const uncalled = Symbol();
|
|
10
|
+
let result = uncalled;
|
|
11
|
+
return ()=>{
|
|
12
|
+
if (result === uncalled) {
|
|
13
|
+
result = fn();
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Lazy load a router
|
|
20
|
+
* @see https://trpc.io/docs/server/merging-routers#lazy-load
|
|
21
|
+
*/ function lazy(importRouter) {
|
|
22
|
+
async function resolve() {
|
|
23
|
+
const mod = await importRouter();
|
|
24
|
+
// if the module is a router, return it
|
|
25
|
+
if (isRouter(mod)) {
|
|
26
|
+
return mod;
|
|
27
|
+
}
|
|
28
|
+
const routers = Object.values(mod);
|
|
29
|
+
if (routers.length !== 1 || !isRouter(routers[0])) {
|
|
30
|
+
throw new Error("Invalid router module - either define exactly 1 export or return the router directly.\nExample: `experimental_lazy(() => import('./slow.js').then((m) => m.slowRouter))`");
|
|
31
|
+
}
|
|
32
|
+
return routers[0];
|
|
33
|
+
}
|
|
34
|
+
resolve[lazySymbol] = true;
|
|
35
|
+
return resolve;
|
|
36
|
+
}
|
|
37
|
+
function isLazy(input) {
|
|
38
|
+
return typeof input === 'function' && lazySymbol in input;
|
|
39
|
+
}
|
|
40
|
+
function isRouter(value) {
|
|
41
|
+
return isObject(value) && isObject(value['_def']) && 'router' in value['_def'];
|
|
9
42
|
}
|
|
10
43
|
const emptyRouter = {
|
|
11
44
|
_ctx: null,
|
|
@@ -38,9 +71,51 @@ const emptyRouter = {
|
|
|
38
71
|
throw new Error('Reserved words used in `router({})` call: ' + Array.from(reservedWordsUsed).join(', '));
|
|
39
72
|
}
|
|
40
73
|
const procedures = omitPrototype({});
|
|
74
|
+
const lazy = omitPrototype({});
|
|
75
|
+
function createLazyLoader(opts) {
|
|
76
|
+
return {
|
|
77
|
+
ref: opts.ref,
|
|
78
|
+
load: once(async ()=>{
|
|
79
|
+
const router = await opts.ref();
|
|
80
|
+
const lazyPath = [
|
|
81
|
+
...opts.path,
|
|
82
|
+
opts.key
|
|
83
|
+
];
|
|
84
|
+
const lazyKey = lazyPath.join('.');
|
|
85
|
+
opts.aggregate[opts.key] = step(router._def.record, lazyPath);
|
|
86
|
+
delete lazy[lazyKey];
|
|
87
|
+
// add lazy loaders for nested routers
|
|
88
|
+
for (const [nestedKey, nestedItem] of Object.entries(router._def.lazy)){
|
|
89
|
+
const nestedRouterKey = [
|
|
90
|
+
...lazyPath,
|
|
91
|
+
nestedKey
|
|
92
|
+
].join('.');
|
|
93
|
+
// console.log('adding lazy', nestedRouterKey);
|
|
94
|
+
lazy[nestedRouterKey] = createLazyLoader({
|
|
95
|
+
ref: nestedItem.ref,
|
|
96
|
+
path: lazyPath,
|
|
97
|
+
key: nestedKey,
|
|
98
|
+
aggregate: opts.aggregate[opts.key]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
};
|
|
103
|
+
}
|
|
41
104
|
function step(from, path = []) {
|
|
42
105
|
const aggregate = omitPrototype({});
|
|
43
106
|
for (const [key, item] of Object.entries(from ?? {})){
|
|
107
|
+
if (isLazy(item)) {
|
|
108
|
+
lazy[[
|
|
109
|
+
...path,
|
|
110
|
+
key
|
|
111
|
+
].join('.')] = createLazyLoader({
|
|
112
|
+
path,
|
|
113
|
+
ref: item,
|
|
114
|
+
key,
|
|
115
|
+
aggregate
|
|
116
|
+
});
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
44
119
|
if (isRouter(item)) {
|
|
45
120
|
aggregate[key] = step(item._def.record, [
|
|
46
121
|
...path,
|
|
@@ -73,16 +148,18 @@ const emptyRouter = {
|
|
|
73
148
|
_config: config,
|
|
74
149
|
router: true,
|
|
75
150
|
procedures,
|
|
151
|
+
lazy,
|
|
76
152
|
...emptyRouter,
|
|
77
153
|
record
|
|
78
154
|
};
|
|
79
|
-
|
|
155
|
+
const router = {
|
|
80
156
|
...record,
|
|
81
157
|
_def,
|
|
82
158
|
createCaller: createCallerFactory()({
|
|
83
159
|
_def
|
|
84
160
|
})
|
|
85
161
|
};
|
|
162
|
+
return router;
|
|
86
163
|
}
|
|
87
164
|
return createRouterInner;
|
|
88
165
|
}
|
|
@@ -91,9 +168,28 @@ function isProcedure(procedureOrRouter) {
|
|
|
91
168
|
}
|
|
92
169
|
/**
|
|
93
170
|
* @internal
|
|
94
|
-
*/ function
|
|
171
|
+
*/ async function getProcedureAtPath(router, path) {
|
|
172
|
+
const { _def } = router;
|
|
173
|
+
let procedure = _def.procedures[path];
|
|
174
|
+
while(!procedure){
|
|
175
|
+
const key = Object.keys(_def.lazy).find((key)=>path.startsWith(key));
|
|
176
|
+
// console.log(`found lazy: ${key ?? 'NOPE'} (fullPath: ${fullPath})`);
|
|
177
|
+
if (!key) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
// console.log('loading', key, '.......');
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
182
|
+
const lazyRouter = _def.lazy[key];
|
|
183
|
+
await lazyRouter.load();
|
|
184
|
+
procedure = _def.procedures[path];
|
|
185
|
+
}
|
|
186
|
+
return procedure;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @internal
|
|
190
|
+
*/ async function callProcedure(opts) {
|
|
95
191
|
const { type, path } = opts;
|
|
96
|
-
const proc = opts.
|
|
192
|
+
const proc = await getProcedureAtPath(opts.router, path);
|
|
97
193
|
if (!proc || !isProcedure(proc) || proc._def.type !== type && !opts.allowMethodOverride) {
|
|
98
194
|
throw new TRPCError({
|
|
99
195
|
code: 'NOT_FOUND',
|
|
@@ -110,16 +206,22 @@ function isProcedure(procedureOrRouter) {
|
|
|
110
206
|
}
|
|
111
207
|
function createCallerFactory() {
|
|
112
208
|
return function createCallerInner(router) {
|
|
113
|
-
const _def = router
|
|
209
|
+
const { _def } = router;
|
|
114
210
|
return function createCaller(ctxOrCallback, opts) {
|
|
115
211
|
return createRecursiveProxy(async ({ path, args })=>{
|
|
116
212
|
const fullPath = path.join('.');
|
|
117
213
|
if (path.length === 1 && path[0] === '_def') {
|
|
118
214
|
return _def;
|
|
119
215
|
}
|
|
120
|
-
const procedure =
|
|
216
|
+
const procedure = await getProcedureAtPath(router, fullPath);
|
|
121
217
|
let ctx = undefined;
|
|
122
218
|
try {
|
|
219
|
+
if (!procedure) {
|
|
220
|
+
throw new TRPCError({
|
|
221
|
+
code: 'NOT_FOUND',
|
|
222
|
+
message: `No procedure found on path "${path}"`
|
|
223
|
+
});
|
|
224
|
+
}
|
|
123
225
|
ctx = isFunction(ctxOrCallback) ? await Promise.resolve(ctxOrCallback()) : ctxOrCallback;
|
|
124
226
|
return await procedure({
|
|
125
227
|
path: fullPath,
|
|
@@ -134,7 +236,7 @@ function createCallerFactory() {
|
|
|
134
236
|
error: getTRPCErrorFromUnknown(cause),
|
|
135
237
|
input: args[0],
|
|
136
238
|
path: fullPath,
|
|
137
|
-
type: procedure
|
|
239
|
+
type: procedure?._def.type ?? 'unknown'
|
|
138
240
|
});
|
|
139
241
|
throw cause;
|
|
140
242
|
}
|
|
@@ -173,4 +275,4 @@ function mergeRouters(...routerList) {
|
|
|
173
275
|
return router;
|
|
174
276
|
}
|
|
175
277
|
|
|
176
|
-
export { callProcedure, createCallerFactory, createRouterFactory, mergeRouters };
|
|
278
|
+
export { callProcedure, createCallerFactory, createRouterFactory, getProcedureAtPath, lazy, mergeRouters };
|
package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { createDeferred } from './utils/createDeferred.mjs';
|
|
|
4
4
|
import { makeResource } from './utils/disposable.mjs';
|
|
5
5
|
import { mergeAsyncIterables } from './utils/mergeAsyncIterables.mjs';
|
|
6
6
|
import { readableStreamFrom } from './utils/readableStreamFrom.mjs';
|
|
7
|
+
import { PING_SYM, withPing } from './utils/withPing.mjs';
|
|
7
8
|
|
|
8
9
|
function _define_property(obj, key, value) {
|
|
9
10
|
if (key in obj) {
|
|
@@ -83,7 +84,9 @@ function _ts_dispose_resources(env) {
|
|
|
83
84
|
return next();
|
|
84
85
|
})(env);
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
+
function isPlainObject(value) {
|
|
88
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
89
|
+
}
|
|
87
90
|
// ---------- types
|
|
88
91
|
const CHUNK_VALUE_TYPE_PROMISE = 0;
|
|
89
92
|
const CHUNK_VALUE_TYPE_ASYNC_ITERABLE = 1;
|
|
@@ -232,13 +235,6 @@ async function* createBatchStreamProducer(opts) {
|
|
|
232
235
|
[]
|
|
233
236
|
];
|
|
234
237
|
}
|
|
235
|
-
if (!isObject(value)) {
|
|
236
|
-
return [
|
|
237
|
-
[
|
|
238
|
-
value
|
|
239
|
-
]
|
|
240
|
-
];
|
|
241
|
-
}
|
|
242
238
|
const reg = encodeAsync(value, path);
|
|
243
239
|
if (reg) {
|
|
244
240
|
return [
|
|
@@ -251,6 +247,13 @@ async function* createBatchStreamProducer(opts) {
|
|
|
251
247
|
]
|
|
252
248
|
];
|
|
253
249
|
}
|
|
250
|
+
if (!isPlainObject(value)) {
|
|
251
|
+
return [
|
|
252
|
+
[
|
|
253
|
+
value
|
|
254
|
+
]
|
|
255
|
+
];
|
|
256
|
+
}
|
|
254
257
|
const newObj = {};
|
|
255
258
|
const asyncValues = [];
|
|
256
259
|
for (const [key, item] of Object.entries(value)){
|
|
@@ -282,7 +285,11 @@ async function* createBatchStreamProducer(opts) {
|
|
|
282
285
|
]);
|
|
283
286
|
}
|
|
284
287
|
yield newHead;
|
|
285
|
-
|
|
288
|
+
let iterable = mergedIterables;
|
|
289
|
+
if (opts.pingMs) {
|
|
290
|
+
iterable = withPing(mergedIterables, opts.pingMs);
|
|
291
|
+
}
|
|
292
|
+
for await (const value of iterable){
|
|
286
293
|
yield value;
|
|
287
294
|
}
|
|
288
295
|
}
|
|
@@ -295,25 +302,24 @@ async function* createBatchStreamProducer(opts) {
|
|
|
295
302
|
if (serialize) {
|
|
296
303
|
stream = stream.pipeThrough(new TransformStream({
|
|
297
304
|
transform (chunk, controller) {
|
|
298
|
-
|
|
305
|
+
if (chunk === PING_SYM) {
|
|
306
|
+
controller.enqueue(PING_SYM);
|
|
307
|
+
} else {
|
|
308
|
+
controller.enqueue(serialize(chunk));
|
|
309
|
+
}
|
|
299
310
|
}
|
|
300
311
|
}));
|
|
301
312
|
}
|
|
302
313
|
return stream.pipeThrough(new TransformStream({
|
|
303
314
|
transform (chunk, controller) {
|
|
304
|
-
|
|
315
|
+
if (chunk === PING_SYM) {
|
|
316
|
+
controller.enqueue(' ');
|
|
317
|
+
} else {
|
|
318
|
+
controller.enqueue(JSON.stringify(chunk) + '\n');
|
|
319
|
+
}
|
|
305
320
|
}
|
|
306
321
|
})).pipeThrough(new TextEncoderStream());
|
|
307
322
|
}
|
|
308
|
-
class StreamInterruptedError extends Error {
|
|
309
|
-
constructor(cause){
|
|
310
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
311
|
-
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
312
|
-
super('Invalid response or stream interrupted', {
|
|
313
|
-
cause
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
323
|
class AsyncError extends Error {
|
|
318
324
|
constructor(data){
|
|
319
325
|
super('Received error from server'), _define_property(this, "data", void 0), this.data = data;
|
|
@@ -403,17 +409,7 @@ function createConsumerStream(from) {
|
|
|
403
409
|
enqueue: (v)=>originalController.enqueue(v),
|
|
404
410
|
close: ()=>{
|
|
405
411
|
originalController.close();
|
|
406
|
-
|
|
407
|
-
Object.assign(streamController, {
|
|
408
|
-
closed: true,
|
|
409
|
-
close: ()=>{
|
|
410
|
-
// noop
|
|
411
|
-
},
|
|
412
|
-
enqueue: ()=>{
|
|
413
|
-
// noop
|
|
414
|
-
},
|
|
415
|
-
getReaderResource: null
|
|
416
|
-
});
|
|
412
|
+
clear();
|
|
417
413
|
if (isEmpty()) {
|
|
418
414
|
abortController.abort();
|
|
419
415
|
}
|
|
@@ -425,8 +421,27 @@ function createConsumerStream(from) {
|
|
|
425
421
|
reader.releaseLock();
|
|
426
422
|
streamController.close();
|
|
427
423
|
});
|
|
424
|
+
},
|
|
425
|
+
error: (reason)=>{
|
|
426
|
+
originalController.error(reason);
|
|
427
|
+
clear();
|
|
428
428
|
}
|
|
429
429
|
};
|
|
430
|
+
function clear() {
|
|
431
|
+
Object.assign(streamController, {
|
|
432
|
+
closed: true,
|
|
433
|
+
close: ()=>{
|
|
434
|
+
// noop
|
|
435
|
+
},
|
|
436
|
+
enqueue: ()=>{
|
|
437
|
+
// noop
|
|
438
|
+
},
|
|
439
|
+
getReaderResource: null,
|
|
440
|
+
error: ()=>{
|
|
441
|
+
// noop
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
430
445
|
return streamController;
|
|
431
446
|
}
|
|
432
447
|
/**
|
|
@@ -442,10 +457,8 @@ function createConsumerStream(from) {
|
|
|
442
457
|
/**
|
|
443
458
|
* Cancels all pending controllers and rejects deferred promises
|
|
444
459
|
*/ function cancelAll(reason) {
|
|
445
|
-
const error = new StreamInterruptedError(reason);
|
|
446
460
|
for (const controller of controllerMap.values()){
|
|
447
|
-
controller.
|
|
448
|
-
controller.close();
|
|
461
|
+
controller.error(reason);
|
|
449
462
|
}
|
|
450
463
|
}
|
|
451
464
|
return {
|
|
@@ -485,9 +498,6 @@ function createConsumerStream(from) {
|
|
|
485
498
|
const reader = _ts_add_disposable_resource(env, controller.getReaderResource(), false);
|
|
486
499
|
;
|
|
487
500
|
const { value } = await reader.read();
|
|
488
|
-
if (value instanceof StreamInterruptedError) {
|
|
489
|
-
throw value;
|
|
490
|
-
}
|
|
491
501
|
const [_chunkId, status, data] = value;
|
|
492
502
|
switch(status){
|
|
493
503
|
case PROMISE_STATUS_FULFILLED:
|
|
@@ -518,9 +528,6 @@ function createConsumerStream(from) {
|
|
|
518
528
|
;
|
|
519
529
|
while(true){
|
|
520
530
|
const { value } = await reader.read();
|
|
521
|
-
if (value instanceof StreamInterruptedError) {
|
|
522
|
-
throw value;
|
|
523
|
-
}
|
|
524
531
|
const [_chunkId, status, data] = value;
|
|
525
532
|
switch(status){
|
|
526
533
|
case ASYNC_ITERABLE_STATUS_YIELD:
|
|
@@ -557,9 +564,8 @@ function createConsumerStream(from) {
|
|
|
557
564
|
return data;
|
|
558
565
|
}
|
|
559
566
|
const closeOrAbort = (reason)=>{
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
streamManager.cancelAll(error);
|
|
567
|
+
headDeferred?.reject(reason);
|
|
568
|
+
streamManager.cancelAll(reason);
|
|
563
569
|
};
|
|
564
570
|
source.pipeTo(new WritableStream({
|
|
565
571
|
write (chunkOrHead) {
|
|
@@ -578,7 +584,7 @@ function createConsumerStream(from) {
|
|
|
578
584
|
const controller = streamManager.getOrCreate(idx);
|
|
579
585
|
controller.enqueue(chunk);
|
|
580
586
|
},
|
|
581
|
-
close: closeOrAbort,
|
|
587
|
+
close: ()=>closeOrAbort(new Error('Stream closed')),
|
|
582
588
|
abort: closeOrAbort
|
|
583
589
|
}), {
|
|
584
590
|
signal: opts.abortController.signal
|
package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Unpromise } from '../../vendor/unpromise/unpromise.mjs';
|
|
2
2
|
import { getTRPCErrorFromUnknown } from '../error/TRPCError.mjs';
|
|
3
|
-
import { isAbortError } from '../http/
|
|
4
|
-
import {
|
|
3
|
+
import { isAbortError } from '../http/abortError.mjs';
|
|
4
|
+
import { identity, run } from '../utils.mjs';
|
|
5
5
|
import { isTrackedEnvelope } from './tracked.mjs';
|
|
6
6
|
import { takeWithGrace, withMaxDuration } from './utils/asyncIterable.mjs';
|
|
7
7
|
import { makeAsyncResource } from './utils/disposable.mjs';
|
|
@@ -77,6 +77,7 @@ function _ts_dispose_resources(env) {
|
|
|
77
77
|
const PING_EVENT = 'ping';
|
|
78
78
|
const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
79
79
|
const CONNECTED_EVENT = 'connected';
|
|
80
|
+
const RETURN_EVENT = 'return';
|
|
80
81
|
/**
|
|
81
82
|
*
|
|
82
83
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
@@ -138,6 +139,10 @@ const CONNECTED_EVENT = 'connected';
|
|
|
138
139
|
async function* generatorWithErrorHandling() {
|
|
139
140
|
try {
|
|
140
141
|
yield* generator();
|
|
142
|
+
yield {
|
|
143
|
+
event: RETURN_EVENT,
|
|
144
|
+
data: ''
|
|
145
|
+
};
|
|
141
146
|
} catch (cause) {
|
|
142
147
|
if (isAbortError(cause)) {
|
|
143
148
|
// ignore abort errors, send any other errors
|
|
@@ -241,6 +246,11 @@ async function withTimeout(opts) {
|
|
|
241
246
|
eventSource
|
|
242
247
|
});
|
|
243
248
|
});
|
|
249
|
+
eventSource.addEventListener(RETURN_EVENT, ()=>{
|
|
250
|
+
eventSource.close();
|
|
251
|
+
controller.close();
|
|
252
|
+
_es = null;
|
|
253
|
+
});
|
|
244
254
|
eventSource.addEventListener('error', (event)=>{
|
|
245
255
|
if (eventSource.readyState === EventSource.CLOSED) {
|
|
246
256
|
controller.error(event);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Unpromise } from '../../../vendor/unpromise/unpromise.mjs';
|
|
2
|
+
import { throwAbortError } from '../../http/abortError.mjs';
|
|
2
3
|
import { makeAsyncResource } from './disposable.mjs';
|
|
3
4
|
import { timerResource, disposablePromiseTimerResult } from './timerResource.mjs';
|
|
4
5
|
|
|
@@ -74,7 +75,7 @@ function iteratorResource(iterable) {
|
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
77
|
-
* Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically
|
|
78
|
+
* Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically aborts after the specified duration.
|
|
78
79
|
*/ async function* withMaxDuration(iterable, opts) {
|
|
79
80
|
const env = {
|
|
80
81
|
stack: [],
|
|
@@ -96,8 +97,7 @@ function iteratorResource(iterable) {
|
|
|
96
97
|
]);
|
|
97
98
|
if (result === disposablePromiseTimerResult) {
|
|
98
99
|
// cancelled due to timeout
|
|
99
|
-
|
|
100
|
-
return res?.value;
|
|
100
|
+
throwAbortError();
|
|
101
101
|
}
|
|
102
102
|
if (result.done) {
|
|
103
103
|
return result;
|
|
@@ -117,7 +117,7 @@ function iteratorResource(iterable) {
|
|
|
117
117
|
/**
|
|
118
118
|
* Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
|
|
119
119
|
* {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
|
|
120
|
-
* values may still come through. After this period, the generator
|
|
120
|
+
* values may still come through. After this period, the generator aborts.
|
|
121
121
|
*/ async function* takeWithGrace(iterable, opts) {
|
|
122
122
|
const env = {
|
|
123
123
|
stack: [],
|
|
@@ -141,9 +141,7 @@ function iteratorResource(iterable) {
|
|
|
141
141
|
timerPromise
|
|
142
142
|
]);
|
|
143
143
|
if (result === disposablePromiseTimerResult) {
|
|
144
|
-
|
|
145
|
-
const res = await iterator.return?.();
|
|
146
|
-
return res?.value;
|
|
144
|
+
throwAbortError();
|
|
147
145
|
}
|
|
148
146
|
if (result.done) {
|
|
149
147
|
return result.value;
|
|
@@ -14,11 +14,12 @@ _Symbol1;
|
|
|
14
14
|
*/ function makeResource(thing, dispose) {
|
|
15
15
|
const it = thing;
|
|
16
16
|
// eslint-disable-next-line no-restricted-syntax
|
|
17
|
-
|
|
18
|
-
throw new Error('Symbol.dispose already exists');
|
|
19
|
-
}
|
|
17
|
+
const existing = it[Symbol.dispose];
|
|
20
18
|
// eslint-disable-next-line no-restricted-syntax
|
|
21
|
-
it[Symbol.dispose] =
|
|
19
|
+
it[Symbol.dispose] = ()=>{
|
|
20
|
+
dispose();
|
|
21
|
+
existing?.();
|
|
22
|
+
};
|
|
22
23
|
return it;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
@@ -30,11 +31,12 @@ _Symbol1;
|
|
|
30
31
|
*/ function makeAsyncResource(thing, dispose) {
|
|
31
32
|
const it = thing;
|
|
32
33
|
// eslint-disable-next-line no-restricted-syntax
|
|
33
|
-
|
|
34
|
-
throw new Error('Symbol.asyncDispose already exists');
|
|
35
|
-
}
|
|
34
|
+
const existing = it[Symbol.asyncDispose];
|
|
36
35
|
// eslint-disable-next-line no-restricted-syntax
|
|
37
|
-
it[Symbol.asyncDispose] =
|
|
36
|
+
it[Symbol.asyncDispose] = async ()=>{
|
|
37
|
+
await dispose();
|
|
38
|
+
await existing?.();
|
|
39
|
+
};
|
|
38
40
|
return it;
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
/** A schema error with useful information. */ class StandardSchemaV1Error extends Error {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a schema error with useful information.
|
|
17
|
+
*
|
|
18
|
+
* @param issues The schema issues.
|
|
19
|
+
*/ constructor(issues){
|
|
20
|
+
super(issues[0]?.message), /** The schema issues. */ _define_property(this, "issues", void 0);
|
|
21
|
+
this.name = 'SchemaError';
|
|
22
|
+
this.issues = issues;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { StandardSchemaV1Error };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.808+4df1eb8fa",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -118,16 +118,16 @@
|
|
|
118
118
|
},
|
|
119
119
|
"devDependencies": {
|
|
120
120
|
"@fastify/websocket": "^10.0.1",
|
|
121
|
-
"@tanstack/react-query": "^5.
|
|
121
|
+
"@tanstack/react-query": "^5.66.0",
|
|
122
122
|
"@types/aws-lambda": "^8.10.137",
|
|
123
|
-
"@types/express": "^
|
|
123
|
+
"@types/express": "^5.0.0",
|
|
124
124
|
"@types/hash-sum": "^1.0.0",
|
|
125
|
-
"@types/node": "^22.
|
|
125
|
+
"@types/node": "^22.13.5",
|
|
126
126
|
"@types/react": "^19.0.0",
|
|
127
127
|
"@types/react-dom": "^19.0.0",
|
|
128
128
|
"@types/ws": "^8.2.0",
|
|
129
129
|
"devalue": "^5.0.0",
|
|
130
|
-
"eslint": "^9.
|
|
130
|
+
"eslint": "^9.21.0",
|
|
131
131
|
"express": "^5.0.0",
|
|
132
132
|
"fastify": "^4.16.0",
|
|
133
133
|
"fastify-plugin": "^5.0.0",
|
|
@@ -136,15 +136,15 @@
|
|
|
136
136
|
"next": "^15.1.3",
|
|
137
137
|
"react": "^19.0.0",
|
|
138
138
|
"react-dom": "^19.0.0",
|
|
139
|
-
"rollup": "^4.
|
|
139
|
+
"rollup": "^4.34.8",
|
|
140
140
|
"superjson": "^1.12.4",
|
|
141
141
|
"superstruct": "^2.0.0",
|
|
142
|
-
"tsx": "^4.
|
|
142
|
+
"tsx": "^4.19.3",
|
|
143
143
|
"typescript": "^5.7.2",
|
|
144
|
-
"valibot": "
|
|
144
|
+
"valibot": "1.0.0-rc.1",
|
|
145
145
|
"ws": "^8.0.0",
|
|
146
146
|
"yup": "^1.0.0",
|
|
147
|
-
"zod": "^3.
|
|
147
|
+
"zod": "^3.24.2"
|
|
148
148
|
},
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
@@ -152,5 +152,5 @@
|
|
|
152
152
|
"peerDependencies": {
|
|
153
153
|
"typescript": ">=5.7.2"
|
|
154
154
|
},
|
|
155
|
-
"gitHead": "
|
|
155
|
+
"gitHead": "4df1eb8fa820341db81bc7cb9907f30dfebbf4d7"
|
|
156
156
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/dom",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.11.
|
|
4
|
+
"version": "1.11.19",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@unhead/schema": "1.11.
|
|
33
|
-
"@unhead/shared": "1.11.
|
|
32
|
+
"@unhead/schema": "1.11.19",
|
|
33
|
+
"@unhead/shared": "1.11.19"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "unbuild .",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.11.
|
|
4
|
+
"version": "1.11.19",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"packrup": "^0.1.2",
|
|
38
|
-
"@unhead/schema": "1.11.
|
|
38
|
+
"@unhead/schema": "1.11.19"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "unbuild .",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/ssr",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.11.
|
|
4
|
+
"version": "1.11.19",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@unhead/schema": "1.11.
|
|
33
|
-
"@unhead/shared": "1.11.
|
|
32
|
+
"@unhead/schema": "1.11.19",
|
|
33
|
+
"@unhead/shared": "1.11.19"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "unbuild .",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{Buffer}from"node:buffer";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{EventEmitter}from"node:events";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EventEmitter as f}from"node-mock-http/_polyfill/events";import{Buffer as h}from"node-mock-http/_polyfill/buffer";function o(n){throw new Error(`${n} is not implemented yet!`)}class i extends f{__unenv__={};readableEncoding=null;readableEnded=!0;readableFlowing=!1;readableHighWaterMark=0;readableLength=0;readableObjectMode=!1;readableAborted=!1;readableDidRead=!1;closed=!1;errored=null;readable=!1;destroyed=!1;static from(e,t){return new i(t)}constructor(e){super()}_read(e){}read(e){}setEncoding(e){return this}pause(){return this}resume(){return this}isPaused(){return!0}unpipe(e){return this}unshift(e,t){}wrap(e){return this}push(e,t){return!1}_destroy(e,t){this.removeAllListeners()}destroy(e){return this.destroyed=!0,this._destroy(e),this}pipe(e,t){return{}}compose(e,t){throw new Error("Method not implemented.")}[Symbol.asyncDispose](){return this.destroy(),Promise.resolve()}async*[Symbol.asyncIterator](){throw o("Readable.asyncIterator")}iterator(e){throw o("Readable.iterator")}map(e,t){throw o("Readable.map")}filter(e,t){throw o("Readable.filter")}forEach(e,t){throw o("Readable.forEach")}reduce(e,t,r){throw o("Readable.reduce")}find(e,t){throw o("Readable.find")}findIndex(e,t){throw o("Readable.findIndex")}some(e,t){throw o("Readable.some")}toArray(e){throw o("Readable.toArray")}every(e,t){throw o("Readable.every")}flatMap(e,t){throw o("Readable.flatMap")}drop(e,t){throw o("Readable.drop")}take(e,t){throw o("Readable.take")}asIndexedPairs(e){throw o("Readable.asIndexedPairs")}}class l extends f{__unenv__={};writable=!0;writableEnded=!1;writableFinished=!1;writableHighWaterMark=0;writableLength=0;writableObjectMode=!1;writableCorked=0;closed=!1;errored=null;writableNeedDrain=!1;destroyed=!1;_data;_encoding="utf8";constructor(e){super()}pipe(e,t){return{}}_write(e,t,r){if(this.writableEnded){r&&r();return}if(this._data===void 0)this._data=e;else{const s=typeof this._data=="string"?h.from(this._data,this._encoding||t||"utf8"):this._data,a=typeof e=="string"?h.from(e,t||this._encoding||"utf8"):e;this._data=h.concat([s,a])}this._encoding=t,r&&r()}_writev(e,t){}_destroy(e,t){}_final(e){}write(e,t,r){const s=typeof t=="string"?this._encoding:"utf8",a=typeof t=="function"?t:typeof r=="function"?r:void 0;return this._write(e,s,a),!0}setDefaultEncoding(e){return this}end(e,t,r){const s=typeof e=="function"?e:typeof t=="function"?t:typeof r=="function"?r:void 0;if(this.writableEnded)return s&&s(),this;const a=e===s?void 0:e;if(a){const u=t===s?void 0:t;this.write(a,u,s)}return this.writableEnded=!0,this.writableFinished=!0,this.emit("close"),this.emit("finish"),this}cork(){}uncork(){}destroy(e){return this.destroyed=!0,delete this._data,this.removeAllListeners(),this}compose(e,t){throw new Error("Method not implemented.")}}const c=class{allowHalfOpen=!0;_destroy;constructor(e=new i,t=new l){Object.assign(this,e),Object.assign(this,t),this._destroy=g(e._destroy,t._destroy)}};function _(){return Object.assign(c.prototype,i.prototype),Object.assign(c.prototype,l.prototype),c}function g(...n){return function(...e){for(const t of n)t(...e)}}const m=_();class A extends m{__unenv__={};bufferSize=0;bytesRead=0;bytesWritten=0;connecting=!1;destroyed=!1;pending=!1;localAddress="";localPort=0;remoteAddress="";remoteFamily="";remotePort=0;autoSelectFamilyAttemptedAddresses=[];readyState="readOnly";constructor(e){super()}write(e,t,r){return!1}connect(e,t,r){return this}end(e,t,r){return this}setEncoding(e){return this}pause(){return this}resume(){return this}setTimeout(e,t){return this}setNoDelay(e){return this}setKeepAlive(e,t){return this}address(){return{}}unref(){return this}ref(){return this}destroySoon(){this.destroy()}resetAndDestroy(){const e=new Error("ERR_SOCKET_CLOSED");return e.code="ERR_SOCKET_CLOSED",this.destroy(e),this}}class y extends i{aborted=!1;httpVersion="1.1";httpVersionMajor=1;httpVersionMinor=1;complete=!0;connection;socket;headers={};trailers={};method="GET";url="/";statusCode=200;statusMessage="";closed=!1;errored=null;readable=!1;constructor(e){super(),this.socket=this.connection=e||new A}get rawHeaders(){const e=this.headers,t=[];for(const r in e)if(Array.isArray(e[r]))for(const s of e[r])t.push(r,s);else t.push(r,e[r]);return t}get rawTrailers(){return[]}setTimeout(e,t){return this}get headersDistinct(){return p(this.headers)}get trailersDistinct(){return p(this.trailers)}}function p(n){const e={};for(const[t,r]of Object.entries(n))t&&(e[t]=(Array.isArray(r)?r:[r]).filter(Boolean));return e}class w extends l{statusCode=200;statusMessage="";upgrading=!1;chunkedEncoding=!1;shouldKeepAlive=!1;useChunkedEncodingByDefault=!1;sendDate=!1;finished=!1;headersSent=!1;strictContentLength=!1;connection=null;socket=null;req;_headers={};constructor(e){super(),this.req=e}assignSocket(e){e._httpMessage=this,this.socket=e,this.connection=e,this.emit("socket",e),this._flush()}_flush(){this.flushHeaders()}detachSocket(e){}writeContinue(e){}writeHead(e,t,r){e&&(this.statusCode=e),typeof t=="string"&&(this.statusMessage=t,t=void 0);const s=r||t;if(s&&!Array.isArray(s))for(const a in s)this.setHeader(a,s[a]);return this.headersSent=!0,this}writeProcessing(){}setTimeout(e,t){return this}appendHeader(e,t){e=e.toLowerCase();const r=this._headers[e],s=[...Array.isArray(r)?r:[r],...Array.isArray(t)?t:[t]].filter(Boolean);return this._headers[e]=s.length>1?s:s[0],this}setHeader(e,t){return this._headers[e.toLowerCase()]=t,this}setHeaders(e){for(const[t,r]of Object.entries(e))this.setHeader(t,r);return this}getHeader(e){return this._headers[e.toLowerCase()]}getHeaders(){return this._headers}getHeaderNames(){return Object.keys(this._headers)}hasHeader(e){return e.toLowerCase()in this._headers}removeHeader(e){delete this._headers[e.toLowerCase()]}addTrailers(e){}flushHeaders(){}writeEarlyHints(e,t){typeof t=="function"&&t()}}const E=(()=>{const n=function(){};return n.prototype=Object.create(null),n})();function R(n={}){const e=new E,t=Array.isArray(n)||H(n)?n:Object.entries(n);for(const[r,s]of t)if(s){if(e[r]===void 0){e[r]=s;continue}e[r]=[...Array.isArray(e[r])?e[r]:[e[r]],...Array.isArray(s)?s:[s]]}return e}function H(n){return typeof n?.entries=="function"}function S(n={}){if(n instanceof Headers)return n;const e=new Headers;for(const[t,r]of Object.entries(n))if(r!==void 0){if(Array.isArray(r)){for(const s of r)e.append(t,String(s));continue}e.set(t,String(r))}return e}const C=new Set([101,204,205,304]);async function b(n,e){const t=new y,r=new w(t);t.url=e.url?.toString()||"/";let s;if(!t.url.startsWith("/")){const d=new URL(t.url);s=d.host,t.url=d.pathname+d.search+d.hash}t.method=e.method||"GET",t.headers=R(e.headers||{}),t.headers.host||(t.headers.host=e.host||s||"localhost"),t.connection.encrypted=t.connection.encrypted||e.protocol==="https",t.body=e.body||null,t.__unenv__=e.context,await n(t,r);let a=r._data;(C.has(r.statusCode)||t.method.toUpperCase()==="HEAD")&&(a=null,delete r._headers["content-length"]);const u={status:r.statusCode,statusText:r.statusMessage,headers:r._headers,body:a};return t.destroy(),r.destroy(),u}async function O(n,e,t={}){try{const r=await b(n,{url:e,...t});return new Response(r.body,{status:r.status,statusText:r.statusText,headers:S(r.headers)})}catch(r){return new Response(r.toString(),{status:Number.parseInt(r.statusCode||r.code)||500,statusText:r.statusText})}}export{y as IncomingMessage,w as ServerResponse,b as callNodeRequestHandler,O as fetchNodeRequestHandler};
|