//:build !wasm package dom // Body returns a handle to document.body. func Body() (e Element) { panic("jsbridge") } // CreateElement creates a new DOM element with the given tag. func CreateElement(tag string) (e Element) { panic("jsbridge") } // CreateTextNode creates a text node. func CreateTextNode(text string) (e Element) { panic("jsbridge") } // GetElementById finds an element by its ID attribute. func GetElementById(id string) (e Element) { panic("jsbridge") } // QuerySelector finds the first element matching a CSS selector. func QuerySelector(sel string) (e Element) { panic("jsbridge") } // QuerySelectorFrom finds the first element matching a CSS selector within root's subtree. func QuerySelectorFrom(root Element, sel string) (e Element) { panic("jsbridge") } // RemoveAttribute removes an attribute from an element. func RemoveAttribute(el Element, name string) { panic("jsbridge") } // GetAttribute returns the value of an attribute on an element. func GetAttribute(el Element, name string) (s string) { panic("jsbridge") } // AppendChild adds a child element to a parent. func AppendChild(parent, child Element) { panic("jsbridge") } // RemoveChild removes a child element from a parent. func RemoveChild(parent, child Element) { panic("jsbridge") } // Remove removes an element from its parent. func Remove(el Element) { panic("jsbridge") } // SetAttribute sets an attribute on an element. func SetAttribute(el Element, name, value string) { panic("jsbridge") } // SetTextContent sets the text content of an element. func SetTextContent(el Element, text string) { panic("jsbridge") } // SetInnerHTML sets the inner HTML of an element. func SetInnerHTML(el Element, html string) { panic("jsbridge") } // SetStyle sets a CSS style property on an element. func SetStyle(el Element, prop, value string) { panic("jsbridge") } // AddClass adds a CSS class to an element. func AddClass(el Element, cls string) { panic("jsbridge") } // RemoveClass removes a CSS class from an element. func RemoveClass(el Element, cls string) { panic("jsbridge") } // Focus sets keyboard focus on an element. func Focus(el Element) { panic("jsbridge") } // SetProperty sets a JS property on an element. func SetProperty(el Element, prop, value string) { panic("jsbridge") } // GetProperty gets a JS property from an element as a string. func GetProperty(el Element, prop string) (s string) { panic("jsbridge") } // BoundingClientLeft returns the element's getBoundingClientRect().left in px // (viewport-relative, truncated to int). func BoundingClientLeft(el Element) (n int32) { panic("jsbridge") } // GetBoundingRect returns the element's full bounding client rect. // fn receives (left, top, right, bottom, width, height) as ints. func GetBoundingRect(el Element, fn func(int32, int32, int32, int32, int32, int32)) { panic("jsbridge") } // GetViewportHeight returns window.innerHeight in px. func GetViewportHeight() (n int32) { panic("jsbridge") } func GetViewportWidth() (n int32) { panic("jsbridge") } // RegisterCallback registers a Go function as a JS event callback. // Returns a callback ID for use with AddEventListener. func RegisterCallback(fn func()) (n int32) { panic("jsbridge") } // ReleaseCallback releases a registered callback. func ReleaseCallback(id int32) { panic("jsbridge") } // AddEventListener adds an event listener. callbackId is from RegisterCallback. func AddEventListener(el Element, event string, callbackId int32) { panic("jsbridge") } // AddSelfEventListener adds an event listener that only fires when // the event target is the element itself, not a descendant. func AddSelfEventListener(el Element, event string, callbackId int32) { panic("jsbridge") } // AddEnterKeyListener fires callback when Enter is pressed on the element. func AddEnterKeyListener(el Element, callbackId int32) { panic("jsbridge") } // OnKeydown registers a keydown handler. fn receives (key, prevent). // Call prevent() to preventDefault the event. func OnKeydown(el Element, fn func(string, func())) { panic("jsbridge") } // InsertMentionChip replaces charCount characters before the caret with a // mention chip displaying name and pic. Works on both textareas and // contenteditable elements. func InsertMentionChip(el Element, charCount int32, npub, name, pic string) { panic("jsbridge") } // RemoveEventListener removes an event listener. func RemoveEventListener(el Element, event string, callbackId int32) { panic("jsbridge") } // ObserveResize attaches a ResizeObserver to el. callbackId fires whenever // the element's content box size changes (image load, embed fill, reflow). // Only one observer per element; a second call replaces the first. func ObserveResize(el Element, callbackId int32) { panic("jsbridge") } // UnobserveResize disconnects and removes the ResizeObserver on el. func UnobserveResize(el Element) { panic("jsbridge") } // RequestAnimationFrame schedules a function to run before the next repaint. func RequestAnimationFrame(fn func()) { panic("jsbridge") } // SetTimeout schedules a function to run after ms milliseconds. Returns timer ID. func SetTimeout(fn func(), ms int32) (n int32) { panic("jsbridge") } // ClearTimeout cancels a timer created by SetTimeout. func ClearTimeout(id int32) { panic("jsbridge") } // FirstChild returns the first child node, or 0 if none. // May return text nodes - use FirstElementChild for Element-only traversal. func FirstChild(el Element) (e Element) { panic("jsbridge") } // FirstElementChild returns the first child that is an Element, or 0 if none. // Skips text nodes and comments. func FirstElementChild(el Element) (e Element) { panic("jsbridge") } // NextSibling returns the next sibling element, or 0 if none. func NextSibling(el Element) (e Element) { panic("jsbridge") } // InsertBefore inserts newChild before refChild in parent. func InsertBefore(parent, newChild, refChild Element) { panic("jsbridge") } // ReleaseElement releases a DOM element handle. func ReleaseElement(el Element) { panic("jsbridge") } // ReleaseAll releases multiple DOM element handles in a single bridge call. func ReleaseAll(ids []int32) { panic("jsbridge") } // ReleaseChildren releases handles for all DOM descendants of el before a // clearChildren/SetInnerHTML("") call. Prevents handle table leaks. func ReleaseChildren(el Element) { panic("jsbridge") } // FetchText fetches a URL and calls fn with the response text. func FetchText(url string, fn func(string)) { panic("jsbridge") } // FetchRelayInfo fetches NIP-11 relay info document from URL. Adds Accept header. func FetchRelayInfo(url string, fn func(string)) { panic("jsbridge") } // IDBSetEncKey sets the 32-byte encryption key (hex encoded) for IDB at-rest encryption. // Once set, all IDBPut/IDBGet/IDBGetAll operations encrypt/decrypt transparently. func IDBSetEncKey(hexKey string) { panic("jsbridge") } // IDBGet retrieves a value from IndexedDB by key. Calls fn with "" if not found. func IDBGet(store, key string, fn func(string)) { panic("jsbridge") } // IDBPut stores a key-value pair in IndexedDB. func IDBPut(store, key, value string) { panic("jsbridge") } // IDBGetAll retrieves all key-value pairs from an IndexedDB store. // Calls fn once per entry with (key, value). Calls done() when finished. func IDBGetAll(store string, fn func(string, string), done func()) { panic("jsbridge") } // PrefersDark returns true if the browser prefers dark color scheme. func PrefersDark() (ok bool) { panic("jsbridge") } // ConsoleLog logs a message to the browser console. func ConsoleLog(msg string) { panic("jsbridge") } // Confirm shows a browser confirm dialog and returns the user's choice. func Confirm(msg string) (ok bool) { panic("jsbridge") } // PostToSW sends a JSON message string to the service worker controller. func PostToSW(msg string) { panic("jsbridge") } // OnSWMessage registers a handler for JSON array messages from the service worker. // fn receives the JSON-stringified array for each message. func OnSWMessage(fn func(string)) { panic("jsbridge") } // PushState pushes a new browser history entry with the given path. func PushState(path string) { panic("jsbridge") } // ReplaceState replaces the current browser history entry with the given path. func ReplaceState(path string) { panic("jsbridge") } // Back navigates one step back in browser history. func Back() { panic("jsbridge") } // LocationReload reloads the current page. func LocationReload() { panic("jsbridge") } // LocationAssign navigates to the given URL. func LocationAssign(url string) { panic("jsbridge") } // HardRefresh clears all SW caches, unregisters service workers, and reloads. func HardRefresh() { panic("jsbridge") } // ClearStoragePrefix removes all localStorage keys starting with the given prefix. func ClearStoragePrefix(prefix string) { panic("jsbridge") } // TimezoneOffsetSeconds returns the local timezone offset in seconds to add to UTC. // E.g. UTC+9 returns 32400, UTC-8 returns -28800. func TimezoneOffsetSeconds() (n int32) { panic("jsbridge") } // ReadClipboard reads text from the clipboard. Uses navigator.clipboard.readText() // if available (secure context), otherwise falls back to prompt(). // Calls fn with the text, or empty string if cancelled/failed. func ReadClipboard(fn func(string)) { panic("jsbridge") } // WriteClipboard writes text to the clipboard via navigator.clipboard.writeText. // fn is called with true on success, false on failure. func WriteClipboard(text string, fn func(bool)) { panic("jsbridge") } // WritePrimarySelection writes text to the X11 primary selection (middle-click // paste buffer) by creating an off-screen textarea, selecting its content, and // letting the browser propagate the selection to the X server. No-op on // non-X11 platforms (Wayland, macOS, Windows). Fire-and-forget; no callback. func WritePrimarySelection(text string) { panic("jsbridge") } // CopyImageToClipboard copies the image element's pixel data to the system // clipboard as image/png using ClipboardItem. Requires a secure context. // fn is called with true on success, false on failure. func CopyImageToClipboard(el Element, fn func(bool)) { panic("jsbridge") } // WindowOpen opens url in a new browser tab. func WindowOpen(url string) { panic("jsbridge") } // EncodeURIComponent returns the URL-encoded form of s (calls JS encodeURIComponent). func EncodeURIComponent(s string) (sv string) { panic("jsbridge") } // GetPath returns the current location.pathname. func GetPath() (s string) { panic("jsbridge") } // GetHash returns the current location.hash (including the leading '#', or empty). func GetHash() (s string) { panic("jsbridge") } // Hostname returns the current location.hostname. func Hostname() (s string) { panic("jsbridge") } // Port returns the current location.port. func Port() (s string) { panic("jsbridge") } // UserAgent returns navigator.userAgent. func UserAgent() (s string) { panic("jsbridge") } // OnPopState registers a handler for browser back/forward navigation. // fn receives the new location.pathname. func OnPopState(fn func(string)) { panic("jsbridge") } func InterceptInternalLinks(fn func(string)) { panic("jsbridge") } // PickFileText opens a file picker dialog and reads the selected file as text. // accept is the file type filter (e.g. ".json" or "application/json"). // Calls fn with the file text content, or empty string if cancelled/error. func PickFileText(accept string, fn func(string)) { panic("jsbridge") } // DownloadText triggers a file download with the given text content and filename. func DownloadText(filename, content, mimeType string) { panic("jsbridge") } // OnPullRefresh registers a handler that fires when the user pulls to refresh // at the top of a scrollable element (wheel or touch). indicator is shown during pull. func OnPullRefresh(el Element, indicator Element, fn func()) { panic("jsbridge") } // NowSeconds returns the current Unix timestamp in seconds. func NowSeconds() (n int64) { panic("jsbridge") } // PickFileBase64 opens a file picker filtered by accept (e.g. "image/*"). // fn receives (base64data, mimeType). base64data has no data: prefix. // Empty strings on cancel/error. func PickFileBase64(accept string, fn func(string, string)) { panic("jsbridge") } // OnPasteImage registers a handler on el that fires when the user pastes an // image from the clipboard. fn receives (base64data, mimeType). base64data is // the raw base64 (no data: prefix). mimeType is e.g. "image/png". func OnPasteImage(el Element, fn func(string, string)) { panic("jsbridge") } // OnDropImage registers drag-and-drop handlers on el for image files. // fn receives (base64data, mimeType) for each dropped image file. func OnDropImage(el Element, fn func(string, string)) { panic("jsbridge") } // FetchPutBlobBase64 sends a PUT request to url with the body decoded from // base64data. contentType sets Content-Type, authHeader sets Authorization. // fn receives the response body text (or "" on error). func FetchPutBlobBase64(url, base64data, contentType, authHeader string, fn func(string)) { panic("jsbridge") }