@widget-js/core 0.7.2 → 0.7.4

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 (137) hide show
  1. package/dist/index.cjs +2027 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.ts +1396 -0
  4. package/dist/index.js +1944 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +15 -16
  7. package/dist/cjs/AppPermission.js +0 -8
  8. package/dist/cjs/api/ApiConstants.js +0 -11
  9. package/dist/cjs/api/AppApi.js +0 -51
  10. package/dist/cjs/api/BaseApi.js +0 -13
  11. package/dist/cjs/api/BroadcastApi.js +0 -22
  12. package/dist/cjs/api/BrowserWindowApi.js +0 -144
  13. package/dist/cjs/api/Channel.js +0 -22
  14. package/dist/cjs/api/ClipboardApi.js +0 -23
  15. package/dist/cjs/api/DeviceApi.js +0 -25
  16. package/dist/cjs/api/DialogApi.js +0 -22
  17. package/dist/cjs/api/ElectronApi.js +0 -15
  18. package/dist/cjs/api/FileApi.js +0 -21
  19. package/dist/cjs/api/HostedWidgetApi.js +0 -64
  20. package/dist/cjs/api/LogApi.js +0 -28
  21. package/dist/cjs/api/NotificationApi.js +0 -117
  22. package/dist/cjs/api/ShortcutApi.js +0 -23
  23. package/dist/cjs/api/StoreApi.js +0 -38
  24. package/dist/cjs/api/WidgetApi.js +0 -92
  25. package/dist/cjs/api/WidgetDataApi.js +0 -95
  26. package/dist/cjs/index.js +0 -51
  27. package/dist/cjs/lang/LanguageCode.js +0 -34
  28. package/dist/cjs/model/AppNotification.js +0 -33
  29. package/dist/cjs/model/BrowserWindowStatus.js +0 -11
  30. package/dist/cjs/model/HostedMode.js +0 -18
  31. package/dist/cjs/model/HostedWidget.js +0 -14
  32. package/dist/cjs/model/SocialInfo.js +0 -10
  33. package/dist/cjs/model/Widget.js +0 -118
  34. package/dist/cjs/model/WidgetData.js +0 -16
  35. package/dist/cjs/model/WidgetPackage.js +0 -98
  36. package/dist/cjs/model/WidgetParams.js +0 -151
  37. package/dist/cjs/model/event/AppMouseEvent.js +0 -2
  38. package/dist/cjs/model/event/BroadcastEvent.js +0 -11
  39. package/dist/cjs/model/event/NativeKeyboardEvent.js +0 -2
  40. package/dist/cjs/model/event/WebSocketEvent.js +0 -14
  41. package/dist/cjs/model/interface/IHostedWidget.js +0 -2
  42. package/dist/cjs/model/interface/Rectangle.js +0 -2
  43. package/dist/cjs/model/msic/graphics.js +0 -10
  44. package/dist/cjs/permission/permission.js +0 -2
  45. package/dist/cjs/router/encoding.js +0 -144
  46. package/dist/cjs/router/query.js +0 -84
  47. package/dist/cjs/utils/ElectronUtils.js +0 -32
  48. package/dist/cjs/utils/LanguageUtils.js +0 -36
  49. package/dist/cjs/utils/UrlUtils.js +0 -36
  50. package/dist/esm/AppPermission.js +0 -5
  51. package/dist/esm/api/ApiConstants.js +0 -7
  52. package/dist/esm/api/AppApi.js +0 -47
  53. package/dist/esm/api/BaseApi.js +0 -9
  54. package/dist/esm/api/BroadcastApi.js +0 -18
  55. package/dist/esm/api/BrowserWindowApi.js +0 -139
  56. package/dist/esm/api/Channel.js +0 -19
  57. package/dist/esm/api/ClipboardApi.js +0 -19
  58. package/dist/esm/api/DeviceApi.js +0 -21
  59. package/dist/esm/api/DialogApi.js +0 -19
  60. package/dist/esm/api/ElectronApi.js +0 -11
  61. package/dist/esm/api/FileApi.js +0 -18
  62. package/dist/esm/api/HostedWidgetApi.js +0 -60
  63. package/dist/esm/api/LogApi.js +0 -25
  64. package/dist/esm/api/NotificationApi.js +0 -113
  65. package/dist/esm/api/ShortcutApi.js +0 -19
  66. package/dist/esm/api/StoreApi.js +0 -35
  67. package/dist/esm/api/WidgetApi.js +0 -88
  68. package/dist/esm/api/WidgetDataApi.js +0 -88
  69. package/dist/esm/index.js +0 -35
  70. package/dist/esm/lang/LanguageCode.js +0 -33
  71. package/dist/esm/model/AppNotification.js +0 -29
  72. package/dist/esm/model/BrowserWindowStatus.js +0 -8
  73. package/dist/esm/model/HostedMode.js +0 -15
  74. package/dist/esm/model/HostedWidget.js +0 -10
  75. package/dist/esm/model/SocialInfo.js +0 -6
  76. package/dist/esm/model/Widget.js +0 -114
  77. package/dist/esm/model/WidgetData.js +0 -12
  78. package/dist/esm/model/WidgetPackage.js +0 -94
  79. package/dist/esm/model/WidgetParams.js +0 -147
  80. package/dist/esm/model/event/AppMouseEvent.js +0 -1
  81. package/dist/esm/model/event/BroadcastEvent.js +0 -7
  82. package/dist/esm/model/event/NativeKeyboardEvent.js +0 -1
  83. package/dist/esm/model/event/WebSocketEvent.js +0 -10
  84. package/dist/esm/model/interface/IHostedWidget.js +0 -1
  85. package/dist/esm/model/interface/Rectangle.js +0 -1
  86. package/dist/esm/model/msic/graphics.js +0 -7
  87. package/dist/esm/permission/permission.js +0 -1
  88. package/dist/esm/router/encoding.js +0 -135
  89. package/dist/esm/router/query.js +0 -79
  90. package/dist/esm/utils/ElectronUtils.js +0 -28
  91. package/dist/esm/utils/LanguageUtils.js +0 -32
  92. package/dist/esm/utils/UrlUtils.js +0 -32
  93. package/dist/types/AppPermission.d.ts +0 -4
  94. package/dist/types/api/ApiConstants.d.ts +0 -7
  95. package/dist/types/api/AppApi.d.ts +0 -29
  96. package/dist/types/api/BaseApi.d.ts +0 -5
  97. package/dist/types/api/BroadcastApi.d.ts +0 -21
  98. package/dist/types/api/BrowserWindowApi.d.ts +0 -111
  99. package/dist/types/api/Channel.d.ts +0 -18
  100. package/dist/types/api/ClipboardApi.d.ts +0 -10
  101. package/dist/types/api/DeviceApi.d.ts +0 -20
  102. package/dist/types/api/DialogApi.d.ts +0 -7
  103. package/dist/types/api/ElectronApi.d.ts +0 -4
  104. package/dist/types/api/FileApi.d.ts +0 -13
  105. package/dist/types/api/HostedWidgetApi.d.ts +0 -55
  106. package/dist/types/api/LogApi.d.ts +0 -9
  107. package/dist/types/api/NotificationApi.d.ts +0 -38
  108. package/dist/types/api/ShortcutApi.d.ts +0 -10
  109. package/dist/types/api/StoreApi.d.ts +0 -10
  110. package/dist/types/api/WidgetApi.d.ts +0 -48
  111. package/dist/types/api/WidgetDataApi.d.ts +0 -44
  112. package/dist/types/index.d.ts +0 -35
  113. package/dist/types/lang/LanguageCode.d.ts +0 -40
  114. package/dist/types/model/AppNotification.d.ts +0 -50
  115. package/dist/types/model/BrowserWindowStatus.d.ts +0 -9
  116. package/dist/types/model/HostedMode.d.ts +0 -14
  117. package/dist/types/model/HostedWidget.d.ts +0 -13
  118. package/dist/types/model/SocialInfo.d.ts +0 -6
  119. package/dist/types/model/Widget.d.ts +0 -136
  120. package/dist/types/model/WidgetData.d.ts +0 -35
  121. package/dist/types/model/WidgetPackage.d.ts +0 -101
  122. package/dist/types/model/WidgetParams.d.ts +0 -61
  123. package/dist/types/model/event/AppMouseEvent.d.ts +0 -14
  124. package/dist/types/model/event/BroadcastEvent.d.ts +0 -21
  125. package/dist/types/model/event/NativeKeyboardEvent.d.ts +0 -6
  126. package/dist/types/model/event/WebSocketEvent.d.ts +0 -8
  127. package/dist/types/model/interface/IHostedWidget.d.ts +0 -13
  128. package/dist/types/model/interface/Rectangle.d.ts +0 -18
  129. package/dist/types/model/msic/graphics.d.ts +0 -14
  130. package/dist/types/permission/permission.d.ts +0 -1
  131. package/dist/types/router/encoding.d.ts +0 -62
  132. package/dist/types/router/query.d.ts +0 -53
  133. package/dist/types/utils/ElectronUtils.d.ts +0 -10
  134. package/dist/types/utils/LanguageUtils.d.ts +0 -8
  135. package/dist/types/utils/UrlUtils.d.ts +0 -6
  136. package/dist/umd/index.js +0 -2
  137. package/dist/umd/index.js.LICENSE.txt +0 -6
