@netless/app-slide 0.2.106-beta.3 → 0.2.106-beta.5

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,38 @@ 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", Promise.resolve().then(e2.fn).catch(function() {
38759
+ }).finally(function() {
38760
+ !t3.isDestroy && t3.tasks.length > 0 ? setTimeout(t3.schedule) : t3.isScheduling = false;
38761
+ })) : t3.isScheduling = false;
38761
38762
  };
38762
38763
  }
38763
- return t2.prototype.addTask = function(t3, e2) {
38764
- var i2;
38764
+ return t2.prototype.cancelPending = function(t3) {
38765
+ for (var e2, i2 = 0, n2 = this.tasks.splice(0); i2 < n2.length; i2++) {
38766
+ var r2 = n2[i2];
38767
+ try {
38768
+ null === (e2 = r2.onCancelled) || void 0 === e2 || e2.call(r2, new Error("Slide " + r2.type + " task " + t3));
38769
+ } catch (t4) {
38770
+ console.warn("[Slide] frozen task cancellation callback failed", t4);
38771
+ }
38772
+ }
38773
+ }, t2.prototype.addTask = function(t3, e2, i2) {
38765
38774
  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;
38775
+ try {
38776
+ null == i2 || i2(new Error("Slide " + t3 + " task cancelled after destroy"));
38777
+ } catch (t4) {
38778
+ console.warn("[Slide] frozen task cancellation callback failed", t4);
38779
+ }
38780
+ else {
38781
+ this.cancelPending("superseded");
38782
+ var n2 = { type: t3, status: "wait", fn: e2, onCancelled: i2 };
38783
+ this.tasks.push(n2), this.isScheduling || this.schedule();
38784
+ }
38777
38785
  }, 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();
38786
+ this.isDestroy = true, this.cancelPending("cancelled after destroy");
38783
38787
  }, t2;
