@seelen-ui/lib 2.5.3 → 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 (237) 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/ClipboardEntry.d.ts +24 -0
  4. package/esm/gen/types/ClipboardEntry.d.ts.map +1 -0
  5. package/esm/gen/types/ClipboardEntryContent.d.ts +16 -0
  6. package/esm/gen/types/ClipboardEntryContent.d.ts.map +1 -0
  7. package/esm/gen/types/FancyToolbarSettings.d.ts +10 -2
  8. package/esm/gen/types/FancyToolbarSettings.d.ts.map +1 -1
  9. package/esm/gen/types/{PinnedWegItemData.d.ts → OldWegItemData.d.ts} +5 -10
  10. package/esm/gen/types/OldWegItemData.d.ts.map +1 -0
  11. package/esm/gen/types/{WegItemSubtype.d.ts → OldWegItemSubtype.d.ts} +2 -2
  12. package/esm/gen/types/OldWegItemSubtype.d.ts.map +1 -0
  13. package/esm/gen/types/OldWegItemSubtype.js +8 -0
  14. package/esm/gen/types/Relaunch.d.ts +20 -0
  15. package/esm/gen/types/Relaunch.d.ts.map +1 -0
  16. package/esm/gen/types/Relaunch.js +1 -0
  17. package/esm/gen/types/Resource.d.ts +12 -5
  18. package/esm/gen/types/Resource.d.ts.map +1 -1
  19. package/esm/gen/types/ResourceId.d.ts +6 -2
  20. package/esm/gen/types/ResourceId.d.ts.map +1 -1
  21. package/esm/gen/types/ResourceMetadata.d.ts +4 -0
  22. package/esm/gen/types/ResourceMetadata.d.ts.map +1 -1
  23. package/esm/gen/types/ResourcePendingUpdate.d.ts +20 -0
  24. package/esm/gen/types/ResourcePendingUpdate.d.ts.map +1 -0
  25. package/esm/gen/types/ResourcePendingUpdate.js +1 -0
  26. package/esm/gen/types/SeelenCommandArgument.d.ts +26 -2
  27. package/esm/gen/types/SeelenCommandArgument.d.ts.map +1 -1
  28. package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts +4 -0
  29. package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts.map +1 -0
  30. package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.js +2 -0
  31. package/esm/gen/types/SeelenCommandClipboardPasteArgs.d.ts +4 -0
  32. package/esm/gen/types/SeelenCommandClipboardPasteArgs.d.ts.map +1 -0
  33. package/esm/gen/types/SeelenCommandClipboardPasteArgs.js +2 -0
  34. package/esm/gen/types/SeelenCommandClipboardSetContentArgs.d.ts +4 -0
  35. package/esm/gen/types/SeelenCommandClipboardSetContentArgs.d.ts.map +1 -0
  36. package/esm/gen/types/SeelenCommandClipboardSetContentArgs.js +2 -0
  37. package/esm/gen/types/SeelenCommandReturn.d.ts +25 -0
  38. package/esm/gen/types/SeelenCommandReturn.d.ts.map +1 -1
  39. package/esm/gen/types/SeelenEventPayload.d.ts +13 -3
  40. package/esm/gen/types/SeelenEventPayload.d.ts.map +1 -1
  41. package/esm/gen/types/SeelenSession.d.ts +15 -0
  42. package/esm/gen/types/SeelenSession.d.ts.map +1 -0
  43. package/esm/gen/types/SeelenSession.js +2 -0
  44. package/esm/gen/types/SeelenWegSettings.d.ts +4 -0
  45. package/esm/gen/types/SeelenWegSettings.d.ts.map +1 -1
  46. package/esm/gen/types/Settings.d.ts +9 -0
  47. package/esm/gen/types/Settings.d.ts.map +1 -1
  48. package/esm/gen/types/SluHotkeyAction.d.ts +2 -0
  49. package/esm/gen/types/SluHotkeyAction.d.ts.map +1 -1
  50. package/esm/gen/types/Slug.d.ts +9 -0
  51. package/esm/gen/types/Slug.d.ts.map +1 -0
  52. package/esm/gen/types/Slug.js +2 -0
  53. package/esm/gen/types/TrashBinInfo.d.ts +11 -0
  54. package/esm/gen/types/TrashBinInfo.d.ts.map +1 -0
  55. package/esm/gen/types/TrashBinInfo.js +2 -0
  56. package/esm/gen/types/UserAppWindow.d.ts +9 -0
  57. package/esm/gen/types/UserAppWindow.d.ts.map +1 -1
  58. package/esm/gen/types/WegItem.d.ts +9 -5
  59. package/esm/gen/types/WegItem.d.ts.map +1 -1
  60. package/esm/gen/types/WegItemData.d.ts +32 -0
  61. package/esm/gen/types/WegItemData.d.ts.map +1 -0
  62. package/esm/gen/types/WegItemData.js +1 -0
  63. package/esm/gen/types/WegItemType.d.ts +3 -3
  64. package/esm/gen/types/WegItemType.d.ts.map +1 -1
  65. package/esm/gen/types/WegItemType.js +2 -2
  66. package/esm/gen/types/mod.d.ts +252 -242
  67. package/esm/gen/types/mod.d.ts.map +1 -1
  68. package/esm/gen/types/mod.js +252 -242
  69. package/esm/src/handlers/commands.d.ts +12 -1
  70. package/esm/src/handlers/commands.d.ts.map +1 -1
  71. package/esm/src/handlers/commands.js +11 -0
  72. package/esm/src/handlers/events.d.ts +6 -3
  73. package/esm/src/handlers/events.d.ts.map +1 -1
  74. package/esm/src/handlers/events.js +5 -2
  75. package/esm/src/state/icon_pack.d.ts.map +1 -1
  76. package/esm/src/state/icon_pack.js +11 -2
  77. package/esm/src/state/mod.d.ts +0 -2
  78. package/esm/src/state/mod.d.ts.map +1 -1
  79. package/esm/src/state/mod.js +0 -2
  80. package/esm/src/state/theme/theming.d.ts +1 -0
  81. package/esm/src/state/theme/theming.d.ts.map +1 -1
  82. package/esm/src/state/theme/theming.js +21 -1
  83. package/esm/src/state/widget/interfaces.d.ts +17 -0
  84. package/esm/src/state/widget/interfaces.d.ts.map +1 -1
  85. package/esm/src/state/widget/mod.d.ts +15 -9
  86. package/esm/src/state/widget/mod.d.ts.map +1 -1
  87. package/esm/src/state/widget/mod.js +87 -94
  88. package/esm/src/state/widget/performance.d.ts +2 -0
  89. package/esm/src/state/widget/performance.d.ts.map +1 -0
  90. package/esm/src/state/widget/performance.js +18 -0
  91. package/esm/src/state/widget/sizing.d.ts +14 -3
  92. package/esm/src/state/widget/sizing.d.ts.map +1 -1
  93. package/esm/src/state/widget/sizing.js +61 -18
  94. package/esm/src/system_state/ui_colors.d.ts +0 -2
  95. package/esm/src/system_state/ui_colors.d.ts.map +1 -1
  96. package/esm/src/system_state/ui_colors.js +0 -8
  97. package/esm/src/utils/async.d.ts +12 -0
  98. package/esm/src/utils/async.d.ts.map +1 -1
  99. package/esm/src/utils/async.js +46 -0
  100. package/esm/src/utils/mod.d.ts +1 -0
  101. package/esm/src/utils/mod.d.ts.map +1 -1
  102. package/esm/src/utils/mod.js +4 -0
  103. package/package.json +1 -1
  104. package/script/gen/types/ClipboardData.d.ts +15 -0
  105. package/script/gen/types/ClipboardData.d.ts.map +1 -0
  106. package/script/gen/types/ClipboardEntry.d.ts +24 -0
  107. package/script/gen/types/ClipboardEntry.d.ts.map +1 -0
  108. package/script/gen/types/ClipboardEntryContent.d.ts +16 -0
  109. package/script/gen/types/ClipboardEntryContent.d.ts.map +1 -0
  110. package/script/gen/types/FancyToolbarSettings.d.ts +10 -2
  111. package/script/gen/types/FancyToolbarSettings.d.ts.map +1 -1
  112. package/script/gen/types/{PinnedWegItemData.d.ts → OldWegItemData.d.ts} +5 -10
  113. package/script/gen/types/OldWegItemData.d.ts.map +1 -0
  114. package/script/gen/types/{WegItemSubtype.d.ts → OldWegItemSubtype.d.ts} +2 -2
  115. package/script/gen/types/OldWegItemSubtype.d.ts.map +1 -0
  116. package/script/gen/types/OldWegItemSubtype.js +11 -0
  117. package/script/gen/types/Relaunch.d.ts +20 -0
  118. package/script/gen/types/Relaunch.d.ts.map +1 -0
  119. package/script/gen/types/Relaunch.js +2 -0
  120. package/script/gen/types/Resource.d.ts +12 -5
  121. package/script/gen/types/Resource.d.ts.map +1 -1
  122. package/script/gen/types/ResourceId.d.ts +6 -2
  123. package/script/gen/types/ResourceId.d.ts.map +1 -1
  124. package/script/gen/types/ResourceMetadata.d.ts +4 -0
  125. package/script/gen/types/ResourceMetadata.d.ts.map +1 -1
  126. package/script/gen/types/ResourcePendingUpdate.d.ts +20 -0
  127. package/script/gen/types/ResourcePendingUpdate.d.ts.map +1 -0
  128. package/script/gen/types/ResourcePendingUpdate.js +2 -0
  129. package/script/gen/types/SeelenCommandArgument.d.ts +26 -2
  130. package/script/gen/types/SeelenCommandArgument.d.ts.map +1 -1
  131. package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts +4 -0
  132. package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts.map +1 -0
  133. package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.js +3 -0
  134. package/script/gen/types/SeelenCommandClipboardPasteArgs.d.ts +4 -0
  135. package/script/gen/types/SeelenCommandClipboardPasteArgs.d.ts.map +1 -0
  136. package/script/gen/types/SeelenCommandClipboardPasteArgs.js +3 -0
  137. package/script/gen/types/SeelenCommandClipboardSetContentArgs.d.ts +4 -0
  138. package/script/gen/types/SeelenCommandClipboardSetContentArgs.d.ts.map +1 -0
  139. package/script/gen/types/SeelenCommandClipboardSetContentArgs.js +3 -0
  140. package/script/gen/types/SeelenCommandReturn.d.ts +25 -0
  141. package/script/gen/types/SeelenCommandReturn.d.ts.map +1 -1
  142. package/script/gen/types/SeelenEventPayload.d.ts +13 -3
  143. package/script/gen/types/SeelenEventPayload.d.ts.map +1 -1
  144. package/script/gen/types/SeelenSession.d.ts +15 -0
  145. package/script/gen/types/SeelenSession.d.ts.map +1 -0
  146. package/script/gen/types/SeelenSession.js +3 -0
  147. package/script/gen/types/SeelenWegSettings.d.ts +4 -0
  148. package/script/gen/types/SeelenWegSettings.d.ts.map +1 -1
  149. package/script/gen/types/Settings.d.ts +9 -0
  150. package/script/gen/types/Settings.d.ts.map +1 -1
  151. package/script/gen/types/SluHotkeyAction.d.ts +2 -0
  152. package/script/gen/types/SluHotkeyAction.d.ts.map +1 -1
  153. package/script/gen/types/Slug.d.ts +9 -0
  154. package/script/gen/types/Slug.d.ts.map +1 -0
  155. package/script/gen/types/Slug.js +3 -0
  156. package/script/gen/types/TrashBinInfo.d.ts +11 -0
  157. package/script/gen/types/TrashBinInfo.d.ts.map +1 -0
  158. package/script/gen/types/TrashBinInfo.js +3 -0
  159. package/script/gen/types/UserAppWindow.d.ts +9 -0
  160. package/script/gen/types/UserAppWindow.d.ts.map +1 -1
  161. package/script/gen/types/WegItem.d.ts +9 -5
  162. package/script/gen/types/WegItem.d.ts.map +1 -1
  163. package/script/gen/types/WegItemData.d.ts +32 -0
  164. package/script/gen/types/WegItemData.d.ts.map +1 -0
  165. package/script/gen/types/WegItemData.js +2 -0
  166. package/script/gen/types/WegItemType.d.ts +3 -3
  167. package/script/gen/types/WegItemType.d.ts.map +1 -1
  168. package/script/gen/types/WegItemType.js +2 -2
  169. package/script/gen/types/mod.d.ts +252 -242
  170. package/script/gen/types/mod.d.ts.map +1 -1
  171. package/script/gen/types/mod.js +252 -242
  172. package/script/src/handlers/commands.d.ts +12 -1
  173. package/script/src/handlers/commands.d.ts.map +1 -1
  174. package/script/src/handlers/commands.js +11 -0
  175. package/script/src/handlers/events.d.ts +6 -3
  176. package/script/src/handlers/events.d.ts.map +1 -1
  177. package/script/src/handlers/events.js +5 -2
  178. package/script/src/state/icon_pack.d.ts.map +1 -1
  179. package/script/src/state/icon_pack.js +11 -2
  180. package/script/src/state/mod.d.ts +0 -2
  181. package/script/src/state/mod.d.ts.map +1 -1
  182. package/script/src/state/mod.js +0 -2
  183. package/script/src/state/theme/theming.d.ts +1 -0
  184. package/script/src/state/theme/theming.d.ts.map +1 -1
  185. package/script/src/state/theme/theming.js +22 -1
  186. package/script/src/state/widget/interfaces.d.ts +17 -0
  187. package/script/src/state/widget/interfaces.d.ts.map +1 -1
  188. package/script/src/state/widget/mod.d.ts +15 -9
  189. package/script/src/state/widget/mod.d.ts.map +1 -1
  190. package/script/src/state/widget/mod.js +86 -93
  191. package/script/src/state/widget/performance.d.ts +2 -0
  192. package/script/src/state/widget/performance.d.ts.map +1 -0
  193. package/script/src/state/widget/performance.js +21 -0
  194. package/script/src/state/widget/sizing.d.ts +14 -3
  195. package/script/src/state/widget/sizing.d.ts.map +1 -1
  196. package/script/src/state/widget/sizing.js +62 -19
  197. package/script/src/system_state/ui_colors.d.ts +0 -2
  198. package/script/src/system_state/ui_colors.d.ts.map +1 -1
  199. package/script/src/system_state/ui_colors.js +0 -8
  200. package/script/src/utils/async.d.ts +12 -0
  201. package/script/src/utils/async.d.ts.map +1 -1
  202. package/script/src/utils/async.js +49 -0
  203. package/script/src/utils/mod.d.ts +1 -0
  204. package/script/src/utils/mod.d.ts.map +1 -1
  205. package/script/src/utils/mod.js +5 -0
  206. package/esm/gen/types/PinnedWegItemData.d.ts.map +0 -1
  207. package/esm/gen/types/SeelenCommandStateGetWegItemsArgs.d.ts +0 -5
  208. package/esm/gen/types/SeelenCommandStateGetWegItemsArgs.d.ts.map +0 -1
  209. package/esm/gen/types/WegAppGroupItem.d.ts +0 -12
  210. package/esm/gen/types/WegAppGroupItem.d.ts.map +0 -1
  211. package/esm/gen/types/WegItemSubtype.d.ts.map +0 -1
  212. package/esm/gen/types/WegItemSubtype.js +0 -8
  213. package/esm/src/state/weg_items.d.ts +0 -14
  214. package/esm/src/state/weg_items.d.ts.map +0 -1
  215. package/esm/src/state/weg_items.js +0 -23
  216. package/esm/src/state/wm_layout.d.ts +0 -2
  217. package/esm/src/state/wm_layout.d.ts.map +0 -1
  218. package/script/gen/types/PinnedWegItemData.d.ts.map +0 -1
  219. package/script/gen/types/SeelenCommandStateGetWegItemsArgs.d.ts +0 -5
  220. package/script/gen/types/SeelenCommandStateGetWegItemsArgs.d.ts.map +0 -1
  221. package/script/gen/types/WegAppGroupItem.d.ts +0 -12
  222. package/script/gen/types/WegAppGroupItem.d.ts.map +0 -1
  223. package/script/gen/types/WegItemSubtype.d.ts.map +0 -1
  224. package/script/gen/types/WegItemSubtype.js +0 -11
  225. package/script/src/state/weg_items.d.ts +0 -14
  226. package/script/src/state/weg_items.d.ts.map +0 -1
  227. package/script/src/state/weg_items.js +0 -27
  228. package/script/src/state/wm_layout.d.ts +0 -2
  229. package/script/src/state/wm_layout.d.ts.map +0 -1
  230. /package/esm/gen/types/{PinnedWegItemData.js → ClipboardData.js} +0 -0
  231. /package/esm/gen/types/{SeelenCommandStateGetWegItemsArgs.js → ClipboardEntry.js} +0 -0
  232. /package/esm/gen/types/{WegAppGroupItem.js → ClipboardEntryContent.js} +0 -0
  233. /package/esm/{src/state/wm_layout.js → gen/types/OldWegItemData.js} +0 -0
  234. /package/script/gen/types/{PinnedWegItemData.js → ClipboardData.js} +0 -0
  235. /package/script/gen/types/{SeelenCommandStateGetWegItemsArgs.js → ClipboardEntry.js} +0 -0
  236. /package/script/gen/types/{WegAppGroupItem.js → ClipboardEntryContent.js} +0 -0
  237. /package/script/{src/state/wm_layout.js → gen/types/OldWegItemData.js} +0 -0
