Skip to content
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

refactor(core): remove deprecated webview_fixed_runtime_path option #10772

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/remove-webview_fixed_runtime_path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"tauri-utils": patch:breaking
"@tauri-apps/cli": patch:breaking
"tauri-cli": patch:breaking
"tauri-bundler": patch:breaking
---

Removed the deprecated `webview_fixed_runtime_path` config option, use the `webview_install_mode` instead.
13 changes: 4 additions & 9 deletions core/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,10 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
.clone()
.unwrap_or_else(|| BundleResources::List(Vec::new()));
if target_triple.contains("windows") {
if let Some(fixed_webview2_runtime_path) =
match &config.bundle.windows.webview_fixed_runtime_path {
Some(path) => Some(path),
None => match &config.bundle.windows.webview_install_mode {
WebviewInstallMode::FixedRuntime { path } => Some(path),
_ => None,
},
}
{
if let Some(fixed_webview2_runtime_path) = match &config.bundle.windows.webview_install_mode {
WebviewInstallMode::FixedRuntime { path } => Some(path),
_ => None,
} {
resources.push(fixed_webview2_runtime_path.display().to_string());
}
}
Expand Down
9 changes: 0 additions & 9 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"signCommand": null,
"timestampUrl": null,
"tsp": false,
"webviewFixedRuntimePath": null,
"webviewInstallMode": {
"silent": true,
"type": "downloadBootstrapper"
Expand Down Expand Up @@ -1650,7 +1649,6 @@
"signCommand": null,
"timestampUrl": null,
"tsp": false,
"webviewFixedRuntimePath": null,
"webviewInstallMode": {
"silent": true,
"type": "downloadBootstrapper"
Expand Down Expand Up @@ -1998,13 +1996,6 @@
}
]
},
"webviewFixedRuntimePath": {
"description": "Path to the webview fixed runtime to use. Overwrites [`Self::webview_install_mode`] if set.\n\n Will be removed in v2, prefer the [`Self::webview_install_mode`] option.\n\n The fixed version can be downloaded [on the official website](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section).\n The `.cab` file must be extracted to a folder and this folder path must be defined on this field.",
"type": [
"string",
"null"
]
},
"allowDowngrades": {
"description": "Validates a second app installation, blocking the user from installing an older version if set to `false`.\n\n For instance, if `1.2.1` is installed, the user won't be able to install app version `1.2.0` or `1.1.5`.\n\n The default value of this flag is `true`.",
"default": true,
Expand Down
18 changes: 1 addition & 17 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,14 +948,6 @@ pub struct WindowsConfig {
/// The installation mode for the Webview2 runtime.
#[serde(default, alias = "webview-install-mode")]
pub webview_install_mode: WebviewInstallMode,
/// Path to the webview fixed runtime to use. Overwrites [`Self::webview_install_mode`] if set.
///
/// Will be removed in v2, prefer the [`Self::webview_install_mode`] option.
///
/// The fixed version can be downloaded [on the official website](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section).
/// The `.cab` file must be extracted to a folder and this folder path must be defined on this field.
#[serde(alias = "webview-fixed-runtime-path")]
pub webview_fixed_runtime_path: Option<PathBuf>,
/// Validates a second app installation, blocking the user from installing an older version if set to `false`.
///
/// For instance, if `1.2.1` is installed, the user won't be able to install app version `1.2.0` or `1.1.5`.
Expand Down Expand Up @@ -986,7 +978,6 @@ impl Default for WindowsConfig {
timestamp_url: None,
tsp: false,
webview_install_mode: Default::default(),
webview_fixed_runtime_path: None,
allow_downgrades: true,
wix: None,
nsis: None,
Expand Down Expand Up @@ -2550,14 +2541,7 @@ mod build {

impl ToTokens for WindowsConfig {
fn to_tokens(&self, tokens: &mut TokenStream) {
let webview_install_mode = if let Some(fixed_runtime_path) = &self.webview_fixed_runtime_path
{
WebviewInstallMode::FixedRuntime {
path: fixed_runtime_path.clone(),
}
} else {
self.webview_install_mode.clone()
};
let webview_install_mode = &self.webview_install_mode;
tokens.append_all(quote! { ::tauri::utils::config::WindowsConfig {
webview_install_mode: #webview_install_mode,
..Default::default()
Expand Down
14 changes: 7 additions & 7 deletions examples/api/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,6 @@ pub struct WindowsSettings {
pub icon_path: PathBuf,
/// The installation mode for the Webview2 runtime.
pub webview_install_mode: WebviewInstallMode,
/// Path to the webview fixed runtime to use.
///
/// Overwrites [`Self::webview_install_mode`] if set.
///
/// Will be removed in v2, use [`Self::webview_install_mode`] instead.
pub webview_fixed_runtime_path: Option<PathBuf>,
/// Validates a second app installation, blocking the user from installing an older version if set to `false`.
///
/// For instance, if `1.2.1` is installed, the user won't be able to install app version `1.2.0` or `1.1.5`.
Expand Down Expand Up @@ -533,7 +527,6 @@ impl Default for WindowsSettings {
nsis: None,
icon_path: PathBuf::from("icons/icon.ico"),
webview_install_mode: Default::default(),
webview_fixed_runtime_path: None,
allow_downgrades: true,
sign_command: None,
}
Expand Down
8 changes: 1 addition & 7 deletions tooling/bundler/src/bundle/windows/msi/wix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,7 @@ pub fn build_wix_app_installer(
silent: silent_webview_install,
}
} else {
let mut webview_install_mode = settings.windows().webview_install_mode.clone();
if let Some(fixed_runtime_path) = settings.windows().webview_fixed_runtime_path.clone() {
webview_install_mode = WebviewInstallMode::FixedRuntime {
path: fixed_runtime_path,
};
}
webview_install_mode
settings.windows().webview_install_mode.clone()
};

data.insert("install_webview", to_json(true));
Expand Down
8 changes: 1 addition & 7 deletions tooling/bundler/src/bundle/windows/nsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,7 @@ fn build_nsis_app_installer(
silent: silent_webview2_install,
}
} else {
let mut webview_install_mode = settings.windows().webview_install_mode.clone();
if let Some(fixed_runtime_path) = settings.windows().webview_fixed_runtime_path.clone() {
webview_install_mode = WebviewInstallMode::FixedRuntime {
path: fixed_runtime_path,
};
}
webview_install_mode
settings.windows().webview_install_mode.clone()
};

let webview2_installer_args = to_json(if silent_webview2_install {
Expand Down
9 changes: 0 additions & 9 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
"signCommand": null,
"timestampUrl": null,
"tsp": false,
"webviewFixedRuntimePath": null,
"webviewInstallMode": {
"silent": true,
"type": "downloadBootstrapper"
Expand Down Expand Up @@ -1650,7 +1649,6 @@
"signCommand": null,
"timestampUrl": null,
"tsp": false,
"webviewFixedRuntimePath": null,
"webviewInstallMode": {
"silent": true,
"type": "downloadBootstrapper"
Expand Down Expand Up @@ -1998,13 +1996,6 @@
}
]
},
"webviewFixedRuntimePath": {
"description": "Path to the webview fixed runtime to use. Overwrites [`Self::webview_install_mode`] if set.\n\n Will be removed in v2, prefer the [`Self::webview_install_mode`] option.\n\n The fixed version can be downloaded [on the official website](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section).\n The `.cab` file must be extracted to a folder and this folder path must be defined on this field.",
"type": [
"string",
"null"
]
},
"allowDowngrades": {
"description": "Validates a second app installation, blocking the user from installing an older version if set to `false`.\n\n For instance, if `1.2.1` is installed, the user won't be able to install app version `1.2.0` or `1.1.5`.\n\n The default value of this flag is `true`.",
"default": true,
Expand Down
5 changes: 1 addition & 4 deletions tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,9 +1280,7 @@ fn tauri_config_to_bundle_settings(

#[cfg(windows)]
{
if let Some(webview_fixed_runtime_path) = &config.windows.webview_fixed_runtime_path {
resources.push(webview_fixed_runtime_path.display().to_string());
} else if let crate::helpers::config::WebviewInstallMode::FixedRuntime { path } =
if let crate::helpers::config::WebviewInstallMode::FixedRuntime { path } =
&config.windows.webview_install_mode
{
resources.push(path.display().to_string());
Expand Down Expand Up @@ -1423,7 +1421,6 @@ fn tauri_config_to_bundle_settings(
nsis: config.windows.nsis.map(nsis_settings),
icon_path: windows_icon_path,
webview_install_mode: config.windows.webview_install_mode,
webview_fixed_runtime_path: config.windows.webview_fixed_runtime_path,
allow_downgrades: config.windows.allow_downgrades,
sign_command: config.windows.sign_command.map(custom_sign_settings),
},
Expand Down
63 changes: 56 additions & 7 deletions tooling/cli/src/migrate/migrations/v1/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,39 @@ fn process_bundle(config: &mut Map<String, Value>, migrated: &MigratedConfig) {
license_file = Some(license);
}
}

// Windows
if let Some(windows) = bundle_config.get_mut("windows") {
if let Some(wix) = windows.get_mut("wix").and_then(|v| v.as_object_mut()) {
if let Some(license_path) = wix.remove("license") {
license_file = Some(license_path);
if let Some(windows) = windows.as_object_mut() {
if let Some(wix) = windows.get_mut("wix").and_then(|v| v.as_object_mut()) {
if let Some(license_path) = wix.remove("license") {
license_file = Some(license_path);
}
}
}
if let Some(nsis) = windows.get_mut("nsis").and_then(|v| v.as_object_mut()) {
if let Some(license_path) = nsis.remove("license") {
license_file = Some(license_path);
if let Some(nsis) = windows.get_mut("nsis").and_then(|v| v.as_object_mut()) {
if let Some(license_path) = nsis.remove("license") {
license_file = Some(license_path);
}
}

if let Some((fixed_runtime_path, key)) = windows
.remove("webviewFixedRuntimePath")
.map(|v| (v, "webviewInstallMode"))
.or_else(|| {
windows
.remove("webview-fixed-runtime-path")
.map(|v| (v, "webview-install-mode"))
})
{
if !fixed_runtime_path.is_null() {
windows.insert(
key.into(),
serde_json::json!({
"type": "fixedRuntime",
"path": fixed_runtime_path
}),
);
}
}
}
}
Expand Down Expand Up @@ -1083,4 +1107,29 @@ mod test {
original["build"]["frontendDist"]
);
}

#[test]
fn migrate_webview_fixed_runtime_path() {
let original = serde_json::json!({
"tauri": {
"bundle": {
"windows": {
"webviewFixedRuntimePath": "./path/to/runtime"
}
}
}
});

let migrated = migrate(&original);

assert_eq!(
migrated["bundle"]["windows"]["webviewInstallMode"]["type"],
"fixedRuntime"
);

assert_eq!(
migrated["bundle"]["windows"]["webviewInstallMode"]["path"],
original["tauri"]["bundle"]["windows"]["webviewFixedRuntimePath"]
);
}
}
Loading