@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,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WebSocketEvent = exports.WebSocketEventType = void 0;
4
- var WebSocketEventType;
5
- (function (WebSocketEventType) {
6
- WebSocketEventType["RESISTER_WIDGETS"] = "ws::cn.widgetjs.core.resister_widgets";
7
- })(WebSocketEventType = exports.WebSocketEventType || (exports.WebSocketEventType = {}));
8
- class WebSocketEvent {
9
- constructor(type, payload) {
10
- this.type = type;
11
- this.payload = payload;
12
- }
13
- }
14
- exports.WebSocketEvent = WebSocketEvent;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Gravity = void 0;
4
- var Gravity;
5
- (function (Gravity) {
6
- Gravity["TOP"] = "TOP";
7
- Gravity["LEFT"] = "LEFT";
8
- Gravity["RIGHT"] = "RIGHT";
9
- Gravity["BOTTOM"] = "BOTTOM";
10
- })(Gravity = exports.Gravity || (exports.Gravity = {}));
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,144 +0,0 @@
1
- "use strict";
2
- /**
3
- * Encoding Rules ␣ = Space Path: ␣ " < > # ? { } Query: ␣ " < > # & = Hash: ␣ "
4
- * < > `
5
- *
6
- * On top of that, the RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.2)
7
- * defines some extra characters to be encoded. Most browsers do not encode them
8
- * in encodeURI https://github.com/whatwg/url/issues/369, so it may be safer to
9
- * also encode `!'()*`. Leaving un-encoded only ASCII alphanumeric(`a-zA-Z0-9`)
10
- * plus `-._~`. This extra safety should be applied to query by patching the
11
- * string returned by encodeURIComponent encodeURI also encodes `[\]^`. `\`
12
- * should be encoded to avoid ambiguity. Browsers (IE, FF, C) transform a `\`
13
- * into a `/` if directly typed in. The _backtick_ (`````) should also be
14
- * encoded everywhere because some browsers like FF encode it when directly
15
- * written while others don't. Safari and IE don't encode ``"<>{}``` in hash.
16
- */
17
- // const EXTRA_RESERVED_RE = /[!'()*]/g
18
- // const encodeReservedReplacer = (c: string) => '%' + c.charCodeAt(0).toString(16)
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.decode = exports.encodeParam = exports.encodePath = exports.encodeQueryKey = exports.encodeQueryValue = exports.encodeHash = exports.PLUS_RE = void 0;
21
- const HASH_RE = /#/g; // %23
22
- const AMPERSAND_RE = /&/g; // %26
23
- const SLASH_RE = /\//g; // %2F
24
- const EQUAL_RE = /=/g; // %3D
25
- const IM_RE = /\?/g; // %3F
26
- exports.PLUS_RE = /\+/g; // %2B
27
- /**
28
- * NOTE: It's not clear to me if we should encode the + symbol in queries, it
29
- * seems to be less flexible than not doing so and I can't find out the legacy
30
- * systems requiring this for regular requests like text/html. In the standard,
31
- * the encoding of the plus character is only mentioned for
32
- * application/x-www-form-urlencoded
33
- * (https://url.spec.whatwg.org/#urlencoded-parsing) and most browsers seems lo
34
- * leave the plus character as is in queries. To be more flexible, we allow the
35
- * plus character on the query, but it can also be manually encoded by the user.
36
- *
37
- * Resources:
38
- * - https://url.spec.whatwg.org/#urlencoded-parsing
39
- * - https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
40
- */
41
- const ENC_BRACKET_OPEN_RE = /%5B/g; // [
42
- const ENC_BRACKET_CLOSE_RE = /%5D/g; // ]
43
- const ENC_CARET_RE = /%5E/g; // ^
44
- const ENC_BACKTICK_RE = /%60/g; // `
45
- const ENC_CURLY_OPEN_RE = /%7B/g; // {
46
- const ENC_PIPE_RE = /%7C/g; // |
47
- const ENC_CURLY_CLOSE_RE = /%7D/g; // }
48
- const ENC_SPACE_RE = /%20/g; // }
49
- /**
50
- * Encode characters that need to be encoded on the path, search and hash
51
- * sections of the URL.
52
- *
53
- * @internal
54
- * @param text - string to encode
55
- * @returns encoded string
56
- */
57
- function commonEncode(text) {
58
- return encodeURI('' + text)
59
- .replace(ENC_PIPE_RE, '|')
60
- .replace(ENC_BRACKET_OPEN_RE, '[')
61
- .replace(ENC_BRACKET_CLOSE_RE, ']');
62
- }
63
- /**
64
- * Encode characters that need to be encoded on the hash section of the URL.
65
- *
66
- * @param text - string to encode
67
- * @returns encoded string
68
- */
69
- function encodeHash(text) {
70
- return commonEncode(text)
71
- .replace(ENC_CURLY_OPEN_RE, '{')
72
- .replace(ENC_CURLY_CLOSE_RE, '}')
73
- .replace(ENC_CARET_RE, '^');
74
- }
75
- exports.encodeHash = encodeHash;
76
- /**
77
- * Encode characters that need to be encoded query values on the query
78
- * section of the URL.
79
- *
80
- * @param text - string to encode
81
- * @returns encoded string
82
- */
83
- function encodeQueryValue(text) {
84
- return (commonEncode(text)
85
- // Encode the space as +, encode the + to differentiate it from the space
86
- .replace(exports.PLUS_RE, '%2B')
87
- .replace(ENC_SPACE_RE, '+')
88
- .replace(HASH_RE, '%23')
89
- .replace(AMPERSAND_RE, '%26')
90
- .replace(ENC_BACKTICK_RE, '`')
91
- .replace(ENC_CURLY_OPEN_RE, '{')
92
- .replace(ENC_CURLY_CLOSE_RE, '}')
93
- .replace(ENC_CARET_RE, '^'));
94
- }
95
- exports.encodeQueryValue = encodeQueryValue;
96
- /**
97
- * Like `encodeQueryValue` but also encodes the `=` character.
98
- *
99
- * @param text - string to encode
100
- */
101
- function encodeQueryKey(text) {
102
- return encodeQueryValue(text).replace(EQUAL_RE, '%3D');
103
- }
104
- exports.encodeQueryKey = encodeQueryKey;
105
- /**
106
- * Encode characters that need to be encoded on the path section of the URL.
107
- *
108
- * @param text - string to encode
109
- * @returns encoded string
110
- */
111
- function encodePath(text) {
112
- return commonEncode(text).replace(HASH_RE, '%23').replace(IM_RE, '%3F');
113
- }
114
- exports.encodePath = encodePath;
115
- /**
116
- * Encode characters that need to be encoded on the path section of the URL as a
117
- * param. This function encodes everything {@link encodePath} does plus the
118
- * slash (`/`) character. If `text` is `null` or `undefined`, returns an empty
119
- * string instead.
120
- *
121
- * @param text - string to encode
122
- * @returns encoded string
123
- */
124
- function encodeParam(text) {
125
- return text == null ? '' : encodePath(text).replace(SLASH_RE, '%2F');
126
- }
127
- exports.encodeParam = encodeParam;
128
- /**
129
- * Decode text using `decodeURIComponent`. Returns the original text if it
130
- * fails.
131
- *
132
- * @param text - string to decode
133
- * @returns decoded string
134
- */
135
- function decode(text) {
136
- try {
137
- return decodeURIComponent('' + text);
138
- }
139
- catch (err) {
140
- // __DEV__ && warn(`Error decoding "${text}". Using original value`)
141
- }
142
- return '' + text;
143
- }
144
- exports.decode = decode;
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringifyQuery = exports.parseQuery = void 0;
4
- const encoding_1 = require("./encoding");
5
- const isArray = Array.isArray;
6
- /**
7
- * Transforms a queryString into a {@link LocationQuery} object. Accept both, a
8
- * version with the leading `?` and without Should work as URLSearchParams
9
- * @internal
10
- *
11
- * @param search - search string to parse
12
- * @returns a query object
13
- */
14
- function parseQuery(search) {
15
- const query = {};
16
- // avoid creating an object with an empty key and empty value
17
- // because of split('&')
18
- if (search === '' || search === '?')
19
- return query;
20
- const hasLeadingIM = search[0] === '?';
21
- const searchParams = (hasLeadingIM ? search.slice(1) : search).split('&');
22
- for (let i = 0; i < searchParams.length; ++i) {
23
- // pre decode the + into space
24
- const searchParam = searchParams[i].replace(encoding_1.PLUS_RE, ' ');
25
- // allow the = character
26
- const eqPos = searchParam.indexOf('=');
27
- const key = (0, encoding_1.decode)(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
28
- const value = eqPos < 0 ? null : (0, encoding_1.decode)(searchParam.slice(eqPos + 1));
29
- if (key in query) {
30
- // an extra variable for ts types
31
- let currentValue = query[key];
32
- if (!isArray(currentValue)) {
33
- currentValue = query[key] = [currentValue];
34
- }
35
- // we force the modification
36
- ;
37
- currentValue.push(value);
38
- }
39
- else {
40
- query[key] = value;
41
- }
42
- }
43
- return query;
44
- }
45
- exports.parseQuery = parseQuery;
46
- /**
47
- * Stringifies a {@link LocationQueryRaw} object. Like `URLSearchParams`, it
48
- * doesn't prepend a `?`
49
- *
50
- * @internal
51
- *
52
- * @param query - query object to stringify
53
- * @returns string version of the query without the leading `?`
54
- */
55
- function stringifyQuery(query) {
56
- let search = '';
57
- for (let key in query) {
58
- const value = query[key];
59
- key = (0, encoding_1.encodeQueryKey)(key);
60
- if (value == null) {
61
- // only null adds the value
62
- if (value !== undefined) {
63
- search += (search.length ? '&' : '') + key;
64
- }
65
- continue;
66
- }
67
- // keep null values
68
- const values = isArray(value)
69
- ? value.map(v => v && (0, encoding_1.encodeQueryValue)(v))
70
- : [value && (0, encoding_1.encodeQueryValue)(value)];
71
- values.forEach(value => {
72
- // skip undefined values in arrays as if they were not present
73
- // smaller code than using filter
74
- if (value !== undefined) {
75
- // only append & with non-empty search
76
- search += (search.length ? '&' : '') + key;
77
- if (value != null)
78
- search += '=' + value;
79
- }
80
- });
81
- }
82
- return search;
83
- }
84
- exports.stringifyQuery = stringifyQuery;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ElectronUtils = void 0;
4
- class ElectronUtils {
5
- static hasElectronApi() {
6
- return this.getAPI() != null;
7
- }
8
- /**
9
- * 获取ElectronAPI
10
- * windows api
11
- */
12
- static getAPI() {
13
- if (Reflect.has(window, "electronAPI")) {
14
- //@ts-ignore
15
- return window.electronAPI;
16
- }
17
- else if (Reflect.has(window.parent, "electronAPI")) {
18
- //@ts-ignore
19
- return window.parent.electronAPI;
20
- }
21
- return null;
22
- }
23
- static async invokeMethod(channel, method, ...args) {
24
- var _a;
25
- return (_a = this.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(channel, method, ...args);
26
- }
27
- static async invoke(channel, ...args) {
28
- var _a;
29
- return (_a = this.getAPI()) === null || _a === void 0 ? void 0 : _a.invoke(channel, ...args);
30
- }
31
- }
32
- exports.ElectronUtils = ElectronUtils;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTextByLanguageCode = void 0;
4
- /**
5
- * 根据语言环境获取文本
6
- * @param langMap 对象
7
- * @param {LanguageCode} langCode 语言环境 例如:zh-CN,en-US
8
- * @param fallbackToBrowser
9
- */
10
- function getTextByLanguageCode(langMap, langCode, fallbackToBrowser = true) {
11
- let result;
12
- if (langCode) {
13
- if (langCode in langMap) {
14
- return langMap[langCode];
15
- }
16
- }
17
- // fallback to browser default language
18
- if (result == undefined && fallbackToBrowser) {
19
- if (typeof navigator != 'undefined' && navigator.languages) {
20
- const langCode = navigator.language;
21
- result = getTextByLanguageCode(langMap, langCode, false);
22
- if (result != undefined) {
23
- return result;
24
- }
25
- }
26
- }
27
- // fallback to first language
28
- if (result == undefined) {
29
- let langCode = Object.keys(langMap);
30
- if (langCode.length > 0) {
31
- return langMap[langCode[0]];
32
- }
33
- }
34
- return undefined;
35
- }
36
- exports.getTextByLanguageCode = getTextByLanguageCode;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UrlUtils = void 0;
4
- class UrlUtils {
5
- static getWidgetUrl(widgetUrl, widgetPackage, widgetParams) {
6
- let url = "";
7
- if (widgetUrl.startsWith("http")) {
8
- url = widgetUrl;
9
- }
10
- else {
11
- url = widgetPackage.getIndexUrl() + widgetUrl;
12
- }
13
- if (url.includes("?")) {
14
- return url + "&" + widgetParams.toUrlParams().toString();
15
- }
16
- else {
17
- return url + "?" + widgetParams.toUrlParams().toString();
18
- }
19
- }
20
- static getWidgetPackageIndexUrl(url, entry, hash) {
21
- const arr = [url];
22
- if (url.startsWith("http")) {
23
- if (hash) {
24
- arr.push(url.endsWith("/") ? "#" : "/#");
25
- }
26
- }
27
- else {
28
- arr.push(entry.startsWith("/") ? entry : `/${entry}`);
29
- if (hash) {
30
- arr.push(url.endsWith("#") ? "" : "#");
31
- }
32
- }
33
- return arr.join("");
34
- }
35
- }
36
- exports.UrlUtils = UrlUtils;
@@ -1,5 +0,0 @@
1
- export var AppPermission;
2
- (function (AppPermission) {
3
- AppPermission["ACCESS_MOUSE_EVENT"] = "ACCESS_MOUSE_EVENT";
4
- AppPermission["ACCESS_KEYBOARD_EVENT"] = "ACCESS_KEYBOARD_EVENT";
5
- })(AppPermission || (AppPermission = {}));
@@ -1,7 +0,0 @@
1
- export class ApiConstants {
2
- }
3
- ApiConstants.CONFIG_LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
4
- ApiConstants.CONFIG_WIDGET_TITLE_COLOR = "CONFIG_WIDGET_TITLE_COLOR";
5
- ApiConstants.CONFIG_DEBUG_MODE = "cn.widgetjs.config.debug";
6
- ApiConstants.CONFIG_GRID_SIZE = "cn.widgetjs.config.grid.size";
7
- ApiConstants.SHORTCUT_PIN_DESKTOP_WIDGETS = "cn.widgetjs.config.shortcut.pin_desktop_widgets";
@@ -1,47 +0,0 @@
1
- import { Channel } from "./Channel";
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
- async getIconFile() {
9
- return this.invokeMethod('getIconFile');
10
- }
11
- getChannel() {
12
- return Channel.APP;
13
- }
14
- async setConfig(key, value) {
15
- return await this.invokeMethod('setConfig', key, value);
16
- }
17
- async getConfig(key, defaultValue) {
18
- const value = await this.invokeMethod("getConfig", key);
19
- if (value === null || value === undefined) {
20
- return defaultValue;
21
- }
22
- if (typeof defaultValue == "boolean") {
23
- return value === "true";
24
- }
25
- if (typeof defaultValue == "number") {
26
- return Number(value);
27
- }
28
- return value;
29
- }
30
- async openAddWidgetWindow() {
31
- return this.invokeMethod('openAddWidgetWindow');
32
- }
33
- /**
34
- * 获取应用版本号,格式为 x.y.z
35
- */
36
- async getVersion() {
37
- return this.invokeMethod('getVersion');
38
- }
39
- async getPreloadPath() {
40
- return this.invokeMethod('getPreloadPath');
41
- }
42
- async openSettingWindow() {
43
- return this.invokeMethod('openSettingWindow');
44
- }
45
- }
46
- const AppApi = new AppApiImpl();
47
- export { AppApi, AppApiEvent };
@@ -1,9 +0,0 @@
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,18 +0,0 @@
1
- import { Channel } from "./Channel";
2
- import { BaseApi } from "./BaseApi";
3
- export class BroadcastApiImpl extends BaseApi {
4
- async send(event) {
5
- await this.invokeMethod('send', event);
6
- }
7
- async register(...event) {
8
- await this.invokeMethod('register', event);
9
- }
10
- async unregister(...event) {
11
- await this.invokeMethod('unregister', event);
12
- }
13
- getChannel() {
14
- return Channel.BROADCAST;
15
- }
16
- }
17
- const BroadcastApi = new BroadcastApiImpl();
18
- export { BroadcastApi };
@@ -1,139 +0,0 @@
1
- import { Channel } from "./Channel";
2
- import { ElectronUtils } from "../utils/ElectronUtils";
3
- import { BaseApi } from "./BaseApi";
4
- var BrowserWindowApiEvent;
5
- (function (BrowserWindowApiEvent) {
6
- BrowserWindowApiEvent["BLUR"] = "event::cn.widgetjs.core.browser-window.blur";
7
- BrowserWindowApiEvent["FOCUS"] = "event::cn.widgetjs.core.browser-window.focus";
8
- BrowserWindowApiEvent["SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.snap_to_edge";
9
- BrowserWindowApiEvent["RESIZE"] = "event::cn.widgetjs.core.browser-window.resize";
10
- BrowserWindowApiEvent["CANCEL_SNAP_TO_EDGE"] = "event::cn.widgetjs.core.browser-window.cancel_snap_to_edge";
11
- })(BrowserWindowApiEvent || (BrowserWindowApiEvent = {}));
12
- export class BrowserWindowApiImpl extends BaseApi {
13
- getChannel() {
14
- return Channel.BROWSER_WINDOW;
15
- }
16
- async setIgnoreMouseEvent(ignore) {
17
- await this.invokeMethod('setIgnoreMouseEvent', ignore);
18
- }
19
- async show() {
20
- await this.invokeMethod('show', true);
21
- }
22
- async showInactive() {
23
- await this.invokeMethod('showInactive', true);
24
- }
25
- async hide() {
26
- await this.invokeMethod('hide', false);
27
- }
28
- async center() {
29
- await this.invokeMethod('center', false);
30
- }
31
- async setAlwaysOnTop(alwaysOnTop) {
32
- await this.invokeMethod('setAlwaysOnTop', alwaysOnTop);
33
- }
34
- async isAlwaysOnTop() {
35
- return await this.invokeMethod('isAlwaysOnTop');
36
- }
37
- async openUrl(url, option) {
38
- if (ElectronUtils.hasElectronApi()) {
39
- await this.invokeMethod('openUrl', url, option);
40
- }
41
- else {
42
- window.open(url, '_blank');
43
- }
44
- }
45
- async moveTop() {
46
- await this.invokeMethod('moveTop');
47
- }
48
- async openDevTools() {
49
- await this.invokeMethod('openDevTools');
50
- }
51
- async setPosition(options) {
52
- await this.invokeMethod('setPosition', options);
53
- }
54
- async getPosition() {
55
- return await this.invokeMethod('getPosition');
56
- }
57
- async blur() {
58
- return await this.invokeMethod('blur');
59
- }
60
- async focus() {
61
- return await this.invokeMethod('focus');
62
- }
63
- /**
64
- * 设置窗口是否可以拉伸
65
- * @param resizable
66
- */
67
- async setResizable(resizable) {
68
- return await this.invokeMethod('setResizable', resizable);
69
- }
70
- async getBounds() {
71
- return await this.invokeMethod('getBounds');
72
- }
73
- async setBounds(bounds, animate) {
74
- return await this.invokeMethod("setBounds", bounds, animate);
75
- }
76
- async alignToScreen(align) {
77
- return await this.invokeMethod('alignToScreen', align);
78
- }
79
- async startDraggingWindow() {
80
- return await this.invokeMethod('startDraggingWindow');
81
- }
82
- async stopDraggingWindow() {
83
- return await this.invokeMethod('stopDraggingWindow');
84
- }
85
- /**
86
- * 通过url检测窗口是否存在
87
- * @param url
88
- */
89
- async existsByUrl(url) {
90
- return await this.invokeMethod('existsByUrl', url);
91
- }
92
- async getMaximumSize() {
93
- return await this.invokeMethod('getMaximumSize');
94
- }
95
- async minimize() {
96
- return await this.invokeMethod('minimize');
97
- }
98
- async maximize() {
99
- return await this.invokeMethod('maximize');
100
- }
101
- async isMaximized() {
102
- return await this.invokeMethod('isMaximized');
103
- }
104
- async isMinimized() {
105
- return await this.invokeMethod('isMinimized');
106
- }
107
- async restore() {
108
- return await this.invokeMethod('restore');
109
- }
110
- async unmaximize() {
111
- return await this.invokeMethod('unmaximize');
112
- }
113
- async setZoomLevel(level) {
114
- return await this.invokeMethod('setZoomLevel');
115
- }
116
- async reload() {
117
- return await this.invokeMethod('reload');
118
- }
119
- async setMovable(movable) {
120
- return await this.invokeMethod('setMovable', movable);
121
- }
122
- async setSize(width, height, animate) {
123
- return this.invokeMethod('setSize', width, height, animate);
124
- }
125
- async isFocused() {
126
- return this.invokeMethod('isFocused');
127
- }
128
- async setMaximumSize(width, height) {
129
- return this.invokeMethod('setMaximumSize', width, height);
130
- }
131
- async setMinimumSize(width, height) {
132
- return this.invokeMethod('setMinimumSize', width, height);
133
- }
134
- getMinimumSize() {
135
- return this.invokeMethod('getMinimumSize');
136
- }
137
- }
138
- const BrowserWindowApi = new BrowserWindowApiImpl();
139
- export { BrowserWindowApi, BrowserWindowApiEvent };
@@ -1,19 +0,0 @@
1
- export var Channel;
2
- (function (Channel) {
3
- Channel["NOTIFICATION"] = "channel::cn.widgetjs.core.notification";
4
- Channel["BROWSER_WINDOW"] = "channel::cn.widgetjs.core.browser_window";
5
- Channel["BROADCAST"] = "channel::cn.widgetjs.core.broadcast";
6
- Channel["WIDGET"] = "channel::cn.widgetjs.core.widget";
7
- Channel["HOSTED_WIDGET"] = "channel::cn.widgetjs.core.hosted_widget";
8
- Channel["APP"] = "channel::cn.widgetjs.core.app";
9
- Channel["DIALOG"] = "channel::cn.widgetjs.core.dialog";
10
- Channel["CLIPBOARD"] = "channel::cn.widgetjs.core.clipboard";
11
- Channel["FILE"] = "channel::cn.widgetjs.core.file";
12
- Channel["SCREEN"] = "channel::cn.widgetjs.core.screen";
13
- Channel["SHORTCUT"] = "channel::cn.widgetjs.core.shortcut";
14
- Channel["LOG"] = "channel::cn.widgetjs.core.log";
15
- Channel["DEVICE"] = "channel::cn.widgetjs.core.device";
16
- Channel["MOUSE"] = "channel::cn.widgetjs.core.mouse";
17
- Channel["KEYBOARD"] = "channel::cn.widgetjs.core.keyboard";
18
- Channel["STORE"] = "channel::cn.widgetjs.core.store";
19
- })(Channel || (Channel = {}));
@@ -1,19 +0,0 @@
1
- import { Channel } from "./Channel";
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');
10
- }
11
- async getText() {
12
- return this.invokeMethod('getText');
13
- }
14
- getChannel() {
15
- return Channel.CLIPBOARD;
16
- }
17
- }
18
- const ClipboardApi = new ClipboardApiImpl();
19
- export { ClipboardApi, ClipboardApiEvent };
@@ -1,21 +0,0 @@
1
- import { Channel } from "./Channel";
2
- import { BaseApi } from "./BaseApi";
3
- export class DeviceApiImpl extends BaseApi {
4
- /**
5
- * 获取当前鼠标位置
6
- */
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;
18
- }
19
- }
20
- const DeviceApi = new DeviceApiImpl();
21
- export { DeviceApi };