@netless/window-manager 1.0.0-canary.5 → 1.0.0-canary.8

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
  }
@@ -1033,20 +1032,23 @@ class AppContext {
1033
1032
  view = this.appProxy.createAppDir();
1034
1033
  }
1035
1034
  const viewWrapper = document.createElement("div");
1035
+ this._viewWrapper = viewWrapper;
1036
1036
  viewWrapper.className = "window-manager-view-wrapper";
1037
1037
  (_a = this.box.$content.parentElement) == null ? void 0 : _a.appendChild(viewWrapper);
1038
1038
  const removeViewWrapper = () => {
1039
1039
  var _a2;
1040
1040
  (_a2 = this.box.$content.parentElement) == null ? void 0 : _a2.removeChild(viewWrapper);
1041
+ this._viewWrapper = void 0;
1041
1042
  };
1042
1043
  view.divElement = viewWrapper;
1043
1044
  if (this.isAddApp) {
1044
- this.initPageSize(size2);
1045
+ this.ensurePageSize(size2);
1045
1046
  }
1046
- this.whiteBoardView = new WhiteBoardView(this, this.appProxy, removeViewWrapper);
1047
+ this.whiteBoardView = new WhiteBoardView(view, this, this.appProxy, removeViewWrapper, this.ensurePageSize);
1047
1048
  return this.whiteBoardView;
1048
1049
  };
1049
- this.initPageSize = (size2) => {
1050
+ this.ensurePageSize = (size2) => {
1051
+ var _a;
1050
1052
  if (!isNumber(size2))
1051
1053
  return;
1052
1054
  if (!this.appProxy.scenePath)
@@ -1057,11 +1059,8 @@ class AppContext {
1057
1059
  throw Error(`[WindowManager]: size ${size2} muse be in range [1, ${MAX_PAGE_SIZE}]`);
1058
1060
  }
1059
1061
  const needInsert = size2 - this.appProxy.pageState.length;
1060
- const startPageNumber = this.appProxy.pageState.length;
1061
- const scenes = new Array(needInsert).fill({}).map((_2, index2) => {
1062
- return { name: `${startPageNumber + index2 + 1}` };
1063
- });
1064
- putScenes(this.room, this.appProxy.scenePath, scenes);
1062
+ const scenes = new Array(needInsert).fill({});
1063
+ (_a = this.room) == null ? void 0 : _a.putScenes(this.appProxy.scenePath, scenes);
1065
1064
  };
1066
1065
  this.getInitScenePath = () => {
1067
1066
  return this.manager.getAppInitPath(this.appId);
@@ -1108,6 +1107,9 @@ class AppContext {
1108
1107
  get displayer() {
1109
1108
  return this.manager.displayer;
1110
1109
  }
1110
+ get destroyed() {
1111
+ return this.appProxy.status === "destroyed";
1112
+ }
1111
1113
  get view() {
1112
1114
  return this.appProxy.view;
1113
1115
  }
@@ -1297,14 +1299,12 @@ class AppViewSync {
1297
1299
  this.synchronizer.setRect(rect);
1298
1300
  }
1299
1301
  }));
1300
- if (!this.appProxy.size$.value) {
1301
- this.appProxy.storeSize({
1302
- id: this.appProxy.uid,
1303
- width: box.contentStageRect.width,
1304
- height: box.contentStageRect.height
1305
- });
1306
- }
1307
1302
  }
1303
+ this.sem.add(() => combine([this.appProxy.camera$, this.appProxy.size$]).subscribe(([camera, size2]) => {
1304
+ if (camera && size2) {
1305
+ this.synchronizer.onRemoteUpdate(camera, size2);
1306
+ }
1307
+ }));
1308
1308
  }
1309
1309
  destroy() {
1310
1310
  this.sem.flushAll();
@@ -1653,12 +1653,45 @@ class AppProxy {
1653
1653
  });
1654
1654
  });
