@phpsandbox/sdk 0.0.36 → 0.0.38
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/README.md +17 -0
- package/dist/browser/phpsandbox-sdk.esm.js +113 -18
- 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 +113 -18
- 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 +53 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -1
- package/dist/terminal.d.ts +13 -0
- package/dist/terminal.d.ts.map +1 -1
- package/dist/terminal.js +38 -14
- package/dist/terminal.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
|
+
NotebookMail: () => NotebookMail,
|
|
337
|
+
NotebookMailApi: () => NotebookMailApi,
|
|
336
338
|
NotebookPreviewAuth: () => NotebookPreviewAuth,
|
|
337
339
|
NotebookPreviewAuthApi: () => NotebookPreviewAuthApi,
|
|
338
340
|
NotebookSecretApi: () => NotebookSecretApi,
|
|
@@ -671,8 +673,46 @@ var PHPSandbox = (() => {
|
|
|
671
673
|
listen(event, handler) {
|
|
672
674
|
return this.okra.listen(event, handler);
|
|
673
675
|
}
|
|
676
|
+
async attach(id, opts) {
|
|
677
|
+
const handle = this.processHandle(id, opts?.abortSignal);
|
|
678
|
+
const task = await this.okra.invoke(
|
|
679
|
+
"terminal.attach",
|
|
680
|
+
{
|
|
681
|
+
id,
|
|
682
|
+
replayHistory: opts?.replayHistory
|
|
683
|
+
},
|
|
684
|
+
{ abortSignal: opts?.abortSignal }
|
|
685
|
+
);
|
|
686
|
+
if (!task) {
|
|
687
|
+
handle.dispose();
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
return {
|
|
691
|
+
...handle.process,
|
|
692
|
+
...task
|
|
693
|
+
};
|
|
694
|
+
}
|
|
674
695
|
async spawn(command, args, opts) {
|
|
675
696
|
const id = opts?.id || nanoid();
|
|
697
|
+
const handle = this.processHandle(id, opts?.abortSignal);
|
|
698
|
+
const { abortSignal, ...otherOpts } = opts ?? {};
|
|
699
|
+
const result = await this.okra.invoke(
|
|
700
|
+
"terminal.spawn",
|
|
701
|
+
{
|
|
702
|
+
command: [command, ...args],
|
|
703
|
+
opts: {
|
|
704
|
+
id,
|
|
705
|
+
...otherOpts
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
{ abortSignal }
|
|
709
|
+
);
|
|
710
|
+
return {
|
|
711
|
+
...handle.process,
|
|
712
|
+
...result
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
processHandle(id, abortSignal) {
|
|
676
716
|
const disposables = /* @__PURE__ */ new Set();
|
|
677
717
|
const dispose = () => {
|
|
678
718
|
for (const disposable of disposables) {
|
|
@@ -722,28 +762,18 @@ var PHPSandbox = (() => {
|
|
|
722
762
|
const resize = (dimensions) => {
|
|
723
763
|
this.okra.invoke("terminal.resize", { id, width: dimensions.cols, height: dimensions.rows });
|
|
724
764
|
};
|
|
725
|
-
const { abortSignal, ...otherOpts } = opts ?? {};
|
|
726
765
|
if (abortSignal) {
|
|
727
766
|
abortSignal.addEventListener("abort", kill);
|
|
728
767
|
}
|
|
729
|
-
const result = await this.okra.invoke(
|
|
730
|
-
"terminal.spawn",
|
|
731
|
-
{
|
|
732
|
-
command: [command, ...args],
|
|
733
|
-
opts: {
|
|
734
|
-
id,
|
|
735
|
-
...otherOpts
|
|
736
|
-
}
|
|
737
|
-
},
|
|
738
|
-
{ abortSignal }
|
|
739
|
-
);
|
|
740
768
|
return {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
769
|
+
process: {
|
|
770
|
+
exit,
|
|
771
|
+
input,
|
|
772
|
+
output,
|
|
773
|
+
kill,
|
|
774
|
+
resize
|
|
775
|
+
},
|
|
776
|
+
dispose
|
|
747
777
|
};
|
|
748
778
|
}
|
|
749
779
|
};
|
|
@@ -5019,6 +5049,7 @@ var PHPSandbox = (() => {
|
|
|
5019
5049
|
this.client = client;
|
|
5020
5050
|
this.secrets = new NotebookSecretApi(client);
|
|
5021
5051
|
this.previewAuth = new NotebookPreviewAuthApi(client);
|
|
5052
|
+
this.mail = new NotebookMailApi(client);
|
|
5022
5053
|
}
|
|
5023
5054
|
async create(template, input = {}, init = true) {
|
|
5024
5055
|
const response = await this.client.post("/notebook", { template, ...input });
|
|
@@ -5141,6 +5172,35 @@ var PHPSandbox = (() => {
|
|
|
5141
5172
|
await this.client.delete(`/notebook/${id}/preview-auth`);
|
|
5142
5173
|
}
|
|
5143
5174
|
};
|
|
5175
|
+
var NotebookMailApi = class {
|
|
5176
|
+
constructor(client) {
|
|
5177
|
+
this.client = client;
|
|
5178
|
+
}
|
|
5179
|
+
async status(id) {
|
|
5180
|
+
const response = await this.client.get(`/notebook/${id}/mail`);
|
|
5181
|
+
return response.data;
|
|
5182
|
+
}
|
|
5183
|
+
async enable(id) {
|
|
5184
|
+
const response = await this.client.put(`/notebook/${id}/mail`);
|
|
5185
|
+
return response.data;
|
|
5186
|
+
}
|
|
5187
|
+
async disable(id) {
|
|
5188
|
+
await this.client.delete(`/notebook/${id}/mail`);
|
|
5189
|
+
}
|
|
5190
|
+
async list(id, options = {}) {
|
|
5191
|
+
const response = await this.client.get(
|
|
5192
|
+
`/notebook/${id}/mails${formatQueryString(options)}`
|
|
5193
|
+
);
|
|
5194
|
+
return response.data;
|
|
5195
|
+
}
|
|
5196
|
+
async get(id, hash) {
|
|
5197
|
+
const response = await this.client.get(`/notebook/${id}/mails/${encodeURIComponent(hash)}`);
|
|
5198
|
+
return response.data;
|
|
5199
|
+
}
|
|
5200
|
+
async delete(id, hash) {
|
|
5201
|
+
await this.client.delete(`/notebook/${id}/mails/${encodeURIComponent(hash)}`);
|
|
5202
|
+
}
|
|
5203
|
+
};
|
|
5144
5204
|
var _initPromise, _NotebookInstance_instances, init_fn;
|
|
5145
5205
|
var NotebookInstance = class {
|
|
5146
5206
|
constructor(data, client) {
|
|
@@ -5172,6 +5232,7 @@ var PHPSandbox = (() => {
|
|
|
5172
5232
|
this.services = new Services(this);
|
|
5173
5233
|
this.secrets = new NotebookSecrets(client, this.data.id);
|
|
5174
5234
|
this.previewAuth = new NotebookPreviewAuth(client, this.data.id);
|
|
5235
|
+
this.mail = new NotebookMail(client, this.data.id);
|
|
5175
5236
|
}
|
|
5176
5237
|
async ready() {
|
|
5177
5238
|
const terminalError = this.socket.getTerminalError();
|
|
@@ -5360,6 +5421,40 @@ var PHPSandbox = (() => {
|
|
|
5360
5421
|
return this.client.notebook.previewAuth.delete(this.notebookId);
|
|
5361
5422
|
}
|
|
5362
5423
|
};
|
|
5424
|
+
var NotebookMail = class {
|
|
5425
|
+
constructor(client, notebookId) {
|
|
5426
|
+
this.client = client;
|
|
5427
|
+
this.notebookId = notebookId;
|
|
5428
|
+
}
|
|
5429
|
+
status() {
|
|
5430
|
+
return this.client.notebook.mail.status(this.notebookId);
|
|
5431
|
+
}
|
|
5432
|
+
enable() {
|
|
5433
|
+
return this.client.notebook.mail.enable(this.notebookId);
|
|
5434
|
+
}
|
|
5435
|
+
disable() {
|
|
5436
|
+
return this.client.notebook.mail.disable(this.notebookId);
|
|
5437
|
+
}
|
|
5438
|
+
list(options = {}) {
|
|
5439
|
+
return this.client.notebook.mail.list(this.notebookId, options);
|
|
5440
|
+
}
|
|
5441
|
+
get(hash) {
|
|
5442
|
+
return this.client.notebook.mail.get(this.notebookId, hash);
|
|
5443
|
+
}
|
|
5444
|
+
delete(hash) {
|
|
5445
|
+
return this.client.notebook.mail.delete(this.notebookId, hash);
|
|
5446
|
+
}
|
|
5447
|
+
};
|
|
5448
|
+
function formatQueryString(params) {
|
|
5449
|
+
const searchParams = new URLSearchParams();
|
|
5450
|
+
for (const [key, value] of Object.entries(params)) {
|
|
5451
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
5452
|
+
searchParams.set(key, String(value));
|
|
5453
|
+
}
|
|
5454
|
+
}
|
|
5455
|
+
const query = searchParams.toString();
|
|
5456
|
+
return query === "" ? "" : `?${query}`;
|
|
5457
|
+
}
|
|
5363
5458
|
return __toCommonJS(index_exports);
|
|
5364
5459
|
})();
|
|
5365
5460
|
/*! Bundled license information:
|