@netless/window-manager 1.0.0-canary.15 → 1.0.0-canary.18

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.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, ViewMode } from "white-web-sdk";
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, removeViewWrapper, ensureSize) {
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, boxManager, appId, appProxy, appOptions) {
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, removeViewWrapper, this.ensurePageSize);
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.boxManager.getBox(this.appId);
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
- if (this.rect) {
1262
- const nextScale = this.rect.width / size2.width;
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,77 @@ class CameraSynchronizer {
1275
1265
  this.remoteCamera = camera;
1276
1266
  }
1277
1267
  }
1278
- class AppViewSync {
1279
- constructor(appProxy) {
1280
- this.appProxy = appProxy;
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 = (_a = this.appProxy.box) == null ? void 0 : _a.contentStageRect;
1284
+ const stage = this.context.stageRect$.value;
1295
1285
  if (stage) {
1296
- const size2 = { width: stage.width, height: stage.height, id: this.appProxy.uid };
1297
- if (!isEqual(size2, this.appProxy.size$.value)) {
1298
- this.appProxy.storeSize(size2);
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
- this.appProxy.storeCamera(__spreadValues({
1304
- id: this.appProxy.uid
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(appProxy.view);
1308
- this.sem.add(() => this.appProxy.camera$.subscribe((camera) => {
1309
- const size2 = this.appProxy.size$.value;
1310
- if (camera && size2) {
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.appProxy.size$.subscribe((size2) => {
1322
+ this.sem.add(() => this.context.size$.subscribe((size2) => {
1315
1323
  if (size2) {
1316
1324
  this.synchronizer.onRemoteSizeUpdate(size2);
1317
1325
  }
1318
1326
  }));
1319
- const box = this.appProxy.box;
1320
- if (box && box.contentStageRect) {
1321
- this.synchronizer.setRect(box.contentStageRect);
1322
- this.sem.add(() => box._contentStageRect$.subscribe((rect) => {
1323
- if (rect) {
1324
- this.synchronizer.setRect(rect);
1325
- }
1326
- }));
1327
- }
1328
- this.sem.add(() => combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size2]) => {
1327
+ this.sem.add(() => this.context.stageRect$.reaction((rect) => {
1328
+ if (rect) {
1329
+ this.synchronizer.setRect(rect);
1330
+ }
1331
+ }));
1332
+ const camera$size$ = combine([this.context.camera$, this.context.size$]);
1333
+ camera$size$.reaction(([camera, size2]) => {
1329
1334
  if (camera && size2) {
1330
1335
  this.synchronizer.onRemoteUpdate(camera, size2);
1336
+ camera$size$.destroy();
1331
1337
  }
1332
- }));
1338
+ });
1333
1339
  }
1334
1340
  destroy() {
1335
1341
  this.sem.flushAll();
@@ -1679,9 +1685,9 @@ class AppProxy {
1679
1685
  var _a2;
1680
1686
  return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
1681
1687
  }, (camera) => {
1682
- if (camera && camera.id !== this.uid) {
1688
+ if (camera) {
1683
1689
  const rawCamera = toJS(camera);
1684
- if (rawCamera !== this.camera$.value) {
1690
+ if (!isEqual(rawCamera, this.camera$.value)) {
1685
1691
  this.camera$.setValue(rawCamera);
1686
1692
  }
1687
1693
  }
@@ -1692,9 +1698,9 @@ class AppProxy {
1692
1698
  var _a2;
1693
1699
  return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
1694
1700
  }, (size2) => {
1695
- if (size2 && size2.id !== this.uid) {
1701
+ if (size2) {
1696
1702
  const rawSize = toJS(size2);
1697
- if (this.size$.value !== rawSize) {
1703
+ if (!isEqual(rawSize, this.size$.value)) {
1698
1704
  this.size$.setValue(rawSize);
1699
1705
  }
1700
1706
  }
@@ -1754,10 +1760,18 @@ class AppProxy {
1754
1760
  });
1755
1761
  this.size$.setValue(toJS(this.appAttributes.size));
1756
1762
  }
1757
- this.appViewSync = new AppViewSync(this);
1763
+ this.viewSync = new ViewSync({
1764
+ uid: this.uid,
1765
+ view$: this.view$,
1766
+ camera$: this.camera$,
1767
+ size$: this.size$,
1768
+ stageRect$: box._contentStageRect$,
1769
+ storeCamera: this.storeCamera,
1770
+ storeSize: this.storeSize
1771
+ });
1758
1772
  this.sideEffectManager.add(() => () => {
1759
1773
  var _a2;
1760
- return (_a2 = this.appViewSync) == null ? void 0 : _a2.destroy();
1774
+ return (_a2 = this.viewSync) == null ? void 0 : _a2.destroy();
1761
1775
  });
1762
1776
  }
1763
1777
  }));
@@ -1849,7 +1863,7 @@ class AppProxy {
1849
1863
  if (!this.boxManager) {
1850
1864
  throw new BoxManagerNotFoundError();
1851
1865
  }
1852
- const context = new AppContext(this.manager, this.boxManager, appId, this, appOptions);
1866
+ const context = new AppContext(this.manager, appId, this, appOptions);
1853
1867
  this.appContext = context;
1854
1868
  try {
1855
1869
  emitter.once(`${appId}${Events.WindowCreated}`).then(async () => {
@@ -1890,12 +1904,14 @@ class AppProxy {
1890
1904
  var _a, _b;
1891
1905
  const box = (_a = this.boxManager) == null ? void 0 : _a.getBox(this.id);
1892
1906
  if (box) {
1893
- (_b = this.boxManager) == null ? void 0 : _b.resizeBox({
1894
- appId: this.id,
1895
- width: box.intrinsicWidth + 1e-3,
1896
- height: box.intrinsicHeight + 1e-3,
1897
- skipUpdate: true
1898
- });
1907
+ if (!box.minimized) {
1908
+ (_b = this.boxManager) == null ? void 0 : _b.resizeBox({
1909
+ appId: this.id,
1910
+ width: box.intrinsicWidth + 1e-3,
1911
+ height: box.intrinsicHeight + 1e-3,
1912
+ skipUpdate: true
1913
+ });
1914
+ }
1899
1915
  }
1900
1916
  }
1901
1917
  async onSeek(time2) {
@@ -2074,6 +2090,8 @@ class AppProxy {
2074
2090
  this.manager.refresher.remove(this.id);
2075
2091
  this.manager.refresher.remove(this.stateKey);
2076
2092
  this.manager.refresher.remove(`${this.id}-fullPath`);
2093
+ this.manager.refresher.remove(`${this.id}-camera`);
2094
+ this.manager.refresher.remove(`${this.id}-size`);
2077
2095
  this.valManager.destroy();
2078
2096
  }
2079
2097
  close() {
@@ -2132,12 +2150,29 @@ const setDefaultCameraBound = (view) => {
2132
2150
  };
2133
2151
  class MainViewProxy {
2134
2152
  constructor(manager) {
2135
- var _a;
2136
2153
  this.manager = manager;
2137
2154
  this.started = false;
2138
2155
  this.mainViewIsAddListener = false;
2139
2156
  this.store = this.manager.store;
2140
2157
  this.sideEffectManager = new SideEffectManager();
2158
+ this.camera$ = new Val(void 0);
2159
+ this.size$ = new Val(void 0);
2160
+ this.view$ = new Val(void 0);
2161
+ this.createViewSync = () => {
2162
+ var _a;
2163
+ if (this.manager.boxManager && !this.viewSync) {
2164
+ this.viewSync = new ViewSync({
2165
+ uid: this.manager.uid,
2166
+ view$: this.view$,
2167
+ camera$: this.camera$,
2168
+ size$: this.size$,
2169
+ stageRect$: (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect$,
2170
+ viewMode$: this.manager.windowManger.viewMode$,
2171
+ storeCamera: this.storeCamera,
2172
+ storeSize: this.storeSize
2173
+ });
2174
+ }
2175
+ };
2141
2176
  this.startListenWritableChange = () => {
2142
2177
  this.sideEffectManager.add(() => emitter.on("writableChange", (isWritable) => {
2143
2178
  if (isWritable) {
@@ -2147,26 +2182,50 @@ class MainViewProxy {
2147
2182
  };
2148
2183
  this.addCameraReaction = () => {
2149
2184
  this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
2185
+ this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
2186
+ };
2187
+ this.storeCurrentCamera = () => {
2188
+ const iCamera = this.view.camera;
2189
+ this.storeCamera(__spreadValues({
2190
+ id: this.manager.uid
2191
+ }, iCamera));
2192
+ };
2193
+ this.storeCurrentSize = () => {
2194
+ var _a;
2195
+ const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
2196
+ if (rect) {
2197
+ this.storeSize({
2198
+ id: this.manager.uid,
2199
+ width: rect.width,
2200
+ height: rect.height
2201
+ });
2202
+ }
2203
+ };
2204
+ this.storeCamera = (camera) => {
2205
+ this.store.setMainViewCamera(camera);
2206
+ };
2207
+ this.storeSize = (size2) => {
2208
+ this.store.setMainViewSize(size2);
2150
2209
  };
2151
2210
  this.cameraReaction = () => {
2152
2211
  return reaction(() => this.mainViewCamera, (camera) => {
2153
- if (camera && camera.id !== this.manager.uid) {
2154
- this.synchronizer.onRemoteUpdate(camera, this.mainViewSize);
2212
+ if (camera) {
2213
+ const rawCamera = toJS(camera);
2214
+ if (!isEqual(rawCamera, this.camera$.value)) {
2215
+ this.camera$.setValue(rawCamera);
2216
+ }
2155
2217
  }
2156
2218
  }, { fireImmediately: true });
2157
2219
  };
2158
- this.onUpdateContainerSizeRatio = () => {
2159
- const size2 = this.store.getMainViewSize();
2160
- if (size2.id === this.manager.uid) {
2161
- this.setCameraAndSize();
2162
- }
2163
- };
2164
- this.onCameraUpdatedByDevice = (camera) => {
2165
- this.synchronizer.onLocalCameraUpdate(camera);
2166
- const size2 = this.getStageSize();
2167
- if (size2 && !isEqual(size2, this.mainViewSize)) {
2168
- this.setMainViewSize(size2);
2169
- }
2220
+ this.sizeReaction = () => {
2221
+ return reaction(() => this.mainViewSize, (size2) => {
2222
+ if (size2) {
2223
+ const rawSize = toJS(size2);
2224
+ if (!isEqual(rawSize, this.size$.value)) {
2225
+ this.size$.setValue(rawSize);
2226
+ }
2227
+ }
2228
+ }, { fireImmediately: true });
2170
2229
  };
2171
2230
  this.mainViewClickListener = () => {
2172
2231
  this.mainViewClickHandler();
@@ -2177,9 +2236,7 @@ class MainViewProxy {
2177
2236
  this.onCameraOrSizeUpdated = () => {
2178
2237
  callbacks$1.emit("cameraStateChange", this.cameraState);
2179
2238
  };
2180
- this.synchronizer = new CameraSynchronizer((camera) => this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid })));
2181
2239
  this.mainView = this.createMainView();
2182
- this.moveCameraSizeByAttributes();
2183
2240
  emitter.once("mainViewMounted").then(() => {
2184
2241
  this.addMainViewListener();
2185
2242
  this.start();
@@ -2187,23 +2244,35 @@ class MainViewProxy {
2187
2244
  this.startListenWritableChange();
2188
2245
  });
2189
2246
  this.sideEffectManager.add(() => [
2190
- emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio),
2191
2247
  emitter.on("startReconnect", () => {
2192
2248
  releaseView(this.mainView);
2193
- }),
2194
- emitter.on("playgroundSizeChange", (rect2) => {
2195
- this.synchronizer.setRect(rect2);
2196
2249
  })
2197
2250
  ]);
2198
- const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
2199
- if (rect) {
2200
- this.synchronizer.setRect(rect);
2201
- }
2251
+ this.createViewSync();
2252
+ this.sideEffectManager.add(() => emitter.on("focusedChange", ({ focused }) => {
2253
+ if (focused === void 0) {
2254
+ const scenePath = this.store.getMainViewScenePath();
2255
+ if (scenePath) {
2256
+ setScenePath(this.manager.room, scenePath);
2257
+ }
2258
+ }
2259
+ }));
2202
2260
  }
2203
2261
  ensureCameraAndSize() {
2262
+ var _a;
2204
2263
  if (!this.mainViewCamera || !this.mainViewSize) {
2205
2264
  this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
2206
- this.setCameraAndSize();
2265
+ this.storeCamera(__spreadValues({
2266
+ id: this.manager.uid
2267
+ }, this.view.camera));
2268
+ const stageRect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
2269
+ if (stageRect && !this.mainViewSize) {
2270
+ this.storeSize({
2271
+ id: this.manager.uid,
2272
+ width: stageRect.width,
2273
+ height: stageRect.height
2274
+ });
2275
+ }
2207
2276
  }
2208
2277
  }
2209
2278
  get mainViewCamera() {
@@ -2215,9 +2284,6 @@ class MainViewProxy {
2215
2284
  get didRelease() {
2216
2285
  return get(this.view, ["didRelease"]);
2217
2286
  }
2218
- moveCameraSizeByAttributes() {
2219
- this.synchronizer.onRemoteUpdate(this.mainViewCamera, this.mainViewSize);
2220
- }
2221
2287
  start() {
2222
2288
  if (this.started)
2223
2289
  return;
@@ -2225,14 +2291,6 @@ class MainViewProxy {
2225
2291
  this.addCameraReaction();
2226
2292
  this.started = true;
2227
2293
  }
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
2294
  get view() {
2237
2295
  return this.mainView;
2238
2296
  }
@@ -2245,7 +2303,7 @@ class MainViewProxy {
2245
2303
  if (mainViewScenePath) {
2246
2304
  setViewFocusScenePath(mainView, mainViewScenePath);
2247
2305
  }
2248
- this.synchronizer.setView(mainView);
2306
+ this.view$.setValue(mainView);
2249
2307
  return mainView;
2250
2308
  }
2251
2309
  onReconnect() {
@@ -2273,13 +2331,6 @@ class MainViewProxy {
2273
2331
  this.addMainViewListener();
2274
2332
  this.start();
2275
2333
  }
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
2334
  addMainViewListener() {
2284
2335
  if (this.mainViewIsAddListener)
2285
2336
  return;
@@ -2304,12 +2355,10 @@ class MainViewProxy {
2304
2355
  (_a = this.manager.boxManager) == null ? void 0 : _a.blurAllBox();
2305
2356
  }
2306
2357
  addCameraListener() {
2307
- this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
2308
2358
  this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
2309
2359
  this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
2310
2360
  }
2311
2361
  removeCameraListener() {
2312
- this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
2313
2362
  this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
2314
2363
  this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
2315
2364
  }
@@ -2320,6 +2369,9 @@ class MainViewProxy {
2320
2369
  this.started = false;
2321
2370
  }
2322
2371
  destroy() {
2372
+ this.camera$.destroy();
2373
+ this.size$.destroy();
2374
+ this.view$.destroy();
2323
2375
  this.removeMainViewListener();
2324
2376
  this.stop();
2325
2377
  this.sideEffectManager.flushAll();
@@ -2634,7 +2686,6 @@ class AppManager {
2634
2686
  if (sceneState) {
2635
2687
  const scenePath = sceneState.scenePath;
2636
2688
  this.appProxies.forEach((appProxy) => {
2637
- console.log("scenePath", scenePath, appProxy.scenePath);
2638
2689
  if (appProxy.scenePath && scenePath.startsWith(appProxy.scenePath)) {
2639
2690
  appProxy.emitAppSceneStateChange(sceneState);
2640
2691
  appProxy.setFullPath(scenePath);
@@ -2872,6 +2923,7 @@ class AppManager {
2872
2923
  }
2873
2924
  setBoxManager(boxManager) {
2874
2925
  this.boxManager = boxManager;
2926
+ this.mainViewProxy.createViewSync();
2875
2927
  }
2876
2928
  resetMaximized() {
2877
2929
  var _a;
@@ -4218,13 +4270,19 @@ class Y$3 {
4218
4270
  const o2 = document.createElement("div");
4219
4271
  o2.className = this.wrapClassName("content-wrap");
4220
4272
  const r2 = document.createElement("div");
4221
- r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2, this._sideEffect.add(() => {
4273
+ r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2;
4274
+ const h = () => {
4275
+ const e3 = r2.getBoundingClientRect();
4276
+ this._contentRect$.setValue({ x: 0, y: 0, width: e3.width, height: e3.height });
4277
+ };
4278
+ this._sideEffect.add(() => {
4222
4279
  const e3 = new W$3(() => {
4223
- const e4 = r2.getBoundingClientRect();
4224
- this._contentRect$.setValue({ x: 0, y: 0, width: e4.width, height: e4.height });
4280
+ this.minimized || h();
4225
4281
  });
4226
4282
  return e3.observe(r2), () => e3.disconnect();
4227
- }), this._sideEffect.add(() => {
4283
+ }), this._sideEffect.addDisposer(this._minimized$.reaction((e3) => {
4284
+ e3 || this._sideEffect.setTimeout(h, 400, "minimized-content-rect-fix");
4285
+ })), this._sideEffect.add(() => {
4228
4286
  let e3;
4229
4287
  return this._$userStyles$.subscribe((t3) => {
4230
4288
  e3 && e3.remove(), e3 = t3, t3 && o2.appendChild(t3);
@@ -4250,13 +4308,13 @@ class Y$3 {
4250
4308
  ((i3 = this.$stage) == null ? void 0 : i3.parentElement) && this.$stage.remove();
4251
4309
  });
4252
4310
  }), o2.appendChild(r2);
4253
- const h = document.createElement("div");
4254
- return h.className = this.wrapClassName("footer-wrap"), this.$footer = h, this._sideEffect.add(() => {
4311
+ const c = document.createElement("div");
4312
+ return c.className = this.wrapClassName("footer-wrap"), this.$footer = c, this._sideEffect.add(() => {
4255
4313
  let e3;
4256
4314
  return this._$userFooter$.subscribe((t3) => {
4257
- e3 && e3.remove(), e3 = t3, t3 && h.appendChild(t3);
4315
+ e3 && e3.remove(), e3 = t3, t3 && c.appendChild(t3);
4258
4316
  });
4259
- }), a2.appendChild(n2), a2.appendChild(o2), a2.appendChild(h), this._renderResizeHandlers(), this.$box;
4317
+ }), a2.appendChild(n2), a2.appendChild(o2), a2.appendChild(c), this._renderResizeHandlers(), this.$box;
4260
4318
  }
4261
4319
  _renderResizeHandlers() {
4262
4320
  const e2 = document.createElement("div");
@@ -4781,6 +4839,9 @@ class BoxManager {
4781
4839
  get stageRect() {
4782
4840
  return this.teleBoxManager.stageRect;
4783
4841
  }
4842
+ get stageRect$() {
4843
+ return this.teleBoxManager._stageRect$;
4844
+ }
4784
4845
  createBox(params) {
4785
4846
  var _a, _b, _c;
4786
4847
  if (!this.teleBoxManager)
@@ -5881,7 +5942,7 @@ class ReconnectRefresher {
5881
5942
  };
5882
5943
  this.onReconnected = debounce(() => {
5883
5944
  this._onReconnected();
5884
- }, 3e3);
5945
+ }, 1e3);
5885
5946
  this._onReconnected = () => {
5886
5947
  log("onReconnected refresh reactors");
5887
5948
  this.releaseDisposers();
@@ -6001,6 +6062,9 @@ const replaceRoomFunction = (room, manager) => {
6001
6062
  room.lockImage = (...args) => manager.lockImage(...args);
6002
6063
  room.lockImages = (...args) => manager.lockImages(...args);
6003
6064
  delegateRemoveScenes(room, manager);
6065
+ if (!room.dynamicPpt.slideStateAdapter.pptHandler) {
6066
+ room.dynamicPpt.slideStateAdapter.pptHandler = manager.createPPTHandler();
6067
+ }
6004
6068
  }
6005
6069
  };
6006
6070
  const delegateRemoveScenes = (room, manager) => {
@@ -15555,14 +15619,15 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
15555
15619
  const _WindowManager = class extends InvisiblePlugin {
15556
15620
  constructor(context) {
15557
15621
  super(context);
15558
- this.version = "1.0.0-canary.15";
15559
- 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" } };
15622
+ this.version = "1.0.0-canary.18";
15623
+ this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "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
15624
  this.emitter = callbacks$1;
15561
15625
  this.viewMode = ViewMode.Broadcaster;
15626
+ this.viewMode$ = new Val(ViewMode.Broadcaster);
15562
15627
  this.isReplay = isPlayer(this.displayer);
15563
15628
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
15564
15629
  _WindowManager.displayer = context.displayer;
15565
- 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" } };
15630
+ window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.18", "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" } };
15566
15631
  }
15567
15632
  static async mount(params) {
15568
15633
  var _a;
@@ -15898,17 +15963,20 @@ const _WindowManager = class extends InvisiblePlugin {
15898
15963
  addEmitterOnceListener(`destroy-${kind2}`, listener);
15899
15964
  }
15900
15965
  setViewMode(mode) {
15901
- var _a, _b, _c;
15966
+ var _a;
15967
+ log("setViewMode", mode);
15968
+ const mainViewProxy = (_a = this.appManager) == null ? void 0 : _a.mainViewProxy;
15902
15969
  if (mode === ViewMode.Broadcaster) {
15903
15970
  if (this.canOperate) {
15904
- (_a = this.appManager) == null ? void 0 : _a.mainViewProxy.setCameraAndSize();
15971
+ mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
15905
15972
  }
15906
- (_b = this.appManager) == null ? void 0 : _b.mainViewProxy.start();
15973
+ mainViewProxy == null ? void 0 : mainViewProxy.start();
15907
15974
  }
15908
15975
  if (mode === ViewMode.Freedom) {
15909
- (_c = this.appManager) == null ? void 0 : _c.mainViewProxy.stop();
15976
+ mainViewProxy == null ? void 0 : mainViewProxy.stop();
15910
15977
  }
15911
15978
  this.viewMode = mode;
15979
+ this.viewMode$.setValue(mode);
15912
15980
  }
15913
15981
  setBoxState(boxState) {
15914
15982
  if (!this.canOperate)
@@ -16055,7 +16123,7 @@ const _WindowManager = class extends InvisiblePlugin {
16055
16123
  (_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCamera, camera);
16056
16124
  setTimeout(() => {
16057
16125
  var _a2;
16058
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.setCameraAndSize();
16126
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
16059
16127
  }, 500);
16060
16128
  }
16061
16129
  moveCameraToContain(rectangle) {
@@ -16064,7 +16132,7 @@ const _WindowManager = class extends InvisiblePlugin {
16064
16132
  (_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
16065
16133
  setTimeout(() => {
16066
16134
  var _a2;
16067
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.setCameraAndSize();
16135
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
16068
16136
  }, 500);
16069
16137
  }
16070
16138
  convertToPointInWorld(point) {
@@ -16191,6 +16259,26 @@ const _WindowManager = class extends InvisiblePlugin {
16191
16259
  this.containerSizeRatio = ratio;
16192
16260
  emitter.emit("containerSizeRatioUpdate", ratio);
16193
16261
  }
16262
+ createPPTHandler() {
16263
+ return {
16264
+ onPageJumpTo: (_pptUUID, index2) => {
16265
+ var _a, _b, _c, _d;
16266
+ (_d = (_c = (_b = (_a = this.appManager) == null ? void 0 : _a.focusApp) == null ? void 0 : _b.appContext) == null ? void 0 : _c.whiteBoardView) == null ? void 0 : _d.jumpPage(index2);
16267
+ },
16268
+ onPageToNext: () => {
16269
+ var _a, _b, _c, _d;
16270
+ if (this.focused) {
16271
+ (_d = (_c = (_b = (_a = this.appManager) == null ? void 0 : _a.focusApp) == null ? void 0 : _b.appContext) == null ? void 0 : _c.whiteBoardView) == null ? void 0 : _d.nextPage();
16272
+ }
16273
+ },
16274
+ onPageToPrev: () => {
16275
+ var _a, _b, _c, _d;
16276
+ if (this.focused) {
16277
+ (_d = (_c = (_b = (_a = this.appManager) == null ? void 0 : _a.focusApp) == null ? void 0 : _b.appContext) == null ? void 0 : _c.whiteBoardView) == null ? void 0 : _d.prevPage();
16278
+ }
16279
+ }
16280
+ };
16281
+ }
16194
16282
  isDynamicPPT(scenes) {
16195
16283
  var _a, _b;
16196
16284
  const sceneSrc = (_b = (_a = scenes[0]) == null ? void 0 : _a.ppt) == null ? void 0 : _b.src;