@phpsandbox/sdk 0.0.41 → 0.0.43

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.
@@ -1200,6 +1200,22 @@ var Services = class {
1200
1200
  }
1201
1201
  };
1202
1202
 
1203
+ // src/config.ts
1204
+ var Config = class {
1205
+ constructor(okra) {
1206
+ this.okra = okra;
1207
+ }
1208
+ get() {
1209
+ return this.okra.invoke("config.get");
1210
+ }
1211
+ update(config) {
1212
+ return this.okra.invoke("config.update", { config });
1213
+ }
1214
+ setPorts(ports) {
1215
+ return this.okra.invoke("config.set-ports", { ports });
1216
+ }
1217
+ };
1218
+
1203
1219
  // node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs
1204
1220
  function utf8Count(str) {
1205
1221
  const strLength = str.length;
@@ -3311,7 +3327,6 @@ var InvalidConfigurationError = class extends Error {
3311
3327
  };
3312
3328
  var _Transport_instances, connect_fn, startPeriodicPing_fn;
3313
3329
  var Transport = class {
3314
- // 30 seconds
3315
3330
  constructor(url, eventEmitter, options = {}) {
3316
3331
  this.eventEmitter = eventEmitter;
3317
3332
  this.options = options;
@@ -3337,6 +3352,8 @@ var Transport = class {
3337
3352
  this.messageQueue = [];
3338
3353
  this.MAX_QUEUE_SIZE = 100;
3339
3354
  this.QUEUE_TIMEOUT = 3e4;
3355
+ // 30 seconds
3356
+ this.incomingMessageChain = Promise.resolve();
3340
3357
  this.validateConfiguration(options);
3341
3358
  this.url = new URL(url);
3342
3359
  this.PING_INTERVAL = options.pingInterval ?? 3e4;
@@ -3401,53 +3418,17 @@ var Transport = class {
3401
3418
  }
3402
3419
  async registerWatchers() {
3403
3420
  const onMessage = (ev) => {
3404
- if (!(ev.data instanceof Blob)) {
3405
- const error = new Error("Unexpected message type: " + typeof ev.data);
3421
+ this.incomingMessageChain = this.incomingMessageChain.catch(() => void 0).then(() => this.processIncomingMessage(ev)).catch((error) => {
3406
3422
  this.connectionStats.totalErrors++;
3407
- this.log("error", "Unexpected WebSocket message type", {
3408
- error: error.message,
3409
- messageType: typeof ev.data
3423
+ this.log("error", "Failed to process queued WebSocket frame", {
3424
+ error: error instanceof Error ? error.message : String(error)
3410
3425
  });
3411
3426
  this.eventEmitter.emit("transport.error", {
3412
- type: "message_type_error",
3427
+ type: "message_handle_error",
3413
3428
  error,
3414
3429
  rawMessage: ev.data,
3415
3430
  timestamp: Date.now()
3416
3431
  });
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
3432
  });
3452
3433
  };
3453
3434
  this.rws.addEventListener("message", onMessage);
@@ -3457,6 +3438,60 @@ var Transport = class {
3457
3438
  }
3458
3439
  });
3459
3440
  }
3441
+ async processIncomingMessage(ev) {
3442
+ if (!(ev.data instanceof Blob)) {
3443
+ const error = new Error("Unexpected message type: " + typeof ev.data);
3444
+ this.connectionStats.totalErrors++;
3445
+ this.log("error", "Unexpected WebSocket message type", {
3446
+ error: error.message,
3447
+ messageType: typeof ev.data
3448
+ });
3449
+ this.eventEmitter.emit("transport.error", {
3450
+ type: "message_type_error",
3451
+ error,
3452
+ rawMessage: ev.data,
3453
+ timestamp: Date.now()
3454
+ });
3455
+ return;
3456
+ }
3457
+ const buffer = await ev.data.arrayBuffer();
3458
+ if (buffer.byteLength === 0) {
3459
+ this.log("warn", "Ignoring empty WebSocket frame");
3460
+ return;
3461
+ }
3462
+ let decoded;
3463
+ try {
3464
+ decoded = decode(buffer);
3465
+ } catch (error) {
3466
+ this.connectionStats.totalErrors++;
3467
+ this.log("error", "Failed to decode 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_decode_error",
3473
+ error,
3474
+ rawMessage: buffer,
3475
+ timestamp: Date.now()
3476
+ });
3477
+ return;
3478
+ }
3479
+ try {
3480
+ await this.handleRawMessage(decoded);
3481
+ } catch (error) {
3482
+ this.connectionStats.totalErrors++;
3483
+ this.log("error", "Failed to process WebSocket frame", {
3484
+ error: error instanceof Error ? error.message : String(error),
3485
+ byteLength: buffer.byteLength
3486
+ });
3487
+ this.eventEmitter.emit("transport.error", {
3488
+ type: "message_handle_error",
3489
+ error,
3490
+ rawMessage: buffer,
3491
+ timestamp: Date.now()
3492
+ });
3493
+ }
3494
+ }
3460
3495
  async handleRawMessage(ev) {
3461
3496
  if (this.closed) {
3462
3497
  this.log("debug", "Ignoring message received after transport was closed");
@@ -5206,6 +5241,7 @@ var NotebookInstance = class {
5206
5241
  this.shell = new Shell(this);
5207
5242
  this.git = new Git(this);
5208
5243
  this.services = new Services(this);
5244
+ this.config = new Config(this);
5209
5245
  this.secrets = new NotebookSecrets(client, this.data.id);
5210
5246
  this.preview = new NotebookPreview(client, this.data.id);
5211
5247
  this.mail = new NotebookMail(client, this.data.id);