@netless/app-slide 0.2.105-beta.1 → 0.2.105-beta.3

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/main.es.js CHANGED
@@ -41502,8 +41502,6 @@ class ResizableContainer {
41502
41502
  this.whiteboardContainer.style.clipPath = `inset(${padding}px 0px ${padding}px 0px)`;
41503
41503
  }
41504
41504
  }
41505
- this.translateX = 0.5;
41506
- this.translateY = 0.5;
41507
41505
  this.renderScrollBar(
41508
41506
  parentBounds.width,
41509
41507
  parentBounds.width * this.scale,
@@ -41512,14 +41510,15 @@ class ResizableContainer {
41512
41510
  );
41513
41511
  this.handleNormalizeTranslate(this.translateX, this.translateY, {
41514
41512
  triggerScrollBar: true,
41515
- triggerSync: true
41513
+ triggerSync: false,
41514
+ force: true
41516
41515
  });
41517
41516
  (_a = this.slide) == null ? void 0 : _a.notifyFrameResize();
41518
41517
  (_b = this.onLayoutUpdated) == null ? void 0 : _b.call(this);
41519
41518
  }
41520
41519
  handleNormalizeTranslate(x, y, options) {
41521
41520
  var _a;
41522
- if (Math.abs(x - this.translateX) < 1e-3 && Math.abs(y - this.translateY) < 1e-3 && !options.triggerSync) {
41521
+ if (Math.abs(x - this.translateX) < 1e-3 && Math.abs(y - this.translateY) < 1e-3 && !options.triggerSync && !options.force) {
41523
41522
  return;
41524
41523
  }
41525
41524
  const parentBounds = this.scrollContainer.getBoundingClientRect();
@@ -42365,6 +42364,7 @@ class SlideDocsViewer {
42365
42364
  this.render();
42366
42365
  this._registerBoxSizeChange();
42367
42366
  this.sideEffect.add(() => {
42367
+ var _a, _b;
42368
42368
  const applyScale = (scale) => {
42369
42369
  if (this.resizableContainer) {
42370
42370
  this.resizableContainer.scaleContainer(scale);
@@ -42381,16 +42381,22 @@ class SlideDocsViewer {
42381
42381
  } else {
42382
42382
  console.log("[SlideDocsViewer] No initial slideScale found");
42383
42383
  }
42384
+ const initialTranslateX = (_a = this.context.storage.state.translateX) != null ? _a : 0.5;
42385
+ const initialTranslateY = (_b = this.context.storage.state.translateY) != null ? _b : 0.5;
42386
+ this.resizableContainer.handleNormalizeTranslate(initialTranslateX, initialTranslateY, {
42387
+ triggerScrollBar: true,
42388
+ triggerSync: false
42389
+ });
42384
42390
  const handler = (diff) => {
42385
- var _a, _b;
42391
+ var _a2, _b2;
42386
42392
  if (diff.slideScale !== void 0) {
42387
42393
  const newScale = diff.slideScale.newValue;
42388
42394
  applyScale(newScale != null ? newScale : 1);
42389
42395
  }
42390
42396
  if (diff.translateX !== void 0 || diff.translateY !== void 0) {
42391
42397
  const currentTranslate = this.resizableContainer.getTranslate();
42392
- const translateX = diff.translateX ? (_a = diff.translateX.newValue) != null ? _a : 0.5 : currentTranslate.x;
42393
- const translateY = diff.translateY ? (_b = diff.translateY.newValue) != null ? _b : 0.5 : currentTranslate.y;
42398
+ const translateX = diff.translateX ? (_a2 = diff.translateX.newValue) != null ? _a2 : 0.5 : currentTranslate.x;
42399
+ const translateY = diff.translateY ? (_b2 = diff.translateY.newValue) != null ? _b2 : 0.5 : currentTranslate.y;
42394
42400
  if (this.resizableContainer) {
42395
42401
  this.resizableContainer.handleNormalizeTranslate(translateX, translateY, {
42396
42402
  triggerScrollBar: true,
@@ -42853,7 +42859,7 @@ class SlidePreviewer {
42853
42859
  }
42854
42860
  }
42855
42861
  const usePlugin = /* @__PURE__ */ Slide.Slide.usePlugin.bind(Slide.Slide);
42856
- const version = "0.2.105-beta.1";
42862
+ const version = "0.2.105-beta.3";
42857
42863
  const DEFAULT_SLIDE_SETUP_READY_TIMEOUT = 5e3;
42858
42864
  const SlideApp = {
42859
42865
  kind: "Slide",
@@ -42919,6 +42925,8 @@ const SlideApp = {
42919
42925
  apps.set(context.appId, slideController, box);
42920
42926
  logger.setAppController(context.appId, slideController);
42921
42927
  slideController.readyPromise.then(options.onReady).then(() => {
42928
+ if (disposed)
42929
+ return;
42922
42930
  const room2 = context.getRoom();
42923
42931
  let synced = false;
42924
42932
  if (room2 && context.getIsWritable()) {
@@ -42973,6 +42981,44 @@ const SlideApp = {
42973
42981
  return () => room.callbacks.off("onRoomStateChanged", onRoomStateChanged);
42974
42982
  });
42975
42983
  }
42984
+ const isLazySetupMode = () => {
42985
+ var _a2;
42986
+ return ((_a2 = context.getWindowManager()) == null ? void 0 : _a2.lazySetupInMaximizedMode) === true;
42987
+ };
42988
+ const isBlurFreezeAllowed = () => {
42989
+ var _a2;
42990
+ const boxStatus = context.getBoxStatus();
42991
+ if (boxStatus)
42992
+ return boxStatus !== "normal";
42993
+ const boxState = (_a2 = context.getWindowManager()) == null ? void 0 : _a2.boxState;
42994
+ return boxState != null && boxState !== "normal";
42995
+ };
42996
+ sideEffect.add(
42997
+ () => context.emitter.on("focus", (isFocused) => {
42998
+ if (disposed)
42999
+ return;
43000
+ if (!isLazySetupMode())
43001
+ return;
43002
+ const controller = docsViewer == null ? void 0 : docsViewer.slideController;
43003
+ if (!controller)
43004
+ return;
43005
+ if (!isFocused) {
43006
+ if (!isBlurFreezeAllowed())
43007
+ return;
43008
+ if (!controller.isFrozen) {
43009
+ log("[Slide] blur freeze", context.appId);
43010
+ controller.freeze();
43011
+ }
43012
+ return;
43013
+ }
43014
+ if (useFreezer) {
43015
+ apps.focus(context.appId);
43016
+ } else if (controller.isFrozen) {
43017
+ log("[Slide] focus unfreeze", context.appId);
43018
+ controller.unfreeze();
43019
+ }
43020
+ })
43021
+ );
42976
43022
  let disposed = false;
42977
43023
  let offDestroy;
42978
43024
  const teardown = () => {
@@ -43036,6 +43082,10 @@ const SlideApp = {
43036
43082
  translateX: 0.5,
43037
43083
  translateY: 0.5
43038
43084
  });
43085
+ container.handleNormalizeTranslate(0.5, 0.5, {
43086
+ triggerScrollBar: true,
43087
+ triggerSync: false
43088
+ });
43039
43089
  container.scaleContainer(applyScale);
43040
43090
  },
43041
43091
  getViewScale: () => {