1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use wasm_bindgen::prelude::*;

crate::macro_import::wasm_bindgen_react! {
    #[derive(Debug, Clone)]
    pub type Element;
    #[wasm_bindgen(structural, method, getter = r#type)]
    pub fn kind(this: &Element) -> JsValue;

    #[wasm_bindgen(js_namespace = React, js_name = createElement)]
    pub fn create_element_no_props(element_type: &JsValue) -> Element;

    #[wasm_bindgen(js_namespace = React, js_name = createElement)]
    pub fn create_element_no_children(element_type: &JsValue, props: &JsValue) -> Element;

    #[wasm_bindgen(variadic, js_namespace = React, js_name = createElement)]
    pub fn create_element(
        element_type: &JsValue,
        props: &JsValue,
        children: &js_sys::Array,
    ) -> Element;

    /// # Safety
    ///
    /// the function in `element_type` closure should live longer enough
    #[wasm_bindgen(variadic, js_namespace = React, js_name = createElement)]
    pub unsafe fn create_element_fn(
        element_type: &Closure<dyn Fn(js_sys::Object) -> Element>,
        props: &JsValue,
        children: &js_sys::Array,
    ) -> Element;

    /// # Safety
    ///
    /// the function in `element_type` closure should live longer enough
    #[wasm_bindgen(variadic, js_namespace = React, js_name = createElement)]
    pub unsafe fn create_element_fn_mut(
        element_type: &Closure<dyn FnMut(js_sys::Object) -> Element>,
        props: &JsValue,
        children: &js_sys::Array,
    ) -> Element;

    #[wasm_bindgen(js_namespace = React, js_name = createElement)]
    pub fn create_element_intrinsic_no_props(element_type: &str) -> Element;

    #[wasm_bindgen(js_namespace = React, js_name = createElement)]
    pub fn create_element_intrinsic_no_children(element_type: &str, props: &JsValue) -> Element;

    #[wasm_bindgen(variadic, js_namespace = React, js_name = createElement)]
    pub fn create_element_intrinsic(
        element_type: &str,
        props: &JsValue,
        children: &js_sys::Array,
    ) -> Element;
}