bindings.rs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #![allow(clippy::unused_unit, non_upper_case_globals)]
  2. use js_sys::Function;
  3. use wasm_bindgen::prelude::*;
  4. use web_sys::Element;
  5. #[wasm_bindgen(module = "/src/interpreter.js")]
  6. extern "C" {
  7. pub type Interpreter;
  8. #[wasm_bindgen(constructor)]
  9. pub fn new(arg: Element) -> Interpreter;
  10. #[wasm_bindgen(method)]
  11. pub fn SaveTemplate(this: &Interpreter, template: JsValue);
  12. #[wasm_bindgen(method)]
  13. pub fn MountToRoot(this: &Interpreter);
  14. #[wasm_bindgen(method)]
  15. pub fn AssignId(this: &Interpreter, path: &[u8], id: u32);
  16. #[wasm_bindgen(method)]
  17. pub fn CreatePlaceholder(this: &Interpreter, id: u32);
  18. #[wasm_bindgen(method)]
  19. pub fn CreateTextNode(this: &Interpreter, value: JsValue, id: u32);
  20. #[wasm_bindgen(method)]
  21. pub fn HydrateText(this: &Interpreter, path: &[u8], value: &str, id: u32);
  22. #[wasm_bindgen(method)]
  23. pub fn LoadTemplate(this: &Interpreter, name: &str, index: u32, id: u32);
  24. #[wasm_bindgen(method)]
  25. pub fn ReplaceWith(this: &Interpreter, id: u32, m: u32);
  26. #[wasm_bindgen(method)]
  27. pub fn ReplacePlaceholder(this: &Interpreter, path: &[u8], m: u32);
  28. #[wasm_bindgen(method)]
  29. pub fn InsertAfter(this: &Interpreter, id: u32, n: u32);
  30. #[wasm_bindgen(method)]
  31. pub fn InsertBefore(this: &Interpreter, id: u32, n: u32);
  32. #[wasm_bindgen(method)]
  33. pub fn SetAttribute(this: &Interpreter, id: u32, name: &str, value: JsValue, ns: Option<&str>);
  34. #[wasm_bindgen(method)]
  35. pub fn SetBoolAttribute(this: &Interpreter, id: u32, name: &str, value: bool);
  36. #[wasm_bindgen(method)]
  37. pub fn SetText(this: &Interpreter, id: u32, text: JsValue);
  38. #[wasm_bindgen(method)]
  39. pub fn NewEventListener(
  40. this: &Interpreter,
  41. name: &str,
  42. id: u32,
  43. bubbles: bool,
  44. handler: &Function,
  45. );
  46. #[wasm_bindgen(method)]
  47. pub fn RemoveEventListener(this: &Interpreter, name: &str, id: u32);
  48. #[wasm_bindgen(method)]
  49. pub fn RemoveAttribute(this: &Interpreter, id: u32, field: &str, ns: Option<&str>);
  50. #[wasm_bindgen(method)]
  51. pub fn Remove(this: &Interpreter, id: u32);
  52. #[wasm_bindgen(method)]
  53. pub fn PushRoot(this: &Interpreter, id: u32);
  54. #[wasm_bindgen(method)]
  55. pub fn AppendChildren(this: &Interpreter, id: u32, m: u32);
  56. }