1655
1655
  combine([this.box$, this.view$]).subscribe(([box, view]) => {
1656
+ var _a2, _b;
1656
1657
  if (box && view) {
1657
- const appViewSync = new AppViewSync(this);
1658
- this.appViewSync = appViewSync;
1659
- this.sideEffectManager.add(() => () => appViewSync.destroy());
1658
+ if (!this.camera$.value) {
1659
+ this.storeCamera({
1660
+ centerX: 0,
1661
+ centerY: 0,
1662
+ scale: 1,
1663
+ id: this.uid
1664
+ });
1665
+ this.camera$.setValue(toJS(this.appAttributes.camera));
1666
+ }
1667
+ if (!this.size$.value && box.contentStageRect) {
1668
+ this.storeSize({
1669
+ id: this.uid,
1670
+ width: (_a2 = box.contentStageRect) == null ? void 0 : _a2.width,
1671
+ height: (_b = box.contentStageRect) == null ? void 0 : _b.height
1672
+ });
1673
+ this.size$.setValue(toJS(this.appAttributes.size));
1674
+ }
1675
+ this.appViewSync = new AppViewSync(this);
1676
+ this.sideEffectManager.add(() => () => {
1677
+ var _a3;
1678
+ return (_a3 = this.appViewSync) == null ? void 0 : _a3.destroy();
1679
+ });
1660
1680
  }
1661
1681
  });
1682
+ this.sideEffectManager.add(() => emitter.on("memberStateChange", (memberState) => {
1683
+ var _a2, _b;
1684
+ const needPointerEventsNone = memberState.currentApplianceName === "clicker";
1685
+ if (needPointerEventsNone) {
1686
+ if ((_a2 = this.appContext) == null ? void 0 : _a2._viewWrapper) {
1687
+ this.appContext._viewWrapper.style.pointerEvents = "none";
1688
+ }
1689
+ } else {
1690
+ if ((_b = this.appContext) == null ? void 0 : _b._viewWrapper) {
1691
+ this.appContext._viewWrapper.style.pointerEvents = "auto";
1692
+ }
1693
+ }
1694
+ }));
1662
1695
  }
1663
1696
  createAppDir() {
1664
1697
  const scenePath = this.scenePath || this.appScenePath;
@@ -2555,6 +2588,9 @@ class AppManager {
2555
2588
  emitter.emit("roomMembersChange", this.members);
2556
2589
  }
2557
2590
  emitter.emit("observerIdChange", this.displayer.observerId);
2591
+ if (state.memberState) {
2592
+ emitter.emit("memberStateChange", toJS(state.memberState));
2593
+ }
2558
2594
  };
2559
2595
  this.displayerWritableListener = (isReadonly) => {
2560
2596
  var _a, _b;
@@ -3982,10 +4018,10 @@ class Y$3 {
3982
4018
  this._sideEffect.addDisposer(re2.reaction((e3, t3) => {
3983
4019
  le2.setValue({ width: Math.max(a2, e3.width), height: Math.max(n2, e3.height) }, t3);
3984
4020
  }));
3985
- 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 });
4021
+ 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 });
3986
4022
  this._sideEffect.addDisposer(() => $e2.destroy());
3987
4023
  withReadonlyValueEnhancer(this, { darkMode: D2, fence: T2, minimized: V2, maximized: W2, readonly: Y2, rootRect: P2, managerStageRect: O2, collectorRect: Z2 });
3988
- 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$ };
4024
+ 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$ };
3989
4025
  withReadonlyValueEnhancer(this, be2, G2);
