mirror of
https://github.com/tauri-apps/tauri.git
synced 2025-01-03 00:21:34 +03:00
This commit is contained in:
parent
dfbbca423b
commit
e3bfb01411
5
.changes/nsis-set-compressor.md
Normal file
5
.changes/nsis-set-compressor.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'tauri-bundler': 'patch:enhance'
|
||||
---
|
||||
|
||||
Add `compression` configuration option under `tauri > bundle > windows > nsis`.
|
@ -1777,6 +1777,17 @@
|
||||
"description": "Whether to display a language selector dialog before the installer and uninstaller windows are rendered or not. By default the OS language is selected, with a fallback to the first language in the `languages` array.",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"compression": {
|
||||
"description": "Set the compression algorithm used to compress files in the installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/NsisCompression"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -1807,6 +1818,32 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"NsisCompression": {
|
||||
"description": "Compression algorithms used in the NSIS installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "ZLIB uses the deflate algorithm, it is a quick and simple method. With the default compression level it uses about 300 KB of memory.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"bzip2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"lzma"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"AllowlistConfig": {
|
||||
"description": "Allowlist configuration. The allowlist is a translation of the [Cargo allowlist features](https://docs.rs/tauri/latest/tauri/#cargo-allowlist-features).\n\n# Notes\n\n- Endpoints that don't have their own allowlist option are enabled by default. - There is only \"opt-in\", no \"opt-out\". Setting an option to `false` has no effect.\n\n# Examples\n\n- * [`\"app-all\": true`](https://tauri.app/v1/api/config/#appallowlistconfig.all) will make the [hide](https://tauri.app/v1/api/js/app#hide) endpoint be available regardless of whether `hide` is set to `false` or `true` in the allowlist.",
|
||||
"type": "object",
|
||||
|
@ -438,6 +438,21 @@ pub struct WixConfig {
|
||||
pub dialog_image_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// Compression algorithms used in the NSIS installer.
|
||||
///
|
||||
/// See <https://nsis.sourceforge.io/Reference/SetCompressor>
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub enum NsisCompression {
|
||||
/// ZLIB uses the deflate algorithm, it is a quick and simple method. With the default compression level it uses about 300 KB of memory.
|
||||
Zlib,
|
||||
/// BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.
|
||||
Bzip2,
|
||||
/// LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.
|
||||
Lzma,
|
||||
}
|
||||
|
||||
/// Configuration for the Installer bundle using NSIS.
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
@ -480,6 +495,10 @@ pub struct NsisConfig {
|
||||
/// By default the OS language is selected, with a fallback to the first language in the `languages` array.
|
||||
#[serde(default, alias = "display-language-selector")]
|
||||
pub display_language_selector: bool,
|
||||
/// Set the compression algorithm used to compress files in the installer.
|
||||
///
|
||||
/// See <https://nsis.sourceforge.io/Reference/SetCompressor>
|
||||
pub compression: Option<NsisCompression>,
|
||||
}
|
||||
|
||||
/// Install Modes for the NSIS installer.
|
||||
|
@ -7,7 +7,7 @@ use super::category::AppCategory;
|
||||
use crate::bundle::{common, platform::target_triple};
|
||||
pub use tauri_utils::config::WebviewInstallMode;
|
||||
use tauri_utils::{
|
||||
config::{BundleType, NSISInstallerMode},
|
||||
config::{BundleType, NSISInstallerMode, NsisCompression},
|
||||
resources::{external_binaries, ResourcePaths},
|
||||
};
|
||||
|
||||
@ -313,6 +313,8 @@ pub struct NsisSettings {
|
||||
/// Whether to display a language selector dialog before the installer and uninstaller windows are rendered or not.
|
||||
/// By default the OS language is selected, with a fallback to the first language in the `languages` array.
|
||||
pub display_language_selector: bool,
|
||||
/// Set compression algorithm used to compress files in the installer.
|
||||
pub compression: Option<NsisCompression>,
|
||||
}
|
||||
|
||||
/// The Windows bundle settings.
|
||||
|
@ -20,7 +20,7 @@ use tauri_utils::display_path;
|
||||
use anyhow::Context;
|
||||
use handlebars::{to_json, Handlebars};
|
||||
use log::{info, warn};
|
||||
use tauri_utils::config::{NSISInstallerMode, WebviewInstallMode};
|
||||
use tauri_utils::config::{NSISInstallerMode, NsisCompression, WebviewInstallMode};
|
||||
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
@ -242,6 +242,15 @@ fn build_nsis_app_installer(
|
||||
);
|
||||
}
|
||||
|
||||
data.insert(
|
||||
"compression",
|
||||
to_json(match &nsis.compression.unwrap_or(NsisCompression::Lzma) {
|
||||
NsisCompression::Zlib => "zlib",
|
||||
NsisCompression::Bzip2 => "bzip2",
|
||||
NsisCompression::Lzma => "lzma",
|
||||
}),
|
||||
);
|
||||
|
||||
data.insert(
|
||||
"display_language_selector",
|
||||
to_json(nsis.display_language_selector && languages.len() > 1),
|
||||
|
@ -1,5 +1,10 @@
|
||||
Unicode true
|
||||
SetCompressor /SOLID lzma
|
||||
; Set the compression algorithm. Default is LZMA.
|
||||
!if "{{compression}}" == ""
|
||||
SetCompressor /SOLID lzma
|
||||
!else
|
||||
SetCompressor /SOLID "{{compression}}"
|
||||
!endif
|
||||
|
||||
!include MUI2.nsh
|
||||
!include FileFunc.nsh
|
||||
|
@ -1777,6 +1777,17 @@
|
||||
"description": "Whether to display a language selector dialog before the installer and uninstaller windows are rendered or not. By default the OS language is selected, with a fallback to the first language in the `languages` array.",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"compression": {
|
||||
"description": "Set the compression algorithm used to compress files in the installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/NsisCompression"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
@ -1807,6 +1818,32 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"NsisCompression": {
|
||||
"description": "Compression algorithms used in the NSIS installer.\n\nSee <https://nsis.sourceforge.io/Reference/SetCompressor>",
|
||||
"oneOf": [
|
||||
{
|
||||
"description": "ZLIB uses the deflate algorithm, it is a quick and simple method. With the default compression level it uses about 300 KB of memory.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"zlib"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"bzip2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"lzma"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"AllowlistConfig": {
|
||||
"description": "Allowlist configuration. The allowlist is a translation of the [Cargo allowlist features](https://docs.rs/tauri/latest/tauri/#cargo-allowlist-features).\n\n# Notes\n\n- Endpoints that don't have their own allowlist option are enabled by default. - There is only \"opt-in\", no \"opt-out\". Setting an option to `false` has no effect.\n\n# Examples\n\n- * [`\"app-all\": true`](https://tauri.app/v1/api/config/#appallowlistconfig.all) will make the [hide](https://tauri.app/v1/api/js/app#hide) endpoint be available regardless of whether `hide` is set to `false` or `true` in the allowlist.",
|
||||
"type": "object",
|
||||
|
@ -108,6 +108,7 @@ pub fn nsis_settings(config: NsisConfig) -> tauri_bundler::NsisSettings {
|
||||
languages: config.languages,
|
||||
custom_language_files: config.custom_language_files,
|
||||
display_language_selector: config.display_language_selector,
|
||||
compression: config.compression,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user