@trpc/client 10.0.0-alpha.15 → 10.0.0-alpha.16
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1086 -23
- package/dist/index.mjs +1069 -18
- package/dist/internals/TRPCClient.d.ts +3 -3
- package/dist/internals/TRPCClient.d.ts.map +1 -1
- package/dist/links/httpBatchLink.d.ts +1 -1
- package/dist/links/httpBatchLink.d.ts.map +1 -1
- package/dist/links/httpLink.d.ts +1 -1
- package/dist/links/httpLink.d.ts.map +1 -1
- package/dist/links/index.d.ts +11 -0
- package/dist/links/index.d.ts.map +1 -0
- package/dist/links/{httpUtils.d.ts → internals/httpUtils.d.ts} +1 -1
- package/dist/links/internals/httpUtils.d.ts.map +1 -0
- package/dist/links/transformerLink.d.ts.map +1 -1
- package/dist/links/types.d.ts +1 -1
- package/dist/links/types.d.ts.map +1 -1
- package/dist/links/wsLink.d.ts +1 -1
- package/dist/links/wsLink.d.ts.map +1 -1
- package/dist/observable/index.d.ts +4 -0
- package/dist/observable/index.d.ts.map +1 -0
- package/dist/{rx/operators → observable}/index.js +3 -3
- package/dist/{rx/operators → observable}/index.mjs +1 -2
- package/dist/{rx → observable}/index.ts.js +0 -0
- package/dist/{rx/util → observable/internals}/identity.d.ts +0 -0
- package/dist/observable/internals/identity.d.ts.map +1 -0
- package/dist/{rx/util → observable/internals}/observableToPromise.d.ts +0 -0
- package/dist/observable/internals/observableToPromise.d.ts.map +1 -0
- package/dist/{rx/util → observable/internals}/pipe.d.ts +0 -0
- package/dist/observable/internals/pipe.d.ts.map +1 -0
- package/dist/{rx → observable}/observable.d.ts +0 -0
- package/dist/observable/observable.d.ts.map +1 -0
- package/dist/{rx → observable}/operators/index.d.ts +0 -0
- package/dist/observable/operators/index.d.ts.map +1 -0
- package/dist/{rx → observable}/operators/map.d.ts +0 -0
- package/dist/observable/operators/map.d.ts.map +1 -0
- package/dist/{rx → observable}/operators/share.d.ts +0 -0
- package/dist/observable/operators/share.d.ts.map +1 -0
- package/dist/{rx → observable}/operators/tap.d.ts +0 -0
- package/dist/observable/operators/tap.d.ts.map +1 -0
- package/dist/{rx → observable}/types.d.ts +0 -0
- package/dist/observable/types.d.ts.map +1 -0
- package/dist/{share-671b63fa.mjs → tap-4bc60fb0.mjs} +131 -1
- package/dist/{share-4d79dc49.js → tap-fcd41ae6.js} +132 -0
- package/package.json +4 -4
- package/src/index.ts +1 -1
- package/src/internals/TRPCClient.ts +7 -10
- package/src/links/dedupeLink.test.ts +1 -1
- package/src/links/dedupeLink.ts +5 -5
- package/src/links/httpBatchLink.ts +6 -2
- package/src/links/httpLink.ts +2 -2
- package/src/links/index.ts +10 -0
- package/src/links/internals/createChain.test.ts +5 -5
- package/src/links/internals/createChain.ts +3 -3
- package/src/links/{httpUtils.ts → internals/httpUtils.ts} +1 -1
- package/src/links/loggerLink.ts +2 -2
- package/src/links/retryLink.ts +2 -2
- package/src/links/splitLink.test.ts +1 -1
- package/src/links/splitLink.ts +1 -1
- package/src/links/transformerLink.ts +9 -5
- package/src/links/types.ts +1 -1
- package/src/links/wsLink.ts +1 -2
- package/src/{rx → observable}/index.ts +1 -0
- package/src/{rx/util → observable/internals}/identity.ts +0 -0
- package/src/{rx/util → observable/internals}/observableToPromise.ts +0 -0
- package/src/{rx/util → observable/internals}/pipe.ts +0 -0
- package/src/{rx → observable}/observable.test.ts +21 -1
- package/src/{rx → observable}/observable.ts +1 -1
- package/src/{rx → observable}/operators/index.ts +0 -0
- package/src/{rx → observable}/operators/map.test.ts +0 -0
- package/src/{rx → observable}/operators/map.ts +0 -0
- package/src/{rx → observable}/operators/share.test.ts +0 -0
- package/src/{rx → observable}/operators/share.ts +0 -0
- package/src/{rx → observable}/operators/tap.ts +0 -0
- package/src/{rx → observable}/types.ts +0 -0
- package/dist/TRPCClientError-17b117e1.mjs +0 -81
- package/dist/TRPCClientError-ec6bd2ca.js +0 -94
- package/dist/createChain-389cc116.mjs +0 -25
- package/dist/createChain-864dbb30.js +0 -27
- package/dist/httpUtils-1f9e4e3c.js +0 -97
- package/dist/httpUtils-c09d7b79.mjs +0 -91
- package/dist/links/httpBatchLink.js +0 -195
- package/dist/links/httpBatchLink.mjs +0 -191
- package/dist/links/httpBatchLink.ts.js +0 -1
- package/dist/links/httpLink.js +0 -44
- package/dist/links/httpLink.mjs +0 -40
- package/dist/links/httpLink.ts.js +0 -1
- package/dist/links/httpUtils.d.ts.map +0 -1
- package/dist/links/loggerLink.js +0 -108
- package/dist/links/loggerLink.mjs +0 -99
- package/dist/links/loggerLink.ts.js +0 -1
- package/dist/links/splitLink.js +0 -32
- package/dist/links/splitLink.mjs +0 -28
- package/dist/links/splitLink.ts.js +0 -1
- package/dist/links/transformerLink.js +0 -75
- package/dist/links/transformerLink.mjs +0 -67
- package/dist/links/transformerLink.ts.js +0 -1
- package/dist/links/wsLink.js +0 -385
- package/dist/links/wsLink.mjs +0 -370
- package/dist/links/wsLink.ts.js +0 -1
- package/dist/observable-7e66cb56.mjs +0 -102
- package/dist/observable-85669100.js +0 -104
- package/dist/rx/index.d.ts +0 -3
- package/dist/rx/index.d.ts.map +0 -1
- package/dist/rx/index.js +0 -9
- package/dist/rx/index.mjs +0 -1
- package/dist/rx/observable.d.ts.map +0 -1
- package/dist/rx/operators/index.d.ts.map +0 -1
- package/dist/rx/operators/index.ts.js +0 -1
- package/dist/rx/operators/map.d.ts.map +0 -1
- package/dist/rx/operators/share.d.ts.map +0 -1
- package/dist/rx/operators/tap.d.ts.map +0 -1
- package/dist/rx/types.d.ts.map +0 -1
- package/dist/rx/util/identity.d.ts.map +0 -1
- package/dist/rx/util/observableToPromise.d.ts.map +0 -1
- package/dist/rx/util/pipe.d.ts.map +0 -1
- package/dist/tap-538fa07f.mjs +0 -30
- package/dist/tap-799a2d33.js +0 -32
- package/links/httpBatchLink/index.d.ts +0 -1
- package/links/httpBatchLink/index.js +0 -1
- package/links/httpLink/index.d.ts +0 -1
- package/links/httpLink/index.js +0 -1
- package/links/loggerLink/index.d.ts +0 -1
- package/links/loggerLink/index.js +0 -1
- package/links/splitLink/index.d.ts +0 -1
- package/links/splitLink/index.js +0 -1
- package/links/transformerLink/index.d.ts +0 -1
- package/links/transformerLink/index.js +0 -1
- package/links/wsLink/index.d.ts +0 -1
- package/links/wsLink/index.js +0 -1
- package/rx/index.d.ts +0 -1
- package/rx/index.js +0 -1
- package/rx/operators/index.d.ts +0 -1
- package/rx/operators/index.js +0 -1
|
@@ -2,8 +2,8 @@ import { AnyRouter, inferHandlerInput, inferProcedureInput, inferSubscriptionOut
|
|
|
2
2
|
import { TRPCResult } from '@trpc/server/rpc';
|
|
3
3
|
import { CancelFn } from '..';
|
|
4
4
|
import { HTTPHeaders, LinkRuntime, OperationContext, TRPCLink } from '../links/types';
|
|
5
|
-
import {
|
|
6
|
-
import { Observer } from '../
|
|
5
|
+
import { Unsubscribable } from '../observable';
|
|
6
|
+
import { Observer } from '../observable/types';
|
|
7
7
|
import { TRPCClientError } from '../TRPCClientError';
|
|
8
8
|
declare type CancellablePromise<T = unknown> = Promise<T> & {
|
|
9
9
|
cancel: CancelFn;
|
|
@@ -59,7 +59,7 @@ export declare class TRPCClient<TRouter extends AnyRouter> {
|
|
|
59
59
|
private requestAsPromise;
|
|
60
60
|
query<TQueries extends TRouter['_def']['queries'], TPath extends string & keyof TQueries>(path: TPath, ...args: [...inferHandlerInput<TQueries[TPath]>, TRPCRequestOptions?]): CancellablePromise<import("@trpc/server").ThenArg<ReturnType<TQueries[TPath]["call"]>>>;
|
|
61
61
|
mutation<TMutations extends TRouter['_def']['mutations'], TPath extends string & keyof TMutations>(path: TPath, ...args: [...inferHandlerInput<TMutations[TPath]>, TRPCRequestOptions?]): CancellablePromise<import("@trpc/server").ThenArg<ReturnType<TMutations[TPath]["call"]>>>;
|
|
62
|
-
subscription<TSubscriptions extends TRouter['_def']['subscriptions'], TPath extends string & keyof TSubscriptions, TOutput extends inferSubscriptionOutput<TRouter, TPath>, TInput extends inferProcedureInput<TSubscriptions[TPath]>>(path: TPath, input: TInput, opts: TRPCRequestOptions & Partial<Observer<TRPCResult<TOutput>, TRPCClientError<TRouter>>>):
|
|
62
|
+
subscription<TSubscriptions extends TRouter['_def']['subscriptions'], TPath extends string & keyof TSubscriptions, TOutput extends inferSubscriptionOutput<TRouter, TPath>, TInput extends inferProcedureInput<TSubscriptions[TPath]>>(path: TPath, input: TInput, opts: TRPCRequestOptions & Partial<Observer<TRPCResult<TOutput>, TRPCClientError<TRouter>>>): Unsubscribable;
|
|
63
63
|
}
|
|
64
64
|
export {};
|
|
65
65
|
//# sourceMappingURL=TRPCClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EAEnB,uBAAuB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAK9B,OAAO,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EAEhB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"TRPCClient.d.ts","sourceRoot":"","sources":["../../src/internals/TRPCClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EAEnB,uBAAuB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAK9B,OAAO,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EAEhB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE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EAAE,uBAAuB,CAAC,OAAO,CAAC;IA4BlD,OAAO,CAAC,QAAQ;IAuBhB,OAAO,CAAC,gBAAgB;IA8BjB,KAAK,CACV,QAAQ,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAC3C,KAAK,SAAS,MAAM,GAAG,MAAM,QAAQ,EAErC,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,CAAC,GAAG,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAchE,QAAQ,CACb,UAAU,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,EAC/C,KAAK,SAAS,MAAM,GAAG,MAAM,UAAU,EAEvC,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,CAAC,GAAG,iBAAiB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC;IAalE,YAAY,CACjB,cAAc,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,EACvD,KAAK,SAAS,MAAM,GAAG,MAAM,cAAc,EAC3C,OAAO,SAAS,uBAAuB,CAAC,OAAO,EAAE,KAAK,CAAC,EACvD,MAAM,SAAS,mBAAmB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAEzD,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,kBAAkB,GACtB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,GACjE,cAAc;CA2BlB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyRouter } from '@trpc/server';
|
|
2
2
|
import { TRPCLink } from './types';
|
|
3
|
-
import { HTTPLinkOptions } from './httpUtils';
|
|
3
|
+
import { HTTPLinkOptions } from './internals/httpUtils';
|
|
4
4
|
export interface HttpBatchLinkOptions extends HTTPLinkOptions {
|
|
5
5
|
maxBatchSize?: number;
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,
|
|
1
|
+
{"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AACD,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,EACrD,IAAI,EAAE,oBAAoB,GACzB,QAAQ,CAAC,OAAO,CAAC,CA+DnB"}
|
package/dist/links/httpLink.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyRouter } from '@trpc/server';
|
|
2
2
|
import { TRPCLink } from './types';
|
|
3
|
-
import { HTTPLinkOptions } from './httpUtils';
|
|
3
|
+
import { HTTPLinkOptions } from './internals/httpUtils';
|
|
4
4
|
export declare function httpLink<TRouter extends AnyRouter>(opts: HTTPLinkOptions): TRPCLink<TRouter>;
|
|
5
5
|
//# sourceMappingURL=httpLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,eAAe,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAC;AAErE,wBAAgB,QAAQ,CAAC,OAAO,SAAS,SAAS,EAChD,IAAI,EAAE,eAAe,GACpB,QAAQ,CAAC,OAAO,CAAC,CA2BnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './dedupeLink';
|
|
2
|
+
export * from './httpBatchLink';
|
|
3
|
+
export * from './httpLink';
|
|
4
|
+
export * from './loggerLink';
|
|
5
|
+
export * from './loggerLink';
|
|
6
|
+
export * from './retryLink';
|
|
7
|
+
export * from './splitLink';
|
|
8
|
+
export * from './transformerLink';
|
|
9
|
+
export * from './wsLink';
|
|
10
|
+
export * from './types';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/links/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpUtils.d.ts","sourceRoot":"","sources":["../../../src/links/internals/httpUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACzD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;CACb;AAiBD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,QAAQ,EAAE,QAAQ,CAAC;KACpB,CAAC;CACH;AACD,wBAAgB,WAAW,CACzB,KAAK,EAAE;IACL,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,CAAC;IAAE,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,GAC/C,gBAAgB,CAAC,aAAa,CAAC,CA2DjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformerLink.d.ts","sourceRoot":"","sources":["../../src/links/transformerLink.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,4BAA4B,EAE7B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAmB,QAAQ,EAAE,MAAM,SAAS,CAAC;AAgCpD,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EACnE,WAAW,EAAE,4BAA4B,GACxC,QAAQ,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"transformerLink.d.ts","sourceRoot":"","sources":["../../src/links/transformerLink.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,4BAA4B,EAE7B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAmB,QAAQ,EAAE,MAAM,SAAS,CAAC;AAgCpD,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EACnE,WAAW,EAAE,4BAA4B,GACxC,QAAQ,CAAC,OAAO,CAAC,CAiCnB"}
|
package/dist/links/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyRouter, inferRouterError, Dict } from '@trpc/server';
|
|
2
2
|
import { TRPCResponse } from '@trpc/server/rpc';
|
|
3
|
-
import { Observable, Observer } from '../
|
|
3
|
+
import { Observable, Observer } from '../observable/types';
|
|
4
4
|
import { TRPCClientError } from '../TRPCClientError';
|
|
5
5
|
export declare type CancelFn = () => void;
|
|
6
6
|
export declare type PromiseAndCancel<TValue> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/links/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/links/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,oBAAY,QAAQ,GAAG,MAAM,IAAI,CAAC;AAElC,oBAAY,gBAAgB,CAAC,MAAM,IAAI;IACrC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF,oBAAY,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACvD,oBAAY,SAAS,CAAC,MAAM,GAAG,OAAO,IAAI;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;IAC5C,K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AC,CAAC;CAC9E,KAAK,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAElD,oBAAY,QAAQ,CAAC,OAAO,SAAS,SAAS,IAAI,CAChD,IAAI,EAAE,WAAW,KACd,aAAa,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/links/wsLink.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyRouter } from '@trpc/server';
|
|
2
2
|
import { retryDelay } from '../internals/retryDelay';
|
|
3
|
-
import { UnsubscribeFn } from '../
|
|
3
|
+
import { UnsubscribeFn } from '../observable';
|
|
4
4
|
import { Operation, OperationResultObserver, TRPCLink } from './types';
|
|
5
5
|
export interface WebSocketClientOptions {
|
|
6
6
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsLink.d.ts","sourceRoot":"","sources":["../../src/links/wsLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAOxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"wsLink.d.ts","sourceRoot":"","sources":["../../src/links/wsLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAOxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAc,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEvE,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,UAAU,CAAC;CAClC;AACD,wBAAgB,cAAc,CAAC,IAAI,EAAE,sBAAsB;;kBA8LpC,SAAS,kEAA0B,aAAa;;EAgDtE;AACD,oBAAY,mBAAmB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAEpE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAiBD,wBAAgB,MAAM,CAAC,OAAO,SAAS,SAAS,EAC9C,IAAI,EAAE,oBAAoB,GACzB,QAAQ,CAAC,OAAO,CAAC,CAkDnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observable/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var tap = require('../../tap-799a2d33.js');
|
|
5
|
+
var tap = require('../tap-fcd41ae6.js');
|
|
7
6
|
|
|
8
7
|
function map(project) {
|
|
9
8
|
return function (originalObserver) {
|
|
@@ -33,6 +32,7 @@ function map(project) {
|
|
|
33
32
|
};
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
exports.
|
|
35
|
+
exports.observable = tap.observable;
|
|
36
|
+
exports.share = tap.share;
|
|
37
37
|
exports.tap = tap.tap;
|
|
38
38
|
exports.map = map;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/observable/internals/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAEnC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observableToPromise.d.ts","sourceRoot":"","sources":["../../../src/observable/internals/observableToPromise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAK5B;AAED,gBAAgB;AAChB,wBAAgB,mBAAmB,CAAC,MAAM,EACxC,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC;;iBAEtB,IAAI;EAkCtB"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../../src/observable/internals/pipe.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAChC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAC9B,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAerB"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../../src/observable/observable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAC;AAEhF,oBAAY,oBAAoB,CAAC,WAAW,SAAS,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,IACvE,WAAW,SAAS,UAAU,CAAC,MAAM,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC;AAErE,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EACjD,SAAS,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,aAAa,GAC/D,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CA6D5B"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/observable/operators/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/observable/operators/map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAgB,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EACnD,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,GAC3D,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAoB7D"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share.d.ts","sourceRoot":"","sources":["../../../src/observable/operators/share.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAA4B,MAAM,UAAU,CAAC;AAG9E,UAAU,WAAW;CAAG;AACxB,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAElC,KAAK,CAAC,EAAE,WAAW,GAClB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CA2D1C"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../../src/observable/operators/tap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE9D,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC1C,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CAqB1C"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/observable/types.ts"],"names":[],"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AAE,MAAM;IACtC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,oBAAY,aAAa,GAEvB,cAAc,GAAG,aAAa,GAAG,IAAI,CAAC;AAExC,oBAAY,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;AAEnD,oBAAY,gBAAgB,CAC1B,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,IACT,aAAa,CACf,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,EACxC,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,CACvC,CAAC;AAEF,oBAAY,wBAAwB,CAAC,MAAM,EAAE,MAAM,IAAI,gBAAgB,CACrE,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,CACP,CAAC"}
|
|
@@ -1,3 +1,104 @@
|
|
|
1
|
+
function identity(x) {
|
|
2
|
+
return x;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/** @internal */
|
|
6
|
+
function pipeFromArray(fns) {
|
|
7
|
+
if (fns.length === 0) {
|
|
8
|
+
return identity;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (fns.length === 1) {
|
|
12
|
+
return fns[0];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return function piped(input) {
|
|
16
|
+
return fns.reduce(function (prev, fn) {
|
|
17
|
+
return fn(prev);
|
|
18
|
+
}, input);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function observable(_subscribe) {
|
|
23
|
+
var self = {
|
|
24
|
+
subscribe: function subscribe(observer) {
|
|
25
|
+
var teardownRef = null;
|
|
26
|
+
var isDone = false;
|
|
27
|
+
var unsubscribed = false;
|
|
28
|
+
var teardownImmediately = false;
|
|
29
|
+
|
|
30
|
+
function unsubscribe() {
|
|
31
|
+
if (teardownRef === null) {
|
|
32
|
+
teardownImmediately = true;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (unsubscribed) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
unsubscribed = true;
|
|
41
|
+
|
|
42
|
+
if (typeof teardownRef === 'function') {
|
|
43
|
+
teardownRef();
|
|
44
|
+
} else if (teardownRef) {
|
|
45
|
+
teardownRef.unsubscribe();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
teardownRef = _subscribe({
|
|
50
|
+
next: function next(value) {
|
|
51
|
+
var _observer$next;
|
|
52
|
+
|
|
53
|
+
if (isDone) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
(_observer$next = observer.next) === null || _observer$next === void 0 ? void 0 : _observer$next.call(observer, value);
|
|
58
|
+
},
|
|
59
|
+
error: function error(err) {
|
|
60
|
+
var _observer$error;
|
|
61
|
+
|
|
62
|
+
if (isDone) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
isDone = true;
|
|
67
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, err);
|
|
68
|
+
unsubscribe();
|
|
69
|
+
},
|
|
70
|
+
complete: function complete() {
|
|
71
|
+
var _observer$complete;
|
|
72
|
+
|
|
73
|
+
if (isDone) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
isDone = true;
|
|
78
|
+
(_observer$complete = observer.complete) === null || _observer$complete === void 0 ? void 0 : _observer$complete.call(observer);
|
|
79
|
+
unsubscribe();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (teardownImmediately) {
|
|
84
|
+
unsubscribe();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
unsubscribe: unsubscribe
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
pipe: function pipe() {
|
|
92
|
+
for (var _len = arguments.length, operations = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
93
|
+
operations[_key] = arguments[_key];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return pipeFromArray(operations)(self);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return self;
|
|
100
|
+
}
|
|
101
|
+
|
|
1
102
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
103
|
|
|
3
104
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -105,4 +206,33 @@ _opts) {
|
|
|
105
206
|
};
|
|
106
207
|
}
|
|
107
208
|
|
|
108
|
-
|
|
209
|
+
function tap(observer) {
|
|
210
|
+
return function (originalObserver) {
|
|
211
|
+
return {
|
|
212
|
+
subscribe: function subscribe(observer2) {
|
|
213
|
+
return originalObserver.subscribe({
|
|
214
|
+
next: function next(v) {
|
|
215
|
+
var _observer$next, _observer2$next;
|
|
216
|
+
|
|
217
|
+
(_observer$next = observer.next) === null || _observer$next === void 0 ? void 0 : _observer$next.call(observer, v);
|
|
218
|
+
(_observer2$next = observer2.next) === null || _observer2$next === void 0 ? void 0 : _observer2$next.call(observer2, v);
|
|
219
|
+
},
|
|
220
|
+
error: function error(v) {
|
|
221
|
+
var _observer$error, _observer2$error;
|
|
222
|
+
|
|
223
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, v);
|
|
224
|
+
(_observer2$error = observer2.error) === null || _observer2$error === void 0 ? void 0 : _observer2$error.call(observer2, v);
|
|
225
|
+
},
|
|
226
|
+
complete: function complete() {
|
|
227
|
+
var _observer$complete, _observer2$complete;
|
|
228
|
+
|
|
229
|
+
(_observer$complete = observer.complete) === null || _observer$complete === void 0 ? void 0 : _observer$complete.call(observer);
|
|
230
|
+
(_observer2$complete = observer2.complete) === null || _observer2$complete === void 0 ? void 0 : _observer2$complete.call(observer2);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export { observable as o, share as s, tap as t };
|
|
@@ -1,5 +1,106 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
function identity(x) {
|
|
4
|
+
return x;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** @internal */
|
|
8
|
+
function pipeFromArray(fns) {
|
|
9
|
+
if (fns.length === 0) {
|
|
10
|
+
return identity;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (fns.length === 1) {
|
|
14
|
+
return fns[0];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return function piped(input) {
|
|
18
|
+
return fns.reduce(function (prev, fn) {
|
|
19
|
+
return fn(prev);
|
|
20
|
+
}, input);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function observable(_subscribe) {
|
|
25
|
+
var self = {
|
|
26
|
+
subscribe: function subscribe(observer) {
|
|
27
|
+
var teardownRef = null;
|
|
28
|
+
var isDone = false;
|
|
29
|
+
var unsubscribed = false;
|
|
30
|
+
var teardownImmediately = false;
|
|
31
|
+
|
|
32
|
+
function unsubscribe() {
|
|
33
|
+
if (teardownRef === null) {
|
|
34
|
+
teardownImmediately = true;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (unsubscribed) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
unsubscribed = true;
|
|
43
|
+
|
|
44
|
+
if (typeof teardownRef === 'function') {
|
|
45
|
+
teardownRef();
|
|
46
|
+
} else if (teardownRef) {
|
|
47
|
+
teardownRef.unsubscribe();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
teardownRef = _subscribe({
|
|
52
|
+
next: function next(value) {
|
|
53
|
+
var _observer$next;
|
|
54
|
+
|
|
55
|
+
if (isDone) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
(_observer$next = observer.next) === null || _observer$next === void 0 ? void 0 : _observer$next.call(observer, value);
|
|
60
|
+
},
|
|
61
|
+
error: function error(err) {
|
|
62
|
+
var _observer$error;
|
|
63
|
+
|
|
64
|
+
if (isDone) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
isDone = true;
|
|
69
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, err);
|
|
70
|
+
unsubscribe();
|
|
71
|
+
},
|
|
72
|
+
complete: function complete() {
|
|
73
|
+
var _observer$complete;
|
|
74
|
+
|
|
75
|
+
if (isDone) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
isDone = true;
|
|
80
|
+
(_observer$complete = observer.complete) === null || _observer$complete === void 0 ? void 0 : _observer$complete.call(observer);
|
|
81
|
+
unsubscribe();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (teardownImmediately) {
|
|
86
|
+
unsubscribe();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
unsubscribe: unsubscribe
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
pipe: function pipe() {
|
|
94
|
+
for (var _len = arguments.length, operations = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
95
|
+
operations[_key] = arguments[_key];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return pipeFromArray(operations)(self);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return self;
|
|
102
|
+
}
|
|
103
|
+
|
|
3
104
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
105
|
|
|
5
106
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -107,4 +208,35 @@ _opts) {
|
|
|
107
208
|
};
|
|
108
209
|
}
|
|
109
210
|
|
|
211
|
+
function tap(observer) {
|
|
212
|
+
return function (originalObserver) {
|
|
213
|
+
return {
|
|
214
|
+
subscribe: function subscribe(observer2) {
|
|
215
|
+
return originalObserver.subscribe({
|
|
216
|
+
next: function next(v) {
|
|
217
|
+
var _observer$next, _observer2$next;
|
|
218
|
+
|
|
219
|
+
(_observer$next = observer.next) === null || _observer$next === void 0 ? void 0 : _observer$next.call(observer, v);
|
|
220
|
+
(_observer2$next = observer2.next) === null || _observer2$next === void 0 ? void 0 : _observer2$next.call(observer2, v);
|
|
221
|
+
},
|
|
222
|
+
error: function error(v) {
|
|
223
|
+
var _observer$error, _observer2$error;
|
|
224
|
+
|
|
225
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 ? void 0 : _observer$error.call(observer, v);
|
|
226
|
+
(_observer2$error = observer2.error) === null || _observer2$error === void 0 ? void 0 : _observer2$error.call(observer2, v);
|
|
227
|
+
},
|
|
228
|
+
complete: function complete() {
|
|
229
|
+
var _observer$complete, _observer2$complete;
|
|
230
|
+
|
|
231
|
+
(_observer$complete = observer.complete) === null || _observer$complete === void 0 ? void 0 : _observer$complete.call(observer);
|
|
232
|
+
(_observer2$complete = observer2.complete) === null || _observer2$complete === void 0 ? void 0 : _observer2$complete.call(observer2);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
exports.observable = observable;
|
|
110
241
|
exports.share = share;
|
|
242
|
+
exports.tap = tap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/client",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.16",
|
|
4
4
|
"description": "tRPC Client lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,13 +74,13 @@
|
|
|
74
74
|
"@babel/runtime": "^7.9.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@trpc/server": "10.0.0-alpha.
|
|
77
|
+
"@trpc/server": "10.0.0-alpha.16"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@trpc/server": "10.0.0-alpha.
|
|
80
|
+
"@trpc/server": "10.0.0-alpha.16"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "08a4af55145d079964f6698130223ebe9b9bed6b"
|
|
86
86
|
}
|
package/src/index.ts
CHANGED
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
OperationLink,
|
|
19
19
|
TRPCLink,
|
|
20
20
|
} from '../links/types';
|
|
21
|
-
import {
|
|
22
|
-
import { inferObservableValue } from '../
|
|
23
|
-
import { share } from '../
|
|
24
|
-
import { Observer } from '../
|
|
25
|
-
import { observableToPromise } from '../
|
|
21
|
+
import { Unsubscribable } from '../observable';
|
|
22
|
+
import { inferObservableValue } from '../observable/observable';
|
|
23
|
+
import { share } from '../observable/operators';
|
|
24
|
+
import { Observer } from '../observable/types';
|
|
25
|
+
import { observableToPromise } from '../observable/internals/observableToPromise';
|
|
26
26
|
import { TRPCClientError } from '../TRPCClientError';
|
|
27
27
|
import { getAbortController } from './fetchHelpers';
|
|
28
28
|
|
|
@@ -218,14 +218,14 @@ export class TRPCClient<TRouter extends AnyRouter> {
|
|
|
218
218
|
input: TInput,
|
|
219
219
|
opts: TRPCRequestOptions &
|
|
220
220
|
Partial<Observer<TRPCResult<TOutput>, TRPCClientError<TRouter>>>,
|
|
221
|
-
):
|
|
221
|
+
): Unsubscribable {
|
|
222
222
|
const observable$ = this.$request<TInput, TOutput>({
|
|
223
223
|
type: 'subscription',
|
|
224
224
|
path,
|
|
225
225
|
input,
|
|
226
226
|
context: opts.context,
|
|
227
227
|
});
|
|
228
|
-
|
|
228
|
+
return observable$.subscribe({
|
|
229
229
|
next(result) {
|
|
230
230
|
if ('error' in result.data) {
|
|
231
231
|
const err = TRPCClientError.from(result.data, {
|
|
@@ -244,8 +244,5 @@ export class TRPCClient<TRouter extends AnyRouter> {
|
|
|
244
244
|
opts.complete?.();
|
|
245
245
|
},
|
|
246
246
|
});
|
|
247
|
-
return () => {
|
|
248
|
-
observer.unsubscribe();
|
|
249
|
-
};
|
|
250
247
|
}
|
|
251
248
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { waitFor } from '@testing-library/dom';
|
|
2
2
|
import { AnyRouter } from '@trpc/server';
|
|
3
3
|
import { OperationLink } from '..';
|
|
4
|
-
import { observable } from '../
|
|
4
|
+
import { observable } from '../observable/observable';
|
|
5
5
|
import { dedupeLink } from './dedupeLink';
|
|
6
6
|
import { createChain } from './internals/createChain';
|
|
7
7
|
|
package/src/links/dedupeLink.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyRouter } from '@trpc/server';
|
|
2
|
-
import { observable } from '../
|
|
3
|
-
import { share } from '../
|
|
4
|
-
import { Observable } from '../
|
|
2
|
+
import { observable } from '../observable/observable';
|
|
3
|
+
import { share } from '../observable/operators';
|
|
4
|
+
import { Observable } from '../observable/types';
|
|
5
5
|
import { TRPCLink } from './types';
|
|
6
6
|
|
|
7
7
|
export function dedupeLink<
|
|
@@ -28,7 +28,7 @@ export function dedupeLink<
|
|
|
28
28
|
function reset() {
|
|
29
29
|
delete pending[key];
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const subscription = next(op).subscribe({
|
|
32
32
|
next(v) {
|
|
33
33
|
observer.next(v);
|
|
34
34
|
},
|
|
@@ -43,7 +43,7 @@ export function dedupeLink<
|
|
|
43
43
|
});
|
|
44
44
|
return () => {
|
|
45
45
|
reset();
|
|
46
|
-
|
|
46
|
+
subscription.unsubscribe();
|
|
47
47
|
};
|
|
48
48
|
}).pipe(share());
|
|
49
49
|
pending[key] = shared$;
|