@netless/window-manager 1.0.0-canary.2 → 1.0.0-canary.22
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 +11 -7
- package/dist/App/AppProxy.d.ts +35 -7
- package/dist/App/{WhiteBoardView.d.ts → WhiteboardView.d.ts} +10 -1
- package/dist/App/index.d.ts +2 -1
- package/dist/App/type.d.ts +21 -0
- package/dist/AppManager.d.ts +5 -5
- package/dist/AttributesDelegate.d.ts +11 -16
- package/dist/BoxManager.d.ts +7 -6
- package/dist/Cursor/index.d.ts +0 -1
- package/dist/InternalEmitter.d.ts +3 -2
- package/dist/Page/PageController.d.ts +1 -0
- package/dist/ReconnectRefresher.d.ts +1 -1
- package/dist/Utils/Common.d.ts +1 -0
- package/dist/View/CameraSynchronizer.d.ts +9 -9
- package/dist/View/MainView.d.ts +18 -7
- package/dist/View/ViewSync.d.ts +24 -0
- package/dist/constants.d.ts +6 -2
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +19 -2
- package/dist/index.es.js +803 -425
- package/dist/index.umd.js +12 -12
- package/dist/style.css +1 -1
- package/docs/app-context.md +98 -64
- package/docs/develop-app.md +2 -5
- package/docs/mirgrate-to-1.0.md +28 -0
- package/package.json +3 -3
- package/pnpm-lock.yaml +9 -9
- package/src/App/AppContext.ts +43 -21
- package/src/App/AppProxy.ts +247 -79
- package/src/App/{WhiteBoardView.ts → WhiteboardView.ts} +38 -4
- package/src/App/index.ts +2 -1
- package/src/App/type.ts +22 -0
- package/src/AppManager.ts +38 -31
- package/src/AttributesDelegate.ts +18 -18
- package/src/BoxManager.ts +28 -22
- package/src/Cursor/index.ts +0 -2
- package/src/InternalEmitter.ts +3 -2
- package/src/Page/PageController.ts +1 -0
- package/src/PageState.ts +1 -1
- package/src/ReconnectRefresher.ts +7 -2
- package/src/Utils/Common.ts +6 -0
- package/src/Utils/Reactive.ts +27 -26
- package/src/Utils/RoomHacker.ts +3 -0
- package/src/View/CameraSynchronizer.ts +43 -30
- package/src/View/MainView.ts +106 -81
- package/src/View/ViewSync.ts +110 -0
- package/src/constants.ts +5 -1
- package/src/index.ts +59 -15
- package/src/style.css +8 -0
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,
|
23
|
-
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, isPlayer, isRoom, ApplianceNames, RoomPhase, InvisiblePlugin
|
22
|
+
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, pick, isBoolean, isNumber, throttle, delay, omitBy, isUndefined, isInteger, orderBy, isEmpty, isFunction, isNull } from "lodash";
|
23
|
+
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, ViewMode, isPlayer, isRoom, ApplianceNames, RoomPhase, InvisiblePlugin } 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) => {
|
@@ -33,7 +33,6 @@ var Events = /* @__PURE__ */ ((Events2) => {
|
|
33
33
|
Events2["AppBoxStateChange"] = "AppBoxStateChange";
|
34
34
|
Events2["GetAttributes"] = "GetAttributes";
|
35
35
|
Events2["UpdateWindowManagerWrapper"] = "UpdateWindowManagerWrapper";
|
36
|
-
Events2["InitReplay"] = "InitReplay";
|
37
36
|
Events2["WindowCreated"] = "WindowCreated";
|
38
37
|
Events2["SetMainViewScenePath"] = "SetMainViewScenePath";
|
39
38
|
Events2["SetMainViewSceneIndex"] = "SetMainViewSceneIndex";
|
@@ -54,6 +53,11 @@ var AppAttributes = /* @__PURE__ */ ((AppAttributes2) => {
|
|
54
53
|
AppAttributes2["Position"] = "position";
|
55
54
|
AppAttributes2["SceneIndex"] = "SceneIndex";
|
56
55
|
AppAttributes2["ZIndex"] = "zIndex";
|
56
|
+
AppAttributes2["Visible"] = "visible";
|
57
|
+
AppAttributes2["Ratio"] = "ratio";
|
58
|
+
AppAttributes2["StageRatio"] = "stageRatio";
|
59
|
+
AppAttributes2["Draggable"] = "draggable";
|
60
|
+
AppAttributes2["Resizable"] = "resizable";
|
57
61
|
return AppAttributes2;
|
58
62
|
})(AppAttributes || {});
|
59
63
|
var AppEvents = /* @__PURE__ */ ((AppEvents2) => {
|
@@ -355,6 +359,11 @@ const setViewFocusScenePath = (view, focusScenePath) => {
|
|
355
359
|
return view;
|
356
360
|
}
|
357
361
|
};
|
362
|
+
const releaseView = (view) => {
|
363
|
+
if (!view.didRelease) {
|
364
|
+
view.release();
|
365
|
+
}
|
366
|
+
};
|
358
367
|
const setScenePath = (room, scenePath) => {
|
359
368
|
if (room && room.isWritable) {
|
360
369
|
if (room.state.sceneState.scenePath !== scenePath) {
|
@@ -893,9 +902,11 @@ class Storage {
|
|
893
902
|
}
|
894
903
|
}
|
895
904
|
class WhiteBoardView {
|
896
|
-
constructor(appContext, appProxy) {
|
905
|
+
constructor(view, appContext, appProxy, ensureSize) {
|
906
|
+
this.view = view;
|
897
907
|
this.appContext = appContext;
|
898
908
|
this.appProxy = appProxy;
|
909
|
+
this.ensureSize = ensureSize;
|
899
910
|
this.nextPage = async () => {
|
900
911
|
const nextIndex = this.pageState.index + 1;
|
901
912
|
return this.jumpPage(nextIndex);
|
@@ -939,13 +950,27 @@ class WhiteBoardView {
|
|
939
950
|
};
|
940
951
|
const pageState$ = new Val(appProxy.pageState);
|
941
952
|
this.pageState$ = pageState$;
|
942
|
-
appProxy.appEmitter.on("pageStateChange", (pageState) => {
|
953
|
+
this.appProxy.sideEffectManager.add(() => appProxy.appEmitter.on("pageStateChange", (pageState) => {
|
943
954
|
pageState$.setValue(pageState);
|
944
|
-
});
|
955
|
+
}));
|
956
|
+
const camera$ = new Val(pick(this.view.camera, ["centerX", "centerY"]));
|
957
|
+
this.camera$ = camera$;
|
958
|
+
this.appProxy.sideEffectManager.add(() => appProxy.camera$.subscribe((camera) => {
|
959
|
+
if (camera) {
|
960
|
+
camera$.setValue(pick(camera, ["centerX", "centerY"]));
|
961
|
+
}
|
962
|
+
}));
|
963
|
+
view.disableCameraTransform = true;
|
945
964
|
}
|
946
965
|
get pageState() {
|
947
966
|
return this.pageState$.value;
|
948
967
|
}
|
968
|
+
moveCamera(camera) {
|
969
|
+
this.appProxy.moveCamera(camera);
|
970
|
+
}
|
971
|
+
setRect(rect) {
|
972
|
+
this.appProxy.updateSize(rect.width, rect.height);
|
973
|
+
}
|
949
974
|
}
|
950
975
|
const setupWrapper = (root) => {
|
951
976
|
const playground = document.createElement("div");
|
@@ -978,9 +1003,8 @@ const serializeRoomMembers = (members) => {
|
|
978
1003
|
});
|
979
1004
|
};
|
980
1005
|
class AppContext {
|
981
|
-
constructor(manager,
|
1006
|
+
constructor(manager, appId, appProxy, appOptions) {
|
982
1007
|
this.manager = manager;
|
983
|
-
this.boxManager = boxManager;
|
984
1008
|
this.appId = appId;
|
985
1009
|
this.appProxy = appProxy;
|
986
1010
|
this.appOptions = appOptions;
|
@@ -1008,7 +1032,8 @@ class AppContext {
|
|
1008
1032
|
return appAttr == null ? void 0 : appAttr.options["scenes"];
|
1009
1033
|
}
|
1010
1034
|
};
|
1011
|
-
this.createWhiteBoardView = (
|
1035
|
+
this.createWhiteBoardView = (params) => {
|
1036
|
+
var _a;
|
1012
1037
|
if (this.whiteBoardView) {
|
1013
1038
|
return this.whiteBoardView;
|
1014
1039
|
}
|
@@ -1016,12 +1041,31 @@ class AppContext {
|
|
1016
1041
|
if (!view) {
|
1017
1042
|
view = this.appProxy.createAppDir();
|
1018
1043
|
}
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1044
|
+
if (params) {
|
1045
|
+
if (isBoolean(params.syncCamera)) {
|
1046
|
+
this.appProxy.syncCamera$.setValue(params.syncCamera);
|
1047
|
+
}
|
1048
|
+
}
|
1049
|
+
const viewWrapper = document.createElement("div");
|
1050
|
+
this._viewWrapper = viewWrapper;
|
1051
|
+
viewWrapper.className = "window-manager-view-wrapper";
|
1052
|
+
(_a = this.box.$content.parentElement) == null ? void 0 : _a.appendChild(viewWrapper);
|
1053
|
+
view.divElement = viewWrapper;
|
1054
|
+
this.appProxy.fireMemberStateChange();
|
1055
|
+
if (this.isAddApp) {
|
1056
|
+
this.ensurePageSize(params == null ? void 0 : params.size);
|
1057
|
+
}
|
1058
|
+
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, this.ensurePageSize);
|
1059
|
+
this.appProxy.sideEffectManager.add(() => {
|
1060
|
+
return () => {
|
1061
|
+
this.whiteBoardView = void 0;
|
1062
|
+
};
|
1063
|
+
});
|
1064
|
+
this.appProxy.whiteBoardViewCreated$.setValue(true);
|
1022
1065
|
return this.whiteBoardView;
|
1023
1066
|
};
|
1024
|
-
this.
|
1067
|
+
this.ensurePageSize = (size2) => {
|
1068
|
+
var _a;
|
1025
1069
|
if (!isNumber(size2))
|
1026
1070
|
return;
|
1027
1071
|
if (!this.appProxy.scenePath)
|
@@ -1032,14 +1076,11 @@ class AppContext {
|
|
1032
1076
|
throw Error(`[WindowManager]: size ${size2} muse be in range [1, ${MAX_PAGE_SIZE}]`);
|
1033
1077
|
}
|
1034
1078
|
const needInsert = size2 - this.appProxy.pageState.length;
|
1035
|
-
const
|
1036
|
-
|
1037
|
-
return { name: `${startPageNumber + index2 + 1}` };
|
1038
|
-
});
|
1039
|
-
putScenes(this.room, this.appProxy.scenePath, scenes);
|
1079
|
+
const scenes = new Array(needInsert).fill({});
|
1080
|
+
(_a = this.room) == null ? void 0 : _a.putScenes(this.appProxy.scenePath, scenes);
|
1040
1081
|
};
|
1041
1082
|
this.getInitScenePath = () => {
|
1042
|
-
return this.
|
1083
|
+
return this.appProxy.scenePath;
|
1043
1084
|
};
|
1044
1085
|
this.setAttributes = (attributes) => {
|
1045
1086
|
this.manager.safeSetAttributes({ [this.appId]: attributes });
|
@@ -1083,14 +1124,17 @@ class AppContext {
|
|
1083
1124
|
get displayer() {
|
1084
1125
|
return this.manager.displayer;
|
1085
1126
|
}
|
1127
|
+
get destroyed() {
|
1128
|
+
return this.appProxy.status === "destroyed";
|
1129
|
+
}
|
1086
1130
|
get view() {
|
1087
1131
|
return this.appProxy.view;
|
1088
1132
|
}
|
1089
1133
|
get isWritable() {
|
1090
|
-
return this.manager.canOperate;
|
1134
|
+
return this.manager.canOperate && !this.destroyed;
|
1091
1135
|
}
|
1092
1136
|
get box() {
|
1093
|
-
const box = this.
|
1137
|
+
const box = this.appProxy.box$.value;
|
1094
1138
|
if (box) {
|
1095
1139
|
return box;
|
1096
1140
|
} else {
|
@@ -1172,6 +1216,162 @@ class AppPageStateImpl {
|
|
1172
1216
|
(_a = this.sceneNode) == null ? void 0 : _a.dispose();
|
1173
1217
|
}
|
1174
1218
|
}
|
1219
|
+
class CameraSynchronizer {
|
1220
|
+
constructor(saveCamera) {
|
1221
|
+
this.saveCamera = saveCamera;
|
1222
|
+
this.setRect = debounce((rect) => {
|
1223
|
+
this.rect = rect;
|
1224
|
+
if (this.remoteCamera && this.remoteSize) {
|
1225
|
+
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1226
|
+
}
|
1227
|
+
}, 10);
|
1228
|
+
this.onRemoteUpdate = throttle((camera, size2) => {
|
1229
|
+
this.remoteCamera = camera;
|
1230
|
+
this.remoteSize = size2;
|
1231
|
+
if (this.remoteSize && this.rect) {
|
1232
|
+
let scale2;
|
1233
|
+
if (size2.width < size2.height) {
|
1234
|
+
scale2 = this.rect.width / size2.width;
|
1235
|
+
} else {
|
1236
|
+
scale2 = this.rect.height / size2.height;
|
1237
|
+
}
|
1238
|
+
const nextScale = camera.scale * scale2;
|
1239
|
+
const moveCamera = () => {
|
1240
|
+
var _a;
|
1241
|
+
const config = {
|
1242
|
+
scale: nextScale,
|
1243
|
+
animationMode: AnimationMode.Immediately
|
1244
|
+
};
|
1245
|
+
if (camera.centerX !== null) {
|
1246
|
+
config.centerX = camera.centerX;
|
1247
|
+
}
|
1248
|
+
if (camera.centerY !== null) {
|
1249
|
+
config.centerY = camera.centerY;
|
1250
|
+
}
|
1251
|
+
(_a = this.view) == null ? void 0 : _a.moveCamera(config);
|
1252
|
+
};
|
1253
|
+
moveCamera();
|
1254
|
+
delay(moveCamera, 50);
|
1255
|
+
}
|
1256
|
+
}, 10);
|
1257
|
+
}
|
1258
|
+
setView(view) {
|
1259
|
+
this.view = view;
|
1260
|
+
}
|
1261
|
+
onRemoteSizeUpdate(size2) {
|
1262
|
+
this.remoteSize = size2;
|
1263
|
+
const needMoveCamera = !isEqual(pick(this.rect, ["width", "height"]), pick(size2, ["width", "height"]));
|
1264
|
+
if (this.rect && this.remoteCamera && needMoveCamera) {
|
1265
|
+
const scale2 = this.rect.width / size2.width;
|
1266
|
+
const nextScale = this.remoteCamera.scale * scale2;
|
1267
|
+
const moveCamera = () => {
|
1268
|
+
var _a;
|
1269
|
+
(_a = this.view) == null ? void 0 : _a.moveCamera({
|
1270
|
+
scale: nextScale,
|
1271
|
+
animationMode: AnimationMode.Immediately
|
1272
|
+
});
|
1273
|
+
};
|
1274
|
+
moveCamera();
|
1275
|
+
delay(moveCamera, 50);
|
1276
|
+
}
|
1277
|
+
}
|
1278
|
+
onLocalCameraUpdate(camera) {
|
1279
|
+
this.saveCamera(camera);
|
1280
|
+
this.remoteCamera = camera;
|
1281
|
+
}
|
1282
|
+
}
|
1283
|
+
class ViewSync {
|
1284
|
+
constructor(context) {
|
1285
|
+
this.context = context;
|
1286
|
+
this.sem = new SideEffectManager();
|
1287
|
+
this.bindView = (view) => {
|
1288
|
+
if (!view)
|
1289
|
+
return;
|
1290
|
+
this.synchronizer.setView(view);
|
1291
|
+
this.sem.flush("view");
|
1292
|
+
this.sem.add(() => {
|
1293
|
+
view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1294
|
+
return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1295
|
+
}, "view");
|
1296
|
+
};
|
1297
|
+
this.onCameraUpdatedByDevice = (camera) => {
|
1298
|
+
if (!camera)
|
1299
|
+
return;
|
1300
|
+
this.synchronizer.onLocalCameraUpdate(__spreadProps(__spreadValues({}, camera), { id: this.context.uid }));
|
1301
|
+
const stage = this.context.stageRect$.value;
|
1302
|
+
if (stage) {
|
1303
|
+
const size2 = { width: stage.width, height: stage.height, id: this.context.uid };
|
1304
|
+
if (!isEqual(size2, this.context.size$.value)) {
|
1305
|
+
this.context.storeSize(size2);
|
1306
|
+
}
|
1307
|
+
}
|
1308
|
+
};
|
1309
|
+
this.synchronizer = new CameraSynchronizer((camera) => {
|
1310
|
+
this.context.camera$.setValue(camera, true);
|
1311
|
+
const notStoreCamera = this.context.viewMode$ && this.context.viewMode$.value === ViewMode.Freedom;
|
1312
|
+
if (notStoreCamera) {
|
1313
|
+
return;
|
1314
|
+
} else {
|
1315
|
+
this.context.storeCamera(camera);
|
1316
|
+
}
|
1317
|
+
});
|
1318
|
+
this.bindView(this.context.view$.value);
|
1319
|
+
this.sem.add(() => [
|
1320
|
+
this.context.view$.subscribe((view) => {
|
1321
|
+
const currentCamera = this.context.camera$.value;
|
1322
|
+
if (currentCamera && this.context.size$.value) {
|
1323
|
+
view == null ? void 0 : view.moveCamera({
|
1324
|
+
scale: 1,
|
1325
|
+
animationMode: AnimationMode.Immediately
|
1326
|
+
});
|
1327
|
+
this.synchronizer.onRemoteUpdate(currentCamera, this.context.size$.value);
|
1328
|
+
}
|
1329
|
+
this.bindView(view);
|
1330
|
+
}),
|
1331
|
+
this.context.camera$.subscribe((camera, skipUpdate) => {
|
1332
|
+
const size2 = this.context.size$.value;
|
1333
|
+
if (camera && size2 && !skipUpdate) {
|
1334
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1335
|
+
}
|
1336
|
+
}),
|
1337
|
+
this.context.size$.subscribe((size2) => {
|
1338
|
+
if (size2) {
|
1339
|
+
this.synchronizer.onRemoteSizeUpdate(size2);
|
1340
|
+
}
|
1341
|
+
}),
|
1342
|
+
this.context.stageRect$.reaction((rect) => {
|
1343
|
+
if (rect) {
|
1344
|
+
this.synchronizer.setRect(rect);
|
1345
|
+
}
|
1346
|
+
})
|
1347
|
+
]);
|
1348
|
+
const camera$size$ = combine([this.context.camera$, this.context.size$]);
|
1349
|
+
camera$size$.reaction(([camera, size2]) => {
|
1350
|
+
if (camera && size2) {
|
1351
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1352
|
+
camera$size$.destroy();
|
1353
|
+
}
|
1354
|
+
});
|
1355
|
+
}
|
1356
|
+
destroy() {
|
1357
|
+
this.sem.flushAll();
|
1358
|
+
}
|
1359
|
+
}
|
1360
|
+
const boxEmitter = new Emittery();
|
1361
|
+
const calculateNextIndex = (index2, pageState) => {
|
1362
|
+
let nextIndex = 0;
|
1363
|
+
const maxIndex = pageState.length - 1;
|
1364
|
+
if (index2 === pageState.index) {
|
1365
|
+
if (index2 === maxIndex) {
|
1366
|
+
nextIndex = index2 - 1;
|
1367
|
+
} else {
|
1368
|
+
nextIndex = pageState.index + 1;
|
1369
|
+
}
|
1370
|
+
} else {
|
1371
|
+
nextIndex = pageState.index;
|
1372
|
+
}
|
1373
|
+
return nextIndex;
|
1374
|
+
};
|
1175
1375
|
var Fields = /* @__PURE__ */ ((Fields2) => {
|
1176
1376
|
Fields2["Apps"] = "apps";
|
1177
1377
|
Fields2["Focus"] = "focus";
|
@@ -1185,6 +1385,8 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
|
|
1185
1385
|
Fields2["CursorState"] = "cursorState";
|
1186
1386
|
Fields2["FullPath"] = "fullPath";
|
1187
1387
|
Fields2["Registered"] = "registered";
|
1388
|
+
Fields2["Camera"] = "camera";
|
1389
|
+
Fields2["Size"] = "size";
|
1188
1390
|
return Fields2;
|
1189
1391
|
})(Fields || {});
|
1190
1392
|
class AttributesDelegate {
|
@@ -1249,6 +1451,9 @@ class AttributesDelegate {
|
|
1249
1451
|
this.context.safeUpdateAttributes(["apps", appId, "state", stateName], state);
|
1250
1452
|
}
|
1251
1453
|
}
|
1454
|
+
updateAppAttributes(appId, key, value) {
|
1455
|
+
this.context.safeUpdateAttributes(["apps", appId, key], value);
|
1456
|
+
}
|
1252
1457
|
cleanAppAttributes(id2) {
|
1253
1458
|
this.context.safeUpdateAttributes(["apps", id2], void 0);
|
1254
1459
|
this.context.safeSetAttributes({ [id2]: void 0 });
|
@@ -1345,21 +1550,6 @@ const log = (...args) => {
|
|
1345
1550
|
console.log(`[WindowManager]:`, ...args);
|
1346
1551
|
}
|
1347
1552
|
};
|
1348
|
-
const calculateNextIndex = (index2, pageState) => {
|
1349
|
-
let nextIndex = 0;
|
1350
|
-
const maxIndex = pageState.length - 1;
|
1351
|
-
if (index2 === pageState.index) {
|
1352
|
-
if (index2 === maxIndex) {
|
1353
|
-
nextIndex = index2 - 1;
|
1354
|
-
} else {
|
1355
|
-
nextIndex = pageState.index + 1;
|
1356
|
-
}
|
1357
|
-
} else {
|
1358
|
-
nextIndex = pageState.index;
|
1359
|
-
}
|
1360
|
-
return nextIndex;
|
1361
|
-
};
|
1362
|
-
const boxEmitter = new Emittery();
|
1363
1553
|
class AppProxy {
|
1364
1554
|
constructor(params, manager, appId, isAddApp) {
|
1365
1555
|
var _a;
|
@@ -1369,65 +1559,100 @@ class AppProxy {
|
|
1369
1559
|
this.appProxies = this.manager.appProxies;
|
1370
1560
|
this.viewManager = this.manager.viewManager;
|
1371
1561
|
this.store = this.manager.store;
|
1562
|
+
this.uid = this.manager.uid;
|
1372
1563
|
this.status = "normal";
|
1373
1564
|
this.sideEffectManager = new SideEffectManager();
|
1565
|
+
this.valManager = new ValManager();
|
1566
|
+
this.fullPath$ = this.valManager.attach(new Val(void 0));
|
1567
|
+
this.camera$ = this.valManager.attach(new Val(void 0));
|
1568
|
+
this.size$ = this.valManager.attach(new Val(void 0));
|
1569
|
+
this.box$ = this.valManager.attach(new Val(void 0));
|
1570
|
+
this.view$ = this.valManager.attach(new Val(void 0));
|
1571
|
+
this.syncCamera$ = this.valManager.attach(new Val(true));
|
1572
|
+
this.whiteBoardViewCreated$ = this.valManager.attach(new Val(false));
|
1573
|
+
this.fireMemberStateChange = () => {
|
1574
|
+
if (this.manager.room) {
|
1575
|
+
this.onMemberStateChange(this.manager.room.state.memberState);
|
1576
|
+
}
|
1577
|
+
};
|
1578
|
+
this.onMemberStateChange = (memberState) => {
|
1579
|
+
var _a2, _b;
|
1580
|
+
const needPointerEventsNone = memberState.currentApplianceName === "clicker";
|
1581
|
+
if (needPointerEventsNone) {
|
1582
|
+
if ((_a2 = this.appContext) == null ? void 0 : _a2._viewWrapper) {
|
1583
|
+
this.appContext._viewWrapper.style.pointerEvents = "none";
|
1584
|
+
}
|
1585
|
+
} else {
|
1586
|
+
if ((_b = this.appContext) == null ? void 0 : _b._viewWrapper) {
|
1587
|
+
this.appContext._viewWrapper.style.pointerEvents = "auto";
|
1588
|
+
}
|
1589
|
+
}
|
1590
|
+
};
|
1591
|
+
this.computedInitialRect = (boxRect) => {
|
1592
|
+
var _a2;
|
1593
|
+
const managerRect = (_a2 = this.manager.boxManager) == null ? void 0 : _a2.stageRect;
|
1594
|
+
if (managerRect) {
|
1595
|
+
const { width, height } = managerRect;
|
1596
|
+
const boxRatio = boxRect.height / boxRect.width;
|
1597
|
+
if (height < 480) {
|
1598
|
+
return {
|
1599
|
+
width: 480 / boxRatio,
|
1600
|
+
height: 480
|
1601
|
+
};
|
1602
|
+
} else {
|
1603
|
+
return {
|
1604
|
+
width: width * 0.65,
|
1605
|
+
height: height * 0.65
|
1606
|
+
};
|
1607
|
+
}
|
1608
|
+
}
|
1609
|
+
};
|
1374
1610
|
this.getAppInitState = (id2) => {
|
1375
1611
|
var _a2, _b;
|
1376
1612
|
const attrs = this.store.getAppState(id2);
|
1377
1613
|
if (!attrs)
|
1378
1614
|
return;
|
1379
|
-
const position = attrs == null ? void 0 : attrs[AppAttributes.Position];
|
1380
1615
|
const focus = this.store.focus;
|
1381
|
-
const size2 = attrs == null ? void 0 : attrs[AppAttributes.Size];
|
1382
|
-
const sceneIndex = attrs == null ? void 0 : attrs[AppAttributes.SceneIndex];
|
1383
1616
|
const maximized = (_a2 = this.attributes) == null ? void 0 : _a2["maximized"];
|
1384
1617
|
const minimized = (_b = this.attributes) == null ? void 0 : _b["minimized"];
|
1385
|
-
|
1386
|
-
|
1387
|
-
if (position) {
|
1388
|
-
payload = __spreadProps(__spreadValues({}, payload), { id: id2, x: position.x, y: position.y });
|
1389
|
-
}
|
1618
|
+
let payload = { maximized, minimized, id: id2 };
|
1619
|
+
const state = omitBy(attrs, isUndefined);
|
1390
1620
|
if (focus === id2) {
|
1391
1621
|
payload = __spreadProps(__spreadValues({}, payload), { focus: true });
|
1392
1622
|
}
|
1393
|
-
|
1394
|
-
payload = __spreadProps(__spreadValues({}, payload), { width: size2.width, height: size2.height });
|
1395
|
-
}
|
1396
|
-
if (sceneIndex) {
|
1397
|
-
payload = __spreadProps(__spreadValues({}, payload), { sceneIndex });
|
1398
|
-
}
|
1399
|
-
return payload;
|
1623
|
+
return Object.assign(payload, state);
|
1400
1624
|
};
|
1401
1625
|
this.appAttributesUpdateListener = (appId2) => {
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1626
|
+
this.sideEffectManager.add(() => [
|
1627
|
+
this.manager.refresher.add(appId2, () => {
|
1628
|
+
return autorun(() => {
|
1629
|
+
const attrs = this.manager.attributes[appId2];
|
1630
|
+
if (attrs) {
|
1631
|
+
this.appEmitter.emit("attributesUpdate", attrs);
|
1632
|
+
}
|
1633
|
+
});
|
1634
|
+
}),
|
1635
|
+
this.manager.refresher.add(this.stateKey, () => {
|
1636
|
+
return autorun(() => {
|
1637
|
+
var _a2, _b, _c;
|
1638
|
+
const appState = (_a2 = this.appAttributes) == null ? void 0 : _a2.state;
|
1639
|
+
if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((_b = this.box) == null ? void 0 : _b.zIndex)) {
|
1640
|
+
(_c = this.boxManager) == null ? void 0 : _c.setZIndex(appId2, appState.zIndex);
|
1641
|
+
}
|
1642
|
+
});
|
1643
|
+
}),
|
1644
|
+
this.manager.refresher.add(`${appId2}-fullPath`, () => {
|
1645
|
+
return autorun(() => {
|
1646
|
+
var _a2;
|
1647
|
+
const fullPath = (_a2 = this.appAttributes) == null ? void 0 : _a2.fullPath;
|
1648
|
+
this.setFocusScenePathHandler(fullPath);
|
1649
|
+
if (this.fullPath$.value !== fullPath) {
|
1650
|
+
this.notifyPageStateChange();
|
1651
|
+
this.fullPath$.setValue(fullPath);
|
1652
|
+
}
|
1653
|
+
});
|
1654
|
+
})
|
1655
|
+
]);
|
1431
1656
|
};
|
1432
1657
|
this.setFocusScenePathHandler = debounce((fullPath) => {
|
1433
1658
|
var _a2;
|
@@ -1440,6 +1665,58 @@ class AppProxy {
|
|
1440
1665
|
this.appEmitter.emit("pageStateChange", this.pageState);
|
1441
1666
|
}
|
1442
1667
|
}, 50);
|
1668
|
+
this.storeCamera = (camera) => {
|
1669
|
+
this.store.updateAppAttributes(this.id, Fields.Camera, camera);
|
1670
|
+
};
|
1671
|
+
this.storeSize = (size2) => {
|
1672
|
+
this.store.updateAppAttributes(this.id, Fields.Size, size2);
|
1673
|
+
};
|
1674
|
+
this.updateSize = (width, height) => {
|
1675
|
+
const iSize = {
|
1676
|
+
id: this.manager.uid,
|
1677
|
+
width,
|
1678
|
+
height
|
1679
|
+
};
|
1680
|
+
this.store.updateAppAttributes(this.id, Fields.Size, iSize);
|
1681
|
+
this.size$.setValue(iSize);
|
1682
|
+
};
|
1683
|
+
this.moveCamera = (camera) => {
|
1684
|
+
if (!this.camera$.value) {
|
1685
|
+
return;
|
1686
|
+
}
|
1687
|
+
const nextCamera = __spreadProps(__spreadValues(__spreadValues({}, this.camera$.value), camera), { id: this.uid });
|
1688
|
+
this.storeCamera(nextCamera);
|
1689
|
+
this.camera$.setValue(nextCamera);
|
1690
|
+
};
|
1691
|
+
this.addCameraReaction = () => {
|
1692
|
+
this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-camera`, () => reaction(() => {
|
1693
|
+
var _a2;
|
1694
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
|
1695
|
+
}, (camera) => {
|
1696
|
+
if (camera) {
|
1697
|
+
const rawCamera = toJS(camera);
|
1698
|
+
if (!isEqual(rawCamera, this.camera$.value)) {
|
1699
|
+
this.camera$.setValue(rawCamera);
|
1700
|
+
}
|
1701
|
+
}
|
1702
|
+
})), "camera");
|
1703
|
+
};
|
1704
|
+
this.addSizeReaction = () => {
|
1705
|
+
this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-size`, () => reaction(() => {
|
1706
|
+
var _a2;
|
1707
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
|
1708
|
+
}, (size2) => {
|
1709
|
+
if (size2) {
|
1710
|
+
const rawSize = toJS(size2);
|
1711
|
+
if (!isEqual(rawSize, this.size$.value)) {
|
1712
|
+
this.size$.setValue(rawSize);
|
1713
|
+
}
|
1714
|
+
}
|
1715
|
+
})), "size");
|
1716
|
+
};
|
1717
|
+
this.onFocus = () => {
|
1718
|
+
this.setScenePath();
|
1719
|
+
};
|
1443
1720
|
this.kind = params.kind;
|
1444
1721
|
this.id = appId;
|
1445
1722
|
this.appScenePath = `/${this.id}-app-dir`;
|
@@ -1461,14 +1738,71 @@ class AppProxy {
|
|
1461
1738
|
view: this.view,
|
1462
1739
|
notifyPageStateChange: this.notifyPageStateChange
|
1463
1740
|
});
|
1464
|
-
this.sideEffectManager.add(() =>
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1741
|
+
this.sideEffectManager.add(() => () => this._pageState.destroy());
|
1742
|
+
this.sideEffectManager.add(() => emitter.on("roomMembersChange", (members) => {
|
1743
|
+
this.appEmitter.emit("roomMembersChange", members);
|
1744
|
+
}));
|
1745
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1746
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1747
|
+
this.addCameraReaction();
|
1748
|
+
this.addSizeReaction();
|
1749
|
+
this.sideEffectManager.add(() => emitter.on("memberStateChange", this.onMemberStateChange));
|
1750
|
+
this.sideEffectManager.add(() => [
|
1751
|
+
this.syncCamera$.reaction((syncCamera) => {
|
1752
|
+
if (!syncCamera) {
|
1753
|
+
if (this.viewSync) {
|
1754
|
+
this.viewSync.destroy();
|
1755
|
+
this.viewSync = void 0;
|
1756
|
+
this.sideEffectManager.flush("camera");
|
1757
|
+
this.sideEffectManager.flush("size");
|
1758
|
+
}
|
1759
|
+
}
|
1760
|
+
}),
|
1761
|
+
this.whiteBoardViewCreated$.reaction((created) => {
|
1762
|
+
if (created && this.box) {
|
1763
|
+
if (!this.syncCamera$.value)
|
1764
|
+
return;
|
1765
|
+
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
1766
|
+
if (box && view) {
|
1767
|
+
if (!this.camera$.value) {
|
1768
|
+
this.storeCamera({
|
1769
|
+
centerX: null,
|
1770
|
+
centerY: null,
|
1771
|
+
scale: 1,
|
1772
|
+
id: this.uid
|
1773
|
+
});
|
1774
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1775
|
+
}
|
1776
|
+
if (!this.size$.value && box.contentStageRect) {
|
1777
|
+
const initialRect = this.computedInitialRect(box.contentStageRect);
|
1778
|
+
const width = (initialRect == null ? void 0 : initialRect.width) || box.contentStageRect.width;
|
1779
|
+
const height = (initialRect == null ? void 0 : initialRect.height) || box.contentStageRect.height;
|
1780
|
+
this.storeSize({
|
1781
|
+
id: this.uid,
|
1782
|
+
width,
|
1783
|
+
height
|
1784
|
+
});
|
1785
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1786
|
+
}
|
1787
|
+
this.viewSync = new ViewSync({
|
1788
|
+
uid: this.uid,
|
1789
|
+
view$: this.view$,
|
1790
|
+
camera$: this.camera$,
|
1791
|
+
size$: this.size$,
|
1792
|
+
stageRect$: box._contentStageRect$,
|
1793
|
+
storeCamera: this.storeCamera,
|
1794
|
+
storeSize: this.storeSize
|
1795
|
+
});
|
1796
|
+
this.sideEffectManager.add(() => () => {
|
1797
|
+
var _a2;
|
1798
|
+
return (_a2 = this.viewSync) == null ? void 0 : _a2.destroy();
|
1799
|
+
});
|
1800
|
+
this.whiteBoardViewCreated$.destroy();
|
1801
|
+
}
|
1802
|
+
});
|
1803
|
+
}
|
1804
|
+
})
|
1805
|
+
]);
|
1472
1806
|
}
|
1473
1807
|
createAppDir() {
|
1474
1808
|
const scenePath = this.scenePath || this.appScenePath;
|
@@ -1496,7 +1830,7 @@ class AppProxy {
|
|
1496
1830
|
}
|
1497
1831
|
}
|
1498
1832
|
get view() {
|
1499
|
-
return this.
|
1833
|
+
return this.view$.value;
|
1500
1834
|
}
|
1501
1835
|
get viewIndex() {
|
1502
1836
|
var _a;
|
@@ -1526,7 +1860,7 @@ class AppProxy {
|
|
1526
1860
|
return fullPath;
|
1527
1861
|
}
|
1528
1862
|
setFullPath(path) {
|
1529
|
-
this.
|
1863
|
+
this.store.updateAppAttributes(this.id, Fields.FullPath, path);
|
1530
1864
|
}
|
1531
1865
|
async baseInsertApp(skipUpdate = false) {
|
1532
1866
|
var _a;
|
@@ -1548,8 +1882,7 @@ class AppProxy {
|
|
1548
1882
|
};
|
1549
1883
|
}
|
1550
1884
|
get box() {
|
1551
|
-
|
1552
|
-
return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
|
1885
|
+
return this.box$.value;
|
1553
1886
|
}
|
1554
1887
|
async setupApp(appId, skipUpdate, app, options, appOptions) {
|
1555
1888
|
var _a;
|
@@ -1557,7 +1890,7 @@ class AppProxy {
|
|
1557
1890
|
if (!this.boxManager) {
|
1558
1891
|
throw new BoxManagerNotFoundError();
|
1559
1892
|
}
|
1560
|
-
const context = new AppContext(this.manager,
|
1893
|
+
const context = new AppContext(this.manager, appId, this, appOptions);
|
1561
1894
|
this.appContext = context;
|
1562
1895
|
try {
|
1563
1896
|
emitter.once(`${appId}${Events.WindowCreated}`).then(async () => {
|
@@ -1577,13 +1910,14 @@ class AppProxy {
|
|
1577
1910
|
this.fixMobileSize();
|
1578
1911
|
}, SETUP_APP_DELAY);
|
1579
1912
|
});
|
1580
|
-
(_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1913
|
+
const box = (_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1581
1914
|
appId,
|
1582
1915
|
app,
|
1583
1916
|
options,
|
1584
1917
|
canOperate: this.manager.canOperate,
|
1585
1918
|
smartPosition: this.isAddApp
|
1586
1919
|
});
|
1920
|
+
this.box$.setValue(box);
|
1587
1921
|
if (this.isAddApp && this.box) {
|
1588
1922
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
1589
1923
|
this.boxManager.focusBox({ appId }, false);
|
@@ -1597,12 +1931,14 @@ class AppProxy {
|
|
1597
1931
|
var _a, _b;
|
1598
1932
|
const box = (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
|
1599
1933
|
if (box) {
|
1600
|
-
(
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1934
|
+
if (!box.minimized) {
|
1935
|
+
(_b = this.boxManager) == null ? void 0 : _b.resizeBox({
|
1936
|
+
appId: this.id,
|
1937
|
+
width: box.intrinsicWidth + 1e-3,
|
1938
|
+
height: box.intrinsicHeight + 1e-3,
|
1939
|
+
skipUpdate: true
|
1940
|
+
});
|
1941
|
+
}
|
1606
1942
|
}
|
1607
1943
|
}
|
1608
1944
|
async onSeek(time2) {
|
@@ -1712,6 +2048,7 @@ class AppProxy {
|
|
1712
2048
|
}
|
1713
2049
|
createView() {
|
1714
2050
|
const view = this.viewManager.createView(this.id);
|
2051
|
+
this.view$.setValue(view);
|
1715
2052
|
this.setViewFocusScenePath();
|
1716
2053
|
return view;
|
1717
2054
|
}
|
@@ -1747,11 +2084,12 @@ class AppProxy {
|
|
1747
2084
|
const fullPath = this._pageState.getFullPath(index2);
|
1748
2085
|
if (fullPath) {
|
1749
2086
|
this.setFullPath(fullPath);
|
2087
|
+
setScenePath(this.manager.room, fullPath);
|
1750
2088
|
}
|
1751
2089
|
}
|
1752
2090
|
}
|
1753
2091
|
async destroy(needCloseBox, cleanAttrs, skipUpdate, error) {
|
1754
|
-
var _a
|
2092
|
+
var _a;
|
1755
2093
|
if (this.status === "destroyed")
|
1756
2094
|
return;
|
1757
2095
|
this.status = "destroyed";
|
@@ -1762,6 +2100,7 @@ class AppProxy {
|
|
1762
2100
|
console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
|
1763
2101
|
}
|
1764
2102
|
this.appEmitter.clearListeners();
|
2103
|
+
this.sideEffectManager.flushAll();
|
1765
2104
|
emitter.emit(`destroy-${this.id}`, { error });
|
1766
2105
|
if (needCloseBox) {
|
1767
2106
|
(_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
|
@@ -1775,11 +2114,7 @@ class AppProxy {
|
|
1775
2114
|
this.appProxies.delete(this.id);
|
1776
2115
|
this.viewManager.destroyView(this.id);
|
1777
2116
|
this.manager.appStatus.delete(this.id);
|
1778
|
-
|
1779
|
-
(_c = this.manager.refresher) == null ? void 0 : _c.remove(this.stateKey);
|
1780
|
-
(_d = this.manager.refresher) == null ? void 0 : _d.remove(`${this.id}-fullPath`);
|
1781
|
-
this._prevFullPath = void 0;
|
1782
|
-
this.sideEffectManager.flushAll();
|
2117
|
+
this.valManager.destroy();
|
1783
2118
|
}
|
1784
2119
|
close() {
|
1785
2120
|
return this.destroy(true, true, false);
|
@@ -1835,102 +2170,84 @@ const setDefaultCameraBound = (view) => {
|
|
1835
2170
|
minContentMode: () => 0.1
|
1836
2171
|
});
|
1837
2172
|
};
|
1838
|
-
class CameraSynchronizer {
|
1839
|
-
constructor(saveCamera) {
|
1840
|
-
this.saveCamera = saveCamera;
|
1841
|
-
this.onRemoteUpdate = throttle((camera, size2) => {
|
1842
|
-
this.remoteCamera = camera;
|
1843
|
-
this.remoteSize = size2;
|
1844
|
-
if (this.remoteSize && this.rect) {
|
1845
|
-
let scale2;
|
1846
|
-
if (size2.width < size2.height) {
|
1847
|
-
scale2 = this.rect.width / size2.width;
|
1848
|
-
} else {
|
1849
|
-
scale2 = this.rect.height / size2.height;
|
1850
|
-
}
|
1851
|
-
const nextScale = camera.scale * scale2;
|
1852
|
-
const moveCamera = () => {
|
1853
|
-
var _a;
|
1854
|
-
return (_a = this.view) == null ? void 0 : _a.moveCamera({
|
1855
|
-
centerX: camera.centerX,
|
1856
|
-
centerY: camera.centerY,
|
1857
|
-
scale: nextScale,
|
1858
|
-
animationMode: AnimationMode.Immediately
|
1859
|
-
});
|
1860
|
-
};
|
1861
|
-
delay(moveCamera, 10);
|
1862
|
-
}
|
1863
|
-
}, 50);
|
1864
|
-
}
|
1865
|
-
setRect(rect) {
|
1866
|
-
this.rect = rect;
|
1867
|
-
if (this.remoteCamera && this.remoteSize) {
|
1868
|
-
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1869
|
-
}
|
1870
|
-
}
|
1871
|
-
setView(view) {
|
1872
|
-
this.view = view;
|
1873
|
-
}
|
1874
|
-
onLocalCameraUpdate(camera) {
|
1875
|
-
this.saveCamera(camera);
|
1876
|
-
}
|
1877
|
-
onLocalSizeUpdate(size2) {
|
1878
|
-
if (this.rect && this.view) {
|
1879
|
-
const scale2 = this.rect.width / size2.width;
|
1880
|
-
const nextScale = this.view.camera.scale * scale2;
|
1881
|
-
this.view.moveCamera({
|
1882
|
-
scale: nextScale,
|
1883
|
-
animationMode: AnimationMode.Immediately
|
1884
|
-
});
|
1885
|
-
}
|
1886
|
-
}
|
1887
|
-
}
|
1888
2173
|
class MainViewProxy {
|
1889
2174
|
constructor(manager) {
|
1890
|
-
var _a;
|
1891
2175
|
this.manager = manager;
|
1892
2176
|
this.started = false;
|
1893
2177
|
this.mainViewIsAddListener = false;
|
1894
2178
|
this.store = this.manager.store;
|
1895
2179
|
this.sideEffectManager = new SideEffectManager();
|
1896
|
-
this.
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
2180
|
+
this.camera$ = new Val(void 0);
|
2181
|
+
this.size$ = new Val(void 0);
|
2182
|
+
this.view$ = new Val(void 0);
|
2183
|
+
this.createViewSync = () => {
|
2184
|
+
var _a;
|
2185
|
+
if (this.manager.boxManager && !this.viewSync) {
|
2186
|
+
this.viewSync = new ViewSync({
|
2187
|
+
uid: this.manager.uid,
|
2188
|
+
view$: this.view$,
|
2189
|
+
camera$: this.camera$,
|
2190
|
+
size$: this.size$,
|
2191
|
+
stageRect$: (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect$,
|
2192
|
+
viewMode$: this.manager.windowManger.viewMode$,
|
2193
|
+
storeCamera: this.storeCamera,
|
2194
|
+
storeSize: this.storeSize
|
1902
2195
|
});
|
1903
|
-
}
|
2196
|
+
}
|
2197
|
+
};
|
2198
|
+
this.startListenWritableChange = () => {
|
2199
|
+
this.sideEffectManager.add(() => emitter.on("writableChange", (isWritable) => {
|
2200
|
+
if (isWritable) {
|
2201
|
+
this.ensureCameraAndSize();
|
2202
|
+
}
|
2203
|
+
}));
|
1904
2204
|
};
|
1905
2205
|
this.addCameraReaction = () => {
|
1906
|
-
|
1907
|
-
|
2206
|
+
this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
|
2207
|
+
this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
|
2208
|
+
};
|
2209
|
+
this.storeCurrentCamera = () => {
|
2210
|
+
const iCamera = this.view.camera;
|
2211
|
+
this.storeCamera(__spreadValues({
|
2212
|
+
id: this.manager.uid
|
2213
|
+
}, iCamera));
|
2214
|
+
};
|
2215
|
+
this.storeCurrentSize = () => {
|
2216
|
+
var _a;
|
2217
|
+
const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2218
|
+
if (rect) {
|
2219
|
+
this.storeSize({
|
2220
|
+
id: this.manager.uid,
|
2221
|
+
width: rect.width,
|
2222
|
+
height: rect.height
|
2223
|
+
});
|
2224
|
+
}
|
2225
|
+
};
|
2226
|
+
this.storeCamera = (camera) => {
|
2227
|
+
this.store.setMainViewCamera(camera);
|
2228
|
+
};
|
2229
|
+
this.storeSize = (size2) => {
|
2230
|
+
this.store.setMainViewSize(size2);
|
1908
2231
|
};
|
1909
2232
|
this.cameraReaction = () => {
|
1910
2233
|
return reaction(() => this.mainViewCamera, (camera) => {
|
1911
|
-
if (camera
|
1912
|
-
|
2234
|
+
if (camera) {
|
2235
|
+
const rawCamera = toJS(camera);
|
2236
|
+
if (!isEqual(rawCamera, this.camera$.value)) {
|
2237
|
+
this.camera$.setValue(rawCamera);
|
2238
|
+
}
|
1913
2239
|
}
|
1914
2240
|
}, { fireImmediately: true });
|
1915
2241
|
};
|
1916
|
-
this.
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
this.setCameraAndSize();
|
1926
|
-
}
|
1927
|
-
};
|
1928
|
-
this.onCameraUpdatedByDevice = (camera) => {
|
1929
|
-
this.synchronizer.onLocalCameraUpdate(camera);
|
1930
|
-
const size2 = this.getStageSize();
|
1931
|
-
if (size2 && !isEqual(size2, this.mainViewSize)) {
|
1932
|
-
this.setMainViewSize(size2);
|
1933
|
-
}
|
2242
|
+
this.sizeReaction = () => {
|
2243
|
+
return reaction(() => this.mainViewSize, (size2) => {
|
2244
|
+
if (size2) {
|
2245
|
+
const rawSize = toJS(size2);
|
2246
|
+
if (!isEqual(rawSize, this.size$.value)) {
|
2247
|
+
this.size$.setValue(rawSize);
|
2248
|
+
}
|
2249
|
+
}
|
2250
|
+
}, { fireImmediately: true });
|
1934
2251
|
};
|
1935
2252
|
this.mainViewClickListener = () => {
|
1936
2253
|
this.mainViewClickHandler();
|
@@ -1941,40 +2258,43 @@ class MainViewProxy {
|
|
1941
2258
|
this.onCameraOrSizeUpdated = () => {
|
1942
2259
|
callbacks$1.emit("cameraStateChange", this.cameraState);
|
1943
2260
|
};
|
1944
|
-
this.synchronizer = new CameraSynchronizer((camera) => this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid })));
|
1945
2261
|
this.mainView = this.createMainView();
|
1946
|
-
this.moveCameraSizeByAttributes();
|
1947
2262
|
emitter.once("mainViewMounted").then(() => {
|
1948
2263
|
this.addMainViewListener();
|
1949
2264
|
this.start();
|
1950
2265
|
this.ensureCameraAndSize();
|
1951
2266
|
this.startListenWritableChange();
|
1952
2267
|
});
|
1953
|
-
this.sideEffectManager.add(() =>
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
2268
|
+
this.sideEffectManager.add(() => [
|
2269
|
+
emitter.on("startReconnect", () => {
|
2270
|
+
releaseView(this.mainView);
|
2271
|
+
})
|
2272
|
+
]);
|
2273
|
+
this.createViewSync();
|
2274
|
+
this.sideEffectManager.add(() => emitter.on("focusedChange", ({ focused }) => {
|
2275
|
+
if (focused === void 0) {
|
2276
|
+
const scenePath = this.store.getMainViewScenePath();
|
2277
|
+
if (scenePath) {
|
2278
|
+
setScenePath(this.manager.room, scenePath);
|
1960
2279
|
}
|
1961
|
-
}
|
1962
|
-
});
|
1963
|
-
const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
1964
|
-
if (rect) {
|
1965
|
-
this.synchronizer.setRect(rect);
|
1966
|
-
}
|
1967
|
-
this.sideEffectManager.add(() => {
|
1968
|
-
return emitter.on("playgroundSizeChange", (rect2) => {
|
1969
|
-
this.synchronizer.setRect(rect2);
|
1970
|
-
this.synchronizer.onLocalSizeUpdate(rect2);
|
1971
|
-
});
|
1972
|
-
});
|
2280
|
+
}
|
2281
|
+
}));
|
1973
2282
|
}
|
1974
2283
|
ensureCameraAndSize() {
|
2284
|
+
var _a;
|
1975
2285
|
if (!this.mainViewCamera || !this.mainViewSize) {
|
1976
2286
|
this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
|
1977
|
-
this.
|
2287
|
+
this.storeCamera(__spreadValues({
|
2288
|
+
id: this.manager.uid
|
2289
|
+
}, this.view.camera));
|
2290
|
+
const stageRect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2291
|
+
if (stageRect && !this.mainViewSize) {
|
2292
|
+
this.storeSize({
|
2293
|
+
id: this.manager.uid,
|
2294
|
+
width: stageRect.width,
|
2295
|
+
height: stageRect.height
|
2296
|
+
});
|
2297
|
+
}
|
1978
2298
|
}
|
1979
2299
|
}
|
1980
2300
|
get mainViewCamera() {
|
@@ -1986,25 +2306,13 @@ class MainViewProxy {
|
|
1986
2306
|
get didRelease() {
|
1987
2307
|
return get(this.view, ["didRelease"]);
|
1988
2308
|
}
|
1989
|
-
moveCameraSizeByAttributes() {
|
1990
|
-
this.synchronizer.onRemoteUpdate(this.mainViewCamera, this.mainViewSize);
|
1991
|
-
}
|
1992
2309
|
start() {
|
1993
2310
|
if (this.started)
|
1994
2311
|
return;
|
1995
|
-
this.sizeChangeHandler(this.mainViewSize);
|
1996
2312
|
this.addCameraListener();
|
1997
2313
|
this.addCameraReaction();
|
1998
2314
|
this.started = true;
|
1999
2315
|
}
|
2000
|
-
setCameraAndSize() {
|
2001
|
-
const stageSize = this.getStageSize();
|
2002
|
-
if (stageSize) {
|
2003
|
-
const camera = __spreadProps(__spreadValues({}, this.mainView.camera), { id: this.manager.uid });
|
2004
|
-
const size2 = __spreadProps(__spreadValues({}, stageSize), { id: this.manager.uid });
|
2005
|
-
this.store.setMainViewCameraAndSize(camera, size2);
|
2006
|
-
}
|
2007
|
-
}
|
2008
2316
|
get view() {
|
2009
2317
|
return this.mainView;
|
2010
2318
|
}
|
@@ -2017,7 +2325,7 @@ class MainViewProxy {
|
|
2017
2325
|
if (mainViewScenePath) {
|
2018
2326
|
setViewFocusScenePath(mainView, mainViewScenePath);
|
2019
2327
|
}
|
2020
|
-
this.
|
2328
|
+
this.view$.setValue(mainView);
|
2021
2329
|
return mainView;
|
2022
2330
|
}
|
2023
2331
|
onReconnect() {
|
@@ -2037,9 +2345,7 @@ class MainViewProxy {
|
|
2037
2345
|
const divElement = this.mainView.divElement;
|
2038
2346
|
const disableCameraTransform = this.mainView.disableCameraTransform;
|
2039
2347
|
this.stop();
|
2040
|
-
|
2041
|
-
this.mainView.release();
|
2042
|
-
}
|
2348
|
+
releaseView(this.mainView);
|
2043
2349
|
this.removeMainViewListener();
|
2044
2350
|
this.mainView = this.createMainView();
|
2045
2351
|
this.mainView.disableCameraTransform = disableCameraTransform;
|
@@ -2047,13 +2353,6 @@ class MainViewProxy {
|
|
2047
2353
|
this.addMainViewListener();
|
2048
2354
|
this.start();
|
2049
2355
|
}
|
2050
|
-
getStageSize() {
|
2051
|
-
var _a;
|
2052
|
-
const stage = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2053
|
-
if (stage) {
|
2054
|
-
return { width: stage.width, height: stage.height };
|
2055
|
-
}
|
2056
|
-
}
|
2057
2356
|
addMainViewListener() {
|
2058
2357
|
if (this.mainViewIsAddListener)
|
2059
2358
|
return;
|
@@ -2078,23 +2377,23 @@ class MainViewProxy {
|
|
2078
2377
|
(_a = this.manager.boxManager) == null ? void 0 : _a.blurAllBox();
|
2079
2378
|
}
|
2080
2379
|
addCameraListener() {
|
2081
|
-
this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
2082
2380
|
this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
|
2083
2381
|
this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
|
2084
2382
|
}
|
2085
2383
|
removeCameraListener() {
|
2086
|
-
this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
2087
2384
|
this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
|
2088
2385
|
this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
|
2089
2386
|
}
|
2090
2387
|
stop() {
|
2091
|
-
var _a, _b;
|
2092
2388
|
this.removeCameraListener();
|
2093
|
-
|
2094
|
-
|
2389
|
+
this.manager.refresher.remove(Fields.MainViewCamera);
|
2390
|
+
this.manager.refresher.remove(Fields.MainViewSize);
|
2095
2391
|
this.started = false;
|
2096
2392
|
}
|
2097
2393
|
destroy() {
|
2394
|
+
this.camera$.destroy();
|
2395
|
+
this.size$.destroy();
|
2396
|
+
this.view$.destroy();
|
2098
2397
|
this.removeMainViewListener();
|
2099
2398
|
this.stop();
|
2100
2399
|
this.sideEffectManager.flushAll();
|
@@ -2169,6 +2468,8 @@ class AppManager {
|
|
2169
2468
|
this.mainViewScenesLength = 0;
|
2170
2469
|
this.callbacksNode = null;
|
2171
2470
|
this.appCreateQueue = new AppCreateQueue();
|
2471
|
+
this.sceneIndex$ = new Val(void 0);
|
2472
|
+
this.focused$ = new Val(void 0);
|
2172
2473
|
this.sideEffectManager = new SideEffectManager();
|
2173
2474
|
this.sceneState = null;
|
2174
2475
|
this.rootDirRemoving = false;
|
@@ -2188,7 +2489,7 @@ class AppManager {
|
|
2188
2489
|
sceneName = (_b = this.callbacksNode) == null ? void 0 : _b.scenes[nextIndex];
|
2189
2490
|
}
|
2190
2491
|
if (sceneName) {
|
2191
|
-
this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
|
2492
|
+
await this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
|
2192
2493
|
}
|
2193
2494
|
await this.setMainViewSceneIndex(nextIndex);
|
2194
2495
|
} else {
|
@@ -2336,26 +2637,27 @@ class AppManager {
|
|
2336
2637
|
});
|
2337
2638
|
};
|
2338
2639
|
this.onMainViewIndexChange = (index2) => {
|
2339
|
-
if (index2 !== void 0 && this.
|
2640
|
+
if (index2 !== void 0 && this.sceneIndex$.value !== index2) {
|
2340
2641
|
callbacks$1.emit("mainViewSceneIndexChange", index2);
|
2341
2642
|
emitter.emit("changePageState");
|
2342
2643
|
if (this.callbacksNode) {
|
2343
2644
|
this.updateSceneState(this.callbacksNode);
|
2344
2645
|
}
|
2345
|
-
this.
|
2646
|
+
this.sceneIndex$.setValue(index2);
|
2346
2647
|
}
|
2347
2648
|
};
|
2348
2649
|
this.onFocusChange = (focused) => {
|
2349
2650
|
var _a;
|
2350
|
-
if (this.
|
2651
|
+
if (this.focused$.value !== focused) {
|
2351
2652
|
callbacks$1.emit("focusedChange", focused);
|
2352
|
-
emitter.emit("focusedChange", { focused, prev: this.
|
2353
|
-
this.
|
2653
|
+
emitter.emit("focusedChange", { focused, prev: this.focused$.value });
|
2654
|
+
this.focused$.setValue(focused);
|
2354
2655
|
if (focused !== void 0) {
|
2355
2656
|
(_a = this.boxManager) == null ? void 0 : _a.focusBox({ appId: focused });
|
2356
2657
|
setTimeout(() => {
|
2357
2658
|
const appProxy = this.appProxies.get(focused);
|
2358
2659
|
if (appProxy) {
|
2660
|
+
appProxy.onFocus();
|
2359
2661
|
appRegister.notifyApp(appProxy.kind, "focus", { appId: focused });
|
2360
2662
|
}
|
2361
2663
|
}, 0);
|
@@ -2419,11 +2721,14 @@ class AppManager {
|
|
2419
2721
|
emitter.emit("roomMembersChange", this.members);
|
2420
2722
|
}
|
2421
2723
|
emitter.emit("observerIdChange", this.displayer.observerId);
|
2724
|
+
if (state.memberState) {
|
2725
|
+
emitter.emit("memberStateChange", toJS(state.memberState));
|
2726
|
+
}
|
2422
2727
|
};
|
2423
2728
|
this.displayerWritableListener = (isReadonly) => {
|
2424
2729
|
var _a, _b;
|
2425
2730
|
const isWritable = !isReadonly;
|
2426
|
-
const isManualWritable = this.windowManger.readonly === void 0 || this.windowManger.readonly
|
2731
|
+
const isManualWritable = this.windowManger.readonly === void 0 || !this.windowManger.readonly;
|
2427
2732
|
if (this.windowManger.readonly === void 0) {
|
2428
2733
|
(_a = this.boxManager) == null ? void 0 : _a.setReadonly(isReadonly);
|
2429
2734
|
} else {
|
@@ -2432,13 +2737,10 @@ class AppManager {
|
|
2432
2737
|
this.appProxies.forEach((appProxy) => {
|
2433
2738
|
appProxy.emitAppIsWritableChange();
|
2434
2739
|
});
|
2435
|
-
if (isWritable
|
2436
|
-
this.mainView.disableCameraTransform = false;
|
2740
|
+
if (isWritable) {
|
2437
2741
|
if (this.room && this.room.disableSerialization === true) {
|
2438
2742
|
this.room.disableSerialization = false;
|
2439
2743
|
}
|
2440
|
-
} else {
|
2441
|
-
this.mainView.disableCameraTransform = true;
|
2442
2744
|
}
|
2443
2745
|
emitter.emit("writableChange", isWritable);
|
2444
2746
|
};
|
@@ -2496,7 +2798,7 @@ class AppManager {
|
|
2496
2798
|
});
|
2497
2799
|
}
|
2498
2800
|
async onRootDirRemoved(needClose = true) {
|
2499
|
-
this.setMainViewScenePath(INIT_DIR);
|
2801
|
+
await this.setMainViewScenePath(INIT_DIR);
|
2500
2802
|
this.createRootDirScenesCallback();
|
2501
2803
|
for (const [id2, appProxy] of this.appProxies.entries()) {
|
2502
2804
|
if (appProxy.view) {
|
@@ -2504,7 +2806,7 @@ class AppManager {
|
|
2504
2806
|
}
|
2505
2807
|
}
|
2506
2808
|
this.mainViewProxy.rebind();
|
2507
|
-
emitter.emit("rootDirRemoved");
|
2809
|
+
await emitter.emit("rootDirRemoved");
|
2508
2810
|
this.updateRootDirRemoving(false);
|
2509
2811
|
}
|
2510
2812
|
get eventName() {
|
@@ -2543,7 +2845,7 @@ class AppManager {
|
|
2543
2845
|
}
|
2544
2846
|
}
|
2545
2847
|
async onCreated() {
|
2546
|
-
var _a
|
2848
|
+
var _a;
|
2547
2849
|
await this.attributesUpdateCallback(this.attributes.apps);
|
2548
2850
|
emitter.emit("updateManagerRect");
|
2549
2851
|
boxEmitter.on("move", this.onBoxMove);
|
@@ -2553,32 +2855,32 @@ class AppManager {
|
|
2553
2855
|
boxEmitter.on("boxStateChange", this.onBoxStateChange);
|
2554
2856
|
this.addAppsChangeListener();
|
2555
2857
|
this.addAppCloseListener();
|
2556
|
-
|
2858
|
+
this.refresher.add("maximized", () => {
|
2557
2859
|
return autorun(() => {
|
2558
2860
|
var _a2;
|
2559
2861
|
const maximized = this.attributes.maximized;
|
2560
2862
|
(_a2 = this.boxManager) == null ? void 0 : _a2.setMaximized(Boolean(maximized));
|
2561
2863
|
});
|
2562
2864
|
});
|
2563
|
-
|
2865
|
+
this.refresher.add("minimized", () => {
|
2564
2866
|
return autorun(() => {
|
2565
2867
|
const minimized = this.attributes.minimized;
|
2566
2868
|
this.onMinimized(minimized);
|
2567
2869
|
});
|
2568
2870
|
});
|
2569
|
-
|
2871
|
+
this.refresher.add("mainViewIndex", () => {
|
2570
2872
|
return autorun(() => {
|
2571
2873
|
const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
|
2572
2874
|
this.onMainViewIndexChange(mainSceneIndex);
|
2573
2875
|
});
|
2574
2876
|
});
|
2575
|
-
|
2877
|
+
this.refresher.add("focusedChange", () => {
|
2576
2878
|
return autorun(() => {
|
2577
2879
|
const focused = get(this.attributes, "focus");
|
2578
2880
|
this.onFocusChange(focused);
|
2579
2881
|
});
|
2580
2882
|
});
|
2581
|
-
|
2883
|
+
this.refresher.add("registeredChange", () => {
|
2582
2884
|
return autorun(() => {
|
2583
2885
|
const registered = get(this.attributes, Fields.Registered);
|
2584
2886
|
this.onRegisteredChange(registered);
|
@@ -2590,9 +2892,9 @@ class AppManager {
|
|
2590
2892
|
return;
|
2591
2893
|
this.resetScenePath(mainScenePath);
|
2592
2894
|
}
|
2593
|
-
this.displayerWritableListener(!((
|
2895
|
+
this.displayerWritableListener(!((_a = this.room) == null ? void 0 : _a.isWritable));
|
2594
2896
|
this.displayer.callbacks.on("onEnableWriteNowChanged", this.displayerWritableListener);
|
2595
|
-
this.
|
2897
|
+
this.focused$.setValue(this.attributes.focus);
|
2596
2898
|
this.sideEffectManager.add(() => {
|
2597
2899
|
const redoUndo = new RedoUndo({
|
2598
2900
|
mainView: () => this.mainViewProxy.view,
|
@@ -2643,6 +2945,7 @@ class AppManager {
|
|
2643
2945
|
}
|
2644
2946
|
setBoxManager(boxManager) {
|
2645
2947
|
this.boxManager = boxManager;
|
2948
|
+
this.mainViewProxy.createViewSync();
|
2646
2949
|
}
|
2647
2950
|
resetMaximized() {
|
2648
2951
|
var _a;
|
@@ -2655,7 +2958,9 @@ class AppManager {
|
|
2655
2958
|
bindMainView(divElement, disableCameraTransform) {
|
2656
2959
|
const mainView = this.mainViewProxy.view;
|
2657
2960
|
mainView.disableCameraTransform = disableCameraTransform;
|
2658
|
-
|
2961
|
+
wait(30).then(() => {
|
2962
|
+
mainView.divElement = divElement;
|
2963
|
+
});
|
2659
2964
|
if (!mainView.focusScenePath) {
|
2660
2965
|
this.setMainViewFocusPath();
|
2661
2966
|
}
|
@@ -2841,8 +3146,8 @@ class AppManager {
|
|
2841
3146
|
}
|
2842
3147
|
callbacks$1.clearListeners();
|
2843
3148
|
this.sideEffectManager.flushAll();
|
2844
|
-
this.
|
2845
|
-
this.
|
3149
|
+
this.sceneIndex$.destroy();
|
3150
|
+
this.focused$.destroy();
|
2846
3151
|
}
|
2847
3152
|
}
|
2848
3153
|
/*! *****************************************************************************
|
@@ -3687,16 +3992,16 @@ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
|
|
3687
3992
|
}
|
3688
3993
|
return true;
|
3689
3994
|
};
|
3690
|
-
var e$2 = Object.defineProperty, t$3 = Object.defineProperties, i$1 = Object.getOwnPropertyDescriptors, s$2 = Object.getOwnPropertySymbols, a$1 = Object.prototype.hasOwnProperty,
|
3995
|
+
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) => {
|
3691
3996
|
for (var i2 in t2 || (t2 = {}))
|
3692
|
-
a$1.call(t2, i2) &&
|
3997
|
+
a$1.call(t2, i2) && o$2(e2, i2, t2[i2]);
|
3693
3998
|
if (s$2)
|
3694
3999
|
for (var i2 of s$2(t2))
|
3695
|
-
|
4000
|
+
n$3.call(t2, i2) && o$2(e2, i2, t2[i2]);
|
3696
4001
|
return e2;
|
3697
4002
|
};
|
3698
|
-
var v$3, w$2, C$3, y$2, E$3, z$2, B$2,
|
3699
|
-
(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", (
|
4003
|
+
var v$3, w$2, C$3, y$2, E$3, z$2, _, B$2, N$3, S$3;
|
4004
|
+
(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";
|
3700
4005
|
function I$3(e2, t2, i2) {
|
3701
4006
|
return Math.min(Math.max(e2, t2), i2);
|
3702
4007
|
}
|
@@ -3717,7 +4022,7 @@ function V$3(e2) {
|
|
3717
4022
|
return !e2;
|
3718
4023
|
}
|
3719
4024
|
class H$3 {
|
3720
|
-
constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart:
|
4025
|
+
constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart: n2, namespace: o2 = "telebox" }) {
|
3721
4026
|
this.sideEffect = new SideEffectManager(), this.lastTitleBarClick = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarClick = (e3) => {
|
3722
4027
|
var t3;
|
3723
4028
|
if (this.readonly$.value)
|
@@ -3728,7 +4033,7 @@ class H$3 {
|
|
3728
4033
|
return;
|
3729
4034
|
k$1(e3);
|
3730
4035
|
const i3 = Date.now();
|
3731
|
-
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:
|
4036
|
+
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;
|
3732
4037
|
}, this.lastTitleBarTouch = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarTouch = (e3) => {
|
3733
4038
|
var t3;
|
3734
4039
|
if (this.readonly$.value)
|
@@ -3737,8 +4042,8 @@ class H$3 {
|
|
3737
4042
|
return;
|
3738
4043
|
k$1(e3);
|
3739
4044
|
const i3 = Date.now(), { clientX: s3 = this.lastTitleBarTouch.clientX + 100, clientY: a3 = this.lastTitleBarTouch.clientY + 100 } = e3.touches[0] || {};
|
3740
|
-
i3 - this.lastTitleBarTouch.timestamp <= 500 ? Math.abs(s3 - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(a3 - this.lastTitleBarTouch.clientY) <= 10 && this.onEvent && this.onEvent({ type:
|
3741
|
-
}, this.readonly$ = e2, this.state$ = t2, this.title$ = i2, this.onEvent = a2, this.onDragStart =
|
4045
|
+
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;
|
4046
|
+
}, 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();
|
3742
4047
|
}
|
3743
4048
|
render() {
|
3744
4049
|
if (!this.$titleBar) {
|
@@ -3814,13 +4119,13 @@ class A$2 {
|
|
3814
4119
|
i2.className = this.wrapClassName("box-stage-mask");
|
3815
4120
|
const s2 = document.createElement("div");
|
3816
4121
|
s2.className = this.wrapClassName("box-stage-frame");
|
3817
|
-
const [a2, o2, r2
|
4122
|
+
const [a2, n2, o2, r2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
|
3818
4123
|
const i3 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
3819
4124
|
i3.setAttribute("viewBox", "0 0 8 8"), i3.setAttribute("class", `${this.wrapClassName("box-stage-frame-corner")} is-${t3}`);
|
3820
4125
|
const s3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
3821
4126
|
return s3.setAttribute("d", e3), s3.setAttribute("fill", "#3381FF"), i3.appendChild(s3), i3;
|
3822
4127
|
});
|
3823
|
-
return s2.appendChild(a2), s2.appendChild(
|
4128
|
+
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) => {
|
3824
4129
|
e2.classList.toggle("is-active", t3);
|
3825
4130
|
})), this._sideEffect.addDisposer(combine([this.highlightStage$, this.stageRect$]).subscribe(([s3, a3]) => {
|
3826
4131
|
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`));
|
@@ -3835,40 +4140,40 @@ class A$2 {
|
|
3835
4140
|
}
|
3836
4141
|
const W$3 = window.ResizeObserver || ResizeObserver$2;
|
3837
4142
|
class Y$3 {
|
3838
|
-
constructor({ id: e2 = genUID(), title: t2 = L$3(), namespace: i2 = "telebox", visible: s2 = true, width: a2 = 0.5, height:
|
4143
|
+
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 }) {
|
3839
4144
|
this.events = new Emittery(), this._delegateEvents = new Emittery(), this.handleTrackStart = (e3) => {
|
3840
4145
|
var t3;
|
3841
4146
|
return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
|
3842
4147
|
}, this._sideEffect = new SideEffectManager(), this.id = e2, this.namespace = i2;
|
3843
|
-
const
|
3844
|
-
this._sideEffect.addDisposer(() =>
|
3845
|
-
const
|
3846
|
-
this._sideEffect.addDisposer(
|
3847
|
-
|
4148
|
+
const G2 = new ValManager();
|
4149
|
+
this._sideEffect.addDisposer(() => G2.destroy());
|
4150
|
+
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 });
|
4151
|
+
this._sideEffect.addDisposer(re2.reaction((e3, t3) => {
|
4152
|
+
le2.setValue({ width: Math.max(a2, e3.width), height: Math.max(n2, e3.height) }, t3);
|
3848
4153
|
}));
|
3849
|
-
const
|
3850
|
-
this._sideEffect.addDisposer(() =>
|
3851
|
-
withReadonlyValueEnhancer(this, { darkMode:
|
3852
|
-
const
|
3853
|
-
withReadonlyValueEnhancer(this,
|
3854
|
-
withValueEnhancer(this, { title:
|
4154
|
+
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), pe2 = new Val(null), xe2 = new Val(P2.value, { compare: shallowequal }), fe2 = new Val(_2), $e2 = new A$2({ namespace: i2, root$: pe2, rootRect$: xe2, ratio$: combine([fe2, j2], ([e3, t3]) => e3 != null ? e3 : t3), highlightStage$: ge2 });
|
4155
|
+
this._sideEffect.addDisposer(() => $e2.destroy());
|
4156
|
+
withReadonlyValueEnhancer(this, { darkMode: D2, fence: T2, minimized: V2, maximized: W2, readonly: Y2, rootRect: P2, managerStageRect: O2, collectorRect: Z2 });
|
4157
|
+
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: xe2, contentStageRect: $e2.stageRect$ };
|
4158
|
+
withReadonlyValueEnhancer(this, be2, G2);
|
4159
|
+
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) => {
|
3855
4160
|
var t3;
|
3856
4161
|
return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
|
3857
|
-
}, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(
|
3858
|
-
e3 > 0 && this.transform(
|
3859
|
-
})), this._sideEffect.addDisposer(
|
3860
|
-
e3 && this.move(
|
3861
|
-
})), this.$box = this.render(),
|
3862
|
-
const
|
4162
|
+
}, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(U2.subscribe((e3) => {
|
4163
|
+
e3 > 0 && this.transform(me2.value.x, me2.value.y, ce2.value.width, ce2.value.height, true);
|
4164
|
+
})), this._sideEffect.addDisposer(T2.subscribe((e3) => {
|
4165
|
+
e3 && this.move(me2.value.x, me2.value.y, true);
|
4166
|
+
})), this.$box = this.render(), pe2.setValue(this.$content.parentElement);
|
4167
|
+
const ve2 = (e3, t3) => {
|
3863
4168
|
this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
|
3864
4169
|
i3 || this.events.emit(t3, e4);
|
3865
4170
|
}));
|
3866
4171
|
};
|
3867
|
-
|
4172
|
+
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) => {
|
3868
4173
|
t3 || e3 || this.events.emit(E$3.Close);
|
3869
|
-
}),
|
4174
|
+
}), te2.reaction((e3, t3) => {
|
3870
4175
|
t3 || this.events.emit(e3 ? E$3.Focus : E$3.Blur);
|
3871
|
-
}),
|
4176
|
+
}), X2.subscribe((e3) => {
|
3872
4177
|
e3 ? e3.appendChild(this.$box) : this.$box.parentNode && this.$box.remove();
|
3873
4178
|
})]);
|
3874
4179
|
}
|
@@ -3901,22 +4206,22 @@ class Y$3 {
|
|
3901
4206
|
}
|
3902
4207
|
move(e2, t2, i2 = false) {
|
3903
4208
|
let s2, a2;
|
3904
|
-
const
|
4209
|
+
const n2 = this.managerStageRect, o2 = this.pxIntrinsicSize;
|
3905
4210
|
if (this.fence)
|
3906
|
-
s2 = I$3(e2,
|
4211
|
+
s2 = I$3(e2, n2.x, n2.x + n2.width - o2.width), a2 = I$3(t2, n2.y, n2.y + n2.height - o2.height);
|
3907
4212
|
else {
|
3908
4213
|
const i3 = this.rootRect;
|
3909
|
-
s2 = I$3(e2,
|
4214
|
+
s2 = I$3(e2, 0 - o2.width + 20, 0 + i3.width - 20), a2 = I$3(t2, 0, 0 + i3.height - 20);
|
3910
4215
|
}
|
3911
|
-
this._intrinsicCoord$.setValue({ x: (s2 -
|
4216
|
+
this._intrinsicCoord$.setValue({ x: (s2 - n2.x) / n2.width, y: (a2 - n2.y) / n2.height }, i2);
|
3912
4217
|
}
|
3913
4218
|
transform(e2, t2, i2, s2, a2 = false) {
|
3914
|
-
const
|
4219
|
+
const n2 = this.managerStageRect, o2 = this.rootRect;
|
3915
4220
|
if (i2 = Math.max(i2, this.pxMinSize.width), s2 = Math.max(s2, this.pxMinSize.height), this.ratio > 0) {
|
3916
4221
|
const e3 = this.ratio * i2;
|
3917
4222
|
t2 !== this.pxIntrinsicCoord.y && (t2 -= e3 - s2), s2 = e3;
|
3918
4223
|
}
|
3919
|
-
t2 <
|
4224
|
+
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);
|
3920
4225
|
}
|
3921
4226
|
mountContent(e2) {
|
3922
4227
|
this._$userContent$.setValue(e2);
|
@@ -3924,6 +4229,12 @@ class Y$3 {
|
|
3924
4229
|
unmountContent() {
|
3925
4230
|
this._$userContent$.setValue(void 0);
|
3926
4231
|
}
|
4232
|
+
mountStage(e2) {
|
4233
|
+
this._$userStage$.setValue(e2);
|
4234
|
+
}
|
4235
|
+
unmountStage() {
|
4236
|
+
this._$userStage$.setValue(void 0);
|
4237
|
+
}
|
3927
4238
|
mountFooter(e2) {
|
3928
4239
|
this._$userFooter$.setValue(e2);
|
3929
4240
|
}
|
@@ -3966,47 +4277,68 @@ class Y$3 {
|
|
3966
4277
|
this.$box.style.zIndex = String(e3);
|
3967
4278
|
})), this.$box.dataset.teleBoxID = this.id;
|
3968
4279
|
const t2 = index(this.$box), i2 = combine([this._maximized$, this._minimized$, this._pxIntrinsicSize$, this._pxIntrinsicCoord$, this._collectorRect$], ([e3, t3, i3, s3, a3]) => {
|
3969
|
-
const
|
4280
|
+
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 };
|
3970
4281
|
if (t3 && a3) {
|
3971
4282
|
const { width: t4, height: s4 } = e3 ? this.rootRect : i3;
|
3972
|
-
|
4283
|
+
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;
|
3973
4284
|
}
|
3974
|
-
return
|
4285
|
+
return n3;
|
3975
4286
|
}, { compare: shallowequal }), s2 = i2.value;
|
3976
4287
|
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) => {
|
3977
4288
|
t2.set(e3);
|
3978
4289
|
}));
|
3979
4290
|
const a2 = document.createElement("div");
|
3980
4291
|
a2.className = this.wrapClassName("box-main"), this.$box.appendChild(a2);
|
4292
|
+
const n2 = document.createElement("div");
|
4293
|
+
n2.className = this.wrapClassName("titlebar-wrap"), n2.appendChild(this.titleBar.render()), this.$titleBar = n2;
|
3981
4294
|
const o2 = document.createElement("div");
|
3982
|
-
o2.className = this.wrapClassName("
|
4295
|
+
o2.className = this.wrapClassName("content-wrap");
|
3983
4296
|
const r2 = document.createElement("div");
|
3984
|
-
r2.className = this.wrapClassName("content-
|
3985
|
-
const
|
3986
|
-
|
4297
|
+
r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2;
|
4298
|
+
const h = () => {
|
4299
|
+
const e3 = r2.getBoundingClientRect();
|
4300
|
+
this._contentRect$.setValue({ x: 0, y: 0, width: e3.width, height: e3.height });
|
4301
|
+
};
|
4302
|
+
this._sideEffect.add(() => {
|
3987
4303
|
const e3 = new W$3(() => {
|
3988
|
-
|
3989
|
-
this._contentRect$.setValue({ x: e4.x, y: e4.y, width: e4.width, height: e4.height });
|
4304
|
+
this.minimized || h();
|
3990
4305
|
});
|
3991
|
-
return e3.observe(
|
3992
|
-
}), this._sideEffect.
|
4306
|
+
return e3.observe(r2), () => e3.disconnect();
|
4307
|
+
}), this._sideEffect.addDisposer(this._minimized$.reaction((e3) => {
|
4308
|
+
e3 || this._sideEffect.setTimeout(h, 400, "minimized-content-rect-fix");
|
4309
|
+
})), this._sideEffect.add(() => {
|
3993
4310
|
let e3;
|
3994
4311
|
return this._$userStyles$.subscribe((t3) => {
|
3995
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4312
|
+
e3 && e3.remove(), e3 = t3, t3 && o2.appendChild(t3);
|
3996
4313
|
});
|
3997
4314
|
}), this._sideEffect.add(() => {
|
3998
4315
|
let e3;
|
3999
4316
|
return this._$userContent$.subscribe((t3) => {
|
4000
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4317
|
+
e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
|
4001
4318
|
});
|
4002
|
-
}),
|
4003
|
-
|
4004
|
-
|
4319
|
+
}), this._sideEffect.add(() => {
|
4320
|
+
let e3;
|
4321
|
+
return this._$userStage$.subscribe((t3) => {
|
4322
|
+
var i3;
|
4323
|
+
if (e3 && e3.remove(), e3 = t3, t3) {
|
4324
|
+
if (!this.$stage) {
|
4325
|
+
const e4 = document.createElement("div");
|
4326
|
+
this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
|
4327
|
+
e4.style.top = t4.y + "px", e4.style.left = t4.x + "px", e4.style.width = t4.width + "px", e4.style.height = t4.height + "px";
|
4328
|
+
}), "content-stage-rect"), r2.appendChild(e4);
|
4329
|
+
}
|
4330
|
+
this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
|
4331
|
+
} else
|
4332
|
+
((i3 = this.$stage) == null ? void 0 : i3.parentElement) && this.$stage.remove();
|
4333
|
+
});
|
4334
|
+
}), o2.appendChild(r2);
|
4335
|
+
const c = document.createElement("div");
|
4336
|
+
return c.className = this.wrapClassName("footer-wrap"), this.$footer = c, this._sideEffect.add(() => {
|
4005
4337
|
let e3;
|
4006
4338
|
return this._$userFooter$.subscribe((t3) => {
|
4007
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4339
|
+
e3 && e3.remove(), e3 = t3, t3 && c.appendChild(t3);
|
4008
4340
|
});
|
4009
|
-
}), a2.appendChild(
|
4341
|
+
}), a2.appendChild(n2), a2.appendChild(o2), a2.appendChild(c), this._renderResizeHandlers(), this.$box;
|
4010
4342
|
}
|
4011
4343
|
_renderResizeHandlers() {
|
4012
4344
|
const e2 = document.createElement("div");
|
@@ -4015,7 +4347,7 @@ class Y$3 {
|
|
4015
4347
|
i3.className = this.wrapClassName(t3) + " " + this.wrapClassName("resize-handle"), i3.dataset.teleBoxHandle = t3, e2.appendChild(i3);
|
4016
4348
|
}), this.$box.appendChild(e2);
|
4017
4349
|
const t2 = "handle-tracking-listener", i2 = this.wrapClassName("transforming");
|
4018
|
-
let s2, a2,
|
4350
|
+
let s2, a2, n2 = 0, o2 = 0, r2 = 0, h = 0, l2 = 0, d2 = 0;
|
4019
4351
|
const c = (e3) => {
|
4020
4352
|
if (this.state !== C$3.Normal)
|
4021
4353
|
return;
|
@@ -4023,36 +4355,36 @@ class Y$3 {
|
|
4023
4355
|
let { pageX: t3, pageY: i3 } = R$3(e3);
|
4024
4356
|
i3 < this.rootRect.y && (i3 = this.rootRect.y);
|
4025
4357
|
const s3 = t3 - l2, c2 = i3 - d2;
|
4026
|
-
let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width:
|
4358
|
+
let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: p2 } = this.pxIntrinsicSize;
|
4027
4359
|
switch (a2) {
|
4028
4360
|
case N$3.North:
|
4029
|
-
u3 =
|
4361
|
+
u3 = o2 + c2, p2 = h - c2;
|
4030
4362
|
break;
|
4031
4363
|
case N$3.South:
|
4032
|
-
|
4364
|
+
p2 = h + c2;
|
4033
4365
|
break;
|
4034
4366
|
case N$3.West:
|
4035
|
-
m3 =
|
4367
|
+
m3 = n2 + s3, g2 = r2 - s3;
|
4036
4368
|
break;
|
4037
4369
|
case N$3.East:
|
4038
|
-
|
4370
|
+
g2 = r2 + s3;
|
4039
4371
|
break;
|
4040
4372
|
case N$3.NorthWest:
|
4041
|
-
m3 =
|
4373
|
+
m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, p2 = h - c2;
|
4042
4374
|
break;
|
4043
4375
|
case N$3.NorthEast:
|
4044
|
-
u3 =
|
4376
|
+
u3 = o2 + c2, g2 = r2 + s3, p2 = h - c2;
|
4045
4377
|
break;
|
4046
4378
|
case N$3.SouthEast:
|
4047
|
-
|
4379
|
+
g2 = r2 + s3, p2 = h + c2;
|
4048
4380
|
break;
|
4049
4381
|
case N$3.SouthWest:
|
4050
|
-
m3 =
|
4382
|
+
m3 = n2 + s3, g2 = r2 - s3, p2 = h + c2;
|
4051
4383
|
break;
|
4052
4384
|
default:
|
4053
|
-
return void this.move(
|
4385
|
+
return void this.move(n2 + s3, o2 + c2);
|
4054
4386
|
}
|
4055
|
-
this.transform(m3, u3,
|
4387
|
+
this.transform(m3, u3, g2, p2);
|
4056
4388
|
}, m2 = (e3) => {
|
4057
4389
|
a2 = void 0, s2 && (k$1(e3), this.$box.classList.toggle(i2, false), this._sideEffect.flush(t2), s2.remove());
|
4058
4390
|
}, u2 = (e3) => {
|
@@ -4063,9 +4395,9 @@ class Y$3 {
|
|
4063
4395
|
return;
|
4064
4396
|
if (!this.draggable || a2 || this.state !== C$3.Normal)
|
4065
4397
|
return;
|
4066
|
-
const
|
4067
|
-
if ((u3 =
|
4068
|
-
k$1(e3), { x:
|
4398
|
+
const g2 = e3.target;
|
4399
|
+
if ((u3 = g2.dataset) == null ? void 0 : u3.teleBoxHandle) {
|
4400
|
+
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"));
|
4069
4401
|
const u4 = a2 ? this.wrapClassName(`cursor-${a2}`) : "";
|
4070
4402
|
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 }), () => {
|
4071
4403
|
window.removeEventListener("mousemove", c), window.removeEventListener("touchmove", c), window.removeEventListener("mouseup", m2), window.removeEventListener("touchend", m2), window.removeEventListener("touchcancel", m2);
|
@@ -4083,33 +4415,33 @@ class Y$3 {
|
|
4083
4415
|
}
|
4084
4416
|
var X$3, P$3;
|
4085
4417
|
class O$3 {
|
4086
|
-
constructor({ minimized$: e2, readonly$: t2, darkMode$: i2,
|
4087
|
-
this._sideEffect = new SideEffectManager(), this.namespace =
|
4088
|
-
const
|
4089
|
-
this._sideEffect.addDisposer(() =>
|
4090
|
-
const
|
4091
|
-
withValueEnhancer(this, { styles:
|
4092
|
-
withReadonlyValueEnhancer(this, { root:
|
4093
|
-
withReadonlyValueEnhancer(this, { rect:
|
4094
|
-
this._sideEffect.addEventListener(
|
4418
|
+
constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, namespace: s2 = "telebox", styles: a2 = {}, root$: n2 }) {
|
4419
|
+
this._sideEffect = new SideEffectManager(), this.namespace = s2;
|
4420
|
+
const o2 = new ValManager();
|
4421
|
+
this._sideEffect.addDisposer(() => o2.destroy());
|
4422
|
+
const r2 = new Val(void 0), h = derive(e2), l2 = new Val(a2), d2 = new Val(document.createElement("button"));
|
4423
|
+
withValueEnhancer(this, { styles: l2, $collector: d2 }, o2);
|
4424
|
+
withReadonlyValueEnhancer(this, { root: n2 });
|
4425
|
+
withReadonlyValueEnhancer(this, { rect: r2, visible: h }, o2), d2.value.className = this.wrapClassName("collector"), d2.value.style.backgroundImage = "url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K')", this._sideEffect.addDisposer(d2.subscribe((s3) => {
|
4426
|
+
this._sideEffect.addEventListener(s3, "click", () => {
|
4095
4427
|
t2.value || e2.setValue(false);
|
4096
|
-
}, {}, "telebox-collector-click"), this._sideEffect.addDisposer([
|
4097
|
-
|
4428
|
+
}, {}, "telebox-collector-click"), this._sideEffect.addDisposer([h.subscribe((e3) => {
|
4429
|
+
s3.classList.toggle(this.wrapClassName("collector-visible"), e3);
|
4098
4430
|
}), t2.subscribe((e3) => {
|
4099
|
-
|
4431
|
+
s3.classList.toggle(this.wrapClassName("collector-readonly"), e3);
|
4100
4432
|
}), i2.subscribe((e3) => {
|
4101
|
-
|
4102
|
-
}),
|
4433
|
+
s3.classList.toggle(this.wrapClassName("color-scheme-dark"), e3), s3.classList.toggle(this.wrapClassName("color-scheme-light"), !e3);
|
4434
|
+
}), l2.subscribe((e3) => {
|
4103
4435
|
Object.keys(e3).forEach((t3) => {
|
4104
4436
|
const i3 = e3[t3];
|
4105
|
-
i3 != null && (
|
4437
|
+
i3 != null && (s3.style[t3] = i3);
|
4106
4438
|
});
|
4107
|
-
}),
|
4108
|
-
e3 && e3.appendChild(
|
4109
|
-
}), combine([e2,
|
4110
|
-
if (e3 &&
|
4111
|
-
const { x: e4, y:
|
4112
|
-
|
4439
|
+
}), n2.subscribe((e3) => {
|
4440
|
+
e3 && e3.appendChild(s3);
|
4441
|
+
}), combine([e2, n2]).subscribe(([e3, t3]) => {
|
4442
|
+
if (e3 && t3) {
|
4443
|
+
const { x: e4, y: i3, width: a3, height: n3 } = s3.getBoundingClientRect(), o3 = t3.getBoundingClientRect();
|
4444
|
+
r2.setValue({ x: e4 - o3.x, y: i3 - o3.y, width: a3, height: n3 });
|
4113
4445
|
}
|
4114
4446
|
})], "telebox-collector-el");
|
4115
4447
|
}));
|
@@ -4135,8 +4467,8 @@ class j$1 extends H$3 {
|
|
4135
4467
|
if (this.$titles && this.state$.value === C$3.Maximized) {
|
4136
4468
|
const { children: i2 } = this.$titles.firstElementChild;
|
4137
4469
|
for (let s2 = i2.length - 1; s2 >= 0; s2 -= 1) {
|
4138
|
-
const a2 = i2[s2],
|
4139
|
-
|
4470
|
+
const a2 = i2[s2], n2 = (t2 = a2.dataset) == null ? void 0 : t2.teleBoxID;
|
4471
|
+
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));
|
4140
4472
|
}
|
4141
4473
|
}
|
4142
4474
|
this.focusedBox = e2;
|
@@ -4176,11 +4508,11 @@ class j$1 extends H$3 {
|
|
4176
4508
|
}
|
4177
4509
|
const Z$3 = window.ResizeObserver || ResizeObserver$2;
|
4178
4510
|
class F$3 {
|
4179
|
-
constructor({ root: e2 = null, prefersColorScheme: t2 = v$3.Light, minimized: i2 = false, maximized: s2 = false, fence: a2 = false, collector:
|
4180
|
-
this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace =
|
4511
|
+
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 } = {}) {
|
4512
|
+
this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace = o2;
|
4181
4513
|
const b2 = new ValManager();
|
4182
4514
|
this._sideEffect.addDisposer(() => b2.destroy());
|
4183
|
-
const w2 = new Val(e2), y2 = new Val(
|
4515
|
+
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 });
|
4184
4516
|
this._sideEffect.addDisposer(w2.subscribe((e3) => {
|
4185
4517
|
this._sideEffect.add(() => {
|
4186
4518
|
if (!e3)
|
@@ -4188,7 +4520,7 @@ class F$3 {
|
|
4188
4520
|
};
|
4189
4521
|
const t3 = new Z$3(() => {
|
4190
4522
|
const t4 = e3.getBoundingClientRect();
|
4191
|
-
I2.setValue({ x:
|
4523
|
+
I2.setValue({ x: 0, y: 0, width: t4.width, height: t4.height });
|
4192
4524
|
});
|
4193
4525
|
return t3.observe(e3), () => t3.disconnect();
|
4194
4526
|
}, "calc-root-rect");
|
@@ -4210,13 +4542,13 @@ class F$3 {
|
|
4210
4542
|
this._sideEffect.addDisposer(D2.reaction((e3, t3) => {
|
4211
4543
|
t3 || this.events.emit(X$3.PrefersColorScheme, e3);
|
4212
4544
|
}));
|
4213
|
-
const L2 = combine([R2, D2], ([e3, t3]) => t3 === "auto" ? e3 : t3 === "dark"), T2 = combine([z2,
|
4214
|
-
this.collector =
|
4215
|
-
const V2 = new A$2({ namespace:
|
4545
|
+
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);
|
4546
|
+
this.collector = n2 != null ? n2 : new O$3({ minimized$: z2, readonly$: y2, darkMode$: L2, namespace: o2, root$: w2 });
|
4547
|
+
const V2 = new A$2({ namespace: o2, rootRect$: I2, ratio$: S2, root$: w2, highlightStage$: combine([M2, B2, z2], ([e3, t3, i3]) => e3 && (i3 || !t3)) });
|
4216
4548
|
this._sideEffect.addDisposer(() => V2.destroy());
|
4217
4549
|
const H2 = { darkMode: L2, state: T2, root: w2, rootRect: I2, stageRect: V2.stageRect$ };
|
4218
4550
|
withReadonlyValueEnhancer(this, H2, b2);
|
4219
|
-
withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized:
|
4551
|
+
withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized: B2, stageRatio: S2, highlightStage: M2 }, b2);
|
4220
4552
|
const W2 = this.wrapClassName("titlebar-icon-close"), Y2 = (e3) => {
|
4221
4553
|
var t3;
|
4222
4554
|
if (y2.value)
|
@@ -4236,10 +4568,10 @@ class F$3 {
|
|
4236
4568
|
};
|
4237
4569
|
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) => {
|
4238
4570
|
switch (e3.type) {
|
4239
|
-
case
|
4240
|
-
|
4571
|
+
case _.Maximize:
|
4572
|
+
B2.setValue(!B2.value);
|
4241
4573
|
break;
|
4242
|
-
case
|
4574
|
+
case _.Minimize:
|
4243
4575
|
z2.setValue(true);
|
4244
4576
|
break;
|
4245
4577
|
case E$3.Close:
|
@@ -4247,7 +4579,7 @@ class F$3 {
|
|
4247
4579
|
}
|
4248
4580
|
} }), this._sideEffect.addDisposer([T2.reaction((e3, t3) => {
|
4249
4581
|
t3 || this.events.emit(X$3.State, e3);
|
4250
|
-
}),
|
4582
|
+
}), B2.reaction((e3, t3) => {
|
4251
4583
|
t3 || this.events.emit(X$3.Maximized, e3);
|
4252
4584
|
}), z2.reaction((e3, t3) => {
|
4253
4585
|
t3 || this.events.emit(X$3.Minimized, e3);
|
@@ -4275,13 +4607,13 @@ class F$3 {
|
|
4275
4607
|
return this;
|
4276
4608
|
}
|
4277
4609
|
create(e2 = {}, s2 = true) {
|
4278
|
-
const a2 = new Y$3((
|
4279
|
-
var
|
4280
|
-
return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(
|
4610
|
+
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))));
|
4611
|
+
var n2, o2;
|
4612
|
+
return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(_.Maximize, () => {
|
4281
4613
|
this.setMaximized(!this.maximized);
|
4282
|
-
}), a2._delegateEvents.on(
|
4614
|
+
}), a2._delegateEvents.on(_.Minimize, () => {
|
4283
4615
|
this.setMinimized(true);
|
4284
|
-
}), a2._delegateEvents.on(
|
4616
|
+
}), a2._delegateEvents.on(_.Close, () => {
|
4285
4617
|
this.remove(a2), this.focusTopBox();
|
4286
4618
|
}), a2._intrinsicCoord$.reaction((e3, t2) => {
|
4287
4619
|
t2 || this.events.emit(X$3.IntrinsicMove, a2);
|
@@ -4366,27 +4698,27 @@ class F$3 {
|
|
4366
4698
|
return (i2) => t2.every((t3) => e2[t3] === i2[t3]);
|
4367
4699
|
}
|
4368
4700
|
updateBox(e2, t2, i2 = false) {
|
4369
|
-
var s2, a2, o2, r2,
|
4370
|
-
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: (
|
4701
|
+
var s2, a2, n2, o2, r2, h;
|
4702
|
+
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);
|
4371
4703
|
}
|
4372
4704
|
smartPosition(e2) {
|
4373
4705
|
let { x: t2, y: i2 } = e2;
|
4374
|
-
const { width: s2 = 0.5, height: a2 = 0.5 } = e2,
|
4706
|
+
const { width: s2 = 0.5, height: a2 = 0.5 } = e2, n2 = this.stageRect, o2 = this.topBox;
|
4375
4707
|
if (t2 == null) {
|
4376
|
-
let e3 =
|
4377
|
-
if (
|
4378
|
-
const t3 =
|
4379
|
-
t3 + s2 *
|
4708
|
+
let e3 = n2.x + 20;
|
4709
|
+
if (o2) {
|
4710
|
+
const t3 = o2.pxIntrinsicCoord.x + 20;
|
4711
|
+
t3 + s2 * n2.width <= n2.x + n2.width && (e3 = t3);
|
4380
4712
|
}
|
4381
|
-
t2 = (e3 -
|
4713
|
+
t2 = (e3 - n2.x) / n2.width;
|
4382
4714
|
}
|
4383
4715
|
if (i2 == null) {
|
4384
|
-
let e3 =
|
4385
|
-
if (
|
4386
|
-
const t3 =
|
4387
|
-
t3 + a2 *
|
4716
|
+
let e3 = n2.y + 20;
|
4717
|
+
if (o2) {
|
4718
|
+
const t3 = o2.pxIntrinsicCoord.y + 20;
|
4719
|
+
t3 + a2 * n2.height <= n2.y + n2.height && (e3 = t3);
|
4388
4720
|
}
|
4389
|
-
i2 = (e3 -
|
4721
|
+
i2 = (e3 - n2.y) / n2.height;
|
4390
4722
|
}
|
4391
4723
|
return { x: t2, y: i2, width: s2, height: a2 };
|
4392
4724
|
}
|
@@ -4403,7 +4735,6 @@ class F$3 {
|
|
4403
4735
|
const createBoxManager = (manager, callbacks2, emitter2, boxEmitter2, options) => {
|
4404
4736
|
return new BoxManager({
|
4405
4737
|
safeSetAttributes: (attributes) => manager.safeSetAttributes(attributes),
|
4406
|
-
getMainView: () => manager.mainView,
|
4407
4738
|
updateAppState: (...args) => {
|
4408
4739
|
var _a;
|
4409
4740
|
return (_a = manager.appManager) == null ? void 0 : _a.store.updateAppState(...args);
|
@@ -4433,17 +4764,17 @@ class BoxManager {
|
|
4433
4764
|
const { emitter: emitter2, callbacks: callbacks2, boxEmitter: boxEmitter2 } = context;
|
4434
4765
|
this.teleBoxManager = this.setupBoxManager(createTeleBoxManagerConfig);
|
4435
4766
|
this.sideEffectManager.add(() => [
|
4436
|
-
this.teleBoxManager.
|
4767
|
+
this.teleBoxManager.onValChanged("state", (state) => {
|
4437
4768
|
callbacks2.emit("boxStateChange", state);
|
4438
4769
|
emitter2.emit("boxStateChange", state);
|
4439
4770
|
}),
|
4440
|
-
this.teleBoxManager.
|
4771
|
+
this.teleBoxManager.onValChanged("darkMode", (darkMode) => {
|
4441
4772
|
callbacks2.emit("darkModeChange", darkMode);
|
4442
4773
|
}),
|
4443
|
-
this.teleBoxManager.
|
4774
|
+
this.teleBoxManager.onValChanged("prefersColorScheme", (colorScheme) => {
|
4444
4775
|
callbacks2.emit("prefersColorSchemeChange", colorScheme);
|
4445
4776
|
}),
|
4446
|
-
this.teleBoxManager.
|
4777
|
+
this.teleBoxManager.onValChanged("minimized", (minimized, skipUpdate) => {
|
4447
4778
|
if (skipUpdate) {
|
4448
4779
|
return;
|
4449
4780
|
}
|
@@ -4459,7 +4790,7 @@ class BoxManager {
|
|
4459
4790
|
}
|
4460
4791
|
}
|
4461
4792
|
}),
|
4462
|
-
this.teleBoxManager.
|
4793
|
+
this.teleBoxManager.onValChanged("maximized", (maximized, skipUpdate) => {
|
4463
4794
|
if (skipUpdate) {
|
4464
4795
|
return;
|
4465
4796
|
}
|
@@ -4471,7 +4802,11 @@ class BoxManager {
|
|
4471
4802
|
});
|
4472
4803
|
}),
|
4473
4804
|
this.teleBoxManager.events.on("intrinsic_move", debounce((box) => {
|
4474
|
-
boxEmitter2.emit("move", {
|
4805
|
+
boxEmitter2.emit("move", {
|
4806
|
+
appId: box.id,
|
4807
|
+
x: box.intrinsicX,
|
4808
|
+
y: box.intrinsicY
|
4809
|
+
});
|
4475
4810
|
}, 50)),
|
4476
4811
|
this.teleBoxManager.events.on("intrinsic_resize", debounce((box) => {
|
4477
4812
|
boxEmitter2.emit("resize", {
|
@@ -4504,9 +4839,6 @@ class BoxManager {
|
|
4504
4839
|
})
|
4505
4840
|
]);
|
4506
4841
|
}
|
4507
|
-
get mainView() {
|
4508
|
-
return this.context.getMainView();
|
4509
|
-
}
|
4510
4842
|
get canOperate() {
|
4511
4843
|
return this.context.canOperate();
|
4512
4844
|
}
|
@@ -4531,6 +4863,9 @@ class BoxManager {
|
|
4531
4863
|
get stageRect() {
|
4532
4864
|
return this.teleBoxManager.stageRect;
|
4533
4865
|
}
|
4866
|
+
get stageRect$() {
|
4867
|
+
return this.teleBoxManager._stageRect$;
|
4868
|
+
}
|
4534
4869
|
createBox(params) {
|
4535
4870
|
var _a, _b, _c;
|
4536
4871
|
if (!this.teleBoxManager)
|
@@ -4553,8 +4888,9 @@ class BoxManager {
|
|
4553
4888
|
height,
|
4554
4889
|
id: params.appId
|
4555
4890
|
};
|
4556
|
-
this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4891
|
+
const box = this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4557
4892
|
this.context.emitter.emit(`${params.appId}${Events.WindowCreated}`);
|
4893
|
+
return box;
|
4558
4894
|
}
|
4559
4895
|
setupBoxManager(createTeleBoxManagerConfig) {
|
4560
4896
|
const root = WindowManager.playground;
|
@@ -4562,7 +4898,8 @@ class BoxManager {
|
|
4562
4898
|
stageRatio: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.stageRatio,
|
4563
4899
|
root,
|
4564
4900
|
fence: false,
|
4565
|
-
prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme
|
4901
|
+
prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme,
|
4902
|
+
highlightStage: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.highlightStage
|
4566
4903
|
};
|
4567
4904
|
const manager = new F$3(initManagerState);
|
4568
4905
|
if (this.teleBoxManager) {
|
@@ -4596,15 +4933,16 @@ class BoxManager {
|
|
4596
4933
|
return this.teleBoxManager.topBox;
|
4597
4934
|
}
|
4598
4935
|
updateBoxState(state) {
|
4936
|
+
var _a, _b, _c, _d;
|
4599
4937
|
if (!state)
|
4600
4938
|
return;
|
4601
4939
|
const box = this.getBox(state.id);
|
4602
4940
|
if (box) {
|
4603
4941
|
this.teleBoxManager.update(box.id, {
|
4604
|
-
x: state.x,
|
4605
|
-
y: state.y,
|
4606
|
-
width: state.width || 0.5,
|
4607
|
-
height: state.height || 0.5,
|
4942
|
+
x: (_a = state.position) == null ? void 0 : _a.x,
|
4943
|
+
y: (_b = state.position) == null ? void 0 : _b.y,
|
4944
|
+
width: ((_c = state.size) == null ? void 0 : _c.width) || 0.5,
|
4945
|
+
height: ((_d = state.size) == null ? void 0 : _d.height) || 0.5,
|
4608
4946
|
zIndex: state.zIndex
|
4609
4947
|
}, true);
|
4610
4948
|
setTimeout(() => {
|
@@ -5562,9 +5900,8 @@ class CursorManager {
|
|
5562
5900
|
}
|
5563
5901
|
}
|
5564
5902
|
updateContainerRect() {
|
5565
|
-
var _a
|
5566
|
-
this.
|
5567
|
-
this.wrapperRect = (_b = WindowManager.playground) == null ? void 0 : _b.getBoundingClientRect();
|
5903
|
+
var _a;
|
5904
|
+
this.wrapperRect = (_a = WindowManager.playground) == null ? void 0 : _a.getBoundingClientRect();
|
5568
5905
|
}
|
5569
5906
|
deleteCursor(uid) {
|
5570
5907
|
this.store.cleanCursor(uid);
|
@@ -5618,18 +5955,22 @@ class ReconnectRefresher {
|
|
5618
5955
|
this.reactors = /* @__PURE__ */ new Map();
|
5619
5956
|
this.disposers = /* @__PURE__ */ new Map();
|
5620
5957
|
this.onPhaseChanged = (phase) => {
|
5621
|
-
var _a;
|
5958
|
+
var _a, _b;
|
5622
5959
|
if (phase === RoomPhase.Reconnecting) {
|
5623
5960
|
this.ctx.emitter.emit("startReconnect");
|
5624
5961
|
}
|
5625
5962
|
if (phase === RoomPhase.Connected && this.phase === RoomPhase.Reconnecting) {
|
5626
|
-
(_a = this.room) == null ? void 0 : _a.
|
5963
|
+
if ((_a = this.room) == null ? void 0 : _a.isWritable) {
|
5964
|
+
(_b = this.room) == null ? void 0 : _b.dispatchMagixEvent(EnsureReconnectEvent, {});
|
5965
|
+
} else {
|
5966
|
+
this.onReconnected();
|
5967
|
+
}
|
5627
5968
|
}
|
5628
5969
|
this.phase = phase;
|
5629
5970
|
};
|
5630
5971
|
this.onReconnected = debounce(() => {
|
5631
5972
|
this._onReconnected();
|
5632
|
-
},
|
5973
|
+
}, 1e3);
|
5633
5974
|
this._onReconnected = () => {
|
5634
5975
|
log("onReconnected refresh reactors");
|
5635
5976
|
this.releaseDisposers();
|
@@ -5677,6 +6018,7 @@ class ReconnectRefresher {
|
|
5677
6018
|
this.reactors.set(id2, func);
|
5678
6019
|
this.disposers.set(id2, func());
|
5679
6020
|
}
|
6021
|
+
return () => this.remove(id2);
|
5680
6022
|
}
|
5681
6023
|
remove(id2) {
|
5682
6024
|
if (this.reactors.has(id2)) {
|
@@ -5748,6 +6090,9 @@ const replaceRoomFunction = (room, manager) => {
|
|
5748
6090
|
room.lockImage = (...args) => manager.lockImage(...args);
|
5749
6091
|
room.lockImages = (...args) => manager.lockImages(...args);
|
5750
6092
|
delegateRemoveScenes(room, manager);
|
6093
|
+
if (!room.dynamicPpt.slideStateAdapter.pptHandler) {
|
6094
|
+
room.dynamicPpt.slideStateAdapter.pptHandler = manager.createPPTHandler();
|
6095
|
+
}
|
5751
6096
|
}
|
5752
6097
|
};
|
5753
6098
|
const delegateRemoveScenes = (room, manager) => {
|
@@ -15302,20 +15647,20 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15302
15647
|
const _WindowManager = class extends InvisiblePlugin {
|
15303
15648
|
constructor(context) {
|
15304
15649
|
super(context);
|
15305
|
-
this.version = "1.0.0-canary.
|
15306
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15650
|
+
this.version = "1.0.0-canary.22";
|
15651
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "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.3.0", "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" } };
|
15307
15652
|
this.emitter = callbacks$1;
|
15308
15653
|
this.viewMode = ViewMode.Broadcaster;
|
15654
|
+
this.viewMode$ = new Val(ViewMode.Broadcaster);
|
15309
15655
|
this.isReplay = isPlayer(this.displayer);
|
15310
15656
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15311
15657
|
_WindowManager.displayer = context.displayer;
|
15312
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15658
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "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.3.0", "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" } };
|
15313
15659
|
}
|
15314
15660
|
static async mount(params) {
|
15315
15661
|
var _a;
|
15316
15662
|
const room = params.room;
|
15317
15663
|
_WindowManager.container = params.container;
|
15318
|
-
const containerSizeRatio = params.containerSizeRatio;
|
15319
15664
|
const debug = params.debug;
|
15320
15665
|
const cursor = params.cursor;
|
15321
15666
|
_WindowManager.params = params;
|
@@ -15352,21 +15697,20 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15352
15697
|
if (!manager) {
|
15353
15698
|
throw new Error("[WindowManager]: create manager failed");
|
15354
15699
|
}
|
15355
|
-
if (containerSizeRatio) {
|
15356
|
-
_WindowManager.containerSizeRatio = containerSizeRatio;
|
15700
|
+
if (params.containerSizeRatio) {
|
15701
|
+
_WindowManager.containerSizeRatio = params.containerSizeRatio;
|
15357
15702
|
}
|
15703
|
+
manager.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15358
15704
|
await manager.ensureAttributes();
|
15359
15705
|
manager.appManager = new AppManager(manager);
|
15360
15706
|
manager._pageState = new PageStateImpl(manager.appManager);
|
15361
15707
|
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.applianceIcons);
|
15362
|
-
if (containerSizeRatio) {
|
15363
|
-
manager.containerSizeRatio = containerSizeRatio;
|
15364
|
-
}
|
15365
15708
|
manager.boxManager = createBoxManager(manager, callbacks$1, emitter, boxEmitter, {
|
15366
15709
|
collectorContainer: params.collectorContainer,
|
15367
15710
|
collectorStyles: params.collectorStyles,
|
15368
15711
|
prefersColorScheme: params.prefersColorScheme,
|
15369
|
-
stageRatio:
|
15712
|
+
stageRatio: _WindowManager.containerSizeRatio,
|
15713
|
+
highlightStage: params.highlightStage
|
15370
15714
|
});
|
15371
15715
|
(_a = manager.appManager) == null ? void 0 : _a.setBoxManager(manager.boxManager);
|
15372
15716
|
if (params.container) {
|
@@ -15586,6 +15930,17 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15586
15930
|
return false;
|
15587
15931
|
}
|
15588
15932
|
}
|
15933
|
+
async jumpPage(index2) {
|
15934
|
+
if (!this.appManager) {
|
15935
|
+
return false;
|
15936
|
+
}
|
15937
|
+
if (index2 < 0 || index2 >= this.pageState.length) {
|
15938
|
+
console.warn(`[WindowManager]: index ${index2} out of range`);
|
15939
|
+
return false;
|
15940
|
+
}
|
15941
|
+
await this.appManager.setMainViewSceneIndex(index2);
|
15942
|
+
return true;
|
15943
|
+
}
|
15589
15944
|
async addPage(params) {
|
15590
15945
|
if (this.appManager) {
|
15591
15946
|
const after = params == null ? void 0 : params.after;
|
@@ -15636,17 +15991,20 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15636
15991
|
addEmitterOnceListener(`destroy-${kind2}`, listener);
|
15637
15992
|
}
|
15638
15993
|
setViewMode(mode) {
|
15639
|
-
var _a
|
15994
|
+
var _a;
|
15995
|
+
log("setViewMode", mode);
|
15996
|
+
const mainViewProxy = (_a = this.appManager) == null ? void 0 : _a.mainViewProxy;
|
15640
15997
|
if (mode === ViewMode.Broadcaster) {
|
15641
15998
|
if (this.canOperate) {
|
15642
|
-
|
15999
|
+
mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
|
15643
16000
|
}
|
15644
|
-
|
16001
|
+
mainViewProxy == null ? void 0 : mainViewProxy.start();
|
15645
16002
|
}
|
15646
16003
|
if (mode === ViewMode.Freedom) {
|
15647
|
-
|
16004
|
+
mainViewProxy == null ? void 0 : mainViewProxy.stop();
|
15648
16005
|
}
|
15649
16006
|
this.viewMode = mode;
|
16007
|
+
this.viewMode$.setValue(mode);
|
15650
16008
|
}
|
15651
16009
|
setBoxState(boxState) {
|
15652
16010
|
if (!this.canOperate)
|
@@ -15793,7 +16151,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15793
16151
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCamera, camera);
|
15794
16152
|
setTimeout(() => {
|
15795
16153
|
var _a2;
|
15796
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
16154
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
|
15797
16155
|
}, 500);
|
15798
16156
|
}
|
15799
16157
|
moveCameraToContain(rectangle) {
|
@@ -15802,7 +16160,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15802
16160
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
15803
16161
|
setTimeout(() => {
|
15804
16162
|
var _a2;
|
15805
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
16163
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
|
15806
16164
|
}, 500);
|
15807
16165
|
}
|
15808
16166
|
convertToPointInWorld(point) {
|
@@ -15914,12 +16272,12 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15914
16272
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.Refresh);
|
15915
16273
|
}
|
15916
16274
|
_refresh() {
|
15917
|
-
var _a, _b
|
16275
|
+
var _a, _b;
|
15918
16276
|
(_a = this.appManager) == null ? void 0 : _a.mainViewProxy.rebind();
|
15919
16277
|
if (_WindowManager.container) {
|
15920
16278
|
this.bindContainer(_WindowManager.container);
|
15921
16279
|
}
|
15922
|
-
(
|
16280
|
+
(_b = this.appManager) == null ? void 0 : _b.refresher.refresh();
|
15923
16281
|
}
|
15924
16282
|
setContainerSizeRatio(ratio) {
|
15925
16283
|
if (!isNumber(ratio)) {
|
@@ -15929,6 +16287,26 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15929
16287
|
this.containerSizeRatio = ratio;
|
15930
16288
|
emitter.emit("containerSizeRatioUpdate", ratio);
|
15931
16289
|
}
|
16290
|
+
createPPTHandler() {
|
16291
|
+
return {
|
16292
|
+
onPageJumpTo: (_pptUUID, index2) => {
|
16293
|
+
var _a, _b, _c, _d;
|
16294
|
+
(_d = (_c = (_b = (_a = this.appManager) == null ? void 0 : _a.focusApp) == null ? void 0 : _b.appContext) == null ? void 0 : _c.whiteBoardView) == null ? void 0 : _d.jumpPage(index2);
|
16295
|
+
},
|
16296
|
+
onPageToNext: () => {
|
16297
|
+
var _a, _b, _c, _d;
|
16298
|
+
if (this.focused) {
|
16299
|
+
(_d = (_c = (_b = (_a = this.appManager) == null ? void 0 : _a.focusApp) == null ? void 0 : _b.appContext) == null ? void 0 : _c.whiteBoardView) == null ? void 0 : _d.nextPage();
|
16300
|
+
}
|
16301
|
+
},
|
16302
|
+
onPageToPrev: () => {
|
16303
|
+
var _a, _b, _c, _d;
|
16304
|
+
if (this.focused) {
|
16305
|
+
(_d = (_c = (_b = (_a = this.appManager) == null ? void 0 : _a.focusApp) == null ? void 0 : _b.appContext) == null ? void 0 : _c.whiteBoardView) == null ? void 0 : _d.prevPage();
|
16306
|
+
}
|
16307
|
+
}
|
16308
|
+
};
|
16309
|
+
}
|
15932
16310
|
isDynamicPPT(scenes) {
|
15933
16311
|
var _a, _b;
|
15934
16312
|
const sceneSrc = (_b = (_a = scenes[0]) == null ? void 0 : _a.ppt) == null ? void 0 : _b.src;
|