@widget-js/core 0.7.2 → 0.7.3

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 +2084 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.ts +1507 -0
  4. package/dist/index.js +1995 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +15 -15
  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,19 +0,0 @@
1
- import { Channel } from "./Channel";
2
- import { BaseApi } from "./BaseApi";
3
- class DialogApiImpl extends BaseApi {
4
- getChannel() {
5
- return Channel.DIALOG;
6
- }
7
- /**
8
- * 选取单个文件
9
- * @param extensions 允许的文件后缀格式,如:["txt","docx","gif"]
10
- */
11
- pickFile(extensions) {
12
- return this.invokeMethod('pickFile', extensions);
13
- }
14
- pickFolder() {
15
- return this.invokeMethod('pickFolder');
16
- }
17
- }
18
- const DialogApi = new DialogApiImpl();
19
- export { DialogApi, };
@@ -1,11 +0,0 @@
1
- import { ElectronUtils } from "../utils/ElectronUtils";
2
- export class ElectronApi {
3
- static async addIpcListener(key, f) {
4
- var _a;
5
- await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.addIpcListener(key, f));
6
- }
7
- static async removeIpcListener(key) {
8
- var _a;
9
- await ((_a = ElectronUtils.getAPI()) === null || _a === void 0 ? void 0 : _a.removeIpcListener(key));
10
- }
11
- }
@@ -1,18 +0,0 @@
1
- import { Channel } from "./Channel";
2
- import { BaseApi } from "./BaseApi";
3
- class FileApiImpl extends BaseApi {
4
- getFileType(filePath) {
5
- return this.invokeMethod('getFileType', filePath);
6
- }
7
- isDirectory(filePath) {
8
- return this.invokeMethod('isDirectory', filePath);
9
- }
10
- getChannel() {
11
- return Channel.FILE;
12
- }
13
- readDirectory(path, options) {
14
- return this.invokeMethod('readDirectory', path, options);
15
- }
16
- }
17
- const FileApi = new FileApiImpl();
18
- export { FileApi };
@@ -1,60 +0,0 @@
1
- import { Channel } from "./Channel";
2
- import { BaseApi } from "./BaseApi";
3
- export class HostedWidgetApiImpl extends BaseApi {
4
- getChannel() {
5
- return Channel.HOSTED_WIDGET;
6
- }
7
- /**
8
- * 移除组件
9
- * @param id
10
- */
11
- async removeHostedWidget(id) {
12
- return this.invokeMethod('removeHostedWidget', id);
13
- }
14
- addWidget(widgetName, hostMode) {
15
- return this.invokeMethod('addWidget', widgetName, hostMode);
16
- }
17
- /**
18
- * 通过组件名移除已添加的组件
19
- * @param name 组件名
20
- */
21
- async removeHostedWidgetByName(name) {
22
- return this.invokeMethod('removeHostedWidgetByName', name);
23
- }
24
- /**
25
- * 获取已添加的组件
26
- * @param name 组件名,可以不传
27
- */
28
- async getHostedWidgets(name) {
29
- return this.invokeMethod('getHostedWidgets', name);
30
- }
31
- async getHostedWidget(id) {
32
- return this.invokeMethod('getHostedWidget', id);
33
- }
34
- /**
35
- * Opens the dev tools for a widget with the specified ID.
36
- *
37
- * @param {string} widgetId - The ID of the widget to open the dev tools for.
38
- * @return {Promise} A Promise that resolves when the dev tools are opened.
39
- */
40
- async openDevTools(widgetId) {
41
- return this.invokeMethod('openDevTools', widgetId);
42
- }
43
- async openConfigRoute(widgetId, params) {
44
- return this.invokeMethod('openConfigRoute', widgetId, params);
45
- }
46
- /**
47
- * 注册激活、呼出、置顶组件快捷键
48
- * @param widgetId 组件id
49
- * @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
50
- * https://www.electronjs.org/docs/latest/api/accelerator
51
- */
52
- async registerActiveShortcut(widgetId, shortcut) {
53
- return this.invokeMethod('registerActiveShortcut', widgetId, shortcut);
54
- }
55
- async setProxy(widgetId, proxy) {
56
- return this.invokeMethod('setProxy', widgetId, proxy);
57
- }
58
- }
59
- const HostedWidgetApi = new HostedWidgetApiImpl();
60
- export { HostedWidgetApi };
@@ -1,25 +0,0 @@
1
- import { Channel } from "./Channel";
2
- import { BaseApi } from "./BaseApi";
3
- class LogApiImpl extends BaseApi {
4
- getChannel() {
5
- return Channel.LOG;
6
- }
7
- info(...data) {
8
- console.info(...data);
9
- this.invokeMethod('info', ...data);
10
- }
11
- error(...data) {
12
- console.error(...data);
13
- this.invokeMethod('error', ...data);
14
- }
15
- warn(...data) {
16
- console.warn(...data);
17
- this.invokeMethod('warn', ...data);
18
- }
19
- log(...data) {
20
- console.log(...data);
21
- this.invokeMethod('log', ...data);
22
- }
23
- }
24
- const LogApi = new LogApiImpl();
25
- export { LogApi };
@@ -1,113 +0,0 @@
1
- import { AppNotification } from "../model/AppNotification";
2
- import { Channel } from "./Channel";
3
- import { BaseApi } from "./BaseApi";
4
- var NotificationApiEvent;
5
- (function (NotificationApiEvent) {
6
- NotificationApiEvent["CONFIRM"] = "event::cn.widgetjs.core.notification.confirm";
7
- NotificationApiEvent["CANCEL"] = "event::cn.widgetjs.core.notification.cancel";
8
- NotificationApiEvent["HIDE"] = "event::cn.widgetjs.core.notification.hide";
9
- })(NotificationApiEvent || (NotificationApiEvent = {}));
10
- class NotificationApiImpl extends BaseApi {
11
- // static async url(url: string, duration: number = -1) {
12
- // this.invoke(Channel.NOTIFICATION, new AppNotification({
13
- // url, message: "",
14
- // duration,
15
- // type: "url",
16
- // }));
17
- // }
18
- /**
19
- * 来电
20
- * @param avatar 头像地址
21
- * @param audio 音频地址
22
- * @param title 标题文件
23
- * @param message 初始消息
24
- * @param lyric 歌词字符串
25
- */
26
- async call(avatar, audio, title, message, lyric) {
27
- await this.invoke(new AppNotification({
28
- avatar,
29
- audio,
30
- message,
31
- title,
32
- duration: -1,
33
- lyric,
34
- type: "call",
35
- }));
36
- }
37
- async send(notification) {
38
- return this.invokeMethod('send', notification);
39
- }
40
- async reminder(title, message, icon, cancelButtonText, confirmButtonText, cancelBroadcast, confirmBroadcast, duration = 5000) {
41
- return await this.send(new AppNotification({
42
- icon,
43
- message,
44
- title,
45
- duration,
46
- cancelButtonText,
47
- confirmButtonText,
48
- cancelBroadcast,
49
- confirmBroadcast,
50
- type: "reminder",
51
- }));
52
- }
53
- async advanceCountdown(message, targetTime, title) {
54
- return await this.send(new AppNotification({
55
- title,
56
- message,
57
- targetTime,
58
- type: "advance-countdown"
59
- }));
60
- }
61
- async countdown(message, targetTime) {
62
- await this.send(new AppNotification({
63
- message,
64
- targetTime,
65
- backgroundColor: 'rgba(0,0,0,0.5)',
66
- duration: -1,
67
- type: "countdown"
68
- }));
69
- }
70
- async success(message, duration = 5000) {
71
- await this.send(new AppNotification({
72
- message,
73
- type: "success",
74
- icon: "check_circle_line",
75
- duration
76
- }));
77
- }
78
- async error(message, duration = 5000) {
79
- await this.send(new AppNotification({
80
- message,
81
- type: "error",
82
- icon: "close_circle_line",
83
- duration
84
- }));
85
- }
86
- async warning(message, duration = 5000) {
87
- await this.send(new AppNotification({
88
- message,
89
- type: "warning",
90
- icon: "warning_line",
91
- duration
92
- }));
93
- }
94
- async info(message, duration = 5000) {
95
- await this.send(new AppNotification({
96
- message,
97
- type: "info",
98
- icon: "information_line",
99
- duration
100
- }));
101
- }
102
- /**
103
- * 隐藏通知
104
- */
105
- async hide() {
106
- await this.invokeMethod('hide');
107
- }
108
- getChannel() {
109
- return Channel.NOTIFICATION;
110
- }
111
- }
112
- const NotificationApi = new NotificationApiImpl();
113
- export { NotificationApi, NotificationApiEvent };
@@ -1,19 +0,0 @@
1
- import { BaseApi } from "./BaseApi";
2
- import { Channel } from "./Channel";
3
- var ShortcutApiEvent;
4
- (function (ShortcutApiEvent) {
5
- ShortcutApiEvent["TRIGGERED"] = "channel::cn.widgetjs.core.shortcut.triggered";
6
- })(ShortcutApiEvent || (ShortcutApiEvent = {}));
7
- class ShortcutApiImpl extends BaseApi {
8
- getChannel() {
9
- return Channel.SHORTCUT;
10
- }
11
- async register(shortcut) {
12
- return await this.invokeMethod('register', shortcut);
13
- }
14
- async unregister(shortcut) {
15
- return await this.invokeMethod('unregister', shortcut);
16
- }
17
- }
18
- const ShortcutApi = new ShortcutApiImpl();
19
- export { ShortcutApi, ShortcutApiEvent };
@@ -1,35 +0,0 @@
1
- import { BaseApi } from './BaseApi';
2
- import { Channel } from './Channel';
3
- class StoreApiImpl extends BaseApi {
4
- getChannel() {
5
- return Channel.STORE;
6
- }
7
- async delete(key) {
8
- return this.invokeMethod('delete', key);
9
- }
10
- async get(key, defaultValue) {
11
- const result = await this.invokeMethod('get', key);
12
- if (result == null && defaultValue != undefined) {
13
- return defaultValue;
14
- }
15
- return result;
16
- }
17
- async getObject(key, defaultValue) {
18
- const result = await this.invokeMethod('get', key);
19
- if (result) {
20
- return JSON.parse(result);
21
- }
22
- if (defaultValue != undefined) {
23
- return defaultValue;
24
- }
25
- return undefined;
26
- }
27
- async set(key, value) {
28
- if (typeof value == 'object') {
29
- return this.invokeMethod('set', key, JSON.stringify(value));
30
- }
31
- return this.invokeMethod('set', key, value);
32
- }
33
- }
34
- const StoreApi = new StoreApiImpl();
35
- export { StoreApi };
@@ -1,88 +0,0 @@
1
- import { Widget } from "../model/Widget";
2
- import { WidgetPackage } from "../model/WidgetPackage";
3
- import { Channel } from "./Channel";
4
- import { UrlUtils } from "../utils/UrlUtils";
5
- import { BaseApi } from "./BaseApi";
6
- var WidgetApiEvent;
7
- (function (WidgetApiEvent) {
8
- WidgetApiEvent["DATA_CHANGED"] = "event::cn.widgetjs.core.widget.data-changed";
9
- WidgetApiEvent["EDIT_DESKTOP_WIDGETS"] = "event::cn.widgetjs.core.widget.desktop.edit";
10
- })(WidgetApiEvent || (WidgetApiEvent = {}));
11
- class WidgetApiImpl extends BaseApi {
12
- getChannel() {
13
- return Channel.WIDGET;
14
- }
15
- async registerWidgets(widgets) {
16
- return this.invokeMethod("registerWidgets", JSON.stringify(widgets));
17
- }
18
- async registerWidgetPackage(widgetPackage) {
19
- return this.invokeMethod("registerWidgetPackage", JSON.stringify(widgetPackage));
20
- }
21
- async getWidgets() {
22
- const data = await this.invokeMethod('getWidgets');
23
- const widgets = [];
24
- if (data) {
25
- for (const item of data) {
26
- widgets.push(Widget.parseObject(item));
27
- }
28
- }
29
- return widgets;
30
- }
31
- async getWidgetPackages() {
32
- return await this.invokeMethod('getWidgetPackages');
33
- }
34
- /**
35
- *
36
- * @param name package name
37
- */
38
- async getWidget(name) {
39
- return Widget.parseObject(await this.invokeMethod('getWidget', name));
40
- }
41
- /**
42
- *
43
- * @param name package name
44
- */
45
- async getWidgetPackage(name) {
46
- return WidgetPackage.parseObject(await this.invokeMethod('getWidgetPackage', name));
47
- }
48
- /**
49
- * 获取组件配置地址
50
- * @param widgetName
51
- */
52
- async getWidgetConfigUrl(widgetName, widgetParams) {
53
- const widget = await this.getWidget(widgetName);
54
- if (!widget)
55
- return null;
56
- const configRoute = widget.getConfigRoute();
57
- if (!configRoute)
58
- return null;
59
- const widgetPackage = await this.getWidgetPackage(widget.packageName);
60
- if (!widgetPackage)
61
- return null;
62
- return UrlUtils.getWidgetUrl(configRoute.url, widgetPackage, widgetParams);
63
- }
64
- async getWidgetUrl(widgetName, widgetParams) {
65
- const widget = await this.getWidget(widgetName);
66
- if (!widget)
67
- return null;
68
- const indexRoute = widget.getIndexRoute();
69
- const widgetPackage = await this.getWidgetPackage(widget.packageName);
70
- if (!widgetPackage)
71
- return null;
72
- return UrlUtils.getWidgetUrl(indexRoute.url, widgetPackage, widgetParams);
73
- }
74
- async getWidgetPackageIndexUrl(packageName, hash) {
75
- const widgetPackage = await this.getWidgetPackage(packageName);
76
- if (!widgetPackage)
77
- return null;
78
- return widgetPackage.getIndexUrl(hash);
79
- }
80
- async getWidgetPackageUrl(packageName) {
81
- const widgetPackage = await this.getWidgetPackage(packageName);
82
- if (!widgetPackage)
83
- return null;
84
- return widgetPackage.url;
85
- }
86
- }
87
- const WidgetApi = new WidgetApiImpl();
88
- export { WidgetApi, WidgetApiEvent };
@@ -1,88 +0,0 @@
1
- import localforage from "localforage";
2
- import { BroadcastEvent } from "../model/event/BroadcastEvent";
3
- import { BroadcastApi } from "./BroadcastApi";
4
- import { WidgetApiEvent } from "./WidgetApi";
5
- export class WidgetDataApiImpl {
6
- constructor() {
7
- this.stores = new Map();
8
- }
9
- /**
10
- * 保存组件数据
11
- * @param data
12
- */
13
- async save(data) {
14
- let store = this.getStore(data.name);
15
- let json = JSON.stringify(data);
16
- const result = await store.setItem(this.getKey(data.name, data.id), json);
17
- const broadcastEvent = new BroadcastEvent({
18
- event: WidgetApiEvent.DATA_CHANGED, payload: { name: data.name, json }
19
- });
20
- await BroadcastApi.send(broadcastEvent);
21
- return result;
22
- }
23
- /**
24
- * 获取组件 LocalForage 存储实例
25
- * @param name
26
- */
27
- getStore(name) {
28
- if (this.stores.has(name)) {
29
- return this.stores.get(name);
30
- }
31
- const store = localforage.createInstance({ name: name });
32
- this.stores.set(name, store);
33
- return store;
34
- }
35
- /**
36
- * 通过组件名保存组件信息,通常用于存储可以在同类组件中共用的数据
37
- * @param data
38
- * @param options
39
- */
40
- async saveByName(data, options = { sendBroadcast: true }) {
41
- const store = this.getStore(data.name);
42
- const json = JSON.stringify(data);
43
- const result = await store.setItem(data.name, json);
44
- if (options === null || options === void 0 ? void 0 : options.sendBroadcast) {
45
- const broadcastEvent = new BroadcastEvent({
46
- event: WidgetApiEvent.DATA_CHANGED, payload: { name: data.name, json }
47
- });
48
- await BroadcastApi.send(broadcastEvent);
49
- }
50
- return result;
51
- }
52
- async findByName(...args) {
53
- let name = '';
54
- let dbStr = '';
55
- let data;
56
- if (args.length === 2) {
57
- name = args[0];
58
- const type = args[1];
59
- data = new type(name);
60
- }
61
- else {
62
- data = args[0];
63
- name = data.name;
64
- }
65
- let store = this.getStore(name);
66
- dbStr = await store.getItem(name);
67
- if (dbStr) {
68
- data.parseJSON(JSON.parse(dbStr));
69
- return data;
70
- }
71
- return undefined;
72
- }
73
- async find(name, id, type) {
74
- let store = this.getStore(name);
75
- let result = await store.getItem(this.getKey(name, id));
76
- if (result) {
77
- const widgetData = new type(name, id);
78
- widgetData.parseJSON(JSON.parse(result));
79
- return widgetData;
80
- }
81
- return undefined;
82
- }
83
- getKey(name, id) {
84
- return `${name}@${id}`;
85
- }
86
- }
87
- const WidgetDataApi = new WidgetDataApiImpl();
88
- export { WidgetDataApi };
package/dist/esm/index.js DELETED
@@ -1,35 +0,0 @@
1
- export * from "./model/Widget";
2
- export * from "./model/event/BroadcastEvent";
3
- export * from "./model/event/WebSocketEvent";
4
- export * from "./model/WidgetData";
5
- export * from "./model/WidgetParams";
6
- export * from "./model/AppNotification";
7
- export * from "./model/HostedMode";
8
- export * from "./model/HostedWidget";
9
- export * from "./model/interface/Rectangle";
10
- export * from "./model/msic/graphics";
11
- export * from "./model/event/NativeKeyboardEvent";
12
- export * from "./model/event/AppMouseEvent";
13
- export * from "./model/WidgetPackage";
14
- export * from "./api/ElectronApi";
15
- export * from "./api/WidgetDataApi";
16
- export * from "./api/BrowserWindowApi";
17
- export * from "./lang/LanguageCode";
18
- export * from "./api/NotificationApi";
19
- export * from "./api/HostedWidgetApi";
20
- export * from "./api/DeviceApi";
21
- export * from "./api/Channel";
22
- export * from "./api/ClipboardApi";
23
- export * from "./api/WidgetApi";
24
- export * from "./api/ApiConstants";
25
- export * from "./api/ShortcutApi";
26
- export * from "./api/BroadcastApi";
27
- export * from "./api/AppApi";
28
- export * from "./api/DialogApi";
29
- export * from "./api/StoreApi";
30
- export * from "./utils/ElectronUtils";
31
- export * from "./api/FileApi";
32
- export * from "./utils/UrlUtils";
33
- export * from "./router/query";
34
- export * from "./api/LogApi";
35
- export * from "./permission/permission";
@@ -1,33 +0,0 @@
1
- class LanguageMapImpl {
2
- constructor() {
3
- this['ar-SA'] = { locale: 'ar-SA', language: 'العربية', code: 'ar' };
4
- this['bn-BD'] = { locale: 'bn-BD', language: 'বাংলা', code: 'bn' };
5
- this['en-US'] = { locale: 'en-US', language: 'English', code: 'en' };
6
- this['de-DE'] = { locale: 'de-DE', language: 'Deutsch', code: 'de' };
7
- this['el-GR'] = { locale: 'el-GR', language: 'Ελληνικά', code: 'el' };
8
- this['es-ES'] = { locale: 'es-ES', language: 'Español', code: 'es-ES' };
9
- this['fi-FI'] = { locale: 'fi-FI', language: 'Suomalainen', code: 'fi' };
10
- this['fil-PH'] = { locale: 'fil-PH', language: 'Filipino', code: 'fil' };
11
- this['fr-FR'] = { locale: 'fr-FR', language: 'Français', code: 'fr' };
12
- this['hi-IN'] = { locale: 'hi-IN', language: 'हिंदी', code: 'hi' };
13
- this['hu-HU'] = { locale: 'hu-HU', language: 'Magyar', code: 'hu' };
14
- this['id-ID'] = { locale: 'id-ID', language: 'Bahasa Indonesia', code: 'id' };
15
- this['it-IT'] = { locale: 'it-IT', language: 'Italiano', code: 'it' };
16
- this['ja-JP'] = { locale: 'ja-JP', language: '日本語', code: 'ja' };
17
- this['ko-KR'] = { locale: 'ko-KR', language: '한국어', code: 'ko' };
18
- this['nl-NL'] = { locale: 'nl-NL', language: 'Nederlands', code: 'nl' };
19
- this['pl-PL'] = { locale: 'pl-PL', language: 'Polski', code: 'pl' };
20
- this['pt-BR'] = { locale: 'pt-BR', language: 'Português (Brazil)', code: 'pt-br' };
21
- this['pt-PT'] = { locale: 'pt-PT', language: 'Português', code: 'pt-pt' };
22
- this['ro-RO'] = { locale: 'ro-RO', language: 'Română', code: 'ro' };
23
- this['ru-RU'] = { locale: 'ru-RU', language: 'Русский', code: 'ru' };
24
- this['sv-SE'] = { locale: 'sv-SE', language: 'Svenska', code: 'sv' };
25
- this['ta-IN'] = { locale: 'ta-IN', language: 'தமிழ்', code: 'ta' };
26
- this['tr-TR'] = { locale: 'tr-TR', language: 'Türkçe', code: 'tr' };
27
- this['uk-UA'] = { locale: 'uk-UA', language: 'Українська', code: 'uk' };
28
- this['vi-VN'] = { locale: 'vi-VN', language: 'Tiếng Việt', code: 'vi' };
29
- this['zh-CN'] = { locale: 'zh-CN', language: '简体中文', code: 'zh-cn' };
30
- this['zh-TW'] = { locale: 'zh-TW', language: '繁體中文', code: 'zh-tw' };
31
- }
32
- }
33
- export {};
@@ -1,29 +0,0 @@
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.createdAt = new Date().toISOString();
12
- this.type = (_a = option.type) !== null && _a !== void 0 ? _a : "info";
13
- this.title = option.title;
14
- this.message = option.message;
15
- this.targetTime = option.targetTime;
16
- this.duration = (_b = option.duration) !== null && _b !== void 0 ? _b : 5000;
17
- this.icon = option.icon;
18
- this.color = (_c = option.color) !== null && _c !== void 0 ? _c : "#5D8AC8";
19
- this.confirmButtonText = option.confirmButtonText;
20
- this.cancelButtonText = option.cancelButtonText;
21
- this.cancelBroadcast = option.cancelBroadcast;
22
- this.confirmBroadcast = option.confirmBroadcast;
23
- this.size = (_d = option.size) !== null && _d !== void 0 ? _d : NotificationSize.NORMAL;
24
- this.audio = option.audio;
25
- this.avatar = option.avatar;
26
- this.lyric = option.lyric;
27
- this.backgroundColor = (_e = option.backgroundColor) !== null && _e !== void 0 ? _e : '#000000';
28
- }
29
- }
@@ -1,8 +0,0 @@
1
- export default class BrowserWindowStatus {
2
- constructor(width, height) {
3
- this.isAlwaysOnTop = false;
4
- this.isAutoHide = false;
5
- this.height = height;
6
- this.width = width;
7
- }
8
- }
@@ -1,15 +0,0 @@
1
- export var HostedMode;
2
- (function (HostedMode) {
3
- HostedMode[HostedMode["NORMAL"] = 1] = "NORMAL";
4
- /**
5
- * 悬浮窗
6
- */
7
- HostedMode[HostedMode["OVERLAP"] = 16] = "OVERLAP";
8
- HostedMode[HostedMode["WALLPAPER"] = 256] = "WALLPAPER";
9
- HostedMode[HostedMode["SCREEN"] = 4096] = "SCREEN";
10
- /**
11
- * 后台组件,没有界面,一般在后台执行定时任务
12
- */
13
- HostedMode[HostedMode["BACKGROUND"] = 65536] = "BACKGROUND";
14
- HostedMode[HostedMode["ALL"] = 69905] = "ALL";
15
- })(HostedMode || (HostedMode = {}));
@@ -1,10 +0,0 @@
1
- import { HostedMode } from "./HostedMode";
2
- export class HostedWidget {
3
- constructor() {
4
- this.x = 0;
5
- this.y = 0;
6
- }
7
- isOverlap() {
8
- return (this.hostedMode & HostedMode.OVERLAP) > 0;
9
- }
10
- }
@@ -1,6 +0,0 @@
1
- export class SocialInfo {
2
- constructor(name, url) {
3
- this.name = name;
4
- this.content = url;
5
- }
6
- }