@netless/window-manager 1.0.0-canary.6 → 1.0.0-canary.9

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
@@ -898,10 +898,12 @@ class Storage {
898
898
  }
899
899
  }
900
900
  class WhiteBoardView {
901
- constructor(appContext, appProxy, removeViewWrapper) {
901
+ constructor(view, appContext, appProxy, removeViewWrapper, ensureSize) {
902
+ this.view = view;
902
903
  this.appContext = appContext;
903
904
  this.appProxy = appProxy;
904
905
  this.removeViewWrapper = removeViewWrapper;
906
+ this.ensureSize = ensureSize;
905
907
  this.nextPage = async () => {
906
908
  const nextIndex = this.pageState.index + 1;
907
909
  return this.jumpPage(nextIndex);
@@ -949,9 +951,6 @@ class WhiteBoardView {
949
951
  pageState$.setValue(pageState);
950
952
  });
951
953
  }
952
- get view() {
953
- return this.appContext.view;
954
- }
955
954
  get pageState() {
956
955
  return this.pageState$.value;
957
956
  }
@@ -1042,13 +1041,15 @@ class AppContext {
1042
1041
  this._viewWrapper = void 0;
1043
1042
  };
1044
1043
  view.divElement = viewWrapper;
1044
+ this.appProxy.fireMemberStateChange();
1045
1045
  if (this.isAddApp) {
1046
- this.initPageSize(size2);
1046
+ this.ensurePageSize(size2);
1047
1047
  }
1048
- this.whiteBoardView = new WhiteBoardView(this, this.appProxy, removeViewWrapper);
1048
+ this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, removeViewWrapper, this.ensurePageSize);
1049
1049
  return this.whiteBoardView;
1050
1050
  };
1051
- this.initPageSize = (size2) => {
1051
+ this.ensurePageSize = (size2) => {
1052
+ var _a;
1052
1053
  if (!isNumber(size2))
1053
1054
  return;
1054
1055
  if (!this.appProxy.scenePath)
@@ -1059,11 +1060,8 @@ class AppContext {
1059
1060
  throw Error(`[WindowManager]: size ${size2} muse be in range [1, ${MAX_PAGE_SIZE}]`);
1060
1061
  }
1061
1062
  const needInsert = size2 - this.appProxy.pageState.length;
1062
- const startPageNumber = this.appProxy.pageState.length;
1063
- const scenes = new Array(needInsert).fill({}).map((_2, index2) => {
1064
- return { name: `${startPageNumber + index2 + 1}` };
1065
- });
1066
- putScenes(this.room, this.appProxy.scenePath, scenes);
1063
+ const scenes = new Array(needInsert).fill({});
1064
+ (_a = this.room) == null ? void 0 : _a.putScenes(this.appProxy.scenePath, scenes);
1067
1065
  };
1068
1066
  this.getInitScenePath = () => {
1069
1067
  return this.manager.getAppInitPath(this.appId);
@@ -1110,11 +1108,14 @@ class AppContext {
1110
1108
  get displayer() {
1111
1109
  return this.manager.displayer;
1112
1110
  }
1111
+ get destroyed() {
1112
+ return this.appProxy.status === "destroyed";
1113
+ }
1113
1114
  get view() {
1114
1115
  return this.appProxy.view;
1115
1116
  }
1116
1117
  get isWritable() {
1117
- return this.manager.canOperate;
1118
+ return this.manager.canOperate && !this.destroyed;
1118
1119
  }
1119
1120
  get box() {
1120
1121
  const box = this.boxManager.getBox(this.appId);
@@ -1225,21 +1226,6 @@ class CameraSynchronizer {
1225
1226
  delay(moveCamera, 50);
1226
1227
  }
1227
1228
  }, 50);
1228
- this.onLocalSizeUpdate = (size2) => {
1229
- if (this.rect && this.view) {
1230
- let scale2;
1231
- if (size2.width < size2.height) {
1232
- scale2 = this.rect.width / size2.width;
1233
- } else {
1234
- scale2 = this.rect.height / size2.height;
1235
- }
1236
- const nextScale = this.view.camera.scale / scale2;
1237
- this.view.moveCamera({
1238
- scale: nextScale,
1239
- animationMode: AnimationMode.Immediately
1240
- });
1241
- }
1242
- };
1243
1229
  }
1244
1230
  setRect(rect) {
1245
1231
  this.rect = rect;
@@ -1300,11 +1286,11 @@ class AppViewSync {
1300
1286
  }
1301
1287
  }));
1302
1288
  }
1303
- combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size2]) => {
1289
+ this.sem.add(() => combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size2]) => {
1304
1290
  if (camera && size2) {
1305
1291
  this.synchronizer.onRemoteUpdate(camera, size2);
1306
1292
  }
1307
- });
1293
+ }));
1308
1294
  }
