@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.
@@ -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
- if (!(ev.data instanceof Blob)) {
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", "Unexpected WebSocket message type", {
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: "message_type_error",
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");
@@ -5016,8 +5035,7 @@ var NotebookApi = class {
5016
5035
  constructor(client) {
5017
5036
  this.client = client;
5018
5037
  this.secrets = new NotebookSecretApi(client);
5019
- this.previewAuth = new NotebookPreviewAuthApi(client);
5020
- this.preview = this.previewAuth;
5038
+ this.preview = new NotebookPreviewApi(client);
5021
5039
  this.mail = new NotebookMailApi(client);
5022
5040
  }
5023
5041
  async create(template, input = {}, init = true) {
@@ -5149,14 +5167,6 @@ var NotebookPreviewApi = class {
5149
5167
  return response.data;
5150
5168
  }
5151
5169
  };
5152
- var NotebookPreviewAuthApi = class extends NotebookPreviewApi {
5153
- set(id, input) {
5154
- return this.setPassword(id, input);
5155
- }
5156
- delete(id) {
5157
- return this.disable(id);
5158
- }
5159
- };
5160
5170
  var NotebookMailApi = class {
5161
5171
  constructor(client) {
5162
5172
  this.client = client;
@@ -5216,8 +5226,7 @@ var NotebookInstance = class {
5216
5226
  this.git = new Git(this);
5217
5227
  this.services = new Services(this);
5218
5228
  this.secrets = new NotebookSecrets(client, this.data.id);
5219
- this.previewAuth = new NotebookPreviewAuth(client, this.data.id);
5220
- this.preview = this.previewAuth;
5229
+ this.preview = new NotebookPreview(client, this.data.id);
5221
5230
  this.mail = new NotebookMail(client, this.data.id);
5222
5231
  }
5223
5232
  async ready() {
@@ -5416,11 +5425,6 @@ var NotebookPreview = class {
5416
5425
  return this.client.notebook.preview.createHandoff(this.notebookId, input);
5417
5426
  }
5418
5427
  };
5419
- var NotebookPreviewAuth = class extends NotebookPreview {
5420
- set(input) {
5421
- return this.setPassword(input);
5422
- }
5423
- };
5424
5428
  var NotebookMail = class {
5425
5429
  constructor(client, notebookId) {
5426
5430
  this.client = client;
@@ -5478,8 +5482,6 @@ export {
5478
5482
  NotebookMailApi,
5479
5483
  NotebookPreview,
5480
5484
  NotebookPreviewApi,
5481
- NotebookPreviewAuth,
5482
- NotebookPreviewAuthApi,
5483
5485
  NotebookSecretApi,
5484
5486
  NotebookSecrets,
5485
5487
  NotebookState,