@tauri-apps/plugin-window-state 2.4.1 → 2.5.1

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/README.md CHANGED
@@ -12,7 +12,7 @@ Save window positions and sizes and restore them when the app is reopened.
12
12
 
13
13
  ## Install
14
14
 
15
- _This plugin requires a Rust version of at least **1.77.2**_
15
+ _This plugin requires a Rust version of at least **1.94**_
16
16
 
17
17
  There are three general methods of installation that we can recommend.
18
18
 
package/dist-js/index.cjs CHANGED
@@ -6,36 +6,93 @@ var window = require('@tauri-apps/api/window');
6
6
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
7
7
  // SPDX-License-Identifier: Apache-2.0
8
8
  // SPDX-License-Identifier: MIT
9
+ /**
10
+ * Save and restore window positions and sizes.
11
+ *
12
+ * @module
13
+ */
14
+ /**
15
+ * Flags controlling which parts of a window's state are saved and restored.
16
+ * Combine multiple flags with the bitwise OR operator (`|`).
17
+ */
9
18
  exports.StateFlags = void 0;
10
19
  (function (StateFlags) {
20
+ /** Save and restore the window size. */
11
21
  StateFlags[StateFlags["SIZE"] = 1] = "SIZE";
22
+ /** Save and restore the window position. */
12
23
  StateFlags[StateFlags["POSITION"] = 2] = "POSITION";
24
+ /** Save and restore whether the window is maximized. */
13
25
  StateFlags[StateFlags["MAXIMIZED"] = 4] = "MAXIMIZED";
26
+ /** Save and restore whether the window is visible. */
14
27
  StateFlags[StateFlags["VISIBLE"] = 8] = "VISIBLE";
28
+ /** Save and restore whether the window has decorations. */
15
29
  StateFlags[StateFlags["DECORATIONS"] = 16] = "DECORATIONS";
30
+ /** Save and restore whether the window is fullscreen. */
16
31
  StateFlags[StateFlags["FULLSCREEN"] = 32] = "FULLSCREEN";
32
+ /** Save and restore every flag above. */
17
33
  StateFlags[StateFlags["ALL"] = 63] = "ALL";
18
34
  })(exports.StateFlags || (exports.StateFlags = {}));
19
35
  /**
20
36
  * Save the state of all open windows to disk.
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state';
41
+ *
42
+ * await saveWindowState(StateFlags.ALL);
43
+ * ```
44
+ *
45
+ * @param flags Which parts of the state to save. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
46
+ * @since 2.0.0
21
47
  */
22
48
  async function saveWindowState(flags) {
23
49
  await core.invoke('plugin:window-state|save_window_state', { flags });
24
50
  }
25
51
  /**
26
52
  * Restore the state for the specified window from disk.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * import { restoreState, StateFlags } from '@tauri-apps/plugin-window-state';
57
+ *
58
+ * await restoreState('main', StateFlags.ALL);
59
+ * ```
60
+ *
61
+ * @param label The label of the window to restore.
62
+ * @param flags Which parts of the state to restore. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
63
+ * @since 2.0.0
27
64
  */
28
65
  async function restoreState(label, flags) {
29
66
  await core.invoke('plugin:window-state|restore_state', { label, flags });
30
67
  }
31
68
  /**
32
69
  * Restore the state for the current window from disk.
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * import { restoreStateCurrent, StateFlags } from '@tauri-apps/plugin-window-state';
74
+ *
75
+ * await restoreStateCurrent(StateFlags.ALL);
76
+ * ```
77
+ *
78
+ * @param flags Which parts of the state to restore. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
79
+ * @since 2.0.0
33
80
  */
34
81
  async function restoreStateCurrent(flags) {
35
82
  await restoreState(window.getCurrentWindow().label, flags);
36
83
  }
37
84
  /**
38
85
  * Get the name of the file used to store window state.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * import { filename } from '@tauri-apps/plugin-window-state';
90
+ *
91
+ * const name = await filename();
92
+ * ```
93
+ *
94
+ * @returns A promise resolving to the name of the file used to store window state.
95
+ * @since 2.0.0
39
96
  */