1309
1295
  destroy() {
1310
1296
  this.sem.flushAll();
@@ -1515,10 +1501,30 @@ class AppProxy {
1515
1501
  this.uid = this.manager.uid;
1516
1502
  this.status = "normal";
1517
1503
  this.sideEffectManager = new SideEffectManager();
1518
- this.camera$ = new Val(void 0);
1519
- this.size$ = new Val(void 0);
1520
- this.box$ = new Val(void 0);
1521
- this.view$ = new Val(void 0);
1504
+ this.valManager = new ValManager();
1505
+ this.fullPath$ = this.valManager.attach(new Val(void 0));
1506
+ this.camera$ = this.valManager.attach(new Val(void 0));
1507
+ this.size$ = this.valManager.attach(new Val(void 0));
1508
+ this.box$ = this.valManager.attach(new Val(void 0));
1509
+ this.view$ = this.valManager.attach(new Val(void 0));
1510
+ this.fireMemberStateChange = () => {
1511
+ if (this.manager.room) {
1512
+ this.onMemberStateChange(this.manager.room.state.memberState);
1513
+ }
1514
+ };
1515
+ this.onMemberStateChange = (memberState) => {
1516
+ var _a2, _b;
1517
+ const needPointerEventsNone = memberState.currentApplianceName === "clicker";
1518
+ if (needPointerEventsNone) {
1519
+ if ((_a2 = this.appContext) == null ? void 0 : _a2._viewWrapper) {
1520
+ this.appContext._viewWrapper.style.pointerEvents = "none";
1521
+ }
1522
+ } else {
1523
+ if ((_b = this.appContext) == null ? void 0 : _b._viewWrapper) {
1524
+ this.appContext._viewWrapper.style.pointerEvents = "auto";
1525
+ }
1526
+ }
1527
+ };
1522
1528
  this.getAppInitState = (id2) => {
1523
1529
  var _a2, _b;
1524
1530
  const attrs = this.store.getAppState(id2);
@@ -1547,8 +1553,7 @@ class AppProxy {
1547
1553
  return payload;
1548
1554
  };
1549
1555
  this.appAttributesUpdateListener = (appId2) => {
1550
- var _a2, _b, _c;
1551
- (_a2 = this.manager.refresher) == null ? void 0 : _a2.add(appId2, () => {
1556
+ this.manager.refresher.add(appId2, () => {
1552
1557
  return autorun(() => {
1553
1558
  const attrs = this.manager.attributes[appId2];
1554
1559
  if (attrs) {
@@ -1556,23 +1561,23 @@ class AppProxy {
1556
1561
  }
1557
1562
  });
1558
1563
  });
1559
- (_b = this.manager.refresher) == null ? void 0 : _b.add(this.stateKey, () => {
1564
+ this.manager.refresher.add(this.stateKey, () => {
1560
1565
  return autorun(() => {
1561
- var _a3, _b2, _c2;
1562
- const appState = (_a3 = this.appAttributes) == null ? void 0 : _a3.state;
1563
- if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((_b2 = this.box) == null ? void 0 : _b2.zIndex)) {
1564
- (_c2 = this.boxManager) == null ? void 0 : _c2.setZIndex(appId2, appState.zIndex);
1566
+ var _a2, _b, _c;
1567
+ const appState = (_a2 = this.appAttributes) == null ? void 0 : _a2.state;
1568
+ if ((appState == null ? void 0 : appState.zIndex) > 0 && appState.zIndex !== ((_b = this.box) == null ? void 0 : _b.zIndex)) {
1569
+ (_c = this.boxManager) == null ? void 0 : _c.setZIndex(appId2, appState.zIndex);
1565
1570
  }
1566
1571
  });
1567
1572
  });
1568
- (_c = this.manager.refresher) == null ? void 0 : _c.add(`${appId2}-fullPath`, () => {
1573
+ this.manager.refresher.add(`${appId2}-fullPath`, () => {
1569
1574
  return autorun(() => {
1570
- var _a3;
1571
- const fullPath = (_a3 = this.appAttributes) == null ? void 0 : _a3.fullPath;
1575
+ var _a2;
1576
+ const fullPath = (_a2 = this.appAttributes) == null ? void 0 : _a2.fullPath;
1572
1577
  this.setFocusScenePathHandler(fullPath);
1573
- if (this._prevFullPath !== fullPath) {
1578
+ if (this.fullPath$.value !== fullPath) {
1574
1579
  this.notifyPageStateChange();
1575
- this._prevFullPath = fullPath;
1580
+ this.fullPath$.setValue(fullPath);
1576
1581
  }
1577
1582
  });
1578
1583
  });
@@ -1601,6 +1606,26 @@ class AppProxy {
1601
1606
  const nextCamera = __spreadValues(__spreadValues({}, this.camera$.value), camera);
1602
1607
  this.storeCamera(nextCamera);
1603
1608
  };
1609
+ this.addCameraReaction = () => {
1610
+ this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-camera`, () => reaction(() => {
1611
+ var _a2;
1612
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
1613
+ }, (camera) => {
1614
+ if (camera && camera.id !== this.uid) {
1615
+ this.camera$.setValue(toJS(camera));
1616
+ }
1617
+ })), "camera");
1618
+ };
1619
+ this.addSizeReaction = () => {
1620
+ this.sideEffectManager.add(() => this.manager.refresher.add(`${this.id}-size`, () => reaction(() => {
1621
+ var _a2;
1622
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
1623
+ }, (size2) => {
1624
+ if (size2 && size2.id !== this.uid) {
1625
+ this.size$.setValue(toJS(size2));
1626
+ }
1627
+ })), "size");
1628
+ };
1604
1629
  this.kind = params.kind;
1605
1630
  this.id = appId;
1606
1631
  this.appScenePath = `/${this.id}-app-dir`;
@@ -1628,31 +1653,9 @@ class AppProxy {
1628
1653
  }));
1629
1654
  this.camera$.setValue(toJS(this.appAttributes.camera));
1630
1655
  this.size$.setValue(toJS(this.appAttributes.size));
1631
- this.sideEffectManager.add(() => {
1632
- return this.manager.refresher.add(`${this.id}-camera`, () => {
1633
- return reaction(() => {
1634
- var _a2;
1635
- return (_a2 = this.appAttributes) == null ? void 0 : _a2.camera;
1636
- }, (camera) => {
1637
- if (camera && camera.id !== this.uid) {
1638
- this.camera$.setValue(toJS(camera));
1639
- }
1640
- });
1641
- });
1642
- });
1643
- this.sideEffectManager.add(() => {
1644
- return this.manager.refresher.add(`${this.id}-size`, () => {
1645
- return reaction(() => {
1646
- var _a2;
1647
- return (_a2 = this.appAttributes) == null ? void 0 : _a2.size;
1648
- }, (size2) => {
1649
- if (size2 && size2.id !== this.uid) {
1650
- this.size$.setValue(toJS(size2));
1651
- }
1652
- });
1653
- });
1654
- });
1655
- combine([this.box$, this.view$]).subscribe(([box, view]) => {
1656
+ this.addCameraReaction();
1657
+ this.addSizeReaction();
1658
+ this.sideEffectManager.add(() => combine([this.box$, this.view$]).subscribe(([box, view]) => {
1656
1659
  var _a2, _b;
1657
1660
  if (box && view) {
1658
1661
  if (!this.camera$.value) {
@@ -1662,6 +1665,7 @@ class AppProxy {
1662
1665
  scale: 1,
1663
1666
  id: this.uid
1664
1667
  });
1668
+ this.camera$.setValue(toJS(this.appAttributes.camera));
1665
1669
  }
1666
1670
  if (!this.size$.value && box.contentStageRect) {
1667
1671
  this.storeSize({
@@ -1669,6 +1673,7 @@ class AppProxy {
1669
1673
  width: (_a2 = box.contentStageRect) == null ? void 0 : _a2.width,
1670
1674
  height: (_b = box.contentStageRect) == null ? void 0 : _b.height
1671
1675
  });
1676
+ this.size$.setValue(toJS(this.appAttributes.size));
1672
1677
  }
1673
1678
  this.appViewSync = new AppViewSync(this);
1674
1679
  this.sideEffectManager.add(() => () => {
@@ -1676,20 +1681,8 @@ class AppProxy {
1676
1681
  return (_a3 = this.appViewSync) == null ? void 0 : _a3.destroy();
1677
1682
  });
1678
1683
  }
1679
- });
1680
- this.sideEffectManager.add(() => emitter.on("memberStateChange", (memberState) => {
1681
- var _a2, _b;
1682
- const needPointerEventsNone = memberState.currentApplianceName === "clicker";
1683
- if (needPointerEventsNone) {
1684
- if ((_a2 = this.appContext) == null ? void 0 : _a2._viewWrapper) {
1685
- this.appContext._viewWrapper.style.pointerEvents = "none";
1686
- }
1687
- } else {
1688
- if ((_b = this.appContext) == null ? void 0 : _b._viewWrapper) {
1689
- this.appContext._viewWrapper.style.pointerEvents = "auto";
1690
- }
1691
- }
1692
1684
  }));
1685
+ this.sideEffectManager.add(() => emitter.on("memberStateChange", this.onMemberStateChange));
1693
1686
  }
1694
1687
  createAppDir() {
1695
1688
  const scenePath = this.scenePath || this.appScenePath;
@@ -1717,7 +1710,7 @@ class AppProxy {
1717
1710
  }
1718
1711
  }
1719
1712
  get view() {
1720
- return this.manager.viewManager.getView(this.id);
1713
+ return this.view$.value;
1721
1714
  }
1722
1715
  get viewIndex() {
1723
1716
  var _a;
@@ -1973,7 +1966,7 @@ class AppProxy {
1973
1966
  }
1974
1967
  }
1975
1968
  async destroy(needCloseBox, cleanAttrs, skipUpdate, error) {
1976
- var _a, _b, _c, _d;
1969
+ var _a;
1977
1970
  if (this.status === "destroyed")
1978
1971
  return;
1979
1972
  this.status = "destroyed";
@@ -1998,13 +1991,10 @@ class AppProxy {
1998
1991
  this.appProxies.delete(this.id);
1999
1992
  this.viewManager.destroyView(this.id);
2000
1993
  this.manager.appStatus.delete(this.id);
2001
- (_b = this.manager.refresher) == null ? void 0 : _b.remove(this.id);
2002
- (_c = this.manager.refresher) == null ? void 0 : _c.remove(this.stateKey);
2003
- (_d = this.manager.refresher) == null ? void 0 : _d.remove(`${this.id}-fullPath`);
2004
- this._prevFullPath = void 0;
2005
- this.camera$.destroy();
2006
- this.size$.destroy();
2007
- this.box$.destroy();
1994
+ this.manager.refresher.remove(this.id);
1995
+ this.manager.refresher.remove(this.stateKey);
1996
+ this.manager.refresher.remove(`${this.id}-fullPath`);
1997
+ this.valManager.destroy();
2008
1998
  }
2009
1999
  close() {
2010
2000
  return this.destroy(true, true, false);
@@ -2069,17 +2059,14 @@ class MainViewProxy {
2069
2059
  this.store = this.manager.store;
2070
2060
  this.sideEffectManager = new SideEffectManager();
2071
2061
  this.startListenWritableChange = () => {
2072
- this.sideEffectManager.add(() => {
2073
- return emitter.on("writableChange", (isWritable) => {
2074
- if (isWritable) {
2075
- this.ensureCameraAndSize();
2076
- }
2077
- });
2078
- });
2062
+ this.sideEffectManager.add(() => emitter.on("writableChange", (isWritable) => {
2063
+ if (isWritable) {
2064
+ this.ensureCameraAndSize();
2065
+ }
2066
+ }));
2079
2067
  };
2080
2068
  this.addCameraReaction = () => {
2081
- var _a2;
2082
- (_a2 = this.manager.refresher) == null ? void 0 : _a2.add(Fields.MainViewCamera, this.cameraReaction);
2069
+ this.manager.refresher.add(Fields.MainViewCamera, this.cameraReaction);
2083
2070
  };
2084
2071
  this.cameraReaction = () => {
2085
2072
  return reaction(() => this.mainViewCamera, (camera) => {
@@ -2088,11 +2075,8 @@ class MainViewProxy {
2088
2075
  }
2089
2076
  }, { fireImmediately: true });
2090
2077
  };
2091
- this.sizeChangeHandler = debounce((size2) => {
2092
- }, 30);
2093
2078
  this.onUpdateContainerSizeRatio = () => {
2094
2079
  const size2 = this.store.getMainViewSize();
2095
- this.sizeChangeHandler(size2);
2096
2080
  if (size2.id === this.manager.uid) {
2097
2081
  this.setCameraAndSize();
2098
2082
  }
@@ -2122,23 +2106,19 @@ class MainViewProxy {
2122
2106
  this.ensureCameraAndSize();
2123
2107
  this.startListenWritableChange();
2124
2108
  });
2125
- this.sideEffectManager.add(() => {
2126
- return emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio);
2127
- });
2128
- this.sideEffectManager.add(() => {
2129
- return emitter.on("startReconnect", () => {
2109
+ this.sideEffectManager.add(() => [
2110
+ emitter.on("containerSizeRatioUpdate", this.onUpdateContainerSizeRatio),
2111
+ emitter.on("startReconnect", () => {
2130
2112
  releaseView(this.mainView);
2131
- });
2132
- });
2113
+ }),
2114
+ emitter.on("playgroundSizeChange", (rect2) => {
2115
+ this.synchronizer.setRect(rect2);
2116
+ })
2117
+ ]);
2133
2118
  const rect = (_a = this.manager.boxManager) == null ? void 0 : _a.stageRect;
2134
2119
  if (rect) {
2135
2120
  this.synchronizer.setRect(rect);
2136
2121
  }
2137
- this.sideEffectManager.add(() => {
2138
- return emitter.on("playgroundSizeChange", (rect2) => {
2139
- this.synchronizer.setRect(rect2);
2140
- });
2141
- });
2142
2122
  }
2143
2123
  ensureCameraAndSize() {
2144
2124
  if (!this.mainViewCamera || !this.mainViewSize) {
@@ -2161,7 +2141,6 @@ class MainViewProxy {
2161
2141
  start() {
2162
2142
  if (this.started)
2163
2143
  return;
2164
- this.sizeChangeHandler(this.mainViewSize);
2165
2144
  this.addCameraListener();
2166
2145
  this.addCameraReaction();
2167
2146
  this.started = true;
@@ -2255,10 +2234,9 @@ class MainViewProxy {
2255
2234
  this.view.callbacks.off("onSizeUpdated", this.onCameraOrSizeUpdated);
2256
2235
  }
2257
2236
  stop() {
2258
- var _a, _b;
2259
2237
  this.removeCameraListener();
2260
- (_a = this.manager.refresher) == null ? void 0 : _a.remove(Fields.MainViewCamera);
2261
- (_b = this.manager.refresher) == null ? void 0 : _b.remove(Fields.MainViewSize);
2238
+ this.manager.refresher.remove(Fields.MainViewCamera);
2239
+ this.manager.refresher.remove(Fields.MainViewSize);
2262
2240
  this.started = false;
2263
2241
  }
2264
2242
  destroy() {
@@ -2336,6 +2314,8 @@ class AppManager {
2336
2314
  this.mainViewScenesLength = 0;
2337
2315
  this.callbacksNode = null;
2338
2316
  this.appCreateQueue = new AppCreateQueue();
2317
+ this.sceneIndex$ = new Val(void 0);
2318
+ this.focused$ = new Val(void 0);
2339
2319
  this.sideEffectManager = new SideEffectManager();
2340
2320
  this.sceneState = null;
2341
2321
  this.rootDirRemoving = false;
@@ -2503,21 +2483,21 @@ class AppManager {
2503
2483
  });
2504
2484
  };
2505
2485
  this.onMainViewIndexChange = (index2) => {
2506
- if (index2 !== void 0 && this._prevSceneIndex !== index2) {
2486
+ if (index2 !== void 0 && this.sceneIndex$.value !== index2) {
2507
2487
  callbacks$1.emit("mainViewSceneIndexChange", index2);
2508
2488
  emitter.emit("changePageState");
2509
2489
  if (this.callbacksNode) {
2510
2490
  this.updateSceneState(this.callbacksNode);
2511
2491
  }
2512
- this._prevSceneIndex = index2;
2492
+ this.sceneIndex$.setValue(index2);
2513
2493
  }
2514
2494
  };
2515
2495
  this.onFocusChange = (focused) => {
2516
2496
  var _a;
2517
- if (this._prevFocused !== focused) {
2497
+ if (this.focused$.value !== focused) {
2518
2498
  callbacks$1.emit("focusedChange", focused);
2519
- emitter.emit("focusedChange", { focused, prev: this._prevFocused });
2520
- this._prevFocused = focused;
2499
+ emitter.emit("focusedChange", { focused, prev: this.focused$.value });
2500
+ this.focused$.setValue(focused);
2521
2501
  if (focused !== void 0) {
2522
2502
  (_a = this.boxManager) == null ? void 0 : _a.focusBox({ appId: focused });
2523
2503
  setTimeout(() => {
@@ -2603,12 +2583,9 @@ class AppManager {
2603
2583
  appProxy.emitAppIsWritableChange();
2604
2584
  });
2605
2585
  if (isWritable === true) {
2606
- this.mainView.disableCameraTransform = false;
2607
2586
  if (this.room && this.room.disableSerialization === true) {
2608
2587
  this.room.disableSerialization = false;
2609
2588
  }
2610
- } else {
2611
- this.mainView.disableCameraTransform = true;
2612
2589
  }
2613
2590
  emitter.emit("writableChange", isWritable);
2614
2591
  };
@@ -2713,7 +2690,7 @@ class AppManager {
2713
2690
  }
2714
2691
  }
2715
2692
  async onCreated() {
2716
- var _a, _b, _c, _d, _e, _f;
2693
+ var _a;
2717
2694
  await this.attributesUpdateCallback(this.attributes.apps);
2718
2695
  emitter.emit("updateManagerRect");
2719
2696
  boxEmitter.on("move", this.onBoxMove);
@@ -2723,32 +2700,32 @@ class AppManager {
2723
2700
  boxEmitter.on("boxStateChange", this.onBoxStateChange);
2724
2701
  this.addAppsChangeListener();
2725
2702
  this.addAppCloseListener();
2726
- (_a = this.refresher) == null ? void 0 : _a.add("maximized", () => {
2703
+ this.refresher.add("maximized", () => {
2727
2704
  return autorun(() => {
2728
2705
  var _a2;
2729
2706
  const maximized = this.attributes.maximized;
2730
2707
  (_a2 = this.boxManager) == null ? void 0 : _a2.setMaximized(Boolean(maximized));
2731
2708
  });
2732
2709
  });
2733
- (_b = this.refresher) == null ? void 0 : _b.add("minimized", () => {
2710
+ this.refresher.add("minimized", () => {
2734
2711
  return autorun(() => {
2735
2712
  const minimized = this.attributes.minimized;
2736
2713
  this.onMinimized(minimized);
2737
2714
  });
2738
2715
  });
2739
- (_c = this.refresher) == null ? void 0 : _c.add("mainViewIndex", () => {
2716
+ this.refresher.add("mainViewIndex", () => {
2740
2717
  return autorun(() => {
2741
2718
  const mainSceneIndex = get(this.attributes, "_mainSceneIndex");
2742
2719
  this.onMainViewIndexChange(mainSceneIndex);
2743
2720
  });
2744
2721
  });
2745
- (_d = this.refresher) == null ? void 0 : _d.add("focusedChange", () => {
2722
+ this.refresher.add("focusedChange", () => {
2746
2723
  return autorun(() => {
2747
2724
  const focused = get(this.attributes, "focus");
2748
2725
  this.onFocusChange(focused);
2749
2726
  });
2750
2727
  });
2751
- (_e = this.refresher) == null ? void 0 : _e.add("registeredChange", () => {
2728
+ this.refresher.add("registeredChange", () => {
2752
2729
  return autorun(() => {
2753
2730
  const registered = get(this.attributes, Fields.Registered);
2754
2731
  this.onRegisteredChange(registered);
@@ -2760,9 +2737,9 @@ class AppManager {
2760
2737
  return;
2761
2738
  this.resetScenePath(mainScenePath);
2762
2739
  }
2763
- this.displayerWritableListener(!((_f = this.room) == null ? void 0 : _f.isWritable));
2740
+ this.displayerWritableListener(!((_a = this.room) == null ? void 0 : _a.isWritable));
2764
2741
  this.displayer.callbacks.on("onEnableWriteNowChanged", this.displayerWritableListener);
2765
- this._prevFocused = this.attributes.focus;
2742
+ this.focused$.setValue(this.attributes.focus);
2766
2743
  this.sideEffectManager.add(() => {
2767
2744
  const redoUndo = new RedoUndo({
2768
2745
  mainView: () => this.mainViewProxy.view,
@@ -3011,8 +2988,8 @@ class AppManager {
3011
2988
  }
3012
2989
  callbacks$1.clearListeners();
3013
2990
  this.sideEffectManager.flushAll();
3014
- this._prevFocused = void 0;
3015
- this._prevSceneIndex = void 0;
2991
+ this.sceneIndex$.destroy();
2992
+ this.focused$.destroy();
3016
2993
  }
3017
2994
  }
3018
2995
  /*! *****************************************************************************
@@ -4016,10 +3993,10 @@ class Y$3 {
4016
3993
  this._sideEffect.addDisposer(re2.reaction((e3, t3) => {
4017
3994
  le2.setValue({ width: Math.max(a2, e3.width), height: Math.max(n2, e3.height) }, t3);
4018
3995
  }));
4019
- const de2 = new Val({ x: l2, y: $ }, { compare: shallowequal }), ce2 = combine([le2, O2], ([e3, t3]) => ({ width: t3.width * e3.width, height: t3.height * e3.height }), { compare: shallowequal }), me2 = combine([de2, O2], ([e3, t3]) => ({ x: e3.x * t3.width + t3.x, y: e3.y * t3.height + t3.y }), { compare: shallowequal }), ue2 = new Val(R2), ge2 = combine([ue2, F2], ([e3, t3]) => e3 != null ? e3 : t3), xe2 = new Val(null), pe2 = new Val(P2.value, { compare: shallowequal }), fe2 = new Val(_2), $e2 = new A$2({ namespace: i2, root$: xe2, rootRect$: pe2, ratio$: combine([fe2, j2], ([e3, t3]) => e3 != null ? e3 : t3), highlightStage$: ge2 });
3996
+ const de2 = new Val({ x: l2, y: $ }, { compare: shallowequal }), ce2 = combine([le2, O2], ([e3, t3]) => ({ width: t3.width * e3.width, height: t3.height * e3.height }), { compare: shallowequal }), me2 = combine([de2, O2], ([e3, t3]) => ({ x: e3.x * t3.width + t3.x, y: e3.y * t3.height + t3.y }), { compare: shallowequal }), ue2 = new Val(R2), ge2 = combine([ue2, F2], ([e3, t3]) => e3 != null ? e3 : t3), pe2 = new Val(null), xe2 = new Val(P2.value, { compare: shallowequal }), fe2 = new Val(_2), $e2 = new A$2({ namespace: i2, root$: pe2, rootRect$: xe2, ratio$: combine([fe2, j2], ([e3, t3]) => e3 != null ? e3 : t3), highlightStage$: ge2 });
4020
3997
  this._sideEffect.addDisposer(() => $e2.destroy());
4021
3998
  withReadonlyValueEnhancer(this, { darkMode: D2, fence: T2, minimized: V2, maximized: W2, readonly: Y2, rootRect: P2, managerStageRect: O2, collectorRect: Z2 });
4022
- const be2 = { zIndex: ee2, focus: te2, $userContent: ie2, $userStage: se2, $userFooter: ae2, $userStyles: ne2, state: oe2, minSize: re2, pxMinSize: he2, intrinsicSize: le2, intrinsicCoord: de2, pxIntrinsicSize: ce2, pxIntrinsicCoord: me2, highlightStage: ge2, boxHighlightStage: ue2, contentRect: pe2, contentStageRect: $e2.stageRect$ };
3999
+ const be2 = { zIndex: ee2, focus: te2, $userContent: ie2, $userStage: se2, $userFooter: ae2, $userStyles: ne2, state: oe2, minSize: re2, pxMinSize: he2, intrinsicSize: le2, intrinsicCoord: de2, pxIntrinsicSize: ce2, pxIntrinsicCoord: me2, highlightStage: ge2, boxHighlightStage: ue2, contentRect: xe2, contentStageRect: $e2.stageRect$ };
4023
4000
  withReadonlyValueEnhancer(this, be2, G2);
4024
4001
  withValueEnhancer(this, { title: J2, visible: q2, resizable: Q2, draggable: K2, ratio: U2, stageRatio: fe2 }, G2), this.titleBar = B2 || new H$3({ readonly$: Y2, state$: oe2, title$: J2, namespace: this.namespace, onDragStart: (e3) => {
4025
4002
  var t3;
@@ -4028,7 +4005,7 @@ class Y$3 {
4028
4005
  e3 > 0 && this.transform(me2.value.x, me2.value.y, ce2.value.width, ce2.value.height, true);
4029
4006
  })), this._sideEffect.addDisposer(T2.subscribe((e3) => {
4030
4007
  e3 && this.move(me2.value.x, me2.value.y, true);
4031
- })), this.$box = this.render(), xe2.setValue(this.$content.parentElement);
4008
+ })), this.$box = this.render(), pe2.setValue(this.$content.parentElement);
4032
4009
  const ve2 = (e3, t3) => {
4033
4010
  this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
4034
4011
  i3 || this.events.emit(t3, e4);
@@ -4162,7 +4139,7 @@ class Y$3 {
4162
4139
  r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2, this._sideEffect.add(() => {
4163
4140
  const e3 = new W$3(() => {
4164
4141
  const e4 = r2.getBoundingClientRect();
4165
- this._contentRect$.setValue({ x: e4.x, y: e4.y, width: e4.width, height: e4.height });
4142
+ this._contentRect$.setValue({ x: 0, y: 0, width: e4.width, height: e4.height });
4166
4143
  });
4167
4144
  return e3.observe(r2), () => e3.disconnect();
4168
4145
  }), this._sideEffect.add(() => {
@@ -4214,13 +4191,13 @@ class Y$3 {
4214
4191
  let { pageX: t3, pageY: i3 } = R$3(e3);
4215
4192
  i3 < this.rootRect.y && (i3 = this.rootRect.y);
4216
4193
  const s3 = t3 - l2, c2 = i3 - d2;
4217
- let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: x2 } = this.pxIntrinsicSize;
4194
+ let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: p2 } = this.pxIntrinsicSize;
4218
4195
  switch (a2) {
4219
4196
  case N$3.North:
4220
- u3 = o2 + c2, x2 = h - c2;
4197
+ u3 = o2 + c2, p2 = h - c2;
4221
4198
  break;
4222
4199
  case N$3.South:
4223
- x2 = h + c2;
4200
+ p2 = h + c2;
4224
4201
  break;
4225
4202
  case N$3.West:
4226
4203
  m3 = n2 + s3, g2 = r2 - s3;
@@ -4229,21 +4206,21 @@ class Y$3 {
4229
4206
  g2 = r2 + s3;
4230
4207
  break;
4231
4208
  case N$3.NorthWest:
4232
- m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, x2 = h - c2;
4209
+ m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, p2 = h - c2;
4233
4210
  break;
4234
4211
  case N$3.NorthEast:
4235
- u3 = o2 + c2, g2 = r2 + s3, x2 = h - c2;
4212
+ u3 = o2 + c2, g2 = r2 + s3, p2 = h - c2;
4236
4213
  break;
4237
4214
  case N$3.SouthEast:
4238
- g2 = r2 + s3, x2 = h + c2;
4215
+ g2 = r2 + s3, p2 = h + c2;
4239
4216
  break;
4240
4217
  case N$3.SouthWest:
4241
- m3 = n2 + s3, g2 = r2 - s3, x2 = h + c2;
4218
+ m3 = n2 + s3, g2 = r2 - s3, p2 = h + c2;
4242
4219
  break;
4243
4220
  default:
4244
4221
  return void this.move(n2 + s3, o2 + c2);
4245
4222
  }
4246
- this.transform(m3, u3, g2, x2);
4223
+ this.transform(m3, u3, g2, p2);
4247
4224
  }, m2 = (e3) => {
4248
4225
  a2 = void 0, s2 && (k$1(e3), this.$box.classList.toggle(i2, false), this._sideEffect.flush(t2), s2.remove());
4249
4226
  }, u2 = (e3) => {
@@ -4379,7 +4356,7 @@ class F$3 {
4379
4356
  };
4380
4357
  const t3 = new Z$3(() => {
4381
4358
  const t4 = e3.getBoundingClientRect();
4382
- I2.setValue({ x: t4.x, y: t4.y, width: t4.width, height: t4.height });
4359
+ I2.setValue({ x: 0, y: 0, width: t4.width, height: t4.height });
4383
4360
  });
4384
4361
  return t3.observe(e3), () => t3.disconnect();
4385
4362
  }, "calc-root-rect");
@@ -4594,7 +4571,6 @@ class F$3 {
4594
4571
  const createBoxManager = (manager, callbacks2, emitter2, boxEmitter2, options) => {
4595
4572
  return new BoxManager({
4596
4573
  safeSetAttributes: (attributes) => manager.safeSetAttributes(attributes),
4597
- getMainView: () => manager.mainView,
4598
4574
  updateAppState: (...args) => {
4599
4575
  var _a;
4600
4576
  return (_a = manager.appManager) == null ? void 0 : _a.store.updateAppState(...args);
@@ -4695,9 +4671,6 @@ class BoxManager {
4695
4671
  })
4696
4672
  ]);
4697
4673
  }
4698
- get mainView() {
4699
- return this.context.getMainView();
4700
- }
4701
4674
  get canOperate() {
4702
4675
  return this.context.canOperate();
4703
4676
  }
@@ -4754,7 +4727,8 @@ class BoxManager {
4754
4727
  stageRatio: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.stageRatio,
4755
4728
  root,
4756
4729
  fence: false,
4757
- prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme
4730
+ prefersColorScheme: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.prefersColorScheme,
4731
+ highlightStage: createTeleBoxManagerConfig == null ? void 0 : createTeleBoxManagerConfig.highlightStage
4758
4732
  };
4759
4733
  const manager = new F$3(initManagerState);
4760
4734
  if (this.teleBoxManager) {
@@ -15495,14 +15469,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
15495
15469
  const _WindowManager = class extends InvisiblePlugin {
15496
15470
  constructor(context) {
15497
15471
  super(context);
15498
- this.version = "1.0.0-canary.6";
15499
- this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.13", "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.2.1", "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" } };
15472
+ this.version = "1.0.0-canary.9";
15473
+ this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.14", "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.2.1", "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" } };
15500
15474
  this.emitter = callbacks$1;
15501
15475
  this.viewMode = ViewMode.Broadcaster;
15502
15476
  this.isReplay = isPlayer(this.displayer);
15503
15477
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
15504
15478
  _WindowManager.displayer = context.displayer;
15505
- window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.13", "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.2.1", "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" } };
15479
+ window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.14", "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.2.1", "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" } };
15506
15480
  }
15507
15481
  static async mount(params) {
15508
15482
  var _a;
@@ -15559,7 +15533,8 @@ const _WindowManager = class extends InvisiblePlugin {
15559
15533
  collectorContainer: params.collectorContainer,
15560
15534
  collectorStyles: params.collectorStyles,
15561
15535
  prefersColorScheme: params.prefersColorScheme,
15562
- stageRatio: params.containerSizeRatio
15536
+ stageRatio: params.containerSizeRatio,
15537
+ highlightStage: params.highlightStage
15563
15538
  });
15564
15539
  (_a = manager.appManager) == null ? void 0 : _a.setBoxManager(manager.boxManager);
15565
15540
  if (params.container) {
@@ -15779,6 +15754,17 @@ const _WindowManager = class extends InvisiblePlugin {
15779
15754
  return false;
15780
15755
  }
15781
15756
  }
15757
+ async jumpPage(index2) {
15758
+ if (!this.appManager) {
15759
+ return false;
15760
+ }
15761
+ if (index2 < 0 || index2 >= this.pageState.length) {
15762
+ console.warn(`[WindowManager]: index ${index2} out of range`);
15763
+ return false;
15764
+ }
15765
+ await this.appManager.setMainViewSceneIndex(index2);
15766
+ return true;
15767
+ }
15782
15768
  async addPage(params) {
15783
15769
  if (this.appManager) {
15784
15770
  const after = params == null ? void 0 : params.after;