@trpc/client 11.0.0-rc.621 → 11.0.0-rc.630
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/TRPCClientError.js +7 -1
- package/dist/TRPCClientError.mjs +7 -1
- package/dist/bundle-analysis.json +58 -43
- package/dist/createTRPCClient.js +1 -1
- package/dist/createTRPCClient.mjs +1 -1
- package/dist/internals/TRPCUntypedClient.js +4 -0
- package/dist/internals/TRPCUntypedClient.mjs +4 -0
- package/dist/links/httpBatchLink.js +1 -1
- package/dist/links/httpBatchLink.mjs +1 -1
- package/dist/links/httpBatchStreamLink.js +1 -1
- package/dist/links/httpBatchStreamLink.mjs +1 -1
- package/dist/links/httpLink.js +2 -2
- package/dist/links/httpLink.mjs +2 -2
- package/dist/links/httpSubscriptionLink.js +5 -5
- package/dist/links/httpSubscriptionLink.mjs +5 -5
- package/dist/links/internals/httpUtils.js +1 -1
- package/dist/links/internals/httpUtils.mjs +1 -1
- package/dist/links/internals/retryLink.js +1 -1
- package/dist/links/internals/retryLink.mjs +1 -1
- package/dist/links/loggerLink.js +7 -7
- package/dist/links/loggerLink.mjs +7 -7
- package/dist/links/wsLink.js +9 -9
- package/dist/links/wsLink.mjs +9 -9
- package/dist/node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js +11 -0
- package/dist/node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs +9 -0
- package/package.json +6 -6
package/dist/TRPCClientError.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _define_property = require('./node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js');
|
|
3
4
|
var unstableCoreDoNotImport = require('@trpc/server/unstable-core-do-not-import');
|
|
4
5
|
|
|
5
6
|
function isTRPCClientError(cause) {
|
|
@@ -50,7 +51,12 @@ class TRPCClientError extends Error {
|
|
|
50
51
|
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
51
52
|
super(message, {
|
|
52
53
|
cause
|
|
53
|
-
})
|
|
54
|
+
}), // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
55
|
+
// @ts-ignore override doesn't work in all environments due to "This member cannot have an 'override' modifier because it is not declared in the base class 'Error'"
|
|
56
|
+
_define_property._(this, "cause", void 0), _define_property._(this, "shape", void 0), _define_property._(this, "data", void 0), /**
|
|
57
|
+
* Additional meta data about the error
|
|
58
|
+
* In the case of HTTP-errors, we'll have `response` and potentially `responseJSON` here
|
|
59
|
+
*/ _define_property._(this, "meta", void 0);
|
|
54
60
|
this.meta = opts?.meta;
|
|
55
61
|
this.cause = cause;
|
|
56
62
|
this.shape = opts?.result?.error;
|
package/dist/TRPCClientError.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _define_property } from './node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs';
|
|
1
2
|
import { isObject } from '@trpc/server/unstable-core-do-not-import';
|
|
2
3
|
|
|
3
4
|
function isTRPCClientError(cause) {
|
|
@@ -48,7 +49,12 @@ class TRPCClientError extends Error {
|
|
|
48
49
|
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
49
50
|
super(message, {
|
|
50
51
|
cause
|
|
51
|
-
})
|
|
52
|
+
}), // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
53
|
+
// @ts-ignore override doesn't work in all environments due to "This member cannot have an 'override' modifier because it is not declared in the base class 'Error'"
|
|
54
|
+
_define_property(this, "cause", void 0), _define_property(this, "shape", void 0), _define_property(this, "data", void 0), /**
|
|
55
|
+
* Additional meta data about the error
|
|
56
|
+
* In the case of HTTP-errors, we'll have `response` and potentially `responseJSON` here
|
|
57
|
+
*/ _define_property(this, "meta", void 0);
|
|
52
58
|
this.meta = opts?.meta;
|
|
53
59
|
this.cause = cause;
|
|
54
60
|
this.shape = opts?.result?.error;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction":
|
|
2
|
+
"bundleSize": 63563,
|
|
3
|
+
"bundleOrigSize": 81324,
|
|
4
|
+
"bundleReduction": 21.84,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/links/wsLink.ts",
|
|
8
|
-
"size":
|
|
8
|
+
"size": 18016,
|
|
9
9
|
"origSize": 20084,
|
|
10
10
|
"renderedExports": [
|
|
11
11
|
"createWSClient",
|
|
@@ -13,44 +13,44 @@
|
|
|
13
13
|
],
|
|
14
14
|
"removedExports": [],
|
|
15
15
|
"dependents": [],
|
|
16
|
-
"percent": 28.
|
|
17
|
-
"reduction": 10.
|
|
16
|
+
"percent": 28.34,
|
|
17
|
+
"reduction": 10.3
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"id": "/src/links/httpSubscriptionLink.ts",
|
|
21
|
-
"size":
|
|
21
|
+
"size": 6709,
|
|
22
22
|
"origSize": 6686,
|
|
23
23
|
"renderedExports": [
|
|
24
24
|
"unstable_httpSubscriptionLink"
|
|
25
25
|
],
|
|
26
26
|
"removedExports": [],
|
|
27
27
|
"dependents": [],
|
|
28
|
-
"percent": 10.
|
|
28
|
+
"percent": 10.55,
|
|
29
29
|
"reduction": 0
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"id": "/src/links/httpBatchStreamLink.ts",
|
|
33
|
-
"size":
|
|
33
|
+
"size": 6006,
|
|
34
34
|
"origSize": 6284,
|
|
35
35
|
"renderedExports": [
|
|
36
36
|
"unstable_httpBatchStreamLink"
|
|
37
37
|
],
|
|
38
38
|
"removedExports": [],
|
|
39
39
|
"dependents": [],
|
|
40
|
-
"percent": 9.
|
|
41
|
-
"reduction": 4.
|
|
40
|
+
"percent": 9.45,
|
|
41
|
+
"reduction": 4.42
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"id": "/src/links/loggerLink.ts",
|
|
45
|
-
"size":
|
|
45
|
+
"size": 5596,
|
|
46
46
|
"origSize": 6946,
|
|
47
47
|
"renderedExports": [
|
|
48
48
|
"loggerLink"
|
|
49
49
|
],
|
|
50
50
|
"removedExports": [],
|
|
51
51
|
"dependents": [],
|
|
52
|
-
"percent": 8.
|
|
53
|
-
"reduction": 19.
|
|
52
|
+
"percent": 8.8,
|
|
53
|
+
"reduction": 19.44
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
"id": "/src/internals/dataLoader.ts",
|
|
@@ -64,24 +64,24 @@
|
|
|
64
64
|
"/src/links/httpBatchLink.ts",
|
|
65
65
|
"/src/links/httpBatchStreamLink.ts"
|
|
66
66
|
],
|
|
67
|
-
"percent": 6.
|
|
67
|
+
"percent": 6.43,
|
|
68
68
|
"reduction": 5.64
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
"id": "/src/links/httpBatchLink.ts",
|
|
72
|
-
"size":
|
|
72
|
+
"size": 3937,
|
|
73
73
|
"origSize": 4170,
|
|
74
74
|
"renderedExports": [
|
|
75
75
|
"httpBatchLink"
|
|
76
76
|
],
|
|
77
77
|
"removedExports": [],
|
|
78
78
|
"dependents": [],
|
|
79
|
-
"percent": 6.
|
|
80
|
-
"reduction": 5.
|
|
79
|
+
"percent": 6.19,
|
|
80
|
+
"reduction": 5.59
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
"id": "/src/links/internals/httpUtils.ts",
|
|
84
|
-
"size":
|
|
84
|
+
"size": 3692,
|
|
85
85
|
"origSize": 5873,
|
|
86
86
|
"renderedExports": [
|
|
87
87
|
"resolveHTTPLinkOptions",
|
|
@@ -99,24 +99,24 @@
|
|
|
99
99
|
"/src/links/httpBatchStreamLink.ts",
|
|
100
100
|
"/src/links/httpSubscriptionLink.ts"
|
|
101
101
|
],
|
|
102
|
-
"percent": 5.
|
|
103
|
-
"reduction": 37.
|
|
102
|
+
"percent": 5.81,
|
|
103
|
+
"reduction": 37.14
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
"id": "/src/links/httpLink.ts",
|
|
107
|
-
"size":
|
|
107
|
+
"size": 3179,
|
|
108
108
|
"origSize": 3707,
|
|
109
109
|
"renderedExports": [
|
|
110
110
|
"httpLink"
|
|
111
111
|
],
|
|
112
112
|
"removedExports": [],
|
|
113
113
|
"dependents": [],
|
|
114
|
-
"percent": 5
|
|
115
|
-
"reduction": 14.
|
|
114
|
+
"percent": 5,
|
|
115
|
+
"reduction": 14.24
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
"id": "/src/internals/TRPCUntypedClient.ts",
|
|
119
|
-
"size":
|
|
119
|
+
"size": 2866,
|
|
120
120
|
"origSize": 4579,
|
|
121
121
|
"renderedExports": [
|
|
122
122
|
"TRPCUntypedClient"
|
|
@@ -126,12 +126,12 @@
|
|
|
126
126
|
"/src/createTRPCUntypedClient.ts",
|
|
127
127
|
"/src/createTRPCClient.ts"
|
|
128
128
|
],
|
|
129
|
-
"percent": 4.
|
|
130
|
-
"reduction":
|
|
129
|
+
"percent": 4.51,
|
|
130
|
+
"reduction": 37.41
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
133
|
"id": "/src/TRPCClientError.ts",
|
|
134
|
-
"size":
|
|
134
|
+
"size": 2496,
|
|
135
135
|
"origSize": 3564,
|
|
136
136
|
"renderedExports": [
|
|
137
137
|
"TRPCClientError"
|
|
@@ -146,20 +146,20 @@
|
|
|
146
146
|
"/src/links/httpSubscriptionLink.ts",
|
|
147
147
|
"/src/internals/TRPCUntypedClient.ts"
|
|
148
148
|
],
|
|
149
|
-
"percent": 3.
|
|
150
|
-
"reduction":
|
|
149
|
+
"percent": 3.93,
|
|
150
|
+
"reduction": 29.97
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
"id": "/src/links/internals/retryLink.ts",
|
|
154
|
-
"size":
|
|
154
|
+
"size": 1419,
|
|
155
155
|
"origSize": 1995,
|
|
156
156
|
"renderedExports": [
|
|
157
157
|
"retryLink"
|
|
158
158
|
],
|
|
159
159
|
"removedExports": [],
|
|
160
160
|
"dependents": [],
|
|
161
|
-
"percent": 2.
|
|
162
|
-
"reduction": 28.
|
|
161
|
+
"percent": 2.23,
|
|
162
|
+
"reduction": 28.87
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
165
|
"id": "/src/internals/signals.ts",
|
|
@@ -175,12 +175,12 @@
|
|
|
175
175
|
"/src/links/httpBatchStreamLink.ts",
|
|
176
176
|
"/src/links/httpSubscriptionLink.ts"
|
|
177
177
|
],
|
|
178
|
-
"percent": 1.
|
|
178
|
+
"percent": 1.87,
|
|
179
179
|
"reduction": 3.88
|
|
180
180
|
},
|
|
181
181
|
{
|
|
182
182
|
"id": "/src/createTRPCClient.ts",
|
|
183
|
-
"size":
|
|
183
|
+
"size": 1185,
|
|
184
184
|
"origSize": 4478,
|
|
185
185
|
"renderedExports": [
|
|
186
186
|
"clientCallTypeToProcedureType",
|
|
@@ -192,8 +192,8 @@
|
|
|
192
192
|
"dependents": [
|
|
193
193
|
"/src/index.ts"
|
|
194
194
|
],
|
|
195
|
-
"percent": 1.
|
|
196
|
-
"reduction": 73.
|
|
195
|
+
"percent": 1.86,
|
|
196
|
+
"reduction": 73.54
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
199
|
"id": "/src/links/internals/createChain.ts",
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
"/src/links/splitLink.ts",
|
|
208
208
|
"/src/internals/TRPCUntypedClient.ts"
|
|
209
209
|
],
|
|
210
|
-
"percent": 1.
|
|
210
|
+
"percent": 1.09,
|
|
211
211
|
"reduction": 32.75
|
|
212
212
|
},
|
|
213
213
|
{
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
],
|
|
220
220
|
"removedExports": [],
|
|
221
221
|
"dependents": [],
|
|
222
|
-
"percent": 0.
|
|
222
|
+
"percent": 0.96,
|
|
223
223
|
"reduction": 44.95
|
|
224
224
|
},
|
|
225
225
|
{
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
"dependents": [
|
|
234
234
|
"/src/unstable-internals.ts"
|
|
235
235
|
],
|
|
236
|
-
"percent": 0.
|
|
236
|
+
"percent": 0.89,
|
|
237
237
|
"reduction": 66.71
|
|
238
238
|
},
|
|
239
239
|
{
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
"/src/index.ts",
|
|
249
249
|
"/src/links/internals/httpUtils.ts"
|
|
250
250
|
],
|
|
251
|
-
"percent": 0.
|
|
251
|
+
"percent": 0.67,
|
|
252
252
|
"reduction": 33.54
|
|
253
253
|
},
|
|
254
254
|
{
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
],
|
|
263
263
|
"removedExports": [],
|
|
264
264
|
"dependents": [],
|
|
265
|
-
"percent": 0.
|
|
265
|
+
"percent": 0.52,
|
|
266
266
|
"reduction": 15.17
|
|
267
267
|
},
|
|
268
268
|
{
|
|
@@ -280,6 +280,21 @@
|
|
|
280
280
|
"percent": 0.38,
|
|
281
281
|
"reduction": 76.38
|
|
282
282
|
},
|
|
283
|
+
{
|
|
284
|
+
"id": "/home/runner/work/trpc/trpc/node_modules/.pnpm/@swc+helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js",
|
|
285
|
+
"size": 227,
|
|
286
|
+
"origSize": 262,
|
|
287
|
+
"renderedExports": [
|
|
288
|
+
"_"
|
|
289
|
+
],
|
|
290
|
+
"removedExports": [],
|
|
291
|
+
"dependents": [
|
|
292
|
+
"/src/TRPCClientError.ts",
|
|
293
|
+
"/src/internals/TRPCUntypedClient.ts"
|
|
294
|
+
],
|
|
295
|
+
"percent": 0.36,
|
|
296
|
+
"reduction": 13.36
|
|
297
|
+
},
|
|
283
298
|
{
|
|
284
299
|
"id": "/src/createTRPCUntypedClient.ts",
|
|
285
300
|
"size": 100,
|
|
@@ -319,5 +334,5 @@
|
|
|
319
334
|
"reduction": 100
|
|
320
335
|
}
|
|
321
336
|
],
|
|
322
|
-
"moduleCount":
|
|
337
|
+
"moduleCount": 23
|
|
323
338
|
}
|
package/dist/createTRPCClient.js
CHANGED
|
@@ -14,7 +14,7 @@ const clientCallTypeMap = {
|
|
|
14
14
|
/**
|
|
15
15
|
* @internal
|
|
16
16
|
*/ function createTRPCClientProxy(client) {
|
|
17
|
-
const proxy = unstableCoreDoNotImport.createRecursiveProxy(({ path
|
|
17
|
+
const proxy = unstableCoreDoNotImport.createRecursiveProxy(({ path, args })=>{
|
|
18
18
|
const pathCopy = [
|
|
19
19
|
...path
|
|
20
20
|
];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _define_property = require('../node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.js');
|
|
3
4
|
var observable = require('@trpc/server/observable');
|
|
4
5
|
var createChain = require('../links/internals/createChain.js');
|
|
5
6
|
var TRPCClientError = require('../TRPCClientError.js');
|
|
@@ -89,6 +90,9 @@ class TRPCUntypedClient {
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
constructor(opts){
|
|
93
|
+
_define_property._(this, "links", void 0);
|
|
94
|
+
_define_property._(this, "runtime", void 0);
|
|
95
|
+
_define_property._(this, "requestId", void 0);
|
|
92
96
|
this.requestId = 0;
|
|
93
97
|
this.runtime = {};
|
|
94
98
|
// Initialize the links
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _define_property } from '../node_modules/.pnpm/@swc_helpers@0.5.13/node_modules/@swc/helpers/esm/_define_property.mjs';
|
|
1
2
|
import { share, observableToPromise } from '@trpc/server/observable';
|
|
2
3
|
import { createChain } from '../links/internals/createChain.mjs';
|
|
3
4
|
import { TRPCClientError } from '../TRPCClientError.mjs';
|
|
@@ -87,6 +88,9 @@ class TRPCUntypedClient {
|
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
constructor(opts){
|
|
91
|
+
_define_property(this, "links", void 0);
|
|
92
|
+
_define_property(this, "runtime", void 0);
|
|
93
|
+
_define_property(this, "requestId", void 0);
|
|
90
94
|
this.requestId = 0;
|
|
91
95
|
this.runtime = {};
|
|
92
96
|
// Initialize the links
|
|
@@ -68,7 +68,7 @@ var httpUtils = require('./internals/httpUtils.js');
|
|
|
68
68
|
query,
|
|
69
69
|
mutation
|
|
70
70
|
};
|
|
71
|
-
return ({ op
|
|
71
|
+
return ({ op })=>{
|
|
72
72
|
return observable.observable((observer)=>{
|
|
73
73
|
/* istanbul ignore if -- @preserve */ if (op.type === 'subscription') {
|
|
74
74
|
throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
|
|
@@ -66,7 +66,7 @@ import { resolveHTTPLinkOptions, getUrl, jsonHttpRequester } from './internals/h
|
|
|
66
66
|
query,
|
|
67
67
|
mutation
|
|
68
68
|
};
|
|
69
|
-
return ({ op
|
|
69
|
+
return ({ op })=>{
|
|
70
70
|
return observable((observer)=>{
|
|
71
71
|
/* istanbul ignore if -- @preserve */ if (op.type === 'subscription') {
|
|
72
72
|
throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
|
|
@@ -106,7 +106,7 @@ var httpUtils = require('./internals/httpUtils.js');
|
|
|
106
106
|
query,
|
|
107
107
|
mutation
|
|
108
108
|
};
|
|
109
|
-
return ({ op
|
|
109
|
+
return ({ op })=>{
|
|
110
110
|
return observable.observable((observer)=>{
|
|
111
111
|
/* istanbul ignore if -- @preserve */ if (op.type === 'subscription') {
|
|
112
112
|
throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
|
|
@@ -104,7 +104,7 @@ import { resolveHTTPLinkOptions, getUrl, fetchHTTPResponse, getBody } from './in
|
|
|
104
104
|
query,
|
|
105
105
|
mutation
|
|
106
106
|
};
|
|
107
|
-
return ({ op
|
|
107
|
+
return ({ op })=>{
|
|
108
108
|
return observable((observer)=>{
|
|
109
109
|
/* istanbul ignore if -- @preserve */ if (op.type === 'subscription') {
|
|
110
110
|
throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
|
package/dist/links/httpLink.js
CHANGED
|
@@ -38,9 +38,9 @@ const universalRequester = (opts)=>{
|
|
|
38
38
|
*/ function httpLink(opts) {
|
|
39
39
|
const resolvedOpts = httpUtils.resolveHTTPLinkOptions(opts);
|
|
40
40
|
return ()=>{
|
|
41
|
-
return ({ op
|
|
41
|
+
return ({ op })=>{
|
|
42
42
|
return observable.observable((observer)=>{
|
|
43
|
-
const { path
|
|
43
|
+
const { path, input, type } = op;
|
|
44
44
|
/* istanbul ignore if -- @preserve */ if (type === 'subscription') {
|
|
45
45
|
throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
|
|
46
46
|
}
|
package/dist/links/httpLink.mjs
CHANGED
|
@@ -36,9 +36,9 @@ const universalRequester = (opts)=>{
|
|
|
36
36
|
*/ function httpLink(opts) {
|
|
37
37
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
38
38
|
return ()=>{
|
|
39
|
-
return ({ op
|
|
39
|
+
return ({ op })=>{
|
|
40
40
|
return observable((observer)=>{
|
|
41
|
-
const { path
|
|
41
|
+
const { path, input, type } = op;
|
|
42
42
|
/* istanbul ignore if -- @preserve */ if (type === 'subscription') {
|
|
43
43
|
throw new Error('Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`');
|
|
44
44
|
}
|
|
@@ -32,9 +32,9 @@ async function urlWithConnectionParams(opts) {
|
|
|
32
32
|
*/ function unstable_httpSubscriptionLink(opts) {
|
|
33
33
|
const transformer$1 = transformer.getTransformer(opts.transformer);
|
|
34
34
|
return ()=>{
|
|
35
|
-
return ({ op
|
|
35
|
+
return ({ op })=>{
|
|
36
36
|
return observable.observable((observer)=>{
|
|
37
|
-
const { type
|
|
37
|
+
const { type, path, input } = op;
|
|
38
38
|
/* istanbul ignore if -- @preserve */ if (type !== 'subscription') {
|
|
39
39
|
throw new Error('httpSubscriptionLink only supports subscriptions');
|
|
40
40
|
}
|
|
@@ -122,14 +122,14 @@ async function urlWithConnectionParams(opts) {
|
|
|
122
122
|
case 'connecting':
|
|
123
123
|
{
|
|
124
124
|
const lastState = connectionState.get();
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
125
|
+
const error = chunk.event && TRPCClientError.TRPCClientError.from(chunk.event);
|
|
126
|
+
if (!error && lastState.state === 'connecting') {
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
129
129
|
connectionState.next({
|
|
130
130
|
type: 'state',
|
|
131
131
|
state: 'connecting',
|
|
132
|
-
error
|
|
132
|
+
error
|
|
133
133
|
});
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
@@ -30,9 +30,9 @@ async function urlWithConnectionParams(opts) {
|
|
|
30
30
|
*/ function unstable_httpSubscriptionLink(opts) {
|
|
31
31
|
const transformer = getTransformer(opts.transformer);
|
|
32
32
|
return ()=>{
|
|
33
|
-
return ({ op
|
|
33
|
+
return ({ op })=>{
|
|
34
34
|
return observable((observer)=>{
|
|
35
|
-
const { type
|
|
35
|
+
const { type, path, input } = op;
|
|
36
36
|
/* istanbul ignore if -- @preserve */ if (type !== 'subscription') {
|
|
37
37
|
throw new Error('httpSubscriptionLink only supports subscriptions');
|
|
38
38
|
}
|
|
@@ -120,14 +120,14 @@ async function urlWithConnectionParams(opts) {
|
|
|
120
120
|
case 'connecting':
|
|
121
121
|
{
|
|
122
122
|
const lastState = connectionState.get();
|
|
123
|
-
const
|
|
124
|
-
if (!
|
|
123
|
+
const error = chunk.event && TRPCClientError.from(chunk.event);
|
|
124
|
+
if (!error && lastState.state === 'connecting') {
|
|
125
125
|
break;
|
|
126
126
|
}
|
|
127
127
|
connectionState.next({
|
|
128
128
|
type: 'state',
|
|
129
129
|
state: 'connecting',
|
|
130
|
-
error
|
|
130
|
+
error
|
|
131
131
|
});
|
|
132
132
|
break;
|
|
133
133
|
}
|
|
@@ -96,7 +96,7 @@ async function fetchHTTPResponse(opts) {
|
|
|
96
96
|
throwIfAborted(opts.signal);
|
|
97
97
|
const url = opts.getUrl(opts);
|
|
98
98
|
const body = opts.getBody(opts);
|
|
99
|
-
const { type
|
|
99
|
+
const { type } = opts;
|
|
100
100
|
const resolvedHeaders = await (async ()=>{
|
|
101
101
|
const heads = await opts.headers();
|
|
102
102
|
if (Symbol.iterator in heads) {
|
|
@@ -94,7 +94,7 @@ async function fetchHTTPResponse(opts) {
|
|
|
94
94
|
throwIfAborted(opts.signal);
|
|
95
95
|
const url = opts.getUrl(opts);
|
|
96
96
|
const body = opts.getBody(opts);
|
|
97
|
-
const { type
|
|
97
|
+
const { type } = opts;
|
|
98
98
|
const resolvedHeaders = await (async ()=>{
|
|
99
99
|
const heads = await opts.headers();
|
|
100
100
|
if (Symbol.iterator in heads) {
|
|
@@ -9,7 +9,7 @@ var observable = require('@trpc/server/observable');
|
|
|
9
9
|
// initialized config
|
|
10
10
|
return ()=>{
|
|
11
11
|
// initialized in app
|
|
12
|
-
return ({ op
|
|
12
|
+
return ({ op, next })=>{
|
|
13
13
|
// initialized for request
|
|
14
14
|
return observable.observable((observer)=>{
|
|
15
15
|
let next$;
|
package/dist/links/loggerLink.js
CHANGED
|
@@ -64,7 +64,7 @@ const palettes = {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
function constructPartsAndArgs(opts) {
|
|
67
|
-
const { direction
|
|
67
|
+
const { direction, type, withContext, path, id, input } = opts;
|
|
68
68
|
const parts = [];
|
|
69
69
|
const args = [];
|
|
70
70
|
if (opts.colorMode === 'none') {
|
|
@@ -108,10 +108,10 @@ function constructPartsAndArgs(opts) {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
// maybe this should be moved to it's own package
|
|
111
|
-
const defaultLogger = ({ c =console
|
|
111
|
+
const defaultLogger = ({ c = console, colorMode = 'css', withContext })=>(props)=>{
|
|
112
112
|
const rawInput = props.input;
|
|
113
113
|
const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
|
|
114
|
-
const { parts
|
|
114
|
+
const { parts, args } = constructPartsAndArgs({
|
|
115
115
|
...props,
|
|
116
116
|
colorMode,
|
|
117
117
|
input,
|
|
@@ -125,16 +125,16 @@ const defaultLogger = ({ c =console , colorMode ='css' , withContext })=>(props
|
|
|
125
125
|
/**
|
|
126
126
|
* @see https://trpc.io/docs/v11/client/links/loggerLink
|
|
127
127
|
*/ function loggerLink(opts = {}) {
|
|
128
|
-
const { enabled =()=>true
|
|
128
|
+
const { enabled = ()=>true } = opts;
|
|
129
129
|
const colorMode = opts.colorMode ?? (typeof window === 'undefined' ? 'ansi' : 'css');
|
|
130
130
|
const withContext = opts.withContext ?? colorMode === 'css';
|
|
131
|
-
const { logger =defaultLogger({
|
|
131
|
+
const { logger = defaultLogger({
|
|
132
132
|
c: opts.console,
|
|
133
133
|
colorMode,
|
|
134
134
|
withContext
|
|
135
|
-
})
|
|
135
|
+
}) } = opts;
|
|
136
136
|
return ()=>{
|
|
137
|
-
return ({ op
|
|
137
|
+
return ({ op, next })=>{
|
|
138
138
|
return observable.observable((observer)=>{
|
|
139
139
|
// ->
|
|
140
140
|
if (enabled({
|
|
@@ -62,7 +62,7 @@ const palettes = {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
function constructPartsAndArgs(opts) {
|
|
65
|
-
const { direction
|
|
65
|
+
const { direction, type, withContext, path, id, input } = opts;
|
|
66
66
|
const parts = [];
|
|
67
67
|
const args = [];
|
|
68
68
|
if (opts.colorMode === 'none') {
|
|
@@ -106,10 +106,10 @@ function constructPartsAndArgs(opts) {
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
// maybe this should be moved to it's own package
|
|
109
|
-
const defaultLogger = ({ c =console
|
|
109
|
+
const defaultLogger = ({ c = console, colorMode = 'css', withContext })=>(props)=>{
|
|
110
110
|
const rawInput = props.input;
|
|
111
111
|
const input = isFormData(rawInput) ? Object.fromEntries(rawInput) : rawInput;
|
|
112
|
-
const { parts
|
|
112
|
+
const { parts, args } = constructPartsAndArgs({
|
|
113
113
|
...props,
|
|
114
114
|
colorMode,
|
|
115
115
|
input,
|
|
@@ -123,16 +123,16 @@ const defaultLogger = ({ c =console , colorMode ='css' , withContext })=>(props
|
|
|
123
123
|
/**
|
|
124
124
|
* @see https://trpc.io/docs/v11/client/links/loggerLink
|
|
125
125
|
*/ function loggerLink(opts = {}) {
|
|
126
|
-
const { enabled =()=>true
|
|
126
|
+
const { enabled = ()=>true } = opts;
|
|
127
127
|
const colorMode = opts.colorMode ?? (typeof window === 'undefined' ? 'ansi' : 'css');
|
|
128
128
|
const withContext = opts.withContext ?? colorMode === 'css';
|
|
129
|
-
const { logger =defaultLogger({
|
|
129
|
+
const { logger = defaultLogger({
|
|
130
130
|
c: opts.console,
|
|
131
131
|
colorMode,
|
|
132
132
|
withContext
|
|
133
|
-
})
|
|
133
|
+
}) } = opts;
|
|
134
134
|
return ()=>{
|
|
135
|
-
return ({ op
|
|
135
|
+
return ({ op, next })=>{
|
|
136
136
|
return observable((observer)=>{
|
|
137
137
|
// ->
|
|
138
138
|
if (enabled({
|
package/dist/links/wsLink.js
CHANGED
|
@@ -18,7 +18,7 @@ const lazyDefaults = {
|
|
|
18
18
|
* 🙋♂️ **Contributors needed** to continue supporting WebSockets!
|
|
19
19
|
* See https://github.com/trpc/trpc/issues/6109
|
|
20
20
|
*/ function createWSClient(opts) {
|
|
21
|
-
const { WebSocket: WebSocketImpl = WebSocket
|
|
21
|
+
const { WebSocket: WebSocketImpl = WebSocket, retryDelayMs: retryDelayFn = exponentialBackoff } = opts;
|
|
22
22
|
const lazyOpts = {
|
|
23
23
|
...lazyDefaults,
|
|
24
24
|
...opts.lazy
|
|
@@ -163,7 +163,7 @@ const lazyDefaults = {
|
|
|
163
163
|
const noop = ()=>{
|
|
164
164
|
// no-op
|
|
165
165
|
};
|
|
166
|
-
const { ws
|
|
166
|
+
const { ws } = self;
|
|
167
167
|
if (ws) {
|
|
168
168
|
ws.onclose = noop;
|
|
169
169
|
ws.onerror = noop;
|
|
@@ -227,7 +227,7 @@ const lazyDefaults = {
|
|
|
227
227
|
if (!opts.keepAlive?.enabled) {
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
const { pongTimeoutMs =1000
|
|
230
|
+
const { pongTimeoutMs = 1000, intervalMs = 5000 } = opts.keepAlive;
|
|
231
231
|
const schedulePing = ()=>{
|
|
232
232
|
const schedulePongTimeout = ()=>{
|
|
233
233
|
pongTimeout = setTimeout(()=>{
|
|
@@ -315,7 +315,7 @@ const lazyDefaults = {
|
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
ws.onmessage = (event)=>{
|
|
318
|
-
const { data
|
|
318
|
+
const { data } = event;
|
|
319
319
|
if (data === 'PONG') {
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
@@ -352,8 +352,8 @@ const lazyDefaults = {
|
|
|
352
352
|
return self;
|
|
353
353
|
}
|
|
354
354
|
function request(opts) {
|
|
355
|
-
const { op
|
|
356
|
-
const { type
|
|
355
|
+
const { op, callbacks, lastEventId } = opts;
|
|
356
|
+
const { type, input, path, id } = op;
|
|
357
357
|
const envelope = {
|
|
358
358
|
id,
|
|
359
359
|
method: type,
|
|
@@ -437,10 +437,10 @@ class TRPCWebSocketClosedError extends Error {
|
|
|
437
437
|
*/ function wsLink(opts) {
|
|
438
438
|
const transformer$1 = transformer.getTransformer(opts.transformer);
|
|
439
439
|
return ()=>{
|
|
440
|
-
const { client
|
|
441
|
-
return ({ op
|
|
440
|
+
const { client } = opts;
|
|
441
|
+
return ({ op })=>{
|
|
442
442
|
return observable.observable((observer)=>{
|
|
443
|
-
const { type
|
|
443
|
+
const { type, path, id, context } = op;
|
|
444
444
|
const input = transformer$1.input.serialize(op.input);
|
|
445
445
|
const connState = type === 'subscription' ? client.connectionState.subscribe({
|
|
446
446
|
next (result) {
|
package/dist/links/wsLink.mjs
CHANGED
|
@@ -16,7 +16,7 @@ const lazyDefaults = {
|
|
|
16
16
|
* 🙋♂️ **Contributors needed** to continue supporting WebSockets!
|
|
17
17
|
* See https://github.com/trpc/trpc/issues/6109
|
|
18
18
|
*/ function createWSClient(opts) {
|
|
19
|
-
const { WebSocket: WebSocketImpl = WebSocket
|
|
19
|
+
const { WebSocket: WebSocketImpl = WebSocket, retryDelayMs: retryDelayFn = exponentialBackoff } = opts;
|
|
20
20
|
const lazyOpts = {
|
|
21
21
|
...lazyDefaults,
|
|
22
22
|
...opts.lazy
|
|
@@ -161,7 +161,7 @@ const lazyDefaults = {
|
|
|
161
161
|
const noop = ()=>{
|
|
162
162
|
// no-op
|
|
163
163
|
};
|
|
164
|
-
const { ws
|
|
164
|
+
const { ws } = self;
|
|
165
165
|
if (ws) {
|
|
166
166
|
ws.onclose = noop;
|
|
167
167
|
ws.onerror = noop;
|
|
@@ -225,7 +225,7 @@ const lazyDefaults = {
|
|
|
225
225
|
if (!opts.keepAlive?.enabled) {
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
|
-
const { pongTimeoutMs =1000
|
|
228
|
+
const { pongTimeoutMs = 1000, intervalMs = 5000 } = opts.keepAlive;
|
|
229
229
|
const schedulePing = ()=>{
|
|
230
230
|
const schedulePongTimeout = ()=>{
|
|
231
231
|
pongTimeout = setTimeout(()=>{
|
|
@@ -313,7 +313,7 @@ const lazyDefaults = {
|
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
315
|
ws.onmessage = (event)=>{
|
|
316
|
-
const { data
|
|
316
|
+
const { data } = event;
|
|
317
317
|
if (data === 'PONG') {
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
@@ -350,8 +350,8 @@ const lazyDefaults = {
|
|
|
350
350
|
return self;
|
|
351
351
|
}
|
|
352
352
|
function request(opts) {
|
|
353
|
-
const { op
|
|
354
|
-
const { type
|
|
353
|
+
const { op, callbacks, lastEventId } = opts;
|
|
354
|
+
const { type, input, path, id } = op;
|
|
355
355
|
const envelope = {
|
|
356
356
|
id,
|
|
357
357
|
method: type,
|
|
@@ -435,10 +435,10 @@ class TRPCWebSocketClosedError extends Error {
|
|
|
435
435
|
*/ function wsLink(opts) {
|
|
436
436
|
const transformer = getTransformer(opts.transformer);
|
|
437
437
|
return ()=>{
|
|
438
|
-
const { client
|
|
439
|
-
return ({ op
|
|
438
|
+
const { client } = opts;
|
|
439
|
+
return ({ op })=>{
|
|
440
440
|
return observable((observer)=>{
|
|
441
|
-
const { type
|
|
441
|
+
const { type, path, id, context } = op;
|
|
442
442
|
const input = transformer.input.serialize(op.input);
|
|
443
443
|
const connState = type === 'subscription' ? client.connectionState.subscribe({
|
|
444
444
|
next (result) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _define_property(obj, key, value) {
|
|
4
|
+
if (key in obj) {
|
|
5
|
+
Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
|
|
6
|
+
} else obj[key] = value;
|
|
7
|
+
|
|
8
|
+
return obj;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports._ = _define_property;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.630+73639524c",
|
|
4
4
|
"description": "The tRPC client library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,16 +76,16 @@
|
|
|
76
76
|
"!**/*.test.*"
|
|
77
77
|
],
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@trpc/server": "11.0.0-rc.
|
|
79
|
+
"@trpc/server": "11.0.0-rc.630+73639524c"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@trpc/server": "11.0.0-rc.
|
|
82
|
+
"@trpc/server": "11.0.0-rc.630+73639524c",
|
|
83
83
|
"@types/isomorphic-fetch": "^0.0.39",
|
|
84
|
-
"@types/node": "^
|
|
84
|
+
"@types/node": "^22.9.0",
|
|
85
85
|
"eslint": "^9.13.0",
|
|
86
86
|
"isomorphic-fetch": "^3.0.0",
|
|
87
87
|
"node-fetch": "^3.3.0",
|
|
88
|
-
"rollup": "^4.
|
|
88
|
+
"rollup": "^4.24.4",
|
|
89
89
|
"tslib": "^2.5.0",
|
|
90
90
|
"tsx": "^4.0.0",
|
|
91
91
|
"undici": "^6.0.1"
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"funding": [
|
|
97
97
|
"https://trpc.io/sponsor"
|
|
98
98
|
],
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "73639524cd2d8071e4818435a76f7234685ac2af"
|
|
100
100
|
}
|