@trpc/server 11.0.0-next-alpha.156 → 11.0.0-next-alpha.158

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.
@@ -4,12 +4,12 @@
4
4
  import type { IncomingMessage } from 'http';
5
5
  import type { AnyRouter, inferRouterContext, MaybePromise } from '@trpc/core';
6
6
  import type { BaseHandlerOptions } from '@trpc/core/http';
7
- import type { WebSocket, WebSocketServer } from 'ws';
7
+ import type ws from 'ws';
8
8
  import type { NodeHTTPCreateContextFnOptions } from './node-http';
9
9
  /**
10
10
  * @public
11
11
  */
12
- export type CreateWSSContextFnOptions = Omit<NodeHTTPCreateContextFnOptions<IncomingMessage, WebSocket>, 'info'>;
12
+ export type CreateWSSContextFnOptions = Omit<NodeHTTPCreateContextFnOptions<IncomingMessage, ws.WebSocket>, 'info'>;
13
13
  /**
14
14
  * @public
15
15
  */
@@ -28,7 +28,7 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<TR
28
28
  **/
29
29
  createContext: CreateWSSContextFn<TRouter>;
30
30
  }) & {
31
- wss: WebSocketServer;
31
+ wss: ws.WebSocketServer;
32
32
  process?: NodeJS.Process;
33
33
  };
34
34
  export declare function applyWSSHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): {
@@ -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,SAAS,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAQ9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAU1D,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACrD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;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,CAAC,eAAe,EAAE,EAAE,CAAC,SAAS,CAAC,EAC7D,MAAM,CACP,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;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IAAI,kBAAkB,CAC3E,OAAO,EACP,eAAe,CAChB,GACC,CAAC,MAAM,SAAS,kBAAkB,CAAC,OAAO,CAAC,GACvC;IACE;;QAEI;IACJ,aAAa,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC7C,GACD;IACE;;QAEI;IACJ,aAAa,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC5C,CAAC,GAAG;IACP,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CAC1B,CAAC;AAEJ,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EAwQjC"}
@@ -6,6 +6,10 @@ var core = require('@trpc/core');
6
6
  var observable = require('@trpc/core/observable');
7
7
  var rpc = require('@trpc/core/rpc');
8
8
 
9
+ /**
10
+ * Importing ws causes a build error
11
+ * @see https://github.com/trpc/trpc/pull/5279
12
+ */ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
9
13
  function applyWSSHandler(opts) {
10
14
  const { wss , createContext , router } = opts;
11
15
  const { transformer } = router._def._config;
@@ -123,7 +127,7 @@ function applyWSSHandler(opts) {
123
127
  });
124
128
  }
125
129
  });
