diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index c6168cc1c..5b08f5356 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Rust uses: actions-rs/toolchain@v1 with: - toolchain: 1.77.2 + toolchain: 1.79 override: true components: clippy, rustfmt - name: Set up cache diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 30863dd74..7437ad5b9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -36,7 +36,7 @@ jobs: - name: Install stable toolchain uses: actions-rs/toolchain@v1 with: - toolchain: 1.77.2 + toolchain: 1.79 override: true components: llvm-tools-preview diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index b0d752be0..d4d9020b0 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -18,7 +18,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.77.2 + toolchain: 1.79 override: true - name: Set up cache diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index 52c10dd72..2ca306d24 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -19,7 +19,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.77.2 + toolchain: 1.79 override: true # Dependencies section diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index 4e80259ce..820cad75f 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -17,7 +17,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.77.2 + toolchain: 1.79 override: true components: clippy, rustfmt - run: rustup component add rustfmt diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index 4fae6a7de..556b400a6 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -19,7 +19,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.77.2 + toolchain: 1.79 override: true - name: Set up cache diff --git a/godot/.gitignore b/godot/.gitignore index 9d50d53ff..3e0fe03eb 100644 --- a/godot/.gitignore +++ b/godot/.gitignore @@ -21,4 +21,7 @@ mono_crash.*.json # System/tool-specific ignores .directory .DS_Store -*~ \ No newline at end of file +*~ + +# Decentraland ignores +/output/ diff --git a/lib/.cargo/config.toml b/lib/.cargo/config.toml index 1028b657c..d269235a9 100644 --- a/lib/.cargo/config.toml +++ b/lib/.cargo/config.toml @@ -14,4 +14,7 @@ rustflags = ["-C", "link-args=-ObjC"] rustflags = ["-C", "link-args=-mios-version-min=12.0 -ObjC"] [target.aarch64-apple-ios-sim] -rustflags = ["-C", "link-args=-mios-version-min=12.0 -ObjC"] \ No newline at end of file +rustflags = ["-C", "link-args=-mios-version-min=12.0 -ObjC"] + +[env] +CARGO_FEATURE_CRT_STATIC = "ohyes" \ No newline at end of file diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 91da80785..5b02b5487 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -8,11 +8,11 @@ publish = false crate-type = ["cdylib"] [dependencies] -godot = { git = "https://github.com/dclexplorer/gdext", rev ="4204285cdd32799690de28ee3a98ef624e95369e", features=["experimental-threads", "serde"] } +godot = { version = "0.1.3", features=["experimental-threads", "serde"] } rand = "0.8" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0.92", features = ["raw_value"] } -tokio = { version = "1.37.0", features = ["full"] } +tokio = { version = "1.40.0", features = ["full"] } protobuf = "3.2.0" prost = "0.11.8" once_cell = "1.16.0" @@ -41,8 +41,8 @@ tracing-subscriber = "0.3" poll-promise = "0.2.0" log-panics = { version = "2", features = ["with-backtrace"]} -v8 = { version = "0.74.3", optional = true } -deno_core = { version = "0.197", optional = true } +v8 = { version = "0.105.1", default-features = false, optional = true } +deno_core = { git = "https://github.com/robtfm/deno_core", branch = "0_307_hotfix", optional = true } uuid = { version = "1.3.0", features = ["v4"] } fastwebsockets = { version = "0.3.1", features = ["upgrade"], optional = true } hyper1 = { package = "hyper", version = "0.14.26", features = ["server","runtime", "http1"], optional = true } @@ -55,7 +55,7 @@ bytes = "1.4.0" tokio-tungstenite = "0.20.1" futures-util = "0.3.30" -livekit = { git = "https://github.com/livekit/rust-sdks", features=["rustls-tls-webpki-roots"], optional = true, rev="8b276f9d4b98437a139e1cbe41cfda1332ce1120" } +livekit = { git = "https://github.com/robtfm/client-sdk-rust", branch="0.6-h264-false-2", features=["rustls-tls-webpki-roots"], optional = true } taffy = "0.5.2" tracing-test = "0.2.4" @@ -83,10 +83,6 @@ use_resource_tracking = [] enable_inspector = ["use_deno", "dep:fastwebsockets", "dep:hyper1"] [build-dependencies] -webrtc-sys-build = { git = "https://github.com/livekit/rust-sdks", optional = true, rev="8b276f9d4b98437a139e1cbe41cfda1332ce1120" } +webrtc-sys-build = { version = "0.3.5", optional = true } prost-build = "0.11.8" -chrono = "0.4.31" - -[patch."https://github.com/godot-rust/godot4-prebuilt".godot4-prebuilt] -git = "https://github.com//godot-rust/godot4-prebuilt" -rev = "bc1e77856d181c14c59d2a5cb6a7e138ea5a2b39" +chrono = "0.4.31" \ No newline at end of file diff --git a/lib/android-build.sh b/lib/android-build.sh index 29fcc1b32..8325a56c3 100755 --- a/lib/android-build.sh +++ b/lib/android-build.sh @@ -39,20 +39,28 @@ if [[ "$1" == "x86_64" ]]; then cp target/x86_64-linux-android/release/libdclgodot.so ../godot/android/build/libs/release/x86_64/libdclgodot.so else - # Run the specified commands + # Run the specified commands export TARGET_CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android35-clang export TARGET_CXX=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android35-clang++ export TARGET_AR=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar - export RUSTY_V8_MIRROR=https://github.com/leanmendoza/rusty_v8/releases/download export CARGO_FFMPEG_SYS_DISABLE_SIZE_T_IS_USIZE=1 export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android35-clang" export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true - + export CXXFLAGS="-v --target=aarch64-linux-android" export RUSTFLAGS="-L${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/lib/aarch64-unknown-linux-musl" + # CI + export RUSTY_V8_MIRROR=https://github.com/leanmendoza/rusty_v8/releases/download + V8_BINDING_FILE_NAME=src_binding_debug_aarch64-linux-android.rs + V8_BINDING=$RUSTY_V8_MIRROR/v0.105.1/$V8_BINDING_FILE_NAME + export RUSTY_V8_SRC_BINDING_PATH=$(pwd)/target/$V8_BINDING_FILE_NAME + # download if not exists + if [ ! -f "target/$V8_BINDING_FILE_NAME" ]; then + curl -L -o target/$V8_BINDING_FILE_NAME $V8_BINDING + fi GODOT_DIR=../godot - + # Local development # - V8 local build # export RUSTY_V8_SRC_BINDING_PATH=/home/user/github/rusty_v8_updated/target/aarch64-linux-android/release/gn_out/src_binding.rs diff --git a/lib/src/avatars/avatar_type.rs b/lib/src/avatars/avatar_type.rs index bcbbe5130..be31885d5 100644 --- a/lib/src/avatars/avatar_type.rs +++ b/lib/src/avatars/avatar_type.rs @@ -90,9 +90,9 @@ impl DclAvatarWireFormat { for (i, emote) in DEFAULT_EMOTES.iter().enumerate() { if let Some(emote) = used_emotes.iter().find(|e| e.slot == i as u32) { - emotes.set(i, GString::from(emote.urn.as_str())); + emotes[i] = GString::from(emote.urn.as_str()); } else { - emotes.set(i, GString::from(*emote)); + emotes[i] = GString::from(*emote); } } emotes @@ -156,7 +156,7 @@ impl DclAvatarWireFormat { fn set_wearables(&mut self, wearables: PackedStringArray) { let mut wearables_vec = Vec::new(); for i in 0..wearables.len() { - wearables_vec.push(wearables.get(i).to_string()); + wearables_vec.push(wearables.get(i).as_ref().unwrap().to_string()); } self.inner.wearables = wearables_vec; } @@ -172,7 +172,7 @@ impl DclAvatarWireFormat { for i in 0..10 { emotes_vec.push(AvatarEmote { slot: i as u32, - urn: emotes.get(i).to_string(), + urn: emotes.get(i).as_ref().unwrap().to_string(), }); } self.inner.emotes = Some(emotes_vec); diff --git a/lib/src/comms/adapter/livekit.rs b/lib/src/comms/adapter/livekit.rs index f0b805cce..41975412d 100644 --- a/lib/src/comms/adapter/livekit.rs +++ b/lib/src/comms/adapter/livekit.rs @@ -11,7 +11,7 @@ use livekit::{ audio_source::native::NativeAudioSource, prelude::{AudioSourceOptions, RtcAudioSource}, }, - DataPacket, DataPacketKind, RoomOptions, + DataPacket, RoomOptions, }; use prost::Message; @@ -411,7 +411,7 @@ fn spawn_livekit_task( echo_cancellation: true, noise_suppression: true, auto_gain_control: true, - }, 48000, 1); + }, 48000, 1, None); let mic_track = LocalTrack::Audio(LocalAudioTrack::create_audio_track("mic", RtcAudioSource::Native(native_source.clone()))); room.local_participant().publish_track(mic_track, TrackPublishOptions{ source: TrackSource::Microphone, ..Default::default() }).await.unwrap(); @@ -473,7 +473,7 @@ fn spawn_livekit_task( livekit::track::RemoteTrack::Audio(audio) => { let sender = sender.clone(); rt2.spawn(async move { - let mut x = livekit::webrtc::audio_stream::native::NativeAudioStream::new(audio.rtc_track()); + let mut x = livekit::webrtc::audio_stream::native::NativeAudioStream::new(audio.rtc_track(), 48000, 1); tracing::debug!("remove track from {:?}", participant.identity().0.as_str()); @@ -519,12 +519,8 @@ fn spawn_livekit_task( break 'stream; }; - let kind = if outgoing.unreliable { - DataPacketKind::Lossy - } else { - DataPacketKind::Reliable - }; - if let Err(e) = room.local_participant().publish_data(DataPacket { payload: outgoing.data, kind, ..Default::default() }).await { + let reliable = !outgoing.unreliable; + if let Err(e) = room.local_participant().publish_data(DataPacket { payload: outgoing.data, reliable, ..Default::default() }).await { tracing::debug!("outgoing failed: {e}; not exiting loop though since it often fails at least once or twice at the start..."); // break 'stream; }; diff --git a/lib/src/dcl/components/mod.rs b/lib/src/dcl/components/mod.rs index 0d5d4662d..2a6c160ef 100644 --- a/lib/src/dcl/components/mod.rs +++ b/lib/src/dcl/components/mod.rs @@ -13,7 +13,7 @@ pub struct SceneEntityId { pub version: u16, } -impl godot::builtin::meta::GodotConvert for SceneEntityId { +impl GodotConvert for SceneEntityId { type Via = i32; } diff --git a/lib/src/dcl/js/adaptation_layer_helper.rs b/lib/src/dcl/js/adaptation_layer_helper.rs index 2a1b70f0e..6995340b9 100644 --- a/lib/src/dcl/js/adaptation_layer_helper.rs +++ b/lib/src/dcl/js/adaptation_layer_helper.rs @@ -1,11 +1,11 @@ use crate::dcl::scene_apis::RpcCall; -use deno_core::{anyhow::anyhow, op, Op, OpDecl, OpState}; +use deno_core::{anyhow::anyhow, op2, OpDecl, OpState}; use serde::Serialize; use std::{cell::RefCell, rc::Rc}; // list of op declarations pub fn ops() -> Vec { - vec![op_get_texture_size::DECL] + vec![op_get_texture_size()] } #[derive(Serialize)] @@ -14,8 +14,9 @@ struct TextureSize { height: f32, } -#[op(v8)] -async fn op_get_texture_size(state: Rc>, src: String) -> TextureSize { +#[op2(async)] +#[serde] +async fn op_get_texture_size(state: Rc>, #[string] src: String) -> TextureSize { let (sx, rx) = tokio::sync::oneshot::channel::>(); state diff --git a/lib/src/dcl/js/comms.rs b/lib/src/dcl/js/comms.rs index a4e9ad187..81de567d8 100644 --- a/lib/src/dcl/js/comms.rs +++ b/lib/src/dcl/js/comms.rs @@ -1,6 +1,6 @@ use std::{cell::RefCell, rc::Rc}; -use deno_core::{op, JsBuffer, Op, OpDecl, OpState}; +use deno_core::{op2, JsBuffer, OpDecl, OpState}; use ethers_core::types::H160; use crate::dcl::scene_apis::RpcCall; @@ -12,16 +12,16 @@ pub(crate) struct InternalPendingBinaryMessages { // list of op declarations pub fn ops() -> Vec { - vec![op_comms_send_string::DECL, op_comms_send_binary::DECL] + vec![op_comms_send_string(), op_comms_send_binary()] } pub(crate) const COMMS_MSG_TYPE_STRING: u8 = 1; pub(crate) const COMMS_MSG_TYPE_BINARY: u8 = 2; -#[op] +#[op2(async)] async fn op_comms_send_string( state: Rc>, - message: String, + #[string] message: String, ) -> Result<(), anyhow::Error> { let mut message = message.into_bytes(); message.insert(0, COMMS_MSG_TYPE_STRING); @@ -29,10 +29,11 @@ async fn op_comms_send_string( Ok(()) } -#[op] +#[op2(async)] +#[serde] async fn op_comms_send_binary( state: Rc>, - messages: Vec, + #[serde] messages: Vec, ) -> Result>, anyhow::Error> { let messages = messages .iter() diff --git a/lib/src/dcl/js/engine.rs b/lib/src/dcl/js/engine.rs index 6e6ee86be..0a1110a8b 100644 --- a/lib/src/dcl/js/engine.rs +++ b/lib/src/dcl/js/engine.rs @@ -4,7 +4,7 @@ use std::{ sync::{Arc, Mutex}, }; -use deno_core::{op, Op, OpDecl, OpState}; +use deno_core::{op2, OpDecl, OpState}; use crate::dcl::{ common::{SceneDying, SceneElapsedTime, SceneLogs, SceneMainCrdtFileContent}, @@ -27,15 +27,12 @@ use super::{ // list of op declarations pub fn ops() -> Vec { - vec![ - op_crdt_send_to_renderer::DECL, - op_crdt_recv_from_renderer::DECL, - ] + vec![op_crdt_send_to_renderer(), op_crdt_recv_from_renderer()] } // receive and process a buffer of crdt messages -#[op(v8)] -fn op_crdt_send_to_renderer(op_state: Rc>, messages: &[u8]) { +#[op2(fast)] +fn op_crdt_send_to_renderer(op_state: Rc>, #[arraybuffer] messages: &[u8]) { let dying = op_state.borrow().borrow::().0; if dying { return; @@ -79,16 +76,20 @@ fn op_crdt_send_to_renderer(op_state: Rc>, messages: &[u8]) { .expect("error sending scene response!!") } -#[op(v8)] -async fn op_crdt_recv_from_renderer(op_state: Rc>) -> Vec> { +#[op2(async)] +#[serde] +async fn op_crdt_recv_from_renderer( + op_state: Rc>, +) -> Result>, anyhow::Error> { let dying = op_state.borrow().borrow::().0; if dying { - return vec![]; + return Ok(vec![]); } let mut receiver = op_state .borrow_mut() - .take::>(); + .try_take::>() + .ok_or(anyhow::Error::msg("already borrowed"))?; let response = receiver.recv().await; let mut op_state = op_state.borrow_mut(); @@ -182,7 +183,7 @@ async fn op_crdt_recv_from_renderer(op_state: Rc>) -> Vec, crdt_state: &SceneCrdtState) { diff --git a/lib/src/dcl/js/ethereum_controller.rs b/lib/src/dcl/js/ethereum_controller.rs index 31fb99014..f01849e9f 100644 --- a/lib/src/dcl/js/ethereum_controller.rs +++ b/lib/src/dcl/js/ethereum_controller.rs @@ -1,4 +1,4 @@ -use deno_core::{anyhow::anyhow, error::AnyError, op, Op, OpDecl, OpState}; +use deno_core::{anyhow::anyhow, error::AnyError, op2, OpDecl, OpState}; use std::{cell::RefCell, rc::Rc, sync::Arc}; @@ -9,14 +9,15 @@ use crate::{ // list of op declarations pub fn ops() -> Vec { - vec![op_send_async::DECL] + vec![op_send_async()] } -#[op] +#[op2(async)] +#[serde] async fn op_send_async( state: Rc>, - method: String, - params: String, + #[string] method: String, + #[string] params: String, ) -> Result { let params: Vec = serde_json::from_str(¶ms)?; diff --git a/lib/src/dcl/js/events.rs b/lib/src/dcl/js/events.rs index 164e53659..d68152b34 100644 --- a/lib/src/dcl/js/events.rs +++ b/lib/src/dcl/js/events.rs @@ -9,7 +9,7 @@ use crate::dcl::{ SceneCrdtStateProtoComponents, }, }; -use deno_core::{op, Op, OpDecl, OpState}; +use deno_core::{op2, OpDecl, OpState}; use ethers_core::types::H160; use serde::Serialize; use std::{ @@ -18,11 +18,7 @@ use std::{ }; pub fn ops() -> Vec { - vec![ - op_subscribe::DECL, - op_unsubscribe::DECL, - op_send_batch::DECL, - ] + vec![op_subscribe(), op_unsubscribe(), op_send_batch()] } #[derive(Serialize)] @@ -155,8 +151,8 @@ struct EventSender { _p: PhantomData T>, } -#[op] -fn op_subscribe(state: &mut OpState, id: &str) { +#[op2(fast)] +fn op_subscribe(state: &mut OpState, #[string] id: &str) { macro_rules! register { ($id: expr, $state: expr, $marker: ty) => {{ if id == <$marker as EventType>::label() { @@ -194,8 +190,8 @@ fn op_subscribe(state: &mut OpState, id: &str) { tracing::warn!("subscribe to unrecognised event {id}"); } -#[op] -fn op_unsubscribe(state: &mut OpState, id: &str) { +#[op2(fast)] +fn op_unsubscribe(state: &mut OpState, #[string] id: &str) { macro_rules! unregister { ($id: expr, $state: expr, $marker: ty) => {{ if id == <$marker as EventType>::label() { @@ -233,7 +229,8 @@ struct EventGeneric { event_data: String, } -#[op] +#[op2] +#[serde] fn op_send_batch(state: &mut OpState) -> Vec { let mut results = Vec::default(); diff --git a/lib/src/dcl/js/fetch/mod.rs b/lib/src/dcl/js/fetch/mod.rs index 6ff07a424..3a4e88234 100644 --- a/lib/src/dcl/js/fetch/mod.rs +++ b/lib/src/dcl/js/fetch/mod.rs @@ -1,6 +1,6 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::Arc, time::Duration}; -use deno_core::{error::AnyError, op, Op, OpDecl, OpState}; +use deno_core::{error::AnyError, op2, OpDecl, OpState}; use http::HeaderValue; use reqwest::Response; use serde::Serialize; @@ -18,10 +18,10 @@ mod signed_fetch; pub fn ops() -> Vec { vec![ - op_fetch_custom::DECL, - op_fetch_consume_text::DECL, - op_fetch_consume_bytes::DECL, - signed_fetch::op_signed_fetch_headers::DECL, + op_fetch_custom(), + op_fetch_consume_text(), + op_fetch_consume_bytes(), + signed_fetch::op_signed_fetch_headers(), ] } @@ -71,15 +71,17 @@ impl FetchRequestsState { } } -#[op] +#[op2(async)] +#[serde] +#[allow(clippy::too_many_arguments)] async fn op_fetch_custom( op_state: Rc>, - method: String, - url: String, - headers: HashMap, + #[string] method: String, + #[string] url: String, + #[serde] headers: HashMap, has_body: bool, - body_data: String, - _redirect: String, // TODO: unimplemented + #[string] body_data: String, + #[string] _redirect: String, // TODO: unimplemented timeout: u32, ) -> Result { let maybe_network_inspector_sender = op_state @@ -282,7 +284,8 @@ async fn op_fetch_custom( } } -#[op] +#[op2(async)] +#[string] async fn op_fetch_consume_text( op_state: Rc>, req_id: u32, @@ -371,7 +374,8 @@ async fn op_fetch_consume_text( } Err(anyhow::Error::msg("couldn't get response")) } -#[op] +#[op2(async)] +#[serde] async fn op_fetch_consume_bytes( op_state: Rc>, req_id: u32, diff --git a/lib/src/dcl/js/fetch/signed_fetch.rs b/lib/src/dcl/js/fetch/signed_fetch.rs index 7a59a642a..9d0814bb8 100644 --- a/lib/src/dcl/js/fetch/signed_fetch.rs +++ b/lib/src/dcl/js/fetch/signed_fetch.rs @@ -1,6 +1,6 @@ use std::{cell::RefCell, rc::Rc, sync::Arc}; -use deno_core::{error::AnyError, op, OpState}; +use deno_core::{error::AnyError, op2, OpState}; use http::Uri; use crate::{ @@ -32,11 +32,12 @@ struct SignedFetchMeta { realm: SignedFetchMetaRealm, } -#[op] +#[op2(async)] +#[serde] pub async fn op_signed_fetch_headers( op_state: Rc>, - uri: String, - method: Option, + #[string] uri: String, + #[string] method: Option, ) -> Result, AnyError> { let wallet = op_state .borrow() diff --git a/lib/src/dcl/js/inspector.rs b/lib/src/dcl/js/inspector.rs index facfdae93..056377292 100644 --- a/lib/src/dcl/js/inspector.rs +++ b/lib/src/dcl/js/inspector.rs @@ -15,7 +15,7 @@ use deno_core::futures::task::Poll; use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::serde_json::Value; -use deno_core::task::spawn; +use deno_core::unsync::spawn; use deno_core::InspectorMsg; use deno_core::InspectorSessionProxy; use deno_core::JsRuntime; @@ -118,7 +118,7 @@ where Fut::Output: 'static, { fn execute(&self, fut: Fut) { - deno_core::task::spawn(fut); + deno_core::unsync::spawn(fut); } } @@ -255,7 +255,7 @@ async fn server( let json_version_response = json!({ "Browser": name, "Protocol-Version": "1.3", - "V8-Version": deno_core::v8_version(), + "V8-Version": deno_core::v8::VERSION_STRING, }); let make_svc = hyper1::service::make_service_fn(|_| { diff --git a/lib/src/dcl/js/js_modules/EngineApi.js b/lib/src/dcl/js/js_modules/EngineApi.js index 844724515..35560cc99 100644 --- a/lib/src/dcl/js/js_modules/EngineApi.js +++ b/lib/src/dcl/js/js_modules/EngineApi.js @@ -1,14 +1,17 @@ // engine module +const { op_crdt_recv_from_renderer, op_crdt_send_to_renderer, op_subscribe, op_send_batch } = Deno.core.ops; + module.exports.crdtSendToRenderer = async function (messages) { - Deno.core.ops.op_crdt_send_to_renderer(messages.data); - const data = (await Deno.core.opAsync("op_crdt_recv_from_renderer")).map((item) => new Uint8Array(item)); + op_crdt_send_to_renderer(messages.data.buffer.slice(messages.data.byteOffset, messages.data.byteLength + messages.data.byteOffset)); + const data = (await op_crdt_recv_from_renderer()).map((item) => new Uint8Array(item)); return { data: data }; } + module.exports.crdtGetState = async function () { - const data = (await Deno.core.opAsync("op_crdt_recv_from_renderer")).map((item) => new Uint8Array(item)) + const data = (await op_crdt_recv_from_renderer()).map((item) => new Uint8Array(item)) return { data: data @@ -27,7 +30,7 @@ module.exports.isServer = async function () { * This function subscribe to an event from the renderer */ module.exports.subscribe = async function (message) { - Deno.core.ops.op_subscribe(message.eventId); + op_subscribe(message.eventId); } /** @@ -35,7 +38,7 @@ module.exports.subscribe = async function (message) { * This function unsubscribe to an event from the renderer */ module.exports.unsubscribe = async function (message) { - Deno.core.ops.op_unsubscribe(message.eventId); + op_unsubscribe(message.eventId); } /** @@ -43,5 +46,5 @@ module.exports.unsubscribe = async function (message) { * This function polls events from the renderer */ module.exports.sendBatch = async function () { - return { events: Deno.core.ops.op_send_batch() } + return { events: op_send_batch() } } diff --git a/lib/src/dcl/js/js_modules/RestrictedActions.js b/lib/src/dcl/js/js_modules/RestrictedActions.js index ce783ad79..65c0e1204 100644 --- a/lib/src/dcl/js/js_modules/RestrictedActions.js +++ b/lib/src/dcl/js/js_modules/RestrictedActions.js @@ -2,15 +2,20 @@ module.exports.movePlayerTo = async function (body) { const position = body.newRelativePosition; if ("cameraTarget" in body) { return await Deno.core.ops.op_move_player_to( - [position.x, position.y, position.z], - [body.cameraTarget.x, body.cameraTarget.y, body.cameraTarget.z] + position.x, position.y, position.z, + true, + body.cameraTarget.x, body.cameraTarget.y, body.cameraTarget.z ); } else { - return await Deno.core.ops.op_move_player_to([ + return await Deno.core.ops.op_move_player_to( position.x, position.y, position.z, - ]); + false, + 0, + 0, + 0 + ); } }; module.exports.teleportTo = async function (body) { diff --git a/lib/src/dcl/js/js_modules/fetch.js b/lib/src/dcl/js/js_modules/fetch.js index a14f26345..1ffc8168c 100644 --- a/lib/src/dcl/js/js_modules/fetch.js +++ b/lib/src/dcl/js/js_modules/fetch.js @@ -152,8 +152,7 @@ async function fetch(url, init) { const reqTimeout = timeout ?? 30 const reqHeaders = headers ?? {} const reqRedirect = redirect ?? 'follow' - const response = await Deno.core.opAsync( - "op_fetch_custom", + const response = await Deno.core.ops.op_fetch_custom( reqMethod, url, reqHeaders, hasBody, body ?? '', reqRedirect, reqTimeout ) const reqId = response._internal_req_id @@ -181,8 +180,7 @@ async function fetch(url, init) { async arrayBuffer() { notifyConsume() throwErrorFailed() - const data = await Deno.core.opAsync( - "op_fetch_consume_bytes", + const data = await Deno.core.ops.op_fetch_consume_bytes( reqId, networkInpectorReqId ) @@ -192,8 +190,7 @@ async function fetch(url, init) { async json() { notifyConsume() throwErrorFailed() - const data = await Deno.core.opAsync( - "op_fetch_consume_text", + const data = await Deno.core.ops.op_fetch_consume_text( reqId, networkInpectorReqId ) @@ -208,8 +205,7 @@ async function fetch(url, init) { async text() { notifyConsume() throwErrorFailed() - const data = await Deno.core.opAsync( - "op_fetch_consume_text", + const data = await Deno.core.ops.op_fetch_consume_text( reqId, networkInpectorReqId ) @@ -218,8 +214,7 @@ async function fetch(url, init) { async bytes() { throwErrorFailed() notifyConsume() - const data = await Deno.core.opAsync( - "op_fetch_consume_bytes", + const data = await Deno.core.ops.op_fetch_consume_bytes( reqId, networkInpectorReqId ) diff --git a/lib/src/dcl/js/js_modules/main.js b/lib/src/dcl/js/js_modules/main.js index 748517ca9..4fb344223 100644 --- a/lib/src/dcl/js/js_modules/main.js +++ b/lib/src/dcl/js/js_modules/main.js @@ -124,6 +124,13 @@ globalThis.performance = { now: () => Date.now() - nowOffset } -Deno.core.ops.op_set_promise_reject_callback((type, promise, reason) => { +Deno.core.setUnhandledPromiseRejectionHandler((promise, reason) => { console.error('Unhandled promise: ', reason) -}) \ No newline at end of file + return false +}) + + +Deno.core.setHandledPromiseRejectionHandler((promise, reason) => { + console.error('Handled promise: ', reason) + return false +}) diff --git a/lib/src/dcl/js/js_modules/ws.js b/lib/src/dcl/js/js_modules/ws.js index 93af8032d..c79099088 100644 --- a/lib/src/dcl/js/js_modules/ws.js +++ b/lib/src/dcl/js/js_modules/ws.js @@ -100,13 +100,13 @@ class WebSocket { send(data) { if (typeof data === 'string') { - Deno.core.opAsync("op_ws_send", this._internal_ws_id, { "type": "Text", data }).then().catch(console.error) + Deno.core.ops.op_ws_send(this._internal_ws_id, { "type": "Text", data }).then().catch(console.error) } else if (typeof data === 'object' && data instanceof Uint8Array) { - Deno.core.opAsync("op_ws_send", this._internal_ws_id, { "type": "Binary", data: Array.from(data) }).then().catch(console.error) + Deno.core.ops.op_ws_send(this._internal_ws_id, { "type": "Binary", data: Array.from(data) }).then().catch(console.error) } else if (typeof data === 'object' && data instanceof ArrayBuffer) { - Deno.core.opAsync("op_ws_send", this._internal_ws_id, { "type": "Binary", data: Array.from(new Uint8Array(data)) }).then().catch(console.error) + Deno.core.ops.op_ws_send(this._internal_ws_id, { "type": "Binary", data: Array.from(new Uint8Array(data)) }).then().catch(console.error) } else if (Array.isArray(data)) { - Deno.core.opAsync("op_ws_send", this._internal_ws_id, { "type": "Binary", data }).then().catch(console.error) + Deno.core.ops.op_ws_send(this._internal_ws_id, { "type": "Binary", data }).then().catch(console.error) } else { console.error(`Unsupported data type: ${typeof data}`, data) throw new Error("Unsupported data type") @@ -124,9 +124,7 @@ class WebSocket { async _poll() { const self = this async function poll_from_native() { - const data = await Deno.core.opAsync( - "op_ws_poll", self._internal_ws_id - ) + const data = await Deno.core.ops.op_ws_poll(self._internal_ws_id) switch (data.type) { case "BinaryData": diff --git a/lib/src/dcl/js/mod.rs b/lib/src/dcl/js/mod.rs index 7245da9bd..f0c151a12 100644 --- a/lib/src/dcl/js/mod.rs +++ b/lib/src/dcl/js/mod.rs @@ -32,8 +32,9 @@ use std::time::Duration; use deno_core::error::JsError; use deno_core::{ error::{generic_error, AnyError}, - include_js_files, op, Extension, Op, OpState, RuntimeOptions, + include_js_files, op2, Extension, OpState, RuntimeOptions, }; +use deno_core::{JsRuntime, OpDecl, PollEventLoopOptions}; use once_cell::sync::Lazy; use serde::Serialize; use v8::IsolateHandle; @@ -49,10 +50,7 @@ pub(crate) static VM_HANDLES: Lazy (deno_core::JsRuntime, Option) { - let mut ext = &mut Extension::builder_with_deps("decentraland", &[]); - - // add core ops - ext = ext.ops(vec![op_require::DECL, op_log::DECL, op_error::DECL]); + let mut ops = vec![op_require(), op_log(), op_error()]; let op_sets: [Vec; 12] = [ engine::ops(), @@ -69,36 +67,42 @@ pub fn create_runtime(inspect: bool) -> (deno_core::JsRuntime, Option OpDecl { if let Some(custom_op) = op_map.get(&op.name) { tracing::debug!("replace: {}", op.name); op.with_implementation_from(custom_op) } else { op } - }) - .build(); + })), + ..Default::default() + }; // create runtime #[allow(unused_mut)] let mut runtime = deno_core::JsRuntime::new(RuntimeOptions { - v8_platform: v8::Platform::new(1, false).make_shared().into(), + v8_platform: deno_core::v8::Platform::new(1, false).make_shared().into(), extensions: vec![ext], inspector: inspect, ..Default::default() @@ -263,7 +267,7 @@ pub(crate) fn scene_thread( .build() .unwrap(); - let script = rt.block_on(async { runtime.execute_script("", scene_code.into()) }); + let script = rt.block_on(async { runtime.execute_script("", scene_code) }); let script = match script { Err(e) => { @@ -355,15 +359,12 @@ pub(crate) fn scene_thread( // helper to setup, acquire, run and return results from a script function async fn run_script( - runtime: &mut deno_core::JsRuntime, + runtime: &mut JsRuntime, script: &v8::Global, fn_name: &str, arg_fn: impl for<'a> Fn(&mut v8::HandleScope<'a>) -> Vec>, ) -> Result<(), AnyError> { // set up scene i/o - let op_state = runtime.op_state(); - op_state.borrow_mut().put(()); - let promise = { let scope = &mut runtime.handle_scope(); let script_this = v8::Local::new(scope, script.clone()); @@ -398,15 +399,19 @@ async fn run_script( v8::Global::new(scope, res) }; - let f = runtime.resolve_value(promise); - f.await.map(|_| ()) + let f = runtime.resolve(promise); + runtime + .with_event_loop_promise(f, PollEventLoopOptions::default()) + .await + .map(|_| ()) } // synchronously returns a string containing JS code from the file system -#[op(v8)] +#[op2] +#[string] fn op_require( state: &mut OpState, - module_spec: String, + #[string] module_spec: String, ) -> Result { match module_spec.as_str() { // core module load @@ -444,8 +449,8 @@ fn op_require( } } -#[op(v8)] -fn op_log(state: Rc>, mut message: String, immediate: bool) { +#[op2(fast)] +fn op_log(state: Rc>, #[string] mut message: String, immediate: bool) { if !is_scene_log_enabled() { return; } @@ -472,8 +477,8 @@ fn op_log(state: Rc>, mut message: String, immediate: bool) { }) } -#[op(v8)] -fn op_error(state: Rc>, mut message: String, immediate: bool) { +#[op2(fast)] +fn op_error(state: Rc>, #[string] mut message: String, immediate: bool) { if !is_scene_log_enabled() { return; } diff --git a/lib/src/dcl/js/players.rs b/lib/src/dcl/js/players.rs index 88460657f..5ed5c4803 100644 --- a/lib/src/dcl/js/players.rs +++ b/lib/src/dcl/js/players.rs @@ -1,6 +1,6 @@ use std::{cell::RefCell, rc::Rc}; -use deno_core::{error::AnyError, op, Op, OpDecl, OpState}; +use deno_core::{error::AnyError, op2, OpDecl, OpState}; use crate::dcl::{ components::{proto_components::common::Color3, SceneEntityId}, @@ -10,16 +10,17 @@ use crate::dcl::{ pub fn ops() -> Vec { vec![ - op_get_player_data::DECL, - op_get_connected_players::DECL, - op_get_players_in_scene::DECL, + op_get_player_data(), + op_get_connected_players(), + op_get_players_in_scene(), ] } -#[op] +#[op2(async)] +#[serde] async fn op_get_player_data( op_state: Rc>, - user_id: String, + #[string] user_id: String, ) -> Result, AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); @@ -34,7 +35,8 @@ async fn op_get_player_data( rx.await.map_err(|e| anyhow::anyhow!(e)) } -#[op] +#[op2(async)] +#[serde] async fn op_get_players_in_scene(op_state: Rc>) -> Result, AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); @@ -47,7 +49,8 @@ async fn op_get_players_in_scene(op_state: Rc>) -> Result>) -> Result, AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); diff --git a/lib/src/dcl/js/portables.rs b/lib/src/dcl/js/portables.rs index efd6de6fb..3589ccf0a 100644 --- a/lib/src/dcl/js/portables.rs +++ b/lib/src/dcl/js/portables.rs @@ -1,22 +1,19 @@ -use deno_core::{anyhow::anyhow, error::AnyError, op, Op, OpDecl, OpState}; +use deno_core::{anyhow::anyhow, error::AnyError, op2, OpDecl, OpState}; use std::{cell::RefCell, rc::Rc}; use crate::dcl::scene_apis::{PortableLocation, RpcCall, SpawnResponse}; // list of op declarations pub fn ops() -> Vec { - vec![ - op_portable_spawn::DECL, - op_portable_list::DECL, - op_portable_kill::DECL, - ] + vec![op_portable_spawn(), op_portable_list(), op_portable_kill()] } -#[op] +#[op2(async)] +#[serde] async fn op_portable_spawn( state: Rc>, - pid: Option, - ens: Option, + #[string] pid: Option, + #[string] ens: Option, ) -> Result { let (sx, rx) = tokio::sync::oneshot::channel::>(); @@ -39,8 +36,11 @@ async fn op_portable_spawn( .map_err(|e| anyhow!(e)) } -#[op] -async fn op_portable_kill(state: Rc>, pid: String) -> Result { +#[op2(async)] +async fn op_portable_kill( + state: Rc>, + #[string] pid: String, +) -> Result { let (sx, rx) = tokio::sync::oneshot::channel::(); // might not be a urn, who even knows @@ -56,7 +56,8 @@ async fn op_portable_kill(state: Rc>, pid: String) -> Result>) -> Vec { let (sx, rx) = tokio::sync::oneshot::channel::>(); diff --git a/lib/src/dcl/js/restricted_actions.rs b/lib/src/dcl/js/restricted_actions.rs index 6f3b40d51..6683d7444 100644 --- a/lib/src/dcl/js/restricted_actions.rs +++ b/lib/src/dcl/js/restricted_actions.rs @@ -1,27 +1,27 @@ use std::{cell::RefCell, rc::Rc}; -use deno_core::{anyhow::anyhow, error::AnyError, op, Op, OpDecl, OpState}; +use deno_core::{anyhow::anyhow, error::AnyError, op2, OpDecl, OpState}; use http::Uri; use crate::dcl::scene_apis::RpcCall; pub fn ops() -> Vec { vec![ - op_change_realm::DECL, - op_open_nft_dialog::DECL, - op_open_external_url::DECL, - op_move_player_to::DECL, - op_teleport_to::DECL, - op_trigger_emote::DECL, - op_trigger_scene_emote::DECL, + op_change_realm(), + op_open_nft_dialog(), + op_open_external_url(), + op_move_player_to(), + op_teleport_to(), + op_trigger_emote(), + op_trigger_scene_emote(), ] } -#[op] +#[op2(async)] async fn op_change_realm( op_state: Rc>, - realm: String, - message: Option, + #[string] realm: String, + #[string] message: Option, ) -> Result<(), AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); @@ -39,8 +39,11 @@ async fn op_change_realm( .map_err(|e| anyhow!(e)) } -#[op] -async fn op_open_nft_dialog(op_state: Rc>, urn: String) -> Result<(), AnyError> { +#[op2(async)] +async fn op_open_nft_dialog( + op_state: Rc>, + #[string] urn: String, +) -> Result<(), AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); op_state @@ -56,8 +59,11 @@ async fn op_open_nft_dialog(op_state: Rc>, urn: String) -> Resu .map_err(|e| anyhow!(e)) } -#[op] -async fn op_open_external_url(op_state: Rc>, url: String) -> Result<(), AnyError> { +#[op2(async)] +async fn op_open_external_url( + op_state: Rc>, + #[string] url: String, +) -> Result<(), AnyError> { let parsed_url = match url.parse::() { Ok(parsed_url) if parsed_url.scheme_str() == Some("https") => parsed_url, Ok(_) => return Err(anyhow!("URL does not use HTTPS")), @@ -79,14 +85,27 @@ async fn op_open_external_url(op_state: Rc>, url: String) -> Re .map_err(|e| anyhow!(e)) } -#[op] +#[op2(async)] +#[allow(clippy::too_many_arguments)] async fn op_move_player_to( op_state: Rc>, - position_target: [f32; 3], - camera_target: Option<[f32; 3]>, + position_x: f32, + position_y: f32, + position_z: f32, + camera: bool, + maybe_camera_x: f32, + maybe_camera_y: f32, + maybe_camera_z: f32, ) -> Result<(), AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); + let position_target = [position_x, position_y, position_z]; + let camera_target = if camera { + Some([maybe_camera_x, maybe_camera_y, maybe_camera_z]) + } else { + None + }; + op_state .borrow_mut() .borrow_mut::>() @@ -101,10 +120,11 @@ async fn op_move_player_to( .map_err(|e| anyhow!(e)) } -#[op] +#[op2(async)] async fn op_teleport_to( op_state: Rc>, - world_coordinates: [i32; 2], + world_coordinates_x: i32, + world_coordinates_y: i32, ) -> Result<(), AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); @@ -112,7 +132,7 @@ async fn op_teleport_to( .borrow_mut() .borrow_mut::>() .push(RpcCall::TeleportTo { - world_coordinates, + world_coordinates: [world_coordinates_x, world_coordinates_y], response: sx.into(), }); @@ -121,10 +141,10 @@ async fn op_teleport_to( .map_err(|e| anyhow!(e)) } -#[op] +#[op2(async)] async fn op_trigger_emote( op_state: Rc>, - emote_id: String, + #[string] emote_id: String, ) -> Result<(), AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); @@ -141,10 +161,10 @@ async fn op_trigger_emote( .map_err(|e| anyhow!(e)) } -#[op] +#[op2(async)] async fn op_trigger_scene_emote( op_state: Rc>, - emote_src: String, + #[string] emote_src: String, looping: bool, ) -> Result<(), AnyError> { let (sx, rx) = tokio::sync::oneshot::channel::>(); diff --git a/lib/src/dcl/js/runtime.rs b/lib/src/dcl/js/runtime.rs index 528b2fbe6..70e98a2f2 100644 --- a/lib/src/dcl/js/runtime.rs +++ b/lib/src/dcl/js/runtime.rs @@ -1,4 +1,4 @@ -use deno_core::{anyhow::anyhow, error::AnyError, op, Op, OpDecl, OpState}; +use deno_core::{anyhow::anyhow, error::AnyError, op2, OpDecl, OpState}; use serde::Serialize; use std::{cell::RefCell, rc::Rc, sync::Arc}; @@ -14,9 +14,9 @@ use crate::{ pub fn ops() -> Vec { vec![ - op_get_file_url::DECL, - op_get_realm::DECL, - op_get_scene_information::DECL, + op_get_file_url(), + op_get_realm(), + op_get_scene_information(), ] } @@ -27,10 +27,11 @@ struct GetFileUrlResponse { hash: String, } -#[op(v8)] +#[op2] +#[serde] fn op_get_file_url( op_state: Rc>, - filename: String, + #[string] filename: String, ) -> Result { let state = op_state.borrow(); let content_mapping = state.borrow::(); @@ -49,12 +50,14 @@ fn op_get_file_url( Err(anyhow!("not found")) } -#[op] +#[op2] +#[serde] fn op_get_realm(op_state: &mut OpState) -> DclSceneRealmData { op_state.borrow::().clone() } -#[op] +#[op2] +#[serde] fn op_get_scene_information(op_state: &mut OpState) -> GetSceneInformationResponse { let scene_entity_definition = op_state.borrow::>().clone(); diff --git a/lib/src/dcl/js/testing.rs b/lib/src/dcl/js/testing.rs index 96ed355d3..849dc0de4 100644 --- a/lib/src/dcl/js/testing.rs +++ b/lib/src/dcl/js/testing.rs @@ -1,4 +1,4 @@ -use deno_core::{anyhow::anyhow, error::AnyError, op, Op, OpDecl, OpState}; +use deno_core::{anyhow::anyhow, error::AnyError, op2, OpDecl, OpState}; use godot::builtin::{Vector2, Vector3}; use crate::dcl::{ @@ -14,20 +14,21 @@ use super::SceneEnv; pub fn ops() -> Vec { vec![ - op_take_and_compare_snapshot::DECL, - op_log_test_result::DECL, - op_log_test_plan::DECL, + op_take_and_compare_snapshot(), + op_log_test_result(), + op_log_test_plan(), ] } -#[op] +#[op2] +#[serde] fn op_take_and_compare_snapshot( state: &mut OpState, - src_stored_snapshot: String, - camera_position: [f32; 3], - camera_target: [f32; 3], - screeshot_size: [f32; 2], - method: TestingScreenshotComparisonMethodRequest, + #[string] src_stored_snapshot: String, + #[serde] camera_position: (f32, f32, f32), + #[serde] camera_target: (f32, f32, f32), + #[serde] screeshot_size: (f32, f32), + #[serde] method: TestingScreenshotComparisonMethodRequest, ) -> Result { let scene_env = state.borrow::(); if !scene_env.testing_enable { @@ -44,18 +45,18 @@ fn op_take_and_compare_snapshot( scene_id, src_stored_snapshot, camera_position: Vector3 { - x: camera_position[0], - y: camera_position[1], - z: -camera_position[2], + x: camera_position.0, + y: camera_position.1, + z: -camera_position.2, }, camera_target: Vector3 { - x: camera_target[0], - y: camera_target[1], - z: -camera_target[2], + x: camera_target.0, + y: camera_target.1, + z: -camera_target.2, }, screeshot_size: Vector2 { - x: screeshot_size[0], - y: screeshot_size[1], + x: screeshot_size.0, + y: screeshot_size.1, }, method, response: sx.into(), @@ -90,15 +91,15 @@ fn op_take_and_compare_snapshot( .map_err(|e| anyhow!(e)) } -#[op] -fn op_log_test_result(state: &mut OpState, body: SceneTestResult) { +#[op2] +fn op_log_test_result(state: &mut OpState, #[serde] body: SceneTestResult) { state .borrow_mut::>() .push(RpcCall::SceneTestResult { body }); } -#[op] -fn op_log_test_plan(state: &mut OpState, body: SceneTestPlan) { +#[op2] +fn op_log_test_plan(state: &mut OpState, #[serde] body: SceneTestPlan) { state .borrow_mut::>() .push(RpcCall::SceneTestPlan { body }); diff --git a/lib/src/dcl/js/websocket/mod.rs b/lib/src/dcl/js/websocket/mod.rs index 351c4ce98..8fa0707f6 100644 --- a/lib/src/dcl/js/websocket/mod.rs +++ b/lib/src/dcl/js/websocket/mod.rs @@ -1,18 +1,13 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc}; -use deno_core::{error::AnyError, op, Op, OpDecl, OpState}; +use deno_core::{error::AnyError, op2, OpDecl, OpState}; use futures_util::{SinkExt, StreamExt}; use http::{HeaderName, HeaderValue}; use serde::{Deserialize, Serialize}; use tokio_tungstenite::tungstenite::{client::IntoClientRequest, protocol::CloseFrame}; pub fn ops() -> Vec { - vec![ - op_ws_create::DECL, - op_ws_cleanup::DECL, - op_ws_send::DECL, - op_ws_poll::DECL, - ] + vec![op_ws_create(), op_ws_cleanup(), op_ws_send(), op_ws_poll()] } #[derive(Debug, Deserialize, Serialize)] @@ -196,8 +191,12 @@ async fn ws_poll( Ok(()) } -#[op] -fn op_ws_create(op_state: Rc>, url: String, protocols: Vec) -> u32 { +#[op2] +fn op_ws_create( + op_state: Rc>, + #[string] url: String, + #[serde] protocols: Vec, +) -> u32 { let has_ws_state = op_state.borrow().has::(); if !has_ws_state { op_state.borrow_mut().put::(WsState { @@ -231,7 +230,8 @@ fn op_ws_create(op_state: Rc>, url: String, protocols: Vec>, res_id: u32) -> Result { let mut receiver = { let mut state = op_state.borrow_mut(); @@ -267,11 +267,11 @@ async fn op_ws_poll(op_state: Rc>, res_id: u32) -> Result>, res_id: u32, - event: WsSendData, + #[serde] event: WsSendData, ) -> Result<(), AnyError> { let sender = { let state = op_state.borrow_mut(); @@ -285,7 +285,7 @@ async fn op_ws_send( sender.send(event).await.map_err(anyhow::Error::from) } -#[op] +#[op2(fast)] fn op_ws_cleanup(state: &mut OpState, res_id: u32) -> Result<(), AnyError> { tracing::debug!("cleanup {:?}", res_id); diff --git a/lib/src/godot_classes/dcl_global.rs b/lib/src/godot_classes/dcl_global.rs index 4071d1a49..b855bd6a2 100644 --- a/lib/src/godot_classes/dcl_global.rs +++ b/lib/src/godot_classes/dcl_global.rs @@ -121,9 +121,9 @@ impl INode for DclGlobal { let args = godot::engine::Os::singleton().get_cmdline_args(); - let testing_scene_mode = args.find("--scene-test".into(), None).is_some(); - let preview_mode = args.find("--preview".into(), None).is_some(); - let developer_mode = args.find("--dev".into(), None).is_some(); + let testing_scene_mode = args.find(&"--scene-test".into(), None).is_some(); + let preview_mode = args.find(&"--preview".into(), None).is_some(); + let developer_mode = args.find(&"--dev".into(), None).is_some(); set_scene_log_enabled(preview_mode || testing_scene_mode || developer_mode); diff --git a/lib/src/godot_classes/dcl_gltf_container.rs b/lib/src/godot_classes/dcl_gltf_container.rs index eebe5bf14..78c955789 100644 --- a/lib/src/godot_classes/dcl_gltf_container.rs +++ b/lib/src/godot_classes/dcl_gltf_container.rs @@ -141,14 +141,14 @@ impl DclGltfContainer { } else { let animation_list = animation_player.get_animation_list(); let animation_name = if animation_list.len() > 1 { - let value = animation_list.get(0).to_string(); + let value = animation_list.get(0).as_ref().unwrap().to_string(); if value == DUMMY_ANIMATION_NAME { - animation_list.get(1).to_string() + animation_list.get(1).as_ref().unwrap().to_string() } else { value } } else if !animation_list.is_empty() { - animation_list.get(0).to_string() + animation_list.get(0).as_ref().unwrap().to_string() } else { return; }; diff --git a/lib/src/godot_classes/mod.rs b/lib/src/godot_classes/mod.rs index 06cf32f71..1f78eb833 100644 --- a/lib/src/godot_classes/mod.rs +++ b/lib/src/godot_classes/mod.rs @@ -37,7 +37,7 @@ where { fn to_godot_from_json(&self) -> Result { let json_str = serde_json::to_string(&self).map_err(|e| e.to_string())?; - let mut json_parser = godot::engine::Json::new_gd(); + let mut json_parser = godot::classes::Json::new_gd(); if json_parser.parse(json_str.into()) == godot::engine::global::Error::OK { Ok(json_parser.get_data()) } else { diff --git a/lib/src/http_request/rust_http_queue_requester.rs b/lib/src/http_request/rust_http_queue_requester.rs index 1f3ffc220..c145a10b9 100644 --- a/lib/src/http_request/rust_http_queue_requester.rs +++ b/lib/src/http_request/rust_http_queue_requester.rs @@ -113,7 +113,10 @@ impl RustHttpQueueRequester { let keys = headers.keys_array(); let values = headers.values_array(); for i in 0..headers.len() { - headers_map.insert(keys.get(i).to_string(), values.get(i).to_string()); + headers_map.insert( + keys.get(i).as_ref().unwrap().to_string(), + values.get(i).as_ref().unwrap().to_string(), + ); } Some(headers_map) }; diff --git a/lib/src/scene_runner/components/material.rs b/lib/src/scene_runner/components/material.rs index 924af6bf5..9e101a83c 100644 --- a/lib/src/scene_runner/components/material.rs +++ b/lib/src/scene_runner/components/material.rs @@ -17,9 +17,9 @@ use crate::{ }; use godot::{ engine::{base_material_3d::Transparency, MeshInstance3D, StandardMaterial3D}, + global::weakref, prelude::*, }; -use utilities::weakref; pub fn update_material(scene: &mut Scene, crdt_state: &mut SceneCrdtState) { let godot_dcl_scene = &mut scene.godot_dcl_scene; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index fb0f94604..7ecf910e3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.77.2" \ No newline at end of file +channel = "1.79" \ No newline at end of file