Update the browser, editor, settings, and installer
This commit is contained in:
Generated
+1
-1
@@ -3130,7 +3130,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "runestone"
|
||||
version = "0.1.18"
|
||||
version = "0.1.23+1"
|
||||
dependencies = [
|
||||
"base64 0.23.1",
|
||||
"dunce",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "runestone"
|
||||
version = "0.1.18"
|
||||
version = "0.1.23+1"
|
||||
description = "Writing workspace plus script editor"
|
||||
authors = ["you"]
|
||||
edition = "2021"
|
||||
@@ -32,7 +32,7 @@ reqwest = { version = "0.13.5", default-features = false, features = ["blocking"
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { version = "0.61.2", features = ["Win32_Storage_FileSystem", "Win32_UI_Input_KeyboardAndMouse"] }
|
||||
webview2-com = "0.38.2"
|
||||
windows = { version = "0.61.3", features = ["Win32_Foundation", "Win32_System_Com"] }
|
||||
windows = { version = "0.61.3", features = ["Win32_Foundation", "Win32_System_Com", "Win32_Globalization"] }
|
||||
|
||||
|
||||
# Read the optimization guideline for more details: https://tauri.app/concept/size/#cargo-configuration
|
||||
@@ -42,3 +42,6 @@ lto = true
|
||||
opt-level = 3
|
||||
panic = "abort"
|
||||
strip = true
|
||||
|
||||
[package.metadata.runestone]
|
||||
version = "0.1.23a"
|
||||
|
||||
@@ -2,6 +2,8 @@ fn main() {
|
||||
tauri_build::try_build(
|
||||
tauri_build::Attributes::new().app_manifest(
|
||||
tauri_build::AppManifest::new().commands(&[
|
||||
"theme_export",
|
||||
"spelling_suggestions",
|
||||
"spelling_menu_install",
|
||||
"spelling_menu_select",
|
||||
"spelling_menu_uninstall",
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
"windows": ["main", "workspace-*", "terminal-*", "browser-*"],
|
||||
"permissions": [
|
||||
"allow-spelling-menu-install",
|
||||
"allow-spelling-suggestions",
|
||||
"allow-theme-export",
|
||||
"allow-spelling-menu-select",
|
||||
"allow-spelling-menu-uninstall",
|
||||
"allow-settings-open-window",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"description": "Settings windows and their plugin settings",
|
||||
"windows": ["settings-main", "settings-workspace-*"],
|
||||
"permissions": [
|
||||
"allow-theme-export",
|
||||
"core:default",
|
||||
"core:window:allow-close",
|
||||
"core:window:allow-minimize",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-spelling-suggestions"
|
||||
description = "Enables the spelling_suggestions command without any pre-configured scope."
|
||||
commands.allow = ["spelling_suggestions"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-spelling-suggestions"
|
||||
description = "Denies the spelling_suggestions command without any pre-configured scope."
|
||||
commands.deny = ["spelling_suggestions"]
|
||||
@@ -0,0 +1,11 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-theme-export"
|
||||
description = "Enables the theme_export command without any pre-configured scope."
|
||||
commands.allow = ["theme_export"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-theme-export"
|
||||
description = "Denies the theme_export command without any pre-configured scope."
|
||||
commands.deny = ["theme_export"]
|
||||
+15
-11
@@ -30,6 +30,10 @@ const COMMANDS: &[&str] = &[
|
||||
"resize",
|
||||
"visible",
|
||||
"input",
|
||||
"insertText",
|
||||
"edit",
|
||||
"contextAction",
|
||||
"frameAck",
|
||||
"createProfile",
|
||||
"renameProfile",
|
||||
"duplicateProfile",
|
||||
@@ -109,15 +113,6 @@ fn executable(app: &AppHandle) -> Result<PathBuf> {
|
||||
} else {
|
||||
"RuneStone-Browser"
|
||||
};
|
||||
let packaged = app
|
||||
.path()
|
||||
.resource_dir()
|
||||
.map_err(fail)?
|
||||
.join("browser-engine")
|
||||
.join(name);
|
||||
if packaged.is_file() {
|
||||
return Ok(packaged);
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
let development = Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
@@ -127,6 +122,15 @@ fn executable(app: &AppHandle) -> Result<PathBuf> {
|
||||
return Ok(development);
|
||||
}
|
||||
}
|
||||
let packaged = app
|
||||
.path()
|
||||
.resource_dir()
|
||||
.map_err(fail)?
|
||||
.join("browser-engine")
|
||||
.join(name);
|
||||
if packaged.is_file() {
|
||||
return Ok(packaged);
|
||||
}
|
||||
Err("The browser runtime is missing. Build RuneStone with its browser runtime.".into())
|
||||
}
|
||||
|
||||
@@ -224,7 +228,7 @@ impl Worker {
|
||||
}
|
||||
}
|
||||
}
|
||||
Some("state") | Some("error") => {
|
||||
Some("state") | Some("error") | Some("context-menu") | Some("open-link") => {
|
||||
if let Ok(routes) = routes.lock() {
|
||||
for target in &routes.windows {
|
||||
if let Some(id) = value["tabId"].as_str() {
|
||||
@@ -410,7 +414,7 @@ impl BrowserState {
|
||||
let _ = app.emit_to(&source, "browser-tab-moved", json!({ "tabId": id }));
|
||||
return Ok(worker.routing.lock().map_err(fail)?.snapshot(result, owner));
|
||||
}
|
||||
if ["closeTab", "navigate", "back", "forward", "reload", "stop", "find", "stopFind", "openExternal", "moveToWindow", "resize", "visible", "input", "bookmark", "agentSnapshot"].contains(&command) {
|
||||
if ["closeTab", "navigate", "back", "forward", "reload", "stop", "find", "stopFind", "openExternal", "moveToWindow", "resize", "visible", "input", "insertText", "edit", "contextAction", "frameAck", "bookmark", "agentSnapshot"].contains(&command) {
|
||||
let id = args["tabId"].as_str().ok_or("Invalid browser tab.")?;
|
||||
match worker.routing.lock().map_err(fail)?.owners.get(id) {
|
||||
Some(window) if window == owner => {},
|
||||
|
||||
@@ -7,6 +7,7 @@ mod git;
|
||||
mod completion;
|
||||
mod settings;
|
||||
mod spelling;
|
||||
mod theme;
|
||||
|
||||
use pty::PtyState;
|
||||
use tauri::Manager;
|
||||
@@ -24,7 +25,9 @@ pub fn run() {
|
||||
.manage(completion::CompletionState::default())
|
||||
.manage(settings::SettingsState::default())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
theme::theme_export,
|
||||
spelling::spelling_menu_install,
|
||||
spelling::spelling_suggestions,
|
||||
spelling::spelling_menu_select,
|
||||
spelling::spelling_menu_uninstall,
|
||||
settings::settings_open_window,
|
||||
|
||||
@@ -269,6 +269,16 @@ fn directory_files(path: &Path) -> Result<BTreeMap<String, Vec<u8>>> {
|
||||
fn tree_hash(path: &Path) -> Result<String> {
|
||||
Ok(fingerprint(&directory_files(path)?))
|
||||
}
|
||||
fn valid_version(version: &str) -> bool {
|
||||
let parts: Vec<_> = version.split('.').collect();
|
||||
if parts.len() != 3 || parts[..2].iter().any(|part| {
|
||||
part.is_empty() || !part.bytes().all(|byte| byte.is_ascii_digit())
|
||||
}) {
|
||||
return false;
|
||||
}
|
||||
let digits = parts[2].bytes().take_while(|byte| byte.is_ascii_digit()).count();
|
||||
digits > 0 && parts[2][digits..].bytes().all(|byte| byte.is_ascii_lowercase())
|
||||
}
|
||||
fn package(source: &Path) -> Result<Package> {
|
||||
let mut files = BTreeMap::new();
|
||||
let mut names = BTreeSet::new();
|
||||
@@ -340,13 +350,8 @@ fn package(source: &Path) -> Result<Package> {
|
||||
{
|
||||
return Err("The manifest needs a name, author, description, and version.".into());
|
||||
}
|
||||
if manifest.version.split('.').count() != 3
|
||||
|| !manifest
|
||||
.version
|
||||
.split('.')
|
||||
.all(|n| !n.is_empty() && n.bytes().all(|c| c.is_ascii_digit()))
|
||||
{
|
||||
return Err("Use a plugin version such as 1.0.0.".into());
|
||||
if !valid_version(&manifest.version) {
|
||||
return Err("Use a plugin version such as 1.0.0 or 1.0.0a.".into());
|
||||
}
|
||||
relative(&manifest.entry)?;
|
||||
if !manifest.entry.ends_with(".js") && !manifest.entry.ends_with(".mjs") {
|
||||
@@ -1460,6 +1465,9 @@ mod tests {
|
||||
#[test]
|
||||
fn author_packager_produces_an_installable_repeatable_zip() {
|
||||
let mut f = Fixture::new();
|
||||
let manifest = fs::read_to_string(f.source.join("plugin.json"))
|
||||
.unwrap().replace("1.0.0", "1.0.0a");
|
||||
fs::write(f.source.join("plugin.json"), manifest).unwrap();
|
||||
fs::create_dir(f.source.join("assets")).unwrap();
|
||||
fs::write(f.source.join("assets/style.css"), "body { color: red; }").unwrap();
|
||||
let script = Path::new(env!("CARGO_MANIFEST_DIR")).join("../scripts/packagePlugin.mjs");
|
||||
@@ -1478,7 +1486,7 @@ mod tests {
|
||||
);
|
||||
};
|
||||
build();
|
||||
let path = output.join("org.test.demo-1.0.0.zip");
|
||||
let path = output.join("org.test.demo-1.0.0a.zip");
|
||||
let first = fs::read(&path).unwrap();
|
||||
build();
|
||||
assert_eq!(first, fs::read(&path).unwrap());
|
||||
@@ -1490,6 +1498,7 @@ mod tests {
|
||||
assert!(row.error.is_none(), "{:?}", row.error);
|
||||
f.service.install("main", &row.token, false).unwrap();
|
||||
let installed = f.service.row("org.test.demo").unwrap();
|
||||
assert_eq!(installed.manifest.version, "1.0.0a");
|
||||
assert!(!installed.enabled);
|
||||
assert_eq!(
|
||||
fs::read(Path::new(&installed.path).join("assets/style.css")).unwrap(),
|
||||
@@ -1550,6 +1559,28 @@ mod tests {
|
||||
.is_none());
|
||||
}
|
||||
#[test]
|
||||
fn hotfix_versions_validate_and_survive_zip_install() {
|
||||
for version in ["0.2.28", "0.2.28a", "0.2.28b", "0.2.28aa", "1.0.1000z"] {
|
||||
assert!(valid_version(version), "{version}");
|
||||
}
|
||||
for version in ["", "1.0", "1.0.0.0", "1.0.a", "1.0.0A", "1.0.0a1", "1.0.0-beta", "1.0.0+build", "1.0.0é"] {
|
||||
assert!(!valid_version(version), "{version}");
|
||||
}
|
||||
let mut f = Fixture::new();
|
||||
let manifest = fs::read_to_string(f.source.join("plugin.json"))
|
||||
.unwrap().replace("1.0.0", "0.2.28a");
|
||||
let path = f.root.join("hotfix.zip");
|
||||
archive(&path, &[("plugin.json", manifest.as_bytes()), ("main.js", b"export function activate() {}")]);
|
||||
assert_eq!(package(&path).unwrap().manifest.version, "0.2.28a");
|
||||
let row = f.service.inspect("main", path);
|
||||
assert!(row.error.is_none());
|
||||
f.service.install("main", &row.token, true).unwrap();
|
||||
let mut reopened = Service::open(f.root.join("app")).unwrap();
|
||||
let snapshot = reopened.snapshot().unwrap();
|
||||
assert_eq!(snapshot.plugins[0].manifest.version, "0.2.28a");
|
||||
assert!(snapshot.plugins[0].enabled);
|
||||
}
|
||||
#[test]
|
||||
fn validates_paths_ids_limits_and_versions() {
|
||||
for name in [
|
||||
"../file",
|
||||
|
||||
+100
-6
@@ -10,6 +10,13 @@ fn requires_native_label(kind: i32, label: &str) -> bool {
|
||||
kind != 3 && label.trim().is_empty()
|
||||
}
|
||||
|
||||
#[cfg(any(windows, test))]
|
||||
fn excluded_command(name: &str, editable: bool) -> bool {
|
||||
// WebView2 names unsupported OS tools "other", including direction and dictation.
|
||||
// Keep recognized editor commands without matching localized labels or runtime IDs.
|
||||
matches!(name, "share" | "writingDirection" | "voiceTyping") || (editable && name == "other")
|
||||
}
|
||||
|
||||
#[cfg(any(windows, test))]
|
||||
fn selection(current: &str, request: &str, command: Option<i32>, fallback: bool, enabled: &std::collections::HashSet<i32>) -> Selection {
|
||||
if current != request { return Selection::Stale; }
|
||||
@@ -31,7 +38,7 @@ mod native {
|
||||
enabled: bool, checked: bool, children: Vec<Item>,
|
||||
}
|
||||
#[derive(Clone, Serialize)]
|
||||
struct Menu { request: String, items: Vec<Item> }
|
||||
struct Menu { request: String, items: Vec<Item>, fallback_spelling: bool }
|
||||
fn requires_native(items: &[Item]) -> bool {
|
||||
items.iter().any(|item| super::requires_native_label(item.kind, &item.label) || requires_native(&item.children))
|
||||
}
|
||||
@@ -53,6 +60,32 @@ mod native {
|
||||
let text = take_pwstr(value);
|
||||
result.map(|_| text)
|
||||
}
|
||||
unsafe fn trim_menu(collection: &ICoreWebView2ContextMenuItemCollection, editable: bool) -> windows::core::Result<u32> {
|
||||
let mut count = 0;
|
||||
collection.Count(&mut count)?;
|
||||
let mut index = 0;
|
||||
let mut separator = true;
|
||||
while index < count {
|
||||
let item = collection.GetValueAtIndex(index)?;
|
||||
let mut kind = COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_COMMAND;
|
||||
item.Kind(&mut kind)?;
|
||||
let name = text(|value| item.Name(value))?;
|
||||
let empty_submenu = kind == COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SUBMENU && trim_menu(&item.Children()?, editable)? == 0;
|
||||
let is_separator = kind == COREWEBVIEW2_CONTEXT_MENU_ITEM_KIND_SEPARATOR;
|
||||
if (!is_separator && super::excluded_command(&name, editable)) || empty_submenu || (is_separator && separator) {
|
||||
collection.RemoveValueAtIndex(index)?;
|
||||
count -= 1;
|
||||
} else {
|
||||
separator = is_separator;
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
if separator && count > 0 {
|
||||
collection.RemoveValueAtIndex(count - 1)?;
|
||||
count -= 1;
|
||||
}
|
||||
Ok(count)
|
||||
}
|
||||
unsafe fn items(collection: ICoreWebView2ContextMenuItemCollection, commands: &mut HashSet<i32>, parent_enabled: bool) -> windows::core::Result<Vec<Item>> {
|
||||
let mut count = 0;
|
||||
collection.Count(&mut count)?;
|
||||
@@ -87,15 +120,17 @@ mod native {
|
||||
let Some(args) = args else { return Ok(()); };
|
||||
let mut editable = BOOL(0);
|
||||
args.ContextMenuTarget()?.IsEditable(&mut editable)?;
|
||||
// Filter the original collection so native fallback uses the same commands.
|
||||
let collection = args.MenuItems()?;
|
||||
trim_menu(&collection, editable.as_bool())?;
|
||||
if !editable.as_bool() { return Ok(()); }
|
||||
let mut commands = HashSet::new();
|
||||
let entries = items(args.MenuItems()?, &mut commands, true)?;
|
||||
// WebView2 can omit spelling labels and reject their command IDs.
|
||||
// Its native menu still owns the suggestion text and correction.
|
||||
if requires_native(&entries) { return Ok(()); }
|
||||
let entries = items(collection, &mut commands, true)?;
|
||||
// Windows supplies suggestions when WebView2 omits their labels.
|
||||
let fallback_spelling = requires_native(&entries) || !entries.iter().any(|item| item.name == "spellCheck" && !item.label.trim().is_empty());
|
||||
let Some(window) = app.get_webview_window(&owner) else { return Ok(()); };
|
||||
let pending = Pending { request: uuid::Uuid::new_v4().to_string(), args: args.clone(), deferral: args.GetDeferral()?, commands };
|
||||
let menu = Menu { request: pending.request.clone(), items: entries };
|
||||
let menu = Menu { request: pending.request.clone(), items: entries, fallback_spelling };
|
||||
args.SetHandled(true)?;
|
||||
let previous = PENDING.with(|state| state.borrow_mut().insert(owner.clone(), pending));
|
||||
drop(previous);
|
||||
@@ -182,11 +217,70 @@ pub fn spelling_menu_uninstall(window: tauri::WebviewWindow) -> Result<(), Strin
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
pub struct Suggestions { language: String, words: Vec<String>, misspelled: bool }
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn spelling_suggestions(word: String, languages: Vec<String>, add: Option<bool>) -> Result<Suggestions, String> {
|
||||
if word.is_empty() || word.len() > 256 || word.contains('\0') || languages.len() > 20 {
|
||||
return Err("Invalid spelling request.".into());
|
||||
}
|
||||
#[cfg(windows)] {
|
||||
tauri::async_runtime::spawn_blocking(move || -> Result<Suggestions, String> {
|
||||
use windows::{core::{HSTRING, PWSTR}, Win32::{Globalization::{ISpellCheckerFactory, SpellCheckerFactory}, System::Com::{CoInitializeEx, CoUninitialize, CoCreateInstance, CLSCTX_INPROC_SERVER, COINIT_APARTMENTTHREADED}}};
|
||||
unsafe {
|
||||
CoInitializeEx(None, COINIT_APARTMENTTHREADED).ok().map_err(|error| error.to_string())?;
|
||||
struct Apartment;
|
||||
impl Drop for Apartment { fn drop(&mut self) { unsafe { CoUninitialize(); } } }
|
||||
let _apartment = Apartment;
|
||||
let factory: ISpellCheckerFactory = CoCreateInstance(&SpellCheckerFactory, None, CLSCTX_INPROC_SERVER).map_err(|error| error.to_string())?;
|
||||
for language in languages {
|
||||
if language.len() > 85 || language.contains('\0') { continue; }
|
||||
let tag = HSTRING::from(&language);
|
||||
if !factory.IsSupported(&tag).map_err(|error| error.to_string())?.as_bool() { continue; }
|
||||
let checker = factory.CreateSpellChecker(&tag).map_err(|error| error.to_string())?;
|
||||
let value = HSTRING::from(&word);
|
||||
if add.unwrap_or(false) {
|
||||
checker.Add(&value).map_err(|error| error.to_string())?;
|
||||
return Ok(Suggestions { language, words: Vec::new(), misspelled: false });
|
||||
}
|
||||
let errors = checker.Check(&value).map_err(|error| error.to_string())?;
|
||||
let mut error = None;
|
||||
errors.Next(&mut error).ok().map_err(|error| error.to_string())?;
|
||||
if error.is_none() { return Ok(Suggestions { language, words: Vec::new(), misspelled: false }); }
|
||||
let suggestions = checker.Suggest(&value).map_err(|error| error.to_string())?;
|
||||
let mut words = Vec::new();
|
||||
for _ in 0..8 {
|
||||
let mut values = [PWSTR::null()];
|
||||
let mut count = 0;
|
||||
suggestions.Next(&mut values, Some(&mut count)).ok().map_err(|error| error.to_string())?;
|
||||
if count == 0 { break; }
|
||||
let suggestion = webview2_com::take_pwstr(values[0]);
|
||||
if !suggestion.is_empty() && suggestion != word { words.push(suggestion); }
|
||||
}
|
||||
return Ok(Suggestions { language, words, misspelled: true });
|
||||
}
|
||||
Err("No spelling dictionary is installed for this language.".into())
|
||||
}
|
||||
}).await.map_err(|error| error.to_string())?
|
||||
}
|
||||
#[cfg(not(windows))] { let _ = (word, languages, add); Err("System spelling is unavailable.".into()) }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
fn unrelated_browser_tools_are_removed_without_changing_editor_commands() {
|
||||
for name in ["share", "writingDirection", "voiceTyping", "other"] { assert!(excluded_command(name, true)); }
|
||||
assert!(!excluded_command("other", false), "Keep unrelated non-editable native actions");
|
||||
for name in ["cut", "copy", "paste", "pasteAndMatchStyle", "undo", "redo", "selectAll", "spellCheck", "addToDictionary", "emoji", "copyLink", "custom"] {
|
||||
assert!(!excluded_command(name, true), "Keep {name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_requests_cannot_select_or_cancel_a_new_menu() {
|
||||
for command in [None, Some(42)] {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn theme_export(app: tauri::AppHandle, contents: String, default_name: String) -> Result<Option<String>, String> {
|
||||
if contents.len() > 1_048_576 { return Err("The theme exceeds the 1 MB limit.".into()); }
|
||||
serde_json::from_str::<serde_json::Value>(&contents).map_err(|_| "The theme contains invalid JSON.".to_string())?;
|
||||
let name = std::path::Path::new(&default_name).file_name().and_then(|name| name.to_str()).unwrap_or("theme.json").to_string();
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
let Some(file) = app.dialog().file().set_title("Export theme").add_filter("Theme JSON", &["json"]).set_file_name(name).blocking_save_file() else { return Ok(None); };
|
||||
let path = file.into_path().map_err(|error| error.to_string())?;
|
||||
std::fs::write(&path, contents).map_err(|error| format!("Could not export the theme: {error}"))?;
|
||||
Ok(Some(path.to_string_lossy().into_owned()))
|
||||
}).await.map_err(|error| error.to_string())?
|
||||
}
|
||||
@@ -404,7 +404,7 @@ fn open_workspace_tab_window(app: &AppHandle, state: &WorkspaceState, root: Path
|
||||
config.title = format!("{} — RuneStone", workspace_info(&root).name);
|
||||
if let Some(token) = transfer {
|
||||
let id = uuid::Uuid::parse_str(&token).map_err(|_| err("Invalid tab transfer."))?;
|
||||
config.url = tauri::WebviewUrl::App(format!("index.html?tabTransfer={id}").into());
|
||||
config.url = tauri::WebviewUrl::App(format!("?tabTransfer={id}").into());
|
||||
}
|
||||
// Bind before building: the new frontend asks for its own root on startup.
|
||||
state.inner.lock().map_err(|_| err("workspace lock"))?.insert(label.clone(), OpenWorkspace {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "RuneStone",
|
||||
"version": "0.1.18",
|
||||
"version": "0.1.23+1",
|
||||
"identifier": "com.runestone.app",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm dev",
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 - Present Tauri Apps Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,996 @@
|
||||
; RuneStone template, adapted from Tauri CLI 2.11.4 (Apache-2.0 OR MIT).
|
||||
; https://github.com/tauri-apps/tauri/blob/tauri-cli-v2.11.4/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi
|
||||
Unicode true
|
||||
ManifestDPIAware true
|
||||
; Add in `dpiAwareness` `PerMonitorV2` to manifest for Windows 10 1607+ (note this should not affect lower versions since they should be able to ignore this and pick up `dpiAware` `true` set by `ManifestDPIAware true`)
|
||||
; Currently undocumented on NSIS's website but is in the Docs folder of source tree, see
|
||||
; https://github.com/kichik/nsis/blob/5fc0b87b819a9eec006df4967d08e522ddd651c9/Docs/src/attributes.but#L286-L300
|
||||
; https://github.com/tauri-apps/tauri/pull/10106
|
||||
ManifestDPIAwareness PerMonitorV2
|
||||
|
||||
!if "{{compression}}" == "none"
|
||||
SetCompress off
|
||||
!else
|
||||
; Set the compression algorithm. We default to LZMA.
|
||||
SetCompressor /SOLID "{{compression}}"
|
||||
!endif
|
||||
|
||||
; Keep above !include to stay ahead of any plugin command
|
||||
; see https://github.com/tauri-apps/tauri/pull/15422#discussion_r3289239624
|
||||
{{#if signed_plugins_path}}
|
||||
!addplugindir "{{signed_plugins_path}}"
|
||||
{{/if}}
|
||||
|
||||
!include MUI2.nsh
|
||||
!include FileFunc.nsh
|
||||
!include x64.nsh
|
||||
!include WordFunc.nsh
|
||||
!include "utils.nsh"
|
||||
!include "FileAssociation.nsh"
|
||||
!include "Win\COM.nsh"
|
||||
!include "Win\Propkey.nsh"
|
||||
!include "StrFunc.nsh"
|
||||
${StrCase}
|
||||
${StrLoc}
|
||||
|
||||
{{#if installer_hooks}}
|
||||
!include "{{installer_hooks}}"
|
||||
{{/if}}
|
||||
|
||||
!define WEBVIEW2APPGUID "{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
|
||||
|
||||
!define MANUFACTURER "{{manufacturer}}"
|
||||
!define PRODUCTNAME "{{product_name}}"
|
||||
!define TOOLCHAINVERSION "{{version}}"
|
||||
!define VERSION "@RUNESTONE_VERSION@"
|
||||
!define VERSIONWITHBUILD "@RUNESTONE_WINDOWS_VERSION@"
|
||||
!include "@RUNESTONE_COMPARE@"
|
||||
!define HOMEPAGE "{{homepage}}"
|
||||
!define INSTALLMODE "{{install_mode}}"
|
||||
!define LICENSE "{{license}}"
|
||||
!define INSTALLERICON "{{installer_icon}}"
|
||||
!define SIDEBARIMAGE "{{sidebar_image}}"
|
||||
!define HEADERIMAGE "{{header_image}}"
|
||||
!define UNINSTALLERICON "{{uninstaller_icon}}"
|
||||
!define UNINSTALLERHEADERIMAGE "{{uninstaller_header_image}}"
|
||||
!define MAINBINARYNAME "{{main_binary_name}}"
|
||||
!define MAINBINARYSRCPATH "{{main_binary_path}}"
|
||||
!define BUNDLEID "{{bundle_id}}"
|
||||
!define COPYRIGHT "{{copyright}}"
|
||||
!define OUTFILE "{{out_file}}"
|
||||
!define ARCH "{{arch}}"
|
||||
!define ADDITIONALPLUGINSPATH "{{additional_plugins_path}}"
|
||||
!define ALLOWDOWNGRADES "{{allow_downgrades}}"
|
||||
!define DISPLAYLANGUAGESELECTOR "{{display_language_selector}}"
|
||||
!define INSTALLWEBVIEW2MODE "{{install_webview2_mode}}"
|
||||
!define WEBVIEW2INSTALLERARGS "{{webview2_installer_args}}"
|
||||
!define WEBVIEW2BOOTSTRAPPERPATH "{{webview2_bootstrapper_path}}"
|
||||
!define WEBVIEW2INSTALLERPATH "{{webview2_installer_path}}"
|
||||
!define MINIMUMWEBVIEW2VERSION "{{minimum_webview2_version}}"
|
||||
!define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}"
|
||||
!define MANUKEY "Software\${MANUFACTURER}"
|
||||
!define MANUPRODUCTKEY "${MANUKEY}\${PRODUCTNAME}"
|
||||
!define UNINSTALLERSIGNCOMMAND "{{uninstaller_sign_cmd}}"
|
||||
!define ESTIMATEDSIZE "{{estimated_size}}"
|
||||
!define STARTMENUFOLDER "{{start_menu_folder}}"
|
||||
|
||||
Var PassiveMode
|
||||
Var UpdateMode
|
||||
Var NoShortcutMode
|
||||
Var WixMode
|
||||
Var OldMainBinaryName
|
||||
|
||||
Name "${PRODUCTNAME}"
|
||||
BrandingText "${COPYRIGHT}"
|
||||
OutFile "${OUTFILE}"
|
||||
|
||||
; We don't actually use this value as default install path,
|
||||
; it's just for nsis to append the product name folder in the directory selector
|
||||
; https://nsis.sourceforge.io/Reference/InstallDir
|
||||
!define PLACEHOLDER_INSTALL_DIR "placeholder\${PRODUCTNAME}"
|
||||
InstallDir "${PLACEHOLDER_INSTALL_DIR}"
|
||||
|
||||
VIProductVersion "${VERSIONWITHBUILD}"
|
||||
VIAddVersionKey "ProductName" "${PRODUCTNAME}"
|
||||
VIAddVersionKey "FileDescription" "${PRODUCTNAME}"
|
||||
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
|
||||
VIAddVersionKey "FileVersion" "${VERSION}"
|
||||
VIAddVersionKey "ProductVersion" "${VERSION}"
|
||||
|
||||
# additional plugins
|
||||
!addplugindir "${ADDITIONALPLUGINSPATH}"
|
||||
|
||||
; Uninstaller signing command
|
||||
!if "${UNINSTALLERSIGNCOMMAND}" != ""
|
||||
!uninstfinalize '${UNINSTALLERSIGNCOMMAND}'
|
||||
!endif
|
||||
|
||||
; Handle install mode, `perUser`, `perMachine` or `both`
|
||||
!if "${INSTALLMODE}" == "perMachine"
|
||||
RequestExecutionLevel admin
|
||||
!endif
|
||||
|
||||
!if "${INSTALLMODE}" == "currentUser"
|
||||
RequestExecutionLevel user
|
||||
!endif
|
||||
|
||||
!if "${INSTALLMODE}" == "both"
|
||||
!define MULTIUSER_MUI
|
||||
!define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCTNAME}"
|
||||
!define MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||
!if "${ARCH}" == "x64"
|
||||
!define MULTIUSER_USE_PROGRAMFILES64
|
||||
!else if "${ARCH}" == "arm64"
|
||||
!define MULTIUSER_USE_PROGRAMFILES64
|
||||
!endif
|
||||
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINSTKEY}"
|
||||
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "CurrentUser"
|
||||
!define MULTIUSER_INSTALLMODEPAGE_SHOWUSERNAME
|
||||
!define MULTIUSER_INSTALLMODE_FUNCTION RestorePreviousInstallLocation
|
||||
!define MULTIUSER_EXECUTIONLEVEL Highest
|
||||
!include MultiUser.nsh
|
||||
!endif
|
||||
|
||||
; Installer icon
|
||||
!if "${INSTALLERICON}" != ""
|
||||
!define MUI_ICON "${INSTALLERICON}"
|
||||
!endif
|
||||
|
||||
; Installer sidebar image
|
||||
!if "${SIDEBARIMAGE}" != ""
|
||||
!define MUI_WELCOMEFINISHPAGE_BITMAP "${SIDEBARIMAGE}"
|
||||
!endif
|
||||
|
||||
; Enable header images for installer and uninstaller pages when either image is configured.
|
||||
!if "${HEADERIMAGE}" != ""
|
||||
!define MUI_HEADERIMAGE
|
||||
!else if "${UNINSTALLERHEADERIMAGE}" != ""
|
||||
!define MUI_HEADERIMAGE
|
||||
!endif
|
||||
|
||||
; Installer header image
|
||||
!if "${HEADERIMAGE}" != ""
|
||||
!define MUI_HEADERIMAGE_BITMAP "${HEADERIMAGE}"
|
||||
!endif
|
||||
|
||||
; Uninstaller header image
|
||||
!if "${UNINSTALLERHEADERIMAGE}" != ""
|
||||
!define MUI_HEADERIMAGE_UNBITMAP "${UNINSTALLERHEADERIMAGE}"
|
||||
!endif
|
||||
|
||||
; Uninstaller icon
|
||||
!if "${UNINSTALLERICON}" != ""
|
||||
!define MUI_UNICON "${UNINSTALLERICON}"
|
||||
!endif
|
||||
|
||||
; Define registry key to store installer language
|
||||
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
|
||||
!define MUI_LANGDLL_REGISTRY_KEY "${MANUPRODUCTKEY}"
|
||||
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
|
||||
|
||||
; Installer pages, must be ordered as they appear
|
||||
; 1. Welcome Page
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
|
||||
; 2. License Page (if defined)
|
||||
!if "${LICENSE}" != ""
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||
!insertmacro MUI_PAGE_LICENSE "${LICENSE}"
|
||||
!endif
|
||||
|
||||
; 3. Install mode (if it is set to `both`)
|
||||
!if "${INSTALLMODE}" == "both"
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||
!insertmacro MULTIUSER_PAGE_INSTALLMODE
|
||||
!endif
|
||||
|
||||
; 4. Custom page to ask user if he wants to reinstall/uninstall
|
||||
; only if a previous installation was detected
|
||||
Var ReinstallPageCheck
|
||||
Page custom PageReinstall PageLeaveReinstall
|
||||
Function PageReinstall
|
||||
; Uninstall previous WiX installation if exists.
|
||||
;
|
||||
; A WiX installer stores the installation info in registry
|
||||
; using a UUID and so we have to loop through all keys under
|
||||
; `HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall`
|
||||
; and check if `DisplayName` and `Publisher` keys match ${PRODUCTNAME} and ${MANUFACTURER}
|
||||
;
|
||||
; This has a potential issue that there maybe another installation that matches
|
||||
; our ${PRODUCTNAME} and ${MANUFACTURER} but wasn't installed by our WiX installer,
|
||||
; however, this should be fine since the user will have to confirm the uninstallation
|
||||
; and they can chose to abort it if doesn't make sense.
|
||||
StrCpy $0 0
|
||||
wix_loop:
|
||||
EnumRegKey $1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $0
|
||||
StrCmp $1 "" wix_loop_done ; Exit loop if there is no more keys to loop on
|
||||
IntOp $0 $0 + 1
|
||||
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "DisplayName"
|
||||
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "Publisher"
|
||||
StrCmp "$R0$R1" "${PRODUCTNAME}${MANUFACTURER}" 0 wix_loop
|
||||
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1" "UninstallString"
|
||||
${StrCase} $R1 $R0 "L"
|
||||
${StrLoc} $R0 $R1 "msiexec" ">"
|
||||
StrCmp $R0 0 0 wix_loop_done
|
||||
StrCpy $WixMode 1
|
||||
StrCpy $R6 "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1"
|
||||
Goto compare_version
|
||||
wix_loop_done:
|
||||
|
||||
; Check if there is an existing installation, if not, abort the reinstall page
|
||||
ReadRegStr $R0 SHCTX "${UNINSTKEY}" ""
|
||||
ReadRegStr $R1 SHCTX "${UNINSTKEY}" "UninstallString"
|
||||
${IfThen} "$R0$R1" == "" ${|} Abort ${|}
|
||||
|
||||
; Compare this installar version with the existing installation
|
||||
; and modify the messages presented to the user accordingly
|
||||
compare_version:
|
||||
StrCpy $R4 "$(older)"
|
||||
${If} $WixMode = 1
|
||||
ReadRegStr $R0 HKLM "$R6" "DisplayVersion"
|
||||
${Else}
|
||||
ReadRegStr $R0 SHCTX "${UNINSTKEY}" "RuneStoneReleaseVersion"
|
||||
${If} $R0 == ""
|
||||
ReadRegStr $R0 SHCTX "${UNINSTKEY}" "DisplayVersion"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
${IfThen} $R0 == "" ${|} StrCpy $R4 "$(unknown)" ${|}
|
||||
|
||||
Push "${VERSION}"
|
||||
Push $R0
|
||||
Call RuneStoneCompareVersions
|
||||
Pop $R0
|
||||
!if "${ALLOWDOWNGRADES}" == "false"
|
||||
${If} $R0 = -1
|
||||
${IfNot} ${Silent}
|
||||
MessageBox MB_ICONSTOP "$(dontUninstallDowngrade)"
|
||||
${EndIf}
|
||||
SetErrorLevel 2
|
||||
Quit
|
||||
${EndIf}
|
||||
!endif
|
||||
; Reinstalling the same version
|
||||
${If} $R0 = 0
|
||||
StrCpy $R1 "$(alreadyInstalledLong)"
|
||||
StrCpy $R2 "$(addOrReinstall)"
|
||||
StrCpy $R3 "$(uninstallApp)"
|
||||
!insertmacro MUI_HEADER_TEXT "$(alreadyInstalled)" "$(chooseMaintenanceOption)"
|
||||
; Upgrading
|
||||
${ElseIf} $R0 = 1
|
||||
StrCpy $R1 "$(olderOrUnknownVersionInstalled)"
|
||||
StrCpy $R2 "$(addOrReinstall)"
|
||||
StrCpy $R3 "$(uninstallApp)"
|
||||
!insertmacro MUI_HEADER_TEXT "$(alreadyInstalled)" "$(choowHowToInstall)"
|
||||
; Downgrading
|
||||
${ElseIf} $R0 = -1
|
||||
StrCpy $R1 "$(newerVersionInstalled)"
|
||||
StrCpy $R2 "$(uninstallBeforeInstalling)"
|
||||
!if "${ALLOWDOWNGRADES}" == "true"
|
||||
StrCpy $R3 "$(dontUninstall)"
|
||||
!else
|
||||
StrCpy $R3 "$(dontUninstallDowngrade)"
|
||||
!endif
|
||||
!insertmacro MUI_HEADER_TEXT "$(alreadyInstalled)" "$(choowHowToInstall)"
|
||||
${Else}
|
||||
Abort
|
||||
${EndIf}
|
||||
|
||||
; Skip showing the page if passive
|
||||
;
|
||||
; Note that we don't call this earlier at the begining
|
||||
; of this function because we need to populate some variables
|
||||
; related to current installed version if detected and whether
|
||||
; we are downgrading or not.
|
||||
${If} $PassiveMode = 1
|
||||
Call PageLeaveReinstall
|
||||
${Else}
|
||||
nsDialogs::Create 1018
|
||||
Pop $R4
|
||||
${IfThen} $(^RTL) = 1 ${|} nsDialogs::SetRTL $(^RTL) ${|}
|
||||
|
||||
${NSD_CreateLabel} 0 0 100% 24u $R1
|
||||
Pop $R1
|
||||
|
||||
${NSD_CreateRadioButton} 30u 50u -30u 8u $R2
|
||||
Pop $R2
|
||||
${NSD_OnClick} $R2 PageReinstallUpdateSelection
|
||||
|
||||
${NSD_CreateRadioButton} 30u 70u -30u 8u $R3
|
||||
Pop $R3
|
||||
; Disable this radio button if downgrading and downgrades are disabled
|
||||
!if "${ALLOWDOWNGRADES}" == "false"
|
||||
${IfThen} $R0 = -1 ${|} EnableWindow $R3 0 ${|}
|
||||
!endif
|
||||
${NSD_OnClick} $R3 PageReinstallUpdateSelection
|
||||
|
||||
; Check the first radio button if this the first time
|
||||
; we enter this page or if the second button wasn't
|
||||
; selected the last time we were on this page
|
||||
${If} $ReinstallPageCheck <> 2
|
||||
SendMessage $R2 ${BM_SETCHECK} ${BST_CHECKED} 0
|
||||
${Else}
|
||||
SendMessage $R3 ${BM_SETCHECK} ${BST_CHECKED} 0
|
||||
${EndIf}
|
||||
|
||||
${NSD_SetFocus} $R2
|
||||
nsDialogs::Show
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
Function PageReinstallUpdateSelection
|
||||
${NSD_GetState} $R2 $R1
|
||||
${If} $R1 == ${BST_CHECKED}
|
||||
StrCpy $ReinstallPageCheck 1
|
||||
${Else}
|
||||
StrCpy $ReinstallPageCheck 2
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
Function PageLeaveReinstall
|
||||
${NSD_GetState} $R2 $R1
|
||||
|
||||
; If migrating from Wix, always uninstall
|
||||
${If} $WixMode = 1
|
||||
Goto reinst_uninstall
|
||||
${EndIf}
|
||||
|
||||
; In update mode, always proceeds without uninstalling
|
||||
${If} $UpdateMode = 1
|
||||
Goto reinst_done
|
||||
${EndIf}
|
||||
|
||||
; $R0 holds whether same(0)/upgrading(1)/downgrading(-1) version
|
||||
; $R1 holds the radio buttons state:
|
||||
; 1 => first choice was selected
|
||||
; 0 => second choice was selected
|
||||
${If} $R0 = 0 ; Same version, proceed
|
||||
${If} $R1 = 1 ; User chose to add/reinstall
|
||||
Goto reinst_done
|
||||
${Else} ; User chose to uninstall
|
||||
Goto reinst_uninstall
|
||||
${EndIf}
|
||||
${ElseIf} $R0 = 1 ; Upgrading
|
||||
${If} $R1 = 1
|
||||
Goto reinst_done
|
||||
${Else}
|
||||
Goto reinst_uninstall
|
||||
${EndIf}
|
||||
${ElseIf} $R0 = -1 ; Downgrading
|
||||
${If} $R1 = 1 ; User chose to uninstall
|
||||
Goto reinst_uninstall
|
||||
${Else}
|
||||
Goto reinst_done ; User chose NOT to uninstall
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
reinst_uninstall:
|
||||
HideWindow
|
||||
ClearErrors
|
||||
|
||||
${If} $WixMode = 1
|
||||
ReadRegStr $R1 HKLM "$R6" "UninstallString"
|
||||
ExecWait '$R1' $0
|
||||
${Else}
|
||||
ReadRegStr $4 SHCTX "${MANUPRODUCTKEY}" ""
|
||||
ReadRegStr $R1 SHCTX "${UNINSTKEY}" "UninstallString"
|
||||
${IfThen} $UpdateMode = 1 ${|} StrCpy $R1 "$R1 /UPDATE" ${|} ; append /UPDATE
|
||||
${IfThen} $PassiveMode = 1 ${|} StrCpy $R1 "$R1 /P" ${|} ; append /P
|
||||
StrCpy $R1 "$R1 _?=$4" ; append uninstall directory
|
||||
ExecWait '$R1' $0
|
||||
${EndIf}
|
||||
|
||||
BringToFront
|
||||
|
||||
${IfThen} ${Errors} ${|} StrCpy $0 2 ${|} ; ExecWait failed, set fake exit code
|
||||
|
||||
${If} $0 <> 0
|
||||
${OrIf} ${FileExists} "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
; User cancelled wix uninstaller? return to select un/reinstall page
|
||||
${If} $WixMode = 1
|
||||
${AndIf} $0 = 1602
|
||||
Abort
|
||||
${EndIf}
|
||||
|
||||
; User cancelled NSIS uninstaller? return to select un/reinstall page
|
||||
${If} $0 = 1
|
||||
Abort
|
||||
${EndIf}
|
||||
|
||||
; Other erros? show generic error message and return to select un/reinstall page
|
||||
MessageBox MB_ICONEXCLAMATION "$(unableToUninstall)"
|
||||
Abort
|
||||
${EndIf}
|
||||
reinst_done:
|
||||
FunctionEnd
|
||||
|
||||
; 5. Choose install directory page
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
|
||||
; 6. Start menu shortcut page
|
||||
Var AppStartMenuFolder
|
||||
!if "${STARTMENUFOLDER}" != ""
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${STARTMENUFOLDER}"
|
||||
!else
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE Skip
|
||||
!endif
|
||||
!insertmacro MUI_PAGE_STARTMENU Application $AppStartMenuFolder
|
||||
|
||||
; 7. Installation page
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
|
||||
; 8. Finish page
|
||||
;
|
||||
; Don't auto jump to finish page after installation page,
|
||||
; because the installation page has useful info that can be used debug any issues with the installer.
|
||||
!define MUI_FINISHPAGE_NOAUTOCLOSE
|
||||
; Use show readme button in the finish page as a button create a desktop shortcut
|
||||
!define MUI_FINISHPAGE_SHOWREADME
|
||||
!define MUI_FINISHPAGE_SHOWREADME_TEXT "$(createDesktop)"
|
||||
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateOrUpdateDesktopShortcut
|
||||
; Show run app after installation.
|
||||
!define MUI_FINISHPAGE_RUN
|
||||
!define MUI_FINISHPAGE_RUN_FUNCTION RunMainBinary
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
|
||||
Function RunMainBinary
|
||||
nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" ""
|
||||
FunctionEnd
|
||||
|
||||
; Uninstaller Pages
|
||||
; 1. Confirm uninstall page
|
||||
Var DeleteAppDataCheckbox
|
||||
Var DeleteAppDataCheckboxState
|
||||
!define /ifndef WS_EX_LAYOUTRTL 0x00400000
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ConfirmShow
|
||||
Function un.ConfirmShow ; Add add a `Delete app data` check box
|
||||
; $1 inner dialog HWND
|
||||
; $2 window DPI
|
||||
; $3 style
|
||||
; $4 x
|
||||
; $5 y
|
||||
; $6 width
|
||||
; $7 height
|
||||
FindWindow $1 "#32770" "" $HWNDPARENT ; Find inner dialog
|
||||
System::Call "user32::GetDpiForWindow(p r1) i .r2"
|
||||
${If} $(^RTL) = 1
|
||||
StrCpy $3 "${__NSD_CheckBox_EXSTYLE} | ${WS_EX_LAYOUTRTL}"
|
||||
IntOp $4 50 * $2
|
||||
${Else}
|
||||
StrCpy $3 "${__NSD_CheckBox_EXSTYLE}"
|
||||
IntOp $4 0 * $2
|
||||
${EndIf}
|
||||
IntOp $5 100 * $2
|
||||
IntOp $6 400 * $2
|
||||
IntOp $7 25 * $2
|
||||
IntOp $4 $4 / 96
|
||||
IntOp $5 $5 / 96
|
||||
IntOp $6 $6 / 96
|
||||
IntOp $7 $7 / 96
|
||||
System::Call 'user32::CreateWindowEx(i r3, w "${__NSD_CheckBox_CLASS}", w "$(deleteAppData)", i ${__NSD_CheckBox_STYLE}, i r4, i r5, i r6, i r7, p r1, i0, i0, i0) i .s'
|
||||
Pop $DeleteAppDataCheckbox
|
||||
SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $1
|
||||
SendMessage $DeleteAppDataCheckbox ${WM_SETFONT} $1 1
|
||||
FunctionEnd
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.ConfirmLeave
|
||||
Function un.ConfirmLeave
|
||||
SendMessage $DeleteAppDataCheckbox ${BM_GETCHECK} 0 0 $DeleteAppDataCheckboxState
|
||||
FunctionEnd
|
||||
!define MUI_PAGE_CUSTOMFUNCTION_PRE un.SkipIfPassive
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
|
||||
; 2. Uninstalling Page
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
|
||||
;Languages
|
||||
{{#each languages}}
|
||||
!insertmacro MUI_LANGUAGE "{{this}}"
|
||||
{{/each}}
|
||||
!insertmacro MUI_RESERVEFILE_LANGDLL
|
||||
{{#each language_files}}
|
||||
!include "{{this}}"
|
||||
{{/each}}
|
||||
|
||||
Function .onInit
|
||||
${GetOptions} $CMDLINE "/P" $PassiveMode
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $PassiveMode 1
|
||||
${EndIf}
|
||||
|
||||
${GetOptions} $CMDLINE "/NS" $NoShortcutMode
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $NoShortcutMode 1
|
||||
${EndIf}
|
||||
|
||||
${GetOptions} $CMDLINE "/UPDATE" $UpdateMode
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $UpdateMode 1
|
||||
${EndIf}
|
||||
|
||||
!if "${DISPLAYLANGUAGESELECTOR}" == "true"
|
||||
!insertmacro MUI_LANGDLL_DISPLAY
|
||||
!endif
|
||||
|
||||
!insertmacro SetContext
|
||||
|
||||
${If} $INSTDIR == "${PLACEHOLDER_INSTALL_DIR}"
|
||||
; Set default install location
|
||||
!if "${INSTALLMODE}" == "perMachine"
|
||||
${If} ${RunningX64}
|
||||
!if "${ARCH}" == "x64"
|
||||
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCTNAME}"
|
||||
!else if "${ARCH}" == "arm64"
|
||||
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCTNAME}"
|
||||
!else
|
||||
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCTNAME}"
|
||||
!endif
|
||||
${Else}
|
||||
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCTNAME}"
|
||||
${EndIf}
|
||||
!else if "${INSTALLMODE}" == "currentUser"
|
||||
StrCpy $INSTDIR "$LOCALAPPDATA\${PRODUCTNAME}"
|
||||
!endif
|
||||
|
||||
Call RestorePreviousInstallLocation
|
||||
${EndIf}
|
||||
|
||||
|
||||
!if "${INSTALLMODE}" == "both"
|
||||
!insertmacro MULTIUSER_INIT
|
||||
!endif
|
||||
FunctionEnd
|
||||
|
||||
|
||||
Section EarlyChecks
|
||||
; Abort silent installer if downgrades is disabled
|
||||
!if "${ALLOWDOWNGRADES}" == "false"
|
||||
${If} ${Silent}
|
||||
; If downgrading
|
||||
${If} $R0 = -1
|
||||
System::Call 'kernel32::AttachConsole(i -1)i.r0'
|
||||
${If} $0 <> 0
|
||||
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
|
||||
System::call 'kernel32::SetConsoleTextAttribute(i r0, i 0x0004)' ; set red color
|
||||
FileWrite $0 "$(silentDowngrades)"
|
||||
${EndIf}
|
||||
Abort
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
!endif
|
||||
|
||||
SectionEnd
|
||||
|
||||
Section WebView2
|
||||
; Check if Webview2 is already installed and skip this section
|
||||
${If} ${RunningX64}
|
||||
ReadRegStr $4 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
|
||||
${Else}
|
||||
ReadRegStr $4 HKLM "SOFTWARE\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
|
||||
${EndIf}
|
||||
${If} $4 == ""
|
||||
ReadRegStr $4 HKCU "SOFTWARE\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
|
||||
${EndIf}
|
||||
|
||||
${If} $4 == ""
|
||||
; Webview2 installation
|
||||
;
|
||||
; Skip if updating
|
||||
${If} $UpdateMode <> 1
|
||||
!if "${INSTALLWEBVIEW2MODE}" == "downloadBootstrapper"
|
||||
Delete "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||
DetailPrint "$(webview2Downloading)"
|
||||
NSISdl::download "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||
Pop $0
|
||||
${If} $0 == "success"
|
||||
DetailPrint "$(webview2DownloadSuccess)"
|
||||
${Else}
|
||||
DetailPrint "$(webview2DownloadError)"
|
||||
Abort "$(webview2AbortError)"
|
||||
${EndIf}
|
||||
StrCpy $6 "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||
Goto install_webview2
|
||||
!endif
|
||||
|
||||
!if "${INSTALLWEBVIEW2MODE}" == "embedBootstrapper"
|
||||
Delete "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||
File "/oname=$TEMP\MicrosoftEdgeWebview2Setup.exe" "${WEBVIEW2BOOTSTRAPPERPATH}"
|
||||
DetailPrint "$(installingWebview2)"
|
||||
StrCpy $6 "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||
Goto install_webview2
|
||||
!endif
|
||||
|
||||
!if "${INSTALLWEBVIEW2MODE}" == "offlineInstaller"
|
||||
Delete "$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
|
||||
File "/oname=$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" "${WEBVIEW2INSTALLERPATH}"
|
||||
DetailPrint "$(installingWebview2)"
|
||||
StrCpy $6 "$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
|
||||
Goto install_webview2
|
||||
!endif
|
||||
|
||||
Goto webview2_done
|
||||
|
||||
install_webview2:
|
||||
DetailPrint "$(installingWebview2)"
|
||||
; $6 holds the path to the webview2 installer
|
||||
ExecWait "$6 ${WEBVIEW2INSTALLERARGS} /install" $1
|
||||
${If} $1 = 0
|
||||
DetailPrint "$(webview2InstallSuccess)"
|
||||
${Else}
|
||||
DetailPrint "$(webview2InstallError)"
|
||||
Abort "$(webview2AbortError)"
|
||||
${EndIf}
|
||||
webview2_done:
|
||||
${EndIf}
|
||||
${Else}
|
||||
!if "${MINIMUMWEBVIEW2VERSION}" != ""
|
||||
${VersionCompare} "${MINIMUMWEBVIEW2VERSION}" "$4" $R0
|
||||
${If} $R0 = 1
|
||||
update_webview:
|
||||
DetailPrint "$(installingWebview2)"
|
||||
${If} ${RunningX64}
|
||||
ReadRegStr $R1 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" "path"
|
||||
${Else}
|
||||
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\EdgeUpdate" "path"
|
||||
${EndIf}
|
||||
${If} $R1 == ""
|
||||
ReadRegStr $R1 HKCU "SOFTWARE\Microsoft\EdgeUpdate" "path"
|
||||
${EndIf}
|
||||
${If} $R1 != ""
|
||||
; Chromium updater docs: https://source.chromium.org/chromium/chromium/src/+/main:docs/updater/user_manual.md
|
||||
; Modified from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView\ModifyPath"
|
||||
ExecWait `"$R1" /install appguid=${WEBVIEW2APPGUID}&needsadmin=true` $1
|
||||
${If} $1 = 0
|
||||
DetailPrint "$(webview2InstallSuccess)"
|
||||
${Else}
|
||||
MessageBox MB_ICONEXCLAMATION|MB_ABORTRETRYIGNORE "$(webview2InstallError)" IDIGNORE ignore IDRETRY update_webview
|
||||
Quit
|
||||
ignore:
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
!endif
|
||||
${EndIf}
|
||||
SectionEnd
|
||||
|
||||
Section Install
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
!ifmacrodef NSIS_HOOK_PREINSTALL
|
||||
!insertmacro NSIS_HOOK_PREINSTALL
|
||||
!endif
|
||||
|
||||
!insertmacro CheckIfAppIsRunning "${MAINBINARYNAME}.exe" "${PRODUCTNAME}"
|
||||
|
||||
; Copy main executable
|
||||
File "${MAINBINARYSRCPATH}"
|
||||
|
||||
; Copy resources
|
||||
{{#each resources_dirs}}
|
||||
CreateDirectory "$INSTDIR\\{{this}}"
|
||||
{{/each}}
|
||||
{{#each resources}}
|
||||
File /a "/oname={{this.[1]}}" "{{no-escape @key}}"
|
||||
{{/each}}
|
||||
|
||||
; Copy external binaries
|
||||
{{#each binaries}}
|
||||
File /a "/oname={{this}}" "{{no-escape @key}}"
|
||||
{{/each}}
|
||||
|
||||
; Create file associations
|
||||
{{#each file_associations as |association| ~}}
|
||||
{{#each association.ext as |ext| ~}}
|
||||
!insertmacro APP_ASSOCIATE "{{ext}}" "{{or association.name ext}}" "{{association-description association.description ext}}" "$INSTDIR\${MAINBINARYNAME}.exe,0" "Open with ${PRODUCTNAME}" "$INSTDIR\${MAINBINARYNAME}.exe $\"%1$\""
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
|
||||
; Register deep links
|
||||
{{#each deep_link_protocols as |protocol| ~}}
|
||||
WriteRegStr SHCTX "Software\Classes\\{{protocol}}" "URL Protocol" ""
|
||||
WriteRegStr SHCTX "Software\Classes\\{{protocol}}" "" "URL:${BUNDLEID} protocol"
|
||||
WriteRegStr SHCTX "Software\Classes\\{{protocol}}\DefaultIcon" "" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\",0"
|
||||
WriteRegStr SHCTX "Software\Classes\\{{protocol}}\shell\open\command" "" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\" $\"%1$\""
|
||||
{{/each}}
|
||||
|
||||
; Create uninstaller
|
||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||
|
||||
; Save $INSTDIR in registry for future installations
|
||||
WriteRegStr SHCTX "${MANUPRODUCTKEY}" "" $INSTDIR
|
||||
|
||||
!if "${INSTALLMODE}" == "both"
|
||||
; Save install mode to be selected by default for the next installation such as updating
|
||||
; or when uninstalling
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" $MultiUser.InstallMode 1
|
||||
!endif
|
||||
|
||||
; Remove old main binary if it doesn't match new main binary name
|
||||
ReadRegStr $OldMainBinaryName SHCTX "${UNINSTKEY}" "MainBinaryName"
|
||||
${If} $OldMainBinaryName != ""
|
||||
${AndIf} $OldMainBinaryName != "${MAINBINARYNAME}.exe"
|
||||
Delete "$INSTDIR\$OldMainBinaryName"
|
||||
${EndIf}
|
||||
|
||||
; Save current MAINBINARYNAME for future updates
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "MainBinaryName" "${MAINBINARYNAME}.exe"
|
||||
|
||||
; Registry information for add/remove programs
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayName" "${PRODUCTNAME}"
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayIcon" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\""
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayVersion" "${TOOLCHAINVERSION}"
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "RuneStoneReleaseVersion" "${VERSION}"
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "Publisher" "${MANUFACTURER}"
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "InstallLocation" "$\"$INSTDIR$\""
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
|
||||
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoModify" "1"
|
||||
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoRepair" "1"
|
||||
|
||||
${GetSize} "$INSTDIR" "/M=uninstall.exe /S=0K /G=0" $0 $1 $2
|
||||
IntOp $0 $0 + ${ESTIMATEDSIZE}
|
||||
IntFmt $0 "0x%08X" $0
|
||||
WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "$0"
|
||||
|
||||
!if "${HOMEPAGE}" != ""
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "URLInfoAbout" "${HOMEPAGE}"
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "URLUpdateInfo" "${HOMEPAGE}"
|
||||
WriteRegStr SHCTX "${UNINSTKEY}" "HelpLink" "${HOMEPAGE}"
|
||||
!endif
|
||||
|
||||
; Create start menu shortcut
|
||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||
Call CreateOrUpdateStartMenuShortcut
|
||||
!insertmacro MUI_STARTMENU_WRITE_END
|
||||
|
||||
; Create desktop shortcut for silent and passive installers
|
||||
; because finish page will be skipped
|
||||
${If} $PassiveMode = 1
|
||||
${OrIf} ${Silent}
|
||||
Call CreateOrUpdateDesktopShortcut
|
||||
${EndIf}
|
||||
|
||||
!ifmacrodef NSIS_HOOK_POSTINSTALL
|
||||
!insertmacro NSIS_HOOK_POSTINSTALL
|
||||
!endif
|
||||
|
||||
; Auto close this page for passive mode
|
||||
${If} $PassiveMode = 1
|
||||
SetAutoClose true
|
||||
${EndIf}
|
||||
SectionEnd
|
||||
|
||||
Function .onInstSuccess
|
||||
; Check for `/R` flag only in silent and passive installers because
|
||||
; GUI installer has a toggle for the user to (re)start the app
|
||||
${If} $PassiveMode = 1
|
||||
${OrIf} ${Silent}
|
||||
${GetOptions} $CMDLINE "/R" $R0
|
||||
${IfNot} ${Errors}
|
||||
${GetOptions} $CMDLINE "/ARGS" $R0
|
||||
nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" "$R0"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Function un.onInit
|
||||
!insertmacro SetContext
|
||||
|
||||
!if "${INSTALLMODE}" == "both"
|
||||
!insertmacro MULTIUSER_UNINIT
|
||||
!endif
|
||||
|
||||
!insertmacro MUI_UNGETLANGUAGE
|
||||
|
||||
${GetOptions} $CMDLINE "/P" $PassiveMode
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $PassiveMode 1
|
||||
${EndIf}
|
||||
|
||||
${GetOptions} $CMDLINE "/UPDATE" $UpdateMode
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $UpdateMode 1
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Section Uninstall
|
||||
|
||||
!ifmacrodef NSIS_HOOK_PREUNINSTALL
|
||||
!insertmacro NSIS_HOOK_PREUNINSTALL
|
||||
!endif
|
||||
|
||||
!insertmacro CheckIfAppIsRunning "${MAINBINARYNAME}.exe" "${PRODUCTNAME}"
|
||||
|
||||
; Delete the app directory and its content from disk
|
||||
; Copy main executable
|
||||
Delete "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
|
||||
; Delete resources
|
||||
{{#each resources}}
|
||||
Delete "$INSTDIR\\{{this.[1]}}"
|
||||
{{/each}}
|
||||
|
||||
; Delete external binaries
|
||||
{{#each binaries}}
|
||||
Delete "$INSTDIR\\{{this}}"
|
||||
{{/each}}
|
||||
|
||||
; Delete app associations
|
||||
{{#each file_associations as |association| ~}}
|
||||
{{#each association.ext as |ext| ~}}
|
||||
!insertmacro APP_UNASSOCIATE "{{ext}}" "{{or association.name ext}}"
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
|
||||
; Delete deep links
|
||||
{{#each deep_link_protocols as |protocol| ~}}
|
||||
ReadRegStr $R7 SHCTX "Software\Classes\\{{protocol}}\shell\open\command" ""
|
||||
${If} $R7 == "$\"$INSTDIR\${MAINBINARYNAME}.exe$\" $\"%1$\""
|
||||
DeleteRegKey SHCTX "Software\Classes\\{{protocol}}"
|
||||
${EndIf}
|
||||
{{/each}}
|
||||
|
||||
|
||||
; Delete uninstaller
|
||||
Delete "$INSTDIR\uninstall.exe"
|
||||
|
||||
{{#each resources_ancestors}}
|
||||
RMDir /REBOOTOK "$INSTDIR\\{{this}}"
|
||||
{{/each}}
|
||||
RMDir "$INSTDIR"
|
||||
|
||||
; Remove shortcuts if not updating
|
||||
${If} $UpdateMode <> 1
|
||||
!insertmacro DeleteAppUserModelId
|
||||
|
||||
; Remove start menu shortcut
|
||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
|
||||
!insertmacro IsShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
Pop $0
|
||||
${If} $0 = 1
|
||||
!insertmacro UnpinShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||
Delete "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||
RMDir "$SMPROGRAMS\$AppStartMenuFolder"
|
||||
${EndIf}
|
||||
!insertmacro IsShortcutTarget "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
Pop $0
|
||||
${If} $0 = 1
|
||||
!insertmacro UnpinShortcut "$SMPROGRAMS\${PRODUCTNAME}.lnk"
|
||||
Delete "$SMPROGRAMS\${PRODUCTNAME}.lnk"
|
||||
${EndIf}
|
||||
|
||||
; Remove desktop shortcuts
|
||||
!insertmacro IsShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
Pop $0
|
||||
${If} $0 = 1
|
||||
!insertmacro UnpinShortcut "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||
Delete "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
; Remove registry information for add/remove programs
|
||||
!if "${INSTALLMODE}" == "both"
|
||||
DeleteRegKey SHCTX "${UNINSTKEY}"
|
||||
!else if "${INSTALLMODE}" == "perMachine"
|
||||
DeleteRegKey HKLM "${UNINSTKEY}"
|
||||
!else
|
||||
DeleteRegKey HKCU "${UNINSTKEY}"
|
||||
!endif
|
||||
|
||||
; Removes the Autostart entry for ${PRODUCTNAME} from the HKCU Run key if it exists.
|
||||
; This ensures the program does not launch automatically after uninstallation if it exists.
|
||||
; If it doesn't exist, it does nothing.
|
||||
; We do this when not updating (to preserve the registry value on updates)
|
||||
${If} $UpdateMode <> 1
|
||||
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCTNAME}"
|
||||
${EndIf}
|
||||
|
||||
; Delete app data if the checkbox is selected
|
||||
; and if not updating
|
||||
${If} $DeleteAppDataCheckboxState = 1
|
||||
${AndIf} $UpdateMode <> 1
|
||||
; Clear the install location $INSTDIR from registry
|
||||
DeleteRegKey SHCTX "${MANUPRODUCTKEY}"
|
||||
DeleteRegKey /ifempty SHCTX "${MANUKEY}"
|
||||
|
||||
; Clear the install language from registry
|
||||
DeleteRegValue HKCU "${MANUPRODUCTKEY}" "Installer Language"
|
||||
DeleteRegKey /ifempty HKCU "${MANUPRODUCTKEY}"
|
||||
DeleteRegKey /ifempty HKCU "${MANUKEY}"
|
||||
|
||||
SetShellVarContext current
|
||||
RmDir /r "$APPDATA\${BUNDLEID}"
|
||||
RmDir /r "$LOCALAPPDATA\${BUNDLEID}"
|
||||
${EndIf}
|
||||
|
||||
!ifmacrodef NSIS_HOOK_POSTUNINSTALL
|
||||
!insertmacro NSIS_HOOK_POSTUNINSTALL
|
||||
!endif
|
||||
|
||||
; Auto close if passive mode or updating
|
||||
${If} $PassiveMode = 1
|
||||
${OrIf} $UpdateMode = 1
|
||||
SetAutoClose true
|
||||
${EndIf}
|
||||
SectionEnd
|
||||
|
||||
Function RestorePreviousInstallLocation
|
||||
ReadRegStr $4 SHCTX "${MANUPRODUCTKEY}" ""
|
||||
StrCmp $4 "" +2 0
|
||||
StrCpy $INSTDIR $4
|
||||
FunctionEnd
|
||||
|
||||
Function Skip
|
||||
Abort
|
||||
FunctionEnd
|
||||
|
||||
Function SkipIfPassive
|
||||
${IfThen} $PassiveMode = 1 ${|} Abort ${|}
|
||||
FunctionEnd
|
||||
Function un.SkipIfPassive
|
||||
${IfThen} $PassiveMode = 1 ${|} Abort ${|}
|
||||
FunctionEnd
|
||||
|
||||
Function CreateOrUpdateStartMenuShortcut
|
||||
; We used to use product name as MAINBINARYNAME
|
||||
; migrate old shortcuts to target the new MAINBINARYNAME
|
||||
StrCpy $R0 0
|
||||
|
||||
!insertmacro IsShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\$OldMainBinaryName"
|
||||
Pop $0
|
||||
${If} $0 = 1
|
||||
!insertmacro SetShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
StrCpy $R0 1
|
||||
${EndIf}
|
||||
|
||||
!insertmacro IsShortcutTarget "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\$OldMainBinaryName"
|
||||
Pop $0
|
||||
${If} $0 = 1
|
||||
!insertmacro SetShortcutTarget "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
StrCpy $R0 1
|
||||
${EndIf}
|
||||
|
||||
${If} $R0 = 1
|
||||
Return
|
||||
${EndIf}
|
||||
|
||||
; Skip creating shortcut if in update mode or no shortcut mode
|
||||
; but always create if migrating from wix
|
||||
${If} $WixMode = 0
|
||||
${If} $UpdateMode = 1
|
||||
${OrIf} $NoShortcutMode = 1
|
||||
Return
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
!if "${STARTMENUFOLDER}" != ""
|
||||
CreateDirectory "$SMPROGRAMS\$AppStartMenuFolder"
|
||||
CreateShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
!insertmacro SetLnkAppUserModelId "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||
!else
|
||||
CreateShortcut "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
!insertmacro SetLnkAppUserModelId "$SMPROGRAMS\${PRODUCTNAME}.lnk"
|
||||
!endif
|
||||
FunctionEnd
|
||||
|
||||
Function CreateOrUpdateDesktopShortcut
|
||||
; We used to use product name as MAINBINARYNAME
|
||||
; migrate old shortcuts to target the new MAINBINARYNAME
|
||||
!insertmacro IsShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\$OldMainBinaryName"
|
||||
Pop $0
|
||||
${If} $0 = 1
|
||||
!insertmacro SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
Return
|
||||
${EndIf}
|
||||
|
||||
; Skip creating shortcut if in update mode or no shortcut mode
|
||||
; but always create if migrating from wix
|
||||
${If} $WixMode = 0
|
||||
${If} $UpdateMode = 1
|
||||
${OrIf} $NoShortcutMode = 1
|
||||
Return
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
CreateShortcut "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||
!insertmacro SetLnkAppUserModelId "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||
FunctionEnd
|
||||
@@ -0,0 +1,124 @@
|
||||
; Compare numeric releases and lowercase hotfix suffixes in release order.
|
||||
; Return an empty string for an invalid version. Callers block that comparison.
|
||||
Function RuneStoneNormalizeVersion
|
||||
Exch $0
|
||||
Push $1
|
||||
Push $2
|
||||
Push $3
|
||||
Push $4
|
||||
Push $5
|
||||
Push $6
|
||||
Push $7
|
||||
Push $8
|
||||
StrCpy $1 ""
|
||||
StrCpy $2 0
|
||||
StrCpy $3 0
|
||||
StrCpy $4 0
|
||||
StrCpy $5 0
|
||||
StrCpy $6 0
|
||||
StrCpy $8 0
|
||||
rs_normalize_loop:
|
||||
StrCpy $7 $0 1 $2
|
||||
StrCmp $7 "" rs_normalize_end
|
||||
IntOp $2 $2 + 1
|
||||
StrCmp $7 "." rs_normalize_dot
|
||||
; Decimal digits cannot follow a letter suffix.
|
||||
StrCmp $7 "0" rs_normalize_digit
|
||||
StrCmp $7 "1" rs_normalize_digit
|
||||
StrCmp $7 "2" rs_normalize_digit
|
||||
StrCmp $7 "3" rs_normalize_digit
|
||||
StrCmp $7 "4" rs_normalize_digit
|
||||
StrCmp $7 "5" rs_normalize_digit
|
||||
StrCmp $7 "6" rs_normalize_digit
|
||||
StrCmp $7 "7" rs_normalize_digit
|
||||
StrCmp $7 "8" rs_normalize_digit
|
||||
StrCmp $7 "9" rs_normalize_digit
|
||||
StrCmp $3 2 0 rs_normalize_invalid
|
||||
StrCmp $4 0 rs_normalize_invalid
|
||||
StrCpy $6 1
|
||||
; Find the lowercase letter's one-based index without locale conversion.
|
||||
Push $0
|
||||
StrCpy $0 0
|
||||
rs_letter_loop:
|
||||
StrCpy $4 "abcdefghijklmnopqrstuvwxyz" 1 $0
|
||||
StrCmpS $7 $4 rs_letter_found
|
||||
IntOp $0 $0 + 1
|
||||
IntCmp $0 26 rs_letter_invalid rs_letter_loop rs_letter_invalid
|
||||
rs_letter_invalid:
|
||||
Pop $0
|
||||
Goto rs_normalize_invalid
|
||||
rs_letter_found:
|
||||
IntOp $0 $0 + 1
|
||||
IntOp $5 $5 * 26
|
||||
IntOp $5 $5 + $0
|
||||
Pop $0
|
||||
IntCmp $5 65535 rs_letter_ok rs_letter_ok rs_normalize_invalid
|
||||
rs_letter_ok:
|
||||
StrCpy $4 1
|
||||
Goto rs_normalize_loop
|
||||
rs_normalize_digit:
|
||||
StrCmp $6 0 0 rs_normalize_invalid
|
||||
IntOp $8 $8 * 10
|
||||
IntOp $8 $8 + $7
|
||||
IntCmp $8 65535 rs_digit_ok rs_digit_ok rs_normalize_invalid
|
||||
rs_digit_ok:
|
||||
StrCpy $1 "$1$7"
|
||||
IntOp $4 $4 + 1
|
||||
Goto rs_normalize_loop
|
||||
rs_normalize_dot:
|
||||
StrCmp $6 0 0 rs_normalize_invalid
|
||||
StrCmp $4 0 rs_normalize_invalid
|
||||
IntOp $3 $3 + 1
|
||||
IntCmp $3 2 rs_dot_ok rs_dot_ok rs_normalize_invalid
|
||||
rs_dot_ok:
|
||||
StrCpy $1 "$1."
|
||||
StrCpy $4 0
|
||||
StrCpy $8 0
|
||||
Goto rs_normalize_loop
|
||||
rs_normalize_end:
|
||||
StrCmp $3 2 0 rs_normalize_invalid
|
||||
StrCmp $4 0 rs_normalize_invalid
|
||||
StrCpy $0 "$1.$5"
|
||||
Goto rs_normalize_return
|
||||
rs_normalize_invalid:
|
||||
StrCpy $0 ""
|
||||
rs_normalize_return:
|
||||
Pop $8
|
||||
Pop $7
|
||||
Pop $6
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Exch $0
|
||||
FunctionEnd
|
||||
|
||||
Function RuneStoneCompareVersions
|
||||
Exch $1
|
||||
Exch
|
||||
Exch $0
|
||||
Push $2
|
||||
Push $0
|
||||
Call RuneStoneNormalizeVersion
|
||||
Pop $0
|
||||
Push $1
|
||||
Call RuneStoneNormalizeVersion
|
||||
Pop $1
|
||||
StrCmp $0 "" rs_compare_invalid
|
||||
StrCmp $1 "" rs_compare_invalid
|
||||
${VersionCompare} $0 $1 $2
|
||||
StrCmp $2 2 rs_compare_older
|
||||
StrCpy $0 $2
|
||||
Goto rs_compare_return
|
||||
rs_compare_older:
|
||||
StrCpy $0 -1
|
||||
Goto rs_compare_return
|
||||
rs_compare_invalid:
|
||||
StrCpy $0 -1
|
||||
rs_compare_return:
|
||||
Pop $2
|
||||
Exch $0
|
||||
Exch
|
||||
Pop $1
|
||||
FunctionEnd
|
||||
Reference in New Issue
Block a user