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