@netless/window-manager 1.0.0-canary.1 → 1.0.0-canary.4
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 +14 -15
- package/dist/App/AppPageStateImpl.d.ts +6 -2
- package/dist/App/AppProxy.d.ts +17 -2
- package/dist/App/AppViewSync.d.ts +11 -0
- package/dist/App/WhiteboardView.d.ts +21 -0
- package/dist/App/index.d.ts +1 -0
- package/dist/AppManager.d.ts +3 -1
- package/dist/AttributesDelegate.d.ts +6 -14
- package/dist/BoxManager.d.ts +1 -1
- package/dist/Helper.d.ts +12 -2
- package/dist/InternalEmitter.d.ts +2 -0
- package/dist/ReconnectRefresher.d.ts +1 -1
- package/dist/Utils/Common.d.ts +1 -0
- package/dist/View/CameraSynchronizer.d.ts +4 -4
- package/dist/View/ViewSync.d.ts +7 -0
- package/dist/constants.d.ts +1 -0
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +563 -576
- 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 +65 -72
- package/src/App/AppPageStateImpl.ts +25 -6
- package/src/App/AppProxy.ts +110 -13
- package/src/App/AppViewSync.ts +69 -0
- package/src/App/Storage/index.ts +4 -4
- package/src/App/WhiteboardView.ts +85 -0
- package/src/App/index.ts +1 -0
- package/src/AppManager.ts +10 -2
- package/src/AttributesDelegate.ts +14 -17
- package/src/BoxManager.ts +3 -2
- package/src/Helper.ts +10 -1
- package/src/InternalEmitter.ts +2 -0
- package/src/ReconnectRefresher.ts +1 -0
- package/src/Utils/Common.ts +6 -0
- package/src/View/CameraSynchronizer.ts +15 -8
- package/src/View/MainView.ts +9 -13
- package/src/View/ViewSync.ts +10 -0
- package/src/constants.ts +2 -0
- package/src/index.ts +3 -1
- 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,101 @@ class Storage {
|
|
890
897
|
}
|
891
898
|
}
|
892
899
|
}
|
900
|
+
class WhiteBoardView {
|
901
|
+
constructor(appContext, appProxy, removeViewWrapper) {
|
902
|
+
this.appContext = appContext;
|
903
|
+
this.appProxy = appProxy;
|
904
|
+
this.removeViewWrapper = removeViewWrapper;
|
905
|
+
this.nextPage = async () => {
|
906
|
+
const nextIndex = this.pageState.index + 1;
|
907
|
+
return this.jumpPage(nextIndex);
|
908
|
+
};
|
909
|
+
this.prevPage = async () => {
|
910
|
+
const nextIndex = this.pageState.index - 1;
|
911
|
+
return this.jumpPage(nextIndex);
|
912
|
+
};
|
913
|
+
this.jumpPage = async (index2) => {
|
914
|
+
if (index2 < 0 || index2 >= this.pageState.length) {
|
915
|
+
console.warn(`[WindowManager]: index ${index2} out of range`);
|
916
|
+
return false;
|
917
|
+
}
|
918
|
+
this.appProxy.setSceneIndex(index2);
|
919
|
+
return true;
|
920
|
+
};
|
921
|
+
this.addPage = async (params) => {
|
922
|
+
const after = params == null ? void 0 : params.after;
|
923
|
+
const scene = params == null ? void 0 : params.scene;
|
924
|
+
const scenePath = this.appProxy.scenePath;
|
925
|
+
if (!scenePath)
|
926
|
+
return;
|
927
|
+
if (after) {
|
928
|
+
const nextIndex = this.pageState.index + 1;
|
929
|
+
putScenes(this.appContext.room, scenePath, [scene || {}], nextIndex);
|
930
|
+
} else {
|
931
|
+
putScenes(this.appContext.room, scenePath, [scene || {}]);
|
932
|
+
}
|
933
|
+
};
|
934
|
+
this.removePage = async (index2) => {
|
935
|
+
const needRemoveIndex = index2 === void 0 ? this.pageState.index : index2;
|
936
|
+
if (this.pageState.length === 1) {
|
937
|
+
console.warn(`[WindowManager]: can not remove the last page`);
|
938
|
+
return false;
|
939
|
+
}
|
940
|
+
if (needRemoveIndex < 0 || needRemoveIndex >= this.pageState.length) {
|
941
|
+
console.warn(`[WindowManager]: page index ${index2} out of range`);
|
942
|
+
return false;
|
943
|
+
}
|
944
|
+
return this.appProxy.removeSceneByIndex(needRemoveIndex);
|
945
|
+
};
|
946
|
+
const pageState$ = new Val(appProxy.pageState);
|
947
|
+
this.pageState$ = pageState$;
|
948
|
+
appProxy.appEmitter.on("pageStateChange", (pageState) => {
|
949
|
+
pageState$.setValue(pageState);
|
950
|
+
});
|
951
|
+
}
|
952
|
+
get view() {
|
953
|
+
return this.appContext.view;
|
954
|
+
}
|
955
|
+
get pageState() {
|
956
|
+
return this.pageState$.value;
|
957
|
+
}
|
958
|
+
moveCamera(camera) {
|
959
|
+
this.appProxy.moveCamera(camera);
|
960
|
+
}
|
961
|
+
destroy() {
|
962
|
+
this.removeViewWrapper();
|
963
|
+
}
|
964
|
+
}
|
965
|
+
const setupWrapper = (root) => {
|
966
|
+
const playground = document.createElement("div");
|
967
|
+
playground.className = "netless-window-manager-playground";
|
968
|
+
const mainViewElement = document.createElement("div");
|
969
|
+
mainViewElement.className = "netless-window-manager-main-view";
|
970
|
+
playground.appendChild(mainViewElement);
|
971
|
+
root.appendChild(playground);
|
972
|
+
return { playground, mainViewElement };
|
973
|
+
};
|
974
|
+
const checkVersion = () => {
|
975
|
+
const version = getVersionNumber(WhiteVersion);
|
976
|
+
if (version < getVersionNumber(REQUIRE_VERSION)) {
|
977
|
+
throw new WhiteWebSDKInvalidError(REQUIRE_VERSION);
|
978
|
+
}
|
979
|
+
};
|
980
|
+
const findMemberByUid = (room, uid) => {
|
981
|
+
const roomMembers = room == null ? void 0 : room.state.roomMembers;
|
982
|
+
return roomMembers == null ? void 0 : roomMembers.find((member) => {
|
983
|
+
var _a;
|
984
|
+
return ((_a = member.payload) == null ? void 0 : _a.uid) === uid;
|
985
|
+
});
|
986
|
+
};
|
987
|
+
const serializeRoomMembers = (members) => {
|
988
|
+
return members.map((member) => {
|
989
|
+
var _a;
|
990
|
+
return __spreadValues({
|
991
|
+
uid: ((_a = member.payload) == null ? void 0 : _a.uid) || ""
|
992
|
+
}, member);
|
993
|
+
});
|
994
|
+
};
|
893
995
|
class AppContext {
|
894
996
|
constructor(manager, boxManager, appId, appProxy, appOptions) {
|
895
997
|
this.manager = manager;
|
@@ -910,9 +1012,6 @@ class AppContext {
|
|
910
1012
|
};
|
911
1013
|
this.store = this.manager.store;
|
912
1014
|
this.isReplay = this.manager.isReplay;
|
913
|
-
this.getDisplayer = () => {
|
914
|
-
return this.manager.displayer;
|
915
|
-
};
|
916
1015
|
this.getAttributes = () => {
|
917
1016
|
return this.appProxy.attributes;
|
918
1017
|
};
|
@@ -924,36 +1023,49 @@ class AppContext {
|
|
924
1023
|
return appAttr == null ? void 0 : appAttr.options["scenes"];
|
925
1024
|
}
|
926
1025
|
};
|
927
|
-
this.
|
928
|
-
|
1026
|
+
this.createWhiteBoardView = (size2) => {
|
1027
|
+
var _a;
|
1028
|
+
if (this.whiteBoardView) {
|
1029
|
+
return this.whiteBoardView;
|
1030
|
+
}
|
1031
|
+
let view = this.view;
|
1032
|
+
if (!view) {
|
1033
|
+
view = this.appProxy.createAppDir();
|
1034
|
+
}
|
1035
|
+
const viewWrapper = document.createElement("div");
|
1036
|
+
viewWrapper.className = "window-manager-view-wrapper";
|
1037
|
+
(_a = this.box.$content.parentElement) == null ? void 0 : _a.appendChild(viewWrapper);
|
1038
|
+
const removeViewWrapper = () => {
|
1039
|
+
var _a2;
|
1040
|
+
(_a2 = this.box.$content.parentElement) == null ? void 0 : _a2.removeChild(viewWrapper);
|
1041
|
+
};
|
1042
|
+
view.divElement = viewWrapper;
|
1043
|
+
if (this.isAddApp) {
|
1044
|
+
this.initPageSize(size2);
|
1045
|
+
}
|
1046
|
+
this.whiteBoardView = new WhiteBoardView(this, this.appProxy, removeViewWrapper);
|
1047
|
+
return this.whiteBoardView;
|
929
1048
|
};
|
930
|
-
this.
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
1049
|
+
this.initPageSize = (size2) => {
|
1050
|
+
if (!isNumber(size2))
|
1051
|
+
return;
|
1052
|
+
if (!this.appProxy.scenePath)
|
1053
|
+
return;
|
1054
|
+
if (this.appProxy.pageState.length >= size2)
|
1055
|
+
return;
|
1056
|
+
if (size2 <= 0 || size2 >= MAX_PAGE_SIZE) {
|
1057
|
+
throw Error(`[WindowManager]: size ${size2} muse be in range [1, ${MAX_PAGE_SIZE}]`);
|
938
1058
|
}
|
1059
|
+
const needInsert = size2 - this.appProxy.pageState.length;
|
1060
|
+
const startPageNumber = this.appProxy.pageState.length;
|
1061
|
+
const scenes = new Array(needInsert).fill({}).map((_2, index2) => {
|
1062
|
+
return { name: `${startPageNumber + index2 + 1}` };
|
1063
|
+
});
|
1064
|
+
putScenes(this.room, this.appProxy.scenePath, scenes);
|
939
1065
|
};
|
940
1066
|
this.getInitScenePath = () => {
|
941
1067
|
return this.manager.getAppInitPath(this.appId);
|
942
1068
|
};
|
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
1069
|
this.setAttributes = (attributes) => {
|
958
1070
|
this.manager.safeSetAttributes({ [this.appId]: attributes });
|
959
1071
|
};
|
@@ -967,7 +1079,7 @@ class AppContext {
|
|
967
1079
|
if (!this.appProxy.box)
|
968
1080
|
return;
|
969
1081
|
this.appProxy.setFullPath(scenePath);
|
970
|
-
(_a = this.
|
1082
|
+
(_a = this.room) == null ? void 0 : _a.setScenePath(scenePath);
|
971
1083
|
};
|
972
1084
|
this.getAppOptions = () => {
|
973
1085
|
return typeof this.appOptions === "function" ? this.appOptions() : this.appOptions;
|
@@ -990,92 +1102,93 @@ class AppContext {
|
|
990
1102
|
return () => this.manager.displayer.removeMagixEventListener(appScopeEvent, handler);
|
991
1103
|
};
|
992
1104
|
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
1105
|
this.emitter = appProxy.appEmitter;
|
1037
1106
|
this.isAddApp = appProxy.isAddApp;
|
1038
1107
|
}
|
1108
|
+
get displayer() {
|
1109
|
+
return this.manager.displayer;
|
1110
|
+
}
|
1111
|
+
get view() {
|
1112
|
+
return this.appProxy.view;
|
1113
|
+
}
|
1114
|
+
get isWritable() {
|
1115
|
+
return this.manager.canOperate;
|
1116
|
+
}
|
1117
|
+
get box() {
|
1118
|
+
const box = this.boxManager.getBox(this.appId);
|
1119
|
+
if (box) {
|
1120
|
+
return box;
|
1121
|
+
} else {
|
1122
|
+
throw new BoxNotCreatedError();
|
1123
|
+
}
|
1124
|
+
}
|
1125
|
+
get room() {
|
1126
|
+
return this.manager.room;
|
1127
|
+
}
|
1128
|
+
get members() {
|
1129
|
+
return this.manager.members;
|
1130
|
+
}
|
1131
|
+
get memberState() {
|
1132
|
+
const self2 = findMemberByUid(this.room, this.manager.uid);
|
1133
|
+
if (!self2) {
|
1134
|
+
throw new Error(`Member ${this.manager.uid} not found.`);
|
1135
|
+
}
|
1136
|
+
return __spreadValues({
|
1137
|
+
uid: this.manager.uid
|
1138
|
+
}, self2);
|
1139
|
+
}
|
1039
1140
|
get storage() {
|
1040
1141
|
if (!this._storage) {
|
1041
1142
|
this._storage = new Storage(this);
|
1042
1143
|
}
|
1043
1144
|
return this._storage;
|
1044
1145
|
}
|
1045
|
-
get pageState() {
|
1046
|
-
return this.appProxy.pageState;
|
1047
|
-
}
|
1048
1146
|
}
|
1049
1147
|
class AppPageStateImpl {
|
1050
1148
|
constructor(params) {
|
1051
1149
|
this.params = params;
|
1052
1150
|
this.sceneNode = null;
|
1053
|
-
this.
|
1054
|
-
this.
|
1151
|
+
this.createSceneNode = (scenePath2) => {
|
1152
|
+
this.scenePath = scenePath2;
|
1153
|
+
if (this.sceneNode) {
|
1154
|
+
this.sceneNode.dispose();
|
1155
|
+
}
|
1156
|
+
this.sceneNode = this.params.displayer.createScenesCallback(scenePath2, {
|
1157
|
+
onAddScene: this.onSceneChange,
|
1158
|
+
onRemoveScene: this.onSceneChange
|
1159
|
+
});
|
1160
|
+
return this.sceneNode;
|
1161
|
+
};
|
1162
|
+
this.onSceneChange = () => {
|
1055
1163
|
this.params.notifyPageStateChange();
|
1056
1164
|
};
|
1057
1165
|
const { displayer, scenePath } = this.params;
|
1166
|
+
this.view = this.params.view;
|
1058
1167
|
if (scenePath) {
|
1168
|
+
this.scenePath = scenePath;
|
1059
1169
|
this.sceneNode = displayer.createScenesCallback(scenePath, {
|
1060
1170
|
onAddScene: this.onSceneChange,
|
1061
1171
|
onRemoveScene: this.onSceneChange
|
1062
1172
|
});
|
1063
1173
|
}
|
1064
1174
|
}
|
1175
|
+
setView(view) {
|
1176
|
+
this.view = view;
|
1177
|
+
}
|
1065
1178
|
getFullPath(index2) {
|
1066
1179
|
var _a;
|
1067
1180
|
const scenes = (_a = this.sceneNode) == null ? void 0 : _a.scenes;
|
1068
|
-
if (this.
|
1181
|
+
if (this.scenePath && scenes) {
|
1069
1182
|
const name = scenes[index2];
|
1070
1183
|
if (name) {
|
1071
|
-
return `${this.
|
1184
|
+
return `${this.scenePath}/${name}`;
|
1072
1185
|
}
|
1073
1186
|
}
|
1074
1187
|
}
|
1075
1188
|
toObject() {
|
1076
1189
|
var _a, _b;
|
1077
1190
|
return {
|
1078
|
-
index: ((_a = this.
|
1191
|
+
index: ((_a = this.view) == null ? void 0 : _a.focusSceneIndex) || 0,
|
1079
1192
|
length: ((_b = this.sceneNode) == null ? void 0 : _b.scenes.length) || 0
|
1080
1193
|
};
|
1081
1194
|
}
|
@@ -1084,6 +1197,135 @@ class AppPageStateImpl {
|
|
1084
1197
|
(_a = this.sceneNode) == null ? void 0 : _a.dispose();
|
1085
1198
|
}
|
1086
1199
|
}
|
1200
|
+
class CameraSynchronizer {
|
1201
|
+
constructor(saveCamera) {
|
1202
|
+
this.saveCamera = saveCamera;
|
1203
|
+
this.onRemoteUpdate = throttle((camera, size2) => {
|
1204
|
+
this.remoteCamera = camera;
|
1205
|
+
this.remoteSize = size2;
|
1206
|
+
if (this.remoteSize && this.rect) {
|
1207
|
+
let scale2;
|
1208
|
+
if (size2.width < size2.height) {
|
1209
|
+
scale2 = this.rect.width / size2.width;
|
1210
|
+
} else {
|
1211
|
+
scale2 = this.rect.height / size2.height;
|
1212
|
+
}
|
1213
|
+
const nextScale = camera.scale * scale2;
|
1214
|
+
const moveCamera = () => {
|
1215
|
+
var _a;
|
1216
|
+
return (_a = this.view) == null ? void 0 : _a.moveCamera({
|
1217
|
+
centerX: camera.centerX,
|
1218
|
+
centerY: camera.centerY,
|
1219
|
+
scale: nextScale,
|
1220
|
+
animationMode: AnimationMode.Immediately
|
1221
|
+
});
|
1222
|
+
};
|
1223
|
+
delay(moveCamera, 50);
|
1224
|
+
}
|
1225
|
+
}, 50);
|
1226
|
+
this.onLocalSizeUpdate = (size2) => {
|
1227
|
+
if (this.rect && this.view) {
|
1228
|
+
let scale2;
|
1229
|
+
if (size2.width < size2.height) {
|
1230
|
+
scale2 = this.rect.width / size2.width;
|
1231
|
+
} else {
|
1232
|
+
scale2 = this.rect.height / size2.height;
|
1233
|
+
}
|
1234
|
+
const nextScale = this.view.camera.scale / scale2;
|
1235
|
+
console.log("onLocalSizeUpdate", nextScale.toFixed(3), scale2.toFixed(3));
|
1236
|
+
this.view.moveCamera({
|
1237
|
+
scale: nextScale,
|
1238
|
+
animationMode: AnimationMode.Immediately
|
1239
|
+
});
|
1240
|
+
}
|
1241
|
+
};
|
1242
|
+
}
|
1243
|
+
setRect(rect) {
|
1244
|
+
this.rect = rect;
|
1245
|
+
if (this.remoteCamera && this.remoteSize) {
|
1246
|
+
this.onRemoteUpdate(this.remoteCamera, this.remoteSize);
|
1247
|
+
}
|
1248
|
+
}
|
1249
|
+
setView(view) {
|
1250
|
+
this.view = view;
|
1251
|
+
}
|
1252
|
+
onLocalCameraUpdate(camera) {
|
1253
|
+
this.saveCamera(camera);
|
1254
|
+
this.remoteCamera = camera;
|
1255
|
+
}
|
1256
|
+
}
|
1257
|
+
class AppViewSync {
|
1258
|
+
constructor(appProxy) {
|
1259
|
+
this.appProxy = appProxy;
|
1260
|
+
this.sem = new SideEffectManager();
|
1261
|
+
this.bindView = (view) => {
|
1262
|
+
if (!view)
|
1263
|
+
return;
|
1264
|
+
this.synchronizer.setView(view);
|
1265
|
+
this.sem.add(() => {
|
1266
|
+
view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1267
|
+
return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1268
|
+
});
|
1269
|
+
};
|
1270
|
+
this.onCameraUpdatedByDevice = (camera) => {
|
1271
|
+
var _a;
|
1272
|
+
this.synchronizer.onLocalCameraUpdate(camera);
|
1273
|
+
const stage = (_a = this.appProxy.box) == null ? void 0 : _a.contentStageRect;
|
1274
|
+
if (stage) {
|
1275
|
+
const size2 = { width: stage.width, height: stage.height, id: this.appProxy.uid };
|
1276
|
+
if (!isEqual(size2, this.appProxy.size$.value)) {
|
1277
|
+
this.appProxy.storeSize(size2);
|
1278
|
+
}
|
1279
|
+
}
|
1280
|
+
};
|
1281
|
+
this.synchronizer = new CameraSynchronizer((camera) => {
|
1282
|
+
this.appProxy.storeCamera(__spreadValues({
|
1283
|
+
id: this.appProxy.uid
|
1284
|
+
}, camera));
|
1285
|
+
});
|
1286
|
+
this.bindView(appProxy.view);
|
1287
|
+
this.sem.add(() => this.appProxy.camera$.subscribe((camera) => {
|
1288
|
+
const size2 = this.appProxy.size$.value;
|
1289
|
+
if (camera && size2) {
|
1290
|
+
this.synchronizer.onRemoteUpdate(camera, size2);
|
1291
|
+
}
|
1292
|
+
}));
|
1293
|
+
const box = this.appProxy.box;
|
1294
|
+
if (box && box.contentStageRect) {
|
1295
|
+
this.synchronizer.setRect(box.contentStageRect);
|
1296
|
+
this.sem.add(() => box._contentStageRect$.subscribe((rect) => {
|
1297
|
+
if (rect) {
|
1298
|
+
this.synchronizer.setRect(rect);
|
1299
|
+
}
|
1300
|
+
}));
|
1301
|
+
if (!this.appProxy.size$.value) {
|
1302
|
+
this.appProxy.storeSize({
|
1303
|
+
id: this.appProxy.uid,
|
1304
|
+
width: box.contentStageRect.width,
|
1305
|
+
height: box.contentStageRect.height
|
1306
|
+
});
|
1307
|
+
}
|
1308
|
+
}
|
1309
|
+
}
|
1310
|
+
destroy() {
|
1311
|
+
this.sem.flushAll();
|
1312
|
+
}
|
1313
|
+
}
|
1314
|
+
const boxEmitter = new Emittery();
|
1315
|
+
const calculateNextIndex = (index2, pageState) => {
|
1316
|
+
let nextIndex = 0;
|
1317
|
+
const maxIndex = pageState.length - 1;
|
1318
|
+
if (index2 === pageState.index) {
|
1319
|
+
if (index2 === maxIndex) {
|
1320
|
+
nextIndex = index2 - 1;
|
1321
|
+
} else {
|
1322
|
+
nextIndex = pageState.index + 1;
|
1323
|
+
}
|
1324
|
+
} else {
|
1325
|
+
nextIndex = pageState.index;
|
1326
|
+
}
|
1327
|
+
return nextIndex;
|
1328
|
+
};
|
1087
1329
|
var Fields = /* @__PURE__ */ ((Fields2) => {
|
1088
1330
|
Fields2["Apps"] = "apps";
|
1089
1331
|
Fields2["Focus"] = "focus";
|
@@ -1097,6 +1339,8 @@ var Fields = /* @__PURE__ */ ((Fields2) => {
|
|
1097
1339
|
Fields2["CursorState"] = "cursorState";
|
1098
1340
|
Fields2["FullPath"] = "fullPath";
|
1099
1341
|
Fields2["Registered"] = "registered";
|
1342
|
+
Fields2["Camera"] = "camera";
|
1343
|
+
Fields2["Size"] = "size";
|
1100
1344
|
return Fields2;
|
1101
1345
|
})(Fields || {});
|
1102
1346
|
class AttributesDelegate {
|
@@ -1161,6 +1405,9 @@ class AttributesDelegate {
|
|
1161
1405
|
this.context.safeUpdateAttributes(["apps", appId, "state", stateName], state);
|
1162
1406
|
}
|
1163
1407
|
}
|
1408
|
+
updateAppAttributes(appId, key, value) {
|
1409
|
+
this.context.safeUpdateAttributes(["apps", appId, key], value);
|
1410
|
+
}
|
1164
1411
|
cleanAppAttributes(id2) {
|
1165
1412
|
this.context.safeUpdateAttributes(["apps", id2], void 0);
|
1166
1413
|
this.context.safeSetAttributes({ [id2]: void 0 });
|
@@ -1257,21 +1504,6 @@ const log = (...args) => {
|
|
1257
1504
|
console.log(`[WindowManager]:`, ...args);
|
1258
1505
|
}
|
1259
1506
|
};
|
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
1507
|
class AppProxy {
|
1276
1508
|
constructor(params, manager, appId, isAddApp) {
|
1277
1509
|
var _a;
|
@@ -1281,7 +1513,13 @@ class AppProxy {
|
|
1281
1513
|
this.appProxies = this.manager.appProxies;
|
1282
1514
|
this.viewManager = this.manager.viewManager;
|
1283
1515
|
this.store = this.manager.store;
|
1516
|
+
this.uid = this.manager.uid;
|
1284
1517
|
this.status = "normal";
|
1518
|
+
this.sideEffectManager = new SideEffectManager();
|
1519
|
+
this.camera$ = new Val(void 0);
|
1520
|
+
this.size$ = new Val(void 0);
|
1521
|
+
this.box$ = new Val(void 0);
|
1522
|
+
this.view$ = new Val(void 0);
|
1285
1523
|
this.getAppInitState = (id2) => {
|
1286
1524
|
var _a2, _b;
|
1287
1525
|
const attrs = this.store.getAppState(id2);
|
@@ -1347,10 +1585,26 @@ class AppProxy {
|
|
1347
1585
|
}
|
1348
1586
|
}, 50);
|
1349
1587
|
this.notifyPageStateChange = debounce(() => {
|
1350
|
-
|
1588
|
+
if (this.pageState) {
|
1589
|
+
this.appEmitter.emit("pageStateChange", this.pageState);
|
1590
|
+
}
|
1351
1591
|
}, 50);
|
1592
|
+
this.storeCamera = (camera) => {
|
1593
|
+
this.store.updateAppAttributes(this.id, Fields.Camera, camera);
|
1594
|
+
};
|
1595
|
+
this.storeSize = (size2) => {
|
1596
|
+
this.store.updateAppAttributes(this.id, Fields.Size, size2);
|
1597
|
+
};
|
1598
|
+
this.moveCamera = (camera) => {
|
1599
|
+
if (!this.camera$.value) {
|
1600
|
+
return;
|
1601
|
+
}
|
1602
|
+
const nextCamera = __spreadValues(__spreadValues({}, this.camera$.value), camera);
|
1603
|
+
this.storeCamera(nextCamera);
|
1604
|
+
};
|
1352
1605
|
this.kind = params.kind;
|
1353
1606
|
this.id = appId;
|
1607
|
+
this.appScenePath = `/${this.id}-app-dir`;
|
1354
1608
|
this.stateKey = `${this.id}_state`;
|
1355
1609
|
this.appProxies.set(this.id, this);
|
1356
1610
|
this.appEmitter = new Emittery();
|
@@ -1360,12 +1614,65 @@ class AppProxy {
|
|
1360
1614
|
if ((_a = this.params.options) == null ? void 0 : _a.scenePath) {
|
1361
1615
|
this.createView();
|
1362
1616
|
}
|
1617
|
+
if (!this.scenePath) {
|
1618
|
+
this.scenePath = this.appScenePath;
|
1619
|
+
}
|
1363
1620
|
this._pageState = new AppPageStateImpl({
|
1364
1621
|
displayer: this.manager.displayer,
|
1365
1622
|
scenePath: this.scenePath,
|
1366
1623
|
view: this.view,
|
1367
1624
|
notifyPageStateChange: this.notifyPageStateChange
|
1368
1625
|
});
|
1626
|
+
this.sideEffectManager.add(() => () => this._pageState.destroy());
|
1627
|
+
this.sideEffectManager.add(() => emitter.on("roomMembersChange", (members) => {
|
1628
|
+
this.appEmitter.emit("roomMembersChange", members);
|
1629
|
+
}));
|
1630
|
+
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1631
|
+
this.size$.setValue(toJS(this.appAttributes.size));
|
1632
|
+
this.sideEffectManager.add(() => {
|
1633
|
+
return this.manager.refresher.add(`${this.id}-camera`, () => {
|
1634
|
+
return reaction(() => {
|
1635
|
+
var _a2;
|
1636
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
|
1637
|
+
}, (camera) => {
|
1638
|
+
if (camera && camera.id !== this.uid) {
|
1639
|
+
this.camera$.setValue(toJS(camera));
|
1640
|
+
}
|
1641
|
+
});
|
1642
|
+
});
|
1643
|
+
});
|
1644
|
+
this.sideEffectManager.add(() => {
|
1645
|
+
return this.manager.refresher.add(`${this.id}-size`, () => {
|
1646
|
+
return reaction(() => {
|
1647
|
+
var _a2;
|
1648
|
+
return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
|
1649
|
+
}, (size2) => {
|
1650
|
+
if (size2 && size2.id !== this.uid) {
|
1651
|
+
this.size$.setValue(toJS(size2));
|
1652
|
+
}
|
1653
|
+
});
|
1654
|
+
});
|
1655
|
+
});
|
1656
|
+
combine([this.box$, this.view$]).subscribe(([box, view]) => {
|
1657
|
+
if (box && view) {
|
1658
|
+
const appViewSync = new AppViewSync(this);
|
1659
|
+
this.appViewSync = appViewSync;
|
1660
|
+
this.sideEffectManager.add(() => () => appViewSync.destroy());
|
1661
|
+
}
|
1662
|
+
});
|
1663
|
+
}
|
1664
|
+
createAppDir() {
|
1665
|
+
const scenePath = this.scenePath || this.appScenePath;
|
1666
|
+
const sceneNode = this._pageState.createSceneNode(scenePath);
|
1667
|
+
if (!sceneNode) {
|
1668
|
+
putScenes(this.manager.room, scenePath, [{ name: "1" }]);
|
1669
|
+
this._pageState.createSceneNode(scenePath);
|
1670
|
+
this.setSceneIndex(0);
|
1671
|
+
}
|
1672
|
+
this.scenes = entireScenes(this.manager.displayer)[scenePath];
|
1673
|
+
const view = this.createView();
|
1674
|
+
this._pageState.setView(view);
|
1675
|
+
return view;
|
1369
1676
|
}
|
1370
1677
|
initScenes() {
|
1371
1678
|
var _a;
|
@@ -1410,7 +1717,7 @@ class AppProxy {
|
|
1410
1717
|
return fullPath;
|
1411
1718
|
}
|
1412
1719
|
setFullPath(path) {
|
1413
|
-
this.
|
1720
|
+
this.store.updateAppAttributes(this.id, Fields.FullPath, path);
|
1414
1721
|
}
|
1415
1722
|
async baseInsertApp(skipUpdate = false) {
|
1416
1723
|
var _a;
|
@@ -1432,8 +1739,7 @@ class AppProxy {
|
|
1432
1739
|
};
|
1433
1740
|
}
|
1434
1741
|
get box() {
|
1435
|
-
|
1436
|
-
return (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
|
1742
|
+
return this.box$.value;
|
1437
1743
|
}
|
1438
1744
|
async setupApp(appId, skipUpdate, app, options, appOptions) {
|
1439
1745
|
var _a;
|
@@ -1461,13 +1767,14 @@ class AppProxy {
|
|
1461
1767
|
this.fixMobileSize();
|
1462
1768
|
}, SETUP_APP_DELAY);
|
1463
1769
|
});
|
1464
|
-
(_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1770
|
+
const box = (_a = this.boxManager) == null ? void 0 : _a.createBox({
|
1465
1771
|
appId,
|
1466
1772
|
app,
|
1467
1773
|
options,
|
1468
1774
|
canOperate: this.manager.canOperate,
|
1469
1775
|
smartPosition: this.isAddApp
|
1470
1776
|
});
|
1777
|
+
this.box$.setValue(box);
|
1471
1778
|
if (this.isAddApp && this.box) {
|
1472
1779
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
1473
1780
|
this.boxManager.focusBox({ appId }, false);
|
@@ -1594,8 +1901,9 @@ class AppProxy {
|
|
1594
1901
|
}
|
1595
1902
|
return fullPath;
|
1596
1903
|
}
|
1597
|
-
|
1598
|
-
const view =
|
1904
|
+
createView() {
|
1905
|
+
const view = this.viewManager.createView(this.id);
|
1906
|
+
this.view$.setValue(view);
|
1599
1907
|
this.setViewFocusScenePath();
|
1600
1908
|
return view;
|
1601
1909
|
}
|
@@ -1604,7 +1912,7 @@ class AppProxy {
|
|
1604
1912
|
}
|
1605
1913
|
async removeSceneByIndex(index2) {
|
1606
1914
|
const scenePath = this._pageState.getFullPath(index2);
|
1607
|
-
if (scenePath) {
|
1915
|
+
if (scenePath && this.pageState) {
|
1608
1916
|
const nextIndex = calculateNextIndex(index2, this.pageState);
|
1609
1917
|
this.setSceneIndexWithoutSync(nextIndex);
|
1610
1918
|
this.manager.dispatchInternalEvent(Events.SetAppFocusIndex, {
|
@@ -1646,6 +1954,7 @@ class AppProxy {
|
|
1646
1954
|
console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
|
1647
1955
|
}
|
1648
1956
|
this.appEmitter.clearListeners();
|
1957
|
+
this.sideEffectManager.flushAll();
|
1649
1958
|
emitter.emit(`destroy-${this.id}`, { error });
|
1650
1959
|
if (needCloseBox) {
|
1651
1960
|
(_a = this.boxManager) == null ? void 0 : _a.closeBox(this.id, skipUpdate);
|
@@ -1657,13 +1966,15 @@ class AppProxy {
|
|
1657
1966
|
}
|
1658
1967
|
}
|
1659
1968
|
this.appProxies.delete(this.id);
|
1660
|
-
this._pageState.destroy();
|
1661
1969
|
this.viewManager.destroyView(this.id);
|
1662
1970
|
this.manager.appStatus.delete(this.id);
|
1663
1971
|
(_b = this.manager.refresher) == null ? void 0 : _b.remove(this.id);
|
1664
1972
|
(_c = this.manager.refresher) == null ? void 0 : _c.remove(this.stateKey);
|
1665
1973
|
(_d = this.manager.refresher) == null ? void 0 : _d.remove(`${this.id}-fullPath`);
|
1666
1974
|
this._prevFullPath = void 0;
|
1975
|
+
this.camera$.destroy();
|
1976
|
+
this.size$.destroy();
|
1977
|
+
this.box$.destroy();
|
1667
1978
|
}
|
1668
1979
|
close() {
|
1669
1980
|
return this.destroy(true, true, false);
|
@@ -1719,56 +2030,6 @@ const setDefaultCameraBound = (view) => {
|
|
1719
2030
|
minContentMode: () => 0.1
|
1720
2031
|
});
|
1721
2032
|
};
|
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
2033
|
class MainViewProxy {
|
1773
2034
|
constructor(manager) {
|
1774
2035
|
var _a;
|
@@ -1798,9 +2059,6 @@ class MainViewProxy {
|
|
1798
2059
|
}, { fireImmediately: true });
|
1799
2060
|
};
|
1800
2061
|
this.sizeChangeHandler = debounce((size2) => {
|
1801
|
-
if (size2) {
|
1802
|
-
this.synchronizer.onLocalSizeUpdate(size2);
|
1803
|
-
}
|
1804
2062
|
}, 30);
|
1805
2063
|
this.onUpdateContainerSizeRatio = () => {
|
1806
2064
|
const size2 = this.store.getMainViewSize();
|
@@ -1839,9 +2097,7 @@ class MainViewProxy {
|
|
1839
2097
|
});
|
1840
2098
|
this.sideEffectManager.add(() => {
|
1841
2099
|
return emitter.on("startReconnect", () => {
|
1842
|
-
|
1843
|
-
this.mainView.release();
|
1844
|
-
}
|
2100
|
+
releaseView(this.mainView);
|
1845
2101
|
});
|
1846
2102
|
});
|
1847
2103
|
const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
@@ -1851,7 +2107,6 @@ class MainViewProxy {
|
|
1851
2107
|
this.sideEffectManager.add(() => {
|
1852
2108
|
return emitter.on("playgroundSizeChange", (rect2) => {
|
1853
2109
|
this.synchronizer.setRect(rect2);
|
1854
|
-
this.synchronizer.onLocalSizeUpdate(rect2);
|
1855
2110
|
});
|
1856
2111
|
});
|
1857
2112
|
}
|
@@ -1921,9 +2176,7 @@ class MainViewProxy {
|
|
1921
2176
|
const divElement = this.mainView.divElement;
|
1922
2177
|
const disableCameraTransform = this.mainView.disableCameraTransform;
|
1923
2178
|
this.stop();
|
1924
|
-
|
1925
|
-
this.mainView.release();
|
1926
|
-
}
|
2179
|
+
releaseView(this.mainView);
|
1927
2180
|
this.removeMainViewListener();
|
1928
2181
|
this.mainView = this.createMainView();
|
1929
2182
|
this.mainView.disableCameraTransform = disableCameraTransform;
|
@@ -2299,6 +2552,9 @@ class AppManager {
|
|
2299
2552
|
this.appProxies.forEach((appProxy) => {
|
2300
2553
|
appProxy.appEmitter.emit("roomStateChange", state);
|
2301
2554
|
});
|
2555
|
+
if (state.roomMembers) {
|
2556
|
+
emitter.emit("roomMembersChange", this.members);
|
2557
|
+
}
|
2302
2558
|
emitter.emit("observerIdChange", this.displayer.observerId);
|
2303
2559
|
};
|
2304
2560
|
this.displayerWritableListener = (isReadonly) => {
|
@@ -2412,6 +2668,9 @@ class AppManager {
|
|
2412
2668
|
var _a;
|
2413
2669
|
return ((_a = this.room) == null ? void 0 : _a.uid) || "";
|
2414
2670
|
}
|
2671
|
+
get members() {
|
2672
|
+
return serializeRoomMembers(this.displayer.state.roomMembers);
|
2673
|
+
}
|
2415
2674
|
getMainViewSceneDir() {
|
2416
2675
|
const scenePath = this.store.getMainViewScenePath();
|
2417
2676
|
if (scenePath) {
|
@@ -2723,28 +2982,6 @@ class AppManager {
|
|
2723
2982
|
this._prevSceneIndex = void 0;
|
2724
2983
|
}
|
2725
2984
|
}
|
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
2985
|
/*! *****************************************************************************
|
2749
2986
|
Copyright (c) Microsoft Corporation.
|
2750
2987
|
|
@@ -3587,289 +3824,16 @@ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
|
|
3587
3824
|
}
|
3588
3825
|
return true;
|
3589
3826
|
};
|
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) => {
|
3827
|
+
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
3828
|
for (var i2 in t2 || (t2 = {}))
|
3865
|
-
a$1.call(t2, i2) &&
|
3829
|
+
a$1.call(t2, i2) && o$2(e2, i2, t2[i2]);
|
3866
3830
|
if (s$2)
|
3867
3831
|
for (var i2 of s$2(t2))
|
3868
|
-
|
3832
|
+
n$3.call(t2, i2) && o$2(e2, i2, t2[i2]);
|
3869
3833
|
return e2;
|
3870
3834
|
};
|
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", (
|
3835
|
+
var v$3, w$2, C$3, y$2, E$3, z$2, _, B$2, N$3, S$3;
|
3836
|
+
(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
3837
|
function I$3(e2, t2, i2) {
|
3874
3838
|
return Math.min(Math.max(e2, t2), i2);
|
3875
3839
|
}
|
@@ -3890,7 +3854,7 @@ function V$3(e2) {
|
|
3890
3854
|
return !e2;
|
3891
3855
|
}
|
3892
3856
|
class H$3 {
|
3893
|
-
constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart:
|
3857
|
+
constructor({ readonly$: e2, state$: t2, title$: i2, buttons: s2, onEvent: a2, onDragStart: n2, namespace: o2 = "telebox" }) {
|
3894
3858
|
this.sideEffect = new SideEffectManager(), this.lastTitleBarClick = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarClick = (e3) => {
|
3895
3859
|
var t3;
|
3896
3860
|
if (this.readonly$.value)
|
@@ -3901,7 +3865,7 @@ class H$3 {
|
|
3901
3865
|
return;
|
3902
3866
|
k$1(e3);
|
3903
3867
|
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:
|
3868
|
+
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
3869
|
}, this.lastTitleBarTouch = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarTouch = (e3) => {
|
3906
3870
|
var t3;
|
3907
3871
|
if (this.readonly$.value)
|
@@ -3910,8 +3874,8 @@ class H$3 {
|
|
3910
3874
|
return;
|
3911
3875
|
k$1(e3);
|
3912
3876
|
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 =
|
3877
|
+
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;
|
3878
|
+
}, 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
3879
|
}
|
3916
3880
|
render() {
|
3917
3881
|
if (!this.$titleBar) {
|
@@ -3987,13 +3951,13 @@ class A$2 {
|
|
3987
3951
|
i2.className = this.wrapClassName("box-stage-mask");
|
3988
3952
|
const s2 = document.createElement("div");
|
3989
3953
|
s2.className = this.wrapClassName("box-stage-frame");
|
3990
|
-
const [a2, o2, r2
|
3954
|
+
const [a2, n2, o2, r2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
|
3991
3955
|
const i3 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
3992
3956
|
i3.setAttribute("viewBox", "0 0 8 8"), i3.setAttribute("class", `${this.wrapClassName("box-stage-frame-corner")} is-${t3}`);
|
3993
3957
|
const s3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
3994
3958
|
return s3.setAttribute("d", e3), s3.setAttribute("fill", "#3381FF"), i3.appendChild(s3), i3;
|
3995
3959
|
});
|
3996
|
-
return s2.appendChild(a2), s2.appendChild(
|
3960
|
+
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
3961
|
e2.classList.toggle("is-active", t3);
|
3998
3962
|
})), this._sideEffect.addDisposer(combine([this.highlightStage$, this.stageRect$]).subscribe(([s3, a3]) => {
|
3999
3963
|
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 +3972,40 @@ class A$2 {
|
|
4008
3972
|
}
|
4009
3973
|
const W$3 = window.ResizeObserver || ResizeObserver$2;
|
4010
3974
|
class Y$3 {
|
4011
|
-
constructor({ id: e2 = genUID(), title: t2 = L$3(), namespace: i2 = "telebox", visible: s2 = true, width: a2 = 0.5, height:
|
3975
|
+
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
3976
|
this.events = new Emittery(), this._delegateEvents = new Emittery(), this.handleTrackStart = (e3) => {
|
4013
3977
|
var t3;
|
4014
3978
|
return (t3 = this._handleTrackStart) == null ? void 0 : t3.call(this, e3);
|
4015
3979
|
}, this._sideEffect = new SideEffectManager(), this.id = e2, this.namespace = i2;
|
4016
|
-
const
|
4017
|
-
this._sideEffect.addDisposer(() =>
|
4018
|
-
const
|
4019
|
-
this._sideEffect.addDisposer(
|
4020
|
-
|
3980
|
+
const G2 = new ValManager();
|
3981
|
+
this._sideEffect.addDisposer(() => G2.destroy());
|
3982
|
+
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 });
|
3983
|
+
this._sideEffect.addDisposer(re2.reaction((e3, t3) => {
|
3984
|
+
le2.setValue({ width: Math.max(a2, e3.width), height: Math.max(n2, e3.height) }, t3);
|
4021
3985
|
}));
|
4022
|
-
const
|
4023
|
-
this._sideEffect.addDisposer(() =>
|
4024
|
-
withReadonlyValueEnhancer(this, { darkMode:
|
4025
|
-
const
|
4026
|
-
withReadonlyValueEnhancer(this,
|
4027
|
-
withValueEnhancer(this, { title:
|
3986
|
+
const de2 = new Val({ x: l2, y: $ }, { compare: shallowequal }), ce2 = combine([le2, O2], ([e3, t3]) => ({ width: t3.width * e3.width, height: t3.height * e3.height }), { compare: shallowequal }), me2 = combine([de2, O2], ([e3, t3]) => ({ x: e3.x * t3.width + t3.x, y: e3.y * t3.height + t3.y }), { compare: shallowequal }), ue2 = new Val(R2), ge2 = combine([ue2, F2], ([e3, t3]) => e3 != null ? e3 : t3), xe2 = new Val(null), pe2 = new Val(P2.value, { compare: shallowequal }), fe2 = new Val(_2), $e2 = new A$2({ namespace: i2, root$: xe2, rootRect$: pe2, ratio$: combine([fe2, j2], ([e3, t3]) => e3 != null ? e3 : t3), highlightStage$: ge2 });
|
3987
|
+
this._sideEffect.addDisposer(() => $e2.destroy());
|
3988
|
+
withReadonlyValueEnhancer(this, { darkMode: D2, fence: T2, minimized: V2, maximized: W2, readonly: Y2, rootRect: P2, managerStageRect: O2, collectorRect: Z2 });
|
3989
|
+
const be2 = { zIndex: ee2, focus: te2, $userContent: ie2, $userStage: se2, $userFooter: ae2, $userStyles: ne2, state: oe2, minSize: re2, pxMinSize: he2, intrinsicSize: le2, intrinsicCoord: de2, pxIntrinsicSize: ce2, pxIntrinsicCoord: me2, highlightStage: ge2, boxHighlightStage: ue2, contentRect: pe2, contentStageRect: $e2.stageRect$ };
|
3990
|
+
withReadonlyValueEnhancer(this, be2, G2);
|
3991
|
+
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
3992
|
var t3;
|
4029
3993
|
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
|
3994
|
+
}, onEvent: (e3) => this._delegateEvents.emit(e3.type) }), this._sideEffect.addDisposer(U2.subscribe((e3) => {
|
3995
|
+
e3 > 0 && this.transform(me2.value.x, me2.value.y, ce2.value.width, ce2.value.height, true);
|
3996
|
+
})), this._sideEffect.addDisposer(T2.subscribe((e3) => {
|
3997
|
+
e3 && this.move(me2.value.x, me2.value.y, true);
|
3998
|
+
})), this.$box = this.render(), xe2.setValue(this.$content.parentElement);
|
3999
|
+
const ve2 = (e3, t3) => {
|
4036
4000
|
this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
|
4037
4001
|
i3 || this.events.emit(t3, e4);
|
4038
4002
|
}));
|
4039
4003
|
};
|
4040
|
-
|
4004
|
+
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
4005
|
t3 || e3 || this.events.emit(E$3.Close);
|
4042
|
-
}),
|
4006
|
+
}), te2.reaction((e3, t3) => {
|
4043
4007
|
t3 || this.events.emit(e3 ? E$3.Focus : E$3.Blur);
|
4044
|
-
}),
|
4008
|
+
}), X2.subscribe((e3) => {
|
4045
4009
|
e3 ? e3.appendChild(this.$box) : this.$box.parentNode && this.$box.remove();
|
4046
4010
|
})]);
|
4047
4011
|
}
|
@@ -4074,22 +4038,22 @@ class Y$3 {
|
|
4074
4038
|
}
|
4075
4039
|
move(e2, t2, i2 = false) {
|
4076
4040
|
let s2, a2;
|
4077
|
-
const
|
4041
|
+
const n2 = this.managerStageRect, o2 = this.pxIntrinsicSize;
|
4078
4042
|
if (this.fence)
|
4079
|
-
s2 = I$3(e2,
|
4043
|
+
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
4044
|
else {
|
4081
4045
|
const i3 = this.rootRect;
|
4082
|
-
s2 = I$3(e2,
|
4046
|
+
s2 = I$3(e2, 0 - o2.width + 20, 0 + i3.width - 20), a2 = I$3(t2, 0, 0 + i3.height - 20);
|
4083
4047
|
}
|
4084
|
-
this._intrinsicCoord$.setValue({ x: (s2 -
|
4048
|
+
this._intrinsicCoord$.setValue({ x: (s2 - n2.x) / n2.width, y: (a2 - n2.y) / n2.height }, i2);
|
4085
4049
|
}
|
4086
4050
|
transform(e2, t2, i2, s2, a2 = false) {
|
4087
|
-
const
|
4051
|
+
const n2 = this.managerStageRect, o2 = this.rootRect;
|
4088
4052
|
if (i2 = Math.max(i2, this.pxMinSize.width), s2 = Math.max(s2, this.pxMinSize.height), this.ratio > 0) {
|
4089
4053
|
const e3 = this.ratio * i2;
|
4090
4054
|
t2 !== this.pxIntrinsicCoord.y && (t2 -= e3 - s2), s2 = e3;
|
4091
4055
|
}
|
4092
|
-
t2 <
|
4056
|
+
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
4057
|
}
|
4094
4058
|
mountContent(e2) {
|
4095
4059
|
this._$userContent$.setValue(e2);
|
@@ -4097,6 +4061,12 @@ class Y$3 {
|
|
4097
4061
|
unmountContent() {
|
4098
4062
|
this._$userContent$.setValue(void 0);
|
4099
4063
|
}
|
4064
|
+
mountStage(e2) {
|
4065
|
+
this._$userStage$.setValue(e2);
|
4066
|
+
}
|
4067
|
+
unmountStage() {
|
4068
|
+
this._$userStage$.setValue(void 0);
|
4069
|
+
}
|
4100
4070
|
mountFooter(e2) {
|
4101
4071
|
this._$userFooter$.setValue(e2);
|
4102
4072
|
}
|
@@ -4139,47 +4109,62 @@ class Y$3 {
|
|
4139
4109
|
this.$box.style.zIndex = String(e3);
|
4140
4110
|
})), this.$box.dataset.teleBoxID = this.id;
|
4141
4111
|
const t2 = index(this.$box), i2 = combine([this._maximized$, this._minimized$, this._pxIntrinsicSize$, this._pxIntrinsicCoord$, this._collectorRect$], ([e3, t3, i3, s3, a3]) => {
|
4142
|
-
const
|
4112
|
+
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
4113
|
if (t3 && a3) {
|
4144
4114
|
const { width: t4, height: s4 } = e3 ? this.rootRect : i3;
|
4145
|
-
|
4115
|
+
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
4116
|
}
|
4147
|
-
return
|
4117
|
+
return n3;
|
4148
4118
|
}, { compare: shallowequal }), s2 = i2.value;
|
4149
4119
|
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
4120
|
t2.set(e3);
|
4151
4121
|
}));
|
4152
4122
|
const a2 = document.createElement("div");
|
4153
4123
|
a2.className = this.wrapClassName("box-main"), this.$box.appendChild(a2);
|
4124
|
+
const n2 = document.createElement("div");
|
4125
|
+
n2.className = this.wrapClassName("titlebar-wrap"), n2.appendChild(this.titleBar.render()), this.$titleBar = n2;
|
4154
4126
|
const o2 = document.createElement("div");
|
4155
|
-
o2.className = this.wrapClassName("
|
4127
|
+
o2.className = this.wrapClassName("content-wrap");
|
4156
4128
|
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(() => {
|
4129
|
+
r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2, this._sideEffect.add(() => {
|
4160
4130
|
const e3 = new W$3(() => {
|
4161
|
-
const e4 =
|
4131
|
+
const e4 = r2.getBoundingClientRect();
|
4162
4132
|
this._contentRect$.setValue({ x: e4.x, y: e4.y, width: e4.width, height: e4.height });
|
4163
4133
|
});
|
4164
|
-
return e3.observe(
|
4134
|
+
return e3.observe(r2), () => e3.disconnect();
|
4165
4135
|
}), this._sideEffect.add(() => {
|
4166
4136
|
let e3;
|
4167
4137
|
return this._$userStyles$.subscribe((t3) => {
|
4168
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4138
|
+
e3 && e3.remove(), e3 = t3, t3 && o2.appendChild(t3);
|
4169
4139
|
});
|
4170
4140
|
}), this._sideEffect.add(() => {
|
4171
4141
|
let e3;
|
4172
4142
|
return this._$userContent$.subscribe((t3) => {
|
4173
|
-
e3 && e3.remove(), e3 = t3, t3 &&
|
4143
|
+
e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
|
4144
|
+
});
|
4145
|
+
}), this._sideEffect.add(() => {
|
4146
|
+
let e3;
|
4147
|
+
return this._$userStage$.subscribe((t3) => {
|
4148
|
+
var i3;
|
4149
|
+
if (e3 && e3.remove(), e3 = t3, t3) {
|
4150
|
+
if (!this.$stage) {
|
4151
|
+
const e4 = document.createElement("div");
|
4152
|
+
this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
|
4153
|
+
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");
|
4154
|
+
}), "content-stage-rect"), r2.appendChild(e4);
|
4155
|
+
}
|
4156
|
+
this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
|
4157
|
+
} else
|
4158
|
+
((i3 = this.$stage) == null ? void 0 : i3.parentElement) && this.$stage.remove();
|
4174
4159
|
});
|
4175
|
-
}),
|
4160
|
+
}), o2.appendChild(r2);
|
4176
4161
|
const h = document.createElement("div");
|
4177
4162
|
return h.className = this.wrapClassName("footer-wrap"), this.$footer = h, this._sideEffect.add(() => {
|
4178
4163
|
let e3;
|
4179
4164
|
return this._$userFooter$.subscribe((t3) => {
|
4180
4165
|
e3 && e3.remove(), e3 = t3, t3 && h.appendChild(t3);
|
4181
4166
|
});
|
4182
|
-
}), a2.appendChild(
|
4167
|
+
}), a2.appendChild(n2), a2.appendChild(o2), a2.appendChild(h), this._renderResizeHandlers(), this.$box;
|
4183
4168
|
}
|
4184
4169
|
_renderResizeHandlers() {
|
4185
4170
|
const e2 = document.createElement("div");
|
@@ -4188,7 +4173,7 @@ class Y$3 {
|
|
4188
4173
|
i3.className = this.wrapClassName(t3) + " " + this.wrapClassName("resize-handle"), i3.dataset.teleBoxHandle = t3, e2.appendChild(i3);
|
4189
4174
|
}), this.$box.appendChild(e2);
|
4190
4175
|
const t2 = "handle-tracking-listener", i2 = this.wrapClassName("transforming");
|
4191
|
-
let s2, a2,
|
4176
|
+
let s2, a2, n2 = 0, o2 = 0, r2 = 0, h = 0, l2 = 0, d2 = 0;
|
4192
4177
|
const c = (e3) => {
|
4193
4178
|
if (this.state !== C$3.Normal)
|
4194
4179
|
return;
|
@@ -4196,36 +4181,36 @@ class Y$3 {
|
|
4196
4181
|
let { pageX: t3, pageY: i3 } = R$3(e3);
|
4197
4182
|
i3 < this.rootRect.y && (i3 = this.rootRect.y);
|
4198
4183
|
const s3 = t3 - l2, c2 = i3 - d2;
|
4199
|
-
let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width:
|
4184
|
+
let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: x2 } = this.pxIntrinsicSize;
|
4200
4185
|
switch (a2) {
|
4201
4186
|
case N$3.North:
|
4202
|
-
u3 =
|
4187
|
+
u3 = o2 + c2, x2 = h - c2;
|
4203
4188
|
break;
|
4204
4189
|
case N$3.South:
|
4205
|
-
|
4190
|
+
x2 = h + c2;
|
4206
4191
|
break;
|
4207
4192
|
case N$3.West:
|
4208
|
-
m3 =
|
4193
|
+
m3 = n2 + s3, g2 = r2 - s3;
|
4209
4194
|
break;
|
4210
4195
|
case N$3.East:
|
4211
|
-
|
4196
|
+
g2 = r2 + s3;
|
4212
4197
|
break;
|
4213
4198
|
case N$3.NorthWest:
|
4214
|
-
m3 =
|
4199
|
+
m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, x2 = h - c2;
|
4215
4200
|
break;
|
4216
4201
|
case N$3.NorthEast:
|
4217
|
-
u3 =
|
4202
|
+
u3 = o2 + c2, g2 = r2 + s3, x2 = h - c2;
|
4218
4203
|
break;
|
4219
4204
|
case N$3.SouthEast:
|
4220
|
-
|
4205
|
+
g2 = r2 + s3, x2 = h + c2;
|
4221
4206
|
break;
|
4222
4207
|
case N$3.SouthWest:
|
4223
|
-
m3 =
|
4208
|
+
m3 = n2 + s3, g2 = r2 - s3, x2 = h + c2;
|
4224
4209
|
break;
|
4225
4210
|
default:
|
4226
|
-
return void this.move(
|
4211
|
+
return void this.move(n2 + s3, o2 + c2);
|
4227
4212
|
}
|
4228
|
-
this.transform(m3, u3,
|
4213
|
+
this.transform(m3, u3, g2, x2);
|
4229
4214
|
}, m2 = (e3) => {
|
4230
4215
|
a2 = void 0, s2 && (k$1(e3), this.$box.classList.toggle(i2, false), this._sideEffect.flush(t2), s2.remove());
|
4231
4216
|
}, u2 = (e3) => {
|
@@ -4236,9 +4221,9 @@ class Y$3 {
|
|
4236
4221
|
return;
|
4237
4222
|
if (!this.draggable || a2 || this.state !== C$3.Normal)
|
4238
4223
|
return;
|
4239
|
-
const
|
4240
|
-
if ((u3 =
|
4241
|
-
k$1(e3), { x:
|
4224
|
+
const g2 = e3.target;
|
4225
|
+
if ((u3 = g2.dataset) == null ? void 0 : u3.teleBoxHandle) {
|
4226
|
+
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
4227
|
const u4 = a2 ? this.wrapClassName(`cursor-${a2}`) : "";
|
4243
4228
|
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
4229
|
window.removeEventListener("mousemove", c), window.removeEventListener("touchmove", c), window.removeEventListener("mouseup", m2), window.removeEventListener("touchend", m2), window.removeEventListener("touchcancel", m2);
|
@@ -4256,14 +4241,14 @@ class Y$3 {
|
|
4256
4241
|
}
|
4257
4242
|
var X$3, P$3;
|
4258
4243
|
class O$3 {
|
4259
|
-
constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles:
|
4244
|
+
constructor({ minimized$: e2, readonly$: t2, darkMode$: i2, rootRect$: s2, namespace: a2 = "telebox", styles: n2 = {}, root$: o2 }) {
|
4260
4245
|
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 },
|
4246
|
+
const r2 = new ValManager();
|
4247
|
+
this._sideEffect.addDisposer(() => r2.destroy());
|
4248
|
+
const h = new Val(void 0), l2 = derive(e2), d2 = new Val(n2), m2 = new Val(document.createElement("button"));
|
4249
|
+
withValueEnhancer(this, { styles: d2, $collector: m2 }, r2);
|
4250
|
+
withReadonlyValueEnhancer(this, { root: o2 });
|
4251
|
+
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
4252
|
this._sideEffect.addEventListener(a3, "click", () => {
|
4268
4253
|
t2.value || e2.setValue(false);
|
4269
4254
|
}, {}, "telebox-collector-click"), this._sideEffect.addDisposer([l2.subscribe((e3) => {
|
@@ -4277,12 +4262,12 @@ class O$3 {
|
|
4277
4262
|
const i3 = e3[t3];
|
4278
4263
|
i3 != null && (a3.style[t3] = i3);
|
4279
4264
|
});
|
4280
|
-
}),
|
4265
|
+
}), o2.subscribe((e3) => {
|
4281
4266
|
e3 && e3.appendChild(a3);
|
4282
|
-
}), combine([e2, s2,
|
4267
|
+
}), combine([e2, s2, o2]).subscribe(([e3, t3, i3]) => {
|
4283
4268
|
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:
|
4269
|
+
const { x: e4, y: i4, width: s3, height: n3 } = a3.getBoundingClientRect();
|
4270
|
+
h.setValue({ x: e4 - t3.x, y: i4 - t3.y, width: s3, height: n3 });
|
4286
4271
|
}
|
4287
4272
|
})], "telebox-collector-el");
|
4288
4273
|
}));
|
@@ -4308,8 +4293,8 @@ class j$1 extends H$3 {
|
|
4308
4293
|
if (this.$titles && this.state$.value === C$3.Maximized) {
|
4309
4294
|
const { children: i2 } = this.$titles.firstElementChild;
|
4310
4295
|
for (let s2 = i2.length - 1; s2 >= 0; s2 -= 1) {
|
4311
|
-
const a2 = i2[s2],
|
4312
|
-
|
4296
|
+
const a2 = i2[s2], n2 = (t2 = a2.dataset) == null ? void 0 : t2.teleBoxID;
|
4297
|
+
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
4298
|
}
|
4314
4299
|
}
|
4315
4300
|
this.focusedBox = e2;
|
@@ -4349,11 +4334,11 @@ class j$1 extends H$3 {
|
|
4349
4334
|
}
|
4350
4335
|
const Z$3 = window.ResizeObserver || ResizeObserver$2;
|
4351
4336
|
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 =
|
4337
|
+
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 } = {}) {
|
4338
|
+
this.events = new Emittery(), this._sideEffect = new SideEffectManager(), this.namespace = o2;
|
4354
4339
|
const b2 = new ValManager();
|
4355
4340
|
this._sideEffect.addDisposer(() => b2.destroy());
|
4356
|
-
const w2 = new Val(e2), y2 = new Val(
|
4341
|
+
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
4342
|
this._sideEffect.addDisposer(w2.subscribe((e3) => {
|
4358
4343
|
this._sideEffect.add(() => {
|
4359
4344
|
if (!e3)
|
@@ -4383,13 +4368,13 @@ class F$3 {
|
|
4383
4368
|
this._sideEffect.addDisposer(D2.reaction((e3, t3) => {
|
4384
4369
|
t3 || this.events.emit(X$3.PrefersColorScheme, e3);
|
4385
4370
|
}));
|
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:
|
4371
|
+
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);
|
4372
|
+
this.collector = n2 != null ? n2 : new O$3({ minimized$: z2, readonly$: y2, darkMode$: L2, namespace: o2, root$: w2, rootRect$: I2 });
|
4373
|
+
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
4374
|
this._sideEffect.addDisposer(() => V2.destroy());
|
4390
4375
|
const H2 = { darkMode: L2, state: T2, root: w2, rootRect: I2, stageRect: V2.stageRect$ };
|
4391
4376
|
withReadonlyValueEnhancer(this, H2, b2);
|
4392
|
-
withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized:
|
4377
|
+
withValueEnhancer(this, { prefersColorScheme: D2, readonly: y2, fence: N2, minimized: z2, maximized: B2, stageRatio: S2, highlightStage: M2 }, b2);
|
4393
4378
|
const W2 = this.wrapClassName("titlebar-icon-close"), Y2 = (e3) => {
|
4394
4379
|
var t3;
|
4395
4380
|
if (y2.value)
|
@@ -4409,10 +4394,10 @@ class F$3 {
|
|
4409
4394
|
};
|
4410
4395
|
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
4396
|
switch (e3.type) {
|
4412
|
-
case
|
4413
|
-
|
4397
|
+
case _.Maximize:
|
4398
|
+
B2.setValue(!B2.value);
|
4414
4399
|
break;
|
4415
|
-
case
|
4400
|
+
case _.Minimize:
|
4416
4401
|
z2.setValue(true);
|
4417
4402
|
break;
|
4418
4403
|
case E$3.Close:
|
@@ -4420,7 +4405,7 @@ class F$3 {
|
|
4420
4405
|
}
|
4421
4406
|
} }), this._sideEffect.addDisposer([T2.reaction((e3, t3) => {
|
4422
4407
|
t3 || this.events.emit(X$3.State, e3);
|
4423
|
-
}),
|
4408
|
+
}), B2.reaction((e3, t3) => {
|
4424
4409
|
t3 || this.events.emit(X$3.Maximized, e3);
|
4425
4410
|
}), z2.reaction((e3, t3) => {
|
4426
4411
|
t3 || this.events.emit(X$3.Minimized, e3);
|
@@ -4448,13 +4433,13 @@ class F$3 {
|
|
4448
4433
|
return this;
|
4449
4434
|
}
|
4450
4435
|
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(
|
4436
|
+
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))));
|
4437
|
+
var n2, o2;
|
4438
|
+
return a2.focus && (this.focusBox(a2), s2 && this.makeBoxTop(a2)), this.boxes$.setValue([...this.boxes, a2]), this._sideEffect.addDisposer([a2._delegateEvents.on(_.Maximize, () => {
|
4454
4439
|
this.setMaximized(!this.maximized);
|
4455
|
-
}), a2._delegateEvents.on(
|
4440
|
+
}), a2._delegateEvents.on(_.Minimize, () => {
|
4456
4441
|
this.setMinimized(true);
|
4457
|
-
}), a2._delegateEvents.on(
|
4442
|
+
}), a2._delegateEvents.on(_.Close, () => {
|
4458
4443
|
this.remove(a2), this.focusTopBox();
|
4459
4444
|
}), a2._intrinsicCoord$.reaction((e3, t2) => {
|
4460
4445
|
t2 || this.events.emit(X$3.IntrinsicMove, a2);
|
@@ -4539,27 +4524,27 @@ class F$3 {
|
|
4539
4524
|
return (i2) => t2.every((t3) => e2[t3] === i2[t3]);
|
4540
4525
|
}
|
4541
4526
|
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: (
|
4527
|
+
var s2, a2, n2, o2, r2, h;
|
4528
|
+
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
4529
|
}
|
4545
4530
|
smartPosition(e2) {
|
4546
4531
|
let { x: t2, y: i2 } = e2;
|
4547
|
-
const { width: s2 = 0.5, height: a2 = 0.5 } = e2,
|
4532
|
+
const { width: s2 = 0.5, height: a2 = 0.5 } = e2, n2 = this.stageRect, o2 = this.topBox;
|
4548
4533
|
if (t2 == null) {
|
4549
|
-
let e3 =
|
4550
|
-
if (
|
4551
|
-
const t3 =
|
4552
|
-
t3 + s2 *
|
4534
|
+
let e3 = n2.x + 20;
|
4535
|
+
if (o2) {
|
4536
|
+
const t3 = o2.pxIntrinsicCoord.x + 20;
|
4537
|
+
t3 + s2 * n2.width <= n2.x + n2.width && (e3 = t3);
|
4553
4538
|
}
|
4554
|
-
t2 = (e3 -
|
4539
|
+
t2 = (e3 - n2.x) / n2.width;
|
4555
4540
|
}
|
4556
4541
|
if (i2 == null) {
|
4557
|
-
let e3 =
|
4558
|
-
if (
|
4559
|
-
const t3 =
|
4560
|
-
t3 + a2 *
|
4542
|
+
let e3 = n2.y + 20;
|
4543
|
+
if (o2) {
|
4544
|
+
const t3 = o2.pxIntrinsicCoord.y + 20;
|
4545
|
+
t3 + a2 * n2.height <= n2.y + n2.height && (e3 = t3);
|
4561
4546
|
}
|
4562
|
-
i2 = (e3 -
|
4547
|
+
i2 = (e3 - n2.y) / n2.height;
|
4563
4548
|
}
|
4564
4549
|
return { x: t2, y: i2, width: s2, height: a2 };
|
4565
4550
|
}
|
@@ -4726,8 +4711,9 @@ class BoxManager {
|
|
4726
4711
|
height,
|
4727
4712
|
id: params.appId
|
4728
4713
|
};
|
4729
|
-
this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4714
|
+
const box = this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4730
4715
|
this.context.emitter.emit(`${params.appId}${Events.WindowCreated}`);
|
4716
|
+
return box;
|
4731
4717
|
}
|
4732
4718
|
setupBoxManager(createTeleBoxManagerConfig) {
|
4733
4719
|
const root = WindowManager.playground;
|
@@ -5850,6 +5836,7 @@ class ReconnectRefresher {
|
|
5850
5836
|
this.reactors.set(id2, func);
|
5851
5837
|
this.disposers.set(id2, func());
|
5852
5838
|
}
|
5839
|
+
return () => this.remove(id2);
|
5853
5840
|
}
|
5854
5841
|
remove(id2) {
|
5855
5842
|
if (this.reactors.has(id2)) {
|
@@ -15475,14 +15462,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15475
15462
|
const _WindowManager = class extends InvisiblePlugin {
|
15476
15463
|
constructor(context) {
|
15477
15464
|
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.
|
15465
|
+
this.version = "1.0.0-canary.4";
|
15466
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.12", "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
15467
|
this.emitter = callbacks$1;
|
15481
15468
|
this.viewMode = ViewMode.Broadcaster;
|
15482
15469
|
this.isReplay = isPlayer(this.displayer);
|
15483
15470
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15484
15471
|
_WindowManager.displayer = context.displayer;
|
15485
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15472
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.12", "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
15473
|
}
|
15487
15474
|
static async mount(params) {
|
15488
15475
|
var _a;
|