Socket
Socket
Sign inDemoInstall

@trpc/client

Package Overview
Dependencies
Maintainers
3
Versions
1030
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trpc/client - npm Package Compare versions

Comparing version 11.0.0-rc.474 to 11.0.0-rc.475

50

dist/bundle-analysis.json
{
"bundleSize": 51847,
"bundleOrigSize": 69119,
"bundleReduction": 24.99,
"bundleSize": 52463,
"bundleOrigSize": 69768,
"bundleReduction": 24.8,
"modules": [
{
"id": "/src/links/wsLink.ts",
"size": 13069,
"origSize": 14556,
"size": 13683,
"origSize": 15132,
"renderedExports": [

@@ -16,4 +16,4 @@ "createWSClient",

"dependents": [],
"percent": 25.21,
"reduction": 10.22
"percent": 26.08,
"reduction": 9.58
},

@@ -29,3 +29,3 @@ {

"dependents": [],
"percent": 11.3,
"percent": 11.17,
"reduction": 3.51

@@ -42,3 +42,3 @@ },

"dependents": [],
"percent": 10.53,
"percent": 10.4,
"reduction": 18.48

@@ -67,3 +67,3 @@ },

],
"percent": 8.61,
"percent": 8.51,
"reduction": 32.82

@@ -83,3 +83,3 @@ },

],
"percent": 7.88,
"percent": 7.78,
"reduction": 5.64

@@ -96,3 +96,3 @@ },

"dependents": [],
"percent": 7.57,
"percent": 7.48,
"reduction": 4.69

@@ -102,4 +102,4 @@ },

"id": "/src/links/httpSubscriptionLink.ts",
"size": 3632,
"origSize": 3952,
"size": 3634,
"origSize": 4025,
"renderedExports": [

@@ -110,4 +110,4 @@ "unstable_httpSubscriptionLink"

"dependents": [],
"percent": 7.01,
"reduction": 8.1
"percent": 6.93,
"reduction": 9.71
},

@@ -123,3 +123,3 @@ {

"dependents": [],
"percent": 6.14,
"percent": 6.07,
"reduction": 14.15

@@ -139,3 +139,3 @@ },

],
"percent": 4.17,
"percent": 4.12,
"reduction": 47.6

@@ -160,3 +160,3 @@ },

],
"percent": 3.74,
"percent": 3.7,
"reduction": 45.43

@@ -178,3 +178,3 @@ },

],
"percent": 2.29,
"percent": 2.26,
"reduction": 73.19

@@ -194,3 +194,3 @@ },

],
"percent": 1.33,
"percent": 1.32,
"reduction": 32.75

@@ -207,3 +207,3 @@ },

"dependents": [],
"percent": 1.18,
"percent": 1.16,
"reduction": 44.95

@@ -222,3 +222,3 @@ },

],
"percent": 1.09,
"percent": 1.08,
"reduction": 66.75

@@ -238,3 +238,3 @@ },

],
"percent": 0.83,
"percent": 0.82,
"reduction": 33.54

@@ -253,3 +253,3 @@ },

"dependents": [],
"percent": 0.64,
"percent": 0.63,
"reduction": 15.17

@@ -256,0 +256,0 @@ },

@@ -66,3 +66,3 @@ 'use strict';

