@phpsandbox/sdk 0.3.2 → 0.3.4
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 +38 -0
- package/dist/beacon/index.js +4 -2
- package/dist/beacon/navigator.js +0 -1
- package/dist/beacon/types.d.ts +1 -1
- package/dist/browser/phpsandbox-sdk.esm.js +405 -308
- package/dist/browser/phpsandbox-sdk.esm.min.js +23 -25
- package/dist/browser/phpsandbox-sdk.iife.js +405 -308
- package/dist/browser/phpsandbox-sdk.iife.min.js +8 -10
- package/dist/composer.js +8 -4
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -3
- package/dist/feedback.js +2 -1
- package/dist/filesystem.js +32 -15
- package/dist/identity.d.ts +13 -0
- package/dist/identity.js +6 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +14 -5
- package/dist/integrations/sandbox.js +1 -1
- package/dist/lsp.d.ts +2 -2
- package/dist/lsp.js +2 -2
- package/dist/publication/index.d.ts +1 -0
- package/dist/publication/index.js +1 -0
- package/dist/publication/instance.d.ts +2 -0
- package/dist/publication/instance.js +8 -0
- package/dist/publication/notebook.js +7 -5
- package/dist/publication/resources.js +2 -1
- package/dist/publication/run.js +2 -76
- package/dist/publication/stream.d.ts +18 -0
- package/dist/publication/stream.js +185 -0
- package/dist/runtime/rest.js +2 -1
- package/dist/runtime.js +1 -1
- package/dist/schemas/publications.js +53 -59
- package/dist/servers.d.ts +2 -0
- package/dist/servers.js +5 -1
- package/dist/shell.js +5 -2
- package/dist/socket/index.js +25 -13
- package/dist/telemetry.js +8 -3
- package/dist/terminal.js +3 -4
- package/dist/utils/promise.js +1 -1
- package/dist/utils/websocket.js +2 -2
- package/package.json +49 -33
- package/dist/auth.d.ts +0 -11
- package/dist/auth.js +0 -12
package/README.md
CHANGED
|
@@ -418,3 +418,41 @@ Preparing or viewing a proposal does not start publishing. Confirmation sends th
|
|
|
418
418
|
Inspect deployment, runtime and routing outcomes for each selected app; a partial outcome is not full success. `retryApplication(id)` retries failed apps after revalidation. If an outcome is uncertain, inspect status and logs before retrying. `destroyApplication(id)` unpublishes; deleting managed resources additionally requires `deleteResources: true`.
|
|
419
419
|
|
|
420
420
|
Shared managed-resource creation currently starts with one app. After creation, update the resource definition to `reuse` with the catalog resource ID before attaching other apps. Simultaneous first-time shared-resource creation is unsupported.
|
|
421
|
+
|
|
422
|
+
#### Browser publishing streams through your backend
|
|
423
|
+
|
|
424
|
+
Keep service-account credentials on your server. After authorizing project access and checking the requested publishing attempt, open the original SSE bytes with `publication.stream()`. Return the SDK's standard `Response` directly from your framework:
|
|
425
|
+
|
|
426
|
+
```ts
|
|
427
|
+
import { createPublicationStreamResponse } from '@phpsandbox/sdk/stream';
|
|
428
|
+
|
|
429
|
+
// Server: `publication` belongs to the authenticated user's project.
|
|
430
|
+
// `requestSignal` is aborted when the downstream client disconnects.
|
|
431
|
+
const bytes = await publication.stream(requestSignal);
|
|
432
|
+
return createPublicationStreamResponse(bytes, {
|
|
433
|
+
signal: requestSignal,
|
|
434
|
+
onDispose: () => notebook.dispose(),
|
|
435
|
+
});
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
The helper forwards bytes unchanged and supplies SSE headers. It releases resources on completion, upstream failure, or downstream cancellation. Dispose resources yourself if opening the upstream stream fails. Opening this endpoint can start an already queued release; it is not a purely passive log subscription.
|
|
439
|
+
|
|
440
|
+
In the browser, use the lightweight `stream` entry point without constructing a client or exposing a PHPSandbox token. For example, if your backend exposes the proxy at `/api/publishing/stream`:
|
|
441
|
+
|
|
442
|
+
```ts
|
|
443
|
+
import { readPublicationStream } from '@phpsandbox/sdk/stream';
|
|
444
|
+
|
|
445
|
+
const controller = new AbortController();
|
|
446
|
+
const response = await fetch('/api/publishing/stream', {
|
|
447
|
+
credentials: 'same-origin',
|
|
448
|
+
headers: { Accept: 'text/event-stream' },
|
|
449
|
+
signal: controller.signal,
|
|
450
|
+
});
|
|
451
|
+
for await (const event of readPublicationStream(response)) {
|
|
452
|
+
// Discriminated union: phase, log, or result. `done` is normalized to result.
|
|
453
|
+
if (event.type === 'log') console.log(event.content);
|
|
454
|
+
}
|
|
455
|
+
// Call controller.abort() when the view closes, including while waiting for an event.
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
`readPublicationStream` also accepts a `ReadableStream<Uint8Array>`. By default, it rejects EOF without a final result (including empty streams). Use `{ requireResult: false }` only when deliberately consuming a stream fragment. It validates recognized event payloads, throws for server error events, and ignores unknown event names and heartbeat comments. Ending iteration early cancels the stream; aborting the fetch interrupts a pending read. Disconnecting observation does not cancel the server-side deployment. `PublicationRun.events()` uses this same parser.
|
package/dist/beacon/index.js
CHANGED
|
@@ -454,7 +454,9 @@ export class Beacon {
|
|
|
454
454
|
* Let's wait for 2 seconds for page to finish rendering.
|
|
455
455
|
* Errors, that might occur during this time will be captured.
|
|
456
456
|
*/
|
|
457
|
-
|
|
457
|
+
if (waitSeconds) {
|
|
458
|
+
await this.wait(waitSeconds);
|
|
459
|
+
}
|
|
458
460
|
// Now request debug capture from the beacon (without navigation)
|
|
459
461
|
const timeoutMs = (request.options?.timeout || 30000) + 5000; // Add 5s buffer
|
|
460
462
|
return this.sendAndWaitFor('debug', 'debugResult', request, timeoutMs);
|
|
@@ -488,7 +490,7 @@ export class Beacon {
|
|
|
488
490
|
this.readyPromise = this.waitForBeaconReady();
|
|
489
491
|
}
|
|
490
492
|
}
|
|
491
|
-
catch
|
|
493
|
+
catch {
|
|
492
494
|
throw new BeaconConnectionError(`Invalid URL: ${url}`);
|
|
493
495
|
}
|
|
494
496
|
}
|
package/dist/beacon/navigator.js
CHANGED
package/dist/beacon/types.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export interface ScreenshotRequest {
|
|
|
91
91
|
maxWidth?: number;
|
|
92
92
|
maxHeight?: number;
|
|
93
93
|
};
|
|
94
|
-
type?:
|
|
94
|
+
type?: string;
|
|
95
95
|
quality?: number;
|
|
96
96
|
/**
|
|
97
97
|
* Wait budget for page media/resources while rendering the DOM screenshot.
|