@@ -161,7 +161,15 @@ export class IconPackManager {
161
161
  return null;
162
162
  }
163
163
  const lowerPath = path?.toLowerCase();
164
- const extension = lowerPath?.split(".").pop();
164
+ // Extract extension only when there's an actual dot after the last path separator,
165
+ // to avoid treating directory names without dots as extensions.
166
+ const lastDot = lowerPath?.lastIndexOf(".");
167
+ const lastSlash = lowerPath?.lastIndexOf("\\") ?? -1;
168
+ const extension = (lastDot !== undefined && lastDot > lastSlash) ? lowerPath.slice(lastDot + 1) : undefined;
169
+ // Add the starting path to __seen so that direct A→B→A cycles are caught in 2 hops.
170
+ if (lowerPath) {
171
+ __seen.add(lowerPath);
172
+ }
165
173
  for (const pack of this.activeIconPacks) {
166
174
  let entry;
167
175
  if (umid) {
@@ -178,7 +186,8 @@ export class IconPackManager {
178
186
  // only search for filename in case of executable files
179
187
  if (extension === "exe") {
180
188
  const filename = lowerPath.split("\\").pop();
181
- if (filename && e.path.endsWith(filename)) {
189
+ // Use separator-aware check to avoid partial name matches (e.g. "mysteam.exe" != "steam.exe")
190
+ if (filename && (e.path === filename || e.path.endsWith("\\" + filename))) {
182
191
  return true;
183
192
  }
184
193
  }
@@ -1,7 +1,5 @@
1
1
  export * from "./theme/mod.js";
2
2
  export * from "./settings/mod.js";
3
- export * from "./weg_items.js";
4
- export * from "./wm_layout.js";
5
3
  export * from "./icon_pack.js";
6
4
  export * from "./plugin/mod.js";
7
5
  export * from "./widget/mod.js";
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/state/mod.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/state/mod.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
@@ -1,7 +1,5 @@
1
1
  export * from "./theme/mod.js";
2
2
  export * from "./settings/mod.js";
3
- export * from "./weg_items.js";
4
- export * from "./wm_layout.js";
5
3
  export * from "./icon_pack.js";
6
4
  export * from "./plugin/mod.js";
7
5
  export * from "./widget/mod.js";
@@ -3,5 +3,6 @@
3
3
  * when the themes or settings change. Also will add the systehm ui colors to the document.
4
4
  */
5
5
  export declare function startThemingTool(): Promise<void>;
6
+ export declare function setPerformanceStyles(): void;
6
7
  export declare function startDateCssVariables(): void;
7
8
  //# sourceMappingURL=theming.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theming.d.ts","sourceRoot":"","sources":["../../../../src/src/state/theme/theming.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAoBtD;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAK5C"}
1
+ {"version":3,"file":"theming.d.ts","sourceRoot":"","sources":["../../../../src/src/state/theme/theming.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAqBtD;AAiBD,wBAAgB,oBAAoB,IAAI,IAAI,CAI3C;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAK5C"}
@@ -17,11 +17,31 @@ export async function startThemingTool() {
17
17
  settings = newSettings;
18
18
  themes.applyToDocument(settings.activeThemes, settings.byTheme);
19
19
  });
20
+ setPerformanceStyles();
21
+ startDateCssVariables();
20
22
  (await UIColors.getAsync()).setAsCssVariables();
21
23
  await UIColors.onChange((colors) => colors.setAsCssVariables());
22
- startDateCssVariables();
23
24
  themes.applyToDocument(settings.activeThemes, settings.byTheme);
24
25
  }
26
+ // Used by performance mode to reduce cpu/gpu usage
27
+ const PERF_CSS = `
28
+ html[data-animations-off] *,
29
+ html[data-animations-off] *::before,
30
+ html[data-animations-off] *::after {
31
+ animation-duration: 0.001ms !important;
32
+ animation-iteration-count: 1 !important;
33
+ animation-delay: 0s !important;
34
+
35
+ transition-duration: 0.001ms !important;
36
+ transition-delay: 0s !important;
37
+
38
+ scroll-behavior: auto !important;
39
+ }`;
40
+ export function setPerformanceStyles() {
41
+ const styleSheet = new RuntimeStyleSheet("@static/performance");
42
+ styleSheet.addStyle(PERF_CSS);
43
+ styleSheet.applyToDocument();
44
+ }
25
45
  export function startDateCssVariables() {
26
46
  // Set initial values immediately
27
47
  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
@@ -27,6 +38,12 @@ export interface InitWidgetOptions {
27
38
  * @default widget.preset === "Desktop"
28
39
  */
29
40
  saveAndRestoreLastRect?: boolean;
41
+ /**
42
+ * Will disable the css animations on the widget when performace mode is set to Extreme
43
+ *
44
+ * @default true
45
+ */
46
+ disableCssAnimations?: boolean;
30
47
  }
31
48
  export interface ReadyWidgetOptions {
32
49
  /**
@@ -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;CAClC;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,6 +1,7 @@
1
- import { type Frame, type Rect, type ThirdPartyWidgetSettings, type Widget as IWidget, type WidgetId, type WidgetTriggerPayload } from "../../../gen/types/mod.js";
2
- import { type WebviewWindow } from "@tauri-apps/api/webviewWindow";
1
+ import { type Alignment, type Frame, type Rect, type ThirdPartyWidgetSettings, type Widget as IWidget, type WidgetId, type WidgetTriggerPayload } from "../../../gen/types/mod.js";
3
2
  import type { InitWidgetOptions, ReadyWidgetOptions, WidgetInformation } from "./interfaces.js";
3
+ import { type Webview } from "@tauri-apps/api/webview";
4
+ import { type Window } from "@tauri-apps/api/window";
4
5
  /**
5
6
  * Represents the widget instance running in the current webview
6
7
  */
@@ -18,18 +19,17 @@ export declare class Widget {
18
19
  readonly def: IWidget;
19
20
  /** decoded widget instance information */
20
21
  readonly decoded: WidgetInformation;
21
- /** current webview window */
22
- readonly webview: WebviewWindow;
22
+ /** current webview where the widget is running */
23
+ readonly webview: Webview;
24
+ /** current window where the widget is running */
25
+ readonly window: Window;
23
26
  private autoSizer?;
24
27
  private runtimeState;
25
28
  private constructor();
26
29
  /** Returns the current window id of the widget */
27
30
  get windowId(): number;
28
- /** Returns the current position and size of the widget */
29
- get frame(): Frame;
30
31
  /** Returns the default config of the widget, declared on the widget definition */
31
32
  getDefaultConfig(): ThirdPartyWidgetSettings;
32
- private applyInvisiblePreset;
33
33
  /** Will apply the recommended settings for a desktop widget */
34
34
  private applyDesktopPreset;
35
35
  /** Will apply the recommended settings for an overlay widget */
@@ -40,7 +40,8 @@ export declare class Widget {
40
40
  * Will restore the saved position and size of the widget on start,
41
41
  * after that will store the position and size of the widget on change.
42
42
  */
43
- persistPositionAndSize(): Promise<void>;
43
+ private persistPositionAndSize;
44
+ private normalizeDevicePixelRatio;
44
45
  /**
45
46
  * Will initialize the widget based on the preset and mark it as `pending`, this function won't show the widget.
46
47
  * This should be called before any other action on the widget. After this you should call
@@ -55,7 +56,12 @@ export declare class Widget {
55
56
  */
56
57
  ready(options?: ReadyWidgetOptions): Promise<void>;
57
58
  onTrigger(cb: (args: WidgetTriggerPayload) => void): void;
58
- /** 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>;
59
65
  setPosition(rect: Rect): Promise<void>;
60
66
  show(): Promise<void>;
61
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;AAEnC,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAM5F,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAkBhG;;GAEG;AACH,q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,QAA8C,CAAC;AACnF,eAAO,MAAM,2BAA2B,EAAE,QAA+C,CAAC;AAC1F,eAAO,MAAM,kBAAkB,EAAE,QAAkD,CAAC"}
@@ -1,13 +1,14 @@
1
1
  import * as dntShim from "../../../_dnt.shims.js";
2
2
  import { WidgetPreset, WidgetStatus, } from "../../../gen/types/mod.js";
3
3
  import { invoke, SeelenCommand, SeelenEvent } from "../../handlers/mod.js";
4
- import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
5
4
  import { decodeBase64Url } from "../../../deps/jsr.io/@std/encoding/1.0.10/mod.js";
6
5
  import { debounce } from "../../utils/async.js";
7
- import { WidgetAutoSizer } from "./sizing.js";
6
+ import { OPTIMISTIC_FRAME, WidgetAutoSizer } from "./sizing.js";
8
7
  import { adjustPositionByPlacement, fitIntoMonitor, initMonitorsState } from "./positioning.js";
9
8
  import { startThemingTool } from "../theme/theming.js";
9
+ import { disableAnimationsOnPerformanceMode } from "./performance.js";
10
10
  import { getCurrentWebview } from "@tauri-apps/api/webview";
11
+ import { getCurrentWindow } from "@tauri-apps/api/window";
11
12
  /**
12
13
  * Represents the widget instance running in the current webview
13
14
  */
@@ -33,26 +34,21 @@ export class Widget {
33
34
  def;
34
35
  /** decoded widget instance information */
35
36
  decoded;
36
- /** current webview window */
37
+ /** current webview where the widget is running */
37
38
  webview;
39
+ /** current window where the widget is running */
40
+ window;
38
41
  autoSizer;
39
42
  runtimeState = {
40
43
  hwnd: 0,
41
44
  initialized: false,
42
45
  ready: false,
43
- position: {
44
- x: 0,
45
- y: 0,
46
- },
47
- size: {
48
- width: 0,
49
- height: 0,
50
- },
51
46
  firstFocus: true,
52
47
  };
53
48
  constructor(widget) {
54
49
  this.def = widget;
55
- this.webview = getCurrentWebviewWindow();
50
+ this.webview = getCurrentWebview();
51
+ this.window = getCurrentWindow();
56
52
  const [id, query] = getDecodedWebviewLabel();
57
53
  const params = new URLSearchParams(query);
58
54
  const paramsObj = Object.freeze(Object.fromEntries(params));
@@ -68,15 +64,6 @@ export class Widget {
68
64
  get windowId() {
69
65
  return this.runtimeState.hwnd;
70
66
  }
71
- /** Returns the current position and size of the widget */
72
- get frame() {
73
- return {
74
- x: this.runtimeState.position.x,
75
- y: this.runtimeState.position.y,
76
- width: this.runtimeState.size.width,
77
- height: this.runtimeState.size.height,
78
- };
79
- }
80
67
  /** Returns the default config of the widget, declared on the widget definition */
81
68
  getDefaultConfig() {
82
69
  const config = { enabled: true };
@@ -85,64 +72,28 @@ export class Widget {
85
72
  }
86
73
  return config;
87
74
  }
88
- applyInvisiblePreset() {
89
- return [
90
- this.webview.setDecorations(false), // no title bar
91
- this.webview.setShadow(false), // no shadows
92
- // hide from native shell
93
- this.webview.setSkipTaskbar(true),
94
- // as a (desktop/overlay) widget we don't wanna allow nothing of these
95
- this.webview.setMinimizable(false),
96
- this.webview.setMaximizable(false),
97
- this.webview.setClosable(false),
98
- ];
99
- }
100
75
  /** Will apply the recommended settings for a desktop widget */
101
- async applyDesktopPreset() {
102
- await Promise.all([...this.applyInvisiblePreset(), this.webview.setAlwaysOnBottom(true)]);
103
- }
76
+ applyDesktopPreset() { }
104
77
  /** Will apply the recommended settings for an overlay widget */
105
- async applyOverlayPreset() {
106
- await Promise.all([...this.applyInvisiblePreset(), this.webview.setAlwaysOnTop(true)]);
107
- }
78
+ applyOverlayPreset() { }
108
79
  /** Will apply the recommended settings for a popup widget */
109
- async applyPopupPreset() {
110
- await Promise.all([...this.applyInvisiblePreset(), this.webview.setAlwaysOnTop(true)]);
111
- const hideWebview = debounce(() => {
80
+ applyPopupPreset() {
81
+ const hideWidget = debounce(() => {
112
82
  this.hide(true);
113
83
  }, 100);
114
- this.webview.onFocusChanged(({ payload: focused }) => {
84
+ this.window.onFocusChanged(({ payload: focused }) => {
115
85
  if (focused) {
116
- hideWebview.cancel();
86
+ hideWidget.cancel();
117
87
  }
118
88
  else {
119
- hideWebview();
89
+ hideWidget();
120
90
  }
121
91
  });
122
92
  this.onTrigger(async ({ desiredPosition, alignX, alignY }) => {
123
93
  // avoid flickering when clicking a button that triggers the widget
124
- hideWebview.cancel();
125
- if (this.autoSizer && alignX && alignY) {
126
- this.autoSizer.originX = alignX;
127
- this.autoSizer.originY = alignY;
128
- }
94
+ hideWidget.cancel();
129
95
  if (desiredPosition) {
130
- const adjusted = adjustPositionByPlacement({
131
- frame: {
132
- x: desiredPosition.x,
133
- y: desiredPosition.y,
134
- width: this.runtimeState.size.width,
135
- height: this.runtimeState.size.height,
136
- },
137
- originX: alignX,
138
- originY: alignY,
139
- });
140
- await this.setPosition({
141
- left: adjusted.x,
142
- top: adjusted.y,
143
- right: adjusted.x + adjusted.width,
144
- bottom: adjusted.y + adjusted.height,
145
- });
96
+ await this.adjustAndSetPosition(desiredPosition.x, desiredPosition.y, alignX, alignY);
146
97
  }
147
98
  await this.show();
148
99
  await this.focus();
@@ -170,19 +121,31 @@ export class Widget {
170
121
  bottom: safeFrame.y + safeFrame.height,
171
122
  });
172
123
  }
173
- this.webview.onMoved(debounce((e) => {
124
+ this.window.onMoved(debounce((e) => {
174
125
  const { x, y } = e.payload;
175
126
  storage.setItem(`x`, x.toString());
176
127
  storage.setItem(`y`, y.toString());
177
128
  console.info(`Widget position saved: ${x} ${y}`);
178
129
  }, 500));
179
- this.webview.onResized(debounce((e) => {
130
+ this.window.onResized(debounce((e) => {
180
131
  const { width, height } = e.payload;
181
132
  storage.setItem(`width`, width.toString());
182
133
  storage.setItem(`height`, height.toString());
183
134
  console.info(`Widget size saved: ${width} ${height}`);
184
135
  }, 500));
185
136
  }
137
+ async normalizeDevicePixelRatio() {
138
+ // play with zoom level to reset device pixel ratio to 1:1
139
+ let oldDPR = globalThis.devicePixelRatio;
140
+ await this.webview.setZoom(1 / oldDPR);
141
+ this.window.onScaleChanged(() => {
142
+ if (globalThis.devicePixelRatio !== oldDPR) {
143
+ // when zoom was set dpr changed, so in case of change this is accomulative unit
144
+ oldDPR = oldDPR * globalThis.devicePixelRatio;
145
+ this.webview.setZoom(1 / (oldDPR * globalThis.devicePixelRatio));
146
+ }
147
+ });
148
+ }
186
149
  /**
187
150
  * Will initialize the widget based on the preset and mark it as `pending`, this function won't show the widget.
188
151
  * This should be called before any other action on the widget. After this you should call
@@ -195,8 +158,11 @@ export class Widget {
195
158
  }
196
159
  this.runtimeState.hwnd = await invoke(SeelenCommand.GetSelfWindowId);
197
160
  this.runtimeState.initialized = true;
161
+ if (options.normalizeDevicePixelRatio) {
162
+ await this.normalizeDevicePixelRatio();
163
+ }
198
164
  if (options.autoSizeByContent) {
199
- this.autoSizer = new WidgetAutoSizer(this, options.autoSizeByContent);
165
+ this.autoSizer = new WidgetAutoSizer(this, options.autoSizeByContent, options.autoSizeFitOnScreen ?? true);
200
166
  }
201
167
  else if (options.saveAndRestoreLastRect ?? this.def.preset === WidgetPreset.Desktop) {
202
168
  await this.persistPositionAndSize();
@@ -205,27 +171,25 @@ export class Widget {
205
171
  case WidgetPreset.None:
206
172
  break;
207
173
  case WidgetPreset.Desktop:
208
- await this.applyDesktopPreset();
174
+ this.applyDesktopPreset();
209
175
  break;
210
176
  case WidgetPreset.Overlay:
211
- await this.applyOverlayPreset();
177
+ this.applyOverlayPreset();
212
178
  break;
213
179
  case WidgetPreset.Popup:
214
- await this.applyPopupPreset();
180
+ this.applyPopupPreset();
215
181
  break;
216
182
  }
217
183
  await startThemingTool();
218
184
  await initMonitorsState();
219
- // state initialization
220
- this.runtimeState.size = await this.webview.outerSize();
221
- this.runtimeState.position = await this.webview.outerPosition();
222
- this.webview.onResized((e) => {
223
- this.runtimeState.size.width = e.payload.width;
224
- this.runtimeState.size.height = e.payload.height;
225
- });
226
- this.webview.onMoved((e) => {
227
- this.runtimeState.position.x = e.payload.x;
228
- this.runtimeState.position.y = e.payload.y;
185
+ if (options.disableCssAnimations ?? true) {
186
+ await disableAnimationsOnPerformanceMode();
187
+ }
188
+ else {
189
+ console.trace("Animations won't be disabled because widget configuration");
190
+ }
191
+ await OPTIMISTIC_FRAME.runExclusive(async (state) => {
192
+ await state.init(this);
229
193
  });
230
194
  }
231
195
  /**
@@ -245,7 +209,7 @@ export class Widget {
245
209
  }
246
210
  this.runtimeState.ready = true;
247
211
  await this.autoSizer?.execute();
248
- if (show && !(await this.webview.isVisible())) {
212
+ if (show && !(await this.window.isVisible())) {
249
213
  await this.show();
250
214
  await this.focus();
251
215
  }
@@ -257,13 +221,8 @@ export class Widget {
257
221
  cb(payload);
258
222
  });
259
223
  }
260
- /** If animations are enabled this will animate the movement of the widget */
261
- setPosition(rect) {
262
- this.runtimeState.position.x = rect.left;
263
- this.runtimeState.position.y = rect.top;
264
- this.runtimeState.size.width = rect.right - rect.left;
265
- this.runtimeState.size.height = rect.bottom - rect.top;
266
- return invoke(SeelenCommand.SetSelfPosition, {
224
+ async __unsafe_setPosition(rect, ref) {
225
+ await invoke(SeelenCommand.SetSelfPosition, {
267
226
  rect: {
268
227
  left: Math.round(rect.left),
269
228
  top: Math.round(rect.top),
@@ -271,10 +230,44 @@ export class Widget {
271
230
  bottom: Math.round(rect.bottom),
272
231
  },
273
232
  });
233
+ // optimistically update state, as arrived event after change is async
234
+ ref.x = rect.left;
235
+ ref.y = rect.top;
236
+ ref.width = rect.right - rect.left;
237
+ ref.height = rect.bottom - rect.top;
238
+ }
239
+ /**
240
+ * This will adjust the position of the widget based on the current placement and alignX/alignY arguments.
241
+ * This makes the widget fit into the monitor where it was placed, avoiding monitor overflow.
242
+ */
243
+ async adjustAndSetPosition(x, y, alignX, alignY) {
244
+ await OPTIMISTIC_FRAME.runExclusive(async (ref) => {
245
+ const adjusted = adjustPositionByPlacement({
246
+ frame: {
247
+ x,
248
+ y,
249
+ width: ref.width,
250
+ height: ref.height,
251
+ },
252
+ originX: alignX,
253
+ originY: alignY,
254
+ });
255
+ await Widget.self.__unsafe_setPosition({
256
+ left: adjusted.x,
257
+ top: adjusted.y,
258
+ right: adjusted.x + adjusted.width,
259
+ bottom: adjusted.y + adjusted.height,
260
+ }, ref);
261
+ });
262
+ }
263
+ async setPosition(rect) {
264
+ await OPTIMISTIC_FRAME.runExclusive(async (frame) => {
265
+ await this.__unsafe_setPosition(rect, frame);
266
+ });
274
267
  }
275
268
  async show() {
276
269
  debouncedClose.cancel();
277
- await this.webview.show();
270
+ await this.window.show();
278
271
  }
279
272
  /** Will force foreground the widget */
280
273
  async focus() {
@@ -287,14 +280,14 @@ export class Widget {
287
280
  });
288
281
  }
289
282
  hide(closeAfterInactivity) {
290
- Widget.self.webview.hide();
283
+ this.window.hide();
291
284
  if (closeAfterInactivity) {
292
285
  debouncedClose();
293
286
  }
294
287
  }
295
288
  }
296
289
  const debouncedClose = debounce(() => {
297
- Widget.self.webview.close();
290
+ Widget.self.window.close();
298
291
  }, 30_000);
299
292
  export const SeelenSettingsWidgetId = "@seelen/settings";
300
293
  export const SeelenPopupWidgetId = "@seelen/popup";
@@ -303,7 +296,7 @@ export const SeelenToolbarWidgetId = "@seelen/fancy-toolbar";
303
296
  export const SeelenWindowManagerWidgetId = "@seelen/window-manager";
304
297
  export const SeelenWallWidgetId = "@seelen/wallpaper-manager";
305
298
  function getDecodedWebviewLabel() {
306
- const encondedLabel = getCurrentWebviewWindow().label;
299
+ const encondedLabel = getCurrentWebview().label;
307
300
  const decodedLabel = new TextDecoder().decode(decodeBase64Url(encondedLabel));
308
301
  const [id, query] = decodedLabel.split("?");
309
302
  if (!id) {
@@ -0,0 +1,2 @@
1
+ export declare function disableAnimationsOnPerformanceMode(): Promise<void>;
2
+ //# sourceMappingURL=performance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/performance.ts"],"names":[],"mappings":"AAGA,wBAAsB,kCAAkC,IAAI,OAAO,CAAC,IAAI,CAAC,CAMxE"}
@@ -0,0 +1,18 @@
1
+ import { PerformanceMode } from "../../../gen/types/mod.js";
2
+ import { invoke, SeelenCommand, SeelenEvent, subscribe } from "../../handlers/mod.js";
3
+ export async function disableAnimationsOnPerformanceMode() {
4
+ const initial = await invoke(SeelenCommand.StateGetPerformanceMode);
5
+ setDisableAnimations(initial);
6
+ subscribe(SeelenEvent.StatePerformanceModeChanged, (e) => {
7
+ setDisableAnimations(e.payload);
8
+ });
9
+ }
10
+ function setDisableAnimations(mode) {
11
+ const root = document.documentElement;
12
+ if (mode === PerformanceMode.Extreme) {
13
+ root.setAttribute("data-animations-off", "");
14
+ }
15
+ else {
16
+ root.removeAttribute("data-animations-off");
17
+ }
18
+ }
@@ -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,CA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