@widget-js/core 0.1.6 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/dist/cjs/api/ApiConstants.js +8 -8
- package/dist/cjs/api/AppApi.js +31 -31
- package/dist/cjs/api/BroadcastApi.js +20 -20
- package/dist/cjs/api/BrowserWindowApi.js +42 -24
- package/dist/cjs/api/Channel.js +11 -11
- package/dist/cjs/api/ElectronApi.js +13 -13
- package/dist/cjs/api/NotificationApi.js +83 -83
- package/dist/cjs/api/WidgetApi.js +58 -49
- package/dist/cjs/index.js +35 -34
- package/dist/cjs/model/HostedMode.js +14 -0
- package/dist/cjs/model/Notification.js +15 -15
- package/dist/cjs/model/SocialInfo.js +10 -10
- package/dist/cjs/model/Widget.js +79 -79
- package/dist/cjs/model/WidgetData.js +16 -16
- package/dist/cjs/model/WidgetPackage.js +21 -6
- package/dist/cjs/model/WidgetParams.js +139 -144
- package/dist/cjs/model/event/BroadcastEvent.js +14 -14
- package/dist/cjs/model/event/WebSocketEvent.js +14 -14
- package/dist/cjs/model/interface/IHostedWidget.js +2 -0
- package/dist/cjs/repository/WidgetDataRepository.js +71 -71
- package/dist/cjs/router/encoding.js +144 -144
- package/dist/cjs/router/query.js +84 -84
- package/dist/cjs/utils/ElectronUtils.js +24 -24
- package/dist/esm/api/ApiConstants.js +4 -4
- package/dist/esm/api/AppApi.js +27 -27
- package/dist/esm/api/BroadcastApi.js +16 -16
- package/dist/esm/api/BrowserWindowApi.js +38 -20
- package/dist/esm/api/Channel.js +8 -8
- package/dist/esm/api/ElectronApi.js +9 -9
- package/dist/esm/api/NotificationApi.js +79 -79
- package/dist/esm/api/WidgetApi.js +54 -45
- package/dist/esm/index.js +19 -18
- package/dist/esm/model/HostedMode.js +11 -0
- package/dist/esm/model/Notification.js +11 -11
- package/dist/esm/model/SocialInfo.js +6 -6
- package/dist/esm/model/Widget.js +75 -75
- package/dist/esm/model/WidgetData.js +12 -12
- package/dist/esm/model/WidgetPackage.js +17 -2
- package/dist/esm/model/WidgetParams.js +135 -140
- package/dist/esm/model/event/BroadcastEvent.js +10 -10
- package/dist/esm/model/event/WebSocketEvent.js +10 -10
- package/dist/esm/model/interface/IHostedWidget.js +1 -0
- package/dist/esm/repository/WidgetDataRepository.js +64 -64
- package/dist/esm/router/encoding.js +135 -135
- package/dist/esm/router/query.js +79 -79
- package/dist/esm/utils/ElectronUtils.js +20 -20
- package/dist/types/api/ApiConstants.d.ts +4 -4
- package/dist/types/api/AppApi.d.ts +10 -10
- package/dist/types/api/BroadcastApi.d.ts +6 -6
- package/dist/types/api/BrowserWindowApi.d.ts +27 -10
- package/dist/types/api/Channel.d.ts +7 -7
- package/dist/types/api/ElectronApi.d.ts +4 -4
- package/dist/types/api/NotificationApi.d.ts +14 -14
- package/dist/types/api/WidgetApi.d.ts +30 -24
- package/dist/types/index.d.ts +19 -18
- package/dist/types/model/HostedMode.d.ts +10 -0
- package/dist/types/model/Notification.d.ts +16 -16
- package/dist/types/model/SocialInfo.d.ts +6 -6
- package/dist/types/model/Widget.d.ts +96 -85
- package/dist/types/model/WidgetData.d.ts +35 -35
- package/dist/types/model/WidgetPackage.d.ts +43 -41
- package/dist/types/model/WidgetParams.d.ts +60 -63
- package/dist/types/model/event/BroadcastEvent.d.ts +12 -12
- package/dist/types/model/event/WebSocketEvent.d.ts +8 -8
- package/dist/types/model/interface/IHostedWidget.d.ts +13 -0
- package/dist/types/repository/WidgetDataRepository.d.ts +26 -26
- package/dist/types/router/encoding.d.ts +62 -62
- package/dist/types/router/query.d.ts +53 -53
- package/dist/types/utils/ElectronUtils.d.ts +8 -8
- package/dist/umd/index.js +1 -1
- package/package.json +2 -2
package/dist/esm/api/AppApi.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
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
|
-
static openAddWidgetWindow() {
|
|
18
|
-
ElectronUtils.getAPI().invoke(Channel.APP, this.OPEN_ADD_WIDGET_WINDOW);
|
|
19
|
-
}
|
|
20
|
-
static openSettingWindow() {
|
|
21
|
-
ElectronUtils.getAPI().invoke(Channel.APP, this.OPEN_SETTING_WINDOW);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
AppApi.SET_CONFIG = "SET_CONFIG";
|
|
25
|
-
AppApi.GET_CONFIG = "GET_CONFIG";
|
|
26
|
-
AppApi.OPEN_ADD_WIDGET_WINDOW = "open-add-widget-window";
|
|
27
|
-
AppApi.OPEN_SETTING_WINDOW = "open-setting-window";
|
|
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
|
+
static openAddWidgetWindow() {
|
|
18
|
+
ElectronUtils.getAPI().invoke(Channel.APP, this.OPEN_ADD_WIDGET_WINDOW);
|
|
19
|
+
}
|
|
20
|
+
static openSettingWindow() {
|
|
21
|
+
ElectronUtils.getAPI().invoke(Channel.APP, this.OPEN_SETTING_WINDOW);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
AppApi.SET_CONFIG = "SET_CONFIG";
|
|
25
|
+
AppApi.GET_CONFIG = "GET_CONFIG";
|
|
26
|
+
AppApi.OPEN_ADD_WIDGET_WINDOW = "open-add-widget-window";
|
|
27
|
+
AppApi.OPEN_SETTING_WINDOW = "open-setting-window";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
|
-
import { Channel } from "./Channel";
|
|
3
|
-
import { ElectronApi } from "./ElectronApi";
|
|
4
|
-
export class BroadcastApi {
|
|
5
|
-
static async sendBroadcastEvent(event) {
|
|
6
|
-
await ElectronUtils.getAPI().invoke(Channel.BROADCAST, JSON.stringify(event));
|
|
7
|
-
}
|
|
8
|
-
static async registerBroadcast(callback) {
|
|
9
|
-
await ElectronApi.addIpcListener(Channel.BROADCAST, (json) => {
|
|
10
|
-
callback(JSON.parse(json));
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
static async unregisterBroadcast() {
|
|
14
|
-
await ElectronApi.removeIpcListener(Channel.BROADCAST);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
|
+
import { Channel } from "./Channel";
|
|
3
|
+
import { ElectronApi } from "./ElectronApi";
|
|
4
|
+
export class BroadcastApi {
|
|
5
|
+
static async sendBroadcastEvent(event) {
|
|
6
|
+
await ElectronUtils.getAPI().invoke(Channel.BROADCAST, JSON.stringify(event));
|
|
7
|
+
}
|
|
8
|
+
static async registerBroadcast(callback) {
|
|
9
|
+
await ElectronApi.addIpcListener(Channel.BROADCAST, (json) => {
|
|
10
|
+
callback(JSON.parse(json));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
static async unregisterBroadcast() {
|
|
14
|
+
await ElectronApi.removeIpcListener(Channel.BROADCAST);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
import { Channel } from "./Channel";
|
|
2
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
3
|
-
export class BrowserWindowApi {
|
|
4
|
-
static async setIgnoreMouseEvent(ignore) {
|
|
5
|
-
await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.IGNORE_MOUSE_EVENT, ignore);
|
|
6
|
-
}
|
|
7
|
-
static async setWindowVisibility(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);
|
|
12
|
-
}
|
|
13
|
-
static async
|
|
14
|
-
await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { Channel } from "./Channel";
|
|
2
|
+
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
3
|
+
export class BrowserWindowApi {
|
|
4
|
+
static async setIgnoreMouseEvent(ignore) {
|
|
5
|
+
await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.IGNORE_MOUSE_EVENT, ignore);
|
|
6
|
+
}
|
|
7
|
+
static async setWindowVisibility(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);
|
|
12
|
+
}
|
|
13
|
+
static async isAlwaysOnTop() {
|
|
14
|
+
return await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.IS_ALWAYS_ON_TOP);
|
|
15
|
+
}
|
|
16
|
+
static async openUrl(url) {
|
|
17
|
+
await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.OPEN_URL, url);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 设置窗口位置
|
|
21
|
+
* @param x
|
|
22
|
+
* @param y
|
|
23
|
+
* @param animation 动画只在mac系统有效
|
|
24
|
+
*/
|
|
25
|
+
static async setPosition(x, y, animation) {
|
|
26
|
+
await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.SET_POSITION, x, y, animation);
|
|
27
|
+
}
|
|
28
|
+
static async getPosition() {
|
|
29
|
+
return await ElectronUtils.getAPI().invoke(Channel.BROWSER_WINDOW, this.GET_POSITION);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
BrowserWindowApi.IGNORE_MOUSE_EVENT = "ignore-mouse-event";
|
|
33
|
+
BrowserWindowApi.WINDOW_VISIBILITY = "window-visibility";
|
|
34
|
+
BrowserWindowApi.ALWAYS_ON_TOP = "always-on-top";
|
|
35
|
+
BrowserWindowApi.IS_ALWAYS_ON_TOP = "is-always-on-top";
|
|
36
|
+
BrowserWindowApi.OPEN_URL = "open-url";
|
|
37
|
+
BrowserWindowApi.SET_POSITION = "set-position";
|
|
38
|
+
BrowserWindowApi.GET_POSITION = "get-position";
|
package/dist/esm/api/Channel.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export var Channel;
|
|
2
|
-
(function (Channel) {
|
|
3
|
-
Channel["NOTIFICATION"] = "channel::cn.widgetjs.core.notification";
|
|
4
|
-
Channel["BROWSER_WINDOW"] = "channel::cn.widgetjs.core.browser_window";
|
|
5
|
-
Channel["BROADCAST"] = "channel::cn.widgetjs.core.broadcast";
|
|
6
|
-
Channel["WIDGET"] = "channel::cn.widgetjs.core.widget";
|
|
7
|
-
Channel["APP"] = "channel::cn.widgetjs.core.app";
|
|
8
|
-
})(Channel || (Channel = {}));
|
|
1
|
+
export var Channel;
|
|
2
|
+
(function (Channel) {
|
|
3
|
+
Channel["NOTIFICATION"] = "channel::cn.widgetjs.core.notification";
|
|
4
|
+
Channel["BROWSER_WINDOW"] = "channel::cn.widgetjs.core.browser_window";
|
|
5
|
+
Channel["BROADCAST"] = "channel::cn.widgetjs.core.broadcast";
|
|
6
|
+
Channel["WIDGET"] = "channel::cn.widgetjs.core.widget";
|
|
7
|
+
Channel["APP"] = "channel::cn.widgetjs.core.app";
|
|
8
|
+
})(Channel || (Channel = {}));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
|
-
export class ElectronApi {
|
|
3
|
-
static async addIpcListener(key, f) {
|
|
4
|
-
await ElectronUtils.getAPI().addIpcListener(key, f);
|
|
5
|
-
}
|
|
6
|
-
static async removeIpcListener(key) {
|
|
7
|
-
await ElectronUtils.getAPI().removeIpcListener(key);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
|
+
export class ElectronApi {
|
|
3
|
+
static async addIpcListener(key, f) {
|
|
4
|
+
await ElectronUtils.getAPI().addIpcListener(key, f);
|
|
5
|
+
}
|
|
6
|
+
static async removeIpcListener(key) {
|
|
7
|
+
await ElectronUtils.getAPI().removeIpcListener(key);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { Notification } from "../model/Notification";
|
|
2
|
-
import { Channel } from "./Channel";
|
|
3
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
4
|
-
export class NotificationApi {
|
|
5
|
-
static async call(duration = 5000) {
|
|
6
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
7
|
-
title: "章鱼哥",
|
|
8
|
-
type: "call",
|
|
9
|
-
message: "下班提醒",
|
|
10
|
-
duration: duration
|
|
11
|
-
}));
|
|
12
|
-
}
|
|
13
|
-
static async advanceCountdown(message, targetTime, title) {
|
|
14
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
15
|
-
title,
|
|
16
|
-
message,
|
|
17
|
-
targetTime,
|
|
18
|
-
type: "advance-countdown"
|
|
19
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
static async countdown(message, targetTime) {
|
|
22
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
23
|
-
message,
|
|
24
|
-
targetTime,
|
|
25
|
-
type: "countdown"
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
static async success(message, duration = 5000) {
|
|
29
|
-
if (ElectronUtils.hasElectronApi()) {
|
|
30
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
31
|
-
message,
|
|
32
|
-
type: "success",
|
|
33
|
-
duration
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.callback("success", message, duration);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
static async error(message, duration = 5000) {
|
|
41
|
-
if (ElectronUtils.hasElectronApi()) {
|
|
42
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
43
|
-
message,
|
|
44
|
-
type: "error",
|
|
45
|
-
duration
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
this.callback("error", message, duration);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
static async warning(message, duration = 5000) {
|
|
53
|
-
if (ElectronUtils.hasElectronApi()) {
|
|
54
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
55
|
-
message,
|
|
56
|
-
type: "warning",
|
|
57
|
-
duration
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
this.callback("warning", message, duration);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
static async message(message, duration = 5000) {
|
|
65
|
-
if (ElectronUtils.hasElectronApi()) {
|
|
66
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
67
|
-
message,
|
|
68
|
-
type: "message",
|
|
69
|
-
duration
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.callback("message", message, duration);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
static setDebugNotification(callback) {
|
|
77
|
-
this.callback = callback;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
1
|
+
import { Notification } from "../model/Notification";
|
|
2
|
+
import { Channel } from "./Channel";
|
|
3
|
+
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
4
|
+
export class NotificationApi {
|
|
5
|
+
static async call(duration = 5000) {
|
|
6
|
+
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
7
|
+
title: "章鱼哥",
|
|
8
|
+
type: "call",
|
|
9
|
+
message: "下班提醒",
|
|
10
|
+
duration: duration
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
static async advanceCountdown(message, targetTime, title) {
|
|
14
|
+
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
15
|
+
title,
|
|
16
|
+
message,
|
|
17
|
+
targetTime,
|
|
18
|
+
type: "advance-countdown"
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
static async countdown(message, targetTime) {
|
|
22
|
+
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
23
|
+
message,
|
|
24
|
+
targetTime,
|
|
25
|
+
type: "countdown"
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
static async success(message, duration = 5000) {
|
|
29
|
+
if (ElectronUtils.hasElectronApi()) {
|
|
30
|
+
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
31
|
+
message,
|
|
32
|
+
type: "success",
|
|
33
|
+
duration
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.callback("success", message, duration);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static async error(message, duration = 5000) {
|
|
41
|
+
if (ElectronUtils.hasElectronApi()) {
|
|
42
|
+
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
43
|
+
message,
|
|
44
|
+
type: "error",
|
|
45
|
+
duration
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.callback("error", message, duration);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static async warning(message, duration = 5000) {
|
|
53
|
+
if (ElectronUtils.hasElectronApi()) {
|
|
54
|
+
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
55
|
+
message,
|
|
56
|
+
type: "warning",
|
|
57
|
+
duration
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.callback("warning", message, duration);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static async message(message, duration = 5000) {
|
|
65
|
+
if (ElectronUtils.hasElectronApi()) {
|
|
66
|
+
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new Notification({
|
|
67
|
+
message,
|
|
68
|
+
type: "message",
|
|
69
|
+
duration
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.callback("message", message, duration);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
static setDebugNotification(callback) {
|
|
77
|
+
this.callback = callback;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,45 +1,54 @@
|
|
|
1
|
-
import { Widget } from "../model/Widget";
|
|
2
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import { Widget } from "../model/Widget";
|
|
2
|
+
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
3
|
+
import { WidgetPackage } from "../model/WidgetPackage";
|
|
4
|
+
import { Channel } from "./Channel";
|
|
5
|
+
export class WidgetApi {
|
|
6
|
+
static async registerWidgets(widgets) {
|
|
7
|
+
await ElectronUtils.getAPI().invoke(Channel.WIDGET, this.REGISTER_WIDGETS, JSON.stringify(widgets));
|
|
8
|
+
}
|
|
9
|
+
static async registerWidgetPackage(widgetPackage) {
|
|
10
|
+
await ElectronUtils.getAPI().invoke(Channel.WIDGET, this.REGISTER_WIDGET_PACKAGE, JSON.stringify(widgetPackage));
|
|
11
|
+
}
|
|
12
|
+
static async getWidgets() {
|
|
13
|
+
const data = await ElectronUtils.getAPI().invoke(Channel.WIDGET, this.GET_WIDGETS);
|
|
14
|
+
const widgets = [];
|
|
15
|
+
if (data) {
|
|
16
|
+
const arr = JSON.parse(data);
|
|
17
|
+
for (const i in arr) {
|
|
18
|
+
widgets.push(Widget.parseObject(arr[i]));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return widgets;
|
|
22
|
+
}
|
|
23
|
+
static async getWidgetPackages() {
|
|
24
|
+
return await ElectronUtils.getAPI().invoke(Channel.WIDGET, this.GET_WIDGET_PACKAGES);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param name package name
|
|
29
|
+
*/
|
|
30
|
+
static async getWidget(name) {
|
|
31
|
+
return Widget.parseObject(await ElectronUtils.getAPI().invoke(Channel.WIDGET, this.GET_WIDGET, name));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param name package name
|
|
36
|
+
*/
|
|
37
|
+
static async getWidgetPackage(name) {
|
|
38
|
+
return WidgetPackage.parseObject(await ElectronUtils.getAPI().invoke(Channel.WIDGET, this.GET_WIDGET_PACKAGE, name));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* 移除组件
|
|
42
|
+
* @param id
|
|
43
|
+
*/
|
|
44
|
+
static async removeHostedWidget(id) {
|
|
45
|
+
return ElectronUtils.getAPI().invoke(Channel.WIDGET, this.REMOVE_HOSTED_WIDGET, id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
WidgetApi.REGISTER_WIDGETS = "register-widgets";
|
|
49
|
+
WidgetApi.REGISTER_WIDGET_PACKAGE = "register-widget-package";
|
|
50
|
+
WidgetApi.GET_WIDGETS = "get-widgets";
|
|
51
|
+
WidgetApi.GET_WIDGET = "get-widget";
|
|
52
|
+
WidgetApi.GET_WIDGET_PACKAGE = "get-widget-package";
|
|
53
|
+
WidgetApi.GET_WIDGET_PACKAGES = "get-widget-packages";
|
|
54
|
+
WidgetApi.REMOVE_HOSTED_WIDGET = "remove-hosted-widget";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
export * from "./model/Widget";
|
|
2
|
-
export * from "./model/event/BroadcastEvent";
|
|
3
|
-
export * from "./model/event/WebSocketEvent";
|
|
4
|
-
export * from "./model/WidgetData";
|
|
5
|
-
export * from "./model/WidgetParams";
|
|
6
|
-
export * from "./model/Notification";
|
|
7
|
-
export * from "./model/
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./api/
|
|
12
|
-
export * from "./api/
|
|
13
|
-
export * from "./api/
|
|
14
|
-
export * from "./api/
|
|
15
|
-
export * from "./api/
|
|
16
|
-
export * from "./api/
|
|
17
|
-
export * from "./
|
|
18
|
-
export * from "./
|
|
1
|
+
export * from "./model/Widget";
|
|
2
|
+
export * from "./model/event/BroadcastEvent";
|
|
3
|
+
export * from "./model/event/WebSocketEvent";
|
|
4
|
+
export * from "./model/WidgetData";
|
|
5
|
+
export * from "./model/WidgetParams";
|
|
6
|
+
export * from "./model/Notification";
|
|
7
|
+
export * from "./model/HostedMode";
|
|
8
|
+
export * from "./model/WidgetPackage";
|
|
9
|
+
export * from "./api/ElectronApi";
|
|
10
|
+
export * from "./repository/WidgetDataRepository";
|
|
11
|
+
export * from "./api/BrowserWindowApi";
|
|
12
|
+
export * from "./api/NotificationApi";
|
|
13
|
+
export * from "./api/Channel";
|
|
14
|
+
export * from "./api/WidgetApi";
|
|
15
|
+
export * from "./api/ApiConstants";
|
|
16
|
+
export * from "./api/BroadcastApi";
|
|
17
|
+
export * from "./api/AppApi";
|
|
18
|
+
export * from "./utils/ElectronUtils";
|
|
19
|
+
export * from "./router/query";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var HostedMode;
|
|
2
|
+
(function (HostedMode) {
|
|
3
|
+
HostedMode[HostedMode["NORMAL"] = 1] = "NORMAL";
|
|
4
|
+
/**
|
|
5
|
+
* 悬浮窗
|
|
6
|
+
*/
|
|
7
|
+
HostedMode[HostedMode["OVERLAP"] = 16] = "OVERLAP";
|
|
8
|
+
HostedMode[HostedMode["WALLPAPER"] = 256] = "WALLPAPER";
|
|
9
|
+
HostedMode[HostedMode["SCREEN"] = 4096] = "SCREEN";
|
|
10
|
+
HostedMode[HostedMode["ALL"] = 4369] = "ALL";
|
|
11
|
+
})(HostedMode || (HostedMode = {}));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export class Notification {
|
|
2
|
-
constructor(option) {
|
|
3
|
-
var _a, _b;
|
|
4
|
-
this.type = "message";
|
|
5
|
-
this.type = (_a = option.type) !== null && _a !== void 0 ? _a : "message";
|
|
6
|
-
this.title = option.title;
|
|
7
|
-
this.message = option.message;
|
|
8
|
-
this.targetTime = option.targetTime;
|
|
9
|
-
this.duration = (_b = option.duration) !== null && _b !== void 0 ? _b : 5000;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
export class Notification {
|
|
2
|
+
constructor(option) {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
this.type = "message";
|
|
5
|
+
this.type = (_a = option.type) !== null && _a !== void 0 ? _a : "message";
|
|
6
|
+
this.title = option.title;
|
|
7
|
+
this.message = option.message;
|
|
8
|
+
this.targetTime = option.targetTime;
|
|
9
|
+
this.duration = (_b = option.duration) !== null && _b !== void 0 ? _b : 5000;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export class SocialInfo {
|
|
2
|
-
constructor(name, url) {
|
|
3
|
-
this.name = name;
|
|
4
|
-
this.content = url;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
1
|
+
export class SocialInfo {
|
|
2
|
+
constructor(name, url) {
|
|
3
|
+
this.name = name;
|
|
4
|
+
this.content = url;
|
|
5
|
+
}
|
|
6
|
+
}
|