126
- /* istanbul ignore next -- @preserve */ if (client.readyState !== client.OPEN) {
130
+ /* istanbul ignore next -- @preserve */ if (client.readyState !== WEBSOCKET_OPEN) {
127
131
  // if the client got disconnected whilst initializing the subscription
128
132
  // no need to send stopped message if the client is disconnected
129
133
  sub1.unsubscribe();
@@ -260,7 +264,7 @@ function applyWSSHandler(opts) {
260
264
  };
261
265
  const data = JSON.stringify(response);
262
266
  for (const client of wss.clients){
263
- if (client.readyState === 1 /* ws.OPEN */ ) {
267
+ if (client.readyState === WEBSOCKET_OPEN) {
264
268
  client.send(data);
265
269
  }
266
270
  }
@@ -2,6 +2,10 @@ import { TRPCError, getErrorShape, getTRPCErrorFromUnknown, transformTRPCRespons
2
2
  import { isObservable } from '@trpc/core/observable';
3
3
  import { parseTRPCMessage } from '@trpc/core/rpc';
4
4
 
5
+ /**
6
+ * Importing ws causes a build error
7
+ * @see https://github.com/trpc/trpc/pull/5279
8
+ */ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
5
9
  function applyWSSHandler(opts) {
6
10
  const { wss , createContext , router } = opts;
7
11
  const { transformer } = router._def._config;
@@ -119,7 +123,7 @@ function applyWSSHandler(opts) {
119
123
  });
120
124
  }
121
125
  });
122
- /* istanbul ignore next -- @preserve */ if (client.readyState !== client.OPEN) {
126
+ /* istanbul ignore next -- @preserve */ if (client.readyState !== WEBSOCKET_OPEN) {
123
127
  // if the client got disconnected whilst initializing the subscription
124
128
  // no need to send stopped message if the client is disconnected
125
129
  sub1.unsubscribe();
@@ -256,7 +260,7 @@ function applyWSSHandler(opts) {
256
260
  };
257
261
  const data = JSON.stringify(response);
258
262
  for (const client of wss.clients){
259
- if (client.readyState === 1 /* ws.OPEN */ ) {
263
+ if (client.readyState === WEBSOCKET_OPEN) {
260
264
  client.send(data);
261
265
  }
262
266
  }
@@ -1,12 +1,12 @@
1
1
  {
2
- "bundleSize": 52010,
3
- "bundleOrigSize": 72424,
4
- "bundleReduction": 28.19,
2
+ "bundleSize": 52154,
3
+ "bundleOrigSize": 72547,
4
+ "bundleReduction": 28.11,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/adapters/ws.ts",
8
- "size": 9593,
9
- "origSize": 8904,
8
+ "size": 9737,
9
+ "origSize": 9027,
10
10
  "renderedExports": [
11
11
  "applyWSSHandler"
12
12
  ],
@@ -14,7 +14,7 @@
14
14
  "dependents": [
15
15
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
16
16
  ],
17
- "percent": 18.44,
17
+ "percent": 18.67,
18
18
  "reduction": 0
19
19
  },
20
20
  {
@@ -30,7 +30,7 @@
30
30
  "dependents": [
31
31
  "/src/adapters/node-http/content-type/form-data/index.ts"
32
32
  ],
33
- "percent": 11.31,
33
+ "percent": 11.27,
34
34
  "reduction": 7.43
35
35
  },
36
36
  {
@@ -46,7 +46,7 @@
46
46
  "dependents": [
47
47
  "/src/adapters/node-http/content-type/form-data/index.ts"
48
48
  ],
49
- "percent": 9.5,
49
+ "percent": 9.47,
50
50
  "reduction": 37.24
51
51
  },
52
52
  {
@@ -70,7 +70,7 @@
70
70
  "dependents": [
71
71
  "/home/runner/work/trpc/trpc/node_modules/.pnpm/@web3-storage+multipart-parser@1.0.0/node_modules/@web3-storage/multipart-parser/esm/src/index.js"
72
72
  ],
73
- "percent": 8.56,
73
+ "percent": 8.54,
74
74
  "reduction": 35.63
75
75
  },
76
76
  {
@@ -84,7 +84,7 @@
84
84
  ],
85
85
  "removedExports": [],
86
86
  "dependents": [],
87
- "percent": 8.37,
87
+ "percent": 8.35,
88
88
  "reduction": 34.87
89
89
  },
90
90
  {
@@ -98,7 +98,7 @@
98
98
  "dependents": [
99
99
  "/src/adapters/node-http/index.ts"
100
100
  ],
101
- "percent": 6.8,
101
+ "percent": 6.79,
102
102
  "reduction": 14.29
103
103
  },
104
104
  {
@@ -112,7 +112,7 @@
112
112
  "dependents": [
113
113
  "/src/adapters/fetch/index.ts"
114
114
  ],
115
- "percent": 6.12,
115
+ "percent": 6.1,
116
116
  "reduction": 10.19
117
117
  },
118
118
  {
@@ -131,7 +131,7 @@
131
131
  "dependents": [
132
132
  "/src/adapters/aws-lambda/index.ts"
133
133
  ],
134
- "percent": 5.69,
134
+ "percent": 5.68,
135
135
  "reduction": 38.44
136
136
  },
137
137
  {
@@ -146,7 +146,7 @@
146
146
  "/src/adapters/fastify/fastifyTRPCPlugin.ts",
147
147
  "/src/adapters/fastify/index.ts"
148
148
  ],
149
- "percent": 4.92,
149
+ "percent": 4.91,
150
150
  "reduction": 29.48
151
151
  },
152
152
  {
@@ -158,7 +158,7 @@
158
158
  ],
159
159
  "removedExports": [],
160
160
  "dependents": [],
161
- "percent": 4.12,
161
+ "percent": 4.11,
162
162
  "reduction": 35.24
163
163
  },
164
164
  {
@@ -172,7 +172,7 @@
172
172
  "dependents": [
173
173
  "/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts"
174
174
  ],
175
- "percent": 2.68,
175
+ "percent": 2.67,
176
176
  "reduction": 0
177
177
  },
178
178
  {
@@ -184,7 +184,7 @@
184
184
  ],
185
185
  "removedExports": [],
186
186
  "dependents": [],
187
- "percent": 2.41,
187
+ "percent": 2.4,
188
188
  "reduction": 28.88
189
189
  },
