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