@seelen-ui/lib 2.5.7 → 2.5.8-next.2604111036

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.
Files changed (133) hide show
  1. package/esm/gen/types/ClipboardData.d.ts +15 -0
  2. package/esm/gen/types/ClipboardData.d.ts.map +1 -0
  3. package/esm/gen/types/ClipboardData.js +1 -0
  4. package/esm/gen/types/ClipboardEntry.d.ts +24 -0
  5. package/esm/gen/types/ClipboardEntry.d.ts.map +1 -0
  6. package/esm/gen/types/ClipboardEntry.js +1 -0
  7. package/esm/gen/types/ClipboardEntryContent.d.ts +16 -0
  8. package/esm/gen/types/ClipboardEntryContent.d.ts.map +1 -0
  9. package/esm/gen/types/ClipboardEntryContent.js +2 -0
  10. package/esm/gen/types/Resource.d.ts +3 -5
  11. package/esm/gen/types/Resource.d.ts.map +1 -1
  12. package/esm/gen/types/ResourceId.d.ts +6 -2
  13. package/esm/gen/types/ResourceId.d.ts.map +1 -1
  14. package/esm/gen/types/ResourceMetadata.d.ts +4 -0
  15. package/esm/gen/types/ResourceMetadata.d.ts.map +1 -1
  16. package/esm/gen/types/SeelenCommandArgument.d.ts +19 -0
  17. package/esm/gen/types/SeelenCommandArgument.d.ts.map +1 -1
  18. package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts +4 -0
  19. package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts.map +1 -0
  20. package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.js +2 -0
  21. package/esm/gen/types/SeelenCommandClipboardPasteArgs.d.ts +4 -0
  22. package/esm/gen/types/SeelenCommandClipboardPasteArgs.d.ts.map +1 -0
  23. package/esm/gen/types/SeelenCommandClipboardPasteArgs.js +2 -0
  24. package/esm/gen/types/SeelenCommandClipboardSetContentArgs.d.ts +4 -0
  25. package/esm/gen/types/SeelenCommandClipboardSetContentArgs.d.ts.map +1 -0
  26. package/esm/gen/types/SeelenCommandClipboardSetContentArgs.js +2 -0
  27. package/esm/gen/types/SeelenCommandReturn.d.ts +18 -0
  28. package/esm/gen/types/SeelenCommandReturn.d.ts.map +1 -1
  29. package/esm/gen/types/SeelenEventPayload.d.ts +6 -0
  30. package/esm/gen/types/SeelenEventPayload.d.ts.map +1 -1
  31. package/esm/gen/types/SeelenSession.d.ts +15 -0
  32. package/esm/gen/types/SeelenSession.d.ts.map +1 -0
  33. package/esm/gen/types/SeelenSession.js +2 -0
  34. package/esm/gen/types/Settings.d.ts +5 -0
  35. package/esm/gen/types/Settings.d.ts.map +1 -1
  36. package/esm/gen/types/SluHotkeyAction.d.ts +2 -0
  37. package/esm/gen/types/SluHotkeyAction.d.ts.map +1 -1
  38. package/esm/gen/types/Slug.d.ts +9 -0
  39. package/esm/gen/types/Slug.d.ts.map +1 -0
  40. package/esm/gen/types/Slug.js +2 -0
  41. package/esm/gen/types/mod.d.ts +252 -244
  42. package/esm/gen/types/mod.d.ts.map +1 -1
  43. package/esm/gen/types/mod.js +252 -244
  44. package/esm/src/handlers/commands.d.ts +9 -1
  45. package/esm/src/handlers/commands.d.ts.map +1 -1
  46. package/esm/src/handlers/commands.js +8 -0
  47. package/esm/src/handlers/events.d.ts +3 -1
  48. package/esm/src/handlers/events.d.ts.map +1 -1
  49. package/esm/src/handlers/events.js +2 -0
  50. package/esm/src/state/theme/theming.d.ts +1 -0
  51. package/esm/src/state/theme/theming.d.ts.map +1 -1
  52. package/esm/src/state/theme/theming.js +21 -1
  53. package/esm/src/state/widget/interfaces.d.ts +11 -0
  54. package/esm/src/state/widget/interfaces.d.ts.map +1 -1
  55. package/esm/src/state/widget/mod.d.ts +9 -6
  56. package/esm/src/state/widget/mod.d.ts.map +1 -1
  57. package/esm/src/state/widget/mod.js +62 -79
  58. package/esm/src/state/widget/sizing.d.ts +14 -3
  59. package/esm/src/state/widget/sizing.d.ts.map +1 -1
  60. package/esm/src/state/widget/sizing.js +60 -17
  61. package/esm/src/utils/async.d.ts +12 -0
  62. package/esm/src/utils/async.d.ts.map +1 -1
  63. package/esm/src/utils/async.js +46 -0
  64. package/esm/src/utils/mod.d.ts +1 -0
  65. package/esm/src/utils/mod.d.ts.map +1 -1
  66. package/esm/src/utils/mod.js +4 -0
  67. package/package.json +1 -1
  68. package/script/gen/types/ClipboardData.d.ts +15 -0
  69. package/script/gen/types/ClipboardData.d.ts.map +1 -0
  70. package/script/gen/types/ClipboardData.js +2 -0
  71. package/script/gen/types/ClipboardEntry.d.ts +24 -0
  72. package/script/gen/types/ClipboardEntry.d.ts.map +1 -0
  73. package/script/gen/types/ClipboardEntry.js +2 -0
  74. package/script/gen/types/ClipboardEntryContent.d.ts +16 -0
  75. package/script/gen/types/ClipboardEntryContent.d.ts.map +1 -0
  76. package/script/gen/types/ClipboardEntryContent.js +3 -0
  77. package/script/gen/types/Resource.d.ts +3 -5
  78. package/script/gen/types/Resource.d.ts.map +1 -1
  79. package/script/gen/types/ResourceId.d.ts +6 -2
  80. package/script/gen/types/ResourceId.d.ts.map +1 -1
  81. package/script/gen/types/ResourceMetadata.d.ts +4 -0
  82. package/script/gen/types/ResourceMetadata.d.ts.map +1 -1
  83. package/script/gen/types/SeelenCommandArgument.d.ts +19 -0
  84. package/script/gen/types/SeelenCommandArgument.d.ts.map +1 -1
  85. package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts +4 -0
  86. package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts.map +1 -0
  87. package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.js +3 -0
  88. package/script/gen/types/SeelenCommandClipboardPasteArgs.d.ts +4 -0
  89. package/script/gen/types/SeelenCommandClipboardPasteArgs.d.ts.map +1 -0
  90. package/script/gen/types/SeelenCommandClipboardPasteArgs.js +3 -0
  91. package/script/gen/types/SeelenCommandClipboardSetContentArgs.d.ts +4 -0
  92. package/script/gen/types/SeelenCommandClipboardSetContentArgs.d.ts.map +1 -0
  93. package/script/gen/types/SeelenCommandClipboardSetContentArgs.js +3 -0
  94. package/script/gen/types/SeelenCommandReturn.d.ts +18 -0
  95. package/script/gen/types/SeelenCommandReturn.d.ts.map +1 -1
  96. package/script/gen/types/SeelenEventPayload.d.ts +6 -0
  97. package/script/gen/types/SeelenEventPayload.d.ts.map +1 -1
  98. package/script/gen/types/SeelenSession.d.ts +15 -0
  99. package/script/gen/types/SeelenSession.d.ts.map +1 -0
  100. package/script/gen/types/SeelenSession.js +3 -0
  101. package/script/gen/types/Settings.d.ts +5 -0
  102. package/script/gen/types/Settings.d.ts.map +1 -1
  103. package/script/gen/types/SluHotkeyAction.d.ts +2 -0
  104. package/script/gen/types/SluHotkeyAction.d.ts.map +1 -1
  105. package/script/gen/types/Slug.d.ts +9 -0
  106. package/script/gen/types/Slug.d.ts.map +1 -0
  107. package/script/gen/types/Slug.js +3 -0
  108. package/script/gen/types/mod.d.ts +252 -244
  109. package/script/gen/types/mod.d.ts.map +1 -1
  110. package/script/gen/types/mod.js +252 -244
  111. package/script/src/handlers/commands.d.ts +9 -1
  112. package/script/src/handlers/commands.d.ts.map +1 -1
  113. package/script/src/handlers/commands.js +8 -0
  114. package/script/src/handlers/events.d.ts +3 -1
  115. package/script/src/handlers/events.d.ts.map +1 -1
  116. package/script/src/handlers/events.js +2 -0
  117. package/script/src/state/theme/theming.d.ts +1 -0
  118. package/script/src/state/theme/theming.d.ts.map +1 -1
  119. package/script/src/state/theme/theming.js +22 -1
  120. package/script/src/state/widget/interfaces.d.ts +11 -0
  121. package/script/src/state/widget/interfaces.d.ts.map +1 -1
  122. package/script/src/state/widget/mod.d.ts +9 -6
  123. package/script/src/state/widget/mod.d.ts.map +1 -1
  124. package/script/src/state/widget/mod.js +61 -78
  125. package/script/src/state/widget/sizing.d.ts +14 -3
  126. package/script/src/state/widget/sizing.d.ts.map +1 -1
  127. package/script/src/state/widget/sizing.js +61 -18
  128. package/script/src/utils/async.d.ts +12 -0
  129. package/script/src/utils/async.d.ts.map +1 -1
  130. package/script/src/utils/async.js +49 -0
  131. package/script/src/utils/mod.d.ts +1 -0
  132. package/script/src/utils/mod.d.ts.map +1 -1
  133. package/script/src/utils/mod.js +5 -0
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.startThemingTool = startThemingTool;
4
+ exports.setPerformanceStyles = setPerformanceStyles;
4
5
  exports.startDateCssVariables = startDateCssVariables;
