@phpsandbox/sdk 0.0.3 → 0.0.6
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 +45 -9
- package/dist/browser/phpsandbox-sdk.esm.js.map +3 -3
- package/dist/browser/phpsandbox-sdk.esm.min.js +2 -2
- package/dist/browser/phpsandbox-sdk.esm.min.js.map +4 -4
- package/dist/browser/phpsandbox-sdk.iife.js +45 -9
- package/dist/browser/phpsandbox-sdk.iife.js.map +3 -3
- package/dist/browser/phpsandbox-sdk.iife.min.js +2 -2
- package/dist/browser/phpsandbox-sdk.iife.min.js.map +4 -4
- package/dist/errors/index.d.ts +8 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +12 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/socket/index.d.ts +6 -0
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js +34 -1
- package/dist/socket/index.js.map +1 -1
- package/dist/utils/promise.d.ts +0 -4
- package/dist/utils/promise.d.ts.map +1 -1
- package/dist/utils/promise.js +1 -6
- package/dist/utils/promise.js.map +1 -1
- package/package.json +2 -1
|
@@ -2874,13 +2874,20 @@ var ReconnectingWebSocket = (
|
|
|
2874
2874
|
);
|
|
2875
2875
|
var reconnecting_websocket_mjs_default = ReconnectingWebSocket;
|
|
2876
2876
|
|
|
2877
|
-
// src/
|
|
2877
|
+
// src/errors/index.ts
|
|
2878
2878
|
var PromiseTimeoutError = class extends Error {
|
|
2879
2879
|
constructor(message, time) {
|
|
2880
2880
|
super(message);
|
|
2881
2881
|
this.time = time;
|
|
2882
2882
|
}
|
|
2883
2883
|
};
|
|
2884
|
+
var SendTimeoutError = class _SendTimeoutError extends PromiseTimeoutError {
|
|
2885
|
+
static fromPromiseTimeoutError(error) {
|
|
2886
|
+
return new _SendTimeoutError(error.message, error.time);
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
|
|
2890
|
+
// src/utils/promise.ts
|
|
2884
2891
|
var timeout = (prom, time) => {
|
|
2885
2892
|
let timer;
|
|
2886
2893
|
return Promise.race([
|
|
@@ -3231,7 +3238,12 @@ var Transport = class {
|
|
|
3231
3238
|
if (!options.timeout) {
|
|
3232
3239
|
return promise;
|
|
3233
3240
|
}
|
|
3234
|
-
return timeout(promise, options.timeout).
|
|
3241
|
+
return timeout(promise, options.timeout).catch((error) => {
|
|
3242
|
+
if (error instanceof PromiseTimeoutError) {
|
|
3243
|
+
throw SendTimeoutError.fromPromiseTimeoutError(error);
|
|
3244
|
+
}
|
|
3245
|
+
throw error;
|
|
3246
|
+
}).finally(removeListeners);
|
|
3235
3247
|
};
|
|
3236
3248
|
return this.sendWithRetry(async () => await send(), options.retries || 10);
|
|
3237
3249
|
}
|
|
@@ -3252,6 +3264,13 @@ var Transport = class {
|
|
|
3252
3264
|
bail(e);
|
|
3253
3265
|
return;
|
|
3254
3266
|
}
|
|
3267
|
+
if (e instanceof SendTimeoutError) {
|
|
3268
|
+
this.reconnect();
|
|
3269
|
+
this.log("warn", "Send operation timed out, connection reset", {
|
|
3270
|
+
attempt,
|
|
3271
|
+
timeout: e.time
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3255
3274
|
this.log("debug", "Retrying send operation", {
|
|
3256
3275
|
attempt,
|
|
3257
3276
|
error: e instanceof Error ? e.message : String(e),
|
|
@@ -3283,6 +3302,19 @@ var Transport = class {
|
|
|
3283
3302
|
}
|
|
3284
3303
|
return this.call("invoke", { action, data }, options);
|
|
3285
3304
|
}
|
|
3305
|
+
/**
|
|
3306
|
+
* Reconnect the websocket without disposing listeners.
|
|
3307
|
+
* Uses the underlying ReconnectingWebSocket's reconnect mechanism.
|
|
3308
|
+
* This preserves all event listeners and state.
|
|
3309
|
+
*/
|
|
3310
|
+
reconnect() {
|
|
3311
|
+
if (this.closed) {
|
|
3312
|
+
throw new Error("Cannot reconnect a closed transport. The transport has been permanently closed.");
|
|
3313
|
+
}
|
|
3314
|
+
this.log("info", "Reconnecting transport");
|
|
3315
|
+
this.connectPromise = null;
|
|
3316
|
+
this.rws.reconnect();
|
|
3317
|
+
}
|
|
3286
3318
|
disconnect() {
|
|
3287
3319
|
if (this.closed) {
|
|
3288
3320
|
console.trace("Transport is already closed, cannot disconnect again");
|
|
@@ -4561,7 +4593,7 @@ var Client = class {
|
|
|
4561
4593
|
var PHPSandbox = class extends Client {
|
|
4562
4594
|
};
|
|
4563
4595
|
var _initPromise, _NotebookInstance_instances, init_fn;
|
|
4564
|
-
var
|
|
4596
|
+
var NotebookInstance = class {
|
|
4565
4597
|
constructor(data, client) {
|
|
4566
4598
|
this.data = data;
|
|
4567
4599
|
this.client = client;
|
|
@@ -4675,9 +4707,12 @@ var _NotebookInstance = class _NotebookInstance {
|
|
|
4675
4707
|
this.disposables.push(disposable);
|
|
4676
4708
|
return disposable;
|
|
4677
4709
|
}
|
|
4678
|
-
reconnect() {
|
|
4679
|
-
this.
|
|
4680
|
-
|
|
4710
|
+
async reconnect() {
|
|
4711
|
+
this.socket.reconnect();
|
|
4712
|
+
this.initialized = false;
|
|
4713
|
+
await this.whenConnected();
|
|
4714
|
+
__privateMethod(this, _NotebookInstance_instances, init_fn).call(this);
|
|
4715
|
+
return this.ready().then(() => this);
|
|
4681
4716
|
}
|
|
4682
4717
|
async beacon(iframe, options) {
|
|
4683
4718
|
const result = await this.ready();
|
|
@@ -4688,7 +4723,7 @@ var _NotebookInstance = class _NotebookInstance {
|
|
|
4688
4723
|
_initPromise = new WeakMap();
|
|
4689
4724
|
_NotebookInstance_instances = new WeakSet();
|
|
4690
4725
|
init_fn = function() {
|
|
4691
|
-
|
|
4726
|
+
__privateSet(this, _initPromise, new Promise((resolve, reject) => {
|
|
4692
4727
|
this.onDidInitialize((result) => {
|
|
4693
4728
|
this.initialized = result;
|
|
4694
4729
|
if (result.type === "error") {
|
|
@@ -4696,9 +4731,9 @@ init_fn = function() {
|
|
|
4696
4731
|
}
|
|
4697
4732
|
resolve(result);
|
|
4698
4733
|
});
|
|
4699
|
-
});
|
|
4734
|
+
}));
|
|
4735
|
+
return __privateGet(this, _initPromise);
|
|
4700
4736
|
};
|
|
4701
|
-
var NotebookInstance = _NotebookInstance;
|
|
4702
4737
|
export {
|
|
4703
4738
|
ApiError,
|
|
4704
4739
|
Beacon,
|
|
@@ -4723,6 +4758,7 @@ export {
|
|
|
4723
4758
|
PHPSandboxError,
|
|
4724
4759
|
PromiseTimeoutError,
|
|
4725
4760
|
RateLimitError,
|
|
4761
|
+
SendTimeoutError,
|
|
4726
4762
|
Transport,
|
|
4727
4763
|
createBeacon,
|
|
4728
4764
|
isBeaconSupported,
|