@netless/window-manager 1.0.0-canary.3 → 1.0.0-canary.30
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/index.cjs.js +120 -12
- package/dist/index.es.js +2243 -950
- package/dist/index.umd.js +120 -12
- package/dist/{App → src/App}/AppContext.d.ts +12 -8
- package/dist/{App → src/App}/AppPageStateImpl.d.ts +0 -0
- package/dist/{App → src/App}/AppProxy.d.ts +36 -7
- package/dist/{App → src/App}/MagixEvent/index.d.ts +0 -0
- package/dist/{App → src/App}/Storage/StorageEvent.d.ts +0 -0
- package/dist/{App → src/App}/Storage/index.d.ts +0 -0
- package/dist/{App → src/App}/Storage/typings.d.ts +0 -0
- package/dist/{App → src/App}/Storage/utils.d.ts +0 -0
- package/dist/src/App/WhiteboardView.d.ts +27 -0
- package/dist/{App → src/App}/index.d.ts +2 -1
- package/dist/src/App/type.d.ts +21 -0
- package/dist/{AppListener.d.ts → src/AppListener.d.ts} +0 -2
- package/dist/{AppManager.d.ts → src/AppManager.d.ts} +7 -6
- package/dist/{AttributesDelegate.d.ts → src/AttributesDelegate.d.ts} +11 -16
- package/dist/{BoxEmitter.d.ts → src/BoxEmitter.d.ts} +0 -0
- package/dist/{BoxManager.d.ts → src/BoxManager.d.ts} +8 -6
- package/dist/{BuiltinApps.d.ts → src/BuiltinApps.d.ts} +3 -0
- package/dist/{Cursor → src/Cursor}/Cursor.d.ts +0 -0
- package/dist/{Cursor → src/Cursor}/icons.d.ts +0 -0
- package/dist/{Cursor → src/Cursor}/index.d.ts +3 -3
- package/dist/{Helper.d.ts → src/Helper.d.ts} +4 -8
- package/dist/{InternalEmitter.d.ts → src/InternalEmitter.d.ts} +3 -4
- package/dist/{Page → src/Page}/PageController.d.ts +1 -0
- package/dist/{Page → src/Page}/index.d.ts +0 -0
- package/dist/{PageState.d.ts → src/PageState.d.ts} +0 -0
- package/dist/{ReconnectRefresher.d.ts → src/ReconnectRefresher.d.ts} +1 -1
- package/dist/{RedoUndo.d.ts → src/RedoUndo.d.ts} +0 -0
- package/dist/{Register → src/Register}/index.d.ts +0 -0
- package/dist/{Register → src/Register}/loader.d.ts +0 -0
- package/dist/{Register → src/Register}/storage.d.ts +0 -0
- package/dist/{Utils → src/Utils}/AppCreateQueue.d.ts +0 -0
- package/dist/{Utils → src/Utils}/Common.d.ts +1 -0
- package/dist/{Utils → src/Utils}/Reactive.d.ts +0 -0
- package/dist/{Utils → src/Utils}/RoomHacker.d.ts +0 -0
- package/dist/{Utils → src/Utils}/error.d.ts +0 -0
- package/dist/{Utils → src/Utils}/log.d.ts +0 -0
- package/dist/src/View/CameraSynchronizer.d.ts +18 -0
- package/dist/{View → src/View}/MainView.d.ts +18 -7
- package/dist/{View → src/View}/ViewManager.d.ts +0 -0
- package/dist/src/View/ViewSync.d.ts +24 -0
- package/dist/{callback.d.ts → src/callback.d.ts} +5 -0
- package/dist/{constants.d.ts → src/constants.d.ts} +8 -5
- package/dist/src/image.d.ts +19 -0
- package/dist/{index.d.ts → src/index.d.ts} +36 -13
- package/dist/src/shim.d.ts +11 -0
- package/dist/{typings.d.ts → src/typings.d.ts} +6 -0
- package/dist/style.css +1 -1
- package/docs/app-context.md +157 -25
- package/docs/mirgrate-to-1.0.md +28 -0
- package/package.json +12 -7
- package/playwright.config.ts +28 -0
- package/pnpm-lock.yaml +517 -35
- package/src/App/AppContext.ts +50 -28
- package/src/App/AppProxy.ts +264 -80
- package/src/App/{WhiteBoardView.ts → WhiteboardView.ts} +38 -7
- package/src/App/index.ts +2 -1
- package/src/App/type.ts +22 -0
- package/src/AppListener.ts +5 -21
- package/src/AppManager.ts +56 -43
- package/src/AttributesDelegate.ts +19 -19
- package/src/BoxManager.ts +54 -40
- package/src/BuiltinApps.ts +5 -0
- package/src/Cursor/Cursor.ts +6 -2
- package/src/Cursor/index.ts +5 -7
- package/src/Helper.ts +25 -7
- package/src/InternalEmitter.ts +3 -4
- package/src/Page/PageController.ts +1 -0
- package/src/PageState.ts +1 -1
- package/src/ReconnectRefresher.ts +7 -2
- package/src/Utils/Common.ts +9 -0
- package/src/Utils/Reactive.ts +27 -26
- package/src/Utils/RoomHacker.ts +3 -0
- package/src/View/CameraSynchronizer.ts +37 -34
- package/src/View/MainView.ts +108 -81
- package/src/View/ViewSync.ts +110 -0
- package/src/callback.ts +1 -0
- package/src/constants.ts +6 -3
- package/src/index.ts +126 -56
- package/src/style.css +2 -45
- package/src/typings.ts +6 -0
- package/vite.config.js +5 -3
- package/dist/App/WhiteBoardView.d.ts +0 -18
- package/dist/View/CameraSynchronizer.d.ts +0 -17
package/dist/index.es.js
CHANGED
@@ -19,12 +19,12 @@ 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,
|
23
|
-
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun,
|
22
|
+
import { debounce, isObject, has, get, size as size$1, mapValues, noop as noop$1, pick, isBoolean, isNumber, throttle, isEqual, omitBy, isUndefined, isInteger, orderBy, isEmpty, omit, isFunction, isNull } from "lodash";
|
23
|
+
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, toJS, WhiteVersion, autorun, 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,
|
27
|
-
import { ResizeObserver as ResizeObserver$
|
26
|
+
import { Val, combine, ValManager, withReadonlyValueEnhancer, withValueEnhancer, derive } from "value-enhancer";
|
27
|
+
import { ResizeObserver as ResizeObserver$3 } from "@juggle/resize-observer";
|
28
28
|
import p$1 from "video.js";
|
29
29
|
var Events = /* @__PURE__ */ ((Events2) => {
|
30
30
|
Events2["AppMove"] = "AppMove";
|
@@ -33,18 +33,16 @@ 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";
|
40
39
|
Events2["SetAppFocusIndex"] = "SetAppFocusIndex";
|
41
40
|
Events2["SwitchViewsToFreedom"] = "SwitchViewsToFreedom";
|
42
|
-
Events2["MoveCamera"] = "MoveCamera";
|
43
|
-
Events2["MoveCameraToContain"] = "MoveCameraToContain";
|
44
41
|
Events2["CursorMove"] = "CursorMove";
|
45
42
|
Events2["RootDirRemoved"] = "RootDirRemoved";
|
46
43
|
Events2["Refresh"] = "Refresh";
|
47
44
|
Events2["InitMainViewCamera"] = "InitMainViewCamera";
|
45
|
+
Events2["InvokeAttributesUpdateCallback"] = "InvokeAttributesUpdateCallback";
|
48
46
|
return Events2;
|
49
47
|
})(Events || {});
|
50
48
|
const MagixEventName = "__WindowManger";
|
@@ -54,6 +52,11 @@ var AppAttributes = /* @__PURE__ */ ((AppAttributes2) => {
|
|
54
52
|
AppAttributes2["Position"] = "position";
|
55
53
|
AppAttributes2["SceneIndex"] = "SceneIndex";
|
56
54
|
AppAttributes2["ZIndex"] = "zIndex";
|
55
|
+
AppAttributes2["Visible"] = "visible";
|
56
|
+
AppAttributes2["Ratio"] = "ratio";
|
57
|
+
AppAttributes2["StageRatio"] = "stageRatio";
|
58
|
+
AppAttributes2["Draggable"] = "draggable";
|
59
|
+
AppAttributes2["Resizable"] = "resizable";
|
57
60
|
return AppAttributes2;
|
58
61
|
})(AppAttributes || {});
|
59
62
|
var AppEvents = /* @__PURE__ */ ((AppEvents2) => {
|
@@ -350,11 +353,19 @@ const genAppId = async (kind2) => {
|
|
350
353
|
return `${kind2}-${v4().replace("-", "").slice(0, 8)}`;
|
351
354
|
};
|
352
355
|
const setViewFocusScenePath = (view, focusScenePath) => {
|
356
|
+
if (view.didRelease) {
|
357
|
+
return;
|
358
|
+
}
|
353
359
|
if (view.focusScenePath !== focusScenePath) {
|
354
360
|
view.focusScenePath = focusScenePath;
|
355
361
|
return view;
|
356
362
|
}
|
357
363
|
};
|
364
|
+
const releaseView = (view) => {
|
365
|
+
if (!view.didRelease) {
|
366
|
+
view.release();
|
367
|
+
}
|
368
|
+
};
|
358
369
|
const setScenePath = (room, scenePath) => {
|
359
370
|
if (room && room.isWritable) {
|
360
371
|
if (room.state.sceneState.scenePath !== scenePath) {
|
@@ -464,14 +475,6 @@ class AppListeners {
|
|
464
475
|
this.setMainViewScenePathHandler(data.payload);
|
465
476
|
break;
|
466
477
|
}
|
467
|
-
case Events.MoveCamera: {
|
468
|
-
this.moveCameraHandler(data.payload);
|
469
|
-
break;
|
470
|
-
}
|
471
|
-
case Events.MoveCameraToContain: {
|
472
|
-
this.moveCameraToContainHandler(data.payload);
|
473
|
-
break;
|
474
|
-
}
|
475
478
|
case Events.CursorMove: {
|
476
479
|
this.cursorMoveHandler(data.payload);
|
477
480
|
break;
|
@@ -492,6 +495,10 @@ class AppListeners {
|
|
492
495
|
this.setAppFocusViewIndexHandler(data.payload);
|
493
496
|
break;
|
494
497
|
}
|
498
|
+
case Events.InvokeAttributesUpdateCallback: {
|
499
|
+
this.manager.attributesUpdateCallback(this.manager.attributes.apps);
|
500
|
+
break;
|
501
|
+
}
|
495
502
|
}
|
496
503
|
}
|
497
504
|
};
|
@@ -511,14 +518,6 @@ class AppListeners {
|
|
511
518
|
setViewFocusScenePath(this.manager.mainView, nextScenePath);
|
512
519
|
callbacks$1.emit("mainViewScenePathChange", nextScenePath);
|
513
520
|
};
|
514
|
-
this.moveCameraHandler = (payload) => {
|
515
|
-
if (isEqual(omit(payload, ["animationMode"]), __spreadValues({}, this.manager.mainView.camera)))
|
516
|
-
return;
|
517
|
-
this.manager.mainView.moveCamera(payload);
|
518
|
-
};
|
519
|
-
this.moveCameraToContainHandler = (payload) => {
|
520
|
-
this.manager.mainView.moveCameraToContain(payload);
|
521
|
-
};
|
522
521
|
this.cursorMoveHandler = (payload) => {
|
523
522
|
emitter.emit("cursorMove", payload);
|
524
523
|
};
|
@@ -893,10 +892,11 @@ class Storage {
|
|
893
892
|
}
|
894
893
|
}
|
895
894
|
class WhiteBoardView {
|
896
|
-
constructor(appContext, appProxy,
|
895
|
+
constructor(view, appContext, appProxy, ensureSize) {
|
896
|
+
this.view = view;
|
897
897
|
this.appContext = appContext;
|
898
898
|
this.appProxy = appProxy;
|
899
|
-
this.
|
899
|
+
this.ensureSize = ensureSize;
|
900
900
|
this.nextPage = async () => {
|
901
901
|
const nextIndex = this.pageState.index + 1;
|
902
902
|
return this.jumpPage(nextIndex);
|
@@ -939,24 +939,48 @@ class WhiteBoardView {
|
|
939
939
|
return this.appProxy.removeSceneByIndex(needRemoveIndex);
|
940
940
|
};
|
941
941
|
const pageState$ = new Val(appProxy.pageState);
|
942
|
+
const baseRect$ = new Val(appProxy.size$.value);
|
943
|
+
const pickCamera = (camera) => pick(camera, ["centerX", "centerY", "scale"]);
|
944
|
+
const camera$ = new Val(pickCamera(this.view.camera));
|
945
|
+
this.baseRect$ = baseRect$;
|
942
946
|
this.pageState$ = pageState$;
|
943
|
-
|
944
|
-
|
945
|
-
|
947
|
+
this.baseCamera$ = camera$;
|
948
|
+
this.appProxy.sideEffectManager.add(() => [
|
949
|
+
appProxy.appEmitter.on("pageStateChange", (pageState) => pageState$.setValue(pageState)),
|
950
|
+
appProxy.camera$.subscribe((camera) => {
|
951
|
+
if (camera) {
|
952
|
+
camera$.setValue(pickCamera(camera));
|
953
|
+
}
|
954
|
+
}),
|
955
|
+
appProxy.size$.subscribe((size2) => {
|
956
|
+
if (size2) {
|
957
|
+
baseRect$.setValue(pick(size2, ["width", "height"]));
|
958
|
+
}
|
959
|
+
})
|
960
|
+
]);
|
961
|
+
view.disableCameraTransform = true;
|
946
962
|
}
|
947
963
|
get pageState() {
|
948
964
|
return this.pageState$.value;
|
949
965
|
}
|
950
|
-
|
951
|
-
this.
|
966
|
+
moveCamera(camera) {
|
967
|
+
this.appProxy.moveCamera(camera);
|
968
|
+
}
|
969
|
+
setBaseRect(rect) {
|
970
|
+
this.appProxy.updateSize(rect.width, rect.height);
|
952
971
|
}
|
953
972
|
}
|
954
|
-
const
|
973
|
+
const log = (...args) => {
|
974
|
+
if (WindowManager.debug) {
|
975
|
+
console.log(`[WindowManager]:`, ...args);
|
976
|
+
}
|
977
|
+
};
|
978
|
+
const setupWrapper = (root, target) => {
|
955
979
|
const playground = document.createElement("div");
|
956
980
|
playground.className = "netless-window-manager-playground";
|
957
981
|
const mainViewElement = document.createElement("div");
|
958
982
|
mainViewElement.className = "netless-window-manager-main-view";
|
959
|
-
|
983
|
+
target.appendChild(mainViewElement);
|
960
984
|
root.appendChild(playground);
|
961
985
|
return { playground, mainViewElement };
|
962
986
|
};
|
@@ -978,13 +1002,25 @@ const serializeRoomMembers = (members) => {
|
|
978
1002
|
var _a;
|
979
1003
|
return __spreadValues({
|
980
1004
|
uid: ((_a = member.payload) == null ? void 0 : _a.uid) || ""
|
981
|
-
}, member);
|
1005
|
+
}, toJS(member));
|
982
1006
|
});
|
983
1007
|
};
|
1008
|
+
const createInvisiblePlugin = async (room) => {
|
1009
|
+
try {
|
1010
|
+
const manager = await room.createInvisiblePlugin(WindowManager, {});
|
1011
|
+
return manager;
|
1012
|
+
} catch (error) {
|
1013
|
+
if (error.message === `invisible plugin "WindowManager" exits`) {
|
1014
|
+
await wait(200);
|
1015
|
+
return room.getInvisiblePlugin(WindowManager.kind);
|
1016
|
+
} else {
|
1017
|
+
log("createInvisiblePlugin failed", error);
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
};
|
984
1021
|
class AppContext {
|
985
|
-
constructor(manager,
|
1022
|
+
constructor(manager, appId, appProxy, appOptions) {
|
986
1023
|
this.manager = manager;
|
987
|
-
this.boxManager = boxManager;
|
988
1024
|
this.appId = appId;
|
989
1025
|
this.appProxy = appProxy;
|
990
1026
|
this.appOptions = appOptions;
|
@@ -1012,8 +1048,7 @@ class AppContext {
|
|
1012
1048
|
return appAttr == null ? void 0 : appAttr.options["scenes"];
|
1013
1049
|
}
|
1014
1050
|
};
|
1015
|
-
this.createWhiteBoardView = (
|
1016
|
-
var _a;
|
1051
|
+
this.createWhiteBoardView = (params) => {
|
1017
1052
|
if (this.whiteBoardView) {
|
1018
1053
|
return this.whiteBoardView;
|
1019
1054
|
}
|
@@ -1021,21 +1056,39 @@ class AppContext {
|
|
1021
1056
|
if (!view) {
|
1022
1057
|
view = this.appProxy.createAppDir();
|
1023
1058
|
}
|
1059
|
+
if (params) {
|
1060
|
+
if (isBoolean(params.syncCamera)) {
|
1061
|
+
this.appProxy.syncCamera$.setValue(params.syncCamera);
|
1062
|
+
}
|
1063
|
+
}
|
1024
1064
|
const viewWrapper = document.createElement("div");
|
1065
|
+
this._viewWrapper = viewWrapper;
|
1025
1066
|
viewWrapper.className = "window-manager-view-wrapper";
|
1026
|
-
|
1027
|
-
const removeViewWrapper = () => {
|
1028
|
-
var _a2;
|
1029
|
-
(_a2 = this.box.$content.parentElement) == null ? void 0 : _a2.removeChild(viewWrapper);
|
1030
|
-
};
|
1067
|
+
this.box.$main.appendChild(viewWrapper);
|
1031
1068
|
view.divElement = viewWrapper;
|
1069
|
+
this.appProxy.fireMemberStateChange();
|
1032
1070
|
if (this.isAddApp) {
|
1033
|
-
this.
|
1034
|
-
}
|
1035
|
-
this.whiteBoardView = new WhiteBoardView(this, this.appProxy,
|
1071
|
+
this.ensurePageSize(params == null ? void 0 : params.size);
|
1072
|
+
}
|
1073
|
+
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, this.ensurePageSize);
|
1074
|
+
this.appProxy.sideEffectManager.add(() => [
|
1075
|
+
this.box._stageRect$.subscribe((rect) => {
|
1076
|
+
viewWrapper.style.left = `${rect.x}px`;
|
1077
|
+
viewWrapper.style.top = `${rect.y}px`;
|
1078
|
+
viewWrapper.style.width = `${rect.width}px`;
|
1079
|
+
viewWrapper.style.height = `${rect.height}px`;
|
1080
|
+
}),
|
1081
|
+
() => {
|
1082
|
+
return () => {
|
1083
|
+
this.whiteBoardView = void 0;
|
1084
|
+
};
|
1085
|
+
}
|
1086
|
+
]);
|
1087
|
+
this.appProxy.whiteBoardViewCreated$.setValue(true);
|
1036
1088
|
return this.whiteBoardView;
|
1037
1089
|
};
|
1038
|
-
this.
|
1090
|
+
this.ensurePageSize = (size2) => {
|
1091
|
+
var _a;
|
1039
1092
|
if (!isNumber(size2))
|
1040
1093
|
return;
|
1041
1094
|
if (!this.appProxy.scenePath)
|
@@ -1046,14 +1099,11 @@ class AppContext {
|
|
1046
1099
|
throw Error(`[WindowManager]: size ${size2} muse be in range [1, ${MAX_PAGE_SIZE}]`);
|
1047
1100
|
}
|
1048
1101
|
const needInsert = size2 - this.appProxy.pageState.length;
|
1049
|
-
const
|
1050
|
-
|
1051
|
-
return { name: `${startPageNumber + index2 + 1}` };
|
1052
|
-
});
|
1053
|
-
putScenes(this.room, this.appProxy.scenePath, scenes);
|
1102
|
+
const scenes = new Array(needInsert).fill({});
|
1103
|
+
(_a = this.room) == null ? void 0 : _a.putScenes(this.appProxy.scenePath, scenes);
|
1054
1104
|
};
|
1055
1105
|
this.getInitScenePath = () => {
|
1056
|
-
return this.
|
1106
|
+
return this.appProxy.scenePath;
|
1057
1107
|
};
|
1058
1108
|
this.setAttributes = (attributes) => {
|
1059
1109
|
this.manager.safeSetAttributes({ [this.appId]: attributes });
|
@@ -1097,14 +1147,17 @@ class AppContext {
|
|
1097
1147
|
get displayer() {
|
1098
1148
|
return this.manager.displayer;
|
1099
1149
|
}
|
1150
|
+
get destroyed() {
|
1151
|
+
return this.appProxy.status === "destroyed";
|
1152
|
+
}
|
1100
1153
|
get view() {
|
1101
1154
|
return this.appProxy.view;
|
1102
1155
|
}
|
1103
1156
|
get isWritable() {
|
1104
|
-
return this.manager.canOperate;
|
1157
|
+
return this.manager.canOperate && !this.destroyed;
|
1105
1158
|
}
|
1106
1159
|
get box() {
|
1107
|
-
const box = this.
|
1160
|
+
const box = this.appProxy.box$.value;
|
1108
1161
|
if (box) {
|
1109
1162
|
return box;
|
1110
1163
|
} else {
|
@@ -1115,9 +1168,9 @@ class AppContext {
|
|
1115
1168
|
return this.manager.room;
|
1116
1169
|
}
|
1117
1170
|
get members() {
|
1118
|
-
return this.manager.members;
|
1171
|
+
return this.manager.members$.value;
|
1119
1172
|
}
|
1120
|
-
get
|
1173
|
+
get currentMember() {
|
1121
1174
|
const self2 = findMemberByUid(this.room, this.manager.uid);
|
1122
1175
|
if (!self2) {
|
1123
1176
|
throw new Error(`Member ${this.manager.uid} not found.`);
|
@@ -1186,6 +1239,151 @@ class AppPageStateImpl {
|
|
1186
1239
|
(_a = this.sceneNode) == null ? void 0 : _a.dispose();
|
1187
1240
|
}
|
1188
1241
|
}
|
1242
|
+
class CameraSynchronizer {
|
1243
|
+
constructor(saveCamera) {
|
1244
|
+
this.saveCamera = saveCamera;
|
1245
|
+
this.setRect = (rect) => {
|
1246
|
+
this.rect = rect;
|
1247
|
+
if (this.remoteCamera && this.remoteSize) {
|
1248
|
+
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1249
|
+
}
|
1250
|
+
};
|
1251
|
+
this.onRemoteUpdate = throttle((camera, size2) => {
|
1252
|
+
this.remoteCamera = camera;
|
1253
|
+
this.remoteSize = size2;
|
1254
|
+
if (this.remoteSize && this.rect) {
|
1255
|
+
const wScale = this.rect.width / size2.width;
|
1256
|
+
const hScale = this.rect.height / size2.height;
|
1257
|
+
const nextScale = camera.scale * Math.min(wScale, hScale);
|
1258
|
+
const config = {
|
1259
|
+
scale: nextScale,
|
1260
|
+
animationMode: AnimationMode.Continuous
|
1261
|
+
};
|
1262
|
+
if (camera.centerX !== null) {
|
1263
|
+
config.centerX = camera.centerX;
|
1264
|
+
}
|
1265
|
+
if (camera.centerY !== null) {
|
1266
|
+
config.centerY = camera.centerY;
|
1267
|
+
}
|
1268
|
+
this.moveCamera(config);
|
1269
|
+
}
|
1270
|
+
}, 10);
|
1271
|
+
}
|
1272
|
+
setView(view) {
|
1273
|
+
this.view = view;
|
1274
|
+
}
|
1275
|
+
onRemoteSizeUpdate(size2) {
|
1276
|
+
this.remoteSize = size2;
|
1277
|
+
const needMoveCamera = !isEqual(pick(this.rect, ["width", "height"]), pick(size2, ["width", "height"]));
|
1278
|
+
if (this.rect && this.remoteCamera && needMoveCamera) {
|
1279
|
+
const scale2 = this.rect.width / size2.width;
|
1280
|
+
const nextScale = this.remoteCamera.scale * scale2;
|
1281
|
+
this.moveCamera({
|
1282
|
+
scale: nextScale
|
1283
|
+
});
|
1284
|
+
}
|
1285
|
+
}
|
1286
|
+
onLocalCameraUpdate(camera) {
|
1287
|
+
this.saveCamera(camera);
|
1288
|
+
this.remoteCamera = camera;
|
1289
|
+
}
|
1290
|
+
moveCamera(camera) {
|
1291
|
+
var _a;
|
1292
|
+
(_a = this.view) == null ? void 0 : _a.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: AnimationMode.Continuous }));
|
1293
|
+
}
|
1294
|
+
}
|
1295
|
+
class ViewSync {
|
1296
|
+
constructor(context) {
|
1297
|
+
this.context = context;
|
1298
|
+
this.sem = new SideEffectManager();
|
1299
|
+
this.bindView = (view) => {
|
1300
|
+
if (!view)
|
1301
|
+
return;
|
1302
|
+
this.synchronizer.setView(view);
|
1303
|
+
this.sem.flush("view");
|
1304
|
+
this.sem.add(() => {
|
1305
|
+
view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1306
|
+
return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1307
|
+
}, "view");
|
1308
|
+
};
|
1309
|
+
this.onCameraUpdatedByDevice = (camera) => {
|
1310
|
+
if (!camera)
|
1311
|
+
return;
|
1312
|
+
this.synchronizer.onLocalCameraUpdate(__spreadProps(__spreadValues({}, camera), { id: this.context.uid }));
|
1313
|
+
const stage = this.context.stageRect$.value;
|
1314
|
+
if (stage) {
|
1315
|
+
const size2 = { width: stage.width, height: stage.height, id: this.context.uid };
|
1316
|
+
if (!isEqual(size2, this.context.size$.value)) {
|
1317
|
+
this.context.storeSize(size2);
|
1318
|
+
}
|
1319
|
+
}
|
1320
|
+
};
|
1321
|
+
this.synchronizer = new CameraSynchronizer((camera) => {
|
1322
|
+
this.context.camera$.setValue(camera, true);
|
1323
|
+
const notStoreCamera = this.context.viewMode$ && this.context.viewMode$.value === ViewMode.Freedom;
|
1324
|
+
if (notStoreCamera) {
|
1325
|
+
return;
|
1326
|
+
} else {
|
1327
|
+
this.context.storeCamera(camera);
|
1328
|
+
}
|
1329
|
+
});
|
1330
|
+
this.bindView(this.context.view$.value);
|
1331
|
+
this.sem.add(() => [
|
1332
|
+
this.context.view$.subscribe((view) => {
|
1333
|
+
const currentCamera = this.context.camera$.value;
|
1334
|
+
if (currentCamera && this.context.size$.value) {
|
1335
|
+
view == null ? void 0 : view.moveCamera({
|
1336
|
+
scale: 1,
|
1337
|
+
animationMode: AnimationMode.Immediately
|
1338
|
+
});
|
1339
|
+
this.synchronizer.onRemoteUpdate(currentCamera, this.context.size$.value);
|
1340
|
+
}
|
1341
|
+
this.bindView(view);
|
1342
|
+
}),
|
1343
|
+
this.context.camera$.subscribe((camera, skipUpdate) => {
|
1344
|
+
const size2 = this.context.size$.value;
|
1345
|
+
if (camera && size2 && !skipUpdate) {
|
1346
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1347
|
+
}
|
1348
|
+
}),
|
1349
|
+
this.context.size$.subscribe((size2) => {
|
1350
|
+
if (size2) {
|
1351
|
+
this.synchronizer.onRemoteSizeUpdate(size2);
|
1352
|
+
}
|
1353
|
+
}),
|
1354
|
+
this.context.stageRect$.reaction((rect) => {
|
1355
|
+
if (rect) {
|
1356
|
+
this.synchronizer.setRect(rect);
|
1357
|
+
}
|
1358
|
+
})
|
1359
|
+
]);
|
1360
|
+
const camera$size$ = combine([this.context.camera$, this.context.size$]);
|
1361
|
+
camera$size$.reaction(([camera, size2]) => {
|
1362
|
+
if (camera && size2) {
|
1363
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1364
|
+
camera$size$.destroy();
|
1365
|
+
}
|
1366
|
+
});
|
1367
|
+
}
|
1368
|
+
destroy() {
|
1369
|
+
this.sem.flushAll();
|
1370
|
+
}
|
1371
|
+
}
|
1372
|
+
const boxEmitter = new Emittery();
|
1373
|
+
const calculateNextIndex = (index2, pageState) => {
|
1374
|
+
let nextIndex = 0;
|
1375
|
+
const maxIndex = pageState.length - 1;
|
1376
|
+
if (index2 === pageState.index) {
|
1377
|
+
if (index2 === maxIndex) {
|
1378
|
+
nextIndex = index2 - 1;
|
1379
|
+
} else {
|
1380
|
+
nextIndex = pageState.index + 1;
|
1381
|
+
}
|
1382
|
+
} else {
|
1383
|
+
nextIndex = pageState.index;
|
1384
|
+
}
|
1385
|
+
return nextIndex;
|
1386
|
+
};
|
1189
1387
|
var Fields = /* @__PURE__ */ ((Fields2) => {
|
1190
1388
|
Fields2["Apps"] = "apps";
|
1191
1389
|
Fields2["Focus"] = "focus";
|
@@ -1199,6 +1397,8 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
|
|
1199
1397
|
Fields2["CursorState"] = "cursorState";
|
1200
1398
|
Fields2["FullPath"] = "fullPath";
|
1201
1399
|
Fields2["Registered"] = "registered";
|
1400
|
+
Fields2["Camera"] = "camera";
|
1401
|
+
Fields2["Size"] = "size";
|
1202
1402
|
return Fields2;
|
1203
1403
|
})(Fields || {});
|
1204
1404
|
class AttributesDelegate {
|
@@ -1246,7 +1446,7 @@ class AttributesDelegate {
|
|
1246
1446
|
attrNames.push("scenes");
|
1247
1447
|
}
|
1248
1448
|
const options = pick(params.options, attrNames);
|
1249
|
-
const attrs = { kind: params.kind, options, isDynamicPPT };
|
1449
|
+
const attrs = { kind: params.kind, options, isDynamicPPT, setup: false };
|
1250
1450
|
if (typeof params.src === "string") {
|
1251
1451
|
attrs.src = params.src;
|
1252
1452
|
}
|
@@ -1263,6 +1463,9 @@ class AttributesDelegate {
|
|
1263
1463
|
this.context.safeUpdateAttributes(["apps", appId, "state", stateName], state);
|
1264
1464
|
}
|
1265
1465
|
}
|
1466
|
+
updateAppAttributes(appId, key, value) {
|
1467
|
+
this.context.safeUpdateAttributes(["apps", appId, key], value);
|
1468
|
+
}
|
1266
1469
|
cleanAppAttributes(id2) {
|
1267
1470
|
this.context.safeUpdateAttributes(["apps", id2], void 0);
|
1268
1471
|
this.context.safeSetAttributes({ [id2]: void 0 });
|
@@ -1354,26 +1557,6 @@ const store = new AttributesDelegate({
|
|
1354
1557
|
throw new Error("safeUpdateAttributes not implemented");
|
1355
1558
|
}
|
1356
1559
|
});
|
1357
|
-
const log = (...args) => {
|
1358
|
-
if (WindowManager.debug) {
|
1359
|
-
console.log(`[WindowManager]:`, ...args);
|
1360
|
-
}
|
1361
|
-
};
|
1362
|
-
const calculateNextIndex = (index2, pageState) => {
|
1363
|
-
let nextIndex = 0;
|
1364
|
-
const maxIndex = pageState.length - 1;
|
1365
|
-
if (index2 === pageState.index) {
|
1366
|
-
if (index2 === maxIndex) {
|
1367
|
-
nextIndex = index2 - 1;
|
1368
|
-
} else {
|
1369
|
-
nextIndex = pageState.index + 1;
|
1370
|
-
}
|
1371
|
-
} else {
|
1372
|
-
nextIndex = pageState.index;
|
1373
|
-
}
|
1374
|
-
return nextIndex;
|
1375
|
-
};
|
1376
|
-
const boxEmitter = new Emittery();
|
1377
1560
|
class AppProxy {
|
1378
1561
|
constructor(params, manager, appId, isAddApp) {
|
1379
1562
|
var _a;
|
@@ -1383,65 +1566,100 @@ class AppProxy {
|
|
1383
1566
|
this.appProxies = this.manager.appProxies;
|
1384
1567
|
this.viewManager = this.manager.viewManager;
|
1385
1568
|
this.store = this.manager.store;
|
1569
|
+
this.uid = this.manager.uid;
|
1386
1570
|
this.status = "normal";
|
1387
1571
|
this.sideEffectManager = new SideEffectManager();
|
1572
|
+
this.valManager = new ValManager();
|
1573
|
+
this.fullPath$ = this.valManager.attach(new Val(void 0));
|
1574
|
+
this.camera$ = this.valManager.attach(new Val(void 0));
|
1575
|
+
this.size$ = this.valManager.attach(new Val(void 0));
|
1576
|
+
this.box$ = this.valManager.attach(new Val(void 0));
|
1577
|
+
this.view$ = this.valManager.attach(new Val(void 0));
|
1578
|
+
this.syncCamera$ = this.valManager.attach(new Val(true));
|
1579
|
+
this.whiteBoardViewCreated$ = this.valManager.attach(new Val(false));
|
1580
|
+
this.fireMemberStateChange = () => {
|
1581
|
+
if (this.manager.room) {
|
1582
|
+
this.onMemberStateChange(this.manager.room.state.memberState);
|
1583
|
+
}
|
1584
|
+
};
|
1585
|
+
this.onMemberStateChange = (memberState) => {
|
1586
|
+
var _a2, _b;
|
1587
|
+
const needPointerEventsNone = memberState.currentApplianceName === "clicker";
|
1588
|
+
if (needPointerEventsNone) {
|
1589
|
+
if ((_a2 = this.appContext) == null ? void 0 : _a2._viewWrapper) {
|
1590
|
+
this.appContext._viewWrapper.style.pointerEvents = "none";
|
1591
|
+
}
|
1592
|
+
} else {
|
1593
|
+
if ((_b = this.appContext) == null ? void 0 : _b._viewWrapper) {
|
1594
|
+
this.appContext._viewWrapper.style.pointerEvents = "auto";
|
1595
|
+
}
|
1596
|
+
}
|
1597
|
+
};
|
1598
|
+
this.computedInitialRect = (boxRect) => {
|
1599
|
+
var _a2;
|
1600
|
+
const managerRect = (_a2 = this.manager.boxManager) == null ? void 0 : _a2.stageRect;
|
1601
|
+
if (managerRect) {
|
1602
|
+
const { width, height } = managerRect;
|
1603
|
+
const boxRatio = boxRect.height / boxRect.width;
|
1604
|
+
if (height < 480) {
|
1605
|
+
return {
|
1606
|
+
width: 480 / boxRatio,
|
1607
|
+
height: 480
|
1608
|
+
};
|
1609
|
+
} else {
|
1610
|
+
return {
|
1611
|
+
width: width * 0.65,
|
1612
|
+
height: height * 0.65
|
1613
|
+
};
|
1614
|
+
}
|
1615
|
+
}
|
1616
|
+
};
|
1388
1617
|
this.getAppInitState = (id2) => {
|
1389
1618
|
var _a2, _b;
|
1390
1619
|
const attrs = this.store.getAppState(id2);
|
1391
1620
|
if (!attrs)
|
1392
1621
|
return;
|
1393
|
-
const position = attrs == null ? void 0 : attrs[AppAttributes.Position];
|
1394
1622
|
const focus = this.store.focus;
|
1395
|
-
const size2 = attrs == null ? void 0 : attrs[AppAttributes.Size];
|
1396
|
-
const sceneIndex = attrs == null ? void 0 : attrs[AppAttributes.SceneIndex];
|
1397
1623
|
const maximized = (_a2 = this.attributes) == null ? void 0 : _a2["maximized"];
|
1398
1624
|
const minimized = (_b = this.attributes) == null ? void 0 : _b["minimized"];
|
1399
|
-
|
1400
|
-
|
1401
|
-
if (position) {
|
1402
|
-
payload = __spreadProps(__spreadValues({}, payload), { id: id2, x: position.x, y: position.y });
|
1403
|
-
}
|
1625
|
+
let payload = { maximized, minimized, id: id2 };
|
1626
|
+
const state = omitBy(attrs, isUndefined);
|
1404
1627
|
if (focus === id2) {
|
1405
1628
|
payload = __spreadProps(__spreadValues({}, payload), { focus: true });
|
1406
1629
|
}
|
1407
|
-
|
1408
|
-
payload = __spreadProps(__spreadValues({}, payload), { width: size2.width, height: size2.height });
|
1409
|
-
}
|
1410
|
-
if (sceneIndex) {
|
1411
|
-
payload = __spreadProps(__spreadValues({}, payload), { sceneIndex });
|
1412
|
-
}
|
1413
|
-
return payload;
|
1630
|
+
return Object.assign(payload, state);
|
1414
1631
|
};
|
1415
1632
|
this.appAttributesUpdateListener = (appId2) => {
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1633
|
+
this.sideEffectManager.add(() => [
|
1634
|
+
this.manager.refresher.add(appId2, () => {
|
1635
|
+
return autorun(() => {
|
1636
|
+
const attrs = this.manager.attributes[appId2];
|
1637
|
+
if (attrs) {
|
1638
|
+
this.appEmitter.emit("attributesUpdate", attrs);
|
1639
|
+
}
|
1640
|
+
});
|
1641
|
+
}),
|
1642
|
+
this.manager.refresher.add(this.stateKey, () => {
|
1643
|
+
return autorun(() => {
|
1644
|
+
var _a2, _b, _c;
|
1645
|
+
const appState = (_a2 = this.appAttributes) == null ? void 0 : _a2.state;
|
1646
|
+
if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((_b = this.box) == null ? void 0 : _b.zIndex)) {
|
1647
|
+
(_c = this.boxManager) == null ? void 0 : _c.setZIndex(appId2, appState.zIndex);
|
1648
|
+
}
|
1649
|
+
});
|
1650
|
+
}),
|
1651
|
+
this.manager.refresher.add(`${appId2}-fullPath`, () => {
|
1652
|
+
return autorun(() => {
|
1653
|
+
var _a2;
|
1654
|
+
const fullPath = (_a2 = this.appAttributes) == null ? void 0 : _a2.fullPath;
|
1655
|
+
this.setFocusScenePathHandler(fullPath);
|
1656
|
+
if (this.fullPath$.value !== fullPath) {
|
1657
|
+
this.notifyPageStateChange();
|
1658
|
+
this.fullPath$.setValue(fullPath);
|
1659
|
+
}
|
1660
|
+
});
|
1661
|
+
})
|
1662
|
+
]);
|
1445
1663
|
};
|
1446
1664
|
this.setFocusScenePathHandler = debounce((fullPath) => {
|
1447
1665
|
var _a2;
|
@@ -1454,6 +1672,62 @@ class AppProxy {
|
|
1454
1672
|
this.appEmitter.emit("pageStateChange", this.pageState);
|
1455
1673
|
}
|
1456
1674
|
}, 50);
|
1675
|
+
this.storeCamera = (camera) => {
|
1676
|
+
this.store.updateAppAttributes(this.id, Fields.Camera, camera);
|
1677
|
+
};
|
1678
|
+
this.storeSize = (size2) => {
|
1679
|
+
this.store.updateAppAttributes(this.id, Fields.Size, size2);
|
1680
|
+
};
|
1681
|
+
this.updateSize = (width, height) => {
|
1682
|
+
const iSize = {
|
1683
|
+
id: this.manager.uid,
|
1684
|
+
width,
|
1685
|
+
height
|
1686
|
+
};
|
1687
|
+
this.store.updateAppAttributes(this.id, Fields.Size, iSize);
|
1688
|
+
this.size$.setValue(iSize);
|
1689
|
+
};
|
1690
|
+
this.moveCamera = (camera) => {
|
1691
|
+
if (!this.camera$.value) {
|
1692
|
+
return;
|
1693
|
+
}
|
1694
|
+
const nextCamera = __spreadProps(__spreadValues(__spreadValues({}, this.camera$.value), camera), { id: this.uid });
|
1695
|
+
this.storeCamera(nextCamera);
|
1696
|
+
this.camera$.setValue(nextCamera);
|
1697
|
+
};
|
1698
|
+
this.addCameraReaction = () => {
|
1699
|
+
this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-camera`, () => reaction(() => {
|
1700
|
+
var _a2;
|
1701
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
|
1702
|
+
}, (camera) => {
|
1703
|
+
if (camera) {
|
1704
|
+
const rawCamera = toJS(camera);
|
1705
|
+
if (!isEqual(rawCamera, this.camera$.value)) {
|
1706
|
+
this.camera$.setValue(rawCamera);
|
1707
|
+
}
|
1708
|
+
}
|
1709
|
+
})), "camera");
|
1710
|
+
};
|
1711
|
+
this.addSizeReaction = () => {
|
1712
|
+
this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-size`, () => reaction(() => {
|
1713
|
+
var _a2;
|
1714
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
|
1715
|
+
}, (size2) => {
|
1716
|
+
if (size2) {
|
1717
|
+
const rawSize = toJS(size2);
|
1718
|
+
if (!isEqual(rawSize, this.size$.value)) {
|
1719
|
+
this.size$.setValue(rawSize);
|
1720
|
+
}
|
1721
|
+
}
|
1722
|
+
})), "size");
|
1723
|
+
};
|
1724
|
+
this.onFocus = () => {
|
1725
|
+
this.setScenePath();
|
1726
|
+
};
|
1727
|
+
this.setupDone = () => {
|
1728
|
+
this.store.updateAppAttributes(this.id, "setup", true);
|
1729
|
+
this.manager.dispatchInternalEvent(Events.InvokeAttributesUpdateCallback);
|
1730
|
+
};
|
1457
1731
|
this.kind = params.kind;
|
1458
1732
|
this.id = appId;
|
1459
1733
|
this.appScenePath = `/${this.id}-app-dir`;
|
@@ -1475,14 +1749,71 @@ class AppProxy {
|
|
1475
1749
|
view: this.view,
|
1476
1750
|
notifyPageStateChange: this.notifyPageStateChange
|
1477
1751
|
});
|
1478
|
-
this.sideEffectManager.add(() =>
|
1479
|
-
|
1480
|
-
|
1481
|
-
this.
|
1482
|
-
|
1752
|
+
this.sideEffectManager.add(() => () => this._pageState.destroy());
|
1753
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1754
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1755
|
+
this.addCameraReaction();
|
1756
|
+
this.addSizeReaction();
|
1757
|
+
this.sideEffectManager.add(() => emitter.on("memberStateChange", this.onMemberStateChange));
|
1758
|
+
this.sideEffectManager.add(() => [
|
1759
|
+
this.syncCamera$.reaction((syncCamera) => {
|
1760
|
+
if (!syncCamera) {
|
1761
|
+
if (this.viewSync) {
|
1762
|
+
this.viewSync.destroy();
|
1763
|
+
this.viewSync = void 0;
|
1764
|
+
this.sideEffectManager.flush("camera");
|
1765
|
+
this.sideEffectManager.flush("size");
|
1766
|
+
}
|
1767
|
+
}
|
1768
|
+
}),
|
1769
|
+
this.whiteBoardViewCreated$.reaction((created) => {
|
1770
|
+
if (created && this.box) {
|
1771
|
+
if (!this.syncCamera$.value)
|
1772
|
+
return;
|
1773
|
+
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
1774
|
+
if (box && view) {
|
1775
|
+
if (!this.camera$.value) {
|
1776
|
+
this.storeCamera({
|
1777
|
+
centerX: null,
|
1778
|
+
centerY: null,
|
1779
|
+
scale: 1,
|
1780
|
+
id: this.uid
|
1781
|
+
});
|
1782
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1783
|
+
}
|
1784
|
+
if (!this.size$.value && box.stageRect) {
|
1785
|
+
const initialRect = this.computedInitialRect(box.stageRect);
|
1786
|
+
const width = (initialRect == null ? void 0 : initialRect.width) || box.stageRect.width;
|
1787
|
+
const height = (initialRect == null ? void 0 : initialRect.height) || box.stageRect.height;
|
1788
|
+
this.storeSize({
|
1789
|
+
id: this.uid,
|
1790
|
+
width,
|
1791
|
+
height
|
1792
|
+
});
|
1793
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1794
|
+
}
|
1795
|
+
this.viewSync = new ViewSync({
|
1796
|
+
uid: this.uid,
|
1797
|
+
view$: this.view$,
|
1798
|
+
camera$: this.camera$,
|
1799
|
+
size$: this.size$,
|
1800
|
+
stageRect$: box._stageRect$,
|
1801
|
+
storeCamera: this.storeCamera,
|
1802
|
+
storeSize: this.storeSize
|
1803
|
+
});
|
1804
|
+
this.sideEffectManager.add(() => () => {
|
1805
|
+
var _a2;
|
1806
|
+
return (_a2 = this.viewSync) == null ? void 0 : _a2.destroy();
|
1807
|
+
});
|
1808
|
+
this.whiteBoardViewCreated$.destroy();
|
1809
|
+
}
|
1810
|
+
});
|
1811
|
+
}
|
1812
|
+
}),
|
1813
|
+
this.manager.members$.reaction((members) => {
|
1483
1814
|
this.appEmitter.emit("roomMembersChange", members);
|
1484
|
-
})
|
1485
|
-
|
1815
|
+
})
|
1816
|
+
]);
|
1486
1817
|
}
|
1487
1818
|
createAppDir() {
|
1488
1819
|
const scenePath = this.scenePath || this.appScenePath;
|
@@ -1510,7 +1841,7 @@ class AppProxy {
|
|
1510
1841
|
}
|
1511
1842
|
}
|
1512
1843
|
get view() {
|
1513
|
-
return this.
|
1844
|
+
return this.view$.value;
|
1514
1845
|
}
|
1515
1846
|
get viewIndex() {
|
1516
1847
|
var _a;
|
@@ -1540,7 +1871,7 @@ class AppProxy {
|
|
1540
1871
|
return fullPath;
|
1541
1872
|
}
|
1542
1873
|
setFullPath(path) {
|
1543
|
-
this.
|
1874
|
+
this.store.updateAppAttributes(this.id, Fields.FullPath, path);
|
1544
1875
|
}
|
1545
1876
|
async baseInsertApp(skipUpdate = false) {
|
1546
1877
|
var _a;
|
@@ -1562,8 +1893,7 @@ class AppProxy {
|
|
1562
1893
|
};
|
1563
1894
|
}
|
1564
1895
|
get box() {
|
1565
|
-
|
1566
|
-
return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
|
1896
|
+
return this.box$.value;
|
1567
1897
|
}
|
1568
1898
|
async setupApp(appId, skipUpdate, app, options, appOptions) {
|
1569
1899
|
var _a;
|
@@ -1571,7 +1901,7 @@ class AppProxy {
|
|
1571
1901
|
if (!this.boxManager) {
|
1572
1902
|
throw new BoxManagerNotFoundError();
|
1573
1903
|
}
|
1574
|
-
const context = new AppContext(this.manager,
|
1904
|
+
const context = new AppContext(this.manager, appId, this, appOptions);
|
1575
1905
|
this.appContext = context;
|
1576
1906
|
try {
|
1577
1907
|
emitter.once(`${appId}${Events.WindowCreated}`).then(async () => {
|
@@ -1589,17 +1919,27 @@ class AppProxy {
|
|
1589
1919
|
this.appResult = result;
|
1590
1920
|
appRegister.notifyApp(this.kind, "created", { appId, result });
|
1591
1921
|
this.fixMobileSize();
|
1922
|
+
this.setupDone();
|
1592
1923
|
}, SETUP_APP_DELAY);
|
1593
1924
|
});
|
1594
|
-
(_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1925
|
+
const box = (_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1595
1926
|
appId,
|
1596
1927
|
app,
|
1597
1928
|
options,
|
1598
1929
|
canOperate: this.manager.canOperate,
|
1599
1930
|
smartPosition: this.isAddApp
|
1600
1931
|
});
|
1932
|
+
const registerParams = appRegister.registered.get(this.kind);
|
1933
|
+
if (registerParams == null ? void 0 : registerParams.contentStyles) {
|
1934
|
+
box == null ? void 0 : box.mountUserStyles(registerParams.contentStyles);
|
1935
|
+
}
|
1936
|
+
this.box$.setValue(box);
|
1601
1937
|
if (this.isAddApp && this.box) {
|
1602
1938
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
1939
|
+
this.store.updateAppState(appId, AppAttributes.Size, {
|
1940
|
+
width: this.box.intrinsicWidth,
|
1941
|
+
height: this.box.intrinsicHeight
|
1942
|
+
});
|
1603
1943
|
this.boxManager.focusBox({ appId }, false);
|
1604
1944
|
}
|
1605
1945
|
} catch (error) {
|
@@ -1611,12 +1951,14 @@ class AppProxy {
|
|
1611
1951
|
var _a, _b;
|
1612
1952
|
const box = (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
|
1613
1953
|
if (box) {
|
1614
|
-
(
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1954
|
+
if (!box.minimized) {
|
1955
|
+
(_b = this.boxManager) == null ? void 0 : _b.resizeBox({
|
1956
|
+
appId: this.id,
|
1957
|
+
width: box.intrinsicWidth + 1e-3,
|
1958
|
+
height: box.intrinsicHeight + 1e-3,
|
1959
|
+
skipUpdate: true
|
1960
|
+
});
|
1961
|
+
}
|
1620
1962
|
}
|
1621
1963
|
}
|
1622
1964
|
async onSeek(time2) {
|
@@ -1718,6 +2060,8 @@ class AppProxy {
|
|
1718
2060
|
}
|
1719
2061
|
}
|
1720
2062
|
setViewFocusScenePath() {
|
2063
|
+
if (this.status === "destroyed")
|
2064
|
+
return;
|
1721
2065
|
const fullPath = this.getFullScenePath();
|
1722
2066
|
if (fullPath && this.view) {
|
1723
2067
|
setViewFocusScenePath(this.view, fullPath);
|
@@ -1726,6 +2070,7 @@ class AppProxy {
|
|
1726
2070
|
}
|
1727
2071
|
createView() {
|
1728
2072
|
const view = this.viewManager.createView(this.id);
|
2073
|
+
this.view$.setValue(view);
|
1729
2074
|
this.setViewFocusScenePath();
|
1730
2075
|
return view;
|
1731
2076
|
}
|
@@ -1761,21 +2106,24 @@ class AppProxy {
|
|
1761
2106
|
const fullPath = this._pageState.getFullPath(index2);
|
1762
2107
|
if (fullPath) {
|
1763
2108
|
this.setFullPath(fullPath);
|
2109
|
+
setScenePath(this.manager.room, fullPath);
|
1764
2110
|
}
|
1765
2111
|
}
|
1766
2112
|
}
|
1767
2113
|
async destroy(needCloseBox, cleanAttrs, skipUpdate, error) {
|
1768
|
-
var _a
|
2114
|
+
var _a;
|
1769
2115
|
if (this.status === "destroyed")
|
1770
2116
|
return;
|
1771
2117
|
this.status = "destroyed";
|
1772
2118
|
try {
|
1773
2119
|
await appRegister.notifyApp(this.kind, "destroy", { appId: this.id });
|
2120
|
+
callbacks$1.emit("appClose", { appId: this.id, kind: this.kind, error });
|
1774
2121
|
await this.appEmitter.emit("destroy", { error });
|
1775
2122
|
} catch (error2) {
|
1776
2123
|
console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
|
1777
2124
|
}
|
1778
2125
|
this.appEmitter.clearListeners();
|
2126
|
+
this.sideEffectManager.flushAll();
|
1779
2127
|
emitter.emit(`destroy-${this.id}`, { error });
|
1780
2128
|
if (needCloseBox) {
|
1781
2129
|
(_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
|
@@ -1789,11 +2137,7 @@ class AppProxy {
|
|
1789
2137
|
this.appProxies.delete(this.id);
|
1790
2138
|
this.viewManager.destroyView(this.id);
|
1791
2139
|
this.manager.appStatus.delete(this.id);
|
1792
|
-
|
1793
|
-
(_c = this.manager.refresher) == null ? void 0 : _c.remove(this.stateKey);
|
1794
|
-
(_d = this.manager.refresher) == null ? void 0 : _d.remove(`${this.id}-fullPath`);
|
1795
|
-
this._prevFullPath = void 0;
|
1796
|
-
this.sideEffectManager.flushAll();
|
2140
|
+
this.valManager.destroy();
|
1797
2141
|
}
|
1798
2142
|
close() {
|
1799
2143
|
return this.destroy(true, true, false);
|
@@ -1849,102 +2193,84 @@ const setDefaultCameraBound = (view) => {
|
|
1849
2193
|
minContentMode: () => 0.1
|
1850
2194
|
});
|
1851
2195
|
};
|
1852
|
-
class CameraSynchronizer {
|
1853
|
-
constructor(saveCamera) {
|
1854
|
-
this.saveCamera = saveCamera;
|
1855
|
-
this.onRemoteUpdate = throttle((camera, size2) => {
|
1856
|
-
this.remoteCamera = camera;
|
1857
|
-
this.remoteSize = size2;
|
1858
|
-
if (this.remoteSize && this.rect) {
|
1859
|
-
let scale2;
|
1860
|
-
if (size2.width < size2.height) {
|
1861
|
-
scale2 = this.rect.width / size2.width;
|
1862
|
-
} else {
|
1863
|
-
scale2 = this.rect.height / size2.height;
|
1864
|
-
}
|
1865
|
-
const nextScale = camera.scale * scale2;
|
1866
|
-
const moveCamera = () => {
|
1867
|
-
var _a;
|
1868
|
-
return (_a = this.view) == null ? void 0 : _a.moveCamera({
|
1869
|
-
centerX: camera.centerX,
|
1870
|
-
centerY: camera.centerY,
|
1871
|
-
scale: nextScale,
|
1872
|
-
animationMode: AnimationMode.Immediately
|
1873
|
-
});
|
1874
|
-
};
|
1875
|
-
delay(moveCamera, 10);
|
1876
|
-
}
|
1877
|
-
}, 50);
|
1878
|
-
}
|
1879
|
-
setRect(rect) {
|
1880
|
-
this.rect = rect;
|
1881
|
-
if (this.remoteCamera && this.remoteSize) {
|
1882
|
-
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1883
|
-
}
|
1884
|
-
}
|
1885
|
-
setView(view) {
|
1886
|
-
this.view = view;
|
1887
|
-
}
|
1888
|
-
onLocalCameraUpdate(camera) {
|
1889
|
-
this.saveCamera(camera);
|
1890
|
-
}
|
1891
|
-
onLocalSizeUpdate(size2) {
|
1892
|
-
if (this.rect && this.view) {
|
1893
|
-
const scale2 = this.rect.width / size2.width;
|
1894
|
-
const nextScale = this.view.camera.scale * scale2;
|
1895
|
-
this.view.moveCamera({
|
1896
|
-
scale: nextScale,
|
1897
|
-
animationMode: AnimationMode.Immediately
|
1898
|
-
});
|
1899
|
-
}
|
1900
|
-
}
|
1901
|
-
}
|
1902
2196
|
class MainViewProxy {
|
1903
2197
|
constructor(manager) {
|
1904
|
-
var _a;
|
1905
2198
|
this.manager = manager;
|
1906
2199
|
this.started = false;
|
1907
2200
|
this.mainViewIsAddListener = false;
|
1908
2201
|
this.store = this.manager.store;
|
1909
2202
|
this.sideEffectManager = new SideEffectManager();
|
1910
|
-
this.
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
2203
|
+
this.camera$ = new Val(void 0);
|
2204
|
+
this.size$ = new Val(void 0);
|
2205
|
+
this.view$ = new Val(void 0);
|
2206
|
+
this.createViewSync = () => {
|
2207
|
+
var _a;
|
2208
|
+
if (this.manager.boxManager && !this.viewSync) {
|
2209
|
+
this.viewSync = new ViewSync({
|
2210
|
+
uid: this.manager.uid,
|
2211
|
+
view$: this.view$,
|
2212
|
+
camera$: this.camera$,
|
2213
|
+
size$: this.size$,
|
2214
|
+
stageRect$: (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect$,
|
2215
|
+
viewMode$: this.manager.windowManger.viewMode$,
|
2216
|
+
storeCamera: this.storeCamera,
|
2217
|
+
storeSize: this.storeSize
|
1916
2218
|
});
|
1917
|
-
}
|
2219
|
+
}
|
2220
|
+
};
|
2221
|
+
this.startListenWritableChange = () => {
|
2222
|
+
this.sideEffectManager.add(() => emitter.on("writableChange", (isWritable) => {
|
2223
|
+
if (isWritable) {
|
2224
|
+
this.ensureCameraAndSize();
|
2225
|
+
}
|
2226
|
+
}));
|
1918
2227
|
};
|
1919
2228
|
this.addCameraReaction = () => {
|
1920
|
-
|
1921
|
-
|
2229
|
+
this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
|
2230
|
+
this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
|
2231
|
+
};
|
2232
|
+
this.storeCurrentCamera = () => {
|
2233
|
+
const iCamera = this.view.camera;
|
2234
|
+
this.storeCamera(__spreadValues({
|
2235
|
+
id: this.manager.uid
|
2236
|
+
}, iCamera));
|
2237
|
+
};
|
2238
|
+
this.storeCurrentSize = () => {
|
2239
|
+
var _a;
|
2240
|
+
const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2241
|
+
if (rect) {
|
2242
|
+
this.storeSize({
|
2243
|
+
id: this.manager.uid,
|
2244
|
+
width: rect.width,
|
2245
|
+
height: rect.height
|
2246
|
+
});
|
2247
|
+
}
|
2248
|
+
};
|
2249
|
+
this.storeCamera = (camera) => {
|
2250
|
+
this.store.setMainViewCamera(camera);
|
2251
|
+
};
|
2252
|
+
this.storeSize = (size2) => {
|
2253
|
+
this.store.setMainViewSize(size2);
|
1922
2254
|
};
|
1923
2255
|
this.cameraReaction = () => {
|
1924
2256
|
return reaction(() => this.mainViewCamera, (camera) => {
|
1925
|
-
if (camera
|
1926
|
-
|
2257
|
+
if (camera) {
|
2258
|
+
const rawCamera = toJS(camera);
|
2259
|
+
if (!isEqual(rawCamera, this.camera$.value)) {
|
2260
|
+
this.camera$.setValue(rawCamera);
|
2261
|
+
}
|
1927
2262
|
}
|
1928
2263
|
}, { fireImmediately: true });
|
1929
2264
|
};
|
1930
|
-
this.
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
this.setCameraAndSize();
|
1940
|
-
}
|
1941
|
-
};
|
1942
|
-
this.onCameraUpdatedByDevice = (camera) => {
|
1943
|
-
this.synchronizer.onLocalCameraUpdate(camera);
|
1944
|
-
const size2 = this.getStageSize();
|
1945
|
-
if (size2 && !isEqual(size2, this.mainViewSize)) {
|
1946
|
-
this.setMainViewSize(size2);
|
1947
|
-
}
|
2265
|
+
this.sizeReaction = () => {
|
2266
|
+
return reaction(() => this.mainViewSize, (size2) => {
|
2267
|
+
if (size2) {
|
2268
|
+
const rawSize = toJS(size2);
|
2269
|
+
if (!isEqual(rawSize, this.size$.value)) {
|
2270
|
+
this.size$.setValue(rawSize);
|
2271
|
+
}
|
2272
|
+
}
|
2273
|
+
}, { fireImmediately: true });
|
1948
2274
|
};
|
1949
2275
|
this.mainViewClickListener = () => {
|
1950
2276
|
this.mainViewClickHandler();
|
@@ -1955,40 +2281,43 @@ class MainViewProxy {
|
|
1955
2281
|
this.onCameraOrSizeUpdated = () => {
|
1956
2282
|
callbacks$1.emit("cameraStateChange", this.cameraState);
|
1957
2283
|
};
|
1958
|
-
this.synchronizer = new CameraSynchronizer((camera) => this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid })));
|
1959
2284
|
this.mainView = this.createMainView();
|
1960
|
-
this.moveCameraSizeByAttributes();
|
1961
2285
|
emitter.once("mainViewMounted").then(() => {
|
1962
2286
|
this.addMainViewListener();
|
1963
2287
|
this.start();
|
1964
2288
|
this.ensureCameraAndSize();
|
1965
2289
|
this.startListenWritableChange();
|
1966
2290
|
});
|
1967
|
-
this.sideEffectManager.add(() =>
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
2291
|
+
this.sideEffectManager.add(() => [
|
2292
|
+
emitter.on("startReconnect", () => {
|
2293
|
+
releaseView(this.mainView);
|
2294
|
+
})
|
2295
|
+
]);
|
2296
|
+
this.createViewSync();
|
2297
|
+
this.sideEffectManager.add(() => emitter.on("focusedChange", ({ focused }) => {
|
2298
|
+
if (focused === void 0) {
|
2299
|
+
const scenePath = this.store.getMainViewScenePath();
|
2300
|
+
if (scenePath) {
|
2301
|
+
setScenePath(this.manager.room, scenePath);
|
1974
2302
|
}
|
1975
|
-
}
|
1976
|
-
});
|
1977
|
-
const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
1978
|
-
if (rect) {
|
1979
|
-
this.synchronizer.setRect(rect);
|
1980
|
-
}
|
1981
|
-
this.sideEffectManager.add(() => {
|
1982
|
-
return emitter.on("playgroundSizeChange", (rect2) => {
|
1983
|
-
this.synchronizer.setRect(rect2);
|
1984
|
-
this.synchronizer.onLocalSizeUpdate(rect2);
|
1985
|
-
});
|
1986
|
-
});
|
2303
|
+
}
|
2304
|
+
}));
|
1987
2305
|
}
|
1988
2306
|
ensureCameraAndSize() {
|
2307
|
+
var _a;
|
1989
2308
|
if (!this.mainViewCamera || !this.mainViewSize) {
|
1990
2309
|
this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
|
1991
|
-
this.
|
2310
|
+
this.storeCamera(__spreadValues({
|
2311
|
+
id: this.manager.uid
|
2312
|
+
}, this.view.camera));
|
2313
|
+
const stageRect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2314
|
+
if (stageRect && !this.mainViewSize) {
|
2315
|
+
this.storeSize({
|
2316
|
+
id: this.manager.uid,
|
2317
|
+
width: stageRect.width,
|
2318
|
+
height: stageRect.height
|
2319
|
+
});
|
2320
|
+
}
|
1992
2321
|
}
|
1993
2322
|
}
|
1994
2323
|
get mainViewCamera() {
|
@@ -2000,25 +2329,13 @@ class MainViewProxy {
|
|
2000
2329
|
get didRelease() {
|
2001
2330
|
return get(this.view, ["didRelease"]);
|
2002
2331
|
}
|
2003
|
-
moveCameraSizeByAttributes() {
|
2004
|
-
this.synchronizer.onRemoteUpdate(this.mainViewCamera, this.mainViewSize);
|
2005
|
-
}
|
2006
2332
|
start() {
|
2007
2333
|
if (this.started)
|
2008
2334
|
return;
|
2009
|
-
this.sizeChangeHandler(this.mainViewSize);
|
2010
2335
|
this.addCameraListener();
|
2011
2336
|
this.addCameraReaction();
|
2012
2337
|
this.started = true;
|
2013
2338
|
}
|
2014
|
-
setCameraAndSize() {
|
2015
|
-
const stageSize = this.getStageSize();
|
2016
|
-
if (stageSize) {
|
2017
|
-
const camera = __spreadProps(__spreadValues({}, this.mainView.camera), { id: this.manager.uid });
|
2018
|
-
const size2 = __spreadProps(__spreadValues({}, stageSize), { id: this.manager.uid });
|
2019
|
-
this.store.setMainViewCameraAndSize(camera, size2);
|
2020
|
-
}
|
2021
|
-
}
|
2022
2339
|
get view() {
|
2023
2340
|
return this.mainView;
|
2024
2341
|
}
|
@@ -2031,7 +2348,7 @@ class MainViewProxy {
|
|
2031
2348
|
if (mainViewScenePath) {
|
2032
2349
|
setViewFocusScenePath(mainView, mainViewScenePath);
|
2033
2350
|
}
|
2034
|
-
this.
|
2351
|
+
this.view$.setValue(mainView);
|
2035
2352
|
return mainView;
|
2036
2353
|
}
|
2037
2354
|
onReconnect() {
|
@@ -2050,24 +2367,17 @@ class MainViewProxy {
|
|
2050
2367
|
rebind() {
|
2051
2368
|
const divElement = this.mainView.divElement;
|
2052
2369
|
const disableCameraTransform = this.mainView.disableCameraTransform;
|
2370
|
+
const camera = __spreadValues({}, this.mainView.camera);
|
2053
2371
|
this.stop();
|
2054
|
-
|
2055
|
-
this.mainView.release();
|
2056
|
-
}
|
2372
|
+
releaseView(this.mainView);
|
2057
2373
|
this.removeMainViewListener();
|
2058
2374
|
this.mainView = this.createMainView();
|
2059
2375
|
this.mainView.disableCameraTransform = disableCameraTransform;
|
2060
2376
|
this.mainView.divElement = divElement;
|
2377
|
+
this.mainView.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: AnimationMode.Immediately }));
|
2061
2378
|
this.addMainViewListener();
|
2062
2379
|
this.start();
|
2063
2380
|
}
|
2064
|
-
getStageSize() {
|
2065
|
-
var _a;
|
2066
|
-
const stage = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2067
|
-
if (stage) {
|
2068
|
-
return { width: stage.width, height: stage.height };
|
2069
|
-
}
|
2070
|
-
}
|
2071
2381
|
addMainViewListener() {
|
2072
2382
|
if (this.mainViewIsAddListener)
|
2073
2383
|
return;
|
@@ -2092,23 +2402,23 @@ class MainViewProxy {
|
|
2092
2402
|
(_a = this.manager.boxManager) == null ? void 0 : _a.blurAllBox();
|
2093
2403
|
}
|
2094
2404
|
addCameraListener() {
|
2095
|
-
this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
2096
2405
|
this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
|
2097
2406
|
this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
|
2098
2407
|
}
|
2099
2408
|
removeCameraListener() {
|
2100
|
-
this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
2101
2409
|
this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
|
2102
2410
|
this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
|
2103
2411
|
}
|
2104
2412
|
stop() {
|
2105
|
-
var _a, _b;
|
2106
2413
|
this.removeCameraListener();
|
2107
|
-
|
2108
|
-
|
2414
|
+
this.manager.refresher.remove(Fields.MainViewCamera);
|
2415
|
+
this.manager.refresher.remove(Fields.MainViewSize);
|
2109
2416
|
this.started = false;
|
2110
2417
|
}
|
2111
2418
|
destroy() {
|
2419
|
+
this.camera$.destroy();
|
2420
|
+
this.size$.destroy();
|
2421
|
+
this.view$.destroy();
|
2112
2422
|
this.removeMainViewListener();
|
2113
2423
|
this.stop();
|
2114
2424
|
this.sideEffectManager.flushAll();
|
@@ -2183,6 +2493,9 @@ class AppManager {
|
|
2183
2493
|
this.mainViewScenesLength = 0;
|
2184
2494
|
this.callbacksNode = null;
|
2185
2495
|
this.appCreateQueue = new AppCreateQueue();
|
2496
|
+
this.sceneIndex$ = new Val(void 0);
|
2497
|
+
this.focused$ = new Val(void 0);
|
2498
|
+
this.members$ = new Val([]);
|
2186
2499
|
this.sideEffectManager = new SideEffectManager();
|
2187
2500
|
this.sceneState = null;
|
2188
2501
|
this.rootDirRemoving = false;
|
@@ -2202,7 +2515,7 @@ class AppManager {
|
|
2202
2515
|
sceneName = (_b = this.callbacksNode) == null ? void 0 : _b.scenes[nextIndex];
|
2203
2516
|
}
|
2204
2517
|
if (sceneName) {
|
2205
|
-
this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
|
2518
|
+
await this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
|
2206
2519
|
}
|
2207
2520
|
await this.setMainViewSceneIndex(nextIndex);
|
2208
2521
|
} else {
|
@@ -2334,8 +2647,7 @@ class AppManager {
|
|
2334
2647
|
this.dispatchInternalEvent(Events.AppBoxStateChange, payload);
|
2335
2648
|
};
|
2336
2649
|
this.addAppsChangeListener = () => {
|
2337
|
-
|
2338
|
-
(_a = this.refresher) == null ? void 0 : _a.add("apps", () => {
|
2650
|
+
this.refresher.add("apps", () => {
|
2339
2651
|
return safeListenPropsUpdated(() => this.attributes.apps, () => {
|
2340
2652
|
this.attributesUpdateCallback(this.attributes.apps);
|
2341
2653
|
});
|
@@ -2350,26 +2662,27 @@ class AppManager {
|
|
2350
2662
|
});
|
2351
2663
|
};
|
2352
2664
|
this.onMainViewIndexChange = (index2) => {
|
2353
|
-
if (index2 !== void 0 && this.
|
2665
|
+
if (index2 !== void 0 && this.sceneIndex$.value !== index2) {
|
2354
2666
|
callbacks$1.emit("mainViewSceneIndexChange", index2);
|
2355
2667
|
emitter.emit("changePageState");
|
2356
2668
|
if (this.callbacksNode) {
|
2357
2669
|
this.updateSceneState(this.callbacksNode);
|
2358
2670
|
}
|
2359
|
-
this.
|
2671
|
+
this.sceneIndex$.setValue(index2);
|
2360
2672
|
}
|
2361
2673
|
};
|
2362
2674
|
this.onFocusChange = (focused) => {
|
2363
2675
|
var _a;
|
2364
|
-
if (this.
|
2676
|
+
if (this.focused$.value !== focused) {
|
2365
2677
|
callbacks$1.emit("focusedChange", focused);
|
2366
|
-
emitter.emit("focusedChange", { focused, prev: this.
|
2367
|
-
this.
|
2678
|
+
emitter.emit("focusedChange", { focused, prev: this.focused$.value });
|
2679
|
+
this.focused$.setValue(focused);
|
2368
2680
|
if (focused !== void 0) {
|
2369
2681
|
(_a = this.boxManager) == null ? void 0 : _a.focusBox({ appId: focused });
|
2370
2682
|
setTimeout(() => {
|
2371
2683
|
const appProxy = this.appProxies.get(focused);
|
2372
2684
|
if (appProxy) {
|
2685
|
+
appProxy.onFocus();
|
2373
2686
|
appRegister.notifyApp(appProxy.kind, "focus", { appId: focused });
|
2374
2687
|
}
|
2375
2688
|
}, 0);
|
@@ -2411,7 +2724,7 @@ class AppManager {
|
|
2411
2724
|
}
|
2412
2725
|
};
|
2413
2726
|
this.closeAll = async () => {
|
2414
|
-
for (const [
|
2727
|
+
for (const [_, appProxy] of this.appProxies.entries()) {
|
2415
2728
|
await appProxy.destroy(true, false, true);
|
2416
2729
|
}
|
2417
2730
|
};
|
@@ -2430,14 +2743,17 @@ class AppManager {
|
|
2430
2743
|
appProxy.appEmitter.emit("roomStateChange", state);
|
2431
2744
|
});
|
2432
2745
|
if (state.roomMembers) {
|
2433
|
-
|
2746
|
+
this.members$.setValue(serializeRoomMembers(state.roomMembers));
|
2434
2747
|
}
|
2435
2748
|
emitter.emit("observerIdChange", this.displayer.observerId);
|
2749
|
+
if (state.memberState) {
|
2750
|
+
emitter.emit("memberStateChange", toJS(state.memberState));
|
2751
|
+
}
|
2436
2752
|
};
|
2437
2753
|
this.displayerWritableListener = (isReadonly) => {
|
2438
2754
|
var _a, _b;
|
2439
2755
|
const isWritable = !isReadonly;
|
2440
|
-
const isManualWritable = this.windowManger.readonly === void 0 || this.windowManger.readonly
|
2756
|
+
const isManualWritable = this.windowManger.readonly === void 0 || !this.windowManger.readonly;
|
2441
2757
|
if (this.windowManger.readonly === void 0) {
|
2442
2758
|
(_a = this.boxManager) == null ? void 0 : _a.setReadonly(isReadonly);
|
2443
2759
|
} else {
|
@@ -2446,13 +2762,10 @@ class AppManager {
|
|
2446
2762
|
this.appProxies.forEach((appProxy) => {
|
2447
2763
|
appProxy.emitAppIsWritableChange();
|
2448
2764
|
});
|
2449
|
-
if (isWritable
|
2450
|
-
this.mainView.disableCameraTransform = false;
|
2765
|
+
if (isWritable) {
|
2451
2766
|
if (this.room && this.room.disableSerialization === true) {
|
2452
2767
|
this.room.disableSerialization = false;
|
2453
2768
|
}
|
2454
|
-
} else {
|
2455
|
-
this.mainView.disableCameraTransform = true;
|
2456
2769
|
}
|
2457
2770
|
emitter.emit("writableChange", isWritable);
|
2458
2771
|
};
|
@@ -2508,9 +2821,10 @@ class AppManager {
|
|
2508
2821
|
appRegister.setSyncRegisterApp((payload) => {
|
2509
2822
|
this.safeUpdateAttributes([Fields.Registered, payload.kind], payload);
|
2510
2823
|
});
|
2824
|
+
this.members$.setValue(serializeRoomMembers(this.displayer.state.roomMembers));
|
2511
2825
|
}
|
2512
2826
|
async onRootDirRemoved(needClose = true) {
|
2513
|
-
this.setMainViewScenePath(INIT_DIR);
|
2827
|
+
await this.setMainViewScenePath(INIT_DIR);
|
2514
2828
|
this.createRootDirScenesCallback();
|
2515
2829
|
for (const [id2, appProxy] of this.appProxies.entries()) {
|
2516
2830
|
if (appProxy.view) {
|
@@ -2518,7 +2832,7 @@ class AppManager {
|
|
2518
2832
|
}
|
2519
2833
|
}
|
2520
2834
|
this.mainViewProxy.rebind();
|
2521
|
-
emitter.emit("rootDirRemoved");
|
2835
|
+
await emitter.emit("rootDirRemoved");
|
2522
2836
|
this.updateRootDirRemoving(false);
|
2523
2837
|
}
|
2524
2838
|
get eventName() {
|
@@ -2545,9 +2859,6 @@ class AppManager {
|
|
2545
2859
|
var _a;
|
2546
2860
|
return ((_a = this.room) == null ? void 0 : _a.uid) || "";
|
2547
2861
|
}
|
2548
|
-
get members() {
|
2549
|
-
return serializeRoomMembers(this.displayer.state.roomMembers);
|
2550
|
-
}
|
2551
2862
|
getMainViewSceneDir() {
|
2552
2863
|
const scenePath = this.store.getMainViewScenePath();
|
2553
2864
|
if (scenePath) {
|
@@ -2557,7 +2868,7 @@ class AppManager {
|
|
2557
2868
|
}
|
2558
2869
|
}
|
2559
2870
|
async onCreated() {
|
2560
|
-
var _a
|
2871
|
+
var _a;
|
2561
2872
|
await this.attributesUpdateCallback(this.attributes.apps);
|
2562
2873
|
emitter.emit("updateManagerRect");
|
2563
2874
|
boxEmitter.on("move", this.onBoxMove);
|
@@ -2567,32 +2878,32 @@ class AppManager {
|
|
2567
2878
|
boxEmitter.on("boxStateChange", this.onBoxStateChange);
|
2568
2879
|
this.addAppsChangeListener();
|
2569
2880
|
this.addAppCloseListener();
|
2570
|
-
|
2881
|
+
this.refresher.add("maximized", () => {
|
2571
2882
|
return autorun(() => {
|
2572
2883
|
var _a2;
|
2573
2884
|
const maximized = this.attributes.maximized;
|
2574
2885
|
(_a2 = this.boxManager) == null ? void 0 : _a2.setMaximized(Boolean(maximized));
|
2575
2886
|
});
|
2576
2887
|
});
|
2577
|
-
|
2888
|
+
this.refresher.add("minimized", () => {
|
2578
2889
|
return autorun(() => {
|
2579
2890
|
const minimized = this.attributes.minimized;
|
2580
2891
|
this.onMinimized(minimized);
|
2581
2892
|
});
|
2582
2893
|
});
|
2583
|
-
|
2894
|
+
this.refresher.add("mainViewIndex", () => {
|
2584
2895
|
return autorun(() => {
|
2585
2896
|
const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
|
2586
2897
|
this.onMainViewIndexChange(mainSceneIndex);
|
2587
2898
|
});
|
2588
2899
|
});
|
2589
|
-
|
2900
|
+
this.refresher.add("focusedChange", () => {
|
2590
2901
|
return autorun(() => {
|
2591
2902
|
const focused = get(this.attributes, "focus");
|
2592
2903
|
this.onFocusChange(focused);
|
2593
2904
|
});
|
2594
2905
|
});
|
2595
|
-
|
2906
|
+
this.refresher.add("registeredChange", () => {
|
2596
2907
|
return autorun(() => {
|
2597
2908
|
const registered = get(this.attributes, Fields.Registered);
|
2598
2909
|
this.onRegisteredChange(registered);
|
@@ -2604,9 +2915,9 @@ class AppManager {
|
|
2604
2915
|
return;
|
2605
2916
|
this.resetScenePath(mainScenePath);
|
2606
2917
|
}
|
2607
|
-
this.displayerWritableListener(!((
|
2918
|
+
this.displayerWritableListener(!((_a = this.room) == null ? void 0 : _a.isWritable));
|
2608
2919
|
this.displayer.callbacks.on("onEnableWriteNowChanged", this.displayerWritableListener);
|
2609
|
-
this.
|
2920
|
+
this.focused$.setValue(this.attributes.focus);
|
2610
2921
|
this.sideEffectManager.add(() => {
|
2611
2922
|
const redoUndo = new RedoUndo({
|
2612
2923
|
mainView: () => this.mainViewProxy.view,
|
@@ -2623,13 +2934,17 @@ class AppManager {
|
|
2623
2934
|
this.appCreateQueue.emitReady();
|
2624
2935
|
}
|
2625
2936
|
const appsWithCreatedAt = appIds.map((appId) => {
|
2626
|
-
|
2627
|
-
|
2628
|
-
|
2629
|
-
|
2937
|
+
if (apps[appId].setup) {
|
2938
|
+
return {
|
2939
|
+
id: appId,
|
2940
|
+
createdAt: apps[appId].createdAt
|
2941
|
+
};
|
2942
|
+
} else {
|
2943
|
+
return {};
|
2944
|
+
}
|
2630
2945
|
});
|
2631
2946
|
for (const { id: id2 } of orderBy(appsWithCreatedAt, "createdAt", "asc")) {
|
2632
|
-
if (!this.appProxies.has(id2) && !this.appStatus.has(id2)) {
|
2947
|
+
if (id2 && !this.appProxies.has(id2) && !this.appStatus.has(id2)) {
|
2633
2948
|
const app = apps[id2];
|
2634
2949
|
try {
|
2635
2950
|
const appAttributes = this.attributes[id2];
|
@@ -2657,6 +2972,7 @@ class AppManager {
|
|
2657
2972
|
}
|
2658
2973
|
setBoxManager(boxManager) {
|
2659
2974
|
this.boxManager = boxManager;
|
2975
|
+
this.mainViewProxy.createViewSync();
|
2660
2976
|
}
|
2661
2977
|
resetMaximized() {
|
2662
2978
|
var _a;
|
@@ -2669,11 +2985,13 @@ class AppManager {
|
|
2669
2985
|
bindMainView(divElement, disableCameraTransform) {
|
2670
2986
|
const mainView = this.mainViewProxy.view;
|
2671
2987
|
mainView.disableCameraTransform = disableCameraTransform;
|
2672
|
-
|
2988
|
+
wait(30).then(() => {
|
2989
|
+
mainView.divElement = divElement;
|
2990
|
+
emitter.emit("mainViewMounted");
|
2991
|
+
});
|
2673
2992
|
if (!mainView.focusScenePath) {
|
2674
2993
|
this.setMainViewFocusPath();
|
2675
2994
|
}
|
2676
|
-
emitter.emit("mainViewMounted");
|
2677
2995
|
}
|
2678
2996
|
setMainViewFocusPath(scenePath) {
|
2679
2997
|
var _a;
|
@@ -2824,6 +3142,7 @@ class AppManager {
|
|
2824
3142
|
}
|
2825
3143
|
}
|
2826
3144
|
async onReconnected() {
|
3145
|
+
this.attributesUpdateCallback(this.attributes.apps);
|
2827
3146
|
const appProxies = Array.from(this.appProxies.values());
|
2828
3147
|
const reconnected = appProxies.map((appProxy) => {
|
2829
3148
|
return appProxy.onReconnected();
|
@@ -2855,8 +3174,9 @@ class AppManager {
|
|
2855
3174
|
}
|
2856
3175
|
callbacks$1.clearListeners();
|
2857
3176
|
this.sideEffectManager.flushAll();
|
2858
|
-
this.
|
2859
|
-
this.
|
3177
|
+
this.sceneIndex$.destroy();
|
3178
|
+
this.focused$.destroy();
|
3179
|
+
this.members$.destroy();
|
2860
3180
|
}
|
2861
3181
|
}
|
2862
3182
|
/*! *****************************************************************************
|
@@ -3020,7 +3340,7 @@ var startLoop = function() {
|
|
3020
3340
|
if (!isProcessing)
|
3021
3341
|
onNextFrame(processFrame);
|
3022
3342
|
};
|
3023
|
-
var clamp$
|
3343
|
+
var clamp$2 = function(min, max) {
|
3024
3344
|
return function(v2) {
|
3025
3345
|
return Math.max(Math.min(v2, max), min);
|
3026
3346
|
};
|
@@ -3038,7 +3358,7 @@ var number = {
|
|
3038
3358
|
return v2;
|
3039
3359
|
}
|
3040
3360
|
};
|
3041
|
-
var alpha = __assign(__assign({}, number), { transform: clamp$
|
3361
|
+
var alpha = __assign(__assign({}, number), { transform: clamp$2(0, 1) });
|
3042
3362
|
var scale = __assign(__assign({}, number), { default: 1 });
|
3043
3363
|
var createUnitType = function(unit) {
|
3044
3364
|
return {
|
@@ -3062,7 +3382,7 @@ var progressPercentage = __assign(__assign({}, percent), { parse: function(v2) {
|
|
3062
3382
|
var getValueFromFunctionString = function(value) {
|
3063
3383
|
return value.substring(value.indexOf("(") + 1, value.lastIndexOf(")"));
|
3064
3384
|
};
|
3065
|
-
var clampRgbUnit = clamp$
|
3385
|
+
var clampRgbUnit = clamp$2(0, 255);
|
3066
3386
|
var isRgba = function(v2) {
|
3067
3387
|
return v2.red !== void 0;
|
3068
3388
|
};
|
@@ -3701,190 +4021,423 @@ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
|
|
3701
4021
|
}
|
3702
4022
|
return true;
|
3703
4023
|
};
|
3704
|
-
var
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
3714
|
-
|
3715
|
-
return
|
3716
|
-
}
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
-
|
3725
|
-
|
4024
|
+
var shadowStyles = /* @__PURE__ */ (() => '.tele-fancy-scrollbar {\n overscroll-behavior: contain;\n overflow: auto;\n overflow-y: scroll;\n overflow-y: overlay;\n -webkit-overflow-scrolling: touch;\n -ms-overflow-style: -ms-autohiding-scrollbar;\n scrollbar-width: auto;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar {\n height: 8px;\n width: 8px;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-track {\n background-color: transparent;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb {\n background-color: rgba(68, 78, 96, 0.1);\n background-color: transparent;\n border-radius: 4px;\n transition: background-color 0.4s;\n}\n.tele-fancy-scrollbar:hover::-webkit-scrollbar-thumb {\n background-color: rgba(68, 78, 96, 0.1);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:hover {\n background-color: rgba(68, 78, 96, 0.2);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:active {\n background-color: rgba(68, 78, 96, 0.2);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:vertical {\n min-height: 50px;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:horizontal {\n min-width: 50px;\n}\n.telebox-quarantine {\n all: initial;\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n.telebox-body-wrap {\n color: #191919;\n color: var(--tele-box-color, #191919);\n flex: 1;\n width: 100%;\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n}\n.telebox-content {\n width: 100%;\n height: 100%;\n position: relative;\n background-color: #f9f9f9;\n background-color: var(--tele-manager-container-background, #f9f9f9);\n}\n.telebox-box-stage {\n position: absolute;\n z-index: 1;\n overflow: hidden;\n background-color: #fff;\n background-color: var(--tele-manager-stage-background, #fff);\n box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.08);\n box-shadow: var(--tele-manager-stage-shadow, 0px 0px 16px rgba(0, 0, 0, 0.08));\n}\n.telebox-footer-wrap {\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n color: #191919;\n color: var(--tele-box-footer-color, #191919);\n background-color: #fff;\n background-color: var(--tele-box-footer-background, #fff);\n}\n.telebox-footer-wrap::before {\n content: "";\n display: block;\n flex: 1;\n}\n.telebox-color-scheme-dark {\n color-scheme: dark;\n}\n.telebox-color-scheme-dark .telebox-body-wrap {\n color: #e9e9e9;\n color: var(--tele-box-color-dark, #e9e9e9);\n}\n.telebox-color-scheme-dark .telebox-content {\n background-color: #25282e;\n background-color: var(--tele-manager-container-background-dark, #25282e);\n}\n.telebox-color-scheme-dark .telebox-box-stage {\n background-color: #272a30;\n background-color: var(--tele-manager-stage-background-dark, #272a30);\n box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.24);\n box-shadow: var(--tele-manager-stage-shadow-dark, 0px 0px 16px rgba(0, 0, 0, 0.24));\n}\n.telebox-color-scheme-dark .telebox-footer-wrap {\n color: #e9e9e9;\n color: var(--tele-box-footer-color-dark, #e9e9e9);\n background-color: #383b42;\n background-color: var(--tele-box-footer-background-dark, #383b42);\n}')();
|
4025
|
+
var TELE_BOX_COLOR_SCHEME = /* @__PURE__ */ ((TELE_BOX_COLOR_SCHEME2) => {
|
4026
|
+
TELE_BOX_COLOR_SCHEME2["Light"] = "light";
|
4027
|
+
TELE_BOX_COLOR_SCHEME2["Dark"] = "dark";
|
4028
|
+
TELE_BOX_COLOR_SCHEME2["Auto"] = "auto";
|
4029
|
+
return TELE_BOX_COLOR_SCHEME2;
|
4030
|
+
})(TELE_BOX_COLOR_SCHEME || {});
|
4031
|
+
var TELE_BOX_STATE = /* @__PURE__ */ ((TELE_BOX_STATE2) => {
|
4032
|
+
TELE_BOX_STATE2["Normal"] = "normal";
|
4033
|
+
TELE_BOX_STATE2["Minimized"] = "minimized";
|
4034
|
+
TELE_BOX_STATE2["Maximized"] = "maximized";
|
4035
|
+
return TELE_BOX_STATE2;
|
4036
|
+
})(TELE_BOX_STATE || {});
|
4037
|
+
var TELE_BOX_EVENT = /* @__PURE__ */ ((TELE_BOX_EVENT2) => {
|
4038
|
+
TELE_BOX_EVENT2["DarkMode"] = "dark_mode";
|
4039
|
+
TELE_BOX_EVENT2["PrefersColorScheme"] = "prefers_color_scheme";
|
4040
|
+
TELE_BOX_EVENT2["Close"] = "close";
|
4041
|
+
TELE_BOX_EVENT2["Focus"] = "focus";
|
4042
|
+
TELE_BOX_EVENT2["Blur"] = "blur";
|
4043
|
+
TELE_BOX_EVENT2["IntrinsicMove"] = "intrinsic_move";
|
4044
|
+
TELE_BOX_EVENT2["IntrinsicResize"] = "intrinsic_resize";
|
4045
|
+
TELE_BOX_EVENT2["ZIndex"] = "z_index";
|
4046
|
+
TELE_BOX_EVENT2["State"] = "state";
|
4047
|
+
TELE_BOX_EVENT2["Minimized"] = "minimized";
|
4048
|
+
TELE_BOX_EVENT2["Maximized"] = "maximized";
|
4049
|
+
TELE_BOX_EVENT2["Readonly"] = "readonly";
|
4050
|
+
TELE_BOX_EVENT2["Destroyed"] = "destroyed";
|
4051
|
+
return TELE_BOX_EVENT2;
|
4052
|
+
})(TELE_BOX_EVENT || {});
|
4053
|
+
var TELE_BOX_DELEGATE_EVENT = /* @__PURE__ */ ((TELE_BOX_DELEGATE_EVENT2) => {
|
4054
|
+
TELE_BOX_DELEGATE_EVENT2["Close"] = "close";
|
4055
|
+
TELE_BOX_DELEGATE_EVENT2["Maximize"] = "maximize";
|
4056
|
+
TELE_BOX_DELEGATE_EVENT2["Minimize"] = "minimize";
|
4057
|
+
return TELE_BOX_DELEGATE_EVENT2;
|
4058
|
+
})(TELE_BOX_DELEGATE_EVENT || {});
|
4059
|
+
var TELE_BOX_RESIZE_HANDLE = /* @__PURE__ */ ((TELE_BOX_RESIZE_HANDLE2) => {
|
4060
|
+
TELE_BOX_RESIZE_HANDLE2["North"] = "n";
|
4061
|
+
TELE_BOX_RESIZE_HANDLE2["South"] = "s";
|
4062
|
+
TELE_BOX_RESIZE_HANDLE2["West"] = "w";
|
4063
|
+
TELE_BOX_RESIZE_HANDLE2["East"] = "e";
|
4064
|
+
TELE_BOX_RESIZE_HANDLE2["NorthWest"] = "nw";
|
4065
|
+
TELE_BOX_RESIZE_HANDLE2["NorthEast"] = "ne";
|
4066
|
+
TELE_BOX_RESIZE_HANDLE2["SouthEast"] = "se";
|
4067
|
+
TELE_BOX_RESIZE_HANDLE2["SouthWest"] = "sw";
|
4068
|
+
return TELE_BOX_RESIZE_HANDLE2;
|
4069
|
+
})(TELE_BOX_RESIZE_HANDLE || {});
|
4070
|
+
const TeleBoxDragHandleType = "dh";
|
4071
|
+
function clamp$1(value, min, max) {
|
4072
|
+
return Math.min(Math.max(value, min), max);
|
3726
4073
|
}
|
3727
|
-
function
|
3728
|
-
|
4074
|
+
function preventEvent$1(ev) {
|
4075
|
+
ev.stopPropagation();
|
4076
|
+
if (ev.cancelable) {
|
4077
|
+
ev.preventDefault();
|
4078
|
+
}
|
3729
4079
|
}
|
3730
|
-
|
3731
|
-
|
4080
|
+
let defaultBoxCount = 1;
|
4081
|
+
function getBoxDefaultName() {
|
4082
|
+
return `New Box ${defaultBoxCount++}`;
|
3732
4083
|
}
|
3733
|
-
class
|
3734
|
-
constructor({
|
3735
|
-
|
3736
|
-
|
3737
|
-
|
3738
|
-
|
3739
|
-
|
3740
|
-
|
3741
|
-
|
4084
|
+
class DefaultTitleBar {
|
4085
|
+
constructor({
|
4086
|
+
readonly$,
|
4087
|
+
state$,
|
4088
|
+
title$,
|
4089
|
+
buttons,
|
4090
|
+
onEvent,
|
4091
|
+
onDragStart,
|
4092
|
+
namespace = "telebox"
|
4093
|
+
}) {
|
4094
|
+
this.sideEffect = new SideEffectManager();
|
4095
|
+
this.lastTitleBarClick = {
|
4096
|
+
timestamp: 0,
|
4097
|
+
clientX: -100,
|
4098
|
+
clientY: -100
|
4099
|
+
};
|
4100
|
+
this.handleTitleBarClick = (ev) => {
|
4101
|
+
var _a;
|
4102
|
+
if (!ev.isPrimary || this.readonly$.value) {
|
3742
4103
|
return;
|
3743
|
-
|
3744
|
-
|
3745
|
-
i3 - this.lastTitleBarClick.timestamp <= 500 ? Math.abs(e3.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(e3.clientY - this.lastTitleBarClick.clientY) <= 5 && this.onEvent && this.onEvent({ type: B$2.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarClick.timestamp = i3, this.lastTitleBarClick.clientX = e3.clientX, this.lastTitleBarClick.clientY = e3.clientY;
|
3746
|
-
}, this.lastTitleBarTouch = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarTouch = (e3) => {
|
3747
|
-
var t3;
|
3748
|
-
if (this.readonly$.value)
|
4104
|
+
}
|
4105
|
+
if (ev.button !== 0) {
|
3749
4106
|
return;
|
3750
|
-
|
4107
|
+
}
|
4108
|
+
if ((_a = ev.target.dataset) == null ? void 0 : _a.teleTitleBarNoDblClick) {
|
3751
4109
|
return;
|
3752
|
-
|
3753
|
-
|
3754
|
-
|
3755
|
-
|
4110
|
+
}
|
4111
|
+
preventEvent$1(ev);
|
4112
|
+
const now = Date.now();
|
4113
|
+
if (now - this.lastTitleBarClick.timestamp <= 500) {
|
4114
|
+
if (Math.abs(ev.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(ev.clientY - this.lastTitleBarClick.clientY) <= 5) {
|
4115
|
+
if (this.onEvent) {
|
4116
|
+
this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
|
4117
|
+
}
|
4118
|
+
}
|
4119
|
+
} else if (this.onDragStart) {
|
4120
|
+
this.onDragStart(ev);
|
4121
|
+
}
|
4122
|
+
this.lastTitleBarClick.timestamp = now;
|
4123
|
+
this.lastTitleBarClick.clientX = ev.clientX;
|
4124
|
+
this.lastTitleBarClick.clientY = ev.clientY;
|
4125
|
+
};
|
4126
|
+
this.readonly$ = readonly$;
|
4127
|
+
this.state$ = state$;
|
4128
|
+
this.title$ = title$;
|
4129
|
+
this.onEvent = onEvent;
|
4130
|
+
this.onDragStart = onDragStart;
|
4131
|
+
this.namespace = namespace;
|
4132
|
+
this.buttons = buttons || [
|
4133
|
+
{
|
4134
|
+
type: TELE_BOX_DELEGATE_EVENT.Minimize,
|
4135
|
+
iconClassName: this.wrapClassName("titlebar-icon-minimize")
|
4136
|
+
},
|
4137
|
+
{
|
4138
|
+
type: TELE_BOX_DELEGATE_EVENT.Maximize,
|
4139
|
+
iconClassName: this.wrapClassName("titlebar-icon-maximize"),
|
4140
|
+
isActive: (state) => state === TELE_BOX_STATE.Maximized
|
4141
|
+
},
|
4142
|
+
{
|
4143
|
+
type: TELE_BOX_DELEGATE_EVENT.Close,
|
4144
|
+
iconClassName: this.wrapClassName("titlebar-icon-close")
|
4145
|
+
}
|
4146
|
+
];
|
4147
|
+
this.$dragArea = this.renderDragArea();
|
3756
4148
|
}
|
3757
4149
|
render() {
|
3758
4150
|
if (!this.$titleBar) {
|
3759
|
-
this.$titleBar = document.createElement("div")
|
3760
|
-
|
3761
|
-
|
3762
|
-
|
3763
|
-
|
3764
|
-
const
|
3765
|
-
|
3766
|
-
|
3767
|
-
|
3768
|
-
|
3769
|
-
|
3770
|
-
|
3771
|
-
|
3772
|
-
|
3773
|
-
|
4151
|
+
this.$titleBar = document.createElement("div");
|
4152
|
+
this.$titleBar.className = this.wrapClassName("titlebar");
|
4153
|
+
const $titleArea = document.createElement("div");
|
4154
|
+
$titleArea.className = this.wrapClassName("title-area");
|
4155
|
+
$titleArea.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
4156
|
+
const $title = document.createElement("h1");
|
4157
|
+
$title.className = this.wrapClassName("title");
|
4158
|
+
$title.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
4159
|
+
$titleArea.appendChild($title);
|
4160
|
+
$titleArea.appendChild(this.$dragArea);
|
4161
|
+
const $buttonsContainer = document.createElement("div");
|
4162
|
+
$buttonsContainer.className = this.wrapClassName("titlebar-btns");
|
4163
|
+
this.buttons.forEach(({ iconClassName }, i2) => {
|
4164
|
+
const teleTitleBarBtnIndex = String(i2);
|
4165
|
+
const $btn = document.createElement("button");
|
4166
|
+
$btn.className = `${this.wrapClassName("titlebar-btn")} ${iconClassName}`;
|
4167
|
+
$btn.dataset.teleTitleBarBtnIndex = teleTitleBarBtnIndex;
|
4168
|
+
$btn.dataset.teleTitleBarNoDblClick = "true";
|
4169
|
+
$buttonsContainer.appendChild($btn);
|
4170
|
+
});
|
4171
|
+
this.sideEffect.addDisposer(this.title$.subscribe((title) => {
|
4172
|
+
$title.textContent = title;
|
4173
|
+
$title.title = title;
|
4174
|
+
}), "render-title");
|
4175
|
+
this.sideEffect.addDisposer(this.state$.subscribe((state) => {
|
4176
|
+
this.buttons.forEach((btn, i2) => {
|
4177
|
+
var _a;
|
4178
|
+
if (btn.isActive) {
|
4179
|
+
(_a = $buttonsContainer.children[i2]) == null ? void 0 : _a.classList.toggle("is-active", btn.isActive(state));
|
4180
|
+
}
|
3774
4181
|
});
|
3775
|
-
}), "render-state-btns")
|
3776
|
-
|
3777
|
-
|
4182
|
+
}), "render-state-btns");
|
4183
|
+
this.sideEffect.addEventListener($buttonsContainer, "pointerup", (ev) => {
|
4184
|
+
var _a;
|
4185
|
+
if (!ev.isPrimary || this.readonly$.value) {
|
3778
4186
|
return;
|
3779
|
-
const i3 = e3.target, s2 = Number((t3 = i3.dataset) == null ? void 0 : t3.teleTitleBarBtnIndex);
|
3780
|
-
if (!Number.isNaN(s2) && s2 < this.buttons.length) {
|
3781
|
-
k$1(e3);
|
3782
|
-
const t4 = this.buttons[s2];
|
3783
|
-
this.onEvent && this.onEvent({ type: t4.type, value: t4.value });
|
3784
4187
|
}
|
3785
|
-
|
4188
|
+
const target = ev.target;
|
4189
|
+
const teleTitleBarBtnIndex = Number((_a = target.dataset) == null ? void 0 : _a.teleTitleBarBtnIndex);
|
4190
|
+
if (!Number.isNaN(teleTitleBarBtnIndex) && teleTitleBarBtnIndex < this.buttons.length) {
|
4191
|
+
preventEvent$1(ev);
|
4192
|
+
const btn = this.buttons[teleTitleBarBtnIndex];
|
4193
|
+
if (this.onEvent) {
|
4194
|
+
this.onEvent({
|
4195
|
+
type: btn.type,
|
4196
|
+
value: btn.value
|
4197
|
+
});
|
4198
|
+
}
|
4199
|
+
}
|
4200
|
+
}, {}, "render-btns-container-click");
|
4201
|
+
this.$titleBar.appendChild($titleArea);
|
4202
|
+
this.$titleBar.appendChild($buttonsContainer);
|
3786
4203
|
}
|
3787
4204
|
return this.$titleBar;
|
3788
4205
|
}
|
3789
4206
|
renderDragArea() {
|
3790
|
-
const
|
3791
|
-
|
4207
|
+
const $dragArea = document.createElement("div");
|
4208
|
+
$dragArea.className = this.wrapClassName("drag-area");
|
4209
|
+
$dragArea.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
4210
|
+
this.sideEffect.addEventListener($dragArea, "pointerdown", this.handleTitleBarClick);
|
4211
|
+
return $dragArea;
|
3792
4212
|
}
|
3793
4213
|
dragHandle() {
|
3794
4214
|
return this.$titleBar;
|
3795
4215
|
}
|
3796
|
-
wrapClassName(
|
3797
|
-
return `${this.namespace}-${
|
4216
|
+
wrapClassName(className) {
|
4217
|
+
return `${this.namespace}-${className}`;
|
3798
4218
|
}
|
3799
4219
|
destroy() {
|
3800
|
-
this.sideEffect.flushAll()
|
3801
|
-
|
3802
|
-
|
3803
|
-
|
3804
|
-
|
3805
|
-
|
3806
|
-
if (t3 <= 0 || e3.width <= 0 || e3.height <= 0)
|
3807
|
-
return e3;
|
3808
|
-
const i3 = e3.width * t3;
|
3809
|
-
if (i3 === e3.height)
|
3810
|
-
return e3;
|
3811
|
-
if (i3 < e3.height)
|
3812
|
-
return { x: 0, y: (e3.height - i3) / 2, width: e3.width, height: i3 };
|
3813
|
-
const s3 = e3.height / t3;
|
3814
|
-
return { x: (e3.width - s3) / 2, y: 0, width: s3, height: e3.height };
|
3815
|
-
}, { compare: shallowequal }), this._sideEffect.addDisposer(combine([a2, s2]).subscribe(([e3, t3]) => {
|
3816
|
-
var i3;
|
3817
|
-
e3 && t3 ? e3.appendChild(this.render()) : ((i3 = this.$boxStage) == null ? void 0 : i3.parentNode) && this.$boxStage.remove();
|
3818
|
-
}));
|
4220
|
+
this.sideEffect.flushAll();
|
4221
|
+
if (this.$titleBar) {
|
4222
|
+
this.$titleBar = void 0;
|
4223
|
+
this.onDragStart = void 0;
|
4224
|
+
this.onEvent = void 0;
|
4225
|
+
}
|
3819
4226
|
}
|
3820
|
-
|
3821
|
-
|
3822
|
-
|
3823
|
-
|
3824
|
-
e2.className = this.wrapClassName("box-stage-container");
|
3825
|
-
const t2 = document.createElement("div");
|
3826
|
-
t2.className = this.wrapClassName("box-stage-mask");
|
3827
|
-
const i2 = document.createElement("div");
|
3828
|
-
i2.className = this.wrapClassName("box-stage-mask");
|
3829
|
-
const s2 = document.createElement("div");
|
3830
|
-
s2.className = this.wrapClassName("box-stage-frame");
|
3831
|
-
const [a2, o2, r2, n2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
|
3832
|
-
const i3 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
3833
|
-
i3.setAttribute("viewBox", "0 0 8 8"), i3.setAttribute("class", `${this.wrapClassName("box-stage-frame-corner")} is-${t3}`);
|
3834
|
-
const s3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
3835
|
-
return s3.setAttribute("d", e3), s3.setAttribute("fill", "#3381FF"), i3.appendChild(s3), i3;
|
3836
|
-
});
|
3837
|
-
return s2.appendChild(a2), s2.appendChild(r2), s2.appendChild(o2), s2.appendChild(n2), e2.appendChild(t2), e2.appendChild(s2), e2.appendChild(i2), this._sideEffect.addDisposer(this.highlightStage$.subscribe((t3) => {
|
3838
|
-
e2.classList.toggle("is-active", t3);
|
3839
|
-
})), this._sideEffect.addDisposer(combine([this.highlightStage$, this.stageRect$]).subscribe(([s3, a3]) => {
|
3840
|
-
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`));
|
3841
|
-
})), this.$boxStage = e2, e2;
|
4227
|
+
}
|
4228
|
+
function calcStageRect([rootRect, ratio]) {
|
4229
|
+
if (ratio <= 0 || rootRect.width <= 0 || rootRect.height <= 0) {
|
4230
|
+
return rootRect;
|
3842
4231
|
}
|
3843
|
-
|
3844
|
-
|
4232
|
+
const preferredHeight = rootRect.width * ratio;
|
4233
|
+
if (preferredHeight === rootRect.height) {
|
4234
|
+
return rootRect;
|
3845
4235
|
}
|
3846
|
-
|
3847
|
-
return
|
3848
|
-
|
3849
|
-
|
3850
|
-
|
3851
|
-
|
3852
|
-
|
3853
|
-
|
3854
|
-
|
3855
|
-
|
3856
|
-
|
3857
|
-
|
3858
|
-
|
3859
|
-
|
3860
|
-
|
3861
|
-
|
4236
|
+
if (preferredHeight < rootRect.height) {
|
4237
|
+
return {
|
4238
|
+
x: 0,
|
4239
|
+
y: (rootRect.height - preferredHeight) / 2,
|
4240
|
+
width: rootRect.width,
|
4241
|
+
height: preferredHeight
|
4242
|
+
};
|
4243
|
+
}
|
4244
|
+
const preferredWidth = rootRect.height / ratio;
|
4245
|
+
return {
|
4246
|
+
x: (rootRect.width - preferredWidth) / 2,
|
4247
|
+
y: 0,
|
4248
|
+
width: preferredWidth,
|
4249
|
+
height: rootRect.height
|
4250
|
+
};
|
4251
|
+
}
|
4252
|
+
const ResizeObserver$1$1 = window.ResizeObserver || ResizeObserver$3;
|
4253
|
+
class TeleBox {
|
4254
|
+
constructor({
|
4255
|
+
id: id2 = genUID(),
|
4256
|
+
title = getBoxDefaultName(),
|
4257
|
+
namespace = "telebox",
|
4258
|
+
visible = true,
|
4259
|
+
width = 0.5,
|
4260
|
+
height = 0.5,
|
4261
|
+
minWidth = 0,
|
4262
|
+
minHeight = 0,
|
4263
|
+
x: x2 = 0.1,
|
4264
|
+
y: y2 = 0.1,
|
4265
|
+
resizable = true,
|
4266
|
+
draggable = true,
|
4267
|
+
boxRatio = -1,
|
4268
|
+
focus = false,
|
4269
|
+
zIndex = 100,
|
4270
|
+
stageRatio = null,
|
4271
|
+
enableShadowDOM = true,
|
4272
|
+
titleBar,
|
4273
|
+
content,
|
4274
|
+
stage,
|
4275
|
+
footer,
|
4276
|
+
styles: styles2,
|
4277
|
+
userStyles,
|
4278
|
+
bodyStyle = null,
|
4279
|
+
stageStyle = null,
|
4280
|
+
darkMode$,
|
4281
|
+
fence$,
|
4282
|
+
minimized$,
|
4283
|
+
maximized$,
|
4284
|
+
readonly$,
|
4285
|
+
root,
|
4286
|
+
rootRect$,
|
4287
|
+
managerStageRect$,
|
4288
|
+
managerStageRatio$,
|
4289
|
+
defaultBoxBodyStyle$,
|
4290
|
+
defaultBoxStageStyle$,
|
4291
|
+
collectorRect$
|
4292
|
+
}) {
|
4293
|
+
this.events = new Emittery();
|
4294
|
+
this._delegateEvents = new Emittery();
|
4295
|
+
this.handleTrackStart = (ev) => {
|
4296
|
+
var _a;
|
4297
|
+
return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, ev);
|
4298
|
+
};
|
4299
|
+
this._sideEffect = new SideEffectManager();
|
4300
|
+
this.id = id2;
|
4301
|
+
this.namespace = namespace;
|
4302
|
+
this.enableShadowDOM = enableShadowDOM;
|
4303
|
+
const valManager = new ValManager();
|
4304
|
+
this._sideEffect.addDisposer(() => valManager.destroy());
|
4305
|
+
const title$ = new Val(title);
|
4306
|
+
const visible$ = new Val(visible);
|
4307
|
+
const resizable$ = new Val(resizable);
|
4308
|
+
const draggable$ = new Val(draggable);
|
4309
|
+
const boxRatio$ = new Val(boxRatio);
|
4310
|
+
const zIndex$ = new Val(zIndex);
|
4311
|
+
const focus$ = new Val(focus);
|
4312
|
+
const state$ = combine([minimized$, maximized$], ([minimized, maximized]) => minimized ? TELE_BOX_STATE.Minimized : maximized ? TELE_BOX_STATE.Maximized : TELE_BOX_STATE.Normal);
|
4313
|
+
const minSize$ = new Val({
|
4314
|
+
width: clamp$1(minWidth, 0, 1),
|
4315
|
+
height: clamp$1(minHeight, 0, 1)
|
4316
|
+
}, { compare: shallowequal });
|
4317
|
+
const pxMinSize$ = combine([minSize$, managerStageRect$], ([minSize, managerStageRect]) => ({
|
4318
|
+
width: minSize.width * managerStageRect.width,
|
4319
|
+
height: minSize.height * managerStageRect.height
|
4320
|
+
}), { compare: shallowequal });
|
4321
|
+
const intrinsicSize$ = new Val({ width, height }, { compare: shallowequal });
|
4322
|
+
this._sideEffect.addDisposer(minSize$.reaction((minSize, skipUpdate) => {
|
4323
|
+
intrinsicSize$.setValue({
|
4324
|
+
width: Math.max(width, minSize.width),
|
4325
|
+
height: Math.max(height, minSize.height)
|
4326
|
+
}, skipUpdate);
|
4327
|
+
}));
|
4328
|
+
const intrinsicCoord$ = new Val({ x: x2, y: y2 }, { compare: shallowequal });
|
4329
|
+
const pxIntrinsicSize$ = combine([intrinsicSize$, managerStageRect$], ([size2, managerStageRect]) => ({
|
4330
|
+
width: managerStageRect.width * size2.width,
|
4331
|
+
height: managerStageRect.height * size2.height
|
4332
|
+
}), { compare: shallowequal });
|
4333
|
+
const pxIntrinsicCoord$ = combine([intrinsicCoord$, managerStageRect$], ([intrinsicCoord, managerStageRect]) => ({
|
4334
|
+
x: intrinsicCoord.x * managerStageRect.width,
|
4335
|
+
y: intrinsicCoord.y * managerStageRect.height
|
4336
|
+
}), { compare: shallowequal });
|
4337
|
+
const bodyStyle$ = new Val(bodyStyle);
|
4338
|
+
const stageStyle$ = new Val(stageStyle);
|
4339
|
+
const contentRoot$ = new Val(null);
|
4340
|
+
const bodyRect$ = new Val(managerStageRect$.value, {
|
4341
|
+
compare: shallowequal
|
4342
|
+
});
|
4343
|
+
const stageRatio$ = new Val(stageRatio);
|
4344
|
+
const finalStageRatio$ = combine([stageRatio$, managerStageRatio$], ([stageRatio2, managerStageRatio]) => stageRatio2 != null ? stageRatio2 : managerStageRatio);
|
4345
|
+
const stageRect$ = combine([bodyRect$, finalStageRatio$], calcStageRect, { compare: shallowequal });
|
4346
|
+
const propsValConfig = {
|
4347
|
+
darkMode: darkMode$,
|
4348
|
+
fence: fence$,
|
4349
|
+
minimized: minimized$,
|
4350
|
+
maximized: maximized$,
|
4351
|
+
readonly: readonly$,
|
4352
|
+
rootRect: rootRect$,
|
4353
|
+
managerStageRect: managerStageRect$,
|
4354
|
+
managerStageRatio: managerStageRatio$,
|
4355
|
+
defaultBoxBodyStyle: defaultBoxBodyStyle$,
|
4356
|
+
defaultBoxStageStyle: defaultBoxStageStyle$,
|
4357
|
+
collectorRect: collectorRect$
|
4358
|
+
};
|
4359
|
+
withReadonlyValueEnhancer(this, propsValConfig);
|
4360
|
+
const myReadonlyValConfig = {
|
4361
|
+
zIndex: zIndex$,
|
4362
|
+
focus: focus$,
|
4363
|
+
state: state$,
|
4364
|
+
minSize: minSize$,
|
4365
|
+
pxMinSize: pxMinSize$,
|
4366
|
+
intrinsicSize: intrinsicSize$,
|
4367
|
+
intrinsicCoord: intrinsicCoord$,
|
4368
|
+
pxIntrinsicSize: pxIntrinsicSize$,
|
4369
|
+
pxIntrinsicCoord: pxIntrinsicCoord$,
|
4370
|
+
bodyRect: bodyRect$,
|
4371
|
+
stageRect: stageRect$
|
4372
|
+
};
|
4373
|
+
withReadonlyValueEnhancer(this, myReadonlyValConfig, valManager);
|
4374
|
+
const valConfig = {
|
4375
|
+
title: title$,
|
4376
|
+
visible: visible$,
|
4377
|
+
resizable: resizable$,
|
4378
|
+
draggable: draggable$,
|
4379
|
+
boxRatio: boxRatio$,
|
4380
|
+
stageRatio: stageRatio$,
|
4381
|
+
bodyStyle: bodyStyle$,
|
4382
|
+
stageStyle: stageStyle$
|
4383
|
+
};
|
4384
|
+
withValueEnhancer(this, valConfig, valManager);
|
4385
|
+
this.titleBar = titleBar || new DefaultTitleBar({
|
4386
|
+
readonly$,
|
4387
|
+
state$,
|
4388
|
+
title$,
|
4389
|
+
namespace: this.namespace,
|
4390
|
+
onDragStart: (event) => {
|
4391
|
+
var _a;
|
4392
|
+
return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, event);
|
4393
|
+
},
|
4394
|
+
onEvent: (event) => this._delegateEvents.emit(event.type)
|
4395
|
+
});
|
4396
|
+
this._sideEffect.addDisposer(boxRatio$.subscribe((boxRatio2) => {
|
4397
|
+
if (boxRatio2 > 0) {
|
4398
|
+
this.transform(pxIntrinsicCoord$.value.x, pxIntrinsicCoord$.value.y, pxIntrinsicSize$.value.width, pxIntrinsicSize$.value.height);
|
4399
|
+
}
|
4400
|
+
}));
|
4401
|
+
this._sideEffect.addDisposer(fence$.subscribe((fence) => {
|
4402
|
+
if (fence) {
|
4403
|
+
this.move(pxIntrinsicCoord$.value.x, pxIntrinsicCoord$.value.y);
|
4404
|
+
}
|
3862
4405
|
}));
|
3863
|
-
|
3864
|
-
this.
|
3865
|
-
|
3866
|
-
|
3867
|
-
|
3868
|
-
|
3869
|
-
|
3870
|
-
|
3871
|
-
|
3872
|
-
|
3873
|
-
|
3874
|
-
|
3875
|
-
|
3876
|
-
const pe2 = (e3, t3) => {
|
3877
|
-
this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
|
3878
|
-
i3 || this.events.emit(t3, e4);
|
4406
|
+
this.$box = this._render();
|
4407
|
+
contentRoot$.setValue(this.$content.parentElement);
|
4408
|
+
content && this.mountContent(content);
|
4409
|
+
stage && this.mountStage(stage);
|
4410
|
+
footer && this.mountFooter(footer);
|
4411
|
+
styles2 && this.mountStyles(styles2);
|
4412
|
+
userStyles && this.mountUserStyles(userStyles);
|
4413
|
+
root.appendChild(this.$box);
|
4414
|
+
const watchValEvent = (val, event) => {
|
4415
|
+
this._sideEffect.addDisposer(val.reaction((v2, skipUpdate) => {
|
4416
|
+
if (!skipUpdate) {
|
4417
|
+
this.events.emit(event, v2);
|
4418
|
+
}
|
3879
4419
|
}));
|
3880
4420
|
};
|
3881
|
-
|
3882
|
-
|
3883
|
-
|
3884
|
-
|
3885
|
-
|
3886
|
-
|
3887
|
-
|
4421
|
+
watchValEvent(darkMode$, TELE_BOX_EVENT.DarkMode);
|
4422
|
+
watchValEvent(readonly$, TELE_BOX_EVENT.Readonly);
|
4423
|
+
watchValEvent(zIndex$, TELE_BOX_EVENT.ZIndex);
|
4424
|
+
watchValEvent(minimized$, TELE_BOX_EVENT.Minimized);
|
4425
|
+
watchValEvent(maximized$, TELE_BOX_EVENT.Maximized);
|
4426
|
+
watchValEvent(state$, TELE_BOX_EVENT.State);
|
4427
|
+
watchValEvent(intrinsicSize$, TELE_BOX_EVENT.IntrinsicResize);
|
4428
|
+
watchValEvent(intrinsicCoord$, TELE_BOX_EVENT.IntrinsicMove);
|
4429
|
+
this._sideEffect.addDisposer([
|
4430
|
+
visible$.reaction((visible2, skipUpdate) => {
|
4431
|
+
if (!skipUpdate && !visible2) {
|
4432
|
+
this.events.emit(TELE_BOX_EVENT.Close);
|
4433
|
+
}
|
4434
|
+
}),
|
4435
|
+
focus$.reaction((focus2, skipUpdate) => {
|
4436
|
+
if (!skipUpdate) {
|
4437
|
+
this.events.emit(focus2 ? TELE_BOX_EVENT.Focus : TELE_BOX_EVENT.Blur);
|
4438
|
+
}
|
4439
|
+
})
|
4440
|
+
]);
|
3888
4441
|
}
|
3889
4442
|
get minWidth() {
|
3890
4443
|
return this._minSize$.value.width;
|
@@ -3892,14 +4445,17 @@ class Y$3 {
|
|
3892
4445
|
get minHeight() {
|
3893
4446
|
return this._minSize$.value.height;
|
3894
4447
|
}
|
3895
|
-
setMinWidth(
|
3896
|
-
this._minSize$.setValue({ width:
|
4448
|
+
setMinWidth(minWidth, skipUpdate = false) {
|
4449
|
+
this._minSize$.setValue({ width: minWidth, height: this.minHeight }, skipUpdate);
|
3897
4450
|
}
|
3898
|
-
setMinHeight(
|
3899
|
-
this._minSize$.setValue({ width: this.minWidth, height:
|
4451
|
+
setMinHeight(minHeight, skipUpdate = false) {
|
4452
|
+
this._minSize$.setValue({ width: this.minWidth, height: minHeight }, skipUpdate);
|
3900
4453
|
}
|
3901
|
-
resize(
|
3902
|
-
this._intrinsicSize$.setValue({
|
4454
|
+
resize(width, height, skipUpdate = false) {
|
4455
|
+
this._intrinsicSize$.setValue({
|
4456
|
+
width: Math.max(width, this.minWidth),
|
4457
|
+
height: Math.max(height, this.minHeight)
|
4458
|
+
}, skipUpdate);
|
3903
4459
|
}
|
3904
4460
|
get intrinsicX() {
|
3905
4461
|
return this._intrinsicCoord$.value.x;
|
@@ -3913,361 +4469,853 @@ class Y$3 {
|
|
3913
4469
|
get intrinsicHeight() {
|
3914
4470
|
return this._intrinsicSize$.value.height;
|
3915
4471
|
}
|
3916
|
-
move(
|
3917
|
-
let
|
3918
|
-
|
3919
|
-
|
3920
|
-
|
3921
|
-
|
3922
|
-
|
3923
|
-
|
3924
|
-
}
|
3925
|
-
|
4472
|
+
move(x2, y2, skipUpdate = false) {
|
4473
|
+
let safeX;
|
4474
|
+
let safeY;
|
4475
|
+
const managerStageRect = this.managerStageRect;
|
4476
|
+
const pxIntrinsicSize = this.pxIntrinsicSize;
|
4477
|
+
if (this.fence) {
|
4478
|
+
safeX = clamp$1(x2, 0, managerStageRect.width - pxIntrinsicSize.width);
|
4479
|
+
safeY = clamp$1(y2, 0, managerStageRect.height - pxIntrinsicSize.height);
|
4480
|
+
} else {
|
4481
|
+
safeX = clamp$1(x2, -(pxIntrinsicSize.width - 120), 0 + managerStageRect.width - 20);
|
4482
|
+
safeY = clamp$1(y2, 0, 0 + managerStageRect.height - 20);
|
4483
|
+
}
|
4484
|
+
this._intrinsicCoord$.setValue({
|
4485
|
+
x: safeX / managerStageRect.width,
|
4486
|
+
y: safeY / managerStageRect.height
|
4487
|
+
}, skipUpdate);
|
4488
|
+
}
|
4489
|
+
transform(x2, y2, width, height, skipUpdate = false) {
|
4490
|
+
const managerStageRect = this.managerStageRect;
|
4491
|
+
width = Math.max(width, this.pxMinSize.width);
|
4492
|
+
height = Math.max(height, this.pxMinSize.height);
|
4493
|
+
if (this.boxRatio > 0) {
|
4494
|
+
const newHeight = this.boxRatio * width;
|
4495
|
+
if (y2 !== this.pxIntrinsicCoord.y) {
|
4496
|
+
y2 -= newHeight - height;
|
4497
|
+
}
|
4498
|
+
height = newHeight;
|
4499
|
+
}
|
4500
|
+
if (y2 < 0) {
|
4501
|
+
y2 = 0;
|
4502
|
+
height = this.pxIntrinsicSize.height;
|
4503
|
+
}
|
4504
|
+
this.move(x2, y2, skipUpdate);
|
4505
|
+
this._intrinsicSize$.setValue({
|
4506
|
+
width: width / managerStageRect.width,
|
4507
|
+
height: height / managerStageRect.height
|
4508
|
+
}, skipUpdate);
|
4509
|
+
}
|
4510
|
+
mountContent(content) {
|
4511
|
+
var _a;
|
4512
|
+
(_a = this.$authorContent) == null ? void 0 : _a.remove();
|
4513
|
+
this.$authorContent = content;
|
4514
|
+
this.$content.appendChild(content);
|
3926
4515
|
}
|
3927
|
-
|
3928
|
-
|
3929
|
-
|
3930
|
-
|
3931
|
-
t2 !== this.pxIntrinsicCoord.y && (t2 -= e3 - s2), s2 = e3;
|
4516
|
+
unmountContent() {
|
4517
|
+
if (this.$authorContent) {
|
4518
|
+
this.$authorContent.remove();
|
4519
|
+
this.$authorContent = void 0;
|
3932
4520
|
}
|
3933
|
-
t2 < r2.y && (t2 = r2.y, s2 = this.pxIntrinsicSize.height), this.move(e2, t2, a2), this._intrinsicSize$.setValue({ width: i2 / o2.width, height: s2 / o2.height }, a2);
|
3934
4521
|
}
|
3935
|
-
|
3936
|
-
|
4522
|
+
mountStage(stage) {
|
4523
|
+
var _a;
|
4524
|
+
(_a = this.$authorStage) == null ? void 0 : _a.remove();
|
4525
|
+
this.$authorStage = stage;
|
4526
|
+
if (!this.$stage) {
|
4527
|
+
this.$stage = this._renderStage();
|
4528
|
+
}
|
4529
|
+
this.$stage.appendChild(stage);
|
4530
|
+
if (!this.$stage.parentElement) {
|
4531
|
+
this.$body.appendChild(this.$stage);
|
4532
|
+
}
|
3937
4533
|
}
|
3938
|
-
|
3939
|
-
|
4534
|
+
unmountStage() {
|
4535
|
+
var _a;
|
4536
|
+
if (this.$authorStage) {
|
4537
|
+
this.$authorStage.remove();
|
4538
|
+
this.$authorStage = void 0;
|
4539
|
+
}
|
4540
|
+
(_a = this.$stage) == null ? void 0 : _a.remove();
|
3940
4541
|
}
|
3941
|
-
mountFooter(
|
3942
|
-
|
4542
|
+
mountFooter(footer) {
|
4543
|
+
var _a;
|
4544
|
+
(_a = this.$authorFooter) == null ? void 0 : _a.remove();
|
4545
|
+
this.$authorFooter = footer;
|
4546
|
+
this.$footer.appendChild(footer);
|
3943
4547
|
}
|
3944
4548
|
unmountFooter() {
|
3945
|
-
this
|
3946
|
-
|
3947
|
-
|
3948
|
-
|
4549
|
+
if (this.$authorFooter) {
|
4550
|
+
this.$authorFooter.remove();
|
4551
|
+
this.$authorFooter = void 0;
|
4552
|
+
}
|
3949
4553
|
}
|
3950
|
-
mountStyles(
|
3951
|
-
|
3952
|
-
typeof e2 == "string" ? (t2 = document.createElement("style"), t2.textContent = e2) : t2 = e2, this._$userStyles$.setValue(t2);
|
4554
|
+
mountStyles(styles2) {
|
4555
|
+
this.$styles.textContent = styles2;
|
3953
4556
|
}
|
3954
4557
|
unmountStyles() {
|
3955
|
-
this.
|
4558
|
+
this.$styles.textContent = "";
|
3956
4559
|
}
|
3957
|
-
|
3958
|
-
this.
|
4560
|
+
mountUserStyles(styles2) {
|
4561
|
+
this.$userStyles.textContent = styles2;
|
3959
4562
|
}
|
3960
|
-
|
3961
|
-
|
4563
|
+
unmountUserStyles() {
|
4564
|
+
this.$userStyles.textContent = "";
|
4565
|
+
}
|
4566
|
+
_render() {
|
4567
|
+
if (this.$box) {
|
3962
4568
|
return this.$box;
|
3963
|
-
|
3964
|
-
const
|
3965
|
-
|
3966
|
-
|
3967
|
-
|
4569
|
+
}
|
4570
|
+
const bindBoxStates = (el, disposerID) => {
|
4571
|
+
return this._sideEffect.addDisposer([
|
4572
|
+
this._readonly$.subscribe((readonly) => el.classList.toggle(this.wrapClassName("readonly"), readonly)),
|
4573
|
+
this._draggable$.subscribe((draggable) => el.classList.toggle(this.wrapClassName("no-drag"), !draggable)),
|
4574
|
+
this._resizable$.subscribe((resizable) => el.classList.toggle(this.wrapClassName("no-resize"), !resizable)),
|
4575
|
+
this._focus$.subscribe((focus) => el.classList.toggle(this.wrapClassName("blur"), !focus)),
|
4576
|
+
this._darkMode$.subscribe((darkMode) => {
|
4577
|
+
el.classList.toggle(this.wrapClassName("color-scheme-dark"), darkMode);
|
4578
|
+
el.classList.toggle(this.wrapClassName("color-scheme-light"), !darkMode);
|
4579
|
+
})
|
4580
|
+
], disposerID);
|
4581
|
+
};
|
4582
|
+
this.$box = document.createElement("div");
|
4583
|
+
this.$box.classList.add(this.wrapClassName("box"));
|
4584
|
+
bindBoxStates(this.$box, "bind-box-state");
|
4585
|
+
this._sideEffect.add(() => {
|
4586
|
+
const minimizedClassName = this.wrapClassName("minimized");
|
4587
|
+
const maximizedClassName = this.wrapClassName("maximized");
|
4588
|
+
const MAXIMIZED_TIMER_ID = "box-maximized-timer";
|
4589
|
+
return this._state$.subscribe((state) => {
|
4590
|
+
this.$box.classList.toggle(minimizedClassName, state === TELE_BOX_STATE.Minimized);
|
4591
|
+
if (state === TELE_BOX_STATE.Maximized) {
|
4592
|
+
this._sideEffect.flush(MAXIMIZED_TIMER_ID);
|
4593
|
+
this.$box.classList.toggle(maximizedClassName, true);
|
4594
|
+
} else {
|
4595
|
+
this._sideEffect.setTimeout(() => {
|
4596
|
+
this.$box.classList.toggle(maximizedClassName, false);
|
4597
|
+
}, 0, MAXIMIZED_TIMER_ID);
|
4598
|
+
}
|
3968
4599
|
});
|
3969
4600
|
});
|
3970
|
-
|
3971
|
-
|
3972
|
-
return this._state$.subscribe((s3) => {
|
3973
|
-
this.$box.classList.toggle(e3, s3 === C$3.Minimized), s3 === C$3.Maximized ? (this._sideEffect.flush(i3), this.$box.classList.toggle(t3, true)) : this._sideEffect.setTimeout(() => {
|
3974
|
-
this.$box.classList.toggle(t3, false);
|
3975
|
-
}, 0, i3);
|
3976
|
-
});
|
3977
|
-
}), this._sideEffect.addDisposer(this._visible$.subscribe((e3) => {
|
3978
|
-
this.$box.style.display = e3 ? "block" : "none";
|
3979
|
-
})), this._sideEffect.addDisposer(this._zIndex$.subscribe((e3) => {
|
3980
|
-
this.$box.style.zIndex = String(e3);
|
3981
|
-
})), this.$box.dataset.teleBoxID = this.id;
|
3982
|
-
const t2 = index(this.$box), i2 = combine([this._maximized$, this._minimized$, this._pxIntrinsicSize$, this._pxIntrinsicCoord$, this._collectorRect$], ([e3, t3, i3, s3, a3]) => {
|
3983
|
-
const o3 = e3 ? { x: 0, y: 0, width: "100%", height: "100%", scaleX: 1, scaleY: 1 } : { x: s3.x, y: s3.y, width: i3.width + "px", height: i3.height + "px", scaleX: 1, scaleY: 1 };
|
3984
|
-
if (t3 && a3) {
|
3985
|
-
const { width: t4, height: s4 } = e3 ? this.rootRect : i3;
|
3986
|
-
o3.x = a3.x - t4 / 2 + a3.width / 2, o3.y = a3.y - s4 / 2 + a3.height / 2, o3.scaleX = a3.width / t4, o3.scaleY = a3.height / s4;
|
3987
|
-
}
|
3988
|
-
return o3;
|
3989
|
-
}, { compare: shallowequal }), s2 = i2.value;
|
3990
|
-
this.$box.style.width = s2.width, this.$box.style.height = s2.height, this.$box.style.transform = `translate(${s2.x - 10}px,${s2.y - 10}px)`, this._sideEffect.addDisposer(i2.subscribe((e3) => {
|
3991
|
-
t2.set(e3);
|
4601
|
+
this._sideEffect.addDisposer(this._visible$.subscribe((visible) => {
|
4602
|
+
this.$box.style.display = visible ? "block" : "none";
|
3992
4603
|
}));
|
3993
|
-
|
3994
|
-
|
3995
|
-
|
3996
|
-
|
3997
|
-
const
|
3998
|
-
|
3999
|
-
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
4003
|
-
|
4004
|
-
|
4005
|
-
|
4006
|
-
|
4007
|
-
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
|
4013
|
-
|
4014
|
-
|
4604
|
+
this._sideEffect.addDisposer(this._zIndex$.subscribe((zIndex) => {
|
4605
|
+
this.$box.style.zIndex = String(zIndex);
|
4606
|
+
}));
|
4607
|
+
this.$box.dataset.teleBoxID = this.id;
|
4608
|
+
const boxStyler = index(this.$box);
|
4609
|
+
const boxStyles$ = combine([
|
4610
|
+
this._maximized$,
|
4611
|
+
this._minimized$,
|
4612
|
+
this._pxIntrinsicSize$,
|
4613
|
+
this._pxIntrinsicCoord$,
|
4614
|
+
this._collectorRect$,
|
4615
|
+
this._rootRect$,
|
4616
|
+
this._managerStageRect$
|
4617
|
+
], ([
|
4618
|
+
maximized,
|
4619
|
+
minimized,
|
4620
|
+
pxIntrinsicSize,
|
4621
|
+
pxIntrinsicCoord,
|
4622
|
+
collectorRect,
|
4623
|
+
rootRect,
|
4624
|
+
managerStageRect
|
4625
|
+
]) => {
|
4626
|
+
const styles2 = maximized ? {
|
4627
|
+
x: -managerStageRect.x,
|
4628
|
+
y: -managerStageRect.y,
|
4629
|
+
width: rootRect.width,
|
4630
|
+
height: rootRect.height,
|
4631
|
+
scaleX: 1,
|
4632
|
+
scaleY: 1
|
4633
|
+
} : {
|
4634
|
+
x: pxIntrinsicCoord.x,
|
4635
|
+
y: pxIntrinsicCoord.y,
|
4636
|
+
width: pxIntrinsicSize.width,
|
4637
|
+
height: pxIntrinsicSize.height,
|
4638
|
+
scaleX: 1,
|
4639
|
+
scaleY: 1
|
4640
|
+
};
|
4641
|
+
if (minimized && collectorRect) {
|
4642
|
+
const { width: boxWidth, height: boxHeight } = maximized ? this.rootRect : pxIntrinsicSize;
|
4643
|
+
styles2.x = collectorRect.x - boxWidth / 2 + collectorRect.width / 2 - managerStageRect.x;
|
4644
|
+
styles2.y = collectorRect.y - boxHeight / 2 + collectorRect.height / 2 - managerStageRect.y;
|
4645
|
+
styles2.scaleX = collectorRect.width / boxWidth;
|
4646
|
+
styles2.scaleY = collectorRect.height / boxHeight;
|
4647
|
+
}
|
4648
|
+
return styles2;
|
4649
|
+
}, { compare: shallowequal });
|
4650
|
+
const boxStyles = boxStyles$.value;
|
4651
|
+
this.$box.style.width = boxStyles.width + "px";
|
4652
|
+
this.$box.style.height = boxStyles.height + "px";
|
4653
|
+
this.$box.style.transform = `translate(${boxStyles.x - 10}px,${boxStyles.y - 10}px)`;
|
4654
|
+
this._sideEffect.addDisposer(boxStyles$.subscribe((styles2) => {
|
4655
|
+
boxStyler.set(styles2);
|
4656
|
+
}));
|
4657
|
+
const $boxMain = document.createElement("div");
|
4658
|
+
$boxMain.className = this.wrapClassName("box-main");
|
4659
|
+
this.$box.appendChild($boxMain);
|
4660
|
+
const $titleBar = document.createElement("div");
|
4661
|
+
$titleBar.className = this.wrapClassName("titlebar-wrap");
|
4662
|
+
$titleBar.appendChild(this.titleBar.render());
|
4663
|
+
this.$titleBar = $titleBar;
|
4664
|
+
const $body = document.createElement("div");
|
4665
|
+
$body.className = this.wrapClassName("body-wrap");
|
4666
|
+
this.$body = $body;
|
4667
|
+
const $styles = document.createElement("style");
|
4668
|
+
this.$styles = $styles;
|
4669
|
+
$body.appendChild($styles);
|
4670
|
+
const $userStyles = document.createElement("style");
|
4671
|
+
this.$userStyles = $userStyles;
|
4672
|
+
$body.appendChild($userStyles);
|
4673
|
+
const $content = document.createElement("div");
|
4674
|
+
$content.className = this.wrapClassName("content") + " tele-fancy-scrollbar";
|
4675
|
+
this.$content = $content;
|
4676
|
+
this._sideEffect.addDisposer(combine([this._bodyStyle$, this._defaultBoxBodyStyle$], ([bodyStyle, defaultBoxBodyStyle]) => bodyStyle != null ? bodyStyle : defaultBoxBodyStyle).subscribe((style2) => $content.style.cssText = style2 || ""));
|
4677
|
+
$body.appendChild($content);
|
4678
|
+
const $footer = document.createElement("div");
|
4679
|
+
$footer.className = this.wrapClassName("footer-wrap");
|
4680
|
+
this.$footer = $footer;
|
4681
|
+
$boxMain.appendChild($titleBar);
|
4682
|
+
const $main = document.createElement("div");
|
4683
|
+
$main.className = this.wrapClassName("main");
|
4684
|
+
this.$main = $main;
|
4685
|
+
$boxMain.appendChild($main);
|
4686
|
+
const $quarantineOuter = document.createElement("div");
|
4687
|
+
$quarantineOuter.className = this.wrapClassName("quarantine-outer");
|
4688
|
+
$main.appendChild($quarantineOuter);
|
4689
|
+
const $quarantine = document.createElement("div");
|
4690
|
+
$quarantine.className = this.wrapClassName("quarantine");
|
4691
|
+
$quarantine.appendChild($body);
|
4692
|
+
$quarantine.appendChild($footer);
|
4693
|
+
if (this.enableShadowDOM) {
|
4694
|
+
bindBoxStates($quarantine, "bind-quarantine-state");
|
4695
|
+
const $shadowStyle = document.createElement("style");
|
4696
|
+
$shadowStyle.textContent = shadowStyles;
|
4697
|
+
$quarantine.insertBefore($shadowStyle, $quarantine.firstChild);
|
4698
|
+
const shadow = $quarantineOuter.attachShadow({ mode: "open" });
|
4699
|
+
shadow.appendChild($quarantine);
|
4700
|
+
} else {
|
4701
|
+
$quarantineOuter.appendChild($quarantine);
|
4702
|
+
}
|
4703
|
+
this._renderResizeHandlers();
|
4704
|
+
const updateBodyRect = () => {
|
4705
|
+
const rect = $body.getBoundingClientRect();
|
4706
|
+
this._bodyRect$.setValue({
|
4707
|
+
x: 0,
|
4708
|
+
y: 0,
|
4709
|
+
width: rect.width,
|
4710
|
+
height: rect.height
|
4015
4711
|
});
|
4016
|
-
}
|
4017
|
-
|
4018
|
-
|
4019
|
-
|
4020
|
-
|
4021
|
-
|
4712
|
+
};
|
4713
|
+
this._sideEffect.add(() => {
|
4714
|
+
const observer = new ResizeObserver$1$1(() => {
|
4715
|
+
if (!this.minimized) {
|
4716
|
+
updateBodyRect();
|
4717
|
+
}
|
4022
4718
|
});
|
4023
|
-
|
4719
|
+
observer.observe($body);
|
4720
|
+
return () => observer.disconnect();
|
4721
|
+
});
|
4722
|
+
this._sideEffect.addDisposer(this._minimized$.reaction((minimized) => {
|
4723
|
+
if (!minimized) {
|
4724
|
+
this._sideEffect.setTimeout(updateBodyRect, 400, "minimized-content-rect-fix");
|
4725
|
+
}
|
4726
|
+
}));
|
4727
|
+
return this.$box;
|
4728
|
+
}
|
4729
|
+
_renderStage() {
|
4730
|
+
const $stage = document.createElement("div");
|
4731
|
+
$stage.className = this.wrapClassName("box-stage");
|
4732
|
+
const updateStageRect = (stageRect) => {
|
4733
|
+
$stage.style.top = stageRect.y + "px";
|
4734
|
+
$stage.style.left = stageRect.x + "px";
|
4735
|
+
$stage.style.width = stageRect.width + "px";
|
4736
|
+
$stage.style.height = stageRect.height + "px";
|
4737
|
+
};
|
4738
|
+
this._sideEffect.addDisposer([
|
4739
|
+
combine([this._stageStyle$, this._defaultBoxStageStyle$], ([stageStyle, defaultBoxStageStyle]) => stageStyle != null ? stageStyle : defaultBoxStageStyle).subscribe((styles2) => {
|
4740
|
+
$stage.style.cssText = styles2 || "";
|
4741
|
+
updateStageRect(this._stageRect$.value);
|
4742
|
+
}),
|
4743
|
+
this._stageRect$.subscribe(updateStageRect)
|
4744
|
+
], "box-stage-styles");
|
4745
|
+
return $stage;
|
4024
4746
|
}
|
4025
4747
|
_renderResizeHandlers() {
|
4026
|
-
const
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4032
|
-
|
4033
|
-
|
4034
|
-
|
4748
|
+
const $resizeHandles = document.createElement("div");
|
4749
|
+
$resizeHandles.className = this.wrapClassName("resize-handles");
|
4750
|
+
Object.values(TELE_BOX_RESIZE_HANDLE).forEach((handleType) => {
|
4751
|
+
const $handle = document.createElement("div");
|
4752
|
+
$handle.className = this.wrapClassName(handleType) + " " + this.wrapClassName("resize-handle");
|
4753
|
+
$handle.dataset.teleBoxHandle = handleType;
|
4754
|
+
$resizeHandles.appendChild($handle);
|
4755
|
+
});
|
4756
|
+
this.$box.appendChild($resizeHandles);
|
4757
|
+
const TRACKING_DISPOSER_ID = "handle-tracking-listener";
|
4758
|
+
const transformingClassName = this.wrapClassName("transforming");
|
4759
|
+
let $trackMask;
|
4760
|
+
let trackStartX = 0;
|
4761
|
+
let trackStartY = 0;
|
4762
|
+
let trackStartWidth = 0;
|
4763
|
+
let trackStartHeight = 0;
|
4764
|
+
let trackStartPageX = 0;
|
4765
|
+
let trackStartPageY = 0;
|
4766
|
+
let trackingHandle;
|
4767
|
+
const handleTracking = (ev) => {
|
4768
|
+
if (!ev.isPrimary || this.state !== TELE_BOX_STATE.Normal) {
|
4035
4769
|
return;
|
4036
|
-
|
4037
|
-
|
4038
|
-
|
4039
|
-
|
4040
|
-
|
4041
|
-
|
4042
|
-
|
4043
|
-
|
4770
|
+
}
|
4771
|
+
preventEvent$1(ev);
|
4772
|
+
let { pageX, pageY } = ev;
|
4773
|
+
if (pageY < 0) {
|
4774
|
+
pageY = 0;
|
4775
|
+
}
|
4776
|
+
const offsetX = pageX - trackStartPageX;
|
4777
|
+
const offsetY = pageY - trackStartPageY;
|
4778
|
+
let { x: newX, y: newY } = this.pxIntrinsicCoord;
|
4779
|
+
let { width: newWidth, height: newHeight } = this.pxIntrinsicSize;
|
4780
|
+
switch (trackingHandle) {
|
4781
|
+
case TELE_BOX_RESIZE_HANDLE.North: {
|
4782
|
+
newY = trackStartY + offsetY;
|
4783
|
+
newHeight = trackStartHeight - offsetY;
|
4044
4784
|
break;
|
4045
|
-
|
4046
|
-
|
4785
|
+
}
|
4786
|
+
case TELE_BOX_RESIZE_HANDLE.South: {
|
4787
|
+
newHeight = trackStartHeight + offsetY;
|
4047
4788
|
break;
|
4048
|
-
|
4049
|
-
|
4789
|
+
}
|
4790
|
+
case TELE_BOX_RESIZE_HANDLE.West: {
|
4791
|
+
newX = trackStartX + offsetX;
|
4792
|
+
newWidth = trackStartWidth - offsetX;
|
4050
4793
|
break;
|
4051
|
-
|
4052
|
-
|
4794
|
+
}
|
4795
|
+
case TELE_BOX_RESIZE_HANDLE.East: {
|
4796
|
+
newWidth = trackStartWidth + offsetX;
|
4053
4797
|
break;
|
4054
|
-
|
4055
|
-
|
4798
|
+
}
|
4799
|
+
case TELE_BOX_RESIZE_HANDLE.NorthWest: {
|
4800
|
+
newX = trackStartX + offsetX;
|
4801
|
+
newY = trackStartY + offsetY;
|
4802
|
+
newWidth = trackStartWidth - offsetX;
|
4803
|
+
newHeight = trackStartHeight - offsetY;
|
4056
4804
|
break;
|
4057
|
-
|
4058
|
-
|
4805
|
+
}
|
4806
|
+
case TELE_BOX_RESIZE_HANDLE.NorthEast: {
|
4807
|
+
newY = trackStartY + offsetY;
|
4808
|
+
newWidth = trackStartWidth + offsetX;
|
4809
|
+
newHeight = trackStartHeight - offsetY;
|
4059
4810
|
break;
|
4060
|
-
|
4061
|
-
|
4811
|
+
}
|
4812
|
+
case TELE_BOX_RESIZE_HANDLE.SouthEast: {
|
4813
|
+
newWidth = trackStartWidth + offsetX;
|
4814
|
+
newHeight = trackStartHeight + offsetY;
|
4062
4815
|
break;
|
4063
|
-
|
4064
|
-
|
4816
|
+
}
|
4817
|
+
case TELE_BOX_RESIZE_HANDLE.SouthWest: {
|
4818
|
+
newX = trackStartX + offsetX;
|
4819
|
+
newWidth = trackStartWidth - offsetX;
|
4820
|
+
newHeight = trackStartHeight + offsetY;
|
4065
4821
|
break;
|
4066
|
-
|
4067
|
-
|
4068
|
-
|
4069
|
-
|
4070
|
-
|
4071
|
-
|
4072
|
-
|
4073
|
-
|
4074
|
-
|
4822
|
+
}
|
4823
|
+
default: {
|
4824
|
+
this.move(trackStartX + offsetX, trackStartY + offsetY);
|
4825
|
+
return;
|
4826
|
+
}
|
4827
|
+
}
|
4828
|
+
this.transform(newX, newY, newWidth, newHeight);
|
4829
|
+
};
|
4830
|
+
const handleTrackEnd = (ev) => {
|
4831
|
+
if (!ev.isPrimary) {
|
4832
|
+
return;
|
4833
|
+
}
|
4834
|
+
trackingHandle = void 0;
|
4835
|
+
if (!$trackMask) {
|
4836
|
+
return;
|
4837
|
+
}
|
4838
|
+
preventEvent$1(ev);
|
4839
|
+
this.$box.classList.toggle(transformingClassName, false);
|
4840
|
+
this._sideEffect.flush(TRACKING_DISPOSER_ID);
|
4841
|
+
$trackMask.remove();
|
4842
|
+
};
|
4843
|
+
const handleTrackStart = (ev) => {
|
4844
|
+
var _a;
|
4845
|
+
if (!ev.isPrimary || this.readonly) {
|
4075
4846
|
return;
|
4076
|
-
|
4847
|
+
}
|
4848
|
+
if (ev.button != null && ev.button !== 0) {
|
4077
4849
|
return;
|
4078
|
-
|
4850
|
+
}
|
4851
|
+
if (!this.draggable || trackingHandle || this.state !== TELE_BOX_STATE.Normal) {
|
4079
4852
|
return;
|
4080
|
-
|
4081
|
-
|
4082
|
-
|
4083
|
-
|
4084
|
-
|
4085
|
-
|
4086
|
-
|
4853
|
+
}
|
4854
|
+
const target = ev.target;
|
4855
|
+
if ((_a = target.dataset) == null ? void 0 : _a.teleBoxHandle) {
|
4856
|
+
preventEvent$1(ev);
|
4857
|
+
({ x: trackStartX, y: trackStartY } = this.pxIntrinsicCoord);
|
4858
|
+
({ width: trackStartWidth, height: trackStartHeight } = this.pxIntrinsicSize);
|
4859
|
+
({ pageX: trackStartPageX, pageY: trackStartPageY } = ev);
|
4860
|
+
trackingHandle = target.dataset.teleBoxHandle;
|
4861
|
+
if (!$trackMask) {
|
4862
|
+
$trackMask = document.createElement("div");
|
4863
|
+
}
|
4864
|
+
const cursor = trackingHandle ? this.wrapClassName(`cursor-${trackingHandle}`) : "";
|
4865
|
+
$trackMask.className = this.wrapClassName(`track-mask${cursor ? ` ${cursor}` : ""}`);
|
4866
|
+
this.$box.appendChild($trackMask);
|
4867
|
+
this.$box.classList.add(transformingClassName);
|
4868
|
+
this._sideEffect.add(() => {
|
4869
|
+
window.addEventListener("pointermove", handleTracking, {
|
4870
|
+
passive: false
|
4871
|
+
});
|
4872
|
+
window.addEventListener("pointerup", handleTrackEnd, {
|
4873
|
+
passive: false
|
4874
|
+
});
|
4875
|
+
window.addEventListener("pointercancel", handleTrackEnd, {
|
4876
|
+
passive: false
|
4877
|
+
});
|
4878
|
+
return () => {
|
4879
|
+
window.removeEventListener("pointermove", handleTracking);
|
4880
|
+
window.removeEventListener("pointerup", handleTrackEnd);
|
4881
|
+
window.removeEventListener("pointercancel", handleTrackEnd);
|
4882
|
+
};
|
4883
|
+
}, TRACKING_DISPOSER_ID);
|
4087
4884
|
}
|
4088
4885
|
};
|
4089
|
-
this._handleTrackStart =
|
4886
|
+
this._handleTrackStart = handleTrackStart;
|
4887
|
+
this._sideEffect.addEventListener($resizeHandles, "pointerdown", handleTrackStart, {}, "box-resizeHandles-pointerdown");
|
4090
4888
|
}
|
4091
4889
|
async destroy() {
|
4092
|
-
this.$box.remove()
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4105
|
-
|
4106
|
-
|
4107
|
-
|
4108
|
-
|
4109
|
-
|
4110
|
-
|
4111
|
-
|
4112
|
-
|
4113
|
-
|
4114
|
-
|
4115
|
-
|
4116
|
-
|
4117
|
-
|
4118
|
-
|
4119
|
-
|
4120
|
-
|
4121
|
-
|
4122
|
-
|
4123
|
-
|
4124
|
-
|
4125
|
-
|
4126
|
-
|
4127
|
-
|
4128
|
-
|
4890
|
+
this.$box.remove();
|
4891
|
+
this._sideEffect.flushAll();
|
4892
|
+
this._sideEffect.flushAll();
|
4893
|
+
await this.events.emit(TELE_BOX_EVENT.Destroyed);
|
4894
|
+
this.events.clearListeners();
|
4895
|
+
this._delegateEvents.clearListeners();
|
4896
|
+
}
|
4897
|
+
wrapClassName(className) {
|
4898
|
+
return `${this.namespace}-${className}`;
|
4899
|
+
}
|
4900
|
+
}
|
4901
|
+
var collectorSVG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K";
|
4902
|
+
class TeleBoxCollector {
|
4903
|
+
constructor({
|
4904
|
+
minimized$,
|
4905
|
+
readonly$,
|
4906
|
+
darkMode$,
|
4907
|
+
namespace = "telebox",
|
4908
|
+
styles: styles2 = {},
|
4909
|
+
root$
|
4910
|
+
}) {
|
4911
|
+
this._sideEffect = new SideEffectManager();
|
4912
|
+
this.namespace = namespace;
|
4913
|
+
const valManager = new ValManager();
|
4914
|
+
this._sideEffect.addDisposer(() => valManager.destroy());
|
4915
|
+
const rect$ = new Val(void 0);
|
4916
|
+
const visible$ = derive(minimized$);
|
4917
|
+
const styles$ = new Val(styles2);
|
4918
|
+
const el$ = new Val(document.createElement("button"));
|
4919
|
+
const valConfig = {
|
4920
|
+
styles: styles$,
|
4921
|
+
$collector: el$
|
4922
|
+
};
|
4923
|
+
withValueEnhancer(this, valConfig, valManager);
|
4924
|
+
const propsValConfig = {
|
4925
|
+
root: root$
|
4926
|
+
};
|
4927
|
+
withReadonlyValueEnhancer(this, propsValConfig);
|
4928
|
+
const myReadonlyValConfig = {
|
4929
|
+
rect: rect$,
|
4930
|
+
visible: visible$
|
4931
|
+
};
|
4932
|
+
withReadonlyValueEnhancer(this, myReadonlyValConfig, valManager);
|
4933
|
+
el$.value.className = this.wrapClassName("collector");
|
4934
|
+
el$.value.style.backgroundImage = `url('${collectorSVG}')`;
|
4935
|
+
this._sideEffect.addDisposer(el$.subscribe(($collector) => {
|
4936
|
+
this._sideEffect.addEventListener($collector, "pointerup", (ev) => {
|
4937
|
+
if (ev.isPrimary && !readonly$.value) {
|
4938
|
+
minimized$.setValue(false);
|
4939
|
+
}
|
4940
|
+
}, {}, "telebox-collector-click");
|
4941
|
+
this._sideEffect.addDisposer([
|
4942
|
+
visible$.subscribe((visible) => {
|
4943
|
+
$collector.classList.toggle(this.wrapClassName("collector-visible"), visible);
|
4944
|
+
}),
|
4945
|
+
readonly$.subscribe((readonly) => {
|
4946
|
+
$collector.classList.toggle(this.wrapClassName("collector-readonly"), readonly);
|
4947
|
+
}),
|
4948
|
+
darkMode$.subscribe((darkMode) => {
|
4949
|
+
$collector.classList.toggle(this.wrapClassName("color-scheme-dark"), darkMode);
|
4950
|
+
$collector.classList.toggle(this.wrapClassName("color-scheme-light"), !darkMode);
|
4951
|
+
}),
|
4952
|
+
styles$.subscribe((styles22) => {
|
4953
|
+
Object.keys(styles22).forEach((key) => {
|
4954
|
+
const value = styles22[key];
|
4955
|
+
if (value != null) {
|
4956
|
+
$collector.style[key] = value;
|
4957
|
+
}
|
4958
|
+
});
|
4959
|
+
}),
|
4960
|
+
root$.subscribe((root) => {
|
4961
|
+
if (root) {
|
4962
|
+
root.appendChild($collector);
|
4963
|
+
}
|
4964
|
+
}),
|
4965
|
+
combine([minimized$, root$]).subscribe(([minimized, root]) => {
|
4966
|
+
if (minimized && root) {
|
4967
|
+
const { x: x2, y: y2, width, height } = $collector.getBoundingClientRect();
|
4968
|
+
const rootRect = root.getBoundingClientRect();
|
4969
|
+
rect$.setValue({
|
4970
|
+
x: x2 - rootRect.x,
|
4971
|
+
y: y2 - rootRect.y,
|
4972
|
+
width,
|
4973
|
+
height
|
4974
|
+
});
|
4975
|
+
}
|
4976
|
+
})
|
4977
|
+
], "telebox-collector-el");
|
4129
4978
|
}));
|
4130
4979
|
}
|
4131
4980
|
destroy() {
|
4132
4981
|
this._sideEffect.flushAll();
|
4133
4982
|
}
|
4134
|
-
wrapClassName(
|
4135
|
-
return `${this.namespace}-${
|
4983
|
+
wrapClassName(className) {
|
4984
|
+
return `${this.namespace}-${className}`;
|
4136
4985
|
}
|
4137
4986
|
}
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4143
|
-
|
4144
|
-
|
4987
|
+
var TELE_BOX_MANAGER_EVENT = /* @__PURE__ */ ((TELE_BOX_MANAGER_EVENT2) => {
|
4988
|
+
TELE_BOX_MANAGER_EVENT2["Focused"] = "focused";
|
4989
|
+
TELE_BOX_MANAGER_EVENT2["Blurred"] = "blurred";
|
4990
|
+
TELE_BOX_MANAGER_EVENT2["Created"] = "created";
|
4991
|
+
TELE_BOX_MANAGER_EVENT2["Removed"] = "removed";
|
4992
|
+
TELE_BOX_MANAGER_EVENT2["State"] = "state";
|
4993
|
+
TELE_BOX_MANAGER_EVENT2["Maximized"] = "maximized";
|
4994
|
+
TELE_BOX_MANAGER_EVENT2["Minimized"] = "minimized";
|
4995
|
+
TELE_BOX_MANAGER_EVENT2["IntrinsicMove"] = "intrinsic_move";
|
4996
|
+
TELE_BOX_MANAGER_EVENT2["IntrinsicResize"] = "intrinsic_resize";
|
4997
|
+
TELE_BOX_MANAGER_EVENT2["ZIndex"] = "z_index";
|
4998
|
+
TELE_BOX_MANAGER_EVENT2["PrefersColorScheme"] = "prefers_color_scheme";
|
4999
|
+
TELE_BOX_MANAGER_EVENT2["DarkMode"] = "dark_mode";
|
5000
|
+
return TELE_BOX_MANAGER_EVENT2;
|
5001
|
+
})(TELE_BOX_MANAGER_EVENT || {});
|
5002
|
+
class MaxTitleBar extends DefaultTitleBar {
|
5003
|
+
constructor(config) {
|
5004
|
+
super(config);
|
5005
|
+
this.boxes$ = config.boxes$;
|
5006
|
+
this.rootRect$ = config.rootRect$;
|
5007
|
+
this.darkMode$ = config.darkMode$;
|
5008
|
+
config.root.appendChild(this.render());
|
4145
5009
|
}
|
4146
|
-
focusBox(
|
4147
|
-
var
|
4148
|
-
if (
|
4149
|
-
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4153
|
-
|
5010
|
+
focusBox(box) {
|
5011
|
+
var _a;
|
5012
|
+
if (this.focusedBox && this.focusedBox === box) {
|
5013
|
+
return;
|
5014
|
+
}
|
5015
|
+
if (this.$titles && this.state$.value === TELE_BOX_STATE.Maximized) {
|
5016
|
+
const { children: children2 } = this.$titles.firstElementChild;
|
5017
|
+
for (let i2 = children2.length - 1; i2 >= 0; i2 -= 1) {
|
5018
|
+
const $tab = children2[i2];
|
5019
|
+
const id2 = (_a = $tab.dataset) == null ? void 0 : _a.teleBoxID;
|
5020
|
+
if (id2) {
|
5021
|
+
if (box && id2 === box.id) {
|
5022
|
+
$tab.classList.toggle(this.wrapClassName("titles-tab-focus"), true);
|
5023
|
+
} else if (this.focusedBox && id2 === this.focusedBox.id) {
|
5024
|
+
$tab.classList.toggle(this.wrapClassName("titles-tab-focus"), false);
|
5025
|
+
}
|
4154
5026
|
}
|
4155
5027
|
}
|
4156
|
-
this.focusedBox = e2;
|
4157
5028
|
}
|
5029
|
+
this.focusedBox = box;
|
4158
5030
|
}
|
4159
5031
|
render() {
|
4160
|
-
if (this.$titleBar)
|
5032
|
+
if (this.$titleBar) {
|
4161
5033
|
return this.$titleBar;
|
4162
|
-
|
4163
|
-
|
4164
|
-
|
4165
|
-
|
4166
|
-
|
4167
|
-
|
4168
|
-
|
4169
|
-
|
4170
|
-
|
4171
|
-
|
4172
|
-
|
4173
|
-
|
5034
|
+
}
|
5035
|
+
const $titleBar = super.render();
|
5036
|
+
$titleBar.classList.add(this.wrapClassName("max-titlebar"));
|
5037
|
+
this.sideEffect.addDisposer([
|
5038
|
+
this.state$.subscribe((state) => {
|
5039
|
+
$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), state === TELE_BOX_STATE.Maximized);
|
5040
|
+
}),
|
5041
|
+
this.readonly$.subscribe((readonly) => {
|
5042
|
+
$titleBar.classList.toggle(this.wrapClassName("readonly"), readonly);
|
5043
|
+
}),
|
5044
|
+
combine([this.state$, this.boxes$]).subscribe(([state, titles]) => {
|
5045
|
+
if (state === TELE_BOX_STATE.Maximized) {
|
5046
|
+
$titleBar.classList.toggle(this.wrapClassName("max-titlebar-single-title"), titles.length === 1);
|
5047
|
+
if (titles.length !== 1) {
|
5048
|
+
$titleBar.replaceChild(this.renderTitles(), $titleBar.firstElementChild);
|
5049
|
+
}
|
5050
|
+
}
|
5051
|
+
})
|
5052
|
+
], "max-render");
|
5053
|
+
const $titlesArea = document.createElement("div");
|
5054
|
+
$titlesArea.classList.add(this.wrapClassName("titles-area"));
|
5055
|
+
$titleBar.insertBefore($titlesArea, $titleBar.firstElementChild);
|
5056
|
+
return $titleBar;
|
4174
5057
|
}
|
4175
5058
|
destroy() {
|
4176
|
-
super.destroy()
|
5059
|
+
super.destroy();
|
5060
|
+
this.$titles = void 0;
|
5061
|
+
this.focusedBox = void 0;
|
4177
5062
|
}
|
4178
5063
|
renderTitles() {
|
4179
|
-
this.$titles = document.createElement("div")
|
4180
|
-
|
5064
|
+
this.$titles = document.createElement("div");
|
5065
|
+
this.$titles.className = this.wrapClassName("titles");
|
5066
|
+
this.sideEffect.addEventListener(this.$titles, "wheel", (ev) => {
|
5067
|
+
ev.currentTarget.scrollBy({
|
5068
|
+
left: ev.deltaY > 0 ? 250 : -250,
|
5069
|
+
behavior: "smooth"
|
5070
|
+
});
|
4181
5071
|
}, { passive: false }, "max-render-wheel-titles");
|
4182
|
-
const
|
4183
|
-
|
4184
|
-
|
4185
|
-
|
4186
|
-
|
5072
|
+
const $content = document.createElement("div");
|
5073
|
+
$content.className = this.wrapClassName("titles-content");
|
5074
|
+
this.$titles.appendChild($content);
|
5075
|
+
const disposers = this.boxes$.value.map((box) => {
|
5076
|
+
const $tab = document.createElement("button");
|
5077
|
+
$tab.className = this.wrapClassName("titles-tab");
|
5078
|
+
$tab.textContent = box.title;
|
5079
|
+
$tab.dataset.teleBoxID = box.id;
|
5080
|
+
$tab.dataset.teleTitleBarNoDblClick = "true";
|
5081
|
+
if (this.focusedBox && box.id === this.focusedBox.id) {
|
5082
|
+
$tab.classList.add(this.wrapClassName("titles-tab-focus"));
|
5083
|
+
}
|
5084
|
+
$content.appendChild($tab);
|
5085
|
+
return box._title$.reaction((title) => $tab.textContent = title);
|
4187
5086
|
});
|
4188
|
-
|
5087
|
+
this.sideEffect.addDisposer(() => disposers.forEach((disposer) => disposer()), "max-render-tab-titles");
|
5088
|
+
return this.$titles;
|
4189
5089
|
}
|
4190
5090
|
}
|
4191
|
-
const
|
4192
|
-
class
|
4193
|
-
constructor({
|
4194
|
-
|
4195
|
-
|
4196
|
-
|
4197
|
-
|
4198
|
-
|
5091
|
+
const ResizeObserver$2 = window.ResizeObserver || ResizeObserver$3;
|
5092
|
+
class TeleBoxManager {
|
5093
|
+
constructor({
|
5094
|
+
root = null,
|
5095
|
+
prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
|
5096
|
+
minimized = false,
|
5097
|
+
maximized = false,
|
5098
|
+
fence = true,
|
5099
|
+
collector,
|
5100
|
+
namespace = "telebox",
|
5101
|
+
readonly = false,
|
5102
|
+
stageRatio = -1,
|
5103
|
+
containerStyle = "",
|
5104
|
+
stageStyle = "",
|
5105
|
+
defaultBoxBodyStyle = null,
|
5106
|
+
defaultBoxStageStyle = null
|
5107
|
+
} = {}) {
|
5108
|
+
this.events = new Emittery();
|
5109
|
+
this._sideEffect = new SideEffectManager();
|
5110
|
+
this.namespace = namespace;
|
5111
|
+
const valManager = new ValManager();
|
5112
|
+
this._sideEffect.addDisposer(() => valManager.destroy());
|
5113
|
+
const root$ = new Val(root);
|
5114
|
+
const readonly$ = new Val(readonly);
|
5115
|
+
const minimized$ = new Val(minimized);
|
5116
|
+
const maximized$ = new Val(maximized);
|
5117
|
+
const fence$ = new Val(fence);
|
5118
|
+
const containerStyle$ = new Val(containerStyle);
|
5119
|
+
const stageStyle$ = new Val(stageStyle);
|
5120
|
+
const stageRatio$ = new Val(stageRatio);
|
5121
|
+
const defaultBoxBodyStyle$ = new Val(defaultBoxBodyStyle);
|
5122
|
+
const defaultBoxStageStyle$ = new Val(defaultBoxStageStyle);
|
5123
|
+
const rootRect$ = new Val({
|
5124
|
+
x: 0,
|
5125
|
+
y: 0,
|
5126
|
+
width: window.innerWidth,
|
5127
|
+
height: window.innerHeight
|
5128
|
+
}, { compare: shallowequal });
|
5129
|
+
this._sideEffect.addDisposer(root$.subscribe((root2) => {
|
4199
5130
|
this._sideEffect.add(() => {
|
4200
|
-
if (!
|
4201
|
-
return () =>
|
4202
|
-
|
4203
|
-
const
|
4204
|
-
const
|
4205
|
-
|
5131
|
+
if (!root2) {
|
5132
|
+
return () => void 0;
|
5133
|
+
}
|
5134
|
+
const observer = new ResizeObserver$2(() => {
|
5135
|
+
const rect = root2.getBoundingClientRect();
|
5136
|
+
rootRect$.setValue({
|
5137
|
+
x: 0,
|
5138
|
+
y: 0,
|
5139
|
+
width: rect.width,
|
5140
|
+
height: rect.height
|
5141
|
+
});
|
4206
5142
|
});
|
4207
|
-
|
5143
|
+
observer.observe(root2);
|
5144
|
+
return () => observer.disconnect();
|
4208
5145
|
}, "calc-root-rect");
|
4209
|
-
})), this.boxes$ = new Val([]), this.topBox$ = new Val(void 0), this._sideEffect.addDisposer(this.boxes$.subscribe((e3) => {
|
4210
|
-
if (e3.length > 0) {
|
4211
|
-
const t3 = e3.reduce((e4, t4) => e4.zIndex > t4.zIndex ? e4 : t4);
|
4212
|
-
this.topBox$.setValue(t3);
|
4213
|
-
} else
|
4214
|
-
this.topBox$.setValue(void 0);
|
4215
5146
|
}));
|
4216
|
-
const
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
5147
|
+
const stageRect$ = combine([rootRect$, stageRatio$], calcStageRect, {
|
5148
|
+
compare: shallowequal
|
5149
|
+
});
|
5150
|
+
this.boxes$ = new Val([]);
|
5151
|
+
this.topBox$ = new Val(void 0);
|
5152
|
+
this._sideEffect.addDisposer(this.boxes$.subscribe((boxes) => {
|
5153
|
+
if (boxes.length > 0) {
|
5154
|
+
const topBox = boxes.reduce((topBox2, box) => topBox2.zIndex > box.zIndex ? topBox2 : box);
|
5155
|
+
this.topBox$.setValue(topBox);
|
5156
|
+
} else {
|
5157
|
+
this.topBox$.setValue(void 0);
|
5158
|
+
}
|
4222
5159
|
}));
|
4223
|
-
const
|
4224
|
-
|
4225
|
-
|
5160
|
+
const prefersDarkMatch = window.matchMedia("(prefers-color-scheme: dark)");
|
5161
|
+
const prefersDark$ = new Val(false);
|
5162
|
+
if (prefersDarkMatch) {
|
5163
|
+
prefersDark$.setValue(prefersDarkMatch.matches);
|
5164
|
+
this._sideEffect.add(() => {
|
5165
|
+
const handler = (evt) => {
|
5166
|
+
prefersDark$.setValue(evt.matches);
|
5167
|
+
};
|
5168
|
+
prefersDarkMatch.addEventListener("change", handler);
|
5169
|
+
return () => prefersDarkMatch.removeEventListener("change", handler);
|
5170
|
+
});
|
5171
|
+
}
|
5172
|
+
const prefersColorScheme$ = new Val(prefersColorScheme);
|
5173
|
+
this._sideEffect.addDisposer(prefersColorScheme$.reaction((prefersColorScheme2, skipUpdate) => {
|
5174
|
+
if (!skipUpdate) {
|
5175
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.PrefersColorScheme, prefersColorScheme2);
|
5176
|
+
}
|
4226
5177
|
}));
|
4227
|
-
const
|
4228
|
-
|
4229
|
-
|
4230
|
-
|
4231
|
-
|
4232
|
-
|
4233
|
-
|
4234
|
-
|
4235
|
-
|
4236
|
-
|
5178
|
+
const darkMode$ = combine([prefersDark$, prefersColorScheme$], ([prefersDark, prefersColorScheme2]) => prefersColorScheme2 === "auto" ? prefersDark : prefersColorScheme2 === "dark");
|
5179
|
+
const state$ = combine([minimized$, maximized$], ([minimized2, maximized2]) => minimized2 ? TELE_BOX_STATE.Minimized : maximized2 ? TELE_BOX_STATE.Maximized : TELE_BOX_STATE.Normal);
|
5180
|
+
this.collector = collector != null ? collector : new TeleBoxCollector({
|
5181
|
+
minimized$,
|
5182
|
+
readonly$,
|
5183
|
+
darkMode$,
|
5184
|
+
namespace,
|
5185
|
+
root$
|
5186
|
+
});
|
5187
|
+
const readonlyValConfig = {
|
5188
|
+
darkMode: darkMode$,
|
5189
|
+
state: state$,
|
5190
|
+
root: root$,
|
5191
|
+
rootRect: rootRect$,
|
5192
|
+
stageRect: stageRect$
|
5193
|
+
};
|
5194
|
+
withReadonlyValueEnhancer(this, readonlyValConfig, valManager);
|
5195
|
+
const valConfig = {
|
5196
|
+
prefersColorScheme: prefersColorScheme$,
|
5197
|
+
readonly: readonly$,
|
5198
|
+
fence: fence$,
|
5199
|
+
minimized: minimized$,
|
5200
|
+
maximized: maximized$,
|
5201
|
+
stageRatio: stageRatio$,
|
5202
|
+
containerStyle: containerStyle$,
|
5203
|
+
stageStyle: stageStyle$,
|
5204
|
+
defaultBoxBodyStyle: defaultBoxBodyStyle$,
|
5205
|
+
defaultBoxStageStyle: defaultBoxStageStyle$
|
5206
|
+
};
|
5207
|
+
withValueEnhancer(this, valConfig, valManager);
|
5208
|
+
const closeBtnClassName = this.wrapClassName("titlebar-icon-close");
|
5209
|
+
const checkFocusBox = (ev) => {
|
5210
|
+
var _a;
|
5211
|
+
if (!ev.isPrimary || readonly$.value) {
|
5212
|
+
return;
|
5213
|
+
}
|
5214
|
+
const target = ev.target;
|
5215
|
+
if (!target.tagName) {
|
4237
5216
|
return;
|
4238
|
-
|
4239
|
-
|
4240
|
-
|
4241
|
-
|
5217
|
+
}
|
5218
|
+
for (let el = target; el; el = el.parentElement) {
|
5219
|
+
if (el.classList && el.classList.contains(closeBtnClassName)) {
|
5220
|
+
return;
|
5221
|
+
}
|
5222
|
+
const id2 = (_a = el.dataset) == null ? void 0 : _a.teleBoxID;
|
5223
|
+
if (id2) {
|
5224
|
+
const box = this.getBox(id2);
|
5225
|
+
if (box) {
|
5226
|
+
this.focusBox(box);
|
5227
|
+
this.makeBoxTop(box);
|
4242
5228
|
return;
|
4243
|
-
const e4 = (t3 = s3.dataset) == null ? void 0 : t3.teleBoxID;
|
4244
|
-
if (e4) {
|
4245
|
-
const t4 = this.getBox(e4);
|
4246
|
-
if (t4)
|
4247
|
-
return this.focusBox(t4), void this.makeBoxTop(t4);
|
4248
5229
|
}
|
4249
5230
|
}
|
5231
|
+
}
|
4250
5232
|
};
|
4251
|
-
this._sideEffect.addEventListener(window, "
|
4252
|
-
|
4253
|
-
|
4254
|
-
|
4255
|
-
|
4256
|
-
|
4257
|
-
|
4258
|
-
|
4259
|
-
|
4260
|
-
|
4261
|
-
}
|
4262
|
-
|
4263
|
-
|
4264
|
-
|
4265
|
-
|
4266
|
-
|
4267
|
-
|
4268
|
-
|
4269
|
-
|
4270
|
-
|
5233
|
+
this._sideEffect.addEventListener(window, "pointerdown", checkFocusBox, true);
|
5234
|
+
this.$container = document.createElement("div");
|
5235
|
+
this.$container.className = this.wrapClassName("manager-container");
|
5236
|
+
this.$stage = document.createElement("div");
|
5237
|
+
this.$stage.className = this.wrapClassName("manager-stage");
|
5238
|
+
this.$container.appendChild(this.$stage);
|
5239
|
+
this._sideEffect.addDisposer([
|
5240
|
+
darkMode$.subscribe((darkMode) => {
|
5241
|
+
this.$container.classList.toggle(this.wrapClassName("color-scheme-dark"), darkMode);
|
5242
|
+
this.$container.classList.toggle(this.wrapClassName("color-scheme-light"), !darkMode);
|
5243
|
+
}),
|
5244
|
+
maximized$.subscribe((maximized2) => {
|
5245
|
+
this.$container.classList.toggle("is-maximized", maximized2);
|
5246
|
+
}),
|
5247
|
+
minimized$.subscribe((minimized2) => {
|
5248
|
+
this.$container.classList.toggle("is-minimized", minimized2);
|
5249
|
+
}),
|
5250
|
+
containerStyle$.subscribe((containerStyle2) => {
|
5251
|
+
this.$container.style.cssText = containerStyle2;
|
5252
|
+
}),
|
5253
|
+
stageStyle$.subscribe((stageStyle2) => {
|
5254
|
+
this.$stage.style.cssText = stageStyle2;
|
5255
|
+
this.$stage.style.width = stageRect$.value.width + "px";
|
5256
|
+
this.$stage.style.height = stageRect$.value.height + "px";
|
5257
|
+
}),
|
5258
|
+
stageRect$.subscribe((stageRect) => {
|
5259
|
+
this.$stage.style.width = stageRect.width + "px";
|
5260
|
+
this.$stage.style.height = stageRect.height + "px";
|
5261
|
+
}),
|
5262
|
+
root$.subscribe((root2) => {
|
5263
|
+
if (root2) {
|
5264
|
+
root2.appendChild(this.$container);
|
5265
|
+
} else if (this.$container.parentElement) {
|
5266
|
+
this.$container.remove();
|
5267
|
+
}
|
5268
|
+
})
|
5269
|
+
]);
|
5270
|
+
this.titleBar = new MaxTitleBar({
|
5271
|
+
namespace: this.namespace,
|
5272
|
+
title$: derive(this.topBox$, (topBox) => (topBox == null ? void 0 : topBox.title) || ""),
|
5273
|
+
boxes$: this.boxes$,
|
5274
|
+
darkMode$,
|
5275
|
+
readonly$,
|
5276
|
+
state$,
|
5277
|
+
rootRect$,
|
5278
|
+
root: this.$container,
|
5279
|
+
onEvent: (event) => {
|
5280
|
+
switch (event.type) {
|
5281
|
+
case TELE_BOX_DELEGATE_EVENT.Maximize: {
|
5282
|
+
maximized$.setValue(!maximized$.value);
|
5283
|
+
break;
|
5284
|
+
}
|
5285
|
+
case TELE_BOX_DELEGATE_EVENT.Minimize: {
|
5286
|
+
minimized$.setValue(true);
|
5287
|
+
break;
|
5288
|
+
}
|
5289
|
+
case TELE_BOX_EVENT.Close: {
|
5290
|
+
this.removeTopBox();
|
5291
|
+
this.focusTopBox();
|
5292
|
+
break;
|
5293
|
+
}
|
5294
|
+
}
|
5295
|
+
}
|
5296
|
+
});
|
5297
|
+
this._sideEffect.addDisposer([
|
5298
|
+
state$.reaction((state, skipUpdate) => {
|
5299
|
+
if (!skipUpdate) {
|
5300
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.State, state);
|
5301
|
+
}
|
5302
|
+
}),
|
5303
|
+
maximized$.reaction((maximized2, skipUpdate) => {
|
5304
|
+
if (!skipUpdate) {
|
5305
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Maximized, maximized2);
|
5306
|
+
}
|
5307
|
+
}),
|
5308
|
+
minimized$.reaction((minimized2, skipUpdate) => {
|
5309
|
+
if (!skipUpdate) {
|
5310
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Minimized, minimized2);
|
5311
|
+
}
|
5312
|
+
}),
|
5313
|
+
darkMode$.reaction((darkMode, skipUpdate) => {
|
5314
|
+
if (!skipUpdate) {
|
5315
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.DarkMode, darkMode);
|
5316
|
+
}
|
5317
|
+
})
|
5318
|
+
]);
|
4271
5319
|
}
|
4272
5320
|
get boxes() {
|
4273
5321
|
return this.boxes$.value;
|
@@ -4275,149 +5323,305 @@ class F$3 {
|
|
4275
5323
|
get topBox() {
|
4276
5324
|
return this.topBox$.value;
|
4277
5325
|
}
|
4278
|
-
setState(
|
4279
|
-
switch (
|
4280
|
-
case
|
4281
|
-
this.setMinimized(false,
|
5326
|
+
setState(state, skipUpdate = false) {
|
5327
|
+
switch (state) {
|
5328
|
+
case TELE_BOX_STATE.Maximized: {
|
5329
|
+
this.setMinimized(false, skipUpdate);
|
5330
|
+
this.setMaximized(true, skipUpdate);
|
4282
5331
|
break;
|
4283
|
-
|
4284
|
-
|
5332
|
+
}
|
5333
|
+
case TELE_BOX_STATE.Minimized: {
|
5334
|
+
this.setMinimized(true, skipUpdate);
|
5335
|
+
this.setMaximized(false, skipUpdate);
|
4285
5336
|
break;
|
4286
|
-
|
4287
|
-
|
5337
|
+
}
|
5338
|
+
default: {
|
5339
|
+
this.setMinimized(false, skipUpdate);
|
5340
|
+
this.setMaximized(false, skipUpdate);
|
5341
|
+
break;
|
5342
|
+
}
|
4288
5343
|
}
|
4289
5344
|
return this;
|
4290
5345
|
}
|
4291
|
-
create(
|
4292
|
-
const
|
4293
|
-
|
4294
|
-
|
4295
|
-
this.
|
4296
|
-
|
4297
|
-
this.
|
4298
|
-
|
4299
|
-
|
4300
|
-
|
4301
|
-
|
4302
|
-
|
4303
|
-
|
4304
|
-
|
4305
|
-
|
4306
|
-
|
4307
|
-
|
4308
|
-
|
4309
|
-
|
4310
|
-
|
4311
|
-
|
4312
|
-
|
4313
|
-
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4318
|
-
|
4319
|
-
|
4320
|
-
|
4321
|
-
|
5346
|
+
create(config = {}, smartPosition = true) {
|
5347
|
+
const box = new TeleBox(__spreadProps(__spreadValues(__spreadValues({
|
5348
|
+
zIndex: this.topBox ? this.topBox.zIndex + 1 : 100
|
5349
|
+
}, config), smartPosition ? this.smartPosition(config) : {}), {
|
5350
|
+
namespace: this.namespace,
|
5351
|
+
root: this.$stage,
|
5352
|
+
darkMode$: this._darkMode$,
|
5353
|
+
maximized$: this._maximized$,
|
5354
|
+
minimized$: this._minimized$,
|
5355
|
+
fence$: this._fence$,
|
5356
|
+
rootRect$: this._rootRect$,
|
5357
|
+
managerStageRect$: this._stageRect$,
|
5358
|
+
managerStageRatio$: this._stageRatio$,
|
5359
|
+
readonly$: this._readonly$,
|
5360
|
+
collectorRect$: this.collector._rect$,
|
5361
|
+
defaultBoxBodyStyle$: this._defaultBoxBodyStyle$,
|
5362
|
+
defaultBoxStageStyle$: this._defaultBoxStageStyle$
|
5363
|
+
}));
|
5364
|
+
if (box.focus) {
|
5365
|
+
this.focusBox(box);
|
5366
|
+
if (smartPosition) {
|
5367
|
+
this.makeBoxTop(box);
|
5368
|
+
}
|
5369
|
+
}
|
5370
|
+
this.boxes$.setValue([...this.boxes, box]);
|
5371
|
+
this._sideEffect.addDisposer([
|
5372
|
+
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
|
5373
|
+
this.setMaximized(!this.maximized);
|
5374
|
+
}),
|
5375
|
+
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
|
5376
|
+
this.setMinimized(true);
|
5377
|
+
}),
|
5378
|
+
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
|
5379
|
+
this.remove(box);
|
5380
|
+
this.focusTopBox();
|
5381
|
+
}),
|
5382
|
+
box._intrinsicCoord$.reaction((_, skipUpdate) => {
|
5383
|
+
if (!skipUpdate) {
|
5384
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.IntrinsicMove, box);
|
5385
|
+
}
|
5386
|
+
}),
|
5387
|
+
box._intrinsicSize$.reaction((_, skipUpdate) => {
|
5388
|
+
if (!skipUpdate) {
|
5389
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.IntrinsicResize, box);
|
5390
|
+
}
|
5391
|
+
}),
|
5392
|
+
box._zIndex$.reaction((_, skipUpdate) => {
|
5393
|
+
if (this.boxes.length > 0) {
|
5394
|
+
const topBox = this.boxes.reduce((topBox2, box2) => topBox2.zIndex > box2.zIndex ? topBox2 : box2);
|
5395
|
+
this.topBox$.setValue(topBox);
|
5396
|
+
}
|
5397
|
+
if (!skipUpdate) {
|
5398
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.ZIndex, box);
|
5399
|
+
}
|
5400
|
+
})
|
5401
|
+
]);
|
5402
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Created, box);
|
5403
|
+
return box;
|
5404
|
+
}
|
5405
|
+
query(config) {
|
5406
|
+
return config ? this.boxes.filter(this.teleBoxMatcher(config)) : [...this.boxes];
|
5407
|
+
}
|
5408
|
+
queryOne(config) {
|
5409
|
+
return config ? this.boxes.find(this.teleBoxMatcher(config)) : this.boxes[0];
|
5410
|
+
}
|
5411
|
+
update(boxID, config, skipUpdate = false) {
|
5412
|
+
const box = this.boxes.find((box2) => box2.id === boxID);
|
5413
|
+
if (box) {
|
5414
|
+
return this.updateBox(box, config, skipUpdate);
|
5415
|
+
}
|
4322
5416
|
}
|
4323
|
-
updateAll(
|
4324
|
-
this.boxes.forEach((
|
4325
|
-
this.updateBox(
|
5417
|
+
updateAll(config, skipUpdate = false) {
|
5418
|
+
this.boxes.forEach((box) => {
|
5419
|
+
this.updateBox(box, config, skipUpdate);
|
4326
5420
|
});
|
4327
5421
|
}
|
4328
|
-
remove(
|
4329
|
-
const
|
4330
|
-
if (
|
4331
|
-
const
|
4332
|
-
|
5422
|
+
remove(boxOrID, skipUpdate = false) {
|
5423
|
+
const index2 = this.getBoxIndex(boxOrID);
|
5424
|
+
if (index2 >= 0) {
|
5425
|
+
const boxes = this.boxes.slice();
|
5426
|
+
const deletedBoxes = boxes.splice(index2, 1);
|
5427
|
+
this.boxes$.setValue(boxes);
|
5428
|
+
deletedBoxes.forEach((box) => box.destroy());
|
5429
|
+
if (!skipUpdate) {
|
5430
|
+
if (this.boxes.length <= 0) {
|
5431
|
+
this.setMaximized(false);
|
5432
|
+
this.setMinimized(false);
|
5433
|
+
}
|
5434
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
|
5435
|
+
}
|
5436
|
+
return deletedBoxes[0];
|
4333
5437
|
}
|
5438
|
+
return;
|
4334
5439
|
}
|
4335
5440
|
removeTopBox() {
|
4336
|
-
if (this.topBox)
|
5441
|
+
if (this.topBox) {
|
4337
5442
|
return this.remove(this.topBox);
|
5443
|
+
}
|
5444
|
+
return;
|
4338
5445
|
}
|
4339
|
-
removeAll(
|
4340
|
-
const
|
4341
|
-
|
5446
|
+
removeAll(skipUpdate = false) {
|
5447
|
+
const deletedBoxes = this.boxes$.value;
|
5448
|
+
this.boxes$.setValue([]);
|
5449
|
+
deletedBoxes.forEach((box) => box.destroy());
|
5450
|
+
if (!skipUpdate) {
|
5451
|
+
if (this.boxes.length <= 0) {
|
5452
|
+
this.setMaximized(false);
|
5453
|
+
this.setMinimized(false);
|
5454
|
+
}
|
5455
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
|
5456
|
+
}
|
5457
|
+
return deletedBoxes;
|
4342
5458
|
}
|
4343
|
-
mount(
|
4344
|
-
this._root$.setValue(
|
5459
|
+
mount(root) {
|
5460
|
+
this._root$.setValue(root);
|
4345
5461
|
}
|
4346
5462
|
unmount() {
|
4347
5463
|
this._root$.setValue(null);
|
4348
5464
|
}
|
4349
|
-
destroy(
|
4350
|
-
this.events.clearListeners()
|
5465
|
+
destroy(skipUpdate = false) {
|
5466
|
+
this.events.clearListeners();
|
5467
|
+
this._sideEffect.flushAll();
|
5468
|
+
this.removeAll(skipUpdate);
|
5469
|
+
this.collector.destroy();
|
5470
|
+
this.titleBar.destroy();
|
4351
5471
|
}
|
4352
|
-
wrapClassName(
|
4353
|
-
return `${this.namespace}-${
|
5472
|
+
wrapClassName(className) {
|
5473
|
+
return `${this.namespace}-${className}`;
|
4354
5474
|
}
|
4355
|
-
focusBox(
|
4356
|
-
const
|
4357
|
-
|
4358
|
-
|
4359
|
-
|
4360
|
-
|
4361
|
-
|
4362
|
-
|
4363
|
-
|
5475
|
+
focusBox(boxOrID, skipUpdate = false) {
|
5476
|
+
const targetBox = this.getBox(boxOrID);
|
5477
|
+
if (targetBox) {
|
5478
|
+
this.boxes.forEach((box) => {
|
5479
|
+
if (targetBox === box) {
|
5480
|
+
let focusChanged = false;
|
5481
|
+
if (!targetBox.focus) {
|
5482
|
+
focusChanged = true;
|
5483
|
+
targetBox._focus$.setValue(true, skipUpdate);
|
5484
|
+
}
|
5485
|
+
if (focusChanged && !skipUpdate) {
|
5486
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Focused, targetBox);
|
5487
|
+
}
|
5488
|
+
} else if (box.focus) {
|
5489
|
+
this.blurBox(box, skipUpdate);
|
5490
|
+
}
|
5491
|
+
});
|
5492
|
+
this.titleBar.focusBox(targetBox);
|
5493
|
+
}
|
4364
5494
|
}
|
4365
5495
|
focusTopBox() {
|
4366
|
-
if (this.topBox && !this.topBox.focus)
|
5496
|
+
if (this.topBox && !this.topBox.focus) {
|
4367
5497
|
return this.focusBox(this.topBox);
|
5498
|
+
}
|
4368
5499
|
}
|
4369
|
-
blurBox(
|
4370
|
-
const
|
4371
|
-
|
4372
|
-
|
4373
|
-
|
4374
|
-
|
4375
|
-
|
4376
|
-
|
5500
|
+
blurBox(boxOrID, skipUpdate = false) {
|
5501
|
+
const targetBox = this.getBox(boxOrID);
|
5502
|
+
if (targetBox) {
|
5503
|
+
if (targetBox.focus) {
|
5504
|
+
targetBox._focus$.setValue(false, skipUpdate);
|
5505
|
+
if (!skipUpdate) {
|
5506
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Blurred, targetBox);
|
5507
|
+
}
|
5508
|
+
}
|
5509
|
+
if (this.titleBar.focusedBox === targetBox) {
|
5510
|
+
this.titleBar.focusBox();
|
5511
|
+
}
|
5512
|
+
}
|
4377
5513
|
}
|
4378
|
-
|
4379
|
-
|
4380
|
-
|
5514
|
+
blurAll(skipUpdate = false) {
|
5515
|
+
this.boxes.forEach((box) => {
|
5516
|
+
if (box.focus) {
|
5517
|
+
box._focus$.setValue(false, skipUpdate);
|
5518
|
+
if (!skipUpdate) {
|
5519
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Blurred, box);
|
5520
|
+
}
|
5521
|
+
}
|
5522
|
+
});
|
5523
|
+
if (this.titleBar.focusedBox) {
|
5524
|
+
this.titleBar.focusBox();
|
5525
|
+
}
|
4381
5526
|
}
|
4382
|
-
|
4383
|
-
|
4384
|
-
|
5527
|
+
teleBoxMatcher(config) {
|
5528
|
+
const keys = Object.keys(config);
|
5529
|
+
return (box) => keys.every((key) => config[key] === box[key]);
|
4385
5530
|
}
|
4386
|
-
|
4387
|
-
|
4388
|
-
|
4389
|
-
|
4390
|
-
|
4391
|
-
|
4392
|
-
|
4393
|
-
|
5531
|
+
updateBox(box, config, skipUpdate = false) {
|
5532
|
+
var _a, _b, _c, _d, _e, _f;
|
5533
|
+
if (config.x != null || config.y != null) {
|
5534
|
+
box._intrinsicCoord$.setValue({
|
5535
|
+
x: (_a = config.x) != null ? _a : box.intrinsicX,
|
5536
|
+
y: (_b = config.y) != null ? _b : box.intrinsicY
|
5537
|
+
}, skipUpdate);
|
5538
|
+
}
|
5539
|
+
if (config.width != null || config.height != null) {
|
5540
|
+
box._intrinsicSize$.setValue({
|
5541
|
+
width: (_c = config.width) != null ? _c : box.intrinsicWidth,
|
5542
|
+
height: (_d = config.height) != null ? _d : box.intrinsicHeight
|
5543
|
+
}, skipUpdate);
|
5544
|
+
}
|
5545
|
+
if (config.title != null) {
|
5546
|
+
box._title$.setValue(config.title);
|
5547
|
+
}
|
5548
|
+
if (config.visible != null) {
|
5549
|
+
box._visible$.setValue(config.visible, skipUpdate);
|
5550
|
+
}
|
5551
|
+
if (config.resizable != null) {
|
5552
|
+
box._resizable$.setValue(config.resizable, skipUpdate);
|
5553
|
+
}
|
5554
|
+
if (config.draggable != null) {
|
5555
|
+
box._draggable$.setValue(config.draggable, skipUpdate);
|
5556
|
+
}
|
5557
|
+
if (config.boxRatio != null) {
|
5558
|
+
box._boxRatio$.setValue(config.boxRatio, skipUpdate);
|
5559
|
+
}
|
5560
|
+
if (config.zIndex != null) {
|
5561
|
+
box._zIndex$.setValue(config.zIndex, skipUpdate);
|
5562
|
+
}
|
5563
|
+
if (config.stageRatio !== void 0) {
|
5564
|
+
box.setStageRatio(config.stageRatio, skipUpdate);
|
5565
|
+
}
|
5566
|
+
if (config.content != null) {
|
5567
|
+
box.mountContent(config.content);
|
5568
|
+
}
|
5569
|
+
if (config.footer != null) {
|
5570
|
+
box.mountFooter(config.footer);
|
5571
|
+
}
|
5572
|
+
if (config.minHeight != null || config.minWidth != null) {
|
5573
|
+
box._minSize$.setValue({
|
5574
|
+
width: (_e = config.minWidth) != null ? _e : box.minWidth,
|
5575
|
+
height: (_f = config.minHeight) != null ? _f : box.minHeight
|
5576
|
+
}, skipUpdate);
|
5577
|
+
}
|
5578
|
+
}
|
5579
|
+
smartPosition(rect) {
|
5580
|
+
let { x: x2, y: y2 } = rect;
|
5581
|
+
const { width = 0.5, height = 0.5 } = rect;
|
5582
|
+
const stageRect = this.stageRect;
|
5583
|
+
const topBox = this.topBox;
|
5584
|
+
if (x2 == null) {
|
5585
|
+
let pxX = 20;
|
5586
|
+
if (topBox) {
|
5587
|
+
const pxPreferredX = topBox.pxIntrinsicCoord.x + 20;
|
5588
|
+
const pxIntrinsicWidth = width * stageRect.width;
|
5589
|
+
if (pxPreferredX + pxIntrinsicWidth <= stageRect.width) {
|
5590
|
+
pxX = pxPreferredX;
|
5591
|
+
}
|
4394
5592
|
}
|
4395
|
-
|
5593
|
+
x2 = pxX / stageRect.width;
|
4396
5594
|
}
|
4397
|
-
if (
|
4398
|
-
let
|
4399
|
-
if (
|
4400
|
-
const
|
4401
|
-
|
5595
|
+
if (y2 == null) {
|
5596
|
+
let pxY = 20;
|
5597
|
+
if (topBox) {
|
5598
|
+
const pxPreferredY = topBox.pxIntrinsicCoord.y + 20;
|
5599
|
+
const pxIntrinsicHeight = height * stageRect.height;
|
5600
|
+
if (pxPreferredY + pxIntrinsicHeight <= stageRect.height) {
|
5601
|
+
pxY = pxPreferredY;
|
5602
|
+
}
|
4402
5603
|
}
|
4403
|
-
|
5604
|
+
y2 = pxY / stageRect.height;
|
4404
5605
|
}
|
4405
|
-
return { x:
|
5606
|
+
return { x: x2, y: y2, width, height };
|
4406
5607
|
}
|
4407
|
-
makeBoxTop(
|
4408
|
-
|
5608
|
+
makeBoxTop(box, skipUpdate = false) {
|
5609
|
+
if (this.topBox) {
|
5610
|
+
if (box !== this.topBox) {
|
5611
|
+
box._zIndex$.setValue(this.topBox.zIndex + 1, skipUpdate);
|
5612
|
+
}
|
5613
|
+
}
|
4409
5614
|
}
|
4410
|
-
getBoxIndex(
|
4411
|
-
return typeof
|
5615
|
+
getBoxIndex(boxOrID) {
|
5616
|
+
return typeof boxOrID === "string" ? this.boxes.findIndex((box) => box.id === boxOrID) : this.boxes.findIndex((box) => box === boxOrID);
|
4412
5617
|
}
|
4413
|
-
getBox(
|
4414
|
-
return typeof
|
5618
|
+
getBox(boxOrID) {
|
5619
|
+
return typeof boxOrID === "string" ? this.boxes.find((box) => box.id === boxOrID) : boxOrID;
|
4415
5620
|
}
|
4416
5621
|
}
|
4417
5622
|
const createBoxManager = (manager, callbacks2, emitter2, boxEmitter2, options) => {
|
4418
5623
|
return new BoxManager({
|
4419
5624
|
safeSetAttributes: (attributes) => manager.safeSetAttributes(attributes),
|
4420
|
-
getMainView: () => manager.mainView,
|
4421
5625
|
updateAppState: (...args) => {
|
4422
5626
|
var _a;
|
4423
5627
|
return (_a = manager.appManager) == null ? void 0 : _a.store.updateAppState(...args);
|
@@ -4447,17 +5651,17 @@ class BoxManager {
|
|
4447
5651
|
const { emitter: emitter2, callbacks: callbacks2, boxEmitter: boxEmitter2 } = context;
|
4448
5652
|
this.teleBoxManager = this.setupBoxManager(createTeleBoxManagerConfig);
|
4449
5653
|
this.sideEffectManager.add(() => [
|
4450
|
-
this.teleBoxManager.
|
5654
|
+
this.teleBoxManager.onValChanged("state", (state) => {
|
4451
5655
|
callbacks2.emit("boxStateChange", state);
|
4452
5656
|
emitter2.emit("boxStateChange", state);
|
4453
5657
|
}),
|
4454
|
-
this.teleBoxManager.
|
5658
|
+
this.teleBoxManager.onValChanged("darkMode", (darkMode) => {
|
4455
5659
|
callbacks2.emit("darkModeChange", darkMode);
|
4456
5660
|
}),
|
4457
|
-
this.teleBoxManager.
|
5661
|
+
this.teleBoxManager.onValChanged("prefersColorScheme", (colorScheme) => {
|
4458
5662
|
callbacks2.emit("prefersColorSchemeChange", colorScheme);
|
4459
5663
|
}),
|
4460
|
-
this.teleBoxManager.
|
5664
|
+
this.teleBoxManager.onValChanged("minimized", (minimized, skipUpdate) => {
|
4461
5665
|
if (skipUpdate) {
|
4462
5666
|
return;
|
4463
5667
|
}
|
@@ -4473,7 +5677,7 @@ class BoxManager {
|
|
4473
5677
|
}
|
4474
5678
|
}
|
4475
5679
|
}),
|
4476
|
-
this.teleBoxManager.
|
5680
|
+
this.teleBoxManager.onValChanged("maximized", (maximized, skipUpdate) => {
|
4477
5681
|
if (skipUpdate) {
|
4478
5682
|
return;
|
4479
5683
|
}
|
@@ -4485,7 +5689,11 @@ class BoxManager {
|
|
4485
5689
|
});
|
4486
5690
|
}),
|
4487
5691
|
this.teleBoxManager.events.on("intrinsic_move", debounce((box) => {
|
4488
|
-
boxEmitter2.emit("move", {
|
5692
|
+
boxEmitter2.emit("move", {
|
5693
|
+
appId: box.id,
|
5694
|
+
x: box.intrinsicX,
|
5695
|
+
y: box.intrinsicY
|
5696
|
+
});
|
4489
5697
|
}, 50)),
|
4490
5698
|
this.teleBoxManager.events.on("intrinsic_resize", debounce((box) => {
|
4491
5699
|
boxEmitter2.emit("resize", {
|
@@ -4506,21 +5714,11 @@ class BoxManager {
|
|
4506
5714
|
this.teleBoxManager.events.on("z_index", (box) => {
|
4507
5715
|
this.context.updateAppState(box.id, AppAttributes.ZIndex, box.zIndex);
|
4508
5716
|
}),
|
4509
|
-
this.teleBoxManager._stageRect$.subscribe((stage) => {
|
4510
|
-
emitter2.emit("playgroundSizeChange", stage);
|
4511
|
-
this.context.notifyContainerRectUpdate(stage);
|
4512
|
-
}),
|
4513
|
-
emitter2.on("writableChange", (isWritable) => {
|
4514
|
-
this.teleBoxManager.setHighlightStage(isWritable);
|
4515
|
-
}),
|
4516
5717
|
emitter2.on("containerSizeRatioUpdate", (ratio) => {
|
4517
5718
|
this.teleBoxManager._stageRatio$.setValue(ratio);
|
4518
5719
|
})
|
4519
5720
|
]);
|
4520
5721
|
}
|
4521
|
-
get mainView() {
|
4522
|
-
return this.context.getMainView();
|
4523
|
-
}
|
4524
5722
|
get canOperate() {
|
4525
5723
|
return this.context.canOperate();
|
4526
5724
|
}
|
@@ -4545,11 +5743,14 @@ class BoxManager {
|
|
4545
5743
|
get stageRect() {
|
4546
5744
|
return this.teleBoxManager.stageRect;
|
4547
5745
|
}
|
5746
|
+
get stageRect$() {
|
5747
|
+
return this.teleBoxManager._stageRect$;
|
5748
|
+
}
|
4548
5749
|
createBox(params) {
|
4549
5750
|
var _a, _b, _c;
|
4550
5751
|
if (!this.teleBoxManager)
|
4551
5752
|
return;
|
4552
|
-
let { minwidth = MIN_WIDTH, minheight = MIN_HEIGHT } = (_a = params.app.config) != null ? _a : {};
|
5753
|
+
let { minwidth = MIN_WIDTH, minheight = MIN_HEIGHT, enableShadowDOM = true } = (_a = params.app.config) != null ? _a : {};
|
4553
5754
|
const { width, height } = (_b = params.app.config) != null ? _b : {};
|
4554
5755
|
const title = ((_c = params.options) == null ? void 0 : _c.title) || params.appId;
|
4555
5756
|
const rect = this.teleBoxManager.rootRect;
|
@@ -4565,10 +5766,12 @@ class BoxManager {
|
|
4565
5766
|
minHeight: minheight,
|
4566
5767
|
width,
|
4567
5768
|
height,
|
4568
|
-
id: params.appId
|
5769
|
+
id: params.appId,
|
5770
|
+
enableShadowDOM
|
4569
5771
|
};
|
4570
|
-
this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
5772
|
+
const box = this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4571
5773
|
this.context.emitter.emit(`${params.appId}${Events.WindowCreated}`);
|
5774
|
+
return box;
|
4572
5775
|
}
|
4573
5776
|
setupBoxManager(createTeleBoxManagerConfig) {
|
4574
5777
|
const root = WindowManager.playground;
|
@@ -4578,7 +5781,13 @@ class BoxManager {
|
|
4578
5781
|
fence: false,
|
4579
5782
|
prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme
|
4580
5783
|
};
|
4581
|
-
|
5784
|
+
if (createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.containerStyle) {
|
5785
|
+
initManagerState.containerStyle = createTeleBoxManagerConfig.containerStyle;
|
5786
|
+
}
|
5787
|
+
if (createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.stageStyle) {
|
5788
|
+
initManagerState.stageStyle = createTeleBoxManagerConfig.stageStyle;
|
5789
|
+
}
|
5790
|
+
const manager = new TeleBoxManager(initManagerState);
|
4582
5791
|
if (this.teleBoxManager) {
|
4583
5792
|
this.teleBoxManager.destroy();
|
4584
5793
|
}
|
@@ -4614,13 +5823,15 @@ class BoxManager {
|
|
4614
5823
|
return;
|
4615
5824
|
const box = this.getBox(state.id);
|
4616
5825
|
if (box) {
|
4617
|
-
|
4618
|
-
|
4619
|
-
|
4620
|
-
|
4621
|
-
|
4622
|
-
|
4623
|
-
|
5826
|
+
if (state.size) {
|
5827
|
+
box._intrinsicSize$.setValue(state.size, true);
|
5828
|
+
}
|
5829
|
+
if (state.position) {
|
5830
|
+
box._intrinsicCoord$.setValue(state.position, true);
|
5831
|
+
}
|
5832
|
+
if (state.zIndex) {
|
5833
|
+
box._zIndex$.setValue(state.zIndex, true);
|
5834
|
+
}
|
4624
5835
|
setTimeout(() => {
|
4625
5836
|
if (state.focus) {
|
4626
5837
|
this.teleBoxManager.focusBox(box.id, true);
|
@@ -4636,13 +5847,19 @@ class BoxManager {
|
|
4636
5847
|
}
|
4637
5848
|
}
|
4638
5849
|
moveBox({ appId, x: x2, y: y2 }) {
|
4639
|
-
this.
|
5850
|
+
const box = this.getBox(appId);
|
5851
|
+
if (box) {
|
5852
|
+
box._intrinsicCoord$.setValue({ x: x2, y: y2 }, true);
|
5853
|
+
}
|
4640
5854
|
}
|
4641
5855
|
focusBox({ appId }, skipUpdate = true) {
|
4642
5856
|
this.teleBoxManager.focusBox(appId, skipUpdate);
|
4643
5857
|
}
|
4644
5858
|
resizeBox({ appId, width, height, skipUpdate }) {
|
4645
|
-
this.
|
5859
|
+
const box = this.getBox(appId);
|
5860
|
+
if (box) {
|
5861
|
+
box._intrinsicSize$.setValue({ width, height }, skipUpdate);
|
5862
|
+
}
|
4646
5863
|
}
|
4647
5864
|
setBoxMinSize(params) {
|
4648
5865
|
this.teleBoxManager.update(params.appId, {
|
@@ -5312,11 +6529,14 @@ class Cursor {
|
|
5312
6529
|
let translateX = point.x - 2;
|
5313
6530
|
let translateY = point.y - 18;
|
5314
6531
|
if (type === "app") {
|
5315
|
-
const wrapperRect = this.cursorManager.
|
6532
|
+
const wrapperRect = this.cursorManager.playgroundRect;
|
5316
6533
|
if (wrapperRect) {
|
5317
6534
|
translateX = translateX + rect.x - wrapperRect.x;
|
5318
6535
|
translateY = translateY + rect.y - wrapperRect.y;
|
5319
6536
|
}
|
6537
|
+
} else {
|
6538
|
+
translateX = translateX + rect.x;
|
6539
|
+
translateY = translateY + rect.y;
|
5320
6540
|
}
|
5321
6541
|
if (point.x < 0 || point.x > rect.width || point.y < 0 || point.y > rect.height) {
|
5322
6542
|
(_a = this.component) == null ? void 0 : _a.$set({ visible: false, x: translateX, y: translateY });
|
@@ -5547,7 +6767,6 @@ class CursorManager {
|
|
5547
6767
|
wrapper.removeEventListener("pointerleave", this.mouseLeaveListener);
|
5548
6768
|
};
|
5549
6769
|
});
|
5550
|
-
this.wrapperRect = wrapper.getBoundingClientRect();
|
5551
6770
|
}
|
5552
6771
|
setMainViewDivElement(div) {
|
5553
6772
|
this.mainViewElement = div;
|
@@ -5577,8 +6796,8 @@ class CursorManager {
|
|
5577
6796
|
}
|
5578
6797
|
updateContainerRect() {
|
5579
6798
|
var _a, _b;
|
5580
|
-
this.
|
5581
|
-
this.
|
6799
|
+
this.wrapperRect = (_a = this.manager.boxManager) == null ? void 0 : _a.teleBoxManager.stageRect;
|
6800
|
+
this.playgroundRect = (_b = WindowManager.playground) == null ? void 0 : _b.getBoundingClientRect();
|
5582
6801
|
}
|
5583
6802
|
deleteCursor(uid) {
|
5584
6803
|
this.store.cleanCursor(uid);
|
@@ -5632,18 +6851,22 @@ class ReconnectRefresher {
|
|
5632
6851
|
this.reactors = /* @__PURE__ */ new Map();
|
5633
6852
|
this.disposers = /* @__PURE__ */ new Map();
|
5634
6853
|
this.onPhaseChanged = (phase) => {
|
5635
|
-
var _a;
|
6854
|
+
var _a, _b;
|
5636
6855
|
if (phase === RoomPhase.Reconnecting) {
|
5637
6856
|
this.ctx.emitter.emit("startReconnect");
|
5638
6857
|
}
|
5639
6858
|
if (phase === RoomPhase.Connected && this.phase === RoomPhase.Reconnecting) {
|
5640
|
-
(_a = this.room) == null ? void 0 : _a.
|
6859
|
+
if ((_a = this.room) == null ? void 0 : _a.isWritable) {
|
6860
|
+
(_b = this.room) == null ? void 0 : _b.dispatchMagixEvent(EnsureReconnectEvent, {});
|
6861
|
+
} else {
|
6862
|
+
this.onReconnected();
|
6863
|
+
}
|
5641
6864
|
}
|
5642
6865
|
this.phase = phase;
|
5643
6866
|
};
|
5644
6867
|
this.onReconnected = debounce(() => {
|
5645
6868
|
this._onReconnected();
|
5646
|
-
},
|
6869
|
+
}, 1e3);
|
5647
6870
|
this._onReconnected = () => {
|
5648
6871
|
log("onReconnected refresh reactors");
|
5649
6872
|
this.releaseDisposers();
|
@@ -5691,6 +6914,7 @@ class ReconnectRefresher {
|
|
5691
6914
|
this.reactors.set(id2, func);
|
5692
6915
|
this.disposers.set(id2, func());
|
5693
6916
|
}
|
6917
|
+
return () => this.remove(id2);
|
5694
6918
|
}
|
5695
6919
|
remove(id2) {
|
5696
6920
|
if (this.reactors.has(id2)) {
|
@@ -5762,6 +6986,9 @@ const replaceRoomFunction = (room, manager) => {
|
|
5762
6986
|
room.lockImage = (...args) => manager.lockImage(...args);
|
5763
6987
|
room.lockImages = (...args) => manager.lockImages(...args);
|
5764
6988
|
delegateRemoveScenes(room, manager);
|
6989
|
+
if (!room.dynamicPpt.slideStateAdapter.pptHandler) {
|
6990
|
+
room.dynamicPpt.slideStateAdapter.pptHandler = manager.createPPTHandler();
|
6991
|
+
}
|
5765
6992
|
}
|
5766
6993
|
};
|
5767
6994
|
const delegateRemoveScenes = (room, manager) => {
|
@@ -15309,6 +16536,10 @@ const BuiltinApps = {
|
|
15309
16536
|
DocsViewer: NetlessAppDocsViewer.kind,
|
15310
16537
|
MediaPlayer: K.kind
|
15311
16538
|
};
|
16539
|
+
const BuiltinAppsMap = {
|
16540
|
+
[BuiltinApps.DocsViewer]: NetlessAppDocsViewer,
|
16541
|
+
[BuiltinApps.MediaPlayer]: K
|
16542
|
+
};
|
15312
16543
|
var videoJs = "";
|
15313
16544
|
var style$1 = "";
|
15314
16545
|
var style = "";
|
@@ -15316,20 +16547,20 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15316
16547
|
const _WindowManager = class extends InvisiblePlugin {
|
15317
16548
|
constructor(context) {
|
15318
16549
|
super(context);
|
15319
|
-
this.version = "1.0.0-canary.
|
15320
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
16550
|
+
this.version = "1.0.0-canary.30";
|
16551
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.27", "emittery": "^0.11.0", "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", "@playwright/test": "^1.23.0", "@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/node": "^18.0.0", "@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", "vite-plugin-dts": "^1.2.0", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15321
16552
|
this.emitter = callbacks$1;
|
15322
16553
|
this.viewMode = ViewMode.Broadcaster;
|
16554
|
+
this.viewMode$ = new Val(ViewMode.Broadcaster);
|
15323
16555
|
this.isReplay = isPlayer(this.displayer);
|
15324
16556
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15325
16557
|
_WindowManager.displayer = context.displayer;
|
15326
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
16558
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.27", "emittery": "^0.11.0", "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", "@playwright/test": "^1.23.0", "@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/node": "^18.0.0", "@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", "vite-plugin-dts": "^1.2.0", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15327
16559
|
}
|
15328
16560
|
static async mount(params) {
|
15329
16561
|
var _a;
|
15330
16562
|
const room = params.room;
|
15331
16563
|
_WindowManager.container = params.container;
|
15332
|
-
const containerSizeRatio = params.containerSizeRatio;
|
15333
16564
|
const debug = params.debug;
|
15334
16565
|
const cursor = params.cursor;
|
15335
16566
|
_WindowManager.params = params;
|
@@ -15366,21 +16597,21 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15366
16597
|
if (!manager) {
|
15367
16598
|
throw new Error("[WindowManager]: create manager failed");
|
15368
16599
|
}
|
15369
|
-
if (containerSizeRatio) {
|
15370
|
-
_WindowManager.containerSizeRatio = containerSizeRatio;
|
16600
|
+
if (params.containerSizeRatio) {
|
16601
|
+
_WindowManager.containerSizeRatio = params.containerSizeRatio;
|
15371
16602
|
}
|
16603
|
+
manager.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15372
16604
|
await manager.ensureAttributes();
|
15373
16605
|
manager.appManager = new AppManager(manager);
|
15374
16606
|
manager._pageState = new PageStateImpl(manager.appManager);
|
15375
16607
|
manager.cursorManager = new CursorManager(manager.appManager, Boolean(cursor), params.applianceIcons);
|
15376
|
-
if (containerSizeRatio) {
|
15377
|
-
manager.containerSizeRatio = containerSizeRatio;
|
15378
|
-
}
|
15379
16608
|
manager.boxManager = createBoxManager(manager, callbacks$1, emitter, boxEmitter, {
|
15380
16609
|
collectorContainer: params.collectorContainer,
|
15381
16610
|
collectorStyles: params.collectorStyles,
|
15382
16611
|
prefersColorScheme: params.prefersColorScheme,
|
15383
|
-
stageRatio:
|
16612
|
+
stageRatio: _WindowManager.containerSizeRatio,
|
16613
|
+
containerStyle: params.containerStyle,
|
16614
|
+
stageStyle: params.stageStyle
|
15384
16615
|
});
|
15385
16616
|
(_a = manager.appManager) == null ? void 0 : _a.setBoxManager(manager.boxManager);
|
15386
16617
|
if (params.container) {
|
@@ -15407,22 +16638,22 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15407
16638
|
} catch (error) {
|
15408
16639
|
throw new Error("[WindowManger]: room must be switched to be writable");
|
15409
16640
|
}
|
15410
|
-
manager = await
|
15411
|
-
manager.ensureAttributes();
|
16641
|
+
manager = await createInvisiblePlugin(room);
|
16642
|
+
manager == null ? void 0 : manager.ensureAttributes();
|
15412
16643
|
await wait(500);
|
15413
16644
|
await room.setWritable(false);
|
15414
16645
|
} else {
|
15415
|
-
manager = await
|
16646
|
+
manager = await createInvisiblePlugin(room);
|
15416
16647
|
}
|
15417
16648
|
}
|
15418
16649
|
}
|
15419
16650
|
return manager;
|
15420
16651
|
}
|
15421
|
-
static initContainer(container, overwriteStyles) {
|
16652
|
+
static initContainer(container, target, overwriteStyles) {
|
15422
16653
|
if (!_WindowManager.container) {
|
15423
16654
|
_WindowManager.container = container;
|
15424
16655
|
}
|
15425
|
-
const { playground, mainViewElement } = setupWrapper(container);
|
16656
|
+
const { playground, mainViewElement } = setupWrapper(container, target);
|
15426
16657
|
_WindowManager.playground = playground;
|
15427
16658
|
if (overwriteStyles) {
|
15428
16659
|
const style2 = document.createElement("style");
|
@@ -15435,7 +16666,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15435
16666
|
return appRegister.registered;
|
15436
16667
|
}
|
15437
16668
|
bindContainer(container) {
|
15438
|
-
var _a, _b, _c, _d, _e;
|
16669
|
+
var _a, _b, _c, _d, _e, _f;
|
15439
16670
|
if (isRoom(this.displayer) && this.room.phase !== RoomPhase.Connected) {
|
15440
16671
|
throw new BindContainerRoomPhaseInvalidError();
|
15441
16672
|
}
|
@@ -15444,23 +16675,24 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15444
16675
|
container.appendChild(_WindowManager.container.firstChild);
|
15445
16676
|
}
|
15446
16677
|
} else {
|
15447
|
-
|
16678
|
+
const teleboxContainer = (_a = this.boxManager) == null ? void 0 : _a.teleBoxManager.$stage;
|
16679
|
+
if (_WindowManager.params && teleboxContainer) {
|
15448
16680
|
const params = _WindowManager.params;
|
15449
|
-
const mainViewElement = _WindowManager.initContainer(container, params.overwriteStyles);
|
16681
|
+
const mainViewElement = _WindowManager.initContainer(container, teleboxContainer, params.overwriteStyles);
|
15450
16682
|
if (this.boxManager && _WindowManager.playground) {
|
15451
16683
|
this.boxManager.setRoot(_WindowManager.playground);
|
15452
16684
|
}
|
15453
16685
|
this.bindMainView(mainViewElement, params.disableCameraTransform);
|
15454
16686
|
if (_WindowManager.playground) {
|
15455
|
-
(
|
16687
|
+
(_b = this.cursorManager) == null ? void 0 : _b.setupWrapper(_WindowManager.playground);
|
15456
16688
|
}
|
15457
16689
|
}
|
15458
16690
|
}
|
15459
16691
|
emitter.emit("updateManagerRect");
|
15460
|
-
(
|
15461
|
-
(
|
15462
|
-
(
|
15463
|
-
(
|
16692
|
+
(_c = this.appManager) == null ? void 0 : _c.refresh();
|
16693
|
+
(_d = this.appManager) == null ? void 0 : _d.resetMaximized();
|
16694
|
+
(_e = this.appManager) == null ? void 0 : _e.resetMinimized();
|
16695
|
+
(_f = this.appManager) == null ? void 0 : _f.displayerWritableListener(!this.room.isWritable);
|
15464
16696
|
_WindowManager.container = container;
|
15465
16697
|
}
|
15466
16698
|
bindCollectorContainer(container) {
|
@@ -15600,6 +16832,17 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15600
16832
|
return false;
|
15601
16833
|
}
|
15602
16834
|
}
|
16835
|
+
async jumpPage(index2) {
|
16836
|
+
if (!this.appManager) {
|
16837
|
+
return false;
|
16838
|
+
}
|
16839
|
+
if (index2 < 0 || index2 >= this.pageState.length) {
|
16840
|
+
console.warn(`[WindowManager]: index ${index2} out of range`);
|
16841
|
+
return false;
|
16842
|
+
}
|
16843
|
+
await this.appManager.setMainViewSceneIndex(index2);
|
16844
|
+
return true;
|
16845
|
+
}
|
15603
16846
|
async addPage(params) {
|
15604
16847
|
if (this.appManager) {
|
15605
16848
|
const after = params == null ? void 0 : params.after;
|
@@ -15650,17 +16893,20 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15650
16893
|
addEmitterOnceListener(`destroy-${kind2}`, listener);
|
15651
16894
|
}
|
15652
16895
|
setViewMode(mode) {
|
15653
|
-
var _a
|
16896
|
+
var _a;
|
16897
|
+
log("setViewMode", mode);
|
16898
|
+
const mainViewProxy = (_a = this.appManager) == null ? void 0 : _a.mainViewProxy;
|
15654
16899
|
if (mode === ViewMode.Broadcaster) {
|
15655
16900
|
if (this.canOperate) {
|
15656
|
-
|
16901
|
+
mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
|
15657
16902
|
}
|
15658
|
-
|
16903
|
+
mainViewProxy == null ? void 0 : mainViewProxy.start();
|
15659
16904
|
}
|
15660
16905
|
if (mode === ViewMode.Freedom) {
|
15661
|
-
|
16906
|
+
mainViewProxy == null ? void 0 : mainViewProxy.stop();
|
15662
16907
|
}
|
15663
16908
|
this.viewMode = mode;
|
16909
|
+
this.viewMode$.setValue(mode);
|
15664
16910
|
}
|
15665
16911
|
setBoxState(boxState) {
|
15666
16912
|
if (!this.canOperate)
|
@@ -15705,6 +16951,20 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15705
16951
|
throw new AppManagerNotInitError();
|
15706
16952
|
}
|
15707
16953
|
}
|
16954
|
+
get baseCamera$() {
|
16955
|
+
if (this.appManager) {
|
16956
|
+
return this.appManager.mainViewProxy.camera$;
|
16957
|
+
} else {
|
16958
|
+
throw new AppManagerNotInitError();
|
16959
|
+
}
|
16960
|
+
}
|
16961
|
+
get baseSize$() {
|
16962
|
+
if (this.appManager) {
|
16963
|
+
return this.appManager.mainViewProxy.size$;
|
16964
|
+
} else {
|
16965
|
+
throw new AppManagerNotInitError();
|
16966
|
+
}
|
16967
|
+
}
|
15708
16968
|
get cameraState() {
|
15709
16969
|
if (this.appManager) {
|
15710
16970
|
return this.appManager.mainViewProxy.cameraState;
|
@@ -15798,26 +17058,31 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15798
17058
|
return (_a = this.appManager) == null ? void 0 : _a.closeApp(appId);
|
15799
17059
|
}
|
15800
17060
|
moveCamera(camera) {
|
15801
|
-
var _a;
|
15802
|
-
const pureCamera = omit(camera, ["animationMode"]);
|
15803
17061
|
const mainViewCamera = __spreadValues({}, this.mainView.camera);
|
15804
|
-
|
17062
|
+
const nextCamera = __spreadValues(__spreadValues({}, mainViewCamera), camera);
|
17063
|
+
if (isEqual(nextCamera, mainViewCamera))
|
15805
17064
|
return;
|
15806
|
-
this.
|
15807
|
-
|
15808
|
-
|
15809
|
-
|
15810
|
-
|
15811
|
-
}, 500);
|
17065
|
+
if (!this.appManager)
|
17066
|
+
return;
|
17067
|
+
this.appManager.mainViewProxy.storeCamera(__spreadValues({
|
17068
|
+
id: this.appManager.uid
|
17069
|
+
}, nextCamera));
|
15812
17070
|
}
|
15813
17071
|
moveCameraToContain(rectangle) {
|
15814
|
-
|
15815
|
-
|
15816
|
-
|
15817
|
-
|
15818
|
-
|
15819
|
-
|
15820
|
-
|
17072
|
+
if (!this.appManager)
|
17073
|
+
return;
|
17074
|
+
const mainViewSize = this.appManager.mainViewProxy.size$.value;
|
17075
|
+
if (mainViewSize) {
|
17076
|
+
const wScale = mainViewSize.width / rectangle.width;
|
17077
|
+
const hScale = mainViewSize.height / rectangle.height;
|
17078
|
+
const nextScale = Math.min(wScale, hScale);
|
17079
|
+
this.appManager.mainViewProxy.storeCamera({
|
17080
|
+
id: this.appManager.uid,
|
17081
|
+
scale: nextScale,
|
17082
|
+
centerX: rectangle.originX,
|
17083
|
+
centerY: rectangle.originY
|
17084
|
+
});
|
17085
|
+
}
|
15821
17086
|
}
|
15822
17087
|
convertToPointInWorld(point) {
|
15823
17088
|
return this.mainView.convertToPointInWorld(point);
|
@@ -15928,12 +17193,12 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15928
17193
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.Refresh);
|
15929
17194
|
}
|
15930
17195
|
_refresh() {
|
15931
|
-
var _a, _b
|
17196
|
+
var _a, _b;
|
15932
17197
|
(_a = this.appManager) == null ? void 0 : _a.mainViewProxy.rebind();
|
15933
17198
|
if (_WindowManager.container) {
|
15934
17199
|
this.bindContainer(_WindowManager.container);
|
15935
17200
|
}
|
15936
|
-
(
|
17201
|
+
(_b = this.appManager) == null ? void 0 : _b.refresher.refresh();
|
15937
17202
|
}
|
15938
17203
|
setContainerSizeRatio(ratio) {
|
15939
17204
|
if (!isNumber(ratio)) {
|
@@ -15943,6 +17208,34 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15943
17208
|
this.containerSizeRatio = ratio;
|
15944
17209
|
emitter.emit("containerSizeRatioUpdate", ratio);
|
15945
17210
|
}
|
17211
|
+
setContainerStyle(style2) {
|
17212
|
+
var _a;
|
17213
|
+
(_a = this.boxManager) == null ? void 0 : _a.teleBoxManager.setContainerStyle(style2);
|
17214
|
+
}
|
17215
|
+
setStageStyle(style2) {
|
17216
|
+
var _a;
|
17217
|
+
(_a = this.boxManager) == null ? void 0 : _a.teleBoxManager.setStageStyle(style2);
|
17218
|
+
}
|
17219
|
+
createPPTHandler() {
|
17220
|
+
return {
|
17221
|
+
onPageJumpTo: (_pptUUID, index2) => {
|
17222
|
+
var _a, _b, _c, _d;
|
17223
|
+
(_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);
|
17224
|
+
},
|
17225
|
+
onPageToNext: () => {
|
17226
|
+
var _a, _b, _c, _d;
|
17227
|
+
if (this.focused) {
|
17228
|
+
(_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();
|
17229
|
+
}
|
17230
|
+
},
|
17231
|
+
onPageToPrev: () => {
|
17232
|
+
var _a, _b, _c, _d;
|
17233
|
+
if (this.focused) {
|
17234
|
+
(_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();
|
17235
|
+
}
|
17236
|
+
}
|
17237
|
+
};
|
17238
|
+
}
|
15946
17239
|
isDynamicPPT(scenes) {
|
15947
17240
|
var _a, _b;
|
15948
17241
|
const sceneSrc = (_b = (_a = scenes[0]) == null ? void 0 : _a.ppt) == null ? void 0 : _b.src;
|
@@ -15977,4 +17270,4 @@ WindowManager.debug = false;
|
|
15977
17270
|
WindowManager.containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
15978
17271
|
WindowManager.isCreated = false;
|
15979
17272
|
setupBuiltin();
|
15980
|
-
export { AppCreateError, AppManagerNotInitError, AppNotRegisterError, BindContainerRoomPhaseInvalidError, BoxManagerNotFoundError, BoxNotCreatedError, BuiltinApps, InvalidScenePath, ParamsInvalidError, WhiteWebSDKInvalidError, WindowManager, calculateNextIndex, reconnectRefresher };
|
17273
|
+
export { AppCreateError, AppManagerNotInitError, AppNotRegisterError, BindContainerRoomPhaseInvalidError, BoxManagerNotFoundError, BoxNotCreatedError, BuiltinApps, BuiltinAppsMap, InvalidScenePath, ParamsInvalidError, WhiteWebSDKInvalidError, WindowManager, calculateNextIndex, reconnectRefresher };
|