using System.Net;
using System.Text.Json;
using XFESystem.Documents;
if (args.Length != 1) throw new ArgumentException("Specify a fresh output directory for host-only browser fixtures.");
var output = Path.GetFullPath(args[0]);
if (Directory.Exists(output)) throw new IOException("The browser fixture directory must be new.");
Directory.CreateDirectory(output);
var builder = new DocumentPreviewBuilder(new());
var markdown = builder.Markdown("""
# XFESystem 文档
| Language | Status |
|---|---|
| C# | Ready |
```js
const greeting = "Hello XFE";
console.log(greeting);
```
Inline math: $a^2+b^2=c^2$.
```mermaid
flowchart LR
A[Markdown] --> B[Preview]
```
""", "XFESystem Markdown");
await File.WriteAllTextAsync(Path.Combine(output, "Markdown.html"), markdown.Html);
var code = builder.Code("public sealed class Sample { public string Name => \"XFE\"; }", "Sample.cs");
await File.WriteAllTextAsync(Path.Combine(output, "Code.html"), code.Html);
var plan = DocumentPreviewBuilder.JavaScript("""
console.log("Result", 6 * 7);
document.body.dataset.Executed = "yes";
fetch("https://outside.invalid/Blocked").catch(() => console.log("Network blocked"));
console.log("Host bridge", typeof window.chrome?.webview);
""");
var jsHost = $"