Skip to content

Commit 50f6dd8

Browse files
feat: improvements to support hyphens in crate name (#5989)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent 2c4a0bb commit 50f6dd8

File tree

25 files changed

+651
-753
lines changed

25 files changed

+651
-753
lines changed

.changes/mobile-lib-name.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"cli.js": patch
4+
---
5+
6+
Add support to custom and kebab case library names for mobile apps.

core/tauri-macros/src/mobile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn entry_point(_attributes: TokenStream, item: TokenStream) -> TokenStream {
3636
let domain = get_env_var("TAURI_ANDROID_PACKAGE_PREFIX", |r| r, &mut error, &function);
3737
let app_name = get_env_var(
3838
"CARGO_PKG_NAME",
39-
|r| r.replace('_', "_1"),
39+
|r| r.replace('-', "_"),
4040
&mut error,
4141
&function,
4242
);

core/tauri-runtime-wry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ exclude = [ "CHANGELOG.md", "/target" ]
1313
readme = "README.md"
1414

1515
[dependencies]
16-
wry = { version = "0.23.4", default-features = false, features = [ "file-drop", "protocol" ] }
16+
wry = { git = "https://github.com/tauri-apps/wry", branch = "dev", default-features = false, features = [ "file-drop", "protocol" ] }
1717
tauri-runtime = { version = "0.13.0-alpha.0", path = "../tauri-runtime" }
1818
tauri-utils = { version = "2.0.0-alpha.0", path = "../tauri-utils" }
1919
uuid = { version = "1", features = [ "v4" ] }

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub use wry::application::platform::macos::{
7979
};
8080

8181
use std::{
82+
borrow::Cow,
8283
cell::RefCell,
8384
collections::{
8485
hash_map::Entry::{Occupied, Vacant},
@@ -284,7 +285,7 @@ impl From<&WryRequest<Vec<u8>>> for HttpRequestWrapper {
284285
}
285286

286287
// response
287-
struct HttpResponseWrapper(WryResponse<Vec<u8>>);
288+
struct HttpResponseWrapper(WryResponse<Cow<'static, [u8]>>);
288289
impl From<HttpResponse> for HttpResponseWrapper {
289290
fn from(response: HttpResponse) -> Self {
290291
let (parts, body) = response.into_parts();

core/tauri-runtime/src/http/response.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::{
77
status::StatusCode,
88
version::Version,
99
};
10-
use std::fmt;
10+
use std::{borrow::Cow, fmt};
1111

1212
type Result<T> = core::result::Result<T, Box<dyn std::error::Error>>;
1313

@@ -33,7 +33,7 @@ type Result<T> = core::result::Result<T, Box<dyn std::error::Error>>;
3333
///
3434
pub struct Response {
3535
head: ResponseParts,
36-
body: Vec<u8>,
36+
body: Cow<'static, [u8]>,
3737
}
3838

3939
/// Component parts of an HTTP `Response`
@@ -67,7 +67,7 @@ pub struct Builder {
6767
impl Response {
6868
/// Creates a new blank `Response` with the body
6969
#[inline]
70-
pub fn new(body: Vec<u8>) -> Response {
70+
pub fn new(body: Cow<'static, [u8]>) -> Response {
7171
Response {
7272
head: ResponseParts::new(),
7373
body,
@@ -81,7 +81,7 @@ impl Response {
8181
/// This API is used internally. It may have breaking changes in the future.
8282
#[inline]
8383
#[doc(hidden)]
84-
pub fn into_parts(self) -> (ResponseParts, Vec<u8>) {
84+
pub fn into_parts(self) -> (ResponseParts, Cow<'static, [u8]>) {
8585
(self.head, self.body)
8686
}
8787

@@ -129,21 +129,21 @@ impl Response {
129129

130130
/// Returns a mutable reference to the associated HTTP body.
131131
#[inline]
132-
pub fn body_mut(&mut self) -> &mut Vec<u8> {
132+
pub fn body_mut(&mut self) -> &mut Cow<'static, [u8]> {
133133
&mut self.body
134134
}
135135

136136
/// Returns a reference to the associated HTTP body.
137137
#[inline]
138-
pub fn body(&self) -> &Vec<u8> {
138+
pub fn body(&self) -> &Cow<'static, [u8]> {
139139
&self.body
140140
}
141141
}
142142

143143
impl Default for Response {
144144
#[inline]
145145
fn default() -> Response {
146-
Response::new(Vec::new())
146+
Response::new(Default::default())
147147
}
148148
}
149149

@@ -280,8 +280,11 @@ impl Builder {
280280
/// .body(Vec::new())
281281
/// .unwrap();
282282
/// ```
283-
pub fn body(self, body: Vec<u8>) -> Result<Response> {
284-
self.inner.map(move |head| Response { head, body })
283+
pub fn body(self, body: impl Into<Cow<'static, [u8]>>) -> Result<Response> {
284+
self.inner.map(move |head| Response {
285+
head,
286+
body: body.into(),
287+
})
285288
}
286289

287290
// private

core/tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ state = "0.5"
6060
tar = "0.4.38"
6161
tempfile = "3"
6262
zip = { version = "0.6", default-features = false, optional = true }
63-
ignore = "0.4"
63+
ignore = "=0.4.18"
6464
flate2 = "1.0"
6565
http = "0.2"
6666
dirs-next = "2.0"

core/tauri/src/manager.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ impl<R: Runtime> WindowManager<R> {
901901
struct CachedResponse {
902902
status: http::StatusCode,
903903
headers: http::HeaderMap,
904-
body: Vec<u8>,
904+
body: Cow<'static, [u8]>,
905905
}
906906

907907
#[cfg(dev)]
@@ -951,7 +951,7 @@ impl<R: Runtime> WindowManager<R> {
951951
let response = CachedResponse {
952952
status,
953953
headers,
954-
body,
954+
body: body.into(),
955955
};
956956
response_cache_.insert(url.clone(), response);
957957
response_cache_.get(&url).unwrap()
@@ -988,7 +988,7 @@ impl<R: Runtime> WindowManager<R> {
988988
let response_csp = String::from_utf8_lossy(response_csp.as_bytes());
989989
let html = String::from_utf8_lossy(response.body());
990990
let body = html.replacen(tauri_utils::html::CSP_TOKEN, &response_csp, 1);
991-
*response.body_mut() = body.as_bytes().to_vec();
991+
*response.body_mut() = body.as_bytes().to_vec().into();
992992
}
993993
Ok(response)
994994
})

core/tauri/src/updater/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ fn copy_files_and_run<R: Read + Seek>(archive_buffer: R, extract_path: &Path) ->
895895
})?;
896896

897897
let _ = std::process::Command::new("touch")
898-
.arg(&extract_path)
898+
.arg(extract_path)
899899
.status();
900900

901901
Ok(())

core/tests/app-updater/tests/update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn bundle_path(root_dir: &Path, version: &str) -> PathBuf {
9494

9595
#[cfg(target_os = "macos")]
9696
fn bundle_path(root_dir: &Path, _version: &str) -> PathBuf {
97-
root_dir.join(format!("target/debug/bundle/macos/app-updater.app"))
97+
root_dir.join("target/debug/bundle/macos/app-updater.app")
9898
}
9999

100100
#[cfg(target_os = "ios")]

0 commit comments

Comments
 (0)