@netless/app-slide 0.1.1 → 0.1.4

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
@@ -31618,7 +31618,7 @@ void main(void){
31618
31618
  r3 ? e4.position.y = h2 > 0 ? h2 : 0 : e4.position.x = u2, this.textureContainer.addChild(e4);
31619
31619
  }
31620
31620
  if (this.underline && (this.underline.render(), this.underline.sprite)) {
31621
- r3 ? (this.underline.sprite.position.y = o3 ? o3 - n2 / 16 : i2, this.underline.sprite.position.x = 0) : (this.underline.sprite.position.x = 0, this.underline.sprite.position.y = 0), document.body.appendChild(this.ctx.renderer.plugins.extract.image(this.underline.sprite));
31621
+ r3 ? (this.underline.sprite.position.y = o3 ? o3 - n2 / 16 : i2, this.underline.sprite.position.x = 0) : (this.underline.sprite.position.x = 0, this.underline.sprite.position.y = 0);
31622
31622
  const t4 = this.textFill.getClonedDisplayObject();
31623
31623
  t4 ? (t4.mask = this.underline.sprite, t4.addChild(this.underline.sprite), this.textureContainer.addChild(t4)) : this.textureContainer.addChild(this.underline.sprite);
31624
31624
  }
@@ -35794,7 +35794,7 @@ void main(void){
35794
35794
  }
35795
35795
  var $P = { syncDispatch: "syncDispatch", syncReceive: "syncReceive", renderStart: "renderStart", renderEnd: "renderEnd", renderError: "renderError", slideChange: "slideChange", mainSeqStepStart: "mainSeqStepStart", mainSeqStepEnd: "mainSeqStepEnd", animateStart: "animateStart", animateEnd: "animateEnd", stateChange: "stateChange" }, QP = { taskId: "", url: "", currentSlideIndex: -1, mainSeqStep: -1, mainSeqState: null, mediaState: /* @__PURE__ */ Object.create(null), interactiveSeqState: /* @__PURE__ */ Object.create(null) }, tI = "";
35796
35796
  try {
35797
- tI = "0.2.8";
35797
+ tI = "0.2.10";
35798
35798
  } catch (t3) {
35799
35799
  tI = "dev";
35800
35800
  }
