Skip to content

Commit

Permalink
feat(plugins): use protocol buffers for serializing across the wasm b…
Browse files Browse the repository at this point in the history
…oundary (#2686)

* work

* almost done with command protobuffers

* done translating command data structures

* mid transferring of every command to protobuff command

* transferred plugin_command.rs, now moving on to shim.rs

* plugin command working with protobufs

* protobuffers in update

* protobuf event tests

* various TODOs and comments

* fix zellij-tile

* clean up prost deps

* remove version mismatch error

* fix panic

* some cleanups

* clean up event protobuffers

* clean up command protobuffers

* clean up various protobufs

* refactor protobufs

* update comments

* some transformation fixes

* use protobufs for workers

* style(fmt): rustfmt

* style(fmt): rustfmt

* chore(build): add protoc

* chore(build): authenticate protoc
  • Loading branch information
imsnif authored Aug 9, 2023
1 parent c3e140c commit 1bedfc9
Show file tree
Hide file tree
Showing 47 changed files with 6,045 additions and 1,072 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
options: -v ${{ github.workspace }}/target:/usr/src/zellij --name ssh
steps:
- uses: actions/checkout@v3
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Add WASM target
run: rustup target add wasm32-wasi
- name: Install musl-tools
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2
Expand All @@ -40,6 +45,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2
Expand All @@ -63,6 +72,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2
Expand Down
97 changes: 97 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 38 additions & 23 deletions default-plugins/fixture-plugin-for-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ impl<'de> ZellijWorker<'de> for TestWorker {
fn on_message(&mut self, message: String, payload: String) {
if message == "ping" {
self.number_of_messages_received += 1;
post_message_to_plugin(
"pong".into(),
format!(
post_message_to_plugin(PluginMessage {
worker_name: None,
name: "pong".into(),
payload: format!(
"{}, received {} messages",
payload, self.number_of_messages_received
),
);
});
}
}
}
Expand Down Expand Up @@ -143,22 +144,30 @@ impl ZellijPlugin for State {
start_or_reload_plugin(plugin_url)
},
Key::Ctrl('g') => {
open_file(std::path::PathBuf::from("/path/to/my/file.rs").as_path());
open_file(FileToOpen {
path: std::path::PathBuf::from("/path/to/my/file.rs"),
..Default::default()
});
},
Key::Ctrl('h') => {
open_file_floating(std::path::PathBuf::from("/path/to/my/file.rs").as_path());
open_file_floating(FileToOpen {
path: std::path::PathBuf::from("/path/to/my/file.rs"),
..Default::default()
});
},
Key::Ctrl('i') => {
open_file_with_line(
std::path::PathBuf::from("/path/to/my/file.rs").as_path(),
42,
);
open_file(FileToOpen {
path: std::path::PathBuf::from("/path/to/my/file.rs"),
line_number: Some(42),
..Default::default()
});
},
Key::Ctrl('j') => {
open_file_with_line_floating(
std::path::PathBuf::from("/path/to/my/file.rs").as_path(),
42,
);
open_file_floating(FileToOpen {
path: std::path::PathBuf::from("/path/to/my/file.rs"),
line_number: Some(42),
..Default::default()
});
},
Key::Ctrl('k') => {
open_terminal(std::path::PathBuf::from("/path/to/my/file.rs").as_path());
Expand All @@ -169,16 +178,18 @@ impl ZellijPlugin for State {
);
},
Key::Ctrl('m') => {
open_command_pane(
std::path::PathBuf::from("/path/to/my/file.rs").as_path(),
vec!["arg1".to_owned(), "arg2".to_owned()],
);
open_command_pane(CommandToRun {
path: std::path::PathBuf::from("/path/to/my/file.rs"),
args: vec!["arg1".to_owned(), "arg2".to_owned()],
..Default::default()
});
},
Key::Ctrl('n') => {
open_command_pane_floating(
std::path::PathBuf::from("/path/to/my/file.rs").as_path(),
vec!["arg1".to_owned(), "arg2".to_owned()],
);
open_command_pane_floating(CommandToRun {
path: std::path::PathBuf::from("/path/to/my/file.rs"),
args: vec!["arg1".to_owned(), "arg2".to_owned()],
..Default::default()
});
},
Key::Ctrl('o') => {
switch_tab_to(1);
Expand Down Expand Up @@ -225,7 +236,11 @@ impl ZellijPlugin for State {
},
Event::SystemClipboardFailure => {
// this is just to trigger the worker message
post_message_to("test", "ping", "gimme_back_my_payload");
post_message_to(PluginMessage {
worker_name: Some("test".into()),
name: "ping".into(),
payload: "gimme_back_my_payload".into(),
});
},
_ => {},
}
Expand Down
Loading

0 comments on commit 1bedfc9

Please sign in to comment.