@widget-js/core 0.1.29 → 0.5.5
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 +25 -23
- package/dist/cjs/api/BaseApi.js +13 -0
- package/dist/cjs/api/BroadcastApi.js +14 -13
- package/dist/cjs/api/BrowserWindowApi.js +58 -63
- package/dist/cjs/api/Channel.js +3 -4
- package/dist/cjs/api/ClipboardApi.js +16 -11
- package/dist/cjs/api/DeviceApi.js +16 -7
- package/dist/cjs/api/DialogApi.js +8 -6
- package/dist/cjs/api/HostedWidgetApi.js +24 -36
- package/dist/cjs/api/LogApi.js +14 -10
- package/dist/cjs/api/NotificationApi.js +44 -70
- package/dist/cjs/api/ShortcutApi.js +23 -0
- package/dist/cjs/api/WidgetApi.js +46 -39
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/lang/LanguageCode.js +34 -0
- package/dist/cjs/model/Widget.js +4 -4
- package/dist/cjs/model/WidgetPackage.js +49 -2
- package/dist/cjs/model/event/BroadcastEvent.js +4 -8
- package/dist/cjs/model/msic/graphics.js +2 -0
- package/dist/cjs/repository/WidgetDataRepository.js +11 -5
- package/dist/cjs/utils/ElectronUtils.js +5 -1
- package/dist/cjs/utils/LanguageUtils.js +38 -0
- package/dist/esm/api/AppApi.js +24 -22
- package/dist/esm/api/BaseApi.js +9 -0
- package/dist/esm/api/BroadcastApi.js +13 -12
- package/dist/esm/api/BrowserWindowApi.js +56 -62
- package/dist/esm/api/Channel.js +3 -4
- package/dist/esm/api/ClipboardApi.js +15 -10
- package/dist/esm/api/DeviceApi.js +15 -6
- package/dist/esm/api/DialogApi.js +9 -6
- package/dist/esm/api/HostedWidgetApi.js +23 -35
- package/dist/esm/api/LogApi.js +15 -10
- package/dist/esm/api/NotificationApi.js +45 -70
- package/dist/esm/api/ShortcutApi.js +19 -0
- package/dist/esm/api/WidgetApi.js +45 -38
- package/dist/esm/index.js +2 -1
- package/dist/esm/lang/LanguageCode.js +33 -0
- package/dist/esm/model/Widget.js +4 -4
- package/dist/esm/model/WidgetPackage.js +49 -2
- package/dist/esm/model/event/BroadcastEvent.js +4 -8
- package/dist/esm/model/msic/graphics.js +1 -0
- package/dist/esm/repository/WidgetDataRepository.js +11 -5
- package/dist/esm/utils/ElectronUtils.js +5 -1
- package/dist/esm/utils/LanguageUtils.js +34 -0
- package/dist/types/api/AppApi.d.ts +23 -11
- package/dist/types/api/BaseApi.d.ts +5 -0
- package/dist/types/api/BroadcastApi.d.ts +19 -4
- package/dist/types/api/BrowserWindowApi.d.ts +56 -46
- package/dist/types/api/Channel.d.ts +4 -5
- package/dist/types/api/ClipboardApi.d.ts +9 -5
- package/dist/types/api/DeviceApi.d.ts +16 -7
- package/dist/types/api/DialogApi.d.ts +5 -7
- package/dist/types/api/HostedWidgetApi.d.ts +24 -18
- package/dist/types/api/LogApi.d.ts +8 -5
- package/dist/types/api/NotificationApi.d.ts +21 -16
- package/dist/types/api/ShortcutApi.d.ts +10 -0
- package/dist/types/api/WidgetApi.d.ts +39 -20
- package/dist/types/index.d.ts +2 -1
- package/dist/types/lang/LanguageCode.d.ts +40 -0
- package/dist/types/model/Widget.d.ts +7 -9
- package/dist/types/model/WidgetPackage.d.ts +55 -12
- package/dist/types/model/event/BroadcastEvent.d.ts +14 -10
- package/dist/types/model/msic/graphics.d.ts +8 -0
- package/dist/types/utils/ElectronUtils.d.ts +2 -1
- package/dist/types/utils/LanguageUtils.d.ts +8 -0
- package/dist/umd/index.js +1 -1
- package/package.json +15 -15
- package/dist/cjs/api/GlobalShortcutApi.js +0 -29
- package/dist/esm/api/GlobalShortcutApi.js +0 -25
- package/dist/types/api/GlobalShortcutApi.d.ts +0 -14
package/dist/esm/api/AppApi.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
1
|
import { Channel } from "./Channel";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
var AppApiEvent;
|
|
4
|
+
(function (AppApiEvent) {
|
|
5
|
+
AppApiEvent["CONFIG_CHANGED"] = "event::cn.widgetjs.core.app.config.changed";
|
|
6
|
+
})(AppApiEvent || (AppApiEvent = {}));
|
|
7
|
+
class AppApiImpl extends BaseApi {
|
|
8
|
+
getChannel() {
|
|
9
|
+
return Channel.APP;
|
|
7
10
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
async setConfig(key, value) {
|
|
12
|
+
return await this.invokeMethod('setConfig', key, value);
|
|
13
|
+
}
|
|
14
|
+
async getConfig(key, defaultValue) {
|
|
15
|
+
const value = await this.invokeMethod("getConfig", key);
|
|
11
16
|
if (value === null || value === undefined) {
|
|
12
17
|
return defaultValue;
|
|
13
18
|
}
|
|
@@ -19,24 +24,21 @@ export class AppApi {
|
|
|
19
24
|
}
|
|
20
25
|
return value;
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.APP, this.OPEN_ADD_WIDGET_WINDOW);
|
|
27
|
+
async openAddWidgetWindow() {
|
|
28
|
+
return this.invokeMethod('openAddWidgetWindow');
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* 获取应用版本号,格式为 x.y.z
|
|
28
32
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
async getVersion() {
|
|
34
|
+
return this.invokeMethod('getVersion');
|
|
35
|
+
}
|
|
36
|
+
async getPreloadPath() {
|
|
37
|
+
return this.invokeMethod('getPreloadPath');
|
|
32
38
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.APP, this.OPEN_SETTING_WINDOW);
|
|
39
|
+
async openSettingWindow() {
|
|
40
|
+
return this.invokeMethod('openSettingWindow');
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
|
-
AppApi
|
|
39
|
-
AppApi
|
|
40
|
-
AppApi.OPEN_ADD_WIDGET_WINDOW = "open-add-widget-window";
|
|
41
|
-
AppApi.OPEN_SETTING_WINDOW = "open-setting-window";
|
|
42
|
-
AppApi.GET_VERSION = "get-version";
|
|
43
|
+
const AppApi = new AppApiImpl();
|
|
44
|
+
export { AppApi, AppApiEvent };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
|
+
export class BaseApi {
|
|
3
|
+
async invokeMethod(method, ...args) {
|
|
4
|
+
return await ElectronUtils.invokeMethod(this.getChannel(), method, ...args);
|
|
5
|
+
}
|
|
6
|
+
async invoke(...args) {
|
|
7
|
+
return await ElectronUtils.invoke(this.getChannel(), ...args);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
1
|
import { Channel } from "./Channel";
|
|
3
|
-
import {
|
|
4
|
-
export class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.BROADCAST, JSON.stringify(event)));
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
export class BroadcastApiImpl extends BaseApi {
|
|
4
|
+
async send(event) {
|
|
5
|
+
await this.invokeMethod('send', event);
|
|
8
6
|
}
|
|
9
|
-
|
|
10
|
-
await
|
|
11
|
-
callback(JSON.parse(json));
|
|
12
|
-
});
|
|
7
|
+
async register(...event) {
|
|
8
|
+
await this.invokeMethod('register', event);
|
|
13
9
|
}
|
|
14
|
-
|
|
15
|
-
await
|
|
10
|
+
async unregister(...event) {
|
|
11
|
+
await this.invokeMethod('unregister', event);
|
|
12
|
+
}
|
|
13
|
+
getChannel() {
|
|
14
|
+
return Channel.BROADCAST;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
17
|
+
const BroadcastApi = new BroadcastApiImpl();
|
|
18
|
+
export { BroadcastApi };
|
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
import { Channel } from "./Channel";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
var BrowserWindowApiEvent;
|
|
4
|
+
(function (BrowserWindowApiEvent) {
|
|
5
|
+
BrowserWindowApiEvent["BLUR"] = "event::cn.widgetjs.core.browser-window.blur";
|
|
6
|
+
BrowserWindowApiEvent["FOCUS"] = "event::cn.widgetjs.core.browser-window.focus";
|
|
7
|
+
})(BrowserWindowApiEvent || (BrowserWindowApiEvent = {}));
|
|
8
|
+
export class BrowserWindowApiImpl extends BaseApi {
|
|
9
|
+
getChannel() {
|
|
10
|
+
return Channel.BROWSER_WINDOW;
|
|
6
11
|
}
|
|
7
|
-
|
|
8
|
-
await
|
|
12
|
+
async setIgnoreMouseEvent(ignore) {
|
|
13
|
+
await this.invokeMethod('setIgnoreMouseEvent', ignore);
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
await
|
|
15
|
+
async show() {
|
|
16
|
+
await this.invokeMethod('show', true);
|
|
12
17
|
}
|
|
13
|
-
|
|
14
|
-
await
|
|
18
|
+
async showInactive() {
|
|
19
|
+
await this.invokeMethod('showInactive', true);
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
await ElectronUtils.invoke(Channel.BROWSER_WINDOW, this.WINDOW_VISIBILITY, show);
|
|
21
|
+
async hide() {
|
|
22
|
+
await this.invokeMethod('hide', false);
|
|
23
|
+
}
|
|
24
|
+
async center() {
|
|
25
|
+
await this.invokeMethod('center', false);
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
await
|
|
27
|
+
async setAlwaysOnTop(alwaysOnTop) {
|
|
28
|
+
await this.invokeMethod('setAlwaysOnTop', alwaysOnTop);
|
|
25
29
|
}
|
|
26
|
-
|
|
27
|
-
return await
|
|
30
|
+
async isAlwaysOnTop() {
|
|
31
|
+
return await this.invokeMethod('isAlwaysOnTop');
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
await
|
|
33
|
+
async openUrl(url) {
|
|
34
|
+
await this.invokeMethod('openUrl', url);
|
|
31
35
|
}
|
|
32
|
-
|
|
33
|
-
await
|
|
36
|
+
async moveTop() {
|
|
37
|
+
await this.invokeMethod('moveTop');
|
|
34
38
|
}
|
|
35
|
-
|
|
36
|
-
await
|
|
39
|
+
async openDevTools() {
|
|
40
|
+
await this.invokeMethod('openDevTools');
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* 设置窗口位置
|
|
@@ -41,57 +45,47 @@ export class BrowserWindowApi {
|
|
|
41
45
|
* @param y
|
|
42
46
|
* @param animation 动画只在mac系统有效
|
|
43
47
|
*/
|
|
44
|
-
|
|
45
|
-
await
|
|
48
|
+
async setPosition(x, y, animation) {
|
|
49
|
+
await this.invokeMethod('setPosition', x, y, animation);
|
|
46
50
|
}
|
|
47
|
-
|
|
48
|
-
return await
|
|
51
|
+
async getPosition() {
|
|
52
|
+
return await this.invokeMethod('getPosition');
|
|
49
53
|
}
|
|
50
|
-
|
|
51
|
-
return await
|
|
54
|
+
async blur() {
|
|
55
|
+
return await this.invokeMethod('blur');
|
|
52
56
|
}
|
|
53
|
-
|
|
54
|
-
return await
|
|
57
|
+
async focus() {
|
|
58
|
+
return await this.invokeMethod('focus');
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
61
|
* 设置窗口是否可以拉伸
|
|
58
62
|
* @param resizable
|
|
59
63
|
*/
|
|
60
|
-
|
|
61
|
-
return await
|
|
64
|
+
async setResizable(resizable) {
|
|
65
|
+
return await this.invokeMethod('setResizable', resizable);
|
|
66
|
+
}
|
|
67
|
+
async getBounds() {
|
|
68
|
+
return await this.invokeMethod('getBounds');
|
|
69
|
+
}
|
|
70
|
+
async setBounds(bounds, animate) {
|
|
71
|
+
return await this.invokeMethod("setBounds", bounds, animate);
|
|
62
72
|
}
|
|
63
|
-
|
|
64
|
-
return await
|
|
73
|
+
async alignToScreen(align) {
|
|
74
|
+
return await this.invokeMethod('alignToScreen', align);
|
|
65
75
|
}
|
|
66
|
-
|
|
67
|
-
return await
|
|
76
|
+
async startDraggingWindow() {
|
|
77
|
+
return await this.invokeMethod('startDraggingWindow');
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
return await
|
|
79
|
+
async stopDraggingWindow() {
|
|
80
|
+
return await this.invokeMethod('stopDraggingWindow');
|
|
71
81
|
}
|
|
72
82
|
/**
|
|
73
83
|
* 通过url检测窗口是否存在
|
|
74
84
|
* @param url
|
|
75
85
|
*/
|
|
76
|
-
|
|
77
|
-
return await
|
|
86
|
+
async existsByUrl(url) {
|
|
87
|
+
return await this.invokeMethod('existsByUrl', url);
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
|
-
BrowserWindowApi
|
|
81
|
-
BrowserWindowApi
|
|
82
|
-
BrowserWindowApi.CENTER = "center";
|
|
83
|
-
BrowserWindowApi.ALWAYS_ON_TOP = "always-on-top";
|
|
84
|
-
BrowserWindowApi.IS_ALWAYS_ON_TOP = "is-always-on-top";
|
|
85
|
-
BrowserWindowApi.OPEN_URL = "open-url";
|
|
86
|
-
BrowserWindowApi.MOVE_TOP = "move-top";
|
|
87
|
-
BrowserWindowApi.OPEN_DEV_TOOLS = "open-dev-tools";
|
|
88
|
-
BrowserWindowApi.SET_POSITION = "set-position";
|
|
89
|
-
BrowserWindowApi.GET_POSITION = "get-position";
|
|
90
|
-
BrowserWindowApi.BLUR = "blur";
|
|
91
|
-
BrowserWindowApi.FOCUS = "focus";
|
|
92
|
-
BrowserWindowApi.SET_RESIZABLE = "set-resizable";
|
|
93
|
-
BrowserWindowApi.GET_BOUNDS = "get-bounds";
|
|
94
|
-
BrowserWindowApi.SET_BOUNDS = "set-bounds";
|
|
95
|
-
BrowserWindowApi.ALIGN_TO_SCREEN = "align-to-screen";
|
|
96
|
-
BrowserWindowApi.EXISTS_BY_URL = "exists-by-url";
|
|
97
|
-
BrowserWindowApi.SHOW = "show";
|
|
90
|
+
const BrowserWindowApi = new BrowserWindowApiImpl();
|
|
91
|
+
export { BrowserWindowApi, BrowserWindowApiEvent };
|
package/dist/esm/api/Channel.js
CHANGED
|
@@ -6,13 +6,12 @@ export var Channel;
|
|
|
6
6
|
Channel["WIDGET"] = "channel::cn.widgetjs.core.widget";
|
|
7
7
|
Channel["HOSTED_WIDGET"] = "channel::cn.widgetjs.core.hosted_widget";
|
|
8
8
|
Channel["APP"] = "channel::cn.widgetjs.core.app";
|
|
9
|
-
Channel["MOUSE_EVENT"] = "channel::cn.widgetjs.core.mouse_event";
|
|
10
|
-
Channel["KEYBOARD_EVENT"] = "channel::cn.widgetjs.core.keyboard_event";
|
|
11
9
|
Channel["DIALOG"] = "channel::cn.widgetjs.core.dialog";
|
|
12
10
|
Channel["CLIPBOARD"] = "channel::cn.widgetjs.core.clipboard";
|
|
13
|
-
Channel["DEVICE"] = "channel::cn.widgetjs.core.device";
|
|
14
|
-
Channel["KEYBOARD"] = "channel::cn.widgetjs.core.keyboard";
|
|
15
11
|
Channel["SCREEN"] = "channel::cn.widgetjs.core.screen";
|
|
16
12
|
Channel["SHORTCUT"] = "channel::cn.widgetjs.core.shortcut";
|
|
17
13
|
Channel["LOG"] = "channel::cn.widgetjs.core.log";
|
|
14
|
+
Channel["DEVICE"] = "channel::cn.widgetjs.core.device";
|
|
15
|
+
Channel["MOUSE"] = "channel::cn.widgetjs.core.mouse";
|
|
16
|
+
Channel["KEYBOARD"] = "channel::cn.widgetjs.core.keyboard";
|
|
18
17
|
})(Channel || (Channel = {}));
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
1
|
import { Channel } from "./Channel";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
var ClipboardApiEvent;
|
|
4
|
+
(function (ClipboardApiEvent) {
|
|
5
|
+
ClipboardApiEvent["CHANGED"] = "clipboard-changed";
|
|
6
|
+
})(ClipboardApiEvent || (ClipboardApiEvent = {}));
|
|
7
|
+
class ClipboardApiImpl extends BaseApi {
|
|
8
|
+
async getSelectedText() {
|
|
9
|
+
return this.invokeMethod('getSelectedText');
|
|
7
10
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
async getText() {
|
|
12
|
+
return this.invokeMethod('getText');
|
|
13
|
+
}
|
|
14
|
+
getChannel() {
|
|
15
|
+
return Channel.CLIPBOARD;
|
|
11
16
|
}
|
|
12
17
|
}
|
|
13
|
-
ClipboardApi
|
|
14
|
-
ClipboardApi
|
|
18
|
+
const ClipboardApi = new ClipboardApiImpl();
|
|
19
|
+
export { ClipboardApi, ClipboardApiEvent };
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
1
|
import { Channel } from "./Channel";
|
|
3
|
-
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
export class DeviceApiImpl extends BaseApi {
|
|
4
4
|
/**
|
|
5
5
|
* 获取当前鼠标位置
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
async getCursorScreenPoint() {
|
|
8
|
+
return this.invokeMethod('getCursorScreenPoint');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 判断是否所有按键都已经释放
|
|
12
|
+
*/
|
|
13
|
+
async isAllKeyReleased() {
|
|
14
|
+
return this.invokeMethod('isAllKeyReleased');
|
|
15
|
+
}
|
|
16
|
+
getChannel() {
|
|
17
|
+
return Channel.DEVICE;
|
|
10
18
|
}
|
|
11
19
|
}
|
|
12
|
-
DeviceApi
|
|
20
|
+
const DeviceApi = new DeviceApiImpl();
|
|
21
|
+
export { DeviceApi };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
1
|
import { Channel } from "./Channel";
|
|
3
|
-
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
class DialogApiImpl extends BaseApi {
|
|
4
|
+
getChannel() {
|
|
5
|
+
return Channel.DIALOG;
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* 选取单个文件
|
|
6
9
|
* @param extensions 允许的文件后缀格式,如:["txt","docx","gif"]
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.DIALOG, this.PICK_FILE, extensions));
|
|
11
|
+
pickFile(extensions) {
|
|
12
|
+
return this.invokeMethod('pickFile', extensions);
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
|
-
DialogApi
|
|
15
|
+
const DialogApi = new DialogApiImpl();
|
|
16
|
+
export { DialogApi, };
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import { ElectronUtils } from "../utils/ElectronUtils";
|
|
2
1
|
import { Channel } from "./Channel";
|
|
3
|
-
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
export class HostedWidgetApiImpl extends BaseApi {
|
|
4
|
+
getChannel() {
|
|
5
|
+
return Channel.HOSTED_WIDGET;
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* 移除组件
|
|
6
9
|
* @param id
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.HOSTED_WIDGET, this.REMOVE_HOSTED_WIDGET, id);
|
|
11
|
+
async removeHostedWidget(id) {
|
|
12
|
+
return this.invokeMethod('removeHostedWidget', id);
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* 通过组件名移除已添加的组件
|
|
14
16
|
* @param name 组件名
|
|
15
17
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.HOSTED_WIDGET, this.REMOVE_HOSTED_WIDGET_BY_NAME, name);
|
|
18
|
+
async removeHostedWidgetByName(name) {
|
|
19
|
+
return this.invokeMethod('removeHostedWidgetByName', name);
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* 获取已添加的组件
|
|
22
23
|
* @param name 组件名,可以不传
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.HOSTED_WIDGET, this.GET_HOSTED_WIDGETS, name);
|
|
25
|
+
async getHostedWidgets(name) {
|
|
26
|
+
return this.invokeMethod('getHostedWidgets', name);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.HOSTED_WIDGET, this.GET_HOSTED_WIDGET, id);
|
|
28
|
+
async getHostedWidget(id) {
|
|
29
|
+
return this.invokeMethod('getHostedWidget', id);
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Opens the dev tools for a widget with the specified ID.
|
|
@@ -35,13 +34,11 @@ export class HostedWidgetApi {
|
|
|
35
34
|
* @param {string} widgetId - The ID of the widget to open the dev tools for.
|
|
36
35
|
* @return {Promise} A Promise that resolves when the dev tools are opened.
|
|
37
36
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.HOSTED_WIDGET, this.OPEN_DEV_TOOLS, widgetId);
|
|
37
|
+
async openDevTools(widgetId) {
|
|
38
|
+
return this.invokeMethod('openDevTools', widgetId);
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.HOSTED_WIDGET, this.OPEN_CONFIG_ROUTE, widgetId, params);
|
|
40
|
+
async openConfigRoute(widgetId, params) {
|
|
41
|
+
return this.invokeMethod('openConfigRoute', widgetId, params);
|
|
45
42
|
}
|
|
46
43
|
/**
|
|
47
44
|
* 注册激活、呼出、置顶组件快捷键
|
|
@@ -49,21 +46,12 @@ export class HostedWidgetApi {
|
|
|
49
46
|
* @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
|
|
50
47
|
* https://www.electronjs.org/docs/latest/api/accelerator
|
|
51
48
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.HOSTED_WIDGET, this.REGISTER_ACTIVE_SHORTCUT, widgetId, shortcut);
|
|
49
|
+
async registerActiveShortcut(widgetId, shortcut) {
|
|
50
|
+
return this.invokeMethod('registerActiveShortcut', widgetId, shortcut);
|
|
55
51
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return (_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(Channel.HOSTED_WIDGET, this.SET_PROXY, widgetId, proxy);
|
|
52
|
+
async setProxy(widgetId, proxy) {
|
|
53
|
+
return this.invokeMethod('setProxy', widgetId, proxy);
|
|
59
54
|
}
|
|
60
55
|
}
|
|
61
|
-
HostedWidgetApi
|
|
62
|
-
HostedWidgetApi
|
|
63
|
-
HostedWidgetApi.GET_HOSTED_WIDGETS = "get-hosted-widgets";
|
|
64
|
-
HostedWidgetApi.GET_HOSTED_WIDGET = "get-hosted-widget";
|
|
65
|
-
HostedWidgetApi.OPEN_DEV_TOOLS = "open-dev-tools";
|
|
66
|
-
HostedWidgetApi.REGISTER_ACTIVE_SHORTCUT = "register-active-shortcut";
|
|
67
|
-
HostedWidgetApi.SET_PROXY = "SET_PROXY";
|
|
68
|
-
HostedWidgetApi.UPDATE = "UPDATE";
|
|
69
|
-
HostedWidgetApi.OPEN_CONFIG_ROUTE = "open-config-route";
|
|
56
|
+
const HostedWidgetApi = new HostedWidgetApiImpl();
|
|
57
|
+
export { HostedWidgetApi };
|
package/dist/esm/api/LogApi.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import { ElectronUtils } from '../utils/ElectronUtils';
|
|
2
1
|
import { Channel } from "./Channel";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { BaseApi } from "./BaseApi";
|
|
3
|
+
class LogApiImpl extends BaseApi {
|
|
4
|
+
getChannel() {
|
|
5
|
+
return Channel.LOG;
|
|
6
|
+
}
|
|
7
|
+
info(...data) {
|
|
5
8
|
console.info(...data);
|
|
6
|
-
|
|
9
|
+
this.invokeMethod('info', ...data);
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
error(...data) {
|
|
9
12
|
console.error(...data);
|
|
10
|
-
|
|
13
|
+
this.invokeMethod('error', ...data);
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
warn(...data) {
|
|
13
16
|
console.warn(...data);
|
|
14
|
-
|
|
17
|
+
this.invokeMethod('warn', ...data);
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
log(...data) {
|
|
17
20
|
console.log(...data);
|
|
18
|
-
|
|
21
|
+
this.invokeMethod('log', ...data);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
24
|
+
const LogApi = new LogApiImpl();
|
|
25
|
+
export { LogApi };
|