@widget-js/core 0.11.22-beta.2 → 24.1.1-beta.1
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/electron.d.ts +6444 -6479
- package/dist/index.cjs +92 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +109 -106
- package/dist/index.js +91 -72
- package/dist/index.js.map +1 -1
- package/package.json +15 -16
package/dist/index.cjs
CHANGED
|
@@ -635,6 +635,7 @@ __export(src_exports, {
|
|
|
635
635
|
ShortcutApi: () => ShortcutApi,
|
|
636
636
|
ShortcutApiEvent: () => ShortcutApiEvent,
|
|
637
637
|
StoreApi: () => StoreApi,
|
|
638
|
+
SystemApiEvent: () => SystemApiEvent,
|
|
638
639
|
ThemeMode: () => ThemeMode,
|
|
639
640
|
WebSocketEvent: () => WebSocketEvent,
|
|
640
641
|
WebSocketEventType: () => WebSocketEventType,
|
|
@@ -691,7 +692,7 @@ function getTextByLanguageCode(langMap, langCode, fallbackToBrowser = true) {
|
|
|
691
692
|
}
|
|
692
693
|
}
|
|
693
694
|
if (result == void 0) {
|
|
694
|
-
|
|
695
|
+
const langCode2 = Object.keys(langMap);
|
|
695
696
|
if (langCode2.length > 0) {
|
|
696
697
|
return langMap[langCode2[0]];
|
|
697
698
|
}
|
|
@@ -701,7 +702,7 @@ function getTextByLanguageCode(langMap, langCode, fallbackToBrowser = true) {
|
|
|
701
702
|
|
|
702
703
|
// src/model/Page.ts
|
|
703
704
|
var Page = class {
|
|
704
|
-
|
|
705
|
+
// 窗口名称,名称与包名类似,e.g. com.example.countdown
|
|
705
706
|
name;
|
|
706
707
|
/**
|
|
707
708
|
* 窗口标题,显示在界面上的,
|
|
@@ -773,8 +774,9 @@ var Page = class {
|
|
|
773
774
|
* @param lang 语言环境,不传则获取默认标题
|
|
774
775
|
*/
|
|
775
776
|
getDescription(lang) {
|
|
776
|
-
if (this.description == void 0)
|
|
777
|
+
if (this.description == void 0) {
|
|
777
778
|
return void 0;
|
|
779
|
+
}
|
|
778
780
|
return getTextByLanguageCode(this.description, lang);
|
|
779
781
|
}
|
|
780
782
|
static parseJSON(json) {
|
|
@@ -782,7 +784,7 @@ var Page = class {
|
|
|
782
784
|
return this.parseObject(object);
|
|
783
785
|
}
|
|
784
786
|
static parseObject(obj) {
|
|
785
|
-
|
|
787
|
+
const widget = new Page({
|
|
786
788
|
path: "",
|
|
787
789
|
description: {},
|
|
788
790
|
height: 0,
|
|
@@ -825,7 +827,7 @@ var Widget = class extends Page {
|
|
|
825
827
|
return this.parseObject(object);
|
|
826
828
|
}
|
|
827
829
|
static parseObject(obj) {
|
|
828
|
-
|
|
830
|
+
const widget = new Widget({
|
|
829
831
|
path: "",
|
|
830
832
|
description: {},
|
|
831
833
|
height: 0,
|
|
@@ -890,7 +892,7 @@ var WebSocketEventType = /* @__PURE__ */ ((WebSocketEventType2) => {
|
|
|
890
892
|
return WebSocketEventType2;
|
|
891
893
|
})(WebSocketEventType || {});
|
|
892
894
|
var WebSocketEvent = class {
|
|
893
|
-
|
|
895
|
+
// 类型
|
|
894
896
|
type;
|
|
895
897
|
payload;
|
|
896
898
|
constructor(type, payload) {
|
|
@@ -969,7 +971,7 @@ var WidgetData = class {
|
|
|
969
971
|
const properties = {};
|
|
970
972
|
if (this.theme) {
|
|
971
973
|
const prefix = "--widget-";
|
|
972
|
-
|
|
974
|
+
const keys = Object.keys(this.theme);
|
|
973
975
|
keys.filter((key) => this.theme[key] != void 0).map((key) => {
|
|
974
976
|
properties[`${prefix}${(0, import_kebabCase.default)(key)}`] = `${this.theme[key]}`;
|
|
975
977
|
});
|
|
@@ -988,6 +990,9 @@ var WidgetData = class {
|
|
|
988
990
|
}
|
|
989
991
|
};
|
|
990
992
|
|
|
993
|
+
// src/model/WidgetParams.ts
|
|
994
|
+
var import_snakeCase = __toESM(require_snakeCase(), 1);
|
|
995
|
+
|
|
991
996
|
// src/router/encoding.ts
|
|
992
997
|
var HASH_RE = /#/g;
|
|
993
998
|
var AMPERSAND_RE = /&/g;
|
|
@@ -1002,7 +1007,7 @@ var ENC_PIPE_RE = /%7C/g;
|
|
|
1002
1007
|
var ENC_CURLY_CLOSE_RE = /%7D/g;
|
|
1003
1008
|
var ENC_SPACE_RE = /%20/g;
|
|
1004
1009
|
function commonEncode(text) {
|
|
1005
|
-
return encodeURI(
|
|
1010
|
+
return encodeURI(`${text}`).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
|
|
1006
1011
|
}
|
|
1007
1012
|
function encodeQueryValue(text) {
|
|
1008
1013
|
return commonEncode(text).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
|
|
@@ -1012,18 +1017,19 @@ function encodeQueryKey(text) {
|
|
|
1012
1017
|
}
|
|
1013
1018
|
function decode(text) {
|
|
1014
1019
|
try {
|
|
1015
|
-
return decodeURIComponent(
|
|
1020
|
+
return decodeURIComponent(`${text}`);
|
|
1016
1021
|
} catch (err) {
|
|
1017
1022
|
}
|
|
1018
|
-
return
|
|
1023
|
+
return `${text}`;
|
|
1019
1024
|
}
|
|
1020
1025
|
|
|
1021
1026
|
// src/router/query.ts
|
|
1022
1027
|
var isArray = Array.isArray;
|
|
1023
1028
|
function parseQuery(search) {
|
|
1024
1029
|
const query = {};
|
|
1025
|
-
if (search === "" || search === "?")
|
|
1030
|
+
if (search === "" || search === "?") {
|
|
1026
1031
|
return query;
|
|
1032
|
+
}
|
|
1027
1033
|
const hasLeadingIM = search[0] === "?";
|
|
1028
1034
|
const searchParams = (hasLeadingIM ? search.slice(1) : search).split("&");
|
|
1029
1035
|
for (let i = 0; i < searchParams.length; ++i) {
|
|
@@ -1059,8 +1065,9 @@ function stringifyQuery(query) {
|
|
|
1059
1065
|
values.forEach((value2) => {
|
|
1060
1066
|
if (value2 !== void 0) {
|
|
1061
1067
|
search += (search.length ? "&" : "") + key;
|
|
1062
|
-
if (value2 != null)
|
|
1063
|
-
search +=
|
|
1068
|
+
if (value2 != null) {
|
|
1069
|
+
search += `=${value2}`;
|
|
1070
|
+
}
|
|
1064
1071
|
}
|
|
1065
1072
|
});
|
|
1066
1073
|
}
|
|
@@ -1068,31 +1075,30 @@ function stringifyQuery(query) {
|
|
|
1068
1075
|
}
|
|
1069
1076
|
|
|
1070
1077
|
// src/model/WidgetParams.ts
|
|
1071
|
-
var import_snakeCase = __toESM(require_snakeCase(), 1);
|
|
1072
1078
|
var _WidgetParams = class {
|
|
1073
|
-
|
|
1079
|
+
// 组件id
|
|
1074
1080
|
id;
|
|
1075
|
-
|
|
1081
|
+
// 网格宽度,1就代表宽度占用1格
|
|
1076
1082
|
width;
|
|
1077
|
-
|
|
1083
|
+
// 宽度,单位px
|
|
1078
1084
|
widthPx;
|
|
1079
|
-
|
|
1085
|
+
// 宽度,单位px
|
|
1080
1086
|
heightPx;
|
|
1081
|
-
|
|
1087
|
+
// 网格高度,2就代表高度占用2格
|
|
1082
1088
|
height;
|
|
1083
1089
|
x;
|
|
1084
1090
|
y;
|
|
1085
|
-
|
|
1091
|
+
// 是否是预览模式,添加组件时,预览状态
|
|
1086
1092
|
preview;
|
|
1087
|
-
|
|
1093
|
+
// 语言环境:zh,en,jp...
|
|
1088
1094
|
lang;
|
|
1089
|
-
|
|
1095
|
+
// 主题:浅色,深色
|
|
1090
1096
|
theme;
|
|
1091
1097
|
//
|
|
1092
1098
|
mode;
|
|
1093
|
-
|
|
1099
|
+
// 系统设置的组件圆角半径
|
|
1094
1100
|
radius;
|
|
1095
|
-
|
|
1101
|
+
// 组件名
|
|
1096
1102
|
name;
|
|
1097
1103
|
title;
|
|
1098
1104
|
/**
|
|
@@ -1103,7 +1109,7 @@ var _WidgetParams = class {
|
|
|
1103
1109
|
toUrlParams() {
|
|
1104
1110
|
const urlParams = new URLSearchParams();
|
|
1105
1111
|
const ownPropertyNames = Object.getOwnPropertyNames(this);
|
|
1106
|
-
for (
|
|
1112
|
+
for (const ownPropertyName of ownPropertyNames) {
|
|
1107
1113
|
const key = ownPropertyName;
|
|
1108
1114
|
const value = this[key];
|
|
1109
1115
|
if (value) {
|
|
@@ -1123,17 +1129,17 @@ var _WidgetParams = class {
|
|
|
1123
1129
|
*/
|
|
1124
1130
|
static fromCurrentLocation() {
|
|
1125
1131
|
const href = window.location.href;
|
|
1126
|
-
|
|
1132
|
+
const strings = href.split("?");
|
|
1127
1133
|
if (strings.length > 1) {
|
|
1128
|
-
|
|
1134
|
+
const queryString = strings[1];
|
|
1129
1135
|
return this.fromObject(parseQuery(queryString));
|
|
1130
1136
|
}
|
|
1131
1137
|
return new _WidgetParams();
|
|
1132
1138
|
}
|
|
1133
1139
|
static fromLocation(url) {
|
|
1134
|
-
|
|
1140
|
+
const strings = url.split("?");
|
|
1135
1141
|
if (strings.length > 1) {
|
|
1136
|
-
|
|
1142
|
+
const queryString = strings[1];
|
|
1137
1143
|
return this.fromObject(parseQuery(queryString));
|
|
1138
1144
|
}
|
|
1139
1145
|
return new _WidgetParams();
|
|
@@ -1143,25 +1149,25 @@ var _WidgetParams = class {
|
|
|
1143
1149
|
if (keyWithoutPrefix == _WidgetParams.PARAM_ID) {
|
|
1144
1150
|
widgetEnv.id = value;
|
|
1145
1151
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_X) {
|
|
1146
|
-
widgetEnv.x = parseInt(value);
|
|
1152
|
+
widgetEnv.x = Number.parseInt(value);
|
|
1147
1153
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_Y) {
|
|
1148
|
-
widgetEnv.y = parseInt(value);
|
|
1154
|
+
widgetEnv.y = Number.parseInt(value);
|
|
1149
1155
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_HEIGHT) {
|
|
1150
|
-
widgetEnv.height = parseInt(value);
|
|
1156
|
+
widgetEnv.height = Number.parseInt(value);
|
|
1151
1157
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_WIDTH) {
|
|
1152
|
-
widgetEnv.width = parseInt(value);
|
|
1158
|
+
widgetEnv.width = Number.parseInt(value);
|
|
1153
1159
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_LANG) {
|
|
1154
1160
|
widgetEnv.lang = value;
|
|
1155
1161
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_THEME) {
|
|
1156
1162
|
widgetEnv.theme = value;
|
|
1157
1163
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_MODE) {
|
|
1158
|
-
widgetEnv.mode = parseInt(value);
|
|
1164
|
+
widgetEnv.mode = Number.parseInt(value);
|
|
1159
1165
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_RADIUS) {
|
|
1160
|
-
widgetEnv.radius = parseInt(value);
|
|
1166
|
+
widgetEnv.radius = Number.parseInt(value);
|
|
1161
1167
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_WIDTH_PX) {
|
|
1162
|
-
widgetEnv.widthPx = parseInt(value);
|
|
1168
|
+
widgetEnv.widthPx = Number.parseInt(value);
|
|
1163
1169
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_HEIGHT_PX) {
|
|
1164
|
-
widgetEnv.heightPx = parseInt(value);
|
|
1170
|
+
widgetEnv.heightPx = Number.parseInt(value);
|
|
1165
1171
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_NAME) {
|
|
1166
1172
|
widgetEnv.name = value;
|
|
1167
1173
|
} else if (keyWithoutPrefix == _WidgetParams.PARAM_TITLE) {
|
|
@@ -1179,7 +1185,7 @@ var _WidgetParams = class {
|
|
|
1179
1185
|
static fromObject(object) {
|
|
1180
1186
|
const widgetEnv = new _WidgetParams();
|
|
1181
1187
|
const ownPropertyNames = Object.getOwnPropertyNames(object);
|
|
1182
|
-
for (
|
|
1188
|
+
for (const ownPropertyName of ownPropertyNames) {
|
|
1183
1189
|
const key = ownPropertyName;
|
|
1184
1190
|
const value = object[key];
|
|
1185
1191
|
this.setValue(widgetEnv, key, value);
|
|
@@ -1311,15 +1317,15 @@ var supportedProtocols = /* @__PURE__ */ new Set([
|
|
|
1311
1317
|
"http:",
|
|
1312
1318
|
"file:"
|
|
1313
1319
|
]);
|
|
1314
|
-
|
|
1320
|
+
function hasCustomProtocol(urlString) {
|
|
1315
1321
|
try {
|
|
1316
1322
|
const { protocol } = new URL(urlString);
|
|
1317
1323
|
return protocol.endsWith(":") && !supportedProtocols.has(protocol);
|
|
1318
1324
|
} catch {
|
|
1319
1325
|
return false;
|
|
1320
1326
|
}
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1327
|
+
}
|
|
1328
|
+
function normalizeDataURL(urlString, option) {
|
|
1323
1329
|
const match = /^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(urlString);
|
|
1324
1330
|
if (!match) {
|
|
1325
1331
|
throw new Error(`Invalid URL: ${urlString}`);
|
|
@@ -1353,7 +1359,7 @@ var normalizeDataURL = (urlString, option) => {
|
|
|
1353
1359
|
normalizedMediaType.unshift(mimeType);
|
|
1354
1360
|
}
|
|
1355
1361
|
return `data:${normalizedMediaType.join(";")},${isBase64 ? data.trim() : data}${hash ? `#${hash}` : ""}`;
|
|
1356
|
-
}
|
|
1362
|
+
}
|
|
1357
1363
|
function normalizeUrl(urlString, options) {
|
|
1358
1364
|
options = {
|
|
1359
1365
|
defaultProtocol: "http",
|
|
@@ -1441,7 +1447,7 @@ function normalizeUrl(urlString, options) {
|
|
|
1441
1447
|
const lastComponent = pathComponents[pathComponents.length - 1];
|
|
1442
1448
|
if (testParameter(lastComponent, options.removeDirectoryIndex)) {
|
|
1443
1449
|
pathComponents = pathComponents.slice(0, -1);
|
|
1444
|
-
urlObject.pathname = pathComponents.slice(1).join("/")
|
|
1450
|
+
urlObject.pathname = `${pathComponents.slice(1).join("/")}/`;
|
|
1445
1451
|
}
|
|
1446
1452
|
}
|
|
1447
1453
|
if (urlObject.hostname) {
|
|
@@ -1610,7 +1616,7 @@ var WidgetPackage = class {
|
|
|
1610
1616
|
this.devOptions = options.devOptions;
|
|
1611
1617
|
this.remote = options.remote;
|
|
1612
1618
|
if (options.widgets) {
|
|
1613
|
-
for (
|
|
1619
|
+
for (const widget of options.widgets) {
|
|
1614
1620
|
this.widgets.push(widget);
|
|
1615
1621
|
}
|
|
1616
1622
|
}
|
|
@@ -1620,7 +1626,7 @@ var WidgetPackage = class {
|
|
|
1620
1626
|
return this.parseObject(object);
|
|
1621
1627
|
}
|
|
1622
1628
|
static parseObject(obj) {
|
|
1623
|
-
|
|
1629
|
+
const widgetPackage = new WidgetPackage({
|
|
1624
1630
|
author: "",
|
|
1625
1631
|
description: {
|
|
1626
1632
|
"zh-CN": ""
|
|
@@ -1637,8 +1643,8 @@ var WidgetPackage = class {
|
|
|
1637
1643
|
Object.assign(widgetPackage, obj);
|
|
1638
1644
|
const widgets = [];
|
|
1639
1645
|
if (widgetPackage.widgets) {
|
|
1640
|
-
for (
|
|
1641
|
-
|
|
1646
|
+
for (const jsonWidget of widgetPackage.widgets) {
|
|
1647
|
+
const widget = new Widget({
|
|
1642
1648
|
previewImage: "",
|
|
1643
1649
|
path: "",
|
|
1644
1650
|
description: { "zh-CN": "" },
|
|
@@ -1757,10 +1763,10 @@ var GridSystem = class extends GridRect {
|
|
|
1757
1763
|
* @param screenY
|
|
1758
1764
|
*/
|
|
1759
1765
|
constructor(cellSize, padding, screenWidth, screenHeight, screenX, screenY) {
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1766
|
+
const gridMaxWidth = screenWidth - padding * 2;
|
|
1767
|
+
const gridMaxHeight = screenHeight - padding * 2;
|
|
1768
|
+
const horizontalPadding = gridMaxWidth % cellSize / 2 + padding;
|
|
1769
|
+
const verticalPadding = gridMaxHeight % cellSize / 2 + padding;
|
|
1764
1770
|
const horizontalCellCount = Math.floor(gridMaxWidth / cellSize);
|
|
1765
1771
|
const verticalCellCount = Math.floor(gridMaxHeight / cellSize);
|
|
1766
1772
|
super(horizontalPadding, verticalPadding, horizontalCellCount * cellSize, verticalCellCount * cellSize);
|
|
@@ -1781,8 +1787,8 @@ var GridSystem = class extends GridRect {
|
|
|
1781
1787
|
* @param gridSystem
|
|
1782
1788
|
*/
|
|
1783
1789
|
snapCanvasPosition(x, y) {
|
|
1784
|
-
|
|
1785
|
-
|
|
1790
|
+
const newX = this.getRangeValue(x - this.left, 0, this.right);
|
|
1791
|
+
const newY = this.getRangeValue(y - this.top, 0, this.bottom);
|
|
1786
1792
|
return this.snapPosition(newX, newY);
|
|
1787
1793
|
}
|
|
1788
1794
|
snapPosition(newX, newY) {
|
|
@@ -1803,8 +1809,8 @@ var GridSystem = class extends GridRect {
|
|
|
1803
1809
|
snapSize(width, height) {
|
|
1804
1810
|
let newWidth = Math.floor(width);
|
|
1805
1811
|
let newHeight = Math.floor(height);
|
|
1806
|
-
|
|
1807
|
-
|
|
1812
|
+
const diffWidth = newWidth % this.cellSize;
|
|
1813
|
+
const diffHeight = newHeight % this.cellSize;
|
|
1808
1814
|
if (diffWidth > this.cellSize / 2) {
|
|
1809
1815
|
newWidth = width + this.cellSize - diffWidth;
|
|
1810
1816
|
} else {
|
|
@@ -1826,7 +1832,7 @@ var GridSystem = class extends GridRect {
|
|
|
1826
1832
|
* @param maxHeight
|
|
1827
1833
|
*/
|
|
1828
1834
|
snapCanvasRect(rect, minWidth, maxWidth, minHeight, maxHeight) {
|
|
1829
|
-
|
|
1835
|
+
const [newX, newY] = this.snapCanvasPosition(rect.left, rect.top);
|
|
1830
1836
|
return this.snapRect(rect, minWidth, maxWidth, minHeight, maxHeight, newX, newY);
|
|
1831
1837
|
}
|
|
1832
1838
|
snapRect(rect, minWidth, maxWidth, minHeight, maxHeight, newX, newY) {
|
|
@@ -1852,7 +1858,7 @@ var GridSystem = class extends GridRect {
|
|
|
1852
1858
|
snapWindow(rect, minWidth, maxWidth, minHeight, maxHeight) {
|
|
1853
1859
|
rect.left = rect.left - (this.screenLeft ?? 0);
|
|
1854
1860
|
rect.top = rect.top - (this.screenTop ?? 0);
|
|
1855
|
-
|
|
1861
|
+
const result = this.snapCanvasRect(rect, minWidth, maxWidth, minHeight, maxHeight);
|
|
1856
1862
|
return new GridRect(
|
|
1857
1863
|
result.left + (this.screenLeft ?? 0),
|
|
1858
1864
|
result.top + (this.screenTop ?? 0),
|
|
@@ -2004,35 +2010,42 @@ var WidgetApiImpl = class extends BaseApi {
|
|
|
2004
2010
|
*/
|
|
2005
2011
|
async getWidgetConfigUrl(widgetName, widgetParams) {
|
|
2006
2012
|
const widget = await this.getWidget(widgetName);
|
|
2007
|
-
if (!widget)
|
|
2013
|
+
if (!widget) {
|
|
2008
2014
|
return null;
|
|
2015
|
+
}
|
|
2009
2016
|
const configPagePath = widget.configPagePath;
|
|
2010
|
-
if (!configPagePath)
|
|
2017
|
+
if (!configPagePath) {
|
|
2011
2018
|
return null;
|
|
2019
|
+
}
|
|
2012
2020
|
const widgetPackage = await this.getWidgetPackage(widget.packageName);
|
|
2013
|
-
if (!widgetPackage)
|
|
2021
|
+
if (!widgetPackage) {
|
|
2014
2022
|
return null;
|
|
2023
|
+
}
|
|
2015
2024
|
return WidgetUrlUtils.getWidgetUrl(configPagePath, widgetPackage, widgetParams);
|
|
2016
2025
|
}
|
|
2017
2026
|
async getWidgetUrl(widgetName, widgetParams) {
|
|
2018
2027
|
const widget = await this.getWidget(widgetName);
|
|
2019
|
-
if (!widget)
|
|
2028
|
+
if (!widget) {
|
|
2020
2029
|
return null;
|
|
2030
|
+
}
|
|
2021
2031
|
const widgetPackage = await this.getWidgetPackage(widget.packageName);
|
|
2022
|
-
if (!widgetPackage)
|
|
2032
|
+
if (!widgetPackage) {
|
|
2023
2033
|
return null;
|
|
2034
|
+
}
|
|
2024
2035
|
return WidgetUrlUtils.getWidgetUrl(widget.path, widgetPackage, widgetParams);
|
|
2025
2036
|
}
|
|
2026
2037
|
async getWidgetPackageIndexUrl(packageName, hash) {
|
|
2027
2038
|
const widgetPackage = await this.getWidgetPackage(packageName);
|
|
2028
|
-
if (!widgetPackage)
|
|
2039
|
+
if (!widgetPackage) {
|
|
2029
2040
|
return null;
|
|
2041
|
+
}
|
|
2030
2042
|
return widgetPackage.getIndexUrl(hash);
|
|
2031
2043
|
}
|
|
2032
2044
|
async getWidgetPackageUrl(packageName) {
|
|
2033
2045
|
const widgetPackage = await this.getWidgetPackage(packageName);
|
|
2034
|
-
if (!widgetPackage)
|
|
2046
|
+
if (!widgetPackage) {
|
|
2035
2047
|
return null;
|
|
2048
|
+
}
|
|
2036
2049
|
return widgetPackage.url;
|
|
2037
2050
|
}
|
|
2038
2051
|
// /**
|
|
@@ -2084,8 +2097,8 @@ var WidgetDataApiImpl = class {
|
|
|
2084
2097
|
* @param options
|
|
2085
2098
|
*/
|
|
2086
2099
|
async save(data, options = { sendBroadcast: true }) {
|
|
2087
|
-
|
|
2088
|
-
|
|
2100
|
+
const store = this.getStore(data.name);
|
|
2101
|
+
const json = JSON.stringify(data);
|
|
2089
2102
|
const result = await store.setItem(this.getKey(data.name, data.id), json);
|
|
2090
2103
|
if (options.sendBroadcast) {
|
|
2091
2104
|
const broadcastEvent = new BroadcastEvent({
|
|
@@ -2134,7 +2147,7 @@ var WidgetDataApiImpl = class {
|
|
|
2134
2147
|
data = args[0];
|
|
2135
2148
|
name = data.name;
|
|
2136
2149
|
}
|
|
2137
|
-
|
|
2150
|
+
const store = this.getStore(name);
|
|
2138
2151
|
dbStr = await store.getItem(name);
|
|
2139
2152
|
if (dbStr) {
|
|
2140
2153
|
data.parseJSON(JSON.parse(dbStr));
|
|
@@ -2143,8 +2156,8 @@ var WidgetDataApiImpl = class {
|
|
|
2143
2156
|
return void 0;
|
|
2144
2157
|
}
|
|
2145
2158
|
async find(name, id, type) {
|
|
2146
|
-
|
|
2147
|
-
|
|
2159
|
+
const store = this.getStore(name);
|
|
2160
|
+
const result = await store.getItem(this.getKey(name, id));
|
|
2148
2161
|
if (result) {
|
|
2149
2162
|
const widgetData = new type(name, id);
|
|
2150
2163
|
widgetData.parseJSON(JSON.parse(result));
|
|
@@ -2269,7 +2282,7 @@ var BrowserWindowApiImpl = class extends BaseApi {
|
|
|
2269
2282
|
return await this.invokeMethod("unmaximize");
|
|
2270
2283
|
}
|
|
2271
2284
|
async setZoomLevel(level) {
|
|
2272
|
-
return await this.invokeMethod("setZoomLevel");
|
|
2285
|
+
return await this.invokeMethod("setZoomLevel", level);
|
|
2273
2286
|
}
|
|
2274
2287
|
async reload() {
|
|
2275
2288
|
return await this.invokeMethod("reload");
|
|
@@ -2633,8 +2646,8 @@ var AppApiImpl = class extends BaseApi {
|
|
|
2633
2646
|
/**
|
|
2634
2647
|
* 获取应用版本号,格式为 x.y.z
|
|
2635
2648
|
*/
|
|
2636
|
-
async getVersion() {
|
|
2637
|
-
return this.invokeMethod("getVersion");
|
|
2649
|
+
async getVersion(type) {
|
|
2650
|
+
return this.invokeMethod("getVersion", type);
|
|
2638
2651
|
}
|
|
2639
2652
|
async getPreloadPath() {
|
|
2640
2653
|
return this.invokeMethod("getPreloadPath");
|
|
@@ -2771,6 +2784,12 @@ var FileApiImpl = class extends BaseApi {
|
|
|
2771
2784
|
}
|
|
2772
2785
|
};
|
|
2773
2786
|
var FileApi = new FileApiImpl();
|
|
2787
|
+
|
|
2788
|
+
// src/api/SystemApi.ts
|
|
2789
|
+
var SystemApiEvent = /* @__PURE__ */ ((SystemApiEvent2) => {
|
|
2790
|
+
SystemApiEvent2["DATE_CHANGED"] = "event::cn.widgetjs.core.sys.date.changed";
|
|
2791
|
+
return SystemApiEvent2;
|
|
2792
|
+
})(SystemApiEvent || {});
|
|
2774
2793
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2775
2794
|
0 && (module.exports = {
|
|
2776
2795
|
ApiConstants,
|
|
@@ -2809,6 +2828,7 @@ var FileApi = new FileApiImpl();
|
|
|
2809
2828
|
ShortcutApi,
|
|
2810
2829
|
ShortcutApiEvent,
|
|
2811
2830
|
StoreApi,
|
|
2831
|
+
SystemApiEvent,
|
|
2812
2832
|
ThemeMode,
|
|
2813
2833
|
WebSocketEvent,
|
|
2814
2834
|
WebSocketEventType,
|