@trpc/client 11.0.0-alpha-tmp-issues-5851-take-two.451 → 11.0.0-alpha-tmp-issues-5851-take-two.454

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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 52206,
3
- "bundleOrigSize": 69751,
4
- "bundleReduction": 25.15,
2
+ "bundleSize": 52610,
3
+ "bundleOrigSize": 70270,
4
+ "bundleReduction": 25.13,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/links/wsLink.ts",
@@ -13,20 +13,20 @@
13
13
  ],
14
14
  "removedExports": [],
15
15
  "dependents": [],
16
- "percent": 24.97,
16
+ "percent": 24.78,
17
17
  "reduction": 10.36
18
18
  },
19
19
  {
20
20
  "id": "/src/links/httpBatchStreamLink.ts",
21
21
  "size": 6237,
22
- "origSize": 6400,
22
+ "origSize": 6454,
23
23
  "renderedExports": [
24
24
  "unstable_httpBatchStreamLink"
25
25
  ],
26
26
  "removedExports": [],
27
27
  "dependents": [],
28
- "percent": 11.95,
29
- "reduction": 2.55
28
+ "percent": 11.86,
29
+ "reduction": 3.36
30
30
  },
31
31
  {
32
32
  "id": "/src/links/loggerLink.ts",
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "removedExports": [],
39
39
  "dependents": [],
40
- "percent": 10.45,
40
+ "percent": 10.37,
41
41
  "reduction": 18.48
42
42
  },
43
43
  {
@@ -52,7 +52,7 @@
52
52
  "/src/links/httpBatchLink.ts",
53
53
  "/src/links/httpBatchStreamLink.ts"
54
54
  ],
55
- "percent": 8.63,
55
+ "percent": 8.56,
56
56
  "reduction": 6.34
57
57
  },
58
58
  {
@@ -64,7 +64,7 @@
64
64
  ],
65
65
  "removedExports": [],
66
66
  "dependents": [],
67
- "percent": 7.72,
67
+ "percent": 7.66,
68
68
  "reduction": 3.43
69
69
  },
70
70
  {
@@ -87,7 +87,7 @@
87
87
  "/src/links/httpBatchStreamLink.ts",
88
88
  "/src/links/httpSubscriptionLink.ts"
89
89
  ],
90
- "percent": 6.79,
90
+ "percent": 6.73,
91
91
  "reduction": 41.03
92
92
  },
93
93
  {
@@ -99,7 +99,7 @@
99
99
  ],
100
100
  "removedExports": [],
101
101
  "dependents": [],
102
- "percent": 6.76,
102
+ "percent": 6.71,
103
103
  "reduction": 6.12
104
104
  },
105
105
  {
@@ -111,13 +111,13 @@
111
111
  ],
112
112
  "removedExports": [],
113
113
  "dependents": [],
114
- "percent": 6.07,
114
+ "percent": 6.02,
115
115
  "reduction": 14.36
116
116
  },
117
117
  {
118
118
  "id": "/src/internals/TRPCUntypedClient.ts",
119
- "size": 2372,
120
- "origSize": 4306,
119
+ "size": 2776,
120
+ "origSize": 4771,
121
121
  "renderedExports": [
122
122
  "TRPCUntypedClient"
123
123
  ],
@@ -126,8 +126,8 @@
126
126
  "/src/createTRPCUntypedClient.ts",
127
127
  "/src/createTRPCClient.ts"
128
128
  ],
129
- "percent": 4.54,
130
- "reduction": 44.91
129
+ "percent": 5.28,
130
+ "reduction": 41.82
131
131
  },
132
132
  {
133
133
  "id": "/src/TRPCClientError.ts",
@@ -147,7 +147,7 @@
147
147
  "/src/internals/TRPCUntypedClient.ts",
148
148
  "/src/links/internals/httpUtils.ts"
149
149
  ],
150
- "percent": 3.57,
150
+ "percent": 3.55,
151
151
  "reduction": 45.71
152
152
  },
153
153
  {
@@ -164,7 +164,7 @@
164
164
  "dependents": [
165
165
  "/src/index.ts"
166
166
  ],
167
- "percent": 2.27,
167
+ "percent": 2.26,
168
168
  "reduction": 73.19
169
169
  },
170
170
  {
@@ -179,7 +179,7 @@
179
179
  "/src/links/splitLink.ts",
180
180
  "/src/internals/TRPCUntypedClient.ts"
181
181
  ],
182
- "percent": 1.32,
182
+ "percent": 1.31,
183
183
  "reduction": 32.75
184
184
  },
185
185
  {
@@ -191,7 +191,7 @@
191
191
  ],
192
192
  "removedExports": [],
193
193
  "dependents": [],
194
- "percent": 1.17,
194
+ "percent": 1.16,
195
195
  "reduction": 44.95
196
196
  },
