@phpsandbox/sdk 0.1.1 → 0.1.2
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 +59 -22
- package/dist/browser/phpsandbox-sdk.esm.js +465 -239
- package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
- package/dist/browser/phpsandbox-sdk.iife.js +465 -239
- package/dist/browser/phpsandbox-sdk.iife.min.js +24 -24
- package/dist/composer.d.ts +36 -23
- package/dist/composer.js +61 -11
- package/dist/container.d.ts +2 -6
- package/dist/container.js +0 -28
- package/dist/filesystem.d.ts +58 -18
- package/dist/filesystem.js +148 -63
- package/dist/index.d.ts +18 -9
- package/dist/index.js +21 -8
- package/dist/log.d.ts +11 -5
- package/dist/log.js +10 -7
- package/dist/metrics.d.ts +10 -0
- package/dist/metrics.js +13 -0
- package/dist/ports.d.ts +10 -0
- package/dist/ports.js +13 -0
- package/dist/runtime/rest.js +1 -4
- package/dist/runtime-telemetry.d.ts +15 -0
- package/dist/runtime-telemetry.js +111 -0
- package/dist/schemas/publications.d.ts +10 -10
- package/dist/services.d.ts +2 -9
- package/dist/services.js +3 -10
- package/dist/shell.d.ts +9 -0
- package/dist/shell.js +4 -4
- package/dist/terminal.d.ts +17 -11
- package/dist/terminal.js +27 -44
- package/docs/api-summary.md +28 -23
- package/docs/cdn-usage.md +2 -2
- package/docs/getting-started.md +13 -13
- package/examples/basic.ts +1 -1
- package/examples/git-merge-smoke.ts +1 -4
- package/examples/laravel-load-test.ts +67 -80
- package/examples/notebook-readonly-smoke.ts +30 -33
- package/package.json +1 -1
|
@@ -155,12 +155,12 @@ async function main(): Promise<void> {
|
|
|
155
155
|
}, false);
|
|
156
156
|
|
|
157
157
|
await recordStep(steps, 'container.opened-ports', options.stepTimeoutMs, async () => {
|
|
158
|
-
const ports = await notebook!.
|
|
159
|
-
return describePorts(assertPortInfoList(ports, '
|
|
158
|
+
const ports = await notebook!.ports.list();
|
|
159
|
+
return describePorts(assertPortInfoList(ports, 'ports.list'));
|
|
160
160
|
}, false);
|
|
161
161
|
|
|
162
162
|
const rootSnapshot = await recordStep(steps, 'filesystem.root', options.stepTimeoutMs, async () => {
|
|
163
|
-
const rootEntries = await notebook!.
|
|
163
|
+
const rootEntries = await notebook!.files.list('/');
|
|
164
164
|
|
|
165
165
|
const preferred = ['composer.json', 'index.php', 'artisan'];
|
|
166
166
|
const rootNames = new Set(rootEntries.map(([name]) => name));
|
|
@@ -174,7 +174,7 @@ async function main(): Promise<void> {
|
|
|
174
174
|
const treePath = rootSnapshot.candidate === 'artisan' ? 'routes' : undefined;
|
|
175
175
|
if (treePath) {
|
|
176
176
|
await recordStep(steps, 'filesystem.tree', options.stepTimeoutMs, async () => {
|
|
177
|
-
const tree = await notebook!.
|
|
177
|
+
const tree = await notebook!.files.tree(treePath);
|
|
178
178
|
return `path=${treePath} bytes=${tree.length}`;
|
|
179
179
|
}, false);
|
|
180
180
|
} else {
|
|
@@ -183,8 +183,8 @@ async function main(): Promise<void> {
|
|
|
183
183
|
|
|
184
184
|
const findSnapshot = await recordStep(steps, 'filesystem.find', options.stepTimeoutMs, async () => {
|
|
185
185
|
const [composerFiles, indexFiles] = await Promise.all([
|
|
186
|
-
notebook!.
|
|
187
|
-
notebook!.
|
|
186
|
+
notebook!.files.find('composer.json', { maxResults: 10 }),
|
|
187
|
+
notebook!.files.find('index.php', { maxResults: 10 }),
|
|
188
188
|
]);
|
|
189
189
|
const candidate = [...composerFiles, ...indexFiles].find((file) => typeof file.path === 'string')?.path;
|
|
190
190
|
return {
|
|
@@ -197,15 +197,13 @@ async function main(): Promise<void> {
|
|
|
197
197
|
|
|
198
198
|
if (candidate) {
|
|
199
199
|
await recordStep(steps, 'filesystem.read-candidate', options.stepTimeoutMs, async () => {
|
|
200
|
-
const [
|
|
201
|
-
notebook!.
|
|
202
|
-
notebook!.
|
|
203
|
-
notebook!.
|
|
204
|
-
notebook!.file.tail(candidate, 10),
|
|
200
|
+
const [stat, content, tail] = await Promise.all([
|
|
201
|
+
notebook!.files.stat(candidate),
|
|
202
|
+
notebook!.files.read(candidate),
|
|
203
|
+
notebook!.files.tail(candidate, { lines: 10 }),
|
|
205
204
|
]);
|
|
206
205
|
|
|
207
|
-
|
|
208
|
-
return `path=${candidate} size=${stat.size} binary=${info.binary} sha256=${sha256(bytes)} tailBytes=${tail.length}`;
|
|
206
|
+
return `path=${candidate} size=${stat.size} sha256=${sha256(content)} tailBytes=${tail.length}`;
|
|
209
207
|
}, false);
|
|
210
208
|
} else {
|
|
211
209
|
recordSkippedStep(steps, 'filesystem.read-candidate', 'No readable candidate file found.');
|
|
@@ -214,7 +212,10 @@ async function main(): Promise<void> {
|
|
|
214
212
|
if (options.includeDownload) {
|
|
215
213
|
if (candidate) {
|
|
216
214
|
await recordStep(steps, 'filesystem.download', options.stepTimeoutMs, async () => {
|
|
217
|
-
const archive = await notebook!.
|
|
215
|
+
const archive = await notebook!.files.download({
|
|
216
|
+
exclude: ['vendor/**', 'node_modules/**'],
|
|
217
|
+
include: [candidate],
|
|
218
|
+
});
|
|
218
219
|
if (archive.size === 0) {
|
|
219
220
|
throw new Error('file.download() returned an empty blob.');
|
|
220
221
|
}
|
|
@@ -228,7 +229,7 @@ async function main(): Promise<void> {
|
|
|
228
229
|
}
|
|
229
230
|
|
|
230
231
|
await recordStep(steps, 'filesystem.search', options.stepTimeoutMs, async () => {
|
|
231
|
-
const [hasMore, matches] = await notebook!.
|
|
232
|
+
const [hasMore, matches] = await notebook!.files.search({
|
|
232
233
|
pattern: 'php',
|
|
233
234
|
isRegExp: false,
|
|
234
235
|
isCaseSensitive: false,
|
|
@@ -260,7 +261,7 @@ async function main(): Promise<void> {
|
|
|
260
261
|
await runExecutionChecks(notebook, steps, options);
|
|
261
262
|
} else {
|
|
262
263
|
recordSkippedStep(steps, 'shell.run', 'Enable with --include-exec.');
|
|
263
|
-
recordSkippedStep(steps, '
|
|
264
|
+
recordSkippedStep(steps, 'terminals.create', 'Enable with --include-exec.');
|
|
264
265
|
recordSkippedStep(steps, 'terminal.interactive', 'Enable with --include-exec.');
|
|
265
266
|
recordSkippedStep(steps, 'terminal.osc', 'Enable with --include-exec.');
|
|
266
267
|
recordSkippedStep(steps, 'repl.eval', 'Enable with --include-exec.');
|
|
@@ -332,26 +333,25 @@ async function runExecutionChecks(notebook: NotebookInstance, steps: StepArtifac
|
|
|
332
333
|
return `exit=${result.exitCode}`;
|
|
333
334
|
}, false);
|
|
334
335
|
|
|
335
|
-
await recordStep(steps, '
|
|
336
|
-
const process = await notebook.
|
|
336
|
+
await recordStep(steps, 'terminals.create', options.stepTimeoutMs, async () => {
|
|
337
|
+
const process = await notebook.terminals.create({ command: 'php', args: ['-r', 'echo "sdk-smoke";'] });
|
|
337
338
|
const [exitCode, output] = await Promise.all([
|
|
338
339
|
withTimeout(process.wait(), options.stepTimeoutMs, 'waiting for terminal process exit'),
|
|
339
340
|
readStreamToString(process.output, options.streamTimeoutMs, options.maxStreamChars),
|
|
340
341
|
]);
|
|
341
342
|
|
|
342
343
|
if (exitCode !== 0 || !output.includes('sdk-smoke')) {
|
|
343
|
-
throw new Error(`
|
|
344
|
+
throw new Error(`terminals.create failed: exit=${exitCode} output=${trimDetail(output)}`);
|
|
344
345
|
}
|
|
345
346
|
|
|
346
347
|
return `exit=${exitCode}`;
|
|
347
348
|
}, false);
|
|
348
349
|
|
|
349
350
|
await recordStep(steps, 'terminal.interactive', options.stepTimeoutMs, async () => {
|
|
350
|
-
const process = await notebook.
|
|
351
|
-
'bash',
|
|
352
|
-
['-lc', 'IFS= read -r line; printf "sdk-input:%s\\n" "$line"'],
|
|
353
|
-
|
|
354
|
-
);
|
|
351
|
+
const process = await notebook.terminals.create({
|
|
352
|
+
command: 'bash',
|
|
353
|
+
args: ['-lc', 'IFS= read -r line; printf "sdk-input:%s\\n" "$line"'],
|
|
354
|
+
});
|
|
355
355
|
|
|
356
356
|
try {
|
|
357
357
|
const writer = process.input.getWriter();
|
|
@@ -374,15 +374,12 @@ async function runExecutionChecks(notebook: NotebookInstance, steps: StepArtifac
|
|
|
374
374
|
}, false);
|
|
375
375
|
|
|
376
376
|
await recordStep(steps, 'terminal.osc', options.stepTimeoutMs, async () => {
|
|
377
|
-
const process = await notebook.
|
|
378
|
-
'bash',
|
|
379
|
-
['-lc', 'printf "sdk-prompt$"'],
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
terminal: { cols: 80, rows: 15 },
|
|
384
|
-
}
|
|
385
|
-
);
|
|
377
|
+
const process = await notebook.terminals.create({
|
|
378
|
+
command: 'bash',
|
|
379
|
+
args: ['-lc', 'printf "sdk-prompt$"'],
|
|
380
|
+
osc: true,
|
|
381
|
+
size: [80, 15],
|
|
382
|
+
});
|
|
386
383
|
|
|
387
384
|
try {
|
|
388
385
|
const [exitCode, output] = await Promise.all([
|
package/package.json
CHANGED