5
6
  const ui_colors_js_1 = require("../../system_state/ui_colors.js");
6
7
  const DOM_js_1 = require("../../utils/DOM.js");
@@ -21,11 +22,31 @@ async function startThemingTool() {
21
22
  settings = newSettings;
22
23
  themes.applyToDocument(settings.activeThemes, settings.byTheme);
23
24
  });
25
+ setPerformanceStyles();
26
+ startDateCssVariables();
24
27
  (await ui_colors_js_1.UIColors.getAsync()).setAsCssVariables();
25
28
  await ui_colors_js_1.UIColors.onChange((colors) => colors.setAsCssVariables());
26
- startDateCssVariables();
27
29
  themes.applyToDocument(settings.activeThemes, settings.byTheme);
28
30
  }
31
+ // Used by performance mode to reduce cpu/gpu usage
32
+ const PERF_CSS = `
33
+ html[data-animations-off] *,
34
+ html[data-animations-off] *::before,
35
+ html[data-animations-off] *::after {
36
+ animation-duration: 0.001ms !important;
37
+ animation-iteration-count: 1 !important;
38
+ animation-delay: 0s !important;
39
+
40
+ transition-duration: 0.001ms !important;
41
+ transition-delay: 0s !important;
42
+
43
+ scroll-behavior: auto !important;
44
+ }`;
45
+ function setPerformanceStyles() {
46
+ const styleSheet = new DOM_js_1.RuntimeStyleSheet("@static/performance");
47
+ styleSheet.addStyle(PERF_CSS);
48
+ styleSheet.applyToDocument();
49
+ }
29
50
  function startDateCssVariables() {
30
51
  // Set initial values immediately
31
52
  updateDateCssVariables();
@@ -19,6 +19,17 @@ export interface InitWidgetOptions {
19
19
  * @default undefined
20
20
  */
21
21
  autoSizeByContent?: HTMLElement | null;
22
+ /**
23
+ * If autoSizeByContent is set, and this is true, will auto size the widget and
24
+ * adjusts the position to fit on screen
25
+ * @default true
26
+ */
27
+ autoSizeFitOnScreen?: boolean;
28
+ /**
29
+ * Will normalize the device pixel ratio to 1:1
30
+ * @default false
31
+ */
32
+ normalizeDevicePixelRatio?: boolean;
22
33
  /**
23
34
  * Will save the position and size of the widget on change.
24
35
  * This is intedeed to be used when the size and position of the widget is
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gEAAgE;IAChE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,EAAE;QAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM;KAAE,CAAC;CAC/C;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gEAAgE;IAChE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,EAAE;QAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM;KAAE,CAAC;CAC/C;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
@@ -1,4 +1,4 @@
1
- import { type Frame, type Rect, type ThirdPartyWidgetSettings, type Widget as IWidget, type WidgetId, type WidgetTriggerPayload } from "../../../gen/types/mod.js";
1
+ import { type Alignment, type Frame, type Rect, type ThirdPartyWidgetSettings, type Widget as IWidget, type WidgetId, type WidgetTriggerPayload } from "../../../gen/types/mod.js";
2
2
  import type { InitWidgetOptions, ReadyWidgetOptions, WidgetInformation } from "./interfaces.js";
3
3
  import { type Webview } from "@tauri-apps/api/webview";
4
4
  import { type Window } from "@tauri-apps/api/window";
@@ -28,11 +28,8 @@ export declare class Widget {
28
28
  private constructor();
29
29
  /** Returns the current window id of the widget */
30
30
  get windowId(): number;
31
- /** Returns the current position and size of the widget */
32
- get frame(): Frame;
33
31
  /** Returns the default config of the widget, declared on the widget definition */
34
32
  getDefaultConfig(): ThirdPartyWidgetSettings;
35
- private applyInvisiblePreset;
36
33
  /** Will apply the recommended settings for a desktop widget */
37
34
  private applyDesktopPreset;
38
35
  /** Will apply the recommended settings for an overlay widget */
@@ -43,7 +40,8 @@ export declare class Widget {
43
40
  * Will restore the saved position and size of the widget on start,
44
41
  * after that will store the position and size of the widget on change.
45
42
  */
46
- persistPositionAndSize(): Promise<void>;
43
+ private persistPositionAndSize;
44
+ private normalizeDevicePixelRatio;
47
45
  /**
48
46
  * Will initialize the widget based on the preset and mark it as `pending`, this function won't show the widget.
49
47
  * This should be called before any other action on the widget. After this you should call
@@ -58,7 +56,12 @@ export declare class Widget {
58
56
  */
59
57
  ready(options?: ReadyWidgetOptions): Promise<void>;
60
58
  onTrigger(cb: (args: WidgetTriggerPayload) => void): void;
61
- /** If animations are enabled this will animate the movement of the widget */
59
+ __unsafe_setPosition(rect: Rect, ref: Frame): Promise<void>;
60
+ /**
61
+ * This will adjust the position of the widget based on the current placement and alignX/alignY arguments.
62
+ * This makes the widget fit into the monitor where it was placed, avoiding monitor overflow.
63
+ */
64
+ adjustAndSetPosition(x: number, y: number, alignX?: Alignment | null, alignY?: Alignment | null): Promise<void>;
62
65
  setPosition(rect: Rect): Promise<void>;
63
66
  show(): Promise<void>;
64
67
  /** Will force foreground the widget */
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/mod.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,MAAM,IAAI,OAAO,EAEtB,KAAK,QAAQ,EAIb,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAOnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEhG,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAiBvE;;GAEG;AACH,qBAAa,MAAM;IACjB;;;OAGG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM;IAU3B,iCAAiC;IACjC,MAAM,KAAK,IAAI,IAAI,MAAM,CAExB;IAED,gBAAgB;IAChB,SAAgB,EAAE,EAAE,QAAQ,CAAC;IAC7B,wBAAwB;IACxB,SAAgB,GAAG,EAAE,OAAO,CAAC;IAC7B,0CAA0C;IAC1C,SAAgB,OAA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0,
85
- },
86
- size: {
87
- width: 0,
88
- height: 0,
89
- },
90
82
  firstFocus: true,
91
83
  };
92
84
  constructor(widget) {
@@ -108,15 +100,6 @@ class Widget {
108
100
  get windowId() {
109
101
  return this.runtimeState.hwnd;
110
102
  }
111
- /** Returns the current position and size of the widget */
112
- get frame() {
113
- return {
114
- x: this.runtimeState.position.x,
115
- y: this.runtimeState.position.y,
116
- width: this.runtimeState.size.width,
117
- height: this.runtimeState.size.height,
118
- };
119
- }
120
103
  /** Returns the default config of the widget, declared on the widget definition */
121
104
  getDefaultConfig() {
122
105
  const config = { enabled: true };
@@ -125,29 +108,12 @@ class Widget {
125
108
  }
126
109
  return config;
127
110
  }
128
- applyInvisiblePreset() {
129
- return [
130
- this.window.setDecorations(false), // no title bar
131
- this.window.setShadow(false), // no shadows
132
- // hide from native shell
133
- this.window.setSkipTaskbar(true),
134
- // as a (desktop/overlay) widget we don't wanna allow nothing of these
135
- this.window.setMinimizable(false),
136
- this.window.setMaximizable(false),
137
- this.window.setClosable(false),
138
- ];
139
- }
140
111
  /** Will apply the recommended settings for a desktop widget */
141
- async applyDesktopPreset() {
142
- await Promise.all([...this.applyInvisiblePreset(), this.window.setAlwaysOnBottom(true)]);
143
- }
112
+ applyDesktopPreset() { }
144
113
  /** Will apply the recommended settings for an overlay widget */
145
- async applyOverlayPreset() {
146
- await Promise.all([...this.applyInvisiblePreset(), this.window.setAlwaysOnTop(true)]);
147
- }
114
+ applyOverlayPreset() { }
148
115
  /** Will apply the recommended settings for a popup widget */
149
- async applyPopupPreset() {
150
- await Promise.all([...this.applyInvisiblePreset(), this.window.setAlwaysOnTop(true)]);
116
+ applyPopupPreset() {
151
117
  const hideWidget = (0, async_js_1.debounce)(() => {
152
118
  this.hide(true);
153
119
  }, 100);
@@ -162,27 +128,8 @@ class Widget {
162
128
  this.onTrigger(async ({ desiredPosition, alignX, alignY }) => {
163
129
  // avoid flickering when clicking a button that triggers the widget
164
130
  hideWidget.cancel();
165
- if (this.autoSizer && alignX && alignY) {
166
- this.autoSizer.originX = alignX;
167
- this.autoSizer.originY = alignY;
168
- }
169
131
  if (desiredPosition) {
170
- const adjusted = (0, positioning_js_1.adjustPositionByPlacement)({
171
- frame: {
172
- x: desiredPosition.x,
173
- y: desiredPosition.y,
174
- width: this.runtimeState.size.width,
175
- height: this.runtimeState.size.height,
176
- },
177
- originX: alignX,
178
- originY: alignY,
179
- });
180
- await this.setPosition({
181
- left: adjusted.x,
182
- top: adjusted.y,
183
- right: adjusted.x + adjusted.width,
184
- bottom: adjusted.y + adjusted.height,
185
- });
132
+ await this.adjustAndSetPosition(desiredPosition.x, desiredPosition.y, alignX, alignY);
186
133
  }
187
134
  await this.show();
188
135
  await this.focus();
@@ -223,6 +170,18 @@ class Widget {
223
170
  console.info(`Widget size saved: ${width} ${height}`);
224
171
  }, 500));
225
172
  }
173
+ async normalizeDevicePixelRatio() {
174
+ // play with zoom level to reset device pixel ratio to 1:1
175
+ let oldDPR = globalThis.devicePixelRatio;
176
+ await this.webview.setZoom(1 / oldDPR);
177
+ this.window.onScaleChanged(() => {
178
+ if (globalThis.devicePixelRatio !== oldDPR) {
179
+ // when zoom was set dpr changed, so in case of change this is accomulative unit
180
+ oldDPR = oldDPR * globalThis.devicePixelRatio;
181
+ this.webview.setZoom(1 / (oldDPR * globalThis.devicePixelRatio));
182
+ }
183
+ });
184
+ }
226
185
  /**
227
186
  * Will initialize the widget based on the preset and mark it as `pending`, this function won't show the widget.
228
187
  * This should be called before any other action on the widget. After this you should call
@@ -235,8 +194,11 @@ class Widget {
235
194
  }
236
195
  this.runtimeState.hwnd = await (0, mod_js_2.invoke)(mod_js_2.SeelenCommand.GetSelfWindowId);
237
196
  this.runtimeState.initialized = true;
197
+ if (options.normalizeDevicePixelRatio) {
198
+ await this.normalizeDevicePixelRatio();
199
+ }
238
200
  if (options.autoSizeByContent) {
239
- this.autoSizer = new sizing_js_1.WidgetAutoSizer(this, options.autoSizeByContent);
201
+ this.autoSizer = new sizing_js_1.WidgetAutoSizer(this, options.autoSizeByContent, options.autoSizeFitOnScreen ?? true);
240
202
  }
241
203
  else if (options.saveAndRestoreLastRect ?? this.def.preset === mod_js_1.WidgetPreset.Desktop) {
242
204
  await this.persistPositionAndSize();
@@ -245,13 +207,13 @@ class Widget {
245
207
  case mod_js_1.WidgetPreset.None:
246
208
  break;
247
209
  case mod_js_1.WidgetPreset.Desktop:
248
- await this.applyDesktopPreset();
210
+ this.applyDesktopPreset();
249
211
  break;
250
212
  case mod_js_1.WidgetPreset.Overlay:
251
- await this.applyOverlayPreset();
213
+ this.applyOverlayPreset();
252
214
  break;
253
215
  case mod_js_1.WidgetPreset.Popup:
254
- await this.applyPopupPreset();
216
+ this.applyPopupPreset();
255
217
  break;
256
218
  }
257
219
  await (0, theming_js_1.startThemingTool)();
@@ -262,16 +224,8 @@ class Widget {
262
224
  else {
263
225
  console.trace("Animations won't be disabled because widget configuration");
264
226
  }
265
- // state initialization
266
- this.runtimeState.size = await this.window.outerSize();
267
- this.runtimeState.position = await this.window.outerPosition();
268
- this.window.onResized((e) => {
269
- this.runtimeState.size.width = e.payload.width;
270
- this.runtimeState.size.height = e.payload.height;
271
- });
272
- this.window.onMoved((e) => {
273
- this.runtimeState.position.x = e.payload.x;
274
- this.runtimeState.position.y = e.payload.y;
227
+ await sizing_js_1.OPTIMISTIC_FRAME.runExclusive(async (state) => {
228
+ await state.init(this);
275
229
  });
276
230
  }
277
231
  /**
@@ -303,13 +257,8 @@ class Widget {
303
257
  cb(payload);
304
258
  });
305
259
  }
306
- /** If animations are enabled this will animate the movement of the widget */
307
- setPosition(rect) {
308
- this.runtimeState.position.x = rect.left;
309
- this.runtimeState.position.y = rect.top;
310
- this.runtimeState.size.width = rect.right - rect.left;
311
- this.runtimeState.size.height = rect.bottom - rect.top;
312
- return (0, mod_js_2.invoke)(mod_js_2.SeelenCommand.SetSelfPosition, {
260
+ async __unsafe_setPosition(rect, ref) {
261
+ await (0, mod_js_2.invoke)(mod_js_2.SeelenCommand.SetSelfPosition, {
313
262
  rect: {
314
263
  left: Math.round(rect.left),
315
264
  top: Math.round(rect.top),
@@ -317,6 +266,40 @@ class Widget {
317
266
  bottom: Math.round(rect.bottom),
318
267
  },
319
268
  });
269
+ // optimistically update state, as arrived event after change is async
270
+ ref.x = rect.left;
271
+ ref.y = rect.top;
272
+ ref.width = rect.right - rect.left;
273
+ ref.height = rect.bottom - rect.top;
274
+ }
275
+ /**
276
+ * This will adjust the position of the widget based on the current placement and alignX/alignY arguments.
277
+ * This makes the widget fit into the monitor where it was placed, avoiding monitor overflow.
278
+ */
279
+ async adjustAndSetPosition(x, y, alignX, alignY) {
280
+ await sizing_js_1.OPTIMISTIC_FRAME.runExclusive(async (ref) => {
281
+ const adjusted = (0, positioning_js_1.adjustPositionByPlacement)({
282
+ frame: {
283
+ x,
284
+ y,
285
+ width: ref.width,
286
+ height: ref.height,
287
+ },
288
+ originX: alignX,
289
+ originY: alignY,
290
+ });
291
+ await Widget.self.__unsafe_setPosition({
292
+ left: adjusted.x,
293
+ top: adjusted.y,
294
+ right: adjusted.x + adjusted.width,
295
+ bottom: adjusted.y + adjusted.height,
296
+ }, ref);
297
+ });
298
+ }
299
+ async setPosition(rect) {
300
+ await sizing_js_1.OPTIMISTIC_FRAME.runExclusive(async (frame) => {
301
+ await this.__unsafe_setPosition(rect, frame);
302
+ });
320
303
  }
321
304
  async show() {
322
305
  debouncedClose.cancel();
@@ -1,14 +1,25 @@
1
1
  import type { Widget } from "./mod.js";
2
2
  import { Alignment } from "../../../gen/types/mod.js";
3
+ import { Mutex } from "../../utils/async.js";
4
+ declare class OptimisiticFrame {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ init(widget: Widget): Promise<void>;
10
+ }
11
+ export declare const OPTIMISTIC_FRAME: Mutex<OptimisiticFrame>;
3
12
  export declare class WidgetAutoSizer {
4
13
  private widget;
5
14
  private element;
15
+ private fitOnScreen;
6
16
  /** From which side the widget will grow */
7
- originX: Alignment;
17
+ originX?: Alignment | null;
8
18
  /** From which side the widget will grow */
9
- originY: Alignment;
10
- constructor(widget: Widget, element: HTMLElement);
19
+ originY?: Alignment | null;
20
+ constructor(widget: Widget, element: HTMLElement, fitOnScreen: boolean);
11
21
  private setup;
12
22
  execute(): Promise<void>;
13
23
  }
24
+ export {};
14
25
  //# sourceMappingURL=sizing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sizing.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/sizing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,qBAAa,eAAe;IAOxB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IAPjB,2CAA2C;IAC3C,OAAO,EAAE,SAAS,CAAmB;IACrC,2CAA2C;IAC3C,OAAO,EAAE,SAAS,CAAmB;gBAG3B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW;IAM9B,OAAO,CAAC,KAAK;IAcP,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CA6C/B"}
1
+ {"version":3,"file":"sizing.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/sizing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,cAAM,gBAAgB;IACpB,CAAC,EAAE,MAAM,CAAK;IACd,CAAC,EAAE,MAAM,CAAK;IACd,KAAK,EAAE,MAAM,CAAK;IAClB,MAAM,EAAE,MAAM,CAAK;IAEb,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAuB1C;AAED,eAAO,MAAM,gBAAgB,yBAAoC,CAAC;AAElE,qBAAa,eAAe;IAOxB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,WAAW;IARrB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;gBAGjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,OAAO;IAM9B,OAAO,CAAC,KAAK;IAqBP,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAsD/B"}
@@ -1,24 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WidgetAutoSizer = void 0;
4
- const dpi_1 = require("@tauri-apps/api/dpi");
3
+ exports.WidgetAutoSizer = exports.OPTIMISTIC_FRAME = void 0;
5
4
  const mod_js_1 = require("../../../gen/types/mod.js");
5
+ const async_js_1 = require("../../utils/async.js");
6
+ const positioning_js_1 = require("./positioning.js");
7
+ class OptimisiticFrame {
8
+ x = 0;
9
+ y = 0;
10
+ width = 0;
11
+ height = 0;
12
+ async init(widget) {
13
+ const { width, height } = await widget.window.outerSize();
14
+ const { x, y } = await widget.window.outerPosition();
15
+ this.width = width;
16
+ this.height = height;
17
+ this.x = x;
18
+ this.y = y;
19
+ widget.window.onResized((e) => {
20
+ exports.OPTIMISTIC_FRAME.runExclusive((ref) => {
21
+ ref.width = e.payload.width;
22
+ ref.height = e.payload.height;
23
+ });
24
+ });
25
+ widget.window.onMoved((e) => {
26
+ exports.OPTIMISTIC_FRAME.runExclusive((ref) => {
27
+ ref.x = e.payload.x;
28
+ ref.y = e.payload.y;
29
+ });
30
+ });
31
+ }
32
+ }
33
+ exports.OPTIMISTIC_FRAME = new async_js_1.Mutex(new OptimisiticFrame());
6
34
  class WidgetAutoSizer {
7
35
  widget;
8
36
  element;
37
+ fitOnScreen;
9
38
  /** From which side the widget will grow */
10
- originX = mod_js_1.Alignment.Start;
39
+ originX;
11
40
  /** From which side the widget will grow */
12
- originY = mod_js_1.Alignment.Start;
13
- constructor(widget, element) {
41
+ originY;
42
+ constructor(widget, element, fitOnScreen) {
14
43
  this.widget = widget;
15
44
  this.element = element;
45
+ this.fitOnScreen = fitOnScreen;
16
46
  this.execute = this.execute.bind(this);
17
47
  this.setup();
18
48
  }
19
49
  setup() {
20
50
  // Disable resizing by the user
21
51
  this.widget.window.setResizable(false);
52
+ this.widget.onTrigger(({ alignX, alignY }) => {
53
+ exports.OPTIMISTIC_FRAME.runExclusive(() => {
54
+ this.originX = alignX;
55
+ this.originY = alignY;
56
+ });
57
+ });
22
58
  const observer = new ResizeObserver(this.execute);
23
59
  observer.observe(this.element, {
24
60
  box: "border-box",
@@ -28,8 +64,9 @@ class WidgetAutoSizer {
28
64
  };
29
65
  }
30
66
  async execute() {
31
- const { x, y, width, height } = this.widget.frame;
32
- const frame = {
67
+ const guard = await exports.OPTIMISTIC_FRAME.acquire();
68
+ const { x, y, width, height } = guard.value;
69
+ let frame = {
33
70
  x,
34
71
  y,
35
72
  width: Math.ceil(this.element.scrollWidth * globalThis.window.devicePixelRatio),
@@ -39,9 +76,12 @@ class WidgetAutoSizer {
39
76
  const heightDiff = frame.height - height;
40
77
  // Only update if the difference is more than 1px (avoid infinite loops from decimal differences)
41
78
  if (widthDiff === 0 && heightDiff === 0) {
79
+ guard.release();
42
80
  return;
43
81
  }
44
- console.trace(`Auto resize from ${width}x${height} to ${frame.width}x${frame.height}`);
82
+ /* console.debug(
83
+ `Auto resizing from ${width}x${height} to ${frame.width}x${frame.height} using ${this.originX}/${this.originY} origin`,
84
+ ); */
45
85
  if (this.originX === mod_js_1.Alignment.Center) {
46
86
  frame.x -= widthDiff / 2;
47
87
  }
@@ -54,17 +94,20 @@ class WidgetAutoSizer {
54
94
  else if (this.originY === mod_js_1.Alignment.End) {
55
95
  frame.y -= heightDiff;
56
96
  }
57
- // only update size no position on this case
58
- if (frame.x === x && frame.y === y) {
59
- await this.widget.window.setSize(new dpi_1.PhysicalSize(frame.width, frame.height));
60
- return;
97
+ if (this.fitOnScreen) {
98
+ frame = (0, positioning_js_1.fitIntoMonitor)(frame);
99
+ }
100
+ try {
101
+ await this.widget.__unsafe_setPosition({
102
+ left: frame.x,
103
+ top: frame.y,
104
+ right: frame.x + frame.width,
105
+ bottom: frame.y + frame.height,
106
+ }, guard.value);
107
+ }
108
+ finally {
109
+ guard.release();
61
110
  }
62
- await this.widget.setPosition({
63
- left: frame.x,
64
- top: frame.y,
65
- right: frame.x + frame.width,
66
- bottom: frame.y + frame.height,
67
- });
68
111
  }
69
112
  }
70
113
  exports.WidgetAutoSizer = WidgetAutoSizer;
@@ -5,4 +5,16 @@ export interface DebouncedFunction<T extends (...args: any[]) => any> {
5
5
  pending(): boolean;
6
6
  }
7
7
  export declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): DebouncedFunction<T>;
8
+ export declare class Mutex<T> {
9
+ private _rawValue;
10
+ constructor(_rawValue: T);
11
+ private lock;
12
+ acquire(): Promise<Guard<T>>;
13
+ runExclusive<U>(fn: (v: T) => U): Promise<U>;
14
+ }
15
+ export declare class Guard<T> {
16
+ value: T;
17
+ release: () => void;
18
+ constructor(value: T, release: () => void);
19
+ }
8
20
  //# sourceMappingURL=async.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/src/utils/async.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;IAClE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/B,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,IAAI,OAAO,CAAC;CACpB;AAGD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,MAAM,GACZ,iBAAiB,CAAC,CAAC,CAAC,CA6CtB"}
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/src/utils/async.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;IAClE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/B,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,IAAI,OAAO,CAAC;CACpB;AAGD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,MAAM,GACZ,iBAAiB,CAAC,CAAC,CAAC,CA6CtB;AAED,qBAAa,KAAK,CAAC,CAAC;IACN,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,CAAC;IAEhC,OAAO,CAAC,IAAI,CAII;IAEV,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IA0B5B,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAQnD;AAED,qBAAa,KAAK,CAAC,CAAC;IAET,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,MAAM,IAAI;gBADnB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,MAAM,IAAI;CAE7B"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Guard = exports.Mutex = void 0;
3
4
  exports.debounce = debounce;
4
5
  // deno-lint-ignore no-explicit-any
5
6
  function debounce(fn, delay) {
@@ -40,3 +41,51 @@ function debounce(fn, delay) {
40
41
  };
41
42
  return debounced;
42
43
  }
44
+ class Mutex {
45
+ _rawValue;
46
+ constructor(_rawValue) {
47
+ this._rawValue = _rawValue;
48
+ }
49
+ lock = null;
50
+ async acquire() {
51
+ if (this.lock) {
52
+ await this.lock.__promise;
53
+ }
54
+ // deno-lint-ignore no-explicit-any
55
+ let __resolve;
56
+ // deno-lint-ignore no-explicit-any
57
+ let __reject;
58
+ const __promise = new Promise((resolve, reject) => {
59
+ __resolve = resolve;
60
+ __reject = reject;
61
+ });
62
+ this.lock = {
63
+ __promise,
64
+ __resolve,
65
+ __reject,
66
+ };
67
+ return new Guard(this._rawValue, () => {
68
+ this.lock = null;
69
+ __resolve();
70
+ });
71
+ }
72
+ async runExclusive(fn) {
73
+ const guard = await this.acquire();
74
+ try {
75
+ return await fn(guard.value);
76
+ }
77
+ finally {
78
+ guard.release();
79
+ }
80
+ }
81
+ }
82
+ exports.Mutex = Mutex;
83
+ class Guard {
84
+ value;
85
+ release;
86
+ constructor(value, release) {
87
+ this.value = value;
88
+ this.release = release;
89
+ }
90
+ }
91
+ exports.Guard = Guard;
@@ -4,4 +4,5 @@ export declare class Rect {
4
4
  right: number;
5
5
  bottom: number;
6
6
  }
7
+ export declare function isSeelenUIRuntime(): boolean;
7
8
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/utils/mod.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;IACf,IAAI,SAAK;IACT,GAAG,SAAK;IACR,KAAK,SAAK;IACV,MAAM,SAAK;CACZ"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/utils/mod.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;IACf,IAAI,SAAK;IACT,GAAG,SAAK;IACR,KAAK,SAAK;IACV,MAAM,SAAK;CACZ;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAG3C"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Rect = void 0;
4
+ exports.isSeelenUIRuntime = isSeelenUIRuntime;
4
5
  class Rect {
5
6
  left = 0;
6
7
  top = 0;
@@ -8,3 +9,7 @@ class Rect {
8
9
  bottom = 0;
9
10
  }
10
11
  exports.Rect = Rect;
12
+ function isSeelenUIRuntime() {
13
+ // deno-lint-ignore no-explicit-any
14
+ return !!globalThis.window.__SLU_WIDGET;
15
+ }