js_browser.h 850 B

123456789101112131415161718192021222324252627
  1. /* Minimal browser bindings for the embedded MuJS interpreter.
  2. *
  3. * The host owns the document and the UI; this layer only exposes the small
  4. * DOM surface the first JavaScript milestone needs: console.log, alert,
  5. * document.getElementById(...).textContent and location.href. */
  6. #ifndef JS_BROWSER_H
  7. #define JS_BROWSER_H
  8. struct br_doc;
  9. struct js_browser_host {
  10. void (*status)(const char *msg, int error);
  11. void (*report)(const char *msg);
  12. void (*navigate)(const char *url);
  13. void (*changed)(void);
  14. };
  15. /* Create a state for this document. Returns 0 on success. */
  16. int js_browser_start(struct br_doc *doc, const struct js_browser_host *host);
  17. void js_browser_stop(void);
  18. /* Run one script. `url` is used in error messages and by location.href. */
  19. int js_browser_run(const char *source, const char *url);
  20. int js_browser_active(void);
  21. #endif