Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser Runtime Implementation #11

Merged
merged 14 commits into from
Sep 2, 2022
Prev Previous commit
Next Next commit
cargo fmt
jakobhellermann committed Sep 2, 2022
commit d7229bd47554b5e8cd7ec66e003a724ada27eb31
1 change: 1 addition & 0 deletions examples/headless.rs
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ fn main() {
.add_js_system("scripts/headless.ts")
.register_type::<TestComponent>()
.run();
}

#[derive(Component, Reflect)]
struct TestComponent {
6 changes: 2 additions & 4 deletions src/runtime/mod.rs
Original file line number Diff line number Diff line change
@@ -15,12 +15,12 @@ mod native;
pub use native::*;

/// The API implemented by different script runtimes.
///
///
/// Currently we have a native runtime built on [`deno_core`] and a web runtime utilizing
/// [`wasm_bindgen`].
pub trait JsRuntimeApi: FromWorld {
/// Load a script
///
///
/// This will not reload a script that has already been loaded unless `reload` is set to `true`.
fn load_script(&self, handle: &Handle<JsScript>, script: &JsScript, reload: bool);

@@ -30,5 +30,3 @@ pub trait JsRuntimeApi: FromWorld {
/// Run a script
fn run_script(&self, handle: &Handle<JsScript>, stage: &CoreStage, world: &mut World);
}


1 change: 0 additions & 1 deletion src/runtime/wasm/ecs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

mod info;
mod query;
mod resource;
4 changes: 3 additions & 1 deletion src/runtime/wasm/ecs/value.rs
Original file line number Diff line number Diff line change
@@ -263,7 +263,9 @@ impl BevyModJsScripting {
// Otherwise, try get the arg as a value ref
let value_ref = value_refs.get_reflect_value_ref(arg)?;
let value_ref = match pass_mode {
PassMode::Ref => ReflectArgIntermediateValue::Ref(value_ref.get(world).unwrap()),
PassMode::Ref => {
ReflectArgIntermediateValue::Ref(value_ref.get(world).unwrap())
}
PassMode::RefMut => {
unimplemented!("values passed by mutable reference in reflect fn call")
}
2 changes: 1 addition & 1 deletion src/runtime/wasm/mod.rs
Original file line number Diff line number Diff line change
@@ -228,4 +228,4 @@ impl GetReflectValueRef for SlotMap<JsValueRefKey, ReflectValueRef> {

self.get(value_ref.key).ok_or(REF_NOT_EXIST).to_js_error()
}
}
}