@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
|
@@ -3311,7 +3311,6 @@ var InvalidConfigurationError = class extends Error {
|
|
|
3311
3311
|
};
|
|
3312
3312
|
var _Transport_instances, connect_fn, startPeriodicPing_fn;
|
|
3313
3313
|
var Transport = class {
|
|
3314
|
-
// 30 seconds
|
|
3315
3314
|
constructor(url, eventEmitter, options = {}) {
|
|
3316
3315
|
this.eventEmitter = eventEmitter;
|
|
3317
3316
|
this.options = options;
|
|
@@ -3337,6 +3336,8 @@ var Transport = class {
|
|
|
3337
3336
|
this.messageQueue = [];
|
|
3338
3337
|
this.MAX_QUEUE_SIZE = 100;
|
|
3339
3338
|
this.QUEUE_TIMEOUT = 3e4;
|
|
3339
|
+
// 30 seconds
|
|
3340
|
+
this.incomingMessageChain = Promise.resolve();
|
|
3340
3341
|
this.validateConfiguration(options);
|
|
3341
3342
|
this.url = new URL(url);
|
|
3342
3343
|
this.PING_INTERVAL = options.pingInterval ?? 3e4;
|
|
@@ -3401,53 +3402,17 @@ var Transport = class {
|
|
|
3401
3402
|
}
|
|
3402
3403
|
async registerWatchers() {
|
|
3403
3404
|
const onMessage = (ev) => {
|
|
3404
|
-
|
|
3405
|
-
const error = new Error("Unexpected message type: " + typeof ev.data);
|
|
3405
|
+
this.incomingMessageChain = this.incomingMessageChain.catch(() => void 0).then(() => this.processIncomingMessage(ev)).catch((error) => {
|
|
3406
3406
|
this.connectionStats.totalErrors++;
|
|
3407
|
-
this.log("error", "
|
|
3408
|
-
error: error.message
|
|
3409
|
-
messageType: typeof ev.data
|
|
3407
|
+
this.log("error", "Failed to process queued WebSocket frame", {
|
|
3408
|
+
error: error instanceof Error ? error.message : String(error)
|
|
3410
3409
|
});
|
|
3411
3410
|
this.eventEmitter.emit("transport.error", {
|
|
3412
|
-
type: "
|
|
3411
|
+
type: "message_handle_error",
|
|
3413
3412
|
error,
|
|
3414
3413
|
rawMessage: ev.data,
|
|
3415
3414
|
timestamp: Date.now()
|
|
3416
3415
|
});
|
|
3417
|
-
return;
|
|
3418
|
-
}
|
|
3419
|
-
ev.data.arrayBuffer().then((buffer) => {
|
|
3420
|
-
if (buffer.byteLength === 0) {
|
|
3421
|
-
this.log("warn", "Ignoring empty WebSocket frame");
|
|
3422
|
-
return;
|
|
3423
|
-
}
|
|
3424
|
-
try {
|
|
3425
|
-
void this.handleRawMessage(decode(buffer)).catch((error) => {
|
|
3426
|
-
this.connectionStats.totalErrors++;
|
|
3427
|
-
this.log("error", "Failed to process WebSocket frame", {
|
|
3428
|
-
error: error instanceof Error ? error.message : String(error),
|
|
3429
|
-
byteLength: buffer.byteLength
|
|
3430
|
-
});
|
|
3431
|
-
this.eventEmitter.emit("transport.error", {
|
|
3432
|
-
type: "message_handle_error",
|
|
3433
|
-
error,
|
|
3434
|
-
rawMessage: buffer,
|
|
3435
|
-
timestamp: Date.now()
|
|
3436
|
-
});
|
|
3437
|
-
});
|
|
3438
|
-
} catch (error) {
|
|
3439
|
-
this.connectionStats.totalErrors++;
|
|
3440
|
-
this.log("error", "Failed to decode WebSocket frame", {
|
|
3441
|
-
error: error instanceof Error ? error.message : String(error),
|
|
3442
|
-
byteLength: buffer.byteLength
|
|
3443
|
-
});
|
|
3444
|
-
this.eventEmitter.emit("transport.error", {
|
|
3445
|
-
type: "message_decode_error",
|
|
3446
|
-
error,
|
|
3447
|
-
rawMessage: buffer,
|
|
3448
|
-
timestamp: Date.now()
|
|
3449
|
-
});
|
|
3450
|
-
}
|
|
3451
3416
|
});
|
|
3452
3417
|
};
|
|
3453
3418
|
this.rws.addEventListener("message", onMessage);
|
|
@@ -3457,6 +3422,60 @@ var Transport = class {
|
|
|
3457
3422
|
}
|
|
3458
3423
|
});
|
|
3459
3424
|
}
|
|
3425
|
+
async processIncomingMessage(ev) {
|
|
3426
|
+
if (!(ev.data instanceof Blob)) {
|
|
3427
|
+
const error = new Error("Unexpected message type: " + typeof ev.data);
|
|
3428
|
+
this.connectionStats.totalErrors++;
|
|
3429
|
+
this.log("error", "Unexpected WebSocket message type", {
|
|
3430
|
+
error: error.message,
|
|
3431
|
+
messageType: typeof ev.data
|
|
3432
|
+
});
|
|
3433
|
+
this.eventEmitter.emit("transport.error", {
|
|
3434
|
+
type: "message_type_error",
|
|
3435
|
+
error,
|
|
3436
|
+
rawMessage: ev.data,
|
|
3437
|
+
timestamp: Date.now()
|
|
3438
|
+
});
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
const buffer = await ev.data.arrayBuffer();
|
|
3442
|
+
if (buffer.byteLength === 0) {
|
|
3443
|
+
this.log("warn", "Ignoring empty WebSocket frame");
|
|
3444
|
+
return;
|
|
3445
|
+
}
|
|
3446
|
+
let decoded;
|
|
3447
|
+
try {
|
|
3448
|
+
decoded = decode(buffer);
|
|
3449
|
+
} catch (error) {
|
|
3450
|
+
this.connectionStats.totalErrors++;
|
|
3451
|
+
this.log("error", "Failed to decode WebSocket frame", {
|
|
3452
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3453
|
+
byteLength: buffer.byteLength
|
|
3454
|
+
});
|
|
3455
|
+
this.eventEmitter.emit("transport.error", {
|
|
3456
|
+
type: "message_decode_error",
|
|
3457
|
+
error,
|
|
3458
|
+
rawMessage: buffer,
|
|
3459
|
+
timestamp: Date.now()
|
|
3460
|
+
});
|
|
3461
|
+
return;
|
|
3462
|
+
}
|
|
3463
|
+
try {
|
|
3464
|
+
await this.handleRawMessage(decoded);
|
|
3465
|
+
} catch (error) {
|
|
3466
|
+
this.connectionStats.totalErrors++;
|
|
3467
|
+
this.log("error", "Failed to process WebSocket frame", {
|
|
3468
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3469
|
+
byteLength: buffer.byteLength
|
|
3470
|
+
});
|
|
3471
|
+
this.eventEmitter.emit("transport.error", {
|
|
3472
|
+
type: "message_handle_error",
|
|
3473
|
+
error,
|
|
3474
|
+
rawMessage: buffer,
|
|
3475
|
+
timestamp: Date.now()
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3460
3479
|
async handleRawMessage(ev) {
|
|
3461
3480
|
if (this.closed) {
|
|
3462
3481
|
this.log("debug", "Ignoring message received after transport was closed");
|