mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-08-17 03:40:23 +03:00
* fix(android): escape kotlin only keyword in template * fix: escape keywords in wry templates aswell * chore: add changelog * chore: remove unused code * fix(android): wry template, package name should reverse * update cargo-mobile2 --------- Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
parent
4754786aa2
commit
71a5e2ba24
5
.changes/cli-allow-kotlin-keyword-as-ident.md
Normal file
5
.changes/cli-allow-kotlin-keyword-as-ident.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"tauri-cli": "patch:enhance"
|
||||||
|
---
|
||||||
|
|
||||||
|
On Android, allow using Kotlin keywords as identifiers and escape them in templates.
|
4
tooling/cli/Cargo.lock
generated
4
tooling/cli/Cargo.lock
generated
@ -483,9 +483,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo-mobile2"
|
name = "cargo-mobile2"
|
||||||
version = "0.12.0"
|
version = "0.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "79fadc84c218c513afcace5b0115bf615fb1c64dac782c1978f1620491339d7d"
|
checksum = "c7ac384d832f346303c9f80328bb11e04000b66743b543578ed8926a6fbc264f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"colored",
|
"colored",
|
||||||
"core-foundation",
|
"core-foundation",
|
||||||
|
@ -39,7 +39,7 @@ name = "cargo-tauri"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cargo-mobile2 = { version = "0.12", default-features = false }
|
cargo-mobile2 = { version = "0.12.1", default-features = false }
|
||||||
jsonrpsee = { version = "0.22", features = [ "server" ] }
|
jsonrpsee = { version = "0.22", features = [ "server" ] }
|
||||||
jsonrpsee-core = "0.22"
|
jsonrpsee-core = "0.22"
|
||||||
jsonrpsee-client-transport = { version = "0.22", features = [ "ws" ] }
|
jsonrpsee-client-transport = { version = "0.22", features = [ "ws" ] }
|
||||||
|
@ -133,7 +133,10 @@ pub fn get_config(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
set_var("WRY_ANDROID_PACKAGE", app.reverse_identifier());
|
set_var(
|
||||||
|
"WRY_ANDROID_PACKAGE",
|
||||||
|
app.android_identifier_escape_kotlin_keyword(),
|
||||||
|
);
|
||||||
set_var("WRY_ANDROID_LIBRARY", app.lib_name());
|
set_var("WRY_ANDROID_LIBRARY", app.lib_name());
|
||||||
set_var("TAURI_ANDROID_PROJECT_PATH", config.project_dir());
|
set_var("TAURI_ANDROID_PROJECT_PATH", config.project_dir());
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ use cargo_mobile2::{
|
|||||||
},
|
},
|
||||||
config::app::App,
|
config::app::App,
|
||||||
dot_cargo,
|
dot_cargo,
|
||||||
|
reserved_names::KOTLIN_ONLY_KEYWORDS,
|
||||||
target::TargetTrait as _,
|
target::TargetTrait as _,
|
||||||
util::{
|
util::{
|
||||||
self,
|
self,
|
||||||
@ -215,6 +216,7 @@ fn handlebars(app: &App) -> (Handlebars<'static>, JsonMap) {
|
|||||||
"reverse-domain-snake-case",
|
"reverse-domain-snake-case",
|
||||||
Box::new(reverse_domain_snake_case),
|
Box::new(reverse_domain_snake_case),
|
||||||
);
|
);
|
||||||
|
h.register_helper("escape-kotlin-keyword", Box::new(escape_kotlin_keyword));
|
||||||
// don't mix these up or very bad things will happen to all of us
|
// don't mix these up or very bad things will happen to all of us
|
||||||
h.register_helper("prefix-path", Box::new(prefix_path));
|
h.register_helper("prefix-path", Box::new(prefix_path));
|
||||||
h.register_helper("unprefix-path", Box::new(unprefix_path));
|
h.register_helper("unprefix-path", Box::new(unprefix_path));
|
||||||
@ -360,6 +362,28 @@ fn reverse_domain_snake_case(
|
|||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn escape_kotlin_keyword(
|
||||||
|
helper: &Helper,
|
||||||
|
_: &Handlebars,
|
||||||
|
_: &Context,
|
||||||
|
_: &mut RenderContext,
|
||||||
|
out: &mut dyn Output,
|
||||||
|
) -> HelperResult {
|
||||||
|
let escaped_result = get_str(helper)
|
||||||
|
.split('.')
|
||||||
|
.map(|s| {
|
||||||
|
if KOTLIN_ONLY_KEYWORDS.contains(&s) {
|
||||||
|
format!("`{}`", s)
|
||||||
|
} else {
|
||||||
|
s.to_string()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(".");
|
||||||
|
|
||||||
|
out.write(&escaped_result).map_err(Into::into)
|
||||||
|
}
|
||||||
|
|
||||||
fn app_root(ctx: &Context) -> Result<&str, RenderError> {
|
fn app_root(ctx: &Context) -> Result<&str, RenderError> {
|
||||||
let app_root = ctx
|
let app_root = ctx
|
||||||
.data()
|
.data()
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
package {{reverse-domain app.identifier}}
|
package {{escape-kotlin-keyword (reverse-domain app.identifier)}}
|
||||||
|
|
||||||
class MainActivity : TauriActivity()
|
class MainActivity : TauriActivity()
|
Loading…
Reference in New Issue
Block a user