@netless/window-manager 1.0.0-canary.13 → 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 +3 -2
- package/dist/App/WhiteboardView.d.ts +4 -4
- package/dist/AppManager.d.ts +2 -2
- 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 +181 -114
- package/dist/index.umd.js +12 -12
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/pnpm-lock.yaml +4 -4
- package/src/App/AppContext.ts +7 -8
- package/src/App/AppProxy.ts +21 -12
- package/src/App/WhiteboardView.ts +21 -10
- package/src/AppManager.ts +9 -8
- package/src/BoxManager.ts +4 -0
- package/src/PageState.ts +1 -1
- package/src/View/CameraSynchronizer.ts +8 -6
- 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
@@ -19,8 +19,8 @@ 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, isEqual, omit, isObject, has, get, size as size$1, mapValues, noop as noop$1, isNumber, throttle, delay,
|
23
|
-
import { ScenePathType, UpdateEventKind, listenUpdated, unlistenUpdated, reaction, WhiteVersion, autorun, toJS, listenDisposed, unlistenDisposed, AnimationMode, isPlayer, isRoom, ApplianceNames, RoomPhase, InvisiblePlugin
|
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, 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;
|
@@ -947,9 +946,16 @@ class WhiteBoardView {
|
|
947
946
|
};
|
948
947
|
const pageState$ = new Val(appProxy.pageState);
|
949
948
|
this.pageState$ = pageState$;
|
950
|
-
appProxy.appEmitter.on("pageStateChange", (pageState) => {
|
949
|
+
this.appProxy.sideEffectManager.add(() => appProxy.appEmitter.on("pageStateChange", (pageState) => {
|
951
950
|
pageState$.setValue(pageState);
|
952
|
-
});
|
951
|
+
}));
|
952
|
+
const camera$ = new Val(pick(this.view.camera, ["centerX", "centerY"]));
|
953
|
+
this.camera$ = camera$;
|
954
|
+
this.appProxy.sideEffectManager.add(() => appProxy.camera$.subscribe((camera) => {
|
955
|
+
if (camera) {
|
956
|
+
camera$.setValue(pick(camera, ["centerX", "centerY"]));
|
957
|
+
}
|
958
|
+
}));
|
953
959
|
view.disableCameraTransform = true;
|
954
960
|
}
|
955
961
|
get pageState() {
|
@@ -961,10 +967,6 @@ class WhiteBoardView {
|
|
961
967
|
setRect(rect) {
|
962
968
|
this.appProxy.updateSize(rect.width, rect.height);
|
963
969
|
}
|
964
|
-
destroy() {
|
965
|
-
this.pageState$.destroy();
|
966
|
-
this.removeViewWrapper();
|
967
|
-
}
|
968
970
|
}
|
969
971
|
const setupWrapper = (root) => {
|
970
972
|
const playground = document.createElement("div");
|
@@ -997,9 +999,8 @@ const serializeRoomMembers = (members) => {
|
|
997
999
|
});
|
998
1000
|
};
|
999
1001
|
class AppContext {
|
1000
|
-
constructor(manager,
|
1002
|
+
constructor(manager, appId, appProxy, appOptions) {
|
1001
1003
|
this.manager = manager;
|
1002
|
-
this.boxManager = boxManager;
|
1003
1004
|
this.appId = appId;
|
1004
1005
|
this.appProxy = appProxy;
|
1005
1006
|
this.appOptions = appOptions;
|
@@ -1040,17 +1041,17 @@ class AppContext {
|
|
1040
1041
|
this._viewWrapper = viewWrapper;
|
1041
1042
|
viewWrapper.className = "window-manager-view-wrapper";
|
1042
1043
|
(_a = this.box.$content.parentElement) == null ? void 0 : _a.appendChild(viewWrapper);
|
1043
|
-
const removeViewWrapper = () => {
|
1044
|
-
var _a2;
|
1045
|
-
(_a2 = this.box.$content.parentElement) == null ? void 0 : _a2.removeChild(viewWrapper);
|
1046
|
-
this._viewWrapper = void 0;
|
1047
|
-
};
|
1048
1044
|
view.divElement = viewWrapper;
|
1049
1045
|
this.appProxy.fireMemberStateChange();
|
1050
1046
|
if (this.isAddApp) {
|
1051
1047
|
this.ensurePageSize(size2);
|
1052
1048
|
}
|
1053
|
-
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy,
|
1049
|
+
this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, this.ensurePageSize);
|
1050
|
+
this.appProxy.sideEffectManager.add(() => {
|
1051
|
+
return () => {
|
1052
|
+
this.whiteBoardView = void 0;
|
1053
|
+
};
|
1054
|
+
});
|
1054
1055
|
return this.whiteBoardView;
|
1055
1056
|
};
|
1056
1057
|
this.ensurePageSize = (size2) => {
|
@@ -1123,7 +1124,7 @@ class AppContext {
|
|
1123
1124
|
return this.manager.canOperate && !this.destroyed;
|
1124
1125
|
}
|
1125
1126
|
get box() {
|
1126
|
-
const box = this.
|
1127
|
+
const box = this.appProxy.box$.value;
|
1127
1128
|
if (box) {
|
1128
1129
|
return box;
|
1129
1130
|
} else {
|
@@ -1243,8 +1244,11 @@ class CameraSynchronizer {
|
|
1243
1244
|
this.view = view;
|
1244
1245
|
}
|
1245
1246
|
onRemoteSizeUpdate(size2) {
|
1246
|
-
|
1247
|
-
|
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;
|
1248
1252
|
const moveCamera = () => {
|
1249
1253
|
var _a;
|
1250
1254
|
(_a = this.view) == null ? void 0 : _a.moveCamera({
|
@@ -1252,6 +1256,7 @@ class CameraSynchronizer {
|
|
1252
1256
|
animationMode: AnimationMode.Immediately
|
1253
1257
|
});
|
1254
1258
|
};
|
1259
|
+
moveCamera();
|
1255
1260
|
delay(moveCamera, 50);
|
1256
1261
|
}
|
1257
1262
|
}
|
@@ -1260,61 +1265,80 @@ class CameraSynchronizer {
|
|
1260
1265
|
this.remoteCamera = camera;
|
1261
1266
|
}
|
1262
1267
|
}
|
1263
|
-
class
|
1264
|
-
constructor(
|
1265
|
-
this.
|
1268
|
+
class ViewSync {
|
1269
|
+
constructor(context) {
|
1270
|
+
this.context = context;
|
1266
1271
|
this.sem = new SideEffectManager();
|
1267
1272
|
this.bindView = (view) => {
|
1268
1273
|
if (!view)
|
1269
1274
|
return;
|
1270
1275
|
this.synchronizer.setView(view);
|
1276
|
+
this.sem.flush("view");
|
1271
1277
|
this.sem.add(() => {
|
1272
1278
|
view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1273
1279
|
return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
1274
|
-
});
|
1280
|
+
}, "view");
|
1275
1281
|
};
|
1276
1282
|
this.onCameraUpdatedByDevice = (camera) => {
|
1277
|
-
var _a;
|
1278
1283
|
this.synchronizer.onLocalCameraUpdate(camera);
|
1279
|
-
const stage =
|
1284
|
+
const stage = this.context.stageRect$.value;
|
1280
1285
|
if (stage) {
|
1281
|
-
const size2 = { width: stage.width, height: stage.height, id: this.
|
1282
|
-
if (!isEqual(size2, this.
|
1283
|
-
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);
|
1284
1289
|
}
|
1285
1290
|
}
|
1286
1291
|
};
|
1287
1292
|
this.synchronizer = new CameraSynchronizer((camera) => {
|
1288
|
-
|
1289
|
-
id: this.
|
1290
|
-
}, 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
|
+
}
|
1291
1303
|
});
|
1292
|
-
this.bindView(
|
1293
|
-
this.sem.add(() => this.
|
1294
|
-
const
|
1295
|
-
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) {
|
1296
1319
|
this.synchronizer.onRemoteUpdate(camera, size2);
|
1297
1320
|
}
|
1298
1321
|
}));
|
1299
|
-
this.sem.add(() => this.
|
1322
|
+
this.sem.add(() => this.context.size$.subscribe((size2) => {
|
1300
1323
|
if (size2) {
|
1301
1324
|
this.synchronizer.onRemoteSizeUpdate(size2);
|
1302
1325
|
}
|
1303
1326
|
}));
|
1304
|
-
|
1305
|
-
|
1306
|
-
this.
|
1307
|
-
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) => {
|
1308
1330
|
if (rect) {
|
1309
1331
|
this.synchronizer.setRect(rect);
|
1310
1332
|
}
|
1311
1333
|
}));
|
1312
1334
|
}
|
1313
|
-
|
1335
|
+
const camera$size$ = combine([this.context.camera$, this.context.size$]);
|
1336
|
+
camera$size$.subscribe(([camera, size2]) => {
|
1314
1337
|
if (camera && size2) {
|
1315
1338
|
this.synchronizer.onRemoteUpdate(camera, size2);
|
1339
|
+
camera$size$.destroy();
|
1316
1340
|
}
|
1317
|
-
})
|
1341
|
+
});
|
1318
1342
|
}
|
1319
1343
|
destroy() {
|
1320
1344
|
this.sem.flushAll();
|
@@ -1655,17 +1679,18 @@ class AppProxy {
|
|
1655
1679
|
if (!this.camera$.value) {
|
1656
1680
|
return;
|
1657
1681
|
}
|
1658
|
-
const nextCamera = __spreadValues(__spreadValues({}, this.camera$.value), camera);
|
1682
|
+
const nextCamera = __spreadProps(__spreadValues(__spreadValues({}, this.camera$.value), camera), { id: this.uid });
|
1659
1683
|
this.storeCamera(nextCamera);
|
1684
|
+
this.camera$.setValue(nextCamera);
|
1660
1685
|
};
|
1661
1686
|
this.addCameraReaction = () => {
|
1662
1687
|
this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-camera`, () => reaction(() => {
|
1663
1688
|
var _a2;
|
1664
1689
|
return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
|
1665
1690
|
}, (camera) => {
|
1666
|
-
if (camera
|
1691
|
+
if (camera) {
|
1667
1692
|
const rawCamera = toJS(camera);
|
1668
|
-
if (rawCamera
|
1693
|
+
if (!isEqual(rawCamera, this.camera$.value)) {
|
1669
1694
|
this.camera$.setValue(rawCamera);
|
1670
1695
|
}
|
1671
1696
|
}
|
@@ -1676,9 +1701,9 @@ class AppProxy {
|
|
1676
1701
|
var _a2;
|
1677
1702
|
return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
|
1678
1703
|
}, (size2) => {
|
1679
|
-
if (size2
|
1704
|
+
if (size2) {
|
1680
1705
|
const rawSize = toJS(size2);
|
1681
|
-
if (this.size$.value
|
1706
|
+
if (!isEqual(rawSize, this.size$.value)) {
|
1682
1707
|
this.size$.setValue(rawSize);
|
1683
1708
|
}
|
1684
1709
|
}
|
@@ -1738,10 +1763,18 @@ class AppProxy {
|
|
1738
1763
|
});
|
1739
1764
|
this.size$.setValue(toJS(this.appAttributes.size));
|
1740
1765
|
}
|
1741
|
-
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
|
+
});
|
1742
1775
|
this.sideEffectManager.add(() => () => {
|
1743
1776
|
var _a2;
|
1744
|
-
return (_a2 = this.
|
1777
|
+
return (_a2 = this.viewSync) == null ? void 0 : _a2.destroy();
|
1745
1778
|
});
|
1746
1779
|
}
|
1747
1780
|
}));
|
@@ -1833,7 +1866,7 @@ class AppProxy {
|
|
1833
1866
|
if (!this.boxManager) {
|
1834
1867
|
throw new BoxManagerNotFoundError();
|
1835
1868
|
}
|
1836
|
-
const context = new AppContext(this.manager,
|
1869
|
+
const context = new AppContext(this.manager, appId, this, appOptions);
|
1837
1870
|
this.appContext = context;
|
1838
1871
|
try {
|
1839
1872
|
emitter.once(`${appId}${Events.WindowCreated}`).then(async () => {
|
@@ -2116,12 +2149,29 @@ const setDefaultCameraBound = (view) => {
|
|
2116
2149
|
};
|
2117
2150
|
class MainViewProxy {
|
2118
2151
|
constructor(manager) {
|
2119
|
-
var _a;
|
2120
2152
|
this.manager = manager;
|
2121
2153
|
this.started = false;
|
2122
2154
|
this.mainViewIsAddListener = false;
|
2123
2155
|
this.store = this.manager.store;
|
2124
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
|
+
};
|
2125
2175
|
this.startListenWritableChange = () => {
|
2126
2176
|
this.sideEffectManager.add(() => emitter.on("writableChange", (isWritable) => {
|
2127
2177
|
if (isWritable) {
|
@@ -2131,26 +2181,50 @@ class MainViewProxy {
|
|
2131
2181
|
};
|
2132
2182
|
this.addCameraReaction = () => {
|
2133
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);
|
2134
2208
|
};
|
2135
2209
|
this.cameraReaction = () => {
|
2136
2210
|
return reaction(() => this.mainViewCamera, (camera) => {
|
2137
|
-
if (camera
|
2138
|
-
|
2211
|
+
if (camera) {
|
2212
|
+
const rawCamera = toJS(camera);
|
2213
|
+
if (!isEqual(rawCamera, this.camera$.value)) {
|
2214
|
+
this.camera$.setValue(rawCamera);
|
2215
|
+
}
|
2139
2216
|
}
|
2140
2217
|
}, { fireImmediately: true });
|
2141
2218
|
};
|
2142
|
-
this.
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
if (size2 && !isEqual(size2, this.mainViewSize)) {
|
2152
|
-
this.setMainViewSize(size2);
|
2153
|
-
}
|
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 });
|
2154
2228
|
};
|
2155
2229
|
this.mainViewClickListener = () => {
|
2156
2230
|
this.mainViewClickHandler();
|
@@ -2161,9 +2235,7 @@ class MainViewProxy {
|
|
2161
2235
|
this.onCameraOrSizeUpdated = () => {
|
2162
2236
|
callbacks$1.emit("cameraStateChange", this.cameraState);
|
2163
2237
|
};
|
2164
|
-
this.synchronizer = new CameraSynchronizer((camera) => this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid })));
|
2165
2238
|
this.mainView = this.createMainView();
|
2166
|
-
this.moveCameraSizeByAttributes();
|
2167
2239
|
emitter.once("mainViewMounted").then(() => {
|
2168
2240
|
this.addMainViewListener();
|
2169
2241
|
this.start();
|
@@ -2171,23 +2243,27 @@ class MainViewProxy {
|
|
2171
2243
|
this.startListenWritableChange();
|
2172
2244
|
});
|
2173
2245
|
this.sideEffectManager.add(() => [
|
2174
|
-
emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio),
|
2175
2246
|
emitter.on("startReconnect", () => {
|
2176
2247
|
releaseView(this.mainView);
|
2177
|
-
}),
|
2178
|
-
emitter.on("playgroundSizeChange", (rect2) => {
|
2179
|
-
this.synchronizer.setRect(rect2);
|
2180
2248
|
})
|
2181
2249
|
]);
|
2182
|
-
|
2183
|
-
if (rect) {
|
2184
|
-
this.synchronizer.setRect(rect);
|
2185
|
-
}
|
2250
|
+
this.createViewSync();
|
2186
2251
|
}
|
2187
2252
|
ensureCameraAndSize() {
|
2253
|
+
var _a;
|
2188
2254
|
if (!this.mainViewCamera || !this.mainViewSize) {
|
2189
2255
|
this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
|
2190
|
-
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
|
+
}
|
2191
2267
|
}
|
2192
2268
|
}
|
2193
2269
|
get mainViewCamera() {
|
@@ -2199,9 +2275,6 @@ class MainViewProxy {
|
|
2199
2275
|
get didRelease() {
|
2200
2276
|
return get(this.view, ["didRelease"]);
|
2201
2277
|
}
|
2202
|
-
moveCameraSizeByAttributes() {
|
2203
|
-
this.synchronizer.onRemoteUpdate(this.mainViewCamera, this.mainViewSize);
|
2204
|
-
}
|
2205
2278
|
start() {
|
2206
2279
|
if (this.started)
|
2207
2280
|
return;
|
@@ -2209,14 +2282,6 @@ class MainViewProxy {
|
|
2209
2282
|
this.addCameraReaction();
|
2210
2283
|
this.started = true;
|
2211
2284
|
}
|
2212
|
-
setCameraAndSize() {
|
2213
|
-
const stageSize = this.getStageSize();
|
2214
|
-
if (stageSize) {
|
2215
|
-
const camera = __spreadProps(__spreadValues({}, this.mainView.camera), { id: this.manager.uid });
|
2216
|
-
const size2 = __spreadProps(__spreadValues({}, stageSize), { id: this.manager.uid });
|
2217
|
-
this.store.setMainViewCameraAndSize(camera, size2);
|
2218
|
-
}
|
2219
|
-
}
|
2220
2285
|
get view() {
|
2221
2286
|
return this.mainView;
|
2222
2287
|
}
|
@@ -2229,7 +2294,7 @@ class MainViewProxy {
|
|
2229
2294
|
if (mainViewScenePath) {
|
2230
2295
|
setViewFocusScenePath(mainView, mainViewScenePath);
|
2231
2296
|
}
|
2232
|
-
this.
|
2297
|
+
this.view$.setValue(mainView);
|
2233
2298
|
return mainView;
|
2234
2299
|
}
|
2235
2300
|
onReconnect() {
|
@@ -2257,13 +2322,6 @@ class MainViewProxy {
|
|
2257
2322
|
this.addMainViewListener();
|
2258
2323
|
this.start();
|
2259
2324
|
}
|
2260
|
-
getStageSize() {
|
2261
|
-
var _a;
|
2262
|
-
const stage = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
|
2263
|
-
if (stage) {
|
2264
|
-
return { width: stage.width, height: stage.height };
|
2265
|
-
}
|
2266
|
-
}
|
2267
2325
|
addMainViewListener() {
|
2268
2326
|
if (this.mainViewIsAddListener)
|
2269
2327
|
return;
|
@@ -2288,12 +2346,10 @@ class MainViewProxy {
|
|
2288
2346
|
(_a = this.manager.boxManager) == null ? void 0 : _a.blurAllBox();
|
2289
2347
|
}
|
2290
2348
|
addCameraListener() {
|
2291
|
-
this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
2292
2349
|
this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
|
2293
2350
|
this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
|
2294
2351
|
}
|
2295
2352
|
removeCameraListener() {
|
2296
|
-
this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
|
2297
2353
|
this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
|
2298
2354
|
this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
|
2299
2355
|
}
|
@@ -2304,6 +2360,9 @@ class MainViewProxy {
|
|
2304
2360
|
this.started = false;
|
2305
2361
|
}
|
2306
2362
|
destroy() {
|
2363
|
+
this.camera$.destroy();
|
2364
|
+
this.size$.destroy();
|
2365
|
+
this.view$.destroy();
|
2307
2366
|
this.removeMainViewListener();
|
2308
2367
|
this.stop();
|
2309
2368
|
this.sideEffectManager.flushAll();
|
@@ -2399,7 +2458,7 @@ class AppManager {
|
|
2399
2458
|
sceneName = (_b = this.callbacksNode) == null ? void 0 : _b.scenes[nextIndex];
|
2400
2459
|
}
|
2401
2460
|
if (sceneName) {
|
2402
|
-
this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
|
2461
|
+
await this.setMainViewScenePath(`${ROOT_DIR}${sceneName}`);
|
2403
2462
|
}
|
2404
2463
|
await this.setMainViewSceneIndex(nextIndex);
|
2405
2464
|
} else {
|
@@ -2639,7 +2698,7 @@ class AppManager {
|
|
2639
2698
|
this.displayerWritableListener = (isReadonly) => {
|
2640
2699
|
var _a, _b;
|
2641
2700
|
const isWritable = !isReadonly;
|
2642
|
-
const isManualWritable = this.windowManger.readonly === void 0 || this.windowManger.readonly
|
2701
|
+
const isManualWritable = this.windowManger.readonly === void 0 || !this.windowManger.readonly;
|
2643
2702
|
if (this.windowManger.readonly === void 0) {
|
2644
2703
|
(_a = this.boxManager) == null ? void 0 : _a.setReadonly(isReadonly);
|
2645
2704
|
} else {
|
@@ -2648,7 +2707,7 @@ class AppManager {
|
|
2648
2707
|
this.appProxies.forEach((appProxy) => {
|
2649
2708
|
appProxy.emitAppIsWritableChange();
|
2650
2709
|
});
|
2651
|
-
if (isWritable
|
2710
|
+
if (isWritable) {
|
2652
2711
|
if (this.room && this.room.disableSerialization === true) {
|
2653
2712
|
this.room.disableSerialization = false;
|
2654
2713
|
}
|
@@ -2709,7 +2768,7 @@ class AppManager {
|
|
2709
2768
|
});
|
2710
2769
|
}
|
2711
2770
|
async onRootDirRemoved(needClose = true) {
|
2712
|
-
this.setMainViewScenePath(INIT_DIR);
|
2771
|
+
await this.setMainViewScenePath(INIT_DIR);
|
2713
2772
|
this.createRootDirScenesCallback();
|
2714
2773
|
for (const [id2, appProxy] of this.appProxies.entries()) {
|
2715
2774
|
if (appProxy.view) {
|
@@ -2717,7 +2776,7 @@ class AppManager {
|
|
2717
2776
|
}
|
2718
2777
|
}
|
2719
2778
|
this.mainViewProxy.rebind();
|
2720
|
-
emitter.emit("rootDirRemoved");
|
2779
|
+
await emitter.emit("rootDirRemoved");
|
2721
2780
|
this.updateRootDirRemoving(false);
|
2722
2781
|
}
|
2723
2782
|
get eventName() {
|
@@ -2856,6 +2915,7 @@ class AppManager {
|
|
2856
2915
|
}
|
2857
2916
|
setBoxManager(boxManager) {
|
2858
2917
|
this.boxManager = boxManager;
|
2918
|
+
this.mainViewProxy.createViewSync();
|
2859
2919
|
}
|
2860
2920
|
resetMaximized() {
|
2861
2921
|
var _a;
|
@@ -4226,7 +4286,7 @@ class Y$3 {
|
|
4226
4286
|
if (!this.$stage) {
|
4227
4287
|
const e4 = document.createElement("div");
|
4228
4288
|
this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
|
4229
|
-
|
4289
|
+
e4.style.top = t4.y + "px", e4.style.left = t4.x + "px", e4.style.width = t4.width + "px", e4.style.height = t4.height + "px";
|
4230
4290
|
}), "content-stage-rect"), r2.appendChild(e4);
|
4231
4291
|
}
|
4232
4292
|
this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
|
@@ -4765,6 +4825,9 @@ class BoxManager {
|
|
4765
4825
|
get stageRect() {
|
4766
4826
|
return this.teleBoxManager.stageRect;
|
4767
4827
|
}
|
4828
|
+
get stageRect$() {
|
4829
|
+
return this.teleBoxManager._stageRect$;
|
4830
|
+
}
|
4768
4831
|
createBox(params) {
|
4769
4832
|
var _a, _b, _c;
|
4770
4833
|
if (!this.teleBoxManager)
|
@@ -15539,14 +15602,15 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
|
|
15539
15602
|
const _WindowManager = class extends InvisiblePlugin {
|
15540
15603
|
constructor(context) {
|
15541
15604
|
super(context);
|
15542
|
-
this.version = "1.0.0-canary.
|
15543
|
-
this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15605
|
+
this.version = "1.0.0-canary.16";
|
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" } };
|
15544
15607
|
this.emitter = callbacks$1;
|
15545
15608
|
this.viewMode = ViewMode.Broadcaster;
|
15609
|
+
this.viewMode$ = new Val(ViewMode.Broadcaster);
|
15546
15610
|
this.isReplay = isPlayer(this.displayer);
|
15547
15611
|
this.containerSizeRatio = _WindowManager.containerSizeRatio;
|
15548
15612
|
_WindowManager.displayer = context.displayer;
|
15549
|
-
window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.
|
15613
|
+
window.NETLESS_DEPS = { "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" } };
|
15550
15614
|
}
|
15551
15615
|
static async mount(params) {
|
15552
15616
|
var _a;
|
@@ -15882,17 +15946,20 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
15882
15946
|
addEmitterOnceListener(`destroy-${kind2}`, listener);
|
15883
15947
|
}
|
15884
15948
|
setViewMode(mode) {
|
15885
|
-
var _a
|
15949
|
+
var _a;
|
15950
|
+
log("setViewMode", mode);
|
15951
|
+
const mainViewProxy = (_a = this.appManager) == null ? void 0 : _a.mainViewProxy;
|
15886
15952
|
if (mode === ViewMode.Broadcaster) {
|
15887
15953
|
if (this.canOperate) {
|
15888
|
-
|
15954
|
+
mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
|
15889
15955
|
}
|
15890
|
-
|
15956
|
+
mainViewProxy == null ? void 0 : mainViewProxy.start();
|
15891
15957
|
}
|
15892
15958
|
if (mode === ViewMode.Freedom) {
|
15893
|
-
|
15959
|
+
mainViewProxy == null ? void 0 : mainViewProxy.stop();
|
15894
15960
|
}
|
15895
15961
|
this.viewMode = mode;
|
15962
|
+
this.viewMode$.setValue(mode);
|
15896
15963
|
}
|
15897
15964
|
setBoxState(boxState) {
|
15898
15965
|
if (!this.canOperate)
|
@@ -16039,7 +16106,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
16039
16106
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCamera, camera);
|
16040
16107
|
setTimeout(() => {
|
16041
16108
|
var _a2;
|
16042
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
16109
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
|
16043
16110
|
}, 500);
|
16044
16111
|
}
|
16045
16112
|
moveCameraToContain(rectangle) {
|
@@ -16048,7 +16115,7 @@ const _WindowManager = class extends InvisiblePlugin {
|
|
16048
16115
|
(_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
|
16049
16116
|
setTimeout(() => {
|
16050
16117
|
var _a2;
|
16051
|
-
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.
|
16118
|
+
(_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
|
16052
16119
|
}, 500);
|
16053
16120
|
}
|
16054
16121
|
convertToPointInWorld(point) {
|