38784
38788
  }(), gw = function() {
38785
38789
  return (gw = Object.assign || function(t2) {
@@ -39461,7 +39465,7 @@ geometry=${JSON.stringify(o2)}`;
39461
39465
  }
39462
39466
  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
39467
  try {
39464
- Fw = "1.4.61";
39468
+ Fw = "1.4.62-beta.1";
39465
39469
  } catch (t2) {
39466
39470
  Fw = "-dev-";
39467
39471
  }
@@ -39479,7 +39483,7 @@ geometry=${JSON.stringify(o2)}`;
39479
39483
  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
39484
  const t3 = 4294967295 * Math.random() | 0, e3 = 4294967295 * Math.random() | 0, i4 = 4294967295 * Math.random() | 0, r4 = 4294967295 * Math.random() | 0;
39481
39485
  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() {
39486
+ }(), 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
39487
  return r3.frameResizeHandler();
39484
39488
  }), r3.timestamp = function() {
39485
39489
  return Date.now();
@@ -39853,65 +39857,65 @@ geometry=${JSON.stringify(o2)}`;
39853
39857
  n2.frame.style.visibility = "visible";
39854
39858
  }, 32));
39855
39859
  }
39856
- }, e2.prototype.setSlideState = function(t3) {
39857
- var e3, i3;
39860
+ }, e2.prototype.setSlideState = function(t3, e3) {
39861
+ var i3, n2;
39858
39862
  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) {
39863
+ var r3, o2, s2, a2, l2, h2, u2, c2 = this;
39864
+ return Cw(this, function(d2) {
39865
+ switch (d2.label) {
39862
39866
  case 0:
39863
39867
  if ("alive" !== this.lifecycle)
39864
39868
  return [2];
39865
- n2 = this.lifecycleGeneration, r3 = function() {
39866
- return "alive" === h2.lifecycle && h2.lifecycleGeneration === n2;
39867
- }, this.isSyncingSlideState = true, u2.label = 1;
39869
+ r3 = this.lifecycleGeneration, o2 = this.player, s2 = function() {
39870
+ return "alive" === c2.lifecycle && c2.lifecycleGeneration === r3 && c2.player === o2;
39871
+ }, this.isSyncingSlideState = true, d2.label = 1;
39868
39872
  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)
39873
+ 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
39874
  return [3, 6];
39871
- u2.label = 2;
39875
+ d2.label = 2;
39872
39876
  case 2:
39873
- return u2.trys.push([2, 4, , 5]), [4, this.enqueueRenderSlide(t3.currentSlideIndex)];
39877
+ return d2.trys.push([2, 4, , 5]), [4, this.enqueueRenderSlide(t3.currentSlideIndex)];
39874
39878
  case 3:
39875
- return u2.sent(), [3, 5];
39879
+ return d2.sent(), [3, 5];
39876
39880
  case 4:
39877
- if ((o2 = u2.sent()) instanceof Qb)
39881
+ if ((a2 = d2.sent()) instanceof Qb)
39878
39882
  return [2];
39879
- throw o2;
39883
+ throw a2;
39880
39884
  case 5:
39881
- if (!r3())
39885
+ if (!s2())
39882
39886
  return [2];
39883
- this.__slideState.currentSlideIndex = t3.currentSlideIndex, u2.label = 6;
39887
+ this.__slideState.currentSlideIndex = t3.currentSlideIndex, d2.label = 6;
39884
39888
  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;
39889
+ return Number.isInteger(t3.currentSlideIndex) ? [4, null == (l2 = this.player) ? void 0 : l2.waitUntilActive(function() {
39890
+ return l2.currentIndex === t3.currentSlideIndex && l2.currentStage;
39887
39891
  }, 3e3)] : [3, 8];
39888
39892
  case 7:
39889
- if (u2.sent(), !r3())
39893
+ if (d2.sent(), !s2())
39890
39894
  return [2];
39891
- u2.label = 8;
39895
+ d2.label = 8;
39892
39896
  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())
39897
+ 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) {
39898
+ if (!s2())
39895
39899
  return [2];
39896
39900
  this.initInteractiveSeq(t3), this.__slideState.interactiveSeqState = t3.interactiveSeqState;
39897
39901
  }
39898
- return [4, Ow(1500)];
39902
+ return null == e3 || e3(), [4, Ow(1500)];
39899
39903
  case 9:
39900
- if (u2.sent(), !r3())
39904
+ if (d2.sent(), !s2())
39901
39905
  return [2];
39902
39906
  if (!t3.mediaState)
39903
39907
  return [3, 14];
39904
- l2 = t3.mediaState, this.pendingPptMediaState = l2, u2.label = 10;
39908
+ u2 = t3.mediaState, this.pendingPptMediaState = u2, d2.label = 10;
39905
39909
  case 10:
39906
- return u2.trys.push([10, , 12, 13]), [4, this.initMedia(t3, r3)];
39910
+ return d2.trys.push([10, , 12, 13]), [4, this.initMedia(t3, s2)];
39907
39911
  case 11:
39908
- return u2.sent(), [3, 13];
39912
+ return d2.sent(), [3, 13];
39909
39913
  case 12:
39910
- return this.pendingPptMediaState === l2 && (this.pendingPptMediaState = void 0), [7];
39914
+ return this.pendingPptMediaState === u2 && (this.pendingPptMediaState = void 0), [7];
39911
39915
  case 13:
39912
- if (!r3())
39916
+ if (!s2())
39913
39917
  return [2];
39914
- this.__slideState.mediaState = l2, u2.label = 14;
39918
+ this.__slideState.mediaState = u2, d2.label = 14;
39915
39919
  case 14:
39916
39920
  return [3, 16];
39917
39921
  case 15:
@@ -40220,59 +40224,71 @@ geometry=${JSON.stringify(o2)}`;
40220
40224
  case 0:
40221
40225
  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
40226
  return !s2.isLoading;
40223
- }, 6e4)] : [3, 3];
40227
+ }, 6e4)] : [3, 2];
40224
40228
  case 1:
40225
40229
  if (a2.sent(), "alive" !== this.lifecycle || this.player !== i3)
40226
40230
  return [2];
40227
40231
  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
40232
  o2 = this.__slideState.mediaState[r3], this.__slideState.mediaState[r3] = Ew(Ew({}, o2), { frozenTime: this.timestamp() });
40229
- return [4, ww(eb.platform)];
40233
+ a2.label = 2;
40230
40234
  case 2:
40231
- a2.sent(), a2.label = 3;
40232
- case 3:
40233
40235
  return t3 && t3(), [2];
40234
40236
  }
40235
40237
  });
40236
40238
  });
