@phpsandbox/sdk 0.0.3 → 0.0.5

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.
@@ -3321,6 +3321,19 @@ var PHPSandbox = (() => {
3321
3321
  }
3322
3322
  return this.call("invoke", { action, data }, options);
3323
3323
  }
3324
+ /**
3325
+ * Reconnect the websocket without disposing listeners.
3326
+ * Uses the underlying ReconnectingWebSocket's reconnect mechanism.
3327
+ * This preserves all event listeners and state.
3328
+ */
3329
+ reconnect() {
3330
+ if (this.closed) {
3331
+ throw new Error("Cannot reconnect a closed transport. The transport has been permanently closed.");
3332
+ }
3333
+ this.log("info", "Reconnecting transport");
3334
+ this.connectPromise = null;
3335
+ this.rws.reconnect();
3336
+ }
3324
3337
  disconnect() {
3325
3338
  if (this.closed) {
3326
3339
  console.trace("Transport is already closed, cannot disconnect again");
@@ -4599,7 +4612,7 @@ var PHPSandbox = (() => {
4599
4612
  var PHPSandbox = class extends Client {
4600
4613
  };
4601
4614
  var _initPromise, _NotebookInstance_instances, init_fn;
4602
- var _NotebookInstance = class _NotebookInstance {
4615
+ var NotebookInstance = class {
4603
4616
  constructor(data, client) {
4604
4617
  this.data = data;
4605
4618
  this.client = client;
@@ -4713,9 +4726,12 @@ var PHPSandbox = (() => {
4713
4726
  this.disposables.push(disposable);
4714
4727
  return disposable;
4715
4728
  }
4716
- reconnect() {
4717
- this.dispose();
4718
- return new _NotebookInstance(this.data, this.client);
4729
+ async reconnect() {
4730
+ this.socket.reconnect();
4731
+ this.initialized = false;
4732
+ await this.whenConnected();
4733
+ __privateMethod(this, _NotebookInstance_instances, init_fn).call(this);
4734
+ return this.ready().then(() => this);
4719
4735
  }
4720
4736
  async beacon(iframe, options) {
4721
4737
  const result = await this.ready();
@@ -4726,7 +4742,7 @@ var PHPSandbox = (() => {
4726
4742
  _initPromise = new WeakMap();
4727
4743
  _NotebookInstance_instances = new WeakSet();
4728
4744
  init_fn = function() {
4729
- return new Promise((resolve, reject) => {
4745
+ __privateSet(this, _initPromise, new Promise((resolve, reject) => {
4730
4746
  this.onDidInitialize((result) => {
4731
4747
  this.initialized = result;
4732
4748
  if (result.type === "error") {
@@ -4734,9 +4750,9 @@ var PHPSandbox = (() => {
4734
4750
  }
4735
4751
  resolve(result);
4736
4752
  });
4737
- });
4753
+ }));
4754
+ return __privateGet(this, _initPromise);
4738
4755
  };
4739
- var NotebookInstance = _NotebookInstance;
4740
4756
  return __toCommonJS(index_exports);
4741
4757
  })();
4742
4758
  /*! Bundled license information: