-
Notifications
You must be signed in to change notification settings - Fork 14
feat: create vendored flag to embed verso into tauri app #21
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
Open
Ludea
wants to merge
13
commits into
versotile-org:main
Choose a base branch
from
Ludea:vendored
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f3b6069
feat: embed verso webview directly into app
Ludea 9e1a24c
Re enable examples
Ludea 221033b
typo
4d0827a
fmt
9cfbab6
apply patch
4d072d7
move versoview dependency into workspace group
ad90b7e
create file for App struct
d4d39f6
move all vendored stuff to its own module
7b8716c
vendored example
3383aff
use right example to embed verso
bbc2f1e
some docs
ba6c69d
no need to download verso bin
fc8d88a
dd vendored example to workspace
Ludea 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,2 @@ | ||
| gen | ||
| versoview/ |
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,22 @@ | ||
| [package] | ||
| name = "vendored" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [build-dependencies] | ||
| tauri-runtime-verso-build = { path = "../../tauri-runtime-verso-build" } | ||
| tauri-build = { version = "2", features = [] } | ||
|
|
||
| [dependencies] | ||
| tauri = { version = "2", default-features = false, features = [ | ||
| # Default features | ||
| # "wry", | ||
| # "compression", | ||
| "common-controls-v6", | ||
| # "x11", | ||
| # "dynamic-acl", | ||
| # Additional features | ||
| # "tray-icon", | ||
| ] } | ||
| tauri-runtime-verso = { path = "../../", features = ["vendored"] } | ||
| # serde = "1" |
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 @@ | ||
| To get started with this example, run `cargo run --package helloworld` (You'll need the [prerequisites](https://tauri.app/start/prerequisites/) of Tauri) |
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,3 @@ | ||
| fn main() { | ||
| tauri_build::build(); | ||
| } |
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,10 @@ | ||
| { | ||
| "$schema": "../gen/schemas/desktop-schema.json", | ||
| "identifier": "main", | ||
| "windows": [ | ||
| "main" | ||
| ], | ||
| "permissions": [ | ||
| "core:default" | ||
| ] | ||
| } |
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,111 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Welcome to Tauri!</title> | ||
| <style> | ||
| :root { | ||
| background-color: #f0f0f2; | ||
| font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, | ||
| Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | ||
|
|
||
| --color-on-primary: white; | ||
| --color-primary: hsl(205, 85%, 40%); | ||
| --color-primary-hightlight: hsl(205, 85%, 35%); | ||
| } | ||
|
|
||
| button, | ||
| input, | ||
| textarea, | ||
| select { | ||
| font: inherit; | ||
| } | ||
|
|
||
| body { | ||
| display: flex; | ||
| flex-direction: column; | ||
| margin: 0; | ||
| height: 100vh; | ||
| } | ||
|
|
||
| .title { | ||
| margin-top: 3em; | ||
| margin-bottom: 2em; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .form-and-message { | ||
| background-color: aliceblue; | ||
| padding: 1em; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| gap: 1em; | ||
| } | ||
|
|
||
| .form-and-message > #form { | ||
| display: flex; | ||
| justify-content: center; | ||
| gap: 1em; | ||
| } | ||
|
|
||
| .form-and-message > #message { | ||
| display: flex; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .form-and-message > #form input { | ||
| padding: 0.5em 0.8em; | ||
| border: 1px solid hsl(0, 0%, 60%); | ||
| outline: none; | ||
| min-width: 0; | ||
| } | ||
| .form-and-message > #form input:focus { | ||
| border-color: var(--color-primary); | ||
| } | ||
|
|
||
| .form-and-message > #form button { | ||
| appearance: none; | ||
| border: none; | ||
| cursor: pointer; | ||
| outline: none; | ||
| padding: 0.4em 1em; | ||
| color: var(--color-on-primary); | ||
| background-color: var(--color-primary); | ||
| display: inline-flex; | ||
| align-items: center; | ||
| } | ||
| .form-and-message > #form button:hover, | ||
| .form-and-message > #form button:focus { | ||
| background-color: var(--color-primary-hightlight); | ||
| } | ||
| </style> | ||
| <script type="module"> | ||
| const { invoke } = window.__TAURI__.core | ||
|
|
||
| const form = document.querySelector('#form') | ||
| const nameEl = document.querySelector('#name') | ||
| const messageEl = document.querySelector('#message') | ||
|
|
||
| form.addEventListener('submit', async (e) => { | ||
| e.preventDefault() | ||
|
|
||
| const name = nameEl.value | ||
| const newMessage = await invoke('greet', { name }) | ||
| messageEl.textContent = newMessage | ||
| }) | ||
| </script> | ||
| </head> | ||
| <body> | ||
| <h1 class="title">Welcome to Tauri!</h1> | ||
|
|
||
| <div class="form-and-message"> | ||
| <form id="form"> | ||
| <input id="name" placeholder="Enter a name..." /> | ||
| <button>Greet</button> | ||
| </form> | ||
| <div id="message"></div> | ||
| </div> | ||
| </body> | ||
| </html> |
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,29 @@ | ||
| #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] | ||
|
|
||
| use tauri::Manager; | ||
|
|
||
| #[tauri::command] | ||
| fn greet(name: &str) -> String { | ||
| format!("Hello {name}, You have been greeted from Rust!") | ||
| } | ||
|
|
||
| fn main() { | ||
| // You can also set the `versoview` executable path yourself | ||
| // tauri_runtime_verso::set_verso_path("../verso/target/debug/versoview"); | ||
|
|
||
| // To use the devtools, set it like to let verso open a devtools server, | ||
| // and you can connect to it through Firefox's devtools in the `about:debugging` page | ||
| tauri_runtime_verso::set_verso_devtools_port(1234); | ||
|
|
||
| tauri_runtime_verso::builder() | ||
| .invoke_handler(tauri::generate_handler![greet]) | ||
| .setup(|app| { | ||
| dbg!(app.get_webview_window("main").unwrap().inner_size()).unwrap(); | ||
| // embed verso webview into app | ||
| tauri_runtime_verso::vendored::create_embedded_versoview().unwrap(); | ||
|
|
||
| Ok(()) | ||
| }) | ||
| .run(tauri::generate_context!()) | ||
| .expect("error while running tauri application") | ||
| } | ||
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,28 @@ | ||
| { | ||
| "$schema": "https://schema.tauri.app/config/2", | ||
| "productName": "Hello World", | ||
| "version": "0.1.0", | ||
| "identifier": "com.tauri.dev", | ||
| "build": { | ||
| "frontendDist": ["index.html"] | ||
| }, | ||
| "app": { | ||
| "withGlobalTauri": true, | ||
| "windows": [ | ||
| { | ||
| "title": "Welcome to Tauri!", | ||
| "width": 700, | ||
| "height": 500 | ||
| } | ||
| ] | ||
| }, | ||
| "bundle": { | ||
| "icon": [ | ||
| "../.icons/icon.ico", | ||
| "../.icons/icon.png" | ||
| ], | ||
| "externalBin": [ | ||
| "versoview/versoview" | ||
| ] | ||
| } | ||
| } |
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,62 @@ | ||
| use versoview::{Result, Verso, verso::EventLoopProxyMessage}; | ||
| use winit::{ | ||
| application::ApplicationHandler, | ||
| event_loop::{self, DeviceEvents, EventLoop, EventLoopProxy}, | ||
| }; | ||
|
|
||
| struct App { | ||
| verso: Option<Verso>, | ||
| proxy: EventLoopProxy<EventLoopProxyMessage>, | ||
| } | ||
|
|
||
| impl ApplicationHandler<EventLoopProxyMessage> for App { | ||
| fn resumed(&mut self, event_loop: &winit::event_loop::ActiveEventLoop) { | ||
| self.verso = Some(Verso::new(event_loop, self.proxy.clone())); | ||
| } | ||
|
|
||
| fn window_event( | ||
| &mut self, | ||
| event_loop: &winit::event_loop::ActiveEventLoop, | ||
| window_id: winit::window::WindowId, | ||
| event: winit::event::WindowEvent, | ||
| ) { | ||
| if let Some(v) = self.verso.as_mut() { | ||
| v.handle_window_event(event_loop, window_id, event); | ||
| } | ||
| } | ||
|
|
||
| fn user_event( | ||
| &mut self, | ||
| event_loop: &event_loop::ActiveEventLoop, | ||
| event: EventLoopProxyMessage, | ||
| ) { | ||
| if let Some(v) = self.verso.as_mut() { | ||
| match event { | ||
| EventLoopProxyMessage::Wake => { | ||
| v.request_redraw(event_loop); | ||
| } | ||
| EventLoopProxyMessage::IpcMessage(message) => { | ||
| v.handle_incoming_webview_message(event_loop, *message); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub fn create_embedded_versoview() -> Result<()> { | ||
| init_crypto(); | ||
|
|
||
| let event_loop = EventLoop::<EventLoopProxyMessage>::with_user_event().build()?; | ||
| event_loop.listen_device_events(DeviceEvents::Never); | ||
| let proxy = event_loop.create_proxy(); | ||
| let mut app = App { verso: None, proxy }; | ||
| event_loop.run_app(&mut app)?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| fn init_crypto() { | ||
| rustls::crypto::aws_lc_rs::default_provider() | ||
| .install_default() | ||
| .expect("Error initializing crypto provider"); | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I get this, isn't this just running the versoview? Don't we need to connect our app with it? And 2 different event loops can't work together, versoview will still need to be on another process for now