@netless/window-manager 1.0.0-canary.3 → 1.0.0-canary.6
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/__mocks__/white-web-sdk.ts +10 -1
- package/dist/App/AppContext.d.ts +2 -1
- package/dist/App/AppProxy.d.ts +12 -1
- package/dist/App/AppViewSync.d.ts +11 -0
- package/dist/App/{WhiteBoardView.d.ts → WhiteboardView.d.ts} +3 -0
- package/dist/App/index.d.ts +1 -1
- package/dist/AppManager.d.ts +1 -1
- package/dist/AttributesDelegate.d.ts +6 -14
- package/dist/BoxManager.d.ts +1 -1
- package/dist/InternalEmitter.d.ts +2 -0
- package/dist/ReconnectRefresher.d.ts +1 -1
- package/dist/Utils/Common.d.ts +1 -0
- package/dist/View/CameraSynchronizer.d.ts +4 -4
- package/dist/View/ViewSync.d.ts +7 -0
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +376 -197
- package/dist/index.umd.js +12 -12
- package/dist/style.css +1 -1
- package/docs/app-context.md +4 -0
- package/package.json +2 -2
- package/pnpm-lock.yaml +4 -4
- package/src/App/AppContext.ts +5 -2
- package/src/App/AppProxy.ts +100 -12
- package/src/App/AppViewSync.ts +68 -0
- package/src/App/{WhiteBoardView.ts → WhiteboardView.ts} +11 -2
- package/src/App/index.ts +1 -1
- package/src/AppManager.ts +7 -4
- package/src/AttributesDelegate.ts +14 -17
- package/src/BoxManager.ts +3 -2
- package/src/InternalEmitter.ts +2 -0
- package/src/ReconnectRefresher.ts +1 -0
- package/src/Utils/Common.ts +6 -0
- package/src/View/CameraSynchronizer.ts +14 -8
- package/src/View/MainView.ts +9 -13
- package/src/View/ViewSync.ts +10 -0
- package/src/index.ts +3 -1
package/dist/index.es.js
CHANGED
@@ -19,11 +19,11 @@ var __spreadValues = (a2, b2) => {
|
|
19
19
|
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
|
20
20
|
import pRetry from "p-retry";
|
21
21
|
import Emittery from "emittery";
|
22
|
-
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, isNumber,
|
22
|
+
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, isNumber, throttle, delay, pick, isInteger, orderBy, isEmpty, isFunction, isNull } from "lodash";
|
23
23
|
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, isPlayer, isRoom, ApplianceNames, RoomPhase, InvisiblePlugin, ViewMode } from "white-web-sdk";
|
24
24
|
import { v4 } from "uuid";
|
25
25
|
import { genUID, SideEffectManager } from "side-effect-manager";
|
26
|
-
import { Val,
|
26
|
+
import { Val, combine, ValManager, withReadonlyValueEnhancer, withValueEnhancer, derive } from "value-enhancer";
|
27
27
|
import { ResizeObserver as ResizeObserver$2 } from "@juggle/resize-observer";
|
28
28
|
import p$1 from "video.js";
|
29
29
|
var Events = /* @__PURE__ */ ((Events2) => {
|
@@ -355,6 +355,11 @@ const setViewFocusScenePath = (view, focusScenePath) => {
|
|
355
355
|
return view;
|
356
356
|
}
|
357
357
|
};
|
358
|
+
const releaseView = (view) => {
|
359
|
+
if (!view.didRelease) {
|
360
|
+
view.release();
|
361
|
+
}
|
362
|
+
};
|
358
363
|
const setScenePath = (room, scenePath) => {
|
359
364
|
if (room && room.isWritable) {
|
360
365
|
if (room.state.sceneState.scenePath !== scenePath) {
|
@@ -944,9 +949,15 @@ class WhiteBoardView {
|
|
944
949
|
pageState$.setValue(pageState);
|
945
950
|
});
|
946
951
|
}
|
952
|
+
get view() {
|
953
|
+
return this.appContext.view;
|
954
|
+
}
|
947
955
|
get pageState() {
|
948
956
|
return this.pageState$.value;
|
949
957
|
}
|
958
|
+
moveCamera(camera) {
|
959
|
+
this.appProxy.moveCamera(camera);
|
960
|
+
}
|
950
961
|
destroy() {
|
951
962
|
this.removeViewWrapper();
|
952
963
|
}
|
@@ -1022,11 +1033,13 @@ class AppContext {
|
|
1022
1033
|
view = this.appProxy.createAppDir();
|
1023
1034
|
}
|
1024
1035
|
const viewWrapper = document.createElement("div");
|
1036
|
+
this._viewWrapper = viewWrapper;
|
1025
1037
|
viewWrapper.className = "window-manager-view-wrapper";
|
1026
1038
|
(_a = this.box.$content.parentElement) == null ? void 0 : _a.appendChild(viewWrapper);
|
1027
1039
|
const removeViewWrapper = () => {
|
1028
1040
|
var _a2;
|
1029
1041
|
(_a2 = this.box.$content.parentElement) == null ? void 0 : _a2.removeChild(viewWrapper);
|
1042
|
+
this._viewWrapper = void 0;
|
1030
1043
|
};
|
1031
1044
|
view.divElement = viewWrapper;
|
1032
1045
|
if (this.isAddApp) {
|
@@ -1186,6 +1199,132 @@ class AppPageStateImpl {
|
|
1186
1199
|
(_a = this.sceneNode) == null ? void 0 : _a.dispose();
|
1187
1200
|
}
|
1188
1201
|
}
|
1202
|
+
class CameraSynchronizer {
|
1203
|
+
constructor(saveCamera) {
|
1204
|
+
this.saveCamera = saveCamera;
|
1205
|
+
this.onRemoteUpdate = throttle((camera, size2) => {
|
1206
|
+
this.remoteCamera = camera;
|
1207
|
+
this.remoteSize = size2;
|
1208
|
+
if (this.remoteSize && this.rect) {
|
1209
|
+
let scale2;
|
1210
|
+
if (size2.width < size2.height) {
|
1211
|
+
scale2 = this.rect.width / size2.width;
|
1212
|
+
} else {
|
1213
|
+
scale2 = this.rect.height / size2.height;
|
1214
|
+
}
|
1215
|
+
const nextScale = camera.scale * scale2;
|
1216
|
+
const moveCamera = () => {
|
1217
|
+
var _a;
|
1218
|
+
return (_a = this.view) == null ? void 0 : _a.moveCamera({
|
1219
|
+
centerX: camera.centerX,
|
1220
|
+
centerY: camera.centerY,
|
1221
|
+
scale: nextScale,
|
1222
|
+
animationMode: AnimationMode.Immediately
|
1223
|
+
});
|
1224
|
+
};
|
1225
|
+
delay(moveCamera, 50);
|
1226
|
+
}
|
1227
|
+
}, 50);
|
1228
|
+
this.onLocalSizeUpdate = (size2) => {
|
1229
|
+
if (this.rect && this.view) {
|
1230
|
+
let scale2;
|
1231
|
+
if (size2.width < size2.height) {
|
1232
|
+
scale2 = this.rect.width / size2.width;
|
1233
|
+
} else {
|
1234
|
+
scale2 = this.rect.height / size2.height;
|
1235
|
+
}
|
1236
|
+
const nextScale = this.view.camera.scale / scale2;
|
1237
|
+
this.view.moveCamera({
|
1238
|
+
scale: nextScale,
|
1239
|
+
animationMode: AnimationMode.Immediately
|
1240
|
+
});
|
1241
|
+
}
|
1242
|
+
};
|
1243
|
+
}
|
1244
|
+
setRect(rect) {
|
1245
|
+
this.rect = rect;
|
1246
|
+
if (this.remoteCamera && this.remoteSize) {
|
1247
|
+
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1248
|
+
}
|
1249
|
+
}
|
1250
|
+
setView(view) {
|
1251
|
+
this.view = view;
|
1252
|
+
}
|
1253
|
+
onLocalCameraUpdate(camera) {
|
1254
|
+
this.saveCamera(camera);
|
1255
|
+
this.remoteCamera = camera;
|
1256
|
+
}
|
1257
|
+
}
|
1258
|
+
class AppViewSync {
|
1259
|
+
constructor(appProxy) {
|
1260
|
+
this.appProxy = appProxy;
|
1261
|
+
this.sem = new SideEffectManager();
|
1262
|
+
this.bindView = (view) => {
|
1263
|
+
if (!view)
|
1264
|
+
return;
|
1265
|
+
this.synchronizer.setView(view);
|
1266
|
+
this.sem.add(() => {
|
1267
|
+
view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1268
|
+
return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1269
|
+
});
|
1270
|
+
};
|
1271
|
+
this.onCameraUpdatedByDevice = (camera) => {
|
1272
|
+
var _a;
|
1273
|
+
this.synchronizer.onLocalCameraUpdate(camera);
|
1274
|
+
const stage = (_a = this.appProxy.box) == null ? void 0 : _a.contentStageRect;
|
1275
|
+
if (stage) {
|
1276
|
+
const size2 = { width: stage.width, height: stage.height, id: this.appProxy.uid };
|
1277
|
+
if (!isEqual(size2, this.appProxy.size$.value)) {
|
1278
|
+
this.appProxy.storeSize(size2);
|
1279
|
+
}
|
1280
|
+
}
|
1281
|
+
};
|
1282
|
+
this.synchronizer = new CameraSynchronizer((camera) => {
|
1283
|
+
this.appProxy.storeCamera(__spreadValues({
|
1284
|
+
id: this.appProxy.uid
|
1285
|
+
}, camera));
|
1286
|
+
});
|
1287
|
+
this.bindView(appProxy.view);
|
1288
|
+
this.sem.add(() => this.appProxy.camera$.subscribe((camera) => {
|
1289
|
+
const size2 = this.appProxy.size$.value;
|
1290
|
+
if (camera && size2) {
|
1291
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1292
|
+
}
|
1293
|
+
}));
|
1294
|
+
const box = this.appProxy.box;
|
1295
|
+
if (box && box.contentStageRect) {
|
1296
|
+
this.synchronizer.setRect(box.contentStageRect);
|
1297
|
+
this.sem.add(() => box._contentStageRect$.subscribe((rect) => {
|
1298
|
+
if (rect) {
|
1299
|
+
this.synchronizer.setRect(rect);
|
1300
|
+
}
|
1301
|
+
}));
|
1302
|
+
}
|
1303
|
+
combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size2]) => {
|
1304
|
+
if (camera && size2) {
|
1305
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1306
|
+
}
|
1307
|
+
});
|
1308
|
+
}
|
1309
|
+
destroy() {
|
1310
|
+
this.sem.flushAll();
|
1311
|
+
}
|
1312
|
+
}
|
1313
|
+
const boxEmitter = new Emittery();
|
1314
|
+
const calculateNextIndex = (index2, pageState) => {
|
1315
|
+
let nextIndex = 0;
|
1316
|
+
const maxIndex = pageState.length - 1;
|
1317
|
+
if (index2 === pageState.index) {
|
1318
|
+
if (index2 === maxIndex) {
|
1319
|
+
nextIndex = index2 - 1;
|
1320
|
+
} else {
|
1321
|
+
nextIndex = pageState.index + 1;
|
1322
|
+
}
|
1323
|
+
} else {
|
1324
|
+
nextIndex = pageState.index;
|
1325
|
+
}
|
1326
|
+
return nextIndex;
|
1327
|
+
};
|
1189
1328
|
var Fields = /* @__PURE__ */ ((Fields2) => {
|
1190
1329
|
Fields2["Apps"] = "apps";
|
1191
1330
|
Fields2["Focus"] = "focus";
|
@@ -1199,6 +1338,8 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
|
|
1199
1338
|
Fields2["CursorState"] = "cursorState";
|
1200
1339
|
Fields2["FullPath"] = "fullPath";
|
1201
1340
|
Fields2["Registered"] = "registered";
|
1341
|
+
Fields2["Camera"] = "camera";
|
1342
|
+
Fields2["Size"] = "size";
|
1202
1343
|
return Fields2;
|
1203
1344
|
})(Fields || {});
|
1204
1345
|
class AttributesDelegate {
|
@@ -1263,6 +1404,9 @@ class AttributesDelegate {
|
|
1263
1404
|
this.context.safeUpdateAttributes(["apps", appId, "state", stateName], state);
|
1264
1405
|
}
|
1265
1406
|
}
|
1407
|
+
updateAppAttributes(appId, key, value) {
|
1408
|
+
this.context.safeUpdateAttributes(["apps", appId, key], value);
|
1409
|
+
}
|
1266
1410
|
cleanAppAttributes(id2) {
|
1267
1411
|
this.context.safeUpdateAttributes(["apps", id2], void 0);
|
1268
1412
|
this.context.safeSetAttributes({ [id2]: void 0 });
|
@@ -1359,21 +1503,6 @@ const log = (...args) => {
|
|
1359
1503
|
console.log(`[WindowManager]:`, ...args);
|
1360
1504
|
}
|
1361
1505
|
};
|
1362
|
-
const calculateNextIndex = (index2, pageState) => {
|
1363
|
-
let nextIndex = 0;
|
1364
|
-
const maxIndex = pageState.length - 1;
|
1365
|
-
if (index2 === pageState.index) {
|
1366
|
-
if (index2 === maxIndex) {
|
1367
|
-
nextIndex = index2 - 1;
|
1368
|
-
} else {
|
1369
|
-
nextIndex = pageState.index + 1;
|
1370
|
-
}
|
1371
|
-
} else {
|
1372
|
-
nextIndex = pageState.index;
|
1373
|
-
}
|
1374
|
-
return nextIndex;
|
1375
|
-
};
|
1376
|
-
const boxEmitter = new Emittery();
|
1377
1506
|
class AppProxy {
|
1378
1507
|
constructor(params, manager, appId, isAddApp) {
|
1379
1508
|
var _a;
|
@@ -1383,8 +1512,13 @@ class AppProxy {
|
|
1383
1512
|
this.appProxies = this.manager.appProxies;
|
1384
1513
|
this.viewManager = this.manager.viewManager;
|
1385
1514
|
this.store = this.manager.store;
|
1515
|
+
this.uid = this.manager.uid;
|
1386
1516
|
this.status = "normal";
|
1387
1517
|
this.sideEffectManager = new SideEffectManager();
|
1518
|
+
this.camera$ = new Val(void 0);
|
1519
|
+
this.size$ = new Val(void 0);
|
1520
|
+
this.box$ = new Val(void 0);
|
1521
|
+
this.view$ = new Val(void 0);
|
1388
1522
|
this.getAppInitState = (id2) => {
|
1389
1523
|
var _a2, _b;
|
1390
1524
|
const attrs = this.store.getAppState(id2);
|
@@ -1454,6 +1588,19 @@ class AppProxy {
|
|
1454
1588
|
this.appEmitter.emit("pageStateChange", this.pageState);
|
1455
1589
|
}
|
1456
1590
|
}, 50);
|
1591
|
+
this.storeCamera = (camera) => {
|
1592
|
+
this.store.updateAppAttributes(this.id, Fields.Camera, camera);
|
1593
|
+
};
|
1594
|
+
this.storeSize = (size2) => {
|
1595
|
+
this.store.updateAppAttributes(this.id, Fields.Size, size2);
|
1596
|
+
};
|
1597
|
+
this.moveCamera = (camera) => {
|
1598
|
+
if (!this.camera$.value) {
|
1599
|
+
return;
|
1600
|
+
}
|
1601
|
+
const nextCamera = __spreadValues(__spreadValues({}, this.camera$.value), camera);
|
1602
|
+
this.storeCamera(nextCamera);
|
1603
|
+
};
|
1457
1604
|
this.kind = params.kind;
|
1458
1605
|
this.id = appId;
|
1459
1606
|
this.appScenePath = `/${this.id}-app-dir`;
|
@@ -1475,14 +1622,74 @@ class AppProxy {
|
|
1475
1622
|
view: this.view,
|
1476
1623
|
notifyPageStateChange: this.notifyPageStateChange
|
1477
1624
|
});
|
1625
|
+
this.sideEffectManager.add(() => () => this._pageState.destroy());
|
1626
|
+
this.sideEffectManager.add(() => emitter.on("roomMembersChange", (members) => {
|
1627
|
+
this.appEmitter.emit("roomMembersChange", members);
|
1628
|
+
}));
|
1629
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1630
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1478
1631
|
this.sideEffectManager.add(() => {
|
1479
|
-
return () =>
|
1632
|
+
return this.manager.refresher.add(`${this.id}-camera`, () => {
|
1633
|
+
return reaction(() => {
|
1634
|
+
var _a2;
|
1635
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
|
1636
|
+
}, (camera) => {
|
1637
|
+
if (camera && camera.id !== this.uid) {
|
1638
|
+
this.camera$.setValue(toJS(camera));
|
1639
|
+
}
|
1640
|
+
});
|
1641
|
+
});
|
1480
1642
|
});
|
1481
1643
|
this.sideEffectManager.add(() => {
|
1482
|
-
return
|
1483
|
-
|
1644
|
+
return this.manager.refresher.add(`${this.id}-size`, () => {
|
1645
|
+
return reaction(() => {
|
1646
|
+
var _a2;
|
1647
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
|
1648
|
+
}, (size2) => {
|
1649
|
+
if (size2 && size2.id !== this.uid) {
|
1650
|
+
this.size$.setValue(toJS(size2));
|
1651
|
+
}
|
1652
|
+
});
|
1484
1653
|
});
|
1485
1654
|
});
|
1655
|
+
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
1656
|
+
var _a2, _b;
|
1657
|
+
if (box && view) {
|
1658
|
+
if (!this.camera$.value) {
|
1659
|
+
this.storeCamera({
|
1660
|
+
centerX: 0,
|
1661
|
+
centerY: 0,
|
1662
|
+
scale: 1,
|
1663
|
+
id: this.uid
|
1664
|
+
});
|
1665
|
+
}
|
1666
|
+
if (!this.size$.value && box.contentStageRect) {
|
1667
|
+
this.storeSize({
|
1668
|
+
id: this.uid,
|
1669
|
+
width: (_a2 = box.contentStageRect) == null ? void 0 : _a2.width,
|
1670
|
+
height: (_b = box.contentStageRect) == null ? void 0 : _b.height
|
1671
|
+
});
|
1672
|
+
}
|
1673
|
+
this.appViewSync = new AppViewSync(this);
|
1674
|
+
this.sideEffectManager.add(() => () => {
|
1675
|
+
var _a3;
|
1676
|
+
return (_a3 = this.appViewSync) == null ? void 0 : _a3.destroy();
|
1677
|
+
});
|
1678
|
+
}
|
1679
|
+
});
|
1680
|
+
this.sideEffectManager.add(() => emitter.on("memberStateChange", (memberState) => {
|
1681
|
+
var _a2, _b;
|
1682
|
+
const needPointerEventsNone = memberState.currentApplianceName === "clicker";
|
1683
|
+
if (needPointerEventsNone) {
|
1684
|
+
if ((_a2 = this.appContext) == null ? void 0 : _a2._viewWrapper) {
|
1685
|
+
this.appContext._viewWrapper.style.pointerEvents = "none";
|
1686
|
+
}
|
1687
|
+
} else {
|
1688
|
+
if ((_b = this.appContext) == null ? void 0 : _b._viewWrapper) {
|
1689
|
+
this.appContext._viewWrapper.style.pointerEvents = "auto";
|
1690
|
+
}
|
1691
|
+
}
|
1692
|
+
}));
|
1486
1693
|
}
|
1487
1694
|
createAppDir() {
|
1488
1695
|
const scenePath = this.scenePath || this.appScenePath;
|
@@ -1540,7 +1747,7 @@ class AppProxy {
|
|
1540
1747
|
return fullPath;
|
1541
1748
|
}
|
1542
1749
|
setFullPath(path) {
|
1543
|
-
this.
|
1750
|
+
this.store.updateAppAttributes(this.id, Fields.FullPath, path);
|
1544
1751
|
}
|
1545
1752
|
async baseInsertApp(skipUpdate = false) {
|
1546
1753
|
var _a;
|
@@ -1562,8 +1769,7 @@ class AppProxy {
|
|
1562
1769
|
};
|
1563
1770
|
}
|
1564
1771
|
get box() {
|
1565
|
-
|
1566
|
-
return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
|
1772
|
+
return this.box$.value;
|
1567
1773
|
}
|
1568
1774
|
async setupApp(appId, skipUpdate, app, options, appOptions) {
|
1569
1775
|
var _a;
|
@@ -1591,13 +1797,14 @@ class AppProxy {
|
|
1591
1797
|
this.fixMobileSize();
|
1592
1798
|
}, SETUP_APP_DELAY);
|
1593
1799
|
});
|
1594
|
-
(_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1800
|
+
const box = (_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1595
1801
|
appId,
|
1596
1802
|
app,
|
1597
1803
|
options,
|
1598
1804
|
canOperate: this.manager.canOperate,
|
1599
1805
|
smartPosition: this.isAddApp
|
1600
1806
|
});
|
1807
|
+
this.box$.setValue(box);
|
1601
1808
|
if (this.isAddApp && this.box) {
|
1602
1809
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
1603
1810
|
this.boxManager.focusBox({ appId }, false);
|
@@ -1726,6 +1933,7 @@ class AppProxy {
|
|
1726
1933
|
}
|
1727
1934
|
createView() {
|
1728
1935
|
const view = this.viewManager.createView(this.id);
|
1936
|
+
this.view$.setValue(view);
|
1729
1937
|
this.setViewFocusScenePath();
|
1730
1938
|
return view;
|
1731
1939
|
}
|
@@ -1776,6 +1984,7 @@ class AppProxy {
|
|
1776
1984
|
console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
|
1777
1985
|
}
|
1778
1986
|
this.appEmitter.clearListeners();
|
1987
|
+
this.sideEffectManager.flushAll();
|
1779
1988
|
emitter.emit(`destroy-${this.id}`, { error });
|
1780
1989
|
if (needCloseBox) {
|
1781
1990
|
(_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
|
@@ -1793,7 +2002,9 @@ class AppProxy {
|
|
1793
2002
|
(_c = this.manager.refresher) == null ? void 0 : _c.remove(this.stateKey);
|
1794
2003
|
(_d = this.manager.refresher) == null ? void 0 : _d.remove(`${this.id}-fullPath`);
|
1795
2004
|
this._prevFullPath = void 0;
|
1796
|
-
this.
|
2005
|
+
this.camera$.destroy();
|
2006
|
+
this.size$.destroy();
|
2007
|
+
this.box$.destroy();
|
1797
2008
|
}
|
1798
2009
|
close() {
|
1799
2010
|
return this.destroy(true, true, false);
|
@@ -1849,56 +2060,6 @@ const setDefaultCameraBound = (view) => {
|
|
1849
2060
|
minContentMode: () => 0.1
|
1850
2061
|
});
|
1851
2062
|
};
|
1852
|
-
class CameraSynchronizer {
|
1853
|
-
constructor(saveCamera) {
|
1854
|
-
this.saveCamera = saveCamera;
|
1855
|
-
this.onRemoteUpdate = throttle((camera, size2) => {
|
1856
|
-
this.remoteCamera = camera;
|
1857
|
-
this.remoteSize = size2;
|
1858
|
-
if (this.remoteSize && this.rect) {
|
1859
|
-
let scale2;
|
1860
|
-
if (size2.width < size2.height) {
|
1861
|
-
scale2 = this.rect.width / size2.width;
|
1862
|
-
} else {
|
1863
|
-
scale2 = this.rect.height / size2.height;
|
1864
|
-
}
|
1865
|
-
const nextScale = camera.scale * scale2;
|
1866
|
-
const moveCamera = () => {
|
1867
|
-
var _a;
|
1868
|
-
return (_a = this.view) == null ? void 0 : _a.moveCamera({
|
1869
|
-
centerX: camera.centerX,
|
1870
|
-
centerY: camera.centerY,
|
1871
|
-
scale: nextScale,
|
1872
|
-
animationMode: AnimationMode.Immediately
|
1873
|
-
});
|
1874
|
-
};
|
1875
|
-
delay(moveCamera, 10);
|
1876
|
-
}
|
1877
|
-
}, 50);
|
1878
|
-
}
|
1879
|
-
setRect(rect) {
|
1880
|
-
this.rect = rect;
|
1881
|
-
if (this.remoteCamera && this.remoteSize) {
|
1882
|
-
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1883
|
-
}
|
1884
|
-
}
|
1885
|
-
setView(view) {
|
1886
|
-
this.view = view;
|
1887
|
-
}
|
1888
|
-
onLocalCameraUpdate(camera) {
|
1889
|
-
this.saveCamera(camera);
|
1890
|
-
}
|
1891
|
-
onLocalSizeUpdate(size2) {
|
1892
|
-
if (this.rect && this.view) {
|
1893
|
-
const scale2 = this.rect.width / size2.width;
|
1894
|
-
const nextScale = this.view.camera.scale * scale2;
|
1895
|
-
this.view.moveCamera({
|
1896
|
-
scale: nextScale,
|
1897
|
-
animationMode: AnimationMode.Immediately
|
1898
|
-
});
|
1899
|
-
}
|
1900
|
-
}
|
1901
|
-
}
|
1902
2063
|
class MainViewProxy {
|
1903
2064
|
constructor(manager) {
|
1904
2065
|
var _a;
|
@@ -1928,9 +2089,6 @@ class MainViewProxy {
|
|
1928
2089
|
}, { fireImmediately: true });
|
1929
2090
|
};
|
1930
2091
|
this.sizeChangeHandler = debounce((size2) => {
|
1931
|
-
if (size2) {
|
1932
|
-
this.synchronizer.onLocalSizeUpdate(size2);
|
1933
|
-
}
|
1934
2092
|
}, 30);
|
1935
2093
|
this.onUpdateContainerSizeRatio = () => {
|
1936
2094
|
const size2 = this.store.getMainViewSize();
|
@@ -1969,9 +2127,7 @@ class MainViewProxy {
|
|
1969
2127
|
});
|
1970
2128
|
this.sideEffectManager.add(() => {
|
1971
2129
|
return emitter.on("startReconnect", () => {
|
1972
|
-
|
1973
|
-
this.mainView.release();
|
1974
|
-
}
|
2130
|
+
releaseView(this.mainView);
|
1975
2131
|
});
|
1976
2132
|
});
|
1977
2133
|
const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
@@ -1981,7 +2137,6 @@ class MainViewProxy {
|
|
1981
2137
|
this.sideEffectManager.add(() => {
|
1982
2138
|
return emitter.on("playgroundSizeChange", (rect2) => {
|
1983
2139
|
this.synchronizer.setRect(rect2);
|
1984
|
-
this.synchronizer.onLocalSizeUpdate(rect2);
|
1985
2140
|
});
|
1986
2141
|
});
|
1987
2142
|
}
|
@@ -2051,9 +2206,7 @@ class MainViewProxy {
|
|
2051
2206
|
const divElement = this.mainView.divElement;
|
2052
2207
|
const disableCameraTransform = this.mainView.disableCameraTransform;
|
2053
2208
|
this.stop();
|
2054
|
-
|
2055
|
-
this.mainView.release();
|
2056
|
-
}
|
2209
|
+
releaseView(this.mainView);
|
2057
2210
|
this.removeMainViewListener();
|
2058
2211
|
this.mainView = this.createMainView();
|
2059
2212
|
this.mainView.disableCameraTransform = disableCameraTransform;
|
@@ -2433,6 +2586,9 @@ class AppManager {
|
|
2433
2586
|
emitter.emit("roomMembersChange", this.members);
|
2434
2587
|
}
|
2435
2588
|
emitter.emit("observerIdChange", this.displayer.observerId);
|
2589
|
+
if (state.memberState) {
|
2590
|
+
emitter.emit("memberStateChange", toJS(state.memberState));
|
2591
|
+
}
|
2436
2592
|
};
|
2437
2593
|
this.displayerWritableListener = (isReadonly) => {
|
2438
2594
|
var _a, _b;
|
@@ -3701,16 +3857,16 @@ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
|
|
3701
3857
|
}
|
3702
3858
|
return true;
|
3703
3859
|
};
|
3704
|
-
var e$2 = Object.defineProperty, t$3 = Object.defineProperties, i$1 = Object.getOwnPropertyDescriptors, s$2 = Object.getOwnPropertySymbols, a$1 = Object.prototype.hasOwnProperty,
|
3860
|
+
var e$2 = Object.defineProperty, t$3 = Object.defineProperties, i$1 = Object.getOwnPropertyDescriptors, s$2 = Object.getOwnPropertySymbols, a$1 = Object.prototype.hasOwnProperty, n$3 = Object.prototype.propertyIsEnumerable, o$2 = (t2, i2, s2) => i2 in t2 ? e$2(t2, i2, { enumerable: true, configurable: true, writable: true, value: s2 }) : t2[i2] = s2, r$4 = (e2, t2) => {
|
3705
3861
|
for (var i2 in t2 || (t2 = {}))
|
3706
|
-
a$1.call(t2, i2) &&
|
3862
|
+
a$1.call(t2, i2) && o$2(e2, i2, t2[i2]);
|
3707
3863
|
if (s$2)
|
3708
3864
|
for (var i2 of s$2(t2))
|
3709
|
-
|
3865
|
+
n$3.call(t2, i2) && o$2(e2, i2, t2[i2]);
|
3710
3866
|
return e2;
|
3711
3867
|
};
|
3712
|
-
var v$3, w$2, C$3, y$2, E$3, z$2, B$2,
|
3713
|
-
(w$2 = v$3 || (v$3 = {})).Light = "light", w$2.Dark = "dark", w$2.Auto = "auto", (y$2 = C$3 || (C$3 = {})).Normal = "normal", y$2.Minimized = "minimized", y$2.Maximized = "maximized", (z$2 = E$3 || (E$3 = {})).DarkMode = "dark_mode", z$2.PrefersColorScheme = "prefers_color_scheme", z$2.Close = "close", z$2.Focus = "focus", z$2.Blur = "blur", z$2.IntrinsicMove = "intrinsic_move", z$2.IntrinsicResize = "intrinsic_resize", z$2.ZIndex = "z_index", z$2.State = "state", z$2.Minimized = "minimized", z$2.Maximized = "maximized", z$2.Readonly = "readonly", z$2.Destroyed = "destroyed", (
|
3868
|
+
var v$3, w$2, C$3, y$2, E$3, z$2, _, B$2, N$3, S$3;
|
3869
|
+
(w$2 = v$3 || (v$3 = {})).Light = "light", w$2.Dark = "dark", w$2.Auto = "auto", (y$2 = C$3 || (C$3 = {})).Normal = "normal", y$2.Minimized = "minimized", y$2.Maximized = "maximized", (z$2 = E$3 || (E$3 = {})).DarkMode = "dark_mode", z$2.PrefersColorScheme = "prefers_color_scheme", z$2.Close = "close", z$2.Focus = "focus", z$2.Blur = "blur", z$2.IntrinsicMove = "intrinsic_move", z$2.IntrinsicResize = "intrinsic_resize", z$2.ZIndex = "z_index", z$2.State = "state", z$2.Minimized = "minimized", z$2.Maximized = "maximized", z$2.Readonly = "readonly", z$2.Destroyed = "destroyed", (B$2 = _ || (_ = {})).Close = "close", B$2.Maximize = "maximize", B$2.Minimize = "minimize", (S$3 = N$3 || (N$3 = {})).North = "n", S$3.South = "s", S$3.West = "w", S$3.East = "e", S$3.NorthWest = "nw", S$3.NorthEast = "ne", S$3.SouthEast = "se", S$3.SouthWest = "sw";
|
3714
3870
|
function I$3(e2, t2, i2) {
|
3715
3871
|
return Math.min(Math.max(e2, t2), i2);
|
3716
3872
|
}
|
@@ -3731,7 +3887,7 @@ function V$3(e2) {
|
|
3731
3887
|
return !e2;
|
3732
3888
|
}
|
3733
3889
|
class H$3 {
|
3734
|
-
constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart:
|
3890
|
+
constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart: n2, namespace: o2 = "telebox" }) {
|
3735
3891
|
this.sideEffect = new SideEffectManager(), this.lastTitleBarClick = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarClick = (e3) => {
|
3736
3892
|
var t3;
|
3737
3893
|
if (this.readonly$.value)
|
@@ -3742,7 +3898,7 @@ class H$3 {
|
|
3742
3898
|
return;
|
3743
3899
|
k$1(e3);
|
3744
3900
|
const i3 = Date.now();
|
3745
|
-
i3 - this.lastTitleBarClick.timestamp <= 500 ? Math.abs(e3.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(e3.clientY - this.lastTitleBarClick.clientY) <= 5 && this.onEvent && this.onEvent({ type:
|
3901
|
+
i3 - this.lastTitleBarClick.timestamp <= 500 ? Math.abs(e3.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(e3.clientY - this.lastTitleBarClick.clientY) <= 5 && this.onEvent && this.onEvent({ type: _.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarClick.timestamp = i3, this.lastTitleBarClick.clientX = e3.clientX, this.lastTitleBarClick.clientY = e3.clientY;
|
3746
3902
|
}, this.lastTitleBarTouch = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarTouch = (e3) => {
|
3747
3903
|
var t3;
|
3748
3904
|
if (this.readonly$.value)
|
@@ -3751,8 +3907,8 @@ class H$3 {
|
|
3751
3907
|
return;
|
3752
3908
|
k$1(e3);
|
3753
3909
|
const i3 = Date.now(), { clientX: s3 = this.lastTitleBarTouch.clientX + 100, clientY: a3 = this.lastTitleBarTouch.clientY + 100 } = e3.touches[0] || {};
|
3754
|
-
i3 - this.lastTitleBarTouch.timestamp <= 500 ? Math.abs(s3 - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(a3 - this.lastTitleBarTouch.clientY) <= 10 && this.onEvent && this.onEvent({ type:
|
3755
|
-
}, this.readonly$ = e2, this.state$ = t2, this.title$ = i2, this.onEvent = a2, this.onDragStart =
|
3910
|
+
i3 - this.lastTitleBarTouch.timestamp <= 500 ? Math.abs(s3 - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(a3 - this.lastTitleBarTouch.clientY) <= 10 && this.onEvent && this.onEvent({ type: _.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarTouch.timestamp = i3, this.lastTitleBarTouch.clientX = s3, this.lastTitleBarTouch.clientY = a3;
|
3911
|
+
}, this.readonly$ = e2, this.state$ = t2, this.title$ = i2, this.onEvent = a2, this.onDragStart = n2, this.namespace = o2, this.buttons = s2 || [{ type: _.Minimize, iconClassName: this.wrapClassName("titlebar-icon-minimize") }, { type: _.Maximize, iconClassName: this.wrapClassName("titlebar-icon-maximize"), isActive: (e3) => e3 === C$3.Maximized }, { type: _.Close, iconClassName: this.wrapClassName("titlebar-icon-close") }], this.$dragArea = this.renderDragArea();
|
3756
3912
|
}
|
3757
3913
|
render() {
|
3758
3914
|
if (!this.$titleBar) {
|
@@ -3828,13 +3984,13 @@ class A$2 {
|
|
3828
3984
|
i2.className = this.wrapClassName("box-stage-mask");
|
3829
3985
|
const s2 = document.createElement("div");
|
3830
3986
|
s2.className = this.wrapClassName("box-stage-frame");
|
3831
|
-
const [a2, o2, r2
|
3987
|
+
const [a2, n2, o2, r2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
|
3832
3988
|
const i3 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
3833
3989
|
i3.setAttribute("viewBox", "0 0 8 8"), i3.setAttribute("class", `${this.wrapClassName("box-stage-frame-corner")} is-${t3}`);
|
3834
3990
|
const s3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
3835
3991
|
return s3.setAttribute("d", e3), s3.setAttribute("fill", "#3381FF"), i3.appendChild(s3), i3;
|
3836
3992
|
});
|
3837
|
-
return s2.appendChild(a2), s2.appendChild(
|
3993
|
+
return s2.appendChild(a2), s2.appendChild(o2), s2.appendChild(n2), s2.appendChild(r2), e2.appendChild(t2), e2.appendChild(s2), e2.appendChild(i2), this._sideEffect.addDisposer(this.highlightStage$.subscribe((t3) => {
|
3838
3994
|
e2.classList.toggle("is-active", t3);
|
3839
3995
|
})), this._sideEffect.addDisposer(combine([this.highlightStage$, this.stageRect$]).subscribe(([s3, a3]) => {
|
3840
3996
|
s3 && (a3.x > 0 ? (e2.style.flexDirection = "row", t2.style.width = `${a3.x}px`, t2.style.height = "", i2.style.width = `${a3.x}px`, i2.style.height = "") : a3.y > 0 && (e2.style.flexDirection = "column", t2.style.width = "", t2.style.height = `${a3.y}px`, i2.style.width = "", i2.style.height = `${a3.y}px`));
|
@@ -3849,40 +4005,40 @@ class A$2 {
|
|
3849
4005
|
}
|
3850
4006
|
const W$3 = window.ResizeObserver || ResizeObserver$2;
|
3851
4007
|
class Y$3 {
|
3852
|
-
constructor({ id: e2 = genUID(), title: t2 = L$3(), namespace: i2 = "telebox", visible: s2 = true, width: a2 = 0.5, height:
|
4008
|
+
constructor({ id: e2 = genUID(), title: t2 = L$3(), namespace: i2 = "telebox", visible: s2 = true, width: a2 = 0.5, height: n2 = 0.5, minWidth: o2 = 0, minHeight: r2 = 0, x: l2 = 0.1, y: $ = 0.1, resizable: b2 = true, draggable: v2 = true, ratio: w2 = -1, focus: y2 = false, zIndex: z2 = 100, stageRatio: _2 = null, titleBar: B2, content: N2, stage: S2, footer: M2, styles: k2, highlightStage: R2 = null, darkMode$: D2, fence$: T2, minimized$: V2, maximized$: W2, readonly$: Y2, root$: X2, rootRect$: P2, managerStageRect$: O2, managerStageRatio$: j2, collectorRect$: Z2, managerHighlightStage$: F2 }) {
|
3853
4009
|
this.events = new Emittery(), this._delegateEvents = new Emittery(), this.handleTrackStart = (e3) => {
|
3854
4010
|
var t3;
|
3855
4011
|
return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
|
3856
4012
|
}, this._sideEffect = new SideEffectManager(), this.id = e2, this.namespace = i2;
|
3857
|
-
const
|
3858
|
-
this._sideEffect.addDisposer(() =>
|
3859
|
-
const
|
3860
|
-
this._sideEffect.addDisposer(
|
3861
|
-
|
4013
|
+
const G2 = new ValManager();
|
4014
|
+
this._sideEffect.addDisposer(() => G2.destroy());
|
4015
|
+
const J2 = new Val(t2), q2 = new Val(s2), Q2 = new Val(b2), K2 = new Val(v2), U2 = new Val(w2), ee2 = new Val(z2), te2 = new Val(y2), ie2 = new Val(N2), se2 = new Val(S2), ae2 = new Val(M2), ne2 = new Val(k2), oe2 = combine([V2, W2], ([e3, t3]) => e3 ? C$3.Minimized : t3 ? C$3.Maximized : C$3.Normal), re2 = new Val({ width: I$3(o2, 0, 1), height: I$3(r2, 0, 1) }, { compare: shallowequal }), he2 = combine([re2, O2], ([e3, t3]) => ({ width: e3.width * t3.width, height: e3.height * t3.height }), { compare: shallowequal }), le2 = new Val({ width: a2, height: n2 }, { compare: shallowequal });
|
4016
|
+
this._sideEffect.addDisposer(re2.reaction((e3, t3) => {
|
4017
|
+
le2.setValue({ width: Math.max(a2, e3.width), height: Math.max(n2, e3.height) }, t3);
|
3862
4018
|
}));
|
3863
|
-
const
|
3864
|
-
this._sideEffect.addDisposer(() =>
|
3865
|
-
withReadonlyValueEnhancer(this, { darkMode:
|
3866
|
-
const
|
3867
|
-
withReadonlyValueEnhancer(this,
|
3868
|
-
withValueEnhancer(this, { title:
|
4019
|
+
const de2 = new Val({ x: l2, y: $ }, { compare: shallowequal }), ce2 = combine([le2, O2], ([e3, t3]) => ({ width: t3.width * e3.width, height: t3.height * e3.height }), { compare: shallowequal }), me2 = combine([de2, O2], ([e3, t3]) => ({ x: e3.x * t3.width + t3.x, y: e3.y * t3.height + t3.y }), { compare: shallowequal }), ue2 = new Val(R2), ge2 = combine([ue2, F2], ([e3, t3]) => e3 != null ? e3 : t3), xe2 = new Val(null), pe2 = new Val(P2.value, { compare: shallowequal }), fe2 = new Val(_2), $e2 = new A$2({ namespace: i2, root$: xe2, rootRect$: pe2, ratio$: combine([fe2, j2], ([e3, t3]) => e3 != null ? e3 : t3), highlightStage$: ge2 });
|
4020
|
+
this._sideEffect.addDisposer(() => $e2.destroy());
|
4021
|
+
withReadonlyValueEnhancer(this, { darkMode: D2, fence: T2, minimized: V2, maximized: W2, readonly: Y2, rootRect: P2, managerStageRect: O2, collectorRect: Z2 });
|
4022
|
+
const be2 = { zIndex: ee2, focus: te2, $userContent: ie2, $userStage: se2, $userFooter: ae2, $userStyles: ne2, state: oe2, minSize: re2, pxMinSize: he2, intrinsicSize: le2, intrinsicCoord: de2, pxIntrinsicSize: ce2, pxIntrinsicCoord: me2, highlightStage: ge2, boxHighlightStage: ue2, contentRect: pe2, contentStageRect: $e2.stageRect$ };
|
4023
|
+
withReadonlyValueEnhancer(this, be2, G2);
|
4024
|
+
withValueEnhancer(this, { title: J2, visible: q2, resizable: Q2, draggable: K2, ratio: U2, stageRatio: fe2 }, G2), this.titleBar = B2 || new H$3({ readonly$: Y2, state$: oe2, title$: J2, namespace: this.namespace, onDragStart: (e3) => {
|
3869
4025
|
var t3;
|
3870
4026
|
return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
|
3871
|
-
}, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(
|
3872
|
-
e3 > 0 && this.transform(
|
3873
|
-
})), this._sideEffect.addDisposer(
|
3874
|
-
e3 && this.move(
|
3875
|
-
})), this.$box = this.render(),
|
3876
|
-
const
|
4027
|
+
}, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(U2.subscribe((e3) => {
|
4028
|
+
e3 > 0 && this.transform(me2.value.x, me2.value.y, ce2.value.width, ce2.value.height, true);
|
4029
|
+
})), this._sideEffect.addDisposer(T2.subscribe((e3) => {
|
4030
|
+
e3 && this.move(me2.value.x, me2.value.y, true);
|
4031
|
+
})), this.$box = this.render(), xe2.setValue(this.$content.parentElement);
|
4032
|
+
const ve2 = (e3, t3) => {
|
3877
4033
|
this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
|
3878
4034
|
i3 || this.events.emit(t3, e4);
|
3879
4035
|
}));
|
3880
4036
|
};
|
3881
|
-
|
4037
|
+
ve2(D2, E$3.DarkMode), ve2(Y2, E$3.Readonly), ve2(ee2, E$3.ZIndex), ve2(V2, E$3.Minimized), ve2(W2, E$3.Maximized), ve2(oe2, E$3.State), ve2(le2, E$3.IntrinsicResize), ve2(de2, E$3.IntrinsicMove), this._sideEffect.addDisposer([q2.reaction((e3, t3) => {
|
3882
4038
|
t3 || e3 || this.events.emit(E$3.Close);
|
3883
|
-
}),
|
4039
|
+
}), te2.reaction((e3, t3) => {
|
3884
4040
|
t3 || this.events.emit(e3 ? E$3.Focus : E$3.Blur);
|
3885
|
-
}),
|
4041
|
+
}), X2.subscribe((e3) => {
|
3886
4042
|
e3 ? e3.appendChild(this.$box) : this.$box.parentNode && this.$box.remove();
|
3887
4043
|
})]);
|
3888
4044
|
}
|
@@ -3915,22 +4071,22 @@ class Y$3 {
|
|
3915
4071
|
}
|
3916
4072
|
move(e2, t2, i2 = false) {
|
3917
4073
|
let s2, a2;
|
3918
|
-
const
|
4074
|
+
const n2 = this.managerStageRect, o2 = this.pxIntrinsicSize;
|
3919
4075
|
if (this.fence)
|
3920
|
-
s2 = I$3(e2,
|
4076
|
+
s2 = I$3(e2, n2.x, n2.x + n2.width - o2.width), a2 = I$3(t2, n2.y, n2.y + n2.height - o2.height);
|
3921
4077
|
else {
|
3922
4078
|
const i3 = this.rootRect;
|
3923
|
-
s2 = I$3(e2,
|
4079
|
+
s2 = I$3(e2, 0 - o2.width + 20, 0 + i3.width - 20), a2 = I$3(t2, 0, 0 + i3.height - 20);
|
3924
4080
|
}
|
3925
|
-
this._intrinsicCoord$.setValue({ x: (s2 -
|
4081
|
+
this._intrinsicCoord$.setValue({ x: (s2 - n2.x) / n2.width, y: (a2 - n2.y) / n2.height }, i2);
|
3926
4082
|
}
|
3927
4083
|
transform(e2, t2, i2, s2, a2 = false) {
|
3928
|
-
const
|
4084
|
+
const n2 = this.managerStageRect, o2 = this.rootRect;
|
3929
4085
|
if (i2 = Math.max(i2, this.pxMinSize.width), s2 = Math.max(s2, this.pxMinSize.height), this.ratio > 0) {
|
3930
4086
|
const e3 = this.ratio * i2;
|
3931
4087
|
t2 !== this.pxIntrinsicCoord.y && (t2 -= e3 - s2), s2 = e3;
|
3932
4088
|
}
|
3933
|
-
t2 <
|
4089
|
+
t2 < o2.y && (t2 = o2.y, s2 = this.pxIntrinsicSize.height), this.move(e2, t2, a2), this._intrinsicSize$.setValue({ width: i2 / n2.width, height: s2 / n2.height }, a2);
|
3934
4090
|
}
|
3935
4091
|
mountContent(e2) {
|
3936
4092
|
this._$userContent$.setValue(e2);
|
@@ -3938,6 +4094,12 @@ class Y$3 {
|
|
3938
4094
|
unmountContent() {
|
3939
4095
|
this._$userContent$.setValue(void 0);
|
3940
4096
|
}
|
4097
|
+
mountStage(e2) {
|
4098
|
+
this._$userStage$.setValue(e2);
|
4099
|
+
}
|
4100
|
+
unmountStage() {
|
4101
|
+
this._$userStage$.setValue(void 0);
|
4102
|
+
}
|
3941
4103
|
mountFooter(e2) {
|
3942
4104
|
this._$userFooter$.setValue(e2);
|
3943
4105
|
}
|
@@ -3980,47 +4142,62 @@ class Y$3 {
|
|
3980
4142
|
this.$box.style.zIndex = String(e3);
|
3981
4143
|
})), this.$box.dataset.teleBoxID = this.id;
|
3982
4144
|
const t2 = index(this.$box), i2 = combine([this._maximized$, this._minimized$, this._pxIntrinsicSize$, this._pxIntrinsicCoord$, this._collectorRect$], ([e3, t3, i3, s3, a3]) => {
|
3983
|
-
const
|
4145
|
+
const n3 = e3 ? { x: 0, y: 0, width: "100%", height: "100%", scaleX: 1, scaleY: 1 } : { x: s3.x, y: s3.y, width: i3.width + "px", height: i3.height + "px", scaleX: 1, scaleY: 1 };
|
3984
4146
|
if (t3 && a3) {
|
3985
4147
|
const { width: t4, height: s4 } = e3 ? this.rootRect : i3;
|
3986
|
-
|
4148
|
+
n3.x = a3.x - t4 / 2 + a3.width / 2, n3.y = a3.y - s4 / 2 + a3.height / 2, n3.scaleX = a3.width / t4, n3.scaleY = a3.height / s4;
|
3987
4149
|
}
|
3988
|
-
return
|
4150
|
+
return n3;
|
3989
4151
|
}, { compare: shallowequal }), s2 = i2.value;
|
3990
4152
|
this.$box.style.width = s2.width, this.$box.style.height = s2.height, this.$box.style.transform = `translate(${s2.x - 10}px,${s2.y - 10}px)`, this._sideEffect.addDisposer(i2.subscribe((e3) => {
|
3991
4153
|
t2.set(e3);
|
3992
4154
|
}));
|
3993
4155
|
const a2 = document.createElement("div");
|
3994
4156
|
a2.className = this.wrapClassName("box-main"), this.$box.appendChild(a2);
|
4157
|
+
const n2 = document.createElement("div");
|
4158
|
+
n2.className = this.wrapClassName("titlebar-wrap"), n2.appendChild(this.titleBar.render()), this.$titleBar = n2;
|
3995
4159
|
const o2 = document.createElement("div");
|
3996
|
-
o2.className = this.wrapClassName("
|
4160
|
+
o2.className = this.wrapClassName("content-wrap");
|
3997
4161
|
const r2 = document.createElement("div");
|
3998
|
-
r2.className = this.wrapClassName("content-
|
3999
|
-
const n2 = document.createElement("div");
|
4000
|
-
n2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = n2, this._sideEffect.add(() => {
|
4162
|
+
r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2, this._sideEffect.add(() => {
|
4001
4163
|
const e3 = new W$3(() => {
|
4002
|
-
const e4 =
|
4164
|
+
const e4 = r2.getBoundingClientRect();
|
4003
4165
|
this._contentRect$.setValue({ x: e4.x, y: e4.y, width: e4.width, height: e4.height });
|
4004
4166
|
});
|
4005
|
-
return e3.observe(
|
4167
|
+
return e3.observe(r2), () => e3.disconnect();
|
4006
4168
|
}), this._sideEffect.add(() => {
|
4007
4169
|
let e3;
|
4008
4170
|
return this._$userStyles$.subscribe((t3) => {
|
4009
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4171
|
+
e3 && e3.remove(), e3 = t3, t3 && o2.appendChild(t3);
|
4010
4172
|
});
|
4011
4173
|
}), this._sideEffect.add(() => {
|
4012
4174
|
let e3;
|
4013
4175
|
return this._$userContent$.subscribe((t3) => {
|
4014
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4176
|
+
e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
|
4177
|
+
});
|
4178
|
+
}), this._sideEffect.add(() => {
|
4179
|
+
let e3;
|
4180
|
+
return this._$userStage$.subscribe((t3) => {
|
4181
|
+
var i3;
|
4182
|
+
if (e3 && e3.remove(), e3 = t3, t3) {
|
4183
|
+
if (!this.$stage) {
|
4184
|
+
const e4 = document.createElement("div");
|
4185
|
+
this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
|
4186
|
+
t4 && (e4.style.top = t4.y + "px", e4.style.left = t4.x + "px", e4.style.width = t4.width + "px", e4.style.height = t4.height + "px");
|
4187
|
+
}), "content-stage-rect"), r2.appendChild(e4);
|
4188
|
+
}
|
4189
|
+
this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
|
4190
|
+
} else
|
4191
|
+
((i3 = this.$stage) == null ? void 0 : i3.parentElement) && this.$stage.remove();
|
4015
4192
|
});
|
4016
|
-
}),
|
4193
|
+
}), o2.appendChild(r2);
|
4017
4194
|
const h = document.createElement("div");
|
4018
4195
|
return h.className = this.wrapClassName("footer-wrap"), this.$footer = h, this._sideEffect.add(() => {
|
4019
4196
|
let e3;
|
4020
4197
|
return this._$userFooter$.subscribe((t3) => {
|
4021
4198
|
e3 && e3.remove(), e3 = t3, t3 && h.appendChild(t3);
|
4022
4199
|
});
|
4023
|
-
}), a2.appendChild(
|
4200
|
+
}), a2.appendChild(n2), a2.appendChild(o2), a2.appendChild(h), this._renderResizeHandlers(), this.$box;
|
4024
4201
|
}
|
4025
4202
|
_renderResizeHandlers() {
|
4026
4203
|
const e2 = document.createElement("div");
|
@@ -4029,7 +4206,7 @@ class Y$3 {
|
|
4029
4206
|
i3.className = this.wrapClassName(t3) + " " + this.wrapClassName("resize-handle"), i3.dataset.teleBoxHandle = t3, e2.appendChild(i3);
|
4030
4207
|
}), this.$box.appendChild(e2);
|
4031
4208
|
const t2 = "handle-tracking-listener", i2 = this.wrapClassName("transforming");
|
4032
|
-
let s2, a2,
|
4209
|
+
let s2, a2, n2 = 0, o2 = 0, r2 = 0, h = 0, l2 = 0, d2 = 0;
|
4033
4210
|
const c = (e3) => {
|
4034
4211
|
if (this.state !== C$3.Normal)
|
4035
4212
|
return;
|
@@ -4037,36 +4214,36 @@ class Y$3 {
|
|
4037
4214
|
let { pageX: t3, pageY: i3 } = R$3(e3);
|
4038
4215
|
i3 < this.rootRect.y && (i3 = this.rootRect.y);
|
4039
4216
|
const s3 = t3 - l2, c2 = i3 - d2;
|
4040
|
-
let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width:
|
4217
|
+
let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: x2 } = this.pxIntrinsicSize;
|
4041
4218
|
switch (a2) {
|
4042
4219
|
case N$3.North:
|
4043
|
-
u3 =
|
4220
|
+
u3 = o2 + c2, x2 = h - c2;
|
4044
4221
|
break;
|
4045
4222
|
case N$3.South:
|
4046
|
-
|
4223
|
+
x2 = h + c2;
|
4047
4224
|
break;
|
4048
4225
|
case N$3.West:
|
4049
|
-
m3 =
|
4226
|
+
m3 = n2 + s3, g2 = r2 - s3;
|
4050
4227
|
break;
|
4051
4228
|
case N$3.East:
|
4052
|
-
|
4229
|
+
g2 = r2 + s3;
|
4053
4230
|
break;
|
4054
4231
|
case N$3.NorthWest:
|
4055
|
-
m3 =
|
4232
|
+
m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, x2 = h - c2;
|
4056
4233
|
break;
|
4057
4234
|
case N$3.NorthEast:
|
4058
|
-
u3 =
|
4235
|
+
u3 = o2 + c2, g2 = r2 + s3, x2 = h - c2;
|
4059
4236
|
break;
|
4060
4237
|
case N$3.SouthEast:
|
4061
|
-
|
4238
|
+
g2 = r2 + s3, x2 = h + c2;
|
4062
4239
|
break;
|
4063
4240
|
case N$3.SouthWest:
|
4064
|
-
m3 =
|
4241
|
+
m3 = n2 + s3, g2 = r2 - s3, x2 = h + c2;
|
4065
4242
|
break;
|
4066
4243
|
default:
|
4067
|
-
return void this.move(
|
4244
|
+
return void this.move(n2 + s3, o2 + c2);
|
4068
4245
|
}
|
4069
|
-
this.transform(m3, u3,
|
4246
|
+
this.transform(m3, u3, g2, x2);
|
4070
4247
|
}, m2 = (e3) => {
|
4071
4248
|
a2 = void 0, s2 && (k$1(e3), this.$box.classList.toggle(i2, false), this._sideEffect.flush(t2), s2.remove());
|
4072
4249
|
}, u2 = (e3) => {
|
@@ -4077,9 +4254,9 @@ class Y$3 {
|
|
4077
4254
|
return;
|
4078
4255
|
if (!this.draggable || a2 || this.state !== C$3.Normal)
|
4079
4256
|
return;
|
4080
|
-
const
|
4081
|
-
if ((u3 =
|
4082
|
-
k$1(e3), { x:
|
4257
|
+
const g2 = e3.target;
|
4258
|
+
if ((u3 = g2.dataset) == null ? void 0 : u3.teleBoxHandle) {
|
4259
|
+
k$1(e3), { x: n2, y: o2 } = this.pxIntrinsicCoord, { width: r2, height: h } = this.pxIntrinsicSize, { pageX: l2, pageY: d2 } = R$3(e3), a2 = g2.dataset.teleBoxHandle, s2 || (s2 = document.createElement("div"));
|
4083
4260
|
const u4 = a2 ? this.wrapClassName(`cursor-${a2}`) : "";
|
4084
4261
|
s2.className = this.wrapClassName("track-mask" + (u4 ? ` ${u4}` : "")), this.$box.appendChild(s2), this.$box.classList.add(i2), this._sideEffect.add(() => (window.addEventListener("mousemove", c), window.addEventListener("touchmove", c, { passive: false }), window.addEventListener("mouseup", m2), window.addEventListener("touchend", m2, { passive: false }), window.addEventListener("touchcancel", m2, { passive: false }), () => {
|
4085
4262
|
window.removeEventListener("mousemove", c), window.removeEventListener("touchmove", c), window.removeEventListener("mouseup", m2), window.removeEventListener("touchend", m2), window.removeEventListener("touchcancel", m2);
|
@@ -4097,14 +4274,14 @@ class Y$3 {
|
|
4097
4274
|
}
|
4098
4275
|
var X$3, P$3;
|
4099
4276
|
class O$3 {
|
4100
|
-
constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles:
|
4277
|
+
constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles: n2 = {}, root$: o2 }) {
|
4101
4278
|
this._sideEffect = new SideEffectManager(), this.namespace = a2;
|
4102
|
-
const
|
4103
|
-
this._sideEffect.addDisposer(() =>
|
4104
|
-
const h = new Val(void 0), l2 = derive(e2), d2 = new Val(
|
4105
|
-
withValueEnhancer(this, { styles: d2, $collector: m2 },
|
4106
|
-
withReadonlyValueEnhancer(this, { root:
|
4107
|
-
withReadonlyValueEnhancer(this, { rect: h, visible: l2 },
|
4279
|
+
const r2 = new ValManager();
|
4280
|
+
this._sideEffect.addDisposer(() => r2.destroy());
|
4281
|
+
const h = new Val(void 0), l2 = derive(e2), d2 = new Val(n2), m2 = new Val(document.createElement("button"));
|
4282
|
+
withValueEnhancer(this, { styles: d2, $collector: m2 }, r2);
|
4283
|
+
withReadonlyValueEnhancer(this, { root: o2 });
|
4284
|
+
withReadonlyValueEnhancer(this, { rect: h, visible: l2 }, r2), m2.value.className = this.wrapClassName("collector"), m2.value.style.backgroundImage = "url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K')", this._sideEffect.addDisposer(m2.subscribe((a3) => {
|
4108
4285
|
this._sideEffect.addEventListener(a3, "click", () => {
|
4109
4286
|
t2.value || e2.setValue(false);
|
4110
4287
|
}, {}, "telebox-collector-click"), this._sideEffect.addDisposer([l2.subscribe((e3) => {
|
@@ -4118,12 +4295,12 @@ class O$3 {
|
|
4118
4295
|
const i3 = e3[t3];
|
4119
4296
|
i3 != null && (a3.style[t3] = i3);
|
4120
4297
|
});
|
4121
|
-
}),
|
4298
|
+
}), o2.subscribe((e3) => {
|
4122
4299
|
e3 && e3.appendChild(a3);
|
4123
|
-
}), combine([e2, s2,
|
4300
|
+
}), combine([e2, s2, o2]).subscribe(([e3, t3, i3]) => {
|
4124
4301
|
if (e3 && i3) {
|
4125
|
-
const { x: e4, y: i4, width: s3, height:
|
4126
|
-
h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height:
|
4302
|
+
const { x: e4, y: i4, width: s3, height: n3 } = a3.getBoundingClientRect();
|
4303
|
+
h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height: n3 });
|
4127
4304
|
}
|
4128
4305
|
})], "telebox-collector-el");
|
4129
4306
|
}));
|
@@ -4149,8 +4326,8 @@ class j$1 extends H$3 {
|
|
4149
4326
|
if (this.$titles && this.state$.value === C$3.Maximized) {
|
4150
4327
|
const { children: i2 } = this.$titles.firstElementChild;
|
4151
4328
|
for (let s2 = i2.length - 1; s2 >= 0; s2 -= 1) {
|
4152
|
-
const a2 = i2[s2],
|
4153
|
-
|
4329
|
+
const a2 = i2[s2], n2 = (t2 = a2.dataset) == null ? void 0 : t2.teleBoxID;
|
4330
|
+
n2 && (e2 && n2 === e2.id ? a2.classList.toggle(this.wrapClassName("titles-tab-focus"), true) : this.focusedBox && n2 === this.focusedBox.id && a2.classList.toggle(this.wrapClassName("titles-tab-focus"), false));
|
4154
4331
|
}
|
4155
4332
|
}
|
4156
4333
|
this.focusedBox = e2;
|
@@ -4190,11 +4367,11 @@ class j$1 extends H$3 {
|
|
4190
4367
|
}
|
4191
4368
|
const Z$3 = window.ResizeObserver || ResizeObserver$2;
|
4192
4369
|
class F$3 {
|
4193
|
-
constructor({ root: e2 = null, prefersColorScheme: t2 = v$3.Light, minimized: i2 = false, maximized: s2 = false, fence: a2 = false, collector:
|
4194
|
-
this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace =
|
4370
|
+
constructor({ root: e2 = null, prefersColorScheme: t2 = v$3.Light, minimized: i2 = false, maximized: s2 = false, fence: a2 = false, collector: n2, namespace: o2 = "telebox", readonly: r2 = false, stageRatio: l2 = -1, highlightStage: m2 = true } = {}) {
|
4371
|
+
this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace = o2;
|
4195
4372
|
const b2 = new ValManager();
|
4196
4373
|
this._sideEffect.addDisposer(() => b2.destroy());
|
4197
|
-
const w2 = new Val(e2), y2 = new Val(
|
4374
|
+
const w2 = new Val(e2), y2 = new Val(r2), z2 = new Val(i2), B2 = new Val(s2), N2 = new Val(a2), S2 = new Val(l2), M2 = new Val(m2), I2 = new Val({ x: 0, y: 0, width: window.innerWidth, height: window.innerHeight }, { compare: shallowequal });
|
4198
4375
|
this._sideEffect.addDisposer(w2.subscribe((e3) => {
|
4199
4376
|
this._sideEffect.add(() => {
|
4200
4377
|
if (!e3)
|
@@ -4224,13 +4401,13 @@ class F$3 {
|
|
4224
4401
|
this._sideEffect.addDisposer(D2.reaction((e3, t3) => {
|
4225
4402
|
t3 || this.events.emit(X$3.PrefersColorScheme, e3);
|
4226
4403
|
}));
|
4227
|
-
const L2 = combine([R2, D2], ([e3, t3]) => t3 === "auto" ? e3 : t3 === "dark"), T2 = combine([z2,
|
4228
|
-
this.collector =
|
4229
|
-
const V2 = new A$2({ namespace:
|
4404
|
+
const L2 = combine([R2, D2], ([e3, t3]) => t3 === "auto" ? e3 : t3 === "dark"), T2 = combine([z2, B2], ([e3, t3]) => e3 ? C$3.Minimized : t3 ? C$3.Maximized : C$3.Normal);
|
4405
|
+
this.collector = n2 != null ? n2 : new O$3({ minimized$: z2, readonly$: y2, darkMode$: L2, namespace: o2, root$: w2, rootRect$: I2 });
|
4406
|
+
const V2 = new A$2({ namespace: o2, rootRect$: I2, ratio$: S2, root$: w2, highlightStage$: combine([M2, B2, z2], ([e3, t3, i3]) => e3 && (i3 || !t3)) });
|
4230
4407
|
this._sideEffect.addDisposer(() => V2.destroy());
|
4231
4408
|
const H2 = { darkMode: L2, state: T2, root: w2, rootRect: I2, stageRect: V2.stageRect$ };
|
4232
4409
|
withReadonlyValueEnhancer(this, H2, b2);
|
4233
|
-
withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized:
|
4410
|
+
withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized: B2, stageRatio: S2, highlightStage: M2 }, b2);
|
4234
4411
|
const W2 = this.wrapClassName("titlebar-icon-close"), Y2 = (e3) => {
|
4235
4412
|
var t3;
|
4236
4413
|
if (y2.value)
|
@@ -4250,10 +4427,10 @@ class F$3 {
|
|
4250
4427
|
};
|
4251
4428
|
this._sideEffect.addEventListener(window, "mousedown", Y2, true), this._sideEffect.addEventListener(window, "touchstart", Y2, true), this.titleBar = new j$1({ namespace: this.namespace, title$: derive(this.topBox$, (e3) => (e3 == null ? void 0 : e3.title) || ""), boxes$: this.boxes$, darkMode$: L2, readonly$: y2, state$: T2, root$: w2, rootRect$: I2, onEvent: (e3) => {
|
4252
4429
|
switch (e3.type) {
|
4253
|
-
case
|
4254
|
-
|
4430
|
+
case _.Maximize:
|
4431
|
+
B2.setValue(!B2.value);
|
4255
4432
|
break;
|
4256
|
-
case
|
4433
|
+
case _.Minimize:
|
4257
4434
|
z2.setValue(true);
|
4258
4435
|
break;
|
4259
4436
|
case E$3.Close:
|
@@ -4261,7 +4438,7 @@ class F$3 {
|
|
4261
4438
|
}
|
4262
4439
|
} }), this._sideEffect.addDisposer([T2.reaction((e3, t3) => {
|
4263
4440
|
t3 || this.events.emit(X$3.State, e3);
|
4264
|
-
}),
|
4441
|
+
}), B2.reaction((e3, t3) => {
|
4265
4442
|
t3 || this.events.emit(X$3.Maximized, e3);
|
4266
4443
|
}), z2.reaction((e3, t3) => {
|
4267
4444
|
t3 || this.events.emit(X$3.Minimized, e3);
|
@@ -4289,13 +4466,13 @@ class F$3 {
|
|
4289
4466
|
return this;
|
4290
4467
|
}
|
4291
4468
|
create(e2 = {}, s2 = true) {
|
4292
|
-
const a2 = new Y$3((
|
4293
|
-
var
|
4294
|
-
return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(
|
4469
|
+
const a2 = new Y$3((n2 = r$4(r$4({ zIndex: this.topBox ? this.topBox.zIndex + 1 : 100 }, e2), s2 ? this.smartPosition(e2) : {}), o2 = { namespace: this.namespace, root$: this._root$, darkMode$: this._darkMode$, maximized$: this._maximized$, minimized$: this._minimized$, fence$: this._fence$, rootRect$: this._rootRect$, managerStageRect$: this._stageRect$, managerStageRatio$: this._stageRatio$, readonly$: this._readonly$, collectorRect$: this.collector._rect$, managerHighlightStage$: this._highlightStage$ }, t$3(n2, i$1(o2))));
|
4470
|
+
var n2, o2;
|
4471
|
+
return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(_.Maximize, () => {
|
4295
4472
|
this.setMaximized(!this.maximized);
|
4296
|
-
}), a2._delegateEvents.on(
|
4473
|
+
}), a2._delegateEvents.on(_.Minimize, () => {
|
4297
4474
|
this.setMinimized(true);
|
4298
|
-
}), a2._delegateEvents.on(
|
4475
|
+
}), a2._delegateEvents.on(_.Close, () => {
|
4299
4476
|
this.remove(a2), this.focusTopBox();
|
4300
4477
|
}), a2._intrinsicCoord$.reaction((e3, t2) => {
|
4301
4478
|
t2 || this.events.emit(X$3.IntrinsicMove, a2);
|
@@ -4380,27 +4557,27 @@ class F$3 {
|
|
4380
4557
|
return (i2) => t2.every((t3) => e2[t3] === i2[t3]);
|
4381
4558
|
}
|
4382
4559
|
updateBox(e2, t2, i2 = false) {
|
4383
|
-
var s2, a2, o2, r2,
|
4384
|
-
t2.x == null && t2.y == null || e2._intrinsicCoord$.setValue({ x: (s2 = t2.x) != null ? s2 : e2.intrinsicX, y: (a2 = t2.y) != null ? a2 : e2.intrinsicY }, i2), t2.width == null && t2.height == null || e2._intrinsicSize$.setValue({ width: (
|
4560
|
+
var s2, a2, n2, o2, r2, h;
|
4561
|
+
t2.x == null && t2.y == null || e2._intrinsicCoord$.setValue({ x: (s2 = t2.x) != null ? s2 : e2.intrinsicX, y: (a2 = t2.y) != null ? a2 : e2.intrinsicY }, i2), t2.width == null && t2.height == null || e2._intrinsicSize$.setValue({ width: (n2 = t2.width) != null ? n2 : e2.intrinsicWidth, height: (o2 = t2.height) != null ? o2 : e2.intrinsicHeight }, i2), t2.title != null && e2._title$.setValue(t2.title), t2.visible != null && e2._visible$.setValue(t2.visible, i2), t2.resizable != null && e2._resizable$.setValue(t2.resizable, i2), t2.draggable != null && e2._draggable$.setValue(t2.draggable, i2), t2.ratio != null && e2._ratio$.setValue(t2.ratio, i2), t2.zIndex != null && e2._zIndex$.setValue(t2.zIndex, i2), t2.stageRatio !== void 0 && e2.setStageRatio(t2.stageRatio, i2), t2.content != null && e2.mountContent(t2.content), t2.footer != null && e2.mountFooter(t2.footer), t2.minHeight == null && t2.minWidth == null || e2._minSize$.setValue({ width: (r2 = t2.minWidth) != null ? r2 : e2.minWidth, height: (h = t2.minHeight) != null ? h : e2.minHeight }, i2);
|
4385
4562
|
}
|
4386
4563
|
smartPosition(e2) {
|
4387
4564
|
let { x: t2, y: i2 } = e2;
|
4388
|
-
const { width: s2 = 0.5, height: a2 = 0.5 } = e2,
|
4565
|
+
const { width: s2 = 0.5, height: a2 = 0.5 } = e2, n2 = this.stageRect, o2 = this.topBox;
|
4389
4566
|
if (t2 == null) {
|
4390
|
-
let e3 =
|
4391
|
-
if (
|
4392
|
-
const t3 =
|
4393
|
-
t3 + s2 *
|
4567
|
+
let e3 = n2.x + 20;
|
4568
|
+
if (o2) {
|
4569
|
+
const t3 = o2.pxIntrinsicCoord.x + 20;
|
4570
|
+
t3 + s2 * n2.width <= n2.x + n2.width && (e3 = t3);
|
4394
4571
|
}
|
4395
|
-
t2 = (e3 -
|
4572
|
+
t2 = (e3 - n2.x) / n2.width;
|
4396
4573
|
}
|
4397
4574
|
if (i2 == null) {
|
4398
|
-
let e3 =
|
4399
|
-
if (
|
4400
|
-
const t3 =
|
4401
|
-
t3 + a2 *
|
4575
|
+
let e3 = n2.y + 20;
|
4576
|
+
if (o2) {
|
4577
|
+
const t3 = o2.pxIntrinsicCoord.y + 20;
|
4578
|
+
t3 + a2 * n2.height <= n2.y + n2.height && (e3 = t3);
|
4402
4579
|
}
|
4403
|
-
i2 = (e3 -
|
4580
|
+
i2 = (e3 - n2.y) / n2.height;
|
4404
4581
|
}
|
4405
4582
|
return { x: t2, y: i2, width: s2, height: a2 };
|
4406
4583
|
}
|
@@ -4567,8 +4744,9 @@ class BoxManager {
|
|
4567
4744
|
height,
|
4568
4745
|
id: params.appId
|
4569
4746
|
};
|
4570
|
-
this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4747
|
+
const box = this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4571
4748
|
this.context.emitter.emit(`${params.appId}${Events.WindowCreated}`);
|
4749
|
+
return box;
|
4572
4750
|
}
|
4573
4751
|
setupBoxManager(createTeleBoxManagerConfig) {
|
4574
4752
|
const root = WindowManager.playground;
|
@@ -5691,6 +5869,7 @@ class ReconnectRefresher {
|
|
5691
5869
|
this.reactors.set(id2, func);
|
5692
5870
|
this.disposers.set(id2, func());
|
5693
5871
|
}
|
5872
|
+
return () => this.remove(id2);
|
5694
5873
|
}
|
5695
5874
|
remove(id2) {
|
5696
5875
|
if (this.reactors.has(id2)) {
|
@@ -15316,14 +15495,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15316
15495
|
const _WindowManager = class extends InvisiblePlugin {
|
15317
15496
|
constructor(context) {
|
15318
15497
|
super(context);
|
15319
|
-
this.version = "1.0.0-canary.
|
15320
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15498
|
+
this.version = "1.0.0-canary.6";
|
15499
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.13", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.2.1", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15321
15500
|
this.emitter = callbacks$1;
|
15322
15501
|
this.viewMode = ViewMode.Broadcaster;
|
15323
15502
|
this.isReplay = isPlayer(this.displayer);
|
15324
15503
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15325
15504
|
_WindowManager.displayer = context.displayer;
|
15326
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15505
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.13", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.2.1", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15327
15506
|
}
|
15328
15507
|
static async mount(params) {
|
15329
15508
|
var _a;
|