@@ -36563,11 +36563,22 @@ class Logger {
36563
36563
  this.apps = {};
36564
36564
  this.level = "debug";
36565
36565
  this._onMessage = (ev) => {
36566
- if (isObj(ev.data)) {
36567
- if (typeof ev.data.slide === "boolean") {
36568
- this.enable = ev.data.slide;
36569
- } else if (ev.data.slide === "__instance") {
36566
+ let data;
36567
+ if (ev instanceof CustomEvent) {
36568
+ data = ev.detail;
36569
+ } else if (isObj(ev.data)) {
36570
+ data = ev.data;
36571
+ }
36572
+ if (data) {
36573
+ if (typeof data.slide === "boolean") {
36574
+ this.enable = data.slide;
36575
+ } else if (data.slide === "__instance") {
36570
36576
  console.log(this);
36577
+ } else if (data.slide === "__debug") {
36578
+ Object.values(this.apps).forEach((app) => {
36579
+ var _a, _b;
36580
+ (_b = (_a = app.controller) == null ? void 0 : _a.slide) == null ? void 0 : _b.createController();
36581
+ });
36571
36582
  }
36572
36583
  }
36573
36584
  };
@@ -36750,6 +36761,8 @@ class SlideController {
36750
36761
  }
36751
36762
  };
36752
36763
  this.unfreeze = async () => {
36764
+ if (!this.visible)
36765
+ return;
36753
36766
  if (this.ready) {
36754
36767
  log("[Slide] unfreeze", this.context.appId);
36755
36768
  if (this.freezePromise) {
@@ -36762,6 +36775,18 @@ class SlideController {
36762
36775
  this._toFreeze = -1;
36763
36776
  }
36764
36777
  };
36778
+ this.onVisibilityChange = async () => {
36779
+ if (!(this.visible = document.visibilityState === "visible")) {
36780
+ this.savedIsFrozen = this.freezePromise ? this._toFreeze === 1 : this.isFrozen;
36781
+ log("[Slide] freeze because tab becomes invisible");
36782
+ this.freeze();
36783
+ } else {
36784
+ log("[Slide] unfreeze because tab becomes visible", { savedIsFrozen: this.savedIsFrozen });
36785
+ if (!this.savedIsFrozen) {
36786
+ this.unfreeze();
36787
+ }
36788
+ }
36789
+ };
36765
36790
  this.onPageChanged = onPageChanged;
36766
36791
  this.onTransitionStart = onTransitionStart;
36767
36792
  this.onTransitionEnd = onTransitionEnd;
@@ -36771,6 +36796,8 @@ class SlideController {
36771
36796
  this.player = this.room ? void 0 : context.getDisplayer();
36772
36797
  this.slide = this.createSlide(anchor);
36773
36798
  this.syncStateOnceFlag = !this.context.isAddApp;
36799
+ this.visible = document.visibilityState === "visible";
36800
+ this.savedIsFrozen = false;
36774
36801
  this.initialize();
36775
36802
  }
36776
36803
  jumpToPage(page) {
@@ -36820,6 +36847,10 @@ class SlideController {
36820
36847
  slide.on(Slide.SLIDE_EVENTS.stateChange, this.onStateChange);
36821
36848
  slide.on(Slide.SLIDE_EVENTS.syncDispatch, this.onSyncDispatch);
36822
36849
  slide.on(Slide.SLIDE_EVENTS.renderEnd, this.resolveReady);
36850
+ this.sideEffect.add(() => {
36851
+ document.addEventListener("visibilitychange", this.onVisibilityChange);
36852
+ return () => document.removeEventListener("visibilitychange", this.onVisibilityChange);
36853
+ });
36823
36854
  }
36824
36855
  syncStateOnce() {
36825
36856
  if (this.syncStateOnceFlag) {
@@ -36844,7 +36875,7 @@ class SlideController {
36844
36875
  return this.slide.slideState.currentSlideIndex;
36845
36876
  }
36846
36877
  createSlide(anchor) {
36847
- var _a, _b;
36878
+ var _a, _b, _c, _d, _e, _f;
36848
36879
  const slide = new Slide.Slide({
36849
36880
  anchor,
36850
36881
  interactive: true,
@@ -36853,12 +36884,12 @@ class SlideController {
36853
36884
  controller: logger.enable,
36854
36885
  enableGlobalClick: true,
36855
36886
  renderOptions: {
36856
- minFPS: 25,
36857
- maxFPS: 30,
36887
+ minFPS: ((_a = this.context.getAppOptions()) == null ? void 0 : _a.minFPS) || 25,
36888
+ maxFPS: ((_b = this.context.getAppOptions()) == null ? void 0 : _b.maxFPS) || 30,
36858
36889
  autoFPS: true,
36859
- autoResolution: true,
36860
- resolution: (_a = this.context.getAppOptions()) == null ? void 0 : _a.resolution,
36861
- transactionBgColor: ((_b = this.context.getAppOptions()) == null ? void 0 : _b.bgColor) || cachedGetBgColor(anchor)
36890
+ autoResolution: (_d = (_c = this.context.getAppOptions()) == null ? void 0 : _c.autoResolution) != null ? _d : true,
36891
+ resolution: (_e = this.context.getAppOptions()) == null ? void 0 : _e.resolution,
36892
+ transactionBgColor: ((_f = this.context.getAppOptions()) == null ? void 0 : _f.bgColor) || cachedGetBgColor(anchor)
36862
36893
  },
36863
36894
  timestamp: this.timestamp
36864
36895
  });
@@ -38214,7 +38245,7 @@ class SlidePreviewer {
38214
38245
  return `${this.namespace}-${className}`;
38215
38246
  }
38216
38247
  }
38217
- const version = "0.1.1";
38248
+ const version = "0.1.4";
38218
38249
  const SlideApp = {
38219
38250
  kind: "Slide",
38220
38251
  setup(context) {