@phpsandbox/sdk 0.0.40 → 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.
@@ -337,8 +337,6 @@ var PHPSandbox = (() => {
337
337
  NotebookMailApi: () => NotebookMailApi,
338
338
  NotebookPreview: () => NotebookPreview,
339
339
  NotebookPreviewApi: () => NotebookPreviewApi,
340
- NotebookPreviewAuth: () => NotebookPreviewAuth,
341
- NotebookPreviewAuthApi: () => NotebookPreviewAuthApi,
342
340
  NotebookSecretApi: () => NotebookSecretApi,
343
341
  NotebookSecrets: () => NotebookSecrets,
344
342
  NotebookState: () => NotebookState,
@@ -3362,7 +3360,6 @@ var PHPSandbox = (() => {
3362
3360
  };
3363
3361
  var _Transport_instances, connect_fn, startPeriodicPing_fn;
3364
3362
  var Transport = class {
3365
- // 30 seconds
3366
3363
  constructor(url, eventEmitter, options = {}) {
3367
3364
  this.eventEmitter = eventEmitter;
3368
3365
  this.options = options;
@@ -3388,6 +3385,8 @@ var PHPSandbox = (() => {
3388
3385
  this.messageQueue = [];
3389
3386
  this.MAX_QUEUE_SIZE = 100;
3390
3387
  this.QUEUE_TIMEOUT = 3e4;
3388
+ // 30 seconds
3389
+ this.incomingMessageChain = Promise.resolve();
3391
3390
  this.validateConfiguration(options);
3392
3391
  this.url = new URL(url);
3393
3392
  this.PING_INTERVAL = options.pingInterval ?? 3e4;
@@ -3452,53 +3451,17 @@ var PHPSandbox = (() => {
3452
3451
  }
3453
3452
  async registerWatchers() {
3454
3453
  const onMessage = (ev) => {
3455
- if (!(ev.data instanceof Blob)) {
3456
- const error = new Error("Unexpected message type: " + typeof ev.data);
3454
+ this.incomingMessageChain = this.incomingMessageChain.catch(() => void 0).then(() => this.processIncomingMessage(ev)).catch((error) => {
3457
3455
  this.connectionStats.totalErrors++;
3458
- this.log("error", "Unexpected WebSocket message type", {
3459
- error: error.message,
3460
- messageType: typeof ev.data
3456
+ this.log("error", "Failed to process queued WebSocket frame", {
3457
+ error: error instanceof Error ? error.message : String(error)
3461
3458
  });
3462
3459
  this.eventEmitter.emit("transport.error", {
3463
- type: "message_type_error",
3460
+ type: "message_handle_error",
3464
3461
  error,
3465
3462
  rawMessage: ev.data,
3466
3463
  timestamp: Date.now()
3467
3464
  });
3468
- return;
3469
- }
3470
- ev.data.arrayBuffer().then((buffer) => {
3471
- if (buffer.byteLength === 0) {
3472
- this.log("warn", "Ignoring empty WebSocket frame");
3473
- return;
3474
- }
3475
- try {
3476
- void this.handleRawMessage(decode(buffer)).catch((error) => {
3477
- this.connectionStats.totalErrors++;
3478
- this.log("error", "Failed to process WebSocket frame", {
3479
- error: error instanceof Error ? error.message : String(error),
3480
- byteLength: buffer.byteLength
3481
- });
3482
- this.eventEmitter.emit("transport.error", {
3483
- type: "message_handle_error",
3484
- error,
3485
- rawMessage: buffer,
3486
- timestamp: Date.now()
3487
- });
3488
- });
3489
- } catch (error) {
3490
- this.connectionStats.totalErrors++;
3491
- this.log("error", "Failed to decode WebSocket frame", {
3492
- error: error instanceof Error ? error.message : String(error),
3493
- byteLength: buffer.byteLength
3494
- });
3495
- this.eventEmitter.emit("transport.error", {
3496
- type: "message_decode_error",
3497
- error,
3498
- rawMessage: buffer,
3499
- timestamp: Date.now()
3500
- });
3501
- }
3502
3465
  });
3503
3466
  };
3504
3467
  this.rws.addEventListener("message", onMessage);
@@ -3508,6 +3471,60 @@ var PHPSandbox = (() => {
3508
3471
  }
3509
3472
  });
3510
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
+ }
3511
3528
  async handleRawMessage(ev) {
3512
3529
  if (this.closed) {
3513
3530
  this.log("debug", "Ignoring message received after transport was closed");
@@ -5067,8 +5084,7 @@ var PHPSandbox = (() => {
5067
5084
  constructor(client) {
5068
5085
  this.client = client;
5069
5086
  this.secrets = new NotebookSecretApi(client);
5070
- this.previewAuth = new NotebookPreviewAuthApi(client);
5071
- this.preview = this.previewAuth;
5087
+ this.preview = new NotebookPreviewApi(client);
5072
5088
  this.mail = new NotebookMailApi(client);
5073
5089
  }
5074
5090
  async create(template, input = {}, init = true) {
@@ -5200,14 +5216,6 @@ var PHPSandbox = (() => {
5200
5216
  return response.data;
5201
5217
  }
5202
5218
  };
5203
- var NotebookPreviewAuthApi = class extends NotebookPreviewApi {
5204
- set(id, input) {
5205
- return this.setPassword(id, input);
5206
- }
5207
- delete(id) {
5208
- return this.disable(id);
5209
- }
5210
- };
5211
5219
  var NotebookMailApi = class {
5212
5220
  constructor(client) {
5213
5221
  this.client = client;
@@ -5267,8 +5275,7 @@ var PHPSandbox = (() => {
5267
5275
  this.git = new Git(this);
5268
5276
  this.services = new Services(this);
5269
5277
  this.secrets = new NotebookSecrets(client, this.data.id);
5270
- this.previewAuth = new NotebookPreviewAuth(client, this.data.id);
5271
- this.preview = this.previewAuth;
5278
+ this.preview = new NotebookPreview(client, this.data.id);
5272
5279
  this.mail = new NotebookMail(client, this.data.id);
5273
5280
  }
5274
5281
  async ready() {
@@ -5467,11 +5474,6 @@ var PHPSandbox = (() => {
5467
5474
  return this.client.notebook.preview.createHandoff(this.notebookId, input);
5468
5475
  }
5469
5476
  };
5470
- var NotebookPreviewAuth = class extends NotebookPreview {
5471
- set(input) {
5472
- return this.setPassword(input);
5473
- }
5474
- };
5475
5477
  var NotebookMail = class {
5476
5478
  constructor(client, notebookId) {
5477
5479
  this.client = client;