tauri-plugin-phyto 0.1.17

Tauri plugin that exposes an HTTP automation server for Phyto end-to-end testing
Documentation
# tauri-plugin-phyto

A Tauri plugin that runs an HTTP automation server inside a Tauri app so
[Phyto](https://github.com/coniferous-dev/phyto) (an end-to-end testing
framework for Tauri) can drive it.

## What it does

When the plugin is initialized, it:

1. Starts an HTTP server on port `9876` (configurable) bound to `0.0.0.0`.
2. Polls the webview until it has navigated past `about:blank`, the Tauri
   IPC bridge is available, and the in-page Phyto harness (injected by
   `@phyto/vite-plugin`) has loaded.
3. Forwards `POST /command` requests to the in-page harness via
   `window.__phyto_harness__.execute()`, then sends the structured result
   back over HTTP.
4. Exposes `GET /health` for readiness probing.

The plugin is intended for **test builds only**. It listens on `0.0.0.0` and
runs arbitrary JavaScript supplied by the test driver — do not enable it in
production builds.

## Usage

Add the dependency to your app's `src-tauri/Cargo.toml`:

```toml
[dependencies]
tauri-plugin-phyto = "0.1"
```

Wire it into your Tauri builder:

```rust
fn main() {
    tauri::Builder::default()
        .plugin(tauri_plugin_phyto::init(Default::default()))
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
```

To gate the plugin behind a Cargo feature (recommended) so it isn't compiled
into production builds:

```toml
[features]
e2e = ["tauri-plugin-phyto"]

[dependencies]
tauri-plugin-phyto = { version = "0.1", optional = true }
```

```rust
fn main() {
    let builder = tauri::Builder::default();

    #[cfg(feature = "e2e")]
    let builder = builder.plugin(tauri_plugin_phyto::init(Default::default()));

    builder
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
```

## Configuration

```rust
use tauri_plugin_phyto::PhytoConfig;

tauri::Builder::default()
    .plugin(tauri_plugin_phyto::init(PhytoConfig { port: 9876 }))
```

| Field | Default | Description                                |
|-------|---------|--------------------------------------------|
| port  | 9876    | Port the HTTP automation server binds to. |

## How it fits together

`tauri-plugin-phyto` is the in-app server half of Phyto. On the other side:

- `@phyto/vite-plugin` (npm) injects the in-page harness into your app's
  build output during test runs.
- `@phyto/driver-tauri` (npm) is the Node-side driver that issues
  `click` / `type` / `wait-for` commands over this plugin's HTTP socket.
- `phyto` (npm) is the test-authoring DSL.
- `@phyto/cli` (npm) is the orchestrator that builds the app, discovers
  tests, and runs each one against a fresh app instance.

See the top-level [Phyto README](https://github.com/coniferous-dev/phyto)
for the full picture.

## Protocol version

The plugin and driver negotiate a `PROTOCOL_VERSION` integer at startup. If
they disagree, the CLI exits with a clear error naming the mismatched
component. Bump this version on breaking wire-format changes only.

## License

[MIT](https://github.com/coniferous-dev/phyto/blob/main/LICENSE)