Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to rpc-websockets v9 #2800

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/library-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"fast-stable-stringify": "^1.0.0",
"jayson": "^4.1.0",
"node-fetch": "^2.7.0",
"rpc-websockets": "^8.0.1",
"rpc-websockets": "^9.0.0",
"superstruct": "^1.0.4"
},
"devDependencies": {
Expand Down
8 changes: 0 additions & 8 deletions packages/library-legacy/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ function generateConfig(configType, format) {
'jayson/lib/client/browser',
'node-fetch',
'rpc-websockets',
'rpc-websockets/dist/lib/client.cjs',
'rpc-websockets/dist/lib/client/client.types.cjs',
'rpc-websockets/dist/lib/client/websocket.cjs',
'rpc-websockets/dist/lib/client/websocket.browser.cjs',
'superstruct',
];
}
Expand Down Expand Up @@ -182,10 +178,6 @@ function generateConfig(configType, format) {
'node-fetch',
'react-native-url-polyfill',
'rpc-websockets',
'rpc-websockets/dist/lib/client.cjs',
'rpc-websockets/dist/lib/client/client.types.cjs',
'rpc-websockets/dist/lib/client/websocket.cjs',
'rpc-websockets/dist/lib/client/websocket.browser.cjs',
'superstruct',
];

Expand Down

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions packages/library-legacy/src/rpc-websocket-factory.ts

This file was deleted.

22 changes: 9 additions & 13 deletions packages/library-legacy/src/rpc-websocket.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import RpcWebSocketCommonClient from 'rpc-websockets/dist/lib/client.cjs';
import WebSocketBrowserImpl from 'rpc-websockets/dist/lib/client/websocket.cjs';
import {
CommonClient,
ICommonWebSocket,
IWSClientAdditionalOptions,
NodeWebSocketType,
NodeWebSocketTypeOptions,
} from 'rpc-websockets/dist/lib/client/client.types.cjs';

import createRpc from './rpc-websocket-factory';
WebSocket as createRpc,
} from 'rpc-websockets';

interface IHasReadyState {
readyState: WebSocket['readyState'];
}

export default class RpcWebSocketClient extends RpcWebSocketCommonClient {
export default class RpcWebSocketClient extends CommonClient {
private underlyingSocket: IHasReadyState | undefined;
constructor(
address?: string,
Expand All @@ -32,9 +30,7 @@ export default class RpcWebSocketClient extends RpcWebSocketCommonClient {
...options,
});
if ('socket' in rpc) {
this.underlyingSocket = rpc.socket as ReturnType<
typeof WebSocketBrowserImpl
>;
this.underlyingSocket = rpc.socket as ReturnType<typeof createRpc>;
} else {
this.underlyingSocket = rpc as NodeWebSocketType;
}
Expand All @@ -43,8 +39,8 @@ export default class RpcWebSocketClient extends RpcWebSocketCommonClient {
super(webSocketFactory, address, options, generate_request_id);
}
call(
...args: Parameters<RpcWebSocketCommonClient['call']>
): ReturnType<RpcWebSocketCommonClient['call']> {
...args: Parameters<CommonClient['call']>
): ReturnType<CommonClient['call']> {
const readyState = this.underlyingSocket?.readyState;
if (readyState === 1 /* WebSocket.OPEN */) {
return super.call(...args);
Expand All @@ -60,8 +56,8 @@ export default class RpcWebSocketClient extends RpcWebSocketCommonClient {
);
}
notify(
...args: Parameters<RpcWebSocketCommonClient['notify']>
): ReturnType<RpcWebSocketCommonClient['notify']> {
...args: Parameters<CommonClient['notify']>
): ReturnType<CommonClient['notify']> {
const readyState = this.underlyingSocket?.readyState;
if (readyState === 1 /* WebSocket.OPEN */) {
return super.notify(...args);
Expand Down
Loading
Loading