@netless/window-manager 1.0.0-canary.36 → 1.0.0-canary.39

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
@@ -495,13 +495,18 @@ class CameraSynchronizer {
495
495
  this.view = view;
496
496
  }
497
497
  onRemoteSizeUpdate(size2) {
498
+ var _a;
498
499
  this.remoteSize = size2;
499
500
  const needMoveCamera = !isEqual(pick(this.rect, ["width", "height"]), pick(size2, ["width", "height"]));
500
501
  if (this.rect && this.remoteCamera && needMoveCamera) {
501
- const scale2 = this.rect.width / size2.width;
502
- const nextScale = this.remoteCamera.scale * scale2;
503
- this.moveCamera({
504
- scale: nextScale
502
+ if (!this.view)
503
+ return;
504
+ const currentCamera = this.view.camera;
505
+ (_a = this.view) == null ? void 0 : _a.moveCameraToContain({
506
+ width: size2.width,
507
+ height: size2.height,
508
+ originX: currentCamera.centerX - size2.width / 2,
509
+ originY: currentCamera.centerY - size2.height / 2
505
510
  });
506
511
  }
507
512
  }
@@ -684,10 +689,10 @@ class InvalidScenePath extends Error {
684
689
  this.message = `[WindowManager]: ScenePath should start with "/"`;
685
690
  }
686
691
  }
687
- class BoxManagerNotFoundError extends Error {
692
+ class BoxManagerNotInitializeError extends Error {
688
693
  constructor() {
689
694
  super(...arguments);
690
- this.message = "[WindowManager]: boxManager not found";
695
+ this.message = "[WindowManager]: boxManager need initialize";
691
696
  }
692
697
  }
693
698
  class BindContainerRoomPhaseInvalidError extends Error {
@@ -1942,7 +1947,7 @@ class AppProxy {
1942
1947
  var _a;
1943
1948
  log("setupApp", appId, app, options);
1944
1949
  if (!this.boxManager) {
1945
- throw new BoxManagerNotFoundError();
1950
+ throw new BoxManagerNotInitializeError();
1946
1951
  }
1947
1952
  const context = new AppContext(this.manager, appId, this, appOptions);
1948
1953
  this.appContext = context;
@@ -2988,7 +2993,7 @@ class AppManager {
2988
2993
  if (appIds.length === 0) {
2989
2994
  this.appCreateQueue.emitReady();
2990
2995
  }
2991
- const appsWithCreatedAt = appIds.map((appId) => {
2996
+ let appsWithCreatedAt = appIds.map((appId) => {
2992
2997
  if (apps[appId].setup) {
2993
2998
  return {
2994
2999
  id: appId,
@@ -2998,6 +3003,14 @@ class AppManager {
2998
3003
  return {};
2999
3004
  }
3000
3005
  });
3006
+ if (this.isReplay) {
3007
+ appsWithCreatedAt = appIds.map((appId) => {
3008
+ return {
3009
+ id: appId,
3010
+ createdAt: apps[appId].createdAt
3011
+ };
3012
+ });
3013
+ }
3001
3014
  for (const { id } of orderBy(appsWithCreatedAt, "createdAt", "asc")) {
3002
3015
  if (id && !this.appProxies.has(id) && !this.appStatus.has(id)) {
3003
3016
  const app = apps[id];
@@ -5801,6 +5814,9 @@ class BoxManager {
5801
5814
  }),
5802
5815
  emitter2.on("containerSizeRatioUpdate", (ratio) => {
5803
5816
  this.teleBoxManager._stageRatio$.setValue(ratio);
5817
+ }),
5818
+ this.teleBoxManager._fullscreen$.reaction((fullscreen) => {
5819
+ callbacks2.emit("fullscreenChange", fullscreen);
5804
5820
  })
5805
5821
  ]);
5806
5822
  }
@@ -12892,15 +12908,51 @@ const reconnectRefresher = new ReconnectRefresher({ emitter });
12892
12908
  const _WindowManager = class extends InvisiblePlugin {
12893
12909
  constructor(context) {
12894
12910
  super(context);
12895
- this.version = "1.0.0-canary.36";
12896
- this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.33", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.1.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.3.0", "@netless/app-plyr": "0.2.0", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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.3", "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", "vite-plugin-dts": "^1.2.1", "vitest": "^0.18.0", "white-web-sdk": "2.16.26" } };
12911
+ this.version = "1.0.0-canary.39";
12912
+ this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.34", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.1.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.3.0", "@netless/app-plyr": "0.2.0", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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.3", "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", "vite-plugin-dts": "^1.2.1", "vitest": "^0.18.0", "white-web-sdk": "2.16.26" } };
12897
12913
  this.emitter = callbacks;
12898
12914
  this.viewMode = ViewMode.Broadcaster;
12899
12915
  this.viewMode$ = new Val$1(ViewMode.Broadcaster);
12900
12916
  this.isReplay = isPlayer(this.displayer);
12901
12917
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
12918
+ this.moveCamera = debounce((camera) => {
12919
+ var _a;
12920
+ const mainViewCamera = __spreadValues({}, this.mainView.camera);
12921
+ const nextCamera = __spreadValues(__spreadValues({}, mainViewCamera), camera);
12922
+ if (isEqual(nextCamera, mainViewCamera))
12923
+ return;
12924
+ if (!this.appManager)
12925
+ return;
12926
+ if (camera.animationMode === AnimationMode.Immediately) {
12927
+ this.appManager.mainViewProxy.storeCamera(__spreadValues({
12928
+ id: this.appManager.uid
12929
+ }, nextCamera));
12930
+ } else {
12931
+ const remoteCamera = this.appManager.mainViewProxy.size$.value;
12932
+ const currentSize = (_a = this.boxManager) == null ? void 0 : _a.stageRect;
12933
+ let nextScale;
12934
+ if (camera.scale && remoteCamera && currentSize) {
12935
+ nextScale = camera.scale * computedMinScale(remoteCamera, currentSize);
12936
+ }
12937
+ if (nextScale) {
12938
+ this.mainView.moveCamera(__spreadProps(__spreadValues({}, camera), {
12939
+ scale: nextScale
12940
+ }));
12941
+ } else {
12942
+ this.mainView.moveCamera(camera);
12943
+ }
12944
+ this.appManager.dispatchInternalEvent(Events.MoveCamera, camera);
12945
+ setTimeout(() => {
12946
+ if (!this.appManager)
12947
+ return;
12948
+ this.appManager.mainViewProxy.storeCamera(__spreadValues({
12949
+ id: this.appManager.uid
12950
+ }, nextCamera));
12951
+ }, 200);
12952
+ }
12953
+ }, 200);
12902
12954
  _WindowManager.displayer = context.displayer;
12903
- window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.33", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.1.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.3.0", "@netless/app-plyr": "0.2.0", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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.3", "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", "vite-plugin-dts": "^1.2.1", "vitest": "^0.18.0", "white-web-sdk": "2.16.26" } };
12955
+ window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "1.0.0-alpha.34", "emittery": "^0.11.0", "lodash": "^4.17.21", "p-retry": "^4.6.2", "side-effect-manager": "^1.1.1", "uuid": "^7.0.3", "value-enhancer": "^1.3.2" }, "peerDependencies": { "white-web-sdk": "^2.16.0" }, "devDependencies": { "@netless/app-docs-viewer": "^0.3.0", "@netless/app-plyr": "0.2.0", "@playwright/test": "^1.23.2", "@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.49", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.6", "@types/node": "^18.0.3", "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.2", "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.3", "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", "vite-plugin-dts": "^1.2.1", "vitest": "^0.18.0", "white-web-sdk": "2.16.26" } };
12904
12956
  }
12905
12957
  static async mount(params) {
12906
12958
  var _a;
@@ -13399,6 +13451,12 @@ const _WindowManager = class extends InvisiblePlugin {
13399
13451
  throw new AppManagerNotInitError();
13400
13452
  }
13401
13453
  }
13454
+ get teleboxManager() {
13455
+ if (!this.boxManager) {
13456
+ throw new BoxManagerNotInitializeError();
13457
+ }
13458
+ return this.boxManager.teleBoxManager;
13459
+ }
13402
13460
  queryAll() {
13403
13461
  var _a;
13404
13462
  return Array.from(((_a = this.appManager) == null ? void 0 : _a.appProxies.values()) || []);
@@ -13411,87 +13469,6 @@ const _WindowManager = class extends InvisiblePlugin {
13411
13469
  var _a;
13412
13470
  return (_a = this.appManager) == null ? void 0 : _a.closeApp(appId);
13413
13471
  }
13414
- moveCamera(camera) {
13415
- var _a;
13416
- const mainViewCamera = __spreadValues({}, this.mainView.camera);
13417
- const nextCamera = __spreadValues(__spreadValues({}, mainViewCamera), camera);
13418
- if (isEqual(nextCamera, mainViewCamera))
13419
- return;
13420
- if (!this.appManager)
13421
- return;
13422
- if (camera.animationMode === AnimationMode.Immediately) {
13423
- this.appManager.mainViewProxy.storeCamera(__spreadValues({
13424
- id: this.appManager.uid
13425
- }, nextCamera));
13426
- } else {
13427
- const remoteCamera = this.appManager.mainViewProxy.size$.value;
13428
- const currentSize = (_a = this.boxManager) == null ? void 0 : _a.stageRect;
13429
- let nextScale;
13430
- if (camera.scale && remoteCamera && currentSize) {
13431
- nextScale = camera.scale * computedMinScale(remoteCamera, currentSize);
13432
- }
13433
- if (nextScale) {
13434
- this.mainView.moveCamera(__spreadProps(__spreadValues({}, camera), {
13435
- scale: nextScale
13436
- }));
13437
- } else {
13438
- this.mainView.moveCamera(camera);
13439
- }
13440
- this.appManager.dispatchInternalEvent(Events.MoveCamera, camera);
13441
- setTimeout(() => {
13442
- if (!this.appManager)
13443
- return;
13444
- this.appManager.mainViewProxy.storeCamera(__spreadValues({
13445
- id: this.appManager.uid
13446
- }, nextCamera));
13447
- }, 200);
13448
- }
13449
- }
13450
- moveCameraToContain(rectangle) {
13451
- if (!this.appManager)
13452
- return;
13453
- const camera = {};
13454
- if (isNumber$2(rectangle.originX)) {
13455
- camera.centerX = rectangle.originX;
13456
- }
13457
- if (isNumber$2(rectangle.originY)) {
13458
- camera.centerY = rectangle.originY;
13459
- }
13460
- if (rectangle.animationMode === AnimationMode.Immediately) {
13461
- this.appManager.mainViewProxy.storeSize({
13462
- id: this.appManager.uid,
13463
- width: rectangle.width,
13464
- height: rectangle.height
13465
- });
13466
- this.mainView.moveCameraToContain(rectangle);
13467
- if (!isEmpty$2(camera) && this.appManager.mainViewProxy.camera$.value) {
13468
- this.appManager.mainViewProxy.storeCamera(__spreadProps(__spreadValues({}, this.appManager.mainViewProxy.camera$.value), {
13469
- id: this.appManager.uid,
13470
- centerX: this.mainView.camera.centerX,
13471
- centerY: this.mainView.camera.centerY
13472
- }));
13473
- }
13474
- } else {
13475
- this.appManager.dispatchInternalEvent(Events.MoveCameraToContain, rectangle);
13476
- this.mainView.moveCameraToContain(rectangle);
13477
- setTimeout(() => {
13478
- if (!this.appManager)
13479
- return;
13480
- this.appManager.mainViewProxy.storeSize({
13481
- id: this.appManager.uid,
13482
- width: rectangle.width,
13483
- height: rectangle.height
13484
- });
13485
- if (!isEmpty$2(camera) && this.appManager.mainViewProxy.camera$.value) {
13486
- this.appManager.mainViewProxy.storeCamera(__spreadProps(__spreadValues({}, this.appManager.mainViewProxy.camera$.value), {
13487
- id: this.appManager.uid,
13488
- centerX: this.mainView.camera.centerX,
13489
- centerY: this.mainView.camera.centerY
13490
- }));
13491
- }
13492
- }, 200);
13493
- }
13494
- }
13495
13472
  convertToPointInWorld(point) {
13496
13473
  return this.mainView.convertToPointInWorld(point);
13497
13474
  }
@@ -13631,6 +13608,14 @@ const _WindowManager = class extends InvisiblePlugin {
13631
13608
  setBaseSize(size2) {
13632
13609
  var _a;
13633
13610
  (_a = this.appManager) == null ? void 0 : _a.mainViewProxy.setMainViewSize(size2);
13611
+ setTimeout(() => {
13612
+ if (!this.appManager || !this.appManager.mainViewProxy.camera$.value)
13613
+ return;
13614
+ this.appManager.mainViewProxy.storeCamera(__spreadProps(__spreadValues({}, this.appManager.mainViewProxy.camera$.value), {
13615
+ id: this.appManager.uid,
13616
+ scale: 1
13617
+ }));
13618
+ }, 500);
13634
13619
  }
13635
13620
  createPPTHandler() {
13636
13621
  return {
@@ -13686,4 +13671,4 @@ WindowManager.debug = false;
13686
13671
  WindowManager.containerSizeRatio = DEFAULT_CONTAINER_RATIO;
13687
13672
  WindowManager.isCreated = false;
13688
13673
  setupBuiltin();
13689
- export { AppCreateError, AppManagerNotInitError, AppNotRegisterError, BindContainerRoomPhaseInvalidError, BoxManagerNotFoundError, BoxNotCreatedError, BuiltinApps, BuiltinAppsMap, InvalidScenePath, ParamsInvalidError, WhiteWebSDKInvalidError, WindowManager, calculateNextIndex, reconnectRefresher };
13674
+ export { AppCreateError, AppManagerNotInitError, AppNotRegisterError, BindContainerRoomPhaseInvalidError, BoxManagerNotInitializeError, BoxNotCreatedError, BuiltinApps, BuiltinAppsMap, InvalidScenePath, ParamsInvalidError, WhiteWebSDKInvalidError, WindowManager, calculateNextIndex, reconnectRefresher };