@netless/window-manager 1.0.0-canary.1 → 1.0.0-canary.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/white-web-sdk.ts +10 -1
- package/dist/App/AppContext.d.ts +16 -15
- package/dist/App/AppPageStateImpl.d.ts +6 -2
- package/dist/App/AppProxy.d.ts +26 -4
- package/dist/App/AppViewSync.d.ts +11 -0
- package/dist/App/WhiteboardView.d.ts +24 -0
- package/dist/App/index.d.ts +1 -0
- package/dist/AppManager.d.ts +5 -3
- package/dist/AttributesDelegate.d.ts +6 -14
- package/dist/BoxManager.d.ts +2 -3
- package/dist/Helper.d.ts +12 -2
- package/dist/InternalEmitter.d.ts +4 -0
- package/dist/Page/PageController.d.ts +1 -0
- package/dist/ReconnectRefresher.d.ts +1 -1
- package/dist/Utils/Common.d.ts +1 -0
- package/dist/View/CameraSynchronizer.d.ts +7 -7
- package/dist/View/MainView.d.ts +0 -1
- package/dist/constants.d.ts +1 -0
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +6 -3
- package/dist/index.es.js +712 -648
- package/dist/index.umd.js +12 -12
- package/dist/style.css +1 -1
- package/dist/typings.d.ts +4 -0
- package/docs/app-context.md +98 -64
- package/docs/develop-app.md +2 -5
- package/package.json +3 -2
- package/pnpm-lock.yaml +11 -5
- package/src/App/AppContext.ts +71 -74
- package/src/App/AppPageStateImpl.ts +25 -6
- package/src/App/AppProxy.ts +206 -26
- package/src/App/AppViewSync.ts +73 -0
- package/src/App/Storage/index.ts +4 -4
- package/src/App/WhiteboardView.ts +89 -0
- package/src/App/index.ts +1 -0
- package/src/AppManager.ts +32 -23
- package/src/AttributesDelegate.ts +14 -17
- package/src/BoxManager.ts +5 -8
- package/src/Helper.ts +10 -1
- package/src/InternalEmitter.ts +4 -0
- package/src/Page/PageController.ts +1 -0
- package/src/ReconnectRefresher.ts +1 -0
- package/src/Utils/Common.ts +6 -0
- package/src/View/CameraSynchronizer.ts +32 -27
- package/src/View/MainView.ts +22 -39
- package/src/constants.ts +2 -0
- package/src/index.ts +18 -3
- package/src/style.css +9 -0
- package/src/typings.ts +4 -0
package/dist/index.es.js
CHANGED
@@ -19,10 +19,11 @@ var __spreadValues = (a2, b2) => {
|
|
19
19
|
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
|
20
20
|
import pRetry from "p-retry";
|
21
21
|
import Emittery from "emittery";
|
22
|
-
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1,
|
23
|
-
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, isPlayer, isRoom,
|
22
|
+
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, isNumber, throttle, delay, pick, isInteger, orderBy, isEmpty, isFunction, isNull } from "lodash";
|
23
|
+
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, isPlayer, isRoom, ApplianceNames, RoomPhase, InvisiblePlugin, ViewMode } from "white-web-sdk";
|
24
24
|
import { v4 } from "uuid";
|
25
25
|
import { genUID, SideEffectManager } from "side-effect-manager";
|
26
|
+
import { Val, combine, ValManager, withReadonlyValueEnhancer, withValueEnhancer, derive } from "value-enhancer";
|
26
27
|
import { ResizeObserver as ResizeObserver$2 } from "@juggle/resize-observer";
|
27
28
|
import p$1 from "video.js";
|
28
29
|
var Events = /* @__PURE__ */ ((Events2) => {
|
@@ -77,6 +78,7 @@ const DEFAULT_CONTAINER_RATIO = 9 / 16;
|
|
77
78
|
const ROOT_DIR = "/";
|
78
79
|
const INIT_DIR = "/init";
|
79
80
|
const SETUP_APP_DELAY = 50;
|
81
|
+
const MAX_PAGE_SIZE = 500;
|
80
82
|
const callbacks$1 = new Emittery();
|
81
83
|
class AppCreateQueue {
|
82
84
|
constructor() {
|
@@ -353,6 +355,11 @@ const setViewFocusScenePath = (view, focusScenePath) => {
|
|
353
355
|
return view;
|
354
356
|
}
|
355
357
|
};
|
358
|
+
const releaseView = (view) => {
|
359
|
+
if (!view.didRelease) {
|
360
|
+
view.release();
|
361
|
+
}
|
362
|
+
};
|
356
363
|
const setScenePath = (room, scenePath) => {
|
357
364
|
if (room && room.isWritable) {
|
358
365
|
if (room.state.sceneState.scenePath !== scenePath) {
|
@@ -688,7 +695,7 @@ class Storage {
|
|
688
695
|
this.id = id2 || null;
|
689
696
|
this._state = {};
|
690
697
|
const rawState = this._getRawState(this._state);
|
691
|
-
if (this._context.
|
698
|
+
if (this._context.isWritable) {
|
692
699
|
if (this.id === null) {
|
693
700
|
if (context.isAddApp && defaultState) {
|
694
701
|
this.setState(defaultState);
|
@@ -748,7 +755,7 @@ class Storage {
|
|
748
755
|
console.error(new Error(`Cannot call setState on destroyed Storage "${this.id}".`));
|
749
756
|
return;
|
750
757
|
}
|
751
|
-
if (!this._context.
|
758
|
+
if (!this._context.isWritable) {
|
752
759
|
console.error(new Error(`Cannot setState on Storage "${this.id}" without writable access`), state);
|
753
760
|
return;
|
754
761
|
}
|
@@ -788,7 +795,7 @@ class Storage {
|
|
788
795
|
console.error(new Error(`Cannot empty destroyed Storage "${this.id}".`));
|
789
796
|
return;
|
790
797
|
}
|
791
|
-
if (!this._context.
|
798
|
+
if (!this._context.isWritable) {
|
792
799
|
console.error(new Error(`Cannot empty Storage "${this.id}" without writable access.`));
|
793
800
|
return;
|
794
801
|
}
|
@@ -798,7 +805,7 @@ class Storage {
|
|
798
805
|
if (this.id === null) {
|
799
806
|
throw new Error(`Cannot delete main Storage`);
|
800
807
|
}
|
801
|
-
if (!this._context.
|
808
|
+
if (!this._context.isWritable) {
|
802
809
|
console.error(new Error(`Cannot delete Storage "${this.id}" without writable access.`));
|
803
810
|
return;
|
804
811
|
}
|
@@ -890,6 +897,104 @@ class Storage {
|
|
890
897
|
}
|
891
898
|
}
|
892
899
|
}
|
900
|
+
class WhiteBoardView {
|
901
|
+
constructor(view, appContext, appProxy, removeViewWrapper, ensureSize) {
|
902
|
+
this.view = view;
|
903
|
+
this.appContext = appContext;
|
904
|
+
this.appProxy = appProxy;
|
905
|
+
this.removeViewWrapper = removeViewWrapper;
|
906
|
+
this.ensureSize = ensureSize;
|
907
|
+
this.nextPage = async () => {
|
908
|
+
const nextIndex = this.pageState.index + 1;
|
909
|
+
return this.jumpPage(nextIndex);
|
910
|
+
};
|
911
|
+
this.prevPage = async () => {
|
912
|
+
const nextIndex = this.pageState.index - 1;
|
913
|
+
return this.jumpPage(nextIndex);
|
914
|
+
};
|
915
|
+
this.jumpPage = async (index2) => {
|
916
|
+
if (index2 < 0 || index2 >= this.pageState.length) {
|
917
|
+
console.warn(`[WindowManager]: index ${index2} out of range`);
|
918
|
+
return false;
|
919
|
+
}
|
920
|
+
this.appProxy.setSceneIndex(index2);
|
921
|
+
return true;
|
922
|
+
};
|
923
|
+
this.addPage = async (params) => {
|
924
|
+
const after = params == null ? void 0 : params.after;
|
925
|
+
const scene = params == null ? void 0 : params.scene;
|
926
|
+
const scenePath = this.appProxy.scenePath;
|
927
|
+
if (!scenePath)
|
928
|
+
return;
|
929
|
+
if (after) {
|
930
|
+
const nextIndex = this.pageState.index + 1;
|
931
|
+
putScenes(this.appContext.room, scenePath, [scene || {}], nextIndex);
|
932
|
+
} else {
|
933
|
+
putScenes(this.appContext.room, scenePath, [scene || {}]);
|
934
|
+
}
|
935
|
+
};
|
936
|
+
this.removePage = async (index2) => {
|
937
|
+
const needRemoveIndex = index2 === void 0 ? this.pageState.index : index2;
|
938
|
+
if (this.pageState.length === 1) {
|
939
|
+
console.warn(`[WindowManager]: can not remove the last page`);
|
940
|
+
return false;
|
941
|
+
}
|
942
|
+
if (needRemoveIndex < 0 || needRemoveIndex >= this.pageState.length) {
|
943
|
+
console.warn(`[WindowManager]: page index ${index2} out of range`);
|
944
|
+
return false;
|
945
|
+
}
|
946
|
+
return this.appProxy.removeSceneByIndex(needRemoveIndex);
|
947
|
+
};
|
948
|
+
const pageState$ = new Val(appProxy.pageState);
|
949
|
+
this.pageState$ = pageState$;
|
950
|
+
appProxy.appEmitter.on("pageStateChange", (pageState) => {
|
951
|
+
pageState$.setValue(pageState);
|
952
|
+
});
|
953
|
+
}
|
954
|
+
get pageState() {
|
955
|
+
return this.pageState$.value;
|
956
|
+
}
|
957
|
+
moveCamera(camera) {
|
958
|
+
this.appProxy.moveCamera(camera);
|
959
|
+
}
|
960
|
+
setRect(rect) {
|
961
|
+
this.appProxy.updateSize(rect.width, rect.height);
|
962
|
+
}
|
963
|
+
destroy() {
|
964
|
+
this.pageState$.destroy();
|
965
|
+
this.removeViewWrapper();
|
966
|
+
}
|
967
|
+
}
|
968
|
+
const setupWrapper = (root) => {
|
969
|
+
const playground = document.createElement("div");
|
970
|
+
playground.className = "netless-window-manager-playground";
|
971
|
+
const mainViewElement = document.createElement("div");
|
972
|
+
mainViewElement.className = "netless-window-manager-main-view";
|
973
|
+
playground.appendChild(mainViewElement);
|
974
|
+
root.appendChild(playground);
|
975
|
+
return { playground, mainViewElement };
|
976
|
+
};
|
977
|
+
const checkVersion = () => {
|
978
|
+
const version = getVersionNumber(WhiteVersion);
|
979
|
+
if (version < getVersionNumber(REQUIRE_VERSION)) {
|
980
|
+
throw new WhiteWebSDKInvalidError(REQUIRE_VERSION);
|
981
|
+
}
|
982
|
+
};
|
983
|
+
const findMemberByUid = (room, uid) => {
|
984
|
+
const roomMembers = room == null ? void 0 : room.state.roomMembers;
|
985
|
+
return roomMembers == null ? void 0 : roomMembers.find((member) => {
|
986
|
+
var _a;
|
987
|
+
return ((_a = member.payload) == null ? void 0 : _a.uid) === uid;
|
988
|
+
});
|
989
|
+
};
|
990
|
+
const serializeRoomMembers = (members) => {
|
991
|
+
return members.map((member) => {
|
992
|
+
var _a;
|
993
|
+
return __spreadValues({
|
994
|
+
uid: ((_a = member.payload) == null ? void 0 : _a.uid) || ""
|
995
|
+
}, member);
|
996
|
+
});
|
997
|
+
};
|
893
998
|
class AppContext {
|
894
999
|
constructor(manager, boxManager, appId, appProxy, appOptions) {
|
895
1000
|
this.manager = manager;
|
@@ -910,9 +1015,6 @@ class AppContext {
|
|
910
1015
|
};
|
911
1016
|
this.store = this.manager.store;
|
912
1017
|
this.isReplay = this.manager.isReplay;
|
913
|
-
this.getDisplayer = () => {
|
914
|
-
return this.manager.displayer;
|
915
|
-
};
|
916
1018
|
this.getAttributes = () => {
|
917
1019
|
return this.appProxy.attributes;
|
918
1020
|
};
|
@@ -924,36 +1026,50 @@ class AppContext {
|
|
924
1026
|
return appAttr == null ? void 0 : appAttr.options["scenes"];
|
925
1027
|
}
|
926
1028
|
};
|
927
|
-
this.
|
928
|
-
|
1029
|
+
this.createWhiteBoardView = (size2) => {
|
1030
|
+
var _a;
|
1031
|
+
if (this.whiteBoardView) {
|
1032
|
+
return this.whiteBoardView;
|
1033
|
+
}
|
1034
|
+
let view = this.view;
|
1035
|
+
if (!view) {
|
1036
|
+
view = this.appProxy.createAppDir();
|
1037
|
+
}
|
1038
|
+
const viewWrapper = document.createElement("div");
|
1039
|
+
this._viewWrapper = viewWrapper;
|
1040
|
+
viewWrapper.className = "window-manager-view-wrapper";
|
1041
|
+
(_a = this.box.$content.parentElement) == null ? void 0 : _a.appendChild(viewWrapper);
|
1042
|
+
const removeViewWrapper = () => {
|
1043
|
+
var _a2;
|
1044
|
+
(_a2 = this.box.$content.parentElement) == null ? void 0 : _a2.removeChild(viewWrapper);
|
1045
|
+
this._viewWrapper = void 0;
|
1046
|
+
};
|
1047
|
+
view.divElement = viewWrapper;
|
1048
|
+
this.appProxy.fireMemberStateChange();
|
1049
|
+
if (this.isAddApp) {
|
1050
|
+
this.ensurePageSize(size2);
|
1051
|
+
}
|
1052
|
+
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, removeViewWrapper, this.ensurePageSize);
|
1053
|
+
return this.whiteBoardView;
|
929
1054
|
};
|
930
|
-
this.
|
931
|
-
|
932
|
-
if (
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
1055
|
+
this.ensurePageSize = (size2) => {
|
1056
|
+
var _a;
|
1057
|
+
if (!isNumber(size2))
|
1058
|
+
return;
|
1059
|
+
if (!this.appProxy.scenePath)
|
1060
|
+
return;
|
1061
|
+
if (this.appProxy.pageState.length >= size2)
|
1062
|
+
return;
|
1063
|
+
if (size2 <= 0 || size2 >= MAX_PAGE_SIZE) {
|
1064
|
+
throw Error(`[WindowManager]: size ${size2} muse be in range [1, ${MAX_PAGE_SIZE}]`);
|
938
1065
|
}
|
1066
|
+
const needInsert = size2 - this.appProxy.pageState.length;
|
1067
|
+
const scenes = new Array(needInsert).fill({});
|
1068
|
+
(_a = this.room) == null ? void 0 : _a.putScenes(this.appProxy.scenePath, scenes);
|
939
1069
|
};
|
940
1070
|
this.getInitScenePath = () => {
|
941
1071
|
return this.manager.getAppInitPath(this.appId);
|
942
1072
|
};
|
943
|
-
this.getIsWritable = () => {
|
944
|
-
return this.manager.canOperate;
|
945
|
-
};
|
946
|
-
this.getBox = () => {
|
947
|
-
const box = this.boxManager.getBox(this.appId);
|
948
|
-
if (box) {
|
949
|
-
return box;
|
950
|
-
} else {
|
951
|
-
throw new BoxNotCreatedError();
|
952
|
-
}
|
953
|
-
};
|
954
|
-
this.getRoom = () => {
|
955
|
-
return this.manager.room;
|
956
|
-
};
|
957
1073
|
this.setAttributes = (attributes) => {
|
958
1074
|
this.manager.safeSetAttributes({ [this.appId]: attributes });
|
959
1075
|
};
|
@@ -967,7 +1083,7 @@ class AppContext {
|
|
967
1083
|
if (!this.appProxy.box)
|
968
1084
|
return;
|
969
1085
|
this.appProxy.setFullPath(scenePath);
|
970
|
-
(_a = this.
|
1086
|
+
(_a = this.room) == null ? void 0 : _a.setScenePath(scenePath);
|
971
1087
|
};
|
972
1088
|
this.getAppOptions = () => {
|
973
1089
|
return typeof this.appOptions === "function" ? this.appOptions() : this.appOptions;
|
@@ -990,92 +1106,96 @@ class AppContext {
|
|
990
1106
|
return () => this.manager.displayer.removeMagixEventListener(appScopeEvent, handler);
|
991
1107
|
};
|
992
1108
|
this.removeMagixEventListener = this.manager.displayer.removeMagixEventListener.bind(this.manager.displayer);
|
993
|
-
this.nextPage = async () => {
|
994
|
-
const nextIndex = this.pageState.index + 1;
|
995
|
-
if (nextIndex > this.pageState.length - 1) {
|
996
|
-
console.warn("[WindowManager] nextPage: index out of range");
|
997
|
-
return false;
|
998
|
-
}
|
999
|
-
this.appProxy.setSceneIndex(nextIndex);
|
1000
|
-
return true;
|
1001
|
-
};
|
1002
|
-
this.prevPage = async () => {
|
1003
|
-
const nextIndex = this.pageState.index - 1;
|
1004
|
-
if (nextIndex < 0) {
|
1005
|
-
console.warn("[WindowManager] prevPage: index out of range");
|
1006
|
-
return false;
|
1007
|
-
}
|
1008
|
-
this.appProxy.setSceneIndex(nextIndex);
|
1009
|
-
return true;
|
1010
|
-
};
|
1011
|
-
this.addPage = async (params) => {
|
1012
|
-
const after = params == null ? void 0 : params.after;
|
1013
|
-
const scene = params == null ? void 0 : params.scene;
|
1014
|
-
const scenePath = this.appProxy.scenePath;
|
1015
|
-
if (!scenePath)
|
1016
|
-
return;
|
1017
|
-
if (after) {
|
1018
|
-
const nextIndex = this.pageState.index + 1;
|
1019
|
-
putScenes(this.manager.room, scenePath, [scene || {}], nextIndex);
|
1020
|
-
} else {
|
1021
|
-
putScenes(this.manager.room, scenePath, [scene || {}]);
|
1022
|
-
}
|
1023
|
-
};
|
1024
|
-
this.removePage = async (index2) => {
|
1025
|
-
const needRemoveIndex = index2 === void 0 ? this.pageState.index : index2;
|
1026
|
-
if (this.pageState.length === 1) {
|
1027
|
-
console.warn(`[WindowManager]: can not remove the last page`);
|
1028
|
-
return false;
|
1029
|
-
}
|
1030
|
-
if (needRemoveIndex < 0 || needRemoveIndex >= this.pageState.length) {
|
1031
|
-
console.warn(`[WindowManager]: page index ${index2} out of range`);
|
1032
|
-
return false;
|
1033
|
-
}
|
1034
|
-
return this.appProxy.removeSceneByIndex(needRemoveIndex);
|
1035
|
-
};
|
1036
1109
|
this.emitter = appProxy.appEmitter;
|
1037
1110
|
this.isAddApp = appProxy.isAddApp;
|
1038
1111
|
}
|
1112
|
+
get displayer() {
|
1113
|
+
return this.manager.displayer;
|
1114
|
+
}
|
1115
|
+
get destroyed() {
|
1116
|
+
return this.appProxy.status === "destroyed";
|
1117
|
+
}
|
1118
|
+
get view() {
|
1119
|
+
return this.appProxy.view;
|
1120
|
+
}
|
1121
|
+
get isWritable() {
|
1122
|
+
return this.manager.canOperate && !this.destroyed;
|
1123
|
+
}
|
1124
|
+
get box() {
|
1125
|
+
const box = this.boxManager.getBox(this.appId);
|
1126
|
+
if (box) {
|
1127
|
+
return box;
|
1128
|
+
} else {
|
1129
|
+
throw new BoxNotCreatedError();
|
1130
|
+
}
|
1131
|
+
}
|
1132
|
+
get room() {
|
1133
|
+
return this.manager.room;
|
1134
|
+
}
|
1135
|
+
get members() {
|
1136
|
+
return this.manager.members;
|
1137
|
+
}
|
1138
|
+
get memberState() {
|
1139
|
+
const self2 = findMemberByUid(this.room, this.manager.uid);
|
1140
|
+
if (!self2) {
|
1141
|
+
throw new Error(`Member ${this.manager.uid} not found.`);
|
1142
|
+
}
|
1143
|
+
return __spreadValues({
|
1144
|
+
uid: this.manager.uid
|
1145
|
+
}, self2);
|
1146
|
+
}
|
1039
1147
|
get storage() {
|
1040
1148
|
if (!this._storage) {
|
1041
1149
|
this._storage = new Storage(this);
|
1042
1150
|
}
|
1043
1151
|
return this._storage;
|
1044
1152
|
}
|
1045
|
-
get pageState() {
|
1046
|
-
return this.appProxy.pageState;
|
1047
|
-
}
|
1048
1153
|
}
|
1049
1154
|
class AppPageStateImpl {
|
1050
1155
|
constructor(params) {
|
1051
1156
|
this.params = params;
|
1052
1157
|
this.sceneNode = null;
|
1053
|
-
this.
|
1054
|
-
this.
|
1158
|
+
this.createSceneNode = (scenePath2) => {
|
1159
|
+
this.scenePath = scenePath2;
|
1160
|
+
if (this.sceneNode) {
|
1161
|
+
this.sceneNode.dispose();
|
1162
|
+
}
|
1163
|
+
this.sceneNode = this.params.displayer.createScenesCallback(scenePath2, {
|
1164
|
+
onAddScene: this.onSceneChange,
|
1165
|
+
onRemoveScene: this.onSceneChange
|
1166
|
+
});
|
1167
|
+
return this.sceneNode;
|
1168
|
+
};
|
1169
|
+
this.onSceneChange = () => {
|
1055
1170
|
this.params.notifyPageStateChange();
|
1056
1171
|
};
|
1057
1172
|
const { displayer, scenePath } = this.params;
|
1173
|
+
this.view = this.params.view;
|
1058
1174
|
if (scenePath) {
|
1175
|
+
this.scenePath = scenePath;
|
1059
1176
|
this.sceneNode = displayer.createScenesCallback(scenePath, {
|
1060
1177
|
onAddScene: this.onSceneChange,
|
1061
1178
|
onRemoveScene: this.onSceneChange
|
1062
1179
|
});
|
1063
1180
|
}
|
1064
1181
|
}
|
1182
|
+
setView(view) {
|
1183
|
+
this.view = view;
|
1184
|
+
}
|
1065
1185
|
getFullPath(index2) {
|
1066
1186
|
var _a;
|
1067
1187
|
const scenes = (_a = this.sceneNode) == null ? void 0 : _a.scenes;
|
1068
|
-
if (this.
|
1188
|
+
if (this.scenePath && scenes) {
|
1069
1189
|
const name = scenes[index2];
|
1070
1190
|
if (name) {
|
1071
|
-
return `${this.
|
1191
|
+
return `${this.scenePath}/${name}`;
|
1072
1192
|
}
|
1073
1193
|
}
|
1074
1194
|
}
|
1075
1195
|
toObject() {
|
1076
1196
|
var _a, _b;
|
1077
1197
|
return {
|
1078
|
-
index: ((_a = this.
|
1198
|
+
index: ((_a = this.view) == null ? void 0 : _a.focusSceneIndex) || 0,
|
1079
1199
|
length: ((_b = this.sceneNode) == null ? void 0 : _b.scenes.length) || 0
|
1080
1200
|
};
|
1081
1201
|
}
|
@@ -1084,6 +1204,135 @@ class AppPageStateImpl {
|
|
1084
1204
|
(_a = this.sceneNode) == null ? void 0 : _a.dispose();
|
1085
1205
|
}
|
1086
1206
|
}
|
1207
|
+
class CameraSynchronizer {
|
1208
|
+
constructor(saveCamera) {
|
1209
|
+
this.saveCamera = saveCamera;
|
1210
|
+
this.setRect = debounce((rect) => {
|
1211
|
+
this.rect = rect;
|
1212
|
+
if (this.remoteCamera && this.remoteSize) {
|
1213
|
+
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1214
|
+
}
|
1215
|
+
}, 50);
|
1216
|
+
this.onRemoteUpdate = throttle((camera, size2) => {
|
1217
|
+
this.remoteCamera = camera;
|
1218
|
+
this.remoteSize = size2;
|
1219
|
+
if (this.remoteSize && this.rect) {
|
1220
|
+
let scale2;
|
1221
|
+
if (size2.width < size2.height) {
|
1222
|
+
scale2 = this.rect.width / size2.width;
|
1223
|
+
} else {
|
1224
|
+
scale2 = this.rect.height / size2.height;
|
1225
|
+
}
|
1226
|
+
const nextScale = camera.scale * scale2;
|
1227
|
+
const moveCamera = () => {
|
1228
|
+
var _a;
|
1229
|
+
(_a = this.view) == null ? void 0 : _a.moveCamera({
|
1230
|
+
centerX: camera.centerX,
|
1231
|
+
centerY: camera.centerY,
|
1232
|
+
scale: nextScale,
|
1233
|
+
animationMode: AnimationMode.Immediately
|
1234
|
+
});
|
1235
|
+
};
|
1236
|
+
delay(moveCamera, 50);
|
1237
|
+
}
|
1238
|
+
}, 50);
|
1239
|
+
}
|
1240
|
+
setView(view) {
|
1241
|
+
this.view = view;
|
1242
|
+
}
|
1243
|
+
onRemoteSizeUpdate(size2) {
|
1244
|
+
if (this.rect) {
|
1245
|
+
const nextScale = this.rect.width / size2.width;
|
1246
|
+
const moveCamera = () => {
|
1247
|
+
var _a;
|
1248
|
+
(_a = this.view) == null ? void 0 : _a.moveCamera({
|
1249
|
+
scale: nextScale,
|
1250
|
+
animationMode: AnimationMode.Immediately
|
1251
|
+
});
|
1252
|
+
};
|
1253
|
+
delay(moveCamera, 50);
|
1254
|
+
}
|
1255
|
+
}
|
1256
|
+
onLocalCameraUpdate(camera) {
|
1257
|
+
this.saveCamera(camera);
|
1258
|
+
this.remoteCamera = camera;
|
1259
|
+
}
|
1260
|
+
}
|
1261
|
+
class AppViewSync {
|
1262
|
+
constructor(appProxy) {
|
1263
|
+
this.appProxy = appProxy;
|
1264
|
+
this.sem = new SideEffectManager();
|
1265
|
+
this.bindView = (view) => {
|
1266
|
+
if (!view)
|
1267
|
+
return;
|
1268
|
+
this.synchronizer.setView(view);
|
1269
|
+
this.sem.add(() => {
|
1270
|
+
view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1271
|
+
return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1272
|
+
});
|
1273
|
+
};
|
1274
|
+
this.onCameraUpdatedByDevice = (camera) => {
|
1275
|
+
var _a;
|
1276
|
+
this.synchronizer.onLocalCameraUpdate(camera);
|
1277
|
+
const stage = (_a = this.appProxy.box) == null ? void 0 : _a.contentStageRect;
|
1278
|
+
if (stage) {
|
1279
|
+
const size2 = { width: stage.width, height: stage.height, id: this.appProxy.uid };
|
1280
|
+
if (!isEqual(size2, this.appProxy.size$.value)) {
|
1281
|
+
this.appProxy.storeSize(size2);
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
};
|
1285
|
+
this.synchronizer = new CameraSynchronizer((camera) => {
|
1286
|
+
this.appProxy.storeCamera(__spreadValues({
|
1287
|
+
id: this.appProxy.uid
|
1288
|
+
}, camera));
|
1289
|
+
});
|
1290
|
+
this.bindView(appProxy.view);
|
1291
|
+
this.sem.add(() => this.appProxy.camera$.subscribe((camera) => {
|
1292
|
+
const size2 = this.appProxy.size$.value;
|
1293
|
+
if (camera && size2) {
|
1294
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1295
|
+
}
|
1296
|
+
}));
|
1297
|
+
this.sem.add(() => this.appProxy.size$.subscribe((size2) => {
|
1298
|
+
if (size2) {
|
1299
|
+
this.synchronizer.onRemoteSizeUpdate(size2);
|
1300
|
+
}
|
1301
|
+
}));
|
1302
|
+
const box = this.appProxy.box;
|
1303
|
+
if (box && box.contentStageRect) {
|
1304
|
+
this.synchronizer.setRect(box.contentStageRect);
|
1305
|
+
this.sem.add(() => box._contentStageRect$.subscribe((rect) => {
|
1306
|
+
if (rect) {
|
1307
|
+
this.synchronizer.setRect(rect);
|
1308
|
+
}
|
1309
|
+
}));
|
1310
|
+
}
|
1311
|
+
this.sem.add(() => combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size2]) => {
|
1312
|
+
if (camera && size2) {
|
1313
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1314
|
+
}
|
1315
|
+
}));
|
1316
|
+
}
|
1317
|
+
destroy() {
|
1318
|
+
this.sem.flushAll();
|
1319
|
+
}
|
1320
|
+
}
|
1321
|
+
const boxEmitter = new Emittery();
|
1322
|
+
const calculateNextIndex = (index2, pageState) => {
|
1323
|
+
let nextIndex = 0;
|
1324
|
+
const maxIndex = pageState.length - 1;
|
1325
|
+
if (index2 === pageState.index) {
|
1326
|
+
if (index2 === maxIndex) {
|
1327
|
+
nextIndex = index2 - 1;
|
1328
|
+
} else {
|
1329
|
+
nextIndex = pageState.index + 1;
|
1330
|
+
}
|
1331
|
+
} else {
|
1332
|
+
nextIndex = pageState.index;
|
1333
|
+
}
|
1334
|
+
return nextIndex;
|
1335
|
+
};
|
1087
1336
|
var Fields = /* @__PURE__ */ ((Fields2) => {
|
1088
1337
|
Fields2["Apps"] = "apps";
|
1089
1338
|
Fields2["Focus"] = "focus";
|
@@ -1097,6 +1346,8 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
|
|
1097
1346
|
Fields2["CursorState"] = "cursorState";
|
1098
1347
|
Fields2["FullPath"] = "fullPath";
|
1099
1348
|
Fields2["Registered"] = "registered";
|
1349
|
+
Fields2["Camera"] = "camera";
|
1350
|
+
Fields2["Size"] = "size";
|
1100
1351
|
return Fields2;
|
1101
1352
|
})(Fields || {});
|
1102
1353
|
class AttributesDelegate {
|
@@ -1161,6 +1412,9 @@ class AttributesDelegate {
|
|
1161
1412
|
this.context.safeUpdateAttributes(["apps", appId, "state", stateName], state);
|
1162
1413
|
}
|
1163
1414
|
}
|
1415
|
+
updateAppAttributes(appId, key, value) {
|
1416
|
+
this.context.safeUpdateAttributes(["apps", appId, key], value);
|
1417
|
+
}
|
1164
1418
|
cleanAppAttributes(id2) {
|
1165
1419
|
this.context.safeUpdateAttributes(["apps", id2], void 0);
|
1166
1420
|
this.context.safeSetAttributes({ [id2]: void 0 });
|
@@ -1257,21 +1511,6 @@ const log = (...args) => {
|
|
1257
1511
|
console.log(`[WindowManager]:`, ...args);
|
1258
1512
|
}
|
1259
1513
|
};
|
1260
|
-
const calculateNextIndex = (index2, pageState) => {
|
1261
|
-
let nextIndex = 0;
|
1262
|
-
const maxIndex = pageState.length - 1;
|
1263
|
-
if (index2 === pageState.index) {
|
1264
|
-
if (index2 === maxIndex) {
|
1265
|
-
nextIndex = index2 - 1;
|
1266
|
-
} else {
|
1267
|
-
nextIndex = pageState.index + 1;
|
1268
|
-
}
|
1269
|
-
} else {
|
1270
|
-
nextIndex = pageState.index;
|
1271
|
-
}
|
1272
|
-
return nextIndex;
|
1273
|
-
};
|
1274
|
-
const boxEmitter = new Emittery();
|
1275
1514
|
class AppProxy {
|
1276
1515
|
constructor(params, manager, appId, isAddApp) {
|
1277
1516
|
var _a;
|
@@ -1281,7 +1520,52 @@ class AppProxy {
|
|
1281
1520
|
this.appProxies = this.manager.appProxies;
|
1282
1521
|
this.viewManager = this.manager.viewManager;
|
1283
1522
|
this.store = this.manager.store;
|
1523
|
+
this.uid = this.manager.uid;
|
1284
1524
|
this.status = "normal";
|
1525
|
+
this.sideEffectManager = new SideEffectManager();
|
1526
|
+
this.valManager = new ValManager();
|
1527
|
+
this.fullPath$ = this.valManager.attach(new Val(void 0));
|
1528
|
+
this.camera$ = this.valManager.attach(new Val(void 0));
|
1529
|
+
this.size$ = this.valManager.attach(new Val(void 0));
|
1530
|
+
this.box$ = this.valManager.attach(new Val(void 0));
|
1531
|
+
this.view$ = this.valManager.attach(new Val(void 0));
|
1532
|
+
this.fireMemberStateChange = () => {
|
1533
|
+
if (this.manager.room) {
|
1534
|
+
this.onMemberStateChange(this.manager.room.state.memberState);
|
1535
|
+
}
|
1536
|
+
};
|
1537
|
+
this.onMemberStateChange = (memberState) => {
|
1538
|
+
var _a2, _b;
|
1539
|
+
const needPointerEventsNone = memberState.currentApplianceName === "clicker";
|
1540
|
+
if (needPointerEventsNone) {
|
1541
|
+
if ((_a2 = this.appContext) == null ? void 0 : _a2._viewWrapper) {
|
1542
|
+
this.appContext._viewWrapper.style.pointerEvents = "none";
|
1543
|
+
}
|
1544
|
+
} else {
|
1545
|
+
if ((_b = this.appContext) == null ? void 0 : _b._viewWrapper) {
|
1546
|
+
this.appContext._viewWrapper.style.pointerEvents = "auto";
|
1547
|
+
}
|
1548
|
+
}
|
1549
|
+
};
|
1550
|
+
this.computedInitialRect = (boxRect) => {
|
1551
|
+
var _a2;
|
1552
|
+
const managerRect = (_a2 = this.manager.boxManager) == null ? void 0 : _a2.stageRect;
|
1553
|
+
if (managerRect) {
|
1554
|
+
const { width, height } = managerRect;
|
1555
|
+
const boxRatio = boxRect.height / boxRect.width;
|
1556
|
+
if (height < 480) {
|
1557
|
+
return {
|
1558
|
+
width: 480 / boxRatio,
|
1559
|
+
height: 480
|
1560
|
+
};
|
1561
|
+
} else {
|
1562
|
+
return {
|
1563
|
+
width: width * 0.65,
|
1564
|
+
height: height * 0.65
|
1565
|
+
};
|
1566
|
+
}
|
1567
|
+
}
|
1568
|
+
};
|
1285
1569
|
this.getAppInitState = (id2) => {
|
1286
1570
|
var _a2, _b;
|
1287
1571
|
const attrs = this.store.getAppState(id2);
|
@@ -1310,8 +1594,7 @@ class AppProxy {
|
|
1310
1594
|
return payload;
|
1311
1595
|
};
|
1312
1596
|
this.appAttributesUpdateListener = (appId2) => {
|
1313
|
-
|
1314
|
-
(_a2 = this.manager.refresher) == null ? void 0 : _a2.add(appId2, () => {
|
1597
|
+
this.manager.refresher.add(appId2, () => {
|
1315
1598
|
return autorun(() => {
|
1316
1599
|
const attrs = this.manager.attributes[appId2];
|
1317
1600
|
if (attrs) {
|
@@ -1319,23 +1602,23 @@ class AppProxy {
|
|
1319
1602
|
}
|
1320
1603
|
});
|
1321
1604
|
});
|
1322
|
-
|
1605
|
+
this.manager.refresher.add(this.stateKey, () => {
|
1323
1606
|
return autorun(() => {
|
1324
|
-
var
|
1325
|
-
const appState = (
|
1326
|
-
if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((
|
1327
|
-
(
|
1607
|
+
var _a2, _b, _c;
|
1608
|
+
const appState = (_a2 = this.appAttributes) == null ? void 0 : _a2.state;
|
1609
|
+
if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((_b = this.box) == null ? void 0 : _b.zIndex)) {
|
1610
|
+
(_c = this.boxManager) == null ? void 0 : _c.setZIndex(appId2, appState.zIndex);
|
1328
1611
|
}
|
1329
1612
|
});
|
1330
1613
|
});
|
1331
|
-
|
1614
|
+
this.manager.refresher.add(`${appId2}-fullPath`, () => {
|
1332
1615
|
return autorun(() => {
|
1333
|
-
var
|
1334
|
-
const fullPath = (
|
1616
|
+
var _a2;
|
1617
|
+
const fullPath = (_a2 = this.appAttributes) == null ? void 0 : _a2.fullPath;
|
1335
1618
|
this.setFocusScenePathHandler(fullPath);
|
1336
|
-
if (this.
|
1619
|
+
if (this.fullPath$.value !== fullPath) {
|
1337
1620
|
this.notifyPageStateChange();
|
1338
|
-
this.
|
1621
|
+
this.fullPath$.setValue(fullPath);
|
1339
1622
|
}
|
1340
1623
|
});
|
1341
1624
|
});
|
@@ -1347,10 +1630,61 @@ class AppProxy {
|
|
1347
1630
|
}
|
1348
1631
|
}, 50);
|
1349
1632
|
this.notifyPageStateChange = debounce(() => {
|
1350
|
-
|
1633
|
+
if (this.pageState) {
|
1634
|
+
this.appEmitter.emit("pageStateChange", this.pageState);
|
1635
|
+
}
|
1351
1636
|
}, 50);
|
1637
|
+
this.storeCamera = (camera) => {
|
1638
|
+
this.store.updateAppAttributes(this.id, Fields.Camera, camera);
|
1639
|
+
};
|
1640
|
+
this.storeSize = (size2) => {
|
1641
|
+
this.store.updateAppAttributes(this.id, Fields.Size, size2);
|
1642
|
+
};
|
1643
|
+
this.updateSize = (width, height) => {
|
1644
|
+
const iSize = {
|
1645
|
+
id: this.manager.uid,
|
1646
|
+
width,
|
1647
|
+
height
|
1648
|
+
};
|
1649
|
+
this.store.updateAppAttributes(this.id, Fields.Size, iSize);
|
1650
|
+
this.size$.setValue(iSize);
|
1651
|
+
};
|
1652
|
+
this.moveCamera = (camera) => {
|
1653
|
+
if (!this.camera$.value) {
|
1654
|
+
return;
|
1655
|
+
}
|
1656
|
+
const nextCamera = __spreadValues(__spreadValues({}, this.camera$.value), camera);
|
1657
|
+
this.storeCamera(nextCamera);
|
1658
|
+
};
|
1659
|
+
this.addCameraReaction = () => {
|
1660
|
+
this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-camera`, () => reaction(() => {
|
1661
|
+
var _a2;
|
1662
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
|
1663
|
+
}, (camera) => {
|
1664
|
+
if (camera && camera.id !== this.uid) {
|
1665
|
+
const rawCamera = toJS(camera);
|
1666
|
+
if (rawCamera !== this.camera$.value) {
|
1667
|
+
this.camera$.setValue(rawCamera);
|
1668
|
+
}
|
1669
|
+
}
|
1670
|
+
})), "camera");
|
1671
|
+
};
|
1672
|
+
this.addSizeReaction = () => {
|
1673
|
+
this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-size`, () => reaction(() => {
|
1674
|
+
var _a2;
|
1675
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
|
1676
|
+
}, (size2) => {
|
1677
|
+
if (size2 && size2.id !== this.uid) {
|
1678
|
+
const rawSize = toJS(size2);
|
1679
|
+
if (this.size$.value !== rawSize) {
|
1680
|
+
this.size$.setValue(rawSize);
|
1681
|
+
}
|
1682
|
+
}
|
1683
|
+
})), "size");
|
1684
|
+
};
|
1352
1685
|
this.kind = params.kind;
|
1353
1686
|
this.id = appId;
|
1687
|
+
this.appScenePath = `/${this.id}-app-dir`;
|
1354
1688
|
this.stateKey = `${this.id}_state`;
|
1355
1689
|
this.appProxies.set(this.id, this);
|
1356
1690
|
this.appEmitter = new Emittery();
|
@@ -1360,12 +1694,66 @@ class AppProxy {
|
|
1360
1694
|
if ((_a = this.params.options) == null ? void 0 : _a.scenePath) {
|
1361
1695
|
this.createView();
|
1362
1696
|
}
|
1697
|
+
if (!this.scenePath) {
|
1698
|
+
this.scenePath = this.appScenePath;
|
1699
|
+
}
|
1363
1700
|
this._pageState = new AppPageStateImpl({
|
1364
1701
|
displayer: this.manager.displayer,
|
1365
1702
|
scenePath: this.scenePath,
|
1366
1703
|
view: this.view,
|
1367
1704
|
notifyPageStateChange: this.notifyPageStateChange
|
1368
1705
|
});
|
1706
|
+
this.sideEffectManager.add(() => () => this._pageState.destroy());
|
1707
|
+
this.sideEffectManager.add(() => emitter.on("roomMembersChange", (members) => {
|
1708
|
+
this.appEmitter.emit("roomMembersChange", members);
|
1709
|
+
}));
|
1710
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1711
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1712
|
+
this.addCameraReaction();
|
1713
|
+
this.addSizeReaction();
|
1714
|
+
this.sideEffectManager.add(() => combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
1715
|
+
if (box && view) {
|
1716
|
+
if (!this.camera$.value) {
|
1717
|
+
this.storeCamera({
|
1718
|
+
centerX: 0,
|
1719
|
+
centerY: 0,
|
1720
|
+
scale: 1,
|
1721
|
+
id: this.uid
|
1722
|
+
});
|
1723
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1724
|
+
}
|
1725
|
+
if (!this.size$.value && box.contentStageRect) {
|
1726
|
+
const initialRect = this.computedInitialRect(box.contentStageRect);
|
1727
|
+
const width = (initialRect == null ? void 0 : initialRect.width) || box.contentStageRect.width;
|
1728
|
+
const height = (initialRect == null ? void 0 : initialRect.height) || box.contentStageRect.height;
|
1729
|
+
this.storeSize({
|
1730
|
+
id: this.uid,
|
1731
|
+
width,
|
1732
|
+
height
|
1733
|
+
});
|
1734
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1735
|
+
}
|
1736
|
+
this.appViewSync = new AppViewSync(this);
|
1737
|
+
this.sideEffectManager.add(() => () => {
|
1738
|
+
var _a2;
|
1739
|
+
return (_a2 = this.appViewSync) == null ? void 0 : _a2.destroy();
|
1740
|
+
});
|
1741
|
+
}
|
1742
|
+
}));
|
1743
|
+
this.sideEffectManager.add(() => emitter.on("memberStateChange", this.onMemberStateChange));
|
1744
|
+
}
|
1745
|
+
createAppDir() {
|
1746
|
+
const scenePath = this.scenePath || this.appScenePath;
|
1747
|
+
const sceneNode = this._pageState.createSceneNode(scenePath);
|
1748
|
+
if (!sceneNode) {
|
1749
|
+
putScenes(this.manager.room, scenePath, [{ name: "1" }]);
|
1750
|
+
this._pageState.createSceneNode(scenePath);
|
1751
|
+
this.setSceneIndex(0);
|
1752
|
+
}
|
1753
|
+
this.scenes = entireScenes(this.manager.displayer)[scenePath];
|
1754
|
+
const view = this.createView();
|
1755
|
+
this._pageState.setView(view);
|
1756
|
+
return view;
|
1369
1757
|
}
|
1370
1758
|
initScenes() {
|
1371
1759
|
var _a;
|
@@ -1380,7 +1768,7 @@ class AppProxy {
|
|
1380
1768
|
}
|
1381
1769
|
}
|
1382
1770
|
get view() {
|
1383
|
-
return this.
|
1771
|
+
return this.view$.value;
|
1384
1772
|
}
|
1385
1773
|
get viewIndex() {
|
1386
1774
|
var _a;
|
@@ -1410,7 +1798,7 @@ class AppProxy {
|
|
1410
1798
|
return fullPath;
|
1411
1799
|
}
|
1412
1800
|
setFullPath(path) {
|
1413
|
-
this.
|
1801
|
+
this.store.updateAppAttributes(this.id, Fields.FullPath, path);
|
1414
1802
|
}
|
1415
1803
|
async baseInsertApp(skipUpdate = false) {
|
1416
1804
|
var _a;
|
@@ -1432,8 +1820,7 @@ class AppProxy {
|
|
1432
1820
|
};
|
1433
1821
|
}
|
1434
1822
|
get box() {
|
1435
|
-
|
1436
|
-
return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
|
1823
|
+
return this.box$.value;
|
1437
1824
|
}
|
1438
1825
|
async setupApp(appId, skipUpdate, app, options, appOptions) {
|
1439
1826
|
var _a;
|
@@ -1461,13 +1848,14 @@ class AppProxy {
|
|
1461
1848
|
this.fixMobileSize();
|
1462
1849
|
}, SETUP_APP_DELAY);
|
1463
1850
|
});
|
1464
|
-
(_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1851
|
+
const box = (_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1465
1852
|
appId,
|
1466
1853
|
app,
|
1467
1854
|
options,
|
1468
1855
|
canOperate: this.manager.canOperate,
|
1469
1856
|
smartPosition: this.isAddApp
|
1470
1857
|
});
|
1858
|
+
this.box$.setValue(box);
|
1471
1859
|
if (this.isAddApp && this.box) {
|
1472
1860
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
1473
1861
|
this.boxManager.focusBox({ appId }, false);
|
@@ -1594,8 +1982,9 @@ class AppProxy {
|
|
1594
1982
|
}
|
1595
1983
|
return fullPath;
|
1596
1984
|
}
|
1597
|
-
|
1598
|
-
const view =
|
1985
|
+
createView() {
|
1986
|
+
const view = this.viewManager.createView(this.id);
|
1987
|
+
this.view$.setValue(view);
|
1599
1988
|
this.setViewFocusScenePath();
|
1600
1989
|
return view;
|
1601
1990
|
}
|
@@ -1604,7 +1993,7 @@ class AppProxy {
|
|
1604
1993
|
}
|
1605
1994
|
async removeSceneByIndex(index2) {
|
1606
1995
|
const scenePath = this._pageState.getFullPath(index2);
|
1607
|
-
if (scenePath) {
|
1996
|
+
if (scenePath && this.pageState) {
|
1608
1997
|
const nextIndex = calculateNextIndex(index2, this.pageState);
|
1609
1998
|
this.setSceneIndexWithoutSync(nextIndex);
|
1610
1999
|
this.manager.dispatchInternalEvent(Events.SetAppFocusIndex, {
|
@@ -1635,7 +2024,7 @@ class AppProxy {
|
|
1635
2024
|
}
|
1636
2025
|
}
|
1637
2026
|
async destroy(needCloseBox, cleanAttrs, skipUpdate, error) {
|
1638
|
-
var _a
|
2027
|
+
var _a;
|
1639
2028
|
if (this.status === "destroyed")
|
1640
2029
|
return;
|
1641
2030
|
this.status = "destroyed";
|
@@ -1646,6 +2035,7 @@ class AppProxy {
|
|
1646
2035
|
console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
|
1647
2036
|
}
|
1648
2037
|
this.appEmitter.clearListeners();
|
2038
|
+
this.sideEffectManager.flushAll();
|
1649
2039
|
emitter.emit(`destroy-${this.id}`, { error });
|
1650
2040
|
if (needCloseBox) {
|
1651
2041
|
(_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
|
@@ -1657,13 +2047,12 @@ class AppProxy {
|
|
1657
2047
|
}
|
1658
2048
|
}
|
1659
2049
|
this.appProxies.delete(this.id);
|
1660
|
-
this._pageState.destroy();
|
1661
2050
|
this.viewManager.destroyView(this.id);
|
1662
2051
|
this.manager.appStatus.delete(this.id);
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
this.
|
2052
|
+
this.manager.refresher.remove(this.id);
|
2053
|
+
this.manager.refresher.remove(this.stateKey);
|
2054
|
+
this.manager.refresher.remove(`${this.id}-fullPath`);
|
2055
|
+
this.valManager.destroy();
|
1667
2056
|
}
|
1668
2057
|
close() {
|
1669
2058
|
return this.destroy(true, true, false);
|
@@ -1719,56 +2108,6 @@ const setDefaultCameraBound = (view) => {
|
|
1719
2108
|
minContentMode: () => 0.1
|
1720
2109
|
});
|
1721
2110
|
};
|
1722
|
-
class CameraSynchronizer {
|
1723
|
-
constructor(saveCamera) {
|
1724
|
-
this.saveCamera = saveCamera;
|
1725
|
-
this.onRemoteUpdate = throttle((camera, size2) => {
|
1726
|
-
this.remoteCamera = camera;
|
1727
|
-
this.remoteSize = size2;
|
1728
|
-
if (this.remoteSize && this.rect) {
|
1729
|
-
let scale2;
|
1730
|
-
if (size2.width < size2.height) {
|
1731
|
-
scale2 = this.rect.width / size2.width;
|
1732
|
-
} else {
|
1733
|
-
scale2 = this.rect.height / size2.height;
|
1734
|
-
}
|
1735
|
-
const nextScale = camera.scale * scale2;
|
1736
|
-
const moveCamera = () => {
|
1737
|
-
var _a;
|
1738
|
-
return (_a = this.view) == null ? void 0 : _a.moveCamera({
|
1739
|
-
centerX: camera.centerX,
|
1740
|
-
centerY: camera.centerY,
|
1741
|
-
scale: nextScale,
|
1742
|
-
animationMode: AnimationMode.Immediately
|
1743
|
-
});
|
1744
|
-
};
|
1745
|
-
delay(moveCamera, 10);
|
1746
|
-
}
|
1747
|
-
}, 50);
|
1748
|
-
}
|
1749
|
-
setRect(rect) {
|
1750
|
-
this.rect = rect;
|
1751
|
-
if (this.remoteCamera && this.remoteSize) {
|
1752
|
-
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1753
|
-
}
|
1754
|
-
}
|
1755
|
-
setView(view) {
|
1756
|
-
this.view = view;
|
1757
|
-
}
|
1758
|
-
onLocalCameraUpdate(camera) {
|
1759
|
-
this.saveCamera(camera);
|
1760
|
-
}
|
1761
|
-
onLocalSizeUpdate(size2) {
|
1762
|
-
if (this.rect && this.view) {
|
1763
|
-
const scale2 = this.rect.width / size2.width;
|
1764
|
-
const nextScale = this.view.camera.scale * scale2;
|
1765
|
-
this.view.moveCamera({
|
1766
|
-
scale: nextScale,
|
1767
|
-
animationMode: AnimationMode.Immediately
|
1768
|
-
});
|
1769
|
-
}
|
1770
|
-
}
|
1771
|
-
}
|
1772
2111
|
class MainViewProxy {
|
1773
2112
|
constructor(manager) {
|
1774
2113
|
var _a;
|
@@ -1778,17 +2117,14 @@ class MainViewProxy {
|
|
1778
2117
|
this.store = this.manager.store;
|
1779
2118
|
this.sideEffectManager = new SideEffectManager();
|
1780
2119
|
this.startListenWritableChange = () => {
|
1781
|
-
this.sideEffectManager.add(() => {
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
});
|
1787
|
-
});
|
2120
|
+
this.sideEffectManager.add(() => emitter.on("writableChange", (isWritable) => {
|
2121
|
+
if (isWritable) {
|
2122
|
+
this.ensureCameraAndSize();
|
2123
|
+
}
|
2124
|
+
}));
|
1788
2125
|
};
|
1789
2126
|
this.addCameraReaction = () => {
|
1790
|
-
|
1791
|
-
(_a2 = this.manager.refresher) == null ? void 0 : _a2.add(Fields.MainViewCamera, this.cameraReaction);
|
2127
|
+
this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
|
1792
2128
|
};
|
1793
2129
|
this.cameraReaction = () => {
|
1794
2130
|
return reaction(() => this.mainViewCamera, (camera) => {
|
@@ -1797,14 +2133,8 @@ class MainViewProxy {
|
|
1797
2133
|
}
|
1798
2134
|
}, { fireImmediately: true });
|
1799
2135
|
};
|
1800
|
-
this.sizeChangeHandler = debounce((size2) => {
|
1801
|
-
if (size2) {
|
1802
|
-
this.synchronizer.onLocalSizeUpdate(size2);
|
1803
|
-
}
|
1804
|
-
}, 30);
|
1805
2136
|
this.onUpdateContainerSizeRatio = () => {
|
1806
2137
|
const size2 = this.store.getMainViewSize();
|
1807
|
-
this.sizeChangeHandler(size2);
|
1808
2138
|
if (size2.id === this.manager.uid) {
|
1809
2139
|
this.setCameraAndSize();
|
1810
2140
|
}
|
@@ -1834,26 +2164,19 @@ class MainViewProxy {
|
|
1834
2164
|
this.ensureCameraAndSize();
|
1835
2165
|
this.startListenWritableChange();
|
1836
2166
|
});
|
1837
|
-
this.sideEffectManager.add(() =>
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
});
|
2167
|
+
this.sideEffectManager.add(() => [
|
2168
|
+
emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio),
|
2169
|
+
emitter.on("startReconnect", () => {
|
2170
|
+
releaseView(this.mainView);
|
2171
|
+
}),
|
2172
|
+
emitter.on("playgroundSizeChange", (rect2) => {
|
2173
|
+
this.synchronizer.setRect(rect2);
|
2174
|
+
})
|
2175
|
+
]);
|
1847
2176
|
const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
1848
2177
|
if (rect) {
|
1849
2178
|
this.synchronizer.setRect(rect);
|
1850
2179
|
}
|
1851
|
-
this.sideEffectManager.add(() => {
|
1852
|
-
return emitter.on("playgroundSizeChange", (rect2) => {
|
1853
|
-
this.synchronizer.setRect(rect2);
|
1854
|
-
this.synchronizer.onLocalSizeUpdate(rect2);
|
1855
|
-
});
|
1856
|
-
});
|
1857
2180
|
}
|
1858
2181
|
ensureCameraAndSize() {
|
1859
2182
|
if (!this.mainViewCamera || !this.mainViewSize) {
|
@@ -1876,7 +2199,6 @@ class MainViewProxy {
|
|
1876
2199
|
start() {
|
1877
2200
|
if (this.started)
|
1878
2201
|
return;
|
1879
|
-
this.sizeChangeHandler(this.mainViewSize);
|
1880
2202
|
this.addCameraListener();
|
1881
2203
|
this.addCameraReaction();
|
1882
2204
|
this.started = true;
|
@@ -1921,9 +2243,7 @@ class MainViewProxy {
|
|
1921
2243
|
const divElement = this.mainView.divElement;
|
1922
2244
|
const disableCameraTransform = this.mainView.disableCameraTransform;
|
1923
2245
|
this.stop();
|
1924
|
-
|
1925
|
-
this.mainView.release();
|
1926
|
-
}
|
2246
|
+
releaseView(this.mainView);
|
1927
2247
|
this.removeMainViewListener();
|
1928
2248
|
this.mainView = this.createMainView();
|
1929
2249
|
this.mainView.disableCameraTransform = disableCameraTransform;
|
@@ -1972,10 +2292,9 @@ class MainViewProxy {
|
|
1972
2292
|
this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
|
1973
2293
|
}
|
1974
2294
|
stop() {
|
1975
|
-
var _a, _b;
|
1976
2295
|
this.removeCameraListener();
|
1977
|
-
|
1978
|
-
|
2296
|
+
this.manager.refresher.remove(Fields.MainViewCamera);
|
2297
|
+
this.manager.refresher.remove(Fields.MainViewSize);
|
1979
2298
|
this.started = false;
|
1980
2299
|
}
|
1981
2300
|
destroy() {
|
@@ -2053,6 +2372,8 @@ class AppManager {
|
|
2053
2372
|
this.mainViewScenesLength = 0;
|
2054
2373
|
this.callbacksNode = null;
|
2055
2374
|
this.appCreateQueue = new AppCreateQueue();
|
2375
|
+
this.sceneIndex$ = new Val(void 0);
|
2376
|
+
this.focused$ = new Val(void 0);
|
2056
2377
|
this.sideEffectManager = new SideEffectManager();
|
2057
2378
|
this.sceneState = null;
|
2058
2379
|
this.rootDirRemoving = false;
|
@@ -2220,21 +2541,21 @@ class AppManager {
|
|
2220
2541
|
});
|
2221
2542
|
};
|
2222
2543
|
this.onMainViewIndexChange = (index2) => {
|
2223
|
-
if (index2 !== void 0 && this.
|
2544
|
+
if (index2 !== void 0 && this.sceneIndex$.value !== index2) {
|
2224
2545
|
callbacks$1.emit("mainViewSceneIndexChange", index2);
|
2225
2546
|
emitter.emit("changePageState");
|
2226
2547
|
if (this.callbacksNode) {
|
2227
2548
|
this.updateSceneState(this.callbacksNode);
|
2228
2549
|
}
|
2229
|
-
this.
|
2550
|
+
this.sceneIndex$.setValue(index2);
|
2230
2551
|
}
|
2231
2552
|
};
|
2232
2553
|
this.onFocusChange = (focused) => {
|
2233
2554
|
var _a;
|
2234
|
-
if (this.
|
2555
|
+
if (this.focused$.value !== focused) {
|
2235
2556
|
callbacks$1.emit("focusedChange", focused);
|
2236
|
-
emitter.emit("focusedChange", { focused, prev: this.
|
2237
|
-
this.
|
2557
|
+
emitter.emit("focusedChange", { focused, prev: this.focused$.value });
|
2558
|
+
this.focused$.setValue(focused);
|
2238
2559
|
if (focused !== void 0) {
|
2239
2560
|
(_a = this.boxManager) == null ? void 0 : _a.focusBox({ appId: focused });
|
2240
2561
|
setTimeout(() => {
|
@@ -2299,7 +2620,13 @@ class AppManager {
|
|
2299
2620
|
this.appProxies.forEach((appProxy) => {
|
2300
2621
|
appProxy.appEmitter.emit("roomStateChange", state);
|
2301
2622
|
});
|
2623
|
+
if (state.roomMembers) {
|
2624
|
+
emitter.emit("roomMembersChange", this.members);
|
2625
|
+
}
|
2302
2626
|
emitter.emit("observerIdChange", this.displayer.observerId);
|
2627
|
+
if (state.memberState) {
|
2628
|
+
emitter.emit("memberStateChange", toJS(state.memberState));
|
2629
|
+
}
|
2303
2630
|
};
|
2304
2631
|
this.displayerWritableListener = (isReadonly) => {
|
2305
2632
|
var _a, _b;
|
@@ -2314,12 +2641,9 @@ class AppManager {
|
|
2314
2641
|
appProxy.emitAppIsWritableChange();
|
2315
2642
|
});
|
2316
2643
|
if (isWritable === true) {
|
2317
|
-
this.mainView.disableCameraTransform = false;
|
2318
2644
|
if (this.room && this.room.disableSerialization === true) {
|
2319
2645
|
this.room.disableSerialization = false;
|
2320
2646
|
}
|
2321
|
-
} else {
|
2322
|
-
this.mainView.disableCameraTransform = true;
|
2323
2647
|
}
|
2324
2648
|
emitter.emit("writableChange", isWritable);
|
2325
2649
|
};
|
@@ -2412,6 +2736,9 @@ class AppManager {
|
|
2412
2736
|
var _a;
|
2413
2737
|
return ((_a = this.room) == null ? void 0 : _a.uid) || "";
|
2414
2738
|
}
|
2739
|
+
get members() {
|
2740
|
+
return serializeRoomMembers(this.displayer.state.roomMembers);
|
2741
|
+
}
|
2415
2742
|
getMainViewSceneDir() {
|
2416
2743
|
const scenePath = this.store.getMainViewScenePath();
|
2417
2744
|
if (scenePath) {
|
@@ -2421,7 +2748,7 @@ class AppManager {
|
|
2421
2748
|
}
|
2422
2749
|
}
|
2423
2750
|
async onCreated() {
|
2424
|
-
var _a
|
2751
|
+
var _a;
|
2425
2752
|
await this.attributesUpdateCallback(this.attributes.apps);
|
2426
2753
|
emitter.emit("updateManagerRect");
|
2427
2754
|
boxEmitter.on("move", this.onBoxMove);
|
@@ -2431,32 +2758,32 @@ class AppManager {
|
|
2431
2758
|
boxEmitter.on("boxStateChange", this.onBoxStateChange);
|
2432
2759
|
this.addAppsChangeListener();
|
2433
2760
|
this.addAppCloseListener();
|
2434
|
-
|
2761
|
+
this.refresher.add("maximized", () => {
|
2435
2762
|
return autorun(() => {
|
2436
2763
|
var _a2;
|
2437
2764
|
const maximized = this.attributes.maximized;
|
2438
2765
|
(_a2 = this.boxManager) == null ? void 0 : _a2.setMaximized(Boolean(maximized));
|
2439
2766
|
});
|
2440
2767
|
});
|
2441
|
-
|
2768
|
+
this.refresher.add("minimized", () => {
|
2442
2769
|
return autorun(() => {
|
2443
2770
|
const minimized = this.attributes.minimized;
|
2444
2771
|
this.onMinimized(minimized);
|
2445
2772
|
});
|
2446
2773
|
});
|
2447
|
-
|
2774
|
+
this.refresher.add("mainViewIndex", () => {
|
2448
2775
|
return autorun(() => {
|
2449
2776
|
const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
|
2450
2777
|
this.onMainViewIndexChange(mainSceneIndex);
|
2451
2778
|
});
|
2452
2779
|
});
|
2453
|
-
|
2780
|
+
this.refresher.add("focusedChange", () => {
|
2454
2781
|
return autorun(() => {
|
2455
2782
|
const focused = get(this.attributes, "focus");
|
2456
2783
|
this.onFocusChange(focused);
|
2457
2784
|
});
|
2458
2785
|
});
|
2459
|
-
|
2786
|
+
this.refresher.add("registeredChange", () => {
|
2460
2787
|
return autorun(() => {
|
2461
2788
|
const registered = get(this.attributes, Fields.Registered);
|
2462
2789
|
this.onRegisteredChange(registered);
|
@@ -2468,9 +2795,9 @@ class AppManager {
|
|
2468
2795
|
return;
|
2469
2796
|
this.resetScenePath(mainScenePath);
|
2470
2797
|
}
|
2471
|
-
this.displayerWritableListener(!((
|
2798
|
+
this.displayerWritableListener(!((_a = this.room) == null ? void 0 : _a.isWritable));
|
2472
2799
|
this.displayer.callbacks.on("onEnableWriteNowChanged", this.displayerWritableListener);
|
2473
|
-
this.
|
2800
|
+
this.focused$.setValue(this.attributes.focus);
|
2474
2801
|
this.sideEffectManager.add(() => {
|
2475
2802
|
const redoUndo = new RedoUndo({
|
2476
2803
|
mainView: () => this.mainViewProxy.view,
|
@@ -2719,32 +3046,10 @@ class AppManager {
|
|
2719
3046
|
}
|
2720
3047
|
callbacks$1.clearListeners();
|
2721
3048
|
this.sideEffectManager.flushAll();
|
2722
|
-
this.
|
2723
|
-
this.
|
3049
|
+
this.sceneIndex$.destroy();
|
3050
|
+
this.focused$.destroy();
|
2724
3051
|
}
|
2725
3052
|
}
|
2726
|
-
const setupWrapper = (root) => {
|
2727
|
-
const playground = document.createElement("div");
|
2728
|
-
playground.className = "netless-window-manager-playground";
|
2729
|
-
const mainViewElement = document.createElement("div");
|
2730
|
-
mainViewElement.className = "netless-window-manager-main-view";
|
2731
|
-
playground.appendChild(mainViewElement);
|
2732
|
-
root.appendChild(playground);
|
2733
|
-
return { playground, mainViewElement };
|
2734
|
-
};
|
2735
|
-
const checkVersion = () => {
|
2736
|
-
const version = getVersionNumber(WhiteVersion);
|
2737
|
-
if (version < getVersionNumber(REQUIRE_VERSION)) {
|
2738
|
-
throw new WhiteWebSDKInvalidError(REQUIRE_VERSION);
|
2739
|
-
}
|
2740
|
-
};
|
2741
|
-
const findMemberByUid = (room, uid) => {
|
2742
|
-
const roomMembers = room == null ? void 0 : room.state.roomMembers;
|
2743
|
-
return roomMembers == null ? void 0 : roomMembers.find((member) => {
|
2744
|
-
var _a;
|
2745
|
-
return ((_a = member.payload) == null ? void 0 : _a.uid) === uid;
|
2746
|
-
});
|
2747
|
-
};
|
2748
3053
|
/*! *****************************************************************************
|
2749
3054
|
Copyright (c) Microsoft Corporation.
|
2750
3055
|
|
@@ -3587,289 +3892,16 @@ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
|
|
3587
3892
|
}
|
3588
3893
|
return true;
|
3589
3894
|
};
|
3590
|
-
var
|
3591
|
-
var __defProps$1 = Object.defineProperties;
|
3592
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
3593
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
3594
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
3595
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
3596
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3597
|
-
var __spreadValues$1 = (a2, b2) => {
|
3598
|
-
for (var prop in b2 || (b2 = {}))
|
3599
|
-
if (__hasOwnProp$1.call(b2, prop))
|
3600
|
-
__defNormalProp$1(a2, prop, b2[prop]);
|
3601
|
-
if (__getOwnPropSymbols$1)
|
3602
|
-
for (var prop of __getOwnPropSymbols$1(b2)) {
|
3603
|
-
if (__propIsEnum$1.call(b2, prop))
|
3604
|
-
__defNormalProp$1(a2, prop, b2[prop]);
|
3605
|
-
}
|
3606
|
-
return a2;
|
3607
|
-
};
|
3608
|
-
var __spreadProps$1 = (a2, b2) => __defProps$1(a2, __getOwnPropDescs$1(b2));
|
3609
|
-
var __publicField = (obj, key, value) => {
|
3610
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
3611
|
-
return value;
|
3612
|
-
};
|
3613
|
-
class Subscribers {
|
3614
|
-
constructor(beforeSubscribe) {
|
3615
|
-
__publicField(this, "_subscribers");
|
3616
|
-
__publicField(this, "_bSub");
|
3617
|
-
__publicField(this, "_bSubDisposer");
|
3618
|
-
this._bSub = beforeSubscribe;
|
3619
|
-
}
|
3620
|
-
get size() {
|
3621
|
-
return this._subscribers ? this._subscribers.size : 0;
|
3622
|
-
}
|
3623
|
-
invoke(newValue, meta) {
|
3624
|
-
if (this._subscribers) {
|
3625
|
-
this._subscribers.forEach((subscriber) => subscriber(newValue, meta));
|
3626
|
-
}
|
3627
|
-
}
|
3628
|
-
add(subscribe) {
|
3629
|
-
if (this._bSub && (!this._subscribers || this._subscribers.size <= 0)) {
|
3630
|
-
this._bSubDisposer = this._bSub();
|
3631
|
-
}
|
3632
|
-
if (!this._subscribers) {
|
3633
|
-
this._subscribers = /* @__PURE__ */ new Set();
|
3634
|
-
}
|
3635
|
-
this._subscribers.add(subscribe);
|
3636
|
-
}
|
3637
|
-
remove(subscriber) {
|
3638
|
-
if (this._subscribers) {
|
3639
|
-
this._subscribers.delete(subscriber);
|
3640
|
-
}
|
3641
|
-
if (this._subscribers && this._subscribers.size <= 0) {
|
3642
|
-
if (this._bSubDisposer) {
|
3643
|
-
const _bSubDisposer = this._bSubDisposer;
|
3644
|
-
this._bSubDisposer = null;
|
3645
|
-
_bSubDisposer();
|
3646
|
-
}
|
3647
|
-
}
|
3648
|
-
}
|
3649
|
-
clear() {
|
3650
|
-
if (this._subscribers) {
|
3651
|
-
this._subscribers.clear();
|
3652
|
-
}
|
3653
|
-
if (this._bSubDisposer) {
|
3654
|
-
const _bSubDisposer = this._bSubDisposer;
|
3655
|
-
this._bSubDisposer = null;
|
3656
|
-
_bSubDisposer();
|
3657
|
-
}
|
3658
|
-
}
|
3659
|
-
destroy() {
|
3660
|
-
this.clear();
|
3661
|
-
}
|
3662
|
-
}
|
3663
|
-
class ReadonlyVal {
|
3664
|
-
constructor(value, config) {
|
3665
|
-
__publicField(this, "_subscribers");
|
3666
|
-
__publicField(this, "_value");
|
3667
|
-
this._value = value;
|
3668
|
-
let beforeSubscribe;
|
3669
|
-
if (config) {
|
3670
|
-
if (config.compare) {
|
3671
|
-
this.compare = config.compare;
|
3672
|
-
}
|
3673
|
-
if (config.beforeSubscribe) {
|
3674
|
-
const _beforeSubscribe = config.beforeSubscribe;
|
3675
|
-
const _setValue = this._setValue.bind(this);
|
3676
|
-
beforeSubscribe = () => _beforeSubscribe(_setValue);
|
3677
|
-
}
|
3678
|
-
}
|
3679
|
-
this._subscribers = new Subscribers(beforeSubscribe);
|
3680
|
-
}
|
3681
|
-
_setValue(value, meta) {
|
3682
|
-
if (!this.compare(value, this._value)) {
|
3683
|
-
this._value = value;
|
3684
|
-
this._subscribers.invoke(value, meta);
|
3685
|
-
}
|
3686
|
-
}
|
3687
|
-
get value() {
|
3688
|
-
return this._value;
|
3689
|
-
}
|
3690
|
-
reaction(subscriber) {
|
3691
|
-
this._subscribers.add(subscriber);
|
3692
|
-
return () => {
|
3693
|
-
this._subscribers.remove(subscriber);
|
3694
|
-
};
|
3695
|
-
}
|
3696
|
-
subscribe(subscriber, meta) {
|
3697
|
-
const disposer = this.reaction(subscriber);
|
3698
|
-
subscriber(this._value, meta);
|
3699
|
-
return disposer;
|
3700
|
-
}
|
3701
|
-
destroy() {
|
3702
|
-
this._subscribers.destroy();
|
3703
|
-
}
|
3704
|
-
unsubscribe(subscriber) {
|
3705
|
-
this._subscribers.remove(subscriber);
|
3706
|
-
}
|
3707
|
-
compare(newValue, oldValue) {
|
3708
|
-
return newValue === oldValue;
|
3709
|
-
}
|
3710
|
-
}
|
3711
|
-
class Val extends ReadonlyVal {
|
3712
|
-
constructor() {
|
3713
|
-
super(...arguments);
|
3714
|
-
__publicField(this, "setValue", this._setValue);
|
3715
|
-
}
|
3716
|
-
}
|
3717
|
-
class DerivedVal extends ReadonlyVal {
|
3718
|
-
constructor(val, transform, config = {}) {
|
3719
|
-
super(transform(val.value), __spreadProps$1(__spreadValues$1({}, config), {
|
3720
|
-
beforeSubscribe: (setValue) => {
|
3721
|
-
const disposer = val.subscribe((newValue, meta) => setValue(transform(newValue), meta));
|
3722
|
-
if (config.beforeSubscribe) {
|
3723
|
-
const beforeSubscribeDisposer = config.beforeSubscribe(setValue);
|
3724
|
-
if (beforeSubscribeDisposer) {
|
3725
|
-
return () => {
|
3726
|
-
disposer();
|
3727
|
-
beforeSubscribeDisposer();
|
3728
|
-
};
|
3729
|
-
}
|
3730
|
-
}
|
3731
|
-
return disposer;
|
3732
|
-
}
|
3733
|
-
}));
|
3734
|
-
__publicField(this, "_srcValue");
|
3735
|
-
this._srcValue = () => transform(val.value);
|
3736
|
-
}
|
3737
|
-
get value() {
|
3738
|
-
if (this._subscribers.size <= 0) {
|
3739
|
-
const value = this._srcValue();
|
3740
|
-
return this.compare(value, this._value) ? this._value : value;
|
3741
|
-
}
|
3742
|
-
return this._value;
|
3743
|
-
}
|
3744
|
-
}
|
3745
|
-
function derive(val, transform = (value) => value, config = {}) {
|
3746
|
-
return new DerivedVal(val, transform, config);
|
3747
|
-
}
|
3748
|
-
class CombinedVal extends ReadonlyVal {
|
3749
|
-
constructor(valInputs, transform, config = {}) {
|
3750
|
-
super(transform(getValues(valInputs)), __spreadProps$1(__spreadValues$1({}, config), {
|
3751
|
-
beforeSubscribe: (setValue) => {
|
3752
|
-
let lastValueInputs = getValues(valInputs);
|
3753
|
-
setValue(transform(lastValueInputs));
|
3754
|
-
const disposers = valInputs.map((val, i2) => val.reaction((value, meta) => {
|
3755
|
-
lastValueInputs = lastValueInputs.slice();
|
3756
|
-
lastValueInputs[i2] = value;
|
3757
|
-
setValue(transform(lastValueInputs), meta);
|
3758
|
-
}));
|
3759
|
-
const disposer = () => disposers.forEach((disposer2) => disposer2());
|
3760
|
-
if (config.beforeSubscribe) {
|
3761
|
-
const beforeSubscribeDisposer = config.beforeSubscribe(setValue);
|
3762
|
-
if (beforeSubscribeDisposer) {
|
3763
|
-
return () => {
|
3764
|
-
disposer();
|
3765
|
-
beforeSubscribeDisposer();
|
3766
|
-
};
|
3767
|
-
}
|
3768
|
-
}
|
3769
|
-
return disposer;
|
3770
|
-
}
|
3771
|
-
}));
|
3772
|
-
__publicField(this, "_srcValue");
|
3773
|
-
this._srcValue = () => transform(getValues(valInputs));
|
3774
|
-
}
|
3775
|
-
get value() {
|
3776
|
-
if (this._subscribers.size <= 0) {
|
3777
|
-
const value = this._srcValue();
|
3778
|
-
return this.compare(value, this._value) ? this._value : value;
|
3779
|
-
}
|
3780
|
-
return this._value;
|
3781
|
-
}
|
3782
|
-
}
|
3783
|
-
function getValues(valInputs) {
|
3784
|
-
return valInputs.map(getValue);
|
3785
|
-
}
|
3786
|
-
function getValue(val) {
|
3787
|
-
return val.value;
|
3788
|
-
}
|
3789
|
-
function combine(valInputs, transform = (value) => value, config = {}) {
|
3790
|
-
return new CombinedVal(valInputs, transform, config);
|
3791
|
-
}
|
3792
|
-
function withReadonlyValueEnhancer(instance2, config, valManager) {
|
3793
|
-
Object.keys(config).forEach((key) => {
|
3794
|
-
bindInstance$1(instance2, key, config[key]);
|
3795
|
-
if (valManager) {
|
3796
|
-
valManager.attach(config[key]);
|
3797
|
-
}
|
3798
|
-
});
|
3799
|
-
}
|
3800
|
-
function bindInstance$1(instance2, key, val) {
|
3801
|
-
Object.defineProperties(instance2, {
|
3802
|
-
[key]: {
|
3803
|
-
get() {
|
3804
|
-
return val.value;
|
3805
|
-
}
|
3806
|
-
},
|
3807
|
-
[`_${key}$`]: {
|
3808
|
-
value: val
|
3809
|
-
}
|
3810
|
-
});
|
3811
|
-
return instance2;
|
3812
|
-
}
|
3813
|
-
function withValueEnhancer(instance2, config, valManager) {
|
3814
|
-
Object.keys(config).forEach((key) => {
|
3815
|
-
bindInstance(instance2, key, config[key]);
|
3816
|
-
if (valManager) {
|
3817
|
-
valManager.attach(config[key]);
|
3818
|
-
}
|
3819
|
-
});
|
3820
|
-
}
|
3821
|
-
function bindInstance(instance2, key, val) {
|
3822
|
-
Object.defineProperties(instance2, {
|
3823
|
-
[key]: {
|
3824
|
-
get() {
|
3825
|
-
return val.value;
|
3826
|
-
},
|
3827
|
-
set(value) {
|
3828
|
-
val.setValue(value);
|
3829
|
-
}
|
3830
|
-
},
|
3831
|
-
[`_${key}$`]: {
|
3832
|
-
value: val
|
3833
|
-
},
|
3834
|
-
[`set${capitalize(key)}`]: {
|
3835
|
-
value: (value, meta) => val.setValue(value, meta)
|
3836
|
-
}
|
3837
|
-
});
|
3838
|
-
return instance2;
|
3839
|
-
}
|
3840
|
-
function capitalize(str) {
|
3841
|
-
return str[0].toUpperCase() + str.slice(1);
|
3842
|
-
}
|
3843
|
-
class ValManager {
|
3844
|
-
constructor() {
|
3845
|
-
__publicField(this, "vals", /* @__PURE__ */ new Set());
|
3846
|
-
}
|
3847
|
-
attach(val) {
|
3848
|
-
this.vals.add(val);
|
3849
|
-
return val;
|
3850
|
-
}
|
3851
|
-
detach(val) {
|
3852
|
-
this.vals.delete(val);
|
3853
|
-
return val;
|
3854
|
-
}
|
3855
|
-
destroy() {
|
3856
|
-
this.vals.forEach(destroyVal);
|
3857
|
-
this.vals.clear();
|
3858
|
-
}
|
3859
|
-
}
|
3860
|
-
function destroyVal(val) {
|
3861
|
-
val.destroy();
|
3862
|
-
}
|
3863
|
-
var e$2 = Object.defineProperty, t$3 = Object.defineProperties, i$1 = Object.getOwnPropertyDescriptors, s$2 = Object.getOwnPropertySymbols, a$1 = Object.prototype.hasOwnProperty, o$2 = Object.prototype.propertyIsEnumerable, r$4 = (t2, i2, s2) => i2 in t2 ? e$2(t2, i2, { enumerable: true, configurable: true, writable: true, value: s2 }) : t2[i2] = s2, n$3 = (e2, t2) => {
|
3895
|
+
var e$2 = Object.defineProperty, t$3 = Object.defineProperties, i$1 = Object.getOwnPropertyDescriptors, s$2 = Object.getOwnPropertySymbols, a$1 = Object.prototype.hasOwnProperty, n$3 = Object.prototype.propertyIsEnumerable, o$2 = (t2, i2, s2) => i2 in t2 ? e$2(t2, i2, { enumerable: true, configurable: true, writable: true, value: s2 }) : t2[i2] = s2, r$4 = (e2, t2) => {
|
3864
3896
|
for (var i2 in t2 || (t2 = {}))
|
3865
|
-
a$1.call(t2, i2) &&
|
3897
|
+
a$1.call(t2, i2) && o$2(e2, i2, t2[i2]);
|
3866
3898
|
if (s$2)
|
3867
3899
|
for (var i2 of s$2(t2))
|
3868
|
-
|
3900
|
+
n$3.call(t2, i2) && o$2(e2, i2, t2[i2]);
|
3869
3901
|
return e2;
|
3870
3902
|
};
|
3871
|
-
var v$3, w$2, C$3, y$2, E$3, z$2, B$2,
|
3872
|
-
(w$2 = v$3 || (v$3 = {})).Light = "light", w$2.Dark = "dark", w$2.Auto = "auto", (y$2 = C$3 || (C$3 = {})).Normal = "normal", y$2.Minimized = "minimized", y$2.Maximized = "maximized", (z$2 = E$3 || (E$3 = {})).DarkMode = "dark_mode", z$2.PrefersColorScheme = "prefers_color_scheme", z$2.Close = "close", z$2.Focus = "focus", z$2.Blur = "blur", z$2.IntrinsicMove = "intrinsic_move", z$2.IntrinsicResize = "intrinsic_resize", z$2.ZIndex = "z_index", z$2.State = "state", z$2.Minimized = "minimized", z$2.Maximized = "maximized", z$2.Readonly = "readonly", z$2.Destroyed = "destroyed", (
|
3903
|
+
var v$3, w$2, C$3, y$2, E$3, z$2, _, B$2, N$3, S$3;
|
3904
|
+
(w$2 = v$3 || (v$3 = {})).Light = "light", w$2.Dark = "dark", w$2.Auto = "auto", (y$2 = C$3 || (C$3 = {})).Normal = "normal", y$2.Minimized = "minimized", y$2.Maximized = "maximized", (z$2 = E$3 || (E$3 = {})).DarkMode = "dark_mode", z$2.PrefersColorScheme = "prefers_color_scheme", z$2.Close = "close", z$2.Focus = "focus", z$2.Blur = "blur", z$2.IntrinsicMove = "intrinsic_move", z$2.IntrinsicResize = "intrinsic_resize", z$2.ZIndex = "z_index", z$2.State = "state", z$2.Minimized = "minimized", z$2.Maximized = "maximized", z$2.Readonly = "readonly", z$2.Destroyed = "destroyed", (B$2 = _ || (_ = {})).Close = "close", B$2.Maximize = "maximize", B$2.Minimize = "minimize", (S$3 = N$3 || (N$3 = {})).North = "n", S$3.South = "s", S$3.West = "w", S$3.East = "e", S$3.NorthWest = "nw", S$3.NorthEast = "ne", S$3.SouthEast = "se", S$3.SouthWest = "sw";
|
3873
3905
|
function I$3(e2, t2, i2) {
|
3874
3906
|
return Math.min(Math.max(e2, t2), i2);
|
3875
3907
|
}
|
@@ -3890,7 +3922,7 @@ function V$3(e2) {
|
|
3890
3922
|
return !e2;
|
3891
3923
|
}
|
3892
3924
|
class H$3 {
|
3893
|
-
constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart:
|
3925
|
+
constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart: n2, namespace: o2 = "telebox" }) {
|
3894
3926
|
this.sideEffect = new SideEffectManager(), this.lastTitleBarClick = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarClick = (e3) => {
|
3895
3927
|
var t3;
|
3896
3928
|
if (this.readonly$.value)
|
@@ -3901,7 +3933,7 @@ class H$3 {
|
|
3901
3933
|
return;
|
3902
3934
|
k$1(e3);
|
3903
3935
|
const i3 = Date.now();
|
3904
|
-
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:
|
3936
|
+
i3 - this.lastTitleBarClick.timestamp <= 500 ? Math.abs(e3.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(e3.clientY - this.lastTitleBarClick.clientY) <= 5 && this.onEvent && this.onEvent({ type: _.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarClick.timestamp = i3, this.lastTitleBarClick.clientX = e3.clientX, this.lastTitleBarClick.clientY = e3.clientY;
|
3905
3937
|
}, this.lastTitleBarTouch = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarTouch = (e3) => {
|
3906
3938
|
var t3;
|
3907
3939
|
if (this.readonly$.value)
|
@@ -3910,8 +3942,8 @@ class H$3 {
|
|
3910
3942
|
return;
|
3911
3943
|
k$1(e3);
|
3912
3944
|
const i3 = Date.now(), { clientX: s3 = this.lastTitleBarTouch.clientX + 100, clientY: a3 = this.lastTitleBarTouch.clientY + 100 } = e3.touches[0] || {};
|
3913
|
-
i3 - this.lastTitleBarTouch.timestamp <= 500 ? Math.abs(s3 - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(a3 - this.lastTitleBarTouch.clientY) <= 10 && this.onEvent && this.onEvent({ type:
|
3914
|
-
}, this.readonly$ = e2, this.state$ = t2, this.title$ = i2, this.onEvent = a2, this.onDragStart =
|
3945
|
+
i3 - this.lastTitleBarTouch.timestamp <= 500 ? Math.abs(s3 - this.lastTitleBarTouch.clientX) <= 10 && Math.abs(a3 - this.lastTitleBarTouch.clientY) <= 10 && this.onEvent && this.onEvent({ type: _.Maximize }) : this.onDragStart && this.onDragStart(e3), this.lastTitleBarTouch.timestamp = i3, this.lastTitleBarTouch.clientX = s3, this.lastTitleBarTouch.clientY = a3;
|
3946
|
+
}, this.readonly$ = e2, this.state$ = t2, this.title$ = i2, this.onEvent = a2, this.onDragStart = n2, this.namespace = o2, this.buttons = s2 || [{ type: _.Minimize, iconClassName: this.wrapClassName("titlebar-icon-minimize") }, { type: _.Maximize, iconClassName: this.wrapClassName("titlebar-icon-maximize"), isActive: (e3) => e3 === C$3.Maximized }, { type: _.Close, iconClassName: this.wrapClassName("titlebar-icon-close") }], this.$dragArea = this.renderDragArea();
|
3915
3947
|
}
|
3916
3948
|
render() {
|
3917
3949
|
if (!this.$titleBar) {
|
@@ -3987,13 +4019,13 @@ class A$2 {
|
|
3987
4019
|
i2.className = this.wrapClassName("box-stage-mask");
|
3988
4020
|
const s2 = document.createElement("div");
|
3989
4021
|
s2.className = this.wrapClassName("box-stage-frame");
|
3990
|
-
const [a2, o2, r2
|
4022
|
+
const [a2, n2, o2, r2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
|
3991
4023
|
const i3 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
3992
4024
|
i3.setAttribute("viewBox", "0 0 8 8"), i3.setAttribute("class", `${this.wrapClassName("box-stage-frame-corner")} is-${t3}`);
|
3993
4025
|
const s3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
3994
4026
|
return s3.setAttribute("d", e3), s3.setAttribute("fill", "#3381FF"), i3.appendChild(s3), i3;
|
3995
4027
|
});
|
3996
|
-
return s2.appendChild(a2), s2.appendChild(
|
4028
|
+
return s2.appendChild(a2), s2.appendChild(o2), s2.appendChild(n2), s2.appendChild(r2), e2.appendChild(t2), e2.appendChild(s2), e2.appendChild(i2), this._sideEffect.addDisposer(this.highlightStage$.subscribe((t3) => {
|
3997
4029
|
e2.classList.toggle("is-active", t3);
|
3998
4030
|
})), this._sideEffect.addDisposer(combine([this.highlightStage$, this.stageRect$]).subscribe(([s3, a3]) => {
|
3999
4031
|
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`));
|
@@ -4008,40 +4040,40 @@ class A$2 {
|
|
4008
4040
|
}
|
4009
4041
|
const W$3 = window.ResizeObserver || ResizeObserver$2;
|
4010
4042
|
class Y$3 {
|
4011
|
-
constructor({ id: e2 = genUID(), title: t2 = L$3(), namespace: i2 = "telebox", visible: s2 = true, width: a2 = 0.5, height:
|
4043
|
+
constructor({ id: e2 = genUID(), title: t2 = L$3(), namespace: i2 = "telebox", visible: s2 = true, width: a2 = 0.5, height: n2 = 0.5, minWidth: o2 = 0, minHeight: r2 = 0, x: l2 = 0.1, y: $ = 0.1, resizable: b2 = true, draggable: v2 = true, ratio: w2 = -1, focus: y2 = false, zIndex: z2 = 100, stageRatio: _2 = null, titleBar: B2, content: N2, stage: S2, footer: M2, styles: k2, highlightStage: R2 = null, darkMode$: D2, fence$: T2, minimized$: V2, maximized$: W2, readonly$: Y2, root$: X2, rootRect$: P2, managerStageRect$: O2, managerStageRatio$: j2, collectorRect$: Z2, managerHighlightStage$: F2 }) {
|
4012
4044
|
this.events = new Emittery(), this._delegateEvents = new Emittery(), this.handleTrackStart = (e3) => {
|
4013
4045
|
var t3;
|
4014
4046
|
return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
|
4015
4047
|
}, this._sideEffect = new SideEffectManager(), this.id = e2, this.namespace = i2;
|
4016
|
-
const
|
4017
|
-
this._sideEffect.addDisposer(() =>
|
4018
|
-
const
|
4019
|
-
this._sideEffect.addDisposer(
|
4020
|
-
|
4048
|
+
const G2 = new ValManager();
|
4049
|
+
this._sideEffect.addDisposer(() => G2.destroy());
|
4050
|
+
const J2 = new Val(t2), q2 = new Val(s2), Q2 = new Val(b2), K2 = new Val(v2), U2 = new Val(w2), ee2 = new Val(z2), te2 = new Val(y2), ie2 = new Val(N2), se2 = new Val(S2), ae2 = new Val(M2), ne2 = new Val(k2), oe2 = combine([V2, W2], ([e3, t3]) => e3 ? C$3.Minimized : t3 ? C$3.Maximized : C$3.Normal), re2 = new Val({ width: I$3(o2, 0, 1), height: I$3(r2, 0, 1) }, { compare: shallowequal }), he2 = combine([re2, O2], ([e3, t3]) => ({ width: e3.width * t3.width, height: e3.height * t3.height }), { compare: shallowequal }), le2 = new Val({ width: a2, height: n2 }, { compare: shallowequal });
|
4051
|
+
this._sideEffect.addDisposer(re2.reaction((e3, t3) => {
|
4052
|
+
le2.setValue({ width: Math.max(a2, e3.width), height: Math.max(n2, e3.height) }, t3);
|
4021
4053
|
}));
|
4022
|
-
const
|
4023
|
-
this._sideEffect.addDisposer(() =>
|
4024
|
-
withReadonlyValueEnhancer(this, { darkMode:
|
4025
|
-
const
|
4026
|
-
withReadonlyValueEnhancer(this,
|
4027
|
-
withValueEnhancer(this, { title:
|
4054
|
+
const de2 = new Val({ x: l2, y: $ }, { compare: shallowequal }), ce2 = combine([le2, O2], ([e3, t3]) => ({ width: t3.width * e3.width, height: t3.height * e3.height }), { compare: shallowequal }), me2 = combine([de2, O2], ([e3, t3]) => ({ x: e3.x * t3.width + t3.x, y: e3.y * t3.height + t3.y }), { compare: shallowequal }), ue2 = new Val(R2), ge2 = combine([ue2, F2], ([e3, t3]) => e3 != null ? e3 : t3), pe2 = new Val(null), xe2 = new Val(P2.value, { compare: shallowequal }), fe2 = new Val(_2), $e2 = new A$2({ namespace: i2, root$: pe2, rootRect$: xe2, ratio$: combine([fe2, j2], ([e3, t3]) => e3 != null ? e3 : t3), highlightStage$: ge2 });
|
4055
|
+
this._sideEffect.addDisposer(() => $e2.destroy());
|
4056
|
+
withReadonlyValueEnhancer(this, { darkMode: D2, fence: T2, minimized: V2, maximized: W2, readonly: Y2, rootRect: P2, managerStageRect: O2, collectorRect: Z2 });
|
4057
|
+
const be2 = { zIndex: ee2, focus: te2, $userContent: ie2, $userStage: se2, $userFooter: ae2, $userStyles: ne2, state: oe2, minSize: re2, pxMinSize: he2, intrinsicSize: le2, intrinsicCoord: de2, pxIntrinsicSize: ce2, pxIntrinsicCoord: me2, highlightStage: ge2, boxHighlightStage: ue2, contentRect: xe2, contentStageRect: $e2.stageRect$ };
|
4058
|
+
withReadonlyValueEnhancer(this, be2, G2);
|
4059
|
+
withValueEnhancer(this, { title: J2, visible: q2, resizable: Q2, draggable: K2, ratio: U2, stageRatio: fe2 }, G2), this.titleBar = B2 || new H$3({ readonly$: Y2, state$: oe2, title$: J2, namespace: this.namespace, onDragStart: (e3) => {
|
4028
4060
|
var t3;
|
4029
4061
|
return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
|
4030
|
-
}, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(
|
4031
|
-
e3 > 0 && this.transform(
|
4032
|
-
})), this._sideEffect.addDisposer(
|
4033
|
-
e3 && this.move(
|
4034
|
-
})), this.$box = this.render(),
|
4035
|
-
const
|
4062
|
+
}, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(U2.subscribe((e3) => {
|
4063
|
+
e3 > 0 && this.transform(me2.value.x, me2.value.y, ce2.value.width, ce2.value.height, true);
|
4064
|
+
})), this._sideEffect.addDisposer(T2.subscribe((e3) => {
|
4065
|
+
e3 && this.move(me2.value.x, me2.value.y, true);
|
4066
|
+
})), this.$box = this.render(), pe2.setValue(this.$content.parentElement);
|
4067
|
+
const ve2 = (e3, t3) => {
|
4036
4068
|
this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
|
4037
4069
|
i3 || this.events.emit(t3, e4);
|
4038
4070
|
}));
|
4039
4071
|
};
|
4040
|
-
|
4072
|
+
ve2(D2, E$3.DarkMode), ve2(Y2, E$3.Readonly), ve2(ee2, E$3.ZIndex), ve2(V2, E$3.Minimized), ve2(W2, E$3.Maximized), ve2(oe2, E$3.State), ve2(le2, E$3.IntrinsicResize), ve2(de2, E$3.IntrinsicMove), this._sideEffect.addDisposer([q2.reaction((e3, t3) => {
|
4041
4073
|
t3 || e3 || this.events.emit(E$3.Close);
|
4042
|
-
}),
|
4074
|
+
}), te2.reaction((e3, t3) => {
|
4043
4075
|
t3 || this.events.emit(e3 ? E$3.Focus : E$3.Blur);
|
4044
|
-
}),
|
4076
|
+
}), X2.subscribe((e3) => {
|
4045
4077
|
e3 ? e3.appendChild(this.$box) : this.$box.parentNode && this.$box.remove();
|
4046
4078
|
})]);
|
4047
4079
|
}
|
@@ -4074,22 +4106,22 @@ class Y$3 {
|
|
4074
4106
|
}
|
4075
4107
|
move(e2, t2, i2 = false) {
|
4076
4108
|
let s2, a2;
|
4077
|
-
const
|
4109
|
+
const n2 = this.managerStageRect, o2 = this.pxIntrinsicSize;
|
4078
4110
|
if (this.fence)
|
4079
|
-
s2 = I$3(e2,
|
4111
|
+
s2 = I$3(e2, n2.x, n2.x + n2.width - o2.width), a2 = I$3(t2, n2.y, n2.y + n2.height - o2.height);
|
4080
4112
|
else {
|
4081
4113
|
const i3 = this.rootRect;
|
4082
|
-
s2 = I$3(e2,
|
4114
|
+
s2 = I$3(e2, 0 - o2.width + 20, 0 + i3.width - 20), a2 = I$3(t2, 0, 0 + i3.height - 20);
|
4083
4115
|
}
|
4084
|
-
this._intrinsicCoord$.setValue({ x: (s2 -
|
4116
|
+
this._intrinsicCoord$.setValue({ x: (s2 - n2.x) / n2.width, y: (a2 - n2.y) / n2.height }, i2);
|
4085
4117
|
}
|
4086
4118
|
transform(e2, t2, i2, s2, a2 = false) {
|
4087
|
-
const
|
4119
|
+
const n2 = this.managerStageRect, o2 = this.rootRect;
|
4088
4120
|
if (i2 = Math.max(i2, this.pxMinSize.width), s2 = Math.max(s2, this.pxMinSize.height), this.ratio > 0) {
|
4089
4121
|
const e3 = this.ratio * i2;
|
4090
4122
|
t2 !== this.pxIntrinsicCoord.y && (t2 -= e3 - s2), s2 = e3;
|
4091
4123
|
}
|
4092
|
-
t2 <
|
4124
|
+
t2 < o2.y && (t2 = o2.y, s2 = this.pxIntrinsicSize.height), this.move(e2, t2, a2), this._intrinsicSize$.setValue({ width: i2 / n2.width, height: s2 / n2.height }, a2);
|
4093
4125
|
}
|
4094
4126
|
mountContent(e2) {
|
4095
4127
|
this._$userContent$.setValue(e2);
|
@@ -4097,6 +4129,12 @@ class Y$3 {
|
|
4097
4129
|
unmountContent() {
|
4098
4130
|
this._$userContent$.setValue(void 0);
|
4099
4131
|
}
|
4132
|
+
mountStage(e2) {
|
4133
|
+
this._$userStage$.setValue(e2);
|
4134
|
+
}
|
4135
|
+
unmountStage() {
|
4136
|
+
this._$userStage$.setValue(void 0);
|
4137
|
+
}
|
4100
4138
|
mountFooter(e2) {
|
4101
4139
|
this._$userFooter$.setValue(e2);
|
4102
4140
|
}
|
@@ -4139,47 +4177,62 @@ class Y$3 {
|
|
4139
4177
|
this.$box.style.zIndex = String(e3);
|
4140
4178
|
})), this.$box.dataset.teleBoxID = this.id;
|
4141
4179
|
const t2 = index(this.$box), i2 = combine([this._maximized$, this._minimized$, this._pxIntrinsicSize$, this._pxIntrinsicCoord$, this._collectorRect$], ([e3, t3, i3, s3, a3]) => {
|
4142
|
-
const
|
4180
|
+
const n3 = e3 ? { x: 0, y: 0, width: "100%", height: "100%", scaleX: 1, scaleY: 1 } : { x: s3.x, y: s3.y, width: i3.width + "px", height: i3.height + "px", scaleX: 1, scaleY: 1 };
|
4143
4181
|
if (t3 && a3) {
|
4144
4182
|
const { width: t4, height: s4 } = e3 ? this.rootRect : i3;
|
4145
|
-
|
4183
|
+
n3.x = a3.x - t4 / 2 + a3.width / 2, n3.y = a3.y - s4 / 2 + a3.height / 2, n3.scaleX = a3.width / t4, n3.scaleY = a3.height / s4;
|
4146
4184
|
}
|
4147
|
-
return
|
4185
|
+
return n3;
|
4148
4186
|
}, { compare: shallowequal }), s2 = i2.value;
|
4149
4187
|
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) => {
|
4150
4188
|
t2.set(e3);
|
4151
4189
|
}));
|
4152
4190
|
const a2 = document.createElement("div");
|
4153
4191
|
a2.className = this.wrapClassName("box-main"), this.$box.appendChild(a2);
|
4192
|
+
const n2 = document.createElement("div");
|
4193
|
+
n2.className = this.wrapClassName("titlebar-wrap"), n2.appendChild(this.titleBar.render()), this.$titleBar = n2;
|
4154
4194
|
const o2 = document.createElement("div");
|
4155
|
-
o2.className = this.wrapClassName("
|
4195
|
+
o2.className = this.wrapClassName("content-wrap");
|
4156
4196
|
const r2 = document.createElement("div");
|
4157
|
-
r2.className = this.wrapClassName("content-
|
4158
|
-
const n2 = document.createElement("div");
|
4159
|
-
n2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = n2, this._sideEffect.add(() => {
|
4197
|
+
r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2, this._sideEffect.add(() => {
|
4160
4198
|
const e3 = new W$3(() => {
|
4161
|
-
const e4 =
|
4162
|
-
this._contentRect$.setValue({ x:
|
4199
|
+
const e4 = r2.getBoundingClientRect();
|
4200
|
+
this._contentRect$.setValue({ x: 0, y: 0, width: e4.width, height: e4.height });
|
4163
4201
|
});
|
4164
|
-
return e3.observe(
|
4202
|
+
return e3.observe(r2), () => e3.disconnect();
|
4165
4203
|
}), this._sideEffect.add(() => {
|
4166
4204
|
let e3;
|
4167
4205
|
return this._$userStyles$.subscribe((t3) => {
|
4168
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4206
|
+
e3 && e3.remove(), e3 = t3, t3 && o2.appendChild(t3);
|
4169
4207
|
});
|
4170
4208
|
}), this._sideEffect.add(() => {
|
4171
4209
|
let e3;
|
4172
4210
|
return this._$userContent$.subscribe((t3) => {
|
4173
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4211
|
+
e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
|
4212
|
+
});
|
4213
|
+
}), this._sideEffect.add(() => {
|
4214
|
+
let e3;
|
4215
|
+
return this._$userStage$.subscribe((t3) => {
|
4216
|
+
var i3;
|
4217
|
+
if (e3 && e3.remove(), e3 = t3, t3) {
|
4218
|
+
if (!this.$stage) {
|
4219
|
+
const e4 = document.createElement("div");
|
4220
|
+
this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
|
4221
|
+
t4 && (e4.style.top = t4.y + "px", e4.style.left = t4.x + "px", e4.style.width = t4.width + "px", e4.style.height = t4.height + "px");
|
4222
|
+
}), "content-stage-rect"), r2.appendChild(e4);
|
4223
|
+
}
|
4224
|
+
this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
|
4225
|
+
} else
|
4226
|
+
((i3 = this.$stage) == null ? void 0 : i3.parentElement) && this.$stage.remove();
|
4174
4227
|
});
|
4175
|
-
}),
|
4228
|
+
}), o2.appendChild(r2);
|
4176
4229
|
const h = document.createElement("div");
|
4177
4230
|
return h.className = this.wrapClassName("footer-wrap"), this.$footer = h, this._sideEffect.add(() => {
|
4178
4231
|
let e3;
|
4179
4232
|
return this._$userFooter$.subscribe((t3) => {
|
4180
4233
|
e3 && e3.remove(), e3 = t3, t3 && h.appendChild(t3);
|
4181
4234
|
});
|
4182
|
-
}), a2.appendChild(
|
4235
|
+
}), a2.appendChild(n2), a2.appendChild(o2), a2.appendChild(h), this._renderResizeHandlers(), this.$box;
|
4183
4236
|
}
|
4184
4237
|
_renderResizeHandlers() {
|
4185
4238
|
const e2 = document.createElement("div");
|
@@ -4188,7 +4241,7 @@ class Y$3 {
|
|
4188
4241
|
i3.className = this.wrapClassName(t3) + " " + this.wrapClassName("resize-handle"), i3.dataset.teleBoxHandle = t3, e2.appendChild(i3);
|
4189
4242
|
}), this.$box.appendChild(e2);
|
4190
4243
|
const t2 = "handle-tracking-listener", i2 = this.wrapClassName("transforming");
|
4191
|
-
let s2, a2,
|
4244
|
+
let s2, a2, n2 = 0, o2 = 0, r2 = 0, h = 0, l2 = 0, d2 = 0;
|
4192
4245
|
const c = (e3) => {
|
4193
4246
|
if (this.state !== C$3.Normal)
|
4194
4247
|
return;
|
@@ -4196,36 +4249,36 @@ class Y$3 {
|
|
4196
4249
|
let { pageX: t3, pageY: i3 } = R$3(e3);
|
4197
4250
|
i3 < this.rootRect.y && (i3 = this.rootRect.y);
|
4198
4251
|
const s3 = t3 - l2, c2 = i3 - d2;
|
4199
|
-
let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width:
|
4252
|
+
let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: p2 } = this.pxIntrinsicSize;
|
4200
4253
|
switch (a2) {
|
4201
4254
|
case N$3.North:
|
4202
|
-
u3 =
|
4255
|
+
u3 = o2 + c2, p2 = h - c2;
|
4203
4256
|
break;
|
4204
4257
|
case N$3.South:
|
4205
|
-
|
4258
|
+
p2 = h + c2;
|
4206
4259
|
break;
|
4207
4260
|
case N$3.West:
|
4208
|
-
m3 =
|
4261
|
+
m3 = n2 + s3, g2 = r2 - s3;
|
4209
4262
|
break;
|
4210
4263
|
case N$3.East:
|
4211
|
-
|
4264
|
+
g2 = r2 + s3;
|
4212
4265
|
break;
|
4213
4266
|
case N$3.NorthWest:
|
4214
|
-
m3 =
|
4267
|
+
m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, p2 = h - c2;
|
4215
4268
|
break;
|
4216
4269
|
case N$3.NorthEast:
|
4217
|
-
u3 =
|
4270
|
+
u3 = o2 + c2, g2 = r2 + s3, p2 = h - c2;
|
4218
4271
|
break;
|
4219
4272
|
case N$3.SouthEast:
|
4220
|
-
|
4273
|
+
g2 = r2 + s3, p2 = h + c2;
|
4221
4274
|
break;
|
4222
4275
|
case N$3.SouthWest:
|
4223
|
-
m3 =
|
4276
|
+
m3 = n2 + s3, g2 = r2 - s3, p2 = h + c2;
|
4224
4277
|
break;
|
4225
4278
|
default:
|
4226
|
-
return void this.move(
|
4279
|
+
return void this.move(n2 + s3, o2 + c2);
|
4227
4280
|
}
|
4228
|
-
this.transform(m3, u3,
|
4281
|
+
this.transform(m3, u3, g2, p2);
|
4229
4282
|
}, m2 = (e3) => {
|
4230
4283
|
a2 = void 0, s2 && (k$1(e3), this.$box.classList.toggle(i2, false), this._sideEffect.flush(t2), s2.remove());
|
4231
4284
|
}, u2 = (e3) => {
|
@@ -4236,9 +4289,9 @@ class Y$3 {
|
|
4236
4289
|
return;
|
4237
4290
|
if (!this.draggable || a2 || this.state !== C$3.Normal)
|
4238
4291
|
return;
|
4239
|
-
const
|
4240
|
-
if ((u3 =
|
4241
|
-
k$1(e3), { x:
|
4292
|
+
const g2 = e3.target;
|
4293
|
+
if ((u3 = g2.dataset) == null ? void 0 : u3.teleBoxHandle) {
|
4294
|
+
k$1(e3), { x: n2, y: o2 } = this.pxIntrinsicCoord, { width: r2, height: h } = this.pxIntrinsicSize, { pageX: l2, pageY: d2 } = R$3(e3), a2 = g2.dataset.teleBoxHandle, s2 || (s2 = document.createElement("div"));
|
4242
4295
|
const u4 = a2 ? this.wrapClassName(`cursor-${a2}`) : "";
|
4243
4296
|
s2.className = this.wrapClassName("track-mask" + (u4 ? ` ${u4}` : "")), this.$box.appendChild(s2), this.$box.classList.add(i2), this._sideEffect.add(() => (window.addEventListener("mousemove", c), window.addEventListener("touchmove", c, { passive: false }), window.addEventListener("mouseup", m2), window.addEventListener("touchend", m2, { passive: false }), window.addEventListener("touchcancel", m2, { passive: false }), () => {
|
4244
4297
|
window.removeEventListener("mousemove", c), window.removeEventListener("touchmove", c), window.removeEventListener("mouseup", m2), window.removeEventListener("touchend", m2), window.removeEventListener("touchcancel", m2);
|
@@ -4256,14 +4309,14 @@ class Y$3 {
|
|
4256
4309
|
}
|
4257
4310
|
var X$3, P$3;
|
4258
4311
|
class O$3 {
|
4259
|
-
constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles:
|
4312
|
+
constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles: n2 = {}, root$: o2 }) {
|
4260
4313
|
this._sideEffect = new SideEffectManager(), this.namespace = a2;
|
4261
|
-
const
|
4262
|
-
this._sideEffect.addDisposer(() =>
|
4263
|
-
const h = new Val(void 0), l2 = derive(e2), d2 = new Val(
|
4264
|
-
withValueEnhancer(this, { styles: d2, $collector: m2 },
|
4265
|
-
withReadonlyValueEnhancer(this, { root:
|
4266
|
-
withReadonlyValueEnhancer(this, { rect: h, visible: l2 },
|
4314
|
+
const r2 = new ValManager();
|
4315
|
+
this._sideEffect.addDisposer(() => r2.destroy());
|
4316
|
+
const h = new Val(void 0), l2 = derive(e2), d2 = new Val(n2), m2 = new Val(document.createElement("button"));
|
4317
|
+
withValueEnhancer(this, { styles: d2, $collector: m2 }, r2);
|
4318
|
+
withReadonlyValueEnhancer(this, { root: o2 });
|
4319
|
+
withReadonlyValueEnhancer(this, { rect: h, visible: l2 }, r2), m2.value.className = this.wrapClassName("collector"), m2.value.style.backgroundImage = "url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K')", this._sideEffect.addDisposer(m2.subscribe((a3) => {
|
4267
4320
|
this._sideEffect.addEventListener(a3, "click", () => {
|
4268
4321
|
t2.value || e2.setValue(false);
|
4269
4322
|
}, {}, "telebox-collector-click"), this._sideEffect.addDisposer([l2.subscribe((e3) => {
|
@@ -4277,12 +4330,12 @@ class O$3 {
|
|
4277
4330
|
const i3 = e3[t3];
|
4278
4331
|
i3 != null && (a3.style[t3] = i3);
|
4279
4332
|
});
|
4280
|
-
}),
|
4333
|
+
}), o2.subscribe((e3) => {
|
4281
4334
|
e3 && e3.appendChild(a3);
|
4282
|
-
}), combine([e2, s2,
|
4335
|
+
}), combine([e2, s2, o2]).subscribe(([e3, t3, i3]) => {
|
4283
4336
|
if (e3 && i3) {
|
4284
|
-
const { x: e4, y: i4, width: s3, height:
|
4285
|
-
h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height:
|
4337
|
+
const { x: e4, y: i4, width: s3, height: n3 } = a3.getBoundingClientRect();
|
4338
|
+
h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height: n3 });
|
4286
4339
|
}
|
4287
4340
|
})], "telebox-collector-el");
|
4288
4341
|
}));
|
@@ -4308,8 +4361,8 @@ class j$1 extends H$3 {
|
|
4308
4361
|
if (this.$titles && this.state$.value === C$3.Maximized) {
|
4309
4362
|
const { children: i2 } = this.$titles.firstElementChild;
|
4310
4363
|
for (let s2 = i2.length - 1; s2 >= 0; s2 -= 1) {
|
4311
|
-
const a2 = i2[s2],
|
4312
|
-
|
4364
|
+
const a2 = i2[s2], n2 = (t2 = a2.dataset) == null ? void 0 : t2.teleBoxID;
|
4365
|
+
n2 && (e2 && n2 === e2.id ? a2.classList.toggle(this.wrapClassName("titles-tab-focus"), true) : this.focusedBox && n2 === this.focusedBox.id && a2.classList.toggle(this.wrapClassName("titles-tab-focus"), false));
|
4313
4366
|
}
|
4314
4367
|
}
|
4315
4368
|
this.focusedBox = e2;
|
@@ -4349,11 +4402,11 @@ class j$1 extends H$3 {
|
|
4349
4402
|
}
|
4350
4403
|
const Z$3 = window.ResizeObserver || ResizeObserver$2;
|
4351
4404
|
class F$3 {
|
4352
|
-
constructor({ root: e2 = null, prefersColorScheme: t2 = v$3.Light, minimized: i2 = false, maximized: s2 = false, fence: a2 = false, collector:
|
4353
|
-
this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace =
|
4405
|
+
constructor({ root: e2 = null, prefersColorScheme: t2 = v$3.Light, minimized: i2 = false, maximized: s2 = false, fence: a2 = false, collector: n2, namespace: o2 = "telebox", readonly: r2 = false, stageRatio: l2 = -1, highlightStage: m2 = true } = {}) {
|
4406
|
+
this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace = o2;
|
4354
4407
|
const b2 = new ValManager();
|
4355
4408
|
this._sideEffect.addDisposer(() => b2.destroy());
|
4356
|
-
const w2 = new Val(e2), y2 = new Val(
|
4409
|
+
const w2 = new Val(e2), y2 = new Val(r2), z2 = new Val(i2), B2 = new Val(s2), N2 = new Val(a2), S2 = new Val(l2), M2 = new Val(m2), I2 = new Val({ x: 0, y: 0, width: window.innerWidth, height: window.innerHeight }, { compare: shallowequal });
|
4357
4410
|
this._sideEffect.addDisposer(w2.subscribe((e3) => {
|
4358
4411
|
this._sideEffect.add(() => {
|
4359
4412
|
if (!e3)
|
@@ -4361,7 +4414,7 @@ class F$3 {
|
|
4361
4414
|
};
|
4362
4415
|
const t3 = new Z$3(() => {
|
4363
4416
|
const t4 = e3.getBoundingClientRect();
|
4364
|
-
I2.setValue({ x:
|
4417
|
+
I2.setValue({ x: 0, y: 0, width: t4.width, height: t4.height });
|
4365
4418
|
});
|
4366
4419
|
return t3.observe(e3), () => t3.disconnect();
|
4367
4420
|
}, "calc-root-rect");
|
@@ -4383,13 +4436,13 @@ class F$3 {
|
|
4383
4436
|
this._sideEffect.addDisposer(D2.reaction((e3, t3) => {
|
4384
4437
|
t3 || this.events.emit(X$3.PrefersColorScheme, e3);
|
4385
4438
|
}));
|
4386
|
-
const L2 = combine([R2, D2], ([e3, t3]) => t3 === "auto" ? e3 : t3 === "dark"), T2 = combine([z2,
|
4387
|
-
this.collector =
|
4388
|
-
const V2 = new A$2({ namespace:
|
4439
|
+
const L2 = combine([R2, D2], ([e3, t3]) => t3 === "auto" ? e3 : t3 === "dark"), T2 = combine([z2, B2], ([e3, t3]) => e3 ? C$3.Minimized : t3 ? C$3.Maximized : C$3.Normal);
|
4440
|
+
this.collector = n2 != null ? n2 : new O$3({ minimized$: z2, readonly$: y2, darkMode$: L2, namespace: o2, root$: w2, rootRect$: I2 });
|
4441
|
+
const V2 = new A$2({ namespace: o2, rootRect$: I2, ratio$: S2, root$: w2, highlightStage$: combine([M2, B2, z2], ([e3, t3, i3]) => e3 && (i3 || !t3)) });
|
4389
4442
|
this._sideEffect.addDisposer(() => V2.destroy());
|
4390
4443
|
const H2 = { darkMode: L2, state: T2, root: w2, rootRect: I2, stageRect: V2.stageRect$ };
|
4391
4444
|
withReadonlyValueEnhancer(this, H2, b2);
|
4392
|
-
withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized:
|
4445
|
+
withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized: B2, stageRatio: S2, highlightStage: M2 }, b2);
|
4393
4446
|
const W2 = this.wrapClassName("titlebar-icon-close"), Y2 = (e3) => {
|
4394
4447
|
var t3;
|
4395
4448
|
if (y2.value)
|
@@ -4409,10 +4462,10 @@ class F$3 {
|
|
4409
4462
|
};
|
4410
4463
|
this._sideEffect.addEventListener(window, "mousedown", Y2, true), this._sideEffect.addEventListener(window, "touchstart", Y2, true), this.titleBar = new j$1({ namespace: this.namespace, title$: derive(this.topBox$, (e3) => (e3 == null ? void 0 : e3.title) || ""), boxes$: this.boxes$, darkMode$: L2, readonly$: y2, state$: T2, root$: w2, rootRect$: I2, onEvent: (e3) => {
|
4411
4464
|
switch (e3.type) {
|
4412
|
-
case
|
4413
|
-
|
4465
|
+
case _.Maximize:
|
4466
|
+
B2.setValue(!B2.value);
|
4414
4467
|
break;
|
4415
|
-
case
|
4468
|
+
case _.Minimize:
|
4416
4469
|
z2.setValue(true);
|
4417
4470
|
break;
|
4418
4471
|
case E$3.Close:
|
@@ -4420,7 +4473,7 @@ class F$3 {
|
|
4420
4473
|
}
|
4421
4474
|
} }), this._sideEffect.addDisposer([T2.reaction((e3, t3) => {
|
4422
4475
|
t3 || this.events.emit(X$3.State, e3);
|
4423
|
-
}),
|
4476
|
+
}), B2.reaction((e3, t3) => {
|
4424
4477
|
t3 || this.events.emit(X$3.Maximized, e3);
|
4425
4478
|
}), z2.reaction((e3, t3) => {
|
4426
4479
|
t3 || this.events.emit(X$3.Minimized, e3);
|
@@ -4448,13 +4501,13 @@ class F$3 {
|
|
4448
4501
|
return this;
|
4449
4502
|
}
|
4450
4503
|
create(e2 = {}, s2 = true) {
|
4451
|
-
const a2 = new Y$3((
|
4452
|
-
var
|
4453
|
-
return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(
|
4504
|
+
const a2 = new Y$3((n2 = r$4(r$4({ zIndex: this.topBox ? this.topBox.zIndex + 1 : 100 }, e2), s2 ? this.smartPosition(e2) : {}), o2 = { namespace: this.namespace, root$: this._root$, darkMode$: this._darkMode$, maximized$: this._maximized$, minimized$: this._minimized$, fence$: this._fence$, rootRect$: this._rootRect$, managerStageRect$: this._stageRect$, managerStageRatio$: this._stageRatio$, readonly$: this._readonly$, collectorRect$: this.collector._rect$, managerHighlightStage$: this._highlightStage$ }, t$3(n2, i$1(o2))));
|
4505
|
+
var n2, o2;
|
4506
|
+
return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(_.Maximize, () => {
|
4454
4507
|
this.setMaximized(!this.maximized);
|
4455
|
-
}), a2._delegateEvents.on(
|
4508
|
+
}), a2._delegateEvents.on(_.Minimize, () => {
|
4456
4509
|
this.setMinimized(true);
|
4457
|
-
}), a2._delegateEvents.on(
|
4510
|
+
}), a2._delegateEvents.on(_.Close, () => {
|
4458
4511
|
this.remove(a2), this.focusTopBox();
|
4459
4512
|
}), a2._intrinsicCoord$.reaction((e3, t2) => {
|
4460
4513
|
t2 || this.events.emit(X$3.IntrinsicMove, a2);
|
@@ -4539,27 +4592,27 @@ class F$3 {
|
|
4539
4592
|
return (i2) => t2.every((t3) => e2[t3] === i2[t3]);
|
4540
4593
|
}
|
4541
4594
|
updateBox(e2, t2, i2 = false) {
|
4542
|
-
var s2, a2, o2, r2,
|
4543
|
-
t2.x == null && t2.y == null || e2._intrinsicCoord$.setValue({ x: (s2 = t2.x) != null ? s2 : e2.intrinsicX, y: (a2 = t2.y) != null ? a2 : e2.intrinsicY }, i2), t2.width == null && t2.height == null || e2._intrinsicSize$.setValue({ width: (
|
4595
|
+
var s2, a2, n2, o2, r2, h;
|
4596
|
+
t2.x == null && t2.y == null || e2._intrinsicCoord$.setValue({ x: (s2 = t2.x) != null ? s2 : e2.intrinsicX, y: (a2 = t2.y) != null ? a2 : e2.intrinsicY }, i2), t2.width == null && t2.height == null || e2._intrinsicSize$.setValue({ width: (n2 = t2.width) != null ? n2 : e2.intrinsicWidth, height: (o2 = t2.height) != null ? o2 : e2.intrinsicHeight }, i2), t2.title != null && e2._title$.setValue(t2.title), t2.visible != null && e2._visible$.setValue(t2.visible, i2), t2.resizable != null && e2._resizable$.setValue(t2.resizable, i2), t2.draggable != null && e2._draggable$.setValue(t2.draggable, i2), t2.ratio != null && e2._ratio$.setValue(t2.ratio, i2), t2.zIndex != null && e2._zIndex$.setValue(t2.zIndex, i2), t2.stageRatio !== void 0 && e2.setStageRatio(t2.stageRatio, i2), t2.content != null && e2.mountContent(t2.content), t2.footer != null && e2.mountFooter(t2.footer), t2.minHeight == null && t2.minWidth == null || e2._minSize$.setValue({ width: (r2 = t2.minWidth) != null ? r2 : e2.minWidth, height: (h = t2.minHeight) != null ? h : e2.minHeight }, i2);
|
4544
4597
|
}
|
4545
4598
|
smartPosition(e2) {
|
4546
4599
|
let { x: t2, y: i2 } = e2;
|
4547
|
-
const { width: s2 = 0.5, height: a2 = 0.5 } = e2,
|
4600
|
+
const { width: s2 = 0.5, height: a2 = 0.5 } = e2, n2 = this.stageRect, o2 = this.topBox;
|
4548
4601
|
if (t2 == null) {
|
4549
|
-
let e3 =
|
4550
|
-
if (
|
4551
|
-
const t3 =
|
4552
|
-
t3 + s2 *
|
4602
|
+
let e3 = n2.x + 20;
|
4603
|
+
if (o2) {
|
4604
|
+
const t3 = o2.pxIntrinsicCoord.x + 20;
|
4605
|
+
t3 + s2 * n2.width <= n2.x + n2.width && (e3 = t3);
|
4553
4606
|
}
|
4554
|
-
t2 = (e3 -
|
4607
|
+
t2 = (e3 - n2.x) / n2.width;
|
4555
4608
|
}
|
4556
4609
|
if (i2 == null) {
|
4557
|
-
let e3 =
|
4558
|
-
if (
|
4559
|
-
const t3 =
|
4560
|
-
t3 + a2 *
|
4610
|
+
let e3 = n2.y + 20;
|
4611
|
+
if (o2) {
|
4612
|
+
const t3 = o2.pxIntrinsicCoord.y + 20;
|
4613
|
+
t3 + a2 * n2.height <= n2.y + n2.height && (e3 = t3);
|
4561
4614
|
}
|
4562
|
-
i2 = (e3 -
|
4615
|
+
i2 = (e3 - n2.y) / n2.height;
|
4563
4616
|
}
|
4564
4617
|
return { x: t2, y: i2, width: s2, height: a2 };
|
4565
4618
|
}
|
@@ -4576,7 +4629,6 @@ class F$3 {
|
|
4576
4629
|
const createBoxManager = (manager, callbacks2, emitter2, boxEmitter2, options) => {
|
4577
4630
|
return new BoxManager({
|
4578
4631
|
safeSetAttributes: (attributes) => manager.safeSetAttributes(attributes),
|
4579
|
-
getMainView: () => manager.mainView,
|
4580
4632
|
updateAppState: (...args) => {
|
4581
4633
|
var _a;
|
4582
4634
|
return (_a = manager.appManager) == null ? void 0 : _a.store.updateAppState(...args);
|
@@ -4677,9 +4729,6 @@ class BoxManager {
|
|
4677
4729
|
})
|
4678
4730
|
]);
|
4679
4731
|
}
|
4680
|
-
get mainView() {
|
4681
|
-
return this.context.getMainView();
|
4682
|
-
}
|
4683
4732
|
get canOperate() {
|
4684
4733
|
return this.context.canOperate();
|
4685
4734
|
}
|
@@ -4726,8 +4775,9 @@ class BoxManager {
|
|
4726
4775
|
height,
|
4727
4776
|
id: params.appId
|
4728
4777
|
};
|
4729
|
-
this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4778
|
+
const box = this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4730
4779
|
this.context.emitter.emit(`${params.appId}${Events.WindowCreated}`);
|
4780
|
+
return box;
|
4731
4781
|
}
|
4732
4782
|
setupBoxManager(createTeleBoxManagerConfig) {
|
4733
4783
|
const root = WindowManager.playground;
|
@@ -4735,7 +4785,8 @@ class BoxManager {
|
|
4735
4785
|
stageRatio: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.stageRatio,
|
4736
4786
|
root,
|
4737
4787
|
fence: false,
|
4738
|
-
prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme
|
4788
|
+
prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme,
|
4789
|
+
highlightStage: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.highlightStage
|
4739
4790
|
};
|
4740
4791
|
const manager = new F$3(initManagerState);
|
4741
4792
|
if (this.teleBoxManager) {
|
@@ -5850,6 +5901,7 @@ class ReconnectRefresher {
|
|
5850
5901
|
this.reactors.set(id2, func);
|
5851
5902
|
this.disposers.set(id2, func());
|
5852
5903
|
}
|
5904
|
+
return () => this.remove(id2);
|
5853
5905
|
}
|
5854
5906
|
remove(id2) {
|
5855
5907
|
if (this.reactors.has(id2)) {
|
@@ -15475,14 +15527,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15475
15527
|
const _WindowManager = class extends InvisiblePlugin {
|
15476
15528
|
constructor(context) {
|
15477
15529
|
super(context);
|
15478
|
-
this.version = "1.0.0-canary.
|
15479
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15530
|
+
this.version = "1.0.0-canary.10";
|
15531
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.15", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.2.1", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15480
15532
|
this.emitter = callbacks$1;
|
15481
15533
|
this.viewMode = ViewMode.Broadcaster;
|
15482
15534
|
this.isReplay = isPlayer(this.displayer);
|
15483
15535
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15484
15536
|
_WindowManager.displayer = context.displayer;
|
15485
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15537
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.15", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.2.1", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15486
15538
|
}
|
15487
15539
|
static async mount(params) {
|
15488
15540
|
var _a;
|
@@ -15539,7 +15591,8 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15539
15591
|
collectorContainer: params.collectorContainer,
|
15540
15592
|
collectorStyles: params.collectorStyles,
|
15541
15593
|
prefersColorScheme: params.prefersColorScheme,
|
15542
|
-
stageRatio: params.containerSizeRatio
|
15594
|
+
stageRatio: params.containerSizeRatio,
|
15595
|
+
highlightStage: params.highlightStage
|
15543
15596
|
});
|
15544
15597
|
(_a = manager.appManager) == null ? void 0 : _a.setBoxManager(manager.boxManager);
|
15545
15598
|
if (params.container) {
|
@@ -15759,6 +15812,17 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15759
15812
|
return false;
|
15760
15813
|
}
|
15761
15814
|
}
|
15815
|
+
async jumpPage(index2) {
|
15816
|
+
if (!this.appManager) {
|
15817
|
+
return false;
|
15818
|
+
}
|
15819
|
+
if (index2 < 0 || index2 >= this.pageState.length) {
|
15820
|
+
console.warn(`[WindowManager]: index ${index2} out of range`);
|
15821
|
+
return false;
|
15822
|
+
}
|
15823
|
+
await this.appManager.setMainViewSceneIndex(index2);
|
15824
|
+
return true;
|
15825
|
+
}
|
15762
15826
|
async addPage(params) {
|
15763
15827
|
if (this.appManager) {
|
15764
15828
|
const after = params == null ? void 0 : params.after;
|