3990
4026
  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) => {
3991
4027
  var t3;
@@ -3994,7 +4030,7 @@ class Y$3 {
3994
4030
  e3 > 0 && this.transform(me2.value.x, me2.value.y, ce2.value.width, ce2.value.height, true);
3995
4031
  })), this._sideEffect.addDisposer(T2.subscribe((e3) => {
3996
4032
  e3 && this.move(me2.value.x, me2.value.y, true);
3997
- })), this.$box = this.render(), xe2.setValue(this.$content.parentElement);
4033
+ })), this.$box = this.render(), pe2.setValue(this.$content.parentElement);
3998
4034
  const ve2 = (e3, t3) => {
3999
4035
  this._sideEffect.addDisposer(e3.reaction((e4, i3) => {
4000
4036
  i3 || this.events.emit(t3, e4);
@@ -4128,7 +4164,7 @@ class Y$3 {
4128
4164
  r2.className = this.wrapClassName("content") + " tele-fancy-scrollbar", this.$content = r2, this._sideEffect.add(() => {
4129
4165
  const e3 = new W$3(() => {
4130
4166
  const e4 = r2.getBoundingClientRect();
4131
- this._contentRect$.setValue({ x: e4.x, y: e4.y, width: e4.width, height: e4.height });
4167
+ this._contentRect$.setValue({ x: 0, y: 0, width: e4.width, height: e4.height });
4132
4168
  });
4133
4169
  return e3.observe(r2), () => e3.disconnect();
4134
4170
  }), this._sideEffect.add(() => {
@@ -4180,13 +4216,13 @@ class Y$3 {
4180
4216
  let { pageX: t3, pageY: i3 } = R$3(e3);
4181
4217
  i3 < this.rootRect.y && (i3 = this.rootRect.y);
4182
4218
  const s3 = t3 - l2, c2 = i3 - d2;
4183
- let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: x2 } = this.pxIntrinsicSize;
4219
+ let { x: m3, y: u3 } = this.pxIntrinsicCoord, { width: g2, height: p2 } = this.pxIntrinsicSize;
4184
4220
  switch (a2) {
4185
4221
  case N$3.North:
4186
- u3 = o2 + c2, x2 = h - c2;
4222
+ u3 = o2 + c2, p2 = h - c2;
4187
4223
  break;
4188
4224
  case N$3.South:
4189
- x2 = h + c2;
4225
+ p2 = h + c2;
4190
4226
  break;
4191
4227
  case N$3.West:
4192
4228
  m3 = n2 + s3, g2 = r2 - s3;
@@ -4195,21 +4231,21 @@ class Y$3 {
4195
4231
  g2 = r2 + s3;
4196
4232
  break;
4197
4233
  case N$3.NorthWest:
4198
- m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, x2 = h - c2;
4234
+ m3 = n2 + s3, u3 = o2 + c2, g2 = r2 - s3, p2 = h - c2;
4199
4235
  break;
4200
4236
  case N$3.NorthEast:
4201
- u3 = o2 + c2, g2 = r2 + s3, x2 = h - c2;
4237
+ u3 = o2 + c2, g2 = r2 + s3, p2 = h - c2;
4202
4238
  break;
4203
4239
  case N$3.SouthEast:
4204
- g2 = r2 + s3, x2 = h + c2;
4240
+ g2 = r2 + s3, p2 = h + c2;
4205
4241
  break;
4206
4242
  case N$3.SouthWest:
4207
- m3 = n2 + s3, g2 = r2 - s3, x2 = h + c2;
4243
+ m3 = n2 + s3, g2 = r2 - s3, p2 = h + c2;
4208
4244
  break;
4209
4245
  default:
4210
4246
  return void this.move(n2 + s3, o2 + c2);
4211
4247
  }
4212
- this.transform(m3, u3, g2, x2);
4248
+ this.transform(m3, u3, g2, p2);
4213
4249
  }, m2 = (e3) => {
4214
4250
  a2 = void 0, s2 && (k$1(e3), this.$box.classList.toggle(i2, false), this._sideEffect.flush(t2), s2.remove());
4215
4251
  }, u2 = (e3) => {
@@ -4345,7 +4381,7 @@ class F$3 {
4345
4381
  };
4346
4382
  const t3 = new Z$3(() => {
4347
4383
  const t4 = e3.getBoundingClientRect();
4348
- I2.setValue({ x: t4.x, y: t4.y, width: t4.width, height: t4.height });
4384
+ I2.setValue({ x: 0, y: 0, width: t4.width, height: t4.height });
4349
4385
  });
4350
4386
  return t3.observe(e3), () => t3.disconnect();
4351
4387
  }, "calc-root-rect");
@@ -15461,14 +15497,14 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
15461
15497
  const _WindowManager = class extends InvisiblePlugin {
15462
15498
  constructor(context) {
15463
15499
  super(context);
15464
- this.version = "1.0.0-canary.5";
15465
- 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" } };
15500
+ this.version = "1.0.0-canary.8";
15501
+ 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" } };
15466
15502
  this.emitter = callbacks$1;
15467
15503
  this.viewMode = ViewMode.Broadcaster;
15468
15504
  this.isReplay = isPlayer(this.displayer);
15469
15505
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
15470
15506
  _WindowManager.displayer = context.displayer;
15471
- 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" } };
15507
+ 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" } };
15472
15508
  }
15473
15509
  static async mount(params) {
15474
15510
  var _a;