Embedded

examples/webview/embedded.ts — a SINGLE-FILE desktop app.

`serve: embedDir(...)` embeds the built SPA directory into the compiled binary at compile time and serves it from an in-binary static server (an ephemeral loopback port), then navigates the window to it. The result is one self-contained executable — no `dist/` folder beside it at runtime. Any framework build that produces static assets works: `quasar build` (SPA or SSG), `vite build`, etc.

Build: klainmain examples/webview/embedded.ts && ./examples/webview/embedded Windows: klainmain examples/webview/embedded.ts && examples/webview/embedded.exe (WebView2; see README) (move or delete examples/webview/dist/ afterward to prove it's embedded.)

For lower-level control, `import { embedDir } from 'klain:assets'` gives an EmbeddedAssets handle with `.get(path): ArrayBuffer` over the embedded bytes.

import { Webview } from 'klain:webview'
import { embedDir } from 'klain:assets'

const w = new Webview({
  title: "Klain (embedded)",
  width: 800,
  height: 600,
  serve: embedDir("./examples/webview/dist"),
})

w.run()
console.log("window closed")
View source on GitHubexamples/webview/embedded.ts