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

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.d.ts CHANGED
@@ -70,6 +70,11 @@ export declare type AppInitState = {
70
70
  sceneIndex?: number;
71
71
  boxState?: TeleBoxState;
72
72
  zIndex?: number;
73
+ visible?: boolean;
74
+ stageRatio?: number;
75
+ resizable?: boolean;
76
+ draggable?: boolean;
77
+ ratio?: number;
73
78
  };
74
79
  export declare type CursorMovePayload = {
75
80
  uid: string;
@@ -81,6 +86,8 @@ export declare type MountParams = {
81
86
  container?: HTMLElement;
82
87
  /** 白板高宽比例, 默认为 9 / 16 */
83
88
  containerSizeRatio?: number;
89
+ /** @deprecated */
90
+ chessboard?: boolean;
84
91
  /** 是否高亮显示同步区域, 默认为 true */
85
92
  highlightStage?: boolean;
86
93
  collectorContainer?: HTMLElement;
package/dist/index.es.js CHANGED
@@ -54,6 +54,11 @@ var AppAttributes = /* @__PURE__ */ ((AppAttributes2) => {
54
54
  AppAttributes2["Position"] = "position";
55
55
  AppAttributes2["SceneIndex"] = "SceneIndex";
56
56
  AppAttributes2["ZIndex"] = "zIndex";
57
+ AppAttributes2["Visible"] = "visible";
58
+ AppAttributes2["Ratio"] = "ratio";
59
+ AppAttributes2["StageRatio"] = "stageRatio";
60
+ AppAttributes2["Draggable"] = "draggable";
61
+ AppAttributes2["Resizable"] = "resizable";
57
62
  return AppAttributes2;
58
63
  })(AppAttributes || {});
59
64
  var AppEvents = /* @__PURE__ */ ((AppEvents2) => {
@@ -656,6 +661,16 @@ const safeListenPropsUpdated = (getProps, callback, onDestroyed) => {
656
661
  };
657
662
  const onObjectRemoved = onObjectByEvent(UpdateEventKind.Removed);
658
663
  onObjectByEvent(UpdateEventKind.Inserted);
664
+ const createValSync = (expr, Val2, isAddApp) => {
665
+ let skipUpdate = false;
666
+ return reaction(expr, (val) => {
667
+ if (isAddApp && !skipUpdate) {
668
+ skipUpdate = true;
669
+ } else {
670
+ Val2.setValue(val);
671
+ }
672
+ }, { fireImmediately: true });
673
+ };
659
674
  const plainObjectKeys = Object.keys;
660
675
  function isRef(e2) {
661
676
  return Boolean(has(e2, "__isRef"));
@@ -1070,7 +1085,7 @@ class AppContext {
1070
1085
  (_a = this.room) == null ? void 0 : _a.putScenes(this.appProxy.scenePath, scenes);
1071
1086
  };
1072
1087
  this.getInitScenePath = () => {
1073
- return this.manager.getAppInitPath(this.appId);
1088
+ return this.appProxy.scenePath;
1074
1089
  };
1075
1090
  this.setAttributes = (attributes) => {
1076
1091
  this.manager.safeSetAttributes({ [this.appId]: attributes });
@@ -1228,12 +1243,17 @@ class CameraSynchronizer {
1228
1243
  const nextScale = camera.scale * scale2;
1229
1244
  const moveCamera = () => {
1230
1245
  var _a;
1231
- (_a = this.view) == null ? void 0 : _a.moveCamera({
1232
- centerX: camera.centerX,
1233
- centerY: camera.centerY,
1246
+ const config = {
1234
1247
  scale: nextScale,
1235
1248
  animationMode: AnimationMode.Immediately
1236
- });
1249
+ };
1250
+ if (camera.centerX !== null) {
1251
+ config.centerX = camera.centerX;
1252
+ }
1253
+ if (camera.centerY !== null) {
1254
+ config.centerY = camera.centerY;
1255
+ }
1256
+ (_a = this.view) == null ? void 0 : _a.moveCamera(config);
1237
1257
  };
1238
1258
  moveCamera();
1239
1259
  delay(moveCamera, 50);
@@ -1280,7 +1300,9 @@ class ViewSync {
1280
1300
  }, "view");
1281
1301
  };
1282
1302
  this.onCameraUpdatedByDevice = (camera) => {
1283
- this.synchronizer.onLocalCameraUpdate(camera);
1303
+ if (!camera)
1304
+ return;
1305
+ this.synchronizer.onLocalCameraUpdate(Object.assign(camera, { id: this.context.uid }));
1284
1306
  const stage = this.context.stageRect$.value;
1285
1307
  if (stage) {
1286
1308
  const size2 = { width: stage.width, height: stage.height, id: this.context.uid };
@@ -1290,15 +1312,12 @@ class ViewSync {
1290
1312
  }
1291
1313
  };
1292
1314
  this.synchronizer = new CameraSynchronizer((camera) => {
1293
- const iCamera = __spreadValues({
1294
- id: this.context.uid
1295
- }, camera);
1296
- this.context.camera$.setValue(iCamera, true);
1315
+ this.context.camera$.setValue(camera, true);
1297
1316
  const notStoreCamera = this.context.viewMode$ && this.context.viewMode$.value === ViewMode.Freedom;
1298
1317
  if (notStoreCamera) {
1299
1318
  return;
1300
1319
  } else {
1301
- this.context.storeCamera(iCamera);
1320
+ this.context.storeCamera(camera);
1302
1321
  }
1303
1322
  });
1304
1323
  this.bindView(this.context.view$.value);
@@ -1742,8 +1761,8 @@ class AppProxy {
1742
1761
  if (box && view) {
1743
1762
  if (!this.camera$.value) {
1744
1763
  this.storeCamera({
1745
- centerX: 0,
1746
- centerY: 0,
1764
+ centerX: null,
1765
+ centerY: null,
1747
1766
  scale: 1,
1748
1767
  id: this.uid
1749
1768
  });
@@ -1776,6 +1795,48 @@ class AppProxy {
1776
1795
  }
1777
1796
  }));
1778
1797
  this.sideEffectManager.add(() => emitter.on("memberStateChange", this.onMemberStateChange));
1798
+ this.box$.subscribe((box) => {
1799
+ if (!box)
1800
+ return;
1801
+ this.sideEffectManager.add(() => [
1802
+ createValSync(() => {
1803
+ var _a2;
1804
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.visible;
1805
+ }, box._visible$, this.isAddApp),
1806
+ createValSync(() => {
1807
+ var _a2;
1808
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.ratio;
1809
+ }, box._ratio$, this.isAddApp),
1810
+ createValSync(() => {
1811
+ var _a2;
1812
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.stageRatio;
1813
+ }, box._stageRatio$, this.isAddApp),
1814
+ createValSync(() => {
1815
+ var _a2;
1816
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.draggable;
1817
+ }, box._draggable$, this.isAddApp),
1818
+ createValSync(() => {
1819
+ var _a2;
1820
+ return (_a2 = this.appAttributes) == null ? void 0 : _a2.state.resizable;
1821
+ }, box._resizable$, this.isAddApp),
1822
+ box._visible$.subscribe((visible) => {
1823
+ this.store.updateAppState(this.id, AppAttributes.Visible, visible);
1824
+ }),
1825
+ box._ratio$.subscribe((ratio) => {
1826
+ this.store.updateAppState(this.id, AppAttributes.Ratio, ratio);
1827
+ }),
1828
+ box._stageRatio$.subscribe((stageRatio) => {
1829
+ this.store.updateAppState(this.id, AppAttributes.StageRatio, stageRatio);
1830
+ }),
1831
+ box._draggable$.subscribe((draggable) => {
1832
+ this.store.updateAppState(this.id, AppAttributes.Draggable, draggable);
1833
+ }),
1834
+ box._resizable$.subscribe((resizable) => {
1835
+ console.log("resizable change", resizable);
1836
+ this.store.updateAppState(this.id, AppAttributes.Resizable, resizable);
1837
+ })
1838
+ ]);
1839
+ });
1779
1840
  }
1780
1841
  createAppDir() {
1781
1842
  const scenePath = this.scenePath || this.appScenePath;
@@ -15619,7 +15680,7 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
15619
15680
  const _WindowManager = class extends InvisiblePlugin {
15620
15681
  constructor(context) {
15621
15682
  super(context);
15622
- this.version = "1.0.0-canary.18";
15683
+ this.version = "1.0.0-canary.20";
15623
15684
  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" } };
15624
15685
  this.emitter = callbacks$1;
15625
15686
  this.viewMode = ViewMode.Broadcaster;