@phpsandbox/sdk 0.0.67 → 0.1.1

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.
Files changed (42) hide show
  1. package/README.md +10 -13
  2. package/dist/auth.d.ts +0 -1
  3. package/dist/auth.js +0 -3
  4. package/dist/beacon/index.d.ts +2 -0
  5. package/dist/beacon/index.js +5 -0
  6. package/dist/browser/phpsandbox-sdk.esm.js +311 -1016
  7. package/dist/browser/phpsandbox-sdk.esm.min.js +24 -24
  8. package/dist/browser/phpsandbox-sdk.iife.js +311 -1016
  9. package/dist/browser/phpsandbox-sdk.iife.min.js +24 -24
  10. package/dist/filesystem.d.ts +2 -1
  11. package/dist/filesystem.js +35 -2
  12. package/dist/index.d.ts +15 -24
  13. package/dist/index.js +19 -28
  14. package/dist/publications.d.ts +222 -0
  15. package/dist/{deployments.js → publications.js} +65 -70
  16. package/dist/repl.d.ts +0 -2
  17. package/dist/repl.js +0 -3
  18. package/dist/runtime/rest.js +1 -1
  19. package/dist/schemas/{deployments.d.ts → publications.d.ts} +68 -68
  20. package/dist/schemas/publications.js +133 -0
  21. package/dist/shell.d.ts +43 -22
  22. package/dist/shell.js +103 -75
  23. package/dist/terminal.d.ts +1 -3
  24. package/dist/terminal.js +2 -5
  25. package/docs/api-summary.md +13 -10
  26. package/docs/cdn-usage.md +4 -4
  27. package/docs/getting-started.md +6 -6
  28. package/examples/README.md +8 -9
  29. package/examples/basic.ts +1 -1
  30. package/examples/git-merge-smoke.ts +2 -2
  31. package/examples/laravel-load-test.ts +14 -19
  32. package/examples/notebook-readonly-smoke.ts +11 -11
  33. package/examples/publication-provider-label.ts +11 -0
  34. package/examples/{deploy-cloudflare-container.ts → publish-cloudflare-container.ts} +11 -11
  35. package/examples/{deploy-laravel-cloud.ts → publish-laravel-cloud.ts} +11 -11
  36. package/examples/{deploy-ssh-agent.ts → publish-ssh-agent.ts} +15 -16
  37. package/package.json +7 -2
  38. package/dist/deployments.d.ts +0 -253
  39. package/dist/laravel.d.ts +0 -22
  40. package/dist/laravel.js +0 -11
  41. package/dist/schemas/deployments.js +0 -133
  42. package/examples/deployment-provider-label.ts +0 -11
