@widget-js/core 0.0.11 → 0.0.13

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 (38) hide show
  1. package/dist/cjs/api/ApiConstants.js +8 -0
  2. package/dist/cjs/api/AppApi.js +23 -0
  3. package/dist/cjs/api/BrowserWindowApi.js +8 -2
  4. package/dist/cjs/api/Channel.js +4 -3
  5. package/dist/cjs/api/ElectronApi.js +5 -12
  6. package/dist/cjs/api/WidgetApi.js +25 -0
  7. package/dist/cjs/index.js +4 -1
  8. package/dist/cjs/model/BroadcastEvent.js +3 -1
  9. package/dist/cjs/model/Widget.js +28 -42
  10. package/dist/cjs/model/WidgetPackage.js +6 -0
  11. package/dist/cjs/model/WidgetParams.js +17 -17
  12. package/dist/esm/api/ApiConstants.js +4 -0
  13. package/dist/esm/api/AppApi.js +19 -0
  14. package/dist/esm/api/BrowserWindowApi.js +8 -2
  15. package/dist/esm/api/Channel.js +4 -3
  16. package/dist/esm/api/ElectronApi.js +5 -12
  17. package/dist/esm/api/WidgetApi.js +21 -0
  18. package/dist/esm/index.js +4 -1
  19. package/dist/esm/model/BroadcastEvent.js +3 -1
  20. package/dist/esm/model/Widget.js +28 -42
  21. package/dist/esm/model/WidgetPackage.js +2 -0
  22. package/dist/esm/model/WidgetParams.js +17 -17
  23. package/dist/types/api/ApiConstants.d.ts +4 -0
  24. package/dist/types/api/AppApi.d.ts +6 -0
  25. package/dist/types/api/BrowserWindowApi.d.ts +4 -0
  26. package/dist/types/api/Channel.d.ts +4 -3
  27. package/dist/types/api/ElectronApi.d.ts +1 -4
  28. package/dist/types/api/WidgetApi.d.ts +7 -0
  29. package/dist/types/index.d.ts +4 -1
  30. package/dist/types/model/BroadcastEvent.d.ts +6 -1
  31. package/dist/types/model/Widget.d.ts +32 -41
  32. package/dist/types/model/WidgetPackage.d.ts +31 -0
  33. package/dist/types/model/WidgetParams.d.ts +7 -7
  34. package/dist/umd/index.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/cjs/api/Keys.js +0 -12
  37. package/dist/esm/api/Keys.js +0 -8
  38. package/dist/types/api/Keys.d.ts +0 -8
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiConstants = void 0;
4
+ class ApiConstants {
5
+ }
6
+ exports.ApiConstants = ApiConstants;
7
+ ApiConstants.CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
8
+ ApiConstants.CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppApi = void 0;
4
+ const ElectronUtils_1 = require("../utils/ElectronUtils");
5
+ const Channel_1 = require("./Channel");
6
+ class AppApi {
7
+ static async setConfig(key, value) {
8
+ await ElectronUtils_1.ElectronUtils.getAPI().invoke(Channel_1.Channel.APP, this.SET_CONFIG, key, value);
9
+ }
10
+ static async getConfig(key, defaultValue) {
11
+ const value = await ElectronUtils_1.ElectronUtils.getAPI().invoke(Channel_1.Channel.APP, this.GET_CONFIG, key);
12
+ if (value === null || value === undefined) {
13
+ return defaultValue;
14
+ }
15
+ if (typeof defaultValue == "boolean") {
16
+ return value === "true";
17
+ }
18
+ return value;
19
+ }
20
+ }
21
+ exports.AppApi = AppApi;
22
+ AppApi.SET_CONFIG = "SET_CONFIG";
23
+ AppApi.GET_CONFIG = "GET_CONFIG";
@@ -5,10 +5,16 @@ const Channel_1 = require("./Channel");
5
5
  const ElectronUtils_1 = require("../utils/ElectronUtils");
6
6
  class BrowserWindowApi {
7
7
  static async setIgnoreMouseEvent(ignore) {
8
- await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc(Channel_1.Channel.SET_IGNORE_MOUSE_EVENT, ignore);
8
+ await ElectronUtils_1.ElectronUtils.getAPI().invoke(Channel_1.Channel.BROWSER_WINDOW, this.IGNORE_MOUSE_EVENT, ignore);
9
9
  }
10
10
  static async setWindowVisibility(show) {
11
- await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc(Channel_1.Channel.BROWSER_WINDOW, show);
11
+ await ElectronUtils_1.ElectronUtils.getAPI().invoke(Channel_1.Channel.BROWSER_WINDOW, this.WINDOW_VISIBILITY, show);
12
+ }
13
+ static async setAlwaysOnTop(alwaysOnTop) {
14
+ await ElectronUtils_1.ElectronUtils.getAPI().invoke(Channel_1.Channel.BROWSER_WINDOW, this.ALWAYS_ON_TOP, alwaysOnTop);
12
15
  }
13
16
  }
14
17
  exports.BrowserWindowApi = BrowserWindowApi;
18
+ BrowserWindowApi.IGNORE_MOUSE_EVENT = "ignore-mouse-event";
19
+ BrowserWindowApi.WINDOW_VISIBILITY = "window-visibility";
20
+ BrowserWindowApi.ALWAYS_ON_TOP = "always-on-top";
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Channel = void 0;
4
4
  var Channel;
5
5
  (function (Channel) {
6
- Channel["SET_IGNORE_MOUSE_EVENT"] = "channel::com.wisdom.widgets.set_ignore_mouse_event";
7
- Channel["NOTIFICATION"] = "channel::com.wisdom.widgets.notification";
8
- Channel["BROWSER_WINDOW"] = "channel::com.wisdom.widgets.browser_window";
6
+ Channel["NOTIFICATION"] = "channel::fun.widget.core.notification";
7
+ Channel["BROWSER_WINDOW"] = "channel::fun.widget.core.browser_window";
8
+ Channel["BROADCAST"] = "channel::fun.widget.core.broadcast";
9
+ Channel["APP"] = "channel::fun.widget.core.app";
9
10
  })(Channel = exports.Channel || (exports.Channel = {}));
@@ -1,29 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ElectronApi = void 0;
4
- const Keys_1 = require("./Keys");
5
4
  const ElectronUtils_1 = require("../utils/ElectronUtils");
