@trpc/server 11.0.0-alpha-tmp-issues-5851-take-two.493 → 11.0.0-alpha-tmp-issues-5851-take-two.495
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/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +7 -6
- package/dist/adapters/ws.mjs +8 -7
- package/dist/bundle-analysis.json +25 -25
- package/package.json +2 -2
- package/src/adapters/ws.ts +8 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/adapters/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAS,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAatE,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAQlE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,8BAA8B,CACpE,eAAe,EACf,EAAE,CAAC,SAAS,CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,IAAI,CAC1D,IAAI,EAAE,yBAAyB,KAC5B,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/C,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,GAC1C,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,iB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,EAAE,eAAe,CAAC,GAC1C,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IACrD,0BAA0B,CAAC,OAAO,CAAC,GAAG;IACpC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QACV;;;WAGG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;;WAGG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAGJ,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,SAAS,EAC9D,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,YAKnB,EAAE,CAAC,SAAS,OAAO,eAAe,mBAqUzD;AAiCD,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EA+BjC"}
|
package/dist/adapters/ws.js
CHANGED
|
@@ -25,9 +25,9 @@ function getWSConnectionHandler(opts) {
|
|
|
25
25
|
function respond(untransformedJSON) {
|
|
26
26
|
client.send(JSON.stringify(transformer.transformTRPCResponse(router$1._def._config, untransformedJSON)));
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
function createCtxPromise(getConnectionParams) {
|
|
29
|
+
return utils.run(async ()=>{
|
|
30
|
+
ctx = await createContext?.({
|
|
31
31
|
req,
|
|
32
32
|
res: client,
|
|
33
33
|
info: {
|
|
@@ -39,7 +39,8 @@ function getWSConnectionHandler(opts) {
|
|
|
39
39
|
signal: abortController.signal
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
|
|
42
|
+
return ctx;
|
|
43
|
+
}).catch((cause)=>{
|
|
43
44
|
const error = TRPCError.getTRPCErrorFromUnknown(cause);
|
|
44
45
|
opts.onError?.({
|
|
45
46
|
error,
|
|
@@ -65,7 +66,7 @@ function getWSConnectionHandler(opts) {
|
|
|
65
66
|
client.close();
|
|
66
67
|
});
|
|
67
68
|
throw error;
|
|
68
|
-
}
|
|
69
|
+
});
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* promise for initializing the context
|
|
@@ -73,7 +74,7 @@ function getWSConnectionHandler(opts) {
|
|
|
73
74
|
* - the context promise will be created immediately on connection if no connectionParams are expected
|
|
74
75
|
* - if connection params are expected, they will be created once received
|
|
75
76
|
*/ let ctxPromise = toURL.toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextSymbol : createCtxPromise(()=>null);
|
|
76
|
-
|
|
77
|
+
let ctx = undefined;
|
|
77
78
|
async function handleRequest(msg) {
|
|
78
79
|
const { id , jsonrpc } = msg;
|
|
79
80
|
/* istanbul ignore next -- @preserve */ if (id === null) {
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
2
2
|
import { TRPCError, getTRPCErrorFromUnknown } from '../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { run, isAsyncIterable, isObject } from '../unstable-core-do-not-import/utils.mjs';
|
|
4
4
|
import { parseConnectionParamsFromUnknown } from '../unstable-core-do-not-import/http/parseConnectionParams.mjs';
|
|
5
5
|
import { parseTRPCMessage } from '../unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
|
|
6
6
|
import { isObservable, observableToAsyncIterable } from '../observable/observable.mjs';
|
|
@@ -23,9 +23,9 @@ function getWSConnectionHandler(opts) {
|
|
|
23
23
|
function respond(untransformedJSON) {
|
|
24
24
|
client.send(JSON.stringify(transformTRPCResponse(router._def._config, untransformedJSON)));
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
function createCtxPromise(getConnectionParams) {
|
|
27
|
+
return run(async ()=>{
|
|
28
|
+
ctx = await createContext?.({
|
|
29
29
|
req,
|
|
30
30
|
res: client,
|
|
31
31
|
info: {
|
|
@@ -37,7 +37,8 @@ function getWSConnectionHandler(opts) {
|
|
|
37
37
|
signal: abortController.signal
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
return ctx;
|
|
41
|
+
}).catch((cause)=>{
|
|
41
42
|
const error = getTRPCErrorFromUnknown(cause);
|
|
42
43
|
opts.onError?.({
|
|
43
44
|
error,
|
|
@@ -63,7 +64,7 @@ function getWSConnectionHandler(opts) {
|
|
|
63
64
|
client.close();
|
|
64
65
|
});
|
|
65
66
|
throw error;
|
|
66
|
-
}
|
|
67
|
+
});
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
70
|
* promise for initializing the context
|
|
@@ -71,7 +72,7 @@ function getWSConnectionHandler(opts) {
|
|
|
71
72
|
* - the context promise will be created immediately on connection if no connectionParams are expected
|
|
72
73
|
* - if connection params are expected, they will be created once received
|
|
73
74
|
*/ let ctxPromise = toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextSymbol : createCtxPromise(()=>null);
|
|
74
|
-
|
|
75
|
+
let ctx = undefined;
|
|
75
76
|
async function handleRequest(msg) {
|
|
76
77
|
const { id , jsonrpc } = msg;
|
|
77
78
|
/* istanbul ignore next -- @preserve */ if (id === null) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 27.
|
|
2
|
+
"bundleSize": 131370,
|
|
3
|
+
"bundleOrigSize": 180751,
|
|
4
|
+
"bundleReduction": 27.32,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"id": "/src/adapters/ws.ts",
|
|
39
|
-
"size":
|
|
40
|
-
"origSize":
|
|
39
|
+
"size": 14422,
|
|
40
|
+
"origSize": 13640,
|
|
41
41
|
"renderedExports": [
|
|
42
42
|
"getWSConnectionHandler",
|
|
43
43
|
"applyWSSHandler"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 10.
|
|
49
|
+
"percent": 10.98,
|
|
50
50
|
"reduction": 0
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"dependents": [
|
|
128
128
|
"/src/adapters/aws-lambda/index.ts"
|
|
129
129
|
],
|
|
130
|
-
"percent": 4.
|
|
130
|
+
"percent": 4.12,
|
|
131
131
|
"reduction": 11.38
|
|
132
132
|
},
|
|
133
133
|
{
|
|
@@ -193,9 +193,9 @@
|
|
|
193
193
|
"removedExports": [],
|
|
194
194
|
"dependents": [
|
|
195
195
|
"/src/unstable-core-do-not-import.ts",
|
|
196
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
197
196
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
198
|
-
"/src/unstable-core-do-not-import/router.ts"
|
|
197
|
+
"/src/unstable-core-do-not-import/router.ts",
|
|
198
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
199
199
|
],
|
|
200
200
|
"percent": 2.09,
|
|
201
201
|
"reduction": 45.94
|
|
@@ -319,11 +319,11 @@
|
|
|
319
319
|
"removedExports": [],
|
|
320
320
|
"dependents": [
|
|
321
321
|
"/src/unstable-core-do-not-import.ts",
|
|
322
|
-
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
323
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
324
322
|
"/src/unstable-core-do-not-import/stream/sse.ts",
|
|
325
323
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
326
324
|
"/src/unstable-core-do-not-import/router.ts",
|
|
325
|
+
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
326
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
327
327
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
328
328
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
329
329
|
"/src/unstable-core-do-not-import/stream/jsonl.ts"
|
|
@@ -393,8 +393,8 @@
|
|
|
393
393
|
"removedExports": [],
|
|
394
394
|
"dependents": [
|
|
395
395
|
"/src/unstable-core-do-not-import.ts",
|
|
396
|
-
"/src/unstable-core-do-not-import/
|
|
397
|
-
"/src/unstable-core-do-not-import/
|
|
396
|
+
"/src/unstable-core-do-not-import/error/getErrorShape.ts",
|
|
397
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
398
398
|
],
|
|
399
399
|
"percent": 0.98,
|
|
400
400
|
"reduction": 18.7
|
|
@@ -415,14 +415,14 @@
|
|
|
415
415
|
"removedExports": [],
|
|
416
416
|
"dependents": [
|
|
417
417
|
"/src/unstable-core-do-not-import.ts",
|
|
418
|
-
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
419
|
-
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
420
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
421
418
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
422
419
|
"/src/unstable-core-do-not-import/stream/sse.ts",
|
|
423
420
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
424
421
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
425
422
|
"/src/unstable-core-do-not-import/router.ts",
|
|
423
|
+
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
424
|
+
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
425
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
426
426
|
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
427
427
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
428
428
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
@@ -710,24 +710,24 @@
|
|
|
710
710
|
"reduction": 93.8
|
|
711
711
|
},
|
|
712
712
|
{
|
|
713
|
-
"id": "/src/
|
|
713
|
+
"id": "/src/index.ts",
|
|
714
714
|
"size": 0,
|
|
715
|
-
"origSize":
|
|
715
|
+
"origSize": 32,
|
|
716
716
|
"renderedExports": [],
|
|
717
717
|
"removedExports": [],
|
|
718
|
-
"dependents": [
|
|
719
|
-
"/src/adapters/ws.ts"
|
|
720
|
-
],
|
|
718
|
+
"dependents": [],
|
|
721
719
|
"percent": 0,
|
|
722
720
|
"reduction": 100
|
|
723
721
|
},
|
|
724
722
|
{
|
|
725
|
-
"id": "/src/
|
|
723
|
+
"id": "/src/http.ts",
|
|
726
724
|
"size": 0,
|
|
727
|
-
"origSize":
|
|
725
|
+
"origSize": 37,
|
|
728
726
|
"renderedExports": [],
|
|
729
727
|
"removedExports": [],
|
|
730
|
-
"dependents": [
|
|
728
|
+
"dependents": [
|
|
729
|
+
"/src/adapters/ws.ts"
|
|
730
|
+
],
|
|
731
731
|
"percent": 0,
|
|
732
732
|
"reduction": 100
|
|
733
733
|
},
|
|
@@ -804,8 +804,8 @@
|
|
|
804
804
|
"removedExports": [],
|
|
805
805
|
"dependents": [
|
|
806
806
|
"/src/adapters/express.ts",
|
|
807
|
-
"/src/adapters/next.ts",
|
|
808
807
|
"/src/adapters/standalone.ts",
|
|
808
|
+
"/src/adapters/next.ts",
|
|
809
809
|
"/src/adapters/fastify/fastifyRequestHandler.ts"
|
|
810
810
|
],
|
|
811
811
|
"percent": 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-alpha-tmp-issues-5851-take-two.
|
|
3
|
+
"version": "11.0.0-alpha-tmp-issues-5851-take-two.495+b70195a19",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "b70195a198a137a0252a4333f1880c7d3b373f43"
|
|
153
153
|
}
|
package/src/adapters/ws.ts
CHANGED
|
@@ -107,11 +107,11 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
function createCtxPromise(
|
|
111
111
|
getConnectionParams: () => TRPCRequestInfo['connectionParams'],
|
|
112
112
|
): Promise<inferRouterContext<TRouter>> {
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
return run(async () => {
|
|
114
|
+
ctx = await createContext?.({
|
|
115
115
|
req,
|
|
116
116
|
res: client,
|
|
117
117
|
info: {
|
|
@@ -123,7 +123,9 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
123
123
|
signal: abortController.signal,
|
|
124
124
|
},
|
|
125
125
|
});
|
|
126
|
-
|
|
126
|
+
|
|
127
|
+
return ctx;
|
|
128
|
+
}).catch((cause) => {
|
|
127
129
|
const error = getTRPCErrorFromUnknown(cause);
|
|
128
130
|
opts.onError?.({
|
|
129
131
|
error,
|
|
@@ -151,7 +153,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
151
153
|
});
|
|
152
154
|
|
|
153
155
|
throw error;
|
|
154
|
-
}
|
|
156
|
+
});
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
/**
|
|
@@ -165,7 +167,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
165
167
|
? unsetContextSymbol
|
|
166
168
|
: createCtxPromise(() => null);
|
|
167
169
|
|
|
168
|
-
|
|
170
|
+
let ctx: inferRouterContext<TRouter> | undefined = undefined;
|
|
169
171
|
|
|
170
172
|
async function handleRequest(msg: TRPCClientOutgoingMessage) {
|
|
171
173
|
const { id, jsonrpc } = msg;
|