for await (const chunk of iterable){
// if the `sse({})`-helper is used, we always have an `id` field
// if the `tracked()`-helper is used, we always have an `id` field
const data = 'id' in chunk ? chunk : chunk.data;

@@ -69,0 +69,0 @@ observer.next({

@@ -48,3 +48,7 @@ import type { Observer, UnsubscribeFn } from '@trpc/server/observable';

close: () => void;
request: (op: Operation, callbacks: WSCallbackObserver<AnyRouter, unknown>) => UnsubscribeFn;
request: (opts: {
op: Operation;
callbacks: WSCallbackObserver<AnyRouter, unknown>;
lastEventId: string | undefined;
}) => UnsubscribeFn;
readonly connection: ({

@@ -51,0 +55,0 @@ id: number;

@@ -102,3 +102,7 @@ 'use strict';

}
request(req.op, req.callbacks);
request({
op: req.op,
callbacks: req.callbacks,
lastEventId: req.lastEventId
});
}

@@ -193,2 +197,5 @@ const startLazyDisconnectTimer = ()=>{

}
if ('result' in data && data.result.type === 'data' && typeof data.result.id === 'string') {
req.lastEventId = data.result.id;
}
if ('result' in data && data.result.type === 'stopped' && activeConnection === self) {

@@ -246,3 +253,4 @@ req.callbacks.complete();

}
function request(op, callbacks) {
function request(opts) {
const { op , callbacks , lastEventId } = opts;
const { type , input , path , id } = op;

@@ -254,3 +262,4 @@ const envelope = {

input,
path
path,
lastEventId
}

@@ -262,3 +271,4 @@ };

callbacks,
op
op,
lastEventId
};

@@ -326,31 +336,35 @@ // enqueue message

const unsub = client.request({
type,
path,
input,
id,
context,
signal: null
}, {
error (err) {
observer.error(err);
unsub();
op: {
type,
path,
input,
id,
context,
signal: null
},
complete () {
observer.complete();
},
next (message) {
const transformed = unstableCoreDoNotImport.transformResult(message, transformer$1.output);
if (!transformed.ok) {
observer.error(TRPCClientError.TRPCClientError.from(transformed.error));
return;
}
observer.next({
result: transformed.result
});
if (op.type !== 'subscription') {
// if it isn't a subscription we don't care about next response
callbacks: {
error (err) {
observer.error(err);
unsub();
},
complete () {
observer.complete();
},
next (message) {
const transformed = unstableCoreDoNotImport.transformResult(message, transformer$1.output);
if (!transformed.ok) {
observer.error(TRPCClientError.TRPCClientError.from(transformed.error));
return;
}
observer.next({
result: transformed.result
});
if (op.type !== 'subscription') {
// if it isn't a subscription we don't care about next response
unsub();
observer.complete();
}
}
}
},
lastEventId: undefined
});

@@ -357,0 +371,0 @@ return ()=>{

{
"name": "@trpc/client",
"version": "11.0.0-rc.474+42b880437",
"version": "11.0.0-rc.475+10b4bde0c",
"description": "The tRPC client library",

@@ -79,6 +79,6 @@ "author": "KATT",

"peerDependencies": {
"@trpc/server": "11.0.0-rc.474+42b880437"
"@trpc/server": "11.0.0-rc.475+10b4bde0c"
},
"devDependencies": {
"@trpc/server": "11.0.0-rc.474+42b880437",
"@trpc/server": "11.0.0-rc.475+10b4bde0c",
"@types/isomorphic-fetch": "^0.0.39",

@@ -100,3 +100,3 @@ "@types/node": "^20.10.0",

],
"gitHead": "42b880437961af45a4e59ff33267acbaedc46cec"
"gitHead": "10b4bde0cb497c29d00f3c78c09fe8b64391f93c"
}

@@ -6,3 +6,2 @@ import { observable } from '@trpc/server/observable';

InferrableClientTypes,
SSEMessage,
} from '@trpc/server/unstable-core-do-not-import';

@@ -100,3 +99,8 @@ import {

eventSource.addEventListener('open', onStarted);
const iterable = sseStreamConsumer<Partial<SSEMessage>>({
const iterable = sseStreamConsumer<
Partial<{
id?: string;
data: unknown;
}>
>({
from: eventSource,

@@ -107,3 +111,3 @@ deserialize: transformer.output.deserialize,

for await (const chunk of iterable) {
// if the `sse({})`-helper is used, we always have an `id` field
// if the `tracked()`-helper is used, we always have an `id` field
const data = 'id' in chunk ? chunk : chunk.data;

@@ -110,0 +114,0 @@ observer.next({

@@ -106,3 +106,3 @@ import type { Observer, UnsubscribeFn } from '@trpc/server/observable';

type TCallbacks = WSCallbackObserver<AnyRouter, unknown>;
type TRequest = {
type WsRequest = {
/**

@@ -115,4 +115,8 @@ * Reference to the WebSocket instance this request was made to

op: Operation;
/**
* The last event id that the client has received
*/
lastEventId: string | undefined;
};
const pendingRequests: Record<number | string, TRequest> =
const pendingRequests: Record<number | string, WsRequest> =
Object.create(null);

@@ -215,7 +219,11 @@ let connectAttempt = 0;

}
function resumeSubscriptionOnReconnect(req: TRequest) {
function resumeSubscriptionOnReconnect(req: WsRequest) {
if (outgoing.some((r) => r.id === req.op.id)) {
return;
}
request(req.op, req.callbacks);
request({
op: req.op,
callbacks: req.callbacks,
lastEventId: req.lastEventId,
});
}

@@ -331,2 +339,9 @@

'result' in data &&
data.result.type === 'data' &&
typeof data.result.id === 'string'
) {
req.lastEventId = data.result.id;
}
if (
'result' in data &&
data.result.type === 'stopped' &&

@@ -395,3 +410,8 @@ activeConnection === self

function request(op: Operation, callbacks: TCallbacks): UnsubscribeFn {
function request(opts: {
op: Operation;
callbacks: TCallbacks;
lastEventId: string | undefined;
}): UnsubscribeFn {
const { op, callbacks, lastEventId } = opts;
const { type, input, path, id } = op;

@@ -404,4 +424,6 @@ const envelope: TRPCRequestMessage = {

path,
lastEventId,
},
};
pendingRequests[id] = {

@@ -412,2 +434,3 @@ connection: null,

op,
lastEventId,
};

@@ -495,5 +518,5 @@

const unsub = client.request(
{ type, path, input, id, context, signal: null },
{
const unsub = client.request({
op: { type, path, input, id, context, signal: null },
callbacks: {
error(err) {

@@ -525,3 +548,4 @@ observer.error(err as TRPCClientError<any>);

},
);
lastEventId: undefined,
});
return () => {

@@ -528,0 +552,0 @@ unsub();

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc