@netless/window-manager 1.0.0-canary.14 → 1.0.0-canary.17

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
@@ -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, pick, 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";
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, 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;
@@ -947,16 +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
- });
953
- const camera$ = new Val(this.view.camera);
951
+ }));
952
+ const camera$ = new Val(pick(this.view.camera, ["centerX", "centerY"]));
954
953
  this.camera$ = camera$;
955
- appProxy.camera$.subscribe((camera) => {
954
+ this.appProxy.sideEffectManager.add(() => appProxy.camera$.subscribe((camera) => {
956
955
  if (camera) {
957
- camera$.setValue(camera, true);
956
+ camera$.setValue(pick(camera, ["centerX", "centerY"]));
958
957
  }
959
- });
958
+ }));
960
959
  view.disableCameraTransform = true;
961
960
  }
962
961
  get pageState() {
@@ -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,17 +1041,17 @@ 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);
1050
+ this.appProxy.sideEffectManager.add(() => {
1051
+ return () => {
1052
+ this.whiteBoardView = void 0;
1053
+ };
1054
+ });
1062
1055
  return this.whiteBoardView;
1063
1056
  };
1064
1057
  this.ensurePageSize = (size2) => {
@@ -1131,7 +1124,7 @@ class AppContext {
1131
1124
  return this.manager.canOperate && !this.destroyed;
1132
1125
  }
1133
1126
  get box() {
1134
- const box = this.boxManager.getBox(this.appId);
1127
+ const box = this.appProxy.box$.value;
1135
1128
  if (box) {
1136
1129
  return box;
1137
1130
  } else {
@@ -1251,8 +1244,11 @@ class CameraSynchronizer {
1251
1244
  this.view = view;
1252
1245
  }
1253
1246
  onRemoteSizeUpdate(size2) {
1254
- if (this.rect) {
1255
- 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;
1256
1252
  const moveCamera = () => {
1257
1253
  var _a;
1258
1254
  (_a = this.view) == null ? void 0 : _a.moveCamera({
@@ -1260,6 +1256,7 @@ class CameraSynchronizer {
1260
1256
  animationMode: AnimationMode.Immediately
1261
1257
  });
1262
1258
  };
1259
+ moveCamera();
1263
1260
  delay(moveCamera, 50);
1264
1261
  }
1265
1262
  }
@@ -1268,61 +1265,77 @@ class CameraSynchronizer {
1268
1265
  this.remoteCamera = camera;
1269
1266
  }
1270
1267
  }
1271
- class AppViewSync {
1272
- constructor(appProxy) {
1273
- this.appProxy = appProxy;
1268
+ class ViewSync {
1269
+ constructor(context) {
1270
+ this.context = context;
1274
1271
  this.sem = new SideEffectManager();
1275
1272
  this.bindView = (view) => {
1276
1273
  if (!view)
1277
1274
  return;
1278
1275
  this.synchronizer.setView(view);
1276
+ this.sem.flush("view");
1279
1277
  this.sem.add(() => {
1280
1278
  view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
1281
1279
  return () => view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
1282
- });
1280
+ }, "view");
1283
1281
  };
1284
1282
  this.onCameraUpdatedByDevice = (camera) => {
1285
- var _a;
1286
1283
  this.synchronizer.onLocalCameraUpdate(camera);
1287
- const stage = (_a = this.appProxy.box) == null ? void 0 : _a.contentStageRect;
1284
+ const stage = this.context.stageRect$.value;
1288
1285
  if (stage) {
1289
- const size2 = { width: stage.width, height: stage.height, id: this.appProxy.uid };
1290
- if (!isEqual(size2, this.appProxy.size$.value)) {
1291
- 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);
1292
1289
  }
1293
1290
  }
1294
1291
  };
1295
1292
  this.synchronizer = new CameraSynchronizer((camera) => {
1296
- this.appProxy.storeCamera(__spreadValues({
1297
- id: this.appProxy.uid
1298
- }, 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
+ }
1299
1303
  });
1300
- this.bindView(appProxy.view);
1301
- this.sem.add(() => this.appProxy.camera$.subscribe((camera) => {
1302
- const size2 = this.appProxy.size$.value;
1303
- 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) {
1304
1319
  this.synchronizer.onRemoteUpdate(camera, size2);
1305
1320
  }
1306
1321
  }));
1307
- this.sem.add(() => this.appProxy.size$.subscribe((size2) => {
1322
+ this.sem.add(() => this.context.size$.subscribe((size2) => {
1308
1323
  if (size2) {
1309
1324
  this.synchronizer.onRemoteSizeUpdate(size2);
1310
1325
  }
1311
1326
  }));
1312
- const box = this.appProxy.box;
1313
- if (box && box.contentStageRect) {
1314
- this.synchronizer.setRect(box.contentStageRect);
1315
- this.sem.add(() => box._contentStageRect$.subscribe((rect) => {
1316
- if (rect) {
1317
- this.synchronizer.setRect(rect);
1318
- }
1319
- }));
1320
- }
1321
- 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]) => {
1322
1334
  if (camera && size2) {
1323
1335
  this.synchronizer.onRemoteUpdate(camera, size2);
1336
+ camera$size$.destroy();
1324
1337
  }
1325
- }));
1338
+ });
1326
1339
  }
1327
1340
  destroy() {
1328
1341
  this.sem.flushAll();
@@ -1663,17 +1676,18 @@ class AppProxy {
1663
1676
  if (!this.camera$.value) {
1664
1677
  return;
1665
1678
  }
1666
- const nextCamera = __spreadValues(__spreadValues({}, this.camera$.value), camera);
1679
+ const nextCamera = __spreadProps(__spreadValues(__spreadValues({}, this.camera$.value), camera), { id: this.uid });
1667
1680
  this.storeCamera(nextCamera);
1681
+ this.camera$.setValue(nextCamera);
1668
1682
  };
1669
1683
  this.addCameraReaction = () => {
1670
1684
  this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-camera`, () => reaction(() => {
1671
1685
  var _a2;
1672
1686
  return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
1673
1687
  }, (camera) => {
1674
- if (camera && camera.id !== this.uid) {
1688
+ if (camera) {
1675
1689
  const rawCamera = toJS(camera);
1676
- if (rawCamera !== this.camera$.value) {
1690
+ if (!isEqual(rawCamera, this.camera$.value)) {
1677
1691
  this.camera$.setValue(rawCamera);
1678
1692
  }
1679
1693
  }
@@ -1684,9 +1698,9 @@ class AppProxy {
1684
1698
  var _a2;
1685
1699
  return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
1686
1700
  }, (size2) => {
1687
- if (size2 && size2.id !== this.uid) {
1701
+ if (size2) {
1688
1702
  const rawSize = toJS(size2);
1689
- if (this.size$.value !== rawSize) {
1703
+ if (!isEqual(rawSize, this.size$.value)) {
1690
1704
  this.size$.setValue(rawSize);
1691
1705
  }
1692
1706
  }
@@ -1746,10 +1760,18 @@ class AppProxy {
1746
1760
  });
1747
1761
  this.size$.setValue(toJS(this.appAttributes.size));
1748
1762
  }
1749
- 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
+ });
1750
1772
  this.sideEffectManager.add(() => () => {
1751
1773
  var _a2;
1752
- return (_a2 = this.appViewSync) == null ? void 0 : _a2.destroy();
1774
+ return (_a2 = this.viewSync) == null ? void 0 : _a2.destroy();
1753
1775
  });
1754
1776
  }
1755
1777
  }));
@@ -1841,7 +1863,7 @@ class AppProxy {
1841
1863
  if (!this.boxManager) {
1842
1864
  throw new BoxManagerNotFoundError();
1843
1865
  }
1844
- const context = new AppContext(this.manager, this.boxManager, appId, this, appOptions);
1866
+ const context = new AppContext(this.manager, appId, this, appOptions);
1845
1867
  this.appContext = context;
1846
1868
  try {
1847
1869
  emitter.once(`${appId}${Events.WindowCreated}`).then(async () => {
@@ -2066,6 +2088,8 @@ class AppProxy {
2066
2088
  this.manager.refresher.remove(this.id);
2067
2089
  this.manager.refresher.remove(this.stateKey);
2068
2090
  this.manager.refresher.remove(`${this.id}-fullPath`);
2091
+ this.manager.refresher.remove(`${this.id}-camera`);
2092
+ this.manager.refresher.remove(`${this.id}-size`);
2069
2093
  this.valManager.destroy();
2070
2094
  }
2071
2095
  close() {
@@ -2124,12 +2148,29 @@ const setDefaultCameraBound = (view) => {
2124
2148
  };
2125
2149
  class MainViewProxy {
2126
2150
  constructor(manager) {
2127
- var _a;
2128
2151
  this.manager = manager;
2129
2152
  this.started = false;
2130
2153
  this.mainViewIsAddListener = false;
2131
2154
  this.store = this.manager.store;
2132
2155
  this.sideEffectManager = new SideEffectManager();
2156
+ this.camera$ = new Val(void 0);
2157
+ this.size$ = new Val(void 0);
2158
+ this.view$ = new Val(void 0);
2159
+ this.createViewSync = () => {
2160
+ var _a;
2161
+ if (this.manager.boxManager && !this.viewSync) {
2162
+ this.viewSync = new ViewSync({
2163
+ uid: this.manager.uid,
2164
+ view$: this.view$,
2165
+ camera$: this.camera$,
2166
+ size$: this.size$,
2167
+ stageRect$: (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect$,
2168
+ viewMode$: this.manager.windowManger.viewMode$,
2169
+ storeCamera: this.storeCamera,
2170
+ storeSize: this.storeSize
2171
+ });
2172
+ }
2173
+ };
2133
2174
  this.startListenWritableChange = () => {
2134
2175
  this.sideEffectManager.add(() => emitter.on("writableChange", (isWritable) => {
2135
2176
  if (isWritable) {
@@ -2139,26 +2180,50 @@ class MainViewProxy {
2139
2180
  };
2140
2181
  this.addCameraReaction = () => {
2141
2182
  this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
2183
+ this.manager.refresher.add(Fields.MainViewSize, this.sizeReaction);
2184
+ };
2185
+ this.storeCurrentCamera = () => {
2186
+ const iCamera = this.view.camera;
2187
+ this.storeCamera(__spreadValues({
2188
+ id: this.manager.uid
2189
+ }, iCamera));
2190
+ };
2191
+ this.storeCurrentSize = () => {
2192
+ var _a;
2193
+ const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
2194
+ if (rect) {
2195
+ this.storeSize({
2196
+ id: this.manager.uid,
2197
+ width: rect.width,
2198
+ height: rect.height
2199
+ });
2200
+ }
2201
+ };
2202
+ this.storeCamera = (camera) => {
2203
+ this.store.setMainViewCamera(camera);
2204
+ };
2205
+ this.storeSize = (size2) => {
2206
+ this.store.setMainViewSize(size2);
2142
2207
  };
2143
2208
  this.cameraReaction = () => {
2144
2209
  return reaction(() => this.mainViewCamera, (camera) => {
2145
- if (camera && camera.id !== this.manager.uid) {
2146
- this.synchronizer.onRemoteUpdate(camera, this.mainViewSize);
2210
+ if (camera) {
2211
+ const rawCamera = toJS(camera);
2212
+ if (!isEqual(rawCamera, this.camera$.value)) {
2213
+ this.camera$.setValue(rawCamera);
2214
+ }
2147
2215
  }
2148
2216
  }, { fireImmediately: true });
2149
2217
  };
2150
- this.onUpdateContainerSizeRatio = () => {
2151
- const size2 = this.store.getMainViewSize();
2152
- if (size2.id === this.manager.uid) {
2153
- this.setCameraAndSize();
2154
- }
2155
- };
2156
- this.onCameraUpdatedByDevice = (camera) => {
2157
- this.synchronizer.onLocalCameraUpdate(camera);
2158
- const size2 = this.getStageSize();
2159
- if (size2 && !isEqual(size2, this.mainViewSize)) {
2160
- this.setMainViewSize(size2);
2161
- }
2218
+ this.sizeReaction = () => {
2219
+ return reaction(() => this.mainViewSize, (size2) => {
2220
+ if (size2) {
2221
+ const rawSize = toJS(size2);
2222
+ if (!isEqual(rawSize, this.size$.value)) {
2223
+ this.size$.setValue(rawSize);
2224
+ }
2225
+ }
2226
+ }, { fireImmediately: true });
2162
2227
  };
2163
2228
  this.mainViewClickListener = () => {
2164
2229
  this.mainViewClickHandler();
@@ -2169,9 +2234,7 @@ class MainViewProxy {
2169
2234
  this.onCameraOrSizeUpdated = () => {
2170
2235
  callbacks$1.emit("cameraStateChange", this.cameraState);
2171
2236
  };
2172
- this.synchronizer = new CameraSynchronizer((camera) => this.store.setMainViewCamera(__spreadProps(__spreadValues({}, camera), { id: this.manager.uid })));
2173
2237
  this.mainView = this.createMainView();
2174
- this.moveCameraSizeByAttributes();
2175
2238
  emitter.once("mainViewMounted").then(() => {
2176
2239
  this.addMainViewListener();
2177
2240
  this.start();
@@ -2179,23 +2242,35 @@ class MainViewProxy {
2179
2242
  this.startListenWritableChange();
2180
2243
  });
2181
2244
  this.sideEffectManager.add(() => [
2182
- emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio),
2183
2245
  emitter.on("startReconnect", () => {
2184
2246
  releaseView(this.mainView);
2185
- }),
2186
- emitter.on("playgroundSizeChange", (rect2) => {
2187
- this.synchronizer.setRect(rect2);
2188
2247
  })
2189
2248
  ]);
2190
- const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
2191
- if (rect) {
2192
- this.synchronizer.setRect(rect);
2193
- }
2249
+ this.createViewSync();
2250
+ this.sideEffectManager.add(() => emitter.on("focusedChange", ({ focused }) => {
2251
+ if (focused === void 0) {
2252
+ const scenePath = this.store.getMainViewScenePath();
2253
+ if (scenePath) {
2254
+ setScenePath(this.manager.room, scenePath);
2255
+ }
2256
+ }
2257
+ }));
2194
2258
  }
2195
2259
  ensureCameraAndSize() {
2260
+ var _a;
2196
2261
  if (!this.mainViewCamera || !this.mainViewSize) {
2197
2262
  this.manager.dispatchInternalEvent(Events.InitMainViewCamera);
2198
- this.setCameraAndSize();
2263
+ this.storeCamera(__spreadValues({
2264
+ id: this.manager.uid
2265
+ }, this.view.camera));
2266
+ const stageRect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
2267
+ if (stageRect && !this.mainViewSize) {
2268
+ this.storeSize({
2269
+ id: this.manager.uid,
2270
+ width: stageRect.width,
2271
+ height: stageRect.height
2272
+ });
2273
+ }
2199
2274
  }
2200
2275
  }
2201
2276
  get mainViewCamera() {
@@ -2207,9 +2282,6 @@ class MainViewProxy {
2207
2282
  get didRelease() {
2208
2283
  return get(this.view, ["didRelease"]);
2209
2284
  }
2210
- moveCameraSizeByAttributes() {
2211
- this.synchronizer.onRemoteUpdate(this.mainViewCamera, this.mainViewSize);
2212
- }
2213
2285
  start() {
2214
2286
  if (this.started)
2215
2287
  return;
@@ -2217,14 +2289,6 @@ class MainViewProxy {
2217
2289
  this.addCameraReaction();
2218
2290
  this.started = true;
2219
2291
  }
2220
- setCameraAndSize() {
2221
- const stageSize = this.getStageSize();
2222
- if (stageSize) {
2223
- const camera = __spreadProps(__spreadValues({}, this.mainView.camera), { id: this.manager.uid });
2224
- const size2 = __spreadProps(__spreadValues({}, stageSize), { id: this.manager.uid });
2225
- this.store.setMainViewCameraAndSize(camera, size2);
2226
- }
2227
- }
2228
2292
  get view() {
2229
2293
  return this.mainView;
2230
2294
  }
@@ -2237,7 +2301,7 @@ class MainViewProxy {
2237
2301
  if (mainViewScenePath) {
2238
2302
  setViewFocusScenePath(mainView, mainViewScenePath);
2239
2303
  }
2240
- this.synchronizer.setView(mainView);
2304
+ this.view$.setValue(mainView);
2241
2305
  return mainView;
2242
2306
  }
2243
2307
  onReconnect() {
@@ -2265,13 +2329,6 @@ class MainViewProxy {
2265
2329
  this.addMainViewListener();
2266
2330
  this.start();
2267
2331
  }
2268
- getStageSize() {
2269
- var _a;
2270
- const stage = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
2271
- if (stage) {
2272
- return { width: stage.width, height: stage.height };
2273
- }
2274
- }
2275
2332
  addMainViewListener() {
2276
2333
  if (this.mainViewIsAddListener)
2277
2334
  return;
@@ -2296,12 +2353,10 @@ class MainViewProxy {
2296
2353
  (_a = this.manager.boxManager) == null ? void 0 : _a.blurAllBox();
2297
2354
  }
2298
2355
  addCameraListener() {
2299
- this.view.callbacks.on("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
2300
2356
  this.view.callbacks.on("onCameraUpdated", this.onCameraOrSizeUpdated);
2301
2357
  this.view.callbacks.on("onSizeUpdated", this.onCameraOrSizeUpdated);
2302
2358
  }
2303
2359
  removeCameraListener() {
2304
- this.view.callbacks.off("onCameraUpdatedByDevice", this.onCameraUpdatedByDevice);
2305
2360
  this.view.callbacks.off("onCameraUpdated", this.onCameraOrSizeUpdated);
2306
2361
  this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
2307
2362
  }
@@ -2312,6 +2367,9 @@ class MainViewProxy {
2312
2367
  this.started = false;
2313
2368
  }
2314
2369
  destroy() {
2370
+ this.camera$.destroy();
2371
+ this.size$.destroy();
2372
+ this.view$.destroy();
2315
2373
  this.removeMainViewListener();
2316
2374
  this.stop();
2317
2375
  this.sideEffectManager.flushAll();
@@ -2626,7 +2684,6 @@ class AppManager {
2626
2684
  if (sceneState) {
2627
2685
  const scenePath = sceneState.scenePath;
2628
2686
  this.appProxies.forEach((appProxy) => {
2629
- console.log("scenePath", scenePath, appProxy.scenePath);
2630
2687
  if (appProxy.scenePath && scenePath.startsWith(appProxy.scenePath)) {
2631
2688
  appProxy.emitAppSceneStateChange(sceneState);
2632
2689
  appProxy.setFullPath(scenePath);
@@ -2864,6 +2921,7 @@ class AppManager {
2864
2921
  }
2865
2922
  setBoxManager(boxManager) {
2866
2923
  this.boxManager = boxManager;
2924
+ this.mainViewProxy.createViewSync();
2867
2925
  }
2868
2926
  resetMaximized() {
2869
2927
  var _a;
@@ -4234,7 +4292,7 @@ class Y$3 {
4234
4292
  if (!this.$stage) {
4235
4293
  const e4 = document.createElement("div");
4236
4294
  this.$stage = e4, e4.className = this.wrapClassName("content-stage"), this._sideEffect.addDisposer(this._contentStageRect$.subscribe((t4) => {
4237
- t4 && (e4.style.top = t4.y + "px", e4.style.left = t4.x + "px", e4.style.width = t4.width + "px", e4.style.height = t4.height + "px");
4295
+ e4.style.top = t4.y + "px", e4.style.left = t4.x + "px", e4.style.width = t4.width + "px", e4.style.height = t4.height + "px";
4238
4296
  }), "content-stage-rect"), r2.appendChild(e4);
4239
4297
  }
4240
4298
  this.$stage.parentElement || r2.appendChild(this.$stage), this.$stage.appendChild(t3);
@@ -4773,6 +4831,9 @@ class BoxManager {
4773
4831
  get stageRect() {
4774
4832
  return this.teleBoxManager.stageRect;
4775
4833
  }
4834
+ get stageRect$() {
4835
+ return this.teleBoxManager._stageRect$;
4836
+ }
4776
4837
  createBox(params) {
4777
4838
  var _a, _b, _c;
4778
4839
  if (!this.teleBoxManager)
@@ -5873,7 +5934,7 @@ class ReconnectRefresher {
5873
5934
  };
5874
5935
  this.onReconnected = debounce(() => {
5875
5936
  this._onReconnected();
5876
- }, 3e3);
5937
+ }, 1e3);
5877
5938
  this._onReconnected = () => {
5878
5939
  log("onReconnected refresh reactors");
5879
5940
  this.releaseDisposers();
@@ -5993,6 +6054,9 @@ const replaceRoomFunction = (room, manager) => {
5993
6054
  room.lockImage = (...args) => manager.lockImage(...args);
5994
6055
  room.lockImages = (...args) => manager.lockImages(...args);
5995
6056
  delegateRemoveScenes(room, manager);
6057
+ if (!room.dynamicPpt.slideStateAdapter.pptHandler) {
6058
+ room.dynamicPpt.slideStateAdapter.pptHandler = manager.createPPTHandler();
6059
+ }
5996
6060
  }
5997
6061
  };
5998
6062
  const delegateRemoveScenes = (room, manager) => {
@@ -15547,14 +15611,15 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
15547
15611
  const _WindowManager = class extends InvisiblePlugin {
15548
15612
  constructor(context) {
15549
15613
  super(context);
15550
- this.version = "1.0.0-canary.14";
15551
- this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.16", "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" } };
15614
+ this.version = "1.0.0-canary.17";
15615
+ 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" } };
15552
15616
  this.emitter = callbacks$1;
15553
15617
  this.viewMode = ViewMode.Broadcaster;
15618
+ this.viewMode$ = new Val(ViewMode.Broadcaster);
15554
15619
  this.isReplay = isPlayer(this.displayer);
15555
15620
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
15556
15621
  _WindowManager.displayer = context.displayer;
15557
- window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.16", "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
+ 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" } };
15558
15623
  }
15559
15624
  static async mount(params) {
15560
15625
  var _a;
@@ -15890,17 +15955,20 @@ const _WindowManager = class extends InvisiblePlugin {
15890
15955
  addEmitterOnceListener(`destroy-${kind2}`, listener);
15891
15956
  }
15892
15957
  setViewMode(mode) {
15893
- var _a, _b, _c;
15958
+ var _a;
15959
+ log("setViewMode", mode);
15960
+ const mainViewProxy = (_a = this.appManager) == null ? void 0 : _a.mainViewProxy;
15894
15961
  if (mode === ViewMode.Broadcaster) {
15895
15962
  if (this.canOperate) {
15896
- (_a = this.appManager) == null ? void 0 : _a.mainViewProxy.setCameraAndSize();
15963
+ mainViewProxy == null ? void 0 : mainViewProxy.storeCurrentCamera();
15897
15964
  }
15898
- (_b = this.appManager) == null ? void 0 : _b.mainViewProxy.start();
15965
+ mainViewProxy == null ? void 0 : mainViewProxy.start();
15899
15966
  }
15900
15967
  if (mode === ViewMode.Freedom) {
15901
- (_c = this.appManager) == null ? void 0 : _c.mainViewProxy.stop();
15968
+ mainViewProxy == null ? void 0 : mainViewProxy.stop();
15902
15969
  }
15903
15970
  this.viewMode = mode;
15971
+ this.viewMode$.setValue(mode);
15904
15972
  }
15905
15973
  setBoxState(boxState) {
15906
15974
  if (!this.canOperate)
@@ -16047,7 +16115,7 @@ const _WindowManager = class extends InvisiblePlugin {
16047
16115
  (_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCamera, camera);
16048
16116
  setTimeout(() => {
16049
16117
  var _a2;
16050
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.setCameraAndSize();
16118
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
16051
16119
  }, 500);
16052
16120
  }
16053
16121
  moveCameraToContain(rectangle) {
@@ -16056,7 +16124,7 @@ const _WindowManager = class extends InvisiblePlugin {
16056
16124
  (_a = this.appManager) == null ? void 0 : _a.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
16057
16125
  setTimeout(() => {
16058
16126
  var _a2;
16059
- (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.setCameraAndSize();
16127
+ (_a2 = this.appManager) == null ? void 0 : _a2.mainViewProxy.storeCurrentCamera();
16060
16128
  }, 500);
16061
16129
  }
16062
16130
  convertToPointInWorld(point) {
@@ -16183,6 +16251,26 @@ const _WindowManager = class extends InvisiblePlugin {
16183
16251
  this.containerSizeRatio = ratio;
16184
16252
  emitter.emit("containerSizeRatioUpdate", ratio);
16185
16253
  }
16254
+ createPPTHandler() {
16255
+ return {
16256
+ onPageJumpTo: (_pptUUID, index2) => {
16257
+ var _a, _b, _c, _d;
16258
+ (_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);
16259
+ },
16260
+ onPageToNext: () => {
16261
+ var _a, _b, _c, _d;
16262
+ if (this.focused) {
16263
+ (_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();
16264
+ }
16265
+ },
16266
+ onPageToPrev: () => {
16267
+ var _a, _b, _c, _d;
16268
+ if (this.focused) {
16269
+ (_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();
16270
+ }
16271
+ }
16272
+ };
16273
+ }
16186
16274
  isDynamicPPT(scenes) {
16187
16275
  var _a, _b;
16188
16276
  const sceneSrc = (_b = (_a = scenes[0]) == null ? void 0 : _a.ppt) == null ? void 0 : _b.src;