@netless/window-manager 1.0.0-canary.15 → 1.0.0-canary.16
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 -3
- package/dist/App/AppProxy.d.ts +1 -1
- package/dist/App/WhiteboardView.d.ts +1 -3
- package/dist/BoxManager.d.ts +1 -0
- package/dist/View/MainView.d.ts +13 -6
- package/dist/View/ViewSync.d.ts +24 -0
- package/dist/index.cjs.js +10 -10
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +156 -105
- package/dist/index.umd.js +12 -12
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/App/AppContext.ts +2 -9
- package/src/App/AppProxy.ts +18 -10
- package/src/App/WhiteboardView.ts +0 -7
- package/src/AppManager.ts +1 -0
- package/src/BoxManager.ts +4 -0
- package/src/View/CameraSynchronizer.ts +7 -5
- package/src/View/MainView.ts +86 -52
- package/src/View/ViewSync.ts +121 -0
- package/src/index.ts +10 -5
- package/src/style.css +0 -1
- package/dist/App/AppViewSync.d.ts +0 -11
- package/src/App/AppViewSync.ts +0 -73
package/dist/index.d.ts
CHANGED
@@ -15,6 +15,7 @@ import type { AppProxy } from "./App";
|
|
15
15
|
import type { PublicEvent } from "./callback";
|
16
16
|
import type Emittery from "emittery";
|
17
17
|
import type { PageController, AddPageParams, PageState } from "./Page";
|
18
|
+
import { Val } from "value-enhancer";
|
18
19
|
export declare type WindowMangerAttributes = {
|
19
20
|
modelValue?: string;
|
20
21
|
boxState: TELE_BOX_STATE;
|
@@ -108,6 +109,7 @@ export declare class WindowManager extends InvisiblePlugin<WindowMangerAttribute
|
|
108
109
|
appManager?: AppManager;
|
109
110
|
cursorManager?: CursorManager;
|
110
111
|
viewMode: ViewMode;
|
112
|
+
viewMode$: Val<ViewMode, any>;
|
111
113
|
isReplay: boolean;
|
112
114
|
private _pageState?;
|
113
115
|
private boxManager?;
|
package/dist/index.es.js
CHANGED
@@ -20,7 +20,7 @@ var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
|
|
20
20
|
import pRetry from "p-retry";
|
21
21
|
import Emittery from "emittery";
|
22
22
|
import { debounce, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, pick, isNumber, throttle, delay, isInteger, orderBy, isEmpty, isFunction, isNull } from "lodash";
|
23
|
-
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, isPlayer, isRoom, ApplianceNames, RoomPhase, InvisiblePlugin
|
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";
|
@@ -898,11 +898,10 @@ class Storage {
|
|
898
898
|
}
|
899
899
|
}
|
900
900
|
class WhiteBoardView {
|
901
|
-
constructor(view, appContext, appProxy,
|
901
|
+
constructor(view, appContext, appProxy, ensureSize) {
|
902
902
|
this.view = view;
|
903
903
|
this.appContext = appContext;
|
904
904
|
this.appProxy = appProxy;
|
905
|
-
this.removeViewWrapper = removeViewWrapper;
|
906
905
|
this.ensureSize = ensureSize;
|
907
906
|
this.nextPage = async () => {
|
908
907
|
const nextIndex = this.pageState.index + 1;
|
@@ -968,11 +967,6 @@ class WhiteBoardView {
|
|
968
967
|
setRect(rect) {
|
969
968
|
this.appProxy.updateSize(rect.width, rect.height);
|
970
969
|
}
|
971
|
-
destroy() {
|
972
|
-
this.pageState$.destroy();
|
973
|
-
this.camera$.destroy();
|
974
|
-
this.removeViewWrapper();
|
975
|
-
}
|
976
970
|
}
|
977
971
|
const setupWrapper = (root) => {
|
978
972
|
const playground = document.createElement("div");
|
@@ -1005,9 +999,8 @@ const serializeRoomMembers = (members) => {
|
|
1005
999
|
});
|
1006
1000
|
};
|
1007
1001
|
class AppContext {
|
1008
|
-
constructor(manager,
|
1002
|
+
constructor(manager, appId, appProxy, appOptions) {
|
1009
1003
|
this.manager = manager;
|
1010
|
-
this.boxManager = boxManager;
|
1011
1004
|
this.appId = appId;
|
1012
1005
|
this.appProxy = appProxy;
|
1013
1006
|
this.appOptions = appOptions;
|
@@ -1048,21 +1041,14 @@ class AppContext {
|
|
1048
1041
|
this._viewWrapper = viewWrapper;
|
1049
1042
|
viewWrapper.className = "window-manager-view-wrapper";
|
1050
1043
|
(_a = this.box.$content.parentElement) == null ? void 0 : _a.appendChild(viewWrapper);
|
1051
|
-
const removeViewWrapper = () => {
|
1052
|
-
var _a2;
|
1053
|
-
(_a2 = this.box.$content.parentElement) == null ? void 0 : _a2.removeChild(viewWrapper);
|
1054
|
-
this._viewWrapper = void 0;
|
1055
|
-
};
|
1056
1044
|
view.divElement = viewWrapper;
|
1057
1045
|
this.appProxy.fireMemberStateChange();
|
1058
1046
|
if (this.isAddApp) {
|
1059
1047
|
this.ensurePageSize(size2);
|
1060
1048
|
}
|
1061
|
-
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy,
|
1049
|
+
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, this.ensurePageSize);
|
1062
1050
|
this.appProxy.sideEffectManager.add(() => {
|
1063
1051
|
return () => {
|
1064
|
-
var _a2;
|
1065
|
-
(_a2 = this.whiteBoardView) == null ? void 0 : _a2.destroy();
|
1066
1052
|
this.whiteBoardView = void 0;
|
1067
1053
|
};
|
1068
1054
|
});
|
@@ -1138,7 +1124,7 @@ class AppContext {
|
|
1138
1124
|
return this.manager.canOperate && !this.destroyed;
|
1139
1125
|
}
|
1140
1126
|
get box() {
|
1141
|
-
const box = this.
|
1127
|
+
const box = this.appProxy.box$.value;
|
1142
1128
|
if (box) {
|
1143
1129
|
return box;
|
1144
1130
|
} else {
|
@@ -1258,8 +1244,11 @@ class CameraSynchronizer {
|
|
1258
1244
|
this.view = view;
|
1259
1245
|
}
|
1260
1246
|
onRemoteSizeUpdate(size2) {
|
1261
|
-
|
1262
|
-
|
1247
|
+
this.remoteSize = size2;
|
1248
|
+
const needMoveCamera = !isEqual(pick(this.rect, ["width", "height"]), pick(size2, ["width", "height"]));
|
1249
|
+
if (this.rect && this.remoteCamera && needMoveCamera) {
|
1250
|
+
const scale2 = this.rect.width / size2.width;
|
1251
|
+
const nextScale = this.remoteCamera.scale * scale2;
|
1263
1252
|
const moveCamera = () => {
|
1264
1253
|
var _a;
|
1265
1254
|
(_a = this.view) == null ? void 0 : _a.moveCamera({
|
@@ -1267,6 +1256,7 @@ class CameraSynchronizer {
|
|
1267
1256
|
animationMode: AnimationMode.Immediately
|
1268
1257
|
});
|
1269
1258
|
};
|
1259
|
+
moveCamera();
|
1270
1260
|
delay(moveCamera, 50);
|
1271
1261
|
}
|
1272
1262
|
}
|
@@ -1275,61 +1265,80 @@ class CameraSynchronizer {
|
|
1275
1265
|
this.remoteCamera = camera;
|
1276
1266
|
}
|
1277
1267
|
}
|
1278
|
-
class
|
1279
|
-
constructor(
|
1280
|
-
this.
|
1268
|
+
class ViewSync {
|
1269
|
+
constructor(context) {
|
1270
|
+
this.context = context;
|
1281
1271
|
this.sem = new SideEffectManager();
|
1282
1272
|
this.bindView = (view) => {
|
1283
1273
|
if (!view)
|
1284
1274
|
return;
|
1285
1275
|
this.synchronizer.setView(view);
|
1276
|
+
this.sem.flush("view");
|
1286
1277
|
this.sem.add(() => {
|
1287
1278
|
view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1288
1279
|
return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1289
|
-
});
|
1280
|
+
}, "view");
|
1290
1281
|
};
|
1291
1282
|
this.onCameraUpdatedByDevice = (camera) => {
|
1292
|
-
var _a;
|
1293
1283
|
this.synchronizer.onLocalCameraUpdate(camera);
|
1294
|
-
const stage =
|
1284
|
+
const stage = this.context.stageRect$.value;
|
1295
1285
|
if (stage) {
|
1296
|
-
const size2 = { width: stage.width, height: stage.height, id: this.
|
1297
|
-
if (!isEqual(size2, this.
|
1298
|
-
this.
|
1286
|
+
const size2 = { width: stage.width, height: stage.height, id: this.context.uid };
|
1287
|
+
if (!isEqual(size2, this.context.size$.value)) {
|
1288
|
+
this.context.storeSize(size2);
|
1299
1289
|
}
|
1300
1290
|
}
|
1301
1291
|
};
|
1302
1292
|
this.synchronizer = new CameraSynchronizer((camera) => {
|
1303
|
-
|
1304
|
-
id: this.
|
1305
|
-
}, camera)
|
1293
|
+
const iCamera = __spreadValues({
|
1294
|
+
id: this.context.uid
|
1295
|
+
}, camera);
|
1296
|
+
this.context.camera$.setValue(iCamera, true);
|
1297
|
+
const notStoreCamera = this.context.viewMode$ && this.context.viewMode$.value === ViewMode.Freedom;
|
1298
|
+
if (notStoreCamera) {
|
1299
|
+
return;
|
1300
|
+
} else {
|
1301
|
+
this.context.storeCamera(iCamera);
|
1302
|
+
}
|
1306
1303
|
});
|
1307
|
-
this.bindView(
|
1308
|
-
this.sem.add(() => this.
|
1309
|
-
const
|
1310
|
-
if (
|
1304
|
+
this.bindView(this.context.view$.value);
|
1305
|
+
this.sem.add(() => this.context.view$.subscribe((view) => {
|
1306
|
+
const currentCamera = this.context.camera$.value;
|
1307
|
+
if (currentCamera && this.context.size$.value) {
|
1308
|
+
view == null ? void 0 : view.moveCamera({
|
1309
|
+
scale: 1,
|
1310
|
+
animationMode: AnimationMode.Immediately
|
1311
|
+
});
|
1312
|
+
this.synchronizer.onRemoteUpdate(currentCamera, this.context.size$.value);
|
1313
|
+
}
|
1314
|
+
this.bindView(view);
|
1315
|
+
}));
|
1316
|
+
this.sem.add(() => this.context.camera$.subscribe((camera, skipUpdate) => {
|
1317
|
+
const size2 = this.context.size$.value;
|
1318
|
+
if (camera && size2 && !skipUpdate) {
|
1311
1319
|
this.synchronizer.onRemoteUpdate(camera, size2);
|
1312
1320
|
}
|
1313
1321
|
}));
|
1314
|
-
this.sem.add(() => this.
|
1322
|
+
this.sem.add(() => this.context.size$.subscribe((size2) => {
|
1315
1323
|
if (size2) {
|
1316
1324
|
this.synchronizer.onRemoteSizeUpdate(size2);
|
1317
1325
|
}
|
1318
1326
|
}));
|
1319
|
-
|
1320
|
-
|
1321
|
-
this.
|
1322
|
-
this.sem.add(() => box._contentStageRect$.subscribe((rect) => {
|
1327
|
+
if (this.context.stageRect$.value) {
|
1328
|
+
this.synchronizer.setRect(this.context.stageRect$.value);
|
1329
|
+
this.sem.add(() => this.context.stageRect$.subscribe((rect) => {
|
1323
1330
|
if (rect) {
|
1324
1331
|
this.synchronizer.setRect(rect);
|
1325
1332
|
}
|
1326
1333
|
}));
|
1327
1334
|
}
|
1328
|
-
|
1335
|
+
const camera$size$ = combine([this.context.camera$, this.context.size$]);
|
1336
|
+
camera$size$.subscribe(([camera, size2]) => {
|
1329
1337
|
if (camera && size2) {
|
1330
1338
|
this.synchronizer.onRemoteUpdate(camera, size2);
|
1339
|
+
camera$size$.destroy();
|
1331
1340
|
}
|
1332
|
-
})
|
1341
|
+
});
|
1333
1342
|
}
|
1334
1343
|
destroy() {
|
1335
1344
|
this.sem.flushAll();
|
@@ -1679,9 +1688,9 @@ class AppProxy {
|
|
1679
1688
|
var _a2;
|
1680
1689
|
return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
|
1681
1690
|
}, (camera) => {
|
1682
|
-
if (camera
|
1691
|
+
if (camera) {
|
1683
1692
|
const rawCamera = toJS(camera);
|
1684
|
-
if (rawCamera
|
1693
|
+
if (!isEqual(rawCamera, this.camera$.value)) {
|
1685
1694
|
this.camera$.setValue(rawCamera);
|
1686
1695
|
}
|
1687
1696
|
}
|
@@ -1692,9 +1701,9 @@ class AppProxy {
|
|
1692
1701
|
var _a2;
|
1693
1702
|
return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
|
1694
1703
|
}, (size2) => {
|
1695
|
-
if (size2
|
1704
|
+
if (size2) {
|
1696
1705
|
const rawSize = toJS(size2);
|
1697
|
-
if (this.size$.value
|
1706
|
+
if (!isEqual(rawSize, this.size$.value)) {
|
1698
1707
|
this.size$.setValue(rawSize);
|
1699
1708
|
}
|
1700
1709
|
}
|
@@ -1754,10 +1763,18 @@ class AppProxy {
|
|
1754
1763
|
});
|
1755
1764
|
this.size$.setValue(toJS(this.appAttributes.size));
|
1756
1765
|
}
|
1757
|
-
this.
|
1766
|
+
this.viewSync = new ViewSync({
|
1767
|
+
uid: this.uid,
|
1768
|
+
view$: this.view$,
|
1769
|
+
camera$: this.camera$,
|
1770
|
+
size$: this.size$,
|
1771
|
+
stageRect$: box._contentStageRect$,
|
1772
|
+
storeCamera: this.storeCamera,
|
1773
|
+
storeSize: this.storeSize
|
1774
|
+
});
|
1758
1775
|
this.sideEffectManager.add(() => () => {
|
1759
1776
|
var _a2;
|
1760
|
-
return (_a2 = this.
|
1777
|
+
return (_a2 = this.viewSync) == null ? void 0 : _a2.destroy();
|
1761
1778
|
});
|
1762
1779
|
}
|
1763
1780
|
}));
|
@@ -1849,7 +1866,7 @@ class AppProxy {
|
|
1849
1866
|
if (!this.boxManager) {
|
1850
1867
|
throw new BoxManagerNotFoundError();
|
1851
1868
|
}
|
1852
|
-
const context = new AppContext(this.manager,
|
1869
|
+
const context = new AppContext(this.manager, appId, this, appOptions);
|
1853
1870
|
this.appContext = context;
|
1854
1871
|
try {
|
1855
1872
|
emitter.once(`${appId}${Events.WindowCreated}`).then(async () => {
|
@@ -2132,12 +2149,29 @@ const setDefaultCameraBound = (view) => {
|
|
2132
2149
|
};
|
2133
2150
|
class MainViewProxy {
|
2134
2151
|
constructor(manager) {
|
2135
|
-
var _a;
|
2136
2152
|
this.manager = manager;
|
2137
2153
|
this.started = false;
|
2138
2154
|
this.mainViewIsAddListener = false;
|
2139
2155
|
this.store = this.manager.store;
|
2140
2156
|
this.sideEffectManager = new SideEffectManager();
|
2157
|
+
this.camera$ = new Val(void 0);
|
2158
|
+
this.size$ = new Val(void 0);
|
2159
|
+
this.view$ = new Val(void 0);
|
2160
|
+
this.createViewSync = () => {
|
2161
|
+
var _a;
|
2162
|
+
if (this.manager.boxManager && !this.viewSync) {
|
2163
|
+
this.viewSync = new ViewSync({
|
2164
|
+
uid: this.manager.uid,
|
2165
|
+
view$: this.view$,
|
2166
|
+
camera$: this.camera$,
|
2167
|
+
size$: this.size$,
|
2168
|
+
stageRect$: (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect$,
|
2169
|
+
viewMode$: this.manager.windowManger.viewMode$,
|
2170
|
+
storeCamera: this.storeCamera,
|
2171
|
+
storeSize: this.storeSize
|
2172
|
+
});
|
2173
|
+
}
|
2174
|
+
};
|
2141
2175
|
this.startListenWritableChange = () => {
|
2142
2176
|
this.sideEffectManager.add(() => emitter.on("writableChange", (isWritable) => {
|
2143
2177
|
if (isWritable) {
|
@@ -2147,26 +2181,50 @@ class MainViewProxy {
|
|
2147
2181
|
};
|
2148
2182
|
this.addCameraReaction = () => {
|
2149
2183
|
this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
|
2184
|
+
this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
|
2185
|
+
};
|
2186
|
+
this.storeCurrentCamera = () => {
|
2187
|
+
const iCamera = this.view.camera;
|
2188
|
+
this.storeCamera(__spreadValues({
|
2189
|
+
id: this.manager.uid
|
2190
|
+
}, iCamera));
|
2191
|
+
};
|
2192
|
+
this.storeCurrentSize = () => {
|
2193
|
+
var _a;
|
2194
|
+
const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2195
|
+
if (rect) {
|
2196
|
+
this.storeSize({
|
2197
|
+
id: this.manager.uid,
|
2198
|
+
width: rect.width,
|
2199
|
+
height: rect.height
|
2200
|
+
});
|
2201
|
+
}
|
2202
|
+
};
|
2203
|
+
this.storeCamera = (camera) => {
|
2204
|
+
this.store.setMainViewCamera(camera);
|
2205
|
+
};
|
2206
|
+
this.storeSize = (size2) => {
|
2207
|
+
this.store.setMainViewSize(size2);
|
2150
2208
|
};
|
2151
2209
|
this.cameraReaction = () => {
|
2152
2210
|
return reaction(() => this.mainViewCamera, (camera) => {
|
2153
|
-
if (camera
|
2154
|
-
|
2211
|
+
if (camera) {
|
2212
|
+
const rawCamera = toJS(camera);
|
2213
|
+
if (!isEqual(rawCamera, this.camera$.value)) {
|
2214
|
+
this.camera$.setValue(rawCamera);
|
2215
|
+
}
|
2155
2216
|
}
|
2156
2217
|
}, { fireImmediately: true });
|
2157
2218
|
};
|
2158
|
-
this.
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
2164
|
-
|
2165
|
-
|
2166
|
-
|
2167
|
-
if (size2 && !isEqual(size2, this.mainViewSize)) {
|
2168
|
-
this.setMainViewSize(size2);
|
2169
|
-
}
|
2219
|
+
this.sizeReaction = () => {
|
2220
|
+
return reaction(() => this.mainViewSize, (size2) => {
|
2221
|
+
if (size2) {
|
2222
|
+
const rawSize = toJS(size2);
|
2223
|
+
if (!isEqual(rawSize, this.size$.value)) {
|
2224
|
+
this.size$.setValue(rawSize);
|
2225
|
+
}
|
2226
|
+
}
|
2227
|
+
}, { fireImmediately: true });
|
2170
2228
|
};
|
2171
2229
|
this.mainViewClickListener = () => {
|
2172
2230
|
this.mainViewClickHandler();
|
@@ -2177,9 +2235,7 @@ class MainViewProxy {
|
|
2177
2235
|
this.onCameraOrSizeUpdated = () => {
|
2178
2236
|
callbacks$1.emit("cameraStateChange", this.cameraState);
|
2179
2237
|
};
|
2180
|
-
this.synchronizer = new CameraSynchronizer((camera) => this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid })));
|
2181
2238
|
this.mainView = this.createMainView();
|
2182
|
-
this.moveCameraSizeByAttributes();
|
2183
2239
|
emitter.once("mainViewMounted").then(() => {
|
2184
2240
|
this.addMainViewListener();
|
2185
2241
|
this.start();
|
@@ -2187,23 +2243,27 @@ class MainViewProxy {
|
|
2187
2243
|
this.startListenWritableChange();
|
2188
2244
|
});
|
2189
2245
|
this.sideEffectManager.add(() => [
|
2190
|
-
emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio),
|
2191
2246
|
emitter.on("startReconnect", () => {
|
2192
2247
|
releaseView(this.mainView);
|
2193
|
-
}),
|
2194
|
-
emitter.on("playgroundSizeChange", (rect2) => {
|
2195
|
-
this.synchronizer.setRect(rect2);
|
2196
2248
|
})
|
2197
2249
|
]);
|
2198
|
-
|
2199
|
-
if (rect) {
|
2200
|
-
this.synchronizer.setRect(rect);
|
2201
|
-
}
|
2250
|
+
this.createViewSync();
|
2202
2251
|
}
|
2203
2252
|
ensureCameraAndSize() {
|
2253
|
+
var _a;
|
2204
2254
|
if (!this.mainViewCamera || !this.mainViewSize) {
|
2205
2255
|
this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
|
2206
|
-
this.
|
2256
|
+
this.storeCamera(__spreadValues({
|
2257
|
+
id: this.manager.uid
|
2258
|
+
}, this.view.camera));
|
2259
|
+
const stageRect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2260
|
+
if (stageRect && !this.mainViewSize) {
|
2261
|
+
this.storeSize({
|
2262
|
+
id: this.manager.uid,
|
2263
|
+
width: stageRect.width,
|
2264
|
+
height: stageRect.height
|
2265
|
+
});
|
2266
|
+
}
|
2207
2267
|
}
|
2208
2268
|
}
|
2209
2269
|
get mainViewCamera() {
|
@@ -2215,9 +2275,6 @@ class MainViewProxy {
|
|
2215
2275
|
get didRelease() {
|
2216
2276
|
return get(this.view, ["didRelease"]);
|
2217
2277
|
}
|
2218
|
-
moveCameraSizeByAttributes() {
|
2219
|
-
this.synchronizer.onRemoteUpdate(this.mainViewCamera, this.mainViewSize);
|
2220
|
-
}
|
2221
2278
|
start() {
|
2222
2279
|
if (this.started)
|
2223
2280
|
return;
|
@@ -2225,14 +2282,6 @@ class MainViewProxy {
|
|
2225
2282
|
this.addCameraReaction();
|
2226
2283
|
this.started = true;
|
2227
2284
|
}
|
2228
|
-
setCameraAndSize() {
|
2229
|
-
const stageSize = this.getStageSize();
|
2230
|
-
if (stageSize) {
|
2231
|
-
const camera = __spreadProps(__spreadValues({}, this.mainView.camera), { id: this.manager.uid });
|
2232
|
-
const size2 = __spreadProps(__spreadValues({}, stageSize), { id: this.manager.uid });
|
2233
|
-
this.store.setMainViewCameraAndSize(camera, size2);
|
2234
|
-
}
|
2235
|
-
}
|
2236
2285
|
get view() {
|
2237
2286
|
return this.mainView;
|
2238
2287
|
}
|
@@ -2245,7 +2294,7 @@ class MainViewProxy {
|
|
2245
2294
|
if (mainViewScenePath) {
|
2246
2295
|
setViewFocusScenePath(mainView, mainViewScenePath);
|
2247
2296
|
}
|
2248
|
-
this.
|
2297
|
+
this.view$.setValue(mainView);
|
2249
2298
|
return mainView;
|
2250
2299
|
}
|
2251
2300
|
onReconnect() {
|
@@ -2273,13 +2322,6 @@ class MainViewProxy {
|
|
2273
2322
|
this.addMainViewListener();
|
2274
2323
|
this.start();
|
2275
2324
|
}
|
2276
|
-
getStageSize() {
|
2277
|
-
var _a;
|
2278
|
-
const stage = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2279
|
-
if (stage) {
|
2280
|
-
return { width: stage.width, height: stage.height };
|
2281
|
-
}
|
2282
|
-
}
|
2283
2325
|
addMainViewListener() {
|
2284
2326
|
if (this.mainViewIsAddListener)
|
2285
2327
|
return;
|
@@ -2304,12 +2346,10 @@ class MainViewProxy {
|
|
2304
2346
|
(_a = this.manager.boxManager) == null ? void 0 : _a.blurAllBox();
|
2305
2347
|
}
|
2306
2348
|
addCameraListener() {
|
2307
|
-
this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
2308
2349
|
this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
|
2309
2350
|
this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
|
2310
2351
|
}
|
2311
2352
|
removeCameraListener() {
|
2312
|
-
this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
2313
2353
|
this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
|
2314
2354
|
this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
|
2315
2355
|
}
|
@@ -2320,6 +2360,9 @@ class MainViewProxy {
|
|
2320
2360
|
this.started = false;
|
2321
2361
|
}
|
2322
2362
|
destroy() {
|
2363
|
+
this.camera$.destroy();
|
2364
|
+
this.size$.destroy();
|
2365
|
+
this.view$.destroy();
|
2323
2366
|
this.removeMainViewListener();
|
2324
2367
|
this.stop();
|
2325
2368
|
this.sideEffectManager.flushAll();
|
@@ -2872,6 +2915,7 @@ class AppManager {
|
|
2872
2915
|
}
|
2873
2916
|
setBoxManager(boxManager) {
|
2874
2917
|
this.boxManager = boxManager;
|
2918
|
+
this.mainViewProxy.createViewSync();
|
2875
2919
|
}
|
2876
2920
|
resetMaximized() {
|
2877
2921
|
var _a;
|
@@ -4781,6 +4825,9 @@ class BoxManager {
|
|
4781
4825
|
get stageRect() {
|
4782
4826
|
return this.teleBoxManager.stageRect;
|
4783
4827
|
}
|
4828
|
+
get stageRect$() {
|
4829
|
+
return this.teleBoxManager._stageRect$;
|
4830
|
+
}
|
4784
4831
|
createBox(params) {
|
4785
4832
|
var _a, _b, _c;
|
4786
4833
|
if (!this.teleBoxManager)
|
@@ -15555,10 +15602,11 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15555
15602
|
const _WindowManager = class extends InvisiblePlugin {
|
15556
15603
|
constructor(context) {
|
15557
15604
|
super(context);
|
15558
|
-
this.version = "1.0.0-canary.
|
15605
|
+
this.version = "1.0.0-canary.16";
|
15559
15606
|
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.17", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "side-effect-manager": "^1.1.0", "uuid": "^7.0.3", "value-enhancer": "^1.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" } };
|
15560
15607
|
this.emitter = callbacks$1;
|
15561
15608
|
this.viewMode = ViewMode.Broadcaster;
|
15609
|
+
this.viewMode$ = new Val(ViewMode.Broadcaster);
|
15562
15610
|
this.isReplay = isPlayer(this.displayer);
|
15563
15611
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15564
15612
|
_WindowManager.displayer = context.displayer;
|
@@ -15898,17 +15946,20 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15898
15946
|
addEmitterOnceListener(`destroy-${kind2}`, listener);
|
15899
15947
|
}
|
15900
15948
|
setViewMode(mode) {
|
15901
|
-
var _a
|
15949
|
+
var _a;
|
15950
|
+
log("setViewMode", mode);
|
15951
|
+
const mainViewProxy = (_a = this.appManager) == null ? void 0 : _a.mainViewProxy;
|
15902
15952
|
if (mode === ViewMode.Broadcaster) {
|
15903
15953
|
if (this.canOperate) {
|
15904
|
-
|
15954
|
+
mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
|
15905
15955
|
}
|
15906
|
-
|
15956
|
+
mainViewProxy == null ? void 0 : mainViewProxy.start();
|
15907
15957
|
}
|
15908
15958
|
if (mode === ViewMode.Freedom) {
|
15909
|
-
|
15959
|
+
mainViewProxy == null ? void 0 : mainViewProxy.stop();
|
15910
15960
|
}
|
15911
15961
|
this.viewMode = mode;
|
15962
|
+
this.viewMode$.setValue(mode);
|
15912
15963
|
}
|
15913
15964
|
setBoxState(boxState) {
|
15914
15965
|
if (!this.canOperate)
|
@@ -16055,7 +16106,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
16055
16106
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCamera, camera);
|
16056
16107
|
setTimeout(() => {
|
16057
16108
|
var _a2;
|
16058
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
16109
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
|
16059
16110
|
}, 500);
|
16060
16111
|
}
|
16061
16112
|
moveCameraToContain(rectangle) {
|
@@ -16064,7 +16115,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
16064
16115
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
16065
16116
|
setTimeout(() => {
|
16066
16117
|
var _a2;
|
16067
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
16118
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
|
16068
16119
|
}, 500);
|
16069
16120
|
}
|
16070
16121
|
convertToPointInWorld(point) {
|