40237
- }, e2.prototype.frozen = function(t3) {
40238
- var e3 = this;
40239
- return this.frozenTaskManager.addTask("frozen", function() {
40240
- return e3._doFrozen(t3);
40241
- });
40242
- }, e2.prototype._doRelease = function(t3) {
40243
- var e3, i3;
40239
+ }, e2.prototype.frozen = function(t3, e3) {
40240
+ var i3 = this;
40241
+ this.frozenTaskManager.addTask("frozen", function() {
40242
+ return i3._doFrozen(t3).catch(function(t4) {
40243
+ throw null == e3 || e3(t4), t4;
40244
+ });
40245
+ }, e3);
40246
+ }, e2.prototype._doRelease = function(t3, e3) {
40247
+ var i3, n2;
40244
40248
  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) {
40249
+ var r3, o2, s2, a2, l2, h2, u2, c2 = this;
40250
+ return Cw(this, function(d2) {
40251
+ switch (d2.label) {
40248
40252
  case 0:
40249
40253
  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;
40254
+ return null == e3 || e3(), [2];
40255
+ this.isReleasing = true, d2.label = 1;
40252
40256
  case 1:
40253
- return l2.trys.push([1, , 5, 6]), [4, ww(eb.platform)];
40257
+ return d2.trys.push([1, 3, , 4]), [4, ww(eb.platform)];
40254
40258
  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)];
40259
+ if (d2.sent(), "alive" !== this.lifecycle || this.player)
40260
+ throw new Error("Slide release cancelled before player creation");
40261
+ 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)
40262
+ "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);
40263
+ return null == e3 || e3(), h2 = Promise.resolve(), this.setSlideState(o2, function() {
40264
+ h2 = new Promise(function(t4) {
40265
+ return setTimeout(function() {
40266
+ "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();
40267
+ }, 333);
40268
+ });
40269
+ }).then(function() {
40270
+ return h2;
40271
+ }).then(function() {
40272
+ "alive" === c2.lifecycle && c2.player === r3 && (null == t3 || t3());
40273
+ }).catch(function(t4) {
40274
+ c2.logger.error("release state restore failed: " + String(t4), c2.taskId);
40275
+ }).finally(function() {
40276
+ c2.isReleasing = false, c2.notifyPptMediaPermissionRequest();
40277
+ }), [3, 4];
40260
40278
  case 3:
40261
- return l2.sent(), "alive" !== this.lifecycle || this.player !== n2 ? [2] : [4, Ow(333)];
40279
+ throw u2 = d2.sent(), this.isReleasing = false, this.notifyPptMediaPermissionRequest(), u2;
40262
40280
  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
40281
  return [2];
40268
40282
  }
40269
40283
  });
40270
40284
  });
