@seelen-ui/lib 2.4.9 → 2.4.10

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 (181) hide show
  1. package/esm/gen/types/BluetoothDevice.d.ts +1 -0
  2. package/esm/gen/types/BluetoothDevice.d.ts.map +1 -1
  3. package/esm/gen/types/DevicePairingAnswer.d.ts +8 -0
  4. package/esm/gen/types/DevicePairingAnswer.d.ts.map +1 -0
  5. package/esm/gen/types/DevicePairingNeededAction.d.ts +18 -0
  6. package/esm/gen/types/DevicePairingNeededAction.d.ts.map +1 -0
  7. package/esm/gen/types/RadioDevice.d.ts +14 -0
  8. package/esm/gen/types/RadioDevice.d.ts.map +1 -0
  9. package/esm/gen/types/RadioDevice.js +1 -0
  10. package/esm/gen/types/RadioDeviceKind.d.ts +8 -0
  11. package/esm/gen/types/RadioDeviceKind.d.ts.map +1 -0
  12. package/esm/gen/types/RadioDeviceKind.js +9 -0
  13. package/esm/gen/types/ResourceMetadata.d.ts +6 -0
  14. package/esm/gen/types/ResourceMetadata.d.ts.map +1 -1
  15. package/esm/gen/types/SeelenCommandArgument.d.ts +25 -14
  16. package/esm/gen/types/SeelenCommandArgument.d.ts.map +1 -1
  17. package/esm/gen/types/SeelenCommandConfirmBluetoothDevicePairingArgs.d.ts +6 -0
  18. package/esm/gen/types/SeelenCommandConfirmBluetoothDevicePairingArgs.d.ts.map +1 -0
  19. package/esm/gen/types/SeelenCommandConfirmBluetoothDevicePairingArgs.js +1 -0
  20. package/esm/gen/types/SeelenCommandDisconnectBluetoothDeviceArgs.d.ts +4 -0
  21. package/esm/gen/types/SeelenCommandDisconnectBluetoothDeviceArgs.d.ts.map +1 -0
  22. package/esm/gen/types/SeelenCommandDisconnectBluetoothDeviceArgs.js +2 -0
  23. package/esm/gen/types/SeelenCommandRequestPairBluetoothDeviceArgs.d.ts +4 -0
  24. package/esm/gen/types/SeelenCommandRequestPairBluetoothDeviceArgs.d.ts.map +1 -0
  25. package/esm/gen/types/SeelenCommandRequestPairBluetoothDeviceArgs.js +2 -0
  26. package/esm/gen/types/SeelenCommandReturn.d.ts +22 -12
  27. package/esm/gen/types/SeelenCommandReturn.d.ts.map +1 -1
  28. package/esm/gen/types/SeelenCommandSetCurrentWidgetStatusArgs.d.ts +5 -0
  29. package/esm/gen/types/SeelenCommandSetCurrentWidgetStatusArgs.d.ts.map +1 -0
  30. package/esm/gen/types/SeelenCommandSetCurrentWidgetStatusArgs.js +1 -0
  31. package/esm/gen/types/SeelenCommandSetRadioStateArgs.d.ts +6 -0
  32. package/esm/gen/types/SeelenCommandSetRadioStateArgs.d.ts.map +1 -0
  33. package/esm/gen/types/SeelenCommandSetRadioStateArgs.js +1 -0
  34. package/esm/gen/types/SeelenEventPayload.d.ts +7 -9
  35. package/esm/gen/types/SeelenEventPayload.d.ts.map +1 -1
  36. package/esm/gen/types/ThemeVariable.d.ts +18 -4
  37. package/esm/gen/types/ThemeVariable.d.ts.map +1 -1
  38. package/esm/gen/types/ThemeVariableDefinition.d.ts +1 -1
  39. package/esm/gen/types/ThemeVariableDefinition.d.ts.map +1 -1
  40. package/esm/gen/types/ThemeVariableWithUnit.d.ts +22 -6
  41. package/esm/gen/types/ThemeVariableWithUnit.d.ts.map +1 -1
  42. package/esm/gen/types/Wallpaper.d.ts +1 -1
  43. package/esm/gen/types/Wallpaper.d.ts.map +1 -1
  44. package/esm/gen/types/Widget.d.ts +4 -0
  45. package/esm/gen/types/Widget.d.ts.map +1 -1
  46. package/esm/gen/types/WidgetStatus.d.ts +8 -0
  47. package/esm/gen/types/WidgetStatus.d.ts.map +1 -0
  48. package/esm/gen/types/WidgetStatus.js +9 -0
  49. package/esm/gen/types/mod.d.ts +10 -2
  50. package/esm/gen/types/mod.d.ts.map +1 -1
  51. package/esm/gen/types/mod.js +10 -2
  52. package/esm/src/handlers/commands.d.ts +11 -7
  53. package/esm/src/handlers/commands.d.ts.map +1 -1
  54. package/esm/src/handlers/commands.js +10 -6
  55. package/esm/src/handlers/events.d.ts +4 -5
  56. package/esm/src/handlers/events.d.ts.map +1 -1
  57. package/esm/src/handlers/events.js +3 -4
  58. package/esm/src/state/theme/mod.d.ts +0 -6
  59. package/esm/src/state/theme/mod.d.ts.map +1 -1
  60. package/esm/src/state/theme/mod.js +12 -30
  61. package/esm/src/state/theme/theming.d.ts +5 -0
  62. package/esm/src/state/theme/theming.d.ts.map +1 -1
  63. package/esm/src/state/theme/theming.js +36 -39
  64. package/esm/src/state/wallpaper/mod.d.ts +4 -2
  65. package/esm/src/state/wallpaper/mod.d.ts.map +1 -1
  66. package/esm/src/state/wallpaper/mod.js +4 -2
  67. package/esm/src/state/widget/mod.d.ts +31 -8
  68. package/esm/src/state/widget/mod.d.ts.map +1 -1
  69. package/esm/src/state/widget/mod.js +69 -31
  70. package/esm/src/state/widget/sizing.d.ts +7 -2
  71. package/esm/src/state/widget/sizing.d.ts.map +1 -1
  72. package/esm/src/state/widget/sizing.js +39 -36
  73. package/esm/src/system_state/bluetooth/mod.d.ts +1 -7
  74. package/esm/src/system_state/bluetooth/mod.d.ts.map +1 -1
  75. package/esm/src/system_state/bluetooth/mod.js +1 -26
  76. package/esm/src/system_state/ui_colors.d.ts +6 -3
  77. package/esm/src/system_state/ui_colors.d.ts.map +1 -1
  78. package/esm/src/system_state/ui_colors.js +63 -32
  79. package/esm/src/utils/DOM.d.ts +9 -0
  80. package/esm/src/utils/DOM.d.ts.map +1 -0
  81. package/esm/src/utils/DOM.js +29 -0
  82. package/package.json +1 -1
  83. package/script/gen/types/BluetoothDevice.d.ts +1 -0
  84. package/script/gen/types/BluetoothDevice.d.ts.map +1 -1
  85. package/script/gen/types/DevicePairingAnswer.d.ts +8 -0
  86. package/script/gen/types/DevicePairingAnswer.d.ts.map +1 -0
  87. package/script/gen/types/DevicePairingNeededAction.d.ts +18 -0
  88. package/script/gen/types/DevicePairingNeededAction.d.ts.map +1 -0
  89. package/script/gen/types/RadioDevice.d.ts +14 -0
  90. package/script/gen/types/RadioDevice.d.ts.map +1 -0
  91. package/script/gen/types/RadioDevice.js +2 -0
  92. package/script/gen/types/RadioDeviceKind.d.ts +8 -0
  93. package/script/gen/types/RadioDeviceKind.d.ts.map +1 -0
  94. package/script/gen/types/RadioDeviceKind.js +12 -0
  95. package/script/gen/types/ResourceMetadata.d.ts +6 -0
  96. package/script/gen/types/ResourceMetadata.d.ts.map +1 -1
  97. package/script/gen/types/SeelenCommandArgument.d.ts +25 -14
  98. package/script/gen/types/SeelenCommandArgument.d.ts.map +1 -1
  99. package/script/gen/types/SeelenCommandConfirmBluetoothDevicePairingArgs.d.ts +6 -0
  100. package/script/gen/types/SeelenCommandConfirmBluetoothDevicePairingArgs.d.ts.map +1 -0
  101. package/script/gen/types/SeelenCommandConfirmBluetoothDevicePairingArgs.js +2 -0
  102. package/script/gen/types/SeelenCommandDisconnectBluetoothDeviceArgs.d.ts +4 -0
  103. package/script/gen/types/SeelenCommandDisconnectBluetoothDeviceArgs.d.ts.map +1 -0
  104. package/script/gen/types/SeelenCommandDisconnectBluetoothDeviceArgs.js +3 -0
  105. package/script/gen/types/SeelenCommandRequestPairBluetoothDeviceArgs.d.ts +4 -0
  106. package/script/gen/types/SeelenCommandRequestPairBluetoothDeviceArgs.d.ts.map +1 -0
  107. package/script/gen/types/SeelenCommandRequestPairBluetoothDeviceArgs.js +3 -0
  108. package/script/gen/types/SeelenCommandReturn.d.ts +22 -12
  109. package/script/gen/types/SeelenCommandReturn.d.ts.map +1 -1
  110. package/script/gen/types/SeelenCommandSetCurrentWidgetStatusArgs.d.ts +5 -0
  111. package/script/gen/types/SeelenCommandSetCurrentWidgetStatusArgs.d.ts.map +1 -0
  112. package/script/gen/types/SeelenCommandSetCurrentWidgetStatusArgs.js +2 -0
  113. package/script/gen/types/SeelenCommandSetRadioStateArgs.d.ts +6 -0
  114. package/script/gen/types/SeelenCommandSetRadioStateArgs.d.ts.map +1 -0
  115. package/script/gen/types/SeelenCommandSetRadioStateArgs.js +2 -0
  116. package/script/gen/types/SeelenEventPayload.d.ts +7 -9
  117. package/script/gen/types/SeelenEventPayload.d.ts.map +1 -1
  118. package/script/gen/types/ThemeVariable.d.ts +18 -4
  119. package/script/gen/types/ThemeVariable.d.ts.map +1 -1
  120. package/script/gen/types/ThemeVariableDefinition.d.ts +1 -1
  121. package/script/gen/types/ThemeVariableDefinition.d.ts.map +1 -1
  122. package/script/gen/types/ThemeVariableWithUnit.d.ts +22 -6
  123. package/script/gen/types/ThemeVariableWithUnit.d.ts.map +1 -1
  124. package/script/gen/types/Wallpaper.d.ts +1 -1
  125. package/script/gen/types/Wallpaper.d.ts.map +1 -1
  126. package/script/gen/types/Widget.d.ts +4 -0
  127. package/script/gen/types/Widget.d.ts.map +1 -1
  128. package/script/gen/types/WidgetStatus.d.ts +8 -0
  129. package/script/gen/types/WidgetStatus.d.ts.map +1 -0
  130. package/script/gen/types/WidgetStatus.js +12 -0
  131. package/script/gen/types/mod.d.ts +10 -2
  132. package/script/gen/types/mod.d.ts.map +1 -1
  133. package/script/gen/types/mod.js +10 -2
  134. package/script/src/handlers/commands.d.ts +11 -7
  135. package/script/src/handlers/commands.d.ts.map +1 -1
  136. package/script/src/handlers/commands.js +10 -6
  137. package/script/src/handlers/events.d.ts +4 -5
  138. package/script/src/handlers/events.d.ts.map +1 -1
  139. package/script/src/handlers/events.js +3 -4
  140. package/script/src/state/theme/mod.d.ts +0 -6
  141. package/script/src/state/theme/mod.d.ts.map +1 -1
  142. package/script/src/state/theme/mod.js +11 -31
  143. package/script/src/state/theme/theming.d.ts +5 -0
  144. package/script/src/state/theme/theming.d.ts.map +1 -1
  145. package/script/src/state/theme/theming.js +37 -39
  146. package/script/src/state/wallpaper/mod.d.ts +4 -2
  147. package/script/src/state/wallpaper/mod.d.ts.map +1 -1
  148. package/script/src/state/wallpaper/mod.js +4 -2
  149. package/script/src/state/widget/mod.d.ts +31 -8
  150. package/script/src/state/widget/mod.d.ts.map +1 -1
  151. package/script/src/state/widget/mod.js +66 -28
  152. package/script/src/state/widget/sizing.d.ts +7 -2
  153. package/script/src/state/widget/sizing.d.ts.map +1 -1
  154. package/script/src/state/widget/sizing.js +41 -37
  155. package/script/src/system_state/bluetooth/mod.d.ts +1 -7
  156. package/script/src/system_state/bluetooth/mod.d.ts.map +1 -1
  157. package/script/src/system_state/bluetooth/mod.js +1 -26
  158. package/script/src/system_state/ui_colors.d.ts +6 -3
  159. package/script/src/system_state/ui_colors.d.ts.map +1 -1
  160. package/script/src/system_state/ui_colors.js +63 -32
  161. package/script/src/utils/DOM.d.ts +9 -0
  162. package/script/src/utils/DOM.d.ts.map +1 -0
  163. package/script/src/utils/DOM.js +33 -0
  164. package/esm/gen/types/SeelenCommandConfirmBluetoothDevicePairArgs.d.ts +0 -5
  165. package/esm/gen/types/SeelenCommandConfirmBluetoothDevicePairArgs.d.ts.map +0 -1
  166. package/esm/gen/types/SeelenCommandPairBluetoothDeviceArgs.d.ts +0 -4
  167. package/esm/gen/types/SeelenCommandPairBluetoothDeviceArgs.d.ts.map +0 -1
  168. package/esm/src/utils/Wrapper.d.ts +0 -3
  169. package/esm/src/utils/Wrapper.d.ts.map +0 -1
  170. package/esm/src/utils/Wrapper.js +0 -5
  171. package/script/gen/types/SeelenCommandConfirmBluetoothDevicePairArgs.d.ts +0 -5
  172. package/script/gen/types/SeelenCommandConfirmBluetoothDevicePairArgs.d.ts.map +0 -1
  173. package/script/gen/types/SeelenCommandPairBluetoothDeviceArgs.d.ts +0 -4
  174. package/script/gen/types/SeelenCommandPairBluetoothDeviceArgs.d.ts.map +0 -1
  175. package/script/src/utils/Wrapper.d.ts +0 -3
  176. package/script/src/utils/Wrapper.d.ts.map +0 -1
  177. package/script/src/utils/Wrapper.js +0 -8
  178. /package/esm/gen/types/{SeelenCommandConfirmBluetoothDevicePairArgs.js → DevicePairingAnswer.js} +0 -0
  179. /package/esm/gen/types/{SeelenCommandPairBluetoothDeviceArgs.js → DevicePairingNeededAction.js} +0 -0
  180. /package/script/gen/types/{SeelenCommandConfirmBluetoothDevicePairArgs.js → DevicePairingAnswer.js} +0 -0
  181. /package/script/gen/types/{SeelenCommandPairBluetoothDeviceArgs.js → DevicePairingNeededAction.js} +0 -0
