@netless/app-slide 0.2.106-beta.3 → 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();
@@ -41189,6 +41195,38 @@ const EmptyAttributes = {
41189
41195
  };
41190
41196
  const noop$1 = function noop2() {
41191
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
+ }
41192
41230
  class SlideControllerBase {
41193
41231
  constructor(props) {
41194
41232
  this.sideEffect = new SideEffectManager();
@@ -41257,6 +41295,9 @@ class SlideControllerBase {
41257
41295
  };
41258
41296
  this._pageCount = 0;
41259
41297
  this.destroyed = false;
41298
+ this.destroyedSignal = new Promise((resolve) => {
41299
+ this.resolveDestroyedSignal = resolve;
41300
+ });
41260
41301
  this.timestamp = () => {
41261
41302
  if (this.room && this.room.calibrationTimestamp) {
41262
41303
  return this.room.calibrationTimestamp;
@@ -41316,7 +41357,19 @@ class SlideControllerBase {
41316
41357
  if (this.ready) {
41317
41358
  log("[Slide] freeze", this.context.appId);
41318
41359
  if (this.invisibleBehavior === "frozen") {
41319
- await this.slide.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}`);
41320
41373
  } else {
41321
41374
  this.slide.pause();
41322
41375
  }
@@ -41341,25 +41394,38 @@ class SlideControllerBase {
41341
41394
  this.isFrozen = false;
41342
41395
  try {
41343
41396
  if (this.ready) {
41344
- let isNeedSyncState = false;
41345
41397
  log("[Slide] unfreeze", this.context.appId);
41346
41398
  if (this.invisibleBehavior === "frozen") {
41347
- await this.slide.release(() => {
41348
- if (!this.isLazySetupMode() || this.shouldBeActive())
41349
- this.slide.notifyFrameResize();
41350
- });
41351
- isNeedSyncState = true;
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}`);
41352
41425
  } else {
41353
41426
  this.slide.resume();
41354
41427
  this.slide.notifyFrameResize();
41355
41428
  }
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
41429
  } else {
41364
41430
  this._toFreeze = -1;
41365
41431
  }
@@ -41626,7 +41692,17 @@ class SlideControllerBase {
41626
41692
  if (!this.destroyed) {
41627
41693
  log("[Slide] destroy slide (once)");
41628
41694
  this.destroyed = true;
41629
- 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();
41630
41706
  }
41631
41707
  return (_a = this.destroyPromise) != null ? _a : Promise.resolve();
41632
41708
  }
@@ -43686,6 +43762,7 @@ class SlideDocsViewer {
43686
43762
  logger.warn("[Slide] render error", error);
43687
43763
  };
43688
43764
  this.onRenderStart = () => {
43765
+ logger.log("[Slide][notes] hide", this.appId, "scene", this.whiteboardView.focusScenePath);
43689
43766
  this.$whiteboardView.classList.add(this.wrapClassName("wb-view-hidden"));
43690
43767
  this.viewer.setPlaying();
43691
43768
  };
@@ -43693,10 +43770,12 @@ class SlideDocsViewer {
43693
43770
  };
43694
43771
  this.onPageChanged = () => {
43695
43772
  clearTimeout(this._onPageChangedTimer);
43773
+ logger.log("[Slide][notes] show scheduled", this.appId, "scene", this.whiteboardView.focusScenePath);
43696
43774
  this._onPageChangedTimer = setTimeout(this._onPageChanged, 200);
43697
43775
  };
43698
43776
  this._onPageChangedTimer = 0;
43699
43777
  this._onPageChanged = () => {
43778
+ logger.log("[Slide][notes] show", this.appId, "scene", this.whiteboardView.focusScenePath);
43700
43779
  this.$overlay.style.opacity = "";
43701
43780
  this.$whiteboardView.classList.remove(this.wrapClassName("wb-view-hidden"));
43702
43781
  };
@@ -44382,7 +44461,7 @@ class SlidePreviewer {
44382
44461
  }
44383
44462
  }
44384
44463
  const usePlugin = /* @__PURE__ */ Slide.Slide.usePlugin.bind(Slide.Slide);
44385
- const version = "0.2.106-beta.3";
44464
+ const version = "0.2.106-beta.4";
44386
44465
  const DEFAULT_SLIDE_SETUP_READY_TIMEOUT = 5e3;
44387
44466
  const SlideApp = {
44388
44467
  kind: "Slide",
@@ -44463,6 +44542,9 @@ const SlideApp = {
44463
44542
  const page = slideController.slide.slideState.currentSlideIndex;
44464
44543
  log("[Slide] page to", page, synced ? "(synced)" : "", "(on ready)");
44465
44544
  slideController.slide.on("renderEnd", options.onRenderEnd);
44545
+ }).catch((error) => {
44546
+ if (!disposed)
44547
+ logger.warn("[Slide] ready callback failed", context.appId, error);
44466
44548
  });
44467
44549
  return slideController;
44468
44550
  };
@@ -44548,9 +44630,10 @@ const SlideApp = {
44548
44630
  return teardownPromise;
44549
44631
  };
44550
44632
  offDestroy = context.emitter.on("destroy", teardown);
44551
- docsViewer.mount();
44552
- SlideApp.__teardownByContext || (SlideApp.__teardownByContext = /* @__PURE__ */ new WeakMap());
44553
- SlideApp.__teardownByContext.set(context, teardown);
44633
+ const mounting = enqueueSlideWebGLTransition(() => {
44634
+ if (!disposed)
44635
+ docsViewer == null ? void 0 : docsViewer.mount();
44636
+ }, false, `setup:${context.appId}`);
44554
44637
  const waitForFirstRender = (timeoutMs) => new Promise((resolve) => {
44555
44638
  let settled = false;
44556
44639
  let timedOut = false;
@@ -44570,7 +44653,10 @@ const SlideApp = {
44570
44653
  }, timeoutMs);
44571
44654
  slideControllerRef == null ? void 0 : slideControllerRef.readyPromise.then(
44572
44655
  () => settle(!firstRenderFailed),
44573
- () => settle(false)
44656
+ () => {
44657
+ firstRenderFailed = true;
44658
+ settle(false);
44659
+ }
44574
44660
  );
44575
44661
  const pollTimer = window.setInterval(() => {
44576
44662
  if (disposed || firstRenderFailed)
@@ -44712,7 +44798,11 @@ const SlideApp = {
44712
44798
  }
44713
44799
  };
44714
44800
  const setupReadyTimeout = (_g = appOptions == null ? void 0 : appOptions.setupReadyTimeout) != null ? _g : DEFAULT_SLIDE_SETUP_READY_TIMEOUT;
44715
- 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 () => {
44716
44806
  if (disposed)
44717
44807
  throw new Error("[Slide] disposed before first render");
44718
44808
  if (firstRenderFailed) {
@@ -44722,12 +44812,11 @@ const SlideApp = {
44722
44812
  log("[Slide] setup ready wait timed out, slide keeps loading in background");
44723
44813
  }
44724
44814
  return appResult;
44815
+ }).catch(async (error) => {
44816
+ if (!disposed)
44817
+ await teardown();
44818
+ throw error;
44725
44819
  });
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
44820
  }
44732
44821
  };
44733
44822
  var Slide$1 = Slide.Slide;