@netless/app-slide 0.2.106-beta.2 → 0.2.106-beta.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
@@ -37170,9 +37170,10 @@ geometry=${JSON.stringify(o2)}`;
37170
37170
  } catch (t4) {
37171
37171
  }
37172
37172
  try {
37173
- const t4 = null == l2 ? void 0 : l2.gl, e3 = null === (o2 = null === (r2 = null == t4 ? void 0 : t4.getExtension) || void 0 === r2 ? void 0 : r2.call(t4, "WEBGL_lose_context")) || void 0 === o2 ? void 0 : o2.loseContext;
37174
- e3 && true !== (null === (s2 = null == t4 ? void 0 : t4.isContextLost) || void 0 === s2 ? void 0 : s2.call(t4)) && e3();
37173
+ const t4 = null == l2 ? void 0 : l2.gl, e3 = null === (r2 = null == t4 ? void 0 : t4.getExtension) || void 0 === r2 ? void 0 : r2.call(t4, "WEBGL_lose_context");
37174
+ (null == e3 ? void 0 : e3.loseContext) && true !== (null === (o2 = null == t4 ? void 0 : t4.isContextLost) || void 0 === o2 ? void 0 : o2.call(t4)) && e3.loseContext(), console.info("[Slide][webgl] release requested", { hasContext: Boolean(t4), hasLoseContext: Boolean(null == e3 ? void 0 : e3.loseContext), contextLost: null === (s2 = null == t4 ? void 0 : t4.isContextLost) || void 0 === s2 ? void 0 : s2.call(t4) });
37175
37175
  } catch (t4) {
37176
+ console.warn("[Slide][webgl] release failed", t4);
37176
37177
  }
37177
37178
  try {
37178
37179
  t3.destroy(true, { children: true, texture: true, baseTexture: true });
@@ -38751,35 +38752,26 @@ geometry=${JSON.stringify(o2)}`;
38751
38752
  }(), mw = function() {
38752
38753
  function t2() {
38753
38754
  var t3 = this;
38754
- this.tasks = [], this.isDestroy = false, this.schedule = function() {
38755
- if (!t3.runningTask && !t3.isDestroy) {
38756
- var e2 = t3.tasks.shift();
38757
- e2 && (e2.status = "running", t3.runningTask = e2, e2.fn.apply(null).then(e2.resolve, e2.reject).finally(function() {
38758
- t3.runningTask === e2 && (t3.runningTask = void 0), !t3.isDestroy && t3.tasks.length > 0 && setTimeout(t3.schedule);
38759
- }));
38760
- }
38755
+ this.tasks = [], this.isDestroy = false, this.isScheduling = false, this.schedule = function() {
38756
+ t3.isScheduling = true;
38757
+ var e2 = t3.tasks.shift();
38758
+ e2 && !t3.isDestroy && (e2.status = "running", t3.runningTask = e2, e2.fn.apply(null).then(function() {
38759
+ t3.runningTask = void 0, t3.tasks.length > 0 ? setTimeout(t3.schedule) : t3.isScheduling = false;
38760
+ }).catch(function() {
38761
+ t3.runningTask = void 0, t3.tasks.length > 0 ? setTimeout(t3.schedule) : t3.isScheduling = false;
38762
+ }));
38761
38763
  };
38762
38764
  }
38763
- return t2.prototype.addTask = function(t3, e2) {
38764
- var i2;
38765
- if (this.isDestroy)
38766
- return Promise.resolve();
38767
- var n2, r2, o2 = null !== (i2 = this.tasks[this.tasks.length - 1]) && void 0 !== i2 ? i2 : this.runningTask;
38768
- if ((null == o2 ? void 0 : o2.type) === t3)
38769
- return o2.promise;
38770
- var s2 = new Promise(function(t4, e3) {
38771
- n2 = t4, r2 = e3;
38772
- });
38773
- s2.catch(function() {
38774
- });
38775
- var a2 = { type: t3, status: "wait", fn: e2, promise: s2, resolve: n2, reject: r2 };
38776
- return this.tasks.push(a2), this.schedule(), s2;
38765
+ return t2.prototype.getRunningTask = function() {
38766
+ var t3;
38767
+ return null !== (t3 = this.runningTask) && void 0 !== t3 ? t3 : null;
38768
+ }, t2.prototype.addTask = function(t3, e2) {
38769
+ var i2 = { type: t3, status: "wait", fn: e2 }, n2 = this.getRunningTask();
38770
+ n2 && t3 === n2.type || (this.tasks = this.tasks.filter(function(e3) {
38771
+ return e3.type !== t3;
38772
+ }), this.tasks.push(i2), this.isScheduling || this.schedule());
38777
38773
  }, t2.prototype.destroy = function() {
38778
- var t3, e2;
38779
- return this.isDestroy = true, this.tasks.splice(0, this.tasks.length).forEach(function(t4) {
38780
- return t4.resolve();
38781
- }), null !== (e2 = null === (t3 = this.runningTask) || void 0 === t3 ? void 0 : t3.promise.catch(function() {
38782
- })) && void 0 !== e2 ? e2 : Promise.resolve();
38774
+ this.isDestroy = true;
38783
38775
  }, t2;
38784
38776
  }(), gw = function() {
38785
38777
  return (gw = Object.assign || function(t2) {
@@ -39461,7 +39453,7 @@ geometry=${JSON.stringify(o2)}`;
39461
39453
  }
39462
39454
  var Nw = { syncDispatch: "syncDispatch", syncReceive: "syncReceive", syncEventLag: "syncEventLag", renderStart: "renderStart", renderEnd: "renderEnd", renderError: "renderError", slideChange: "slideChange", mainSeqStepStart: "mainSeqStepStart", mainSeqStepEnd: "mainSeqStepEnd", animateStart: "animateStart", animateEnd: "animateEnd", stateChange: "stateChange", slideStepEnd: "slideEnd", slideStepStart: "slideStart", useraddLink: "useraddLink" }, Dw = { taskId: "", url: "", currentSlideIndex: -1, mainSeqStep: -1, mainSeqState: null, mediaState: /* @__PURE__ */ Object.create(null), interactiveSeqState: /* @__PURE__ */ Object.create(null) }, Fw = "";
39463
39455
  try {
39464
- Fw = "1.4.61";
39456
+ Fw = "1.4.62-beta.0";
39465
39457
  } catch (t2) {
39466
39458
  Fw = "-dev-";
39467
39459
  }
@@ -39479,7 +39471,7 @@ geometry=${JSON.stringify(o2)}`;
39479
39471
  r3.iosResetCache = [], r3.iosResetPending = false, r3.version = Fw, r3.__slideState = hb()(Dw), r3.userInputTime = 0, r3.isSyncingSlideState = false, r3.frozenTaskManager = new mw(), r3.randomId = function() {
39480
39472
  const t3 = 4294967295 * Math.random() | 0, e3 = 4294967295 * Math.random() | 0, i4 = 4294967295 * Math.random() | 0, r4 = 4294967295 * Math.random() | 0;
39481
39473
  return (n[255 & t3] + n[t3 >> 8 & 255] + n[t3 >> 16 & 255] + n[t3 >> 24 & 255] + "-" + n[255 & e3] + n[e3 >> 8 & 255] + "-" + n[e3 >> 16 & 15 | 64] + n[e3 >> 24 & 255] + "-" + n[63 & i4 | 128] + n[i4 >> 8 & 255] + "-" + n[i4 >> 16 & 255] + n[i4 >> 24 & 255] + n[255 & r4] + n[r4 >> 8 & 255] + n[r4 >> 16 & 255] + n[r4 >> 24 & 255]).toUpperCase();
39482
- }(), r3.resize = false, r3.isAnimating = false, r3.renderingTaskManager = new tT(), r3.lifecycle = "alive", r3.lifecycleGeneration = 0, r3.renderVisibilityTimers = /* @__PURE__ */ new Set(), r3.isLoading = false, r3.isReleasing = false, r3.interactive = true, r3.canRetryWithoutPlayer = false, r3.syncCatchUpInputBlocked = false, r3.playerGeneration = 0, r3.playerGenerations = /* @__PURE__ */ new WeakMap(), r3.playerSwapRenderTimeoutMs = 6e4, r3.pptMediaPermissionCallbacks = /* @__PURE__ */ new Set(), r3.pptMediaPermissionNotified = false, r3.pptMediaPermissionRenotifyPending = false, r3.renderingIndex = 0, r3.frameWidth = 1, r3.frameHeight = 1, r3.frame = document.createElement("div"), r3.canvasContainer = document.createElement("div"), r3.medianController = document.createElement("div"), r3.frameResizeObserver = new Pw(function() {
39474
+ }(), r3.resize = false, r3.isAnimating = false, r3.renderingTaskManager = new tT(), r3.lifecycle = "alive", r3.lifecycleGeneration = 0, r3.playerDestroyCallbacks = [], r3.renderVisibilityTimers = /* @__PURE__ */ new Set(), r3.isLoading = false, r3.isReleasing = false, r3.interactive = true, r3.canRetryWithoutPlayer = false, r3.syncCatchUpInputBlocked = false, r3.playerGeneration = 0, r3.playerGenerations = /* @__PURE__ */ new WeakMap(), r3.playerSwapRenderTimeoutMs = 6e4, r3.pptMediaPermissionCallbacks = /* @__PURE__ */ new Set(), r3.pptMediaPermissionNotified = false, r3.pptMediaPermissionRenotifyPending = false, r3.renderingIndex = 0, r3.frameWidth = 1, r3.frameHeight = 1, r3.frame = document.createElement("div"), r3.canvasContainer = document.createElement("div"), r3.medianController = document.createElement("div"), r3.frameResizeObserver = new Pw(function() {
39483
39475
  return r3.frameResizeHandler();
39484
39476
  }), r3.timestamp = function() {
39485
39477
  return Date.now();
@@ -39853,65 +39845,65 @@ geometry=${JSON.stringify(o2)}`;
39853
39845
  n2.frame.style.visibility = "visible";
39854
39846
  }, 32));
39855
39847
  }
39856
- }, e2.prototype.setSlideState = function(t3) {
39857
- var e3, i3;
39848
+ }, e2.prototype.setSlideState = function(t3, e3) {
39849
+ var i3, n2;
39858
39850
  return Mw(this, void 0, void 0, function() {
39859
- var n2, r3, o2, s2, a2, l2, h2 = this;
39860
- return Cw(this, function(u2) {
39861
- switch (u2.label) {
39851
+ var r3, o2, s2, a2, l2, h2, u2, c2 = this;
39852
+ return Cw(this, function(d2) {
39853
+ switch (d2.label) {
39862
39854
  case 0:
39863
39855
  if ("alive" !== this.lifecycle)
39864
39856
  return [2];
39865
- n2 = this.lifecycleGeneration, r3 = function() {
39866
- return "alive" === h2.lifecycle && h2.lifecycleGeneration === n2;
39867
- }, this.isSyncingSlideState = true, u2.label = 1;
39857
+ r3 = this.lifecycleGeneration, o2 = this.player, s2 = function() {
39858
+ return "alive" === c2.lifecycle && c2.lifecycleGeneration === r3 && c2.player === o2;
39859
+ }, this.isSyncingSlideState = true, d2.label = 1;
39868
39860
  case 1:
39869
- if (u2.trys.push([1, , 15, 16]), this.logger.info("stateChange receive " + JSON.stringify(t3), this.taskId), t3.taskId && t3.taskId !== this.__slideState.taskId && (this.__slideState.taskId = t3.taskId, null === (e3 = this.player) || void 0 === e3 || e3.setResourceData(t3.taskId, this.__slideState.url)), t3.url && t3.url !== this.__slideState.url && (this.__slideState.url = t3.url, null === (i3 = this.player) || void 0 === i3 || i3.setResourceData(this.__slideState.taskId, t3.url)), !Number.isInteger(t3.currentSlideIndex) || t3.currentSlideIndex === this.__slideState.currentSlideIndex)
39861
+ if (d2.trys.push([1, , 15, 16]), this.logger.info("stateChange receive " + JSON.stringify(t3), this.taskId), t3.taskId && t3.taskId !== this.__slideState.taskId && (this.__slideState.taskId = t3.taskId, null === (i3 = this.player) || void 0 === i3 || i3.setResourceData(t3.taskId, this.__slideState.url)), t3.url && t3.url !== this.__slideState.url && (this.__slideState.url = t3.url, null === (n2 = this.player) || void 0 === n2 || n2.setResourceData(this.__slideState.taskId, t3.url)), !Number.isInteger(t3.currentSlideIndex) || t3.currentSlideIndex === this.__slideState.currentSlideIndex)
39870
39862
  return [3, 6];
39871
- u2.label = 2;
39863
+ d2.label = 2;
39872
39864
  case 2:
39873
- return u2.trys.push([2, 4, , 5]), [4, this.enqueueRenderSlide(t3.currentSlideIndex)];
39865
+ return d2.trys.push([2, 4, , 5]), [4, this.enqueueRenderSlide(t3.currentSlideIndex)];
39874
39866
  case 3:
39875
- return u2.sent(), [3, 5];
39867
+ return d2.sent(), [3, 5];
39876
39868
  case 4:
39877
- if ((o2 = u2.sent()) instanceof Qb)
39869
+ if ((a2 = d2.sent()) instanceof Qb)
39878
39870
  return [2];
39879
- throw o2;
39871
+ throw a2;
39880
39872
  case 5:
39881
- if (!r3())
39873
+ if (!s2())
39882
39874
  return [2];
39883
- this.__slideState.currentSlideIndex = t3.currentSlideIndex, u2.label = 6;
39875
+ this.__slideState.currentSlideIndex = t3.currentSlideIndex, d2.label = 6;
39884
39876
  case 6:
39885
- return Number.isInteger(t3.currentSlideIndex) ? [4, null == (s2 = this.player) ? void 0 : s2.waitUntilActive(function() {
39886
- return s2.currentIndex === t3.currentSlideIndex && s2.currentStage;
39877
+ return Number.isInteger(t3.currentSlideIndex) ? [4, null == (l2 = this.player) ? void 0 : l2.waitUntilActive(function() {
39878
+ return l2.currentIndex === t3.currentSlideIndex && l2.currentStage;
39887
39879
  }, 3e3)] : [3, 8];
39888
39880
  case 7:
39889
- if (u2.sent(), !r3())
39881
+ if (d2.sent(), !s2())
39890
39882
  return [2];
39891
- u2.label = 8;
39883
+ d2.label = 8;
39892
39884
  case 8:
39893
- if (a2 = false, Number.isInteger(t3.mainSeqStep) && t3.mainSeqStep !== this.__slideState.mainSeqStep && (a2 = true, this.__slideState.mainSeqStep = t3.mainSeqStep), t3.mainSeqState && t3.mainSeqState !== this.__slideState.mainSeqState && (a2 = true, this.__slideState.mainSeqState = t3.mainSeqState), a2 && this.setMainSeqStep(this.__slideState.mainSeqStep, "idle" === this.__slideState.mainSeqState ? "start" : "end"), t3.interactiveSeqState) {
39894
- if (!r3())
39885
+ if (h2 = false, Number.isInteger(t3.mainSeqStep) && t3.mainSeqStep !== this.__slideState.mainSeqStep && (h2 = true, this.__slideState.mainSeqStep = t3.mainSeqStep), t3.mainSeqState && t3.mainSeqState !== this.__slideState.mainSeqState && (h2 = true, this.__slideState.mainSeqState = t3.mainSeqState), h2 && this.setMainSeqStep(this.__slideState.mainSeqStep, "idle" === this.__slideState.mainSeqState ? "start" : "end"), t3.interactiveSeqState) {
39886
+ if (!s2())
39895
39887
  return [2];
39896
39888
  this.initInteractiveSeq(t3), this.__slideState.interactiveSeqState = t3.interactiveSeqState;
39897
39889
  }
39898
- return [4, Ow(1500)];
39890
+ return null == e3 || e3(), [4, Ow(1500)];
39899
39891
  case 9:
39900
- if (u2.sent(), !r3())
39892
+ if (d2.sent(), !s2())
39901
39893
  return [2];
39902
39894
  if (!t3.mediaState)
39903
39895
  return [3, 14];
39904
- l2 = t3.mediaState, this.pendingPptMediaState = l2, u2.label = 10;
39896
+ u2 = t3.mediaState, this.pendingPptMediaState = u2, d2.label = 10;
39905
39897
  case 10:
39906
- return u2.trys.push([10, , 12, 13]), [4, this.initMedia(t3, r3)];
39898
+ return d2.trys.push([10, , 12, 13]), [4, this.initMedia(t3, s2)];
39907
39899
  case 11:
39908
- return u2.sent(), [3, 13];
39900
+ return d2.sent(), [3, 13];
39909
39901
  case 12:
39910
- return this.pendingPptMediaState === l2 && (this.pendingPptMediaState = void 0), [7];
39902
+ return this.pendingPptMediaState === u2 && (this.pendingPptMediaState = void 0), [7];
39911
39903
  case 13:
39912
- if (!r3())
39904
+ if (!s2())
39913
39905
  return [2];
39914
- this.__slideState.mediaState = l2, u2.label = 14;
39906
+ this.__slideState.mediaState = u2, d2.label = 14;
39915
39907
  case 14:
39916
39908
  return [3, 16];
39917
39909
  case 15:
@@ -40220,58 +40212,70 @@ geometry=${JSON.stringify(o2)}`;
40220
40212
  case 0:
40221
40213
  return this.logger.info("do frozen with player[" + !!this.player + "]", this.taskId), this.tracker({ name: "frozenSlide", reason: "", result: "", payload: { taskId: this.taskId } }), this.view && this.player ? [4, (i3 = this.player).waitUntilActive(function() {
40222
40214
  return !s2.isLoading;
40223
- }, 6e4)] : [3, 3];
40215
+ }, 6e4)] : [3, 2];
40224
40216
  case 1:
40225
40217
  if (a2.sent(), "alive" !== this.lifecycle || this.player !== i3)
40226
40218
  return [2];
40227
40219
  for (r3 in n2 = i3.getSnapshot() || "", this.cacheImage.src = n2, this.cacheImage.style.display = "block", "hidden" === this.frame.style.visibility && (this.frame.style.visibility = "visible"), i3.destroy(), null === (e3 = this.playerController) || void 0 === e3 || e3.destroy(), this.player = void 0, this.pptMediaPermissionNotified = false, this.__slideState.mediaState)
40228
40220
  o2 = this.__slideState.mediaState[r3], this.__slideState.mediaState[r3] = Ew(Ew({}, o2), { frozenTime: this.timestamp() });
40229
- return [4, ww(eb.platform)];
40221
+ a2.label = 2;
40230
40222
  case 2:
40231
- a2.sent(), a2.label = 3;
40232
- case 3:
40233
40223
  return t3 && t3(), [2];
40234
40224
  }
40235
40225
  });
40236
40226
  });
