@netless/window-manager 1.0.0-canary.23 → 1.0.0-canary.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App/AppContext.d.ts +1 -1
- package/dist/App/WhiteboardView.d.ts +3 -3
- package/dist/AppListener.d.ts +0 -2
- package/dist/BoxManager.d.ts +3 -0
- package/dist/Cursor/index.d.ts +3 -2
- package/dist/Helper.d.ts +2 -0
- package/dist/constants.d.ts +0 -2
- package/dist/index.cjs.js +12 -12
- package/dist/index.d.ts +11 -8
- package/dist/index.es.js +106 -64
- package/dist/index.umd.js +12 -12
- package/dist/style.css +1 -1
- package/docs/app-context.md +68 -26
- package/package.json +2 -2
- package/pnpm-lock.yaml +2 -9
- package/src/App/AppContext.ts +13 -5
- package/src/App/AppProxy.ts +4 -0
- package/src/App/WhiteboardView.ts +6 -6
- package/src/AppListener.ts +1 -21
- package/src/AppManager.ts +2 -1
- package/src/BoxManager.ts +12 -0
- package/src/Cursor/Cursor.ts +6 -2
- package/src/Cursor/index.ts +5 -5
- package/src/Helper.ts +20 -3
- package/src/View/CameraSynchronizer.ts +2 -2
- package/src/View/MainView.ts +3 -1
- package/src/constants.ts +0 -2
- package/src/index.ts +52 -41
- package/src/style.css +2 -6
package/dist/index.d.ts
CHANGED
@@ -5,9 +5,10 @@ import { ReconnectRefresher } from "./ReconnectRefresher";
|
|
5
5
|
import "video.js/dist/video-js.css";
|
6
6
|
import "./style.css";
|
7
7
|
import "@netless/telebox-insider/dist/style.css";
|
8
|
+
import { Val } from "value-enhancer";
|
8
9
|
import type { TELE_BOX_STATE } from "./BoxManager";
|
9
10
|
import type { Apps, Position, ICamera, ISize } from "./AttributesDelegate";
|
10
|
-
import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera,
|
11
|
+
import type { Displayer, SceneDefinition, View, Room, InvisiblePluginContext, Camera, CameraBound, Point, CameraState, Player, ImageInformation, SceneState, Rectangle } from "white-web-sdk";
|
11
12
|
import type { AppListeners } from "./AppListener";
|
12
13
|
import type { ApplianceIcons, NetlessApp, RegisterParams } from "./typings";
|
13
14
|
import type { TeleBoxColorScheme, TeleBoxState } from "@netless/telebox-insider";
|
@@ -15,7 +16,6 @@ import type { AppProxy } from "./App";
|
|
15
16
|
import type { PublicEvent } from "./callback";
|
16
17
|
import type Emittery from "emittery";
|
17
18
|
import type { PageController, AddPageParams, PageState } from "./Page";
|
18
|
-
import { Val } from "value-enhancer";
|
19
19
|
export declare type WindowMangerAttributes = {
|
20
20
|
modelValue?: string;
|
21
21
|
boxState: TELE_BOX_STATE;
|
@@ -190,6 +190,13 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
190
190
|
setMinimized(minimized: boolean): void;
|
191
191
|
get mainView(): View;
|
192
192
|
get camera(): Camera;
|
193
|
+
get baseCamera$(): Val<{
|
194
|
+
id: string;
|
195
|
+
centerX: number | null;
|
196
|
+
centerY: number | null;
|
197
|
+
scale: number;
|
198
|
+
} | undefined, any>;
|
199
|
+
get baseSize$(): Val<ISize | undefined, any>;
|
193
200
|
get cameraState(): CameraState;
|
194
201
|
get apps(): Apps | undefined;
|
195
202
|
get boxState(): TeleBoxState | undefined;
|
@@ -217,12 +224,8 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
217
224
|
* 关闭 APP
|
218
225
|
*/
|
219
226
|
closeApp(appId: string): Promise<void>;
|
220
|
-
moveCamera(camera: Partial<Camera>
|
221
|
-
|
222
|
-
}): void;
|
223
|
-
moveCameraToContain(rectangle: Rectangle & Readonly<{
|
224
|
-
animationMode?: AnimationMode;
|
225
|
-
}>): void;
|
227
|
+
moveCamera(camera: Partial<Camera>): void;
|
228
|
+
moveCameraToContain(rectangle: Rectangle): void;
|
226
229
|
convertToPointInWorld(point: Point): Point;
|
227
230
|
setCameraBound(cameraBound: CameraBound): void;
|
228
231
|
onDestroy(): void;
|
package/dist/index.es.js
CHANGED
@@ -19,7 +19,7 @@ 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";
|
@@ -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";
|
@@ -473,14 +471,6 @@ class AppListeners {
|
|
473
471
|
this.setMainViewScenePathHandler(data.payload);
|
474
472
|
break;
|
475
473
|
}
|
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
474
|
case Events.CursorMove: {
|
485
475
|
this.cursorMoveHandler(data.payload);
|
486
476
|
break;
|
@@ -520,14 +510,6 @@ class AppListeners {
|
|
520
510
|
setViewFocusScenePath(this.manager.mainView, nextScenePath);
|
521
511
|
callbacks$1.emit("mainViewScenePathChange", nextScenePath);
|
522
512
|
};
|
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
513
|
this.cursorMoveHandler = (payload) => {
|
532
514
|
emitter.emit("cursorMove", payload);
|
533
515
|
};
|
@@ -953,11 +935,11 @@ class WhiteBoardView {
|
|
953
935
|
this.appProxy.sideEffectManager.add(() => appProxy.appEmitter.on("pageStateChange", (pageState) => {
|
954
936
|
pageState$.setValue(pageState);
|
955
937
|
}));
|
956
|
-
const camera$ = new Val(pick(this.view.camera, ["centerX", "centerY"]));
|
957
|
-
this.
|
938
|
+
const camera$ = new Val(pick(this.view.camera, ["centerX", "centerY", "scale"]));
|
939
|
+
this.baseCamera$ = camera$;
|
958
940
|
this.appProxy.sideEffectManager.add(() => appProxy.camera$.subscribe((camera) => {
|
959
941
|
if (camera) {
|
960
|
-
camera$.setValue(pick(camera, ["centerX", "centerY"]));
|
942
|
+
camera$.setValue(pick(camera, ["centerX", "centerY", "scale"]));
|
961
943
|
}
|
962
944
|
}));
|
963
945
|
view.disableCameraTransform = true;
|
@@ -968,10 +950,15 @@ class WhiteBoardView {
|
|
968
950
|
moveCamera(camera) {
|
969
951
|
this.appProxy.moveCamera(camera);
|
970
952
|
}
|
971
|
-
|
953
|
+
setBaseRect(rect) {
|
972
954
|
this.appProxy.updateSize(rect.width, rect.height);
|
973
955
|
}
|
974
956
|
}
|
957
|
+
const log = (...args) => {
|
958
|
+
if (WindowManager.debug) {
|
959
|
+
console.log(`[WindowManager]:`, ...args);
|
960
|
+
}
|
961
|
+
};
|
975
962
|
const setupWrapper = (root) => {
|
976
963
|
const playground = document.createElement("div");
|
977
964
|
playground.className = "netless-window-manager-playground";
|
@@ -1002,6 +989,19 @@ const serializeRoomMembers = (members) => {
|
|
1002
989
|
}, member);
|
1003
990
|
});
|
1004
991
|
};
|
992
|
+
const createInvisiblePlugin = async (room) => {
|
993
|
+
try {
|
994
|
+
const manager = await room.createInvisiblePlugin(WindowManager, {});
|
995
|
+
return manager;
|
996
|
+
} catch (error) {
|
997
|
+
if (error.message === `invisible plugin "WindowManager" exits`) {
|
998
|
+
await wait(200);
|
999
|
+
return room.getInvisiblePlugin(WindowManager.kind);
|
1000
|
+
} else {
|
1001
|
+
log("createInvisiblePlugin failed", error);
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
};
|
1005
1005
|
class AppContext {
|
1006
1006
|
constructor(manager, appId, appProxy, appOptions) {
|
1007
1007
|
this.manager = manager;
|
@@ -1056,11 +1056,19 @@ class AppContext {
|
|
1056
1056
|
this.ensurePageSize(params == null ? void 0 : params.size);
|
1057
1057
|
}
|
1058
1058
|
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, this.ensurePageSize);
|
1059
|
-
this.appProxy.sideEffectManager.add(() =>
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1059
|
+
this.appProxy.sideEffectManager.add(() => [
|
1060
|
+
this.box._contentStageRect$.subscribe((rect) => {
|
1061
|
+
viewWrapper.style.left = `${rect.x}px`;
|
1062
|
+
viewWrapper.style.top = `${rect.y}px`;
|
1063
|
+
viewWrapper.style.width = `${rect.width}px`;
|
1064
|
+
viewWrapper.style.height = `${rect.height}px`;
|
1065
|
+
}),
|
1066
|
+
() => {
|
1067
|
+
return () => {
|
1068
|
+
this.whiteBoardView = void 0;
|
1069
|
+
};
|
1070
|
+
}
|
1071
|
+
]);
|
1064
1072
|
this.appProxy.whiteBoardViewCreated$.setValue(true);
|
1065
1073
|
return this.whiteBoardView;
|
1066
1074
|
};
|
@@ -1147,7 +1155,7 @@ class AppContext {
|
|
1147
1155
|
get members() {
|
1148
1156
|
return this.manager.members;
|
1149
1157
|
}
|
1150
|
-
get
|
1158
|
+
get currentMember() {
|
1151
1159
|
const self2 = findMemberByUid(this.room, this.manager.uid);
|
1152
1160
|
if (!self2) {
|
1153
1161
|
throw new Error(`Member ${this.manager.uid} not found.`);
|
@@ -1239,7 +1247,7 @@ class CameraSynchronizer {
|
|
1239
1247
|
const nextScale = camera.scale * scale2;
|
1240
1248
|
const config = {
|
1241
1249
|
scale: nextScale,
|
1242
|
-
animationMode: AnimationMode.
|
1250
|
+
animationMode: AnimationMode.Continuous
|
1243
1251
|
};
|
1244
1252
|
if (camera.centerX !== null) {
|
1245
1253
|
config.centerX = camera.centerX;
|
@@ -1263,7 +1271,7 @@ class CameraSynchronizer {
|
|
1263
1271
|
const nextScale = this.remoteCamera.scale * scale2;
|
1264
1272
|
(_a = this.view) == null ? void 0 : _a.moveCamera({
|
1265
1273
|
scale: nextScale,
|
1266
|
-
animationMode: AnimationMode.
|
1274
|
+
animationMode: AnimationMode.Continuous
|
1267
1275
|
});
|
1268
1276
|
}
|
1269
1277
|
}
|
@@ -1537,11 +1545,6 @@ const store = new AttributesDelegate({
|
|
1537
1545
|
throw new Error("safeUpdateAttributes not implemented");
|
1538
1546
|
}
|
1539
1547
|
});
|
1540
|
-
const log = (...args) => {
|
1541
|
-
if (WindowManager.debug) {
|
1542
|
-
console.log(`[WindowManager]:`, ...args);
|
1543
|
-
}
|
1544
|
-
};
|
1545
1548
|
class AppProxy {
|
1546
1549
|
constructor(params, manager, appId, isAddApp) {
|
1547
1550
|
var _a;
|
@@ -1912,6 +1915,10 @@ class AppProxy {
|
|
1912
1915
|
this.box$.setValue(box);
|
1913
1916
|
if (this.isAddApp && this.box) {
|
1914
1917
|
this.store.updateAppState(appId, AppAttributes.ZIndex, this.box.zIndex);
|
1918
|
+
this.store.updateAppState(appId, AppAttributes.Size, {
|
1919
|
+
width: this.box.intrinsicWidth,
|
1920
|
+
height: this.box.intrinsicHeight
|
1921
|
+
});
|
1915
1922
|
this.boxManager.focusBox({ appId }, false);
|
1916
1923
|
}
|
1917
1924
|
} catch (error) {
|
@@ -2336,12 +2343,14 @@ class MainViewProxy {
|
|
2336
2343
|
rebind() {
|
2337
2344
|
const divElement = this.mainView.divElement;
|
2338
2345
|
const disableCameraTransform = this.mainView.disableCameraTransform;
|
2346
|
+
const camera = __spreadValues({}, this.mainView.camera);
|
2339
2347
|
this.stop();
|
2340
2348
|
releaseView(this.mainView);
|
2341
2349
|
this.removeMainViewListener();
|
2342
2350
|
this.mainView = this.createMainView();
|
2343
2351
|
this.mainView.disableCameraTransform = disableCameraTransform;
|
2344
2352
|
this.mainView.divElement = divElement;
|
2353
|
+
this.mainView.moveCamera(__spreadProps(__spreadValues({}, camera), { animationMode: AnimationMode.Immediately }));
|
2345
2354
|
this.addMainViewListener();
|
2346
2355
|
this.start();
|
2347
2356
|
}
|
@@ -2613,8 +2622,7 @@ class AppManager {
|
|
2613
2622
|
this.dispatchInternalEvent(Events.AppBoxStateChange, payload);
|
2614
2623
|
};
|
2615
2624
|
this.addAppsChangeListener = () => {
|
2616
|
-
|
2617
|
-
(_a = this.refresher) == null ? void 0 : _a.add("apps", () => {
|
2625
|
+
this.refresher.add("apps", () => {
|
2618
2626
|
return safeListenPropsUpdated(() => this.attributes.apps, () => {
|
2619
2627
|
this.attributesUpdateCallback(this.attributes.apps);
|
2620
2628
|
});
|
@@ -3107,6 +3115,7 @@ class AppManager {
|
|
3107
3115
|
}
|
3108
3116
|
}
|
3109
3117
|
async onReconnected() {
|
3118
|
+
this.attributesUpdateCallback(this.attributes.apps);
|
3110
3119
|
const appProxies = Array.from(this.appProxies.values());
|
3111
3120
|
const reconnected = appProxies.map((appProxy) => {
|
3112
3121
|
return appProxy.onReconnected();
|
@@ -4752,6 +4761,15 @@ const createBoxManager = (manager, callbacks2, emitter2, boxEmitter2, options) =
|
|
4752
4761
|
class BoxManager {
|
4753
4762
|
constructor(context, createTeleBoxManagerConfig) {
|
4754
4763
|
this.context = context;
|
4764
|
+
this.mainViewElement$ = new Val(void 0);
|
4765
|
+
this.updateStyle = (element2, rect) => {
|
4766
|
+
if (!element2)
|
4767
|
+
return;
|
4768
|
+
element2.style.width = rect.width + "px";
|
4769
|
+
element2.style.height = rect.height + "px";
|
4770
|
+
element2.style.left = rect.x + "px";
|
4771
|
+
element2.style.top = rect.y + "px";
|
4772
|
+
};
|
4755
4773
|
this.sideEffectManager = new SideEffectManager();
|
4756
4774
|
const { emitter: emitter2, callbacks: callbacks2, boxEmitter: boxEmitter2 } = context;
|
4757
4775
|
this.teleBoxManager = this.setupBoxManager(createTeleBoxManagerConfig);
|
@@ -4820,6 +4838,7 @@ class BoxManager {
|
|
4820
4838
|
this.context.updateAppState(box.id, AppAttributes.ZIndex, box.zIndex);
|
4821
4839
|
}),
|
4822
4840
|
this.teleBoxManager._stageRect$.subscribe((stage) => {
|
4841
|
+
this.updateStyle(this.mainViewElement$.value, stage);
|
4823
4842
|
emitter2.emit("playgroundSizeChange", stage);
|
4824
4843
|
this.context.notifyContainerRectUpdate(stage);
|
4825
4844
|
}),
|
@@ -5628,11 +5647,14 @@ class Cursor {
|
|
5628
5647
|
let translateX = point.x - 2;
|
5629
5648
|
let translateY = point.y - 18;
|
5630
5649
|
if (type === "app") {
|
5631
|
-
const wrapperRect = this.cursorManager.
|
5650
|
+
const wrapperRect = this.cursorManager.playgroundRect;
|
5632
5651
|
if (wrapperRect) {
|
5633
5652
|
translateX = translateX + rect.x - wrapperRect.x;
|
5634
5653
|
translateY = translateY + rect.y - wrapperRect.y;
|
5635
5654
|
}
|
5655
|
+
} else {
|
5656
|
+
translateX = translateX + rect.x;
|
5657
|
+
translateY = translateY + rect.y;
|
5636
5658
|
}
|
5637
5659
|
if (point.x < 0 || point.x > rect.width || point.y < 0 || point.y > rect.height) {
|
5638
5660
|
(_a = this.component) == null ? void 0 : _a.$set({ visible: false, x: translateX, y: translateY });
|
@@ -5863,7 +5885,6 @@ class CursorManager {
|
|
5863
5885
|
wrapper.removeEventListener("pointerleave", this.mouseLeaveListener);
|
5864
5886
|
};
|
5865
5887
|
});
|
5866
|
-
this.wrapperRect = wrapper.getBoundingClientRect();
|
5867
5888
|
}
|
5868
5889
|
setMainViewDivElement(div) {
|
5869
5890
|
this.mainViewElement = div;
|
@@ -5892,8 +5913,9 @@ class CursorManager {
|
|
5892
5913
|
}
|
5893
5914
|
}
|
5894
5915
|
updateContainerRect() {
|
5895
|
-
var _a;
|
5896
|
-
this.wrapperRect = (_a =
|
5916
|
+
var _a, _b;
|
5917
|
+
this.wrapperRect = (_a = this.manager.boxManager) == null ? void 0 : _a.teleBoxManager.stageRect;
|
5918
|
+
this.playgroundRect = (_b = WindowManager.playground) == null ? void 0 : _b.getBoundingClientRect();
|
5897
5919
|
}
|
5898
5920
|
deleteCursor(uid) {
|
5899
5921
|
this.store.cleanCursor(uid);
|
@@ -15639,15 +15661,15 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15639
15661
|
const _WindowManager = class extends InvisiblePlugin {
|
15640
15662
|
constructor(context) {
|
15641
15663
|
super(context);
|
15642
|
-
this.version = "1.0.0-canary.
|
15643
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "emittery": "^0.
|
15664
|
+
this.version = "1.0.0-canary.26";
|
15665
|
+
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "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", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15644
15666
|
this.emitter = callbacks$1;
|
15645
15667
|
this.viewMode = ViewMode.Broadcaster;
|
15646
15668
|
this.viewMode$ = new Val(ViewMode.Broadcaster);
|
15647
15669
|
this.isReplay = isPlayer(this.displayer);
|
15648
15670
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15649
15671
|
_WindowManager.displayer = context.displayer;
|
15650
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "emittery": "^0.
|
15672
|
+
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "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", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "^1.0.0-next.22", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.5.3", "vitest": "^0.14.1", "white-web-sdk": "2.16.10" } };
|
15651
15673
|
}
|
15652
15674
|
static async mount(params) {
|
15653
15675
|
var _a;
|
@@ -15729,12 +15751,12 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15729
15751
|
} catch (error) {
|
15730
15752
|
throw new Error("[WindowManger]: room must be switched to be writable");
|
15731
15753
|
}
|
15732
|
-
manager = await
|
15733
|
-
manager.ensureAttributes();
|
15754
|
+
manager = await createInvisiblePlugin(room);
|
15755
|
+
manager == null ? void 0 : manager.ensureAttributes();
|
15734
15756
|
await wait(500);
|
15735
15757
|
await room.setWritable(false);
|
15736
15758
|
} else {
|
15737
|
-
manager = await
|
15759
|
+
manager = await createInvisiblePlugin(room);
|
15738
15760
|
}
|
15739
15761
|
}
|
15740
15762
|
}
|
@@ -15771,6 +15793,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15771
15793
|
const mainViewElement = _WindowManager.initContainer(container, params.overwriteStyles);
|
15772
15794
|
if (this.boxManager && _WindowManager.playground) {
|
15773
15795
|
this.boxManager.setRoot(_WindowManager.playground);
|
15796
|
+
this.boxManager.mainViewElement$.setValue(mainViewElement);
|
15774
15797
|
}
|
15775
15798
|
this.bindMainView(mainViewElement, params.disableCameraTransform);
|
15776
15799
|
if (_WindowManager.playground) {
|
@@ -16041,6 +16064,20 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
16041
16064
|
throw new AppManagerNotInitError();
|
16042
16065
|
}
|
16043
16066
|
}
|
16067
|
+
get baseCamera$() {
|
16068
|
+
if (this.appManager) {
|
16069
|
+
return this.appManager.mainViewProxy.camera$;
|
16070
|
+
} else {
|
16071
|
+
throw new AppManagerNotInitError();
|
16072
|
+
}
|
16073
|
+
}
|
16074
|
+
get baseSize$() {
|
16075
|
+
if (this.appManager) {
|
16076
|
+
return this.appManager.mainViewProxy.size$;
|
16077
|
+
} else {
|
16078
|
+
throw new AppManagerNotInitError();
|
16079
|
+
}
|
16080
|
+
}
|
16044
16081
|
get cameraState() {
|
16045
16082
|
if (this.appManager) {
|
16046
16083
|
return this.appManager.mainViewProxy.cameraState;
|
@@ -16134,26 +16171,31 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
16134
16171
|
return (_a = this.appManager) == null ? void 0 : _a.closeApp(appId);
|
16135
16172
|
}
|
16136
16173
|
moveCamera(camera) {
|
16137
|
-
var _a;
|
16138
|
-
const pureCamera = omit(camera, ["animationMode"]);
|
16139
16174
|
const mainViewCamera = __spreadValues({}, this.mainView.camera);
|
16140
|
-
|
16175
|
+
const nextCamera = __spreadValues(__spreadValues({}, mainViewCamera), camera);
|
16176
|
+
if (isEqual(nextCamera, mainViewCamera))
|
16141
16177
|
return;
|
16142
|
-
this.
|
16143
|
-
|
16144
|
-
|
16145
|
-
|
16146
|
-
|
16147
|
-
}, 500);
|
16178
|
+
if (!this.appManager)
|
16179
|
+
return;
|
16180
|
+
this.appManager.mainViewProxy.storeCamera(__spreadValues({
|
16181
|
+
id: this.appManager.uid
|
16182
|
+
}, nextCamera));
|
16148
16183
|
}
|
16149
16184
|
moveCameraToContain(rectangle) {
|
16150
|
-
|
16151
|
-
|
16152
|
-
|
16153
|
-
|
16154
|
-
|
16155
|
-
|
16156
|
-
|
16185
|
+
if (!this.appManager)
|
16186
|
+
return;
|
16187
|
+
const mainViewSize = this.appManager.mainViewProxy.size$.value;
|
16188
|
+
if (mainViewSize) {
|
16189
|
+
const wScale = mainViewSize.width / rectangle.width;
|
16190
|
+
const hScale = mainViewSize.height / rectangle.height;
|
16191
|
+
const nextScale = Math.min(wScale, hScale);
|
16192
|
+
this.appManager.mainViewProxy.storeCamera({
|
16193
|
+
id: this.appManager.uid,
|
16194
|
+
scale: nextScale,
|
16195
|
+
centerX: rectangle.originX,
|
16196
|
+
centerY: rectangle.originY
|
16197
|
+
});
|
16198
|
+
}
|
16157
16199
|
}
|
16158
16200
|
convertToPointInWorld(point) {
|
16159
16201
|
return this.mainView.convertToPointInWorld(point);
|