pake-cli 3.7.3 โ†’ 3.7.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
@@ -22,7 +22,7 @@ import * as psl from 'psl';
22
22
  import { InvalidArgumentError, program as program$1, Option } from 'commander';
23
23
 
24
24
  var name = "pake-cli";
25
- var version = "3.7.3";
25
+ var version = "3.7.4";
26
26
  var description = "๐Ÿคฑ๐Ÿป Turn any webpage into a desktop app with one command. ๐Ÿคฑ๐Ÿป ไธ€้”ฎๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆ่ฝป้‡ๆกŒ้ขๅบ”็”จใ€‚";
27
27
  var engines = {
28
28
  node: ">=18.0.0"
@@ -484,7 +484,7 @@ async function mergeConfig(url, options, tauriConf) {
484
484
  await fsExtra.copy(sourcePath, destPath);
485
485
  }
486
486
  }));
487
- const { width, height, fullscreen, maximize, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name = 'pake-app', resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, multiInstance, startToTray, forceInternalNavigation, zoom, minWidth, minHeight, ignoreCertificateErrors, } = options;
487
+ const { width, height, fullscreen, maximize, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name = 'pake-app', resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, multiInstance, startToTray, forceInternalNavigation, zoom, minWidth, minHeight, ignoreCertificateErrors, newWindow, } = options;
488
488
  const { platform } = process;
489
489
  const platformHideOnClose = hideOnClose ?? platform === 'darwin';
