@phpsandbox/sdk 0.0.18 → 0.0.20
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 +40 -7
- package/dist/browser/phpsandbox-sdk.esm.js.map +2 -2
- package/dist/browser/phpsandbox-sdk.esm.min.js +2 -2
- package/dist/browser/phpsandbox-sdk.esm.min.js.map +3 -3
- package/dist/browser/phpsandbox-sdk.iife.js +40 -7
- package/dist/browser/phpsandbox-sdk.iife.js.map +2 -2
- package/dist/browser/phpsandbox-sdk.iife.min.js +2 -2
- package/dist/browser/phpsandbox-sdk.iife.min.js.map +3 -3
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/socket/index.d.ts +1 -0
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js +26 -1
- package/dist/socket/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3002,6 +3002,7 @@ var PHPSandbox = (() => {
|
|
|
3002
3002
|
this.closed = false;
|
|
3003
3003
|
this.disposables = new NamedDisposable();
|
|
3004
3004
|
this.connectPromise = null;
|
|
3005
|
+
this.pingIntervalStarted = false;
|
|
3005
3006
|
// Connection health monitoring
|
|
3006
3007
|
this.connectionStats = {
|
|
3007
3008
|
connectTime: 0,
|
|
@@ -3080,7 +3081,25 @@ var PHPSandbox = (() => {
|
|
|
3080
3081
|
throw new Error("Unexpected message type: " + typeof ev.data);
|
|
3081
3082
|
}
|
|
3082
3083
|
ev.data.arrayBuffer().then((buffer) => {
|
|
3083
|
-
|
|
3084
|
+
if (buffer.byteLength === 0) {
|
|
3085
|
+
this.log("warn", "Ignoring empty WebSocket frame");
|
|
3086
|
+
return;
|
|
3087
|
+
}
|
|
3088
|
+
try {
|
|
3089
|
+
this.handleRawMessage(decode(buffer));
|
|
3090
|
+
} catch (error) {
|
|
3091
|
+
this.connectionStats.totalErrors++;
|
|
3092
|
+
this.log("error", "Failed to decode WebSocket frame", {
|
|
3093
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3094
|
+
byteLength: buffer.byteLength
|
|
3095
|
+
});
|
|
3096
|
+
this.eventEmitter.emit("transport.error", {
|
|
3097
|
+
type: "message_decode_error",
|
|
3098
|
+
error,
|
|
3099
|
+
rawMessage: buffer,
|
|
3100
|
+
timestamp: Date.now()
|
|
3101
|
+
});
|
|
3102
|
+
}
|
|
3084
3103
|
});
|
|
3085
3104
|
};
|
|
3086
3105
|
this.rws.addEventListener("message", onMessage);
|
|
@@ -3725,6 +3744,10 @@ var PHPSandbox = (() => {
|
|
|
3725
3744
|
return this.connectPromise;
|
|
3726
3745
|
};
|
|
3727
3746
|
startPeriodicPing_fn = function() {
|
|
3747
|
+
if (this.pingIntervalStarted || this.closed) {
|
|
3748
|
+
return;
|
|
3749
|
+
}
|
|
3750
|
+
this.pingIntervalStarted = true;
|
|
3728
3751
|
this.disposables.add("pingInterval", () => {
|
|
3729
3752
|
const interval = setInterval(async () => {
|
|
3730
3753
|
try {
|
|
@@ -3748,6 +3771,7 @@ var PHPSandbox = (() => {
|
|
|
3748
3771
|
return {
|
|
3749
3772
|
dispose: () => {
|
|
3750
3773
|
clearInterval(interval);
|
|
3774
|
+
this.pingIntervalStarted = false;
|
|
3751
3775
|
}
|
|
3752
3776
|
};
|
|
3753
3777
|
});
|
|
@@ -4564,9 +4588,11 @@ var PHPSandbox = (() => {
|
|
|
4564
4588
|
|
|
4565
4589
|
// src/index.ts
|
|
4566
4590
|
var NotebookInitError = class extends Error {
|
|
4567
|
-
constructor(message) {
|
|
4591
|
+
constructor(message, data = {}) {
|
|
4568
4592
|
super(message);
|
|
4569
4593
|
this.message = message;
|
|
4594
|
+
this.data = data;
|
|
4595
|
+
this.name = "NotebookInitError";
|
|
4570
4596
|
}
|
|
4571
4597
|
};
|
|
4572
4598
|
var ApiError = class extends Error {
|
|
@@ -4593,6 +4619,10 @@ var PHPSandbox = (() => {
|
|
|
4593
4619
|
const response = await this.client.get(`/notebook/${id}`);
|
|
4594
4620
|
return new NotebookInstance(response.data, this.client);
|
|
4595
4621
|
}
|
|
4622
|
+
async update(id, input = {}) {
|
|
4623
|
+
const response = await this.client.put(`/notebook/${id}`, input);
|
|
4624
|
+
return new NotebookInstance(response.data, this.client);
|
|
4625
|
+
}
|
|
4596
4626
|
async delete(id) {
|
|
4597
4627
|
await this.client.delete(`/notebook/${id}`);
|
|
4598
4628
|
}
|
|
@@ -4636,6 +4666,9 @@ var PHPSandbox = (() => {
|
|
|
4636
4666
|
delete(path) {
|
|
4637
4667
|
return this.makeRequest("DELETE", path);
|
|
4638
4668
|
}
|
|
4669
|
+
put(path, body) {
|
|
4670
|
+
return this.makeRequest("PUT", path, { body: body ? JSON.stringify(body) : void 0 });
|
|
4671
|
+
}
|
|
4639
4672
|
async makeRequest(method, path, init) {
|
|
4640
4673
|
const response = await this.fetch(
|
|
4641
4674
|
new Request(new URL(`v1/${path.replace(/^\//, "")}`, this.baseUrl), {
|
|
@@ -4708,7 +4741,9 @@ var PHPSandbox = (() => {
|
|
|
4708
4741
|
return this.invoke("ping");
|
|
4709
4742
|
}
|
|
4710
4743
|
listen(event, handler) {
|
|
4711
|
-
|
|
4744
|
+
const disposable = this.emitter.listen(event, handler);
|
|
4745
|
+
this.disposables.push(disposable);
|
|
4746
|
+
return disposable;
|
|
4712
4747
|
}
|
|
4713
4748
|
dispose() {
|
|
4714
4749
|
this.disposables.forEach((d) => d.dispose());
|
|
@@ -4766,9 +4801,7 @@ var PHPSandbox = (() => {
|
|
|
4766
4801
|
return this.invoke("notebook.update");
|
|
4767
4802
|
}
|
|
4768
4803
|
onDidInitialize(handler) {
|
|
4769
|
-
|
|
4770
|
-
this.disposables.push(disposable);
|
|
4771
|
-
return disposable;
|
|
4804
|
+
return this.listen("notebook.initialized", handler);
|
|
4772
4805
|
}
|
|
4773
4806
|
async reconnect() {
|
|
4774
4807
|
const whenConnected = this.whenConnected();
|
|
@@ -4791,7 +4824,7 @@ var PHPSandbox = (() => {
|
|
|
4791
4824
|
this.onDidInitialize((result) => {
|
|
4792
4825
|
this.initialized = result;
|
|
4793
4826
|
if (result.type === "error") {
|
|
4794
|
-
reject(new NotebookInitError(result.message));
|
|
4827
|
+
reject(new NotebookInitError(result.message, result.data));
|
|
4795
4828
|
}
|
|
4796
4829
|
resolve(result);
|
|
4797
4830
|
});
|