40271
- }, e2.prototype.release = function(t3) {
40272
- var e3 = this;
40273
- return this.frozenTaskManager.addTask("release", function() {
40274
- return e3._doRelease(t3);
40275
- });
40285
+ }, e2.prototype.release = function(t3, e3, i3) {
40286
+ var n2 = this;
40287
+ this.frozenTaskManager.addTask("release", function() {
40288
+ return n2._doRelease(t3, e3).catch(function(t4) {
40289
+ throw null == i3 || i3(t4), t4;
40290
+ });
40291
+ }, i3);
40276
40292
  }, e2.prototype._doDestroy = function() {
40277
40293
  var t3, i3, n2, r3, o2 = this;
40278
40294
  if ("disposed" !== this.lifecycle) {
@@ -40321,29 +40337,31 @@ geometry=${JSON.stringify(o2)}`;
40321
40337
  return this.player ? this.player.preload(t3) : Promise.resolve();
40322
40338
  }, e2.prototype.preloadResource = function(t3) {
40323
40339
  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];
40340
+ }, e2.prototype.destroy = function(t3, e3) {
40341
+ var i3, n2, r3, o2, s2, a2 = this, l2 = { onDestroyed: t3, onError: e3 }, h2 = this.playerDestroyOutcome;
40342
+ 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) {
40343
+ this.lifecycle = "disposing", this.lifecycleGeneration += 1, this.renderVisibilityTimers.forEach(function(t4) {
40344
+ return clearTimeout(t4);
40345
+ }), this.renderVisibilityTimers.clear(), this.renderingTaskManager.destroy();
40346
+ try {
40347
+ null === (n2 = this.player) || void 0 === n2 || n2.destroy(), this.playerDestroyOutcome = { ok: true };
40348
+ } catch (t4) {
40349
+ this.playerDestroyOutcome = { ok: false, error: t4 };
40350
+ }
40351
+ for (var u2 = 0, c2 = (null !== (r3 = this.playerDestroyCallbacks) && void 0 !== r3 ? r3 : []).splice(0); u2 < c2.length; u2++) {
40352
+ var d2 = c2[u2];
40353
+ try {
40354
+ 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);
40355
+ } catch (t4) {
40356
+ this.logger.error("player destroy callback failed: " + String(t4), this.taskId);
40344
40357
  }
40345
- });
40346
- }), this.destroyPromise);
40358
+ }
40359
+ if (!this.playerDestroyOutcome.ok)
40360
+ throw this.playerDestroyOutcome.error;
40361
+ this.logger.info("pre destroy slide", ""), this.isLoading ? this.waitLoadEnd().then(function() {
40362
+ a2._doDestroy();
40363
+ }) : this._doDestroy();
40364
+ }
40347
40365
  }, e2.prototype.clearSlideCache = function() {
40348
40366
  var t3;
40349
40367
  null === (t3 = this.player) || void 0 === t3 || t3.clearLocalCache();
@@ -41189,6 +41207,38 @@ const EmptyAttributes = {
41189
41207
  };
41190
41208
  const noop$1 = function noop2() {
41191
41209
  };
41210
+ const slideWebGLTasks = [];
41211
+ let slideWebGLRunning = false;
41212
+ function runNextSlideWebGLTask() {
41213
+ if (slideWebGLRunning)
41214
+ return;
41215
+ const task = slideWebGLTasks.shift();
41216
+ if (!task)
41217
+ return;
41218
+ slideWebGLRunning = true;
41219
+ const startedAt = performance.now();
41220
+ log("[Slide][player-queue] start", task.label, "pending", slideWebGLTasks.length);
41221
+ void Promise.resolve().then(task.run).then(() => {
41222
+ log("[Slide][player-queue] done", task.label, "ms", Math.round(performance.now() - startedAt));
41223
+ task.resolve();
41224
+ }, (error) => {
41225
+ log("[Slide][player-queue] failed", task.label, error);
41226
+ task.reject(error);
41227
+ }).finally(() => {
41228
+ slideWebGLRunning = false;
41229
+ runNextSlideWebGLTask();
41230
+ });
41231
+ }
41232
+ function enqueueSlideWebGLTransition(run, priority = false, label = "unspecified") {
41233
+ return new Promise((resolve, reject) => {
41234
+ const task = { label, run, resolve, reject };
41235
+ if (priority)
41236
+ slideWebGLTasks.unshift(task);
41237
+ else
41238
+ slideWebGLTasks.push(task);
41239
+ runNextSlideWebGLTask();
41240
+ });
41241
+ }
41192
41242
  class SlideControllerBase {
41193
41243
  constructor(props) {
41194
41244
  this.sideEffect = new SideEffectManager();
@@ -41257,6 +41307,9 @@ class SlideControllerBase {
41257
41307
  };
41258
41308
  this._pageCount = 0;
41259
41309
  this.destroyed = false;
41310
+ this.destroyedSignal = new Promise((resolve) => {
41311
+ this.resolveDestroyedSignal = resolve;
41312
+ });
41260
41313
  this.timestamp = () => {
41261
41314
  if (this.room && this.room.calibrationTimestamp) {
41262
41315
  return this.room.calibrationTimestamp;
@@ -41316,7 +41369,19 @@ class SlideControllerBase {
41316
41369
  if (this.ready) {
41317
41370
  log("[Slide] freeze", this.context.appId);
41318
41371
  if (this.invisibleBehavior === "frozen") {
41319
- await this.slide.frozen();
41372
+ await enqueueSlideWebGLTransition(() => {
41373
+ if (this.destroyed)
41374
+ return Promise.resolve();
41375
+ const destroyed = new Promise((resolve, reject) => {
41376
+ const result = this.slide.frozen.call(this.slide, () => {
41377
+ log("[Slide][player] frozen callback", this.context.appId);
41378
+ resolve();
41379
+ }, reject);
41380
+ if (result)
41381
+ void result.then(resolve, reject);
41382
+ });
41383
+ return Promise.race([destroyed, this.destroyedSignal]);
41384
+ }, false, `freeze:${this.context.appId}`);
41320
41385
  } else {
41321
41386
  this.slide.pause();
41322
41387
  }
@@ -41341,25 +41406,38 @@ class SlideControllerBase {
41341
41406
  this.isFrozen = false;
41342
41407
  try {
41343
41408
  if (this.ready) {
41344
- let isNeedSyncState = false;
41345
41409
  log("[Slide] unfreeze", this.context.appId);
41346
41410
  if (this.invisibleBehavior === "frozen") {
41347
- await this.slide.release(() => {
41348
- if (!this.isLazySetupMode() || this.shouldBeActive())
41349
- this.slide.notifyFrameResize();
41350
- });
41351
- isNeedSyncState = true;
41411
+ await enqueueSlideWebGLTransition(() => {
41412
+ if (this.destroyed)
41413
+ return Promise.resolve();
41414
+ const created = new Promise((resolve, reject) => {
41415
+ const result = this.slide.release.call(this.slide, () => {
41416
+ log("[Slide][player] restored callback", this.context.appId);
41417
+ if (this.isLazySetupMode() && !this.shouldBeActive())
41418
+ return;
41419
+ this.slide.notifyFrameResize();
41420
+ const state = this.context.storage.state.state;
41421
+ if (state) {
41422
+ log("[Slide] sync storage", JSON.stringify(state));
41423
+ void this.slide.setSlideState(state).catch((error) => {
41424
+ this.resourceStateUnknown = true;
41425
+ logger.warn("[Slide] storage sync after release failed", this.context.appId, error);
41426
+ });
41427
+ }
41428
+ }, () => {
41429
+ log("[Slide][player] created callback", this.context.appId);
41430
+ resolve();
41431
+ }, reject);
41432
+ if (result)
41433
+ void result.then(resolve, reject);
41434
+ });
41435
+ return Promise.race([created, this.destroyedSignal]);
41436
+ }, false, `release:${this.context.appId}`);
41352
41437
  } else {
41353
41438
  this.slide.resume();
41354
41439
  this.slide.notifyFrameResize();
41355
41440
  }
41356
- if (isNeedSyncState && (!this.isLazySetupMode() || this.shouldBeActive())) {
41357
- const state = this.context.storage.state.state;
41358
- if (state) {
41359
- log("[Slide] sync storage", JSON.stringify(state));
41360
- await this.slide.setSlideState(state);
41361
- }
41362
- }
41363
41441
  } else {
41364
41442
  this._toFreeze = -1;
41365
41443
  }
@@ -41626,7 +41704,17 @@ class SlideControllerBase {
41626
41704
  if (!this.destroyed) {
41627
41705
  log("[Slide] destroy slide (once)");
41628
41706
  this.destroyed = true;
41629
- this.destroyPromise = Promise.resolve(this.slide.destroy());
41707
+ this.destroyPromise = enqueueSlideWebGLTransition(() => new Promise((resolve, reject) => {
41708
+ try {
41709
+ this.slide.destroy.call(this.slide, () => {
41710
+ log("[Slide][player] destroy callback", this.context.appId);
41711
+ resolve();
41712
+ }, reject);
41713
+ } catch (error) {
41714
+ reject(error);
41715
+ }
41716
+ }), true, `destroy:${this.context.appId}`);
41717
+ this.resolveDestroyedSignal();
41630
41718
  }
41631
41719
  return (_a = this.destroyPromise) != null ? _a : Promise.resolve();
41632
41720
  }
@@ -43686,6 +43774,7 @@ class SlideDocsViewer {
43686
43774
  logger.warn("[Slide] render error", error);
43687
43775
  };
43688
43776
  this.onRenderStart = () => {
43777
+ logger.log("[Slide][notes] hide", this.appId, "scene", this.whiteboardView.focusScenePath);
43689
43778
  this.$whiteboardView.classList.add(this.wrapClassName("wb-view-hidden"));
43690
43779
  this.viewer.setPlaying();
43691
43780
  };
@@ -43693,10 +43782,12 @@ class SlideDocsViewer {
43693
43782
  };
43694
43783
  this.onPageChanged = () => {
43695
43784
  clearTimeout(this._onPageChangedTimer);
43785
+ logger.log("[Slide][notes] show scheduled", this.appId, "scene", this.whiteboardView.focusScenePath);
43696
43786
  this._onPageChangedTimer = setTimeout(this._onPageChanged, 200);
43697
43787
  };
43698
43788
  this._onPageChangedTimer = 0;
43699
43789
  this._onPageChanged = () => {
43790
+ logger.log("[Slide][notes] show", this.appId, "scene", this.whiteboardView.focusScenePath);
43700
43791
  this.$overlay.style.opacity = "";
43701
43792
  this.$whiteboardView.classList.remove(this.wrapClassName("wb-view-hidden"));
43702
43793
  };
@@ -44382,7 +44473,7 @@ class SlidePreviewer {
44382
44473
  }
44383
44474
  }
44384
44475
  const usePlugin = /* @__PURE__ */ Slide.Slide.usePlugin.bind(Slide.Slide);
44385
- const version = "0.2.106-beta.3";
44476
+ const version = "0.2.106-beta.5";
44386
44477
  const DEFAULT_SLIDE_SETUP_READY_TIMEOUT = 5e3;
44387
44478
  const SlideApp = {
44388
44479
  kind: "Slide",
@@ -44463,6 +44554,9 @@ const SlideApp = {
44463
44554
  const page = slideController.slide.slideState.currentSlideIndex;
44464
44555
  log("[Slide] page to", page, synced ? "(synced)" : "", "(on ready)");
44465
44556
  slideController.slide.on("renderEnd", options.onRenderEnd);
44557
+ }).catch((error) => {
44558
+ if (!disposed)
44559
+ logger.warn("[Slide] ready callback failed", context.appId, error);
44466
44560
  });
44467
44561
  return slideController;
44468
44562
  };
@@ -44548,9 +44642,10 @@ const SlideApp = {
44548
44642
  return teardownPromise;
44549
44643
  };
44550
44644
  offDestroy = context.emitter.on("destroy", teardown);
44551
- docsViewer.mount();
44552
- SlideApp.__teardownByContext || (SlideApp.__teardownByContext = /* @__PURE__ */ new WeakMap());
44553
- SlideApp.__teardownByContext.set(context, teardown);
44645
+ const mounting = enqueueSlideWebGLTransition(() => {
44646
+ if (!disposed)
44647
+ docsViewer == null ? void 0 : docsViewer.mount();
44648
+ }, false, `setup:${context.appId}`);
44554
44649
  const waitForFirstRender = (timeoutMs) => new Promise((resolve) => {
44555
44650
  let settled = false;
44556
44651
  let timedOut = false;
@@ -44570,7 +44665,10 @@ const SlideApp = {
44570
44665
  }, timeoutMs);
44571
44666
  slideControllerRef == null ? void 0 : slideControllerRef.readyPromise.then(
44572
44667
  () => settle(!firstRenderFailed),
44573
- () => settle(false)
44668
+ () => {
44669
+ firstRenderFailed = true;
44670
+ settle(false);
44671
+ }
44574
44672
  );
44575
44673
  const pollTimer = window.setInterval(() => {
44576
44674
  if (disposed || firstRenderFailed)
@@ -44712,7 +44810,11 @@ const SlideApp = {
44712
44810
  }
44713
44811
  };
44714
44812
  const setupReadyTimeout = (_g = appOptions == null ? void 0 : appOptions.setupReadyTimeout) != null ? _g : DEFAULT_SLIDE_SETUP_READY_TIMEOUT;
44715
- return waitForFirstRender(setupReadyTimeout).then(() => {
44813
+ return mounting.then(() => {
44814
+ if (disposed)
44815
+ throw new Error("[Slide] disposed before first render");
44816
+ return waitForFirstRender(setupReadyTimeout);
44817
+ }).then(async () => {
44716
44818
  if (disposed)
44717
44819
  throw new Error("[Slide] disposed before first render");
44718
44820
  if (firstRenderFailed) {
@@ -44722,12 +44824,11 @@ const SlideApp = {
44722
44824
  log("[Slide] setup ready wait timed out, slide keeps loading in background");
44723
44825
  }
44724
44826
  return appResult;
44827
+ }).catch(async (error) => {
44828
+ if (!disposed)
44829
+ await teardown();
44830
+ throw error;
44725
44831
  });
44726
- },
44727
- async teardown(context) {
44728
- var _a, _b, _c;
44729
- await ((_b = (_a = SlideApp.__teardownByContext) == null ? void 0 : _a.get(context)) == null ? void 0 : _b());
44730
- (_c = SlideApp.__teardownByContext) == null ? void 0 : _c.delete(context);
44731
44832
  }
44732
44833
  };
44733
44834
  var Slide$1 = Slide.Slide;