.
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1398,7 +1398,9 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tracing-wasm",
|
"tracing-wasm",
|
||||||
"ui",
|
"ui",
|
||||||
|
"universal-time",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
"web-time",
|
||||||
"workspace",
|
"workspace",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ version.workspace = true
|
|||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
publish.workspace = true
|
publish.workspace = true
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
workspace = { path = "../crates/workspace" }
|
workspace = { path = "../crates/workspace" }
|
||||||
assets = { path = "../crates/assets" }
|
assets = { path = "../crates/assets" }
|
||||||
@@ -29,6 +26,8 @@ console_error_panic_hook = "0.1"
|
|||||||
tracing-wasm = "0.2"
|
tracing-wasm = "0.2"
|
||||||
console_log = "1.0"
|
console_log = "1.0"
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
|
universal-time = "0.3.0"
|
||||||
|
web-time = "1.1.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
getrandom_0_2 = { package = "getrandom", version = "0.2", features = ["js"] }
|
getrandom_0_2 = { package = "getrandom", version = "0.2", features = ["js"] }
|
||||||
|
|||||||
@@ -1,7 +1,31 @@
|
|||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use gpui::*;
|
use gpui::*;
|
||||||
use ui::Root;
|
use ui::Root;
|
||||||
|
use universal_time::{Instant, MonotonicClock, SystemTime, WallClock, define_time_provider};
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
struct CustomTimeProvider;
|
||||||
|
|
||||||
|
impl WallClock for CustomTimeProvider {
|
||||||
|
fn system_time(&self) -> SystemTime {
|
||||||
|
SystemTime::from_unix_duration(Duration::from_secs(0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MonotonicClock for CustomTimeProvider {
|
||||||
|
fn instant(&self) -> Instant {
|
||||||
|
Instant::from_ticks(Duration::from_secs(0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
define_time_provider!(CustomTimeProvider);
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Binary entry point — actual initialization happens in `run()` below,
|
||||||
|
// which is called explicitly from JavaScript after the WASM module loads.
|
||||||
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn run() -> Result<(), JsValue> {
|
pub fn run() -> Result<(), JsValue> {
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
Reference in New Issue
Block a user