Bläddra i källkod

refactor: rename `tauri::dev` to `is_dev` and mark as constant fn (#9890)

* refactor: made `tauri::dev` as constant function

this enables the `tauri::dev()` can be used as const or static

* is_dev && change files

---------

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Rajaniraiyn R 1 år sedan
förälder
incheckning
aaecb6a72e

+ 5 - 0
.changes/tauri-build-dev-fn.md

@@ -0,0 +1,5 @@
+---
+"tauri-build": "patch:breaking"
+---
+
+Renamed `dev` function to `is_dev`

+ 5 - 0
.changes/tauri-dev-fn-const.md

@@ -0,0 +1,5 @@
+---
+"tauri": "patch:breaking"
+---
+
+Renamed `dev` function to `is_dev` and marked it as `const fn`

+ 1 - 1
core/tauri-build/src/codegen/context.rs

@@ -121,7 +121,7 @@ impl CodegenContext {
     );
 
     let code = context_codegen(ContextData {
-      dev: crate::dev(),
+      dev: crate::is_dev(),
       config,
       config_parent,
       // it's very hard to have a build script for unit tests, so assume this is always called from

+ 2 - 2
core/tauri-build/src/lib.rs

@@ -386,7 +386,7 @@ impl Attributes {
   }
 }
 
-pub fn dev() -> bool {
+pub fn is_dev() -> bool {
   std::env::var("DEP_TAURI_DEV")
     .expect("missing `cargo:dev` instruction, please update tauri to latest")
     == "true"
@@ -474,7 +474,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
     mobile::generate_gradle_files(project_dir, &config)?;
   }
 
-  cfg_alias("dev", dev());
+  cfg_alias("dev", is_dev());
 
   let ws_path = get_workspace_dir()?;
   let mut manifest =

+ 1 - 1
core/tauri/src/lib.rs

@@ -335,7 +335,7 @@ macro_rules! tauri_build_context {
 pub use pattern::Pattern;
 
 /// Whether we are running in development mode or not.
-pub fn dev() -> bool {
+pub const fn is_dev() -> bool {
   !cfg!(feature = "custom-protocol")
 }
 

+ 1 - 1
core/tauri/src/manager/mod.rs

@@ -330,7 +330,7 @@ impl<R: Runtime> AppManager<R> {
   }
 
   fn csp(&self) -> Option<Csp> {
-    if !crate::dev() {
+    if !crate::is_dev() {
       self.config.app.security.csp.clone()
     } else {
       self