dom.go raw

   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  // SetProperty sets a JS property on an element.
  46  func SetProperty(el Element, prop, value string) { panic("jsbridge") }
  47  
  48  // GetProperty gets a JS property from an element as a string.
  49  func GetProperty(el Element, prop string) string { panic("jsbridge") }
  50  
  51  // RegisterCallback registers a Go function as a JS event callback.
  52  // Returns a callback ID for use with AddEventListener.
  53  func RegisterCallback(fn func()) int { panic("jsbridge") }
  54  
  55  // ReleaseCallback releases a registered callback.
  56  func ReleaseCallback(id int) { panic("jsbridge") }
  57  
  58  // AddEventListener adds an event listener. callbackId is from RegisterCallback.
  59  func AddEventListener(el Element, event string, callbackId int) { panic("jsbridge") }
  60  
  61  // RemoveEventListener removes an event listener.
  62  func RemoveEventListener(el Element, event string, callbackId int) { panic("jsbridge") }
  63  
  64  // RequestAnimationFrame schedules a function to run before the next repaint.
  65  func RequestAnimationFrame(fn func()) { panic("jsbridge") }
  66  
  67  // SetTimeout schedules a function to run after ms milliseconds. Returns timer ID.
  68  func SetTimeout(fn func(), ms int) int { panic("jsbridge") }
  69  
  70  // ClearTimeout cancels a timer created by SetTimeout.
  71  func ClearTimeout(id int) { panic("jsbridge") }
  72  
  73  // FirstChild returns the first child element, or 0 if none.
  74  func FirstChild(el Element) Element { panic("jsbridge") }
  75  
  76  // NextSibling returns the next sibling element, or 0 if none.
  77  func NextSibling(el Element) Element { panic("jsbridge") }
  78  
  79  // InsertBefore inserts newChild before refChild in parent.
  80  func InsertBefore(parent, newChild, refChild Element) { panic("jsbridge") }
  81  
  82  // ReleaseElement releases a DOM element handle.
  83  func ReleaseElement(el Element) { panic("jsbridge") }
  84  
  85  // FetchText fetches a URL and calls fn with the response text.
  86  func FetchText(url string, fn func(string)) { panic("jsbridge") }
  87  
  88  // FetchRelayInfo fetches NIP-11 relay info document from URL. Adds Accept header.
  89  func FetchRelayInfo(url string, fn func(string)) { panic("jsbridge") }
  90  
  91  // IDBGet retrieves a value from IndexedDB by key. Calls fn with "" if not found.
  92  func IDBGet(store, key string, fn func(string)) { panic("jsbridge") }
  93  
  94  // IDBPut stores a key-value pair in IndexedDB.
  95  func IDBPut(store, key, value string) { panic("jsbridge") }
  96  
  97  // IDBGetAll retrieves all key-value pairs from an IndexedDB store.
  98  // Calls fn once per entry with (key, value). Calls done() when finished.
  99  func IDBGetAll(store string, fn func(string, string), done func()) { panic("jsbridge") }
 100  
 101  // PrefersDark returns true if the browser prefers dark color scheme.
 102  func PrefersDark() bool { panic("jsbridge") }
 103  
 104  // ConsoleLog logs a message to the browser console.
 105  func ConsoleLog(msg string) { panic("jsbridge") }
 106  
 107  // Confirm shows a browser confirm dialog and returns the user's choice.
 108  func Confirm(msg string) bool { panic("jsbridge") }
 109  
 110  // PostToSW sends a JSON message string to the service worker controller.
 111  func PostToSW(msg string) { panic("jsbridge") }
 112  
 113  // OnSWMessage registers a handler for JSON array messages from the service worker.
 114  // fn receives the JSON-stringified array for each message.
 115  func OnSWMessage(fn func(string)) { panic("jsbridge") }
 116  
 117  // PushState pushes a new browser history entry with the given path.
 118  func PushState(path string) { panic("jsbridge") }
 119  
 120  // ReplaceState replaces the current browser history entry with the given path.
 121  func ReplaceState(path string) { panic("jsbridge") }
 122  
 123  // LocationReload reloads the current page.
 124  func LocationReload() { panic("jsbridge") }
 125  
 126  // GetPath returns the current location.pathname.
 127  func GetPath() string { panic("jsbridge") }
 128  
 129  // Hostname returns the current location.hostname.
 130  func Hostname() string { panic("jsbridge") }
 131  
 132  // Port returns the current location.port.
 133  func Port() string { panic("jsbridge") }
 134  
 135  // OnPopState registers a handler for browser back/forward navigation.
 136  // fn receives the new location.pathname.
 137  func OnPopState(fn func(string)) { panic("jsbridge") }
 138