@trpc/server 11.3.1 → 11.3.2-canary.2
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/adapters/aws-lambda/package.json +1 -0
- package/adapters/express/package.json +1 -0
- package/adapters/fastify/package.json +1 -0
- package/adapters/fetch/package.json +1 -0
- package/adapters/next/package.json +1 -0
- package/adapters/next-app-dir/package.json +1 -0
- package/adapters/node-http/package.json +1 -0
- package/adapters/standalone/package.json +1 -0
- package/adapters/ws/package.json +1 -0
- package/dist/adapters/aws-lambda/index.cjs +255 -0
- package/dist/adapters/aws-lambda/index.d.cts +31 -0
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -0
- package/dist/adapters/aws-lambda/index.d.mts +31 -0
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -0
- package/dist/adapters/aws-lambda/index.mjs +248 -57
- package/dist/adapters/aws-lambda/index.mjs.map +1 -0
- package/dist/adapters/express.cjs +34 -0
- package/dist/adapters/express.d.cts +15 -0
- package/dist/adapters/express.d.cts.map +1 -0
- package/dist/adapters/express.d.mts +15 -0
- package/dist/adapters/express.d.mts.map +1 -0
- package/dist/adapters/express.mjs +30 -32
- package/dist/adapters/express.mjs.map +1 -0
- package/dist/adapters/fastify/index.cjs +75 -0
- package/dist/adapters/fastify/index.d.cts +29 -0
- package/dist/adapters/fastify/index.d.cts.map +1 -0
- package/dist/adapters/fastify/index.d.mts +29 -0
- package/dist/adapters/fastify/index.d.mts.map +1 -0
- package/dist/adapters/fastify/index.mjs +75 -2
- package/dist/adapters/fastify/index.mjs.map +1 -0
- package/dist/adapters/fetch/index.cjs +58 -0
- package/dist/adapters/fetch/index.d.cts +30 -0
- package/dist/adapters/fetch/index.d.cts.map +1 -0
- package/dist/adapters/fetch/index.d.mts +30 -0
- package/dist/adapters/fetch/index.d.mts.map +1 -0
- package/dist/adapters/fetch/index.mjs +59 -1
- package/dist/adapters/fetch/index.mjs.map +1 -0
- package/dist/adapters/next-app-dir.cjs +3050 -0
- package/dist/adapters/next-app-dir.d.cts +58 -0
- package/dist/adapters/next-app-dir.d.cts.map +1 -0
- package/dist/adapters/next-app-dir.d.mts +58 -0
- package/dist/adapters/next-app-dir.d.mts.map +1 -0
- package/dist/adapters/next-app-dir.mjs +3048 -4
- package/dist/adapters/next-app-dir.mjs.map +1 -0
- package/dist/adapters/next.cjs +41 -0
- package/dist/adapters/next.d.cts +19 -0
- package/dist/adapters/next.d.cts.map +1 -0
- package/dist/adapters/next.d.mts +19 -0
- package/dist/adapters/next.d.mts.map +1 -0
- package/dist/adapters/next.mjs +37 -44
- package/dist/adapters/next.mjs.map +1 -0
- package/dist/adapters/node-http/index.cjs +15 -0
- package/dist/adapters/node-http/index.d.cts +5 -0
- package/dist/adapters/node-http/index.d.mts +5 -0
- package/dist/adapters/node-http/index.mjs +12 -2
- package/dist/adapters/standalone.cjs +52 -0
- package/dist/adapters/standalone.d.cts +33 -0
- package/dist/adapters/standalone.d.cts.map +1 -0
- package/dist/adapters/standalone.d.mts +33 -0
- package/dist/adapters/standalone.d.mts.map +1 -0
- package/dist/adapters/standalone.mjs +40 -34
- package/dist/adapters/standalone.mjs.map +1 -0
- package/dist/adapters/ws.cjs +17 -0
- package/dist/adapters/ws.d.cts +61 -0
- package/dist/adapters/ws.d.cts.map +1 -0
- package/dist/adapters/ws.d.mts +61 -0
- package/dist/adapters/ws.d.mts.map +1 -0
- package/dist/adapters/ws.mjs +14 -539
- package/dist/contentTypeParsers-SN4WL9ze.mjs +13 -0
- package/dist/contentTypeParsers-SN4WL9ze.mjs.map +1 -0
- package/dist/contentTypeParsers-iAFF_pJG.cjs +18 -0
- package/dist/getErrorShape-CsikfkAc.cjs +201 -0
- package/dist/getErrorShape-DyYil4aT.mjs +149 -0
- package/dist/getErrorShape-DyYil4aT.mjs.map +1 -0
- package/dist/http-CWyjOa1l.mjs +0 -0
- package/dist/http-DXy3XyhL.cjs +0 -0
- package/dist/http.cjs +14 -0
- package/dist/http.d.cts +3 -0
- package/dist/http.d.mts +3 -0
- package/dist/http.mjs +9 -8
- package/dist/index.cjs +22 -0
- package/dist/index.d-BiUz7kM_.d.cts +65 -0
- package/dist/index.d-BiUz7kM_.d.cts.map +1 -0
- package/dist/index.d-ChWYhXbd.d.cts +99 -0
- package/dist/index.d-ChWYhXbd.d.cts.map +1 -0
- package/dist/index.d-CvZXeEyR.d.cts +11 -0
- package/dist/index.d-CvZXeEyR.d.cts.map +1 -0
- package/dist/index.d-D4qZxQJh.d.mts +65 -0
- package/dist/index.d-D4qZxQJh.d.mts.map +1 -0
- package/dist/index.d-Ocy_AnXj.d.mts +99 -0
- package/dist/index.d-Ocy_AnXj.d.mts.map +1 -0
- package/dist/index.d-vq_QHko2.d.mts +11 -0
- package/dist/index.d-vq_QHko2.d.mts.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +6 -13
- package/dist/initTRPC-COaJMShh.mjs +339 -0
- package/dist/initTRPC-COaJMShh.mjs.map +1 -0
- package/dist/initTRPC-DjEpHmY2.cjs +397 -0
- package/dist/node-http-BPR68yI4.cjs +243 -0
- package/dist/node-http-BUQnHuGI.mjs +221 -0
- package/dist/node-http-BUQnHuGI.mjs.map +1 -0
- package/dist/observable/index.cjs +13 -0
- package/dist/observable/index.d.cts +2 -0
- package/dist/observable/index.d.mts +2 -0
- package/dist/observable/index.mjs +4 -3
- package/dist/observable-B1orLHHI.mjs +155 -0
- package/dist/observable-B1orLHHI.mjs.map +1 -0
- package/dist/observable-BwdrSFZU.cjs +178 -0
- package/dist/observable-C6qq2Ydk.cjs +180 -0
- package/dist/observable-CFXA_tyK.mjs +146 -0
- package/dist/observable-CFXA_tyK.mjs.map +1 -0
- package/dist/parseTRPCMessage-ByQWigsq.cjs +73 -0
- package/dist/parseTRPCMessage-CNyYMSRB.mjs +63 -0
- package/dist/parseTRPCMessage-CNyYMSRB.mjs.map +1 -0
- package/dist/resolveResponse-B2CuaT_1.cjs +2042 -0
- package/dist/resolveResponse-DPbYgJDD.mjs +1912 -0
- package/dist/resolveResponse-DPbYgJDD.mjs.map +1 -0
- package/dist/rpc.cjs +6 -0
- package/dist/rpc.d.cts +3 -0
- package/dist/rpc.d.mts +3 -0
- package/dist/rpc.mjs +4 -5
- package/dist/shared.cjs +5 -0
- package/dist/shared.d.cts +4 -0
- package/dist/shared.d.mts +4 -0
- package/dist/shared.mjs +4 -6
- package/dist/tracked-Dl9sBZxY.cjs +483 -0
- package/dist/tracked-GEWPoL0C.mjs +383 -0
- package/dist/tracked-GEWPoL0C.mjs.map +1 -0
- package/dist/unstable-core-do-not-import-D89CaGtL.mjs +29 -0
- package/dist/unstable-core-do-not-import-D89CaGtL.mjs.map +1 -0
- package/dist/unstable-core-do-not-import-DFQys1IC.cjs +34 -0
- package/dist/unstable-core-do-not-import.cjs +83 -0
- package/dist/unstable-core-do-not-import.d-CSxj_rbP.d.cts +1974 -0
- package/dist/unstable-core-do-not-import.d-CSxj_rbP.d.cts.map +1 -0
- package/dist/unstable-core-do-not-import.d-ptrxwuSa.d.mts +1974 -0
- package/dist/unstable-core-do-not-import.d-ptrxwuSa.d.mts.map +1 -0
- package/dist/unstable-core-do-not-import.d.cts +3 -0
- package/dist/unstable-core-do-not-import.d.mts +3 -0
- package/dist/unstable-core-do-not-import.mjs +11 -30
- package/dist/utils-BHZJcBRv.mjs +137 -0
- package/dist/utils-BHZJcBRv.mjs.map +1 -0
- package/dist/utils-DVO6HZiR.cjs +220 -0
- package/dist/ws-C2nEUNk_.cjs +425 -0
- package/dist/ws-eIVIMTrw.mjs +409 -0
- package/dist/ws-eIVIMTrw.mjs.map +1 -0
- package/http/package.json +1 -0
- package/observable/package.json +1 -0
- package/package.json +131 -55
- package/rpc/package.json +1 -0
- package/shared/package.json +1 -0
- package/src/@trpc/server/index.ts +24 -0
- package/src/unstable-core-do-not-import/http/contentType.ts +5 -4
- package/src/unstable-core-do-not-import/initTRPC.ts +79 -4
- package/src/unstable-core-do-not-import/router.ts +36 -12
- package/src/unstable-core-do-not-import/utils.ts +3 -2
- package/unstable-core-do-not-import/package.json +1 -0
- package/adapters/aws-lambda/index.d.ts +0 -1
- package/adapters/aws-lambda/index.js +0 -1
- package/adapters/express/index.d.ts +0 -1
- package/adapters/express/index.js +0 -1
- package/adapters/fastify/index.d.ts +0 -1
- package/adapters/fastify/index.js +0 -1
- package/adapters/fetch/index.d.ts +0 -1
- package/adapters/fetch/index.js +0 -1
- package/adapters/next/index.d.ts +0 -1
- package/adapters/next/index.js +0 -1
- package/adapters/next-app-dir/index.d.ts +0 -1
- package/adapters/next-app-dir/index.js +0 -1
- package/adapters/node-http/content-type/form-data/index.d.ts +0 -1
- package/adapters/node-http/content-type/form-data/index.js +0 -1
- package/adapters/node-http/content-type/json/index.d.ts +0 -1
- package/adapters/node-http/content-type/json/index.js +0 -1
- package/adapters/node-http/index.d.ts +0 -1
- package/adapters/node-http/index.js +0 -1
- package/adapters/standalone/index.d.ts +0 -1
- package/adapters/standalone/index.js +0 -1
- package/adapters/ws/index.d.ts +0 -1
- package/adapters/ws/index.js +0 -1
- package/dist/@trpc/server/http.d.ts +0 -8
- package/dist/@trpc/server/http.d.ts.map +0 -1
- package/dist/@trpc/server/index.d.ts +0 -65
- package/dist/@trpc/server/index.d.ts.map +0 -1
- package/dist/@trpc/server/rpc.d.ts +0 -3
- package/dist/@trpc/server/rpc.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/getPlanner.d.ts +0 -15
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/getPlanner.js +0 -179
- package/dist/adapters/aws-lambda/getPlanner.mjs +0 -177
- package/dist/adapters/aws-lambda/index.d.ts +0 -23
- package/dist/adapters/aws-lambda/index.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/index.js +0 -67
- package/dist/adapters/express.d.ts +0 -15
- package/dist/adapters/express.d.ts.map +0 -1
- package/dist/adapters/express.js +0 -39
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +0 -22
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +0 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +0 -49
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +0 -47
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +0 -21
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +0 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +0 -56
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +0 -54
- package/dist/adapters/fastify/index.d.ts +0 -3
- package/dist/adapters/fastify/index.d.ts.map +0 -1
- package/dist/adapters/fastify/index.js +0 -9
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +0 -13
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +0 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +0 -77
- package/dist/adapters/fetch/fetchRequestHandler.mjs +0 -75
- package/dist/adapters/fetch/index.d.ts +0 -3
- package/dist/adapters/fetch/index.d.ts.map +0 -1
- package/dist/adapters/fetch/index.js +0 -7
- package/dist/adapters/fetch/types.d.ts +0 -27
- package/dist/adapters/fetch/types.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts +0 -25
- package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/nextAppDirCaller.js +0 -94
- package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +0 -92
- package/dist/adapters/next-app-dir/notFound.d.ts +0 -7
- package/dist/adapters/next-app-dir/notFound.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/notFound.js +0 -18
- package/dist/adapters/next-app-dir/notFound.mjs +0 -16
- package/dist/adapters/next-app-dir/redirect.d.ts +0 -18
- package/dist/adapters/next-app-dir/redirect.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/redirect.js +0 -49
- package/dist/adapters/next-app-dir/redirect.mjs +0 -46
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts +0 -6
- package/dist/adapters/next-app-dir/rethrowNextErrors.d.ts.map +0 -1
- package/dist/adapters/next-app-dir/rethrowNextErrors.js +0 -70
- package/dist/adapters/next-app-dir/rethrowNextErrors.mjs +0 -49
- package/dist/adapters/next-app-dir.d.ts +0 -7
- package/dist/adapters/next-app-dir.d.ts.map +0 -1
- package/dist/adapters/next-app-dir.js +0 -13
- package/dist/adapters/next.d.ts +0 -19
- package/dist/adapters/next.d.ts.map +0 -1
- package/dist/adapters/next.js +0 -51
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +0 -12
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +0 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +0 -123
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +0 -120
- package/dist/adapters/node-http/index.d.ts +0 -4
- package/dist/adapters/node-http/index.d.ts.map +0 -1
- package/dist/adapters/node-http/index.js +0 -11
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +0 -20
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +0 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +0 -96
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +0 -93
- package/dist/adapters/node-http/types.d.ts +0 -81
- package/dist/adapters/node-http/types.d.ts.map +0 -1
- package/dist/adapters/node-http/writeResponse.d.ts +0 -18
- package/dist/adapters/node-http/writeResponse.d.ts.map +0 -1
- package/dist/adapters/node-http/writeResponse.js +0 -83
- package/dist/adapters/node-http/writeResponse.mjs +0 -80
- package/dist/adapters/standalone.d.ts +0 -36
- package/dist/adapters/standalone.d.ts.map +0 -1
- package/dist/adapters/standalone.js +0 -49
- package/dist/adapters/ws.d.ts +0 -54
- package/dist/adapters/ws.d.ts.map +0 -1
- package/dist/adapters/ws.js +0 -544
- package/dist/http.d.ts +0 -2
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -19
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -35
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@12.1.2_rollup@4.34.8_tslib@2.8.1_typescript@5.8.2/node_modules/tslib/tslib.es6.js +0 -73
- package/dist/observable/behaviorSubject.d.ts +0 -15
- package/dist/observable/behaviorSubject.d.ts.map +0 -1
- package/dist/observable/behaviorSubject.js +0 -40
- package/dist/observable/behaviorSubject.mjs +0 -38
- package/dist/observable/index.d.ts +0 -5
- package/dist/observable/index.d.ts.map +0 -1
- package/dist/observable/index.js +0 -18
- package/dist/observable/observable.d.ts +0 -12
- package/dist/observable/observable.d.ts.map +0 -1
- package/dist/observable/observable.js +0 -180
- package/dist/observable/observable.mjs +0 -175
- package/dist/observable/operators.d.ts +0 -10
- package/dist/observable/operators.d.ts.map +0 -1
- package/dist/observable/operators.js +0 -134
- package/dist/observable/operators.mjs +0 -128
- package/dist/observable/types.d.ts +0 -26
- package/dist/observable/types.d.ts.map +0 -1
- package/dist/rpc.d.ts +0 -2
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js +0 -13
- package/dist/shared.d.ts +0 -26
- package/dist/shared.d.ts.map +0 -1
- package/dist/shared.js +0 -13
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts +0 -17
- package/dist/unstable-core-do-not-import/clientish/inference.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts +0 -36
- package/dist/unstable-core-do-not-import/clientish/inferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts +0 -69
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.js +0 -76
- package/dist/unstable-core-do-not-import/createProxy.mjs +0 -73
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.js +0 -76
- package/dist/unstable-core-do-not-import/error/TRPCError.mjs +0 -72
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -38
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.js +0 -7
- package/dist/unstable-core-do-not-import/error/formatter.mjs +0 -5
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.js +0 -31
- package/dist/unstable-core-do-not-import/error/getErrorShape.mjs +0 -29
- package/dist/unstable-core-do-not-import/http/abortError.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/abortError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/abortError.js +0 -13
- package/dist/unstable-core-do-not-import/http/abortError.mjs +0 -10
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -13
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +0 -229
- package/dist/unstable-core-do-not-import/http/contentType.mjs +0 -227
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts +0 -14
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.js +0 -14
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +0 -12
- package/dist/unstable-core-do-not-import/http/formDataToObject.d.ts +0 -2
- package/dist/unstable-core-do-not-import/http/formDataToObject.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/formDataToObject.js +0 -40
- package/dist/unstable-core-do-not-import/http/formDataToObject.mjs +0 -38
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -10
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +0 -85
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +0 -78
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts +0 -4
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.js +0 -42
- package/dist/unstable-core-do-not-import/http/parseConnectionParams.mjs +0 -39
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts +0 -15
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +0 -572
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +0 -570
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -138
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -94
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/initTRPC.js +0 -82
- package/dist/unstable-core-do-not-import/initTRPC.mjs +0 -80
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -107
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.js +0 -96
- package/dist/unstable-core-do-not-import/middleware.mjs +0 -90
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -44
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.js +0 -54
- package/dist/unstable-core-do-not-import/parser.mjs +0 -52
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -77
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.js +0 -9
- package/dist/unstable-core-do-not-import/procedure.mjs +0 -7
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -161
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -201
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +0 -199
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -98
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.js +0 -8
- package/dist/unstable-core-do-not-import/rootConfig.mjs +0 -6
- package/dist/unstable-core-do-not-import/router.d.ts +0 -98
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.js +0 -285
- package/dist/unstable-core-do-not-import/router.mjs +0 -278
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -45
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.js +0 -69
- package/dist/unstable-core-do-not-import/rpc/codes.mjs +0 -65
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -109
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.js +0 -63
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.mjs +0 -61
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts +0 -119
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.js +0 -607
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +0 -603
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +0 -108
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/sse.js +0 -373
- package/dist/unstable-core-do-not-import/stream/sse.mjs +0 -369
- package/dist/unstable-core-do-not-import/stream/sse.types.d.ts +0 -31
- package/dist/unstable-core-do-not-import/stream/sse.types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts +0 -31
- package/dist/unstable-core-do-not-import/stream/tracked.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/tracked.js +0 -29
- package/dist/unstable-core-do-not-import/stream/tracked.mjs +0 -25
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.js +0 -174
- package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +0 -170
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts +0 -7
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.js +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/createDeferred.mjs +0 -15
- package/dist/unstable-core-do-not-import/stream/utils/disposable.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/disposable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/disposable.js +0 -46
- package/dist/unstable-core-do-not-import/stream/utils/disposable.mjs +0 -43
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts +0 -17
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.js +0 -241
- package/dist/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.mjs +0 -239
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.d.ts +0 -8
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.js +0 -25
- package/dist/unstable-core-do-not-import/stream/utils/readableStreamFrom.mjs +0 -23
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.d.ts +0 -5
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.js +0 -26
- package/dist/unstable-core-do-not-import/stream/utils/timerResource.mjs +0 -23
- package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts +0 -7
- package/dist/unstable-core-do-not-import/stream/utils/withPing.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/stream/utils/withPing.js +0 -130
- package/dist/unstable-core-do-not-import/stream/utils/withPing.mjs +0 -127
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -99
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.js +0 -106
- package/dist/unstable-core-do-not-import/transformer.mjs +0 -101
- package/dist/unstable-core-do-not-import/types.d.ts +0 -127
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -42
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.js +0 -96
- package/dist/unstable-core-do-not-import/utils.mjs +0 -83
- package/dist/unstable-core-do-not-import.d.ts +0 -47
- package/dist/unstable-core-do-not-import.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import.js +0 -109
- package/dist/vendor/cookie-es/set-cookie/split.d.ts +0 -18
- package/dist/vendor/cookie-es/set-cookie/split.d.ts.map +0 -1
- package/dist/vendor/cookie-es/set-cookie/split.js +0 -79
- package/dist/vendor/cookie-es/set-cookie/split.mjs +0 -77
- package/dist/vendor/standard-schema-v1/error.d.ts +0 -13
- package/dist/vendor/standard-schema-v1/error.d.ts.map +0 -1
- package/dist/vendor/standard-schema-v1/error.js +0 -28
- package/dist/vendor/standard-schema-v1/error.mjs +0 -26
- package/dist/vendor/standard-schema-v1/spec.d.ts +0 -60
- package/dist/vendor/standard-schema-v1/spec.d.ts.map +0 -1
- package/dist/vendor/unpromise/index.d.ts +0 -3
- package/dist/vendor/unpromise/index.d.ts.map +0 -1
- package/dist/vendor/unpromise/types.d.ts +0 -28
- package/dist/vendor/unpromise/types.d.ts.map +0 -1
- package/dist/vendor/unpromise/unpromise.d.ts +0 -121
- package/dist/vendor/unpromise/unpromise.d.ts.map +0 -1
- package/dist/vendor/unpromise/unpromise.js +0 -292
- package/dist/vendor/unpromise/unpromise.mjs +0 -289
- package/http/index.d.ts +0 -1
- package/http/index.js +0 -1
- package/observable/index.d.ts +0 -1
- package/observable/index.js +0 -1
- package/rpc/index.d.ts +0 -1
- package/rpc/index.js +0 -1
- package/shared/index.d.ts +0 -1
- package/shared/index.js +0 -1
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
const require_resolveResponse = require('./resolveResponse-B2CuaT_1.cjs');
|
|
2
|
+
const require_getErrorShape = require('./getErrorShape-CsikfkAc.cjs');
|
|
3
|
+
const require_tracked = require('./tracked-Dl9sBZxY.cjs');
|
|
4
|
+
const require_utils = require('./utils-DVO6HZiR.cjs');
|
|
5
|
+
const require_parseTRPCMessage = require('./parseTRPCMessage-ByQWigsq.cjs');
|
|
6
|
+
const require_observable = require('./observable-BwdrSFZU.cjs');
|
|
7
|
+
const require_node_http = require('./node-http-BPR68yI4.cjs');
|
|
8
|
+
|
|
9
|
+
//#region src/adapters/ws.ts
|
|
10
|
+
var import_usingCtx = require_resolveResponse.__toESM(require_resolveResponse.require_usingCtx(), 1);
|
|
11
|
+
/**
|
|
12
|
+
* Importing ws causes a build error
|
|
13
|
+
* @see https://github.com/trpc/trpc/pull/5279
|
|
14
|
+
*/
|
|
15
|
+
const WEBSOCKET_OPEN = 1;
|
|
16
|
+
function getWSConnectionHandler(opts) {
|
|
17
|
+
const { createContext, router } = opts;
|
|
18
|
+
const { transformer } = router._def._config;
|
|
19
|
+
return (client, req) => {
|
|
20
|
+
const clientSubscriptions = /* @__PURE__ */ new Map();
|
|
21
|
+
const abortController = new AbortController();
|
|
22
|
+
if (opts.keepAlive?.enabled) {
|
|
23
|
+
const { pingMs, pongWaitMs } = opts.keepAlive;
|
|
24
|
+
handleKeepAlive(client, pingMs, pongWaitMs);
|
|
25
|
+
}
|
|
26
|
+
function respond(untransformedJSON) {
|
|
27
|
+
client.send(JSON.stringify(require_tracked.transformTRPCResponse(router._def._config, untransformedJSON)));
|
|
28
|
+
}
|
|
29
|
+
async function createCtxPromise(getConnectionParams) {
|
|
30
|
+
try {
|
|
31
|
+
return await require_utils.run(async () => {
|
|
32
|
+
ctx = await createContext?.({
|
|
33
|
+
req,
|
|
34
|
+
res: client,
|
|
35
|
+
info: {
|
|
36
|
+
connectionParams: getConnectionParams(),
|
|
37
|
+
calls: [],
|
|
38
|
+
isBatchCall: false,
|
|
39
|
+
accept: null,
|
|
40
|
+
type: "unknown",
|
|
41
|
+
signal: abortController.signal,
|
|
42
|
+
url: null
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
ok: true,
|
|
47
|
+
value: ctx
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
} catch (cause) {
|
|
51
|
+
const error = require_tracked.getTRPCErrorFromUnknown(cause);
|
|
52
|
+
opts.onError?.({
|
|
53
|
+
error,
|
|
54
|
+
path: void 0,
|
|
55
|
+
type: "unknown",
|
|
56
|
+
ctx,
|
|
57
|
+
req,
|
|
58
|
+
input: void 0
|
|
59
|
+
});
|
|
60
|
+
respond({
|
|
61
|
+
id: null,
|
|
62
|
+
error: require_getErrorShape.getErrorShape({
|
|
63
|
+
config: router._def._config,
|
|
64
|
+
error,
|
|
65
|
+
type: "unknown",
|
|
66
|
+
path: void 0,
|
|
67
|
+
input: void 0,
|
|
68
|
+
ctx
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
(globalThis.setImmediate ?? globalThis.setTimeout)(() => {
|
|
72
|
+
client.close();
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
error
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let ctx = void 0;
|
|
81
|
+
/**
|
|
82
|
+
* promise for initializing the context
|
|
83
|
+
*
|
|
84
|
+
* - the context promise will be created immediately on connection if no connectionParams are expected
|
|
85
|
+
* - if connection params are expected, they will be created once received
|
|
86
|
+
*/
|
|
87
|
+
let ctxPromise = require_node_http.createURL(req).searchParams.get("connectionParams") === "1" ? null : createCtxPromise(() => null);
|
|
88
|
+
function handleRequest(msg) {
|
|
89
|
+
const { id, jsonrpc } = msg;
|
|
90
|
+
if (id === null) {
|
|
91
|
+
const error = require_tracked.getTRPCErrorFromUnknown(new require_tracked.TRPCError({
|
|
92
|
+
code: "PARSE_ERROR",
|
|
93
|
+
message: "`id` is required"
|
|
94
|
+
}));
|
|
95
|
+
opts.onError?.({
|
|
96
|
+
error,
|
|
97
|
+
path: void 0,
|
|
98
|
+
type: "unknown",
|
|
99
|
+
ctx,
|
|
100
|
+
req,
|
|
101
|
+
input: void 0
|
|
102
|
+
});
|
|
103
|
+
respond({
|
|
104
|
+
id,
|
|
105
|
+
jsonrpc,
|
|
106
|
+
error: require_getErrorShape.getErrorShape({
|
|
107
|
+
config: router._def._config,
|
|
108
|
+
error,
|
|
109
|
+
type: "unknown",
|
|
110
|
+
path: void 0,
|
|
111
|
+
input: void 0,
|
|
112
|
+
ctx
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (msg.method === "subscription.stop") {
|
|
118
|
+
clientSubscriptions.get(id)?.abort();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const { path, lastEventId } = msg.params;
|
|
122
|
+
let { input } = msg.params;
|
|
123
|
+
const type = msg.method;
|
|
124
|
+
if (lastEventId !== void 0) if (require_utils.isObject(input)) input = {
|
|
125
|
+
...input,
|
|
126
|
+
lastEventId
|
|
127
|
+
};
|
|
128
|
+
else input ??= { lastEventId };
|
|
129
|
+
require_utils.run(async () => {
|
|
130
|
+
const res = await ctxPromise;
|
|
131
|
+
if (!res.ok) throw res.error;
|
|
132
|
+
const abortController$1 = new AbortController();
|
|
133
|
+
const result = await require_tracked.callProcedure({
|
|
134
|
+
router,
|
|
135
|
+
path,
|
|
136
|
+
getRawInput: async () => input,
|
|
137
|
+
ctx,
|
|
138
|
+
type,
|
|
139
|
+
signal: abortController$1.signal
|
|
140
|
+
});
|
|
141
|
+
const isIterableResult = require_utils.isAsyncIterable(result) || require_observable.isObservable(result);
|
|
142
|
+
if (type !== "subscription") {
|
|
143
|
+
if (isIterableResult) throw new require_tracked.TRPCError({
|
|
144
|
+
code: "UNSUPPORTED_MEDIA_TYPE",
|
|
145
|
+
message: `Cannot return an async iterable or observable from a ${type} procedure with WebSockets`
|
|
146
|
+
});
|
|
147
|
+
respond({
|
|
148
|
+
id,
|
|
149
|
+
jsonrpc,
|
|
150
|
+
result: {
|
|
151
|
+
type: "data",
|
|
152
|
+
data: result
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!isIterableResult) throw new require_tracked.TRPCError({
|
|
158
|
+
message: `Subscription ${path} did not return an observable or a AsyncGenerator`,
|
|
159
|
+
code: "INTERNAL_SERVER_ERROR"
|
|
160
|
+
});
|
|
161
|
+
/* istanbul ignore next -- @preserve */
|
|
162
|
+
if (client.readyState !== WEBSOCKET_OPEN) return;
|
|
163
|
+
/* istanbul ignore next -- @preserve */
|
|
164
|
+
if (clientSubscriptions.has(id)) throw new require_tracked.TRPCError({
|
|
165
|
+
message: `Duplicate id ${id}`,
|
|
166
|
+
code: "BAD_REQUEST"
|
|
167
|
+
});
|
|
168
|
+
const iterable = require_observable.isObservable(result) ? require_observable.observableToAsyncIterable(result, abortController$1.signal) : result;
|
|
169
|
+
require_utils.run(async () => {
|
|
170
|
+
try {
|
|
171
|
+
var _usingCtx = (0, import_usingCtx.default)();
|
|
172
|
+
const iterator = _usingCtx.a(require_resolveResponse.iteratorResource(iterable));
|
|
173
|
+
const abortPromise = new Promise((resolve) => {
|
|
174
|
+
abortController$1.signal.onabort = () => resolve("abort");
|
|
175
|
+
});
|
|
176
|
+
let next;
|
|
177
|
+
let result$1;
|
|
178
|
+
while (true) {
|
|
179
|
+
next = await require_resolveResponse.Unpromise.race([iterator.next().catch(require_tracked.getTRPCErrorFromUnknown), abortPromise]);
|
|
180
|
+
if (next === "abort") {
|
|
181
|
+
await iterator.return?.();
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
if (next instanceof Error) {
|
|
185
|
+
const error = require_tracked.getTRPCErrorFromUnknown(next);
|
|
186
|
+
opts.onError?.({
|
|
187
|
+
error,
|
|
188
|
+
path,
|
|
189
|
+
type,
|
|
190
|
+
ctx,
|
|
191
|
+
req,
|
|
192
|
+
input
|
|
193
|
+
});
|
|
194
|
+
respond({
|
|
195
|
+
id,
|
|
196
|
+
jsonrpc,
|
|
197
|
+
error: require_getErrorShape.getErrorShape({
|
|
198
|
+
config: router._def._config,
|
|
199
|
+
error,
|
|
200
|
+
type,
|
|
201
|
+
path,
|
|
202
|
+
input,
|
|
203
|
+
ctx
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
if (next.done) break;
|
|
209
|
+
result$1 = {
|
|
210
|
+
type: "data",
|
|
211
|
+
data: next.value
|
|
212
|
+
};
|
|
213
|
+
if (require_tracked.isTrackedEnvelope(next.value)) {
|
|
214
|
+
const [id$1, data] = next.value;
|
|
215
|
+
result$1.id = id$1;
|
|
216
|
+
result$1.data = {
|
|
217
|
+
id: id$1,
|
|
218
|
+
data
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
respond({
|
|
222
|
+
id,
|
|
223
|
+
jsonrpc,
|
|
224
|
+
result: result$1
|
|
225
|
+
});
|
|
226
|
+
next = null;
|
|
227
|
+
result$1 = null;
|
|
228
|
+
}
|
|
229
|
+
respond({
|
|
230
|
+
id,
|
|
231
|
+
jsonrpc,
|
|
232
|
+
result: { type: "stopped" }
|
|
233
|
+
});
|
|
234
|
+
clientSubscriptions.delete(id);
|
|
235
|
+
} catch (_) {
|
|
236
|
+
_usingCtx.e = _;
|
|
237
|
+
} finally {
|
|
238
|
+
await _usingCtx.d();
|
|
239
|
+
}
|
|
240
|
+
}).catch((cause) => {
|
|
241
|
+
const error = require_tracked.getTRPCErrorFromUnknown(cause);
|
|
242
|
+
opts.onError?.({
|
|
243
|
+
error,
|
|
244
|
+
path,
|
|
245
|
+
type,
|
|
246
|
+
ctx,
|
|
247
|
+
req,
|
|
248
|
+
input
|
|
249
|
+
});
|
|
250
|
+
respond({
|
|
251
|
+
id,
|
|
252
|
+
jsonrpc,
|
|
253
|
+
error: require_getErrorShape.getErrorShape({
|
|
254
|
+
config: router._def._config,
|
|
255
|
+
error,
|
|
256
|
+
type,
|
|
257
|
+
path,
|
|
258
|
+
input,
|
|
259
|
+
ctx
|
|
260
|
+
})
|
|
261
|
+
});
|
|
262
|
+
abortController$1.abort();
|
|
263
|
+
});
|
|
264
|
+
clientSubscriptions.set(id, abortController$1);
|
|
265
|
+
respond({
|
|
266
|
+
id,
|
|
267
|
+
jsonrpc,
|
|
268
|
+
result: { type: "started" }
|
|
269
|
+
});
|
|
270
|
+
}).catch((cause) => {
|
|
271
|
+
const error = require_tracked.getTRPCErrorFromUnknown(cause);
|
|
272
|
+
opts.onError?.({
|
|
273
|
+
error,
|
|
274
|
+
path,
|
|
275
|
+
type,
|
|
276
|
+
ctx,
|
|
277
|
+
req,
|
|
278
|
+
input
|
|
279
|
+
});
|
|
280
|
+
respond({
|
|
281
|
+
id,
|
|
282
|
+
jsonrpc,
|
|
283
|
+
error: require_getErrorShape.getErrorShape({
|
|
284
|
+
config: router._def._config,
|
|
285
|
+
error,
|
|
286
|
+
type,
|
|
287
|
+
path,
|
|
288
|
+
input,
|
|
289
|
+
ctx
|
|
290
|
+
})
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
client.on("message", (rawData) => {
|
|
295
|
+
const msgStr = rawData.toString();
|
|
296
|
+
if (msgStr === "PONG") return;
|
|
297
|
+
if (msgStr === "PING") {
|
|
298
|
+
if (!opts.dangerouslyDisablePong) client.send("PONG");
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (!ctxPromise) {
|
|
302
|
+
ctxPromise = createCtxPromise(() => {
|
|
303
|
+
let msg;
|
|
304
|
+
try {
|
|
305
|
+
msg = JSON.parse(msgStr);
|
|
306
|
+
if (!require_utils.isObject(msg)) throw new Error("Message was not an object");
|
|
307
|
+
} catch (cause) {
|
|
308
|
+
throw new require_tracked.TRPCError({
|
|
309
|
+
code: "PARSE_ERROR",
|
|
310
|
+
message: `Malformed TRPCConnectionParamsMessage`,
|
|
311
|
+
cause
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
const connectionParams = require_resolveResponse.parseConnectionParamsFromUnknown(msg.data);
|
|
315
|
+
return connectionParams;
|
|
316
|
+
});
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const parsedMsgs = require_utils.run(() => {
|
|
320
|
+
try {
|
|
321
|
+
const msgJSON = JSON.parse(msgStr);
|
|
322
|
+
const msgs = Array.isArray(msgJSON) ? msgJSON : [msgJSON];
|
|
323
|
+
return msgs.map((raw) => require_parseTRPCMessage.parseTRPCMessage(raw, transformer));
|
|
324
|
+
} catch (cause) {
|
|
325
|
+
const error = new require_tracked.TRPCError({
|
|
326
|
+
code: "PARSE_ERROR",
|
|
327
|
+
cause
|
|
328
|
+
});
|
|
329
|
+
respond({
|
|
330
|
+
id: null,
|
|
331
|
+
error: require_getErrorShape.getErrorShape({
|
|
332
|
+
config: router._def._config,
|
|
333
|
+
error,
|
|
334
|
+
type: "unknown",
|
|
335
|
+
path: void 0,
|
|
336
|
+
input: void 0,
|
|
337
|
+
ctx
|
|
338
|
+
})
|
|
339
|
+
});
|
|
340
|
+
return [];
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
parsedMsgs.map(handleRequest);
|
|
344
|
+
});
|
|
345
|
+
client.on("error", (cause) => {
|
|
346
|
+
opts.onError?.({
|
|
347
|
+
ctx,
|
|
348
|
+
error: require_tracked.getTRPCErrorFromUnknown(cause),
|
|
349
|
+
input: void 0,
|
|
350
|
+
path: void 0,
|
|
351
|
+
type: "unknown",
|
|
352
|
+
req
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
client.once("close", () => {
|
|
356
|
+
for (const sub of clientSubscriptions.values()) sub.abort();
|
|
357
|
+
clientSubscriptions.clear();
|
|
358
|
+
abortController.abort();
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Handle WebSocket keep-alive messages
|
|
364
|
+
*/
|
|
365
|
+
function handleKeepAlive(client, pingMs = 3e4, pongWaitMs = 5e3) {
|
|
366
|
+
let timeout = void 0;
|
|
367
|
+
let ping = void 0;
|
|
368
|
+
const schedulePing = () => {
|
|
369
|
+
const scheduleTimeout = () => {
|
|
370
|
+
timeout = setTimeout(() => {
|
|
371
|
+
client.terminate();
|
|
372
|
+
}, pongWaitMs);
|
|
373
|
+
};
|
|
374
|
+
ping = setTimeout(() => {
|
|
375
|
+
client.send("PING");
|
|
376
|
+
scheduleTimeout();
|
|
377
|
+
}, pingMs);
|
|
378
|
+
};
|
|
379
|
+
const onMessage = () => {
|
|
380
|
+
clearTimeout(ping);
|
|
381
|
+
clearTimeout(timeout);
|
|
382
|
+
schedulePing();
|
|
383
|
+
};
|
|
384
|
+
client.on("message", onMessage);
|
|
385
|
+
client.on("close", () => {
|
|
386
|
+
clearTimeout(ping);
|
|
387
|
+
clearTimeout(timeout);
|
|
388
|
+
});
|
|
389
|
+
schedulePing();
|
|
390
|
+
}
|
|
391
|
+
function applyWSSHandler(opts) {
|
|
392
|
+
const onConnection = getWSConnectionHandler(opts);
|
|
393
|
+
opts.wss.on("connection", (client, req) => {
|
|
394
|
+
if (opts.prefix && !req.url?.startsWith(opts.prefix)) return;
|
|
395
|
+
onConnection(client, req);
|
|
396
|
+
});
|
|
397
|
+
return { broadcastReconnectNotification: () => {
|
|
398
|
+
const response = {
|
|
399
|
+
id: null,
|
|
400
|
+
method: "reconnect"
|
|
401
|
+
};
|
|
402
|
+
const data = JSON.stringify(response);
|
|
403
|
+
for (const client of opts.wss.clients) if (client.readyState === WEBSOCKET_OPEN) client.send(data);
|
|
404
|
+
} };
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
//#endregion
|
|
408
|
+
Object.defineProperty(exports, 'applyWSSHandler', {
|
|
409
|
+
enumerable: true,
|
|
410
|
+
get: function () {
|
|
411
|
+
return applyWSSHandler;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
Object.defineProperty(exports, 'getWSConnectionHandler', {
|
|
415
|
+
enumerable: true,
|
|
416
|
+
get: function () {
|
|
417
|
+
return getWSConnectionHandler;
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
Object.defineProperty(exports, 'handleKeepAlive', {
|
|
421
|
+
enumerable: true,
|
|
422
|
+
get: function () {
|
|
423
|
+
return handleKeepAlive;
|
|
424
|
+
}
|
|
425
|
+
});
|