px_wsdom/
lib.rs

1/*!
2# WSDOM
3
4WSDOM is a roundtrip-free Rust → JavaScript *Remote Method Invocation* or *Distributed Objects* system.
5It lets Rust code hold and manipulate JavaScript objects over the network.
6
7For an overview of what this library does, see the [README on GitHub](https://github.com/wishawa/wsdom).
8
9Small code examples to help you get started are available [on GitHub](https://github.com/wishawa/wsdom/tree/main/examples).
10
11# Documentation
12`wsdom::dom` is the module you will be working with most of the time.
13This module contains stubs for the Web API (`HTMLElement`, `Canvas`, etc.).
14The stubs were auto-generated so they don't have documentation attached to them,
15but you can always look for the item with the corresponding name on [MDN](https://developer.mozilla.org/en-US/docs/Web/API).
16
17The `wsdom::js` module contains stubs for the base JavaScript functionalities (`ArrayBuffer`, `RegExp`, etc.).
18Note that this module is **incomplete**. I only auto-generated a small subset of the JS API
19(because the TypeScript typings for these stuff are quite complicated so auto-translating them to Rust is hard).
20
21The `js_types` module contains JavaScript primitives such as `number`, `string`, and `object`.
22*/
23#![no_std]
24extern crate alloc;
25#[doc(hidden)]
26pub mod __wsdom_load_ts_macro {
27    //! Private module for our macro. Don't use this.
28    pub use ref_cast::RefCast;
29    pub use wsdom_core::{
30        for_macro::{RawCodeImmediate, UpcastWorkaround},
31        js_types::*,
32        Browser, JsCast, ToJs, UseInJsCode,
33    };
34    pub use wsdom_javascript::Array;
35    pub use wsdom_macros_decl::*;
36}
37
38pub use wsdom_core::callback;
39pub use wsdom_core::immediates::*;
40pub use wsdom_core::{js_types, Browser, JsCast, ToJs};
41pub use wsdom_dom as dom;
42pub use wsdom_javascript as js;
43pub use wsdom_macros::load_custom_ts;
44
45#[allow(non_snake_case)]
46#[cfg(test)]
47mod tests {
48    #[test]
49    fn dummy() {
50        use super::__wsdom_load_ts_macro;
51        wsdom_macros::load_ts!("../typescript-defs/test/dummy.d.ts");
52    }
53    #[test]
54    fn history() {
55        use super::__wsdom_load_ts_macro;
56        wsdom_macros::load_ts!("../typescript-defs/test/history.d.ts");
57    }
58
59    #[test]
60    #[allow(non_snake_case, non_camel_case_types)]
61    fn console() {
62        use super::__wsdom_load_ts_macro;
63        use wsdom_javascript::*;
64        wsdom_macros::load_ts!("../typescript-defs/test/console.d.ts");
65    }
66
67    #[test]
68    fn math() {
69        use super::__wsdom_load_ts_macro;
70        use wsdom_javascript::*;
71        wsdom_macros::load_ts!("../typescript-defs/test/math.d.ts");
72    }
73    #[test]
74    fn unify_nullable() {
75        use super::__wsdom_load_ts_macro;
76        wsdom_macros::load_ts!("../typescript-defs/test/unify-null.d.ts");
77    }
78
79    #[test]
80    fn generic() {
81        use super::__wsdom_load_ts_macro;
82        wsdom_macros::load_ts!("../typescript-defs/test/generic.d.ts");
83    }
84
85    #[test]
86    fn unify() {
87        use super::__wsdom_load_ts_macro;
88        wsdom_macros::load_ts!("../typescript-defs/test/unify.d.ts");
89    }
90}