gui: native WebView host as nested module yetano.dev/yetano/core/gui
Extracted from prototypes/yetano-webview (AP1): packages assets, document, bridge and window (macOS Cocoa/WKWebView via cgo, Windows Win32/WebView2 pure Go). No local HTTP listener or port: assets go through the WebView's resource handler, app routes through the native message binding. Own go.mod and gui/vX.Y.Z tags keep cgo and the WebView dependencies out of the main core module. Adds backend-free tests for the window's dispatch/destroy guards and a yet-gui migration guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
90132e2d76
commit
8c63d42a27
27 files changed
+4849
-3
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package bridge
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
//go:embed bridge.js
|
||||
var bridgeJS string
|
||||
|
||||
// PageConfig is exposed to the page as window.__yetano_config (and
|
||||
// window.yetano.config) before the bridge installs itself.
|
||||
type PageConfig struct {
|
||||
External string `json:"external"` // "reject" (default) or "passthrough"
|
||||
Transport string `json:"transport"` // "native" (scheme handler) or "inline" (data: entry, bridge only)
|
||||
Origin string `json:"origin,omitempty"`
|
||||
DefaultTimeoutMs int `json:"defaultTimeoutMs,omitempty"`
|
||||
HandshakeTimeoutMs int `json:"handshakeTimeoutMs,omitempty"`
|
||||
ForwardConsole bool `json:"forwardConsole,omitempty"`
|
||||
Selftest bool `json:"selftest,omitempty"`
|
||||
Run int `json:"run,omitempty"`
|
||||
ProtocolOverride int `json:"protocolOverride,omitempty"` // tests only
|
||||
}
|
||||
|
||||
// InitScript returns the document-start script: config + bridge.
|
||||
func InitScript(cfg PageConfig) string {
|
||||
if cfg.External == "" {
|
||||
cfg.External = "reject"
|
||||
}
|
||||
b, _ := json.Marshal(cfg)
|
||||
return "window.__yetano_config=" + string(b) + ";\n" + bridgeJS
|
||||
}
|
||||
Reference in new issue
Block a user