40237
- }, e2.prototype.frozen = function(t3) {
40238
- var e3 = this;
40239
- return this.frozenTaskManager.addTask("frozen", function() {
40240
- return e3._doFrozen(t3);
40227
+ }, e2.prototype.frozen = function(t3, e3) {
40228
+ var i3 = this;
40229
+ this.frozenTaskManager.addTask("frozen", function() {
40230
+ return i3._doFrozen(t3).catch(function(t4) {
40231
+ throw null == e3 || e3(t4), t4;
40232
+ });
40241
40233
  });
40242
- }, e2.prototype._doRelease = function(t3) {
40243
- var e3, i3;
40234
+ }, e2.prototype._doRelease = function(t3, e3) {
40235
+ var i3, n2;
40244
40236
  return Mw(this, void 0, void 0, function() {
40245
- var n2, r3, o2, s2, a2;
40246
- return Cw(this, function(l2) {
40247
- switch (l2.label) {
40237
+ var r3, o2, s2, a2, l2, h2, u2, c2 = this;
40238
+ return Cw(this, function(d2) {
40239
+ switch (d2.label) {
40248
40240
  case 0:
40249
40241
  if (this.logger.info("do release slide", this.taskId), this.tracker({ name: "releaseSlide", reason: "", result: "", payload: { taskId: this.taskId } }), this.player)
40250
- return [2];
40251
- this.isReleasing = true, l2.label = 1;
40242
+ return null == e3 || e3(), [2];
40243
+ this.isReleasing = true, d2.label = 1;
40252
40244
  case 1:
40253
- return l2.trys.push([1, , 5, 6]), [4, ww(eb.platform)];
40245
+ return d2.trys.push([1, 3, , 4]), [4, ww(eb.platform)];
40254
40246
  case 2:
40255
- if (l2.sent(), "alive" !== this.lifecycle || this.player)
40256
- return [2];
40257
- for (o2 in n2 = this.player = this.initPlayer(this.config), (null === (e3 = this.config) || void 0 === e3 ? void 0 : e3.controller) && this.createController(), this.player.view && (this.canvasContainer.appendChild(this.player.view), this.player.view.style.visibility = "hidden"), r3 = this.__slideState, this.__slideState = hb()(Dw), r3.mediaState)
40258
- "play" === (s2 = r3.mediaState[o2]).type && (a2 = Math.max(null !== (i3 = s2.frozenTime) && void 0 !== i3 ? i3 : 0, s2.time), s2.time = this.timestamp() - (a2 - s2.time), s2.frozenTime = void 0);
40259
- return [4, this.setSlideState(r3)];
40247
+ if (d2.sent(), "alive" !== this.lifecycle || this.player)
40248
+ throw new Error("Slide release cancelled before player creation");
40249
+ for (s2 in r3 = this.player = this.initPlayer(this.config), (null === (i3 = this.config) || void 0 === i3 ? void 0 : i3.controller) && this.createController(), this.player.view && (this.canvasContainer.appendChild(this.player.view), this.player.view.style.visibility = "hidden"), o2 = this.__slideState, this.__slideState = hb()(Dw), o2.mediaState)
40250
+ "play" === (a2 = o2.mediaState[s2]).type && (l2 = Math.max(null !== (n2 = a2.frozenTime) && void 0 !== n2 ? n2 : 0, a2.time), a2.time = this.timestamp() - (l2 - a2.time), a2.frozenTime = void 0);
40251
+ return null == e3 || e3(), h2 = Promise.resolve(), this.setSlideState(o2, function() {
40252
+ h2 = new Promise(function(t4) {
40253
+ return setTimeout(function() {
40254
+ "alive" === c2.lifecycle && c2.player === r3 && (r3.view && (r3.view.style.visibility = "visible"), "hidden" === c2.frame.style.visibility && (c2.frame.style.visibility = "visible"), c2.cacheImage.style.display = "none"), t4();
40255
+ }, 333);
40256
+ });
40257
+ }).then(function() {
40258
+ return h2;
40259
+ }).then(function() {
40260
+ "alive" === c2.lifecycle && c2.player === r3 && (null == t3 || t3());
40261
+ }).catch(function(t4) {
40262
+ c2.logger.error("release state restore failed: " + String(t4), c2.taskId);
40263
+ }).finally(function() {
40264
+ c2.isReleasing = false, c2.notifyPptMediaPermissionRequest();
40265
+ }), [3, 4];
40260
40266
  case 3:
40261
- return l2.sent(), "alive" !== this.lifecycle || this.player !== n2 ? [2] : [4, Ow(333)];
40267
+ throw u2 = d2.sent(), this.isReleasing = false, this.notifyPptMediaPermissionRequest(), u2;
40262
40268
  case 4:
40263
- return l2.sent(), "alive" !== this.lifecycle || this.player !== n2 ? [2] : (n2.view && (n2.view.style.visibility = "visible"), "hidden" === this.frame.style.visibility && (this.frame.style.visibility = "visible"), this.cacheImage.style.display = "none", t3 && t3(), [3, 6]);
40264
- case 5:
40265
- return this.isReleasing = false, this.notifyPptMediaPermissionRequest(), [7];
40266
- case 6:
40267
40269
  return [2];
40268
40270
  }
40269
40271
  });
40270
40272
  });
40271
- }, e2.prototype.release = function(t3) {
40272
- var e3 = this;
40273
- return this.frozenTaskManager.addTask("release", function() {
40274
- return e3._doRelease(t3);
40273
+ }, e2.prototype.release = function(t3, e3, i3) {
40274
+ var n2 = this;
40275
+ this.frozenTaskManager.addTask("release", function() {
40276
+ return n2._doRelease(t3, e3).catch(function(t4) {
40277
+ throw null == i3 || i3(t4), t4;
40278
+ });
40275
40279
  });
40276
40280
  }, e2.prototype._doDestroy = function() {
40277
40281
  var t3, i3, n2, r3, o2 = this;
@@ -40321,29 +40325,31 @@ geometry=${JSON.stringify(o2)}`;
40321
40325
  return this.player ? this.player.preload(t3) : Promise.resolve();
40322
40326
  }, e2.prototype.preloadResource = function(t3) {
40323
40327
  return this.player ? this.player.preloadResource(t3) : Promise.resolve();
40324
- }, e2.prototype.destroy = function() {
40325
- var t3, e3 = this;
40326
- return this.destroyPromise ? this.destroyPromise : "disposed" === this.lifecycle ? Promise.resolve() : (this.lifecycle = "disposing", this.lifecycleGeneration += 1, this.renderVisibilityTimers.forEach(function(t4) {
40327
- return clearTimeout(t4);
40328
- }), this.renderVisibilityTimers.clear(), this.renderingTaskManager.destroy(), null === (t3 = this.player) || void 0 === t3 || t3.destroy(), this.logger.info("pre destroy slide", ""), this.destroyPromise = Mw(e3, void 0, void 0, function() {
40329
- var t4;
40330
- return Cw(this, function(e4) {
40331
- switch (e4.label) {
40332
- case 0:
40333
- return [4, this.frozenTaskManager.destroy()];
40334
- case 1:
40335
- return e4.sent(), this.isLoading ? [4, this.waitLoadEnd()] : [3, 3];
40336
- case 2:
40337
- e4.sent(), e4.label = 3;
40338
- case 3:
40339
- return t4 = Boolean(this.player || this.iosNewPlayer), this._doDestroy(), t4 ? [4, ww(eb.platform)] : [3, 5];
40340
- case 4:
40341
- e4.sent(), e4.label = 5;
40342
- case 5:
40343
- return [2];
40328
+ }, e2.prototype.destroy = function(t3, e3) {
40329
+ var i3, n2, r3, o2, s2, a2 = this, l2 = { onDestroyed: t3, onError: e3 }, h2 = this.playerDestroyOutcome;
40330
+ if (h2 ? h2.ok ? null == t3 || t3() : null == e3 || e3(h2.error) : (t3 || e3) && (null !== (i3 = this.playerDestroyCallbacks) && void 0 !== i3 ? i3 : this.playerDestroyCallbacks = []).push(l2), "alive" === this.lifecycle) {
40331
+ this.lifecycle = "disposing", this.lifecycleGeneration += 1, this.renderVisibilityTimers.forEach(function(t4) {
40332
+ return clearTimeout(t4);
40333
+ }), this.renderVisibilityTimers.clear(), this.renderingTaskManager.destroy();
40334
+ try {
40335
+ null === (n2 = this.player) || void 0 === n2 || n2.destroy(), this.playerDestroyOutcome = { ok: true };
40336
+ } catch (t4) {
40337
+ this.playerDestroyOutcome = { ok: false, error: t4 };
40338
+ }
40339
+ for (var u2 = 0, c2 = (null !== (r3 = this.playerDestroyCallbacks) && void 0 !== r3 ? r3 : []).splice(0); u2 < c2.length; u2++) {
40340
+ var d2 = c2[u2];
40341
+ try {
40342
+ this.playerDestroyOutcome.ok ? null === (o2 = d2.onDestroyed) || void 0 === o2 || o2.call(d2) : null === (s2 = d2.onError) || void 0 === s2 || s2.call(d2, this.playerDestroyOutcome.error);
40343
+ } catch (t4) {
40344
+ this.logger.error("player destroy callback failed: " + String(t4), this.taskId);
40344
40345
  }
40345
- });
40346
- }), this.destroyPromise);
40346
+ }
40347
+ if (!this.playerDestroyOutcome.ok)
40348
+ throw this.playerDestroyOutcome.error;
40349
+ this.logger.info("pre destroy slide", ""), this.isLoading ? this.waitLoadEnd().then(function() {
40350
+ a2._doDestroy();
40351
+ }) : this._doDestroy();
40352
+ }
40347
40353
  }, e2.prototype.clearSlideCache = function() {
40348
40354
  var t3;
40349
40355
  null === (t3 = this.player) || void 0 === t3 || t3.clearLocalCache();
@@ -41109,6 +41115,32 @@ function cachedGetBgColor(el) {
41109
41115
  const getRoomTracker = (displayer) => {
41110
41116
  return displayer.tracker;
41111
41117
  };
41118
+ function shouldSlideRuntimeBeActive(isFocused, isVisible, isMinimized) {
41119
+ return isFocused && isVisible && !isMinimized;
41120
+ }
41121
+ function createFocusTransitionQueue(initialState, apply, onError) {
41122
+ let acceptedState = initialState;
41123
+ let revision = 0;
41124
+ let queue = Promise.resolve();
41125
+ let acceptedPromise = Promise.resolve();
41126
+ return (isFocused, force = false) => {
41127
+ if (!force && isFocused === acceptedState)
41128
+ return acceptedPromise;
41129
+ acceptedState = isFocused;
41130
+ const transitionRevision = ++revision;
41131
+ const transition = queue.then(() => apply(isFocused)).catch((error) => {
41132
+ if (revision === transitionRevision) {
41133
+ acceptedState = void 0;
41134
+ acceptedPromise = Promise.resolve();
41135
+ }
41136
+ onError == null ? void 0 : onError(error);
41137
+ throw error;
41138
+ });
41139
+ queue = transition.catch(() => void 0);
41140
+ acceptedPromise = transition;
41141
+ return transition;
41142
+ };
41143
+ }
41112
41144
  function createDocsViewerPages(slide, previewUrls = []) {
41113
41145
  const { width, height, slideCount, slideState } = slide;
41114
41146
  const { taskId, url } = slideState;
@@ -41163,9 +41195,42 @@ const EmptyAttributes = {
41163
41195
  };
41164
41196
  const noop$1 = function noop2() {
41165
41197
  };
41198
+ const slideWebGLTasks = [];
41199
+ let slideWebGLRunning = false;
41200
+ function runNextSlideWebGLTask() {
41201
+ if (slideWebGLRunning)
41202
+ return;
41203
+ const task = slideWebGLTasks.shift();
41204
+ if (!task)
41205
+ return;
41206
+ slideWebGLRunning = true;
41207
+ const startedAt = performance.now();
41208
+ log("[Slide][player-queue] start", task.label, "pending", slideWebGLTasks.length);
41209
+ void Promise.resolve().then(task.run).then(() => {
41210
+ log("[Slide][player-queue] done", task.label, "ms", Math.round(performance.now() - startedAt));
41211
+ task.resolve();
41212
+ }, (error) => {
41213
+ log("[Slide][player-queue] failed", task.label, error);
41214
+ task.reject(error);
41215
+ }).finally(() => {
41216
+ slideWebGLRunning = false;
41217
+ runNextSlideWebGLTask();
41218
+ });
41219
+ }
41220
+ function enqueueSlideWebGLTransition(run, priority = false, label = "unspecified") {
41221
+ return new Promise((resolve, reject) => {
41222
+ const task = { label, run, resolve, reject };
41223
+ if (priority)
41224
+ slideWebGLTasks.unshift(task);
41225
+ else
41226
+ slideWebGLTasks.push(task);
41227
+ runNextSlideWebGLTask();
41228
+ });
41229
+ }
41166
41230
  class SlideControllerBase {
41167
41231
  constructor(props) {
41168
41232
  this.sideEffect = new SideEffectManager();
41233
+ this.focused = true;
41169
41234
  this.previewList = [];
41170
41235
  this.ready = false;
41171
41236
  this.readyPromise = new Promise((resolve) => {
@@ -41174,7 +41239,11 @@ class SlideControllerBase {
41174
41239
  log("[Slide] render end", slideIndex);
41175
41240
  } else {
41176
41241
  setTimeout(() => {
41242
+ if (this.destroyed)
41243
+ return;
41177
41244
  this.ready = true;
41245
+ if (this.isLazySetupMode())
41246
+ void this.reconcileActivity(true).catch(() => void 0);
41178
41247
  resolve();
41179
41248
  }, 1e3);
41180
41249
  }
@@ -41207,6 +41276,10 @@ class SlideControllerBase {
41207
41276
  this.pollCount = 0;
41208
41277
  this.pollReadyState = () => {
41209
41278
  if (this.ready) {
41279
+ if (this.isLazySetupMode()) {
41280
+ void this.reconcileActivity().catch(() => void 0);
41281
+ return;
41282
+ }
41210
41283
  if (this._toFreeze === 1) {
41211
41284
  this.freeze();
41212
41285
  } else if (this._toFreeze === -1) {
@@ -41222,6 +41295,9 @@ class SlideControllerBase {
41222
41295
  };
41223
41296
  this._pageCount = 0;
41224
41297
  this.destroyed = false;
41298
+ this.destroyedSignal = new Promise((resolve) => {
41299
+ this.resolveDestroyedSignal = resolve;
41300
+ });
41225
41301
  this.timestamp = () => {
41226
41302
  if (this.room && this.room.calibrationTimestamp) {
41227
41303
  return this.room.calibrationTimestamp;
@@ -41232,48 +41308,133 @@ class SlideControllerBase {
41232
41308
  }
41233
41309
  };
41234
41310
  this.isFrozen = false;
41311
+ this.resourceStateUnknown = false;
41312
+ this.managedActivity = false;
41235
41313
  this._toFreeze = 0;
41236
- this.freeze = () => {
41314
+ this.setFocusedState = (focused) => {
41315
+ this.focused = focused;
41316
+ return this.reconcileActivity();
41317
+ };
41318
+ this.resourceTransition = createFocusTransitionQueue(
41319
+ void 0,
41320
+ async (active) => {
41321
+ if (this.destroyed)
41322
+ return;
41323
+ if (active && this.shouldBeActive())
41324
+ await this.unfreeze();
41325
+ else
41326
+ await this.freeze();
41327
+ },
41328
+ (error) => logger.warn("[Slide] resource transition failed", this.context.appId, error)
41329
+ );
41330
+ this.shouldBeActive = () => {
41331
+ var _a, _b, _c;
41332
+ const wm = this.context.getWindowManager();
41333
+ const host = (_b = (_a = this.context).getRuntimeActivity) == null ? void 0 : _b.call(_a);
41334
+ const lazy = this.isLazySetupMode();
41335
+ const minimized = lazy && host ? !host.active : (wm == null ? void 0 : wm.boxState) === "minimized" || ((_c = wm == null ? void 0 : wm.attributes) == null ? void 0 : _c.minimized) === true || this.context.getBoxStatus() === "minimized";
41336
+ return shouldSlideRuntimeBeActive(
41337
+ !lazy || this.focused,
41338
+ document.visibilityState !== "hidden",
41339
+ minimized
41340
+ ) && (!lazy || (host == null ? void 0 : host.active) !== false);
41341
+ };
41342
+ this.reconcileActivity = (force = false) => {
41343
+ if (this.destroyed)
41344
+ return Promise.resolve();
41345
+ if (this.isLazySetupMode())
41346
+ this.managedActivity = true;
41347
+ if (!this.managedActivity)
41348
+ return Promise.resolve();
41349
+ this.visible = document.visibilityState !== "hidden";
41350
+ return this.resourceTransition(this.shouldBeActive(), force);
41351
+ };
41352
+ this.freeze = async () => {
41353
+ const previousIsFrozen = this.isFrozen;
41354
+ const previousToFreeze = this._toFreeze;
41237
41355
  this.isFrozen = true;
41238
- if (this.ready) {
41239
- log("[Slide] freeze", this.context.appId);
41240
- if (this.invisibleBehavior === "frozen") {
41241
- return Promise.resolve(this.slide.frozen());
41356
+ try {
41357
+ if (this.ready) {
41358
+ log("[Slide] freeze", this.context.appId);
41359
+ if (this.invisibleBehavior === "frozen") {
41360
+ await enqueueSlideWebGLTransition(() => {
41361
+ if (this.destroyed)
41362
+ return Promise.resolve();
41363
+ const destroyed = new Promise((resolve, reject) => {
41364
+ const result = this.slide.frozen.call(this.slide, () => {
41365
+ log("[Slide][player] frozen callback", this.context.appId);
41366
+ resolve();
41367
+ }, reject);
41368
+ if (result)
41369
+ void result.then(resolve, reject);
41370
+ });
41371
+ return Promise.race([destroyed, this.destroyedSignal]);
41372
+ }, false, `freeze:${this.context.appId}`);
41373
+ } else {
41374
+ this.slide.pause();
41375
+ }
41242
41376
  } else {
41243
- this.slide.pause();
41377
+ this._toFreeze = 1;
41244
41378
  }
41245
- } else {
41246
- this._toFreeze = 1;
41379
+ this.resourceStateUnknown = false;
41380
+ } catch (error) {
41381
+ this.resourceStateUnknown = true;
41382
+ this.isFrozen = previousIsFrozen;
41383
+ this._toFreeze = previousToFreeze;
41384
+ throw error;
41247
41385
  }
41248
- return Promise.resolve();
41249
41386
  };
41250
41387
  this.unfreeze = async () => {
41251
41388
  if (!this.visible)
41252
41389
  return;
41253
- if (!this.isFrozen && this.ready)
41390
+ if (!this.isFrozen && this.ready && !this.resourceStateUnknown)
41254
41391
  return;
41392
+ const previousIsFrozen = this.isFrozen;
41393
+ const previousToFreeze = this._toFreeze;
41255
41394
  this.isFrozen = false;
41256
- if (this.ready) {
41257
- let isNeedSyncState = false;
41258
- log("[Slide] unfreeze", this.context.appId);
41259
- if (this.invisibleBehavior === "frozen") {
41260
- await this.slide.release(() => {
41395
+ try {
41396
+ if (this.ready) {
41397
+ log("[Slide] unfreeze", this.context.appId);
41398
+ if (this.invisibleBehavior === "frozen") {
41399
+ await enqueueSlideWebGLTransition(() => {
41400
+ if (this.destroyed)
41401
+ return Promise.resolve();
41402
+ const created = new Promise((resolve, reject) => {
41403
+ const result = this.slide.release.call(this.slide, () => {
41404
+ log("[Slide][player] restored callback", this.context.appId);
41405
+ if (this.isLazySetupMode() && !this.shouldBeActive())
41406
+ return;
41407
+ this.slide.notifyFrameResize();
41408
+ const state = this.context.storage.state.state;
41409
+ if (state) {
41410
+ log("[Slide] sync storage", JSON.stringify(state));
41411
+ void this.slide.setSlideState(state).catch((error) => {
41412
+ this.resourceStateUnknown = true;
41413
+ logger.warn("[Slide] storage sync after release failed", this.context.appId, error);
41414
+ });
41415
+ }
41416
+ }, () => {
41417
+ log("[Slide][player] created callback", this.context.appId);
41418
+ resolve();
41419
+ }, reject);
41420
+ if (result)
41421
+ void result.then(resolve, reject);
41422
+ });
41423
+ return Promise.race([created, this.destroyedSignal]);
41424
+ }, false, `release:${this.context.appId}`);
41425
+ } else {
41426
+ this.slide.resume();
41261
41427
  this.slide.notifyFrameResize();
41262
- });
41263
- isNeedSyncState = true;
41264
- } else {
41265
- this.slide.resume();
41266
- this.slide.notifyFrameResize();
41267
- }
41268
- if (isNeedSyncState) {
41269
- const state = this.context.storage.state.state;
41270
- if (state) {
41271
- log("[Slide] sync storage", JSON.stringify(state));
41272
- this.slide.setSlideState(state);
41273
41428
  }
41429
+ } else {
41430
+ this._toFreeze = -1;
41274
41431
  }
41275
- } else {
41276
- this._toFreeze = -1;
41432
+ this.resourceStateUnknown = false;
41433
+ } catch (error) {
41434
+ this.resourceStateUnknown = true;
41435
+ this.isFrozen = previousIsFrozen;
41436
+ this._toFreeze = previousToFreeze;
41437
+ throw error;
41277
41438
  }
41278
41439
  };
41279
41440
  this.bindAppStateChangeEvent = () => {
@@ -41297,6 +41458,10 @@ class SlideControllerBase {
41297
41458
  }
41298
41459
  };
41299
41460
  this.onAppStateChangeHandler = (state) => {
41461
+ if (this.isLazySetupMode() || this.managedActivity) {
41462
+ void this.reconcileActivity().catch(() => void 0);
41463
+ return;
41464
+ }
41300
41465
  if (state === "minimized") {
41301
41466
  log("[Slide] freeze because app state is minimized");
41302
41467
  this.freeze();
@@ -41304,6 +41469,10 @@ class SlideControllerBase {
41304
41469
  };
41305
41470
  this.onAppStatusChangeHandler = (payload) => {
41306
41471
  const { appId, status } = payload;
41472
+ if (appId === this.context.appId && (this.isLazySetupMode() || this.managedActivity)) {
41473
+ void this.reconcileActivity().catch(() => void 0);
41474
+ return;
41475
+ }
41307
41476
  if (appId === this.context.appId && status === "minimized") {
41308
41477
  log("[Slide] freeze because app status is minimized");
41309
41478
  this.freeze();
@@ -41322,21 +41491,35 @@ class SlideControllerBase {
41322
41491
  return void 0;
41323
41492
  }
41324
41493
  };
41494
+ this.isLazySetupMode = () => {
41495
+ var _a;
41496
+ try {
41497
+ return ((_a = this.context.getWindowManager()) == null ? void 0 : _a.lazySetupInMaximizedMode) === true;
41498
+ } catch {
41499
+ return false;
41500
+ }
41501
+ };
41325
41502
  this.onVisibilityChange = async () => {
41503
+ this.visible = document.visibilityState === "visible";
41504
+ if (this.isLazySetupMode() || this.managedActivity) {
41505
+ await this.reconcileActivity().catch(() => void 0);
41506
+ return;
41507
+ }
41326
41508
  const appStatus = this.getAppStatus();
41509
+ if (!this.visible) {
41510
+ this.savedIsFrozen = this.isFrozen;
41511
+ log("[Slide] freeze because tab becomes invisible");
41512
+ if (!this.isFrozen)
41513
+ await this.freeze();
41514
+ return;
41515
+ }
41327
41516
  if (appStatus === "minimized") {
41328
41517
  log("[Slide] do nothing because app state is minimized");
41329
41518
  return;
41330
41519
  }
41331
- if (!(this.visible = document.visibilityState === "visible")) {
41332
- this.savedIsFrozen = this.isFrozen;
41333
- log("[Slide] freeze because tab becomes invisible");
41334
- this.freeze();
41335
- } else {
41336
- if (!this.savedIsFrozen) {
41337
- log("[Slide] unfreeze because tab becomes visible", { savedIsFrozen: this.savedIsFrozen });
41338
- this.unfreeze();
41339
- }
41520
+ if (!this.savedIsFrozen) {
41521
+ log("[Slide] unfreeze because tab becomes visible", { savedIsFrozen: this.savedIsFrozen });
41522
+ await this.unfreeze();
41340
41523
  }
41341
41524
  };
41342
41525
  const {
@@ -41509,7 +41692,17 @@ class SlideControllerBase {
41509
41692
  if (!this.destroyed) {
41510
41693
  log("[Slide] destroy slide (once)");
41511
41694
  this.destroyed = true;
41512
- this.destroyPromise = Promise.resolve(this.slide.destroy());
41695
+ this.destroyPromise = enqueueSlideWebGLTransition(() => new Promise((resolve, reject) => {
41696
+ try {
41697
+ this.slide.destroy.call(this.slide, () => {
41698
+ log("[Slide][player] destroy callback", this.context.appId);
41699
+ resolve();
41700
+ }, reject);
41701
+ } catch (error) {
41702
+ reject(error);
41703
+ }
41704
+ }), true, `destroy:${this.context.appId}`);
41705
+ this.resolveDestroyedSignal();
41513
41706
  }
41514
41707
  return (_a = this.destroyPromise) != null ? _a : Promise.resolve();
41515
41708
  }
@@ -43569,6 +43762,7 @@ class SlideDocsViewer {
43569
43762
  logger.warn("[Slide] render error", error);
43570
43763
  };
43571
43764
  this.onRenderStart = () => {
43765
+ logger.log("[Slide][notes] hide", this.appId, "scene", this.whiteboardView.focusScenePath);
43572
43766
  this.$whiteboardView.classList.add(this.wrapClassName("wb-view-hidden"));
43573
43767
  this.viewer.setPlaying();
43574
43768
  };
@@ -43576,10 +43770,12 @@ class SlideDocsViewer {
43576
43770
  };
43577
43771
  this.onPageChanged = () => {
43578
43772
  clearTimeout(this._onPageChangedTimer);
43773
+ logger.log("[Slide][notes] show scheduled", this.appId, "scene", this.whiteboardView.focusScenePath);
43579
43774
  this._onPageChangedTimer = setTimeout(this._onPageChanged, 200);
43580
43775
  };
43581
43776
  this._onPageChangedTimer = 0;
43582
43777
  this._onPageChanged = () => {
43778
+ logger.log("[Slide][notes] show", this.appId, "scene", this.whiteboardView.focusScenePath);
43583
43779
  this.$overlay.style.opacity = "";
43584
43780
  this.$whiteboardView.classList.remove(this.wrapClassName("wb-view-hidden"));
43585
43781
  };
@@ -44265,7 +44461,7 @@ class SlidePreviewer {
44265
44461
  }
44266
44462
  }
44267
44463
  const usePlugin = /* @__PURE__ */ Slide.Slide.usePlugin.bind(Slide.Slide);
44268
- const version = "0.2.106-beta.2";
44464
+ const version = "0.2.106-beta.4";
44269
44465
  const DEFAULT_SLIDE_SETUP_READY_TIMEOUT = 5e3;
44270
44466
  const SlideApp = {
44271
44467
  kind: "Slide",
@@ -44346,6 +44542,9 @@ const SlideApp = {
44346
44542
  const page = slideController.slide.slideState.currentSlideIndex;
44347
44543
  log("[Slide] page to", page, synced ? "(synced)" : "", "(on ready)");
44348
44544
  slideController.slide.on("renderEnd", options.onRenderEnd);
44545
+ }).catch((error) => {
44546
+ if (!disposed)
44547
+ logger.warn("[Slide] ready callback failed", context.appId, error);
44349
44548
  });
44350
44549
  return slideController;
44351
44550
  };
@@ -44392,36 +44591,19 @@ const SlideApp = {
44392
44591
  return () => room.callbacks.off("onRoomStateChanged", onRoomStateChanged);
44393
44592
  });
44394
44593
  }
44395
- const isBlurFreezeAllowed = () => {
44396
- var _a2;
44397
- const boxStatus = context.getBoxStatus();
44398
- if (boxStatus)
44399
- return boxStatus !== "normal";
44400
- const boxState = (_a2 = context.getWindowManager()) == null ? void 0 : _a2.boxState;
44401
- return boxState != null && boxState !== "normal";
44402
- };
44403
44594
  sideEffect.add(
44404
- () => context.emitter.on("focus", async (isFocused) => {
44595
+ () => context.emitter.on("focus", (isFocused) => {
44405
44596
  if (disposed)
44406
44597
  return;
44407
- if (!isLazySetupMode())
44408
- return;
44409
44598
  const controller = docsViewer == null ? void 0 : docsViewer.slideController;
44410
- if (!controller)
44411
- return;
44412
- if (!isFocused) {
44413
- if (!isBlurFreezeAllowed())
44414
- return;
44415
- if (!controller.isFrozen) {
44416
- log("[Slide] blur freeze", context.appId);
44417
- await controller.freeze();
44418
- }
44419
- return;
44420
- }
44421
- if (controller.isFrozen) {
44422
- log("[Slide] focus unfreeze", context.appId);
44423
- await controller.unfreeze();
44424
- }
44599
+ return controller == null ? void 0 : controller.setFocusedState(isFocused);
44600
+ })
44601
+ );
44602
+ sideEffect.add(
44603
+ () => context.emitter.on("runtimeActivity", () => {
44604
+ var _a2;
44605
+ if (!disposed)
44606
+ return (_a2 = docsViewer == null ? void 0 : docsViewer.slideController) == null ? void 0 : _a2.reconcileActivity();
44425
44607
  })
44426
44608
  );
44427
44609
  let disposed = false;
@@ -44448,11 +44630,13 @@ const SlideApp = {
44448
44630
  return teardownPromise;
44449
44631
  };
44450
44632
  offDestroy = context.emitter.on("destroy", teardown);
44451
- docsViewer.mount();
44452
- SlideApp.__teardownByContext || (SlideApp.__teardownByContext = /* @__PURE__ */ new WeakMap());
44453
- SlideApp.__teardownByContext.set(context, teardown);
44633
+ const mounting = enqueueSlideWebGLTransition(() => {
44634
+ if (!disposed)
44635
+ docsViewer == null ? void 0 : docsViewer.mount();
44636
+ }, false, `setup:${context.appId}`);
44454
44637
  const waitForFirstRender = (timeoutMs) => new Promise((resolve) => {
44455
44638
  let settled = false;
44639
+ let timedOut = false;
44456
44640
  const settle = (loaded) => {
44457
44641
  if (settled)
44458
44642
  return;
@@ -44461,14 +44645,24 @@ const SlideApp = {
44461
44645
  window.clearInterval(pollTimer);
44462
44646
  resolve(loaded);
44463
44647
  };
44464
- const timeoutTimer = window.setTimeout(() => settle(false), timeoutMs);
44648
+ const timeoutTimer = window.setTimeout(() => {
44649
+ timedOut = true;
44650
+ logger.warn("[Slide] first render still pending", context.appId, timeoutMs);
44651
+ if (!context.waitForActualSetupReady)
44652
+ settle(false);
44653
+ }, timeoutMs);
44465
44654
  slideControllerRef == null ? void 0 : slideControllerRef.readyPromise.then(
44466
44655
  () => settle(!firstRenderFailed),
44467
- () => settle(false)
44656
+ () => {
44657
+ firstRenderFailed = true;
44658
+ settle(false);
44659
+ }
44468
44660
  );
44469
44661
  const pollTimer = window.setInterval(() => {
44470
44662
  if (disposed || firstRenderFailed)
44471
44663
  settle(false);
44664
+ else if (timedOut && !context.waitForActualSetupReady)
44665
+ settle(false);
44472
44666
  }, 100);
44473
44667
  });
44474
44668
  const appResult = {
@@ -44604,7 +44798,13 @@ const SlideApp = {
44604
44798
  }
44605
44799
  };
44606
44800
  const setupReadyTimeout = (_g = appOptions == null ? void 0 : appOptions.setupReadyTimeout) != null ? _g : DEFAULT_SLIDE_SETUP_READY_TIMEOUT;
44607
- return waitForFirstRender(setupReadyTimeout).then(() => {
44801
+ return mounting.then(() => {
44802
+ if (disposed)
44803
+ throw new Error("[Slide] disposed before first render");
44804
+ return waitForFirstRender(setupReadyTimeout);
44805
+ }).then(async () => {
44806
+ if (disposed)
44807
+ throw new Error("[Slide] disposed before first render");
44608
44808
  if (firstRenderFailed) {
44609
44809
  throw new Error("[Slide] first render failed before ready");
44610
44810
  }
@@ -44612,12 +44812,11 @@ const SlideApp = {
44612
44812
  log("[Slide] setup ready wait timed out, slide keeps loading in background");
44613
44813
  }
44614
44814
  return appResult;
44815
+ }).catch(async (error) => {
44816
+ if (!disposed)
44817
+ await teardown();
44818
+ throw error;
44615
44819
  });
44616
- },
44617
- async teardown(context) {
44618
- var _a, _b, _c;
44619
- await ((_b = (_a = SlideApp.__teardownByContext) == null ? void 0 : _a.get(context)) == null ? void 0 : _b());
44620
- (_c = SlideApp.__teardownByContext) == null ? void 0 : _c.delete(context);
44621
44820
  }
44622
44821
  };
44623
44822
  var Slide$1 = Slide.Slide;