190
190
  {
@@ -198,7 +198,7 @@
198
198
  "dependents": [
199
199
  "/src/adapters/fastify/index.ts"
200
200
  ],
201
- "percent": 2.3,
201
+ "percent": 2.29,
202
202
  "reduction": 38.13
203
203
  },
204
204
  {
@@ -212,7 +212,7 @@
212
212
  "dependents": [
213
213
  "/src/adapters/node-http/content-type/json/index.ts"
214
214
  ],
215
- "percent": 2.11,
215
+ "percent": 2.1,
216
216
  "reduction": 0.99
217
217
  },
218
218
  {
@@ -232,7 +232,7 @@
232
232
  "/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts",
233
233
  "/src/adapters/node-http/content-type/form-data/index.ts"
234
234
  ],
235
- "percent": 1.4,
235
+ "percent": 1.39,
236
236
  "reduction": 67.5
237
237
  },
238
238
  {
@@ -264,7 +264,7 @@
264
264
  "dependents": [
265
265
  "/src/adapters/node-http/content-type/form-data/index.ts"
266
266
  ],
267
- "percent": 1.32,
267
+ "percent": 1.31,
268
268
  "reduction": 71.78
269
269
  },
270
270
  {
@@ -277,7 +277,7 @@
277
277
  ],
278
278
  "removedExports": [],
279
279
  "dependents": [],
280
- "percent": 1.27,
280
+ "percent": 1.26,
281
281
  "reduction": 51.15
282
282
  },
283
283
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-next-alpha.156+d1eaced0f",
3
+ "version": "11.0.0-next-alpha.158+880f891f9",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -131,7 +131,7 @@
131
131
  "access": "public"
132
132
  },
133
133
  "dependencies": {
134
- "@trpc/core": "11.0.0-next-alpha.156+d1eaced0f"
134
+ "@trpc/core": "11.0.0-next-alpha.158+880f891f9"
135
135
  },
136
136
  "devDependencies": {
137
137
  "@fastify/websocket": "^7.1.2",
@@ -170,5 +170,5 @@
170
170
  "funding": [
171
171
  "https://trpc.io/sponsor"
172
172
  ],
173
- "gitHead": "d1eaced0f7c2a876739a2a0b568d887989230a4d"
173
+ "gitHead": "880f891f9c1a138765d4ae26fbb6f9fad5a7bdd2"
174
174
  }
@@ -17,14 +17,20 @@ import type {
17
17
  TRPCResponseMessage,
18
18
  } from '@trpc/core/rpc';
19
19
  import { parseTRPCMessage } from '@trpc/core/rpc';
20
- import type { WebSocket, WebSocketServer } from 'ws';
20
+ import type ws from 'ws';
21
21
  import type { NodeHTTPCreateContextFnOptions } from './node-http';
22
22
 
23
+ /**
24
+ * Importing ws causes a build error
25
+ * @see https://github.com/trpc/trpc/pull/5279
26
+ */
27
+ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
28
+
23
29
  /**
24
30
  * @public
25
31
  */
26
32
  export type CreateWSSContextFnOptions = Omit<
27
- NodeHTTPCreateContextFnOptions<IncomingMessage, WebSocket>,
33
+ NodeHTTPCreateContextFnOptions<IncomingMessage, ws.WebSocket>,
28
34
  'info'
29
35
  >;
30
36
 
@@ -55,7 +61,7 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<
55
61
  **/
56
62
  createContext: CreateWSSContextFn<TRouter>;
57
63
  }) & {
58
- wss: WebSocketServer;
64
+ wss: ws.WebSocketServer;
59
65
  process?: NodeJS.Process;
60
66
  };
61
67
 
@@ -183,7 +189,7 @@ export function applyWSSHandler<TRouter extends AnyRouter>(
183
189
  },
184
190
  });
185
191
  /* istanbul ignore next -- @preserve */
186
- if (client.readyState !== client.OPEN) {
192
+ if (client.readyState !== WEBSOCKET_OPEN) {
187
193
  // if the client got disconnected whilst initializing the subscription
188
194
  // no need to send stopped message if the client is disconnected
189
195
  sub.unsubscribe();
@@ -318,7 +324,7 @@ export function applyWSSHandler<TRouter extends AnyRouter>(
318
324
  };
319
325
  const data = JSON.stringify(response);
320
326
  for (const client of wss.clients) {
321
- if (client.readyState === 1 /* ws.OPEN */) {
327
+ if (client.readyState === WEBSOCKET_OPEN) {
322
328
  client.send(data);
323
329
  }
324
330
  }