@trpc/client
Advanced tools
Comparing version 11.0.0-rc.593 to 11.0.0-rc.599
{ | ||
"bundleSize": 62217, | ||
"bundleOrigSize": 80632, | ||
"bundleReduction": 22.84, | ||
"bundleSize": 62359, | ||
"bundleOrigSize": 80871, | ||
"bundleReduction": 22.89, | ||
"modules": [ | ||
@@ -16,3 +16,3 @@ { | ||
"dependents": [], | ||
"percent": 28.89, | ||
"percent": 28.83, | ||
"reduction": 10.34 | ||
@@ -22,4 +22,4 @@ }, | ||
"id": "/src/links/httpSubscriptionLink.ts", | ||
"size": 6663, | ||
"origSize": 6599, | ||
"size": 6723, | ||
"origSize": 6686, | ||
"renderedExports": [ | ||
@@ -30,3 +30,3 @@ "unstable_httpSubscriptionLink" | ||
"dependents": [], | ||
"percent": 10.71, | ||
"percent": 10.78, | ||
"reduction": 0 | ||
@@ -43,3 +43,3 @@ }, | ||
"dependents": [], | ||
"percent": 9.65, | ||
"percent": 9.63, | ||
"reduction": 4.41 | ||
@@ -56,3 +56,3 @@ }, | ||
"dependents": [], | ||
"percent": 8.82, | ||
"percent": 8.8, | ||
"reduction": 20.69 | ||
@@ -72,3 +72,3 @@ }, | ||
], | ||
"percent": 6.56, | ||
"percent": 6.55, | ||
"reduction": 5.64 | ||
@@ -85,3 +85,3 @@ }, | ||
"dependents": [], | ||
"percent": 6.33, | ||
"percent": 6.32, | ||
"reduction": 5.56 | ||
@@ -109,3 +109,3 @@ }, | ||
], | ||
"percent": 5.94, | ||
"percent": 5.92, | ||
"reduction": 37.12 | ||
@@ -122,3 +122,3 @@ }, | ||
"dependents": [], | ||
"percent": 5.12, | ||
"percent": 5.1, | ||
"reduction": 14.14 | ||
@@ -138,3 +138,3 @@ }, | ||
], | ||
"percent": 4.35, | ||
"percent": 4.34, | ||
"reduction": 40.88 | ||
@@ -159,3 +159,3 @@ }, | ||
], | ||
"percent": 3.12, | ||
"percent": 3.11, | ||
"reduction": 45.57 | ||
@@ -172,3 +172,3 @@ }, | ||
"dependents": [], | ||
"percent": 2.07, | ||
"percent": 2.06, | ||
"reduction": 33.02 | ||
@@ -207,3 +207,3 @@ }, | ||
], | ||
"percent": 1.91, | ||
"percent": 1.9, | ||
"reduction": 73.19 | ||
@@ -283,4 +283,4 @@ }, | ||
"id": "/src/links/internals/urlWithConnectionParams.ts", | ||
"size": 158, | ||
"origSize": 864, | ||
"size": 240, | ||
"origSize": 1016, | ||
"renderedExports": [ | ||
@@ -294,4 +294,4 @@ "resultOf" | ||
], | ||
"percent": 0.25, | ||
"reduction": 81.71 | ||
"percent": 0.38, | ||
"reduction": 76.38 | ||
}, | ||
@@ -298,0 +298,0 @@ { |
import type { AnyClientTypes, EventSourceLike, inferClientTypes, InferrableClientTypes } from '@trpc/server/unstable-core-do-not-import'; | ||
import { type TransformerOptions } from '../unstable-internals'; | ||
import type { CallbackOrValue } from './internals/urlWithConnectionParams'; | ||
import { type UrlOptionsWithConnectionParams } from './internals/urlWithConnectionParams'; | ||
import type { TRPCLink } from './types'; | ||
import type { Operation, TRPCLink } from './types'; | ||
type HTTPSubscriptionLinkOptions<TRoot extends AnyClientTypes, TEventSource extends EventSourceLike.AnyConstructor = typeof EventSource> = { | ||
@@ -14,3 +13,5 @@ /** | ||
*/ | ||
eventSourceOptions?: CallbackOrValue<EventSourceLike.InitDictOf<TEventSource>>; | ||
eventSourceOptions?: EventSourceLike.InitDictOf<TEventSource> | ((opts: { | ||
op: Operation; | ||
}) => EventSourceLike.InitDictOf<TEventSource> | Promise<EventSourceLike.InitDictOf<TEventSource>>); | ||
} & TransformerOptions<TRoot> & UrlOptionsWithConnectionParams; | ||
@@ -17,0 +18,0 @@ /** |
@@ -52,3 +52,5 @@ 'use strict'; | ||
}), | ||
init: ()=>urlWithConnectionParams$1.resultOf(opts.eventSourceOptions), | ||
init: ()=>urlWithConnectionParams$1.resultOf(opts.eventSourceOptions, { | ||
op | ||
}), | ||
signal, | ||
@@ -55,0 +57,0 @@ deserialize: transformer$1.output.deserialize, |
import { type TRPCRequestInfo } from '@trpc/server/http'; | ||
/** | ||
* Get the result of a value or function that returns a value | ||
* It also optionally accepts typesafe arguments for the function | ||
*/ | ||
export declare const resultOf: <T>(value: T | (() => T)) => T; | ||
export declare const resultOf: <T, TArgs extends any[]>(value: T | ((...args: TArgs) => T), ...args: TArgs) => T; | ||
/** | ||
@@ -7,0 +8,0 @@ * A value that can be wrapped in callback |
@@ -5,6 +5,7 @@ 'use strict'; | ||
* Get the result of a value or function that returns a value | ||
*/ const resultOf = (value)=>{ | ||
return typeof value === 'function' ? value() : value; | ||
* It also optionally accepts typesafe arguments for the function | ||
*/ const resultOf = (value, ...args)=>{ | ||
return typeof value === 'function' ? value(...args) : value; | ||
}; | ||
exports.resultOf = resultOf; |
{ | ||
"name": "@trpc/client", | ||
"version": "11.0.0-rc.593+f73cd3fd9", | ||
"version": "11.0.0-rc.599+e16cd8d7c", | ||
"description": "The tRPC client library", | ||
@@ -79,6 +79,6 @@ "author": "KATT", | ||
"peerDependencies": { | ||
"@trpc/server": "11.0.0-rc.593+f73cd3fd9" | ||
"@trpc/server": "11.0.0-rc.599+e16cd8d7c" | ||
}, | ||
"devDependencies": { | ||
"@trpc/server": "11.0.0-rc.593+f73cd3fd9", | ||
"@trpc/server": "11.0.0-rc.599+e16cd8d7c", | ||
"@types/isomorphic-fetch": "^0.0.39", | ||
@@ -100,3 +100,3 @@ "@types/node": "^20.10.0", | ||
], | ||
"gitHead": "f73cd3fd99734e83d3a6e8ea7ec77eb853055c43" | ||
"gitHead": "e16cd8d7cee12eaf1545273858407f0947ca97fc" | ||
} |
@@ -19,3 +19,2 @@ import { behaviorSubject, observable } from '@trpc/server/observable'; | ||
import { getUrl } from './internals/httpUtils'; | ||
import type { CallbackOrValue } from './internals/urlWithConnectionParams'; | ||
import { | ||
@@ -25,3 +24,3 @@ resultOf, | ||
} from './internals/urlWithConnectionParams'; | ||
import type { TRPCLink } from './types'; | ||
import type { Operation, TRPCLink } from './types'; | ||
@@ -54,5 +53,9 @@ async function urlWithConnectionParams( | ||
*/ | ||
eventSourceOptions?: CallbackOrValue< | ||
EventSourceLike.InitDictOf<TEventSource> | ||
>; | ||
eventSourceOptions?: | ||
| EventSourceLike.InitDictOf<TEventSource> | ||
| ((opts: { | ||
op: Operation; | ||
}) => | ||
| EventSourceLike.InitDictOf<TEventSource> | ||
| Promise<EventSourceLike.InitDictOf<TEventSource>>); | ||
} & TransformerOptions<TRoot> & | ||
@@ -115,3 +118,3 @@ UrlOptionsWithConnectionParams; | ||
}), | ||
init: () => resultOf(opts.eventSourceOptions), | ||
init: () => resultOf(opts.eventSourceOptions, { op }), | ||
signal, | ||
@@ -118,0 +121,0 @@ deserialize: transformer.output.deserialize, |
@@ -5,5 +5,11 @@ import { type TRPCRequestInfo } from '@trpc/server/http'; | ||
* Get the result of a value or function that returns a value | ||
* It also optionally accepts typesafe arguments for the function | ||
*/ | ||
export const resultOf = <T>(value: T | (() => T)): T => { | ||
return typeof value === 'function' ? (value as () => T)() : value; | ||
export const resultOf = <T, TArgs extends any[]>( | ||
value: T | ((...args: TArgs) => T), | ||
...args: TArgs | ||
): T => { | ||
return typeof value === 'function' | ||
? (value as (...args: TArgs) => T)(...args) | ||
: value; | ||
}; | ||
@@ -10,0 +16,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
295362
7709