@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
|
@@ -338,6 +338,7 @@ var PHPSandbox = (() => {
|
|
|
338
338
|
PHPSandboxError: () => PHPSandboxError,
|
|
339
339
|
PromiseTimeoutError: () => PromiseTimeoutError,
|
|
340
340
|
RateLimitError: () => RateLimitError,
|
|
341
|
+
SendTimeoutError: () => SendTimeoutError,
|
|
341
342
|
Transport: () => Transport,
|
|
342
343
|
createBeacon: () => createBeacon,
|
|
343
344
|
isBeaconSupported: () => isBeaconSupported,
|
|
@@ -2912,13 +2913,20 @@ var PHPSandbox = (() => {
|
|
|
2912
2913
|
);
|
|
2913
2914
|
var reconnecting_websocket_mjs_default = ReconnectingWebSocket;
|
|
2914
2915
|
|
|
2915
|
-
// src/
|
|
2916
|
+
// src/errors/index.ts
|
|
2916
2917
|
var PromiseTimeoutError = class extends Error {
|
|
2917
2918
|
constructor(message, time) {
|
|
2918
2919
|
super(message);
|
|
2919
2920
|
this.time = time;
|
|
2920
2921
|
}
|
|
2921
2922
|
};
|
|
2923
|
+
var SendTimeoutError = class _SendTimeoutError extends PromiseTimeoutError {
|
|
2924
|
+
static fromPromiseTimeoutError(error) {
|
|
2925
|
+
return new _SendTimeoutError(error.message, error.time);
|
|
2926
|
+
}
|
|
2927
|
+
};
|
|
2928
|
+
|
|
2929
|
+
// src/utils/promise.ts
|
|
2922
2930
|
var timeout = (prom, time) => {
|
|
2923
2931
|
let timer;
|
|
2924
2932
|
return Promise.race([
|
|
@@ -3269,7 +3277,12 @@ var PHPSandbox = (() => {
|
|
|
3269
3277
|
if (!options.timeout) {
|
|
3270
3278
|
return promise;
|
|
3271
3279
|
}
|
|
3272
|
-
return timeout(promise, options.timeout).
|
|
3280
|
+
return timeout(promise, options.timeout).catch((error) => {
|
|
3281
|
+
if (error instanceof PromiseTimeoutError) {
|
|
3282
|
+
throw SendTimeoutError.fromPromiseTimeoutError(error);
|
|
3283
|
+
}
|
|
3284
|
+
throw error;
|
|
3285
|
+
}).finally(removeListeners);
|
|
3273
3286
|
};
|
|
3274
3287
|
return this.sendWithRetry(async () => await send(), options.retries || 10);
|
|
3275
3288
|
}
|
|
@@ -3290,6 +3303,13 @@ var PHPSandbox = (() => {
|
|
|
3290
3303
|
bail(e);
|
|
3291
3304
|
return;
|
|
3292
3305
|
}
|
|
3306
|
+
if (e instanceof SendTimeoutError) {
|
|
3307
|
+
this.reconnect();
|
|
3308
|
+
this.log("warn", "Send operation timed out, connection reset", {
|
|
3309
|
+
attempt,
|
|
3310
|
+
timeout: e.time
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3293
3313
|
this.log("debug", "Retrying send operation", {
|
|
3294
3314
|
attempt,
|
|
3295
3315
|
error: e instanceof Error ? e.message : String(e),
|
|
@@ -3321,6 +3341,19 @@ var PHPSandbox = (() => {
|
|
|
3321
3341
|
}
|
|
3322
3342
|
return this.call("invoke", { action, data }, options);
|
|
3323
3343
|
}
|
|
3344
|
+
/**
|
|
3345
|
+
* Reconnect the websocket without disposing listeners.
|
|
3346
|
+
* Uses the underlying ReconnectingWebSocket's reconnect mechanism.
|
|
3347
|
+
* This preserves all event listeners and state.
|
|
3348
|
+
*/
|
|
3349
|
+
reconnect() {
|
|
3350
|
+
if (this.closed) {
|
|
3351
|
+
throw new Error("Cannot reconnect a closed transport. The transport has been permanently closed.");
|
|
3352
|
+
}
|
|
3353
|
+
this.log("info", "Reconnecting transport");
|
|
3354
|
+
this.connectPromise = null;
|
|
3355
|
+
this.rws.reconnect();
|
|
3356
|
+
}
|
|
3324
3357
|
disconnect() {
|
|
3325
3358
|
if (this.closed) {
|
|
3326
3359
|
console.trace("Transport is already closed, cannot disconnect again");
|
|
@@ -4599,7 +4632,7 @@ var PHPSandbox = (() => {
|
|
|
4599
4632
|
var PHPSandbox = class extends Client {
|
|
4600
4633
|
};
|
|
4601
4634
|
var _initPromise, _NotebookInstance_instances, init_fn;
|
|
4602
|
-
var
|
|
4635
|
+
var NotebookInstance = class {
|
|
4603
4636
|
constructor(data, client) {
|
|
4604
4637
|
this.data = data;
|
|
4605
4638
|
this.client = client;
|
|
@@ -4713,9 +4746,12 @@ var PHPSandbox = (() => {
|
|
|
4713
4746
|
this.disposables.push(disposable);
|
|
4714
4747
|
return disposable;
|
|
4715
4748
|
}
|
|
4716
|
-
reconnect() {
|
|
4717
|
-
this.
|
|
4718
|
-
|
|
4749
|
+
async reconnect() {
|
|
4750
|
+
this.socket.reconnect();
|
|
4751
|
+
this.initialized = false;
|
|
4752
|
+
await this.whenConnected();
|
|
4753
|
+
__privateMethod(this, _NotebookInstance_instances, init_fn).call(this);
|
|
4754
|
+
return this.ready().then(() => this);
|
|
4719
4755
|
}
|
|
4720
4756
|
async beacon(iframe, options) {
|
|
4721
4757
|
const result = await this.ready();
|
|
@@ -4726,7 +4762,7 @@ var PHPSandbox = (() => {
|
|
|
4726
4762
|
_initPromise = new WeakMap();
|
|
4727
4763
|
_NotebookInstance_instances = new WeakSet();
|
|
4728
4764
|
init_fn = function() {
|
|
4729
|
-
|
|
4765
|
+
__privateSet(this, _initPromise, new Promise((resolve, reject) => {
|
|
4730
4766
|
this.onDidInitialize((result) => {
|
|
4731
4767
|
this.initialized = result;
|
|
4732
4768
|
if (result.type === "error") {
|
|
@@ -4734,9 +4770,9 @@ var PHPSandbox = (() => {
|
|
|
4734
4770
|
}
|
|
4735
4771
|
resolve(result);
|
|
4736
4772
|
});
|
|
4737
|
-
});
|
|
4773
|
+
}));
|
|
4774
|
+
return __privateGet(this, _initPromise);
|
|
4738
4775
|
};
|
|
4739
|
-
var NotebookInstance = _NotebookInstance;
|
|
4740
4776
|
return __toCommonJS(index_exports);
|
|
4741
4777
|
})();
|
|
4742
4778
|
/*! Bundled license information:
|