-
Notifications
You must be signed in to change notification settings - Fork 569
Wasm support #759
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
Merged
Merged
Wasm support #759
Changes from 37 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
19c186f
Add wasm backend + fix std::time dep
elrnv 30d66ba
Disable simple logger on wasm
elrnv cfb3627
Fix resizing in wasm backends
elrnv fbce712
Added scrolling support + fixed hidpi handling
elrnv 999ef45
Use explicit lifetime in StrOrChar
elrnv 8ee237f
Added keyboard support on wasm
elrnv 659e136
Fix browser zooming issue for web backend
elrnv 4658a17
Fix a typo causing the web build to break
elrnv 439b319
Format with cargo fmt
elrnv 85f400b
Prevent the browser from going back on backspace
elrnv 3316120
Fix key text + require console_log + adjust style
elrnv e2d8e00
Run rustfmt on stepper.rs
elrnv 204230c
Fix up console_log dependency
elrnv c191012
Add wasm build to ci
elrnv 844cbc2
Update ci by running wasm-pack explicitly
elrnv a37c3b4
Add druid/examples/wasm to workspace toml
elrnv 2d67cd7
Address format and clippy warnings
elrnv 481b796
Add wasm32 tests for druid & druid-shell in ci.yml
elrnv 9b2a3d8
Fix build.rs in druid-wasm-examples
elrnv fbd6073
Fix windows build for druid-wasm-examples
elrnv 23424af
Added simple_logger dep for wasm
elrnv 510a60a
Remove invald cfg feature guard
elrnv e7e257c
Unwrap from examples that return result
elrnv cfe5153
Run rustfmt on build.rs for druid-wasm-examples
elrnv 4b6150d
Address clippy concerns in druid examples
elrnv 5609e38
Fix the build script for wasm examples
elrnv 5ed32cb
Add .gitignore to wasm examples + fix clippy bugs
elrnv ad3c7e8
Update README.md formatting in druid wasm examples
elrnv d101869
Revert accidental change to build.rs
elrnv 8d05b09
Fix examples for wasm
elrnv ea81ffe
Fix x11 keycodes StrOrChar conversion
elrnv 78b4631
Rustfmt on recent changes to examples
elrnv 3cd4144
Fix clippy warnings -- small structs passed by ref
elrnv 1dbb4e9
Fix wasm build for multiwin example
elrnv 2102f82
Add --no-run to `cargo test` for wasm targets
elrnv 5021017
Do not build the unit test module for wasm32
elrnv a143692
Install necessary deps in wasm CI for macos/ubuntu
elrnv e0949ff
Add warnings for unimplemented file ops in web backend
elrnv 0df38af
Remove windows specific comment from web/window.rs
elrnv 5f64d4b
Ignore automatically generated html files in wasm example
elrnv ee88c7f
Remove unused dialog module from web backend
elrnv ea79c84
Remove TODO for adding to app state in web backend
elrnv e072555
Rework the generated examples in the wasm example
elrnv d0bc9df
Update Cargo.lock
elrnv 3a528fa
Rename switch example js entry point for wasm build
elrnv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,5 @@ members = [ | |
| "druid-shell", | ||
| "druid-derive", | ||
| "docs/book_examples", | ||
| "druid/examples/wasm", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright 2020 The xi-editor Authors. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Web implementation of features at the application scope. | ||
|
|
||
| use super::clipboard::Clipboard; | ||
| use crate::application::AppHandler; | ||
|
|
||
| pub struct Application; | ||
|
|
||
| impl Application { | ||
| pub fn new(_handler: Option<Box<dyn AppHandler>>) -> Application { | ||
| // TODO: Implement this | ||
| Application | ||
| } | ||
|
|
||
| pub fn run(&mut self) {} | ||
|
|
||
| pub fn quit() {} | ||
|
|
||
| pub fn clipboard() -> Clipboard { | ||
| Clipboard | ||
| } | ||
|
|
||
| pub fn get_locale() -> String { | ||
| //TODO ahem | ||
| "en-US".into() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // Copyright 2020 The xi-editor Authors. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Interactions with the browser pasteboard. | ||
|
|
||
| use crate::clipboard::{ClipboardFormat, FormatId}; | ||
|
|
||
| /// The browser clipboard. | ||
| #[derive(Debug, Clone, Default)] | ||
| pub struct Clipboard; | ||
|
|
||
| impl Clipboard { | ||
| /// Put a string onto the system clipboard. | ||
| pub fn put_string(&mut self, _s: impl AsRef<str>) { | ||
| log::warn!("unimplemented"); | ||
| } | ||
|
|
||
| /// Put multi-format data on the system clipboard. | ||
| pub fn put_formats(&mut self, _formats: &[ClipboardFormat]) { | ||
| log::warn!("unimplemented"); | ||
| } | ||
|
|
||
| /// Get a string from the system clipboard, if one is available. | ||
| pub fn get_string(&self) -> Option<String> { | ||
| log::warn!("unimplemented"); | ||
| None | ||
| } | ||
|
|
||
| /// Given a list of supported clipboard types, returns the supported type which has | ||
| /// highest priority on the system clipboard, or `None` if no types are supported. | ||
| pub fn preferred_format(&self, _formats: &[FormatId]) -> Option<FormatId> { | ||
| log::warn!("unimplemented"); | ||
| None | ||
| } | ||
|
|
||
| /// Return data in a given format, if available. | ||
| /// | ||
| /// It is recommended that the `fmt` argument be a format returned by | ||
| /// [`Clipboard::preferred_format`] | ||
| pub fn get_format(&self, _format: FormatId) -> Option<Vec<u8>> { | ||
| log::warn!("unimplemented"); | ||
| None | ||
| } | ||
|
|
||
| pub fn available_type_names(&self) -> Vec<String> { | ||
| log::warn!("unimplemented"); | ||
| Vec::new() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright 2020 The xi-editor Authors. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #![allow(dead_code)] | ||
| //! File open/save dialogs, Web implementation. | ||
elrnv marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// Type of file dialog. | ||
| pub enum FileDialogType { | ||
| /// File open dialog. | ||
| Open, | ||
| /// File save dialog. | ||
| Save, | ||
| } | ||
|
|
||
| #[derive(Default)] | ||
| pub struct FileDialogOptions; | ||
|
|
||
| impl FileDialogOptions { | ||
| /// Include system and hidden items. | ||
| pub fn set_show_hidden(&mut self) { | ||
| // TODO | ||
| } | ||
|
|
||
| // TODO: more options as needed | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.