@@ -1,144 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BrowserWindowApiEvent = exports.BrowserWindowApi = exports.BrowserWindowApiImpl = void 0;
4
- const Channel_1 = require("./Channel");
5
- const ElectronUtils_1 = require("../utils/ElectronUtils");
6
- const BaseApi_1 = require("./BaseApi");
7
- var BrowserWindowApiEvent;
8
- (function (BrowserWindowApiEvent) {
9
- BrowserWindowApiEvent["BLUR"] = "event::cn.widgetjs.core.browser-window.blur";
10
- BrowserWindowApiEvent["FOCUS"] = "event::cn.widgetjs.core.browser-window.focus";
11
- BrowserWindowApiEvent["SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.snap_to_edge";
12
- BrowserWindowApiEvent["RESIZE"] = "event::cn.widgetjs.core.browser-window.resize";
13
- BrowserWindowApiEvent["CANCEL_SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge";
14
- })(BrowserWindowApiEvent || (BrowserWindowApiEvent = {}));
15
- exports.BrowserWindowApiEvent = BrowserWindowApiEvent;
16
- class BrowserWindowApiImpl extends BaseApi_1.BaseApi {
17
- getChannel() {
18
- return Channel_1.Channel.BROWSER_WINDOW;
19
- }
20
- async setIgnoreMouseEvent(ignore) {
21
- await this.invokeMethod('setIgnoreMouseEvent', ignore);
22
- }
23
- async show() {
24
- await this.invokeMethod('show', true);
25
- }
26
- async showInactive() {
27
- await this.invokeMethod('showInactive', true);
28
- }
29
- async hide() {
30
- await this.invokeMethod('hide', false);
31
- }
32
- async center() {
33
- await this.invokeMethod('center', false);
34
- }
35
- async setAlwaysOnTop(alwaysOnTop) {
36
- await this.invokeMethod('setAlwaysOnTop', alwaysOnTop);
37
- }
38
- async isAlwaysOnTop() {
39
- return await this.invokeMethod('isAlwaysOnTop');
40
- }
41
- async openUrl(url, option) {
42
- if (ElectronUtils_1.ElectronUtils.hasElectronApi()) {
43
- await this.invokeMethod('openUrl', url, option);
44
- }
45
- else {
46
- window.open(url, '_blank');
47
- }
48
- }
49
- async moveTop() {
50
- await this.invokeMethod('moveTop');
51
- }
52
- async openDevTools() {
53
- await this.invokeMethod('openDevTools');
54
- }
55
- async setPosition(options) {
56
- await this.invokeMethod('setPosition', options);
57
- }
58
- async getPosition() {
59
- return await this.invokeMethod('getPosition');
60
- }
61
- async blur() {
62
- return await this.invokeMethod('blur');
63
- }
64
- async focus() {
65
- return await this.invokeMethod('focus');
66
- }
67
- /**
68
- * 设置窗口是否可以拉伸
69
- * @param resizable
70
- */
71
- async setResizable(resizable) {
72
- return await this.invokeMethod('setResizable', resizable);
73
- }
74
- async getBounds() {
75
- return await this.invokeMethod('getBounds');
76
- }
77
- async setBounds(bounds, animate) {
78
- return await this.invokeMethod("setBounds", bounds, animate);
79
- }
80
- async alignToScreen(align) {
81
- return await this.invokeMethod('alignToScreen', align);
82
- }
83
- async startDraggingWindow() {
84
- return await this.invokeMethod('startDraggingWindow');
85
- }
86
- async stopDraggingWindow() {
87
- return await this.invokeMethod('stopDraggingWindow');
88
- }
89
- /**
90
- * 通过url检测窗口是否存在
91
- * @param url
92
- */
93
- async existsByUrl(url) {
94
- return await this.invokeMethod('existsByUrl', url);
95
- }
96
- async getMaximumSize() {
97
- return await this.invokeMethod('getMaximumSize');
98
- }
99
- async minimize() {
100
- return await this.invokeMethod('minimize');
101
- }
102
- async maximize() {
103
- return await this.invokeMethod('maximize');
104
- }
105
- async isMaximized() {
106
- return await this.invokeMethod('isMaximized');
107
- }
108
- async isMinimized() {
109
- return await this.invokeMethod('isMinimized');
110
- }
111
- async restore() {
112
- return await this.invokeMethod('restore');
113
- }
114
- async unmaximize() {
115
- return await this.invokeMethod('unmaximize');
116
- }
117
- async setZoomLevel(level) {
118
- return await this.invokeMethod('setZoomLevel');
119
- }
120
- async reload() {
121
- return await this.invokeMethod('reload');
122
- }
123
- async setMovable(movable) {
124
- return await this.invokeMethod('setMovable', movable);
125
- }
126
- async setSize(width, height, animate) {
127
- return this.invokeMethod('setSize', width, height, animate);
128
- }
129
- async isFocused() {
130
- return this.invokeMethod('isFocused');
131
- }
132
- async setMaximumSize(width, height) {
133
- return this.invokeMethod('setMaximumSize', width, height);
134
- }
135
- async setMinimumSize(width, height) {
136
- return this.invokeMethod('setMinimumSize', width, height);
137
- }
138
- getMinimumSize() {
139
- return this.invokeMethod('getMinimumSize');
140
- }
141
- }
142
- exports.BrowserWindowApiImpl = BrowserWindowApiImpl;
143
- const BrowserWindowApi = new BrowserWindowApiImpl();
144
- exports.BrowserWindowApi = BrowserWindowApi;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Channel = void 0;
4
- var Channel;
5
- (function (Channel) {
6
- Channel["NOTIFICATION"] = "channel::cn.widgetjs.core.notification";
7
- Channel["BROWSER_WINDOW"] = "channel::cn.widgetjs.core.browser_window";
8
- Channel["BROADCAST"] = "channel::cn.widgetjs.core.broadcast";
9
- Channel["WIDGET"] = "channel::cn.widgetjs.core.widget";
10
- Channel["HOSTED_WIDGET"] = "channel::cn.widgetjs.core.hosted_widget";
11
- Channel["APP"] = "channel::cn.widgetjs.core.app";
12
- Channel["DIALOG"] = "channel::cn.widgetjs.core.dialog";
13
- Channel["CLIPBOARD"] = "channel::cn.widgetjs.core.clipboard";
14
- Channel["FILE"] = "channel::cn.widgetjs.core.file";
15
- Channel["SCREEN"] = "channel::cn.widgetjs.core.screen";
16
- Channel["SHORTCUT"] = "channel::cn.widgetjs.core.shortcut";
17
- Channel["LOG"] = "channel::cn.widgetjs.core.log";
18
- Channel["DEVICE"] = "channel::cn.widgetjs.core.device";
19
- Channel["MOUSE"] = "channel::cn.widgetjs.core.mouse";
20
- Channel["KEYBOARD"] = "channel::cn.widgetjs.core.keyboard";
21
- Channel["STORE"] = "channel::cn.widgetjs.core.store";
22
- })(Channel = exports.Channel || (exports.Channel = {}));
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClipboardApiEvent = exports.ClipboardApi = void 0;
4
- const Channel_1 = require("./Channel");
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');
14
- }
15
- async getText() {
16
- return this.invokeMethod('getText');
17
- }
18
- getChannel() {
19
- return Channel_1.Channel.CLIPBOARD;
20
- }
21
- }
22
- const ClipboardApi = new ClipboardApiImpl();
23
- exports.ClipboardApi = ClipboardApi;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DeviceApi = exports.DeviceApiImpl = void 0;
4
- const Channel_1 = require("./Channel");
5
- const BaseApi_1 = require("./BaseApi");
6
- class DeviceApiImpl extends BaseApi_1.BaseApi {
7
- /**
8
- * 获取当前鼠标位置
9
- */
10
- async getCursorScreenPoint() {
11
- return this.invokeMethod('getCursorScreenPoint');
12
- }
13
- /**
14
- * 判断是否所有按键都已经释放
15
- */
16
- async isAllKeyReleased() {
17
- return this.invokeMethod('isAllKeyReleased');
18
- }
19
- getChannel() {
20
- return Channel_1.Channel.DEVICE;
21
- }
22
- }
23
- exports.DeviceApiImpl = DeviceApiImpl;
24
- const DeviceApi = new DeviceApiImpl();
25
- exports.DeviceApi = DeviceApi;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DialogApi = void 0;
4
- const Channel_1 = require("./Channel");
5
- const BaseApi_1 = require("./BaseApi");
6
- class DialogApiImpl extends BaseApi_1.BaseApi {
7
- getChannel() {
8
- return Channel_1.Channel.DIALOG;
9
- }
10
- /**
11
- * 选取单个文件
12
- * @param extensions 允许的文件后缀格式,如:["txt","docx","gif"]
13
- */
14
- pickFile(extensions) {
15
- return this.invokeMethod('pickFile', extensions);
16
- }
17
- pickFolder() {
18
- return this.invokeMethod('pickFolder');
19
- }
20
- }
21
- const DialogApi = new DialogApiImpl();
22
- exports.DialogApi = DialogApi;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ElectronApi = void 0;
4
- const ElectronUtils_1 = require("../utils/ElectronUtils");
5
- class ElectronApi {
6
- static async addIpcListener(key, f) {
7
- var _a;
8
- await ((_a = ElectronUtils_1.ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.addIpcListener(key, f));
9
- }
10
- static async removeIpcListener(key) {
11
- var _a;
12
- await ((_a = ElectronUtils_1.ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.removeIpcListener(key));
13
- }
14
- }
15
- exports.ElectronApi = ElectronApi;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileApi = void 0;
4
- const Channel_1 = require("./Channel");
5
- const BaseApi_1 = require("./BaseApi");
6
- class FileApiImpl extends BaseApi_1.BaseApi {
7
- getFileType(filePath) {
8
- return this.invokeMethod('getFileType', filePath);
9
- }
10
- isDirectory(filePath) {
11
- return this.invokeMethod('isDirectory', filePath);
12
- }
13
- getChannel() {
14
- return Channel_1.Channel.FILE;
15
- }
16
- readDirectory(path, options) {
17
- return this.invokeMethod('readDirectory', path, options);
18
- }
19
- }
20
- const FileApi = new FileApiImpl();
21
- exports.FileApi = FileApi;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HostedWidgetApi = exports.HostedWidgetApiImpl = void 0;
4
- const Channel_1 = require("./Channel");
5
- const BaseApi_1 = require("./BaseApi");
6
- class HostedWidgetApiImpl extends BaseApi_1.BaseApi {
7
- getChannel() {
8
- return Channel_1.Channel.HOSTED_WIDGET;
9
- }
10
- /**
11
- * 移除组件
12
- * @param id
13
- */
14
- async removeHostedWidget(id) {
15
- return this.invokeMethod('removeHostedWidget', id);
16
- }
17
- addWidget(widgetName, hostMode) {
18
- return this.invokeMethod('addWidget', widgetName, hostMode);
19
- }
20
- /**
21
- * 通过组件名移除已添加的组件
22
- * @param name 组件名
23
- */
24
- async removeHostedWidgetByName(name) {
25
- return this.invokeMethod('removeHostedWidgetByName', name);
26
- }
27
- /**
28
- * 获取已添加的组件
29
- * @param name 组件名,可以不传
30
- */
31
- async getHostedWidgets(name) {
32
- return this.invokeMethod('getHostedWidgets', name);
33
- }
34
- async getHostedWidget(id) {
35
- return this.invokeMethod('getHostedWidget', id);
36
- }
37
- /**
38
- * Opens the dev tools for a widget with the specified ID.
39
- *
40
- * @param {string} widgetId - The ID of the widget to open the dev tools for.
41
- * @return {Promise} A Promise that resolves when the dev tools are opened.
42
- */
43
- async openDevTools(widgetId) {
44
- return this.invokeMethod('openDevTools', widgetId);
45
- }
46
- async openConfigRoute(widgetId, params) {
47
- return this.invokeMethod('openConfigRoute', widgetId, params);
48
- }
49
- /**
50
- * 注册激活、呼出、置顶组件快捷键
51
- * @param widgetId 组件id
52
- * @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
53
- * https://www.electronjs.org/docs/latest/api/accelerator
54
- */
55
- async registerActiveShortcut(widgetId, shortcut) {
56
- return this.invokeMethod('registerActiveShortcut', widgetId, shortcut);
57
- }
58
- async setProxy(widgetId, proxy) {
59
- return this.invokeMethod('setProxy', widgetId, proxy);
60
- }
61
- }
62
- exports.HostedWidgetApiImpl = HostedWidgetApiImpl;
63
- const HostedWidgetApi = new HostedWidgetApiImpl();
64
- exports.HostedWidgetApi = HostedWidgetApi;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LogApi = void 0;
4
- const Channel_1 = require("./Channel");
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) {
11
- console.info(...data);
12
- this.invokeMethod('info', ...data);
13
- }
14
- error(...data) {
15
- console.error(...data);
16
- this.invokeMethod('error', ...data);
17
- }
18
- warn(...data) {
19
- console.warn(...data);
20
- this.invokeMethod('warn', ...data);
21
- }
22
- log(...data) {
23
- console.log(...data);
24
- this.invokeMethod('log', ...data);
25
- }
26
- }
27
- const LogApi = new LogApiImpl();
28
- exports.LogApi = LogApi;
@@ -1,117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotificationApiEvent = exports.NotificationApi = void 0;
4
- const AppNotification_1 = require("../model/AppNotification");
5
- const Channel_1 = require("./Channel");
6
- const BaseApi_1 = require("./BaseApi");
7
- var NotificationApiEvent;
8
- (function (NotificationApiEvent) {
9
- NotificationApiEvent["CONFIRM"] = "event::cn.widgetjs.core.notification.confirm";
10
- NotificationApiEvent["CANCEL"] = "event::cn.widgetjs.core.notification.cancel";
11
- NotificationApiEvent["HIDE"] = "event::cn.widgetjs.core.notification.hide";
12
- })(NotificationApiEvent || (NotificationApiEvent = {}));
13
- exports.NotificationApiEvent = NotificationApiEvent;
14
- class NotificationApiImpl extends BaseApi_1.BaseApi {
15
- // static async url(url: string, duration: number = -1) {
16
- // this.invoke(Channel.NOTIFICATION, new AppNotification({
17
- // url, message: "",
18
- // duration,
19
- // type: "url",
20
- // }));
21
- // }
22
- /**
23
- * 来电
24
- * @param avatar 头像地址
25
- * @param audio 音频地址
26
- * @param title 标题文件
27
- * @param message 初始消息
28
- * @param lyric 歌词字符串
29
- */
30
- async call(avatar, audio, title, message, lyric) {
31
- await this.invoke(new AppNotification_1.AppNotification({
32
- avatar,
33
- audio,
34
- message,
35
- title,
36
- duration: -1,
37
- lyric,
38
- type: "call",
39
- }));
40
- }
41
- async send(notification) {
42
- return this.invokeMethod('send', notification);
43
- }
44
- async reminder(title, message, icon, cancelButtonText, confirmButtonText, cancelBroadcast, confirmBroadcast, duration = 5000) {
45
- return await this.send(new AppNotification_1.AppNotification({
46
- icon,
47
- message,
48
- title,
49
- duration,
50
- cancelButtonText,
51
- confirmButtonText,
52
- cancelBroadcast,
53
- confirmBroadcast,
54
- type: "reminder",
55
- }));
56
- }
57
- async advanceCountdown(message, targetTime, title) {
58
- return await this.send(new AppNotification_1.AppNotification({
59
- title,
60
- message,
61
- targetTime,
62
- type: "advance-countdown"
63
- }));
64
- }
65
- async countdown(message, targetTime) {
66
- await this.send(new AppNotification_1.AppNotification({
67
- message,
68
- targetTime,
69
- backgroundColor: 'rgba(0,0,0,0.5)',
70
- duration: -1,
71
- type: "countdown"
72
- }));
73
- }
74
- async success(message, duration = 5000) {
75
- await this.send(new AppNotification_1.AppNotification({
76
- message,
77
- type: "success",
78
- icon: "check_circle_line",
79
- duration
80
- }));
81
- }
82
- async error(message, duration = 5000) {
83
- await this.send(new AppNotification_1.AppNotification({
84
- message,
85
- type: "error",
86
- icon: "close_circle_line",
87
- duration
88
- }));
89
- }
90
- async warning(message, duration = 5000) {
91
- await this.send(new AppNotification_1.AppNotification({
92
- message,
93
- type: "warning",
94
- icon: "warning_line",
95
- duration
96
- }));
97
- }
98
- async info(message, duration = 5000) {
99
- await this.send(new AppNotification_1.AppNotification({
100
- message,
101
- type: "info",
102
- icon: "information_line",
103
- duration
104
- }));
105
- }
106
- /**
107
- * 隐藏通知
108
- */
109
- async hide() {
110
- await this.invokeMethod('hide');
111
- }
112
- getChannel() {
113
- return Channel_1.Channel.NOTIFICATION;
114
- }
115
- }
116
- const NotificationApi = new NotificationApiImpl();
117
- exports.NotificationApi = NotificationApi;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ShortcutApiEvent = exports.ShortcutApi = void 0;
4
- const BaseApi_1 = require("./BaseApi");
5
- const Channel_1 = require("./Channel");
6
- var ShortcutApiEvent;
7
- (function (ShortcutApiEvent) {
8
- ShortcutApiEvent["TRIGGERED"] = "channel::cn.widgetjs.core.shortcut.triggered";
9
- })(ShortcutApiEvent || (ShortcutApiEvent = {}));
10
- exports.ShortcutApiEvent = ShortcutApiEvent;
11
- class ShortcutApiImpl extends BaseApi_1.BaseApi {
12
- getChannel() {
13
- return Channel_1.Channel.SHORTCUT;
14
- }
15
- async register(shortcut) {
16
- return await this.invokeMethod('register', shortcut);
17
- }
18
- async unregister(shortcut) {
19
- return await this.invokeMethod('unregister', shortcut);
20
- }
21
- }
22
- const ShortcutApi = new ShortcutApiImpl();
23
- exports.ShortcutApi = ShortcutApi;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StoreApi = void 0;
4
- const BaseApi_1 = require("./BaseApi");
5
- const Channel_1 = require("./Channel");
6
- class StoreApiImpl extends BaseApi_1.BaseApi {
7
- getChannel() {
8
- return Channel_1.Channel.STORE;
9
- }
10
- async delete(key) {
11
- return this.invokeMethod('delete', key);
12
- }
13
- async get(key, defaultValue) {
14
- const result = await this.invokeMethod('get', key);
15
- if (result == null && defaultValue != undefined) {
16
- return defaultValue;
17
- }
18
- return result;
19
- }
20
- async getObject(key, defaultValue) {
21
- const result = await this.invokeMethod('get', key);
22
- if (result) {
23
- return JSON.parse(result);
24
- }
25
- if (defaultValue != undefined) {
26
- return defaultValue;
27
- }
28
- return undefined;
29
- }
30
- async set(key, value) {
31
- if (typeof value == 'object') {
32
- return this.invokeMethod('set', key, JSON.stringify(value));
33
- }
34
- return this.invokeMethod('set', key, value);
35
- }
36
- }
37
- const StoreApi = new StoreApiImpl();
38
- exports.StoreApi = StoreApi;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WidgetApiEvent = exports.WidgetApi = void 0;
4
- const Widget_1 = require("../model/Widget");
5
- const WidgetPackage_1 = require("../model/WidgetPackage");
6
- const Channel_1 = require("./Channel");
7
- const UrlUtils_1 = require("../utils/UrlUtils");
8
- const BaseApi_1 = require("./BaseApi");
9
- var WidgetApiEvent;
10
- (function (WidgetApiEvent) {
11
- WidgetApiEvent["DATA_CHANGED"] = "event::cn.widgetjs.core.widget.data-changed";
12
- WidgetApiEvent["EDIT_DESKTOP_WIDGETS"] = "event::cn.widgetjs.core.widget.desktop.edit";
13
- })(WidgetApiEvent || (WidgetApiEvent = {}));
14
- exports.WidgetApiEvent = WidgetApiEvent;
15
- class WidgetApiImpl extends BaseApi_1.BaseApi {
16
- getChannel() {
17
- return Channel_1.Channel.WIDGET;
18
- }
19
- async registerWidgets(widgets) {
20
- return this.invokeMethod("registerWidgets", JSON.stringify(widgets));
21
- }
22
- async registerWidgetPackage(widgetPackage) {
23
- return this.invokeMethod("registerWidgetPackage", JSON.stringify(widgetPackage));
24
- }
25
- async getWidgets() {
26
- const data = await this.invokeMethod('getWidgets');
27
- const widgets = [];
28
- if (data) {
29
- for (const item of data) {
30
- widgets.push(Widget_1.Widget.parseObject(item));
31
- }
32
- }
33
- return widgets;
34
- }
35
- async getWidgetPackages() {
36
- return await this.invokeMethod('getWidgetPackages');
37
- }
38
- /**
39
- *
40
- * @param name package name
41
- */
42
- async getWidget(name) {
43
- return Widget_1.Widget.parseObject(await this.invokeMethod('getWidget', name));
44
- }
45
- /**
46
- *
47
- * @param name package name
48
- */
49
- async getWidgetPackage(name) {
50
- return WidgetPackage_1.WidgetPackage.parseObject(await this.invokeMethod('getWidgetPackage', name));
51
- }
52
- /**
53
- * 获取组件配置地址
54
- * @param widgetName
55
- */
56
- async getWidgetConfigUrl(widgetName, widgetParams) {
57
- const widget = await this.getWidget(widgetName);
58
- if (!widget)
59
- return null;
60
- const configRoute = widget.getConfigRoute();
61
- if (!configRoute)
62
- return null;
63
- const widgetPackage = await this.getWidgetPackage(widget.packageName);
64
- if (!widgetPackage)
65
- return null;
66
- return UrlUtils_1.UrlUtils.getWidgetUrl(configRoute.url, widgetPackage, widgetParams);
67
- }
68
- async getWidgetUrl(widgetName, widgetParams) {
69
- const widget = await this.getWidget(widgetName);
70
- if (!widget)
71
- return null;
72
- const indexRoute = widget.getIndexRoute();
73
- const widgetPackage = await this.getWidgetPackage(widget.packageName);
74
- if (!widgetPackage)
75
- return null;
76
- return UrlUtils_1.UrlUtils.getWidgetUrl(indexRoute.url, widgetPackage, widgetParams);
77
- }
78
- async getWidgetPackageIndexUrl(packageName, hash) {
79
- const widgetPackage = await this.getWidgetPackage(packageName);
80
- if (!widgetPackage)
81
- return null;
82
- return widgetPackage.getIndexUrl(hash);
83
- }
84
- async getWidgetPackageUrl(packageName) {
85
- const widgetPackage = await this.getWidgetPackage(packageName);
86
- if (!widgetPackage)
87
- return null;
88
- return widgetPackage.url;
89
- }
90
- }
91
- const WidgetApi = new WidgetApiImpl();
92
- exports.WidgetApi = WidgetApi;