akanjs 3.3.0 → 3.4.0-rc.0
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/common/PipelinePlanSchema.ts +31 -7
- package/common/index.ts +6 -0
- package/common/pipelinePlan.ts +31 -5
- package/index.ts +7 -5
- package/package.json +1 -1
- package/pipelineConfig.ts +25 -2
- package/service/agentLoop/agentLoop.ts +19 -12
- package/service/predefinedAdaptor/anthropicTools.ts +8 -2
- package/types/common/index.d.ts +1 -1
- package/types/common/pipelinePlan.d.ts +35 -6
- package/types/index.d.ts +7 -5
- package/types/pipelineConfig.d.ts +20 -3
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/service/predefinedAdaptor/anthropicTools.d.ts +1 -0
- package/types/vendor/@akanjs/native/packages/cli/src/api-updates.d.ts +149 -0
- package/types/vendor/@akanjs/native/packages/cli/src/api.d.ts +16 -162
- package/types/vendor/@akanjs/native/packages/cli/src/config.d.ts +3 -2
- package/types/vendor/@akanjs/native/packages/cli/src/lib/api-task.d.ts +79 -0
- package/types/vendor/@akanjs/native/packages/cli/src/lib/prepare.d.ts +1 -1
- package/types/vendor/@akanjs/native/packages/cli/src/lib/publish.d.ts +17 -5
- package/types/vendor/@akanjs/native/packages/cli/src/lib/updates.d.ts +29 -2
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.d.ts +36 -0
- package/types/vendor/@akanjs/native/packages/cli/src/platforms/linux-install.d.ts +15 -0
- package/types/vendor/@akanjs/native/packages/core/src/kernel.d.ts +16 -5
- package/types/vendor/@akanjs/native/packages/desktop/src/commands.d.ts +81 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/deeplinks.d.ts +5 -1
- package/types/vendor/@akanjs/native/packages/desktop/src/dispatcher.d.ts +3 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/lifecycle.d.ts +8 -1
- package/types/vendor/@akanjs/native/packages/desktop/src/plugin.d.ts +21 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/server.d.ts +1 -0
- package/types/vendor/@akanjs/native/plugins/updates/src/desktop.d.ts +4 -4
- package/types/vendor/@akanjs/native/plugins/updates/src/reports.d.ts +49 -0
- package/types/vendor/@akanjs/native/plugins/updates/src/signer.d.ts +21 -0
- package/types/vendor/@akanjs/native/plugins/window/src/index.d.ts +55 -3
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +209 -54
- package/vendor/@akanjs/native/packages/cli/src/api-updates.ts +332 -0
- package/vendor/@akanjs/native/packages/cli/src/api.ts +67 -419
- package/vendor/@akanjs/native/packages/cli/src/commands/build.ts +4 -1
- package/vendor/@akanjs/native/packages/cli/src/config.ts +3 -2
- package/vendor/@akanjs/native/packages/cli/src/lib/api-task.ts +223 -0
- package/vendor/@akanjs/native/packages/cli/src/lib/prepare.ts +2 -7
- package/vendor/@akanjs/native/packages/cli/src/lib/publish.ts +164 -19
- package/vendor/@akanjs/native/packages/cli/src/lib/updates.ts +90 -3
- package/vendor/@akanjs/native/packages/cli/src/platforms/desktop-update.ts +195 -43
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux-appimage.ts +1 -1
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux-install.ts +206 -0
- package/vendor/@akanjs/native/packages/cli/src/platforms/linux.ts +5 -1
- package/vendor/@akanjs/native/packages/core/src/kernel.ts +21 -6
- package/vendor/@akanjs/native/packages/core/vectors/updates.json +2 -1
- package/vendor/@akanjs/native/packages/desktop/src/commands.ts +380 -0
- package/vendor/@akanjs/native/packages/desktop/src/deeplinks.ts +20 -3
- package/vendor/@akanjs/native/packages/desktop/src/dispatcher.ts +28 -13
- package/vendor/@akanjs/native/packages/desktop/src/host.ts +6 -18
- package/vendor/@akanjs/native/packages/desktop/src/lifecycle.ts +8 -1
- package/vendor/@akanjs/native/packages/desktop/src/plugin.ts +21 -0
- package/vendor/@akanjs/native/packages/desktop/src/server.ts +1 -1
- package/vendor/@akanjs/native/plugins/updates/src/desktop.ts +90 -164
- package/vendor/@akanjs/native/plugins/updates/src/reports.ts +255 -0
- package/vendor/@akanjs/native/plugins/updates/src/signer.ts +133 -0
- package/vendor/@akanjs/native/plugins/window/native-plugin.json +6 -1
- package/vendor/@akanjs/native/plugins/window/src/desktop.ts +20 -4
- package/vendor/@akanjs/native/plugins/window/src/index.ts +55 -3
|
@@ -653,6 +653,8 @@ struct Requested<'a> {
|
|
|
653
653
|
maximized: Option<bool>,
|
|
654
654
|
minimized: Option<bool>,
|
|
655
655
|
fullscreen: Option<bool>,
|
|
656
|
+
/// Linux: tao shows and hides a window on its next loop turn.
|
|
657
|
+
visible: Option<bool>,
|
|
656
658
|
}
|
|
657
659
|
|
|
658
660
|
/// Logical inner size. On macOS wry replaces the window's content view with its own parent
|
|
@@ -705,7 +707,7 @@ fn window_state_with(window: &tao::window::Window, webview: Option<&WebView>, re
|
|
|
705
707
|
req.minimized.unwrap_or_else(|| window.is_minimized()),
|
|
706
708
|
req.fullscreen.unwrap_or_else(|| window.fullscreen().is_some()),
|
|
707
709
|
window.is_focused(),
|
|
708
|
-
window.is_visible(),
|
|
710
|
+
req.visible.unwrap_or_else(|| window.is_visible()),
|
|
709
711
|
theme_name(window_theme(window)),
|
|
710
712
|
json::quote(req.title.map(str::to_string).unwrap_or_else(|| window.title()).as_str())
|
|
711
713
|
)
|
|
@@ -774,8 +776,29 @@ fn window_op(window: &tao::window::Window, webview: Option<&WebView>, cmd: &json
|
|
|
774
776
|
"window.setDecorations" => window.set_decorations(flag("value")?),
|
|
775
777
|
//? Hidden while it is over this window only: a kiosk's screen shows no pointer, the rest of the desktop still does.
|
|
776
778
|
"window.setCursorVisible" => window.set_cursor_visible(flag("value")?),
|
|
777
|
-
"window.
|
|
778
|
-
|
|
779
|
+
"window.setIgnoreCursorEvents" => {
|
|
780
|
+
let value = flag("value")?;
|
|
781
|
+
//? tao 0.37 on Linux unwraps the GDK window, which a never-shown window lacks until realized: an abort, unrealized.
|
|
782
|
+
#[cfg(target_os = "linux")]
|
|
783
|
+
{
|
|
784
|
+
use gtk::prelude::WidgetExt;
|
|
785
|
+
use tao::platform::unix::WindowExtUnix;
|
|
786
|
+
window.gtk_window().realize();
|
|
787
|
+
}
|
|
788
|
+
window.set_ignore_cursor_events(value).map_err(|e| e.to_string())?
|
|
789
|
+
}
|
|
790
|
+
#[cfg(not(target_os = "windows"))]
|
|
791
|
+
"window.setVisibleOnAllWorkspaces" => window.set_visible_on_all_workspaces(flag("value")?),
|
|
792
|
+
#[cfg(target_os = "windows")]
|
|
793
|
+
"window.setVisibleOnAllWorkspaces" => return Err("UNSUPPORTED: Windows moves no window onto every virtual desktop for an app".into()),
|
|
794
|
+
"window.show" => {
|
|
795
|
+
window.set_visible(true);
|
|
796
|
+
req.visible = Some(true);
|
|
797
|
+
}
|
|
798
|
+
"window.hide" => {
|
|
799
|
+
window.set_visible(false);
|
|
800
|
+
req.visible = Some(false);
|
|
801
|
+
}
|
|
779
802
|
"window.focus" => window.set_focus(),
|
|
780
803
|
// Unlike window.restore, keeps a maximized window maximized (single-instance).
|
|
781
804
|
"window.unminimize" => {
|
|
@@ -849,15 +872,6 @@ impl Colors {
|
|
|
849
872
|
}
|
|
850
873
|
}
|
|
851
874
|
|
|
852
|
-
/// SH-3 background for the current appearance, on the window and the webview.
|
|
853
|
-
fn paint(window: &tao::window::Window, webview: Option<&WebView>, colors: &Colors, dark: bool) {
|
|
854
|
-
let c = if dark { colors.dark } else { colors.light };
|
|
855
|
-
window.set_background_color(Some(c));
|
|
856
|
-
if let Some(wv) = webview {
|
|
857
|
-
let _ = wv.set_background_color(c);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
|
|
861
875
|
fn parse_color(s: &str) -> Option<(u8, u8, u8, u8)> {
|
|
862
876
|
let hex = s.strip_prefix('#')?;
|
|
863
877
|
let byte = |i: usize| u8::from_str_radix(hex.get(i..i + 2)?, 16).ok();
|
|
@@ -1201,6 +1215,7 @@ fn read_icon(path: &std::path::Path) -> Option<tao::window::Icon> {
|
|
|
1201
1215
|
tao::window::Icon::from_rgba(bytes[8..].to_vec(), width, height).map_err(|e| log!("icon {}: {e}", path.display())).ok()
|
|
1202
1216
|
}
|
|
1203
1217
|
|
|
1218
|
+
#[derive(Default)]
|
|
1204
1219
|
struct WindowOptions {
|
|
1205
1220
|
/// App path, e.g. "/settings?tab=2" (always on the app origin).
|
|
1206
1221
|
path: String,
|
|
@@ -1214,6 +1229,58 @@ struct WindowOptions {
|
|
|
1214
1229
|
skip_taskbar: bool,
|
|
1215
1230
|
/// No title bar or border: a kiosk drawn at an exact size, as an LED board needs.
|
|
1216
1231
|
frameless: bool,
|
|
1232
|
+
/// The minimum inner size it is created with, in place of MIN_INNER: a window that small never shows larger first.
|
|
1233
|
+
min_size: Option<(f64, f64)>,
|
|
1234
|
+
/// Nothing is painted behind the page, the theme colour included.
|
|
1235
|
+
transparent: bool,
|
|
1236
|
+
/// None: the system's choice, and none around a transparent window, whose shadow AppKit keeps as an earlier frame
|
|
1237
|
+
/// drew it.
|
|
1238
|
+
#[cfg_attr(target_os = "linux", allow(dead_code))]
|
|
1239
|
+
shadow: Option<bool>,
|
|
1240
|
+
always_on_top: bool,
|
|
1241
|
+
/// Not revealed when its first load finishes: the page places it, then calls window.show.
|
|
1242
|
+
hidden: bool,
|
|
1243
|
+
unfocusable: bool,
|
|
1244
|
+
all_workspaces: bool,
|
|
1245
|
+
/// A companion to the app's windows, not one of them: never the primary window, and not counted as the last one.
|
|
1246
|
+
auxiliary: bool,
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
impl WindowOptions {
|
|
1250
|
+
/// window.create's arguments, the position it cascades to aside.
|
|
1251
|
+
fn from_cmd(cmd: &json::V) -> Result<Self, String> {
|
|
1252
|
+
let flag = |k: &str, default: bool| match cmd.get(k) {
|
|
1253
|
+
None => Ok(default),
|
|
1254
|
+
Some(v) => v.as_bool().ok_or_else(|| format!("{k} must be a boolean")),
|
|
1255
|
+
};
|
|
1256
|
+
let positive = |pair: Option<(f64, f64)>, what: &str| match pair {
|
|
1257
|
+
Some((w, h)) if !(w >= 1.0 && h >= 1.0) => Err(format!("{what} must be positive")),
|
|
1258
|
+
pair => Ok(pair),
|
|
1259
|
+
};
|
|
1260
|
+
Ok(Self {
|
|
1261
|
+
path: app_path(cmd)?,
|
|
1262
|
+
title: match cmd.get("title") {
|
|
1263
|
+
None => None,
|
|
1264
|
+
Some(v) => Some(v.as_str().ok_or("title must be a string")?.to_string()),
|
|
1265
|
+
},
|
|
1266
|
+
size: positive(placement::logical_pair(cmd, "width", "height")?, "width and height")?,
|
|
1267
|
+
position: placement::logical_pair(cmd, "x", "y")?,
|
|
1268
|
+
skip_taskbar: flag("skipTaskbar", false)?,
|
|
1269
|
+
frameless: flag("frameless", false)?,
|
|
1270
|
+
min_size: positive(placement::logical_pair(cmd, "minWidth", "minHeight")?, "minWidth and minHeight")?,
|
|
1271
|
+
transparent: flag("transparent", false)?,
|
|
1272
|
+
shadow: match cmd.get("shadow") {
|
|
1273
|
+
None => None,
|
|
1274
|
+
Some(v) => Some(v.as_bool().ok_or("shadow must be a boolean")?),
|
|
1275
|
+
},
|
|
1276
|
+
always_on_top: flag("alwaysOnTop", false)?,
|
|
1277
|
+
hidden: !flag("visible", true)?,
|
|
1278
|
+
unfocusable: !flag("focusable", true)?,
|
|
1279
|
+
all_workspaces: flag("visibleOnAllWorkspaces", false)?,
|
|
1280
|
+
auxiliary: flag("auxiliary", false)?,
|
|
1281
|
+
..Self::default()
|
|
1282
|
+
})
|
|
1283
|
+
}
|
|
1217
1284
|
}
|
|
1218
1285
|
|
|
1219
1286
|
/// One window. The webview is declared first so that it is dropped before its window.
|
|
@@ -1233,6 +1300,30 @@ struct Win {
|
|
|
1233
1300
|
min_size: (f64, f64),
|
|
1234
1301
|
/// window.setCursorVisible(false): the external views over it hide the pointer too.
|
|
1235
1302
|
cursor_hidden: bool,
|
|
1303
|
+
/// Created transparent: it is never painted the theme colour.
|
|
1304
|
+
transparent: bool,
|
|
1305
|
+
/// Created with `visible: false` and not shown yet: a finished load does not reveal it.
|
|
1306
|
+
held_hidden: bool,
|
|
1307
|
+
unfocusable: bool,
|
|
1308
|
+
auxiliary: bool,
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
impl Win {
|
|
1312
|
+
/// SH-3 background for the current appearance, on the window and the webview.
|
|
1313
|
+
fn paint(&self, colors: &Colors, dark: bool) {
|
|
1314
|
+
if self.transparent {
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
let c = if dark { colors.dark } else { colors.light };
|
|
1318
|
+
self.window.set_background_color(Some(c));
|
|
1319
|
+
let _ = self.webview.set_background_color(c);
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/// Windows::primary over ids alone: an auxiliary window is picked only when no other is left.
|
|
1324
|
+
fn primary_of(focus: &[u32], auxiliary: &HashMap<u32, bool>) -> Option<u32> {
|
|
1325
|
+
let regular = |id: &u32| auxiliary.get(id) == Some(&false);
|
|
1326
|
+
focus.iter().rev().copied().find(regular).or_else(|| auxiliary.keys().copied().filter(regular).min()).or_else(|| auxiliary.keys().copied().min())
|
|
1236
1327
|
}
|
|
1237
1328
|
|
|
1238
1329
|
struct Windows {
|
|
@@ -1386,15 +1477,30 @@ fn open_window(target: &EventLoopWindowTarget<UserEvent>, shell: &Shell, context
|
|
|
1386
1477
|
#[allow(unused_mut)]
|
|
1387
1478
|
let mut background = if is_dark() { shell.colors.dark } else { shell.colors.light };
|
|
1388
1479
|
let (width, height) = opts.size.unwrap_or(shell.size);
|
|
1480
|
+
let min = opts.min_size.unwrap_or(MIN_INNER);
|
|
1389
1481
|
let mut builder = WindowBuilder::new()
|
|
1390
1482
|
.with_title(opts.title.as_deref().unwrap_or(&shell.title))
|
|
1391
1483
|
.with_inner_size(LogicalSize::new(width, height))
|
|
1392
|
-
.with_min_inner_size(LogicalSize::new(
|
|
1393
|
-
.with_background_color(background)
|
|
1484
|
+
.with_min_inner_size(LogicalSize::new(min.0, min.1))
|
|
1394
1485
|
// D2: stay hidden until the first page load finished, so no blank frame is ever shown.
|
|
1395
1486
|
.with_visible(false)
|
|
1396
1487
|
.with_decorations(!opts.frameless)
|
|
1488
|
+
.with_always_on_top(opts.always_on_top)
|
|
1489
|
+
.with_focusable(!opts.unfocusable)
|
|
1490
|
+
.with_visible_on_all_workspaces(opts.all_workspaces)
|
|
1397
1491
|
.with_window_icon(shell.icon.clone());
|
|
1492
|
+
builder = if opts.transparent { builder.with_transparent(true) } else { builder.with_background_color(background) };
|
|
1493
|
+
#[cfg(target_os = "macos")]
|
|
1494
|
+
if let Some(shadow) = opts.shadow.or(opts.transparent.then_some(false)) {
|
|
1495
|
+
use tao::platform::macos::WindowBuilderExtMacOS;
|
|
1496
|
+
builder = builder.with_has_shadow(shadow);
|
|
1497
|
+
}
|
|
1498
|
+
//? Windows draws a frame's shadow itself: only a frameless window's is the app's to choose.
|
|
1499
|
+
#[cfg(target_os = "windows")]
|
|
1500
|
+
if let Some(shadow) = opts.shadow.or(opts.transparent.then_some(false)) {
|
|
1501
|
+
use tao::platform::windows::WindowBuilderExtWindows;
|
|
1502
|
+
builder = builder.with_undecorated_shadow(shadow);
|
|
1503
|
+
}
|
|
1398
1504
|
// Reopen where asked, unless that display is gone (placement.rs; window-state for window 1).
|
|
1399
1505
|
// Not WindowBuilder::with_position: on macOS tao takes that as the content's top-left corner
|
|
1400
1506
|
// (tao/src/platform_impl/macos/window.rs:202-208), so the title bar would end up above it;
|
|
@@ -1403,7 +1509,7 @@ fn open_window(target: &EventLoopWindowTarget<UserEvent>, shell: &Shell, context
|
|
|
1403
1509
|
let mut placed = None;
|
|
1404
1510
|
if let Some((x, y)) = opts.position {
|
|
1405
1511
|
let wanted = placement::Rect { x, y, width, height };
|
|
1406
|
-
match placement::place(wanted, &placement::monitors(target),
|
|
1512
|
+
match placement::place(wanted, &placement::monitors(target), min) {
|
|
1407
1513
|
Some(r) => {
|
|
1408
1514
|
builder = builder.with_inner_size(LogicalSize::new(r.width, r.height));
|
|
1409
1515
|
outer_position = Some(tao::dpi::LogicalPosition::new(r.x, r.y));
|
|
@@ -1430,10 +1536,19 @@ fn open_window(target: &EventLoopWindowTarget<UserEvent>, shell: &Shell, context
|
|
|
1430
1536
|
let window = builder.build(target).map_err(|e| format!("window: {e}"))?;
|
|
1431
1537
|
// Windows and Linux: the system theme is known once a window exists (tao reads it then).
|
|
1432
1538
|
#[cfg(not(target_os = "macos"))]
|
|
1433
|
-
if window_theme(&window) == tao::window::Theme::Dark && background != shell.colors.dark {
|
|
1539
|
+
if !opts.transparent && window_theme(&window) == tao::window::Theme::Dark && background != shell.colors.dark {
|
|
1434
1540
|
background = shell.colors.dark;
|
|
1435
1541
|
window.set_background_color(Some(background));
|
|
1436
1542
|
}
|
|
1543
|
+
//? AppKit puts a titled window in the Window menu by itself.
|
|
1544
|
+
#[cfg(target_os = "macos")]
|
|
1545
|
+
if opts.auxiliary {
|
|
1546
|
+
use tao::platform::macos::WindowExtMacOS;
|
|
1547
|
+
// Safety: tao's ns_window is the NSWindow of this live window.
|
|
1548
|
+
if let Some(ns_window) = unsafe { objc2::rc::Retained::retain(window.ns_window() as *mut objc2_app_kit::NSWindow) } {
|
|
1549
|
+
ns_window.setExcludedFromWindowsMenu(true);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1437
1552
|
// Still hidden (D2), so nothing visibly moves. Both calls are queued on the main queue in
|
|
1438
1553
|
// this order: the window zooms on the saved display, and un-zooming returns to these bounds.
|
|
1439
1554
|
if let Some(position) = outer_position {
|
|
@@ -1499,10 +1614,10 @@ fn open_window(target: &EventLoopWindowTarget<UserEvent>, shell: &Shell, context
|
|
|
1499
1614
|
// SH-4: pages never leave the app origin (navigation.rs). Linux decides in its own signal handlers.
|
|
1500
1615
|
#[cfg(not(target_os = "linux"))]
|
|
1501
1616
|
let builder = builder.with_navigation_handler(move |url| navigation::allow(&url, id));
|
|
1617
|
+
let builder = if opts.transparent { builder.with_transparent(true) } else { builder.with_background_color(background) };
|
|
1502
1618
|
let builder = builder
|
|
1503
1619
|
.with_id(&webview_id)
|
|
1504
1620
|
.with_url(format!("{START_URL}{}", opts.path))
|
|
1505
|
-
.with_background_color(background)
|
|
1506
1621
|
.with_devtools(shell.devtools)
|
|
1507
1622
|
.with_new_window_req_handler(move |url, _features| {
|
|
1508
1623
|
// window.open and target=_blank: links go to the OS; the app's own pages open no second
|
|
@@ -1609,7 +1724,19 @@ fn open_window(target: &EventLoopWindowTarget<UserEvent>, shell: &Shell, context
|
|
|
1609
1724
|
std::thread::sleep(Duration::from_millis(3000));
|
|
1610
1725
|
send(UserEvent::Show(id));
|
|
1611
1726
|
});
|
|
1612
|
-
Ok(Win {
|
|
1727
|
+
Ok(Win {
|
|
1728
|
+
webview,
|
|
1729
|
+
window,
|
|
1730
|
+
reloaded_at: None,
|
|
1731
|
+
gone_streak: 0,
|
|
1732
|
+
reload_pending: false,
|
|
1733
|
+
min_size: min,
|
|
1734
|
+
cursor_hidden: false,
|
|
1735
|
+
transparent: opts.transparent,
|
|
1736
|
+
held_hidden: opts.hidden,
|
|
1737
|
+
unfocusable: opts.unfocusable,
|
|
1738
|
+
auxiliary: opts.auxiliary,
|
|
1739
|
+
})
|
|
1613
1740
|
}
|
|
1614
1741
|
|
|
1615
1742
|
/// A `window` argument: a positive whole number.
|
|
@@ -1647,13 +1774,7 @@ impl Windows {
|
|
|
1647
1774
|
/// recently focused window, which is also the one macOS brings forward when the app is
|
|
1648
1775
|
/// activated; before any focus change window 1, else the oldest.
|
|
1649
1776
|
fn primary(&self) -> Option<u32> {
|
|
1650
|
-
self.focus.iter().
|
|
1651
|
-
if self.map.contains_key(&1) {
|
|
1652
|
-
Some(1)
|
|
1653
|
-
} else {
|
|
1654
|
-
self.map.keys().min().copied()
|
|
1655
|
-
}
|
|
1656
|
-
})
|
|
1777
|
+
primary_of(&self.focus, &self.map.iter().map(|(id, win)| (*id, win.auxiliary)).collect())
|
|
1657
1778
|
}
|
|
1658
1779
|
|
|
1659
1780
|
fn focused(&mut self, id: u32) {
|
|
@@ -1662,37 +1783,25 @@ impl Windows {
|
|
|
1662
1783
|
}
|
|
1663
1784
|
|
|
1664
1785
|
fn state(&self, id: u32, win: &Win) -> String {
|
|
1665
|
-
// {"id":N, ...state}
|
|
1666
|
-
format!(r#"{{"id":{id},{}"#, &window_state(&win.window, Some(&win.webview))[1..])
|
|
1786
|
+
// {"id":N,"auxiliary":…, ...state}
|
|
1787
|
+
format!(r#"{{"id":{id},"auxiliary":{},{}"#, win.auxiliary, &window_state(&win.window, Some(&win.webview))[1..])
|
|
1667
1788
|
}
|
|
1668
1789
|
|
|
1669
1790
|
fn create(&mut self, target: &EventLoopWindowTarget<UserEvent>, cmd: &json::V) -> Result<String, String> {
|
|
1670
|
-
let
|
|
1671
|
-
if size.is_some_and(|(w, h)| !(w >= 1.0 && h >= 1.0)) {
|
|
1672
|
-
return Err("width and height must be positive".into());
|
|
1673
|
-
}
|
|
1674
|
-
let title = match cmd.get("title") {
|
|
1675
|
-
None => None,
|
|
1676
|
-
Some(v) => Some(v.as_str().ok_or("title must be a string")?.to_string()),
|
|
1677
|
-
};
|
|
1678
|
-
let frameless = match cmd.get("frameless") {
|
|
1679
|
-
None => false,
|
|
1680
|
-
Some(v) => v.as_bool().ok_or("frameless must be a boolean")?,
|
|
1681
|
-
};
|
|
1791
|
+
let mut opts = WindowOptions::from_cmd(cmd)?;
|
|
1682
1792
|
// Without a position, cascade from the focused window like AppKit does for new documents.
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
None => self.focus.iter().rev().find_map(|id| self.map.get(id)).and_then(|w| {
|
|
1793
|
+
opts.position = opts.position.or_else(|| {
|
|
1794
|
+
self.focus.iter().rev().find_map(|id| self.map.get(id).filter(|w| !w.auxiliary)).and_then(|w| {
|
|
1686
1795
|
let scale = w.window.scale_factor();
|
|
1687
1796
|
w.window.outer_position().ok().map(|p| {
|
|
1688
1797
|
let l = p.to_logical::<f64>(scale);
|
|
1689
1798
|
(l.x + 28.0, l.y + 28.0)
|
|
1690
1799
|
})
|
|
1691
|
-
})
|
|
1692
|
-
};
|
|
1800
|
+
})
|
|
1801
|
+
});
|
|
1693
1802
|
let id = self.next;
|
|
1694
1803
|
self.next += 1;
|
|
1695
|
-
let win = open_window(target, &self.shell, &mut self.web_context, id,
|
|
1804
|
+
let win = open_window(target, &self.shell, &mut self.web_context, id, opts)?;
|
|
1696
1805
|
let state = self.state(id, &win);
|
|
1697
1806
|
self.insert(id, win);
|
|
1698
1807
|
push_event(&format!(r#"{{"type":"window","event":"created","window":{id}}}"#));
|
|
@@ -1924,7 +2033,7 @@ impl Windows {
|
|
|
1924
2033
|
linux::appearance::set_theme(theme);
|
|
1925
2034
|
let dark = theme.map_or_else(|| window_theme(&win.window) == tao::window::Theme::Dark, |t| t == tao::window::Theme::Dark);
|
|
1926
2035
|
for w in self.map.values() {
|
|
1927
|
-
|
|
2036
|
+
w.paint(&self.shell.colors, dark);
|
|
1928
2037
|
}
|
|
1929
2038
|
return Ok(window_state(&win.window, Some(&win.webview)));
|
|
1930
2039
|
}
|
|
@@ -1955,6 +2064,9 @@ impl Windows {
|
|
|
1955
2064
|
self.map.get_mut(&id).expect("looked up above").cursor_hidden = hidden;
|
|
1956
2065
|
self.external.set_cursor_hidden(id, hidden);
|
|
1957
2066
|
}
|
|
2067
|
+
if op == "window.show" {
|
|
2068
|
+
self.map.get_mut(&id).expect("looked up above").held_hidden = false;
|
|
2069
|
+
}
|
|
1958
2070
|
Ok(state)
|
|
1959
2071
|
}
|
|
1960
2072
|
}
|
|
@@ -2095,13 +2207,12 @@ pub unsafe extern "C" fn akan_native_run(config_json: *const c_char) -> i32 {
|
|
|
2095
2207
|
};
|
|
2096
2208
|
let main = WindowOptions {
|
|
2097
2209
|
path: cfg.start_path.clone(),
|
|
2098
|
-
title: None,
|
|
2099
|
-
size: None,
|
|
2100
2210
|
position: cfg.position,
|
|
2101
2211
|
maximized: cfg.maximized,
|
|
2102
2212
|
fullscreen: cfg.fullscreen,
|
|
2103
2213
|
skip_taskbar: cfg.skip_taskbar,
|
|
2104
2214
|
frameless: cfg.frameless,
|
|
2215
|
+
..WindowOptions::default()
|
|
2105
2216
|
};
|
|
2106
2217
|
match open_window(&event_loop, &windows.shell, &mut windows.web_context, 1, main) {
|
|
2107
2218
|
Ok(win) => windows.insert(1, win),
|
|
@@ -2166,7 +2277,7 @@ pub unsafe extern "C" fn akan_native_run(config_json: *const c_char) -> i32 {
|
|
|
2166
2277
|
push_event(&format!(r#"{{"type":"window","event":"moved","window":{id},"x":{},"y":{}}}"#, logical.x, logical.y));
|
|
2167
2278
|
}
|
|
2168
2279
|
WindowEvent::ThemeChanged(theme) => {
|
|
2169
|
-
|
|
2280
|
+
win.paint(&windows.shell.colors, theme == tao::window::Theme::Dark);
|
|
2170
2281
|
push_event(&format!(r#"{{"type":"window","event":"themeChanged","window":{id},"theme":"{}"}}"#, theme_name(theme)));
|
|
2171
2282
|
}
|
|
2172
2283
|
_ => {}
|
|
@@ -2262,9 +2373,9 @@ pub unsafe extern "C" fn akan_native_run(config_json: *const c_char) -> i32 {
|
|
|
2262
2373
|
}
|
|
2263
2374
|
Event::UserEvent(UserEvent::Show(id)) => {
|
|
2264
2375
|
if let Some(win) = windows.map.get(&id) {
|
|
2265
|
-
if !win.window.is_visible() {
|
|
2376
|
+
if !win.held_hidden && !win.window.is_visible() {
|
|
2266
2377
|
win.window.set_visible(true);
|
|
2267
|
-
if windows.shell.activate {
|
|
2378
|
+
if windows.shell.activate && !win.unfocusable {
|
|
2268
2379
|
win.window.set_focus();
|
|
2269
2380
|
}
|
|
2270
2381
|
}
|
|
@@ -2286,7 +2397,8 @@ pub unsafe extern "C" fn akan_native_run(config_json: *const c_char) -> i32 {
|
|
|
2286
2397
|
if WATCH_TAKEN.load(Ordering::Acquire) >= watch || QUITTING.load(Ordering::Acquire) || !windows.map.contains_key(&window) {
|
|
2287
2398
|
return; // taken meanwhile, or gone
|
|
2288
2399
|
}
|
|
2289
|
-
|
|
2400
|
+
//? As the host decides (lifecycle.ts): an auxiliary window is not one the app is left with.
|
|
2401
|
+
if windows.map.iter().any(|(id, win)| *id != window && !win.auxiliary) {
|
|
2290
2402
|
log!("the plugin host did not take the close request of window {window} within {WATCH_TIMEOUT:?}; closing it");
|
|
2291
2403
|
let _ = windows.destroy(window);
|
|
2292
2404
|
} else {
|
|
@@ -2297,7 +2409,7 @@ pub unsafe extern "C" fn akan_native_run(config_json: *const c_char) -> i32 {
|
|
|
2297
2409
|
Event::UserEvent(UserEvent::ThemeChanged) => {
|
|
2298
2410
|
for (id, win) in &windows.map {
|
|
2299
2411
|
let theme = window_theme(&win.window);
|
|
2300
|
-
|
|
2412
|
+
win.paint(&windows.shell.colors, theme == tao::window::Theme::Dark);
|
|
2301
2413
|
push_event(&format!(r#"{{"type":"window","event":"themeChanged","window":{id},"theme":"{}"}}"#, theme_name(theme)));
|
|
2302
2414
|
}
|
|
2303
2415
|
}
|
|
@@ -2476,7 +2588,8 @@ mod range_tests {
|
|
|
2476
2588
|
|
|
2477
2589
|
#[cfg(test)]
|
|
2478
2590
|
mod window_arg_tests {
|
|
2479
|
-
use super::{app_path, json, parse_config, window_arg};
|
|
2591
|
+
use super::{app_path, json, parse_config, primary_of, window_arg, WindowOptions};
|
|
2592
|
+
use std::collections::HashMap;
|
|
2480
2593
|
|
|
2481
2594
|
#[test]
|
|
2482
2595
|
fn window_ids() {
|
|
@@ -2505,6 +2618,48 @@ mod window_arg_tests {
|
|
|
2505
2618
|
assert_eq!(start(r#","startPath":"/en/home?csr=true""#), Ok("/en/home?csr=true".into()));
|
|
2506
2619
|
assert!(start(r#","startPath":"//evil.com/x""#).is_err());
|
|
2507
2620
|
}
|
|
2621
|
+
|
|
2622
|
+
#[test]
|
|
2623
|
+
fn a_window_is_created_plain_unless_asked_otherwise() {
|
|
2624
|
+
let opts = |s: &str| WindowOptions::from_cmd(&json::parse(s).unwrap());
|
|
2625
|
+
let plain = opts(r#"{}"#).unwrap();
|
|
2626
|
+
assert_eq!((plain.path.as_str(), plain.size, plain.min_size, plain.shadow), ("/", None, None, None));
|
|
2627
|
+
assert!(!(plain.transparent || plain.always_on_top || plain.skip_taskbar || plain.hidden || plain.unfocusable || plain.all_workspaces || plain.auxiliary || plain.frameless));
|
|
2628
|
+
|
|
2629
|
+
let companion = opts(
|
|
2630
|
+
r#"{"path":"/pet","width":96,"height":96,"minWidth":96,"minHeight":96,"frameless":true,"transparent":true,"shadow":true,"alwaysOnTop":true,"skipTaskbar":true,"visible":false,"focusable":false,"visibleOnAllWorkspaces":true,"auxiliary":true}"#,
|
|
2631
|
+
)
|
|
2632
|
+
.unwrap();
|
|
2633
|
+
assert_eq!((companion.size, companion.min_size, companion.shadow), (Some((96.0, 96.0)), Some((96.0, 96.0)), Some(true)));
|
|
2634
|
+
assert!(companion.transparent && companion.always_on_top && companion.skip_taskbar && companion.hidden && companion.unfocusable && companion.all_workspaces && companion.auxiliary && companion.frameless);
|
|
2635
|
+
|
|
2636
|
+
for bad in [
|
|
2637
|
+
r#"{"minWidth":96}"#,
|
|
2638
|
+
r#"{"minWidth":0,"minHeight":96}"#,
|
|
2639
|
+
r#"{"width":0,"height":96}"#,
|
|
2640
|
+
r#"{"transparent":1}"#,
|
|
2641
|
+
r#"{"shadow":"off"}"#,
|
|
2642
|
+
r#"{"visible":null}"#,
|
|
2643
|
+
r#"{"focusable":"no"}"#,
|
|
2644
|
+
r#"{"auxiliary":0}"#,
|
|
2645
|
+
r#"{"path":"https://example.com"}"#,
|
|
2646
|
+
] {
|
|
2647
|
+
assert!(opts(bad).is_err(), "{bad}");
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
#[test]
|
|
2652
|
+
fn the_primary_window_is_never_an_auxiliary_one_while_another_exists() {
|
|
2653
|
+
let windows = |list: &[(u32, bool)]| list.iter().copied().collect::<HashMap<u32, bool>>();
|
|
2654
|
+
let both = windows(&[(1, false), (2, true)]);
|
|
2655
|
+
assert_eq!(primary_of(&[], &both), Some(1));
|
|
2656
|
+
assert_eq!(primary_of(&[1, 2], &both), Some(1), "the companion was clicked last");
|
|
2657
|
+
assert_eq!(primary_of(&[1, 3, 2], &windows(&[(1, false), (2, true), (3, false)])), Some(3));
|
|
2658
|
+
assert_eq!(primary_of(&[1, 3], &windows(&[(1, false), (2, false)])), Some(1), "window 3 is gone");
|
|
2659
|
+
assert_eq!(primary_of(&[], &windows(&[(4, false), (2, true), (3, false)])), Some(3), "the oldest regular one");
|
|
2660
|
+
assert_eq!(primary_of(&[2], &windows(&[(2, true)])), Some(2));
|
|
2661
|
+
assert_eq!(primary_of(&[1], &windows(&[])), None);
|
|
2662
|
+
}
|
|
2508
2663
|
}
|
|
2509
2664
|
|
|
2510
2665
|
#[cfg(test)]
|