This commit is contained in:
2026-07-29 17:14:55 +07:00
parent 5945251a60
commit 480039c6c5
3 changed files with 23 additions and 44 deletions

View File

@@ -31,8 +31,20 @@ pub fn run() -> Result<(), JsValue> {
#[cfg(target_family = "wasm")]
gpui_platform::web_init();
#[cfg(not(target_family = "wasm"))]
let app = gpui_platform::application();
#[cfg(target_family = "wasm")]
let app = {
let app = gpui_platform::single_threaded_web();
gpui_platform::application().run(|cx| {
// Temporary fix: intentionally leak the `Rc<AppCell>` to keep the application alive
struct WasmApplication(std::rc::Rc<AppCell>);
let wasm_app = unsafe { std::mem::transmute::<Application, WasmApplication>(app) };
std::mem::forget(wasm_app.0.clone());
unsafe { std::mem::transmute::<WasmApplication, Application>(wasm_app) }
};
app.run(|cx| {
// Open the root window
cx.open_window(WindowOptions::default(), |window, cx| {
// Initialize components