@trpc/client 11.0.0-next.92 → 11.0.0-rc.329
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/README.md +4 -4
- package/dist/TRPCClientError.d.ts +8 -7
- package/dist/TRPCClientError.d.ts.map +1 -1
- package/dist/{TRPCClientError-e224e397.js → TRPCClientError.js} +3 -3
- package/dist/{TRPCClientError-0de4d231.mjs → TRPCClientError.mjs} +4 -4
- package/dist/bundle-analysis.json +126 -155
- package/dist/createTRPCClient.d.ts +27 -19
- package/dist/createTRPCClient.d.ts.map +1 -1
- package/dist/createTRPCClient.js +50 -0
- package/dist/createTRPCClient.mjs +45 -0
- package/dist/createTRPCUntypedClient.d.ts +3 -2
- package/dist/createTRPCUntypedClient.d.ts.map +1 -1
- package/dist/createTRPCUntypedClient.js +10 -0
- package/dist/createTRPCUntypedClient.mjs +7 -0
- package/dist/getFetch.d.ts +1 -1
- package/dist/getFetch.d.ts.map +1 -1
- package/dist/getFetch.js +17 -0
- package/dist/getFetch.mjs +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -370
- package/dist/index.mjs +9 -354
- package/dist/internals/TRPCUntypedClient.d.ts +5 -30
- package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
- package/dist/internals/TRPCUntypedClient.js +85 -0
- package/dist/internals/TRPCUntypedClient.mjs +83 -0
- package/dist/internals/dataLoader.d.ts +1 -1
- package/dist/internals/dataLoader.d.ts.map +1 -1
- package/dist/{httpBatchLink-204206a5.mjs → internals/dataLoader.js} +2 -117
- package/dist/internals/dataLoader.mjs +131 -0
- package/dist/internals/getAbortController.d.ts +2 -2
- package/dist/internals/getAbortController.d.ts.map +1 -1
- package/dist/internals/getAbortController.js +18 -0
- package/dist/internals/getAbortController.mjs +16 -0
- package/dist/internals/transformer.d.ts +42 -0
- package/dist/internals/transformer.d.ts.map +1 -0
- package/dist/internals/transformer.js +30 -0
- package/dist/internals/transformer.mjs +28 -0
- package/dist/internals/types.d.ts +4 -2
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/links/HTTPBatchLinkOptions.d.ts +6 -5
- package/dist/links/HTTPBatchLinkOptions.d.ts.map +1 -1
- package/dist/links/httpBatchLink.d.ts +2 -2
- package/dist/links/httpBatchLink.d.ts.map +1 -1
- package/dist/links/httpBatchLink.js +37 -9
- package/dist/links/httpBatchLink.mjs +39 -5
- package/dist/links/httpBatchStreamLink.d.ts +6 -5
- package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
- package/dist/links/httpBatchStreamLink.js +43 -0
- package/dist/links/httpBatchStreamLink.mjs +41 -0
- package/dist/links/httpFormDataLink.d.ts +1 -1
- package/dist/links/httpFormDataLink.d.ts.map +1 -1
- package/dist/links/httpFormDataLink.js +31 -0
- package/dist/links/httpFormDataLink.mjs +29 -0
- package/dist/links/httpLink.d.ts +8 -8
- package/dist/links/httpLink.d.ts.map +1 -1
- package/dist/links/httpLink.js +6 -9
- package/dist/links/httpLink.mjs +6 -7
- package/dist/links/internals/createChain.d.ts +2 -2
- package/dist/links/internals/createChain.d.ts.map +1 -1
- package/dist/{splitLink-f29e84be.js → links/internals/createChain.js} +0 -22
- package/dist/{splitLink-4c75f7be.mjs → links/internals/createChain.mjs} +1 -22
- package/dist/links/internals/createHTTPBatchLink.d.ts +6 -6
- package/dist/links/internals/createHTTPBatchLink.d.ts.map +1 -1
- package/dist/links/internals/createHTTPBatchLink.js +85 -0
- package/dist/links/internals/createHTTPBatchLink.mjs +83 -0
- package/dist/links/internals/dedupeLink.d.ts +2 -2
- package/dist/links/internals/dedupeLink.d.ts.map +1 -1
- package/dist/links/internals/getTextDecoder.d.ts +1 -1
- package/dist/links/internals/getTextDecoder.d.ts.map +1 -1
- package/dist/links/internals/getTextDecoder.js +18 -0
- package/dist/links/internals/getTextDecoder.mjs +16 -0
- package/dist/links/internals/httpUtils.d.ts +19 -11
- package/dist/links/internals/httpUtils.d.ts.map +1 -1
- package/dist/{httpUtils-c0e7bf5a.js → links/internals/httpUtils.js} +20 -39
- package/dist/{httpUtils-f58ceda1.mjs → links/internals/httpUtils.mjs} +20 -38
- package/dist/links/internals/parseJSONStream.d.ts +5 -6
- package/dist/links/internals/parseJSONStream.d.ts.map +1 -1
- package/dist/links/internals/parseJSONStream.js +118 -0
- package/dist/links/internals/parseJSONStream.mjs +115 -0
- package/dist/links/internals/retryLink.d.ts +2 -2
- package/dist/links/internals/retryLink.d.ts.map +1 -1
- package/dist/links/loggerLink.d.ts +4 -4
- package/dist/links/loggerLink.d.ts.map +1 -1
- package/dist/links/loggerLink.js +6 -4
- package/dist/links/loggerLink.mjs +6 -2
- package/dist/links/splitLink.d.ts +2 -2
- package/dist/links/splitLink.d.ts.map +1 -1
- package/dist/links/splitLink.js +23 -6
- package/dist/links/splitLink.mjs +25 -2
- package/dist/links/types.d.ts +15 -14
- package/dist/links/types.d.ts.map +1 -1
- package/dist/links/wsLink.d.ts +44 -13
- package/dist/links/wsLink.d.ts.map +1 -1
- package/dist/links/wsLink.js +64 -24
- package/dist/links/wsLink.mjs +64 -22
- package/dist/links.d.ts +10 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/unstable-internals.d.ts +2 -0
- package/dist/unstable-internals.d.ts.map +1 -0
- package/dist/unstable-internals.js +7 -0
- package/dist/unstable-internals.mjs +1 -0
- package/package.json +26 -28
- package/src/TRPCClientError.ts +24 -13
- package/src/createTRPCClient.ts +58 -51
- package/src/createTRPCUntypedClient.ts +3 -5
- package/src/getFetch.ts +1 -1
- package/src/index.ts +2 -0
- package/src/internals/TRPCUntypedClient.ts +14 -84
- package/src/internals/dataLoader.ts +1 -1
- package/src/internals/getAbortController.ts +2 -2
- package/src/internals/transformer.ts +76 -0
- package/src/internals/types.ts +8 -1
- package/src/links/HTTPBatchLinkOptions.ts +17 -15
- package/src/links/httpBatchLink.ts +9 -8
- package/src/links/httpBatchStreamLink.ts +17 -17
- package/src/links/httpFormDataLink.ts +11 -12
- package/src/links/httpLink.ts +27 -19
- package/src/links/internals/createChain.ts +6 -2
- package/src/links/internals/createHTTPBatchLink.ts +24 -16
- package/src/links/internals/dedupeLink.ts +4 -3
- package/src/links/internals/getTextDecoder.ts +1 -1
- package/src/links/internals/httpUtils.ts +42 -21
- package/src/links/internals/parseJSONStream.ts +12 -14
- package/src/links/internals/retryLink.ts +4 -3
- package/src/links/loggerLink.ts +5 -5
- package/src/links/splitLink.ts +2 -2
- package/src/links/types.ts +27 -22
- package/src/links/wsLink.ts +124 -36
- package/src/links.ts +14 -0
- package/src/unstable-internals.ts +1 -0
- package/unstable-internals/index.d.ts +1 -0
- package/unstable-internals/index.js +1 -0
- package/dist/TRPCClientError-23c8aa93.js +0 -61
- package/dist/httpBatchLink-64fceaac.js +0 -251
- package/dist/httpBatchLink-92dab48e.js +0 -247
- package/dist/httpUtils-35e50476.js +0 -145
- package/dist/internals/isObject.d.ts +0 -2
- package/dist/internals/isObject.d.ts.map +0 -1
- package/dist/internals/retryDelay.d.ts +0 -2
- package/dist/internals/retryDelay.d.ts.map +0 -1
- package/dist/links/index.d.ts +0 -10
- package/dist/links/index.d.ts.map +0 -1
- package/dist/shared/index.d.ts +0 -2
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/index.js +0 -9
- package/dist/shared/index.mjs +0 -1
- package/dist/shared/transformResult.d.ts +0 -34
- package/dist/shared/transformResult.d.ts.map +0 -1
- package/dist/splitLink-0df96fdc.js +0 -41
- package/dist/transformResult-ace864b8.mjs +0 -58
- package/dist/transformResult-c1422cb5.js +0 -60
- package/dist/transformResult-dfce8f15.js +0 -61
- package/shared/index.d.ts +0 -1
- package/shared/index.js +0 -1
- package/src/internals/isObject.ts +0 -4
- package/src/internals/retryDelay.ts +0 -3
- package/src/links/index.ts +0 -14
- package/src/shared/index.ts +0 -1
- package/src/shared/transformResult.ts +0 -79
package/dist/links/splitLink.mjs
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
import '@trpc/server/observable';
|
|
2
|
-
|
|
1
|
+
import { observable } from '@trpc/server/observable';
|
|
2
|
+
import { createChain } from './internals/createChain.mjs';
|
|
3
|
+
|
|
4
|
+
function asArray(value) {
|
|
5
|
+
return Array.isArray(value) ? value : [
|
|
6
|
+
value
|
|
7
|
+
];
|
|
8
|
+
}
|
|
9
|
+
function splitLink(opts) {
|
|
10
|
+
return (runtime)=>{
|
|
11
|
+
const yes = asArray(opts.true).map((link)=>link(runtime));
|
|
12
|
+
const no = asArray(opts.false).map((link)=>link(runtime));
|
|
13
|
+
return (props)=>{
|
|
14
|
+
return observable((observer)=>{
|
|
15
|
+
const links = opts.condition(props.op) ? yes : no;
|
|
16
|
+
return createChain({
|
|
17
|
+
op: props.op,
|
|
18
|
+
links
|
|
19
|
+
}).subscribe(observer);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { splitLink };
|
package/dist/links/types.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { TRPCClientError } from '../TRPCClientError';
|
|
1
|
+
import type { Observable, Observer } from '@trpc/server/observable';
|
|
2
|
+
import type { InferrableClientTypes, TRPCResultMessage, TRPCSuccessResponse } from '@trpc/server/unstable-core-do-not-import';
|
|
3
|
+
import type { ResponseEsque } from '../internals/types';
|
|
4
|
+
import type { TRPCClientError } from '../TRPCClientError';
|
|
6
5
|
/**
|
|
7
6
|
* @internal
|
|
8
7
|
*/
|
|
@@ -29,18 +28,19 @@ export type Operation<TInput = unknown> = {
|
|
|
29
28
|
path: string;
|
|
30
29
|
context: OperationContext;
|
|
31
30
|
};
|
|
31
|
+
interface HeadersInitEsque {
|
|
32
|
+
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
33
|
+
}
|
|
32
34
|
/**
|
|
33
35
|
* @internal
|
|
34
36
|
*/
|
|
35
|
-
export type HTTPHeaders = Record<string, string[] | string | undefined>;
|
|
37
|
+
export type HTTPHeaders = HeadersInitEsque | Record<string, string[] | string | undefined>;
|
|
36
38
|
/**
|
|
37
39
|
* The default `fetch` implementation has an overloaded signature. By convention this library
|
|
38
40
|
* only uses the overload taking a string and options object.
|
|
39
41
|
*/
|
|
40
42
|
export type TRPCFetch = (url: string, options?: RequestInit) => Promise<ResponseEsque>;
|
|
41
43
|
export interface TRPCClientRuntime {
|
|
42
|
-
transformer: DataTransformer;
|
|
43
|
-
combinedTransformer: CombinedDataTransformer;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* @internal
|
|
@@ -52,20 +52,21 @@ export interface OperationResultEnvelope<TOutput> {
|
|
|
52
52
|
/**
|
|
53
53
|
* @internal
|
|
54
54
|
*/
|
|
55
|
-
export type OperationResultObservable<
|
|
55
|
+
export type OperationResultObservable<TInferrable extends InferrableClientTypes, TOutput> = Observable<OperationResultEnvelope<TOutput>, TRPCClientError<TInferrable>>;
|
|
56
56
|
/**
|
|
57
57
|
* @internal
|
|
58
58
|
*/
|
|
59
|
-
export type OperationResultObserver<
|
|
59
|
+
export type OperationResultObserver<TInferrable extends InferrableClientTypes, TOutput> = Observer<OperationResultEnvelope<TOutput>, TRPCClientError<TInferrable>>;
|
|
60
60
|
/**
|
|
61
61
|
* @internal
|
|
62
62
|
*/
|
|
63
|
-
export type OperationLink<
|
|
63
|
+
export type OperationLink<TInferrable extends InferrableClientTypes, TInput = unknown, TOutput = unknown> = (opts: {
|
|
64
64
|
op: Operation<TInput>;
|
|
65
|
-
next: (op: Operation<TInput>) => OperationResultObservable<
|
|
66
|
-
}) => OperationResultObservable<
|
|
65
|
+
next: (op: Operation<TInput>) => OperationResultObservable<TInferrable, TOutput>;
|
|
66
|
+
}) => OperationResultObservable<TInferrable, TOutput>;
|
|
67
67
|
/**
|
|
68
68
|
* @public
|
|
69
69
|
*/
|
|
70
|
-
export type TRPCLink<
|
|
70
|
+
export type TRPCLink<TInferrable extends InferrableClientTypes> = (opts: TRPCClientRuntime) => OperationLink<TInferrable>;
|
|
71
|
+
export {};
|
|
71
72
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/links/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/links/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI;IACrC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAG;AAEpE;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,MAAM,GAAG,OAAO,IAAI;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,gBAAgB,CAAC;CAC3B,CAAC;AAEF,UAAU,gBAAgB;IACxB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,gBAAgB,GAChB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,MAAM,WAAW,iBAAiB;CAEjC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB,CAAC,OAAO;IAC9C,MAAM,EACF,iBAAiB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,GACpC,mBAAmB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,CACnC,WAAW,SAAS,qBAAqB,EACzC,OAAO,IACL,UAAU,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,uBAAuB,CACjC,WAAW,SAAS,qBAAqB,EACzC,OAAO,IACL,QAAQ,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,aAAa,CACvB,WAAW,SAAS,qBAAqB,EACzC,MAAM,GAAG,OAAO,EAChB,OAAO,GAAG,OAAO,IACf,CAAC,IAAI,EAAE;IACT,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,EAAE,CACJ,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,KAClB,yBAAyB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;CACtD,KAAK,yBAAyB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,WAAW,SAAS,qBAAqB,IAAI,CAChE,IAAI,EAAE,iBAAiB,KACpB,aAAa,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/links/wsLink.d.ts
CHANGED
|
@@ -1,24 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TRPCResponseMessage } from '@trpc/server/rpc';
|
|
4
|
-
import { retryDelay } from '../internals/retryDelay';
|
|
1
|
+
import type { Observer, UnsubscribeFn } from '@trpc/server/observable';
|
|
2
|
+
import type { AnyRouter, inferClientTypes, inferRouterError, MaybePromise, TRPCResponseMessage } from '@trpc/server/unstable-core-do-not-import';
|
|
5
3
|
import { TRPCClientError } from '../TRPCClientError';
|
|
6
|
-
import {
|
|
4
|
+
import type { TransformerOptions } from '../unstable-internals';
|
|
5
|
+
import type { Operation, TRPCLink } from './types';
|
|
7
6
|
type WSCallbackResult<TRouter extends AnyRouter, TOutput> = TRPCResponseMessage<TOutput, inferRouterError<TRouter>>;
|
|
8
7
|
type WSCallbackObserver<TRouter extends AnyRouter, TOutput> = Observer<WSCallbackResult<TRouter, TOutput>, TRPCClientError<TRouter>>;
|
|
9
|
-
|
|
8
|
+
declare const exponentialBackoff: (attemptIndex: number) => number;
|
|
9
|
+
export interface WebSocketClientOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The URL to connect to (can be a function that returns a URL)
|
|
12
|
+
*/
|
|
10
13
|
url: string | (() => MaybePromise<string>);
|
|
14
|
+
/**
|
|
15
|
+
* Ponyfill which WebSocket implementation to use
|
|
16
|
+
*/
|
|
11
17
|
WebSocket?: typeof WebSocket;
|
|
12
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The number of milliseconds before a reconnect is attempted.
|
|
20
|
+
* @default {@link exponentialBackoff}
|
|
21
|
+
*/
|
|
22
|
+
retryDelayMs?: typeof exponentialBackoff;
|
|
23
|
+
/**
|
|
24
|
+
* Triggered when a WebSocket connection is established
|
|
25
|
+
*/
|
|
13
26
|
onOpen?: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Triggered when a WebSocket connection is closed
|
|
29
|
+
*/
|
|
14
30
|
onClose?: (cause?: {
|
|
15
31
|
code?: number;
|
|
16
32
|
}) => void;
|
|
17
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Lazy mode will close the WebSocket automatically after a period of inactivity (no messages sent or received and no pending requests)
|
|
35
|
+
*/
|
|
36
|
+
lazy?: {
|
|
37
|
+
/**
|
|
38
|
+
* Enable lazy mode
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
enabled: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Close the WebSocket after this many milliseconds
|
|
44
|
+
* @default 0
|
|
45
|
+
*/
|
|
46
|
+
closeMs: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
18
49
|
export declare function createWSClient(opts: WebSocketClientOptions): {
|
|
19
50
|
close: () => void;
|
|
20
51
|
request: (op: Operation, callbacks: WSCallbackObserver<AnyRouter, unknown>) => UnsubscribeFn;
|
|
21
|
-
|
|
52
|
+
readonly connection: ({
|
|
22
53
|
id: number;
|
|
23
54
|
} & ({
|
|
24
55
|
state: 'open';
|
|
@@ -32,12 +63,12 @@ export declare function createWSClient(opts: WebSocketClientOptions): {
|
|
|
32
63
|
})) | null;
|
|
33
64
|
};
|
|
34
65
|
export type TRPCWebSocketClient = ReturnType<typeof createWSClient>;
|
|
35
|
-
export
|
|
66
|
+
export type WebSocketLinkOptions<TRouter extends AnyRouter> = {
|
|
36
67
|
client: TRPCWebSocketClient;
|
|
37
|
-
}
|
|
68
|
+
} & TransformerOptions<inferClientTypes<TRouter>>;
|
|
38
69
|
/**
|
|
39
|
-
* @
|
|
70
|
+
* @link https://trpc.io/docs/v11/client/links/wsLink
|
|
40
71
|
*/
|
|
41
|
-
export declare function wsLink<TRouter extends AnyRouter>(opts: WebSocketLinkOptions): TRPCLink<TRouter>;
|
|
72
|
+
export declare function wsLink<TRouter extends AnyRouter>(opts: WebSocketLinkOptions<TRouter>): TRPCLink<TRouter>;
|
|
42
73
|
export {};
|
|
43
74
|
//# sourceMappingURL=wsLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsLink.d.ts","sourceRoot":"","sources":["../../src/links/wsLink.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"wsLink.d.ts","sourceRoot":"","sources":["../../src/links/wsLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EAMZ,mBAAmB,EACpB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInD,KAAK,gBAAgB,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO,IAAI,mBAAmB,CAC7E,OAAO,EACP,gBAAgB,CAAC,OAAO,CAAC,CAC1B,CAAC;AAEF,KAAK,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO,IAAI,QAAQ,CACpE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,EAClC,eAAe,CAAC,OAAO,CAAC,CACzB,CAAC;AAEF,QAAA,MAAM,kBAAkB,iBAAkB,MAAM,WACoB,CAAC;AAErE,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3C;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,kBAAkB,CAAC;IACzC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC9C;;OAEG;IACH,IAAI,CAAC,EAAE;QACL;;;WAGG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;;WAGG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAOD,wBAAgB,cAAc,CAAC,IAAI,EAAE,sBAAsB;;kBAgSpC,SAAS,wDAA0B,aAAa;;YAhP/D,MAAM;;eAGC,MAAM;YACT,SAAS;;eAGN,QAAQ;YACX,SAAS;;eAGN,YAAY;;;EAqS1B;AACD,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAEpE,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,SAAS,IAAI;IAC5D,MAAM,EAAE,mBAAmB,CAAC;CAC7B,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AASlD;;GAEG;AACH,wBAAgB,MAAM,CAAC,OAAO,SAAS,SAAS,EAC9C,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAClC,QAAQ,CAAC,OAAO,CAAC,CA8CnB"}
|
package/dist/links/wsLink.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var observable = require('@trpc/server/observable');
|
|
6
|
-
var
|
|
7
|
-
var TRPCClientError = require('../TRPCClientError
|
|
8
|
-
|
|
9
|
-
/* istanbul ignore next -- @preserve */ const retryDelay = (attemptIndex)=>attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);
|
|
4
|
+
var unstableCoreDoNotImport = require('@trpc/server/unstable-core-do-not-import');
|
|
5
|
+
var TRPCClientError = require('../TRPCClientError.js');
|
|
6
|
+
var transformer = require('../internals/transformer.js');
|
|
10
7
|
|
|
11
8
|
const run = (fn)=>fn();
|
|
9
|
+
const exponentialBackoff = (attemptIndex)=>attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);
|
|
10
|
+
const lazyDefaults = {
|
|
11
|
+
enabled: false,
|
|
12
|
+
closeMs: 0
|
|
13
|
+
};
|
|
12
14
|
function createWSClient(opts) {
|
|
13
|
-
const { url , WebSocket: WebSocketImpl = WebSocket , retryDelayMs: retryDelayFn =
|
|
15
|
+
const { url , WebSocket: WebSocketImpl = WebSocket , retryDelayMs: retryDelayFn = exponentialBackoff , onOpen , onClose , } = opts;
|
|
16
|
+
const lazyOpts = {
|
|
17
|
+
...lazyDefaults,
|
|
18
|
+
...opts.lazy
|
|
19
|
+
};
|
|
14
20
|
/* istanbul ignore next -- @preserve */ if (!WebSocketImpl) {
|
|
15
21
|
throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
|
|
16
22
|
}
|
|
@@ -21,13 +27,15 @@ function createWSClient(opts) {
|
|
|
21
27
|
let connectAttempt = 0;
|
|
22
28
|
let connectTimer = undefined;
|
|
23
29
|
let connectionIndex = 0;
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
* Global connection has been killed
|
|
27
|
-
*/ let killed = false;
|
|
30
|
+
let lazyDisconnectTimer = undefined;
|
|
31
|
+
let activeConnection = lazyOpts.enabled ? null : createConnection();
|
|
28
32
|
/**
|
|
29
33
|
* tries to send the list of messages
|
|
30
34
|
*/ function dispatch() {
|
|
35
|
+
if (!activeConnection) {
|
|
36
|
+
activeConnection = createConnection();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
31
39
|
// using a timeout to batch messages
|
|
32
40
|
setTimeout(()=>{
|
|
33
41
|
if (activeConnection?.state !== 'open') {
|
|
@@ -47,16 +55,29 @@ function createWSClient(opts) {
|
|
|
47
55
|
}
|
|
48
56
|
// clear
|
|
49
57
|
outgoing = [];
|
|
58
|
+
startLazyDisconnectTimer();
|
|
50
59
|
});
|
|
51
60
|
}
|
|
52
|
-
function tryReconnect() {
|
|
53
|
-
if (!!connectTimer
|
|
61
|
+
function tryReconnect(conn) {
|
|
62
|
+
if (!!connectTimer) {
|
|
54
63
|
return;
|
|
55
64
|
}
|
|
65
|
+
conn.state = 'connecting';
|
|
56
66
|
const timeout = retryDelayFn(connectAttempt++);
|
|
57
67
|
reconnectInMs(timeout);
|
|
58
68
|
}
|
|
69
|
+
function hasPendingRequests(conn) {
|
|
70
|
+
const requests = Object.values(pendingRequests);
|
|
71
|
+
if (!conn) {
|
|
72
|
+
return requests.length > 0;
|
|
73
|
+
}
|
|
74
|
+
return requests.some((req)=>req.connection === conn);
|
|
75
|
+
}
|
|
59
76
|
function reconnect() {
|
|
77
|
+
if (lazyOpts.enabled && !hasPendingRequests()) {
|
|
78
|
+
// Skip reconnecting if there are pending requests and we're in lazy mode
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
60
81
|
const oldConnection = activeConnection;
|
|
61
82
|
activeConnection = createConnection();
|
|
62
83
|
oldConnection && closeIfNoPending(oldConnection);
|
|
@@ -68,9 +89,8 @@ function createWSClient(opts) {
|
|
|
68
89
|
connectTimer = setTimeout(reconnect, ms);
|
|
69
90
|
}
|
|
70
91
|
function closeIfNoPending(conn) {
|
|
71
|
-
// disconnect as soon as there are are no pending
|
|
72
|
-
|
|
73
|
-
if (!hasPendingRequests) {
|
|
92
|
+
// disconnect as soon as there are are no pending requests
|
|
93
|
+
if (!hasPendingRequests(conn)) {
|
|
74
94
|
conn.ws?.close();
|
|
75
95
|
}
|
|
76
96
|
}
|
|
@@ -80,15 +100,31 @@ function createWSClient(opts) {
|
|
|
80
100
|
}
|
|
81
101
|
request(req.op, req.callbacks);
|
|
82
102
|
}
|
|
103
|
+
const startLazyDisconnectTimer = ()=>{
|
|
104
|
+
if (!lazyOpts.enabled) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
clearTimeout(lazyDisconnectTimer);
|
|
108
|
+
lazyDisconnectTimer = setTimeout(()=>{
|
|
109
|
+
if (!activeConnection) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!hasPendingRequests(activeConnection)) {
|
|
113
|
+
activeConnection.ws?.close();
|
|
114
|
+
activeConnection = null;
|
|
115
|
+
}
|
|
116
|
+
}, lazyOpts.closeMs);
|
|
117
|
+
};
|
|
83
118
|
function createConnection() {
|
|
84
119
|
const self = {
|
|
85
120
|
id: ++connectionIndex,
|
|
86
121
|
state: 'connecting'
|
|
87
122
|
};
|
|
123
|
+
clearTimeout(lazyDisconnectTimer);
|
|
88
124
|
const onError = ()=>{
|
|
89
125
|
self.state = 'closed';
|
|
90
126
|
if (self === activeConnection) {
|
|
91
|
-
tryReconnect();
|
|
127
|
+
tryReconnect(self);
|
|
92
128
|
}
|
|
93
129
|
};
|
|
94
130
|
run(async ()=>{
|
|
@@ -139,6 +175,7 @@ function createWSClient(opts) {
|
|
|
139
175
|
}
|
|
140
176
|
};
|
|
141
177
|
ws.addEventListener('message', ({ data })=>{
|
|
178
|
+
startLazyDisconnectTimer();
|
|
142
179
|
const msg = JSON.parse(data);
|
|
143
180
|
if ('method' in msg) {
|
|
144
181
|
handleIncomingRequest(msg);
|
|
@@ -159,7 +196,7 @@ function createWSClient(opts) {
|
|
|
159
196
|
self.state = 'closed';
|
|
160
197
|
if (activeConnection === self) {
|
|
161
198
|
// connection might have been replaced already
|
|
162
|
-
tryReconnect();
|
|
199
|
+
tryReconnect(self);
|
|
163
200
|
}
|
|
164
201
|
for (const [key, req] of Object.entries(pendingRequests)){
|
|
165
202
|
if (req.connection !== self) {
|
|
@@ -216,11 +253,12 @@ function createWSClient(opts) {
|
|
|
216
253
|
});
|
|
217
254
|
dispatch();
|
|
218
255
|
}
|
|
256
|
+
startLazyDisconnectTimer();
|
|
219
257
|
};
|
|
220
258
|
}
|
|
221
259
|
return {
|
|
222
260
|
close: ()=>{
|
|
223
|
-
|
|
261
|
+
connectAttempt = 0;
|
|
224
262
|
for (const req of Object.values(pendingRequests)){
|
|
225
263
|
if (req.type === 'subscription') {
|
|
226
264
|
req.callbacks.complete();
|
|
@@ -232,9 +270,10 @@ function createWSClient(opts) {
|
|
|
232
270
|
activeConnection && closeIfNoPending(activeConnection);
|
|
233
271
|
clearTimeout(connectTimer);
|
|
234
272
|
connectTimer = undefined;
|
|
273
|
+
activeConnection = null;
|
|
235
274
|
},
|
|
236
275
|
request,
|
|
237
|
-
|
|
276
|
+
get connection () {
|
|
238
277
|
return activeConnection;
|
|
239
278
|
}
|
|
240
279
|
};
|
|
@@ -247,14 +286,15 @@ class TRPCWebSocketClosedError extends Error {
|
|
|
247
286
|
}
|
|
248
287
|
}
|
|
249
288
|
/**
|
|
250
|
-
* @
|
|
289
|
+
* @link https://trpc.io/docs/v11/client/links/wsLink
|
|
251
290
|
*/ function wsLink(opts) {
|
|
252
|
-
|
|
291
|
+
const transformer$1 = transformer.getTransformer(opts.transformer);
|
|
292
|
+
return ()=>{
|
|
253
293
|
const { client } = opts;
|
|
254
294
|
return ({ op })=>{
|
|
255
295
|
return observable.observable((observer)=>{
|
|
256
296
|
const { type , path , id , context } = op;
|
|
257
|
-
const input =
|
|
297
|
+
const input = transformer$1.input.serialize(op.input);
|
|
258
298
|
const unsub = client.request({
|
|
259
299
|
type,
|
|
260
300
|
path,
|
|
@@ -270,7 +310,7 @@ class TRPCWebSocketClosedError extends Error {
|
|
|
270
310
|
observer.complete();
|
|
271
311
|
},
|
|
272
312
|
next (message) {
|
|
273
|
-
const transformed =
|
|
313
|
+
const transformed = unstableCoreDoNotImport.transformResult(message, transformer$1.output);
|
|
274
314
|
if (!transformed.ok) {
|
|
275
315
|
observer.error(TRPCClientError.TRPCClientError.from(transformed.error));
|
|
276
316
|
return;
|
package/dist/links/wsLink.mjs
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { observable } from '@trpc/server/observable';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
/* istanbul ignore next -- @preserve */ const retryDelay = (attemptIndex)=>attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);
|
|
2
|
+
import { transformResult } from '@trpc/server/unstable-core-do-not-import';
|
|
3
|
+
import { TRPCClientError } from '../TRPCClientError.mjs';
|
|
4
|
+
import { getTransformer } from '../internals/transformer.mjs';
|
|
6
5
|
|
|
7
6
|
const run = (fn)=>fn();
|
|
7
|
+
const exponentialBackoff = (attemptIndex)=>attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);
|
|
8
|
+
const lazyDefaults = {
|
|
9
|
+
enabled: false,
|
|
10
|
+
closeMs: 0
|
|
11
|
+
};
|
|
8
12
|
function createWSClient(opts) {
|
|
9
|
-
const { url , WebSocket: WebSocketImpl = WebSocket , retryDelayMs: retryDelayFn =
|
|
13
|
+
const { url , WebSocket: WebSocketImpl = WebSocket , retryDelayMs: retryDelayFn = exponentialBackoff , onOpen , onClose , } = opts;
|
|
14
|
+
const lazyOpts = {
|
|
15
|
+
...lazyDefaults,
|
|
16
|
+
...opts.lazy
|
|
17
|
+
};
|
|
10
18
|
/* istanbul ignore next -- @preserve */ if (!WebSocketImpl) {
|
|
11
19
|
throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
|
|
12
20
|
}
|
|
@@ -17,13 +25,15 @@ function createWSClient(opts) {
|
|
|
17
25
|
let connectAttempt = 0;
|
|
18
26
|
let connectTimer = undefined;
|
|
19
27
|
let connectionIndex = 0;
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
* Global connection has been killed
|
|
23
|
-
*/ let killed = false;
|
|
28
|
+
let lazyDisconnectTimer = undefined;
|
|
29
|
+
let activeConnection = lazyOpts.enabled ? null : createConnection();
|
|
24
30
|
/**
|
|
25
31
|
* tries to send the list of messages
|
|
26
32
|
*/ function dispatch() {
|
|
33
|
+
if (!activeConnection) {
|
|
34
|
+
activeConnection = createConnection();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
27
37
|
// using a timeout to batch messages
|
|
28
38
|
setTimeout(()=>{
|
|
29
39
|
if (activeConnection?.state !== 'open') {
|
|
@@ -43,16 +53,29 @@ function createWSClient(opts) {
|
|
|
43
53
|
}
|
|
44
54
|
// clear
|
|
45
55
|
outgoing = [];
|
|
56
|
+
startLazyDisconnectTimer();
|
|
46
57
|
});
|
|
47
58
|
}
|
|
48
|
-
function tryReconnect() {
|
|
49
|
-
if (!!connectTimer
|
|
59
|
+
function tryReconnect(conn) {
|
|
60
|
+
if (!!connectTimer) {
|
|
50
61
|
return;
|
|
51
62
|
}
|
|
63
|
+
conn.state = 'connecting';
|
|
52
64
|
const timeout = retryDelayFn(connectAttempt++);
|
|
53
65
|
reconnectInMs(timeout);
|
|
54
66
|
}
|
|
67
|
+
function hasPendingRequests(conn) {
|
|
68
|
+
const requests = Object.values(pendingRequests);
|
|
69
|
+
if (!conn) {
|
|
70
|
+
return requests.length > 0;
|
|
71
|
+
}
|
|
72
|
+
return requests.some((req)=>req.connection === conn);
|
|
73
|
+
}
|
|
55
74
|
function reconnect() {
|
|
75
|
+
if (lazyOpts.enabled && !hasPendingRequests()) {
|
|
76
|
+
// Skip reconnecting if there are pending requests and we're in lazy mode
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
56
79
|
const oldConnection = activeConnection;
|
|
57
80
|
activeConnection = createConnection();
|
|
58
81
|
oldConnection && closeIfNoPending(oldConnection);
|
|
@@ -64,9 +87,8 @@ function createWSClient(opts) {
|
|
|
64
87
|
connectTimer = setTimeout(reconnect, ms);
|
|
65
88
|
}
|
|
66
89
|
function closeIfNoPending(conn) {
|
|
67
|
-
// disconnect as soon as there are are no pending
|
|
68
|
-
|
|
69
|
-
if (!hasPendingRequests) {
|
|
90
|
+
// disconnect as soon as there are are no pending requests
|
|
91
|
+
if (!hasPendingRequests(conn)) {
|
|
70
92
|
conn.ws?.close();
|
|
71
93
|
}
|
|
72
94
|
}
|
|
@@ -76,15 +98,31 @@ function createWSClient(opts) {
|
|
|
76
98
|
}
|
|
77
99
|
request(req.op, req.callbacks);
|
|
78
100
|
}
|
|
101
|
+
const startLazyDisconnectTimer = ()=>{
|
|
102
|
+
if (!lazyOpts.enabled) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
clearTimeout(lazyDisconnectTimer);
|
|
106
|
+
lazyDisconnectTimer = setTimeout(()=>{
|
|
107
|
+
if (!activeConnection) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (!hasPendingRequests(activeConnection)) {
|
|
111
|
+
activeConnection.ws?.close();
|
|
112
|
+
activeConnection = null;
|
|
113
|
+
}
|
|
114
|
+
}, lazyOpts.closeMs);
|
|
115
|
+
};
|
|
79
116
|
function createConnection() {
|
|
80
117
|
const self = {
|
|
81
118
|
id: ++connectionIndex,
|
|
82
119
|
state: 'connecting'
|
|
83
120
|
};
|
|
121
|
+
clearTimeout(lazyDisconnectTimer);
|
|
84
122
|
const onError = ()=>{
|
|
85
123
|
self.state = 'closed';
|
|
86
124
|
if (self === activeConnection) {
|
|
87
|
-
tryReconnect();
|
|
125
|
+
tryReconnect(self);
|
|
88
126
|
}
|
|
89
127
|
};
|
|
90
128
|
run(async ()=>{
|
|
@@ -135,6 +173,7 @@ function createWSClient(opts) {
|
|
|
135
173
|
}
|
|
136
174
|
};
|
|
137
175
|
ws.addEventListener('message', ({ data })=>{
|
|
176
|
+
startLazyDisconnectTimer();
|
|
138
177
|
const msg = JSON.parse(data);
|
|
139
178
|
if ('method' in msg) {
|
|
140
179
|
handleIncomingRequest(msg);
|
|
@@ -155,7 +194,7 @@ function createWSClient(opts) {
|
|
|
155
194
|
self.state = 'closed';
|
|
156
195
|
if (activeConnection === self) {
|
|
157
196
|
// connection might have been replaced already
|
|
158
|
-
tryReconnect();
|
|
197
|
+
tryReconnect(self);
|
|
159
198
|
}
|
|
160
199
|
for (const [key, req] of Object.entries(pendingRequests)){
|
|
161
200
|
if (req.connection !== self) {
|
|
@@ -212,11 +251,12 @@ function createWSClient(opts) {
|
|
|
212
251
|
});
|
|
213
252
|
dispatch();
|
|
214
253
|
}
|
|
254
|
+
startLazyDisconnectTimer();
|
|
215
255
|
};
|
|
216
256
|
}
|
|
217
257
|
return {
|
|
218
258
|
close: ()=>{
|
|
219
|
-
|
|
259
|
+
connectAttempt = 0;
|
|
220
260
|
for (const req of Object.values(pendingRequests)){
|
|
221
261
|
if (req.type === 'subscription') {
|
|
222
262
|
req.callbacks.complete();
|
|
@@ -228,9 +268,10 @@ function createWSClient(opts) {
|
|
|
228
268
|
activeConnection && closeIfNoPending(activeConnection);
|
|
229
269
|
clearTimeout(connectTimer);
|
|
230
270
|
connectTimer = undefined;
|
|
271
|
+
activeConnection = null;
|
|
231
272
|
},
|
|
232
273
|
request,
|
|
233
|
-
|
|
274
|
+
get connection () {
|
|
234
275
|
return activeConnection;
|
|
235
276
|
}
|
|
236
277
|
};
|
|
@@ -243,14 +284,15 @@ class TRPCWebSocketClosedError extends Error {
|
|
|
243
284
|
}
|
|
244
285
|
}
|
|
245
286
|
/**
|
|
246
|
-
* @
|
|
287
|
+
* @link https://trpc.io/docs/v11/client/links/wsLink
|
|
247
288
|
*/ function wsLink(opts) {
|
|
248
|
-
|
|
289
|
+
const transformer = getTransformer(opts.transformer);
|
|
290
|
+
return ()=>{
|
|
249
291
|
const { client } = opts;
|
|
250
292
|
return ({ op })=>{
|
|
251
293
|
return observable((observer)=>{
|
|
252
294
|
const { type , path , id , context } = op;
|
|
253
|
-
const input =
|
|
295
|
+
const input = transformer.input.serialize(op.input);
|
|
254
296
|
const unsub = client.request({
|
|
255
297
|
type,
|
|
256
298
|
path,
|
|
@@ -266,7 +308,7 @@ class TRPCWebSocketClosedError extends Error {
|
|
|
266
308
|
observer.complete();
|
|
267
309
|
},
|
|
268
310
|
next (message) {
|
|
269
|
-
const transformed = transformResult(message,
|
|
311
|
+
const transformed = transformResult(message, transformer.output);
|
|
270
312
|
if (!transformed.ok) {
|
|
271
313
|
observer.error(TRPCClientError.from(transformed.error));
|
|
272
314
|
return;
|
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './links/types';
|
|
2
|
+
export * from './links/HTTPBatchLinkOptions';
|
|
3
|
+
export * from './links/httpBatchLink';
|
|
4
|
+
export * from './links/httpBatchStreamLink';
|
|
5
|
+
export * from './links/httpLink';
|
|
6
|
+
export * from './links/loggerLink';
|
|
7
|
+
export * from './links/splitLink';
|
|
8
|
+
export * from './links/wsLink';
|
|
9
|
+
export * from './links/httpFormDataLink';
|
|
10
|
+
//# sourceMappingURL=links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAE9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unstable-internals.d.ts","sourceRoot":"","sources":["../src/unstable-internals.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getTransformer } from './internals/transformer.mjs';
|