@phpsandbox/sdk 0.0.34 → 0.0.36
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 +77 -16
- 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 +77 -16
- 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 +28 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -1
- package/dist/socket/index.d.ts +2 -0
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js +37 -18
- package/dist/socket/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -333,6 +333,8 @@ var PHPSandbox = (() => {
|
|
|
333
333
|
NotebookApi: () => NotebookApi,
|
|
334
334
|
NotebookInitError: () => NotebookInitError,
|
|
335
335
|
NotebookInstance: () => NotebookInstance,
|
|
336
|
+
NotebookPreviewAuth: () => NotebookPreviewAuth,
|
|
337
|
+
NotebookPreviewAuthApi: () => NotebookPreviewAuthApi,
|
|
336
338
|
NotebookSecretApi: () => NotebookSecretApi,
|
|
337
339
|
NotebookSecrets: () => NotebookSecrets,
|
|
338
340
|
NotebookState: () => NotebookState,
|
|
@@ -3267,6 +3269,12 @@ var PHPSandbox = (() => {
|
|
|
3267
3269
|
};
|
|
3268
3270
|
|
|
3269
3271
|
// src/socket/index.ts
|
|
3272
|
+
var ConnectionTimeoutError = class extends Error {
|
|
3273
|
+
constructor(message = "WebSocket connection timeout") {
|
|
3274
|
+
super(message);
|
|
3275
|
+
this.name = "ConnectionTimeoutError";
|
|
3276
|
+
}
|
|
3277
|
+
};
|
|
3270
3278
|
var ConnectionFailedError = class extends Error {
|
|
3271
3279
|
constructor(message, originalError) {
|
|
3272
3280
|
super(message);
|
|
@@ -3325,6 +3333,7 @@ var PHPSandbox = (() => {
|
|
|
3325
3333
|
this.validateConfiguration(options);
|
|
3326
3334
|
this.url = new URL(url);
|
|
3327
3335
|
this.PING_INTERVAL = options.pingInterval ?? 3e4;
|
|
3336
|
+
this.CONNECT_WAIT_TIMEOUT = options.connectWaitTimeout ?? 3e4;
|
|
3328
3337
|
this.connectionStats.connectionStartTime = Date.now();
|
|
3329
3338
|
const startClosed = options.startClosed !== false;
|
|
3330
3339
|
this.rws = new reconnecting_websocket_mjs_default(this.url.toString(), [], {
|
|
@@ -3354,6 +3363,9 @@ var PHPSandbox = (() => {
|
|
|
3354
3363
|
if (options.connectionTimeout !== void 0 && (options.connectionTimeout < 100 || options.connectionTimeout > 3e4)) {
|
|
3355
3364
|
throw new InvalidConfigurationError("connectionTimeout must be between 100ms and 30000ms");
|
|
3356
3365
|
}
|
|
3366
|
+
if (options.connectWaitTimeout !== void 0 && (options.connectWaitTimeout < 1e3 || options.connectWaitTimeout > 3e5)) {
|
|
3367
|
+
throw new InvalidConfigurationError("connectWaitTimeout must be between 1000ms and 300000ms");
|
|
3368
|
+
}
|
|
3357
3369
|
if (options.maxRetries !== void 0 && (options.maxRetries < 0 || options.maxRetries > 100)) {
|
|
3358
3370
|
throw new InvalidConfigurationError("maxRetries must be between 0 and 100");
|
|
3359
3371
|
}
|
|
@@ -4088,34 +4100,50 @@ var PHPSandbox = (() => {
|
|
|
4088
4100
|
__privateMethod(this, _Transport_instances, startPeriodicPing_fn).call(this);
|
|
4089
4101
|
return;
|
|
4090
4102
|
}
|
|
4091
|
-
if (this.rws.readyState === 3) {
|
|
4092
|
-
this.rws.reconnect();
|
|
4093
|
-
}
|
|
4094
4103
|
let timeoutId;
|
|
4095
|
-
|
|
4104
|
+
let errorCount = 0;
|
|
4105
|
+
const cleanup = () => {
|
|
4096
4106
|
this.rws.removeEventListener("open", openHandler);
|
|
4097
4107
|
this.rws.removeEventListener("error", errorHandler);
|
|
4108
|
+
this.rws.removeEventListener("close", closeHandler);
|
|
4098
4109
|
clearTimeout(timeoutId);
|
|
4110
|
+
};
|
|
4111
|
+
const openHandler = () => {
|
|
4112
|
+
cleanup();
|
|
4099
4113
|
this.connectPromise = null;
|
|
4100
4114
|
resolve();
|
|
4101
4115
|
__privateMethod(this, _Transport_instances, startPeriodicPing_fn).call(this);
|
|
4102
4116
|
};
|
|
4103
4117
|
const errorHandler = (error) => {
|
|
4104
|
-
|
|
4105
|
-
this.
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4118
|
+
errorCount += 1;
|
|
4119
|
+
this.log("warn", "WebSocket emitted an error while connecting; waiting for reconnect/open", {
|
|
4120
|
+
errorCount,
|
|
4121
|
+
error: describeWebSocketEvent(error)
|
|
4122
|
+
});
|
|
4123
|
+
};
|
|
4124
|
+
const closeHandler = (event) => {
|
|
4125
|
+
const detail = describeWebSocketEvent(event);
|
|
4126
|
+
if ("code" in event && (event.code === 1008 || event.code === 4e3)) {
|
|
4127
|
+
cleanup();
|
|
4128
|
+
this.connectPromise = null;
|
|
4129
|
+
reject(new ConnectionFailedError(`WebSocket connection failed: ${detail}`, event));
|
|
4130
|
+
return;
|
|
4131
|
+
}
|
|
4132
|
+
this.log("warn", "WebSocket closed before opening; waiting for reconnect/open", {
|
|
4133
|
+
error: detail
|
|
4134
|
+
});
|
|
4110
4135
|
};
|
|
4111
|
-
timeoutId = setTimeout(() => {
|
|
4112
|
-
this.rws.removeEventListener("open", openHandler);
|
|
4113
|
-
this.rws.removeEventListener("error", errorHandler);
|
|
4114
|
-
this.connectPromise = null;
|
|
4115
|
-
reject(new Error("WebSocket connection timeout"));
|
|
4116
|
-
}, 1e4);
|
|
4117
4136
|
this.rws.addEventListener("open", openHandler);
|
|
4118
4137
|
this.rws.addEventListener("error", errorHandler);
|
|
4138
|
+
this.rws.addEventListener("close", closeHandler);
|
|
4139
|
+
if (this.rws.readyState === 3) {
|
|
4140
|
+
this.rws.reconnect();
|
|
4141
|
+
}
|
|
4142
|
+
timeoutId = setTimeout(() => {
|
|
4143
|
+
cleanup();
|
|
4144
|
+
this.connectPromise = null;
|
|
4145
|
+
reject(new ConnectionTimeoutError(`WebSocket connection timeout after ${this.CONNECT_WAIT_TIMEOUT}ms`));
|
|
4146
|
+
}, this.CONNECT_WAIT_TIMEOUT);
|
|
4119
4147
|
});
|
|
4120
4148
|
return this.connectPromise;
|
|
4121
4149
|
};
|
|
@@ -4990,6 +5018,7 @@ var PHPSandbox = (() => {
|
|
|
4990
5018
|
constructor(client) {
|
|
4991
5019
|
this.client = client;
|
|
4992
5020
|
this.secrets = new NotebookSecretApi(client);
|
|
5021
|
+
this.previewAuth = new NotebookPreviewAuthApi(client);
|
|
4993
5022
|
}
|
|
4994
5023
|
async create(template, input = {}, init = true) {
|
|
4995
5024
|
const response = await this.client.post("/notebook", { template, ...input });
|
|
@@ -5096,6 +5125,22 @@ var PHPSandbox = (() => {
|
|
|
5096
5125
|
await this.client.delete(`/notebook/${id}/secrets/${encodeURIComponent(name)}`);
|
|
5097
5126
|
}
|
|
5098
5127
|
};
|
|
5128
|
+
var NotebookPreviewAuthApi = class {
|
|
5129
|
+
constructor(client) {
|
|
5130
|
+
this.client = client;
|
|
5131
|
+
}
|
|
5132
|
+
async get(id) {
|
|
5133
|
+
const response = await this.client.get(`/notebook/${id}/preview-auth`);
|
|
5134
|
+
return response.data;
|
|
5135
|
+
}
|
|
5136
|
+
async set(id, input) {
|
|
5137
|
+
const response = await this.client.put(`/notebook/${id}/preview-auth`, input);
|
|
5138
|
+
return response.data;
|
|
5139
|
+
}
|
|
5140
|
+
async delete(id) {
|
|
5141
|
+
await this.client.delete(`/notebook/${id}/preview-auth`);
|
|
5142
|
+
}
|
|
5143
|
+
};
|
|
5099
5144
|
var _initPromise, _NotebookInstance_instances, init_fn;
|
|
5100
5145
|
var NotebookInstance = class {
|
|
5101
5146
|
constructor(data, client) {
|
|
@@ -5126,6 +5171,7 @@ var PHPSandbox = (() => {
|
|
|
5126
5171
|
this.git = new Git(this);
|
|
5127
5172
|
this.services = new Services(this);
|
|
5128
5173
|
this.secrets = new NotebookSecrets(client, this.data.id);
|
|
5174
|
+
this.previewAuth = new NotebookPreviewAuth(client, this.data.id);
|
|
5129
5175
|
}
|
|
5130
5176
|
async ready() {
|
|
5131
5177
|
const terminalError = this.socket.getTerminalError();
|
|
@@ -5299,6 +5345,21 @@ var PHPSandbox = (() => {
|
|
|
5299
5345
|
return this.client.notebook.secrets.delete(this.notebookId, name);
|
|
5300
5346
|
}
|
|
5301
5347
|
};
|
|
5348
|
+
var NotebookPreviewAuth = class {
|
|
5349
|
+
constructor(client, notebookId) {
|
|
5350
|
+
this.client = client;
|
|
5351
|
+
this.notebookId = notebookId;
|
|
5352
|
+
}
|
|
5353
|
+
get() {
|
|
5354
|
+
return this.client.notebook.previewAuth.get(this.notebookId);
|
|
5355
|
+
}
|
|
5356
|
+
set(input) {
|
|
5357
|
+
return this.client.notebook.previewAuth.set(this.notebookId, input);
|
|
5358
|
+
}
|
|
5359
|
+
disable() {
|
|
5360
|
+
return this.client.notebook.previewAuth.delete(this.notebookId);
|
|
5361
|
+
}
|
|
5362
|
+
};
|
|
5302
5363
|
return __toCommonJS(index_exports);
|
|
5303
5364
|
})();
|
|
5304
5365
|
/*! Bundled license information:
|