@limrun/api 0.16.1 → 0.17.0-rc.2
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/CHANGELOG.md +0 -17
- package/client.d.mts +1 -1
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -1
- package/client.d.ts.map +1 -1
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/instance-client.d.mts.map +1 -1
- package/instance-client.d.ts.map +1 -1
- package/instance-client.js +8 -24
- package/instance-client.js.map +1 -1
- package/instance-client.mjs +9 -25
- package/instance-client.mjs.map +1 -1
- package/internal/tslib.js +4 -0
- package/ios-client.d.mts +207 -0
- package/ios-client.d.mts.map +1 -0
- package/ios-client.d.ts +207 -0
- package/ios-client.d.ts.map +1 -0
- package/ios-client.js +521 -0
- package/ios-client.js.map +1 -0
- package/ios-client.mjs +515 -0
- package/ios-client.mjs.map +1 -0
- package/package.json +11 -1
- package/src/client.ts +1 -1
- package/src/index.ts +1 -0
- package/src/instance-client.ts +9 -30
- package/src/ios-client.ts +788 -0
- package/src/tunnel.ts +6 -48
- package/src/version.ts +1 -1
- package/tunnel.d.mts +0 -1
- package/tunnel.d.mts.map +1 -1
- package/tunnel.d.ts +0 -1
- package/tunnel.d.ts.map +1 -1
- package/tunnel.js +6 -44
- package/tunnel.js.map +1 -1
- package/tunnel.mjs +6 -42
- package/tunnel.mjs.map +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
package/src/instance-client.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebSocket, Data } from 'ws';
|
|
2
2
|
import { exec } from 'node:child_process';
|
|
3
3
|
|
|
4
|
-
import { startTcpTunnel
|
|
4
|
+
import { startTcpTunnel } from './tunnel';
|
|
5
5
|
import type { Tunnel } from './tunnel';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -156,7 +156,6 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
156
156
|
let reconnectAttempts = 0;
|
|
157
157
|
let reconnectTimeout: NodeJS.Timeout | undefined;
|
|
158
158
|
let intentionalDisconnect = false;
|
|
159
|
-
let lastError: string | undefined;
|
|
160
159
|
|
|
161
160
|
const screenshotRequests: Map<
|
|
162
161
|
string,
|
|
@@ -176,19 +175,19 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
176
175
|
|
|
177
176
|
const stateChangeCallbacks: Set<ConnectionStateCallback> = new Set();
|
|
178
177
|
|
|
178
|
+
// Logger functions
|
|
179
179
|
const logger = {
|
|
180
180
|
debug: (...args: any[]) => {
|
|
181
|
-
if (logLevel === 'debug') console.log(
|
|
181
|
+
if (logLevel === 'debug') console.log(...args);
|
|
182
182
|
},
|
|
183
183
|
info: (...args: any[]) => {
|
|
184
|
-
if (logLevel === 'info' || logLevel === 'debug') console.log(
|
|
184
|
+
if (logLevel === 'info' || logLevel === 'debug') console.log(...args);
|
|
185
185
|
},
|
|
186
186
|
warn: (...args: any[]) => {
|
|
187
|
-
if (logLevel === 'warn' || logLevel === 'info' || logLevel === 'debug')
|
|
188
|
-
console.warn('[Endpoint]', ...args);
|
|
187
|
+
if (logLevel === 'warn' || logLevel === 'info' || logLevel === 'debug') console.warn(...args);
|
|
189
188
|
},
|
|
190
189
|
error: (...args: any[]) => {
|
|
191
|
-
if (logLevel !== 'none') console.error(
|
|
190
|
+
if (logLevel !== 'none') console.error(...args);
|
|
192
191
|
},
|
|
193
192
|
};
|
|
194
193
|
|
|
@@ -243,16 +242,8 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
243
242
|
return;
|
|
244
243
|
}
|
|
245
244
|
|
|
246
|
-
if (isNonRetryableError(lastError ?? '')) {
|
|
247
|
-
logger.debug('Skipping reconnection (non-retryable error)');
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
245
|
if (reconnectAttempts >= maxReconnectAttempts) {
|
|
252
|
-
logger.error(
|
|
253
|
-
`Max reconnection attempts (${maxReconnectAttempts}) reached. Giving up.`,
|
|
254
|
-
lastError ? `Last error: ${lastError}` : '',
|
|
255
|
-
);
|
|
246
|
+
logger.error(`Max reconnection attempts (${maxReconnectAttempts}) reached. Giving up.`);
|
|
256
247
|
updateConnectionState('disconnected');
|
|
257
248
|
return;
|
|
258
249
|
}
|
|
@@ -359,9 +350,7 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
359
350
|
});
|
|
360
351
|
|
|
361
352
|
ws.on('error', (err: Error) => {
|
|
362
|
-
|
|
363
|
-
lastError = errMessage;
|
|
364
|
-
logger.debug('WebSocket error:', errMessage);
|
|
353
|
+
logger.error('WebSocket error:', err.message);
|
|
365
354
|
if (!hasResolved && (ws?.readyState === WebSocket.CONNECTING || ws?.readyState === WebSocket.OPEN)) {
|
|
366
355
|
rejectConnection(err);
|
|
367
356
|
}
|
|
@@ -373,10 +362,7 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
373
362
|
pingInterval = undefined;
|
|
374
363
|
}
|
|
375
364
|
|
|
376
|
-
const shouldReconnect =
|
|
377
|
-
!intentionalDisconnect &&
|
|
378
|
-
!isNonRetryableError(lastError ?? '') &&
|
|
379
|
-
connectionState !== 'disconnected';
|
|
365
|
+
const shouldReconnect = !intentionalDisconnect && connectionState !== 'disconnected';
|
|
380
366
|
updateConnectionState('disconnected');
|
|
381
367
|
|
|
382
368
|
logger.debug('Disconnected from server.');
|
|
@@ -385,19 +371,12 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
385
371
|
|
|
386
372
|
if (shouldReconnect) {
|
|
387
373
|
scheduleReconnect();
|
|
388
|
-
} else if (isNonRetryableError(lastError ?? '')) {
|
|
389
|
-
logger.error(`Closing connection due to non-retryable error: ${lastError}`);
|
|
390
|
-
cleanup();
|
|
391
|
-
updateConnectionState('disconnected');
|
|
392
|
-
failPendingRequests('Non-retryable error');
|
|
393
|
-
logger.debug('Non-retryable error. Closing connection.');
|
|
394
374
|
}
|
|
395
375
|
});
|
|
396
376
|
|
|
397
377
|
ws.on('open', () => {
|
|
398
378
|
logger.debug(`Connected to ${serverAddress}`);
|
|
399
379
|
reconnectAttempts = 0;
|
|
400
|
-
lastError = undefined;
|
|
401
380
|
updateConnectionState('connected');
|
|
402
381
|
|
|
403
382
|
pingInterval = setInterval(() => {
|