1 //:build !wasm
2 3 package dom
4 5 // Body returns a handle to document.body.
6 func Body() (e Element) { panic("jsbridge") }
7 8 // CreateElement creates a new DOM element with the given tag.
9 func CreateElement(tag string) (e Element) { panic("jsbridge") }
10 11 // CreateTextNode creates a text node.
12 func CreateTextNode(text string) (e Element) { panic("jsbridge") }
13 14 // GetElementById finds an element by its ID attribute.
15 func GetElementById(id string) (e Element) { panic("jsbridge") }
16 17 // QuerySelector finds the first element matching a CSS selector.
18 func QuerySelector(sel string) (e Element) { panic("jsbridge") }
19 20 // QuerySelectorFrom finds the first element matching a CSS selector within root's subtree.
21 func QuerySelectorFrom(root Element, sel string) (e Element) { panic("jsbridge") }
22 23 // RemoveAttribute removes an attribute from an element.
24 func RemoveAttribute(el Element, name string) { panic("jsbridge") }
25 26 // GetAttribute returns the value of an attribute on an element.
27 func GetAttribute(el Element, name string) (s string) { panic("jsbridge") }
28 29 // AppendChild adds a child element to a parent.
30 func AppendChild(parent, child Element) { panic("jsbridge") }
31 32 // RemoveChild removes a child element from a parent.
33 func RemoveChild(parent, child Element) { panic("jsbridge") }
34 35 // Remove removes an element from its parent.
36 func Remove(el Element) { panic("jsbridge") }
37 38 // SetAttribute sets an attribute on an element.
39 func SetAttribute(el Element, name, value string) { panic("jsbridge") }
40 41 // SetTextContent sets the text content of an element.
42 func SetTextContent(el Element, text string) { panic("jsbridge") }
43 44 // SetInnerHTML sets the inner HTML of an element.
45 func SetInnerHTML(el Element, html string) { panic("jsbridge") }
46 47 // SetStyle sets a CSS style property on an element.
48 func SetStyle(el Element, prop, value string) { panic("jsbridge") }
49 50 // AddClass adds a CSS class to an element.
51 func AddClass(el Element, cls string) { panic("jsbridge") }
52 53 // RemoveClass removes a CSS class from an element.
54 func RemoveClass(el Element, cls string) { panic("jsbridge") }
55 56 // Focus sets keyboard focus on an element.
57 func Focus(el Element) { panic("jsbridge") }
58 59 // SetProperty sets a JS property on an element.
60 func SetProperty(el Element, prop, value string) { panic("jsbridge") }
61 62 // GetProperty gets a JS property from an element as a string.
63 func GetProperty(el Element, prop string) (s string) { panic("jsbridge") }
64 65 // BoundingClientLeft returns the element's getBoundingClientRect().left in px
66 // (viewport-relative, truncated to int).
67 func BoundingClientLeft(el Element) (n int32) { panic("jsbridge") }
68 69 // GetBoundingRect returns the element's full bounding client rect.
70 // fn receives (left, top, right, bottom, width, height) as ints.
71 func GetBoundingRect(el Element, fn func(int32, int32, int32, int32, int32, int32)) { panic("jsbridge") }
72 73 // GetViewportHeight returns window.innerHeight in px.
74 func GetViewportHeight() (n int32) { panic("jsbridge") }
75 76 func GetViewportWidth() (n int32) { panic("jsbridge") }
77 78 // RegisterCallback registers a Go function as a JS event callback.
79 // Returns a callback ID for use with AddEventListener.
80 func RegisterCallback(fn func()) (n int32) { panic("jsbridge") }
81 82 // ReleaseCallback releases a registered callback.
83 func ReleaseCallback(id int32) { panic("jsbridge") }
84 85 // AddEventListener adds an event listener. callbackId is from RegisterCallback.
86 func AddEventListener(el Element, event string, callbackId int32) { panic("jsbridge") }
87 88 // AddSelfEventListener adds an event listener that only fires when
89 // the event target is the element itself, not a descendant.
90 func AddSelfEventListener(el Element, event string, callbackId int32) { panic("jsbridge") }
91 92 // AddEnterKeyListener fires callback when Enter is pressed on the element.
93 func AddEnterKeyListener(el Element, callbackId int32) { panic("jsbridge") }
94 95 // OnKeydown registers a keydown handler. fn receives (key, prevent).
96 // Call prevent() to preventDefault the event.
97 func OnKeydown(el Element, fn func(string, func())) { panic("jsbridge") }
98 99 // InsertMentionChip replaces charCount characters before the caret with a
100 // mention chip displaying name and pic. Works on both textareas and
101 // contenteditable elements.
102 func InsertMentionChip(el Element, charCount int32, npub, name, pic string) { panic("jsbridge") }
103 104 // RemoveEventListener removes an event listener.
105 func RemoveEventListener(el Element, event string, callbackId int32) { panic("jsbridge") }
106 107 // ObserveResize attaches a ResizeObserver to el. callbackId fires whenever
108 // the element's content box size changes (image load, embed fill, reflow).
109 // Only one observer per element; a second call replaces the first.
110 func ObserveResize(el Element, callbackId int32) { panic("jsbridge") }
111 112 // UnobserveResize disconnects and removes the ResizeObserver on el.
113 func UnobserveResize(el Element) { panic("jsbridge") }
114 115 // RequestAnimationFrame schedules a function to run before the next repaint.
116 func RequestAnimationFrame(fn func()) { panic("jsbridge") }
117 118 // SetTimeout schedules a function to run after ms milliseconds. Returns timer ID.
119 func SetTimeout(fn func(), ms int32) (n int32) { panic("jsbridge") }
120 121 // ClearTimeout cancels a timer created by SetTimeout.
122 func ClearTimeout(id int32) { panic("jsbridge") }
123 124 // FirstChild returns the first child node, or 0 if none.
125 // May return text nodes - use FirstElementChild for Element-only traversal.
126 func FirstChild(el Element) (e Element) { panic("jsbridge") }
127 128 // FirstElementChild returns the first child that is an Element, or 0 if none.
129 // Skips text nodes and comments.
130 func FirstElementChild(el Element) (e Element) { panic("jsbridge") }
131 132 // NextSibling returns the next sibling element, or 0 if none.
133 func NextSibling(el Element) (e Element) { panic("jsbridge") }
134 135 // InsertBefore inserts newChild before refChild in parent.
136 func InsertBefore(parent, newChild, refChild Element) { panic("jsbridge") }
137 138 // ReleaseElement releases a DOM element handle.
139 func ReleaseElement(el Element) { panic("jsbridge") }
140 141 // ReleaseAll releases multiple DOM element handles in a single bridge call.
142 func ReleaseAll(ids []int32) { panic("jsbridge") }
143 144 // ReleaseChildren releases handles for all DOM descendants of el before a
145 // clearChildren/SetInnerHTML("") call. Prevents handle table leaks.
146 func ReleaseChildren(el Element) { panic("jsbridge") }
147 148 // FetchText fetches a URL and calls fn with the response text.
149 func FetchText(url string, fn func(string)) { panic("jsbridge") }
150 151 // FetchRelayInfo fetches NIP-11 relay info document from URL. Adds Accept header.
152 func FetchRelayInfo(url string, fn func(string)) { panic("jsbridge") }
153 154 // IDBSetEncKey sets the 32-byte encryption key (hex encoded) for IDB at-rest encryption.
155 // Once set, all IDBPut/IDBGet/IDBGetAll operations encrypt/decrypt transparently.
156 func IDBSetEncKey(hexKey string) { panic("jsbridge") }
157 158 // IDBGet retrieves a value from IndexedDB by key. Calls fn with "" if not found.
159 func IDBGet(store, key string, fn func(string)) { panic("jsbridge") }
160 161 // IDBPut stores a key-value pair in IndexedDB.
162 func IDBPut(store, key, value string) { panic("jsbridge") }
163 164 // IDBGetAll retrieves all key-value pairs from an IndexedDB store.
165 // Calls fn once per entry with (key, value). Calls done() when finished.
166 func IDBGetAll(store string, fn func(string, string), done func()) { panic("jsbridge") }
167 168 // PrefersDark returns true if the browser prefers dark color scheme.
169 func PrefersDark() (ok bool) { panic("jsbridge") }
170 171 // ConsoleLog logs a message to the browser console.
172 func ConsoleLog(msg string) { panic("jsbridge") }
173 174 // Confirm shows a browser confirm dialog and returns the user's choice.
175 func Confirm(msg string) (ok bool) { panic("jsbridge") }
176 177 // PostToSW sends a JSON message string to the service worker controller.
178 func PostToSW(msg string) { panic("jsbridge") }
179 180 // OnSWMessage registers a handler for JSON array messages from the service worker.
181 // fn receives the JSON-stringified array for each message.
182 func OnSWMessage(fn func(string)) { panic("jsbridge") }
183 184 // PushState pushes a new browser history entry with the given path.
185 func PushState(path string) { panic("jsbridge") }
186 187 // ReplaceState replaces the current browser history entry with the given path.
188 func ReplaceState(path string) { panic("jsbridge") }
189 190 // Back navigates one step back in browser history.
191 func Back() { panic("jsbridge") }
192 193 // LocationReload reloads the current page.
194 func LocationReload() { panic("jsbridge") }
195 196 // LocationAssign navigates to the given URL.
197 func LocationAssign(url string) { panic("jsbridge") }
198 199 // HardRefresh clears all SW caches, unregisters service workers, and reloads.
200 func HardRefresh() { panic("jsbridge") }
201 202 // ClearStoragePrefix removes all localStorage keys starting with the given prefix.
203 func ClearStoragePrefix(prefix string) { panic("jsbridge") }
204 205 // TimezoneOffsetSeconds returns the local timezone offset in seconds to add to UTC.
206 // E.g. UTC+9 returns 32400, UTC-8 returns -28800.
207 func TimezoneOffsetSeconds() (n int32) { panic("jsbridge") }
208 209 // ReadClipboard reads text from the clipboard. Uses navigator.clipboard.readText()
210 // if available (secure context), otherwise falls back to prompt().
211 // Calls fn with the text, or empty string if cancelled/failed.
212 func ReadClipboard(fn func(string)) { panic("jsbridge") }
213 214 // WriteClipboard writes text to the clipboard via navigator.clipboard.writeText.
215 // fn is called with true on success, false on failure.
216 func WriteClipboard(text string, fn func(bool)) { panic("jsbridge") }
217 218 // WritePrimarySelection writes text to the X11 primary selection (middle-click
219 // paste buffer) by creating an off-screen textarea, selecting its content, and
220 // letting the browser propagate the selection to the X server. No-op on
221 // non-X11 platforms (Wayland, macOS, Windows). Fire-and-forget; no callback.
222 func WritePrimarySelection(text string) { panic("jsbridge") }
223 224 // CopyImageToClipboard copies the image element's pixel data to the system
225 // clipboard as image/png using ClipboardItem. Requires a secure context.
226 // fn is called with true on success, false on failure.
227 func CopyImageToClipboard(el Element, fn func(bool)) { panic("jsbridge") }
228 229 // WindowOpen opens url in a new browser tab.
230 func WindowOpen(url string) { panic("jsbridge") }
231 232 // EncodeURIComponent returns the URL-encoded form of s (calls JS encodeURIComponent).
233 func EncodeURIComponent(s string) (sv string) { panic("jsbridge") }
234 235 // GetPath returns the current location.pathname.
236 func GetPath() (s string) { panic("jsbridge") }
237 238 // GetHash returns the current location.hash (including the leading '#', or empty).
239 func GetHash() (s string) { panic("jsbridge") }
240 241 // Hostname returns the current location.hostname.
242 func Hostname() (s string) { panic("jsbridge") }
243 244 // Port returns the current location.port.
245 func Port() (s string) { panic("jsbridge") }
246 247 // UserAgent returns navigator.userAgent.
248 func UserAgent() (s string) { panic("jsbridge") }
249 250 // OnPopState registers a handler for browser back/forward navigation.
251 // fn receives the new location.pathname.
252 func OnPopState(fn func(string)) { panic("jsbridge") }
253 254 func InterceptInternalLinks(fn func(string)) { panic("jsbridge") }
255 256 // PickFileText opens a file picker dialog and reads the selected file as text.
257 // accept is the file type filter (e.g. ".json" or "application/json").
258 // Calls fn with the file text content, or empty string if cancelled/error.
259 func PickFileText(accept string, fn func(string)) { panic("jsbridge") }
260 261 // DownloadText triggers a file download with the given text content and filename.
262 func DownloadText(filename, content, mimeType string) { panic("jsbridge") }
263 264 // OnPullRefresh registers a handler that fires when the user pulls to refresh
265 // at the top of a scrollable element (wheel or touch). indicator is shown during pull.
266 func OnPullRefresh(el Element, indicator Element, fn func()) { panic("jsbridge") }
267 268 // NowSeconds returns the current Unix timestamp in seconds.
269 func NowSeconds() (n int64) { panic("jsbridge") }
270 271 // PickFileBase64 opens a file picker filtered by accept (e.g. "image/*").
272 // fn receives (base64data, mimeType). base64data has no data: prefix.
273 // Empty strings on cancel/error.
274 func PickFileBase64(accept string, fn func(string, string)) { panic("jsbridge") }
275 276 // OnPasteImage registers a handler on el that fires when the user pastes an
277 // image from the clipboard. fn receives (base64data, mimeType). base64data is
278 // the raw base64 (no data: prefix). mimeType is e.g. "image/png".
279 func OnPasteImage(el Element, fn func(string, string)) { panic("jsbridge") }
280 281 // OnDropImage registers drag-and-drop handlers on el for image files.
282 // fn receives (base64data, mimeType) for each dropped image file.
283 func OnDropImage(el Element, fn func(string, string)) { panic("jsbridge") }
284 285 // FetchPutBlobBase64 sends a PUT request to url with the body decoded from
286 // base64data. contentType sets Content-Type, authHeader sets Authorization.
287 // fn receives the response body text (or "" on error).
288 func FetchPutBlobBase64(url, base64data, contentType, authHeader string, fn func(string)) { panic("jsbridge") }
289