package/README.md CHANGED
@@ -76,14 +76,11 @@ PHPSandbox.rest('token', 'https://api.phpsandbox.io/v1', {
76
76
  const client = PHPSandbox.realtime(process.env.PHPSANDBOX_TOKEN!);
77
77
 
78
78
  const created = await client.notebook.create('laravel');
79
- const opened = await client.notebook.open('notebook-id');
80
- await opened.ready();
81
-
82
79
  const fetched = await client.notebook.get('notebook-id');
83
80
  await fetched.ready();
84
81
 
85
82
  const forked = await created.fork();
86
- await forked.delete();
83
+ await forked.destroy();
87
84
 
88
85
  const persistent = await client.notebook.create('laravel', {
89
86
  title: 'Persistent Laravel',
@@ -101,9 +98,9 @@ console.log(persistentFork.data.policy);
101
98
  Notes:
102
99
 
103
100
  - `create()` and `fork()` initialize automatically.
104
- - `open()` and `get()` return a notebook instance; call `await notebook.ready()` before using tools.
101
+ - `get()` returns a notebook instance; call `await notebook.ready()` before using tools.
105
102
  - API notebook creates and forks are ephemeral by default. `persistent: true` requires an entitled account.
106
- - Use `NotebookData.runtimeUrl`, `runtimeUrlProvider`, and `DeploymentData.eventStreamUrl` for runtime access. Their `okraUrl` and `okraUrlProvider` aliases are deprecated compatibility fields.
103
+ - Use `NotebookData.runtimeUrl`, `runtimeUrlProvider`, and `PublicationData.eventStreamUrl` for runtime access.
107
104
 
108
105
  ## Services At A Glance
109
106
 
@@ -117,7 +114,6 @@ Each `NotebookInstance` exposes service clients:
117
114
  - `notebook.git` (`Git`)
118
115
  - `notebook.lsp` (`Lsp`)
119
116
  - `notebook.repl` (`Repl`)
120
- - `notebook.laravel` (`Laravel`)
121
117
  - `notebook.auth` (`Auth`)
122
118
  - `notebook.log` (`Log`)
123
119
  - `notebook.services` (`Services`)
@@ -125,9 +121,8 @@ Each `NotebookInstance` exposes service clients:
125
121
 
126
122
  Notes:
127
123
 
128
- - `terminal.spawn()` and `shell.exec()` are part of the current runtime action set. `terminal.start` currently is not.
129
- - `notebook.repl.eval()` is part of the current runtime action set. `repl.start` is currently not.
130
- - `notebook.laravel` is exposed by the SDK, but the current runtime action set does not expose Laravel maintenance actions.
124
+ - `terminal.spawn()` is the TTY-oriented process API; `notebook.run()` is the native non-TTY process API.
125
+ - `notebook.repl.eval()` evaluates PHP without exposing the unsupported `repl.start` action.
131
126
 
132
127
  ## Common Operations
133
128
 
@@ -166,9 +161,11 @@ console.log(exitCode);
166
161
  ### Shell
167
162
 
168
163
  ```ts
169
- const result = await notebook.shell.exec('php -v');
170
- result.throw();
171
- console.log(result.output);
164
+ const process = notebook.run('php -v', { tty: false });
165
+ for await (const chunk of process.output) {
166
+ console.log(chunk.source, new TextDecoder().decode(chunk.data));
167
+ }
168
+ (await process.exit).throw();
172
169
  ```
173
170
 
174
171
  ### Services
package/dist/auth.d.ts CHANGED
@@ -7,6 +7,5 @@ export interface AuthActions {
7
7
  export default class Auth {
8
8
  protected okra: NotebookInstance;
9
9
  constructor(okra: NotebookInstance);
10
- logout(): void;
11
10
  login(runtimeUrl: string): Promise<boolean>;
12
11
  }
package/dist/auth.js CHANGED
@@ -2,9 +2,6 @@ export default class Auth {
2
2
  constructor(okra) {
3
3
  this.okra = okra;
4
4
  }
5
- logout() {
6
- this.okra.dispose();
7
- }
8
5
  login(runtimeUrl) {
9
6
  const runtimeTicket = new URL(runtimeUrl).searchParams.get('ticket');
10
7
  if (runtimeTicket === null || runtimeTicket === '') {
@@ -1,6 +1,7 @@
1
1
  import { Disposable } from '../types.js';
2
2
  import { BeaconActions, BeaconEvents, BeaconOptions, DebugInfo, ConsoleEvent, BeaconErrorEvent, DebugRequest, DebugResult, ScreenshotRequest, ScreenshotResult, FetchRequest, FetchResult } from './types.js';
3
3
  import { Navigator } from './navigator.js';
4
+ import type { NotebookInstance } from '../index.js';
4
5
  export * from './types.js';
5
6
  export { Navigator } from './navigator.js';
6
7
  /**
@@ -166,6 +167,7 @@ export declare class Beacon implements BeaconActions {
166
167
  * Factory function to create a beacon instance for an iframe
167
168
  */
168
169
  export declare function createBeacon(iframe: HTMLIFrameElement, options?: BeaconOptions): Beacon;
170
+ export declare function connectBeacon(notebook: NotebookInstance, iframe: HTMLIFrameElement, options?: BeaconOptions): Promise<Beacon>;
169
171
  /**
170
172
  * Check if the current environment supports the Beacon SDK
171
173
  */
@@ -530,6 +530,11 @@ export class Beacon {
530
530
  export function createBeacon(iframe, options) {
531
531
  return new Beacon(iframe, options);
532
532
  }
533
+ export async function connectBeacon(notebook, iframe, options) {
534
+ const result = await notebook.ready();
535
+ iframe.src = result.data.previewUrl;
536
+ return createBeacon(iframe, options);
537
+ }
533
538
  /**
534
539
  * Check if the current environment supports the Beacon SDK
535
540
  */