1 package dom
2 3 // Element is an opaque handle to a browser DOM element.
4 type Element int
5 6 // Body returns a handle to document.body.
7 func Body() Element { panic("jsbridge") }
8 9 // CreateElement creates a new DOM element with the given tag.
10 func CreateElement(tag string) Element { panic("jsbridge") }
11 12 // CreateTextNode creates a text node.
13 func CreateTextNode(text string) Element { panic("jsbridge") }
14 15 // GetElementById finds an element by its ID attribute.
16 func GetElementById(id string) Element { panic("jsbridge") }
17 18 // QuerySelector finds the first element matching a CSS selector.
19 func QuerySelector(sel string) Element { panic("jsbridge") }
20 21 // AppendChild adds a child element to a parent.
22 func AppendChild(parent, child Element) { panic("jsbridge") }
23 24 // RemoveChild removes a child element from a parent.
25 func RemoveChild(parent, child Element) { panic("jsbridge") }
26 27 // SetAttribute sets an attribute on an element.
28 func SetAttribute(el Element, name, value string) { panic("jsbridge") }
29 30 // SetTextContent sets the text content of an element.
31 func SetTextContent(el Element, text string) { panic("jsbridge") }
32 33 // SetInnerHTML sets the inner HTML of an element.
34 func SetInnerHTML(el Element, html string) { panic("jsbridge") }
35 36 // SetStyle sets a CSS style property on an element.
37 func SetStyle(el Element, prop, value string) { panic("jsbridge") }
38 39 // AddClass adds a CSS class to an element.
40 func AddClass(el Element, cls string) { panic("jsbridge") }
41 42 // RemoveClass removes a CSS class from an element.
43 func RemoveClass(el Element, cls string) { panic("jsbridge") }
44 45 // Focus sets keyboard focus on an element.
46 func Focus(el Element) { panic("jsbridge") }
47 48 // SetProperty sets a JS property on an element.
49 func SetProperty(el Element, prop, value string) { panic("jsbridge") }
50 51 // GetProperty gets a JS property from an element as a string.
52 func GetProperty(el Element, prop string) string { panic("jsbridge") }
53 54 // RegisterCallback registers a Go function as a JS event callback.
55 // Returns a callback ID for use with AddEventListener.
56 func RegisterCallback(fn func()) int { panic("jsbridge") }
57 58 // ReleaseCallback releases a registered callback.
59 func ReleaseCallback(id int) { panic("jsbridge") }
60 61 // AddEventListener adds an event listener. callbackId is from RegisterCallback.
62 func AddEventListener(el Element, event string, callbackId int) { panic("jsbridge") }
63 64 // AddSelfEventListener adds an event listener that only fires when
65 // the event target is the element itself, not a descendant.
66 func AddSelfEventListener(el Element, event string, callbackId int) { panic("jsbridge") }
67 68 // AddEnterKeyListener fires callback when Enter is pressed on the element.
69 func AddEnterKeyListener(el Element, callbackId int) { panic("jsbridge") }
70 71 // RemoveEventListener removes an event listener.
72 func RemoveEventListener(el Element, event string, callbackId int) { panic("jsbridge") }
73 74 // RequestAnimationFrame schedules a function to run before the next repaint.
75 func RequestAnimationFrame(fn func()) { panic("jsbridge") }
76 77 // SetTimeout schedules a function to run after ms milliseconds. Returns timer ID.
78 func SetTimeout(fn func(), ms int) int { panic("jsbridge") }
79 80 // ClearTimeout cancels a timer created by SetTimeout.
81 func ClearTimeout(id int) { panic("jsbridge") }
82 83 // FirstChild returns the first child node, or 0 if none.
84 // May return text nodes — use FirstElementChild for Element-only traversal.
85 func FirstChild(el Element) Element { panic("jsbridge") }
86 87 // FirstElementChild returns the first child that is an Element, or 0 if none.
88 // Skips text nodes and comments.
89 func FirstElementChild(el Element) Element { panic("jsbridge") }
90 91 // NextSibling returns the next sibling element, or 0 if none.
92 func NextSibling(el Element) Element { panic("jsbridge") }
93 94 // InsertBefore inserts newChild before refChild in parent.
95 func InsertBefore(parent, newChild, refChild Element) { panic("jsbridge") }
96 97 // ReleaseElement releases a DOM element handle.
98 func ReleaseElement(el Element) { panic("jsbridge") }
99 100 // FetchText fetches a URL and calls fn with the response text.
101 func FetchText(url string, fn func(string)) { panic("jsbridge") }
102 103 // FetchRelayInfo fetches NIP-11 relay info document from URL. Adds Accept header.
104 func FetchRelayInfo(url string, fn func(string)) { panic("jsbridge") }
105 106 // IDBGet retrieves a value from IndexedDB by key. Calls fn with "" if not found.
107 func IDBGet(store, key string, fn func(string)) { panic("jsbridge") }
108 109 // IDBPut stores a key-value pair in IndexedDB.
110 func IDBPut(store, key, value string) { panic("jsbridge") }
111 112 // IDBGetAll retrieves all key-value pairs from an IndexedDB store.
113 // Calls fn once per entry with (key, value). Calls done() when finished.
114 func IDBGetAll(store string, fn func(string, string), done func()) { panic("jsbridge") }
115 116 // PrefersDark returns true if the browser prefers dark color scheme.
117 func PrefersDark() bool { panic("jsbridge") }
118 119 // ConsoleLog logs a message to the browser console.
120 func ConsoleLog(msg string) { panic("jsbridge") }
121 122 // Confirm shows a browser confirm dialog and returns the user's choice.
123 func Confirm(msg string) bool { panic("jsbridge") }
124 125 // PostToSW sends a JSON message string to the service worker controller.
126 func PostToSW(msg string) { panic("jsbridge") }
127 128 // OnSWMessage registers a handler for JSON array messages from the service worker.
129 // fn receives the JSON-stringified array for each message.
130 func OnSWMessage(fn func(string)) { panic("jsbridge") }
131 132 // PushState pushes a new browser history entry with the given path.
133 func PushState(path string) { panic("jsbridge") }
134 135 // ReplaceState replaces the current browser history entry with the given path.
136 func ReplaceState(path string) { panic("jsbridge") }
137 138 // Back navigates one step back in browser history.
139 func Back() { panic("jsbridge") }
140 141 // LocationReload reloads the current page.
142 func LocationReload() { panic("jsbridge") }
143 144 // HardRefresh clears all SW caches, unregisters service workers, and reloads.
145 func HardRefresh() { panic("jsbridge") }
146 147 // ClearStoragePrefix removes all localStorage keys starting with the given prefix.
148 func ClearStoragePrefix(prefix string) { panic("jsbridge") }
149 150 // TimezoneOffsetSeconds returns the local timezone offset in seconds to add to UTC.
151 // E.g. UTC+9 returns 32400, UTC-8 returns -28800.
152 func TimezoneOffsetSeconds() int { panic("jsbridge") }
153 154 // ReadClipboard reads text from the clipboard. Uses navigator.clipboard.readText()
155 // if available (secure context), otherwise falls back to prompt().
156 // Calls fn with the text, or empty string if cancelled/failed.
157 func ReadClipboard(fn func(string)) { panic("jsbridge") }
158 159 // GetPath returns the current location.pathname.
160 func GetPath() string { panic("jsbridge") }
161 162 // Hostname returns the current location.hostname.
163 func Hostname() string { panic("jsbridge") }
164 165 // Port returns the current location.port.
166 func Port() string { panic("jsbridge") }
167 168 // UserAgent returns navigator.userAgent.
169 func UserAgent() string { panic("jsbridge") }
170 171 // OnPopState registers a handler for browser back/forward navigation.
172 // fn receives the new location.pathname.
173 func OnPopState(fn func(string)) { panic("jsbridge") }
174 175 // PickFileText opens a file picker dialog and reads the selected file as text.
176 // accept is the file type filter (e.g. ".json" or "application/json").
177 // Calls fn with the file text content, or empty string if cancelled/error.
178 func PickFileText(accept string, fn func(string)) { panic("jsbridge") }
179 180 // DownloadText triggers a file download with the given text content and filename.
181 func DownloadText(filename, content, mimeType string) { panic("jsbridge") }
182 183 // OnPullRefresh registers a handler that fires when the user pulls to refresh
184 // at the top of a scrollable element (wheel or touch). indicator is shown during pull.
185 func OnPullRefresh(el Element, indicator Element, fn func()) { panic("jsbridge") }
186 187 // NowSeconds returns the current Unix timestamp in seconds.
188 func NowSeconds() int64 { panic("jsbridge") }
189