197
197
  {
@@ -205,7 +205,7 @@
205
205
  "dependents": [
206
206
  "/src/unstable-internals.ts"
207
207
  ],
208
- "percent": 1.08,
208
+ "percent": 1.07,
209
209
  "reduction": 66.75
210
210
  },
211
211
  {
@@ -220,7 +220,7 @@
220
220
  "/src/index.ts",
221
221
  "/src/links/internals/httpUtils.ts"
222
222
  ],
223
- "percent": 0.82,
223
+ "percent": 0.81,
224
224
  "reduction": 33.54
225
225
  },
226
226
  {
@@ -234,7 +234,7 @@
234
234
  "dependents": [
235
235
  "/src/links/internals/httpUtils.ts"
236
236
  ],
237
- "percent": 0.76,
237
+ "percent": 0.75,
238
238
  "reduction": 30.4
239
239
  },
240
240
  {
@@ -281,26 +281,26 @@
281
281
  "reduction": 82.58
282
282
  },
283
283
  {
284
- "id": "/src/unstable-internals.ts",
284
+ "id": "/src/index.ts",
285
285
  "size": 0,
286
- "origSize": 41,
286
+ "origSize": 588,
287
287
  "renderedExports": [],
288
288
  "removedExports": [],
289
- "dependents": [
290
- "/src/links/wsLink.ts",
291
- "/src/links/httpSubscriptionLink.ts",
292
- "/src/links/internals/httpUtils.ts"
293
- ],
289
+ "dependents": [],
294
290
  "percent": 0,
295
291
  "reduction": 100
296
292
  },