40
97
  async function filename() {
41
98
  return await core.invoke('plugin:window-state|filename');
@@ -1,27 +1,79 @@
1
1
  import { type WindowLabel } from '@tauri-apps/api/window';
2
+ /**
3
+ * Flags controlling which parts of a window's state are saved and restored.
4
+ * Combine multiple flags with the bitwise OR operator (`|`).
5
+ */
2
6
  export declare enum StateFlags {
7
+ /** Save and restore the window size. */
3
8
  SIZE = 1,
9
+ /** Save and restore the window position. */
4
10
  POSITION = 2,
11
+ /** Save and restore whether the window is maximized. */
5
12
  MAXIMIZED = 4,
13
+ /** Save and restore whether the window is visible. */
6
14
  VISIBLE = 8,
15
+ /** Save and restore whether the window has decorations. */
7
16
  DECORATIONS = 16,
17
+ /** Save and restore whether the window is fullscreen. */
8
18
  FULLSCREEN = 32,
19
+ /** Save and restore every flag above. */
9
20
  ALL = 63
10
21
  }
11
22
  /**
12
23
  * Save the state of all open windows to disk.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state';
28
+ *
29
+ * await saveWindowState(StateFlags.ALL);
30
+ * ```
31
+ *
32
+ * @param flags Which parts of the state to save. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
33
+ * @since 2.0.0
13
34
  */
14
35
  declare function saveWindowState(flags?: StateFlags): Promise<void>;
15
36
  /**
16
37
  * Restore the state for the specified window from disk.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { restoreState, StateFlags } from '@tauri-apps/plugin-window-state';
42
+ *
43
+ * await restoreState('main', StateFlags.ALL);
44
+ * ```
45
+ *
46
+ * @param label The label of the window to restore.
47
+ * @param flags Which parts of the state to restore. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
48
+ * @since 2.0.0
17
49
  */
18
50
  declare function restoreState(label: WindowLabel, flags?: StateFlags): Promise<void>;
19
51
  /**
20
52
  * Restore the state for the current window from disk.
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * import { restoreStateCurrent, StateFlags } from '@tauri-apps/plugin-window-state';
57
+ *
58
+ * await restoreStateCurrent(StateFlags.ALL);
59
+ * ```
60
+ *
61
+ * @param flags Which parts of the state to restore. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
62
+ * @since 2.0.0
21
63
  */
22
64
  declare function restoreStateCurrent(flags?: StateFlags): Promise<void>;
23
65
  /**
24
66
  * Get the name of the file used to store window state.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * import { filename } from '@tauri-apps/plugin-window-state';
71
+ *
72
+ * const name = await filename();
73
+ * ```
74
+ *
75
+ * @returns A promise resolving to the name of the file used to store window state.
76
+ * @since 2.0.0
25
77
  */
26
78
  declare function filename(): Promise<string>;
27
79
  export { restoreState, restoreStateCurrent, saveWindowState, filename };
package/dist-js/index.js CHANGED
@@ -4,36 +4,93 @@ import { getCurrentWindow } from '@tauri-apps/api/window';
4
4
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
5
5
  // SPDX-License-Identifier: Apache-2.0
6
6
  // SPDX-License-Identifier: MIT
7
+ /**
8
+ * Save and restore window positions and sizes.
9
+ *
10
+ * @module
11
+ */
12
+ /**
13
+ * Flags controlling which parts of a window's state are saved and restored.
14
+ * Combine multiple flags with the bitwise OR operator (`|`).
15
+ */
7
16
  var StateFlags;
8
17
  (function (StateFlags) {
18
+ /** Save and restore the window size. */
9
19
  StateFlags[StateFlags["SIZE"] = 1] = "SIZE";
20
+ /** Save and restore the window position. */
10
21
  StateFlags[StateFlags["POSITION"] = 2] = "POSITION";
22
+ /** Save and restore whether the window is maximized. */
11
23
  StateFlags[StateFlags["MAXIMIZED"] = 4] = "MAXIMIZED";
24
+ /** Save and restore whether the window is visible. */
12
25
  StateFlags[StateFlags["VISIBLE"] = 8] = "VISIBLE";
26
+ /** Save and restore whether the window has decorations. */
13
27
  StateFlags[StateFlags["DECORATIONS"] = 16] = "DECORATIONS";
28
+ /** Save and restore whether the window is fullscreen. */
14
29
  StateFlags[StateFlags["FULLSCREEN"] = 32] = "FULLSCREEN";
30
+ /** Save and restore every flag above. */
15
31
  StateFlags[StateFlags["ALL"] = 63] = "ALL";
16
32
  })(StateFlags || (StateFlags = {}));
17
33
  /**
18
34
  * Save the state of all open windows to disk.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state';
39
+ *
40
+ * await saveWindowState(StateFlags.ALL);
41
+ * ```
42
+ *
43
+ * @param flags Which parts of the state to save. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
44
+ * @since 2.0.0
19
45
  */
20
46
  async function saveWindowState(flags) {
21
47
  await invoke('plugin:window-state|save_window_state', { flags });
22
48
  }
23
49
  /**
24
50
  * Restore the state for the specified window from disk.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * import { restoreState, StateFlags } from '@tauri-apps/plugin-window-state';
55
+ *
56
+ * await restoreState('main', StateFlags.ALL);
57
+ * ```
58
+ *
59
+ * @param label The label of the window to restore.
60
+ * @param flags Which parts of the state to restore. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
61
+ * @since 2.0.0
25
62
  */
26
63
  async function restoreState(label, flags) {
27
64
  await invoke('plugin:window-state|restore_state', { label, flags });
28
65
  }
29
66
  /**
30
67
  * Restore the state for the current window from disk.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * import { restoreStateCurrent, StateFlags } from '@tauri-apps/plugin-window-state';
72
+ *
73
+ * await restoreStateCurrent(StateFlags.ALL);
74
+ * ```
75
+ *
76
+ * @param flags Which parts of the state to restore. Defaults to the flags passed to the plugin `Builder` (all flags if none were set).
77
+ * @since 2.0.0
31
78
  */
32
79
  async function restoreStateCurrent(flags) {
33
80
  await restoreState(getCurrentWindow().label, flags);
34
81
  }
35
82
  /**
36
83
  * Get the name of the file used to store window state.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * import { filename } from '@tauri-apps/plugin-window-state';
88
+ *
89
+ * const name = await filename();
90
+ * ```
91
+ *
92
+ * @returns A promise resolving to the name of the file used to store window state.
93
+ * @since 2.0.0
37
94
  */
38
95
  async function filename() {
39
96
  return await invoke('plugin:window-state|filename');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-window-state",
3
- "version": "2.4.1",
3
+ "version": "2.5.1",
4
4
  "description": "Save window positions and sizes and restore them when the app is reopened.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "authors": [
@@ -25,6 +25,6 @@
25
25
  "LICENSE"
26
26
  ],
27
27
  "dependencies": {
28
- "@tauri-apps/api": "^2.8.0"
28
+ "@tauri-apps/api": "^2.13.0"
29
29
  }
30
30
  }