@widget-js/core 0.1.14 → 0.1.16
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/dist/cjs/api/AppApi.js +8 -4
- package/dist/cjs/api/BroadcastApi.js +2 -1
- package/dist/cjs/api/BrowserWindowApi.js +37 -12
- package/dist/cjs/api/Channel.js +2 -0
- package/dist/cjs/api/DialogApi.js +2 -1
- package/dist/cjs/api/ElectronApi.js +4 -2
- package/dist/cjs/api/NotificationApi.js +55 -15
- package/dist/cjs/api/WidgetApi.js +29 -7
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/model/AppNotification.js +32 -0
- package/dist/cjs/model/WidgetPackage.js +3 -5
- package/dist/cjs/model/WidgetParams.js +6 -2
- package/dist/cjs/model/event/AppKeyboardEvent.js +2 -0
- package/dist/cjs/model/event/AppMouseEvent.js +2 -0
- package/dist/cjs/utils/UrlUtils.js +15 -0
- package/dist/esm/api/AppApi.js +8 -4
- package/dist/esm/api/BroadcastApi.js +2 -1
- package/dist/esm/api/BrowserWindowApi.js +37 -12
- package/dist/esm/api/Channel.js +2 -0
- package/dist/esm/api/DialogApi.js +2 -1
- package/dist/esm/api/ElectronApi.js +4 -2
- package/dist/esm/api/NotificationApi.js +55 -15
- package/dist/esm/api/WidgetApi.js +29 -7
- package/dist/esm/index.js +3 -1
- package/dist/esm/model/AppNotification.js +28 -0
- package/dist/esm/model/WidgetPackage.js +3 -5
- package/dist/esm/model/WidgetParams.js +6 -2
- package/dist/esm/model/event/AppKeyboardEvent.js +1 -0
- package/dist/esm/model/event/AppMouseEvent.js +1 -0
- package/dist/esm/utils/UrlUtils.js +15 -0
- package/dist/types/api/BrowserWindowApi.d.ts +7 -0
- package/dist/types/api/Channel.d.ts +2 -0
- package/dist/types/api/NotificationApi.d.ts +15 -3
- package/dist/types/api/WidgetApi.d.ts +2 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/model/AppNotification.d.ts +49 -0
- package/dist/types/model/WidgetPackage.d.ts +1 -1
- package/dist/types/model/event/AppKeyboardEvent.d.ts +16 -0
- package/dist/types/model/event/AppMouseEvent.d.ts +14 -0
- package/dist/types/utils/UrlUtils.d.ts +1 -0
- package/dist/umd/index.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/model/Notification.js +0 -15
- package/dist/esm/model/Notification.js +0 -11
- package/dist/types/model/Notification.d.ts +0 -16
|
@@ -6,7 +6,8 @@ export class DialogApi {
|
|
|
6
6
|
* @param extensions 允许的文件后缀格式,如:["txt","docx","gif"]
|
|
7
7
|
*/
|
|
8
8
|
static async pickFile(extensions) {
|
|
9
|
-
|
|
9
|
+
var _a;
|
|
10
|
+
return await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.DIALOG, this.PICK_FILE, extensions));
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
DialogApi.PICK_FILE = "pick-file";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
2
|
export class ElectronApi {
|
|
3
3
|
static async addIpcListener(key, f) {
|
|
4
|
-
|
|
4
|
+
var _a;
|
|
5
|
+
await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.addIpcListener(key, f));
|
|
5
6
|
}
|
|
6
7
|
static async removeIpcListener(key) {
|
|
7
|
-
|
|
8
|
+
var _a;
|
|
9
|
+
await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.removeIpcListener(key));
|
|
8
10
|
}
|
|
9
11
|
}
|
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppNotification } from "../model/AppNotification";
|
|
2
2
|
import { Channel } from "./Channel";
|
|
3
3
|
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
4
4
|
export class NotificationApi {
|
|
5
|
-
static async
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// static async url(url: string, duration: number = -1) {
|
|
6
|
+
// ElectronUtils.getAPI()?.invoke(Channel.NOTIFICATION, new AppNotification({
|
|
7
|
+
// url, message: "",
|
|
8
|
+
// duration,
|
|
9
|
+
// type: "url",
|
|
10
|
+
// }));
|
|
11
|
+
// }
|
|
12
|
+
/**
|
|
13
|
+
* 来电
|
|
14
|
+
* @param avatar 头像地址
|
|
15
|
+
* @param audio 音频地址
|
|
16
|
+
* @param title 标题文件
|
|
17
|
+
* @param message 初始消息
|
|
18
|
+
* @param lyric 歌词字符串
|
|
19
|
+
*/
|
|
20
|
+
static async call(avatar, audio, title, message, lyric) {
|
|
21
|
+
var _a;
|
|
22
|
+
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.NOTIFICATION, new AppNotification({
|
|
23
|
+
avatar,
|
|
24
|
+
audio,
|
|
25
|
+
message,
|
|
26
|
+
title,
|
|
27
|
+
duration: -1,
|
|
28
|
+
lyric,
|
|
8
29
|
type: "call",
|
|
9
|
-
message: "下班提醒",
|
|
10
|
-
duration: duration
|
|
11
30
|
}));
|
|
12
31
|
}
|
|
13
32
|
static async advanceCountdown(message, targetTime, title) {
|
|
14
|
-
|
|
33
|
+
var _a;
|
|
34
|
+
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.NOTIFICATION, new AppNotification({
|
|
15
35
|
title,
|
|
16
36
|
message,
|
|
17
37
|
targetTime,
|
|
@@ -19,17 +39,22 @@ export class NotificationApi {
|
|
|
19
39
|
}));
|
|
20
40
|
}
|
|
21
41
|
static async countdown(message, targetTime) {
|
|
22
|
-
|
|
42
|
+
var _a;
|
|
43
|
+
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.NOTIFICATION, new AppNotification({
|
|
23
44
|
message,
|
|
24
45
|
targetTime,
|
|
46
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
47
|
+
duration: -1,
|
|
25
48
|
type: "countdown"
|
|
26
49
|
}));
|
|
27
50
|
}
|
|
28
51
|
static async success(message, duration = 5000) {
|
|
52
|
+
var _a;
|
|
29
53
|
if (ElectronUtils.hasElectronApi()) {
|
|
30
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new
|
|
54
|
+
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.NOTIFICATION, new AppNotification({
|
|
31
55
|
message,
|
|
32
56
|
type: "success",
|
|
57
|
+
icon: "check_circle_line",
|
|
33
58
|
duration
|
|
34
59
|
}));
|
|
35
60
|
}
|
|
@@ -38,10 +63,12 @@ export class NotificationApi {
|
|
|
38
63
|
}
|
|
39
64
|
}
|
|
40
65
|
static async error(message, duration = 5000) {
|
|
66
|
+
var _a;
|
|
41
67
|
if (ElectronUtils.hasElectronApi()) {
|
|
42
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new
|
|
68
|
+
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.NOTIFICATION, new AppNotification({
|
|
43
69
|
message,
|
|
44
70
|
type: "error",
|
|
71
|
+
icon: "close_circle_line",
|
|
45
72
|
duration
|
|
46
73
|
}));
|
|
47
74
|
}
|
|
@@ -50,10 +77,12 @@ export class NotificationApi {
|
|
|
50
77
|
}
|
|
51
78
|
}
|
|
52
79
|
static async warning(message, duration = 5000) {
|
|
80
|
+
var _a;
|
|
53
81
|
if (ElectronUtils.hasElectronApi()) {
|
|
54
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new
|
|
82
|
+
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.NOTIFICATION, new AppNotification({
|
|
55
83
|
message,
|
|
56
84
|
type: "warning",
|
|
85
|
+
icon: "warning_line",
|
|
57
86
|
duration
|
|
58
87
|
}));
|
|
59
88
|
}
|
|
@@ -61,16 +90,27 @@ export class NotificationApi {
|
|
|
61
90
|
this.callback("warning", message, duration);
|
|
62
91
|
}
|
|
63
92
|
}
|
|
64
|
-
static async
|
|
93
|
+
static async info(message, duration = 5000) {
|
|
94
|
+
var _a;
|
|
65
95
|
if (ElectronUtils.hasElectronApi()) {
|
|
66
|
-
ElectronUtils.getAPI().invoke(Channel.NOTIFICATION, new
|
|
96
|
+
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.NOTIFICATION, new AppNotification({
|
|
67
97
|
message,
|
|
68
|
-
type: "
|
|
98
|
+
type: "info",
|
|
99
|
+
icon: "information_line",
|
|
69
100
|
duration
|
|
70
101
|
}));
|
|
71
102
|
}
|
|
72
103
|
else {
|
|
73
|
-
this.callback("
|
|
104
|
+
this.callback("info", message, duration);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 隐藏通知
|
|
109
|
+
*/
|
|
110
|
+
static async hide() {
|
|
111
|
+
var _a;
|
|
112
|
+
if (ElectronUtils.hasElectronApi()) {
|
|
113
|
+
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.NOTIFICATION, null);
|
|
74
114
|
}
|
|
75
115
|
}
|
|
76
116
|
static setDebugNotification(callback) {
|
|
@@ -8,13 +8,16 @@ import { BroadcastApi } from "./BroadcastApi";
|
|
|
8
8
|
import localforage from "localforage";
|
|
9
9
|
export class WidgetApi {
|
|
10
10
|
static async registerWidgets(widgets) {
|
|
11
|
-
|
|
11
|
+
var _a;
|
|
12
|
+
await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.WIDGET, this.REGISTER_WIDGETS, JSON.stringify(widgets)));
|
|
12
13
|
}
|
|
13
14
|
static async registerWidgetPackage(widgetPackage) {
|
|
14
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.WIDGET, this.REGISTER_WIDGET_PACKAGE, JSON.stringify(widgetPackage)));
|
|
15
17
|
}
|
|
16
18
|
static async getWidgets() {
|
|
17
|
-
|
|
19
|
+
var _a;
|
|
20
|
+
const data = await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.WIDGET, this.GET_WIDGETS));
|
|
18
21
|
const widgets = [];
|
|
19
22
|
if (data) {
|
|
20
23
|
const arr = JSON.parse(data);
|
|
@@ -25,28 +28,32 @@ export class WidgetApi {
|
|
|
25
28
|
return widgets;
|
|
26
29
|
}
|
|
27
30
|
static async getWidgetPackages() {
|
|
28
|
-
|
|
31
|
+
var _a;
|
|
32
|
+
return await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.WIDGET, this.GET_WIDGET_PACKAGES));
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
31
35
|
*
|
|
32
36
|
* @param name package name
|
|
33
37
|
*/
|
|
34
38
|
static async getWidget(name) {
|
|
35
|
-
|
|
39
|
+
var _a;
|
|
40
|
+
return Widget.parseObject(await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.WIDGET, this.GET_WIDGET, name)));
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
38
43
|
*
|
|
39
44
|
* @param name package name
|
|
40
45
|
*/
|
|
41
46
|
static async getWidgetPackage(name) {
|
|
42
|
-
|
|
47
|
+
var _a;
|
|
48
|
+
return WidgetPackage.parseObject(await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.WIDGET, this.GET_WIDGET_PACKAGE, name)));
|
|
43
49
|
}
|
|
44
50
|
/**
|
|
45
51
|
* 移除组件
|
|
46
52
|
* @param id
|
|
47
53
|
*/
|
|
48
54
|
static async removeHostedWidget(id) {
|
|
49
|
-
|
|
55
|
+
var _a;
|
|
56
|
+
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.WIDGET, this.REMOVE_HOSTED_WIDGET, id);
|
|
50
57
|
}
|
|
51
58
|
/**
|
|
52
59
|
* 获取组件配置地址
|
|
@@ -61,6 +68,21 @@ export class WidgetApi {
|
|
|
61
68
|
return null;
|
|
62
69
|
return UrlUtils.getWidgetUrl(widget.configUrl, widgetPackage, widgetParams);
|
|
63
70
|
}
|
|
71
|
+
static async getWidgetUrl(widgetName, widgetParams) {
|
|
72
|
+
const widget = await this.getWidget(widgetName);
|
|
73
|
+
if (!widget || widget.configUrl == null)
|
|
74
|
+
return null;
|
|
75
|
+
const widgetPackage = await this.getWidgetPackage(widget.packageName);
|
|
76
|
+
if (!widgetPackage)
|
|
77
|
+
return null;
|
|
78
|
+
return UrlUtils.getWidgetUrl(widget.url, widgetPackage, widgetParams);
|
|
79
|
+
}
|
|
80
|
+
static async getWidgetPackageUrl(packageName, hash) {
|
|
81
|
+
const widgetPackage = await this.getWidgetPackage(packageName);
|
|
82
|
+
if (!widgetPackage)
|
|
83
|
+
return null;
|
|
84
|
+
return widgetPackage.getFullUrl(hash);
|
|
85
|
+
}
|
|
64
86
|
/**
|
|
65
87
|
* 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
|
|
66
88
|
* @param data
|
package/dist/esm/index.js
CHANGED
|
@@ -3,9 +3,11 @@ export * from "./model/event/BroadcastEvent";
|
|
|
3
3
|
export * from "./model/event/WebSocketEvent";
|
|
4
4
|
export * from "./model/WidgetData";
|
|
5
5
|
export * from "./model/WidgetParams";
|
|
6
|
-
export * from "./model/
|
|
6
|
+
export * from "./model/AppNotification";
|
|
7
7
|
export * from "./model/HostedMode";
|
|
8
8
|
export * from "./model/interface/Rectangle";
|
|
9
|
+
export * from "./model/event/AppKeyboardEvent";
|
|
10
|
+
export * from "./model/event/AppMouseEvent";
|
|
9
11
|
export * from "./model/WidgetPackage";
|
|
10
12
|
export * from "./api/ElectronApi";
|
|
11
13
|
export * from "./repository/WidgetDataRepository";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export var NotificationSize;
|
|
2
|
+
(function (NotificationSize) {
|
|
3
|
+
NotificationSize["SMALL"] = "small";
|
|
4
|
+
NotificationSize["NORMAL"] = "normal";
|
|
5
|
+
NotificationSize["LARGE"] = "large";
|
|
6
|
+
})(NotificationSize || (NotificationSize = {}));
|
|
7
|
+
export class AppNotification {
|
|
8
|
+
constructor(option) {
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
10
|
+
this.type = "info";
|
|
11
|
+
this.type = (_a = option.type) !== null && _a !== void 0 ? _a : "info";
|
|
12
|
+
this.title = option.title;
|
|
13
|
+
this.message = option.message;
|
|
14
|
+
this.targetTime = option.targetTime;
|
|
15
|
+
this.duration = (_b = option.duration) !== null && _b !== void 0 ? _b : 5000;
|
|
16
|
+
this.icon = option.icon;
|
|
17
|
+
this.color = (_c = option.color) !== null && _c !== void 0 ? _c : "#5D8AC8";
|
|
18
|
+
this.confirmButtonText = option.confirmButtonText;
|
|
19
|
+
this.cancelButtonText = option.cancelButtonText;
|
|
20
|
+
this.cancelBroadcast = option.cancelBroadcast;
|
|
21
|
+
this.confirmBroadcast = option.confirmBroadcast;
|
|
22
|
+
this.size = (_d = option.size) !== null && _d !== void 0 ? _d : NotificationSize.NORMAL;
|
|
23
|
+
this.audio = option.audio;
|
|
24
|
+
this.avatar = option.avatar;
|
|
25
|
+
this.lyric = option.lyric;
|
|
26
|
+
this.backgroundColor = (_e = option.backgroundColor) !== null && _e !== void 0 ? _e : '#000000';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UrlUtils } from "../utils/UrlUtils";
|
|
1
2
|
export class WidgetPackage {
|
|
2
3
|
constructor() {
|
|
3
4
|
/**
|
|
@@ -19,10 +20,7 @@ export class WidgetPackage {
|
|
|
19
20
|
* 如果url是http链接,直接返回链接
|
|
20
21
|
* 如果是本地组件:file://链接,则返回 url+entry,e.g. file://C:\users\neo\desktop\index.html#
|
|
21
22
|
*/
|
|
22
|
-
getFullUrl() {
|
|
23
|
-
|
|
24
|
-
return this.url;
|
|
25
|
-
}
|
|
26
|
-
return this.url + (this.entry.startsWith("/") ? this.entry : `/${this.entry}`);
|
|
23
|
+
getFullUrl(hash) {
|
|
24
|
+
return UrlUtils.getWidgetPackageUrl(this.url, this.entry, hash == null ? this.hash : hash);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -32,8 +32,12 @@ export class WidgetParams {
|
|
|
32
32
|
*/
|
|
33
33
|
static fromCurrentLocation() {
|
|
34
34
|
const href = window.location.href;
|
|
35
|
-
let
|
|
36
|
-
|
|
35
|
+
let strings = href.split("?");
|
|
36
|
+
if (strings.length > 1) {
|
|
37
|
+
let queryString = strings[1];
|
|
38
|
+
return this.fromObject(parseQuery(queryString));
|
|
39
|
+
}
|
|
40
|
+
return new WidgetParams();
|
|
37
41
|
}
|
|
38
42
|
static setValue(widgetEnv, key, value) {
|
|
39
43
|
const keyWithoutPrefix = key.replace(this.PARAM_PREFIX, "");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,4 +14,19 @@ export class UrlUtils {
|
|
|
14
14
|
return url + "?" + widgetParams.toUrlParams().toString();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
static getWidgetPackageUrl(url, entry, hash) {
|
|
18
|
+
const arr = [url];
|
|
19
|
+
if (url.startsWith("http")) {
|
|
20
|
+
if (hash) {
|
|
21
|
+
arr.push(url.endsWith("/") ? "#" : "/#");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
arr.push(entry.startsWith("/") ? entry : `/${entry}`);
|
|
26
|
+
if (hash) {
|
|
27
|
+
arr.push(url.endsWith("#") ? "" : "#");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return arr.join("");
|
|
31
|
+
}
|
|
17
32
|
}
|
|
@@ -16,7 +16,14 @@ export declare class BrowserWindowApi {
|
|
|
16
16
|
static readonly SET_RESIZABLE = "set-resizable";
|
|
17
17
|
static readonly GET_BOUNDS = "get-bounds";
|
|
18
18
|
static readonly SET_BOUNDS = "set-bounds";
|
|
19
|
+
static readonly SHOW = "show";
|
|
19
20
|
static setIgnoreMouseEvent(ignore: boolean): Promise<void>;
|
|
21
|
+
static show(): Promise<void>;
|
|
22
|
+
static hide(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated
|
|
25
|
+
* @param show
|
|
26
|
+
*/
|
|
20
27
|
static setWindowVisibility(show: boolean): Promise<void>;
|
|
21
28
|
static setAlwaysOnTop(alwaysOnTop: boolean): Promise<void>;
|
|
22
29
|
static isAlwaysOnTop(): Promise<boolean>;
|
|
@@ -4,5 +4,7 @@ export declare enum Channel {
|
|
|
4
4
|
BROADCAST = "channel::cn.widgetjs.core.broadcast",
|
|
5
5
|
WIDGET = "channel::cn.widgetjs.core.widget",
|
|
6
6
|
APP = "channel::cn.widgetjs.core.app",
|
|
7
|
+
MOUSE_EVENT = "channel::cn.widgetjs.core.mouse_event",
|
|
8
|
+
KEYBOARD_EVENT = "channel::cn.widgetjs.core.keyboard_event",
|
|
7
9
|
DIALOG = "channel::cn.widgetjs.core.dialog"
|
|
8
10
|
}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import { NotificationType } from "../model/
|
|
1
|
+
import { NotificationType } from "../model/AppNotification";
|
|
2
2
|
type NotificationCallback = (type: NotificationType, message: string, duration: number) => void;
|
|
3
3
|
export declare class NotificationApi {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 来电
|
|
6
|
+
* @param avatar 头像地址
|
|
7
|
+
* @param audio 音频地址
|
|
8
|
+
* @param title 标题文件
|
|
9
|
+
* @param message 初始消息
|
|
10
|
+
* @param lyric 歌词字符串
|
|
11
|
+
*/
|
|
12
|
+
static call(avatar: string, audio: string, title: string, message: string, lyric: string): Promise<void>;
|
|
5
13
|
static advanceCountdown(message: string, targetTime: string, title?: string): Promise<void>;
|
|
6
14
|
static countdown(message: string, targetTime: string): Promise<void>;
|
|
7
15
|
static success(message: string, duration?: number): Promise<void>;
|
|
8
16
|
static error(message: string, duration?: number): Promise<void>;
|
|
9
17
|
static warning(message: string, duration?: number): Promise<void>;
|
|
10
|
-
static
|
|
18
|
+
static info(message: string, duration?: number): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* 隐藏通知
|
|
21
|
+
*/
|
|
22
|
+
static hide(): Promise<void>;
|
|
11
23
|
private static callback;
|
|
12
24
|
static setDebugNotification(callback: NotificationCallback): void;
|
|
13
25
|
}
|
|
@@ -38,6 +38,8 @@ export declare class WidgetApi {
|
|
|
38
38
|
* @param widgetName
|
|
39
39
|
*/
|
|
40
40
|
static getWidgetConfigUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
41
|
+
static getWidgetUrl(widgetName: string, widgetParams: WidgetParams): Promise<string | null>;
|
|
42
|
+
static getWidgetPackageUrl(packageName: string, hash?: boolean): Promise<string | null>;
|
|
41
43
|
/**
|
|
42
44
|
* 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
|
|
43
45
|
* @param data
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ export * from "./model/event/BroadcastEvent";
|
|
|
3
3
|
export * from "./model/event/WebSocketEvent";
|
|
4
4
|
export * from "./model/WidgetData";
|
|
5
5
|
export * from "./model/WidgetParams";
|
|
6
|
-
export * from "./model/
|
|
6
|
+
export * from "./model/AppNotification";
|
|
7
7
|
export * from "./model/HostedMode";
|
|
8
8
|
export * from "./model/interface/Rectangle";
|
|
9
|
+
export * from "./model/event/AppKeyboardEvent";
|
|
10
|
+
export * from "./model/event/AppMouseEvent";
|
|
9
11
|
export * from "./model/WidgetPackage";
|
|
10
12
|
export * from "./api/ElectronApi";
|
|
11
13
|
export * from "./repository/WidgetDataRepository";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type NotificationType = "countdown" | "advance-countdown" | "error" | "success" | "warning" | "info" | "reminder" | "url" | "call";
|
|
2
|
+
export declare enum NotificationSize {
|
|
3
|
+
SMALL = "small",
|
|
4
|
+
NORMAL = "normal",
|
|
5
|
+
LARGE = "large"
|
|
6
|
+
}
|
|
7
|
+
export interface NotificationOption {
|
|
8
|
+
type?: NotificationType;
|
|
9
|
+
title?: string;
|
|
10
|
+
message: string;
|
|
11
|
+
targetTime?: string;
|
|
12
|
+
duration?: number;
|
|
13
|
+
/**
|
|
14
|
+
* 图片名,目前只支持mingcute图标。
|
|
15
|
+
* https://www.mingcute.com/
|
|
16
|
+
*/
|
|
17
|
+
icon?: string;
|
|
18
|
+
color?: string;
|
|
19
|
+
confirmButtonText?: string;
|
|
20
|
+
cancelButtonText?: string;
|
|
21
|
+
cancelBroadcast?: string;
|
|
22
|
+
confirmBroadcast?: string;
|
|
23
|
+
size?: NotificationSize;
|
|
24
|
+
url?: string;
|
|
25
|
+
avatar?: string;
|
|
26
|
+
audio?: string;
|
|
27
|
+
lyric?: string;
|
|
28
|
+
backgroundColor?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class AppNotification {
|
|
31
|
+
type: NotificationType;
|
|
32
|
+
message: string;
|
|
33
|
+
title?: string;
|
|
34
|
+
targetTime?: string;
|
|
35
|
+
duration: number;
|
|
36
|
+
icon?: string;
|
|
37
|
+
color?: string;
|
|
38
|
+
backgroundColor?: string;
|
|
39
|
+
confirmButtonText?: string;
|
|
40
|
+
cancelButtonText?: string;
|
|
41
|
+
cancelBroadcast?: string;
|
|
42
|
+
confirmBroadcast?: string;
|
|
43
|
+
size: NotificationSize;
|
|
44
|
+
url?: string;
|
|
45
|
+
avatar?: string;
|
|
46
|
+
audio?: string;
|
|
47
|
+
lyric?: string;
|
|
48
|
+
constructor(option: NotificationOption);
|
|
49
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface AppKeyboardEvent {
|
|
2
|
+
scanCode: number;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
isKeyDown: boolean;
|
|
5
|
+
isKeyUp: boolean;
|
|
6
|
+
isExtendedKey: boolean;
|
|
7
|
+
alt: boolean;
|
|
8
|
+
control: boolean;
|
|
9
|
+
handled: boolean;
|
|
10
|
+
keyCode: number;
|
|
11
|
+
keyValue: number;
|
|
12
|
+
keyData: number;
|
|
13
|
+
modifiers: number;
|
|
14
|
+
shift: boolean;
|
|
15
|
+
suppressKeyPress: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AppMouseEvent {
|
|
2
|
+
handled: boolean;
|
|
3
|
+
wheelScrolled: boolean;
|
|
4
|
+
clicked: boolean;
|
|
5
|
+
isMouseButtonDown: boolean;
|
|
6
|
+
isMouseButtonUp: boolean;
|
|
7
|
+
timestamp: number;
|
|
8
|
+
button: number;
|
|
9
|
+
clicks: number;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
delta: number;
|
|
13
|
+
location: string;
|
|
14
|
+
}
|
|
@@ -2,4 +2,5 @@ import { WidgetPackage } from "../model/WidgetPackage";
|
|
|
2
2
|
import { WidgetParams } from "../model/WidgetParams";
|
|
3
3
|
export declare class UrlUtils {
|
|
4
4
|
static getWidgetUrl(widgetUrl: string, widgetPackage: WidgetPackage, widgetParams: WidgetParams): string;
|
|
5
|
+
static getWidgetPackageUrl(url: string, entry: string, hash: boolean): string;
|
|
5
6
|
}
|