297
293
  {
298
- "id": "/src/index.ts",
294
+ "id": "/src/unstable-internals.ts",
299
295
  "size": 0,
300
- "origSize": 588,
296
+ "origSize": 41,
301
297
  "renderedExports": [],
302
298
  "removedExports": [],
303
- "dependents": [],
299
+ "dependents": [
300
+ "/src/links/wsLink.ts",
301
+ "/src/links/httpSubscriptionLink.ts",
302
+ "/src/links/internals/httpUtils.ts"
303
+ ],
304
304
  "percent": 0,
305
305
  "reduction": 100
306
306
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TRPCUntypedClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCUntypedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACf,MAAM,yBAAyB,CAAC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AAM,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,CAAC,OAAO,SAAS,qBAAqB,IAAI;IAC3E,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,SAAS,CAAC,qEAAqE,CAAC,CAAC;CAChG,CAAC;AAEF,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,GAC/B,UAAU,GACV,OAAO,GACP,UAAU,GACV,OAAO,GACP,kBAAkB,GAClB,WAAW,GACX,SAAS,GACT,cAAc,CAAC;AAcnB,qBAAa,iBAAiB,CAAC,OAAO,SAAS,SAAS;IACtD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;IACnD,SAAgB,OAAO,EAAE,iBAAiB,CAAC;IAC3C,OAAO,CAAC,SAAS,CAAS;gBAEd,IAAI,EAAE,uBAAuB,CAAC,OAAO,CAAC;IASlD,OAAO,CAAC,QAAQ;IAwBhB,OAAO,CAAC,gBAAgB;IAgCjB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,kBAAkB;IAS9D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,kBAAkB;IASjE,YAAY,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,OAAO,CACX,wBAAwB,CAAC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAC9D,GACC,kBAAkB,GACnB,cAAc;CA2BlB"}
@@ -1,9 +1,18 @@
1
1
  'use strict';
2
2
 
3
3
  var observable = require('@trpc/server/observable');
4
+ var unstableCoreDoNotImport = require('@trpc/server/unstable-core-do-not-import');
4
5
  var createChain = require('../links/internals/createChain.js');
5
6
  var TRPCClientError = require('../TRPCClientError.js');
6
7
 
8
+ async function* abortableIterable(from, signal) {
9
+ for await (const value of from){
10
+ if (signal?.throwIfAborted()) {
11
+ return;
12
+ }
13
+ yield value;
14
+ }
15
+ }
7
16
  class TRPCUntypedClient {
8
17
  $request({ type , input , path , context ={} }) {
9
18
  const chain$ = createChain.createChain({
@@ -24,7 +33,12 @@ class TRPCUntypedClient {
24
33
  const abortablePromise = new Promise((resolve, reject)=>{
25
34
  opts.signal?.addEventListener('abort', abort);
26
35
  promise.then((envelope)=>{
27
- resolve(envelope.result.data);
36
+ const data = envelope.result.data;
37
+ if (!unstableCoreDoNotImport.isAsyncIterable(data)) {
38
+ resolve(data);
39
+ return;
40
+ }
41
+ resolve(abortableIterable(data, opts.signal));
28
42
  }).catch((err)=>{
29
43
  reject(TRPCClientError.TRPCClientError.from(err));
30
44
  });
@@ -1,7 +1,16 @@
1
1
  import { share, observableToPromise } from '@trpc/server/observable';
2
+ import { isAsyncIterable } from '@trpc/server/unstable-core-do-not-import';
2
3
  import { createChain } from '../links/internals/createChain.mjs';
3
4
  import { TRPCClientError } from '../TRPCClientError.mjs';
4
5
 
6
+ async function* abortableIterable(from, signal) {
7
+ for await (const value of from){
8
+ if (signal?.throwIfAborted()) {
9
+ return;
10
+ }
11
+ yield value;
12
+ }
13
+ }
5
14
  class TRPCUntypedClient {
6
15
  $request({ type , input , path , context ={} }) {
7
16
  const chain$ = createChain({
@@ -22,7 +31,12 @@ class TRPCUntypedClient {
22
31
  const abortablePromise = new Promise((resolve, reject)=>{
23
32
  opts.signal?.addEventListener('abort', abort);
24
33
  promise.then((envelope)=>{
25
- resolve(envelope.result.data);
34
+ const data = envelope.result.data;
35
+ if (!isAsyncIterable(data)) {
36
+ resolve(data);
37
+ return;
38
+ }
39
+ resolve(abortableIterable(data, opts.signal));
26
40
  }).catch((err)=>{
27
41
  reject(TRPCClientError.from(err));
28
42
  });
@@ -1 +1 @@
1
- {"version":3,"file":"httpBatchStreamLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchSt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,CAAC,CAAC,GACrE,QAAQ,CAAC,OAAO,CAAC,CAsKnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "11.0.0-alpha-tmp-issues-5851-take-two.451+27b7d9bc9",
3
+ "version": "11.0.0-alpha-tmp-issues-5851-take-two.454+1fa4b0c5f",
4
4
  "description": "The tRPC client library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -76,10 +76,10 @@
76
76
  "!**/*.test.*"
77
77
  ],
78
78
  "peerDependencies": {
79
- "@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.451+27b7d9bc9"
79
+ "@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.454+1fa4b0c5f"
80
80
  },
81
81
  "devDependencies": {
82
- "@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.451+27b7d9bc9",
82
+ "@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.454+1fa4b0c5f",
83
83
  "@types/isomorphic-fetch": "^0.0.39",
84
84
  "@types/node": "^20.10.0",
85
85
  "eslint": "^8.56.0",
@@ -96,5 +96,5 @@
96
96
  "funding": [
97
97
  "https://trpc.io/sponsor"
98
98
  ],
99
- "gitHead": "27b7d9bc9e6568fe608c8354a147274d0205c5bf"
99
+ "gitHead": "1fa4b0c5ff4a47b02497c580f464d5aa01356c8d"
100
100
  }
@@ -8,6 +8,7 @@ import type {
8
8
  InferrableClientTypes,
9
9
  TypeError,
10
10
  } from '@trpc/server/unstable-core-do-not-import';
11
+ import { isAsyncIterable } from '@trpc/server/unstable-core-do-not-import';
11
12
  import { createChain } from '../links/internals/createChain';
12
13
  import type {
13
14
  OperationContext,
@@ -51,6 +52,18 @@ export type UntypedClientProperties =
51
52
  | 'runtime'
52
53
  | 'subscription';
53
54
 
55
+ async function* abortableIterable<T>(
56
+ from: AsyncIterable<T>,
57
+ signal: AbortSignal | undefined,
58
+ ) {
59
+ for await (const value of from) {
60
+ if (signal?.throwIfAborted()) {
61
+ return;
62
+ }
63
+ yield value;
64
+ }
65
+ }
66
+
54
67
  export class TRPCUntypedClient<TRouter extends AnyRouter> {
55
68
  private readonly links: OperationLink<AnyRouter>[];
56
69
  public readonly runtime: TRPCClientRuntime;
@@ -88,6 +101,7 @@ export class TRPCUntypedClient<TRouter extends AnyRouter> {
88
101
  });
89
102
  return chain$.pipe(share());
90
103
  }
104
+
91
105
  private requestAsPromise<TInput = unknown, TOutput = unknown>(opts: {
92
106
  type: TRPCType;
93
107
  input: TInput;
@@ -104,7 +118,14 @@ export class TRPCUntypedClient<TRouter extends AnyRouter> {
104
118
 
105
119
  promise
106
120
  .then((envelope) => {
107
- resolve((envelope.result as any).data);
121
+ const data = (envelope.result as any).data;
122
+
123
+ if (!isAsyncIterable(data)) {
124
+ resolve(data);
125
+ return;
126
+ }
127
+
128
+ resolve(abortableIterable(data, opts.signal) as any);
108
129
  })
109
130
  .catch((err) => {
110
131
  reject(TRPCClientError.from(err));
@@ -108,6 +108,7 @@ export function unstable_httpBatchStreamLink<TRouter extends AnyRouter>(
108
108
  error,
109
109
  });
110
110
  },
111
+ // pass in an abort controller here!?
111
112
  });
112
113
 
113
114
  const promises = Object.keys(batchOps).map(