RichoDemus / bevy-console

MIT License
285 stars 63 forks source link

WASM support #14

Open youth95 opened 2 years ago

youth95 commented 2 years ago

hi, I want to use the crate in wasm. look like this:

#[wasm_bindgen]
pub fn run() {
    App::new()
        .insert_resource(Msaa { samples: 1 })
        .insert_resource(ClearColor(Color::rgb(0.4, 0.4, 0.4)))
        .add_plugins(DefaultPlugins)
        .add_plugin(GamePlugin)
        .add_plugin(ConsolePlugin)
        .insert_resource(ConsoleConfiguration {
            // override config here
            ..Default::default()
        })
        .add_console_command::<LogCommand, _, _>(log_command)
        .run();
}

but compile failed. can you help me? thank you.

Compiling bevy_console v0.3.0

error: there is no argument named `name`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/commands/help.rs:39:43
   |
39 |                 let mut line = format!("  {name}{}", " ".repeat(longest_command_name - name.len()));
   |                                           ^^^^^^

error: there is no argument named `description`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/commands/help.rs:45:48
   |
45 |                     line.push_str(&format!(" - {description}"));
   |                                                ^^^^^^^^^^^^^

error: there is no argument named `name`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:154:26
    |
154 |             write!(buf, "{name}");
    |                          ^^^^^^

error: there is no argument named `description`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:174:28
    |
174 |             writeln!(buf, "{description}");
    |                            ^^^^^^^^^^^^^

error: there is no argument named `name`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:193:22
    |
193 |                 "    {name} {}",
    |                      ^^^^^^

error: there is no argument named `ty`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:201:26
    |
201 |             write!(buf, "{ty}");
    |                          ^^^^

error: there is no argument named `description`
   --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/console.rs:211:41
    |
211 |                     writeln!(buf, "   - {description}");
    |                                         ^^^^^^^^^^^^^

error: there is no argument named `expected`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/value.rs:64:36
   |
64 |                 "[error] expected '{expected}' but got '{received}' for arg #{}",
   |                                    ^^^^^^^^^^

error: there is no argument named `received`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/value.rs:64:57
   |
64 |                 "[error] expected '{expected}' but got '{received}' for arg #{}",
   |                                                         ^^^^^^^^^^

error: there is no argument named `msg`
  --> /Users/admin/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_console-0.3.0/src/value.rs:75:63
   |
75 |             FromValueError::Custom(msg) => write!(f, "[error] {msg}"),
   |                                                               ^^^^^

error: could not compile `bevy_console` due to 10 previous errors
makspll commented 2 months ago

The crate doesn't have official support for WASM yet which would be why this happens