pake-cli 3.16.3 โ†’ 3.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ import * as psl from 'psl';
19
19
  import { InvalidArgumentError, program as program$1, Option } from 'commander';
20
20
 
21
21
  var name = "pake-cli";
22
- var version = "3.16.3";
22
+ var version = "3.16.4";
23
23
  var description = "๐Ÿคฑ๐Ÿป Turn any webpage into a desktop app with one command. ๐Ÿคฑ๐Ÿป ไธ€้”ฎๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆ่ฝป้‡ๆกŒ้ขๅบ”็”จใ€‚";
24
24
  var engines = {
25
25
  node: ">=20.9.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "3.16.3",
3
+ "version": "3.16.4",
4
4
  "description": "๐Ÿคฑ๐Ÿป Turn any webpage into a desktop app with one command. ๐Ÿคฑ๐Ÿป ไธ€้”ฎๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆ่ฝป้‡ๆกŒ้ขๅบ”็”จใ€‚",
5
5
  "engines": {
6
6
  "node": ">=20.9.0"
@@ -2564,7 +2564,7 @@ dependencies = [
2564
2564
 
2565
2565
  [[package]]
2566
2566
  name = "pake"
2567
- version = "3.16.3"
2567
+ version = "3.16.4"
2568
2568
  dependencies = [
2569
2569
  "block2",
2570
2570
  "dispatch",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "pake"
3
- version = "3.16.3"
3
+ version = "3.16.4"
4
4
  description = "๐Ÿคฑ๐Ÿป Turn any webpage into a desktop app with Rust."
5
5
  authors = ["Tw93"]
6
6
  license = "GPL-3.0-or-later"
@@ -405,6 +405,27 @@ fn build_window(
405
405
  ))
406
406
  })?;
407
407
 
408
+ let restored_url = if label == "pake"
409
+ && window_config.url_type == "web"
410
+ && !window_config.incognito
411
+ {
412
+ match app.path().app_data_dir() {
413
+ Ok(directory) => match crate::util::read_last_url(&directory.join("last-url.txt")) {
414
+ Ok(url) => url,
415
+ Err(error) => {
416
+ eprintln!("[Pake] Could not read the last URL: {error}");
417
+ None
418
+ }
419
+ },
420
+ Err(error) => {
421
+ eprintln!("[Pake] Could not locate the last URL: {error}");
422
+ None
423
+ }
424
+ }
425
+ } else {
426
+ None
427
+ };
428
+
408
429
  // On macOS both HTTP Basic auth and certificate bypass use the same
409
430
  // navigation-delegate proxy. Start on a neutral page so the proxy is in
410
431
  // place before the target can issue its first authentication challenge.
@@ -413,11 +434,15 @@ fn build_window(
413
434
  && window_config.url_type == "web"
414
435
  && (config.basic_auth || window_config.ignore_certificate_errors)
415
436
  {
416
- Url::parse(&window_config.url).ok()
437
+ restored_url
438
+ .clone()
439
+ .or_else(|| Url::parse(&window_config.url).ok())
417
440
  } else {
418
441
  None
419
442
  };
420
443
 
444
+ let url = restored_url.map(WebviewUrl::External).unwrap_or(url);
445
+
421
446
  // The delegate must be installed before the first TLS challenge. Start on
422
447
  // a neutral page, then navigate from the with_webview callback below.
423
448
  #[cfg(target_os = "macos")]
@@ -821,6 +846,20 @@ fn build_window(
821
846
  Ok(window)
822
847
  }
823
848
 
849
+ pub fn save_last_url(app: &AppHandle) {
850
+ let Some(window) = app.get_webview_window("pake") else {
851
+ return;
852
+ };
853
+ let result = (|| -> Result<(), Box<dyn std::error::Error>> {
854
+ let path = app.path().app_data_dir()?.join("last-url.txt");
855
+ crate::util::write_last_url(&path, &window.url()?)?;
856
+ Ok(())
857
+ })();
858
+ if let Err(error) = result {
859
+ eprintln!("[Pake] Could not save the last URL: {error}");
860
+ }
861
+ }
862
+
824
863
  #[cfg(all(test, target_os = "windows"))]
825
864
  mod proxy_arg_tests {
826
865
  use super::*;
@@ -32,8 +32,8 @@ use app::{
32
32
  },
33
33
  setup::{set_global_shortcut, set_system_tray},
34
34
  window::{
35
- open_additional_window_safe, reapply_window_icon, reveal_built_window, set_window,
36
- MultiWindowState,
35
+ open_additional_window_safe, reapply_window_icon, reveal_built_window, save_last_url,
36
+ set_window, MultiWindowState,
37
37
  },
38
38
  };
39
39
  use util::get_pake_config;
@@ -201,6 +201,8 @@ pub fn run_app() {
201
201
 
202
202
  let show_system_tray = pake_config.show_system_tray();
203
203
  let hide_on_close = pake_config.windows[0].hide_on_close;
204
+ let remember_url =
205
+ pake_config.windows[0].url_type == "web" && !pake_config.windows[0].incognito;
204
206
  let activation_shortcut = pake_config.windows[0].activation_shortcut.clone();
205
207
  let init_fullscreen = pake_config.windows[0].fullscreen;
206
208
  let start_to_tray = pake_config.windows[0].start_to_tray && show_system_tray; // Only valid when tray is enabled
@@ -357,6 +359,9 @@ pub fn run_app() {
357
359
  })
358
360
  .on_window_event(move |_window, _event| {
359
361
  if let tauri::WindowEvent::CloseRequested { api, .. } = _event {
362
+ if remember_url && _window.label() == "pake" {
363
+ save_last_url(_window.app_handle());
364
+ }
360
365
  if hide_on_close && _window.label() == "pake" {
361
366
  // User dismissed the window; do not let startup reveal reopen it.
362
367
  cancel_startup_reveal(&close_revealed);
@@ -395,6 +400,9 @@ pub fn run_app() {
395
400
  std::process::exit(1);
396
401
  })
397
402
  .run(move |_app, _event| {
403
+ if remember_url && matches!(&_event, tauri::RunEvent::Exit) {
404
+ save_last_url(_app);
405
+ }
398
406
  // Handle macOS dock icon click to reopen hidden window
399
407
  #[cfg(target_os = "macos")]
400
408
  if let tauri::RunEvent::Reopen {
@@ -48,6 +48,26 @@ pub fn get_data_dir(app: &AppHandle, package_name: String) -> std::io::Result<Pa
48
48
  Ok(data_dir)
49
49
  }
50
50
 
51
+ pub fn read_last_url(path: &Path) -> std::io::Result<Option<tauri::Url>> {
52
+ match std::fs::read_to_string(path) {
53
+ Ok(value) => Ok(tauri::Url::parse(&value)
54
+ .ok()
55
+ .filter(|url| matches!(url.scheme(), "http" | "https"))),
56
+ Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(None),
57
+ Err(error) => Err(error),
58
+ }
59
+ }
60
+
61
+ pub fn write_last_url(path: &Path, url: &tauri::Url) -> std::io::Result<()> {
62
+ if matches!(url.scheme(), "http" | "https") {
63
+ if let Some(parent) = path.parent() {
64
+ std::fs::create_dir_all(parent)?;
65
+ }
66
+ std::fs::write(path, url.as_str())?;
67
+ }
68
+ Ok(())
69
+ }
70
+
51
71
  /// Both native and IPC downloads use the trusted, packaged configuration.
52
72
  pub fn get_download_dir(app: &AppHandle) -> Result<PathBuf, String> {
53
73
  let state = app
@@ -257,6 +277,25 @@ mod tests {
257
277
  dir
258
278
  }
259
279
 
280
+ #[test]
281
+ fn last_url_round_trip_preserves_full_address() {
282
+ let path = temp_path("state/last-url.txt");
283
+ assert_eq!(read_last_url(&path).unwrap(), None);
284
+ for address in [
285
+ "https://acme.example/projects/42?view=board#activity",
286
+ "https://login.example/callback?code=example#result",
287
+ ] {
288
+ let url = tauri::Url::parse(address).unwrap();
289
+ write_last_url(&path, &url).unwrap();
290
+ assert_eq!(read_last_url(&path).unwrap(), Some(url));
291
+ }
292
+ write_last_url(&path, &tauri::Url::parse("about:blank").unwrap()).unwrap();
293
+ assert!(read_last_url(&path).unwrap().is_some());
294
+ std::fs::write(&path, "invalid URL").unwrap();
295
+ assert_eq!(read_last_url(&path).unwrap(), None);
296
+ fs::remove_dir_all(path.parent().unwrap().parent().unwrap()).unwrap();
297
+ }
298
+
260
299
  #[test]
261
300
  fn expand_download_dir_preserves_absolute_paths_without_home() {
262
301
  let absolute = temp_path("My Downloads");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "productName": "Weekly",
3
3
  "identifier": "com.pake.weekly",
4
- "version": "3.16.3",
4
+ "version": "3.16.4",
5
5
  "app": {
6
6
  "withGlobalTauri": true,
7
7
  "trayIcon": {