Skip to content

Commit 1f98853

Browse files
renovate[bot]lucasfernogNgo Iok Ui (Wu Yu Wei)renovate-botlemarier
authored
chore(deps) Update Tauri Core (#2480)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio> Co-authored-by: lucasfernog <lucasfernog@users.noreply.github.com> Co-authored-by: Ngo Iok Ui (Wu Yu Wei) <wusyong9104@gmail.com> Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: david <david@lemarier.ca> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: chip <chip@chip.sh>
1 parent 5ca831e commit 1f98853

59 files changed

Lines changed: 5270 additions & 215 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changes/clap-beta.4-core.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Change `Error::ParseCliArguments(clap::Error)` to `Error::ParseCliArguments(String)` because `clap::Error` is not `Send`.

.changes/clap-beta.4.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": patch
3+
---
4+
5+
Change `CliArg` numeric types from `u64` to `usize`.

.changes/pre.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
".changes/app-set-activation-policy.md",
3636
".changes/app-state.md",
3737
".changes/appwindow-events.md",
38+
".changes/asset-path.md",
3839
".changes/asset-protocol.md",
3940
".changes/assets-refactor.md",
4041
".changes/async-commands.md",
@@ -75,6 +76,7 @@
7576
".changes/cli.js-rustup.md",
7677
".changes/cli.rs-dev-workspaces.md",
7778
".changes/cli.rs-features-arg.md",
79+
".changes/cli.rs-fix-cli.yml-assertion.md",
7880
".changes/cli.rs-libwebkit2gtk-4.0-37.md",
7981
".changes/cli.rs-release-arg.md",
8082
".changes/cli.rs-wix-banner-icon.md",
@@ -221,6 +223,7 @@
221223
".changes/product-name-original.md",
222224
".changes/raw-window-handle-dependency.md",
223225
".changes/readd-esm-cli.js.md",
226+
".changes/refactor-register-uri-scheme-protocol.md",
224227
".changes/refactor-settings.md",
225228
".changes/refactor-window-management.md",
226229
".changes/regular-script-invoke-key-injection.md",
@@ -233,6 +236,7 @@
233236
".changes/resources-dir-refactor.md",
234237
".changes/restart-application.md",
235238
".changes/revert-cli.js-es-module.md",
239+
".changes/revert-es2021.md",
236240
".changes/rpc-security.md",
237241
".changes/run-iteration.md",
238242
".changes/run-on-main-thread-refactor.md",
@@ -263,6 +267,7 @@
263267
".changes/tauri-icon-fix.md",
264268
".changes/tauri-info-framework-bundler.md",
265269
".changes/tauri-macos-tray-icon-template.md",
270+
".changes/tauri-protocol.md",
266271
".changes/tauri-ready-event.md",
267272
".changes/tauri-updater-linux.md",
268273
".changes/tauri-updater-windows.md",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri": patch
3+
"tauri-runtime": patch
4+
---
5+
6+
**Breaking change:** Removed `register_uri_scheme_protocol` from the `WebviewAttibutes` struct and renamed `register_global_uri_scheme_protocol` to `register_uri_scheme_protocol` on the `Builder` struct, which now takes a `Fn(&AppHandle, &http::Request) -> http::Response` closure.

.changes/revert-es2021.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"api": patch
3+
---
4+
5+
Revert target back to ES5.

.changes/tauri-protocol.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri": minor
3+
"tauri-runtime": minor
4+
"tauri-runtime-wry": minor
5+
---
6+
7+
Migrate to latest custom protocol allowing `Partial content` streaming and Header parsing.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ __handlers__/
9393

9494
# benches
9595
gh-pages
96+
test_video.mp4

core/tauri-runtime-wry/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## \[0.2.1]
4+
5+
- Migrate to latest custom protocol allowing `Partial content` streaming and Header parsing.
6+
- [539e4489](https://www.github.com/tauri-apps/tauri/commit/539e4489e0bac7029d86917e9982ea49e02fe489) refactor: custom protocol ([#2503](https://www.github.com/tauri-apps/tauri/pull/2503)) on 2021-08-23
7+
38
## \[0.2.0]
49

510
- Fix blur/focus events being incorrect on Windows.

core/tauri-runtime-wry/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tauri-runtime-wry"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
authors = [ "Tauri Programme within The Commons Conservancy" ]
55
categories = [ "gui", "web-programming" ]
66
license = "Apache-2.0 OR MIT"
@@ -13,7 +13,7 @@ readme = "README.md"
1313

1414
[dependencies]
1515
wry = { version = "0.12", default-features = false, features = [ "file-drop", "protocol" ] }
16-
tauri-runtime = { version = "0.2.0", path = "../tauri-runtime" }
16+
tauri-runtime = { version = "0.2.1", path = "../tauri-runtime" }
1717
tauri-utils = { version = "1.0.0-beta.3", path = "../tauri-utils" }
1818
uuid = { version = "0.8.2", features = [ "v4" ] }
1919
infer = "0.4"

core/tauri-runtime-wry/src/lib.rs

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
//! The [`wry`] Tauri [`Runtime`].
66
77
use tauri_runtime::{
8+
http::{
9+
Request as HttpRequest, RequestParts as HttpRequestParts, Response as HttpResponse,
10+
ResponseParts as HttpResponseParts,
11+
},
812
menu::{CustomMenuItem, Menu, MenuEntry, MenuHash, MenuItem, MenuUpdate, Submenu},
913
monitor::Monitor,
1014
webview::{
@@ -54,6 +58,10 @@ use wry::{
5458
monitor::MonitorHandle,
5559
window::{Fullscreen, Icon as WindowIcon, UserAttentionType as WryUserAttentionType},
5660
},
61+
http::{
62+
Request as WryHttpRequest, RequestParts as WryRequestParts, Response as WryHttpResponse,
63+
ResponseParts as WryResponseParts,
64+
},
5765
webview::{
5866
FileDropEvent as WryFileDropEvent, RpcRequest as WryRpcRequest, RpcResponse, WebContext,
5967
WebView, WebViewBuilder,
@@ -95,9 +103,6 @@ mod system_tray;
95103
#[cfg(feature = "system-tray")]
96104
use system_tray::*;
97105

98-
mod mime_type;
99-
use mime_type::MimeType;
100-
101106
type WebContextStore = Mutex<HashMap<Option<PathBuf>, WebContext>>;
102107
// window
103108
type WindowEventHandler = Box<dyn Fn(&WindowEvent) + Send>;
@@ -152,6 +157,72 @@ struct EventLoopContext {
152157
proxy: EventLoopProxy<Message>,
153158
}
154159

160+
struct HttpRequestPartsWrapper(HttpRequestParts);
161+
162+
impl From<HttpRequestPartsWrapper> for HttpRequestParts {
163+
fn from(parts: HttpRequestPartsWrapper) -> Self {
164+
Self {
165+
method: parts.0.method,
166+
uri: parts.0.uri,
167+
headers: parts.0.headers,
168+
}
169+
}
170+
}
171+
172+
impl From<HttpRequestParts> for HttpRequestPartsWrapper {
173+
fn from(request: HttpRequestParts) -> Self {
174+
Self(HttpRequestParts {
175+
method: request.method,
176+
uri: request.uri,
177+
headers: request.headers,
178+
})
179+
}
180+
}
181+
182+
impl From<WryRequestParts> for HttpRequestPartsWrapper {
183+
fn from(request: WryRequestParts) -> Self {
184+
Self(HttpRequestParts {
185+
method: request.method,
186+
uri: request.uri,
187+
headers: request.headers,
188+
})
189+
}
190+
}
191+
192+
struct HttpRequestWrapper(HttpRequest);
193+
194+
impl From<&WryHttpRequest> for HttpRequestWrapper {
195+
fn from(req: &WryHttpRequest) -> Self {
196+
Self(HttpRequest {
197+
body: req.body.clone(),
198+
head: HttpRequestPartsWrapper::from(req.head.clone()).0,
199+
})
200+
}
201+
}
202+
203+
// response
204+
struct HttpResponsePartsWrapper(WryResponseParts);
205+
impl From<HttpResponseParts> for HttpResponsePartsWrapper {
206+
fn from(response: HttpResponseParts) -> Self {
207+
Self(WryResponseParts {
208+
mimetype: response.mimetype,
209+
status: response.status,
210+
version: response.version,
211+
headers: response.headers,
212+
})
213+
}
214+
}
215+
216+
struct HttpResponseWrapper(WryHttpResponse);
217+
impl From<HttpResponse> for HttpResponseWrapper {
218+
fn from(response: HttpResponse) -> Self {
219+
Self(WryHttpResponse {
220+
body: response.body,
221+
head: HttpResponsePartsWrapper::from(response.head).0,
222+
})
223+
}
224+
}
225+
155226
pub struct MenuItemAttributesWrapper<'a>(pub WryMenuItemAttributes<'a>);
156227

157228
impl<'a> From<&'a CustomMenuItem> for MenuItemAttributesWrapper<'a> {
@@ -2327,6 +2398,7 @@ fn create_webview(
23272398
#[allow(unused_mut)]
23282399
let PendingWindow {
23292400
webview_attributes,
2401+
uri_scheme_protocols,
23302402
mut window_builder,
23312403
rpc_handler,
23322404
file_drop_handler,
@@ -2375,13 +2447,10 @@ fn create_webview(
23752447
handler,
23762448
));
23772449
}
2378-
for (scheme, protocol) in webview_attributes.uri_scheme_protocols {
2379-
webview_builder = webview_builder.with_custom_protocol(scheme, move |url| {
2380-
protocol(url)
2381-
.map(|data| {
2382-
let mime_type = MimeType::parse(&data, url);
2383-
(data, mime_type)
2384-
})
2450+
for (scheme, protocol) in uri_scheme_protocols {
2451+
webview_builder = webview_builder.with_custom_protocol(scheme, move |wry_request| {
2452+
protocol(&HttpRequestWrapper::from(wry_request).0)
2453+
.map(|tauri_response| HttpResponseWrapper::from(tauri_response).0)
23852454
.map_err(|_| wry::Error::InitScriptError)
23862455
});
23872456
}
@@ -2409,7 +2478,7 @@ fn create_webview(
24092478
.build()
24102479
.map_err(|e| Error::CreateWebview(Box::new(e)))?
24112480
} else {
2412-
let mut context = WebContext::new(webview_attributes.data_directory.clone());
2481+
let mut context = WebContext::new(webview_attributes.data_directory);
24132482
webview_builder
24142483
.with_web_context(&mut context)
24152484
.build()

0 commit comments

Comments
 (0)