@widget-js/core 0.10.21 → 0.10.31
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 +19543 -0
- package/dist/index.cjs +62 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +47 -7
- package/dist/index.js +62 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1115,14 +1115,26 @@ var GridSystem = class extends GridRect {
|
|
|
1115
1115
|
verticalCellCount;
|
|
1116
1116
|
screenWidth;
|
|
1117
1117
|
screenHeight;
|
|
1118
|
+
/**
|
|
1119
|
+
* 屏幕x坐标,用于解决多块屏幕坐标计算问题
|
|
1120
|
+
*/
|
|
1121
|
+
screenLeft;
|
|
1122
|
+
/**
|
|
1123
|
+
* 屏幕y坐标,用于解决多块屏幕坐标计算问题
|
|
1124
|
+
*/
|
|
1125
|
+
screenTop;
|
|
1126
|
+
canvasScreenTop;
|
|
1127
|
+
canvasScreenLeft;
|
|
1118
1128
|
/**
|
|
1119
1129
|
*
|
|
1120
1130
|
* @param cellSize
|
|
1121
1131
|
* @param padding 至少保留的边距
|
|
1122
1132
|
* @param screenWidth
|
|
1123
1133
|
* @param screenHeight
|
|
1134
|
+
* @param screenX
|
|
1135
|
+
* @param screenY
|
|
1124
1136
|
*/
|
|
1125
|
-
constructor(cellSize, padding, screenWidth, screenHeight) {
|
|
1137
|
+
constructor(cellSize, padding, screenWidth, screenHeight, screenX, screenY) {
|
|
1126
1138
|
let gridMaxWidth = screenWidth - padding * 2;
|
|
1127
1139
|
let gridMaxHeight = screenHeight - padding * 2;
|
|
1128
1140
|
let horizontalPadding = gridMaxWidth % cellSize / 2 + padding;
|
|
@@ -1130,20 +1142,28 @@ var GridSystem = class extends GridRect {
|
|
|
1130
1142
|
const horizontalCellCount = Math.floor(gridMaxWidth / cellSize);
|
|
1131
1143
|
const verticalCellCount = Math.floor(gridMaxHeight / cellSize);
|
|
1132
1144
|
super(horizontalPadding, verticalPadding, horizontalCellCount * cellSize, verticalCellCount * cellSize);
|
|
1145
|
+
this.canvasScreenLeft = horizontalPadding + (screenX ?? 0);
|
|
1146
|
+
this.canvasScreenTop = verticalPadding + (screenY ?? 0);
|
|
1133
1147
|
this.cellSize = cellSize;
|
|
1134
1148
|
this.screenWidth = screenWidth;
|
|
1135
1149
|
this.screenHeight = screenHeight;
|
|
1136
1150
|
this.horizontalCellCount = horizontalCellCount;
|
|
1137
1151
|
this.verticalCellCount = verticalCellCount;
|
|
1152
|
+
this.screenLeft = screenX;
|
|
1153
|
+
this.screenTop = screenY;
|
|
1138
1154
|
}
|
|
1139
1155
|
/**
|
|
1140
1156
|
* 将坐标对齐到网格上
|
|
1141
1157
|
* @param x
|
|
1142
1158
|
* @param y
|
|
1159
|
+
* @param gridSystem
|
|
1143
1160
|
*/
|
|
1144
|
-
|
|
1145
|
-
let newX = this.getRangeValue(x - this.left, 0, this.
|
|
1146
|
-
let newY = this.getRangeValue(y - this.top, 0, this.
|
|
1161
|
+
snapCanvasPosition(x, y) {
|
|
1162
|
+
let newX = this.getRangeValue(x - this.left, 0, this.right);
|
|
1163
|
+
let newY = this.getRangeValue(y - this.top, 0, this.bottom);
|
|
1164
|
+
return this.snapPosition(newX, newY);
|
|
1165
|
+
}
|
|
1166
|
+
snapPosition(newX, newY) {
|
|
1147
1167
|
const diffX = newX % this.cellSize;
|
|
1148
1168
|
if (diffX >= this.cellSize / 2) {
|
|
1149
1169
|
newX = newX + this.cellSize - diffX;
|
|
@@ -1183,8 +1203,11 @@ var GridSystem = class extends GridRect {
|
|
|
1183
1203
|
* @param minHeight
|
|
1184
1204
|
* @param maxHeight
|
|
1185
1205
|
*/
|
|
1186
|
-
|
|
1187
|
-
let [newX, newY] = this.
|
|
1206
|
+
snapCanvasRect(rect, minWidth, maxWidth, minHeight, maxHeight) {
|
|
1207
|
+
let [newX, newY] = this.snapCanvasPosition(rect.left, rect.top);
|
|
1208
|
+
return this.snapRect(rect, minWidth, maxWidth, minHeight, maxHeight, newX, newY);
|
|
1209
|
+
}
|
|
1210
|
+
snapRect(rect, minWidth, maxWidth, minHeight, maxHeight, newX, newY) {
|
|
1188
1211
|
let [newWidth, newHeight] = this.snapSize(rect.width, rect.height);
|
|
1189
1212
|
newWidth = this.getRangeValue(newWidth, minWidth, maxWidth);
|
|
1190
1213
|
newHeight = this.getRangeValue(newHeight, minHeight, maxHeight);
|
|
@@ -1196,6 +1219,32 @@ var GridSystem = class extends GridRect {
|
|
|
1196
1219
|
}
|
|
1197
1220
|
return new GridRect(newX, newY, newWidth, newHeight);
|
|
1198
1221
|
}
|
|
1222
|
+
/**
|
|
1223
|
+
* 将矩形对齐到网格上,与snapRect的区别是,这个会加上屏幕x和y坐标,用于适配多个显示器
|
|
1224
|
+
* @param rect
|
|
1225
|
+
* @param minWidth
|
|
1226
|
+
* @param maxWidth
|
|
1227
|
+
* @param minHeight
|
|
1228
|
+
* @param maxHeight
|
|
1229
|
+
*/
|
|
1230
|
+
snapWindow(rect, minWidth, maxWidth, minHeight, maxHeight) {
|
|
1231
|
+
rect.left = rect.left - (this.screenLeft ?? 0);
|
|
1232
|
+
rect.top = rect.top - (this.screenTop ?? 0);
|
|
1233
|
+
let result = this.snapCanvasRect(rect, minWidth, maxWidth, minHeight, maxHeight);
|
|
1234
|
+
return new GridRect(
|
|
1235
|
+
result.left + (this.screenLeft ?? 0),
|
|
1236
|
+
result.top + (this.screenTop ?? 0),
|
|
1237
|
+
result.width,
|
|
1238
|
+
result.height
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* 限制值不超出屏幕
|
|
1243
|
+
* @param value
|
|
1244
|
+
* @param min
|
|
1245
|
+
* @param max
|
|
1246
|
+
* @private
|
|
1247
|
+
*/
|
|
1199
1248
|
getRangeValue(value, min, max) {
|
|
1200
1249
|
if (value < min) {
|
|
1201
1250
|
return min;
|
|
@@ -1206,10 +1255,10 @@ var GridSystem = class extends GridRect {
|
|
|
1206
1255
|
return value;
|
|
1207
1256
|
}
|
|
1208
1257
|
getWidth() {
|
|
1209
|
-
return this.
|
|
1258
|
+
return this.width;
|
|
1210
1259
|
}
|
|
1211
1260
|
getHeight() {
|
|
1212
|
-
return this.
|
|
1261
|
+
return this.height;
|
|
1213
1262
|
}
|
|
1214
1263
|
};
|
|
1215
1264
|
|
|
@@ -1232,7 +1281,7 @@ var Channel = /* @__PURE__ */ ((Channel2) => {
|
|
|
1232
1281
|
Channel2["BROWSER_WINDOW"] = "channel::cn.widgetjs.core.browser_window";
|
|
1233
1282
|
Channel2["BROADCAST"] = "channel::cn.widgetjs.core.broadcast";
|
|
1234
1283
|
Channel2["WIDGET"] = "channel::cn.widgetjs.core.widget";
|
|
1235
|
-
Channel2["
|
|
1284
|
+
Channel2["DEPLOYED_WIDGET"] = "channel::cn.widgetjs.core.deployed_widget";
|
|
1236
1285
|
Channel2["APP"] = "channel::cn.widgetjs.core.app";
|
|
1237
1286
|
Channel2["DIALOG"] = "channel::cn.widgetjs.core.dialog";
|
|
1238
1287
|
Channel2["CLIPBOARD"] = "channel::cn.widgetjs.core.clipboard";
|
|
@@ -1647,6 +1696,9 @@ var BrowserWindowApiImpl = class extends BaseApi {
|
|
|
1647
1696
|
await this.center();
|
|
1648
1697
|
}
|
|
1649
1698
|
}
|
|
1699
|
+
async setProxy(config) {
|
|
1700
|
+
return await this.invokeMethod("setProxy", config);
|
|
1701
|
+
}
|
|
1650
1702
|
};
|
|
1651
1703
|
var BrowserWindowApi = new BrowserWindowApiImpl();
|
|
1652
1704
|
|
|
@@ -1764,7 +1816,7 @@ var NotificationApi = new NotificationApiImpl();
|
|
|
1764
1816
|
// src/api/DeployedWidgetApi.ts
|
|
1765
1817
|
var DeployedWidgetApiImpl = class extends BaseApi {
|
|
1766
1818
|
getChannel() {
|
|
1767
|
-
return "channel::cn.widgetjs.core.
|
|
1819
|
+
return "channel::cn.widgetjs.core.deployed_widget" /* DEPLOYED_WIDGET */;
|
|
1768
1820
|
}
|
|
1769
1821
|
/**
|
|
1770
1822
|
* 移除组件
|