5
+ const Channel_1 = require("./Channel");
6
6
  class ElectronApi {
7
7
  static openAddWidgetWindow() {
8
8
  ElectronUtils_1.ElectronUtils.getAPI().invokeIpc("openAddWidgetWindow");
9
9
  }
10
- static async registerWidgets(widgets) {
11
- const data = JSON.parse(JSON.stringify(widgets.map(item => JSON.stringify(item))));
12
- await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc("registerWidgets", data);
13
- }
14
- static async setConfig(key, value) {
15
- await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc("setConfig", { key, value });
16
- }
17
10
  static async sendBroadcastEvent(event) {
18
- await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc(Keys_1.Keys.BROADCAST_EVENT, JSON.stringify(event));
11
+ await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc(Channel_1.Channel.BROADCAST, JSON.stringify(event));
19
12
  }
20
13
  static async registerBroadcast(callback) {
21
- await this.addIpcListener(Keys_1.Keys.BROADCAST_EVENT, (json) => {
14
+ await this.addIpcListener(Channel_1.Channel.BROADCAST, (json) => {
22
15
  callback(JSON.parse(json));
23
16
  });
24
17
  }
25
18
  static async unregisterBroadcast() {
26
- await this.removeIpcListener(Keys_1.Keys.BROADCAST_EVENT);
19
+ await this.removeIpcListener(Channel_1.Channel.BROADCAST);
27
20
  }
28
21
  static async addIpcListener(key, f) {
29
22
  await ElectronUtils_1.ElectronUtils.getAPI().addIpcListener(key, f);
@@ -31,7 +24,7 @@ class ElectronApi {
31
24
  static async removeIpcListener(key) {
32
25
  await ElectronUtils_1.ElectronUtils.getAPI().removeIpcListener(key);
33
26
  }
34
- static async getConfig(key, defaultValue) {
27
+ static async upgradeNewVersion(key, defaultValue) {
35
28
  const value = await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc("getConfig", key);
36
29
  if (value === null || value === undefined) {
37
30
  return defaultValue;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WidgetApi = void 0;
4
+ const Widget_1 = require("../model/Widget");
5
+ const ElectronUtils_1 = require("../utils/ElectronUtils");
6
+ class WidgetApi {
7
+ static async registerWidgets(widgets) {
8
+ await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc("registerWidgets", JSON.stringify(widgets));
9
+ }
10
+ static async registerWidgetPackage(widgetPackage) {
11
+ await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc("registerWidgetPackage", JSON.stringify(widgetPackage));
12
+ }
13
+ static async getWidgets() {
14
+ const data = await ElectronUtils_1.ElectronUtils.getAPI().invokeIpc("getWidgets");
15
+ const widgets = [];
16
+ if (data) {
17
+ const arr = JSON.parse(data);
18
+ for (const i in arr) {
19
+ widgets.push(Widget_1.Widget.parseObject(arr[i]));
20
+ }
21
+ }
22
+ return widgets;
23
+ }
24
+ }
25
+ exports.WidgetApi = WidgetApi;
package/dist/cjs/index.js CHANGED
@@ -19,10 +19,13 @@ __exportStar(require("./model/BroadcastEvent"), exports);
19
19
  __exportStar(require("./model/WidgetData"), exports);
20
20
  __exportStar(require("./model/WidgetParams"), exports);
21
21
  __exportStar(require("./model/Notification"), exports);
22
+ __exportStar(require("./model/WidgetPackage"), exports);
22
23
  __exportStar(require("./api/ElectronApi"), exports);
23
- __exportStar(require("./api/Keys"), exports);
24
24
  __exportStar(require("./repository/WidgetDataRepository"), exports);
25
25
  __exportStar(require("./api/BrowserWindowApi"), exports);
26
26
  __exportStar(require("./api/NotificationApi"), exports);
27
27
  __exportStar(require("./api/Channel"), exports);
28
+ __exportStar(require("./api/WidgetApi"), exports);
29
+ __exportStar(require("./api/ApiConstants"), exports);
30
+ __exportStar(require("./api/AppApi"), exports);
28
31
  __exportStar(require("./utils/ElectronUtils"), exports);
@@ -9,4 +9,6 @@ class BroadcastEvent {
9
9
  }
10
10
  }
11
11
  exports.BroadcastEvent = BroadcastEvent;
12
- BroadcastEvent.TYPE_WIDGET_UPDATED = "BROADCAST:WIDGET_UPDATED";
12
+ BroadcastEvent.TYPE_WIDGET_UPDATED = "broadcast::fun.widget.core.widget_updated";
13
+ BroadcastEvent.TYPE_APP_CONFIG_UPDATED = "broadcast::fun.widget.core.app_config_updated";
14
+ BroadcastEvent.TYPE_THEME_CHANGED = "broadcast::fun.widget.core.theme_changed";
@@ -13,65 +13,51 @@ class Widget {
13
13
  this.description = options.description;
14
14
  this.keywords = options.keywords;
15
15
  this.lang = options.lang;
16
- this.w = options.w;
17
- this.h = options.h;
18
- this.maxW = (_a = options.maxW) !== null && _a !== void 0 ? _a : options.w;
19
- this.maxH = (_b = options.maxH) !== null && _b !== void 0 ? _b : options.h;
20
- this.minW = (_c = options.minW) !== null && _c !== void 0 ? _c : options.w;
21
- this.minH = (_d = options.minH) !== null && _d !== void 0 ? _d : options.h;
16
+ this.width = options.width;
17
+ this.height = options.height;
18
+ this.maxWidth = (_a = options.maxWidth) !== null && _a !== void 0 ? _a : options.width;
19
+ this.maxHeight = (_b = options.maxHeight) !== null && _b !== void 0 ? _b : options.height;
20
+ this.minWidth = (_c = options.minWidth) !== null && _c !== void 0 ? _c : options.width;
21
+ this.minHeight = (_d = options.minHeight) !== null && _d !== void 0 ? _d : options.height;
22
22
  this.url = options.url;
23
23
  this.configUrl = options.configUrl;
24
- this.extraUrl = (_e = options.extraUrl) !== null && _e !== void 0 ? _e : new Map();
24
+ this.extraUrl = (_e = options.extraUrl) !== null && _e !== void 0 ? _e : {};
25
25
  }
26
26
  /**
27
27
  * 获取组件标题
28
28
  * @param lang 语言环境,不传则获取默认语言
29
29
  */
30
30
  getTitle(lang) {
31
- return lang ? this.title.get(lang) : this.title.get(this.lang);
31
+ var _a;
32
+ return lang ? (_a = this.title[lang]) !== null && _a !== void 0 ? _a : this.title[this.lang] : this.title[this.lang];
32
33
  }
33
34
  /**
34
35
  * 获取组件标描述
35
36
  * @param lang 语言环境,不传则获取默认标题
36
37
  */
37
38
  getDescription(lang) {
38
- return lang ? this.description.get(lang) : this.description.get(this.lang);
39
+ return lang ? this.description[lang] : this.description[this.lang];
39
40
  }
40
- toJSON() {
41
- return {
42
- name: this.name,
43
- title: Object.fromEntries(this.title),
44
- description: Object.fromEntries(this.description),
45
- keywords: this.keywords,
46
- lang: this.lang,
47
- w: this.w,
48
- h: this.h,
49
- maxW: this.maxW,
50
- maxH: this.maxH,
51
- minW: this.minW,
52
- minH: this.minH,
53
- url: this.url,
54
- configUrl: this.configUrl,
55
- extraUrl: Object.fromEntries(this.extraUrl),
56
- };
57
- }
58
- static parse(json) {
41
+ static parseJSON(json) {
59
42
  const object = JSON.parse(json);
43
+ return this.parseObject(object);
44
+ }
45
+ static parseObject(obj) {
60
46
  return new Widget({
61
- configUrl: object["configUrl"],
62
- description: new Map(Object.entries(object["description"])),
63
- extraUrl: new Map(Object.entries(object["extraUrl"])),
64
- h: object["h"],
65
- keywords: object["keywords"],
66
- lang: object["lang"],
67
- maxH: object["maxH"],
68
- maxW: object["maxW"],
69
- minH: object["minH"],
70
- minW: object["minW"],
71
- name: object["name"],
72
- title: new Map(Object.entries(object["title"])),
73
- url: object["url"],
74
- w: object["w"]
47
+ configUrl: obj["configUrl"],
48
+ description: obj["description"],
49
+ extraUrl: obj["extraUrl"],
50
+ width: obj["width"],
51
+ keywords: obj["keywords"],
52
+ lang: obj["lang"],
53
+ maxHeight: obj["maxHeight"],
54
+ maxWidth: obj["maxWidth"],
55
+ height: obj["height"],
56
+ minHeight: obj["minHeight"],
57
+ minWidth: obj["minWidth"],
58
+ name: obj["name"],
59
+ title: obj["title"],
60
+ url: obj["url"]
75
61
  });
76
62
  }
77
63
  }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WidgetPackage = void 0;
4
+ class WidgetPackage {
5
+ }
6
+ exports.WidgetPackage = WidgetPackage;
@@ -30,7 +30,7 @@ class WidgetParams {
30
30
  * 从当前地址解析组件参数:
31
31
  * http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
32
32
  * =>
33
- * {w:2,h:2,id:21,width:156,height:156}
33
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
34
34
  */
35
35
  static fromCurrentLocation() {
36
36
  const href = window.location.href;
@@ -48,11 +48,11 @@ class WidgetParams {
48
48
  else if (keyWithoutPrefix == WidgetParams.PARAM_Y) {
49
49
  widgetEnv.y = parseInt(value);
50
50
  }
51
- else if (keyWithoutPrefix == WidgetParams.PARAM_H) {
52
- widgetEnv.h = parseInt(value);
51
+ else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT) {
52
+ widgetEnv.height = parseInt(value);
53
53
  }
54
- else if (keyWithoutPrefix == WidgetParams.PARAM_W) {
55
- widgetEnv.w = parseInt(value);
54
+ else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH) {
55
+ widgetEnv.width = parseInt(value);
56
56
  }
57
57
  else if (keyWithoutPrefix == WidgetParams.PARAM_LANG) {
58
58
  widgetEnv.lang = value;
@@ -66,11 +66,11 @@ class WidgetParams {
66
66
  else if (keyWithoutPrefix == WidgetParams.PARAM_RADIUS) {
67
67
  widgetEnv.radius = parseInt(value);
68
68
  }
69
- else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH) {
70
- widgetEnv.width = parseInt(value);
69
+ else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH_PX) {
70
+ widgetEnv.widthPx = parseInt(value);
71
71
  }
72
- else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT) {
73
- widgetEnv.height = parseInt(value);
72
+ else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT_PX) {
73
+ widgetEnv.heightPx = parseInt(value);
74
74
  }
75
75
  else if (keyWithoutPrefix == WidgetParams.PARAM_NAME) {
76
76
  widgetEnv.name = value;
@@ -84,8 +84,8 @@ class WidgetParams {
84
84
  }
85
85
  /**
86
86
  * 从对象键值对中初始化组件参数
87
- * {w_w:2,w_h:2,w_id:21,w_width:156,w_height:156}=>
88
- * {w:2,h:2,id:21,width:156,height:156}
87
+ * {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
88
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
89
89
  * @param object
90
90
  */
91
91
  static fromObject(object) {
@@ -102,10 +102,10 @@ class WidgetParams {
102
102
  exports.WidgetParams = WidgetParams;
103
103
  WidgetParams.PARAM_PREFIX = "w_";
104
104
  WidgetParams.PARAM_ID = "id";
105
- WidgetParams.PARAM_W = "w";
106
- WidgetParams.PARAM_H = "h";
107
105
  WidgetParams.PARAM_WIDTH = "width";
108
106
  WidgetParams.PARAM_HEIGHT = "height";
107
+ WidgetParams.PARAM_WIDTH_PX = "width_px";
108
+ WidgetParams.PARAM_HEIGHT_PX = "height_px";
109
109
  WidgetParams.PARAM_X = "x";
110
110
  WidgetParams.PARAM_Y = "y";
111
111
  WidgetParams.PARAM_LANG = "lang";
@@ -117,15 +117,15 @@ WidgetParams.PARAM_TITLE = "title";
117
117
  WidgetParams.PARAM_PREVIEW = "preview";
118
118
  WidgetParams.PARAMS = [
119
119
  WidgetParams.PARAM_ID,
120
- WidgetParams.PARAM_W,
121
- WidgetParams.PARAM_H,
120
+ WidgetParams.PARAM_WIDTH,
121
+ WidgetParams.PARAM_HEIGHT,
122
122
  WidgetParams.PARAM_X,
123
123
  WidgetParams.PARAM_Y,
124
124
  WidgetParams.PARAM_LANG,
125
125
  WidgetParams.PARAM_THEME,
126
126
  WidgetParams.PARAM_MODE,
127
- WidgetParams.PARAM_WIDTH,
128
- WidgetParams.PARAM_HEIGHT,
127
+ WidgetParams.PARAM_WIDTH_PX,
128
+ WidgetParams.PARAM_HEIGHT_PX,
129
129
  WidgetParams.PARAM_NAME,
130
130
  WidgetParams.PARAM_TITLE,
131
131
  WidgetParams.PARAM_PREVIEW,
@@ -0,0 +1,4 @@
1
+ export class ApiConstants {
2
+ }
3
+ ApiConstants.CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
4
+ ApiConstants.CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
@@ -0,0 +1,19 @@
1
+ import { ElectronUtils } from "../utils/ElectronUtils";
2
+ import { Channel } from "./Channel";
3
+ export class AppApi {
4
+ static async setConfig(key, value) {
5
+ await ElectronUtils.getAPI().invoke(Channel.APP, this.SET_CONFIG, key, value);
6
+ }
7
+ static async getConfig(key, defaultValue) {
8
+ const value = await ElectronUtils.getAPI().invoke(Channel.APP, this.GET_CONFIG, key);
9
+ if (value === null || value === undefined) {
10
+ return defaultValue;
11
+ }
12
+ if (typeof defaultValue == "boolean") {
13
+ return value === "true";
14
+ }
15
+ return value;
16
+ }
17
+ }
18
+ AppApi.SET_CONFIG = "SET_CONFIG";
19
+ AppApi.GET_CONFIG = "GET_CONFIG";
@@ -2,9 +2,15 @@ import { Channel } from "./Channel";
2
2
  import { ElectronUtils } from "../utils/ElectronUtils";
3
3
  export class BrowserWindowApi {
4
4
  static async setIgnoreMouseEvent(ignore) {
5
- await ElectronUtils.getAPI().invokeIpc(Channel.SET_IGNORE_MOUSE_EVENT, ignore);
5
+ await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.IGNORE_MOUSE_EVENT, ignore);
6
6
  }
7
7
  static async setWindowVisibility(show) {
8
- await ElectronUtils.getAPI().invokeIpc(Channel.BROWSER_WINDOW, show);
8
+ await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.WINDOW_VISIBILITY, show);
9
+ }
10
+ static async setAlwaysOnTop(alwaysOnTop) {
11
+ await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.ALWAYS_ON_TOP, alwaysOnTop);
9
12
  }
10
13
  }
14
+ BrowserWindowApi.IGNORE_MOUSE_EVENT = "ignore-mouse-event";
15
+ BrowserWindowApi.WINDOW_VISIBILITY = "window-visibility";
16
+ BrowserWindowApi.ALWAYS_ON_TOP = "always-on-top";
@@ -1,6 +1,7 @@
1
1
  export var Channel;
2
2
  (function (Channel) {
3
- Channel["SET_IGNORE_MOUSE_EVENT"] = "channel::com.wisdom.widgets.set_ignore_mouse_event";
4
- Channel["NOTIFICATION"] = "channel::com.wisdom.widgets.notification";
5
- Channel["BROWSER_WINDOW"] = "channel::com.wisdom.widgets.browser_window";
3
+ Channel["NOTIFICATION"] = "channel::fun.widget.core.notification";
4
+ Channel["BROWSER_WINDOW"] = "channel::fun.widget.core.browser_window";
5
+ Channel["BROADCAST"] = "channel::fun.widget.core.broadcast";
6
+ Channel["APP"] = "channel::fun.widget.core.app";
6
7
  })(Channel || (Channel = {}));
@@ -1,26 +1,19 @@
1
- import { Keys } from "./Keys";
2
1
  import { ElectronUtils } from "../utils/ElectronUtils";
2
+ import { Channel } from "./Channel";
3
3
  export class ElectronApi {
4
4
  static openAddWidgetWindow() {
5
5
  ElectronUtils.getAPI().invokeIpc("openAddWidgetWindow");
6
6
  }
7
- static async registerWidgets(widgets) {
8
- const data = JSON.parse(JSON.stringify(widgets.map(item => JSON.stringify(item))));
9
- await ElectronUtils.getAPI().invokeIpc("registerWidgets", data);
10
- }
11
- static async setConfig(key, value) {
12
- await ElectronUtils.getAPI().invokeIpc("setConfig", { key, value });
13
- }
14
7
  static async sendBroadcastEvent(event) {
15
- await ElectronUtils.getAPI().invokeIpc(Keys.BROADCAST_EVENT, JSON.stringify(event));
8
+ await ElectronUtils.getAPI().invokeIpc(Channel.BROADCAST, JSON.stringify(event));
16
9
  }
17
10
  static async registerBroadcast(callback) {
18
- await this.addIpcListener(Keys.BROADCAST_EVENT, (json) => {
11
+ await this.addIpcListener(Channel.BROADCAST, (json) => {
19
12
  callback(JSON.parse(json));
20
13
  });
21
14
  }
22
15
  static async unregisterBroadcast() {
23
- await this.removeIpcListener(Keys.BROADCAST_EVENT);
16
+ await this.removeIpcListener(Channel.BROADCAST);
24
17
  }
25
18
  static async addIpcListener(key, f) {
26
19
  await ElectronUtils.getAPI().addIpcListener(key, f);
@@ -28,7 +21,7 @@ export class ElectronApi {
28
21
  static async removeIpcListener(key) {
29
22
  await ElectronUtils.getAPI().removeIpcListener(key);
30
23
  }
31
- static async getConfig(key, defaultValue) {
24
+ static async upgradeNewVersion(key, defaultValue) {
32
25
  const value = await ElectronUtils.getAPI().invokeIpc("getConfig", key);
33
26
  if (value === null || value === undefined) {
34
27
  return defaultValue;
@@ -0,0 +1,21 @@
1
+ import { Widget } from "../model/Widget";
2
+ import { ElectronUtils } from "../utils/ElectronUtils";
3
+ export class WidgetApi {
4
+ static async registerWidgets(widgets) {
5
+ await ElectronUtils.getAPI().invokeIpc("registerWidgets", JSON.stringify(widgets));
6
+ }
7
+ static async registerWidgetPackage(widgetPackage) {
8
+ await ElectronUtils.getAPI().invokeIpc("registerWidgetPackage", JSON.stringify(widgetPackage));
9
+ }
10
+ static async getWidgets() {
11
+ const data = await ElectronUtils.getAPI().invokeIpc("getWidgets");
12
+ const widgets = [];
13
+ if (data) {
14
+ const arr = JSON.parse(data);
15
+ for (const i in arr) {
16
+ widgets.push(Widget.parseObject(arr[i]));
17
+ }
18
+ }
19
+ return widgets;
20
+ }
21
+ }
package/dist/esm/index.js CHANGED
@@ -3,10 +3,13 @@ export * from "./model/BroadcastEvent";
3
3
  export * from "./model/WidgetData";
4
4
  export * from "./model/WidgetParams";
5
5
  export * from "./model/Notification";
6
+ export * from "./model/WidgetPackage";
6
7
  export * from "./api/ElectronApi";
7
- export * from "./api/Keys";
8
8
  export * from "./repository/WidgetDataRepository";
9
9
  export * from "./api/BrowserWindowApi";
10
10
  export * from "./api/NotificationApi";
11
11
  export * from "./api/Channel";
12
+ export * from "./api/WidgetApi";
13
+ export * from "./api/ApiConstants";
14
+ export * from "./api/AppApi";
12
15
  export * from "./utils/ElectronUtils";
@@ -5,4 +5,6 @@ export class BroadcastEvent {
5
5
  this.payload = payload;
6
6
  }
7
7
  }
8
- BroadcastEvent.TYPE_WIDGET_UPDATED = "BROADCAST:WIDGET_UPDATED";
8
+ BroadcastEvent.TYPE_WIDGET_UPDATED = "broadcast::fun.widget.core.widget_updated";
9
+ BroadcastEvent.TYPE_APP_CONFIG_UPDATED = "broadcast::fun.widget.core.app_config_updated";
10
+ BroadcastEvent.TYPE_THEME_CHANGED = "broadcast::fun.widget.core.theme_changed";
@@ -10,65 +10,51 @@ export class Widget {
10
10
  this.description = options.description;
11
11
  this.keywords = options.keywords;
12
12
  this.lang = options.lang;
13
- this.w = options.w;
14
- this.h = options.h;
15
- this.maxW = (_a = options.maxW) !== null && _a !== void 0 ? _a : options.w;
16
- this.maxH = (_b = options.maxH) !== null && _b !== void 0 ? _b : options.h;
17
- this.minW = (_c = options.minW) !== null && _c !== void 0 ? _c : options.w;
18
- this.minH = (_d = options.minH) !== null && _d !== void 0 ? _d : options.h;
13
+ this.width = options.width;
14
+ this.height = options.height;
15
+ this.maxWidth = (_a = options.maxWidth) !== null && _a !== void 0 ? _a : options.width;
16
+ this.maxHeight = (_b = options.maxHeight) !== null && _b !== void 0 ? _b : options.height;
17
+ this.minWidth = (_c = options.minWidth) !== null && _c !== void 0 ? _c : options.width;
18
+ this.minHeight = (_d = options.minHeight) !== null && _d !== void 0 ? _d : options.height;
19
19
  this.url = options.url;
20
20
  this.configUrl = options.configUrl;
21
- this.extraUrl = (_e = options.extraUrl) !== null && _e !== void 0 ? _e : new Map();
21
+ this.extraUrl = (_e = options.extraUrl) !== null && _e !== void 0 ? _e : {};
22
22
  }
23
23
  /**
24
24
  * 获取组件标题
25
25
  * @param lang 语言环境,不传则获取默认语言
26
26
  */
27
27
  getTitle(lang) {
28
- return lang ? this.title.get(lang) : this.title.get(this.lang);
28
+ var _a;
29
+ return lang ? (_a = this.title[lang]) !== null && _a !== void 0 ? _a : this.title[this.lang] : this.title[this.lang];
29
30
  }
30
31
  /**
31
32
  * 获取组件标描述
32
33
  * @param lang 语言环境,不传则获取默认标题
33
34
  */
34
35
  getDescription(lang) {
35
- return lang ? this.description.get(lang) : this.description.get(this.lang);
36
+ return lang ? this.description[lang] : this.description[this.lang];
36
37
  }
37
- toJSON() {
38
- return {
39
- name: this.name,
40
- title: Object.fromEntries(this.title),
41
- description: Object.fromEntries(this.description),
42
- keywords: this.keywords,
43
- lang: this.lang,
44
- w: this.w,
45
- h: this.h,
46
- maxW: this.maxW,
47
- maxH: this.maxH,
48
- minW: this.minW,
49
- minH: this.minH,
50
- url: this.url,
51
- configUrl: this.configUrl,
52
- extraUrl: Object.fromEntries(this.extraUrl),
53
- };
54
- }
55
- static parse(json) {
38
+ static parseJSON(json) {
56
39
  const object = JSON.parse(json);
40
+ return this.parseObject(object);
41
+ }
42
+ static parseObject(obj) {
57
43
  return new Widget({
58
- configUrl: object["configUrl"],
59
- description: new Map(Object.entries(object["description"])),
60
- extraUrl: new Map(Object.entries(object["extraUrl"])),
61
- h: object["h"],
62
- keywords: object["keywords"],
63
- lang: object["lang"],
64
- maxH: object["maxH"],
65
- maxW: object["maxW"],
66
- minH: object["minH"],
67
- minW: object["minW"],
68
- name: object["name"],
69
- title: new Map(Object.entries(object["title"])),
70
- url: object["url"],
71
- w: object["w"]
44
+ configUrl: obj["configUrl"],
45
+ description: obj["description"],
46
+ extraUrl: obj["extraUrl"],
47
+ width: obj["width"],
48
+ keywords: obj["keywords"],
49
+ lang: obj["lang"],
50
+ maxHeight: obj["maxHeight"],
51
+ maxWidth: obj["maxWidth"],
52
+ height: obj["height"],
53
+ minHeight: obj["minHeight"],
54
+ minWidth: obj["minWidth"],
55
+ name: obj["name"],
56
+ title: obj["title"],
57
+ url: obj["url"]
72
58
  });
73
59
  }
74
60
  }
@@ -0,0 +1,2 @@
1
+ export class WidgetPackage {
2
+ }
@@ -27,7 +27,7 @@ export class WidgetParams {
27
27
  * 从当前地址解析组件参数:
28
28
  * http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
29
29
  * =>
30
- * {w:2,h:2,id:21,width:156,height:156}
30
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
31
31
  */
32
32
  static fromCurrentLocation() {
33
33
  const href = window.location.href;
@@ -45,11 +45,11 @@ export class WidgetParams {
45
45
  else if (keyWithoutPrefix == WidgetParams.PARAM_Y) {
46
46
  widgetEnv.y = parseInt(value);
47
47
  }
48
- else if (keyWithoutPrefix == WidgetParams.PARAM_H) {
49
- widgetEnv.h = parseInt(value);
48
+ else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT) {
49
+ widgetEnv.height = parseInt(value);
50
50
  }
51
- else if (keyWithoutPrefix == WidgetParams.PARAM_W) {
52
- widgetEnv.w = parseInt(value);
51
+ else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH) {
52
+ widgetEnv.width = parseInt(value);
53
53
  }
54
54
  else if (keyWithoutPrefix == WidgetParams.PARAM_LANG) {
55
55
  widgetEnv.lang = value;
@@ -63,11 +63,11 @@ export class WidgetParams {
63
63
  else if (keyWithoutPrefix == WidgetParams.PARAM_RADIUS) {
64
64
  widgetEnv.radius = parseInt(value);
65
65
  }
66
- else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH) {
67
- widgetEnv.width = parseInt(value);
66
+ else if (keyWithoutPrefix == WidgetParams.PARAM_WIDTH_PX) {
67
+ widgetEnv.widthPx = parseInt(value);
68
68
  }
69
- else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT) {
70
- widgetEnv.height = parseInt(value);
69
+ else if (keyWithoutPrefix == WidgetParams.PARAM_HEIGHT_PX) {
70
+ widgetEnv.heightPx = parseInt(value);
71
71
  }
72
72
  else if (keyWithoutPrefix == WidgetParams.PARAM_NAME) {
73
73
  widgetEnv.name = value;
@@ -81,8 +81,8 @@ export class WidgetParams {
81
81
  }
82
82
  /**
83
83
  * 从对象键值对中初始化组件参数
84
- * {w_w:2,w_h:2,w_id:21,w_width:156,w_height:156}=>
85
- * {w:2,h:2,id:21,width:156,height:156}
84
+ * {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
85
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
86
86
  * @param object
87
87
  */
88
88
  static fromObject(object) {
@@ -98,10 +98,10 @@ export class WidgetParams {
98
98
  }
99
99
  WidgetParams.PARAM_PREFIX = "w_";
100
100
  WidgetParams.PARAM_ID = "id";
101
- WidgetParams.PARAM_W = "w";
102
- WidgetParams.PARAM_H = "h";
103
101
  WidgetParams.PARAM_WIDTH = "width";
104
102
  WidgetParams.PARAM_HEIGHT = "height";
103
+ WidgetParams.PARAM_WIDTH_PX = "width_px";
104
+ WidgetParams.PARAM_HEIGHT_PX = "height_px";
105
105
  WidgetParams.PARAM_X = "x";
106
106
  WidgetParams.PARAM_Y = "y";
107
107
  WidgetParams.PARAM_LANG = "lang";
@@ -113,15 +113,15 @@ WidgetParams.PARAM_TITLE = "title";
113
113
  WidgetParams.PARAM_PREVIEW = "preview";
114
114
  WidgetParams.PARAMS = [
115
115
  WidgetParams.PARAM_ID,
116
- WidgetParams.PARAM_W,
117
- WidgetParams.PARAM_H,
116
+ WidgetParams.PARAM_WIDTH,
117
+ WidgetParams.PARAM_HEIGHT,
118
118
  WidgetParams.PARAM_X,
119
119
  WidgetParams.PARAM_Y,
120
120
  WidgetParams.PARAM_LANG,
121
121
  WidgetParams.PARAM_THEME,
122
122
  WidgetParams.PARAM_MODE,
123
- WidgetParams.PARAM_WIDTH,
124
- WidgetParams.PARAM_HEIGHT,
123
+ WidgetParams.PARAM_WIDTH_PX,
124
+ WidgetParams.PARAM_HEIGHT_PX,
125
125
  WidgetParams.PARAM_NAME,
126
126
  WidgetParams.PARAM_TITLE,
127
127
  WidgetParams.PARAM_PREVIEW,
@@ -0,0 +1,4 @@
1
+ export declare class ApiConstants {
2
+ static readonly CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
3
+ static readonly CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
4
+ }
@@ -0,0 +1,6 @@
1
+ export declare class AppApi {
2
+ static readonly SET_CONFIG = "SET_CONFIG";
3
+ static readonly GET_CONFIG = "GET_CONFIG";
4
+ static setConfig(key: string, value: string | number | boolean): Promise<void>;
5
+ static getConfig(key: string, defaultValue: string | number | boolean): Promise<any>;
6
+ }
@@ -1,4 +1,8 @@
1
1
  export declare class BrowserWindowApi {
2
+ static readonly IGNORE_MOUSE_EVENT = "ignore-mouse-event";
3
+ static readonly WINDOW_VISIBILITY = "window-visibility";
4
+ static readonly ALWAYS_ON_TOP = "always-on-top";
2
5
  static setIgnoreMouseEvent(ignore: boolean): Promise<void>;
3
6
  static setWindowVisibility(show: boolean): Promise<void>;
7
+ static setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
4
8
  }
@@ -1,5 +1,6 @@
1
1
  export declare enum Channel {
2
- SET_IGNORE_MOUSE_EVENT = "channel::com.wisdom.widgets.set_ignore_mouse_event",
3
- NOTIFICATION = "channel::com.wisdom.widgets.notification",
4
- BROWSER_WINDOW = "channel::com.wisdom.widgets.browser_window"
2
+ NOTIFICATION = "channel::fun.widget.core.notification",
3
+ BROWSER_WINDOW = "channel::fun.widget.core.browser_window",
4
+ BROADCAST = "channel::fun.widget.core.broadcast",
5
+ APP = "channel::fun.widget.core.app"
5
6
  }
@@ -1,13 +1,10 @@
1
- import { Widget } from "../model/Widget";
2
1
  import { BroadcastEvent } from "../model/BroadcastEvent";
3
2
  export declare class ElectronApi {
4
3
  static openAddWidgetWindow(): void;
5
- static registerWidgets(widgets: Widget[]): Promise<void>;
6
- static setConfig(key: string, value: string | number | boolean): Promise<void>;
7
4
  static sendBroadcastEvent(event: BroadcastEvent): Promise<void>;
8
5
  static registerBroadcast(callback: (event: BroadcastEvent) => void): Promise<void>;
9
6
  static unregisterBroadcast(): Promise<void>;
10
7
  static addIpcListener(key: String, f: Function): Promise<void>;
11
8
  static removeIpcListener(key: String): Promise<void>;
12
- static getConfig(key: string, defaultValue: string | number | boolean): Promise<any>;
9
+ static upgradeNewVersion(key: string, defaultValue: string | number | boolean): Promise<any>;
13
10
  }
@@ -0,0 +1,7 @@
1
+ import { Widget } from "../model/Widget";
2
+ import { WidgetPackage } from "../model/WidgetPackage";
3
+ export declare class WidgetApi {
4
+ static registerWidgets(widgets: Widget[]): Promise<void>;
5
+ static registerWidgetPackage(widgetPackage: WidgetPackage): Promise<void>;
6
+ static getWidgets(): Promise<Widget[]>;
7
+ }
@@ -3,10 +3,13 @@ export * from "./model/BroadcastEvent";
3
3
  export * from "./model/WidgetData";
4
4
  export * from "./model/WidgetParams";
5
5
  export * from "./model/Notification";
6
+ export * from "./model/WidgetPackage";
6
7
  export * from "./api/ElectronApi";
7
- export * from "./api/Keys";
8
8
  export * from "./repository/WidgetDataRepository";
9
9
  export * from "./api/BrowserWindowApi";
10
10
  export * from "./api/NotificationApi";
11
11
  export * from "./api/Channel";
12
+ export * from "./api/WidgetApi";
13
+ export * from "./api/ApiConstants";
14
+ export * from "./api/AppApi";
12
15
  export * from "./utils/ElectronUtils";
@@ -1,6 +1,11 @@
1
1
  export declare class BroadcastEvent {
2
- static TYPE_WIDGET_UPDATED: string;
2
+ static readonly TYPE_WIDGET_UPDATED = "broadcast::fun.widget.core.widget_updated";
3
+ static readonly TYPE_APP_CONFIG_UPDATED = "broadcast::fun.widget.core.app_config_updated";
4
+ static readonly TYPE_THEME_CHANGED = "broadcast::fun.widget.core.theme_changed";
3
5
  type: string;
6
+ /**
7
+ * 发送人,一般为组件名,如:com.example.widgets.countdown
8
+ */
4
9
  from: string;
5
10
  payload: any;
6
11
  constructor(type: string, from: string, payload: any);
@@ -1,18 +1,24 @@
1
1
  type WidgetOptions = {
2
2
  name: string;
3
- title: Map<string, string>;
4
- description: Map<string, string>;
3
+ title: {
4
+ [key: string]: string;
5
+ };
6
+ description: {
7
+ [key: string]: string;
8
+ };
5
9
  keywords: WidgetKeyword[];
6
10
  lang: string;
7
- w: number;
8
- h: number;
9
- maxW?: number;
10
- maxH?: number;
11
- minW?: number;
12
- minH?: number;
11
+ width: number;
12
+ height: number;
13
+ maxWidth?: number;
14
+ maxHeight?: number;
15
+ minWidth?: number;
16
+ minHeight?: number;
13
17
  url: string;
14
18
  configUrl?: string;
15
- extraUrl?: Map<string, string>;
19
+ extraUrl?: {
20
+ [key: string]: string;
21
+ };
16
22
  };
17
23
  export declare class Widget {
18
24
  readonly name: string;
@@ -20,28 +26,34 @@ export declare class Widget {
20
26
  * 组件标题,显示在界面上的,
21
27
  * https://zh.m.wikipedia.org/zh-hans/ISO_639-1
22
28
  */
23
- readonly title: Map<string, string>;
29
+ readonly title: {
30
+ [key: string]: string;
31
+ };
24
32
  /**
25
33
  * 组件介绍
26
34
  */
27
- readonly description: Map<string, string>;
35
+ readonly description: {
36
+ [key: string]: string;
37
+ };
28
38
  readonly keywords: WidgetKeyword[];
29
39
  /**
30
40
  * 组件默认语言
31
41
  */
32
42
  readonly lang: string;
33
- readonly w: number;
34
- readonly h: number;
35
- readonly maxW: number;
36
- readonly maxH: number;
37
- readonly minW: number;
38
- readonly minH: number;
43
+ readonly width: number;
44
+ readonly height: number;
45
+ readonly maxWidth: number;
46
+ readonly maxHeight: number;
47
+ readonly minWidth: number;
48
+ readonly minHeight: number;
39
49
  readonly url: string;
40
50
  readonly configUrl?: string | null;
41
51
  /**
42
52
  * 组件其他页面的url在这注册
43
53
  */
44
- readonly extraUrl: Map<string, string>;
54
+ readonly extraUrl: {
55
+ [key: string]: string;
56
+ };
45
57
  constructor(options: WidgetOptions);
46
58
  /**
47
59
  * 获取组件标题
@@ -53,29 +65,8 @@ export declare class Widget {
53
65
  * @param lang 语言环境,不传则获取默认标题
54
66
  */
55
67
  getDescription(lang?: string): string | undefined;
56
- toJSON(): {
57
- name: string;
58
- title: {
59
- [k: string]: string;
60
- };
61
- description: {
62
- [k: string]: string;
63
- };
64
- keywords: WidgetKeyword[];
65
- lang: string;
66
- w: number;
67
- h: number;
68
- maxW: number;
69
- maxH: number;
70
- minW: number;
71
- minH: number;
72
- url: string;
73
- configUrl: string | null | undefined;
74
- extraUrl: {
75
- [k: string]: string;
76
- };
77
- };
78
- static parse(json: string): Widget;
68
+ static parseJSON(json: string): Widget;
69
+ static parseObject(obj: any): Widget;
79
70
  }
80
71
  export declare enum WidgetKeyword {
81
72
  RECOMMEND = "recommend",
@@ -0,0 +1,31 @@
1
+ import { Widget } from "./Widget";
2
+ export declare class WidgetPackage {
3
+ /**
4
+ * 组件名称,名称与包名类似,e.g. com.example.countdown
5
+ */
6
+ name: string;
7
+ /**
8
+ * 组件包版本
9
+ */
10
+ version: string;
11
+ /**
12
+ * 组件作者署名
13
+ */
14
+ author: string;
15
+ /**
16
+ * 组件首页
17
+ */
18
+ homepage: string;
19
+ /**
20
+ * 组件包介绍
21
+ */
22
+ /**
23
+ * 组件描述
24
+ */
25
+ description: {};
26
+ /**
27
+ * 组件入口文件,通常为 index.html
28
+ */
29
+ entry: string;
30
+ widgets: Widget[];
31
+ }
@@ -1,10 +1,10 @@
1
1
  export declare class WidgetParams {
2
2
  static readonly PARAM_PREFIX = "w_";
3
3
  static readonly PARAM_ID = "id";
4
- static readonly PARAM_W = "w";
5
- static readonly PARAM_H = "h";
6
4
  static readonly PARAM_WIDTH = "width";
7
5
  static readonly PARAM_HEIGHT = "height";
6
+ static readonly PARAM_WIDTH_PX = "width_px";
7
+ static readonly PARAM_HEIGHT_PX = "height_px";
8
8
  static readonly PARAM_X = "x";
9
9
  static readonly PARAM_Y = "y";
10
10
  static readonly PARAM_LANG = "lang";
@@ -16,10 +16,10 @@ export declare class WidgetParams {
16
16
  static readonly PARAM_PREVIEW = "preview";
17
17
  static readonly PARAMS: string[];
18
18
  id?: string;
19
- w?: number;
20
19
  width?: number;
20
+ widthPx?: number;
21
+ heightPx?: number;
21
22
  height?: number;
22
- h?: number;
23
23
  x?: number;
24
24
  y?: number;
25
25
  preview?: boolean;
@@ -40,14 +40,14 @@ export declare class WidgetParams {
40
40
  * 从当前地址解析组件参数:
41
41
  * http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
42
42
  * =>
43
- * {w:2,h:2,id:21,width:156,height:156}
43
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
44
44
  */
45
45
  static fromCurrentLocation(): WidgetParams;
46
46
  private static setValue;
47
47
  /**
48
48
  * 从对象键值对中初始化组件参数
49
- * {w_w:2,w_h:2,w_id:21,w_width:156,w_height:156}=>
50
- * {w:2,h:2,id:21,width:156,height:156}
49
+ * {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
50
+ * {width:2,height:2,id:21,width_px:156,height_px:156}
51
51
  * @param object
52
52
  */
53
53
  static fromObject(object: any): WidgetParams;
package/dist/umd/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.exampleTypescriptPackage=t():e.exampleTypescriptPackage=t()}(this,(()=>(()=>{var e={483:(e,t,n)=>{e.exports=function e(t,n,r){function o(a,c){if(!n[a]){if(!t[a]){if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[a]={exports:{}};t[a][0].call(u.exports,(function(e){return o(t[a][1][e]||e)}),u,u.exports,e,t,n,r)}return n[a].exports}for(var i=void 0,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,r){(function(e){"use strict";var n,r,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),c=e.document.createTextNode("");a.observe(c,{characterData:!0}),n=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var s=new e.MessageChannel;s.port1.onmessage=f,n=function(){s.port2.postMessage(0)}}var u=[];function f(){var e,t;r=!0;for(var n=u.length;n;){for(t=u,u=[],e=-1;++e<n;)t[e]();n=u.length}r=!1}t.exports=function(e){1!==u.push(e)||r||n()}}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){"use strict";var r=e(1);function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],s=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,e!==o&&h(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r((function(){var r;try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=v((function(){t(o,r)}));"error"===a.status&&r(a.value)}function v(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=u,u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(o);return this.state!==s?l(n,this.state===c?e:t,this.outcome):this.queue.push(new f(n,e,t)),n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=v(d,t);if("error"===n.status)return i.reject(e,n.value);var r=n.value;if(r)h(e,r);else{e.state=c,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},u.resolve=function(e){return e instanceof this?e:i.resolve(new this(o),e)},u.reject=function(e){var t=new this(o);return i.reject(t,e)},u.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),c=0,s=-1,u=new this(o);++s<n;)f(e[s],s);return u;function f(e,o){t.resolve(e).then((function(e){a[o]=e,++c!==n||r||(r=!0,i.resolve(u,a))}),(function(e){r||(r=!0,i.reject(u,e))}))}},u.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n,r=e.length,a=!1;if(!r)return this.resolve([]);for(var c=-1,s=new this(o);++c<r;)n=e[c],t.resolve(n).then((function(e){a||(a=!0,i.resolve(s,e))}),(function(e){a||(a=!0,i.reject(s,e))}));return s}},{1:1}],3:[function(e,t,r){(function(t){"use strict";"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function i(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var a=Promise;function c(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function s(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function u(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,h={},v=Object.prototype.toString,p="readonly",y="readwrite";function g(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function m(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a((function(t){var n=e.transaction(l,y),r=i([""]);n.objectStore(l).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return d=e}))}function b(e){var t=h[e.name],n={};n.promise=new a((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function _(e){var t=h[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function I(e,t){var n=h[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function A(e,t){return new a((function(n,r){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);b(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var a=o.open.apply(o,i);t&&(a.onupgradeneeded=function(t){var n=a.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(l)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){var t=a.result;t.onversionchange=function(e){e.target.close()},n(t),_(e)}}))}function w(e){return A(e,!1)}function E(e){return A(e,!0)}function N(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function O(e){return i([g(atob(e.data))],{type:e.type})}function S(e){return e&&e.__local_forage_encoded_blob}function R(e){var t=this,n=t._initReady().then((function(){var e=h[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return s(n,e,e),n}function P(e,t,n,r){void 0===r&&(r=1);try{var o=e.db.transaction(e.storeName,t);n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),E(e)})).then((function(){return function(e){b(e);for(var t=h[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,w(e).then((function(t){return e.db=t,N(e)?E(e):t})).then((function(r){e.db=t.db=r;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r})).catch((function(t){throw I(e,t),t}))}(e).then((function(){P(e,t,n,r-1)}))})).catch(n);n(o)}}var T={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var o=h[n.name];o||(o={forages:[],db:null,dbReady:null,deferredOperations:[]},h[n.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=R);var i=[];function c(){return a.resolve()}for(var s=0;s<o.forages.length;s++){var u=o.forages[s];u!==t&&i.push(u._initReady().catch(c))}var f=o.forages.slice(0);return a.all(i).then((function(){return n.db=o.db,w(n)})).then((function(e){return n.db=e,N(n,t._defaultConfig.version)?E(n):e})).then((function(e){n.db=o.db=e,t._dbInfo=n;for(var r=0;r<f.length;r++){var i=f[r];i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.version)}}))},_support:function(){try{if(!o||!o.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){P(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).openCursor(),c=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;S(r)&&(r=O(r));var o=e(r,n.key,c++);void 0!==o?t(o):n.continue()}else t()},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){P(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),S(e)&&(e=O(e)),t(e)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},setItem:function(e,t,n){var r=this;e=u(e);var o=new a((function(n,o){var i;r.ready().then((function(){return i=r._dbInfo,"[object Blob]"===v.call(t)?m(i.db).then((function(e){return e?t:(n=t,new a((function(e,t){var r=new FileReader;r.onerror=t,r.onloadend=function(t){var r=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:r,type:n.type})},r.readAsBinaryString(n)})));var n})):t})).then((function(t){P(r._dbInfo,y,(function(i,a){if(i)return o(i);try{var c=a.objectStore(r._dbInfo.storeName);null===t&&(t=void 0);var s=c.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=s.error?s.error:s.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return c(o,n),o},removeItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){P(n._dbInfo,y,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){r(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){P(t._dbInfo,y,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){P(t._dbInfo,p,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){e<0?t(null):n.ready().then((function(){P(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName),c=!1,s=a.openKeyCursor();s.onsuccess=function(){var n=s.result;n?0===e||c?t(n.key):(c=!0,n.advance(e)):t(null)},s.onerror=function(){r(s.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){P(t._dbInfo,p,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var t=i.result;t?(a.push(t.key),t.continue()):e(a)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,i=this;if(e.name){var s=e.name===n.name&&i._dbInfo.db?a.resolve(i._dbInfo.db):w(e).then((function(t){var n=h[e.name],r=n.forages;n.db=t;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t;return t}));r=e.storeName?s.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;b(e);var r=h[e.name],i=r.forages;t.close();for(var c=0;c<i.length;c++){var s=i[c];s._dbInfo.db=null,s._dbInfo.version=n}var u=new a((function(t,r){var i=o.open(e.name,n);i.onerror=function(e){i.result.close(),r(e)},i.onupgradeneeded=function(){i.result.deleteObjectStore(e.storeName)},i.onsuccess=function(){var e=i.result;e.close(),t(e)}}));return u.then((function(e){r.db=e;for(var t=0;t<i.length;t++){var n=i[t];n._dbInfo.db=e,_(n._dbInfo)}})).catch((function(t){throw(I(e,t)||a.resolve()).catch((function(){})),t}))}})):s.then((function(t){b(e);var n=h[e.name],r=n.forages;t.close();for(var i=0;i<r.length;i++)r[i]._dbInfo.db=null;var c=new a((function(t,n){var r=o.deleteDatabase(e.name);r.onerror=function(){var e=r.result;e&&e.close(),n(r.error)},r.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},r.onsuccess=function(){var e=r.result;e&&e.close(),t(e)}}));return c.then((function(e){n.db=e;for(var t=0;t<r.length;t++)_(r[t]._dbInfo)})).catch((function(t){throw(I(e,t)||a.resolve()).catch((function(){})),t}))}))}else r=a.reject("Invalid arguments");return c(r,t),r}};var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",D=/^~~local_forage_type~([^~]+)~/,j="__lfsc__:",C=j.length,x="arbf",U="blob",W="si08",B="ui08",k="uic8",L="si16",F="si32",H="ur16",z="ui32",K="fl32",G="fl64",V=C+x.length,Q=Object.prototype.toString;function J(e){var t,n,r,o,i,a=.75*e.length,c=e.length,s=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),f=new Uint8Array(u);for(t=0;t<c;t+=4)n=M.indexOf(e[t]),r=M.indexOf(e[t+1]),o=M.indexOf(e[t+2]),i=M.indexOf(e[t+3]),f[s++]=n<<2|r>>4,f[s++]=(15&r)<<4|o>>2,f[s++]=(3&o)<<6|63&i;return u}function q(e){var t,n=new Uint8Array(e),r="";for(t=0;t<n.length;t+=3)r+=M[n[t]>>2],r+=M[(3&n[t])<<4|n[t+1]>>4],r+=M[(15&n[t+1])<<2|n[t+2]>>6],r+=M[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var X={serialize:function(e,t){var n="";if(e&&(n=Q.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===Q.call(e.buffer))){var r,o=j;e instanceof ArrayBuffer?(r=e,o+=x):(r=e.buffer,"[object Int8Array]"===n?o+=W:"[object Uint8Array]"===n?o+=B:"[object Uint8ClampedArray]"===n?o+=k:"[object Int16Array]"===n?o+=L:"[object Uint16Array]"===n?o+=H:"[object Int32Array]"===n?o+=F:"[object Uint32Array]"===n?o+=z:"[object Float32Array]"===n?o+=K:"[object Float64Array]"===n?o+=G:t(new Error("Failed to get type for BinaryArray"))),t(o+q(r))}else if("[object Blob]"===n){var i=new FileReader;i.onload=function(){var n="~~local_forage_type~"+e.type+"~"+q(this.result);t("__lfsc__:blob"+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,C)!==j)return JSON.parse(e);var t,n=e.substring(V),r=e.substring(C,V);if(r===U&&D.test(n)){var o=n.match(D);t=o[1],n=n.substring(o[0].length)}var a=J(n);switch(r){case x:return a;case U:return i([a],{type:t});case W:return new Int8Array(a);case B:return new Uint8Array(a);case k:return new Uint8ClampedArray(a);case L:return new Int16Array(a);case H:return new Uint16Array(a);case F:return new Int32Array(a);case z:return new Uint32Array(a);case K:return new Float32Array(a);case G:return new Float64Array(a);default:throw new Error("Unkown type: "+r)}},stringToBuffer:J,bufferToString:q};function Y(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function $(e,t,n,r,o,i){e.executeSql(n,r,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?i(e,a):Y(e,t,(function(){e.executeSql(n,r,o,i)}),i)}),i):i(e,a)}),i)}function Z(e,t,n,r){var o=this;e=u(e);var i=new a((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var c=t,s=o._dbInfo;s.serializer.serialize(t,(function(t,u){u?a(u):s.db.transaction((function(n){$(n,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(c)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void i(Z.apply(o,[e,c,n,r-1]));a(t)}}))}))})).catch(a)}));return c(i,n),i}function ee(e){return new a((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var o=[],i=0;i<r.rows.length;i++)o.push(r.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}var te={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var o=new a((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction((function(o){Y(o,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=X,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT * FROM "+o.storeName,[],(function(n,r){for(var i=r.rows,a=i.length,c=0;c<a;c++){var s=i.item(c),u=s.value;if(u&&(u=o.serializer.deserialize(u)),void 0!==(u=e(u,s.key,c+1)))return void t(u)}t()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=o.serializer.deserialize(r)),t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},setItem:function(e,t,n){return Z.apply(this,[e,t,n,1])},removeItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"DELETE FROM "+r.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(t,n){var r=n.rows.item(0).c;e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"SELECT key FROM "+r.storeName,[],(function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key);e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;return c(r=e.name?new a((function(t){var r;r=e.name===n.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:r,storeNames:[e.storeName]}):t(ee(r))})).then((function(e){return new a((function(t,n){e.db.transaction((function(r){function o(e){return new a((function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var i=[],c=0,s=e.storeNames.length;c<s;c++)i.push(o(e.storeNames[c]));a.all(i).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):a.reject("Invalid arguments"),t),r}};function ne(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function re(){return!function(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}()||localStorage.length>0}var oe={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=ne(e,this._defaultConfig),re()?(this._dbInfo=t,t.serializer=X,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,c=0;c<i;c++){var s=localStorage.key(c);if(0===s.indexOf(r)){var u=localStorage.getItem(s);if(u&&(u=t.serializer.deserialize(u)),void 0!==(u=e(u,s.substring(o),a++)))return u}}}));return c(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=n.ready().then((function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&(r=t.serializer.deserialize(r)),r}));return c(r,t),r},setItem:function(e,t,n){var r=this;e=u(e);var o=r.ready().then((function(){void 0===t&&(t=null);var n=t;return new a((function(o,i){var a=r._dbInfo;a.serializer.serialize(t,(function(t,r){if(r)i(r);else try{localStorage.setItem(a.keyPrefix+e,t),o(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return c(o,n),o},removeItem:function(e,t){var n=this;e=u(e);var r=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return c(r,t),r},clear:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return c(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return c(t,e),t},key:function(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return c(r,t),r},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o<n;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&r.push(i.substring(e.keyPrefix.length))}return r}));return c(n,e),n},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,o=this;return r=e.name?new a((function(t){e.storeName?t(ne(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):a.reject("Invalid arguments"),c(r,t),r}},ie=function(e,t){for(var n=e.length,r=0;r<n;){if((o=e[r])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0;r++}var o,i;return!1},ae=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ce={},se={},ue={INDEXEDDB:T,WEBSQL:te,LOCALSTORAGE:oe},fe=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],le=["dropInstance"],de=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(le),he={description:"",driver:fe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ve(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function pe(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(ae(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var ye=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue)if(ue.hasOwnProperty(n)){var r=ue[n],o=r._driver;this[n]=o,ce[o]||this.defineDriver(r)}this._defaultConfig=pe({},he),this._config=pe({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new a((function(t,n){try{var r=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(o);for(var i=de.concat("_initStorage"),s=0,u=i.length;s<u;s++){var f=i[s];if((!ie(le,f)||e[f])&&"function"!=typeof e[f])return void n(o)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=a.reject(t);return c(n,arguments[arguments.length-1]),n}},n=0,r=le.length;n<r;n++){var o=le[n];e[o]||(e[o]=t(o))}}();var l=function(n){ce[r]&&console.info("Redefining LocalForage driver: "+r),ce[r]=e,se[r]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(l,n):l(!!e._support):l(!0)}catch(e){n(e)}}));return s(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=ce[e]?a.resolve(ce[e]):a.reject(new Error("Driver not found."));return s(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(X);return s(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return s(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this;ae(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){r._config.driver=r.driver()}function c(e){return r._extend(e),i(),r._ready=r._initStorage(r._config),r._ready}var u=null!==this._driverSet?this._driverSet.catch((function(){return a.resolve()})):a.resolve();return this._driverSet=u.then((function(){var e=o[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then((function(e){r._driver=e._driver,i(),r._wrapLibraryMethodsWithReady(),r._initDriver=function(e){return function(){var t=0;return function n(){for(;t<e.length;){var o=e[t];return t++,r._dbInfo=null,r._ready=null,r.getDriver(o).then(c).catch(n)}i();var s=new Error("No available storage method found.");return r._driverSet=a.reject(s),r._driverSet}()}}(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return r._driverSet=a.reject(e),r._driverSet})),s(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!se[e]},e.prototype._extend=function(e){pe(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=de.length;e<t;e++)ve(this,de[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),ge=new ye;t.exports=ge},{3:3}]},{},[4])(4)},434:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserWindowApi=void 0;const r=n(714),o=n(823);t.BrowserWindowApi=class{static async setIgnoreMouseEvent(e){await o.ElectronUtils.getAPI().invokeIpc(r.Channel.SET_IGNORE_MOUSE_EVENT,e)}static async setWindowVisibility(e){await o.ElectronUtils.getAPI().invokeIpc(r.Channel.BROWSER_WINDOW,e)}}},714:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Channel=void 0,(n=t.Channel||(t.Channel={})).SET_IGNORE_MOUSE_EVENT="channel::com.wisdom.widgets.set_ignore_mouse_event",n.NOTIFICATION="channel::com.wisdom.widgets.notification",n.BROWSER_WINDOW="channel::com.wisdom.widgets.browser_window"},991:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ElectronApi=void 0;const r=n(873),o=n(823);t.ElectronApi=class{static openAddWidgetWindow(){o.ElectronUtils.getAPI().invokeIpc("openAddWidgetWindow")}static async registerWidgets(e){const t=JSON.parse(JSON.stringify(e.map((e=>JSON.stringify(e)))));await o.ElectronUtils.getAPI().invokeIpc("registerWidgets",t)}static async setConfig(e,t){await o.ElectronUtils.getAPI().invokeIpc("setConfig",{key:e,value:t})}static async sendBroadcastEvent(e){await o.ElectronUtils.getAPI().invokeIpc(r.Keys.BROADCAST_EVENT,JSON.stringify(e))}static async registerBroadcast(e){await this.addIpcListener(r.Keys.BROADCAST_EVENT,(t=>{e(JSON.parse(t))}))}static async unregisterBroadcast(){await this.removeIpcListener(r.Keys.BROADCAST_EVENT)}static async addIpcListener(e,t){await o.ElectronUtils.getAPI().addIpcListener(e,t)}static async removeIpcListener(e){await o.ElectronUtils.getAPI().removeIpcListener(e)}static async getConfig(e,t){const n=await o.ElectronUtils.getAPI().invokeIpc("getConfig",e);return null==n?t:"boolean"==typeof t?"true"===n:n}}},873:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Keys=void 0;class n{}t.Keys=n,n.CONFIG_LAUNCH_AT_STARTUP="LAUNCH_AT_STARTUP",n.CONFIG_WIDGET_SHADOW="WIDGET_SHADOW",n.CHANNEL_MAIN="WeiZ5kaKijae",n.EVENT_WIDGET_UPDATED="WIDGET_SHADOW",n.BROADCAST_EVENT="sendBroadcastEvent",n.INVOKE_SET_IGNORE_MOUSE_EVENT="SEND_NOTIFICATION"},585:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NotificationApi=void 0;const r=n(957),o=n(714),i=n(823);t.NotificationApi=class{static async call(e=5e3){i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({title:"章鱼哥",type:"call",message:"下班提醒",duration:e}))}static async advanceCountdown(e,t,n){i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({title:n,message:e,targetTime:t,type:"advance-countdown"}))}static async countdown(e,t){i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,targetTime:t,type:"countdown"}))}static async success(e,t=5e3){i.ElectronUtils.hasElectronApi()?i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,type:"success",duration:t})):this.callback("success",e,t)}static async error(e,t=5e3){i.ElectronUtils.hasElectronApi()?i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,type:"error",duration:t})):this.callback("error",e,t)}static async warning(e,t=5e3){i.ElectronUtils.hasElectronApi()?i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,type:"warning",duration:t})):this.callback("warning",e,t)}static async message(e,t=5e3){i.ElectronUtils.hasElectronApi()?i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,type:"message",duration:t})):this.callback("message",e,t)}static setDebugNotification(e){this.callback=e}}},432:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(203),t),o(n(982),t),o(n(791),t),o(n(387),t),o(n(957),t),o(n(991),t),o(n(873),t),o(n(865),t),o(n(434),t),o(n(585),t),o(n(714),t),o(n(823),t)},982:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BroadcastEvent=void 0;class n{constructor(e,t,n){this.type=e,this.from=t,this.payload=n}}t.BroadcastEvent=n,n.TYPE_WIDGET_UPDATED="BROADCAST:WIDGET_UPDATED"},957:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Notification=void 0,t.Notification=class{constructor(e){var t,n;this.type="message",this.type=null!==(t=e.type)&&void 0!==t?t:"message",this.title=e.title,this.message=e.message,this.targetTime=e.targetTime,this.duration=null!==(n=e.duration)&&void 0!==n?n:5e3}}},203:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetKeyword=t.Widget=void 0;class n{constructor(e){var t,n,r,o,i;this.lang="zh",this.name=e.name,this.title=e.title,this.description=e.description,this.keywords=e.keywords,this.lang=e.lang,this.w=e.w,this.h=e.h,this.maxW=null!==(t=e.maxW)&&void 0!==t?t:e.w,this.maxH=null!==(n=e.maxH)&&void 0!==n?n:e.h,this.minW=null!==(r=e.minW)&&void 0!==r?r:e.w,this.minH=null!==(o=e.minH)&&void 0!==o?o:e.h,this.url=e.url,this.configUrl=e.configUrl,this.extraUrl=null!==(i=e.extraUrl)&&void 0!==i?i:new Map}getTitle(e){return e?this.title.get(e):this.title.get(this.lang)}getDescription(e){return e?this.description.get(e):this.description.get(this.lang)}toJSON(){return{name:this.name,title:Object.fromEntries(this.title),description:Object.fromEntries(this.description),keywords:this.keywords,lang:this.lang,w:this.w,h:this.h,maxW:this.maxW,maxH:this.maxH,minW:this.minW,minH:this.minH,url:this.url,configUrl:this.configUrl,extraUrl:Object.fromEntries(this.extraUrl)}}static parse(e){const t=JSON.parse(e);return new n({configUrl:t.configUrl,description:new Map(Object.entries(t.description)),extraUrl:new Map(Object.entries(t.extraUrl)),h:t.h,keywords:t.keywords,lang:t.lang,maxH:t.maxH,maxW:t.maxW,minH:t.minH,minW:t.minW,name:t.name,title:new Map(Object.entries(t.title)),url:t.url,w:t.w})}}var r;t.Widget=n,(r=t.WidgetKeyword||(t.WidgetKeyword={})).RECOMMEND="recommend",r.TOOLS="tools",r.EFFICIENCY="efficiency",r.PICTURE="picture",r.LIFE="life",r.SHORTCUT="shortcut",r.COUNTDOWN="countdown",r.TIMER="timer",r.INFO="info",r.DASHBOARD="dashboard"},791:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetData=void 0,t.WidgetData=class{constructor(e,t){this.id=t,this.name=e}parseJSON(e){Object.assign(this,e)}}},387:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetHostMode=t.ThemeMode=t.WidgetParams=void 0;const r=n(470);class o{toUrlParams(){const e=new URLSearchParams,t=Object.getOwnPropertyNames(this);for(let n of t){const t=this[n];t&&e.append(o.PARAM_PREFIX+n,t.toString())}return e}getPersistKey(){return`${this.name}-${this.id}`}static fromCurrentLocation(){let e=window.location.href.split("?")[1];return this.fromObject((0,r.parseQuery)(e))}static setValue(e,t,n){const r=t.replace(this.PARAM_PREFIX,"");r==o.PARAM_ID?e.id=n:r==o.PARAM_X?e.x=parseInt(n):r==o.PARAM_Y?e.y=parseInt(n):r==o.PARAM_H?e.h=parseInt(n):r==o.PARAM_W?e.w=parseInt(n):r==o.PARAM_LANG?e.lang=n:r==o.PARAM_THEME?e.theme=n:r==o.PARAM_MODE?e.mode=parseInt(n):r==o.PARAM_RADIUS?e.radius=parseInt(n):r==o.PARAM_WIDTH?e.width=parseInt(n):r==o.PARAM_HEIGHT?e.height=parseInt(n):r==o.PARAM_NAME?e.name=n:r==o.PARAM_TITLE?e.title=n:r==o.PARAM_PREVIEW&&(e.preview="true"===n)}static fromObject(e){const t=new o,n=Object.getOwnPropertyNames(e);for(let r of n){const n=r,o=e[n];this.setValue(t,n,o)}return t}}var i,a;t.WidgetParams=o,o.PARAM_PREFIX="w_",o.PARAM_ID="id",o.PARAM_W="w",o.PARAM_H="h",o.PARAM_WIDTH="width",o.PARAM_HEIGHT="height",o.PARAM_X="x",o.PARAM_Y="y",o.PARAM_LANG="lang",o.PARAM_THEME="theme",o.PARAM_MODE="mode",o.PARAM_RADIUS="radius",o.PARAM_NAME="name",o.PARAM_TITLE="title",o.PARAM_PREVIEW="preview",o.PARAMS=[o.PARAM_ID,o.PARAM_W,o.PARAM_H,o.PARAM_X,o.PARAM_Y,o.PARAM_LANG,o.PARAM_THEME,o.PARAM_MODE,o.PARAM_WIDTH,o.PARAM_HEIGHT,o.PARAM_NAME,o.PARAM_TITLE,o.PARAM_PREVIEW],(a=t.ThemeMode||(t.ThemeMode={})).AUTO="auto",a.LIGHT="LIGHT",a.DARK="DARK",(i=t.WidgetHostMode||(t.WidgetHostMode={}))[i.DEFAULT=0]="DEFAULT",i[i.OVERLAP=1]="OVERLAP"},865:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetDataRepository=void 0;const o=r(n(483)),i=n(982),a=n(991);class c{static async save(e){let t=this.getStore(e.name);const n=await t.setItem(this.getKey(e.name,e.id),JSON.stringify(e)),r=new i.BroadcastEvent(i.BroadcastEvent.TYPE_WIDGET_UPDATED,"",e);return await a.ElectronApi.sendBroadcastEvent(r),n}static getStore(e){if(this.stores.has(e))return this.stores.get(e);const t=o.default.createInstance({name:e});return this.stores.set(e,t),t}static async saveByName(e){const t=this.getStore(e.name),n=JSON.stringify(e),r=await t.setItem(e.name,n),o=new i.BroadcastEvent(i.BroadcastEvent.TYPE_WIDGET_UPDATED,"",{name:e.name,json:n});return await a.ElectronApi.sendBroadcastEvent(o),r}static async findByName(e,t){let n=this.getStore(e),r=await n.getItem(e);if(r){const n=new t(e);return n.parseJSON(JSON.parse(r)),n}}static async find(e,t,n){let r=this.getStore(e),o=await r.getItem(this.getKey(e,t));if(o){const r=new n(e,t);return r.parseJSON(JSON.parse(o)),r}}static getKey(e,t){return`${e}@${t}`}}t.WidgetDataRepository=c,c.stores=new Map},194:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encodeParam=t.encodePath=t.encodeQueryKey=t.encodeQueryValue=t.encodeHash=t.PLUS_RE=void 0;const n=/#/g,r=/&/g,o=/\//g,i=/=/g,a=/\?/g;t.PLUS_RE=/\+/g;const c=/%5B/g,s=/%5D/g,u=/%5E/g,f=/%60/g,l=/%7B/g,d=/%7C/g,h=/%7D/g,v=/%20/g;function p(e){return encodeURI(""+e).replace(d,"|").replace(c,"[").replace(s,"]")}function y(e){return p(e).replace(t.PLUS_RE,"%2B").replace(v,"+").replace(n,"%23").replace(r,"%26").replace(f,"`").replace(l,"{").replace(h,"}").replace(u,"^")}function g(e){return p(e).replace(n,"%23").replace(a,"%3F")}t.encodeHash=function(e){return p(e).replace(l,"{").replace(h,"}").replace(u,"^")},t.encodeQueryValue=y,t.encodeQueryKey=function(e){return y(e).replace(i,"%3D")},t.encodePath=g,t.encodeParam=function(e){return null==e?"":g(e).replace(o,"%2F")},t.decode=function(e){try{return decodeURIComponent(""+e)}catch(e){}return""+e}},470:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeQuery=t.stringifyQuery=t.parseQuery=void 0;const r=n(194),o=Array.isArray;t.parseQuery=function(e){const t={};if(""===e||"?"===e)return t;const n=("?"===e[0]?e.slice(1):e).split("&");for(let e=0;e<n.length;++e){const i=n[e].replace(r.PLUS_RE," "),a=i.indexOf("="),c=(0,r.decode)(a<0?i:i.slice(0,a)),s=a<0?null:(0,r.decode)(i.slice(a+1));if(c in t){let e=t[c];o(e)||(e=t[c]=[e]),e.push(s)}else t[c]=s}return t},t.stringifyQuery=function(e){let t="";for(let n in e){const i=e[n];(n=(0,r.encodeQueryKey)(n),null!=i)?(o(i)?i.map((e=>e&&(0,r.encodeQueryValue)(e))):[i&&(0,r.encodeQueryValue)(i)]).forEach((e=>{void 0!==e&&(t+=(t.length?"&":"")+n,null!=e&&(t+="="+e))})):void 0!==i&&(t+=(t.length?"&":"")+n)}return t},t.normalizeQuery=function(e){const t={};for(const n in e){const r=e[n];void 0!==r&&(t[n]=o(r)?r.map((e=>null==e?null:""+e)):null==r?r:""+r)}return t}},823:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ElectronUtils=void 0,t.ElectronUtils=class{static hasElectronApi(){return Reflect.has(window,"electronAPI")}static getAPI(){return Reflect.has(window,"electronAPI")?window.electronAPI:Reflect.has(window.parent,"electronAPI")?window.parent.electronAPI:null}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(432)})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.exampleTypescriptPackage=t():e.exampleTypescriptPackage=t()}(this,(()=>(()=>{var e={483:(e,t,n)=>{e.exports=function e(t,n,r){function o(a,c){if(!n[a]){if(!t[a]){if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[a]={exports:{}};t[a][0].call(u.exports,(function(e){return o(t[a][1][e]||e)}),u,u.exports,e,t,n,r)}return n[a].exports}for(var i=void 0,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,r){(function(e){"use strict";var n,r,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var i=0,a=new o(f),c=e.document.createTextNode("");a.observe(c,{characterData:!0}),n=function(){c.data=i=++i%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var s=new e.MessageChannel;s.port1.onmessage=f,n=function(){s.port2.postMessage(0)}}var u=[];function f(){var e,t;r=!0;for(var n=u.length;n;){for(t=u,u=[],e=-1;++e<n;)t[e]();n=u.length}r=!1}t.exports=function(e){1!==u.push(e)||r||n()}}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){"use strict";var r=e(1);function o(){}var i={},a=["REJECTED"],c=["FULFILLED"],s=["PENDING"];function u(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,e!==o&&h(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r((function(){var r;try{r=t(n)}catch(t){return i.reject(e,t)}r===e?i.reject(e,new TypeError("Cannot resolve promise with itself")):i.resolve(e,r)}))}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function r(t){n||(n=!0,i.reject(e,t))}function o(t){n||(n=!0,i.resolve(e,t))}var a=v((function(){t(o,r)}));"error"===a.status&&r(a.value)}function v(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=u,u.prototype.catch=function(e){return this.then(null,e)},u.prototype.then=function(e,t){if("function"!=typeof e&&this.state===c||"function"!=typeof t&&this.state===a)return this;var n=new this.constructor(o);return this.state!==s?l(n,this.state===c?e:t,this.outcome):this.queue.push(new f(n,e,t)),n},f.prototype.callFulfilled=function(e){i.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){i.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},i.resolve=function(e,t){var n=v(d,t);if("error"===n.status)return i.reject(e,n.value);var r=n.value;if(r)h(e,r);else{e.state=c,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},i.reject=function(e,t){e.state=a,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},u.resolve=function(e){return e instanceof this?e:i.resolve(new this(o),e)},u.reject=function(e){var t=new this(o);return i.reject(t,e)},u.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);for(var a=new Array(n),c=0,s=-1,u=new this(o);++s<n;)f(e[s],s);return u;function f(e,o){t.resolve(e).then((function(e){a[o]=e,++c!==n||r||(r=!0,i.resolve(u,a))}),(function(e){r||(r=!0,i.reject(u,e))}))}},u.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n,r=e.length,a=!1;if(!r)return this.resolve([]);for(var c=-1,s=new this(o);++c<r;)n=e[c],t.resolve(n).then((function(e){a||(a=!0,i.resolve(s,e))}),(function(e){a||(a=!0,i.reject(s,e))}));return s}},{1:1}],3:[function(e,t,r){(function(t){"use strict";"function"!=typeof t.Promise&&(t.Promise=e(2))}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var o=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function i(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(o){if("TypeError"!==o.name)throw o;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}"undefined"==typeof Promise&&e(3);var a=Promise;function c(e,t){t&&e.then((function(e){t(null,e)}),(function(e){t(e)}))}function s(e,t,n){"function"==typeof t&&e.then(t),"function"==typeof n&&e.catch(n)}function u(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function f(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}var l="local-forage-detect-blob-support",d=void 0,h={},v=Object.prototype.toString,p="readonly",y="readwrite";function g(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o<t;o++)r[o]=e.charCodeAt(o);return n}function _(e){return"boolean"==typeof d?a.resolve(d):function(e){return new a((function(t){var n=e.transaction(l,y),r=i([""]);n.objectStore(l).put(r,"key"),n.onabort=function(e){e.preventDefault(),e.stopPropagation(),t(!1)},n.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!e||parseInt(e[1],10)>=43)}})).catch((function(){return!1}))}(e).then((function(e){return d=e}))}function m(e){var t=h[e.name],n={};n.promise=new a((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function b(e){var t=h[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function I(e,t){var n=h[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function A(e,t){return new a((function(n,r){if(h[e.name]=h[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);m(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var a=o.open.apply(o,i);t&&(a.onupgradeneeded=function(t){var n=a.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(l)}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){var t=a.result;t.onversionchange=function(e){e.target.close()},n(t),b(e)}}))}function w(e){return A(e,!1)}function E(e){return A(e,!0)}function P(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.version<e.db.version,o=e.version>e.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||n){if(n){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function O(e){return i([g(atob(e.data))],{type:e.type})}function N(e){return e&&e.__local_forage_encoded_blob}function S(e){var t=this,n=t._initReady().then((function(){var e=h[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady}));return s(n,e,e),n}function R(e,t,n,r){void 0===r&&(r=1);try{var o=e.db.transaction(e.storeName,t);n(null,o)}catch(o){if(r>0&&(!e.db||"InvalidStateError"===o.name||"NotFoundError"===o.name))return a.resolve().then((function(){if(!e.db||"NotFoundError"===o.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),E(e)})).then((function(){return function(e){m(e);for(var t=h[e.name],n=t.forages,r=0;r<n.length;r++){var o=n[r];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,w(e).then((function(t){return e.db=t,P(e)?E(e):t})).then((function(r){e.db=t.db=r;for(var o=0;o<n.length;o++)n[o]._dbInfo.db=r})).catch((function(t){throw I(e,t),t}))}(e).then((function(){R(e,t,n,r-1)}))})).catch(n);n(o)}}var T={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var o=h[n.name];o||(o={forages:[],db:null,dbReady:null,deferredOperations:[]},h[n.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=S);var i=[];function c(){return a.resolve()}for(var s=0;s<o.forages.length;s++){var u=o.forages[s];u!==t&&i.push(u._initReady().catch(c))}var f=o.forages.slice(0);return a.all(i).then((function(){return n.db=o.db,w(n)})).then((function(e){return n.db=e,P(n,t._defaultConfig.version)?E(n):e})).then((function(e){n.db=o.db=e,t._dbInfo=n;for(var r=0;r<f.length;r++){var i=f[r];i!==t&&(i._dbInfo.db=n.db,i._dbInfo.version=n.version)}}))},_support:function(){try{if(!o||!o.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||t)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){R(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).openCursor(),c=1;a.onsuccess=function(){var n=a.result;if(n){var r=n.value;N(r)&&(r=O(r));var o=e(r,n.key,c++);void 0!==o?t(o):n.continue()}else t()},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){R(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).get(e);a.onsuccess=function(){var e=a.result;void 0===e&&(e=null),N(e)&&(e=O(e)),t(e)},a.onerror=function(){r(a.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},setItem:function(e,t,n){var r=this;e=u(e);var o=new a((function(n,o){var i;r.ready().then((function(){return i=r._dbInfo,"[object Blob]"===v.call(t)?_(i.db).then((function(e){return e?t:(n=t,new a((function(e,t){var r=new FileReader;r.onerror=t,r.onloadend=function(t){var r=btoa(t.target.result||"");e({__local_forage_encoded_blob:!0,data:r,type:n.type})},r.readAsBinaryString(n)})));var n})):t})).then((function(t){R(r._dbInfo,y,(function(i,a){if(i)return o(i);try{var c=a.objectStore(r._dbInfo.storeName);null===t&&(t=void 0);var s=c.put(t,e);a.oncomplete=function(){void 0===t&&(t=null),n(t)},a.onabort=a.onerror=function(){var e=s.error?s.error:s.transaction.error;o(e)}}catch(e){o(e)}}))})).catch(o)}));return c(o,n),o},removeItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){R(n._dbInfo,y,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName).delete(e);i.oncomplete=function(){t()},i.onerror=function(){r(a.error)},i.onabort=function(){var e=a.error?a.error:a.transaction.error;r(e)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){R(t._dbInfo,y,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).clear();o.oncomplete=function(){e()},o.onabort=o.onerror=function(){var e=i.error?i.error:i.transaction.error;n(e)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){R(t._dbInfo,p,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).count();i.onsuccess=function(){e(i.result)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){e<0?t(null):n.ready().then((function(){R(n._dbInfo,p,(function(o,i){if(o)return r(o);try{var a=i.objectStore(n._dbInfo.storeName),c=!1,s=a.openKeyCursor();s.onsuccess=function(){var n=s.result;n?0===e||c?t(n.key):(c=!0,n.advance(e)):t(null)},s.onerror=function(){r(s.error)}}catch(e){r(e)}}))})).catch(r)}));return c(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){R(t._dbInfo,p,(function(r,o){if(r)return n(r);try{var i=o.objectStore(t._dbInfo.storeName).openKeyCursor(),a=[];i.onsuccess=function(){var t=i.result;t?(a.push(t.key),t.continue()):e(a)},i.onerror=function(){n(i.error)}}catch(e){n(e)}}))})).catch(n)}));return c(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,i=this;if(e.name){var s=e.name===n.name&&i._dbInfo.db?a.resolve(i._dbInfo.db):w(e).then((function(t){var n=h[e.name],r=n.forages;n.db=t;for(var o=0;o<r.length;o++)r[o]._dbInfo.db=t;return t}));r=e.storeName?s.then((function(t){if(t.objectStoreNames.contains(e.storeName)){var n=t.version+1;m(e);var r=h[e.name],i=r.forages;t.close();for(var c=0;c<i.length;c++){var s=i[c];s._dbInfo.db=null,s._dbInfo.version=n}var u=new a((function(t,r){var i=o.open(e.name,n);i.onerror=function(e){i.result.close(),r(e)},i.onupgradeneeded=function(){i.result.deleteObjectStore(e.storeName)},i.onsuccess=function(){var e=i.result;e.close(),t(e)}}));return u.then((function(e){r.db=e;for(var t=0;t<i.length;t++){var n=i[t];n._dbInfo.db=e,b(n._dbInfo)}})).catch((function(t){throw(I(e,t)||a.resolve()).catch((function(){})),t}))}})):s.then((function(t){m(e);var n=h[e.name],r=n.forages;t.close();for(var i=0;i<r.length;i++)r[i]._dbInfo.db=null;var c=new a((function(t,n){var r=o.deleteDatabase(e.name);r.onerror=function(){var e=r.result;e&&e.close(),n(r.error)},r.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},r.onsuccess=function(){var e=r.result;e&&e.close(),t(e)}}));return c.then((function(e){n.db=e;for(var t=0;t<r.length;t++)b(r[t]._dbInfo)})).catch((function(t){throw(I(e,t)||a.resolve()).catch((function(){})),t}))}))}else r=a.reject("Invalid arguments");return c(r,t),r}};var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",D=/^~~local_forage_type~([^~]+)~/,j="__lfsc__:",C=j.length,W="arbf",x="blob",U="si08",k="ui08",B="uic8",L="si16",F="si32",H="ur16",G="ui32",z="fl32",V="fl64",Q=C+W.length,K=Object.prototype.toString;function J(e){var t,n,r,o,i,a=.75*e.length,c=e.length,s=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),f=new Uint8Array(u);for(t=0;t<c;t+=4)n=M.indexOf(e[t]),r=M.indexOf(e[t+1]),o=M.indexOf(e[t+2]),i=M.indexOf(e[t+3]),f[s++]=n<<2|r>>4,f[s++]=(15&r)<<4|o>>2,f[s++]=(3&o)<<6|63&i;return u}function X(e){var t,n=new Uint8Array(e),r="";for(t=0;t<n.length;t+=3)r+=M[n[t]>>2],r+=M[(3&n[t])<<4|n[t+1]>>4],r+=M[(15&n[t+1])<<2|n[t+2]>>6],r+=M[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var Y={serialize:function(e,t){var n="";if(e&&(n=K.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===K.call(e.buffer))){var r,o=j;e instanceof ArrayBuffer?(r=e,o+=W):(r=e.buffer,"[object Int8Array]"===n?o+=U:"[object Uint8Array]"===n?o+=k:"[object Uint8ClampedArray]"===n?o+=B:"[object Int16Array]"===n?o+=L:"[object Uint16Array]"===n?o+=H:"[object Int32Array]"===n?o+=F:"[object Uint32Array]"===n?o+=G:"[object Float32Array]"===n?o+=z:"[object Float64Array]"===n?o+=V:t(new Error("Failed to get type for BinaryArray"))),t(o+X(r))}else if("[object Blob]"===n){var i=new FileReader;i.onload=function(){var n="~~local_forage_type~"+e.type+"~"+X(this.result);t("__lfsc__:blob"+n)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,C)!==j)return JSON.parse(e);var t,n=e.substring(Q),r=e.substring(C,Q);if(r===x&&D.test(n)){var o=n.match(D);t=o[1],n=n.substring(o[0].length)}var a=J(n);switch(r){case W:return a;case x:return i([a],{type:t});case U:return new Int8Array(a);case k:return new Uint8Array(a);case B:return new Uint8ClampedArray(a);case L:return new Int16Array(a);case H:return new Uint16Array(a);case F:return new Int32Array(a);case G:return new Uint32Array(a);case z:return new Float32Array(a);case V:return new Float64Array(a);default:throw new Error("Unkown type: "+r)}},stringToBuffer:J,bufferToString:X};function q(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function $(e,t,n,r,o,i){e.executeSql(n,r,o,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,c){c.rows.length?i(e,a):q(e,t,(function(){e.executeSql(n,r,o,i)}),i)}),i):i(e,a)}),i)}function Z(e,t,n,r){var o=this;e=u(e);var i=new a((function(i,a){o.ready().then((function(){void 0===t&&(t=null);var c=t,s=o._dbInfo;s.serializer.serialize(t,(function(t,u){u?a(u):s.db.transaction((function(n){$(n,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[e,t],(function(){i(c)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void i(Z.apply(o,[e,c,n,r-1]));a(t)}}))}))})).catch(a)}));return c(i,n),i}function ee(e){return new a((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var o=[],i=0;i<r.rows.length;i++)o.push(r.rows.item(i).name);t({db:e,storeNames:o})}),(function(e,t){n(t)}))}),(function(e){n(e)}))}))}var te={_driver:"webSQLStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]="string"!=typeof e[r]?e[r].toString():e[r];var o=new a((function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction((function(o){q(o,n,(function(){t._dbInfo=n,e()}),(function(e,t){r(t)}))}),r)}));return n.serializer=Y,o},_support:"function"==typeof openDatabase,iterate:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT * FROM "+o.storeName,[],(function(n,r){for(var i=r.rows,a=i.length,c=0;c<a;c++){var s=i.item(c),u=s.value;if(u&&(u=o.serializer.deserialize(u)),void 0!==(u=e(u,s.key,c+1)))return void t(u)}t()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT * FROM "+o.storeName+" WHERE key = ? LIMIT 1",[e],(function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&(r=o.serializer.deserialize(r)),t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},setItem:function(e,t,n){return Z.apply(this,[e,t,n,1])},removeItem:function(e,t){var n=this;e=u(e);var r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"DELETE FROM "+o.storeName+" WHERE key = ?",[e],(function(){t()}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},clear:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"DELETE FROM "+r.storeName,[],(function(){e()}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},length:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"SELECT COUNT(key) as c FROM "+r.storeName,[],(function(t,n){var r=n.rows.item(0).c;e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},key:function(e,t){var n=this,r=new a((function(t,r){n.ready().then((function(){var o=n._dbInfo;o.db.transaction((function(n){$(n,o,"SELECT key FROM "+o.storeName+" WHERE id = ? LIMIT 1",[e+1],(function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)}),(function(e,t){r(t)}))}))})).catch(r)}));return c(r,t),r},keys:function(e){var t=this,n=new a((function(e,n){t.ready().then((function(){var r=t._dbInfo;r.db.transaction((function(t){$(t,r,"SELECT key FROM "+r.storeName,[],(function(t,n){for(var r=[],o=0;o<n.rows.length;o++)r.push(n.rows.item(o).key);e(r)}),(function(e,t){n(t)}))}))})).catch(n)}));return c(n,e),n},dropInstance:function(e,t){t=f.apply(this,arguments);var n=this.config();(e="function"!=typeof e&&e||{}).name||(e.name=e.name||n.name,e.storeName=e.storeName||n.storeName);var r,o=this;return c(r=e.name?new a((function(t){var r;r=e.name===n.name?o._dbInfo.db:openDatabase(e.name,"","",0),e.storeName?t({db:r,storeNames:[e.storeName]}):t(ee(r))})).then((function(e){return new a((function(t,n){e.db.transaction((function(r){function o(e){return new a((function(t,n){r.executeSql("DROP TABLE IF EXISTS "+e,[],(function(){t()}),(function(e,t){n(t)}))}))}for(var i=[],c=0,s=e.storeNames.length;c<s;c++)i.push(o(e.storeNames[c]));a.all(i).then((function(){t()})).catch((function(e){n(e)}))}),(function(e){n(e)}))}))})):a.reject("Invalid arguments"),t),r}};function ne(e,t){var n=e.name+"/";return e.storeName!==t.storeName&&(n+=e.storeName+"/"),n}function re(){return!function(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch(e){return!0}}()||localStorage.length>0}var oe={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=ne(e,this._defaultConfig),re()?(this._dbInfo=t,t.serializer=Y,a.resolve()):a.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,o=r.length,i=localStorage.length,a=1,c=0;c<i;c++){var s=localStorage.key(c);if(0===s.indexOf(r)){var u=localStorage.getItem(s);if(u&&(u=t.serializer.deserialize(u)),void 0!==(u=e(u,s.substring(o),a++)))return u}}}));return c(r,t),r},getItem:function(e,t){var n=this;e=u(e);var r=n.ready().then((function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&(r=t.serializer.deserialize(r)),r}));return c(r,t),r},setItem:function(e,t,n){var r=this;e=u(e);var o=r.ready().then((function(){void 0===t&&(t=null);var n=t;return new a((function(o,i){var a=r._dbInfo;a.serializer.serialize(t,(function(t,r){if(r)i(r);else try{localStorage.setItem(a.keyPrefix+e,t),o(n)}catch(e){"QuotaExceededError"!==e.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==e.name||i(e),i(e)}}))}))}));return c(o,n),o},removeItem:function(e,t){var n=this;e=u(e);var r=n.ready().then((function(){var t=n._dbInfo;localStorage.removeItem(t.keyPrefix+e)}));return c(r,t),r},clear:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return c(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return c(t,e),t},key:function(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return c(r,t),r},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],o=0;o<n;o++){var i=localStorage.key(o);0===i.indexOf(e.keyPrefix)&&r.push(i.substring(e.keyPrefix.length))}return r}));return c(n,e),n},dropInstance:function(e,t){if(t=f.apply(this,arguments),!(e="function"!=typeof e&&e||{}).name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var r,o=this;return r=e.name?new a((function(t){e.storeName?t(ne(e,o._defaultConfig)):t(e.name+"/")})).then((function(e){for(var t=localStorage.length-1;t>=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):a.reject("Invalid arguments"),c(r,t),r}},ie=function(e,t){for(var n=e.length,r=0;r<n;){if((o=e[r])===(i=t)||"number"==typeof o&&"number"==typeof i&&isNaN(o)&&isNaN(i))return!0;r++}var o,i;return!1},ae=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},ce={},se={},ue={INDEXEDDB:T,WEBSQL:te,LOCALSTORAGE:oe},fe=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],le=["dropInstance"],de=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(le),he={description:"",driver:fe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function ve(e,t){e[t]=function(){var n=arguments;return e.ready().then((function(){return e[t].apply(e,n)}))}}function pe(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var n in t)t.hasOwnProperty(n)&&(ae(t[n])?arguments[0][n]=t[n].slice():arguments[0][n]=t[n])}return arguments[0]}var ye=function(){function e(t){for(var n in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),ue)if(ue.hasOwnProperty(n)){var r=ue[n],o=r._driver;this[n]=o,ce[o]||this.defineDriver(r)}this._defaultConfig=pe({},he),this._config=pe({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch((function(){}))}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":r(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,t,n){var r=new a((function(t,n){try{var r=e._driver,o=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(o);for(var i=de.concat("_initStorage"),s=0,u=i.length;s<u;s++){var f=i[s];if((!ie(le,f)||e[f])&&"function"!=typeof e[f])return void n(o)}!function(){for(var t=function(e){return function(){var t=new Error("Method "+e+" is not implemented by the current driver"),n=a.reject(t);return c(n,arguments[arguments.length-1]),n}},n=0,r=le.length;n<r;n++){var o=le[n];e[o]||(e[o]=t(o))}}();var l=function(n){ce[r]&&console.info("Redefining LocalForage driver: "+r),ce[r]=e,se[r]=n,t()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(l,n):l(!!e._support):l(!0)}catch(e){n(e)}}));return s(r,t,n),r},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,t,n){var r=ce[e]?a.resolve(ce[e]):a.reject(new Error("Driver not found."));return s(r,t,n),r},e.prototype.getSerializer=function(e){var t=a.resolve(Y);return s(t,e),t},e.prototype.ready=function(e){var t=this,n=t._driverSet.then((function(){return null===t._ready&&(t._ready=t._initDriver()),t._ready}));return s(n,e,e),n},e.prototype.setDriver=function(e,t,n){var r=this;ae(e)||(e=[e]);var o=this._getSupportedDrivers(e);function i(){r._config.driver=r.driver()}function c(e){return r._extend(e),i(),r._ready=r._initStorage(r._config),r._ready}var u=null!==this._driverSet?this._driverSet.catch((function(){return a.resolve()})):a.resolve();return this._driverSet=u.then((function(){var e=o[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then((function(e){r._driver=e._driver,i(),r._wrapLibraryMethodsWithReady(),r._initDriver=function(e){return function(){var t=0;return function n(){for(;t<e.length;){var o=e[t];return t++,r._dbInfo=null,r._ready=null,r.getDriver(o).then(c).catch(n)}i();var s=new Error("No available storage method found.");return r._driverSet=a.reject(s),r._driverSet}()}}(o)}))})).catch((function(){i();var e=new Error("No available storage method found.");return r._driverSet=a.reject(e),r._driverSet})),s(this._driverSet,t,n),this._driverSet},e.prototype.supports=function(e){return!!se[e]},e.prototype._extend=function(e){pe(this,e)},e.prototype._getSupportedDrivers=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var o=e[n];this.supports(o)&&t.push(o)}return t},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,t=de.length;e<t;e++)ve(this,de[e])},e.prototype.createInstance=function(t){return new e(t)},e}(),ge=new ye;t.exports=ge},{3:3}]},{},[4])(4)},250:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApiConstants=void 0;class n{}t.ApiConstants=n,n.CONFIG_LAUNCH_AT_STARTUP="CONFIG_LAUNCH_AT_STARTUP",n.CONFIG_WIDGET_TITLE_COLOR="CONFIG_WIDGET_TITLE_COLOR"},828:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AppApi=void 0;const r=n(823),o=n(714);class i{static async setConfig(e,t){await r.ElectronUtils.getAPI().invoke(o.Channel.APP,this.SET_CONFIG,e,t)}static async getConfig(e,t){const n=await r.ElectronUtils.getAPI().invoke(o.Channel.APP,this.GET_CONFIG,e);return null==n?t:"boolean"==typeof t?"true"===n:n}}t.AppApi=i,i.SET_CONFIG="SET_CONFIG",i.GET_CONFIG="GET_CONFIG"},434:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserWindowApi=void 0;const r=n(714),o=n(823);class i{static async setIgnoreMouseEvent(e){await o.ElectronUtils.getAPI().invoke(r.Channel.BROWSER_WINDOW,this.IGNORE_MOUSE_EVENT,e)}static async setWindowVisibility(e){await o.ElectronUtils.getAPI().invoke(r.Channel.BROWSER_WINDOW,this.WINDOW_VISIBILITY,e)}static async setAlwaysOnTop(e){await o.ElectronUtils.getAPI().invoke(r.Channel.BROWSER_WINDOW,this.ALWAYS_ON_TOP,e)}}t.BrowserWindowApi=i,i.IGNORE_MOUSE_EVENT="ignore-mouse-event",i.WINDOW_VISIBILITY="window-visibility",i.ALWAYS_ON_TOP="always-on-top"},714:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Channel=void 0,(n=t.Channel||(t.Channel={})).NOTIFICATION="channel::fun.widget.core.notification",n.BROWSER_WINDOW="channel::fun.widget.core.browser_window",n.BROADCAST="channel::fun.widget.core.broadcast",n.APP="channel::fun.widget.core.app"},991:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ElectronApi=void 0;const r=n(823),o=n(714);t.ElectronApi=class{static openAddWidgetWindow(){r.ElectronUtils.getAPI().invokeIpc("openAddWidgetWindow")}static async sendBroadcastEvent(e){await r.ElectronUtils.getAPI().invokeIpc(o.Channel.BROADCAST,JSON.stringify(e))}static async registerBroadcast(e){await this.addIpcListener(o.Channel.BROADCAST,(t=>{e(JSON.parse(t))}))}static async unregisterBroadcast(){await this.removeIpcListener(o.Channel.BROADCAST)}static async addIpcListener(e,t){await r.ElectronUtils.getAPI().addIpcListener(e,t)}static async removeIpcListener(e){await r.ElectronUtils.getAPI().removeIpcListener(e)}static async upgradeNewVersion(e,t){const n=await r.ElectronUtils.getAPI().invokeIpc("getConfig",e);return null==n?t:"boolean"==typeof t?"true"===n:n}}},585:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NotificationApi=void 0;const r=n(957),o=n(714),i=n(823);t.NotificationApi=class{static async call(e=5e3){i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({title:"章鱼哥",type:"call",message:"下班提醒",duration:e}))}static async advanceCountdown(e,t,n){i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({title:n,message:e,targetTime:t,type:"advance-countdown"}))}static async countdown(e,t){i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,targetTime:t,type:"countdown"}))}static async success(e,t=5e3){i.ElectronUtils.hasElectronApi()?i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,type:"success",duration:t})):this.callback("success",e,t)}static async error(e,t=5e3){i.ElectronUtils.hasElectronApi()?i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,type:"error",duration:t})):this.callback("error",e,t)}static async warning(e,t=5e3){i.ElectronUtils.hasElectronApi()?i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,type:"warning",duration:t})):this.callback("warning",e,t)}static async message(e,t=5e3){i.ElectronUtils.hasElectronApi()?i.ElectronUtils.getAPI().invokeIpc(o.Channel.NOTIFICATION,new r.Notification({message:e,type:"message",duration:t})):this.callback("message",e,t)}static setDebugNotification(e){this.callback=e}}},426:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetApi=void 0;const r=n(203),o=n(823);t.WidgetApi=class{static async registerWidgets(e){await o.ElectronUtils.getAPI().invokeIpc("registerWidgets",JSON.stringify(e))}static async registerWidgetPackage(e){await o.ElectronUtils.getAPI().invokeIpc("registerWidgetPackage",JSON.stringify(e))}static async getWidgets(){const e=await o.ElectronUtils.getAPI().invokeIpc("getWidgets"),t=[];if(e){const n=JSON.parse(e);for(const e in n)t.push(r.Widget.parseObject(n[e]))}return t}}},432:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(203),t),o(n(982),t),o(n(791),t),o(n(387),t),o(n(957),t),o(n(363),t),o(n(991),t),o(n(865),t),o(n(434),t),o(n(585),t),o(n(714),t),o(n(426),t),o(n(250),t),o(n(828),t),o(n(823),t)},982:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BroadcastEvent=void 0;class n{constructor(e,t,n){this.type=e,this.from=t,this.payload=n}}t.BroadcastEvent=n,n.TYPE_WIDGET_UPDATED="broadcast::fun.widget.core.widget_updated",n.TYPE_APP_CONFIG_UPDATED="broadcast::fun.widget.core.app_config_updated",n.TYPE_THEME_CHANGED="broadcast::fun.widget.core.theme_changed"},957:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Notification=void 0,t.Notification=class{constructor(e){var t,n;this.type="message",this.type=null!==(t=e.type)&&void 0!==t?t:"message",this.title=e.title,this.message=e.message,this.targetTime=e.targetTime,this.duration=null!==(n=e.duration)&&void 0!==n?n:5e3}}},203:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetKeyword=t.Widget=void 0;class n{constructor(e){var t,n,r,o,i;this.lang="zh",this.name=e.name,this.title=e.title,this.description=e.description,this.keywords=e.keywords,this.lang=e.lang,this.width=e.width,this.height=e.height,this.maxWidth=null!==(t=e.maxWidth)&&void 0!==t?t:e.width,this.maxHeight=null!==(n=e.maxHeight)&&void 0!==n?n:e.height,this.minWidth=null!==(r=e.minWidth)&&void 0!==r?r:e.width,this.minHeight=null!==(o=e.minHeight)&&void 0!==o?o:e.height,this.url=e.url,this.configUrl=e.configUrl,this.extraUrl=null!==(i=e.extraUrl)&&void 0!==i?i:{}}getTitle(e){var t;return e&&null!==(t=this.title[e])&&void 0!==t?t:this.title[this.lang]}getDescription(e){return e?this.description[e]:this.description[this.lang]}static parseJSON(e){const t=JSON.parse(e);return this.parseObject(t)}static parseObject(e){return new n({configUrl:e.configUrl,description:e.description,extraUrl:e.extraUrl,width:e.width,keywords:e.keywords,lang:e.lang,maxHeight:e.maxHeight,maxWidth:e.maxWidth,height:e.height,minHeight:e.minHeight,minWidth:e.minWidth,name:e.name,title:e.title,url:e.url})}}var r;t.Widget=n,(r=t.WidgetKeyword||(t.WidgetKeyword={})).RECOMMEND="recommend",r.TOOLS="tools",r.EFFICIENCY="efficiency",r.PICTURE="picture",r.LIFE="life",r.SHORTCUT="shortcut",r.COUNTDOWN="countdown",r.TIMER="timer",r.INFO="info",r.DASHBOARD="dashboard"},791:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetData=void 0,t.WidgetData=class{constructor(e,t){this.id=t,this.name=e}parseJSON(e){Object.assign(this,e)}}},363:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetPackage=void 0,t.WidgetPackage=class{}},387:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetHostMode=t.ThemeMode=t.WidgetParams=void 0;const r=n(470);class o{toUrlParams(){const e=new URLSearchParams,t=Object.getOwnPropertyNames(this);for(let n of t){const t=this[n];t&&e.append(o.PARAM_PREFIX+n,t.toString())}return e}getPersistKey(){return`${this.name}-${this.id}`}static fromCurrentLocation(){let e=window.location.href.split("?")[1];return this.fromObject((0,r.parseQuery)(e))}static setValue(e,t,n){const r=t.replace(this.PARAM_PREFIX,"");r==o.PARAM_ID?e.id=n:r==o.PARAM_X?e.x=parseInt(n):r==o.PARAM_Y?e.y=parseInt(n):r==o.PARAM_HEIGHT?e.height=parseInt(n):r==o.PARAM_WIDTH?e.width=parseInt(n):r==o.PARAM_LANG?e.lang=n:r==o.PARAM_THEME?e.theme=n:r==o.PARAM_MODE?e.mode=parseInt(n):r==o.PARAM_RADIUS?e.radius=parseInt(n):r==o.PARAM_WIDTH_PX?e.widthPx=parseInt(n):r==o.PARAM_HEIGHT_PX?e.heightPx=parseInt(n):r==o.PARAM_NAME?e.name=n:r==o.PARAM_TITLE?e.title=n:r==o.PARAM_PREVIEW&&(e.preview="true"===n)}static fromObject(e){const t=new o,n=Object.getOwnPropertyNames(e);for(let r of n){const n=r,o=e[n];this.setValue(t,n,o)}return t}}var i,a;t.WidgetParams=o,o.PARAM_PREFIX="w_",o.PARAM_ID="id",o.PARAM_WIDTH="width",o.PARAM_HEIGHT="height",o.PARAM_WIDTH_PX="width_px",o.PARAM_HEIGHT_PX="height_px",o.PARAM_X="x",o.PARAM_Y="y",o.PARAM_LANG="lang",o.PARAM_THEME="theme",o.PARAM_MODE="mode",o.PARAM_RADIUS="radius",o.PARAM_NAME="name",o.PARAM_TITLE="title",o.PARAM_PREVIEW="preview",o.PARAMS=[o.PARAM_ID,o.PARAM_WIDTH,o.PARAM_HEIGHT,o.PARAM_X,o.PARAM_Y,o.PARAM_LANG,o.PARAM_THEME,o.PARAM_MODE,o.PARAM_WIDTH_PX,o.PARAM_HEIGHT_PX,o.PARAM_NAME,o.PARAM_TITLE,o.PARAM_PREVIEW],(a=t.ThemeMode||(t.ThemeMode={})).AUTO="auto",a.LIGHT="LIGHT",a.DARK="DARK",(i=t.WidgetHostMode||(t.WidgetHostMode={}))[i.DEFAULT=0]="DEFAULT",i[i.OVERLAP=1]="OVERLAP"},865:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WidgetDataRepository=void 0;const o=r(n(483)),i=n(982),a=n(991);class c{static async save(e){let t=this.getStore(e.name);const n=await t.setItem(this.getKey(e.name,e.id),JSON.stringify(e)),r=new i.BroadcastEvent(i.BroadcastEvent.TYPE_WIDGET_UPDATED,"",e);return await a.ElectronApi.sendBroadcastEvent(r),n}static getStore(e){if(this.stores.has(e))return this.stores.get(e);const t=o.default.createInstance({name:e});return this.stores.set(e,t),t}static async saveByName(e){const t=this.getStore(e.name),n=JSON.stringify(e),r=await t.setItem(e.name,n),o=new i.BroadcastEvent(i.BroadcastEvent.TYPE_WIDGET_UPDATED,"",{name:e.name,json:n});return await a.ElectronApi.sendBroadcastEvent(o),r}static async findByName(e,t){let n=this.getStore(e),r=await n.getItem(e);if(r){const n=new t(e);return n.parseJSON(JSON.parse(r)),n}}static async find(e,t,n){let r=this.getStore(e),o=await r.getItem(this.getKey(e,t));if(o){const r=new n(e,t);return r.parseJSON(JSON.parse(o)),r}}static getKey(e,t){return`${e}@${t}`}}t.WidgetDataRepository=c,c.stores=new Map},194:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encodeParam=t.encodePath=t.encodeQueryKey=t.encodeQueryValue=t.encodeHash=t.PLUS_RE=void 0;const n=/#/g,r=/&/g,o=/\//g,i=/=/g,a=/\?/g;t.PLUS_RE=/\+/g;const c=/%5B/g,s=/%5D/g,u=/%5E/g,f=/%60/g,l=/%7B/g,d=/%7C/g,h=/%7D/g,v=/%20/g;function p(e){return encodeURI(""+e).replace(d,"|").replace(c,"[").replace(s,"]")}function y(e){return p(e).replace(t.PLUS_RE,"%2B").replace(v,"+").replace(n,"%23").replace(r,"%26").replace(f,"`").replace(l,"{").replace(h,"}").replace(u,"^")}function g(e){return p(e).replace(n,"%23").replace(a,"%3F")}t.encodeHash=function(e){return p(e).replace(l,"{").replace(h,"}").replace(u,"^")},t.encodeQueryValue=y,t.encodeQueryKey=function(e){return y(e).replace(i,"%3D")},t.encodePath=g,t.encodeParam=function(e){return null==e?"":g(e).replace(o,"%2F")},t.decode=function(e){try{return decodeURIComponent(""+e)}catch(e){}return""+e}},470:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeQuery=t.stringifyQuery=t.parseQuery=void 0;const r=n(194),o=Array.isArray;t.parseQuery=function(e){const t={};if(""===e||"?"===e)return t;const n=("?"===e[0]?e.slice(1):e).split("&");for(let e=0;e<n.length;++e){const i=n[e].replace(r.PLUS_RE," "),a=i.indexOf("="),c=(0,r.decode)(a<0?i:i.slice(0,a)),s=a<0?null:(0,r.decode)(i.slice(a+1));if(c in t){let e=t[c];o(e)||(e=t[c]=[e]),e.push(s)}else t[c]=s}return t},t.stringifyQuery=function(e){let t="";for(let n in e){const i=e[n];(n=(0,r.encodeQueryKey)(n),null!=i)?(o(i)?i.map((e=>e&&(0,r.encodeQueryValue)(e))):[i&&(0,r.encodeQueryValue)(i)]).forEach((e=>{void 0!==e&&(t+=(t.length?"&":"")+n,null!=e&&(t+="="+e))})):void 0!==i&&(t+=(t.length?"&":"")+n)}return t},t.normalizeQuery=function(e){const t={};for(const n in e){const r=e[n];void 0!==r&&(t[n]=o(r)?r.map((e=>null==e?null:""+e)):null==r?r:""+r)}return t}},823:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ElectronUtils=void 0,t.ElectronUtils=class{static hasElectronApi(){return Reflect.has(window,"electronAPI")}static getAPI(){return Reflect.has(window,"electronAPI")?window.electronAPI:Reflect.has(window.parent,"electronAPI")?window.parent.electronAPI:null}}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}return n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n(432)})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widget-js/core",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Keys = void 0;
4
- class Keys {
5
- }
6
- exports.Keys = Keys;
7
- Keys.CONFIG_LAUNCH_AT_STARTUP = "LAUNCH_AT_STARTUP";
8
- Keys.CONFIG_WIDGET_SHADOW = "WIDGET_SHADOW";
9
- Keys.CHANNEL_MAIN = "WeiZ5kaKijae";
10
- Keys.EVENT_WIDGET_UPDATED = "WIDGET_SHADOW";
11
- Keys.BROADCAST_EVENT = "sendBroadcastEvent";
12
- Keys.INVOKE_SET_IGNORE_MOUSE_EVENT = "SEND_NOTIFICATION";
@@ -1,8 +0,0 @@
1
- export class Keys {
2
- }
3
- Keys.CONFIG_LAUNCH_AT_STARTUP = "LAUNCH_AT_STARTUP";
4
- Keys.CONFIG_WIDGET_SHADOW = "WIDGET_SHADOW";
5
- Keys.CHANNEL_MAIN = "WeiZ5kaKijae";
6
- Keys.EVENT_WIDGET_UPDATED = "WIDGET_SHADOW";
7
- Keys.BROADCAST_EVENT = "sendBroadcastEvent";
8
- Keys.INVOKE_SET_IGNORE_MOUSE_EVENT = "SEND_NOTIFICATION";
@@ -1,8 +0,0 @@
1
- export declare class Keys {
2
- static readonly CONFIG_LAUNCH_AT_STARTUP = "LAUNCH_AT_STARTUP";
3
- static readonly CONFIG_WIDGET_SHADOW = "WIDGET_SHADOW";
4
- static readonly CHANNEL_MAIN = "WeiZ5kaKijae";
5
- static readonly EVENT_WIDGET_UPDATED = "WIDGET_SHADOW";
6
- static readonly BROADCAST_EVENT = "sendBroadcastEvent";
7
- static readonly INVOKE_SET_IGNORE_MOUSE_EVENT = "SEND_NOTIFICATION";
8
- }