Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
feat: support optional Windows password-save prompts
WaveYoe12768bcf098
diff --git a/bin/defaults.ts b/bin/defaults.tsindex 4b484e53..fa0aae0a 100644--- a/bin/defaults.ts+++ b/bin/defaults.ts@@ -41,6 +41,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {installerLanguage: 'en-US',hideOnClose: undefined, // Platform-specific: true for macOS, false for othersincognito: false,+ passwordAutosave: false,wasm: false,enableDragDrop: false,bundle: true,diff --git a/bin/helpers/cli-program.ts b/bin/helpers/cli-program.tsindex 09cc1aea..ec689f63 100644--- a/bin/helpers/cli-program.ts+++ b/bin/helpers/cli-program.ts@@ -185,6 +185,14 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with.default(DEFAULT.incognito).hideHelp(),)+ .addOption(+ new Option(+ '--password-autosave',+ 'Enable native password-save prompts on Windows',+ )+ .default(DEFAULT.passwordAutosave)+ .hideHelp(),+ ).addOption(new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)').default(DEFAULT.wasm)diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.tsindex a2d58845..b7d774c1 100644--- a/bin/helpers/merge.ts+++ b/bin/helpers/merge.ts@@ -54,6 +54,7 @@ export function buildWindowConfigOverrides(disabled_web_shortcuts: options.disabledWebShortcuts,hide_on_close: platformHideOnClose,incognito: options.incognito,+ password_autosave: options.passwordAutosave,title: options.title,enable_wasm: options.wasm,enable_drag_drop: options.enableDragDrop,diff --git a/bin/types.ts b/bin/types.tsindex 8a790fa8..8e0428a6 100644--- a/bin/types.ts+++ b/bin/types.ts@@ -104,6 +104,9 @@ export interface PakeCliOptions {// Launch app in incognito/private mode, default falseincognito: boolean;+ // Enable native WebView2 password-save prompts on Windows, default false+ passwordAutosave: boolean;+// Enable WebAssembly support (Flutter Web, etc.), default falsewasm: boolean;@@ -192,6 +195,7 @@ export interface WindowConfig {activation_shortcut: string;hide_on_close: boolean;incognito: boolean;+ password_autosave: boolean;title?: string;enable_wasm: boolean;enable_drag_drop: boolean;diff --git a/dist/cli.js b/dist/cli.jsindex ba9e4079..a825ca35 100644--- a/dist/cli.js+++ b/dist/cli.js@@ -944,6 +944,7 @@ function buildWindowConfigOverrides(options, platform = asSupportedPlatform(procdisabled_web_shortcuts: options.disabledWebShortcuts,hide_on_close: platformHideOnClose,incognito: options.incognito,+ password_autosave: options.passwordAutosave,title: options.title,enable_wasm: options.wasm,enable_drag_drop: options.enableDragDrop,@@ -3536,6 +3537,7 @@ const DEFAULT_PAKE_OPTIONS = {installerLanguage: 'en-US',hideOnClose: undefined, // Platform-specific: true for macOS, false for othersincognito: false,+ passwordAutosave: false,wasm: false,enableDragDrop: false,bundle: true,@@ -3706,6 +3708,9 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with.addOption(new Option('--incognito', 'Launch app in incognito/private mode').default(DEFAULT_PAKE_OPTIONS.incognito).hideHelp())+ .addOption(new Option('--password-autosave', 'Enable native password-save prompts on Windows')+ .default(DEFAULT_PAKE_OPTIONS.passwordAutosave)+ .hideHelp()).addOption(new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)').default(DEFAULT_PAKE_OPTIONS.wasm).hideHelp())diff --git a/docs/cli-usage.md b/docs/cli-usage.mdindex d857970c..2ab2c3b1 100644--- a/docs/cli-usage.md+++ b/docs/cli-usage.md@@ -457,6 +457,14 @@ Launch the application in incognito/private browsing mode. Default is `false`. W--incognito```+#### [password-autosave]++Enable native WebView2 password-save prompts on Windows. Passwords are stored in the packaged app's own WebView2 profile and are not shared with Chrome or Edge. This option is ignored on macOS and Linux, and is disabled when `--incognito` is enabled. Default is `false`. Disabling it stops new saves and save/update prompts; existing saved passwords may still autofill, including in an InPrivate window using the same profile.++```bash+--password-autosave+```+#### [wasm]Enable WebAssembly support with cross-origin isolation headers. Required for Flutter Web applications and other web applications that use WebAssembly modules like `sqlite3.wasm`, `canvaskit.wasm`. Default is `false`.diff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.mdindex 15df9a6f..6c7c1f87 100644--- a/docs/cli-usage_CN.md+++ b/docs/cli-usage_CN.md@@ -455,6 +455,14 @@ pake https://github.com --name GitHub --show-system-tray --start-to-tray--incognito```+#### [password-autosave]++在 Windows 上启用 WebView2 原生的密码保存提示,密码保存在打包应用自己的 WebView2 配置文件中,不会与 Chrome 或 Edge 共享。默认值为 `false`,macOS 和 Linux 会忽略此选项,启用 `--incognito` 时也会关闭保存提示。关闭后不会保存新密码,也不会弹出保存或更新提示,但已有密码仍可能自动填充,包括使用同一配置文件的隐私窗口。++```bash+--password-autosave+```+#### [wasm]启用 WebAssembly 支持,添加跨域隔离头部,适用于 Flutter Web 应用以及其他使用 WebAssembly 模块(如 `sqlite3.wasm`、`canvaskit.wasm`)的 Web 应用,默认为 `false`。diff --git a/schema/pake.schema.json b/schema/pake.schema.jsonindex 12cd50e6..dea7bd84 100644--- a/schema/pake.schema.json+++ b/schema/pake.schema.json@@ -159,6 +159,11 @@"description": "Launch in incognito/private mode (no persisted cookies or storage).","default": false},+ "passwordAutosave": {+ "type": "boolean",+ "description": "Enable native WebView2 password-save prompts on Windows. Disabled in incognito mode. Uses the app's own profile; existing saved passwords may still autofill when disabled.",+ "default": false+ },"wasm": {"type": "boolean","description": "Enable WebAssembly support (Flutter Web, etc.).",diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 156a879c..426635d1 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -2587,6 +2587,7 @@ dependencies = ["tokio","webkit2gtk","webview2-com",+ "windows-core 0.61.2","windows-sys 0.61.2",]diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex c9f278ab..88c2195d 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -61,6 +61,8 @@ windows-sys = { version = "0.61.2", features = [] }# Used for native WebView2 GoBack/GoForward on error pages (no page JS).webview2-com = "0.38"+# The generated WebView2 interfaces use this trait for COM interface casts.+windows-core = "0.61.2"[features]# this feature is used for development builds from development clidiff --git a/src-tauri/pake.json b/src-tauri/pake.jsonindex 28568487..3d6d3eac 100644--- a/src-tauri/pake.json+++ b/src-tauri/pake.json@@ -15,6 +15,7 @@"disabled_web_shortcuts": false,"hide_on_close": true,"incognito": false,+ "password_autosave": false,"enable_wasm": false,"enable_drag_drop": false,"maximize": false,diff --git a/src-tauri/src/app/config.rs b/src-tauri/src/app/config.rsindex fa69ab0e..e0a65ab9 100644--- a/src-tauri/src/app/config.rs+++ b/src-tauri/src/app/config.rs@@ -22,6 +22,8 @@ pub struct WindowConfig {pub activation_shortcut: String,pub hide_on_close: bool,pub incognito: bool,+ #[serde(default)]+ pub password_autosave: bool,pub title: Option<String>,pub enable_wasm: bool,pub enable_drag_drop: bool,@@ -48,6 +50,13 @@ fn default_zoom() -> u32 {100}+#[cfg(any(windows, test))]+impl WindowConfig {+ pub fn password_autosave_enabled(&self) -> bool {+ self.password_autosave && !self.incognito+ }+}+#[derive(Clone, Debug, Serialize, Deserialize)]pub struct PlatformSpecific<T> {pub macos: T,@@ -171,6 +180,23 @@ mod tests {config}+ #[test]+ fn password_autosave_is_opt_in_and_disabled_in_private_windows() {+ let mut window = config_for("https://example.com").windows.remove(0);+ for enabled in [false, true] {+ for incognito in [false, true] {+ window.password_autosave = enabled;+ window.incognito = incognito;+ assert_eq!(window.password_autosave_enabled(), enabled && !incognito);+ }+ }+ let mut legacy = serde_json::to_value(window).unwrap();+ legacy.as_object_mut().unwrap().remove("password_autosave");+ let legacy: WindowConfig = serde_json::from_value(legacy).unwrap();+ assert!(!legacy.password_autosave);+ assert!(!legacy.password_autosave_enabled());+ }+fn resolve(config: &PakeConfig) -> Resolved {let manifest: BTreeMap<String, Manifest> = serde_json::from_str(include_str!(concat!(env!("OUT_DIR"),diff --git a/src-tauri/src/app/navigation.rs b/src-tauri/src/app/navigation.rsindex ab9bb23b..71da1a7c 100644--- a/src-tauri/src/app/navigation.rs+++ b/src-tauri/src/app/navigation.rs@@ -31,6 +31,29 @@ pub fn history_step(window: &WebviewWindow, back: bool) {}}+/// Apply the password-save prompt setting, including explicit opt-out.+///+/// This deliberately configures the app's own WebView2 profile; it does not+/// access or share credentials with a Microsoft Edge profile.+#[cfg(windows)]+pub fn set_password_autosave(webview: &tauri::webview::PlatformWebview, enabled: bool) {+ use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2Settings4;+ use windows_core::Interface;++ let controller = webview.controller();+ let result = unsafe {+ controller+ .CoreWebView2()+ .and_then(|core| core.Settings())+ .and_then(|settings| settings.cast::<ICoreWebView2Settings4>())+ .and_then(|settings| settings.SetIsPasswordAutosaveEnabled(enabled))+ };++ if let Err(error) = result {+ eprintln!("[Pake] Failed to configure WebView2 password autosave: {error}");+ }+}+#[cfg(target_os = "macos")]fn history_step_platform(webview: &tauri::webview::PlatformWebview, back: bool) {use objc2::msg_send;diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rsindex b8d0c767..b83187bc 100644--- a/src-tauri/src/app/window.rs+++ b/src-tauri/src/app/window.rs@@ -1,4 +1,6 @@use crate::app::config::PakeConfig;+#[cfg(target_os = "windows")]+use crate::app::navigation::set_password_autosave;use crate::util::{check_file_or_append, get_data_dir, get_download_dir, get_download_message_with_lang,sanitize_download_filename, show_toast, MessageType,@@ -818,6 +820,16 @@ fn build_window(let window = window_builder.build()?;+ #[cfg(target_os = "windows")]+ {+ let password_autosave = window_config.password_autosave_enabled();+ if let Err(error) = window.with_webview(move |webview| {+ set_password_autosave(&webview, password_autosave);+ }) {+ eprintln!("[Pake] Failed to access WebView2 for password autosave: {error}");+ }+ }+// The tab bar's + button exists only while some window class answers// `newWindowForTab:`. Install it for every tabbing window, the main one// included: its tab bar is the one the user sees first.diff --git a/tests/unit/__snapshots__/merge-window-options.test.ts.snap b/tests/unit/__snapshots__/merge-window-options.test.ts.snapindex 0d65e2b7..77f7836b 100644--- a/tests/unit/__snapshots__/merge-window-options.test.ts.snap+++ b/tests/unit/__snapshots__/merge-window-options.test.ts.snap@@ -22,6 +22,7 @@ exports[`buildWindowConfigOverrides > matches the default snapshot on Linux 1`]"min_height": 0,"min_width": 0,"new_window": false,+ "password_autosave": false,"resizable": true,"start_to_tray": false,"title": undefined,@@ -52,6 +53,7 @@ exports[`buildWindowConfigOverrides > matches the default snapshot on Windows 1`"min_height": 0,"min_width": 0,"new_window": false,+ "password_autosave": false,"resizable": true,"start_to_tray": false,"title": undefined,@@ -82,6 +84,7 @@ exports[`buildWindowConfigOverrides > matches the default snapshot on macOS 1`]"min_height": 0,"min_width": 0,"new_window": false,+ "password_autosave": false,"resizable": true,"start_to_tray": false,"title": undefined,diff --git a/tests/unit/cli-options.test.ts b/tests/unit/cli-options.test.tsindex e3672164..32104ace 100644--- a/tests/unit/cli-options.test.ts+++ b/tests/unit/cli-options.test.ts@@ -40,6 +40,15 @@ describe('CLI options', () => {expect(option?.optional).toBe(false);});+ it('registers password autosave as a hidden Windows opt-in', () => {+ const option = program.options.find(+ (item) => item.long === '--password-autosave',+ );+ expect(option?.defaultValue).toBe(false);+ expect(option?.hidden).toBe(true);+ expect(option?.required).toBe(false);+ });+it('exposes --internal-url-regex option', () => {const option = program.options.find((item) => item.long === '--internal-url-regex',diff --git a/tests/unit/config-file.test.ts b/tests/unit/config-file.test.tsindex bb52775c..247cb341 100644--- a/tests/unit/config-file.test.ts+++ b/tests/unit/config-file.test.ts@@ -100,6 +100,15 @@ describe('loadConfigFile', () => {expect(loaded.options.downloadDir).toBe('~/Documents/My App');});+ it.each([false, true])(+ 'loads passwordAutosave=%s from config',+ async (enabled) => {+ const configPath = await writeConfig({ passwordAutosave: enabled });+ const loaded = await loadConfigFile(configPath, validKeys);+ expect(loaded.options.passwordAutosave).toBe(enabled);+ },+ );+it('rejects a missing file with INVALID_INPUT', async () => {const missing = path.join(tmpDir, 'nope.json');await expect(loadConfigFile(missing, validKeys)).rejects.toMatchObject({diff --git a/tests/unit/merge-window-options.test.ts b/tests/unit/merge-window-options.test.tsindex 8f094b21..28d7c6e5 100644--- a/tests/unit/merge-window-options.test.ts+++ b/tests/unit/merge-window-options.test.ts@@ -12,6 +12,17 @@ function makeOptions(overrides: Partial<PakeAppOptions> = {}): PakeAppOptions {}describe('buildWindowConfigOverrides', () => {+ it.each([false, true])(+ 'forwards password autosave=%s to native config',+ (enabled) => {+ expect(+ buildWindowConfigOverrides(+ makeOptions({ passwordAutosave: enabled }),+ 'win32',+ ).password_autosave,+ ).toBe(enabled);+ },+ );it('matches the default snapshot on macOS', () => {const result = buildWindowConfigOverrides(makeOptions(), 'darwin');expect(result).toMatchSnapshot();diff --git a/tests/unit/password-autosave.test.ts b/tests/unit/password-autosave.test.tsnew file mode 100644index 00000000..027bb897--- /dev/null+++ b/tests/unit/password-autosave.test.ts@@ -0,0 +1,25 @@+import fs from 'node:fs';+import { describe, expect, it } from 'vitest';++describe('Windows password autosave configuration', () => {+ it('applies both enabled and disabled settings to each Windows webview', () => {+ const window = fs.readFileSync('src-tauri/src/app/window.rs', 'utf8');+ expect(window).toMatch(+ /let password_autosave = window_config\.password_autosave_enabled\(\);/,+ );+ expect(window).toMatch(+ /set_password_autosave\(&webview, password_autosave\);/,+ );+ expect(window).not.toMatch(/if window_config\.password_autosave/);+ });++ it('uses the older supported settings interface without changing ordinary autofill', () => {+ const navigation = fs.readFileSync(+ 'src-tauri/src/app/navigation.rs',+ 'utf8',+ );+ expect(navigation).toMatch(/\.cast::<ICoreWebView2Settings4>\(\)/);+ expect(navigation).toMatch(/\.SetIsPasswordAutosaveEnabled\(enabled\)/);+ expect(navigation).not.toContain('SetIsGeneralAutofillEnabled');+ });+});