@trpc/client 11.0.0-rc.461 → 11.0.0-rc.466

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": 51737,
3
- "bundleOrigSize": 68912,
4
- "bundleReduction": 24.92,
2
+ "bundleSize": 51847,
3
+ "bundleOrigSize": 69119,
4
+ "bundleReduction": 24.99,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/links/wsLink.ts",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "removedExports": [],
15
15
  "dependents": [],
16
- "percent": 25.26,
16
+ "percent": 25.21,
17
17
  "reduction": 10.22
18
18
  },
19
19
  {
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "removedExports": [],
27
27
  "dependents": [],
28
- "percent": 11.33,
28
+ "percent": 11.3,
29
29
  "reduction": 3.51
30
30
  },
31
31
  {
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "removedExports": [],
39
39
  "dependents": [],
40
- "percent": 10.55,
40
+ "percent": 10.53,
41
41
  "reduction": 18.48
42
42
  },
43
43
  {
@@ -56,12 +56,12 @@
56
56
  ],
57
57
  "removedExports": [],
58
58
  "dependents": [
59
- "/src/links/httpBatchLink.ts",
60
59
  "/src/links/httpLink.ts",
60
+ "/src/links/httpBatchLink.ts",
61
61
  "/src/links/httpBatchStreamLink.ts",
62
62
  "/src/links/httpSubscriptionLink.ts"
63
63
  ],
64
- "percent": 8.63,
64
+ "percent": 8.61,
65
65
  "reduction": 32.82
66
66
  },
67
67
  {
@@ -76,7 +76,7 @@
76
76
  "/src/links/httpBatchLink.ts",
77
77
  "/src/links/httpBatchStreamLink.ts"
78
78
  ],
79
- "percent": 7.89,
79
+ "percent": 7.88,
80
80
  "reduction": 5.64
81
81
  },
82
82
  {
@@ -88,20 +88,20 @@
88
88
  ],
89
89
  "removedExports": [],
90
90
  "dependents": [],
91
- "percent": 7.59,
91
+ "percent": 7.57,
92
92
  "reduction": 4.69
93
93
  },
94
94
  {
95
95
  "id": "/src/links/httpSubscriptionLink.ts",
96
- "size": 3522,
97
- "origSize": 3752,
96
+ "size": 3632,
97
+ "origSize": 3952,
98
98
  "renderedExports": [
99
99
  "unstable_httpSubscriptionLink"
100
100
  ],
101
101
  "removedExports": [],
102
102
  "dependents": [],
103
- "percent": 6.81,
104
- "reduction": 6.13
103
+ "percent": 7.01,
104
+ "reduction": 8.1
105
105
  },
106
106
  {
107
107
  "id": "/src/links/httpLink.ts",
@@ -112,7 +112,7 @@
112
112
  ],
113
113
  "removedExports": [],
114
114
  "dependents": [],
115
- "percent": 6.15,
115
+ "percent": 6.14,
116
116
  "reduction": 14.15
117
117
  },
118
118
  {
@@ -127,7 +127,7 @@
127
127
  "/src/createTRPCUntypedClient.ts",
128
128
  "/src/createTRPCClient.ts"
129
129
  ],
130
- "percent": 4.18,
130
+ "percent": 4.17,
131
131
  "reduction": 47.6
132
132
  },
133
133
  {
@@ -140,14 +140,14 @@
140
140
  "removedExports": [],
141
141
  "dependents": [
142
142
  "/src/index.ts",
143
- "/src/links/httpBatchLink.ts",
144
143
  "/src/links/httpLink.ts",
144
+ "/src/links/httpBatchLink.ts",
145
145
  "/src/links/wsLink.ts",
146
146
  "/src/links/httpBatchStreamLink.ts",
147
147
  "/src/links/httpSubscriptionLink.ts",
148
148
  "/src/internals/TRPCUntypedClient.ts"
149
149
  ],
150
- "percent": 3.75,
150
+ "percent": 3.74,
151
151
  "reduction": 45.43
152
152
  },
153
153
  {
@@ -240,7 +240,7 @@
240
240
  {
241
241
  "id": "/src/links/internals/urlWithConnectionParams.ts",
242
242
  "size": 158,
243
- "origSize": 857,
243
+ "origSize": 864,
244
244
  "renderedExports": [
245
245
  "resultOf"
246
246
  ],
@@ -249,8 +249,8 @@
249
249
  "/src/links/wsLink.ts",
250
250
  "/src/links/httpSubscriptionLink.ts"
251
251
  ],
252
- "percent": 0.31,
253
- "reduction": 81.56
252
+ "percent": 0.3,
253
+ "reduction": 81.71
254
254
  },
