fix(build): tighten TypeScript compatibility and update project build configuration

This commit is contained in:
2026-04-30 15:22:54 +00:00
parent d75486ac6e
commit 554af7752e
14 changed files with 2389 additions and 1962 deletions
+14 -10
View File
@@ -28,10 +28,10 @@ export class SmartsocketClient {
public shortId = plugins.isounique.uni();
// the shortId of the remote we connect to
public remoteShortId: string = null;
public remoteShortId: string | null = null;
public alias: string;
public socketConnection: SocketConnection;
public socketConnection?: SocketConnection;
public serverUrl: string;
public serverPort: number;
public autoReconnect: boolean;
@@ -50,7 +50,7 @@ export class SmartsocketClient {
// tagStore
private tagStore: { [key: string]: interfaces.ITag } = {};
private tagStoreSubscription: plugins.smartrx.rxjs.Subscription;
private tagStoreSubscription?: plugins.smartrx.rxjs.Subscription;
/**
* adds a tag to a connection
@@ -86,7 +86,7 @@ export class SmartsocketClient {
this.alias = optionsArg.alias;
this.serverUrl = optionsArg.url;
this.serverPort = optionsArg.port;
this.autoReconnect = optionsArg.autoReconnect;
this.autoReconnect = optionsArg.autoReconnect ?? false;
this.maxRetries = optionsArg.maxRetries ?? 100; // Default to 100 retries
this.initialBackoffDelay = optionsArg.initialBackoffDelay ?? 1000; // Default to 1 second
this.maxBackoffDelay = optionsArg.maxBackoffDelay ?? 60000; // Default to 1 minute
@@ -148,6 +148,7 @@ export class SmartsocketClient {
smartsocketHost: this,
socket: socket as any,
});
const socketConnection = this.socketConnection;
// Increment attempt ID to invalidate any pending timers from previous attempts
this.connectionAttemptId++;
@@ -183,7 +184,7 @@ export class SmartsocketClient {
this.remoteShortId = authRequestPayload.serverAlias;
// Send authentication data
this.socketConnection.sendMessage({
socketConnection.sendMessage({
type: 'auth',
payload: { alias: this.alias },
});
@@ -193,7 +194,7 @@ export class SmartsocketClient {
const authResponse = message.payload as interfaces.IAuthResponsePayload;
if (authResponse.success) {
logger.log('info', 'client is authenticated');
this.socketConnection.authenticated = true;
socketConnection.authenticated = true;
} else {
logger.log('warn', `authentication failed: ${authResponse.error}`);
await this.disconnect();
@@ -202,15 +203,15 @@ export class SmartsocketClient {
case 'serverReady':
// Set up function request listening
await this.socketConnection.listenToFunctionRequests();
await socketConnection.listenToFunctionRequests();
// Handle retagging
const oldTagStore = this.tagStore;
this.tagStoreSubscription?.unsubscribe();
for (const keyArg of Object.keys(this.tagStore)) {
this.socketConnection.addTag(this.tagStore[keyArg]);
socketConnection.addTag(this.tagStore[keyArg]);
}
this.tagStoreSubscription = this.socketConnection.tagStoreObservable.subscribe(
this.tagStoreSubscription = socketConnection.tagStoreObservable.subscribe(
(tagStoreArg) => {
this.tagStore = tagStoreArg;
}
@@ -226,7 +227,7 @@ export class SmartsocketClient {
default:
// Other messages are handled by SocketConnection
this.socketConnection.handleMessage(message);
socketConnection.handleMessage(message);
break;
}
} catch (err) {
@@ -341,6 +342,9 @@ export class SmartsocketClient {
functionNameArg: T['method'],
dataArg: T['request']
): Promise<T['response']> {
if (!this.socketConnection) {
throw new Error('Cannot call server without an active socket connection');
}
const socketRequest = new SocketRequest<T>(this, {
side: 'requesting',
originSocketConnection: this.socketConnection,