490
490
  const tauriConfWindowOptions = {
@@ -509,6 +509,7 @@ async function mergeConfig(url, options, tauriConf) {
509
509
  min_width: minWidth,
510
510
  min_height: minHeight,
511
511
  ignore_certificate_errors: ignoreCertificateErrors,
512
+ new_window: newWindow,
512
513
  };
513
514
  Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
514
515
  tauriConf.productName = name;
@@ -1925,6 +1926,7 @@ const DEFAULT_PAKE_OPTIONS = {
1925
1926
  minWidth: 0,
1926
1927
  minHeight: 0,
1927
1928
  ignoreCertificateErrors: false,
1929
+ newWindow: false,
1928
1930
  };
1929
1931
 
1930
1932
  function validateNumberInput(value) {
@@ -2075,6 +2077,9 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
2075
2077
  .addOption(new Option('--iterative-build', 'Turn on rapid build mode (app only, no dmg/deb/msi), good for debugging')
2076
2078
  .default(DEFAULT_PAKE_OPTIONS.iterativeBuild)
2077
2079
  .hideHelp())
2080
+ .addOption(new Option('--new-window', 'Allow new window for third-party login')
2081
+ .default(DEFAULT_PAKE_OPTIONS.newWindow)
2082
+ .hideHelp())
2078
2083
  .version(packageJson.version, '-v, --version')
2079
2084
  .configureHelp({
2080
2085
  sortSubcommands: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "3.7.3",
3
+ "version": "3.7.4",
4
4
  "description": "๐Ÿคฑ๐Ÿป Turn any webpage into a desktop app with one command. ๐Ÿคฑ๐Ÿป ไธ€้”ฎๆ‰“ๅŒ…็ฝ‘้กต็”Ÿๆˆ่ฝป้‡ๆกŒ้ขๅบ”็”จใ€‚",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -18,7 +18,8 @@
18
18
  "enable_drag_drop": false,
19
19
  "maximize": false,
20
20
  "start_to_tray": false,
21
- "force_internal_navigation": false
21
+ "force_internal_navigation": false,
22
+ "new_window": false
22
23
  }
23
24
  ],
24
25
  "user_agent": {
@@ -19,6 +19,7 @@ pub struct WindowConfig {
19
19
  pub title: Option<String>,
20
20
  pub enable_wasm: bool,
21
21
  pub enable_drag_drop: bool,
22
+ pub new_window: bool,
22
23
  pub start_to_tray: bool,
23
24
  #[serde(default)]
24
25
  pub force_internal_navigation: bool,
@@ -82,6 +82,11 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
82
82
  window_builder = window_builder.disable_drag_drop_handler();
83
83
  }
84
84
 
85
+ if window_config.new_window {
86
+ window_builder = window_builder
87
+ .on_new_window(move |_url, _features| tauri::webview::NewWindowResponse::Allow);
88
+ }
89
+
85
90
  // Add initialization scripts
86
91
  window_builder = window_builder
87
92
  .initialization_script(&config_script)
@@ -148,9 +153,13 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
148
153
  };
149
154
  window_builder = window_builder.title_bar_style(title_bar_style);
150
155
 
151
- if window_config.dark_mode {
152
- window_builder = window_builder.theme(Some(Theme::Dark));
153
- }
156
+ // Default to following system theme (None), only force dark when explicitly set
157
+ let theme = if window_config.dark_mode {
158
+ Some(Theme::Dark)
159
+ } else {
160
+ None // Follow system theme
161
+ };
162
+ window_builder = window_builder.theme(theme);
154
163
  }
155
164
 
156
165
  // Windows and Linux: set data_directory before proxy_url
@@ -1,124 +1,59 @@
1
1
  document.addEventListener("DOMContentLoaded", () => {
2
- // Helper: Calculate brightness from RGB color
3
- const isDarkColor = (color) => {
4
- if (!color) return false;
5
- const match = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
6
- if (!match) return false;
7
- const r = parseInt(match[1]);
8
- const g = parseInt(match[2]);
9
- const b = parseInt(match[3]);
10
- // Standard luminance formula
11
- const luminance = 0.299 * r + 0.587 * g + 0.114 * b;
12
- return luminance < 128;
13
- };
14
-
15
- // Debounce helper
16
2
  const debounce = (func, wait) => {
17
3
  let timeout;
18
- return function executedFunction(...args) {
19
- const later = () => {
20
- clearTimeout(timeout);
21
- func(...args);
22
- };
4
+ return (...args) => {
23
5
  clearTimeout(timeout);
24
- timeout = setTimeout(later, wait);
6
+ timeout = setTimeout(() => func(...args), wait);
25
7
  };
26
8
  };
27
9
 
28
- // Function to detect and send theme to Rust
29
10
  const updateTheme = () => {
30
- let mode = "light";
31
- let detected = false;
32
-
33
- // Strategy 1: Explicit DOM Class/Attribute (High Priority)
34
- // Many apps use specific classes for hard-coded themes
35
11
  const doc = document.documentElement;
36
12
  const body = document.body;
13
+ let mode = null;
37
14
 
38
- const isExplicitDark =
15
+ // Check for explicit theme classes or attributes
16
+ const isDark =
39
17
  doc.classList.contains("dark") ||
40
18
  body.classList.contains("dark") ||
41
19
  doc.getAttribute("data-theme") === "dark" ||
42
20
  body.getAttribute("data-theme") === "dark" ||
43
21
  doc.style.colorScheme === "dark";
44
22
 
45
- const isExplicitLight =
23
+ const isLight =
46
24
  doc.classList.contains("light") ||
47
25
  body.classList.contains("light") ||
48
26
  doc.getAttribute("data-theme") === "light" ||
49
27
  body.getAttribute("data-theme") === "light" ||
50
28
  doc.style.colorScheme === "light";
51
29
 
52
- if (isExplicitDark) {
53
- mode = "dark";
54
- detected = true;
55
- } else if (isExplicitLight) {
56
- mode = "light";
57
- detected = true;
58
- }
59
-
60
- // Strategy 2: Computed Background Color (Fallback & Verification)
61
- // If no explicit class is found, or to double-check, look at the actual background color.
62
- // This is useful when the site relies purely on CSS media queries without classes.
63
- if (!detected) {
64
- const bodyBg = window.getComputedStyle(document.body).backgroundColor;
65
- const htmlBg = window.getComputedStyle(
66
- document.documentElement,
67
- ).backgroundColor;
30
+ if (isDark) mode = "dark";
31
+ else if (isLight) mode = "light";
68
32
 
69
- // Check body first, then html
70
- if (bodyBg && bodyBg !== "rgba(0, 0, 0, 0)" && bodyBg !== "transparent") {
71
- mode = isDarkColor(bodyBg) ? "dark" : "light";
72
- } else if (
73
- htmlBg &&
74
- htmlBg !== "rgba(0, 0, 0, 0)" &&
75
- htmlBg !== "transparent"
76
- ) {
77
- mode = isDarkColor(htmlBg) ? "dark" : "light";
78
- } else {
79
- // Strategy 3: System Preference (Last Resort)
80
- if (
81
- window.matchMedia &&
82
- window.matchMedia("(prefers-color-scheme: dark)").matches
83
- ) {
84
- mode = "dark";
85
- }
86
- }
87
- }
88
-
89
- // Send to Rust
90
- if (window.__TAURI__ && window.__TAURI__.core) {
33
+ // Only invoke Rust command if an explicit theme override is detected
34
+ if (mode && window.__TAURI__?.core) {
91
35
  window.__TAURI__.core.invoke("update_theme_mode", { mode });
92
36
  }
93
37
  };
94
38
 
95
- // Debounced version of updateTheme
96
39
  const debouncedUpdateTheme = debounce(updateTheme, 200);
97
40
 
98
- // Initial check
99
- // Delay slightly to ensure styles are applied
100
- setTimeout(updateTheme, 100);
101
-
102
- // Watch for system theme changes
103
- window
104
- .matchMedia("(prefers-color-scheme: dark)")
105
- .addEventListener("change", updateTheme);
41
+ // Initial check with delay to allow site to render
42
+ setTimeout(updateTheme, 500);
106
43
 
107
44
  // Watch for DOM changes
108
- // We observe attributes for class changes, and also style changes just in case
109
- const observer = new MutationObserver((mutations) => {
110
- debouncedUpdateTheme();
111
- });
112
-
113
- observer.observe(document.documentElement, {
45
+ const observer = new MutationObserver(debouncedUpdateTheme);
46
+ const config = {
114
47
  attributes: true,
115
48
  attributeFilter: ["class", "data-theme", "style"],
116
49
  subtree: false,
117
- });
50
+ };
118
51
 
119
- observer.observe(document.body, {
120
- attributes: true,
121
- attributeFilter: ["class", "data-theme", "style"],
122
- subtree: false,
123
- });
52
+ observer.observe(document.documentElement, config);
53
+ observer.observe(document.body, config);
54
+
55
+ // Watch for system theme changes (though window should handle this natively now)
56
+ window
57
+ .matchMedia("(prefers-color-scheme: dark)")
58
+ .addEventListener("change", updateTheme);
124
59
  });