@@ -1,6 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startThemingTool = startThemingTool;
3
4
  exports.startDateCssVariables = startDateCssVariables;
5
+ const ui_colors_js_1 = require("../../system_state/ui_colors.js");
6
+ const DOM_js_1 = require("../../utils/DOM.js");
7
+ const mod_js_1 = require("../settings/mod.js");
8
+ const mod_js_2 = require("./mod.js");
9
+ /**
10
+ * This will apply the active themes for this widget, and automatically update
11
+ * when the themes or settings change. Also will add the systehm ui colors to the document.
12
+ */
13
+ async function startThemingTool() {
14
+ let settings = await mod_js_1.Settings.getAsync();
15
+ let themes = await mod_js_2.ThemeList.getAsync();
16
+ await mod_js_2.ThemeList.onChange((newThemes) => {
17
+ themes = newThemes;
18
+ themes.applyToDocument(settings.activeThemes, settings.byTheme);
19
+ });
20
+ await mod_js_1.Settings.onChange((newSettings) => {
21
+ settings = newSettings;
22
+ themes.applyToDocument(settings.activeThemes, settings.byTheme);
23
+ });
24
+ (await ui_colors_js_1.UIColors.getAsync()).setAsCssVariables();
25
+ await ui_colors_js_1.UIColors.onChange((colors) => colors.setAsCssVariables());
26
+ startDateCssVariables();
27
+ themes.applyToDocument(settings.activeThemes, settings.byTheme);
28
+ }
4
29
  function startDateCssVariables() {
5
30
  // Set initial values immediately
6
31
  updateDateCssVariables();
@@ -20,43 +45,16 @@ function updateDateCssVariables() {
20
45
  const dayOfMonth = now.getDate(); // 1-31
21
46
  const monthNumber = now.getMonth() + 1; // 1-12
22
47
  const year = now.getFullYear(); // 2025, etc.
23
- insertIntoStyleSheet({
24
- // Time variables
25
- "--date-hour": String(hour),
26
- "--date-minute": String(minute),
27
- // Date name variables (localized)
28
- "--date-day-name": dayName,
29
- "--date-month-name": monthName,
30
- // Date numeric variables
31
- "--date-day": String(dayOfMonth),
32
- "--date-month": String(monthNumber),
33
- "--date-year": String(year),
34
- });
35
- }
36
- function getRuntimeStyleSheet() {
37
- const styleId = "slu-lib-date-variables";
38
- let styleElement = document.getElementById(styleId);
39
- if (!styleElement) {
40
- styleElement = document.createElement("style");
41
- styleElement.id = styleId;
42
- styleElement.textContent = ":root {\n}";
43
- document.head.appendChild(styleElement);
44
- }
45
- return styleElement;
46
- }
47
- function insertIntoStyleSheet(obj) {
48
- const sheet = getRuntimeStyleSheet();
49
- const lines = sheet.textContent.split("\n");
50
- lines.pop(); // remove the closing brace
51
- for (const [key, value] of Object.entries(obj)) {
52
- const old = lines.findIndex((line) => line.startsWith(key));
53
- if (old !== -1) {
54
- lines[old] = `${key}: ${value};`;
55
- }
56
- else {
57
- lines.push(`${key}: ${value};`);
58
- }
59
- }
60
- lines.push("}");
61
- sheet.textContent = lines.join("\n");
48
+ const styleSheet = new DOM_js_1.RuntimeStyleSheet("@runtime/date-variables");
49
+ // Time variables
50
+ styleSheet.addVariable("--date-hour", String(hour));
51
+ styleSheet.addVariable("--date-minute", String(minute));
52
+ // Date name variables (localized)
53
+ styleSheet.addVariable("--date-day-name", dayName);
54
+ styleSheet.addVariable("--date-month-name", monthName);
55
+ // Date numeric variables
56
+ styleSheet.addVariable("--date-day", String(dayOfMonth));
57
+ styleSheet.addVariable("--date-month", String(monthNumber));
58
+ styleSheet.addVariable("--date-year", String(year));
59
+ styleSheet.applyToDocument();
62
60
  }
@@ -1,14 +1,16 @@
1
1
  import type { Wallpaper as IWallpaper, WallpaperInstanceSettings } from "../../../gen/types/mod.js";
2
2
  import { type UnSubscriber } from "../../handlers/mod.js";
3
3
  import { List } from "../../utils/List.js";
4
- import { Wrapper } from "../../utils/Wrapper.js";
5
4
  export declare const SUPPORTED_IMAGE_WALLPAPER_EXTENSIONS: string[];
6
5
  export declare const SUPPORTED_VIDEO_WALLPAPER_EXTENSIONS: string[];
7
6
  export declare class WallpaperList extends List<IWallpaper> {
8
7
  static getAsync(): Promise<WallpaperList>;
9
8
  static onChange(cb: (payload: WallpaperList) => void): Promise<UnSubscriber>;
10
9
  }
11
- export declare class WallpaperConfiguration extends Wrapper<WallpaperInstanceSettings> {
10
+ export interface WallpaperConfiguration extends WallpaperInstanceSettings {
11
+ }
12
+ export declare class WallpaperConfiguration {
13
+ constructor(plain: WallpaperInstanceSettings);
12
14
  static default(): Promise<WallpaperConfiguration>;
13
15
  }
14
16
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/state/wallpaper/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,IAAI,UAAU,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEpG,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,eAAO,MAAM,oCAAoC,UAYhD,CAAC;AAEF,eAAO,MAAM,oCAAoC,UAQhD,CAAC;AAEF,qBAAa,aAAc,SAAQ,IAAI,CAAC,UAAU,CAAC;IACjD,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC;IAIzC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;CAG7E;AAED,qBAAa,sBAAuB,SAAQ,OAAO,CAAC,yBAAyB,CAAC;IAC5E,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAGlD"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/state/wallpaper/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,IAAI,UAAU,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEpG,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG3C,eAAO,MAAM,oCAAoC,UAYhD,CAAC;AAEF,eAAO,MAAM,oCAAoC,UAQhD,CAAC;AAEF,qBAAa,aAAc,SAAQ,IAAI,CAAC,UAAU,CAAC;IACjD,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC;IAIzC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;CAG7E;AAED,MAAM,WAAW,sBAAuB,SAAQ,yBAAyB;CAAG;AAC5E,qBAAa,sBAAsB;gBACrB,KAAK,EAAE,yBAAyB;IAI5C,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC,sBAAsB,CAAC;CAGlD"}
@@ -4,7 +4,6 @@ exports.WallpaperConfiguration = exports.WallpaperList = exports.SUPPORTED_VIDEO
4
4
  const mod_js_1 = require("../../handlers/mod.js");
5
5
  const List_js_1 = require("../../utils/List.js");
6
6
  const State_js_1 = require("../../utils/State.js");
7
- const Wrapper_js_1 = require("../../utils/Wrapper.js");
8
7
  exports.SUPPORTED_IMAGE_WALLPAPER_EXTENSIONS = [
9
8
  "apng",
10
9
  "avif",
@@ -36,7 +35,10 @@ class WallpaperList extends List_js_1.List {
36
35
  }
37
36
  }
38
37
  exports.WallpaperList = WallpaperList;
39
- class WallpaperConfiguration extends Wrapper_js_1.Wrapper {
38
+ class WallpaperConfiguration {
39
+ constructor(plain) {
40
+ Object.assign(this, plain);
41
+ }
40
42
  static default() {
41
43
  return (0, State_js_1.newFromInvoke)(this, mod_js_1.SeelenCommand.StateGetDefaultWallpaperSettings);
42
44
  }
@@ -14,7 +14,7 @@ export declare class WidgetList extends List<IWidget> {
14
14
  static onChange(cb: (payload: WidgetList) => void): Promise<UnSubscriber>;
15
15
  findById(id: WidgetId): IWidget | undefined;
16
16
  }
17
- interface WidgetInformation {
17
+ export interface WidgetInformation {
18
18
  /** decoded webview label */
19
19
  label: string;
20
20
  /** Will be present if the widget replicas is set to by monitor */
@@ -26,6 +26,20 @@ interface WidgetInformation {
26
26
  readonly [key in string]?: string;
27
27
  };
28
28
  }
29
+ export interface InitWidgetOptions {
30
+ /**
31
+ * @default !widget.lazy
32
+ */
33
+ show?: boolean;
34
+ /**
35
+ * Will auto size the widget to the content size of the element
36
+ * @example
37
+ * autoSizeByContent: document.body,
38
+ * autoSizeByContent: document.getElementById("root"),
39
+ * @default undefined
40
+ */
41
+ autoSizeByContent?: HTMLElement | null;
42
+ }
29
43
  /**
30
44
  * Represents the widget instance running in the current webview
31
45
  */
@@ -38,6 +52,9 @@ export declare class Widget {
38
52
  readonly decoded: WidgetInformation;
39
53
  /** current webview window */
40
54
  readonly webview: WebviewWindow;
55
+ private autoSizer?;
56
+ private initOptions;
57
+ private runtimeState;
41
58
  private constructor();
42
59
  private static getDecodedWebviewLabel;
43
60
  /** Will throw if the library is being used on a non Seelen UI environment */
@@ -55,17 +72,23 @@ export declare class Widget {
55
72
  /** Will apply the recommended settings for a popup widget */
56
73
  private applyPopupPreset;
57
74
  /**
58
- * Will restore the saved position and size of the widget after that
59
- * will store the position and size of the widget on change.
75
+ * Will restore the saved position and size of the widget on start,
76
+ * after that will store the position and size of the widget on change.
60
77
  */
61
78
  persistPositionAndSize(): Promise<void>;
62
- autoSizeWebviewByElement(element?: HTMLElement): void;
63
79
  /**
64
- * Will initialize the widget based on the preset, this function won't show the widget.
65
- * You need to call `webview.show()` to show the widget.
80
+ * Will initialize the widget based on the preset and mark it as `pending`, this function won't show the widget.
81
+ * This should be called before any other action on the widget. After this you should call
82
+ * `ready` to mark the widget as ready and show it.
83
+ */
84
+ init(options?: InitWidgetOptions): Promise<void>;
85
+ /**
86
+ * Will mark the widget as `ready` and pool pending triggers.
87
+ *
88
+ * If the widget is not lazy this will inmediately show the widget.
89
+ * Lazy widget should be shown on trigger action.
66
90
  */
67
- init(): Promise<void>;
91
+ ready(): Promise<void>;
68
92
  onTrigger(cb: (args: WidgetTriggerPayload) => void): void;
69
93
  }
70
- export {};
71
94
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/mod.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,QAAQ,EAEb,KAAK,oBAAoB,EAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAS5F,eAAO,MAAM,sBAAsB,EAAE,QAAyC,CAAC;AAC/E,eAAO,MAAM,mBAAmB,EAAE,QAAsC,CAAC;AACzE,eAAO,MAAM,iBAAiB,EAAE,QAAoC,CAAC;AACrE,eAAO,MAAM,qBAAqB,EAAE,QAA8C,CAAC;AACnF,eAAO,MAAM,2BAA2B,EAAE,QAA+C,CAAC;AAC1F,eAAO,MAAM,sBAAsB,EAAE,QAAyC,CAAC;AAC/E,eAAO,MAAM,kBAAkB,EAAE,QAAkD,CAAC;AAEpF,qBAAa,UAAW,SAAQ,IAAI,CAAC,OAAO,CAAC;IAC3C,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC;IAItC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAIzE,QAAQ,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS;CAG5C;AAED,UAAU,iBAAiB;IACzB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,k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;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACxC;AAOD;;GAEG;AACH,qBAAa,MAAM;IACjB,gBAAgB;IAChB,SAAgB,EAAE,EAAE,QAAQ,CAAC;IAC7B,wBAAwB;IACxB,SAAgB,GAAG,EAAE,OAAO,CAAC;IAC7B,0CAA0C;IAC1C,SAAgB,OAAO,EAAE,iBAAiB,CAAC;IAC3C,6BAA6B;IAC7B,SAAgB,OAAO,EAAE,aAAa,CAAC;IAEvC,OAAO,CAAC,SAAS,CAAC,CAAkB;IACpC,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,YAAY,CAGlB;IAEF,OAAO;IAiBP,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAUrC,6EAA6E;IAC7E,MAAM,CAAC,kBAAkB,IAAI,QAAQ;IAIrC,6EAA6E;IAC7E,MAAM,CAAC,UAAU,IAAI,MAAM;IAU3B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAUpC,kFAAkF;IAC3E,gBAAgB,IAAI,wBAAwB;IAUnD,OAAO,CAAC,oBAAoB;IAa5B,+DAA+D;YACjD,kBAAkB;IAShC,gEAAgE;YAClD,kBAAkB;IAShC,6DAA6D;YAC/C,gBAAgB;IA0C9B;;;OAGG;IACU,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuCpD;;;;OAIG;IACU,IAAI,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BjE;;;;;OAKG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB5B,SAAS,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,GAAG,IAAI;CAOjE"}
@@ -46,6 +46,7 @@ const window_1 = require("@tauri-apps/api/window");
46
46
  const async_js_1 = require("../../utils/async.js");
47
47
  const sizing_js_1 = require("./sizing.js");
48
48
  const positioning_js_1 = require("./positioning.js");
49
+ const theming_js_1 = require("../theme/theming.js");
49
50
  exports.SeelenSettingsWidgetId = "@seelen/settings";
50
51
  exports.SeelenPopupWidgetId = "@seelen/popup";
51
52
  exports.SeelenWegWidgetId = "@seelen/weg";
@@ -77,6 +78,12 @@ class Widget {
77
78
  decoded;
78
79
  /** current webview window */
79
80
  webview;
81
+ autoSizer;
82
+ initOptions = {};
83
+ runtimeState = {
84
+ initialized: false,
85
+ ready: false,
86
+ };
80
87
  constructor(widget) {
81
88
  this.def = widget;
82
89
  this.webview = (0, webviewWindow_1.getCurrentWebviewWindow)();
@@ -149,8 +156,8 @@ class Widget {
149
156
  ...this.applyInvisiblePreset(),
150
157
  // Desktop widgets are always on bottom
151
158
  this.webview.setAlwaysOnBottom(true),
159
+ this.persistPositionAndSize(),
152
160
  ]);
153
- await this.persistPositionAndSize();
154
161
  }
155
162
  /** Will apply the recommended settings for an overlay widget */
156
163
  async applyOverlayPreset() {
@@ -158,25 +165,31 @@ class Widget {
158
165
  ...this.applyInvisiblePreset(),
159
166
  // Overlay widgets are always on top
160
167
  this.webview.setAlwaysOnTop(true),
168
+ this.persistPositionAndSize(),
161
169
  ]);
162
170
  }
163
171
  /** Will apply the recommended settings for a popup widget */
164
172
  async applyPopupPreset() {
165
- await Promise.all([...this.applyInvisiblePreset(), this.webview.setResizable(false)]);
166
- // auto close on focus lost
173
+ await Promise.all([...this.applyInvisiblePreset()]);
174
+ // auto close after 1 minute when not in use to save resources
167
175
  const closeOnTimeout = (0, async_js_1.debounce)(() => {
168
- // this.webview.close(); todo
169
- }, 5000);
170
- this.webview.onFocusChanged((e) => {
171
- if (e.payload) {
172
- closeOnTimeout.cancel();
176
+ this.webview.close();
177
+ }, 60_000);
178
+ const hideWebview = (0, async_js_1.debounce)(() => {
179
+ this.webview.hide();
180
+ closeOnTimeout();
181
+ }, 100);
182
+ this.webview.onFocusChanged(({ payload: focused }) => {
183
+ if (focused) {
184
+ hideWebview.cancel();
173
185
  }
174
186
  else {
175
- this.webview.hide();
176
- closeOnTimeout();
187
+ hideWebview();
177
188
  }
178
189
  });
179
190
  this.onTrigger(async ({ desiredPosition, alignX, alignY }) => {
191
+ // avoid flickering when clicking a button that triggers the widget
192
+ hideWebview.cancel();
180
193
  if (desiredPosition) {
181
194
  const { width, height } = await this.webview.outerSize();
182
195
  const pos = await (0, positioning_js_1.adjustPostionByPlacement)({
@@ -190,11 +203,12 @@ class Widget {
190
203
  await this.webview.setPosition(new dpi_1.PhysicalPosition(pos.x, pos.y));
191
204
  }
192
205
  await this.webview.show();
206
+ await this.webview.setFocus();
193
207
  });
194
208
  }
195
209
  /**
196
- * Will restore the saved position and size of the widget after that
197
- * will store the position and size of the widget on change.
210
+ * Will restore the saved position and size of the widget on start,
211
+ * after that will store the position and size of the widget on change.
198
212
  */
199
213
  async persistPositionAndSize() {
200
214
  const storage = globalThis.window.localStorage;
@@ -225,15 +239,18 @@ class Widget {
225
239
  console.info(`Widget size saved: ${width} ${height}`);
226
240
  }, 500));
227
241
  }
228
- // this will monitor the element and resize the webview accordingly
229
- autoSizeWebviewByElement(element = document.body) {
230
- (0, sizing_js_1.autoSizeWebviewBasedOnContent)(this.webview, element);
231
- }
232
242
  /**
233
- * Will initialize the widget based on the preset, this function won't show the widget.
234
- * You need to call `webview.show()` to show the widget.
243
+ * Will initialize the widget based on the preset and mark it as `pending`, this function won't show the widget.
244
+ * This should be called before any other action on the widget. After this you should call
245
+ * `ready` to mark the widget as ready and show it.
235
246
  */
236
- async init() {
247
+ async init(options = {}) {
248
+ if (this.runtimeState.initialized) {
249
+ console.warn(`Widget already initialized`);
250
+ return;
251
+ }
252
+ this.runtimeState.initialized = true;
253
+ this.initOptions = options;
237
254
  switch (this.def.preset) {
238
255
  case mod_js_1.WidgetPreset.None:
239
256
  break;
@@ -247,18 +264,39 @@ class Widget {
247
264
  await this.applyPopupPreset();
248
265
  break;
249
266
  }
267
+ await (0, theming_js_1.startThemingTool)();
268
+ if (options.autoSizeByContent) {
269
+ this.autoSizer = new sizing_js_1.WidgetAutoSizer(this.webview, options.autoSizeByContent);
270
+ }
271
+ }
272
+ /**
273
+ * Will mark the widget as `ready` and pool pending triggers.
274
+ *
275
+ * If the widget is not lazy this will inmediately show the widget.
276
+ * Lazy widget should be shown on trigger action.
277
+ */
278
+ async ready() {
279
+ if (!this.runtimeState.initialized) {
280
+ throw new Error(`Widget was not initialized before ready`);
281
+ }
282
+ if (this.runtimeState.ready) {
283
+ console.warn(`Widget is already ready`);
284
+ return;
285
+ }
286
+ this.runtimeState.ready = true;
287
+ await this.autoSizer?.execute();
288
+ if (this.initOptions.show ?? !this.def.lazy) {
289
+ await this.webview.show();
290
+ }
291
+ // this will mark the widget as ready, and send pending trigger event if exists
292
+ await (0, mod_js_2.invoke)(mod_js_2.SeelenCommand.SetCurrentWidgetStatus, { status: mod_js_1.WidgetStatus.Ready });
250
293
  }
251
294
  onTrigger(cb) {
252
- const fn = ({ payload }) => {
253
- const { id, monitorId, instanceId } = payload;
254
- if (id !== this.id ||
255
- (monitorId && monitorId !== this.decoded.monitorId) ||
256
- (instanceId && instanceId !== this.decoded.instanceId)) {
257
- return;
258
- }
295
+ this.webview.listen(mod_js_2.SeelenEvent.WidgetTriggered, ({ payload }) => {
296
+ // fix for cutted popups, ensure correct size on trigger.
297
+ // await this.autoSizer?.execute();
259
298
  cb(payload);
260
- };
261
- (0, mod_js_2.subscribe)(mod_js_2.SeelenEvent.WidgetTriggered, fn.bind(this));
299
+ });
262
300
  }
263
301
  }
264
302
  exports.Widget = Widget;
@@ -2,6 +2,11 @@ import type { WebviewWindow } from "@tauri-apps/api/webviewWindow";
2
2
  export interface AutoSizeOptions {
3
3
  onResize?: () => void;
4
4
  }
5
- /** This function will update the size of the webview/window based on the size of the root element */
6
- export declare function autoSizeWebviewBasedOnContent(webview: WebviewWindow, element: HTMLElement, options?: AutoSizeOptions): () => void;
5
+ export declare class WidgetAutoSizer {
6
+ private webview;
7
+ private element;
8
+ constructor(webview: WebviewWindow, element: HTMLElement);
9
+ private setup;
10
+ execute(): Promise<void>;
11
+ }
7
12
  //# sourceMappingURL=sizing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sizing.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/sizing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,qGAAqG;AACrG,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,eAAoB,GAC5B,MAAM,IAAI,CA6CZ"}
1
+ {"version":3,"file":"sizing.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/sizing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,OAAO;IAAiB,OAAO,CAAC,OAAO;gBAAvC,OAAO,EAAE,aAAa,EAAU,OAAO,EAAE,WAAW;IAKxE,OAAO,CAAC,KAAK;IAmBP,OAAO;CAkBd"}
@@ -1,42 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.autoSizeWebviewBasedOnContent = autoSizeWebviewBasedOnContent;
3
+ exports.WidgetAutoSizer = void 0;
4
4
  const dpi_1 = require("@tauri-apps/api/dpi");
5
- /** This function will update the size of the webview/window based on the size of the root element */
6
- function autoSizeWebviewBasedOnContent(webview, element, options = {}) {
7
- const { onResize } = options;
8
- const updateSize = async () => {
9
- const contentWidth = Math.floor(element.scrollWidth);
10
- const contentHeight = Math.floor(element.scrollHeight);
11
- if (contentWidth > 0 && contentHeight > 0) {
12
- const { width: currentWidth, height: currentHeight } = await webview.outerSize();
13
- const currentWidthFloored = Math.floor(currentWidth);
14
- const currentHeightFloored = Math.floor(currentHeight);
15
- // Only update if the difference is more than 1px (avoid infinite loops from decimal differences)
16
- if (Math.abs(contentWidth - currentWidthFloored) > 1 ||
17
- Math.abs(contentHeight - currentHeightFloored) > 1) {
18
- const size = new dpi_1.LogicalSize(contentWidth, contentHeight);
19
- webview.setSize(size).catch((err) => {
20
- console.error("Failed to update webview size:", err);
21
- });
22
- onResize?.();
23
- }
5
+ class WidgetAutoSizer {
6
+ webview;
7
+ element;
8
+ constructor(webview, element) {
9
+ this.webview = webview;
10
+ this.element = element;
11
+ this.execute = this.execute.bind(this);
12
+ this.setup();
13
+ }
14
+ setup() {
15
+ // Disable resizing by the user
16
+ this.webview.setResizable(false);
17
+ // Update size when content changes
18
+ const observer = new MutationObserver(this.execute);
19
+ observer.observe(this.element, {
20
+ childList: true,
21
+ subtree: true,
22
+ attributes: true,
23
+ characterData: true,
24
+ });
25
+ // Cleanup function
26
+ return () => {
27
+ observer.disconnect();
28
+ };
29
+ }
30
+ async execute() {
31
+ const contentWidth = this.element.scrollWidth;
32
+ const contentHeight = this.element.scrollHeight;
33
+ if (contentWidth < 1 || contentHeight < 1) {
34
+ return;
24
35
  }
25
- };
26
- // Initial size update
27
- updateSize();
28
- // Update size when content changes
29
- const observer = new MutationObserver(() => {
30
- updateSize();
31
- });
32
- observer.observe(element, {
33
- childList: true,
34
- subtree: true,
35
- attributes: true,
36
- characterData: true,
37
- });
38
- // Cleanup function
39
- return () => {
40
- observer.disconnect();
41
- };
36
+ const { width: physicalWidth, height: physicalHeight } = await this.webview.outerSize();
37
+ const logicalWidth = physicalWidth * globalThis.window.devicePixelRatio;
38
+ const logicalHeight = physicalHeight * globalThis.window.devicePixelRatio;
39
+ // Only update if the difference is more than 1px (avoid infinite loops from decimal differences)
40
+ if (Math.abs(contentWidth - logicalWidth) > 1 || Math.abs(contentHeight - logicalHeight) > 1) {
41
+ const size = new dpi_1.LogicalSize(contentWidth, contentHeight);
42
+ await this.webview.setSize(size);
43
+ }
44
+ }
42
45
  }
46
+ exports.WidgetAutoSizer = WidgetAutoSizer;
@@ -1,17 +1,11 @@
1
1
  import { type UnSubscriber } from "../../handlers/mod.js";
2
2
  import { List } from "../../utils/List.js";
3
- import type { BluetoothDevice, BluetoothDevicePairShowPinRequest } from "../../../gen/types/mod.js";
4
- import type { UnlistenFn } from "@tauri-apps/api/event";
3
+ import type { BluetoothDevice } from "../../../gen/types/mod.js";
5
4
  export declare class BluetoothDevices extends List<BluetoothDevice> {
6
5
  static getAsync(): Promise<BluetoothDevices>;
7
6
  static onChange(cb: (payload: BluetoothDevices) => void): Promise<UnSubscriber>;
8
- static onDiscoveredDevicesChange(cb: (payload: BluetoothDevices) => void): Promise<UnSubscriber>;
9
7
  static discover(): Promise<void>;
10
8
  static stopDiscovery(): Promise<void>;
11
- static pairDevice(address: bigint): Promise<void>;
12
- static forgetDevice(id: string): Promise<void>;
13
- static confirmPair(accept: boolean, passphrase: string): Promise<void>;
14
- static onPairRequest(cb: (param: BluetoothDevicePairShowPinRequest | null) => void): Promise<UnlistenFn>;
15
9
  static default(): BluetoothDevices;
16
10
  }
17
11
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/system_state/bluetooth/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AACpG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD,qBAAa,gBAAiB,SAAQ,IAAI,CAAC,eAAe,CAAC;IACzD,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAI5C,MAAM,CAAC,QAAQ,CACb,EAAE,EAAE,CA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AAM,CAAC,OAAO,IAAI,gBAAgB;CAGnC"}
@@ -3,45 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BluetoothDevices = void 0;
4
4
  const mod_js_1 = require("../../handlers/mod.js");
5
5
  const List_js_1 = require("../../utils/List.js");
6
- const mod_js_2 = require("../../handlers/mod.js");
7
6
  const State_js_1 = require("../../utils/State.js");
8
7
  class BluetoothDevices extends List_js_1.List {
9
8
  static getAsync() {
10
- return (0, State_js_1.newFromInvoke)(this, mod_js_1.SeelenCommand.GetConnectedBluetoothDevices);
9
+ return (0, State_js_1.newFromInvoke)(this, mod_js_1.SeelenCommand.GetBluetoothDevices);
11
10
  }
12
11
  static onChange(cb) {
13
12
  return (0, State_js_1.newOnEvent)(cb, this, mod_js_1.SeelenEvent.BluetoothDevicesChanged);
14
13
  }
15
- static onDiscoveredDevicesChange(cb) {
16
- return (0, State_js_1.newOnEvent)(cb, this, mod_js_1.SeelenEvent.BluetoothDiscoveredDevicesChanged);
17
- }
18
14
  static async discover() {
19
15
  return await (0, mod_js_1.invoke)(mod_js_1.SeelenCommand.StartBluetoothScanning);
20
16
  }
21
17
  static async stopDiscovery() {
22
18
  return await (0, mod_js_1.invoke)(mod_js_1.SeelenCommand.StopBluetoothScanning);
23
19
  }
24
- static async pairDevice(address) {
25
- return await (0, mod_js_1.invoke)(mod_js_1.SeelenCommand.PairBluetoothDevice, { address });
26
- }
27
- static async forgetDevice(id) {
28
- return await (0, mod_js_1.invoke)(mod_js_1.SeelenCommand.ForgetBluetoothDevice, { id });
29
- }
30
- static async confirmPair(accept, passphrase) {
31
- return await (0, mod_js_1.invoke)(mod_js_1.SeelenCommand.ConfirmBluetoothDevicePair, {
32
- accept,
33
- passphrase,
34
- });
35
- }
36
- static async onPairRequest(cb) {
37
- //TODO(Eythaan): from here the process does not continues
38
- const unlistenShowPin = await (0, mod_js_2.subscribe)(mod_js_1.SeelenEvent.BluetoothPairShowPin, (param) => cb(param.payload));
39
- const unlistenRequestPin = await (0, mod_js_2.subscribe)(mod_js_1.SeelenEvent.BluetoothPairRequestPin, (param) => cb(param.payload));
40
- return () => {
41
- unlistenRequestPin();
42
- unlistenShowPin();
43
- };
44
- }
45
20
  static default() {
46
21
  return new this([]);
47
22
  }
@@ -8,14 +8,16 @@ export declare class UIColors {
8
8
  static default(): UIColors;
9
9
  setAsCssVariables(): void;
10
10
  }
11
+ export interface Color extends IColor {
12
+ }
11
13
  export declare class Color {
12
- inner: IColor;
13
- constructor(inner: IColor);
14
+ constructor(obj: IColor);
14
15
  /** generates a random solid color */
15
16
  static random(): Color;
17
+ static fromHex(hex: string): Color;
18
+ toHexString(): string;
16
19
  private getRuntimeStyleSheet;
17
20
  private insertIntoStyleSheet;
18
- toHexString(): string;
19
21
  /**
20
22
  * @param name the name of the color
21
23
  * the name will be parsed to lower kebab case and remove non-alphanumeric characters
@@ -32,5 +34,6 @@ export declare class Color {
32
34
  * @returns a number between 0 and 255
33
35
  */
34
36
  calcLuminance(accuracy?: boolean): number;
37
+ complementary(): Color;
35
38
  }
36
39
  //# sourceMappingURL=ui_colors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui_colors.d.ts","sourceRoot":"","sources":["../../../src/src/system_state/ui_colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAErF,qBAAa,QAAQ;IACA,KAAK,EAAE,SAAS;gBAAhB,KAAK,EAAE,SAAS;IAEnC,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC;IAIpC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAIvE,MAAM,CAAC,OAAO,IAAI,QAAQ;IAe1B,iBAAiB,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