@mediar-ai/terminator 0.24.9 → 0.24.11

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/package.json CHANGED
@@ -38,8 +38,8 @@
38
38
  }
39
39
  },
40
40
  "optionalDependencies": {
41
- "@mediar-ai/terminator-win32-arm64-msvc": "0.24.9",
42
- "@mediar-ai/terminator-win32-x64-msvc": "0.24.9"
41
+ "@mediar-ai/terminator-win32-arm64-msvc": "0.24.11",
42
+ "@mediar-ai/terminator-win32-x64-msvc": "0.24.11"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",
@@ -57,5 +57,5 @@
57
57
  "test-hook": "powershell.exe -ExecutionPolicy Bypass -File \"../../.git/hooks/pre-push.ps1\""
58
58
  },
59
59
  "types": "wrapper.d.ts",
60
- "version": "0.24.9"
60
+ "version": "0.24.11"
61
61
  }
package/src/desktop.rs CHANGED
@@ -2444,6 +2444,49 @@ impl Desktop {
2444
2444
  .map_err(map_error)
2445
2445
  }
2446
2446
 
2447
+ /// (async) Close a browser tab safely.
2448
+ ///
2449
+ /// This method can identify the tab to close by:
2450
+ /// - tabId: Close a specific tab by its Chrome tab ID
2451
+ /// - url: Find and close a tab matching this URL (partial match supported)
2452
+ /// - title: Find and close a tab matching this title (case-insensitive partial match)
2453
+ /// - If none provided, closes the currently active tab
2454
+ ///
2455
+ /// Returns information about the closed tab for verification.
2456
+ /// Returns null if no browser extension is connected or tab couldn't be found.
2457
+ ///
2458
+ /// Safety:
2459
+ /// - Will NOT close protected browser pages (chrome://, edge://, about:, etc.)
2460
+ /// - Returns the closed tab's URL/title so you can verify the correct tab was closed
2461
+ ///
2462
+ /// @param {number} [tabId] - Specific Chrome tab ID to close.
2463
+ /// @param {string} [url] - URL to match (partial match supported).
2464
+ /// @param {string} [title] - Title to match (case-insensitive partial match).
2465
+ /// @returns {Promise<CloseTabResult | null>} Info about closed tab, or null if no extension/tab found.
2466
+ ///
2467
+ /// @example
2468
+ /// // Close by URL
2469
+ /// const result = await desktop.closeTab({ url: "example.com" });
2470
+ ///
2471
+ /// @example
2472
+ /// // Close by title
2473
+ /// const result = await desktop.closeTab({ title: "My Page" });
2474
+ ///
2475
+ /// @example
2476
+ /// // Close active tab
2477
+ /// const result = await desktop.closeTab();
2478
+ #[napi]
2479
+ pub async fn close_tab(
2480
+ &self,
2481
+ options: Option<crate::types::CloseTabOptions>,
2482
+ ) -> napi::Result<Option<crate::types::CloseTabResult>> {
2483
+ let opts = options.unwrap_or_default();
2484
+ self.inner
2485
+ .close_tab(opts.tab_id, opts.url.as_deref(), opts.title.as_deref())
2486
+ .await
2487
+ .map(|opt| opt.map(crate::types::CloseTabResult::from))
2488
+ .map_err(map_error)
2489
+ }
2447
2490
  /// (async) Delay execution for a specified number of milliseconds.
2448
2491
  /// Useful for waiting between actions to ensure UI stability.
2449
2492
  ///
package/src/types.rs CHANGED
@@ -917,3 +917,47 @@ impl From<terminator::ComputerUseResult> for ComputerUseResult {
917
917
  }
918
918
  }
919
919
  }
920
+
921
+ /// Result of closing a browser tab
922
+ #[napi(object)]
923
+ #[derive(Debug, Clone)]
924
+ pub struct CloseTabResult {
925
+ pub closed: bool,
926
+ pub tab: ClosedTabInfo,
927
+ }
928
+
929
+ /// Information about a closed tab
930
+ #[napi(object)]
931
+ #[derive(Debug, Clone)]
932
+ pub struct ClosedTabInfo {
933
+ pub id: i32,
934
+ pub url: Option<String>,
935
+ pub title: Option<String>,
936
+ pub window_id: Option<i32>,
937
+ }
938
+
939
+ impl From<terminator::extension_bridge::CloseTabResult> for CloseTabResult {
940
+ fn from(result: terminator::extension_bridge::CloseTabResult) -> Self {
941
+ CloseTabResult {
942
+ closed: result.closed,
943
+ tab: ClosedTabInfo {
944
+ id: result.tab.id,
945
+ url: result.tab.url,
946
+ title: result.tab.title,
947
+ window_id: result.tab.window_id,
948
+ },
949
+ }
950
+ }
951
+ }
952
+
953
+ /// Options for closing a browser tab
954
+ #[napi(object)]
955
+ #[derive(Debug, Clone, Default)]
956
+ pub struct CloseTabOptions {
957
+ /// Specific Chrome tab ID to close
958
+ pub tab_id: Option<i32>,
959
+ /// URL to match (partial match supported)
960
+ pub url: Option<String>,
961
+ /// Title to match (case-insensitive partial match)
962
+ pub title: Option<String>,
963
+ }