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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! # expo-modules-rs
//!
//! Rust SDK for writing Expo native modules that integrate directly
//! with the JavaScript Interface (JSI) runtime.
//!
//! This crate provides:
//! - The `ExpoModule` trait and `ModuleBuilder` for defining modules
//! - `JsValue` types and conversion traits (`FromJsValue`, `IntoJsValue`)
//! - The cxx bridge to the JSI C++ layer
//! - The `#[expo_module]` and `#[derive(ExpoRecord)]` proc macros
//!
//! ## Architecture
//!
//! ```text
//! +---------------+ +----------------+ +----------------+
//! | JavaScript |---->| JSI (C++) |---->| Rust Module |
//! | (Hermes) |<----| jsi_shim.cpp |<----| (your crate) |
//! +---------------+ +----------------+ +----------------+
//! | | |
//! JS calls cxx bridge ExpoModule
//! module.fn() FfiValue trait impl
//! ```
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use expo_modules_rs::prelude::*;
//!
//! struct MathModule;
//!
//! #[expo_module("RustMath")]
//! impl MathModule {
//! #[constant]
//! const PI: f64 = std::f64::consts::PI;
//!
//! fn add(a: f64, b: f64) -> f64 {
//! a + b
//! }
//! }
//! ```
/// Prelude module - import everything needed for module development.
/// C entry point called from the native side (Android JNI or iOS ObjC++)
/// to initialize Rust modules on the JSI runtime.
///
/// The `get_registry` closure must return a `ModuleRegistry` populated
/// with all modules to install.
///
/// # Safety
/// The runtime_ptr must be a valid pointer to a `jsi::Runtime`.
pub unsafe