@phpsandbox/sdk 0.0.41 → 0.0.42
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/dist/browser/phpsandbox-sdk.esm.js +60 -41
- package/dist/browser/phpsandbox-sdk.esm.js.map +2 -2
- package/dist/browser/phpsandbox-sdk.esm.min.js +2 -2
- package/dist/browser/phpsandbox-sdk.esm.min.js.map +3 -3
- package/dist/browser/phpsandbox-sdk.iife.js +60 -41
- package/dist/browser/phpsandbox-sdk.iife.js.map +2 -2
- package/dist/browser/phpsandbox-sdk.iife.min.js +2 -2
- package/dist/browser/phpsandbox-sdk.iife.min.js.map +3 -3
- package/dist/container.d.ts +2 -0
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js.map +1 -1
- package/dist/socket/index.d.ts +2 -0
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js +64 -41
- package/dist/socket/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3360,7 +3360,6 @@ var PHPSandbox = (() => {
|
|
|
3360
3360
|
};
|
|
3361
3361
|
var _Transport_instances, connect_fn, startPeriodicPing_fn;
|
|
3362
3362
|
var Transport = class {
|
|
3363
|
-
// 30 seconds
|
|
3364
3363
|
constructor(url, eventEmitter, options = {}) {
|
|
3365
3364
|
this.eventEmitter = eventEmitter;
|
|
3366
3365
|
this.options = options;
|
|
@@ -3386,6 +3385,8 @@ var PHPSandbox = (() => {
|
|
|
3386
3385
|
this.messageQueue = [];
|
|
3387
3386
|
this.MAX_QUEUE_SIZE = 100;
|
|
3388
3387
|
this.QUEUE_TIMEOUT = 3e4;
|
|
3388
|
+
// 30 seconds
|
|
3389
|
+
this.incomingMessageChain = Promise.resolve();
|
|
3389
3390
|
this.validateConfiguration(options);
|
|
3390
3391
|
this.url = new URL(url);
|
|
3391
3392
|
this.PING_INTERVAL = options.pingInterval ?? 3e4;
|
|
@@ -3450,53 +3451,17 @@ var PHPSandbox = (() => {
|
|
|
3450
3451
|
}
|
|
3451
3452
|
async registerWatchers() {
|
|
3452
3453
|
const onMessage = (ev) => {
|
|
3453
|
-
|
|
3454
|
-
const error = new Error("Unexpected message type: " + typeof ev.data);
|
|
3454
|
+
this.incomingMessageChain = this.incomingMessageChain.catch(() => void 0).then(() => this.processIncomingMessage(ev)).catch((error) => {
|
|
3455
3455
|
this.connectionStats.totalErrors++;
|
|
3456
|
-
this.log("error", "
|
|
3457
|
-
error: error.message
|
|
3458
|
-
messageType: typeof ev.data
|
|
3456
|
+
this.log("error", "Failed to process queued WebSocket frame", {
|
|
3457
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3459
3458
|
});
|
|
3460
3459
|
this.eventEmitter.emit("transport.error", {
|
|
3461
|
-
type: "
|
|
3460
|
+
type: "message_handle_error",
|
|
3462
3461
|
error,
|
|
3463
3462
|
rawMessage: ev.data,
|
|
3464
3463
|
timestamp: Date.now()
|
|
3465
3464
|
});
|
|
3466
|
-
return;
|
|
3467
|
-
}
|
|
3468
|
-
ev.data.arrayBuffer().then((buffer) => {
|
|
3469
|
-
if (buffer.byteLength === 0) {
|
|
3470
|
-
this.log("warn", "Ignoring empty WebSocket frame");
|
|
3471
|
-
return;
|
|
3472
|
-
}
|
|
3473
|
-
try {
|
|
3474
|
-
void this.handleRawMessage(decode(buffer)).catch((error) => {
|
|
3475
|
-
this.connectionStats.totalErrors++;
|
|
3476
|
-
this.log("error", "Failed to process WebSocket frame", {
|
|
3477
|
-
error: error instanceof Error ? error.message : String(error),
|
|
3478
|
-
byteLength: buffer.byteLength
|
|
3479
|
-
});
|
|
3480
|
-
this.eventEmitter.emit("transport.error", {
|
|
3481
|
-
type: "message_handle_error",
|
|
3482
|
-
error,
|
|
3483
|
-
rawMessage: buffer,
|
|
3484
|
-
timestamp: Date.now()
|
|
3485
|
-
});
|
|
3486
|
-
});
|
|
3487
|
-
} catch (error) {
|
|
3488
|
-
this.connectionStats.totalErrors++;
|
|
3489
|
-
this.log("error", "Failed to decode WebSocket frame", {
|
|
3490
|
-
error: error instanceof Error ? error.message : String(error),
|
|
3491
|
-
byteLength: buffer.byteLength
|
|
3492
|
-
});
|
|
3493
|
-
this.eventEmitter.emit("transport.error", {
|
|
3494
|
-
type: "message_decode_error",
|
|
3495
|
-
error,
|
|
3496
|
-
rawMessage: buffer,
|
|
3497
|
-
timestamp: Date.now()
|
|
3498
|
-
});
|
|
3499
|
-
}
|
|
3500
3465
|
});
|
|
3501
3466
|
};
|
|
3502
3467
|
this.rws.addEventListener("message", onMessage);
|
|
@@ -3506,6 +3471,60 @@ var PHPSandbox = (() => {
|
|
|
3506
3471
|
}
|
|
3507
3472
|
});
|
|
3508
3473
|
}
|
|
3474
|
+
async processIncomingMessage(ev) {
|
|
3475
|
+
if (!(ev.data instanceof Blob)) {
|
|
3476
|
+
const error = new Error("Unexpected message type: " + typeof ev.data);
|
|
3477
|
+
this.connectionStats.totalErrors++;
|
|
3478
|
+
this.log("error", "Unexpected WebSocket message type", {
|
|
3479
|
+
error: error.message,
|
|
3480
|
+
messageType: typeof ev.data
|
|
3481
|
+
});
|
|
3482
|
+
this.eventEmitter.emit("transport.error", {
|
|
3483
|
+
type: "message_type_error",
|
|
3484
|
+
error,
|
|
3485
|
+
rawMessage: ev.data,
|
|
3486
|
+
timestamp: Date.now()
|
|
3487
|
+
});
|
|
3488
|
+
return;
|
|
3489
|
+
}
|
|
3490
|
+
const buffer = await ev.data.arrayBuffer();
|
|
3491
|
+
if (buffer.byteLength === 0) {
|
|
3492
|
+
this.log("warn", "Ignoring empty WebSocket frame");
|
|
3493
|
+
return;
|
|
3494
|
+
}
|
|
3495
|
+
let decoded;
|
|
3496
|
+
try {
|
|
3497
|
+
decoded = decode(buffer);
|
|
3498
|
+
} catch (error) {
|
|
3499
|
+
this.connectionStats.totalErrors++;
|
|
3500
|
+
this.log("error", "Failed to decode WebSocket frame", {
|
|
3501
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3502
|
+
byteLength: buffer.byteLength
|
|
3503
|
+
});
|
|
3504
|
+
this.eventEmitter.emit("transport.error", {
|
|
3505
|
+
type: "message_decode_error",
|
|
3506
|
+
error,
|
|
3507
|
+
rawMessage: buffer,
|
|
3508
|
+
timestamp: Date.now()
|
|
3509
|
+
});
|
|
3510
|
+
return;
|
|
3511
|
+
}
|
|
3512
|
+
try {
|
|
3513
|
+
await this.handleRawMessage(decoded);
|
|
3514
|
+
} catch (error) {
|
|
3515
|
+
this.connectionStats.totalErrors++;
|
|
3516
|
+
this.log("error", "Failed to process WebSocket frame", {
|
|
3517
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3518
|
+
byteLength: buffer.byteLength
|
|
3519
|
+
});
|
|
3520
|
+
this.eventEmitter.emit("transport.error", {
|
|
3521
|
+
type: "message_handle_error",
|
|
3522
|
+
error,
|
|
3523
|
+
rawMessage: buffer,
|
|
3524
|
+
timestamp: Date.now()
|
|
3525
|
+
});
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3509
3528
|
async handleRawMessage(ev) {
|
|
3510
3529
|
if (this.closed) {
|
|
3511
3530
|
this.log("debug", "Ignoring message received after transport was closed");
|