//go:build !(js && wasm) package wasmruntime import "kjol/wasmruntime/vdom" // The server half of the host API (see host.go). Nothing here touches a browser, // because there isn't one: measurements are zero, listeners are never installed, // timers never fire, storage is always empty. Components call these // unconditionally and render their unmeasured state, which is what SSR ships. func Measure(*vdom.Ref) Rect { return Rect{} } func Viewport() Size { return Size{} } func CSSVarPx(string) float64 { return 0 } // Now is 0 on the server: there is no page load to measure from. A component that // reports a timing therefore SSRs an empty reading and fills it in once the client has // taken over — which is the honest answer, since the number IS a property of the client. func Now() float64 { return 0 } // The theme is a property of the BROWSER — the OS setting and a localStorage choice, // neither of which the server can see. So the server always renders the light theme, and // the document's boot script (webui.ThemeBootScript) applies the dark class before the // first paint. Nothing here can help with that, and pretending otherwise would just move // the flash somewhere harder to find. func PrefersDark() bool { return false } func OnMediaChange(string, func(bool)) Unsub { return func() {} } func SetRootClass(string, bool) {} func RAF(func()) int { return 0 } func CancelRAF(int) {} func AfterRender(func()) {} func SetStyle(*vdom.Ref, string, string) {} func RemoveStyle(*vdom.Ref, string) {} func SetText(*vdom.Ref, string) {} func SetHTML(*vdom.Ref, string) {} func Focus(*vdom.Ref) {} func Blur(*vdom.Ref) {} func SelectionRange(*vdom.Ref) (int, int) { return 0, 0 } func SetSelectionRange(*vdom.Ref, int, int) {} func ScrollIntoView(*vdom.Ref, bool, string) {} func ScrollLeft(*vdom.Ref) float64 { return 0 } func SetScrollLeft(*vdom.Ref, float64) {} // OverflowsX is false on the server: with no layout, nothing can overflow. A // component that collapses overflowing content therefore SSRs its uncollapsed form, // and the client collapses it on the first commit — before paint, so it is not seen. func OverflowsX(*vdom.Ref) bool { return false } func Contains(*vdom.Ref, any) bool { return false } func ClosestAttr(any, string, string) (string, bool) { return "", false } func QuerySelector(string) *vdom.Ref { return vdom.NewRef() } func OnWindow(string, bool, func(vdom.Event)) Unsub { return func() {} } func OnDocument(string, bool, func(vdom.Event)) Unsub { return func() {} } func ObserveResize(*vdom.Ref, func()) Unsub { return func() {} } func SetTimeout(int, func()) int { return 0 } func ClearTimeout(int) {} func StorageGet(string) (string, bool) { return "", false } func StorageSet(string, string) {} func StorageRemove(string) {} func Download(string, string, []byte) {} func Print(string, []byte) {}