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