255
255
  {
256
256
  "id": "/src/createTRPCUntypedClient.ts",
@@ -1,12 +1,13 @@
1
1
  import type { AnyClientTypes, inferClientTypes, InferrableClientTypes } from '@trpc/server/unstable-core-do-not-import';
2
2
  import { type TransformerOptions } from '../unstable-internals';
3
+ import type { CallbackOrValue } from './internals/urlWithConnectionParams';
3
4
  import { type UrlOptionsWithConnectionParams } from './internals/urlWithConnectionParams';
4
5
  import type { TRPCLink } from './types';
5
6
  type HTTPSubscriptionLinkOptions<TRoot extends AnyClientTypes> = {
6
7
  /**
7
- * EventSource options
8
+ * EventSource options or a callback that returns them
8
9
  */
9
- eventSourceOptions?: EventSourceInit;
10
+ eventSourceOptions?: CallbackOrValue<EventSourceInit>;
10
11
  } & TransformerOptions<TRoot> & UrlOptionsWithConnectionParams;
11
12
  /**
12
13
  * @see https://trpc.io/docs/client/links/httpSubscriptionLink
@@ -1 +1 @@
1
- {"version":3,"file":"httpSubscriptionLink.d.ts","sourceRoot":"","sources":["../../src/links/httpSubscriptionLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,0CAA0C,CAAC;AAMlD,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBxC,KAAK,2BAA2B,CAAC,KAAK,SAAS,cAAc,IAAI;IAC/D;;OAEG;IACH,kBAAkB,CAAC,EAAE,eAAe,CAAC;CACtC,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAC3B,8BAA8B,CAAC;AAEjC;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,SAAS,qBAAqB,EAEzC,IAAI,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,GAC/D,QAAQ,CAAC,WAAW,CAAC,CA8EvB"}
1
+ {"version":3,"file":"httpSubscriptionLink.d.ts","sourceRoot":"","sources":["../../src/links/httpSubscriptionLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,0CAA0C,CAAC;AAMlD,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBxC,KAAK,2BAA2B,CAAC,KAAK,SAAS,cAAc,IAAI;IAC/D;;OAEG;IACH,kBAAkB,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;CACvD,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAC3B,8BAA8B,CAAC;AAEjC;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,SAAS,qBAAqB,EAEzC,IAAI,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,GAC/D,QAAQ,CAAC,WAAW,CAAC,CAgFvB"}
@@ -38,11 +38,12 @@ async function urlWithConnectionParams(opts) {
38
38
  type,
39
39
  signal: null
40
40
  });
41
+ const eventSourceOptions = await urlWithConnectionParams$1.resultOf(opts.eventSourceOptions);
41
42
  /* istanbul ignore if -- @preserve */ if (unsubscribed) {
42
43
  // already unsubscribed - rare race condition
43
44
  return;
44
45
  }
45
- eventSource = new EventSource(url, opts.eventSourceOptions);
46
+ eventSource = new EventSource(url, eventSourceOptions);
46
47
  const onStarted = ()=>{
47
48
  observer.next({
48
49
  result: {
@@ -59,7 +60,7 @@ async function urlWithConnectionParams(opts) {
59
60
  eventSource.addEventListener('open', onStarted);
60
61
  const iterable = unstableCoreDoNotImport.sseStreamConsumer({
61
62
  from: eventSource,
62
- deserialize: transformer$1.input.deserialize
63
+ deserialize: transformer$1.output.deserialize
63
64
  });
64
65
  for await (const chunk of iterable){
65
66
  // if the `sse({})`-helper is used, we always have an `id` field
@@ -36,11 +36,12 @@ async function urlWithConnectionParams(opts) {
36
36
  type,
37
37
  signal: null
38
38
  });
39
+ const eventSourceOptions = await resultOf(opts.eventSourceOptions);
39
40
  /* istanbul ignore if -- @preserve */ if (unsubscribed) {
40
41
  // already unsubscribed - rare race condition
41
42
  return;
42
43
  }
43
- eventSource = new EventSource(url, opts.eventSourceOptions);
44
+ eventSource = new EventSource(url, eventSourceOptions);
44
45
  const onStarted = ()=>{
45
46
  observer.next({
46
47
  result: {
@@ -57,7 +58,7 @@ async function urlWithConnectionParams(opts) {
57
58
  eventSource.addEventListener('open', onStarted);
58
59
  const iterable = sseStreamConsumer({
59
60
  from: eventSource,
60
- deserialize: transformer.input.deserialize
61
+ deserialize: transformer.output.deserialize
61
62
  });
62
63
  for await (const chunk of iterable){
63
64
  // if the `sse({})`-helper is used, we always have an `id` field
@@ -6,7 +6,7 @@ export declare const resultOf: <T>(value: T | (() => T)) => T;
6
6
  /**
7
7
  * A value that can be wrapped in callback
8
8
  */
9
- type CallbackOrValue<T> = T | (() => T | Promise<T>);
9
+ export type CallbackOrValue<T> = T | (() => T | Promise<T>);
10
10
  export interface UrlOptionsWithConnectionParams {
11
11
  /**
12
12
  * The URL to connect to (can be a function that returns a URL)
@@ -19,5 +19,4 @@ export interface UrlOptionsWithConnectionParams {
19
19
  */
20
20
  connectionParams?: CallbackOrValue<TRPCRequestInfo['connectionParams']>;
21
21
  }
22
- export {};
23
22
  //# sourceMappingURL=urlWithConnectionParams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"urlWithConnectionParams.d.ts","sourceRoot":"","sources":["../../../src/links/internals/urlWithConnectionParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAG,CAElD,CAAC;AAEF;;GAEG;AACH,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAErD,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAE7B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;CACzE"}
1
+ {"version":3,"file":"urlWithConnectionParams.d.ts","sourceRoot":"","sources":["../../../src/links/internals/urlWithConnectionParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,KAAG,CAElD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5D,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAE7B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAAC;CACzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "11.0.0-rc.461+f178d3fed",
3
+ "version": "11.0.0-rc.466+1e8344ea7",
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-rc.461+f178d3fed"
79
+ "@trpc/server": "11.0.0-rc.466+1e8344ea7"
80
80
  },
81
81
  "devDependencies": {
82
- "@trpc/server": "11.0.0-rc.461+f178d3fed",
82
+ "@trpc/server": "11.0.0-rc.466+1e8344ea7",
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": "f178d3fed131c9036014603665a0803de0533c9a"
99
+ "gitHead": "1e8344ea7733b77b6d1b6dd07f7ed8630295447a"
100
100
  }
@@ -12,6 +12,7 @@ import {
12
12
  import { TRPCClientError } from '../TRPCClientError';
13
13
  import { getTransformer, type TransformerOptions } from '../unstable-internals';
14
14
  import { getUrl } from './internals/httpUtils';
15
+ import type { CallbackOrValue } from './internals/urlWithConnectionParams';
15
16
  import {
16
17
  resultOf,
17
18
  type UrlOptionsWithConnectionParams,
@@ -35,9 +36,9 @@ async function urlWithConnectionParams(
35
36
 
36
37
  type HTTPSubscriptionLinkOptions<TRoot extends AnyClientTypes> = {
37
38
  /**
38
- * EventSource options
39
+ * EventSource options or a callback that returns them
39
40
  */
40
- eventSourceOptions?: EventSourceInit;
41
+ eventSourceOptions?: CallbackOrValue<EventSourceInit>;
41
42
  } & TransformerOptions<TRoot> &
42
43
  UrlOptionsWithConnectionParams;
43
44
 
@@ -50,6 +51,7 @@ export function unstable_httpSubscriptionLink<
50
51
  opts: HTTPSubscriptionLinkOptions<inferClientTypes<TInferrable>>,
51
52
  ): TRPCLink<TInferrable> {
52
53
  const transformer = getTransformer(opts.transformer);
54
+
53
55
  return () => {
54
56
  return ({ op }) => {
55
57
  return observable((observer) => {
@@ -72,12 +74,13 @@ export function unstable_httpSubscriptionLink<
72
74
  signal: null,
73
75
  });
74
76
 
77
+ const eventSourceOptions = await resultOf(opts.eventSourceOptions);
75
78
  /* istanbul ignore if -- @preserve */
76
79
  if (unsubscribed) {
77
80
  // already unsubscribed - rare race condition
78
81
  return;
79
82
  }
80
- eventSource = new EventSource(url, opts.eventSourceOptions);
83
+ eventSource = new EventSource(url, eventSourceOptions);
81
84
  const onStarted = () => {
82
85
  observer.next({
83
86
  result: {
@@ -95,7 +98,7 @@ export function unstable_httpSubscriptionLink<
95
98
  eventSource.addEventListener('open', onStarted);
96
99
  const iterable = sseStreamConsumer<Partial<SSEMessage>>({
97
100
  from: eventSource,
98
- deserialize: transformer.input.deserialize,
101
+ deserialize: transformer.output.deserialize,
99
102
  });
100
103
 
101
104
  for await (const chunk of iterable) {
@@ -10,7 +10,7 @@ export const resultOf = <T>(value: T | (() => T)): T => {
10
10
  /**
11
11
  * A value that can be wrapped in callback
12
12
  */
13
- type CallbackOrValue<T> = T | (() => T | Promise<T>);
13
+ export type CallbackOrValue<T> = T | (() => T | Promise<T>);
14
14
 
15
15
  export interface UrlOptionsWithConnectionParams {
16
16
  /**