window.d.ts 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  1. import type { EventName, EventCallback, UnlistenFn } from './event';
  2. import { type Event } from './helpers/event';
  3. type Theme = 'light' | 'dark';
  4. type TitleBarStyle = 'visible' | 'transparent' | 'overlay';
  5. /**
  6. * Allows you to retrieve information about a given monitor.
  7. *
  8. * @since 1.0.0
  9. */
  10. interface Monitor {
  11. /** Human-readable name of the monitor */
  12. name: string | null;
  13. /** The monitor's resolution. */
  14. size: PhysicalSize;
  15. /** the Top-left corner position of the monitor relative to the larger full screen area. */
  16. position: PhysicalPosition;
  17. /** The scale factor that can be used to map physical pixels to logical pixels. */
  18. scaleFactor: number;
  19. }
  20. /**
  21. * The payload for the `scaleChange` event.
  22. *
  23. * @since 1.0.2
  24. */
  25. interface ScaleFactorChanged {
  26. /** The new window scale factor. */
  27. scaleFactor: number;
  28. /** The new window size */
  29. size: PhysicalSize;
  30. }
  31. /** The file drop event types. */
  32. type FileDropEvent = {
  33. type: 'hover';
  34. paths: string[];
  35. } | {
  36. type: 'drop';
  37. paths: string[];
  38. } | {
  39. type: 'cancel';
  40. };
  41. /**
  42. * A size represented in logical pixels.
  43. *
  44. * @since 1.0.0
  45. */
  46. declare class LogicalSize {
  47. type: string;
  48. width: number;
  49. height: number;
  50. constructor(width: number, height: number);
  51. }
  52. /**
  53. * A size represented in physical pixels.
  54. *
  55. * @since 1.0.0
  56. */
  57. declare class PhysicalSize {
  58. type: string;
  59. width: number;
  60. height: number;
  61. constructor(width: number, height: number);
  62. /**
  63. * Converts the physical size to a logical one.
  64. * @example
  65. * ```typescript
  66. * import { appWindow } from '@tauri-apps/api/window';
  67. * const factor = await appWindow.scaleFactor();
  68. * const size = await appWindow.innerSize();
  69. * const logical = size.toLogical(factor);
  70. * ```
  71. * */
  72. toLogical(scaleFactor: number): LogicalSize;
  73. }
  74. /**
  75. * A position represented in logical pixels.
  76. *
  77. * @since 1.0.0
  78. */
  79. declare class LogicalPosition {
  80. type: string;
  81. x: number;
  82. y: number;
  83. constructor(x: number, y: number);
  84. }
  85. /**
  86. * A position represented in physical pixels.
  87. *
  88. * @since 1.0.0
  89. */
  90. declare class PhysicalPosition {
  91. type: string;
  92. x: number;
  93. y: number;
  94. constructor(x: number, y: number);
  95. /**
  96. * Converts the physical position to a logical one.
  97. * @example
  98. * ```typescript
  99. * import { appWindow } from '@tauri-apps/api/window';
  100. * const factor = await appWindow.scaleFactor();
  101. * const position = await appWindow.innerPosition();
  102. * const logical = position.toLogical(factor);
  103. * ```
  104. * */
  105. toLogical(scaleFactor: number): LogicalPosition;
  106. }
  107. /** @ignore */
  108. interface WindowDef {
  109. label: string;
  110. }
  111. /** @ignore */
  112. declare global {
  113. interface Window {
  114. __TAURI_METADATA__: {
  115. __windows: WindowDef[];
  116. __currentWindow: WindowDef;
  117. };
  118. }
  119. }
  120. /**
  121. * Attention type to request on a window.
  122. *
  123. * @since 1.0.0
  124. */
  125. declare enum UserAttentionType {
  126. /**
  127. * #### Platform-specific
  128. * - **macOS:** Bounces the dock icon until the application is in focus.
  129. * - **Windows:** Flashes both the window and the taskbar button until the application is in focus.
  130. */
  131. Critical = 1,
  132. /**
  133. * #### Platform-specific
  134. * - **macOS:** Bounces the dock icon once.
  135. * - **Windows:** Flashes the taskbar button until the application is in focus.
  136. */
  137. Informational = 2
  138. }
  139. export type CursorIcon = 'default' | 'crosshair' | 'hand' | 'arrow' | 'move' | 'text' | 'wait' | 'help' | 'progress' | 'notAllowed' | 'contextMenu' | 'cell' | 'verticalText' | 'alias' | 'copy' | 'noDrop' | 'grab' | 'grabbing' | 'allScroll' | 'zoomIn' | 'zoomOut' | 'eResize' | 'nResize' | 'neResize' | 'nwResize' | 'sResize' | 'seResize' | 'swResize' | 'wResize' | 'ewResize' | 'nsResize' | 'neswResize' | 'nwseResize' | 'colResize' | 'rowResize';
  140. /**
  141. * Get an instance of `WebviewWindow` for the current webview window.
  142. *
  143. * @since 1.0.0
  144. */
  145. declare function getCurrent(): WebviewWindow;
  146. /**
  147. * Gets a list of instances of `WebviewWindow` for all available webview windows.
  148. *
  149. * @since 1.0.0
  150. */
  151. declare function getAll(): WebviewWindow[];
  152. /** @ignore */
  153. export type WindowLabel = string;
  154. /**
  155. * A webview window handle allows emitting and listening to events from the backend that are tied to the window.
  156. *
  157. * @ignore
  158. * @since 1.0.0
  159. */
  160. declare class WebviewWindowHandle {
  161. /** The window label. It is a unique identifier for the window, can be used to reference it later. */
  162. label: WindowLabel;
  163. /** Local event listeners. */
  164. listeners: Record<string, Array<EventCallback<any>>>;
  165. constructor(label: WindowLabel);
  166. /**
  167. * Listen to an event emitted by the backend or webview.
  168. * The event must either be a global event or an event targetting this window.
  169. *
  170. * See {@link WebviewWindow.emit | `emit`} for more information.
  171. *
  172. * @example
  173. * ```typescript
  174. * import { appWindow } from '@tauri-apps/api/window';
  175. * const unlisten = await appWindow.listen<string>('state-changed', (event) => {
  176. * console.log(`Got error: ${payload}`);
  177. * });
  178. *
  179. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  180. * unlisten();
  181. * ```
  182. *
  183. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  184. *
  185. * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
  186. * @param handler Event handler.
  187. * @returns A promise resolving to a function to unlisten to the event.
  188. */
  189. listen<T>(event: EventName, handler: EventCallback<T>): Promise<UnlistenFn>;
  190. /**
  191. * Listen to an one-off event.
  192. * See {@link WebviewWindow.listen | `listen`} for more information.
  193. *
  194. * @example
  195. * ```typescript
  196. * import { appWindow } from '@tauri-apps/api/window';
  197. * const unlisten = await appWindow.once<null>('initialized', (event) => {
  198. * console.log(`Window initialized!`);
  199. * });
  200. *
  201. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  202. * unlisten();
  203. * ```
  204. *
  205. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  206. *
  207. * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
  208. * @param handler Event handler.
  209. * @returns A promise resolving to a function to unlisten to the event.
  210. */
  211. once<T>(event: string, handler: EventCallback<T>): Promise<UnlistenFn>;
  212. /**
  213. * Emits an event to the backend and all Tauri windows.
  214. * The event will have this window's {@link WebviewWindow.label | label} as {@link Event.windowLabel | source window label}.
  215. *
  216. * @example
  217. * ```typescript
  218. * import { appWindow } from '@tauri-apps/api/window';
  219. * await appWindow.emit('window-loaded', { loggedIn: true, token: 'authToken' });
  220. * ```
  221. *
  222. * This function can also be used to communicate between windows:
  223. * ```typescript
  224. * import { appWindow } from '@tauri-apps/api/window';
  225. * await appWindow.listen('sync-data', (event) => { });
  226. *
  227. * // on another window...
  228. * import { WebviewWindow } from '@tauri-apps/api/window';
  229. * const otherWindow = WebviewWindow.getByLabel('other')
  230. * await otherWindow.emit('sync-data');
  231. * ```
  232. *
  233. * Global listeners are also triggered:
  234. * ```typescript
  235. * import { appWindow } from '@tauri-apps/api/window';
  236. * import { listen } from '@tauri-apps/api/event';
  237. * await listen('ping', (event) => { });
  238. *
  239. * await appWindow.emit('ping');
  240. * ```
  241. *
  242. * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
  243. * @param payload Event payload.
  244. */
  245. emit(event: string, payload?: unknown): Promise<void>;
  246. /** @ignore */
  247. _handleTauriEvent<T>(event: string, handler: EventCallback<T>): boolean;
  248. }
  249. /**
  250. * Manage the current window object.
  251. *
  252. * @ignore
  253. * @since 1.0.0
  254. */
  255. declare class WindowManager extends WebviewWindowHandle {
  256. /**
  257. * The scale factor that can be used to map physical pixels to logical pixels.
  258. * @example
  259. * ```typescript
  260. * import { appWindow } from '@tauri-apps/api/window';
  261. * const factor = await appWindow.scaleFactor();
  262. * ```
  263. *
  264. * @returns The window's monitor scale factor.
  265. * */
  266. scaleFactor(): Promise<number>;
  267. /**
  268. * The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.
  269. * @example
  270. * ```typescript
  271. * import { appWindow } from '@tauri-apps/api/window';
  272. * const position = await appWindow.innerPosition();
  273. * ```
  274. *
  275. * @returns The window's inner position.
  276. * */
  277. innerPosition(): Promise<PhysicalPosition>;
  278. /**
  279. * The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
  280. * @example
  281. * ```typescript
  282. * import { appWindow } from '@tauri-apps/api/window';
  283. * const position = await appWindow.outerPosition();
  284. * ```
  285. *
  286. * @returns The window's outer position.
  287. * */
  288. outerPosition(): Promise<PhysicalPosition>;
  289. /**
  290. * The physical size of the window's client area.
  291. * The client area is the content of the window, excluding the title bar and borders.
  292. * @example
  293. * ```typescript
  294. * import { appWindow } from '@tauri-apps/api/window';
  295. * const size = await appWindow.innerSize();
  296. * ```
  297. *
  298. * @returns The window's inner size.
  299. */
  300. innerSize(): Promise<PhysicalSize>;
  301. /**
  302. * The physical size of the entire window.
  303. * These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
  304. * @example
  305. * ```typescript
  306. * import { appWindow } from '@tauri-apps/api/window';
  307. * const size = await appWindow.outerSize();
  308. * ```
  309. *
  310. * @returns The window's outer size.
  311. */
  312. outerSize(): Promise<PhysicalSize>;
  313. /**
  314. * Gets the window's current fullscreen state.
  315. * @example
  316. * ```typescript
  317. * import { appWindow } from '@tauri-apps/api/window';
  318. * const fullscreen = await appWindow.isFullscreen();
  319. * ```
  320. *
  321. * @returns Whether the window is in fullscreen mode or not.
  322. * */
  323. isFullscreen(): Promise<boolean>;
  324. /**
  325. * Gets the window's current minimized state.
  326. * @example
  327. * ```typescript
  328. * import { appWindow } from '@tauri-apps/api/window';
  329. * const minimized = await appWindow.isMinimized();
  330. * ```
  331. *
  332. * @since 1.3.0
  333. * */
  334. isMinimized(): Promise<boolean>;
  335. /**
  336. * Gets the window's current maximized state.
  337. * @example
  338. * ```typescript
  339. * import { appWindow } from '@tauri-apps/api/window';
  340. * const maximized = await appWindow.isMaximized();
  341. * ```
  342. *
  343. * @returns Whether the window is maximized or not.
  344. * */
  345. isMaximized(): Promise<boolean>;
  346. /**
  347. * Gets the window's current focus state.
  348. * @example
  349. * ```typescript
  350. * import { appWindow } from '@tauri-apps/api/window';
  351. * const focused = await appWindow.isFocused();
  352. * ```
  353. *
  354. * @returns Whether the window is focused or not.
  355. *
  356. * @since 1.4
  357. * */
  358. isFocused(): Promise<boolean>;
  359. /**
  360. * Gets the window's current decorated state.
  361. * @example
  362. * ```typescript
  363. * import { appWindow } from '@tauri-apps/api/window';
  364. * const decorated = await appWindow.isDecorated();
  365. * ```
  366. *
  367. * @returns Whether the window is decorated or not.
  368. * */
  369. isDecorated(): Promise<boolean>;
  370. /**
  371. * Gets the window's current resizable state.
  372. * @example
  373. * ```typescript
  374. * import { appWindow } from '@tauri-apps/api/window';
  375. * const resizable = await appWindow.isResizable();
  376. * ```
  377. *
  378. * @returns Whether the window is resizable or not.
  379. * */
  380. isResizable(): Promise<boolean>;
  381. /**
  382. * Gets the window’s native maximize button state.
  383. *
  384. * #### Platform-specific
  385. *
  386. * - **Linux / iOS / Android:** Unsupported.
  387. *
  388. * @example
  389. * ```typescript
  390. * import { appWindow } from '@tauri-apps/api/window';
  391. * const maximizable = await appWindow.isMaximizable();
  392. * ```
  393. *
  394. * @returns Whether the window's native maximize button is enabled or not.
  395. * */
  396. isMaximizable(): Promise<boolean>;
  397. /**
  398. * Gets the window’s native minimize button state.
  399. *
  400. * #### Platform-specific
  401. *
  402. * - **Linux / iOS / Android:** Unsupported.
  403. *
  404. * @example
  405. * ```typescript
  406. * import { appWindow } from '@tauri-apps/api/window';
  407. * const minimizable = await appWindow.isMinimizable();
  408. * ```
  409. *
  410. * @returns Whether the window's native minimize button is enabled or not.
  411. * */
  412. isMinimizable(): Promise<boolean>;
  413. /**
  414. * Gets the window’s native close button state.
  415. *
  416. * #### Platform-specific
  417. *
  418. * - **Linux / iOS / Android:** Unsupported.
  419. *
  420. * @example
  421. * ```typescript
  422. * import { appWindow } from '@tauri-apps/api/window';
  423. * const closable = await appWindow.isClosable();
  424. * ```
  425. *
  426. * @returns Whether the window's native close button is enabled or not.
  427. * */
  428. isClosable(): Promise<boolean>;
  429. /**
  430. * Gets the window's current visible state.
  431. * @example
  432. * ```typescript
  433. * import { appWindow } from '@tauri-apps/api/window';
  434. * const visible = await appWindow.isVisible();
  435. * ```
  436. *
  437. * @returns Whether the window is visible or not.
  438. * */
  439. isVisible(): Promise<boolean>;
  440. /**
  441. * Gets the window's current title.
  442. * @example
  443. * ```typescript
  444. * import { appWindow } from '@tauri-apps/api/window';
  445. * const title = await appWindow.title();
  446. * ```
  447. *
  448. * @since 1.3.0
  449. * */
  450. title(): Promise<string>;
  451. /**
  452. * Gets the window's current theme.
  453. *
  454. * #### Platform-specific
  455. *
  456. * - **macOS:** Theme was introduced on macOS 10.14. Returns `light` on macOS 10.13 and below.
  457. *
  458. * @example
  459. * ```typescript
  460. * import { appWindow } from '@tauri-apps/api/window';
  461. * const theme = await appWindow.theme();
  462. * ```
  463. *
  464. * @returns The window theme.
  465. * */
  466. theme(): Promise<Theme | null>;
  467. /**
  468. * Centers the window.
  469. * @example
  470. * ```typescript
  471. * import { appWindow } from '@tauri-apps/api/window';
  472. * await appWindow.center();
  473. * ```
  474. *
  475. * @returns A promise indicating the success or failure of the operation.
  476. */
  477. center(): Promise<void>;
  478. /**
  479. * Requests user attention to the window, this has no effect if the application
  480. * is already focused. How requesting for user attention manifests is platform dependent,
  481. * see `UserAttentionType` for details.
  482. *
  483. * Providing `null` will unset the request for user attention. Unsetting the request for
  484. * user attention might not be done automatically by the WM when the window receives input.
  485. *
  486. * #### Platform-specific
  487. *
  488. * - **macOS:** `null` has no effect.
  489. * - **Linux:** Urgency levels have the same effect.
  490. * @example
  491. * ```typescript
  492. * import { appWindow } from '@tauri-apps/api/window';
  493. * await appWindow.requestUserAttention();
  494. * ```
  495. *
  496. * @param requestType
  497. * @returns A promise indicating the success or failure of the operation.
  498. */
  499. requestUserAttention(requestType: UserAttentionType | null): Promise<void>;
  500. /**
  501. * Updates the window resizable flag.
  502. * @example
  503. * ```typescript
  504. * import { appWindow } from '@tauri-apps/api/window';
  505. * await appWindow.setResizable(false);
  506. * ```
  507. *
  508. * @param resizable
  509. * @returns A promise indicating the success or failure of the operation.
  510. */
  511. setResizable(resizable: boolean): Promise<void>;
  512. /**
  513. * Sets whether the window's native maximize button is enabled or not.
  514. * If resizable is set to false, this setting is ignored.
  515. *
  516. * #### Platform-specific
  517. *
  518. * - **macOS:** Disables the "zoom" button in the window titlebar, which is also used to enter fullscreen mode.
  519. * - **Linux / iOS / Android:** Unsupported.
  520. *
  521. * @example
  522. * ```typescript
  523. * import { appWindow } from '@tauri-apps/api/window';
  524. * await appWindow.setMaximizable(false);
  525. * ```
  526. *
  527. * @param maximizable
  528. * @returns A promise indicating the success or failure of the operation.
  529. */
  530. setMaximizable(maximizable: boolean): Promise<void>;
  531. /**
  532. * Sets whether the window's native minimize button is enabled or not.
  533. *
  534. * #### Platform-specific
  535. *
  536. * - **Linux / iOS / Android:** Unsupported.
  537. *
  538. * @example
  539. * ```typescript
  540. * import { appWindow } from '@tauri-apps/api/window';
  541. * await appWindow.setMinimizable(false);
  542. * ```
  543. *
  544. * @param minimizable
  545. * @returns A promise indicating the success or failure of the operation.
  546. */
  547. setMinimizable(minimizable: boolean): Promise<void>;
  548. /**
  549. * Sets whether the window's native close button is enabled or not.
  550. *
  551. * #### Platform-specific
  552. *
  553. * - **Linux:** GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible
  554. * - **iOS / Android:** Unsupported.
  555. *
  556. * @example
  557. * ```typescript
  558. * import { appWindow } from '@tauri-apps/api/window';
  559. * await appWindow.setClosable(false);
  560. * ```
  561. *
  562. * @param closable
  563. * @returns A promise indicating the success or failure of the operation.
  564. */
  565. setClosable(closable: boolean): Promise<void>;
  566. /**
  567. * Sets the window title.
  568. * @example
  569. * ```typescript
  570. * import { appWindow } from '@tauri-apps/api/window';
  571. * await appWindow.setTitle('Tauri');
  572. * ```
  573. *
  574. * @param title The new title
  575. * @returns A promise indicating the success or failure of the operation.
  576. */
  577. setTitle(title: string): Promise<void>;
  578. /**
  579. * Maximizes the window.
  580. * @example
  581. * ```typescript
  582. * import { appWindow } from '@tauri-apps/api/window';
  583. * await appWindow.maximize();
  584. * ```
  585. *
  586. * @returns A promise indicating the success or failure of the operation.
  587. */
  588. maximize(): Promise<void>;
  589. /**
  590. * Unmaximizes the window.
  591. * @example
  592. * ```typescript
  593. * import { appWindow } from '@tauri-apps/api/window';
  594. * await appWindow.unmaximize();
  595. * ```
  596. *
  597. * @returns A promise indicating the success or failure of the operation.
  598. */
  599. unmaximize(): Promise<void>;
  600. /**
  601. * Toggles the window maximized state.
  602. * @example
  603. * ```typescript
  604. * import { appWindow } from '@tauri-apps/api/window';
  605. * await appWindow.toggleMaximize();
  606. * ```
  607. *
  608. * @returns A promise indicating the success or failure of the operation.
  609. */
  610. toggleMaximize(): Promise<void>;
  611. /**
  612. * Minimizes the window.
  613. * @example
  614. * ```typescript
  615. * import { appWindow } from '@tauri-apps/api/window';
  616. * await appWindow.minimize();
  617. * ```
  618. *
  619. * @returns A promise indicating the success or failure of the operation.
  620. */
  621. minimize(): Promise<void>;
  622. /**
  623. * Unminimizes the window.
  624. * @example
  625. * ```typescript
  626. * import { appWindow } from '@tauri-apps/api/window';
  627. * await appWindow.unminimize();
  628. * ```
  629. *
  630. * @returns A promise indicating the success or failure of the operation.
  631. */
  632. unminimize(): Promise<void>;
  633. /**
  634. * Sets the window visibility to true.
  635. * @example
  636. * ```typescript
  637. * import { appWindow } from '@tauri-apps/api/window';
  638. * await appWindow.show();
  639. * ```
  640. *
  641. * @returns A promise indicating the success or failure of the operation.
  642. */
  643. show(): Promise<void>;
  644. /**
  645. * Sets the window visibility to false.
  646. * @example
  647. * ```typescript
  648. * import { appWindow } from '@tauri-apps/api/window';
  649. * await appWindow.hide();
  650. * ```
  651. *
  652. * @returns A promise indicating the success or failure of the operation.
  653. */
  654. hide(): Promise<void>;
  655. /**
  656. * Closes the window.
  657. * @example
  658. * ```typescript
  659. * import { appWindow } from '@tauri-apps/api/window';
  660. * await appWindow.close();
  661. * ```
  662. *
  663. * @returns A promise indicating the success or failure of the operation.
  664. */
  665. close(): Promise<void>;
  666. /**
  667. * Whether the window should have borders and bars.
  668. * @example
  669. * ```typescript
  670. * import { appWindow } from '@tauri-apps/api/window';
  671. * await appWindow.setDecorations(false);
  672. * ```
  673. *
  674. * @param decorations Whether the window should have borders and bars.
  675. * @returns A promise indicating the success or failure of the operation.
  676. */
  677. setDecorations(decorations: boolean): Promise<void>;
  678. /**
  679. * Whether the window should always be on top of other windows.
  680. * @example
  681. * ```typescript
  682. * import { appWindow } from '@tauri-apps/api/window';
  683. * await appWindow.setAlwaysOnTop(true);
  684. * ```
  685. *
  686. * @param alwaysOnTop Whether the window should always be on top of other windows or not.
  687. * @returns A promise indicating the success or failure of the operation.
  688. */
  689. setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
  690. /**
  691. * Prevents the window contents from being captured by other apps.
  692. * @example
  693. * ```typescript
  694. * import { appWindow } from '@tauri-apps/api/window';
  695. * await appWindow.setContentProtected(true);
  696. * ```
  697. *
  698. * @returns A promise indicating the success or failure of the operation.
  699. *
  700. * @since 1.2.0
  701. */
  702. setContentProtected(protected_: boolean): Promise<void>;
  703. /**
  704. * Resizes the window with a new inner size.
  705. * @example
  706. * ```typescript
  707. * import { appWindow, LogicalSize } from '@tauri-apps/api/window';
  708. * await appWindow.setSize(new LogicalSize(600, 500));
  709. * ```
  710. *
  711. * @param size The logical or physical inner size.
  712. * @returns A promise indicating the success or failure of the operation.
  713. */
  714. setSize(size: LogicalSize | PhysicalSize): Promise<void>;
  715. /**
  716. * Sets the window minimum inner size. If the `size` argument is not provided, the constraint is unset.
  717. * @example
  718. * ```typescript
  719. * import { appWindow, PhysicalSize } from '@tauri-apps/api/window';
  720. * await appWindow.setMinSize(new PhysicalSize(600, 500));
  721. * ```
  722. *
  723. * @param size The logical or physical inner size, or `null` to unset the constraint.
  724. * @returns A promise indicating the success or failure of the operation.
  725. */
  726. setMinSize(size: LogicalSize | PhysicalSize | null | undefined): Promise<void>;
  727. /**
  728. * Sets the window maximum inner size. If the `size` argument is undefined, the constraint is unset.
  729. * @example
  730. * ```typescript
  731. * import { appWindow, LogicalSize } from '@tauri-apps/api/window';
  732. * await appWindow.setMaxSize(new LogicalSize(600, 500));
  733. * ```
  734. *
  735. * @param size The logical or physical inner size, or `null` to unset the constraint.
  736. * @returns A promise indicating the success or failure of the operation.
  737. */
  738. setMaxSize(size: LogicalSize | PhysicalSize | null | undefined): Promise<void>;
  739. /**
  740. * Sets the window outer position.
  741. * @example
  742. * ```typescript
  743. * import { appWindow, LogicalPosition } from '@tauri-apps/api/window';
  744. * await appWindow.setPosition(new LogicalPosition(600, 500));
  745. * ```
  746. *
  747. * @param position The new position, in logical or physical pixels.
  748. * @returns A promise indicating the success or failure of the operation.
  749. */
  750. setPosition(position: LogicalPosition | PhysicalPosition): Promise<void>;
  751. /**
  752. * Sets the window fullscreen state.
  753. * @example
  754. * ```typescript
  755. * import { appWindow } from '@tauri-apps/api/window';
  756. * await appWindow.setFullscreen(true);
  757. * ```
  758. *
  759. * @param fullscreen Whether the window should go to fullscreen or not.
  760. * @returns A promise indicating the success or failure of the operation.
  761. */
  762. setFullscreen(fullscreen: boolean): Promise<void>;
  763. /**
  764. * Bring the window to front and focus.
  765. * @example
  766. * ```typescript
  767. * import { appWindow } from '@tauri-apps/api/window';
  768. * await appWindow.setFocus();
  769. * ```
  770. *
  771. * @returns A promise indicating the success or failure of the operation.
  772. */
  773. setFocus(): Promise<void>;
  774. /**
  775. * Sets the window icon.
  776. * @example
  777. * ```typescript
  778. * import { appWindow } from '@tauri-apps/api/window';
  779. * await appWindow.setIcon('/tauri/awesome.png');
  780. * ```
  781. *
  782. * Note that you need the `icon-ico` or `icon-png` Cargo features to use this API.
  783. * To enable it, change your Cargo.toml file:
  784. * ```toml
  785. * [dependencies]
  786. * tauri = { version = "...", features = ["...", "icon-png"] }
  787. * ```
  788. *
  789. * @param icon Icon bytes or path to the icon file.
  790. * @returns A promise indicating the success or failure of the operation.
  791. */
  792. setIcon(icon: string | Uint8Array): Promise<void>;
  793. /**
  794. * Whether the window icon should be hidden from the taskbar or not.
  795. *
  796. * #### Platform-specific
  797. *
  798. * - **macOS:** Unsupported.
  799. * @example
  800. * ```typescript
  801. * import { appWindow } from '@tauri-apps/api/window';
  802. * await appWindow.setSkipTaskbar(true);
  803. * ```
  804. *
  805. * @param skip true to hide window icon, false to show it.
  806. * @returns A promise indicating the success or failure of the operation.
  807. */
  808. setSkipTaskbar(skip: boolean): Promise<void>;
  809. /**
  810. * Grabs the cursor, preventing it from leaving the window.
  811. *
  812. * There's no guarantee that the cursor will be hidden. You should
  813. * hide it by yourself if you want so.
  814. *
  815. * #### Platform-specific
  816. *
  817. * - **Linux:** Unsupported.
  818. * - **macOS:** This locks the cursor in a fixed location, which looks visually awkward.
  819. * @example
  820. * ```typescript
  821. * import { appWindow } from '@tauri-apps/api/window';
  822. * await appWindow.setCursorGrab(true);
  823. * ```
  824. *
  825. * @param grab `true` to grab the cursor icon, `false` to release it.
  826. * @returns A promise indicating the success or failure of the operation.
  827. */
  828. setCursorGrab(grab: boolean): Promise<void>;
  829. /**
  830. * Modifies the cursor's visibility.
  831. *
  832. * #### Platform-specific
  833. *
  834. * - **Windows:** The cursor is only hidden within the confines of the window.
  835. * - **macOS:** The cursor is hidden as long as the window has input focus, even if the cursor is
  836. * outside of the window.
  837. * @example
  838. * ```typescript
  839. * import { appWindow } from '@tauri-apps/api/window';
  840. * await appWindow.setCursorVisible(false);
  841. * ```
  842. *
  843. * @param visible If `false`, this will hide the cursor. If `true`, this will show the cursor.
  844. * @returns A promise indicating the success or failure of the operation.
  845. */
  846. setCursorVisible(visible: boolean): Promise<void>;
  847. /**
  848. * Modifies the cursor icon of the window.
  849. * @example
  850. * ```typescript
  851. * import { appWindow } from '@tauri-apps/api/window';
  852. * await appWindow.setCursorIcon('help');
  853. * ```
  854. *
  855. * @param icon The new cursor icon.
  856. * @returns A promise indicating the success or failure of the operation.
  857. */
  858. setCursorIcon(icon: CursorIcon): Promise<void>;
  859. /**
  860. * Changes the position of the cursor in window coordinates.
  861. * @example
  862. * ```typescript
  863. * import { appWindow, LogicalPosition } from '@tauri-apps/api/window';
  864. * await appWindow.setCursorPosition(new LogicalPosition(600, 300));
  865. * ```
  866. *
  867. * @param position The new cursor position.
  868. * @returns A promise indicating the success or failure of the operation.
  869. */
  870. setCursorPosition(position: LogicalPosition | PhysicalPosition): Promise<void>;
  871. /**
  872. * Changes the cursor events behavior.
  873. *
  874. * @example
  875. * ```typescript
  876. * import { appWindow } from '@tauri-apps/api/window';
  877. * await appWindow.setIgnoreCursorEvents(true);
  878. * ```
  879. *
  880. * @param ignore `true` to ignore the cursor events; `false` to process them as usual.
  881. * @returns A promise indicating the success or failure of the operation.
  882. */
  883. setIgnoreCursorEvents(ignore: boolean): Promise<void>;
  884. /**
  885. * Starts dragging the window.
  886. * @example
  887. * ```typescript
  888. * import { appWindow } from '@tauri-apps/api/window';
  889. * await appWindow.startDragging();
  890. * ```
  891. *
  892. * @return A promise indicating the success or failure of the operation.
  893. */
  894. startDragging(): Promise<void>;
  895. /**
  896. * Listen to window resize.
  897. *
  898. * @example
  899. * ```typescript
  900. * import { appWindow } from "@tauri-apps/api/window";
  901. * const unlisten = await appWindow.onResized(({ payload: size }) => {
  902. * console.log('Window resized', size);
  903. * });
  904. *
  905. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  906. * unlisten();
  907. * ```
  908. *
  909. * @returns A promise resolving to a function to unlisten to the event.
  910. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  911. *
  912. * @since 1.0.2
  913. */
  914. onResized(handler: EventCallback<PhysicalSize>): Promise<UnlistenFn>;
  915. /**
  916. * Listen to window move.
  917. *
  918. * @example
  919. * ```typescript
  920. * import { appWindow } from "@tauri-apps/api/window";
  921. * const unlisten = await appWindow.onMoved(({ payload: position }) => {
  922. * console.log('Window moved', position);
  923. * });
  924. *
  925. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  926. * unlisten();
  927. * ```
  928. *
  929. * @returns A promise resolving to a function to unlisten to the event.
  930. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  931. *
  932. * @since 1.0.2
  933. */
  934. onMoved(handler: EventCallback<PhysicalPosition>): Promise<UnlistenFn>;
  935. /**
  936. * Listen to window close requested. Emitted when the user requests to closes the window.
  937. *
  938. * @example
  939. * ```typescript
  940. * import { appWindow } from "@tauri-apps/api/window";
  941. * import { confirm } from '@tauri-apps/api/dialog';
  942. * const unlisten = await appWindow.onCloseRequested(async (event) => {
  943. * const confirmed = await confirm('Are you sure?');
  944. * if (!confirmed) {
  945. * // user did not confirm closing the window; let's prevent it
  946. * event.preventDefault();
  947. * }
  948. * });
  949. *
  950. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  951. * unlisten();
  952. * ```
  953. *
  954. * @returns A promise resolving to a function to unlisten to the event.
  955. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  956. *
  957. * @since 1.0.2
  958. */
  959. onCloseRequested(handler: (event: CloseRequestedEvent) => void | Promise<void>): Promise<UnlistenFn>;
  960. /**
  961. * Listen to window focus change.
  962. *
  963. * @example
  964. * ```typescript
  965. * import { appWindow } from "@tauri-apps/api/window";
  966. * const unlisten = await appWindow.onFocusChanged(({ payload: focused }) => {
  967. * console.log('Focus changed, window is focused? ' + focused);
  968. * });
  969. *
  970. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  971. * unlisten();
  972. * ```
  973. *
  974. * @returns A promise resolving to a function to unlisten to the event.
  975. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  976. *
  977. * @since 1.0.2
  978. */
  979. onFocusChanged(handler: EventCallback<boolean>): Promise<UnlistenFn>;
  980. /**
  981. * Listen to window scale change. Emitted when the window's scale factor has changed.
  982. * The following user actions can cause DPI changes:
  983. * - Changing the display's resolution.
  984. * - Changing the display's scale factor (e.g. in Control Panel on Windows).
  985. * - Moving the window to a display with a different scale factor.
  986. *
  987. * @example
  988. * ```typescript
  989. * import { appWindow } from "@tauri-apps/api/window";
  990. * const unlisten = await appWindow.onScaleChanged(({ payload }) => {
  991. * console.log('Scale changed', payload.scaleFactor, payload.size);
  992. * });
  993. *
  994. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  995. * unlisten();
  996. * ```
  997. *
  998. * @returns A promise resolving to a function to unlisten to the event.
  999. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  1000. *
  1001. * @since 1.0.2
  1002. */
  1003. onScaleChanged(handler: EventCallback<ScaleFactorChanged>): Promise<UnlistenFn>;
  1004. /**
  1005. * Listen to the window menu item click. The payload is the item id.
  1006. *
  1007. * @example
  1008. * ```typescript
  1009. * import { appWindow } from "@tauri-apps/api/window";
  1010. * const unlisten = await appWindow.onMenuClicked(({ payload: menuId }) => {
  1011. * console.log('Menu clicked: ' + menuId);
  1012. * });
  1013. *
  1014. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  1015. * unlisten();
  1016. * ```
  1017. *
  1018. * @returns A promise resolving to a function to unlisten to the event.
  1019. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  1020. *
  1021. * @since 1.0.2
  1022. */
  1023. onMenuClicked(handler: EventCallback<string>): Promise<UnlistenFn>;
  1024. /**
  1025. * Listen to a file drop event.
  1026. * The listener is triggered when the user hovers the selected files on the window,
  1027. * drops the files or cancels the operation.
  1028. *
  1029. * @example
  1030. * ```typescript
  1031. * import { appWindow } from "@tauri-apps/api/window";
  1032. * const unlisten = await appWindow.onFileDropEvent((event) => {
  1033. * if (event.payload.type === 'hover') {
  1034. * console.log('User hovering', event.payload.paths);
  1035. * } else if (event.payload.type === 'drop') {
  1036. * console.log('User dropped', event.payload.paths);
  1037. * } else {
  1038. * console.log('File drop cancelled');
  1039. * }
  1040. * });
  1041. *
  1042. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  1043. * unlisten();
  1044. * ```
  1045. *
  1046. * @returns A promise resolving to a function to unlisten to the event.
  1047. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  1048. *
  1049. * @since 1.0.2
  1050. */
  1051. onFileDropEvent(handler: EventCallback<FileDropEvent>): Promise<UnlistenFn>;
  1052. /**
  1053. * Listen to the system theme change.
  1054. *
  1055. * @example
  1056. * ```typescript
  1057. * import { appWindow } from "@tauri-apps/api/window";
  1058. * const unlisten = await appWindow.onThemeChanged(({ payload: theme }) => {
  1059. * console.log('New theme: ' + theme);
  1060. * });
  1061. *
  1062. * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
  1063. * unlisten();
  1064. * ```
  1065. *
  1066. * @returns A promise resolving to a function to unlisten to the event.
  1067. * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
  1068. *
  1069. * @since 1.0.2
  1070. */
  1071. onThemeChanged(handler: EventCallback<Theme>): Promise<UnlistenFn>;
  1072. }
  1073. /**
  1074. * @since 1.0.2
  1075. */
  1076. declare class CloseRequestedEvent {
  1077. /** Event name */
  1078. event: EventName;
  1079. /** The label of the window that emitted this event. */
  1080. windowLabel: string;
  1081. /** Event identifier used to unlisten */
  1082. id: number;
  1083. private _preventDefault;
  1084. constructor(event: Event<null>);
  1085. preventDefault(): void;
  1086. isPreventDefault(): boolean;
  1087. }
  1088. /**
  1089. * Create new webview windows and get a handle to existing ones.
  1090. *
  1091. * Windows are identified by a *label* a unique identifier that can be used to reference it later.
  1092. * It may only contain alphanumeric characters `a-zA-Z` plus the following special characters `-`, `/`, `:` and `_`.
  1093. *
  1094. * @example
  1095. * ```typescript
  1096. * // loading embedded asset:
  1097. * const webview = new WebviewWindow('theUniqueLabel', {
  1098. * url: 'path/to/page.html'
  1099. * });
  1100. * // alternatively, load a remote URL:
  1101. * const webview = new WebviewWindow('theUniqueLabel', {
  1102. * url: 'https://github.com/tauri-apps/tauri'
  1103. * });
  1104. *
  1105. * webview.once('tauri://created', function () {
  1106. * // webview window successfully created
  1107. * });
  1108. * webview.once('tauri://error', function (e) {
  1109. * // an error happened creating the webview window
  1110. * });
  1111. *
  1112. * // emit an event to the backend
  1113. * await webview.emit("some event", "data");
  1114. * // listen to an event from the backend
  1115. * const unlisten = await webview.listen("event name", e => {});
  1116. * unlisten();
  1117. * ```
  1118. *
  1119. * @since 1.0.2
  1120. */
  1121. declare class WebviewWindow extends WindowManager {
  1122. /**
  1123. * Creates a new WebviewWindow.
  1124. * @example
  1125. * ```typescript
  1126. * import { WebviewWindow } from '@tauri-apps/api/window';
  1127. * const webview = new WebviewWindow('my-label', {
  1128. * url: 'https://github.com/tauri-apps/tauri'
  1129. * });
  1130. * webview.once('tauri://created', function () {
  1131. * // webview window successfully created
  1132. * });
  1133. * webview.once('tauri://error', function (e) {
  1134. * // an error happened creating the webview window
  1135. * });
  1136. * ```
  1137. *
  1138. * * @param label The unique webview window label. Must be alphanumeric: `a-zA-Z-/:_`.
  1139. * @returns The WebviewWindow instance to communicate with the webview.
  1140. */
  1141. constructor(label: WindowLabel, options?: WindowOptions);
  1142. /**
  1143. * Gets the WebviewWindow for the webview associated with the given label.
  1144. * @example
  1145. * ```typescript
  1146. * import { WebviewWindow } from '@tauri-apps/api/window';
  1147. * const mainWindow = WebviewWindow.getByLabel('main');
  1148. * ```
  1149. *
  1150. * @param label The webview window label.
  1151. * @returns The WebviewWindow instance to communicate with the webview or null if the webview doesn't exist.
  1152. */
  1153. static getByLabel(label: string): WebviewWindow | null;
  1154. /**
  1155. * Gets the focused window.
  1156. * @example
  1157. * ```typescript
  1158. * import { WebviewWindow } from '@tauri-apps/api/window';
  1159. * const focusedWindow = WebviewWindow.getFocusedWindow();
  1160. * ```
  1161. *
  1162. * @returns The WebviewWindow instance to communicate with the webview or `undefined` if there is not any focused window.
  1163. *
  1164. * @since 1.4
  1165. */
  1166. static getFocusedWindow(): Promise<WebviewWindow | null>;
  1167. }
  1168. /** The WebviewWindow for the current window. */
  1169. declare let appWindow: WebviewWindow;
  1170. /**
  1171. * Configuration for the window to create.
  1172. *
  1173. * @since 1.0.0
  1174. */
  1175. interface WindowOptions {
  1176. /**
  1177. * Remote URL or local file path to open.
  1178. *
  1179. * - URL such as `https://github.com/tauri-apps` is opened directly on a Tauri window.
  1180. * - data: URL such as `data:text/html,<html>...` is only supported with the `window-data-url` Cargo feature for the `tauri` dependency.
  1181. * - local file path or route such as `/path/to/page.html` or `/users` is appended to the application URL (the devServer URL on development, or `tauri://localhost/` and `https://tauri.localhost/` on production).
  1182. */
  1183. url?: string;
  1184. /** Show window in the center of the screen.. */
  1185. center?: boolean;
  1186. /** The initial vertical position. Only applies if `y` is also set. */
  1187. x?: number;
  1188. /** The initial horizontal position. Only applies if `x` is also set. */
  1189. y?: number;
  1190. /** The initial width. */
  1191. width?: number;
  1192. /** The initial height. */
  1193. height?: number;
  1194. /** The minimum width. Only applies if `minHeight` is also set. */
  1195. minWidth?: number;
  1196. /** The minimum height. Only applies if `minWidth` is also set. */
  1197. minHeight?: number;
  1198. /** The maximum width. Only applies if `maxHeight` is also set. */
  1199. maxWidth?: number;
  1200. /** The maximum height. Only applies if `maxWidth` is also set. */
  1201. maxHeight?: number;
  1202. /** Whether the window is resizable or not. */
  1203. resizable?: boolean;
  1204. /** Window title. */
  1205. title?: string;
  1206. /** Whether the window is in fullscreen mode or not. */
  1207. fullscreen?: boolean;
  1208. /** Whether the window will be initially focused or not. */
  1209. focus?: boolean;
  1210. /**
  1211. * Whether the window is transparent or not.
  1212. * Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > tauri > macOSPrivateApi`.
  1213. * WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.
  1214. */
  1215. transparent?: boolean;
  1216. /** Whether the window should be maximized upon creation or not. */
  1217. maximized?: boolean;
  1218. /** Whether the window should be immediately visible upon creation or not. */
  1219. visible?: boolean;
  1220. /** Whether the window should have borders and bars or not. */
  1221. decorations?: boolean;
  1222. /** Whether the window should always be on top of other windows or not. */
  1223. alwaysOnTop?: boolean;
  1224. /** Prevents the window contents from being captured by other apps. */
  1225. contentProtected?: boolean;
  1226. /** Whether or not the window icon should be added to the taskbar. */
  1227. skipTaskbar?: boolean;
  1228. /**
  1229. * Whether the file drop is enabled or not on the webview. By default it is enabled.
  1230. *
  1231. * Disabling it is required to use drag and drop on the frontend on Windows.
  1232. */
  1233. fileDropEnabled?: boolean;
  1234. /**
  1235. * The initial window theme. Defaults to the system theme.
  1236. *
  1237. * Only implemented on Windows and macOS 10.14+.
  1238. */
  1239. theme?: Theme;
  1240. /**
  1241. * The style of the macOS title bar.
  1242. */
  1243. titleBarStyle?: TitleBarStyle;
  1244. /**
  1245. * If `true`, sets the window title to be hidden on macOS.
  1246. */
  1247. hiddenTitle?: boolean;
  1248. /**
  1249. * Whether clicking an inactive window also clicks through to the webview on macOS.
  1250. */
  1251. acceptFirstMouse?: boolean;
  1252. /**
  1253. * Defines the window [tabbing identifier](https://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier) on macOS.
  1254. *
  1255. * Windows with the same tabbing identifier will be grouped together.
  1256. * If the tabbing identifier is not set, automatic tabbing will be disabled.
  1257. */
  1258. tabbingIdentifier?: string;
  1259. /**
  1260. * The user agent for the webview.
  1261. */
  1262. userAgent?: string;
  1263. /**
  1264. * Whether the window's native maximize button is enabled or not. Defaults to `true`.
  1265. */
  1266. maximizable?: boolean;
  1267. /**
  1268. * Whether the window's native minimize button is enabled or not. Defaults to `true`.
  1269. */
  1270. minimizable?: boolean;
  1271. /**
  1272. * Whether the window's native close button is enabled or not. Defaults to `true`.
  1273. */
  1274. closable?: boolean;
  1275. }
  1276. /**
  1277. * Returns the monitor on which the window currently resides.
  1278. * Returns `null` if current monitor can't be detected.
  1279. * @example
  1280. * ```typescript
  1281. * import { currentMonitor } from '@tauri-apps/api/window';
  1282. * const monitor = currentMonitor();
  1283. * ```
  1284. *
  1285. * @since 1.0.0
  1286. */
  1287. declare function currentMonitor(): Promise<Monitor | null>;
  1288. /**
  1289. * Returns the primary monitor of the system.
  1290. * Returns `null` if it can't identify any monitor as a primary one.
  1291. * @example
  1292. * ```typescript
  1293. * import { primaryMonitor } from '@tauri-apps/api/window';
  1294. * const monitor = primaryMonitor();
  1295. * ```
  1296. *
  1297. * @since 1.0.0
  1298. */
  1299. declare function primaryMonitor(): Promise<Monitor | null>;
  1300. /**
  1301. * Returns the list of all the monitors available on the system.
  1302. * @example
  1303. * ```typescript
  1304. * import { availableMonitors } from '@tauri-apps/api/window';
  1305. * const monitors = availableMonitors();
  1306. * ```
  1307. *
  1308. * @since 1.0.0
  1309. */
  1310. declare function availableMonitors(): Promise<Monitor[]>;
  1311. export { WebviewWindow, WebviewWindowHandle, WindowManager, CloseRequestedEvent, getCurrent, getAll, appWindow, LogicalSize, PhysicalSize, LogicalPosition, PhysicalPosition, UserAttentionType, currentMonitor, primaryMonitor, availableMonitors };
  1312. export type { Theme, TitleBarStyle, Monitor, ScaleFactorChanged, FileDropEvent, WindowOptions };