@netless/window-manager 1.0.0-canary.26 → 1.0.0-canary.29
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/dist/index.cjs.js +120 -12
- package/dist/index.es.js +1537 -657
- package/dist/index.umd.js +120 -12
- package/dist/{App → src/App}/AppContext.d.ts +0 -0
- package/dist/{App → src/App}/AppPageStateImpl.d.ts +0 -0
- package/dist/{App → src/App}/AppProxy.d.ts +0 -0
- package/dist/{App → src/App}/MagixEvent/index.d.ts +0 -0
- package/dist/{App → src/App}/Storage/StorageEvent.d.ts +0 -0
- package/dist/{App → src/App}/Storage/index.d.ts +0 -0
- package/dist/{App → src/App}/Storage/typings.d.ts +0 -0
- package/dist/{App → src/App}/Storage/utils.d.ts +0 -0
- package/dist/{App → src/App}/WhiteboardView.d.ts +3 -1
- package/dist/{App → src/App}/index.d.ts +0 -0
- package/dist/{App → src/App}/type.d.ts +0 -0
- package/dist/{AppListener.d.ts → src/AppListener.d.ts} +0 -0
- package/dist/{AppManager.d.ts → src/AppManager.d.ts} +0 -0
- package/dist/{AttributesDelegate.d.ts → src/AttributesDelegate.d.ts} +0 -0
- package/dist/{BoxEmitter.d.ts → src/BoxEmitter.d.ts} +0 -0
- package/dist/{BoxManager.d.ts → src/BoxManager.d.ts} +2 -4
- package/dist/{BuiltinApps.d.ts → src/BuiltinApps.d.ts} +3 -0
- package/dist/{Cursor → src/Cursor}/Cursor.d.ts +0 -0
- package/dist/{Cursor → src/Cursor}/icons.d.ts +0 -0
- package/dist/{Cursor → src/Cursor}/index.d.ts +0 -0
- package/dist/{Helper.d.ts → src/Helper.d.ts} +1 -1
- package/dist/{InternalEmitter.d.ts → src/InternalEmitter.d.ts} +0 -0
- package/dist/{Page → src/Page}/PageController.d.ts +0 -0
- package/dist/{Page → src/Page}/index.d.ts +0 -0
- package/dist/{PageState.d.ts → src/PageState.d.ts} +0 -0
- package/dist/{ReconnectRefresher.d.ts → src/ReconnectRefresher.d.ts} +0 -0
- package/dist/{RedoUndo.d.ts → src/RedoUndo.d.ts} +0 -0
- package/dist/{Register → src/Register}/index.d.ts +0 -0
- package/dist/{Register → src/Register}/loader.d.ts +0 -0
- package/dist/{Register → src/Register}/storage.d.ts +0 -0
- package/dist/{Utils → src/Utils}/AppCreateQueue.d.ts +0 -0
- package/dist/{Utils → src/Utils}/Common.d.ts +0 -0
- package/dist/{Utils → src/Utils}/Reactive.d.ts +0 -0
- package/dist/{Utils → src/Utils}/RoomHacker.d.ts +0 -0
- package/dist/{Utils → src/Utils}/error.d.ts +0 -0
- package/dist/{Utils → src/Utils}/log.d.ts +0 -0
- package/dist/{View → src/View}/CameraSynchronizer.d.ts +0 -0
- package/dist/{View → src/View}/MainView.d.ts +0 -0
- package/dist/{View → src/View}/ViewManager.d.ts +0 -0
- package/dist/{View → src/View}/ViewSync.d.ts +0 -0
- package/dist/{callback.d.ts → src/callback.d.ts} +5 -0
- package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
- package/dist/src/image.d.ts +19 -0
- package/dist/{index.d.ts → src/index.d.ts} +5 -4
- package/dist/src/shim.d.ts +11 -0
- package/dist/{typings.d.ts → src/typings.d.ts} +6 -0
- package/dist/style.css +1 -1
- package/docs/app-context.md +2 -2
- package/package.json +10 -5
- package/playwright.config.ts +28 -0
- package/pnpm-lock.yaml +514 -21
- package/src/App/AppContext.ts +2 -2
- package/src/App/AppProxy.ts +14 -7
- package/src/App/WhiteboardView.ts +19 -14
- package/src/BoxManager.ts +32 -36
- package/src/BuiltinApps.ts +5 -0
- package/src/Helper.ts +3 -2
- package/src/Utils/Common.ts +3 -0
- package/src/View/CameraSynchronizer.ts +3 -7
- package/src/callback.ts +1 -0
- package/src/index.ts +18 -5
- package/src/style.css +3 -41
- package/src/typings.ts +6 -0
- package/vite.config.js +5 -3
package/dist/index.es.js
CHANGED
@@ -24,7 +24,7 @@ import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reactio
|
|
24
24
|
import { v4 } from "uuid";
|
25
25
|
import { genUID, SideEffectManager } from "side-effect-manager";
|
26
26
|
import { Val, combine, ValManager, withReadonlyValueEnhancer, withValueEnhancer, derive } from "value-enhancer";
|
27
|
-
import { ResizeObserver as ResizeObserver$
|
27
|
+
import { ResizeObserver as ResizeObserver$3 } from "@juggle/resize-observer";
|
28
28
|
import p$1 from "video.js";
|
29
29
|
var Events = /* @__PURE__ */ ((Events2) => {
|
30
30
|
Events2["AppMove"] = "AppMove";
|
@@ -352,6 +352,9 @@ const genAppId = async (kind2) => {
|
|
352
352
|
return `${kind2}-${v4().replace("-", "").slice(0, 8)}`;
|
353
353
|
};
|
354
354
|
const setViewFocusScenePath = (view, focusScenePath) => {
|
355
|
+
if (view.didRelease) {
|
356
|
+
return;
|
357
|
+
}
|
355
358
|
if (view.focusScenePath !== focusScenePath) {
|
356
359
|
view.focusScenePath = focusScenePath;
|
357
360
|
return view;
|
@@ -931,17 +934,25 @@ class WhiteBoardView {
|
|
931
934
|
return this.appProxy.removeSceneByIndex(needRemoveIndex);
|
932
935
|
};
|
933
936
|
const pageState$ = new Val(appProxy.pageState);
|
937
|
+
const baseRect$ = new Val(appProxy.size$.value);
|
938
|
+
const pickCamera = (camera) => pick(camera, ["centerX", "centerY", "scale"]);
|
939
|
+
const camera$ = new Val(pickCamera(this.view.camera));
|
940
|
+
this.baseRect$ = baseRect$;
|
934
941
|
this.pageState$ = pageState$;
|
935
|
-
this.appProxy.sideEffectManager.add(() => appProxy.appEmitter.on("pageStateChange", (pageState) => {
|
936
|
-
pageState$.setValue(pageState);
|
937
|
-
}));
|
938
|
-
const camera$ = new Val(pick(this.view.camera, ["centerX", "centerY", "scale"]));
|
939
942
|
this.baseCamera$ = camera$;
|
940
|
-
this.appProxy.sideEffectManager.add(() =>
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
943
|
+
this.appProxy.sideEffectManager.add(() => [
|
944
|
+
appProxy.appEmitter.on("pageStateChange", (pageState) => pageState$.setValue(pageState)),
|
945
|
+
appProxy.camera$.subscribe((camera) => {
|
946
|
+
if (camera) {
|
947
|
+
camera$.setValue(pickCamera(camera));
|
948
|
+
}
|
949
|
+
}),
|
950
|
+
appProxy.size$.subscribe((size2) => {
|
951
|
+
if (size2) {
|
952
|
+
baseRect$.setValue(pick(size2, ["width", "height"]));
|
953
|
+
}
|
954
|
+
})
|
955
|
+
]);
|
945
956
|
view.disableCameraTransform = true;
|
946
957
|
}
|
947
958
|
get pageState() {
|
@@ -959,12 +970,12 @@ const log = (...args) => {
|
|
959
970
|
console.log(`[WindowManager]:`, ...args);
|
960
971
|
}
|
961
972
|
};
|
962
|
-
const setupWrapper = (root) => {
|
973
|
+
const setupWrapper = (root, target) => {
|
963
974
|
const playground = document.createElement("div");
|
964
975
|
playground.className = "netless-window-manager-playground";
|
965
976
|
const mainViewElement = document.createElement("div");
|
966
977
|
mainViewElement.className = "netless-window-manager-main-view";
|
967
|
-
|
978
|
+
target.appendChild(mainViewElement);
|
968
979
|
root.appendChild(playground);
|
969
980
|
return { playground, mainViewElement };
|
970
981
|
};
|
@@ -1033,7 +1044,6 @@ class AppContext {
|
|
1033
1044
|
}
|
1034
1045
|
};
|
1035
1046
|
this.createWhiteBoardView = (params) => {
|
1036
|
-
var _a;
|
1037
1047
|
if (this.whiteBoardView) {
|
1038
1048
|
return this.whiteBoardView;
|
1039
1049
|
}
|
@@ -1049,7 +1059,7 @@ class AppContext {
|
|
1049
1059
|
const viewWrapper = document.createElement("div");
|
1050
1060
|
this._viewWrapper = viewWrapper;
|
1051
1061
|
viewWrapper.className = "window-manager-view-wrapper";
|
1052
|
-
|
1062
|
+
this.box.$main.appendChild(viewWrapper);
|
1053
1063
|
view.divElement = viewWrapper;
|
1054
1064
|
this.appProxy.fireMemberStateChange();
|
1055
1065
|
if (this.isAddApp) {
|
@@ -1057,7 +1067,7 @@ class AppContext {
|
|
1057
1067
|
}
|
1058
1068
|
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, this.ensurePageSize);
|
1059
1069
|
this.appProxy.sideEffectManager.add(() => [
|
1060
|
-
this.box.
|
1070
|
+
this.box._stageRect$.subscribe((rect) => {
|
1061
1071
|
viewWrapper.style.left = `${rect.x}px`;
|
1062
1072
|
viewWrapper.style.top = `${rect.y}px`;
|
1063
1073
|
viewWrapper.style.width = `${rect.width}px`;
|
@@ -1238,13 +1248,9 @@ class CameraSynchronizer {
|
|
1238
1248
|
this.remoteCamera = camera;
|
1239
1249
|
this.remoteSize = size2;
|
1240
1250
|
if (this.remoteSize && this.rect) {
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
} else {
|
1245
|
-
scale2 = this.rect.height / size2.height;
|
1246
|
-
}
|
1247
|
-
const nextScale = camera.scale * scale2;
|
1251
|
+
const wScale = this.rect.width / size2.width;
|
1252
|
+
const hScale = this.rect.height / size2.height;
|
1253
|
+
const nextScale = camera.scale * Math.min(wScale, hScale);
|
1248
1254
|
const config = {
|
1249
1255
|
scale: nextScale,
|
1250
1256
|
animationMode: AnimationMode.Continuous
|
@@ -1768,10 +1774,10 @@ class AppProxy {
|
|
1768
1774
|
});
|
1769
1775
|
this.camera$.setValue(toJS(this.appAttributes.camera));
|
1770
1776
|
}
|
1771
|
-
if (!this.size$.value && box.
|
1772
|
-
const initialRect = this.computedInitialRect(box.
|
1773
|
-
const width = (initialRect == null ? void 0 : initialRect.width) || box.
|
1774
|
-
const height = (initialRect == null ? void 0 : initialRect.height) || box.
|
1777
|
+
if (!this.size$.value && box.stageRect) {
|
1778
|
+
const initialRect = this.computedInitialRect(box.stageRect);
|
1779
|
+
const width = (initialRect == null ? void 0 : initialRect.width) || box.stageRect.width;
|
1780
|
+
const height = (initialRect == null ? void 0 : initialRect.height) || box.stageRect.height;
|
1775
1781
|
this.storeSize({
|
1776
1782
|
id: this.uid,
|
1777
1783
|
width,
|
@@ -1784,7 +1790,7 @@ class AppProxy {
|
|
1784
1790
|
view$: this.view$,
|
1785
1791
|
camera$: this.camera$,
|
1786
1792
|
size$: this.size$,
|
1787
|
-
stageRect$: box.
|
1793
|
+
stageRect$: box._stageRect$,
|
1788
1794
|
storeCamera: this.storeCamera,
|
1789
1795
|
storeSize: this.storeSize
|
1790
1796
|
});
|
@@ -1912,6 +1918,10 @@ class AppProxy {
|
|
1912
1918
|
canOperate: this.manager.canOperate,
|
1913
1919
|
smartPosition: this.isAddApp
|
1914
1920
|
});
|
1921
|
+
const registerParams = appRegister.registered.get(this.kind);
|
1922
|
+
if (registerParams == null ? void 0 : registerParams.contentStyles) {
|
1923
|
+
box == null ? void 0 : box.mountUserStyles(registerParams.contentStyles);
|
1924
|
+
}
|
1915
1925
|
this.box$.setValue(box);
|
1916
1926
|
if (this.isAddApp && this.box) {
|
1917
1927
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
@@ -2039,6 +2049,8 @@ class AppProxy {
|
|
2039
2049
|
}
|
2040
2050
|
}
|
2041
2051
|
setViewFocusScenePath() {
|
2052
|
+
if (this.status === "destroyed")
|
2053
|
+
return;
|
2042
2054
|
const fullPath = this.getFullScenePath();
|
2043
2055
|
if (fullPath && this.view) {
|
2044
2056
|
setViewFocusScenePath(this.view, fullPath);
|
@@ -2094,6 +2106,7 @@ class AppProxy {
|
|
2094
2106
|
this.status = "destroyed";
|
2095
2107
|
try {
|
2096
2108
|
await appRegister.notifyApp(this.kind, "destroy", { appId: this.id });
|
2109
|
+
callbacks$1.emit("appClose", { appId: this.id, kind: this.kind, error });
|
2097
2110
|
await this.appEmitter.emit("destroy", { error });
|
2098
2111
|
} catch (error2) {
|
2099
2112
|
console.error("[WindowManager]: notifyApp error", error2.message, error2.stack);
|
@@ -2699,7 +2712,7 @@ class AppManager {
|
|
2699
2712
|
}
|
2700
2713
|
};
|
2701
2714
|
this.closeAll = async () => {
|
2702
|
-
for (const [
|
2715
|
+
for (const [_, appProxy] of this.appProxies.entries()) {
|
2703
2716
|
await appProxy.destroy(true, false, true);
|
2704
2717
|
}
|
2705
2718
|
};
|
@@ -3312,7 +3325,7 @@ var startLoop = function() {
|
|
3312
3325
|
if (!isProcessing)
|
3313
3326
|
onNextFrame(processFrame);
|
3314
3327
|
};
|
3315
|
-
var clamp$
|
3328
|
+
var clamp$2 = function(min, max) {
|
3316
3329
|
return function(v2) {
|
3317
3330
|
return Math.max(Math.min(v2, max), min);
|
3318
3331
|
};
|
@@ -3330,7 +3343,7 @@ var number = {
|
|
3330
3343
|
return v2;
|
3331
3344
|
}
|
3332
3345
|
};
|
3333
|
-
var alpha = __assign(__assign({}, number), { transform: clamp$
|
3346
|
+
var alpha = __assign(__assign({}, number), { transform: clamp$2(0, 1) });
|
3334
3347
|
var scale = __assign(__assign({}, number), { default: 1 });
|
3335
3348
|
var createUnitType = function(unit) {
|
3336
3349
|
return {
|
@@ -3354,7 +3367,7 @@ var progressPercentage = __assign(__assign({}, percent), { parse: function(v2) {
|
|
3354
3367
|
var getValueFromFunctionString = function(value) {
|
3355
3368
|
return value.substring(value.indexOf("(") + 1, value.lastIndexOf(")"));
|
3356
3369
|
};
|
3357
|
-
var clampRgbUnit = clamp$
|
3370
|
+
var clampRgbUnit = clamp$2(0, 255);
|
3358
3371
|
var isRgba = function(v2) {
|
3359
3372
|
return v2.red !== void 0;
|
3360
3373
|
};
|
@@ -3993,190 +4006,423 @@ var shallowequal = function shallowEqual(objA, objB, compare, compareContext) {
|
|
3993
4006
|
}
|
3994
4007
|
return true;
|
3995
4008
|
};
|
3996
|
-
var
|
3997
|
-
|
3998
|
-
|
3999
|
-
|
4000
|
-
|
4001
|
-
|
4002
|
-
|
4003
|
-
|
4004
|
-
|
4005
|
-
|
4006
|
-
|
4007
|
-
return
|
4008
|
-
}
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4012
|
-
|
4013
|
-
|
4014
|
-
|
4015
|
-
|
4016
|
-
|
4017
|
-
|
4009
|
+
var shadowStyles = /* @__PURE__ */ (() => '.tele-fancy-scrollbar {\n overscroll-behavior: contain;\n overflow: auto;\n overflow-y: scroll;\n overflow-y: overlay;\n -webkit-overflow-scrolling: touch;\n -ms-overflow-style: -ms-autohiding-scrollbar;\n scrollbar-width: auto;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar {\n height: 8px;\n width: 8px;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-track {\n background-color: transparent;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb {\n background-color: rgba(68, 78, 96, 0.1);\n background-color: transparent;\n border-radius: 4px;\n transition: background-color 0.4s;\n}\n.tele-fancy-scrollbar:hover::-webkit-scrollbar-thumb {\n background-color: rgba(68, 78, 96, 0.1);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:hover {\n background-color: rgba(68, 78, 96, 0.2);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:active {\n background-color: rgba(68, 78, 96, 0.2);\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:vertical {\n min-height: 50px;\n}\n.tele-fancy-scrollbar::-webkit-scrollbar-thumb:horizontal {\n min-width: 50px;\n}\n.telebox-quarantine {\n all: initial;\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n}\n.telebox-body-wrap {\n color: #191919;\n color: var(--tele-box-color, #191919);\n flex: 1;\n width: 100%;\n overflow: hidden;\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n}\n.telebox-content {\n width: 100%;\n height: 100%;\n position: relative;\n background-color: #f9f9f9;\n background-color: var(--tele-manager-container-background, #f9f9f9);\n}\n.telebox-box-stage {\n position: absolute;\n z-index: 1;\n overflow: hidden;\n background-color: #fff;\n background-color: var(--tele-manager-stage-background, #fff);\n box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.08);\n box-shadow: var(--tele-manager-stage-shadow, 0px 0px 16px rgba(0, 0, 0, 0.08));\n}\n.telebox-footer-wrap {\n flex-shrink: 0;\n display: flex;\n flex-direction: column;\n color: #191919;\n color: var(--tele-box-footer-color, #191919);\n background-color: #fff;\n background-color: var(--tele-box-footer-background, #fff);\n}\n.telebox-footer-wrap::before {\n content: "";\n display: block;\n flex: 1;\n}\n.telebox-color-scheme-dark {\n color-scheme: dark;\n}\n.telebox-color-scheme-dark .telebox-body-wrap {\n color: #e9e9e9;\n color: var(--tele-box-color-dark, #e9e9e9);\n}\n.telebox-color-scheme-dark .telebox-content {\n background-color: #25282e;\n background-color: var(--tele-manager-container-background-dark, #25282e);\n}\n.telebox-color-scheme-dark .telebox-box-stage {\n background-color: #272a30;\n background-color: var(--tele-manager-stage-background-dark, #272a30);\n box-shadow: 0px 0px 16px rgba(0, 0, 0, 0.24);\n box-shadow: var(--tele-manager-stage-shadow-dark, 0px 0px 16px rgba(0, 0, 0, 0.24));\n}\n.telebox-color-scheme-dark .telebox-footer-wrap {\n color: #e9e9e9;\n color: var(--tele-box-footer-color-dark, #e9e9e9);\n background-color: #383b42;\n background-color: var(--tele-box-footer-background-dark, #383b42);\n}')();
|
4010
|
+
var TELE_BOX_COLOR_SCHEME = /* @__PURE__ */ ((TELE_BOX_COLOR_SCHEME2) => {
|
4011
|
+
TELE_BOX_COLOR_SCHEME2["Light"] = "light";
|
4012
|
+
TELE_BOX_COLOR_SCHEME2["Dark"] = "dark";
|
4013
|
+
TELE_BOX_COLOR_SCHEME2["Auto"] = "auto";
|
4014
|
+
return TELE_BOX_COLOR_SCHEME2;
|
4015
|
+
})(TELE_BOX_COLOR_SCHEME || {});
|
4016
|
+
var TELE_BOX_STATE = /* @__PURE__ */ ((TELE_BOX_STATE2) => {
|
4017
|
+
TELE_BOX_STATE2["Normal"] = "normal";
|
4018
|
+
TELE_BOX_STATE2["Minimized"] = "minimized";
|
4019
|
+
TELE_BOX_STATE2["Maximized"] = "maximized";
|
4020
|
+
return TELE_BOX_STATE2;
|
4021
|
+
})(TELE_BOX_STATE || {});
|
4022
|
+
var TELE_BOX_EVENT = /* @__PURE__ */ ((TELE_BOX_EVENT2) => {
|
4023
|
+
TELE_BOX_EVENT2["DarkMode"] = "dark_mode";
|
4024
|
+
TELE_BOX_EVENT2["PrefersColorScheme"] = "prefers_color_scheme";
|
4025
|
+
TELE_BOX_EVENT2["Close"] = "close";
|
4026
|
+
TELE_BOX_EVENT2["Focus"] = "focus";
|
4027
|
+
TELE_BOX_EVENT2["Blur"] = "blur";
|
4028
|
+
TELE_BOX_EVENT2["IntrinsicMove"] = "intrinsic_move";
|
4029
|
+
TELE_BOX_EVENT2["IntrinsicResize"] = "intrinsic_resize";
|
4030
|
+
TELE_BOX_EVENT2["ZIndex"] = "z_index";
|
4031
|
+
TELE_BOX_EVENT2["State"] = "state";
|
4032
|
+
TELE_BOX_EVENT2["Minimized"] = "minimized";
|
4033
|
+
TELE_BOX_EVENT2["Maximized"] = "maximized";
|
4034
|
+
TELE_BOX_EVENT2["Readonly"] = "readonly";
|
4035
|
+
TELE_BOX_EVENT2["Destroyed"] = "destroyed";
|
4036
|
+
return TELE_BOX_EVENT2;
|
4037
|
+
})(TELE_BOX_EVENT || {});
|
4038
|
+
var TELE_BOX_DELEGATE_EVENT = /* @__PURE__ */ ((TELE_BOX_DELEGATE_EVENT2) => {
|
4039
|
+
TELE_BOX_DELEGATE_EVENT2["Close"] = "close";
|
4040
|
+
TELE_BOX_DELEGATE_EVENT2["Maximize"] = "maximize";
|
4041
|
+
TELE_BOX_DELEGATE_EVENT2["Minimize"] = "minimize";
|
4042
|
+
return TELE_BOX_DELEGATE_EVENT2;
|
4043
|
+
})(TELE_BOX_DELEGATE_EVENT || {});
|
4044
|
+
var TELE_BOX_RESIZE_HANDLE = /* @__PURE__ */ ((TELE_BOX_RESIZE_HANDLE2) => {
|
4045
|
+
TELE_BOX_RESIZE_HANDLE2["North"] = "n";
|
4046
|
+
TELE_BOX_RESIZE_HANDLE2["South"] = "s";
|
4047
|
+
TELE_BOX_RESIZE_HANDLE2["West"] = "w";
|
4048
|
+
TELE_BOX_RESIZE_HANDLE2["East"] = "e";
|
4049
|
+
TELE_BOX_RESIZE_HANDLE2["NorthWest"] = "nw";
|
4050
|
+
TELE_BOX_RESIZE_HANDLE2["NorthEast"] = "ne";
|
4051
|
+
TELE_BOX_RESIZE_HANDLE2["SouthEast"] = "se";
|
4052
|
+
TELE_BOX_RESIZE_HANDLE2["SouthWest"] = "sw";
|
4053
|
+
return TELE_BOX_RESIZE_HANDLE2;
|
4054
|
+
})(TELE_BOX_RESIZE_HANDLE || {});
|
4055
|
+
const TeleBoxDragHandleType = "dh";
|
4056
|
+
function clamp$1(value, min, max) {
|
4057
|
+
return Math.min(Math.max(value, min), max);
|
4018
4058
|
}
|
4019
|
-
function
|
4020
|
-
|
4059
|
+
function preventEvent$1(ev) {
|
4060
|
+
ev.stopPropagation();
|
4061
|
+
if (ev.cancelable) {
|
4062
|
+
ev.preventDefault();
|
4063
|
+
}
|
4021
4064
|
}
|
4022
|
-
|
4023
|
-
|
4065
|
+
let defaultBoxCount = 1;
|
4066
|
+
function getBoxDefaultName() {
|
4067
|
+
return `New Box ${defaultBoxCount++}`;
|
4024
4068
|
}
|
4025
|
-
class
|
4026
|
-
constructor({
|
4027
|
-
|
4028
|
-
|
4029
|
-
|
4030
|
-
|
4031
|
-
|
4032
|
-
|
4033
|
-
|
4069
|
+
class DefaultTitleBar {
|
4070
|
+
constructor({
|
4071
|
+
readonly$,
|
4072
|
+
state$,
|
4073
|
+
title$,
|
4074
|
+
buttons,
|
4075
|
+
onEvent,
|
4076
|
+
onDragStart,
|
4077
|
+
namespace = "telebox"
|
4078
|
+
}) {
|
4079
|
+
this.sideEffect = new SideEffectManager();
|
4080
|
+
this.lastTitleBarClick = {
|
4081
|
+
timestamp: 0,
|
4082
|
+
clientX: -100,
|
4083
|
+
clientY: -100
|
4084
|
+
};
|
4085
|
+
this.handleTitleBarClick = (ev) => {
|
4086
|
+
var _a;
|
4087
|
+
if (!ev.isPrimary || this.readonly$.value) {
|
4034
4088
|
return;
|
4035
|
-
|
4036
|
-
|
4037
|
-
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;
|
4038
|
-
}, this.lastTitleBarTouch = { timestamp: 0, clientX: -100, clientY: -100 }, this.handleTitleBarTouch = (e3) => {
|
4039
|
-
var t3;
|
4040
|
-
if (this.readonly$.value)
|
4089
|
+
}
|
4090
|
+
if (ev.button !== 0) {
|
4041
4091
|
return;
|
4042
|
-
|
4092
|
+
}
|
4093
|
+
if ((_a = ev.target.dataset) == null ? void 0 : _a.teleTitleBarNoDblClick) {
|
4043
4094
|
return;
|
4044
|
-
|
4045
|
-
|
4046
|
-
|
4047
|
-
|
4095
|
+
}
|
4096
|
+
preventEvent$1(ev);
|
4097
|
+
const now = Date.now();
|
4098
|
+
if (now - this.lastTitleBarClick.timestamp <= 500) {
|
4099
|
+
if (Math.abs(ev.clientX - this.lastTitleBarClick.clientX) <= 5 && Math.abs(ev.clientY - this.lastTitleBarClick.clientY) <= 5) {
|
4100
|
+
if (this.onEvent) {
|
4101
|
+
this.onEvent({ type: TELE_BOX_DELEGATE_EVENT.Maximize });
|
4102
|
+
}
|
4103
|
+
}
|
4104
|
+
} else if (this.onDragStart) {
|
4105
|
+
this.onDragStart(ev);
|
4106
|
+
}
|
4107
|
+
this.lastTitleBarClick.timestamp = now;
|
4108
|
+
this.lastTitleBarClick.clientX = ev.clientX;
|
4109
|
+
this.lastTitleBarClick.clientY = ev.clientY;
|
4110
|
+
};
|
4111
|
+
this.readonly$ = readonly$;
|
4112
|
+
this.state$ = state$;
|
4113
|
+
this.title$ = title$;
|
4114
|
+
this.onEvent = onEvent;
|
4115
|
+
this.onDragStart = onDragStart;
|
4116
|
+
this.namespace = namespace;
|
4117
|
+
this.buttons = buttons || [
|
4118
|
+
{
|
4119
|
+
type: TELE_BOX_DELEGATE_EVENT.Minimize,
|
4120
|
+
iconClassName: this.wrapClassName("titlebar-icon-minimize")
|
4121
|
+
},
|
4122
|
+
{
|
4123
|
+
type: TELE_BOX_DELEGATE_EVENT.Maximize,
|
4124
|
+
iconClassName: this.wrapClassName("titlebar-icon-maximize"),
|
4125
|
+
isActive: (state) => state === TELE_BOX_STATE.Maximized
|
4126
|
+
},
|
4127
|
+
{
|
4128
|
+
type: TELE_BOX_DELEGATE_EVENT.Close,
|
4129
|
+
iconClassName: this.wrapClassName("titlebar-icon-close")
|
4130
|
+
}
|
4131
|
+
];
|
4132
|
+
this.$dragArea = this.renderDragArea();
|
4048
4133
|
}
|
4049
4134
|
render() {
|
4050
4135
|
if (!this.$titleBar) {
|
4051
|
-
this.$titleBar = document.createElement("div")
|
4052
|
-
|
4053
|
-
|
4054
|
-
|
4055
|
-
|
4056
|
-
const
|
4057
|
-
|
4058
|
-
|
4059
|
-
|
4060
|
-
|
4061
|
-
|
4062
|
-
|
4063
|
-
|
4064
|
-
|
4065
|
-
|
4136
|
+
this.$titleBar = document.createElement("div");
|
4137
|
+
this.$titleBar.className = this.wrapClassName("titlebar");
|
4138
|
+
const $titleArea = document.createElement("div");
|
4139
|
+
$titleArea.className = this.wrapClassName("title-area");
|
4140
|
+
$titleArea.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
4141
|
+
const $title = document.createElement("h1");
|
4142
|
+
$title.className = this.wrapClassName("title");
|
4143
|
+
$title.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
4144
|
+
$titleArea.appendChild($title);
|
4145
|
+
$titleArea.appendChild(this.$dragArea);
|
4146
|
+
const $buttonsContainer = document.createElement("div");
|
4147
|
+
$buttonsContainer.className = this.wrapClassName("titlebar-btns");
|
4148
|
+
this.buttons.forEach(({ iconClassName }, i2) => {
|
4149
|
+
const teleTitleBarBtnIndex = String(i2);
|
4150
|
+
const $btn = document.createElement("button");
|
4151
|
+
$btn.className = `${this.wrapClassName("titlebar-btn")} ${iconClassName}`;
|
4152
|
+
$btn.dataset.teleTitleBarBtnIndex = teleTitleBarBtnIndex;
|
4153
|
+
$btn.dataset.teleTitleBarNoDblClick = "true";
|
4154
|
+
$buttonsContainer.appendChild($btn);
|
4155
|
+
});
|
4156
|
+
this.sideEffect.addDisposer(this.title$.subscribe((title) => {
|
4157
|
+
$title.textContent = title;
|
4158
|
+
$title.title = title;
|
4159
|
+
}), "render-title");
|
4160
|
+
this.sideEffect.addDisposer(this.state$.subscribe((state) => {
|
4161
|
+
this.buttons.forEach((btn, i2) => {
|
4162
|
+
var _a;
|
4163
|
+
if (btn.isActive) {
|
4164
|
+
(_a = $buttonsContainer.children[i2]) == null ? void 0 : _a.classList.toggle("is-active", btn.isActive(state));
|
4165
|
+
}
|
4066
4166
|
});
|
4067
|
-
}), "render-state-btns")
|
4068
|
-
|
4069
|
-
|
4167
|
+
}), "render-state-btns");
|
4168
|
+
this.sideEffect.addEventListener($buttonsContainer, "pointerup", (ev) => {
|
4169
|
+
var _a;
|
4170
|
+
if (!ev.isPrimary || this.readonly$.value) {
|
4070
4171
|
return;
|
4071
|
-
const i3 = e3.target, s2 = Number((t3 = i3.dataset) == null ? void 0 : t3.teleTitleBarBtnIndex);
|
4072
|
-
if (!Number.isNaN(s2) && s2 < this.buttons.length) {
|
4073
|
-
k$1(e3);
|
4074
|
-
const t4 = this.buttons[s2];
|
4075
|
-
this.onEvent && this.onEvent({ type: t4.type, value: t4.value });
|
4076
4172
|
}
|
4077
|
-
|
4173
|
+
const target = ev.target;
|
4174
|
+
const teleTitleBarBtnIndex = Number((_a = target.dataset) == null ? void 0 : _a.teleTitleBarBtnIndex);
|
4175
|
+
if (!Number.isNaN(teleTitleBarBtnIndex) && teleTitleBarBtnIndex < this.buttons.length) {
|
4176
|
+
preventEvent$1(ev);
|
4177
|
+
const btn = this.buttons[teleTitleBarBtnIndex];
|
4178
|
+
if (this.onEvent) {
|
4179
|
+
this.onEvent({
|
4180
|
+
type: btn.type,
|
4181
|
+
value: btn.value
|
4182
|
+
});
|
4183
|
+
}
|
4184
|
+
}
|
4185
|
+
}, {}, "render-btns-container-click");
|
4186
|
+
this.$titleBar.appendChild($titleArea);
|
4187
|
+
this.$titleBar.appendChild($buttonsContainer);
|
4078
4188
|
}
|
4079
4189
|
return this.$titleBar;
|
4080
4190
|
}
|
4081
4191
|
renderDragArea() {
|
4082
|
-
const
|
4083
|
-
|
4192
|
+
const $dragArea = document.createElement("div");
|
4193
|
+
$dragArea.className = this.wrapClassName("drag-area");
|
4194
|
+
$dragArea.dataset.teleBoxHandle = TeleBoxDragHandleType;
|
4195
|
+
this.sideEffect.addEventListener($dragArea, "pointerdown", this.handleTitleBarClick);
|
4196
|
+
return $dragArea;
|
4084
4197
|
}
|
4085
4198
|
dragHandle() {
|
4086
4199
|
return this.$titleBar;
|
4087
4200
|
}
|
4088
|
-
wrapClassName(
|
4089
|
-
return `${this.namespace}-${
|
4201
|
+
wrapClassName(className) {
|
4202
|
+
return `${this.namespace}-${className}`;
|
4090
4203
|
}
|
4091
4204
|
destroy() {
|
4092
|
-
this.sideEffect.flushAll()
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
if (t3 <= 0 || e3.width <= 0 || e3.height <= 0)
|
4099
|
-
return e3;
|
4100
|
-
const i3 = e3.width * t3;
|
4101
|
-
if (i3 === e3.height)
|
4102
|
-
return e3;
|
4103
|
-
if (i3 < e3.height)
|
4104
|
-
return { x: 0, y: (e3.height - i3) / 2, width: e3.width, height: i3 };
|
4105
|
-
const s3 = e3.height / t3;
|
4106
|
-
return { x: (e3.width - s3) / 2, y: 0, width: s3, height: e3.height };
|
4107
|
-
}, { compare: shallowequal }), this._sideEffect.addDisposer(combine([a2, s2]).subscribe(([e3, t3]) => {
|
4108
|
-
var i3;
|
4109
|
-
e3 && t3 ? e3.appendChild(this.render()) : ((i3 = this.$boxStage) == null ? void 0 : i3.parentNode) && this.$boxStage.remove();
|
4110
|
-
}));
|
4205
|
+
this.sideEffect.flushAll();
|
4206
|
+
if (this.$titleBar) {
|
4207
|
+
this.$titleBar = void 0;
|
4208
|
+
this.onDragStart = void 0;
|
4209
|
+
this.onEvent = void 0;
|
4210
|
+
}
|
4111
4211
|
}
|
4112
|
-
|
4113
|
-
|
4114
|
-
|
4115
|
-
|
4116
|
-
e2.className = this.wrapClassName("box-stage-container");
|
4117
|
-
const t2 = document.createElement("div");
|
4118
|
-
t2.className = this.wrapClassName("box-stage-mask");
|
4119
|
-
const i2 = document.createElement("div");
|
4120
|
-
i2.className = this.wrapClassName("box-stage-mask");
|
4121
|
-
const s2 = document.createElement("div");
|
4122
|
-
s2.className = this.wrapClassName("box-stage-frame");
|
4123
|
-
const [a2, n2, o2, r2] = ["M0 8V0h8v2H2v6H0Z", "M8 8V0H0v2h6v6h2Z", "M0 0v8h8V6H2V0H0Z", "M8 0v8H0V6h6V0h2Z"].map((e3, t3) => {
|
4124
|
-
const i3 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
4125
|
-
i3.setAttribute("viewBox", "0 0 8 8"), i3.setAttribute("class", `${this.wrapClassName("box-stage-frame-corner")} is-${t3}`);
|
4126
|
-
const s3 = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
4127
|
-
return s3.setAttribute("d", e3), s3.setAttribute("fill", "#3381FF"), i3.appendChild(s3), i3;
|
4128
|
-
});
|
4129
|
-
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) => {
|
4130
|
-
e2.classList.toggle("is-active", t3);
|
4131
|
-
})), this._sideEffect.addDisposer(combine([this.highlightStage$, this.stageRect$]).subscribe(([s3, a3]) => {
|
4132
|
-
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`));
|
4133
|
-
})), this.$boxStage = e2, e2;
|
4212
|
+
}
|
4213
|
+
function calcStageRect([rootRect, ratio]) {
|
4214
|
+
if (ratio <= 0 || rootRect.width <= 0 || rootRect.height <= 0) {
|
4215
|
+
return rootRect;
|
4134
4216
|
}
|
4135
|
-
|
4136
|
-
|
4217
|
+
const preferredHeight = rootRect.width * ratio;
|
4218
|
+
if (preferredHeight === rootRect.height) {
|
4219
|
+
return rootRect;
|
4137
4220
|
}
|
4138
|
-
|
4139
|
-
return
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4143
|
-
|
4144
|
-
|
4145
|
-
|
4146
|
-
|
4147
|
-
|
4148
|
-
|
4149
|
-
|
4150
|
-
|
4151
|
-
|
4152
|
-
|
4153
|
-
|
4221
|
+
if (preferredHeight < rootRect.height) {
|
4222
|
+
return {
|
4223
|
+
x: 0,
|
4224
|
+
y: (rootRect.height - preferredHeight) / 2,
|
4225
|
+
width: rootRect.width,
|
4226
|
+
height: preferredHeight
|
4227
|
+
};
|
4228
|
+
}
|
4229
|
+
const preferredWidth = rootRect.height / ratio;
|
4230
|
+
return {
|
4231
|
+
x: (rootRect.width - preferredWidth) / 2,
|
4232
|
+
y: 0,
|
4233
|
+
width: preferredWidth,
|
4234
|
+
height: rootRect.height
|
4235
|
+
};
|
4236
|
+
}
|
4237
|
+
const ResizeObserver$1$1 = window.ResizeObserver || ResizeObserver$3;
|
4238
|
+
class TeleBox {
|
4239
|
+
constructor({
|
4240
|
+
id: id2 = genUID(),
|
4241
|
+
title = getBoxDefaultName(),
|
4242
|
+
namespace = "telebox",
|
4243
|
+
visible = true,
|
4244
|
+
width = 0.5,
|
4245
|
+
height = 0.5,
|
4246
|
+
minWidth = 0,
|
4247
|
+
minHeight = 0,
|
4248
|
+
x: x2 = 0.1,
|
4249
|
+
y: y2 = 0.1,
|
4250
|
+
resizable = true,
|
4251
|
+
draggable = true,
|
4252
|
+
boxRatio = -1,
|
4253
|
+
focus = false,
|
4254
|
+
zIndex = 100,
|
4255
|
+
stageRatio = null,
|
4256
|
+
enableShadowDOM = true,
|
4257
|
+
titleBar,
|
4258
|
+
content,
|
4259
|
+
stage,
|
4260
|
+
footer,
|
4261
|
+
styles: styles2,
|
4262
|
+
userStyles,
|
4263
|
+
bodyStyle = null,
|
4264
|
+
stageStyle = null,
|
4265
|
+
darkMode$,
|
4266
|
+
fence$,
|
4267
|
+
minimized$,
|
4268
|
+
maximized$,
|
4269
|
+
readonly$,
|
4270
|
+
root,
|
4271
|
+
rootRect$,
|
4272
|
+
managerStageRect$,
|
4273
|
+
managerStageRatio$,
|
4274
|
+
defaultBoxBodyStyle$,
|
4275
|
+
defaultBoxStageStyle$,
|
4276
|
+
collectorRect$
|
4277
|
+
}) {
|
4278
|
+
this.events = new Emittery();
|
4279
|
+
this._delegateEvents = new Emittery();
|
4280
|
+
this.handleTrackStart = (ev) => {
|
4281
|
+
var _a;
|
4282
|
+
return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, ev);
|
4283
|
+
};
|
4284
|
+
this._sideEffect = new SideEffectManager();
|
4285
|
+
this.id = id2;
|
4286
|
+
this.namespace = namespace;
|
4287
|
+
this.enableShadowDOM = enableShadowDOM;
|
4288
|
+
const valManager = new ValManager();
|
4289
|
+
this._sideEffect.addDisposer(() => valManager.destroy());
|
4290
|
+
const title$ = new Val(title);
|
4291
|
+
const visible$ = new Val(visible);
|
4292
|
+
const resizable$ = new Val(resizable);
|
4293
|
+
const draggable$ = new Val(draggable);
|
4294
|
+
const boxRatio$ = new Val(boxRatio);
|
4295
|
+
const zIndex$ = new Val(zIndex);
|
4296
|
+
const focus$ = new Val(focus);
|
4297
|
+
const state$ = combine([minimized$, maximized$], ([minimized, maximized]) => minimized ? TELE_BOX_STATE.Minimized : maximized ? TELE_BOX_STATE.Maximized : TELE_BOX_STATE.Normal);
|
4298
|
+
const minSize$ = new Val({
|
4299
|
+
width: clamp$1(minWidth, 0, 1),
|
4300
|
+
height: clamp$1(minHeight, 0, 1)
|
4301
|
+
}, { compare: shallowequal });
|
4302
|
+
const pxMinSize$ = combine([minSize$, managerStageRect$], ([minSize, managerStageRect]) => ({
|
4303
|
+
width: minSize.width * managerStageRect.width,
|
4304
|
+
height: minSize.height * managerStageRect.height
|
4305
|
+
}), { compare: shallowequal });
|
4306
|
+
const intrinsicSize$ = new Val({ width, height }, { compare: shallowequal });
|
4307
|
+
this._sideEffect.addDisposer(minSize$.reaction((minSize, skipUpdate) => {
|
4308
|
+
intrinsicSize$.setValue({
|
4309
|
+
width: Math.max(width, minSize.width),
|
4310
|
+
height: Math.max(height, minSize.height)
|
4311
|
+
}, skipUpdate);
|
4312
|
+
}));
|
4313
|
+
const intrinsicCoord$ = new Val({ x: x2, y: y2 }, { compare: shallowequal });
|
4314
|
+
const pxIntrinsicSize$ = combine([intrinsicSize$, managerStageRect$], ([size2, managerStageRect]) => ({
|
4315
|
+
width: managerStageRect.width * size2.width,
|
4316
|
+
height: managerStageRect.height * size2.height
|
4317
|
+
}), { compare: shallowequal });
|
4318
|
+
const pxIntrinsicCoord$ = combine([intrinsicCoord$, managerStageRect$], ([intrinsicCoord, managerStageRect]) => ({
|
4319
|
+
x: intrinsicCoord.x * managerStageRect.width,
|
4320
|
+
y: intrinsicCoord.y * managerStageRect.height
|
4321
|
+
}), { compare: shallowequal });
|
4322
|
+
const bodyStyle$ = new Val(bodyStyle);
|
4323
|
+
const stageStyle$ = new Val(stageStyle);
|
4324
|
+
const contentRoot$ = new Val(null);
|
4325
|
+
const bodyRect$ = new Val(managerStageRect$.value, {
|
4326
|
+
compare: shallowequal
|
4327
|
+
});
|
4328
|
+
const stageRatio$ = new Val(stageRatio);
|
4329
|
+
const finalStageRatio$ = combine([stageRatio$, managerStageRatio$], ([stageRatio2, managerStageRatio]) => stageRatio2 != null ? stageRatio2 : managerStageRatio);
|
4330
|
+
const stageRect$ = combine([bodyRect$, finalStageRatio$], calcStageRect, { compare: shallowequal });
|
4331
|
+
const propsValConfig = {
|
4332
|
+
darkMode: darkMode$,
|
4333
|
+
fence: fence$,
|
4334
|
+
minimized: minimized$,
|
4335
|
+
maximized: maximized$,
|
4336
|
+
readonly: readonly$,
|
4337
|
+
rootRect: rootRect$,
|
4338
|
+
managerStageRect: managerStageRect$,
|
4339
|
+
managerStageRatio: managerStageRatio$,
|
4340
|
+
defaultBoxBodyStyle: defaultBoxBodyStyle$,
|
4341
|
+
defaultBoxStageStyle: defaultBoxStageStyle$,
|
4342
|
+
collectorRect: collectorRect$
|
4343
|
+
};
|
4344
|
+
withReadonlyValueEnhancer(this, propsValConfig);
|
4345
|
+
const myReadonlyValConfig = {
|
4346
|
+
zIndex: zIndex$,
|
4347
|
+
focus: focus$,
|
4348
|
+
state: state$,
|
4349
|
+
minSize: minSize$,
|
4350
|
+
pxMinSize: pxMinSize$,
|
4351
|
+
intrinsicSize: intrinsicSize$,
|
4352
|
+
intrinsicCoord: intrinsicCoord$,
|
4353
|
+
pxIntrinsicSize: pxIntrinsicSize$,
|
4354
|
+
pxIntrinsicCoord: pxIntrinsicCoord$,
|
4355
|
+
bodyRect: bodyRect$,
|
4356
|
+
stageRect: stageRect$
|
4357
|
+
};
|
4358
|
+
withReadonlyValueEnhancer(this, myReadonlyValConfig, valManager);
|
4359
|
+
const valConfig = {
|
4360
|
+
title: title$,
|
4361
|
+
visible: visible$,
|
4362
|
+
resizable: resizable$,
|
4363
|
+
draggable: draggable$,
|
4364
|
+
boxRatio: boxRatio$,
|
4365
|
+
stageRatio: stageRatio$,
|
4366
|
+
bodyStyle: bodyStyle$,
|
4367
|
+
stageStyle: stageStyle$
|
4368
|
+
};
|
4369
|
+
withValueEnhancer(this, valConfig, valManager);
|
4370
|
+
this.titleBar = titleBar || new DefaultTitleBar({
|
4371
|
+
readonly$,
|
4372
|
+
state$,
|
4373
|
+
title$,
|
4374
|
+
namespace: this.namespace,
|
4375
|
+
onDragStart: (event) => {
|
4376
|
+
var _a;
|
4377
|
+
return (_a = this._handleTrackStart) == null ? void 0 : _a.call(this, event);
|
4378
|
+
},
|
4379
|
+
onEvent: (event) => this._delegateEvents.emit(event.type)
|
4380
|
+
});
|
4381
|
+
this._sideEffect.addDisposer(boxRatio$.subscribe((boxRatio2) => {
|
4382
|
+
if (boxRatio2 > 0) {
|
4383
|
+
this.transform(pxIntrinsicCoord$.value.x, pxIntrinsicCoord$.value.y, pxIntrinsicSize$.value.width, pxIntrinsicSize$.value.height);
|
4384
|
+
}
|
4385
|
+
}));
|
4386
|
+
this._sideEffect.addDisposer(fence$.subscribe((fence) => {
|
4387
|
+
if (fence) {
|
4388
|
+
this.move(pxIntrinsicCoord$.value.x, pxIntrinsicCoord$.value.y);
|
4389
|
+
}
|
4154
4390
|
}));
|
4155
|
-
|
4156
|
-
this.
|
4157
|
-
|
4158
|
-
|
4159
|
-
|
4160
|
-
|
4161
|
-
|
4162
|
-
|
4163
|
-
|
4164
|
-
|
4165
|
-
|
4166
|
-
|
4167
|
-
|
4168
|
-
const ve2 = (e3, t3) => {
|
4169
|
-
this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
|
4170
|
-
i3 || this.events.emit(t3, e4);
|
4391
|
+
this.$box = this._render();
|
4392
|
+
contentRoot$.setValue(this.$content.parentElement);
|
4393
|
+
content && this.mountContent(content);
|
4394
|
+
stage && this.mountStage(stage);
|
4395
|
+
footer && this.mountFooter(footer);
|
4396
|
+
styles2 && this.mountStyles(styles2);
|
4397
|
+
userStyles && this.mountUserStyles(userStyles);
|
4398
|
+
root.appendChild(this.$box);
|
4399
|
+
const watchValEvent = (val, event) => {
|
4400
|
+
this._sideEffect.addDisposer(val.reaction((v2, skipUpdate) => {
|
4401
|
+
if (!skipUpdate) {
|
4402
|
+
this.events.emit(event, v2);
|
4403
|
+
}
|
4171
4404
|
}));
|
4172
4405
|
};
|
4173
|
-
|
4174
|
-
|
4175
|
-
|
4176
|
-
|
4177
|
-
|
4178
|
-
|
4179
|
-
|
4406
|
+
watchValEvent(darkMode$, TELE_BOX_EVENT.DarkMode);
|
4407
|
+
watchValEvent(readonly$, TELE_BOX_EVENT.Readonly);
|
4408
|
+
watchValEvent(zIndex$, TELE_BOX_EVENT.ZIndex);
|
4409
|
+
watchValEvent(minimized$, TELE_BOX_EVENT.Minimized);
|
4410
|
+
watchValEvent(maximized$, TELE_BOX_EVENT.Maximized);
|
4411
|
+
watchValEvent(state$, TELE_BOX_EVENT.State);
|
4412
|
+
watchValEvent(intrinsicSize$, TELE_BOX_EVENT.IntrinsicResize);
|
4413
|
+
watchValEvent(intrinsicCoord$, TELE_BOX_EVENT.IntrinsicMove);
|
4414
|
+
this._sideEffect.addDisposer([
|
4415
|
+
visible$.reaction((visible2, skipUpdate) => {
|
4416
|
+
if (!skipUpdate && !visible2) {
|
4417
|
+
this.events.emit(TELE_BOX_EVENT.Close);
|
4418
|
+
}
|
4419
|
+
}),
|
4420
|
+
focus$.reaction((focus2, skipUpdate) => {
|
4421
|
+
if (!skipUpdate) {
|
4422
|
+
this.events.emit(focus2 ? TELE_BOX_EVENT.Focus : TELE_BOX_EVENT.Blur);
|
4423
|
+
}
|
4424
|
+
})
|
4425
|
+
]);
|
4180
4426
|
}
|
4181
4427
|
get minWidth() {
|
4182
4428
|
return this._minSize$.value.width;
|
@@ -4184,14 +4430,17 @@ class Y$3 {
|
|
4184
4430
|
get minHeight() {
|
4185
4431
|
return this._minSize$.value.height;
|
4186
4432
|
}
|
4187
|
-
setMinWidth(
|
4188
|
-
this._minSize$.setValue({ width:
|
4433
|
+
setMinWidth(minWidth, skipUpdate = false) {
|
4434
|
+
this._minSize$.setValue({ width: minWidth, height: this.minHeight }, skipUpdate);
|
4189
4435
|
}
|
4190
|
-
setMinHeight(
|
4191
|
-
this._minSize$.setValue({ width: this.minWidth, height:
|
4436
|
+
setMinHeight(minHeight, skipUpdate = false) {
|
4437
|
+
this._minSize$.setValue({ width: this.minWidth, height: minHeight }, skipUpdate);
|
4192
4438
|
}
|
4193
|
-
resize(
|
4194
|
-
this._intrinsicSize$.setValue({
|
4439
|
+
resize(width, height, skipUpdate = false) {
|
4440
|
+
this._intrinsicSize$.setValue({
|
4441
|
+
width: Math.max(width, this.minWidth),
|
4442
|
+
height: Math.max(height, this.minHeight)
|
4443
|
+
}, skipUpdate);
|
4195
4444
|
}
|
4196
4445
|
get intrinsicX() {
|
4197
4446
|
return this._intrinsicCoord$.value.x;
|
@@ -4205,388 +4454,853 @@ class Y$3 {
|
|
4205
4454
|
get intrinsicHeight() {
|
4206
4455
|
return this._intrinsicSize$.value.height;
|
4207
4456
|
}
|
4208
|
-
move(
|
4209
|
-
let
|
4210
|
-
|
4211
|
-
|
4212
|
-
|
4213
|
-
|
4214
|
-
|
4215
|
-
|
4216
|
-
}
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
|
4228
|
-
this.
|
4457
|
+
move(x2, y2, skipUpdate = false) {
|
4458
|
+
let safeX;
|
4459
|
+
let safeY;
|
4460
|
+
const managerStageRect = this.managerStageRect;
|
4461
|
+
const pxIntrinsicSize = this.pxIntrinsicSize;
|
4462
|
+
if (this.fence) {
|
4463
|
+
safeX = clamp$1(x2, 0, managerStageRect.width - pxIntrinsicSize.width);
|
4464
|
+
safeY = clamp$1(y2, 0, managerStageRect.height - pxIntrinsicSize.height);
|
4465
|
+
} else {
|
4466
|
+
safeX = clamp$1(x2, -(pxIntrinsicSize.width - 120), 0 + managerStageRect.width - 20);
|
4467
|
+
safeY = clamp$1(y2, 0, 0 + managerStageRect.height - 20);
|
4468
|
+
}
|
4469
|
+
this._intrinsicCoord$.setValue({
|
4470
|
+
x: safeX / managerStageRect.width,
|
4471
|
+
y: safeY / managerStageRect.height
|
4472
|
+
}, skipUpdate);
|
4473
|
+
}
|
4474
|
+
transform(x2, y2, width, height, skipUpdate = false) {
|
4475
|
+
const managerStageRect = this.managerStageRect;
|
4476
|
+
width = Math.max(width, this.pxMinSize.width);
|
4477
|
+
height = Math.max(height, this.pxMinSize.height);
|
4478
|
+
if (this.boxRatio > 0) {
|
4479
|
+
const newHeight = this.boxRatio * width;
|
4480
|
+
if (y2 !== this.pxIntrinsicCoord.y) {
|
4481
|
+
y2 -= newHeight - height;
|
4482
|
+
}
|
4483
|
+
height = newHeight;
|
4484
|
+
}
|
4485
|
+
if (y2 < 0) {
|
4486
|
+
y2 = 0;
|
4487
|
+
height = this.pxIntrinsicSize.height;
|
4488
|
+
}
|
4489
|
+
this.move(x2, y2, skipUpdate);
|
4490
|
+
this._intrinsicSize$.setValue({
|
4491
|
+
width: width / managerStageRect.width,
|
4492
|
+
height: height / managerStageRect.height
|
4493
|
+
}, skipUpdate);
|
4494
|
+
}
|
4495
|
+
mountContent(content) {
|
4496
|
+
var _a;
|
4497
|
+
(_a = this.$authorContent) == null ? void 0 : _a.remove();
|
4498
|
+
this.$authorContent = content;
|
4499
|
+
this.$content.appendChild(content);
|
4229
4500
|
}
|
4230
4501
|
unmountContent() {
|
4231
|
-
this
|
4502
|
+
if (this.$authorContent) {
|
4503
|
+
this.$authorContent.remove();
|
4504
|
+
this.$authorContent = void 0;
|
4505
|
+
}
|
4232
4506
|
}
|
4233
|
-
mountStage(
|
4234
|
-
|
4507
|
+
mountStage(stage) {
|
4508
|
+
var _a;
|
4509
|
+
(_a = this.$authorStage) == null ? void 0 : _a.remove();
|
4510
|
+
this.$authorStage = stage;
|
4511
|
+
if (!this.$stage) {
|
4512
|
+
this.$stage = this._renderStage();
|
4513
|
+
}
|
4514
|
+
this.$stage.appendChild(stage);
|
4515
|
+
if (!this.$stage.parentElement) {
|
4516
|
+
this.$body.appendChild(this.$stage);
|
4517
|
+
}
|
4235
4518
|
}
|
4236
4519
|
unmountStage() {
|
4237
|
-
|
4520
|
+
var _a;
|
4521
|
+
if (this.$authorStage) {
|
4522
|
+
this.$authorStage.remove();
|
4523
|
+
this.$authorStage = void 0;
|
4524
|
+
}
|
4525
|
+
(_a = this.$stage) == null ? void 0 : _a.remove();
|
4238
4526
|
}
|
4239
|
-
mountFooter(
|
4240
|
-
|
4527
|
+
mountFooter(footer) {
|
4528
|
+
var _a;
|
4529
|
+
(_a = this.$authorFooter) == null ? void 0 : _a.remove();
|
4530
|
+
this.$authorFooter = footer;
|
4531
|
+
this.$footer.appendChild(footer);
|
4241
4532
|
}
|
4242
4533
|
unmountFooter() {
|
4243
|
-
this
|
4244
|
-
|
4245
|
-
|
4246
|
-
|
4534
|
+
if (this.$authorFooter) {
|
4535
|
+
this.$authorFooter.remove();
|
4536
|
+
this.$authorFooter = void 0;
|
4537
|
+
}
|
4247
4538
|
}
|
4248
|
-
mountStyles(
|
4249
|
-
|
4250
|
-
typeof e2 == "string" ? (t2 = document.createElement("style"), t2.textContent = e2) : t2 = e2, this._$userStyles$.setValue(t2);
|
4539
|
+
mountStyles(styles2) {
|
4540
|
+
this.$styles.textContent = styles2;
|
4251
4541
|
}
|
4252
4542
|
unmountStyles() {
|
4253
|
-
this.
|
4543
|
+
this.$styles.textContent = "";
|
4254
4544
|
}
|
4255
|
-
|
4256
|
-
this.
|
4545
|
+
mountUserStyles(styles2) {
|
4546
|
+
this.$userStyles.textContent = styles2;
|
4257
4547
|
}
|
4258
|
-
|
4259
|
-
|
4548
|
+
unmountUserStyles() {
|
4549
|
+
this.$userStyles.textContent = "";
|
4550
|
+
}
|
4551
|
+
_render() {
|
4552
|
+
if (this.$box) {
|
4260
4553
|
return this.$box;
|
4261
|
-
|
4262
|
-
const
|
4263
|
-
|
4264
|
-
|
4265
|
-
|
4554
|
+
}
|
4555
|
+
const bindBoxStates = (el, disposerID) => {
|
4556
|
+
return this._sideEffect.addDisposer([
|
4557
|
+
this._readonly$.subscribe((readonly) => el.classList.toggle(this.wrapClassName("readonly"), readonly)),
|
4558
|
+
this._draggable$.subscribe((draggable) => el.classList.toggle(this.wrapClassName("no-drag"), !draggable)),
|
4559
|
+
this._resizable$.subscribe((resizable) => el.classList.toggle(this.wrapClassName("no-resize"), !resizable)),
|
4560
|
+
this._focus$.subscribe((focus) => el.classList.toggle(this.wrapClassName("blur"), !focus)),
|
4561
|
+
this._darkMode$.subscribe((darkMode) => {
|
4562
|
+
el.classList.toggle(this.wrapClassName("color-scheme-dark"), darkMode);
|
4563
|
+
el.classList.toggle(this.wrapClassName("color-scheme-light"), !darkMode);
|
4564
|
+
})
|
4565
|
+
], disposerID);
|
4566
|
+
};
|
4567
|
+
this.$box = document.createElement("div");
|
4568
|
+
this.$box.classList.add(this.wrapClassName("box"));
|
4569
|
+
bindBoxStates(this.$box, "bind-box-state");
|
4570
|
+
this._sideEffect.add(() => {
|
4571
|
+
const minimizedClassName = this.wrapClassName("minimized");
|
4572
|
+
const maximizedClassName = this.wrapClassName("maximized");
|
4573
|
+
const MAXIMIZED_TIMER_ID = "box-maximized-timer";
|
4574
|
+
return this._state$.subscribe((state) => {
|
4575
|
+
this.$box.classList.toggle(minimizedClassName, state === TELE_BOX_STATE.Minimized);
|
4576
|
+
if (state === TELE_BOX_STATE.Maximized) {
|
4577
|
+
this._sideEffect.flush(MAXIMIZED_TIMER_ID);
|
4578
|
+
this.$box.classList.toggle(maximizedClassName, true);
|
4579
|
+
} else {
|
4580
|
+
this._sideEffect.setTimeout(() => {
|
4581
|
+
this.$box.classList.toggle(maximizedClassName, false);
|
4582
|
+
}, 0, MAXIMIZED_TIMER_ID);
|
4583
|
+
}
|
4266
4584
|
});
|
4267
4585
|
});
|
4268
|
-
|
4269
|
-
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4273
|
-
|
4274
|
-
|
4275
|
-
|
4276
|
-
|
4277
|
-
|
4278
|
-
this
|
4279
|
-
|
4280
|
-
|
4281
|
-
|
4282
|
-
|
4283
|
-
|
4284
|
-
|
4285
|
-
|
4286
|
-
|
4287
|
-
|
4288
|
-
|
4289
|
-
|
4586
|
+
this._sideEffect.addDisposer(this._visible$.subscribe((visible) => {
|
4587
|
+
this.$box.style.display = visible ? "block" : "none";
|
4588
|
+
}));
|
4589
|
+
this._sideEffect.addDisposer(this._zIndex$.subscribe((zIndex) => {
|
4590
|
+
this.$box.style.zIndex = String(zIndex);
|
4591
|
+
}));
|
4592
|
+
this.$box.dataset.teleBoxID = this.id;
|
4593
|
+
const boxStyler = index(this.$box);
|
4594
|
+
const boxStyles$ = combine([
|
4595
|
+
this._maximized$,
|
4596
|
+
this._minimized$,
|
4597
|
+
this._pxIntrinsicSize$,
|
4598
|
+
this._pxIntrinsicCoord$,
|
4599
|
+
this._collectorRect$,
|
4600
|
+
this._rootRect$,
|
4601
|
+
this._managerStageRect$
|
4602
|
+
], ([
|
4603
|
+
maximized,
|
4604
|
+
minimized,
|
4605
|
+
pxIntrinsicSize,
|
4606
|
+
pxIntrinsicCoord,
|
4607
|
+
collectorRect,
|
4608
|
+
rootRect,
|
4609
|
+
managerStageRect
|
4610
|
+
]) => {
|
4611
|
+
const styles2 = maximized ? {
|
4612
|
+
x: -managerStageRect.x,
|
4613
|
+
y: -managerStageRect.y,
|
4614
|
+
width: rootRect.width,
|
4615
|
+
height: rootRect.height,
|
4616
|
+
scaleX: 1,
|
4617
|
+
scaleY: 1
|
4618
|
+
} : {
|
4619
|
+
x: pxIntrinsicCoord.x,
|
4620
|
+
y: pxIntrinsicCoord.y,
|
4621
|
+
width: pxIntrinsicSize.width,
|
4622
|
+
height: pxIntrinsicSize.height,
|
4623
|
+
scaleX: 1,
|
4624
|
+
scaleY: 1
|
4625
|
+
};
|
4626
|
+
if (minimized && collectorRect) {
|
4627
|
+
const { width: boxWidth, height: boxHeight } = maximized ? this.rootRect : pxIntrinsicSize;
|
4628
|
+
styles2.x = collectorRect.x - boxWidth / 2 + collectorRect.width / 2 - managerStageRect.x;
|
4629
|
+
styles2.y = collectorRect.y - boxHeight / 2 + collectorRect.height / 2 - managerStageRect.y;
|
4630
|
+
styles2.scaleX = collectorRect.width / boxWidth;
|
4631
|
+
styles2.scaleY = collectorRect.height / boxHeight;
|
4632
|
+
}
|
4633
|
+
return styles2;
|
4634
|
+
}, { compare: shallowequal });
|
4635
|
+
const boxStyles = boxStyles$.value;
|
4636
|
+
this.$box.style.width = boxStyles.width + "px";
|
4637
|
+
this.$box.style.height = boxStyles.height + "px";
|
4638
|
+
this.$box.style.transform = `translate(${boxStyles.x - 10}px,${boxStyles.y - 10}px)`;
|
4639
|
+
this._sideEffect.addDisposer(boxStyles$.subscribe((styles2) => {
|
4640
|
+
boxStyler.set(styles2);
|
4290
4641
|
}));
|
4291
|
-
const
|
4292
|
-
|
4293
|
-
|
4294
|
-
|
4295
|
-
|
4296
|
-
|
4297
|
-
|
4298
|
-
|
4299
|
-
|
4300
|
-
|
4301
|
-
|
4642
|
+
const $boxMain = document.createElement("div");
|
4643
|
+
$boxMain.className = this.wrapClassName("box-main");
|
4644
|
+
this.$box.appendChild($boxMain);
|
4645
|
+
const $titleBar = document.createElement("div");
|
4646
|
+
$titleBar.className = this.wrapClassName("titlebar-wrap");
|
4647
|
+
$titleBar.appendChild(this.titleBar.render());
|
4648
|
+
this.$titleBar = $titleBar;
|
4649
|
+
const $body = document.createElement("div");
|
4650
|
+
$body.className = this.wrapClassName("body-wrap");
|
4651
|
+
this.$body = $body;
|
4652
|
+
const $styles = document.createElement("style");
|
4653
|
+
this.$styles = $styles;
|
4654
|
+
$body.appendChild($styles);
|
4655
|
+
const $userStyles = document.createElement("style");
|
4656
|
+
this.$userStyles = $userStyles;
|
4657
|
+
$body.appendChild($userStyles);
|
4658
|
+
const $content = document.createElement("div");
|
4659
|
+
$content.className = this.wrapClassName("content") + " tele-fancy-scrollbar";
|
4660
|
+
this.$content = $content;
|
4661
|
+
this._sideEffect.addDisposer(combine([this._bodyStyle$, this._defaultBoxBodyStyle$], ([bodyStyle, defaultBoxBodyStyle]) => bodyStyle != null ? bodyStyle : defaultBoxBodyStyle).subscribe((style2) => $content.style.cssText = style2 || ""));
|
4662
|
+
$body.appendChild($content);
|
4663
|
+
const $footer = document.createElement("div");
|
4664
|
+
$footer.className = this.wrapClassName("footer-wrap");
|
4665
|
+
this.$footer = $footer;
|
4666
|
+
$boxMain.appendChild($titleBar);
|
4667
|
+
const $main = document.createElement("div");
|
4668
|
+
$main.className = this.wrapClassName("main");
|
4669
|
+
this.$main = $main;
|
4670
|
+
$boxMain.appendChild($main);
|
4671
|
+
const $quarantineOuter = document.createElement("div");
|
4672
|
+
$quarantineOuter.className = this.wrapClassName("quarantine-outer");
|
4673
|
+
$main.appendChild($quarantineOuter);
|
4674
|
+
const $quarantine = document.createElement("div");
|
4675
|
+
$quarantine.className = this.wrapClassName("quarantine");
|
4676
|
+
$quarantine.appendChild($body);
|
4677
|
+
$quarantine.appendChild($footer);
|
4678
|
+
if (this.enableShadowDOM) {
|
4679
|
+
bindBoxStates($quarantine, "bind-quarantine-state");
|
4680
|
+
const $shadowStyle = document.createElement("style");
|
4681
|
+
$shadowStyle.textContent = shadowStyles;
|
4682
|
+
$quarantine.insertBefore($shadowStyle, $quarantine.firstChild);
|
4683
|
+
const shadow = $quarantineOuter.attachShadow({ mode: "open" });
|
4684
|
+
shadow.appendChild($quarantine);
|
4685
|
+
} else {
|
4686
|
+
$quarantineOuter.appendChild($quarantine);
|
4687
|
+
}
|
4688
|
+
this._renderResizeHandlers();
|
4689
|
+
const updateBodyRect = () => {
|
4690
|
+
const rect = $body.getBoundingClientRect();
|
4691
|
+
this._bodyRect$.setValue({
|
4692
|
+
x: 0,
|
4693
|
+
y: 0,
|
4694
|
+
width: rect.width,
|
4695
|
+
height: rect.height
|
4696
|
+
});
|
4302
4697
|
};
|
4303
4698
|
this._sideEffect.add(() => {
|
4304
|
-
const
|
4305
|
-
this.minimized
|
4306
|
-
|
4307
|
-
|
4308
|
-
}), this._sideEffect.addDisposer(this._minimized$.reaction((e3) => {
|
4309
|
-
e3 || this._sideEffect.setTimeout(h, 400, "minimized-content-rect-fix");
|
4310
|
-
})), this._sideEffect.add(() => {
|
4311
|
-
let e3;
|
4312
|
-
return this._$userStyles$.subscribe((t3) => {
|
4313
|
-
e3 && e3.remove(), e3 = t3, t3 && o2.appendChild(t3);
|
4314
|
-
});
|
4315
|
-
}), this._sideEffect.add(() => {
|
4316
|
-
let e3;
|
4317
|
-
return this._$userContent$.subscribe((t3) => {
|
4318
|
-
e3 && e3.remove(), e3 = t3, t3 && r2.appendChild(t3);
|
4319
|
-
});
|
4320
|
-
}), this._sideEffect.add(() => {
|
4321
|
-
let e3;
|
4322
|
-
return this._$userStage$.subscribe((t3) => {
|
4323
|
-
var i3;
|
4324
|
-
if (e3 && e3.remove(), e3 = t3, t3) {
|
4325
|
-
if (!this.$stage) {
|
4326
|
-
const e4 = document.createElement("div");
|
4327
|
-
this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
|
4328
|
-
e4.style.top = t4.y + "px", e4.style.left = t4.x + "px", e4.style.width = t4.width + "px", e4.style.height = t4.height + "px";
|
4329
|
-
}), "content-stage-rect"), r2.appendChild(e4);
|
4330
|
-
}
|
4331
|
-
this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
|
4332
|
-
} else
|
4333
|
-
((i3 = this.$stage) == null ? void 0 : i3.parentElement) && this.$stage.remove();
|
4334
|
-
});
|
4335
|
-
}), o2.appendChild(r2);
|
4336
|
-
const c = document.createElement("div");
|
4337
|
-
return c.className = this.wrapClassName("footer-wrap"), this.$footer = c, this._sideEffect.add(() => {
|
4338
|
-
let e3;
|
4339
|
-
return this._$userFooter$.subscribe((t3) => {
|
4340
|
-
e3 && e3.remove(), e3 = t3, t3 && c.appendChild(t3);
|
4699
|
+
const observer = new ResizeObserver$1$1(() => {
|
4700
|
+
if (!this.minimized) {
|
4701
|
+
updateBodyRect();
|
4702
|
+
}
|
4341
4703
|
});
|
4342
|
-
|
4704
|
+
observer.observe($body);
|
4705
|
+
return () => observer.disconnect();
|
4706
|
+
});
|
4707
|
+
this._sideEffect.addDisposer(this._minimized$.reaction((minimized) => {
|
4708
|
+
if (!minimized) {
|
4709
|
+
this._sideEffect.setTimeout(updateBodyRect, 400, "minimized-content-rect-fix");
|
4710
|
+
}
|
4711
|
+
}));
|
4712
|
+
return this.$box;
|
4713
|
+
}
|
4714
|
+
_renderStage() {
|
4715
|
+
const $stage = document.createElement("div");
|
4716
|
+
$stage.className = this.wrapClassName("box-stage");
|
4717
|
+
const updateStageRect = (stageRect) => {
|
4718
|
+
$stage.style.top = stageRect.y + "px";
|
4719
|
+
$stage.style.left = stageRect.x + "px";
|
4720
|
+
$stage.style.width = stageRect.width + "px";
|
4721
|
+
$stage.style.height = stageRect.height + "px";
|
4722
|
+
};
|
4723
|
+
this._sideEffect.addDisposer([
|
4724
|
+
combine([this._stageStyle$, this._defaultBoxStageStyle$], ([stageStyle, defaultBoxStageStyle]) => stageStyle != null ? stageStyle : defaultBoxStageStyle).subscribe((styles2) => {
|
4725
|
+
$stage.style.cssText = styles2 || "";
|
4726
|
+
updateStageRect(this._stageRect$.value);
|
4727
|
+
}),
|
4728
|
+
this._stageRect$.subscribe(updateStageRect)
|
4729
|
+
], "box-stage-styles");
|
4730
|
+
return $stage;
|
4343
4731
|
}
|
4344
4732
|
_renderResizeHandlers() {
|
4345
|
-
const
|
4346
|
-
|
4347
|
-
|
4348
|
-
|
4349
|
-
|
4350
|
-
|
4351
|
-
|
4352
|
-
|
4353
|
-
|
4733
|
+
const $resizeHandles = document.createElement("div");
|
4734
|
+
$resizeHandles.className = this.wrapClassName("resize-handles");
|
4735
|
+
Object.values(TELE_BOX_RESIZE_HANDLE).forEach((handleType) => {
|
4736
|
+
const $handle = document.createElement("div");
|
4737
|
+
$handle.className = this.wrapClassName(handleType) + " " + this.wrapClassName("resize-handle");
|
4738
|
+
$handle.dataset.teleBoxHandle = handleType;
|
4739
|
+
$resizeHandles.appendChild($handle);
|
4740
|
+
});
|
4741
|
+
this.$box.appendChild($resizeHandles);
|
4742
|
+
const TRACKING_DISPOSER_ID = "handle-tracking-listener";
|
4743
|
+
const transformingClassName = this.wrapClassName("transforming");
|
4744
|
+
let $trackMask;
|
4745
|
+
let trackStartX = 0;
|
4746
|
+
let trackStartY = 0;
|
4747
|
+
let trackStartWidth = 0;
|
4748
|
+
let trackStartHeight = 0;
|
4749
|
+
let trackStartPageX = 0;
|
4750
|
+
let trackStartPageY = 0;
|
4751
|
+
let trackingHandle;
|
4752
|
+
const handleTracking = (ev) => {
|
4753
|
+
if (!ev.isPrimary || this.state !== TELE_BOX_STATE.Normal) {
|
4354
4754
|
return;
|
4355
|
-
|
4356
|
-
|
4357
|
-
|
4358
|
-
|
4359
|
-
|
4360
|
-
|
4361
|
-
|
4362
|
-
|
4755
|
+
}
|
4756
|
+
preventEvent$1(ev);
|
4757
|
+
let { pageX, pageY } = ev;
|
4758
|
+
if (pageY < 0) {
|
4759
|
+
pageY = 0;
|
4760
|
+
}
|
4761
|
+
const offsetX = pageX - trackStartPageX;
|
4762
|
+
const offsetY = pageY - trackStartPageY;
|
4763
|
+
let { x: newX, y: newY } = this.pxIntrinsicCoord;
|
4764
|
+
let { width: newWidth, height: newHeight } = this.pxIntrinsicSize;
|
4765
|
+
switch (trackingHandle) {
|
4766
|
+
case TELE_BOX_RESIZE_HANDLE.North: {
|
4767
|
+
newY = trackStartY + offsetY;
|
4768
|
+
newHeight = trackStartHeight - offsetY;
|
4363
4769
|
break;
|
4364
|
-
|
4365
|
-
|
4770
|
+
}
|
4771
|
+
case TELE_BOX_RESIZE_HANDLE.South: {
|
4772
|
+
newHeight = trackStartHeight + offsetY;
|
4366
4773
|
break;
|
4367
|
-
|
4368
|
-
|
4774
|
+
}
|
4775
|
+
case TELE_BOX_RESIZE_HANDLE.West: {
|
4776
|
+
newX = trackStartX + offsetX;
|
4777
|
+
newWidth = trackStartWidth - offsetX;
|
4369
4778
|
break;
|
4370
|
-
|
4371
|
-
|
4779
|
+
}
|
4780
|
+
case TELE_BOX_RESIZE_HANDLE.East: {
|
4781
|
+
newWidth = trackStartWidth + offsetX;
|
4372
4782
|
break;
|
4373
|
-
|
4374
|
-
|
4783
|
+
}
|
4784
|
+
case TELE_BOX_RESIZE_HANDLE.NorthWest: {
|
4785
|
+
newX = trackStartX + offsetX;
|
4786
|
+
newY = trackStartY + offsetY;
|
4787
|
+
newWidth = trackStartWidth - offsetX;
|
4788
|
+
newHeight = trackStartHeight - offsetY;
|
4375
4789
|
break;
|
4376
|
-
|
4377
|
-
|
4790
|
+
}
|
4791
|
+
case TELE_BOX_RESIZE_HANDLE.NorthEast: {
|
4792
|
+
newY = trackStartY + offsetY;
|
4793
|
+
newWidth = trackStartWidth + offsetX;
|
4794
|
+
newHeight = trackStartHeight - offsetY;
|
4378
4795
|
break;
|
4379
|
-
|
4380
|
-
|
4796
|
+
}
|
4797
|
+
case TELE_BOX_RESIZE_HANDLE.SouthEast: {
|
4798
|
+
newWidth = trackStartWidth + offsetX;
|
4799
|
+
newHeight = trackStartHeight + offsetY;
|
4381
4800
|
break;
|
4382
|
-
|
4383
|
-
|
4801
|
+
}
|
4802
|
+
case TELE_BOX_RESIZE_HANDLE.SouthWest: {
|
4803
|
+
newX = trackStartX + offsetX;
|
4804
|
+
newWidth = trackStartWidth - offsetX;
|
4805
|
+
newHeight = trackStartHeight + offsetY;
|
4384
4806
|
break;
|
4385
|
-
|
4386
|
-
|
4387
|
-
|
4388
|
-
|
4389
|
-
|
4390
|
-
|
4391
|
-
|
4392
|
-
|
4393
|
-
|
4807
|
+
}
|
4808
|
+
default: {
|
4809
|
+
this.move(trackStartX + offsetX, trackStartY + offsetY);
|
4810
|
+
return;
|
4811
|
+
}
|
4812
|
+
}
|
4813
|
+
this.transform(newX, newY, newWidth, newHeight);
|
4814
|
+
};
|
4815
|
+
const handleTrackEnd = (ev) => {
|
4816
|
+
if (!ev.isPrimary) {
|
4394
4817
|
return;
|
4395
|
-
|
4818
|
+
}
|
4819
|
+
trackingHandle = void 0;
|
4820
|
+
if (!$trackMask) {
|
4396
4821
|
return;
|
4397
|
-
|
4822
|
+
}
|
4823
|
+
preventEvent$1(ev);
|
4824
|
+
this.$box.classList.toggle(transformingClassName, false);
|
4825
|
+
this._sideEffect.flush(TRACKING_DISPOSER_ID);
|
4826
|
+
$trackMask.remove();
|
4827
|
+
};
|
4828
|
+
const handleTrackStart = (ev) => {
|
4829
|
+
var _a;
|
4830
|
+
if (!ev.isPrimary || this.readonly) {
|
4831
|
+
return;
|
4832
|
+
}
|
4833
|
+
if (ev.button != null && ev.button !== 0) {
|
4398
4834
|
return;
|
4399
|
-
|
4400
|
-
if (
|
4401
|
-
|
4402
|
-
|
4403
|
-
|
4404
|
-
|
4405
|
-
|
4835
|
+
}
|
4836
|
+
if (!this.draggable || trackingHandle || this.state !== TELE_BOX_STATE.Normal) {
|
4837
|
+
return;
|
4838
|
+
}
|
4839
|
+
const target = ev.target;
|
4840
|
+
if ((_a = target.dataset) == null ? void 0 : _a.teleBoxHandle) {
|
4841
|
+
preventEvent$1(ev);
|
4842
|
+
({ x: trackStartX, y: trackStartY } = this.pxIntrinsicCoord);
|
4843
|
+
({ width: trackStartWidth, height: trackStartHeight } = this.pxIntrinsicSize);
|
4844
|
+
({ pageX: trackStartPageX, pageY: trackStartPageY } = ev);
|
4845
|
+
trackingHandle = target.dataset.teleBoxHandle;
|
4846
|
+
if (!$trackMask) {
|
4847
|
+
$trackMask = document.createElement("div");
|
4848
|
+
}
|
4849
|
+
const cursor = trackingHandle ? this.wrapClassName(`cursor-${trackingHandle}`) : "";
|
4850
|
+
$trackMask.className = this.wrapClassName(`track-mask${cursor ? ` ${cursor}` : ""}`);
|
4851
|
+
this.$box.appendChild($trackMask);
|
4852
|
+
this.$box.classList.add(transformingClassName);
|
4853
|
+
this._sideEffect.add(() => {
|
4854
|
+
window.addEventListener("pointermove", handleTracking, {
|
4855
|
+
passive: false
|
4856
|
+
});
|
4857
|
+
window.addEventListener("pointerup", handleTrackEnd, {
|
4858
|
+
passive: false
|
4859
|
+
});
|
4860
|
+
window.addEventListener("pointercancel", handleTrackEnd, {
|
4861
|
+
passive: false
|
4862
|
+
});
|
4863
|
+
return () => {
|
4864
|
+
window.removeEventListener("pointermove", handleTracking);
|
4865
|
+
window.removeEventListener("pointerup", handleTrackEnd);
|
4866
|
+
window.removeEventListener("pointercancel", handleTrackEnd);
|
4867
|
+
};
|
4868
|
+
}, TRACKING_DISPOSER_ID);
|
4406
4869
|
}
|
4407
4870
|
};
|
4408
|
-
this._handleTrackStart =
|
4871
|
+
this._handleTrackStart = handleTrackStart;
|
4872
|
+
this._sideEffect.addEventListener($resizeHandles, "pointerdown", handleTrackStart, {}, "box-resizeHandles-pointerdown");
|
4409
4873
|
}
|
4410
4874
|
async destroy() {
|
4411
|
-
this.$box.remove()
|
4412
|
-
|
4413
|
-
|
4414
|
-
|
4415
|
-
|
4416
|
-
|
4417
|
-
|
4418
|
-
|
4419
|
-
|
4420
|
-
|
4421
|
-
|
4422
|
-
|
4423
|
-
|
4424
|
-
|
4425
|
-
|
4426
|
-
|
4427
|
-
|
4428
|
-
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4433
|
-
|
4434
|
-
|
4435
|
-
|
4436
|
-
|
4437
|
-
|
4438
|
-
|
4439
|
-
|
4440
|
-
|
4441
|
-
|
4442
|
-
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4875
|
+
this.$box.remove();
|
4876
|
+
this._sideEffect.flushAll();
|
4877
|
+
this._sideEffect.flushAll();
|
4878
|
+
await this.events.emit(TELE_BOX_EVENT.Destroyed);
|
4879
|
+
this.events.clearListeners();
|
4880
|
+
this._delegateEvents.clearListeners();
|
4881
|
+
}
|
4882
|
+
wrapClassName(className) {
|
4883
|
+
return `${this.namespace}-${className}`;
|
4884
|
+
}
|
4885
|
+
}
|
4886
|
+
var collectorSVG = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOCAxNiI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIHN0cm9rZT0iIzdCODhBMCIgc3Ryb2tlLXdpZHRoPSIxLjQiIGQ9Ik0uNyAxLjJoMTYuNnYxMy42SC43eiIgLz4KICAgICAgICA8cGF0aCBmaWxsPSIjN0I4OEEwIiBkPSJNNCA1LjVoNnYxLjRINHpNNCA5LjVoMTB2MS40SDR6IiAvPgogICAgPC9nPgo8L3N2Zz4K";
|
4887
|
+
class TeleBoxCollector {
|
4888
|
+
constructor({
|
4889
|
+
minimized$,
|
4890
|
+
readonly$,
|
4891
|
+
darkMode$,
|
4892
|
+
namespace = "telebox",
|
4893
|
+
styles: styles2 = {},
|
4894
|
+
root$
|
4895
|
+
}) {
|
4896
|
+
this._sideEffect = new SideEffectManager();
|
4897
|
+
this.namespace = namespace;
|
4898
|
+
const valManager = new ValManager();
|
4899
|
+
this._sideEffect.addDisposer(() => valManager.destroy());
|
4900
|
+
const rect$ = new Val(void 0);
|
4901
|
+
const visible$ = derive(minimized$);
|
4902
|
+
const styles$ = new Val(styles2);
|
4903
|
+
const el$ = new Val(document.createElement("button"));
|
4904
|
+
const valConfig = {
|
4905
|
+
styles: styles$,
|
4906
|
+
$collector: el$
|
4907
|
+
};
|
4908
|
+
withValueEnhancer(this, valConfig, valManager);
|
4909
|
+
const propsValConfig = {
|
4910
|
+
root: root$
|
4911
|
+
};
|
4912
|
+
withReadonlyValueEnhancer(this, propsValConfig);
|
4913
|
+
const myReadonlyValConfig = {
|
4914
|
+
rect: rect$,
|
4915
|
+
visible: visible$
|
4916
|
+
};
|
4917
|
+
withReadonlyValueEnhancer(this, myReadonlyValConfig, valManager);
|
4918
|
+
el$.value.className = this.wrapClassName("collector");
|
4919
|
+
el$.value.style.backgroundImage = `url('${collectorSVG}')`;
|
4920
|
+
this._sideEffect.addDisposer(el$.subscribe(($collector) => {
|
4921
|
+
this._sideEffect.addEventListener($collector, "pointerup", (ev) => {
|
4922
|
+
if (ev.isPrimary && !readonly$.value) {
|
4923
|
+
minimized$.setValue(false);
|
4924
|
+
}
|
4925
|
+
}, {}, "telebox-collector-click");
|
4926
|
+
this._sideEffect.addDisposer([
|
4927
|
+
visible$.subscribe((visible) => {
|
4928
|
+
$collector.classList.toggle(this.wrapClassName("collector-visible"), visible);
|
4929
|
+
}),
|
4930
|
+
readonly$.subscribe((readonly) => {
|
4931
|
+
$collector.classList.toggle(this.wrapClassName("collector-readonly"), readonly);
|
4932
|
+
}),
|
4933
|
+
darkMode$.subscribe((darkMode) => {
|
4934
|
+
$collector.classList.toggle(this.wrapClassName("color-scheme-dark"), darkMode);
|
4935
|
+
$collector.classList.toggle(this.wrapClassName("color-scheme-light"), !darkMode);
|
4936
|
+
}),
|
4937
|
+
styles$.subscribe((styles22) => {
|
4938
|
+
Object.keys(styles22).forEach((key) => {
|
4939
|
+
const value = styles22[key];
|
4940
|
+
if (value != null) {
|
4941
|
+
$collector.style[key] = value;
|
4942
|
+
}
|
4943
|
+
});
|
4944
|
+
}),
|
4945
|
+
root$.subscribe((root) => {
|
4946
|
+
if (root) {
|
4947
|
+
root.appendChild($collector);
|
4948
|
+
}
|
4949
|
+
}),
|
4950
|
+
combine([minimized$, root$]).subscribe(([minimized, root]) => {
|
4951
|
+
if (minimized && root) {
|
4952
|
+
const { x: x2, y: y2, width, height } = $collector.getBoundingClientRect();
|
4953
|
+
const rootRect = root.getBoundingClientRect();
|
4954
|
+
rect$.setValue({
|
4955
|
+
x: x2 - rootRect.x,
|
4956
|
+
y: y2 - rootRect.y,
|
4957
|
+
width,
|
4958
|
+
height
|
4959
|
+
});
|
4960
|
+
}
|
4961
|
+
})
|
4962
|
+
], "telebox-collector-el");
|
4448
4963
|
}));
|
4449
4964
|
}
|
4450
4965
|
destroy() {
|
4451
4966
|
this._sideEffect.flushAll();
|
4452
4967
|
}
|
4453
|
-
wrapClassName(
|
4454
|
-
return `${this.namespace}-${
|
4968
|
+
wrapClassName(className) {
|
4969
|
+
return `${this.namespace}-${className}`;
|
4455
4970
|
}
|
4456
4971
|
}
|
4457
|
-
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4463
|
-
|
4972
|
+
var TELE_BOX_MANAGER_EVENT = /* @__PURE__ */ ((TELE_BOX_MANAGER_EVENT2) => {
|
4973
|
+
TELE_BOX_MANAGER_EVENT2["Focused"] = "focused";
|
4974
|
+
TELE_BOX_MANAGER_EVENT2["Blurred"] = "blurred";
|
4975
|
+
TELE_BOX_MANAGER_EVENT2["Created"] = "created";
|
4976
|
+
TELE_BOX_MANAGER_EVENT2["Removed"] = "removed";
|
4977
|
+
TELE_BOX_MANAGER_EVENT2["State"] = "state";
|
4978
|
+
TELE_BOX_MANAGER_EVENT2["Maximized"] = "maximized";
|
4979
|
+
TELE_BOX_MANAGER_EVENT2["Minimized"] = "minimized";
|
4980
|
+
TELE_BOX_MANAGER_EVENT2["IntrinsicMove"] = "intrinsic_move";
|
4981
|
+
TELE_BOX_MANAGER_EVENT2["IntrinsicResize"] = "intrinsic_resize";
|
4982
|
+
TELE_BOX_MANAGER_EVENT2["ZIndex"] = "z_index";
|
4983
|
+
TELE_BOX_MANAGER_EVENT2["PrefersColorScheme"] = "prefers_color_scheme";
|
4984
|
+
TELE_BOX_MANAGER_EVENT2["DarkMode"] = "dark_mode";
|
4985
|
+
return TELE_BOX_MANAGER_EVENT2;
|
4986
|
+
})(TELE_BOX_MANAGER_EVENT || {});
|
4987
|
+
class MaxTitleBar extends DefaultTitleBar {
|
4988
|
+
constructor(config) {
|
4989
|
+
super(config);
|
4990
|
+
this.boxes$ = config.boxes$;
|
4991
|
+
this.rootRect$ = config.rootRect$;
|
4992
|
+
this.darkMode$ = config.darkMode$;
|
4993
|
+
config.root.appendChild(this.render());
|
4464
4994
|
}
|
4465
|
-
focusBox(
|
4466
|
-
var
|
4467
|
-
if (
|
4468
|
-
|
4469
|
-
|
4470
|
-
|
4471
|
-
|
4472
|
-
|
4995
|
+
focusBox(box) {
|
4996
|
+
var _a;
|
4997
|
+
if (this.focusedBox && this.focusedBox === box) {
|
4998
|
+
return;
|
4999
|
+
}
|
5000
|
+
if (this.$titles && this.state$.value === TELE_BOX_STATE.Maximized) {
|
5001
|
+
const { children: children2 } = this.$titles.firstElementChild;
|
5002
|
+
for (let i2 = children2.length - 1; i2 >= 0; i2 -= 1) {
|
5003
|
+
const $tab = children2[i2];
|
5004
|
+
const id2 = (_a = $tab.dataset) == null ? void 0 : _a.teleBoxID;
|
5005
|
+
if (id2) {
|
5006
|
+
if (box && id2 === box.id) {
|
5007
|
+
$tab.classList.toggle(this.wrapClassName("titles-tab-focus"), true);
|
5008
|
+
} else if (this.focusedBox && id2 === this.focusedBox.id) {
|
5009
|
+
$tab.classList.toggle(this.wrapClassName("titles-tab-focus"), false);
|
5010
|
+
}
|
4473
5011
|
}
|
4474
5012
|
}
|
4475
|
-
this.focusedBox = e2;
|
4476
5013
|
}
|
5014
|
+
this.focusedBox = box;
|
4477
5015
|
}
|
4478
5016
|
render() {
|
4479
|
-
if (this.$titleBar)
|
5017
|
+
if (this.$titleBar) {
|
4480
5018
|
return this.$titleBar;
|
4481
|
-
|
4482
|
-
|
4483
|
-
|
4484
|
-
|
4485
|
-
|
4486
|
-
|
4487
|
-
|
4488
|
-
|
4489
|
-
|
4490
|
-
|
4491
|
-
|
4492
|
-
|
5019
|
+
}
|
5020
|
+
const $titleBar = super.render();
|
5021
|
+
$titleBar.classList.add(this.wrapClassName("max-titlebar"));
|
5022
|
+
this.sideEffect.addDisposer([
|
5023
|
+
this.state$.subscribe((state) => {
|
5024
|
+
$titleBar.classList.toggle(this.wrapClassName("max-titlebar-maximized"), state === TELE_BOX_STATE.Maximized);
|
5025
|
+
}),
|
5026
|
+
this.readonly$.subscribe((readonly) => {
|
5027
|
+
$titleBar.classList.toggle(this.wrapClassName("readonly"), readonly);
|
5028
|
+
}),
|
5029
|
+
combine([this.state$, this.boxes$]).subscribe(([state, titles]) => {
|
5030
|
+
if (state === TELE_BOX_STATE.Maximized) {
|
5031
|
+
$titleBar.classList.toggle(this.wrapClassName("max-titlebar-single-title"), titles.length === 1);
|
5032
|
+
if (titles.length !== 1) {
|
5033
|
+
$titleBar.replaceChild(this.renderTitles(), $titleBar.firstElementChild);
|
5034
|
+
}
|
5035
|
+
}
|
5036
|
+
})
|
5037
|
+
], "max-render");
|
5038
|
+
const $titlesArea = document.createElement("div");
|
5039
|
+
$titlesArea.classList.add(this.wrapClassName("titles-area"));
|
5040
|
+
$titleBar.insertBefore($titlesArea, $titleBar.firstElementChild);
|
5041
|
+
return $titleBar;
|
4493
5042
|
}
|
4494
5043
|
destroy() {
|
4495
|
-
super.destroy()
|
5044
|
+
super.destroy();
|
5045
|
+
this.$titles = void 0;
|
5046
|
+
this.focusedBox = void 0;
|
4496
5047
|
}
|
4497
5048
|
renderTitles() {
|
4498
|
-
this.$titles = document.createElement("div")
|
4499
|
-
|
5049
|
+
this.$titles = document.createElement("div");
|
5050
|
+
this.$titles.className = this.wrapClassName("titles");
|
5051
|
+
this.sideEffect.addEventListener(this.$titles, "wheel", (ev) => {
|
5052
|
+
ev.currentTarget.scrollBy({
|
5053
|
+
left: ev.deltaY > 0 ? 250 : -250,
|
5054
|
+
behavior: "smooth"
|
5055
|
+
});
|
4500
5056
|
}, { passive: false }, "max-render-wheel-titles");
|
4501
|
-
const
|
4502
|
-
|
4503
|
-
|
4504
|
-
|
4505
|
-
|
5057
|
+
const $content = document.createElement("div");
|
5058
|
+
$content.className = this.wrapClassName("titles-content");
|
5059
|
+
this.$titles.appendChild($content);
|
5060
|
+
const disposers = this.boxes$.value.map((box) => {
|
5061
|
+
const $tab = document.createElement("button");
|
5062
|
+
$tab.className = this.wrapClassName("titles-tab");
|
5063
|
+
$tab.textContent = box.title;
|
5064
|
+
$tab.dataset.teleBoxID = box.id;
|
5065
|
+
$tab.dataset.teleTitleBarNoDblClick = "true";
|
5066
|
+
if (this.focusedBox && box.id === this.focusedBox.id) {
|
5067
|
+
$tab.classList.add(this.wrapClassName("titles-tab-focus"));
|
5068
|
+
}
|
5069
|
+
$content.appendChild($tab);
|
5070
|
+
return box._title$.reaction((title) => $tab.textContent = title);
|
4506
5071
|
});
|
4507
|
-
|
5072
|
+
this.sideEffect.addDisposer(() => disposers.forEach((disposer) => disposer()), "max-render-tab-titles");
|
5073
|
+
return this.$titles;
|
4508
5074
|
}
|
4509
5075
|
}
|
4510
|
-
const
|
4511
|
-
class
|
4512
|
-
constructor({
|
4513
|
-
|
4514
|
-
|
4515
|
-
|
4516
|
-
|
4517
|
-
|
5076
|
+
const ResizeObserver$2 = window.ResizeObserver || ResizeObserver$3;
|
5077
|
+
class TeleBoxManager {
|
5078
|
+
constructor({
|
5079
|
+
root = null,
|
5080
|
+
prefersColorScheme = TELE_BOX_COLOR_SCHEME.Light,
|
5081
|
+
minimized = false,
|
5082
|
+
maximized = false,
|
5083
|
+
fence = true,
|
5084
|
+
collector,
|
5085
|
+
namespace = "telebox",
|
5086
|
+
readonly = false,
|
5087
|
+
stageRatio = -1,
|
5088
|
+
containerStyle = "",
|
5089
|
+
stageStyle = "",
|
5090
|
+
defaultBoxBodyStyle = null,
|
5091
|
+
defaultBoxStageStyle = null
|
5092
|
+
} = {}) {
|
5093
|
+
this.events = new Emittery();
|
5094
|
+
this._sideEffect = new SideEffectManager();
|
5095
|
+
this.namespace = namespace;
|
5096
|
+
const valManager = new ValManager();
|
5097
|
+
this._sideEffect.addDisposer(() => valManager.destroy());
|
5098
|
+
const root$ = new Val(root);
|
5099
|
+
const readonly$ = new Val(readonly);
|
5100
|
+
const minimized$ = new Val(minimized);
|
5101
|
+
const maximized$ = new Val(maximized);
|
5102
|
+
const fence$ = new Val(fence);
|
5103
|
+
const containerStyle$ = new Val(containerStyle);
|
5104
|
+
const stageStyle$ = new Val(stageStyle);
|
5105
|
+
const stageRatio$ = new Val(stageRatio);
|
5106
|
+
const defaultBoxBodyStyle$ = new Val(defaultBoxBodyStyle);
|
5107
|
+
const defaultBoxStageStyle$ = new Val(defaultBoxStageStyle);
|
5108
|
+
const rootRect$ = new Val({
|
5109
|
+
x: 0,
|
5110
|
+
y: 0,
|
5111
|
+
width: window.innerWidth,
|
5112
|
+
height: window.innerHeight
|
5113
|
+
}, { compare: shallowequal });
|
5114
|
+
this._sideEffect.addDisposer(root$.subscribe((root2) => {
|
4518
5115
|
this._sideEffect.add(() => {
|
4519
|
-
if (!
|
4520
|
-
return () =>
|
4521
|
-
|
4522
|
-
const
|
4523
|
-
const
|
4524
|
-
|
5116
|
+
if (!root2) {
|
5117
|
+
return () => void 0;
|
5118
|
+
}
|
5119
|
+
const observer = new ResizeObserver$2(() => {
|
5120
|
+
const rect = root2.getBoundingClientRect();
|
5121
|
+
rootRect$.setValue({
|
5122
|
+
x: 0,
|
5123
|
+
y: 0,
|
5124
|
+
width: rect.width,
|
5125
|
+
height: rect.height
|
5126
|
+
});
|
4525
5127
|
});
|
4526
|
-
|
5128
|
+
observer.observe(root2);
|
5129
|
+
return () => observer.disconnect();
|
4527
5130
|
}, "calc-root-rect");
|
4528
|
-
})), this.boxes$ = new Val([]), this.topBox$ = new Val(void 0), this._sideEffect.addDisposer(this.boxes$.subscribe((e3) => {
|
4529
|
-
if (e3.length > 0) {
|
4530
|
-
const t3 = e3.reduce((e4, t4) => e4.zIndex > t4.zIndex ? e4 : t4);
|
4531
|
-
this.topBox$.setValue(t3);
|
4532
|
-
} else
|
4533
|
-
this.topBox$.setValue(void 0);
|
4534
5131
|
}));
|
4535
|
-
const
|
4536
|
-
|
4537
|
-
|
4538
|
-
|
4539
|
-
|
4540
|
-
|
5132
|
+
const stageRect$ = combine([rootRect$, stageRatio$], calcStageRect, {
|
5133
|
+
compare: shallowequal
|
5134
|
+
});
|
5135
|
+
this.boxes$ = new Val([]);
|
5136
|
+
this.topBox$ = new Val(void 0);
|
5137
|
+
this._sideEffect.addDisposer(this.boxes$.subscribe((boxes) => {
|
5138
|
+
if (boxes.length > 0) {
|
5139
|
+
const topBox = boxes.reduce((topBox2, box) => topBox2.zIndex > box.zIndex ? topBox2 : box);
|
5140
|
+
this.topBox$.setValue(topBox);
|
5141
|
+
} else {
|
5142
|
+
this.topBox$.setValue(void 0);
|
5143
|
+
}
|
4541
5144
|
}));
|
4542
|
-
const
|
4543
|
-
|
4544
|
-
|
5145
|
+
const prefersDarkMatch = window.matchMedia("(prefers-color-scheme: dark)");
|
5146
|
+
const prefersDark$ = new Val(false);
|
5147
|
+
if (prefersDarkMatch) {
|
5148
|
+
prefersDark$.setValue(prefersDarkMatch.matches);
|
5149
|
+
this._sideEffect.add(() => {
|
5150
|
+
const handler = (evt) => {
|
5151
|
+
prefersDark$.setValue(evt.matches);
|
5152
|
+
};
|
5153
|
+
prefersDarkMatch.addEventListener("change", handler);
|
5154
|
+
return () => prefersDarkMatch.removeEventListener("change", handler);
|
5155
|
+
});
|
5156
|
+
}
|
5157
|
+
const prefersColorScheme$ = new Val(prefersColorScheme);
|
5158
|
+
this._sideEffect.addDisposer(prefersColorScheme$.reaction((prefersColorScheme2, skipUpdate) => {
|
5159
|
+
if (!skipUpdate) {
|
5160
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.PrefersColorScheme, prefersColorScheme2);
|
5161
|
+
}
|
4545
5162
|
}));
|
4546
|
-
const
|
4547
|
-
|
4548
|
-
|
4549
|
-
|
4550
|
-
|
4551
|
-
|
4552
|
-
|
4553
|
-
|
4554
|
-
|
4555
|
-
|
5163
|
+
const darkMode$ = combine([prefersDark$, prefersColorScheme$], ([prefersDark, prefersColorScheme2]) => prefersColorScheme2 === "auto" ? prefersDark : prefersColorScheme2 === "dark");
|
5164
|
+
const state$ = combine([minimized$, maximized$], ([minimized2, maximized2]) => minimized2 ? TELE_BOX_STATE.Minimized : maximized2 ? TELE_BOX_STATE.Maximized : TELE_BOX_STATE.Normal);
|
5165
|
+
this.collector = collector != null ? collector : new TeleBoxCollector({
|
5166
|
+
minimized$,
|
5167
|
+
readonly$,
|
5168
|
+
darkMode$,
|
5169
|
+
namespace,
|
5170
|
+
root$
|
5171
|
+
});
|
5172
|
+
const readonlyValConfig = {
|
5173
|
+
darkMode: darkMode$,
|
5174
|
+
state: state$,
|
5175
|
+
root: root$,
|
5176
|
+
rootRect: rootRect$,
|
5177
|
+
stageRect: stageRect$
|
5178
|
+
};
|
5179
|
+
withReadonlyValueEnhancer(this, readonlyValConfig, valManager);
|
5180
|
+
const valConfig = {
|
5181
|
+
prefersColorScheme: prefersColorScheme$,
|
5182
|
+
readonly: readonly$,
|
5183
|
+
fence: fence$,
|
5184
|
+
minimized: minimized$,
|
5185
|
+
maximized: maximized$,
|
5186
|
+
stageRatio: stageRatio$,
|
5187
|
+
containerStyle: containerStyle$,
|
5188
|
+
stageStyle: stageStyle$,
|
5189
|
+
defaultBoxBodyStyle: defaultBoxBodyStyle$,
|
5190
|
+
defaultBoxStageStyle: defaultBoxStageStyle$
|
5191
|
+
};
|
5192
|
+
withValueEnhancer(this, valConfig, valManager);
|
5193
|
+
const closeBtnClassName = this.wrapClassName("titlebar-icon-close");
|
5194
|
+
const checkFocusBox = (ev) => {
|
5195
|
+
var _a;
|
5196
|
+
if (!ev.isPrimary || readonly$.value) {
|
5197
|
+
return;
|
5198
|
+
}
|
5199
|
+
const target = ev.target;
|
5200
|
+
if (!target.tagName) {
|
4556
5201
|
return;
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
5202
|
+
}
|
5203
|
+
for (let el = target; el; el = el.parentElement) {
|
5204
|
+
if (el.classList && el.classList.contains(closeBtnClassName)) {
|
5205
|
+
return;
|
5206
|
+
}
|
5207
|
+
const id2 = (_a = el.dataset) == null ? void 0 : _a.teleBoxID;
|
5208
|
+
if (id2) {
|
5209
|
+
const box = this.getBox(id2);
|
5210
|
+
if (box) {
|
5211
|
+
this.focusBox(box);
|
5212
|
+
this.makeBoxTop(box);
|
4561
5213
|
return;
|
4562
|
-
const e4 = (t3 = s3.dataset) == null ? void 0 : t3.teleBoxID;
|
4563
|
-
if (e4) {
|
4564
|
-
const t4 = this.getBox(e4);
|
4565
|
-
if (t4)
|
4566
|
-
return this.focusBox(t4), void this.makeBoxTop(t4);
|
4567
5214
|
}
|
4568
5215
|
}
|
5216
|
+
}
|
4569
5217
|
};
|
4570
|
-
this._sideEffect.addEventListener(window, "
|
4571
|
-
|
4572
|
-
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
|
4577
|
-
|
4578
|
-
|
4579
|
-
|
4580
|
-
}
|
4581
|
-
|
4582
|
-
|
4583
|
-
|
4584
|
-
|
4585
|
-
|
4586
|
-
|
4587
|
-
|
4588
|
-
|
4589
|
-
|
5218
|
+
this._sideEffect.addEventListener(window, "pointerdown", checkFocusBox, true);
|
5219
|
+
this.$container = document.createElement("div");
|
5220
|
+
this.$container.className = this.wrapClassName("manager-container");
|
5221
|
+
this.$stage = document.createElement("div");
|
5222
|
+
this.$stage.className = this.wrapClassName("manager-stage");
|
5223
|
+
this.$container.appendChild(this.$stage);
|
5224
|
+
this._sideEffect.addDisposer([
|
5225
|
+
darkMode$.subscribe((darkMode) => {
|
5226
|
+
this.$container.classList.toggle(this.wrapClassName("color-scheme-dark"), darkMode);
|
5227
|
+
this.$container.classList.toggle(this.wrapClassName("color-scheme-light"), !darkMode);
|
5228
|
+
}),
|
5229
|
+
maximized$.subscribe((maximized2) => {
|
5230
|
+
this.$container.classList.toggle("is-maximized", maximized2);
|
5231
|
+
}),
|
5232
|
+
minimized$.subscribe((minimized2) => {
|
5233
|
+
this.$container.classList.toggle("is-minimized", minimized2);
|
5234
|
+
}),
|
5235
|
+
containerStyle$.subscribe((containerStyle2) => {
|
5236
|
+
this.$container.style.cssText = containerStyle2;
|
5237
|
+
}),
|
5238
|
+
stageStyle$.subscribe((stageStyle2) => {
|
5239
|
+
this.$stage.style.cssText = stageStyle2;
|
5240
|
+
this.$stage.style.width = stageRect$.value.width + "px";
|
5241
|
+
this.$stage.style.height = stageRect$.value.height + "px";
|
5242
|
+
}),
|
5243
|
+
stageRect$.subscribe((stageRect) => {
|
5244
|
+
this.$stage.style.width = stageRect.width + "px";
|
5245
|
+
this.$stage.style.height = stageRect.height + "px";
|
5246
|
+
}),
|
5247
|
+
root$.subscribe((root2) => {
|
5248
|
+
if (root2) {
|
5249
|
+
root2.appendChild(this.$container);
|
5250
|
+
} else if (this.$container.parentElement) {
|
5251
|
+
this.$container.remove();
|
5252
|
+
}
|
5253
|
+
})
|
5254
|
+
]);
|
5255
|
+
this.titleBar = new MaxTitleBar({
|
5256
|
+
namespace: this.namespace,
|
5257
|
+
title$: derive(this.topBox$, (topBox) => (topBox == null ? void 0 : topBox.title) || ""),
|
5258
|
+
boxes$: this.boxes$,
|
5259
|
+
darkMode$,
|
5260
|
+
readonly$,
|
5261
|
+
state$,
|
5262
|
+
rootRect$,
|
5263
|
+
root: this.$container,
|
5264
|
+
onEvent: (event) => {
|
5265
|
+
switch (event.type) {
|
5266
|
+
case TELE_BOX_DELEGATE_EVENT.Maximize: {
|
5267
|
+
maximized$.setValue(!maximized$.value);
|
5268
|
+
break;
|
5269
|
+
}
|
5270
|
+
case TELE_BOX_DELEGATE_EVENT.Minimize: {
|
5271
|
+
minimized$.setValue(true);
|
5272
|
+
break;
|
5273
|
+
}
|
5274
|
+
case TELE_BOX_EVENT.Close: {
|
5275
|
+
this.removeTopBox();
|
5276
|
+
this.focusTopBox();
|
5277
|
+
break;
|
5278
|
+
}
|
5279
|
+
}
|
5280
|
+
}
|
5281
|
+
});
|
5282
|
+
this._sideEffect.addDisposer([
|
5283
|
+
state$.reaction((state, skipUpdate) => {
|
5284
|
+
if (!skipUpdate) {
|
5285
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.State, state);
|
5286
|
+
}
|
5287
|
+
}),
|
5288
|
+
maximized$.reaction((maximized2, skipUpdate) => {
|
5289
|
+
if (!skipUpdate) {
|
5290
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Maximized, maximized2);
|
5291
|
+
}
|
5292
|
+
}),
|
5293
|
+
minimized$.reaction((minimized2, skipUpdate) => {
|
5294
|
+
if (!skipUpdate) {
|
5295
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Minimized, minimized2);
|
5296
|
+
}
|
5297
|
+
}),
|
5298
|
+
darkMode$.reaction((darkMode, skipUpdate) => {
|
5299
|
+
if (!skipUpdate) {
|
5300
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.DarkMode, darkMode);
|
5301
|
+
}
|
5302
|
+
})
|
5303
|
+
]);
|
4590
5304
|
}
|
4591
5305
|
get boxes() {
|
4592
5306
|
return this.boxes$.value;
|
@@ -4594,143 +5308,300 @@ class F$3 {
|
|
4594
5308
|
get topBox() {
|
4595
5309
|
return this.topBox$.value;
|
4596
5310
|
}
|
4597
|
-
setState(
|
4598
|
-
switch (
|
4599
|
-
case
|
4600
|
-
this.setMinimized(false,
|
5311
|
+
setState(state, skipUpdate = false) {
|
5312
|
+
switch (state) {
|
5313
|
+
case TELE_BOX_STATE.Maximized: {
|
5314
|
+
this.setMinimized(false, skipUpdate);
|
5315
|
+
this.setMaximized(true, skipUpdate);
|
4601
5316
|
break;
|
4602
|
-
|
4603
|
-
|
5317
|
+
}
|
5318
|
+
case TELE_BOX_STATE.Minimized: {
|
5319
|
+
this.setMinimized(true, skipUpdate);
|
5320
|
+
this.setMaximized(false, skipUpdate);
|
4604
5321
|
break;
|
4605
|
-
|
4606
|
-
|
5322
|
+
}
|
5323
|
+
default: {
|
5324
|
+
this.setMinimized(false, skipUpdate);
|
5325
|
+
this.setMaximized(false, skipUpdate);
|
5326
|
+
break;
|
5327
|
+
}
|
4607
5328
|
}
|
4608
5329
|
return this;
|
4609
5330
|
}
|
4610
|
-
create(
|
4611
|
-
const
|
4612
|
-
|
4613
|
-
|
4614
|
-
this.
|
4615
|
-
|
4616
|
-
this.
|
4617
|
-
|
4618
|
-
|
4619
|
-
|
4620
|
-
|
4621
|
-
|
4622
|
-
|
4623
|
-
|
4624
|
-
|
4625
|
-
|
4626
|
-
|
4627
|
-
|
4628
|
-
|
4629
|
-
|
4630
|
-
|
4631
|
-
|
4632
|
-
|
4633
|
-
|
4634
|
-
|
4635
|
-
|
4636
|
-
|
4637
|
-
|
4638
|
-
|
4639
|
-
|
4640
|
-
|
5331
|
+
create(config = {}, smartPosition = true) {
|
5332
|
+
const box = new TeleBox(__spreadProps(__spreadValues(__spreadValues({
|
5333
|
+
zIndex: this.topBox ? this.topBox.zIndex + 1 : 100
|
5334
|
+
}, config), smartPosition ? this.smartPosition(config) : {}), {
|
5335
|
+
namespace: this.namespace,
|
5336
|
+
root: this.$stage,
|
5337
|
+
darkMode$: this._darkMode$,
|
5338
|
+
maximized$: this._maximized$,
|
5339
|
+
minimized$: this._minimized$,
|
5340
|
+
fence$: this._fence$,
|
5341
|
+
rootRect$: this._rootRect$,
|
5342
|
+
managerStageRect$: this._stageRect$,
|
5343
|
+
managerStageRatio$: this._stageRatio$,
|
5344
|
+
readonly$: this._readonly$,
|
5345
|
+
collectorRect$: this.collector._rect$,
|
5346
|
+
defaultBoxBodyStyle$: this._defaultBoxBodyStyle$,
|
5347
|
+
defaultBoxStageStyle$: this._defaultBoxStageStyle$
|
5348
|
+
}));
|
5349
|
+
if (box.focus) {
|
5350
|
+
this.focusBox(box);
|
5351
|
+
if (smartPosition) {
|
5352
|
+
this.makeBoxTop(box);
|
5353
|
+
}
|
5354
|
+
}
|
5355
|
+
this.boxes$.setValue([...this.boxes, box]);
|
5356
|
+
this._sideEffect.addDisposer([
|
5357
|
+
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Maximize, () => {
|
5358
|
+
this.setMaximized(!this.maximized);
|
5359
|
+
}),
|
5360
|
+
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Minimize, () => {
|
5361
|
+
this.setMinimized(true);
|
5362
|
+
}),
|
5363
|
+
box._delegateEvents.on(TELE_BOX_DELEGATE_EVENT.Close, () => {
|
5364
|
+
this.remove(box);
|
5365
|
+
this.focusTopBox();
|
5366
|
+
}),
|
5367
|
+
box._intrinsicCoord$.reaction((_, skipUpdate) => {
|
5368
|
+
if (!skipUpdate) {
|
5369
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.IntrinsicMove, box);
|
5370
|
+
}
|
5371
|
+
}),
|
5372
|
+
box._intrinsicSize$.reaction((_, skipUpdate) => {
|
5373
|
+
if (!skipUpdate) {
|
5374
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.IntrinsicResize, box);
|
5375
|
+
}
|
5376
|
+
}),
|
5377
|
+
box._zIndex$.reaction((_, skipUpdate) => {
|
5378
|
+
if (this.boxes.length > 0) {
|
5379
|
+
const topBox = this.boxes.reduce((topBox2, box2) => topBox2.zIndex > box2.zIndex ? topBox2 : box2);
|
5380
|
+
this.topBox$.setValue(topBox);
|
5381
|
+
}
|
5382
|
+
if (!skipUpdate) {
|
5383
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.ZIndex, box);
|
5384
|
+
}
|
5385
|
+
})
|
5386
|
+
]);
|
5387
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Created, box);
|
5388
|
+
return box;
|
5389
|
+
}
|
5390
|
+
query(config) {
|
5391
|
+
return config ? this.boxes.filter(this.teleBoxMatcher(config)) : [...this.boxes];
|
4641
5392
|
}
|
4642
|
-
|
4643
|
-
this.boxes.
|
4644
|
-
|
5393
|
+
queryOne(config) {
|
5394
|
+
return config ? this.boxes.find(this.teleBoxMatcher(config)) : this.boxes[0];
|
5395
|
+
}
|
5396
|
+
update(boxID, config, skipUpdate = false) {
|
5397
|
+
const box = this.boxes.find((box2) => box2.id === boxID);
|
5398
|
+
if (box) {
|
5399
|
+
return this.updateBox(box, config, skipUpdate);
|
5400
|
+
}
|
5401
|
+
}
|
5402
|
+
updateAll(config, skipUpdate = false) {
|
5403
|
+
this.boxes.forEach((box) => {
|
5404
|
+
this.updateBox(box, config, skipUpdate);
|
4645
5405
|
});
|
4646
5406
|
}
|
4647
|
-
remove(
|
4648
|
-
const
|
4649
|
-
if (
|
4650
|
-
const
|
4651
|
-
|
5407
|
+
remove(boxOrID, skipUpdate = false) {
|
5408
|
+
const index2 = this.getBoxIndex(boxOrID);
|
5409
|
+
if (index2 >= 0) {
|
5410
|
+
const boxes = this.boxes.slice();
|
5411
|
+
const deletedBoxes = boxes.splice(index2, 1);
|
5412
|
+
this.boxes$.setValue(boxes);
|
5413
|
+
deletedBoxes.forEach((box) => box.destroy());
|
5414
|
+
if (!skipUpdate) {
|
5415
|
+
if (this.boxes.length <= 0) {
|
5416
|
+
this.setMaximized(false);
|
5417
|
+
this.setMinimized(false);
|
5418
|
+
}
|
5419
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
|
5420
|
+
}
|
5421
|
+
return deletedBoxes[0];
|
4652
5422
|
}
|
5423
|
+
return;
|
4653
5424
|
}
|
4654
5425
|
removeTopBox() {
|
4655
|
-
if (this.topBox)
|
5426
|
+
if (this.topBox) {
|
4656
5427
|
return this.remove(this.topBox);
|
5428
|
+
}
|
5429
|
+
return;
|
4657
5430
|
}
|
4658
|
-
removeAll(
|
4659
|
-
const
|
4660
|
-
|
5431
|
+
removeAll(skipUpdate = false) {
|
5432
|
+
const deletedBoxes = this.boxes$.value;
|
5433
|
+
this.boxes$.setValue([]);
|
5434
|
+
deletedBoxes.forEach((box) => box.destroy());
|
5435
|
+
if (!skipUpdate) {
|
5436
|
+
if (this.boxes.length <= 0) {
|
5437
|
+
this.setMaximized(false);
|
5438
|
+
this.setMinimized(false);
|
5439
|
+
}
|
5440
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Removed, deletedBoxes);
|
5441
|
+
}
|
5442
|
+
return deletedBoxes;
|
4661
5443
|
}
|
4662
|
-
mount(
|
4663
|
-
this._root$.setValue(
|
5444
|
+
mount(root) {
|
5445
|
+
this._root$.setValue(root);
|
4664
5446
|
}
|
4665
5447
|
unmount() {
|
4666
5448
|
this._root$.setValue(null);
|
4667
5449
|
}
|
4668
|
-
destroy(
|
4669
|
-
this.events.clearListeners()
|
5450
|
+
destroy(skipUpdate = false) {
|
5451
|
+
this.events.clearListeners();
|
5452
|
+
this._sideEffect.flushAll();
|
5453
|
+
this.removeAll(skipUpdate);
|
5454
|
+
this.collector.destroy();
|
5455
|
+
this.titleBar.destroy();
|
4670
5456
|
}
|
4671
|
-
wrapClassName(
|
4672
|
-
return `${this.namespace}-${
|
5457
|
+
wrapClassName(className) {
|
5458
|
+
return `${this.namespace}-${className}`;
|
4673
5459
|
}
|
4674
|
-
focusBox(
|
4675
|
-
const
|
4676
|
-
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4680
|
-
|
4681
|
-
|
4682
|
-
|
5460
|
+
focusBox(boxOrID, skipUpdate = false) {
|
5461
|
+
const targetBox = this.getBox(boxOrID);
|
5462
|
+
if (targetBox) {
|
5463
|
+
this.boxes.forEach((box) => {
|
5464
|
+
if (targetBox === box) {
|
5465
|
+
let focusChanged = false;
|
5466
|
+
if (!targetBox.focus) {
|
5467
|
+
focusChanged = true;
|
5468
|
+
targetBox._focus$.setValue(true, skipUpdate);
|
5469
|
+
}
|
5470
|
+
if (focusChanged && !skipUpdate) {
|
5471
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Focused, targetBox);
|
5472
|
+
}
|
5473
|
+
} else if (box.focus) {
|
5474
|
+
this.blurBox(box, skipUpdate);
|
5475
|
+
}
|
5476
|
+
});
|
5477
|
+
this.titleBar.focusBox(targetBox);
|
5478
|
+
}
|
4683
5479
|
}
|
4684
5480
|
focusTopBox() {
|
4685
|
-
if (this.topBox && !this.topBox.focus)
|
5481
|
+
if (this.topBox && !this.topBox.focus) {
|
4686
5482
|
return this.focusBox(this.topBox);
|
5483
|
+
}
|
4687
5484
|
}
|
4688
|
-
blurBox(
|
4689
|
-
const
|
4690
|
-
|
4691
|
-
|
4692
|
-
|
4693
|
-
|
4694
|
-
|
4695
|
-
|
4696
|
-
|
4697
|
-
|
4698
|
-
|
4699
|
-
|
4700
|
-
|
4701
|
-
updateBox(e2, t2, i2 = false) {
|
4702
|
-
var s2, a2, n2, o2, r2, h;
|
4703
|
-
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);
|
5485
|
+
blurBox(boxOrID, skipUpdate = false) {
|
5486
|
+
const targetBox = this.getBox(boxOrID);
|
5487
|
+
if (targetBox) {
|
5488
|
+
if (targetBox.focus) {
|
5489
|
+
targetBox._focus$.setValue(false, skipUpdate);
|
5490
|
+
if (!skipUpdate) {
|
5491
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Blurred, targetBox);
|
5492
|
+
}
|
5493
|
+
}
|
5494
|
+
if (this.titleBar.focusedBox === targetBox) {
|
5495
|
+
this.titleBar.focusBox();
|
5496
|
+
}
|
5497
|
+
}
|
4704
5498
|
}
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4709
|
-
|
4710
|
-
|
4711
|
-
|
4712
|
-
t3 + s2 * n2.width <= n2.x + n2.width && (e3 = t3);
|
5499
|
+
blurAll(skipUpdate = false) {
|
5500
|
+
this.boxes.forEach((box) => {
|
5501
|
+
if (box.focus) {
|
5502
|
+
box._focus$.setValue(false, skipUpdate);
|
5503
|
+
if (!skipUpdate) {
|
5504
|
+
this.events.emit(TELE_BOX_MANAGER_EVENT.Blurred, box);
|
5505
|
+
}
|
4713
5506
|
}
|
4714
|
-
|
5507
|
+
});
|
5508
|
+
if (this.titleBar.focusedBox) {
|
5509
|
+
this.titleBar.focusBox();
|
5510
|
+
}
|
5511
|
+
}
|
5512
|
+
teleBoxMatcher(config) {
|
5513
|
+
const keys = Object.keys(config);
|
5514
|
+
return (box) => keys.every((key) => config[key] === box[key]);
|
5515
|
+
}
|
5516
|
+
updateBox(box, config, skipUpdate = false) {
|
5517
|
+
var _a, _b, _c, _d, _e, _f;
|
5518
|
+
if (config.x != null || config.y != null) {
|
5519
|
+
box._intrinsicCoord$.setValue({
|
5520
|
+
x: (_a = config.x) != null ? _a : box.intrinsicX,
|
5521
|
+
y: (_b = config.y) != null ? _b : box.intrinsicY
|
5522
|
+
}, skipUpdate);
|
5523
|
+
}
|
5524
|
+
if (config.width != null || config.height != null) {
|
5525
|
+
box._intrinsicSize$.setValue({
|
5526
|
+
width: (_c = config.width) != null ? _c : box.intrinsicWidth,
|
5527
|
+
height: (_d = config.height) != null ? _d : box.intrinsicHeight
|
5528
|
+
}, skipUpdate);
|
5529
|
+
}
|
5530
|
+
if (config.title != null) {
|
5531
|
+
box._title$.setValue(config.title);
|
5532
|
+
}
|
5533
|
+
if (config.visible != null) {
|
5534
|
+
box._visible$.setValue(config.visible, skipUpdate);
|
5535
|
+
}
|
5536
|
+
if (config.resizable != null) {
|
5537
|
+
box._resizable$.setValue(config.resizable, skipUpdate);
|
5538
|
+
}
|
5539
|
+
if (config.draggable != null) {
|
5540
|
+
box._draggable$.setValue(config.draggable, skipUpdate);
|
5541
|
+
}
|
5542
|
+
if (config.boxRatio != null) {
|
5543
|
+
box._boxRatio$.setValue(config.boxRatio, skipUpdate);
|
5544
|
+
}
|
5545
|
+
if (config.zIndex != null) {
|
5546
|
+
box._zIndex$.setValue(config.zIndex, skipUpdate);
|
5547
|
+
}
|
5548
|
+
if (config.stageRatio !== void 0) {
|
5549
|
+
box.setStageRatio(config.stageRatio, skipUpdate);
|
5550
|
+
}
|
5551
|
+
if (config.content != null) {
|
5552
|
+
box.mountContent(config.content);
|
5553
|
+
}
|
5554
|
+
if (config.footer != null) {
|
5555
|
+
box.mountFooter(config.footer);
|
5556
|
+
}
|
5557
|
+
if (config.minHeight != null || config.minWidth != null) {
|
5558
|
+
box._minSize$.setValue({
|
5559
|
+
width: (_e = config.minWidth) != null ? _e : box.minWidth,
|
5560
|
+
height: (_f = config.minHeight) != null ? _f : box.minHeight
|
5561
|
+
}, skipUpdate);
|
5562
|
+
}
|
5563
|
+
}
|
5564
|
+
smartPosition(rect) {
|
5565
|
+
let { x: x2, y: y2 } = rect;
|
5566
|
+
const { width = 0.5, height = 0.5 } = rect;
|
5567
|
+
const stageRect = this.stageRect;
|
5568
|
+
const topBox = this.topBox;
|
5569
|
+
if (x2 == null) {
|
5570
|
+
let pxX = 20;
|
5571
|
+
if (topBox) {
|
5572
|
+
const pxPreferredX = topBox.pxIntrinsicCoord.x + 20;
|
5573
|
+
const pxIntrinsicWidth = width * stageRect.width;
|
5574
|
+
if (pxPreferredX + pxIntrinsicWidth <= stageRect.width) {
|
5575
|
+
pxX = pxPreferredX;
|
5576
|
+
}
|
5577
|
+
}
|
5578
|
+
x2 = pxX / stageRect.width;
|
4715
5579
|
}
|
4716
|
-
if (
|
4717
|
-
let
|
4718
|
-
if (
|
4719
|
-
const
|
4720
|
-
|
5580
|
+
if (y2 == null) {
|
5581
|
+
let pxY = 20;
|
5582
|
+
if (topBox) {
|
5583
|
+
const pxPreferredY = topBox.pxIntrinsicCoord.y + 20;
|
5584
|
+
const pxIntrinsicHeight = height * stageRect.height;
|
5585
|
+
if (pxPreferredY + pxIntrinsicHeight <= stageRect.height) {
|
5586
|
+
pxY = pxPreferredY;
|
5587
|
+
}
|
4721
5588
|
}
|
4722
|
-
|
5589
|
+
y2 = pxY / stageRect.height;
|
4723
5590
|
}
|
4724
|
-
return { x:
|
5591
|
+
return { x: x2, y: y2, width, height };
|
4725
5592
|
}
|
4726
|
-
makeBoxTop(
|
4727
|
-
|
5593
|
+
makeBoxTop(box, skipUpdate = false) {
|
5594
|
+
if (this.topBox) {
|
5595
|
+
if (box !== this.topBox) {
|
5596
|
+
box._zIndex$.setValue(this.topBox.zIndex + 1, skipUpdate);
|
5597
|
+
}
|
5598
|
+
}
|
4728
5599
|
}
|
4729
|
-
getBoxIndex(
|
4730
|
-
return typeof
|
5600
|
+
getBoxIndex(boxOrID) {
|
5601
|
+
return typeof boxOrID === "string" ? this.boxes.findIndex((box) => box.id === boxOrID) : this.boxes.findIndex((box) => box === boxOrID);
|
4731
5602
|
}
|
4732
|
-
getBox(
|
4733
|
-
return typeof
|
5603
|
+
getBox(boxOrID) {
|
5604
|
+
return typeof boxOrID === "string" ? this.boxes.find((box) => box.id === boxOrID) : boxOrID;
|
4734
5605
|
}
|
4735
5606
|
}
|
4736
5607
|
const createBoxManager = (manager, callbacks2, emitter2, boxEmitter2, options) => {
|
@@ -4761,15 +5632,6 @@ const createBoxManager = (manager, callbacks2, emitter2, boxEmitter2, options) =
|
|
4761
5632
|
class BoxManager {
|
4762
5633
|
constructor(context, createTeleBoxManagerConfig) {
|
4763
5634
|
this.context = context;
|
4764
|
-
this.mainViewElement$ = new Val(void 0);
|
4765
|
-
this.updateStyle = (element2, rect) => {
|
4766
|
-
if (!element2)
|
4767
|
-
return;
|
4768
|
-
element2.style.width = rect.width + "px";
|
4769
|
-
element2.style.height = rect.height + "px";
|
4770
|
-
element2.style.left = rect.x + "px";
|
4771
|
-
element2.style.top = rect.y + "px";
|
4772
|
-
};
|
4773
5635
|
this.sideEffectManager = new SideEffectManager();
|
4774
5636
|
const { emitter: emitter2, callbacks: callbacks2, boxEmitter: boxEmitter2 } = context;
|
4775
5637
|
this.teleBoxManager = this.setupBoxManager(createTeleBoxManagerConfig);
|
@@ -4837,14 +5699,6 @@ class BoxManager {
|
|
4837
5699
|
this.teleBoxManager.events.on("z_index", (box) => {
|
4838
5700
|
this.context.updateAppState(box.id, AppAttributes.ZIndex, box.zIndex);
|
4839
5701
|
}),
|
4840
|
-
this.teleBoxManager._stageRect$.subscribe((stage) => {
|
4841
|
-
this.updateStyle(this.mainViewElement$.value, stage);
|
4842
|
-
emitter2.emit("playgroundSizeChange", stage);
|
4843
|
-
this.context.notifyContainerRectUpdate(stage);
|
4844
|
-
}),
|
4845
|
-
emitter2.on("writableChange", (isWritable) => {
|
4846
|
-
this.teleBoxManager.setHighlightStage(isWritable);
|
4847
|
-
}),
|
4848
5702
|
emitter2.on("containerSizeRatioUpdate", (ratio) => {
|
4849
5703
|
this.teleBoxManager._stageRatio$.setValue(ratio);
|
4850
5704
|
})
|
@@ -4881,7 +5735,7 @@ class BoxManager {
|
|
4881
5735
|
var _a, _b, _c;
|
4882
5736
|
if (!this.teleBoxManager)
|
4883
5737
|
return;
|
4884
|
-
let { minwidth = MIN_WIDTH, minheight = MIN_HEIGHT } = (_a = params.app.config) != null ? _a : {};
|
5738
|
+
let { minwidth = MIN_WIDTH, minheight = MIN_HEIGHT, enableShadowDOM = true } = (_a = params.app.config) != null ? _a : {};
|
4885
5739
|
const { width, height } = (_b = params.app.config) != null ? _b : {};
|
4886
5740
|
const title = ((_c = params.options) == null ? void 0 : _c.title) || params.appId;
|
4887
5741
|
const rect = this.teleBoxManager.rootRect;
|
@@ -4897,7 +5751,8 @@ class BoxManager {
|
|
4897
5751
|
minHeight: minheight,
|
4898
5752
|
width,
|
4899
5753
|
height,
|
4900
|
-
id: params.appId
|
5754
|
+
id: params.appId,
|
5755
|
+
enableShadowDOM
|
4901
5756
|
};
|
4902
5757
|
const box = this.teleBoxManager.create(createBoxConfig, params.smartPosition);
|
4903
5758
|
this.context.emitter.emit(`${params.appId}${Events.WindowCreated}`);
|
@@ -4909,10 +5764,15 @@ class BoxManager {
|
|
4909
5764
|
stageRatio: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.stageRatio,
|
4910
5765
|
root,
|
4911
5766
|
fence: false,
|
4912
|
-
prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme
|
4913
|
-
highlightStage: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.highlightStage
|
5767
|
+
prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme
|
4914
5768
|
};
|
4915
|
-
|
5769
|
+
if (createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.containerStyle) {
|
5770
|
+
initManagerState.containerStyle = createTeleBoxManagerConfig.containerStyle;
|
5771
|
+
}
|
5772
|
+
if (createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.stageStyle) {
|
5773
|
+
initManagerState.stageStyle = createTeleBoxManagerConfig.stageStyle;
|
5774
|
+
}
|
5775
|
+
const manager = new TeleBoxManager(initManagerState);
|
4916
5776
|
if (this.teleBoxManager) {
|
4917
5777
|
this.teleBoxManager.destroy();
|
4918
5778
|
}
|
@@ -4944,18 +5804,19 @@ class BoxManager {
|
|
4944
5804
|
return this.teleBoxManager.topBox;
|
4945
5805
|
}
|
4946
5806
|
updateBoxState(state) {
|
4947
|
-
var _a, _b, _c, _d;
|
4948
5807
|
if (!state)
|
4949
5808
|
return;
|
4950
5809
|
const box = this.getBox(state.id);
|
4951
5810
|
if (box) {
|
4952
|
-
|
4953
|
-
|
4954
|
-
|
4955
|
-
|
4956
|
-
|
4957
|
-
|
4958
|
-
|
5811
|
+
if (state.size) {
|
5812
|
+
box._intrinsicSize$.setValue(state.size, true);
|
5813
|
+
}
|
5814
|
+
if (state.position) {
|
5815
|
+
box._intrinsicCoord$.setValue(state.position, true);
|
5816
|
+
}
|
5817
|
+
if (state.zIndex) {
|
5818
|
+
box._zIndex$.setValue(state.zIndex, true);
|
5819
|
+
}
|
4959
5820
|
setTimeout(() => {
|
4960
5821
|
if (state.focus) {
|
4961
5822
|
this.teleBoxManager.focusBox(box.id, true);
|
@@ -4971,13 +5832,19 @@ class BoxManager {
|
|
4971
5832
|
}
|
4972
5833
|
}
|
4973
5834
|
moveBox({ appId, x: x2, y: y2 }) {
|
4974
|
-
this.
|
5835
|
+
const box = this.getBox(appId);
|
5836
|
+
if (box) {
|
5837
|
+
box._intrinsicCoord$.setValue({ x: x2, y: y2 }, true);
|
5838
|
+
}
|
4975
5839
|
}
|
4976
5840
|
focusBox({ appId }, skipUpdate = true) {
|
4977
5841
|
this.teleBoxManager.focusBox(appId, skipUpdate);
|
4978
5842
|
}
|
4979
5843
|
resizeBox({ appId, width, height, skipUpdate }) {
|
4980
|
-
this.
|
5844
|
+
const box = this.getBox(appId);
|
5845
|
+
if (box) {
|
5846
|
+
box._intrinsicSize$.setValue({ width, height }, skipUpdate);
|
5847
|
+
}
|
4981
5848
|
}
|
4982
5849
|
setBoxMinSize(params) {
|
4983
5850
|
this.teleBoxManager.update(params.appId, {
|
@@ -15654,6 +16521,10 @@ const BuiltinApps = {
|
|
15654
16521
|
DocsViewer: NetlessAppDocsViewer.kind,
|
15655
16522
|
MediaPlayer: K.kind
|
15656
16523
|
};
|
16524
|
+
const BuiltinAppsMap = {
|
16525
|
+
[BuiltinApps.DocsViewer]: NetlessAppDocsViewer,
|
16526
|
+
[BuiltinApps.MediaPlayer]: K
|
16527
|
+
};
|
15657
16528
|
var videoJs = "";
|
15658
16529
|
var style$1 = "";
|
15659
16530
|
var style = "";
|
@@ -15661,15 +16532,15 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15661
16532
|
const _WindowManager = class extends InvisiblePlugin {
|
15662
16533
|
constructor(context) {
|
15663
16534
|
super(context);
|
15664
|
-
this.version = "1.0.0-canary.
|
15665
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
16535
|
+
this.version = "1.0.0-canary.29";
|
16536
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.27", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.3.0", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@playwright/test": "^1.23.0", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/node": "^18.0.0", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vite-plugin-dts": "^1.2.0", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15666
16537
|
this.emitter = callbacks$1;
|
15667
16538
|
this.viewMode = ViewMode.Broadcaster;
|
15668
16539
|
this.viewMode$ = new Val(ViewMode.Broadcaster);
|
15669
16540
|
this.isReplay = isPlayer(this.displayer);
|
15670
16541
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15671
16542
|
_WindowManager.displayer = context.displayer;
|
15672
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
16543
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.27", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.3.0", "video.js": ">=7" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.2.9", "@netless/app-media-player": "0.1.0-beta.5", "@playwright/test": "^1.23.0", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/node": "^18.0.0", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vite-plugin-dts": "^1.2.0", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15673
16544
|
}
|
15674
16545
|
static async mount(params) {
|
15675
16546
|
var _a;
|
@@ -15724,7 +16595,8 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15724
16595
|
collectorStyles: params.collectorStyles,
|
15725
16596
|
prefersColorScheme: params.prefersColorScheme,
|
15726
16597
|
stageRatio: _WindowManager.containerSizeRatio,
|
15727
|
-
|
16598
|
+
containerStyle: params.containerStyle,
|
16599
|
+
stageStyle: params.stageStyle
|
15728
16600
|
});
|
15729
16601
|
(_a = manager.appManager) == null ? void 0 : _a.setBoxManager(manager.boxManager);
|
15730
16602
|
if (params.container) {
|
@@ -15762,11 +16634,11 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15762
16634
|
}
|
15763
16635
|
return manager;
|
15764
16636
|
}
|
15765
|
-
static initContainer(container, overwriteStyles) {
|
16637
|
+
static initContainer(container, target, overwriteStyles) {
|
15766
16638
|
if (!_WindowManager.container) {
|
15767
16639
|
_WindowManager.container = container;
|
15768
16640
|
}
|
15769
|
-
const { playground, mainViewElement } = setupWrapper(container);
|
16641
|
+
const { playground, mainViewElement } = setupWrapper(container, target);
|
15770
16642
|
_WindowManager.playground = playground;
|
15771
16643
|
if (overwriteStyles) {
|
15772
16644
|
const style2 = document.createElement("style");
|
@@ -15779,7 +16651,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15779
16651
|
return appRegister.registered;
|
15780
16652
|
}
|
15781
16653
|
bindContainer(container) {
|
15782
|
-
var _a, _b, _c, _d, _e;
|
16654
|
+
var _a, _b, _c, _d, _e, _f;
|
15783
16655
|
if (isRoom(this.displayer) && this.room.phase !== RoomPhase.Connected) {
|
15784
16656
|
throw new BindContainerRoomPhaseInvalidError();
|
15785
16657
|
}
|
@@ -15788,24 +16660,24 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15788
16660
|
container.appendChild(_WindowManager.container.firstChild);
|
15789
16661
|
}
|
15790
16662
|
} else {
|
15791
|
-
|
16663
|
+
const teleboxContainer = (_a = this.boxManager) == null ? void 0 : _a.teleBoxManager.$stage;
|
16664
|
+
if (_WindowManager.params && teleboxContainer) {
|
15792
16665
|
const params = _WindowManager.params;
|
15793
|
-
const mainViewElement = _WindowManager.initContainer(container, params.overwriteStyles);
|
16666
|
+
const mainViewElement = _WindowManager.initContainer(container, teleboxContainer, params.overwriteStyles);
|
15794
16667
|
if (this.boxManager && _WindowManager.playground) {
|
15795
16668
|
this.boxManager.setRoot(_WindowManager.playground);
|
15796
|
-
this.boxManager.mainViewElement$.setValue(mainViewElement);
|
15797
16669
|
}
|
15798
16670
|
this.bindMainView(mainViewElement, params.disableCameraTransform);
|
15799
16671
|
if (_WindowManager.playground) {
|
15800
|
-
(
|
16672
|
+
(_b = this.cursorManager) == null ? void 0 : _b.setupWrapper(_WindowManager.playground);
|
15801
16673
|
}
|
15802
16674
|
}
|
15803
16675
|
}
|
15804
16676
|
emitter.emit("updateManagerRect");
|
15805
|
-
(
|
15806
|
-
(
|
15807
|
-
(
|
15808
|
-
(
|
16677
|
+
(_c = this.appManager) == null ? void 0 : _c.refresh();
|
16678
|
+
(_d = this.appManager) == null ? void 0 : _d.resetMaximized();
|
16679
|
+
(_e = this.appManager) == null ? void 0 : _e.resetMinimized();
|
16680
|
+
(_f = this.appManager) == null ? void 0 : _f.displayerWritableListener(!this.room.isWritable);
|
15809
16681
|
_WindowManager.container = container;
|
15810
16682
|
}
|
15811
16683
|
bindCollectorContainer(container) {
|
@@ -16321,6 +17193,14 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
16321
17193
|
this.containerSizeRatio = ratio;
|
16322
17194
|
emitter.emit("containerSizeRatioUpdate", ratio);
|
16323
17195
|
}
|
17196
|
+
setContainerStyle(style2) {
|
17197
|
+
var _a;
|
17198
|
+
(_a = this.boxManager) == null ? void 0 : _a.teleBoxManager.setContainerStyle(style2);
|
17199
|
+
}
|
17200
|
+
setStageStyle(style2) {
|
17201
|
+
var _a;
|
17202
|
+
(_a = this.boxManager) == null ? void 0 : _a.teleBoxManager.setStageStyle(style2);
|
17203
|
+
}
|
16324
17204
|
createPPTHandler() {
|
16325
17205
|
return {
|
16326
17206
|
onPageJumpTo: (_pptUUID, index2) => {
|
@@ -16375,4 +17255,4 @@ WindowManager.debug = false;
|
|
16375
17255
|
WindowManager.containerSizeRatio = DEFAULT_CONTAINER_RATIO;
|
16376
17256
|
WindowManager.isCreated = false;
|
16377
17257
|
setupBuiltin();
|
16378
|
-
export { AppCreateError, AppManagerNotInitError, AppNotRegisterError, BindContainerRoomPhaseInvalidError, BoxManagerNotFoundError, BoxNotCreatedError, BuiltinApps, InvalidScenePath, ParamsInvalidError, WhiteWebSDKInvalidError, WindowManager, calculateNextIndex, reconnectRefresher };
|
17258
|
+
export { AppCreateError, AppManagerNotInitError, AppNotRegisterError, BindContainerRoomPhaseInvalidError, BoxManagerNotFoundError, BoxNotCreatedError, BuiltinApps, BuiltinAppsMap, InvalidScenePath, ParamsInvalidError, WhiteWebSDKInvalidError, WindowManager, calculateNextIndex, reconnectRefresher };
|