@netless/app-slide 0.2.51 → 0.2.53-alpha.0

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
@@ -31612,10 +31612,14 @@ void main(void){
31612
31612
  return this.videoResource.load();
31613
31613
  }
31614
31614
  pause() {
31615
- this.isPlaying = false, this.ctx.logger.warn(this.url + ", pause video manual.", this.ctx.taskId), this.ctx.logger.warn(this.url + ", pause rtc audio manual.", this.ctx.taskId), this.rtcAudio.on("pause", () => {
31616
- var t2;
31617
- (t2 = this.videoElement) === null || t2 === void 0 || t2.pause();
31618
- }), this.rtcAudio.pause();
31615
+ return c_(this, void 0, void 0, function* () {
31616
+ return new Promise((t2) => {
31617
+ this.isPlaying = false, this.ctx.logger.warn(this.url + ", pause video manual.", this.ctx.taskId), this.ctx.logger.warn(this.url + ", pause rtc audio manual.", this.ctx.taskId), this.rtcAudio.on("pause", () => {
31618
+ var e2;
31619
+ (e2 = this.videoElement) === null || e2 === void 0 || e2.pause(), t2();
31620
+ }), this.rtcAudio.pause();
31621
+ });
31622
+ });
31619
31623
  }
31620
31624
  globalPause() {
31621
31625
  this.isPlaying && (this.isGlobalPause = true, this.pause());
@@ -31722,7 +31726,9 @@ void main(void){
31722
31726
  });
31723
31727
  }
31724
31728
  pause() {
31725
- this.ctx.isPlayerPaused() ? this.ctx.logger.info("Audio player prevent pause event with paused state", this.ctx.taskId) : (this.isPlaying = false, this.audioPlayer.pause());
31729
+ return p_(this, void 0, void 0, function* () {
31730
+ this.ctx.isPlayerPaused() ? this.ctx.logger.info("Audio player prevent pause event with paused state", this.ctx.taskId) : (this.isPlaying = false, this.audioPlayer.pause());
31731
+ });
31726
31732
  }
31727
31733
  globalPause() {
31728
31734
  this.isPlaying && (this.isGlobalPause = true, this.pause());
@@ -37353,6 +37359,8 @@ const EmptyAttributes = {
37353
37359
  url: "",
37354
37360
  state: null
37355
37361
  };
37362
+ const noop$1 = function noop2() {
37363
+ };
37356
37364
  class SlideController {
37357
37365
  constructor({
37358
37366
  context,
@@ -37361,6 +37369,7 @@ class SlideController {
37361
37369
  onPageChanged,
37362
37370
  onTransitionStart,
37363
37371
  onTransitionEnd,
37372
+ onNavigate,
37364
37373
  onError,
37365
37374
  onRenderError,
37366
37375
  showRenderError
@@ -37416,8 +37425,7 @@ class SlideController {
37416
37425
  setTimeout(this.pollReadyState, 500);
37417
37426
  } else {
37418
37427
  this.pollCount = 0;
37419
- log("[Slide] renderSlide 1 (retry after timeout)");
37420
- this.slide.renderSlide(1);
37428
+ log("[Slide] init timeout");
37421
37429
  }
37422
37430
  };
37423
37431
  this._pageCount = 0;
@@ -37469,6 +37477,7 @@ class SlideController {
37469
37477
  this.onPageChanged = onPageChanged;
37470
37478
  this.onTransitionStart = onTransitionStart;
37471
37479
  this.onTransitionEnd = onTransitionEnd;
37480
+ this.onNavigate = onNavigate || noop$1;
37472
37481
  this.onError = onError;
37473
37482
  this.onRenderError = onRenderError;
37474
37483
  this.showRenderError = showRenderError != null ? showRenderError : true;
@@ -37484,9 +37493,10 @@ class SlideController {
37484
37493
  this.savedIsFrozen = false;
37485
37494
  this.initialize();
37486
37495
  }
37487
- jumpToPage(page) {
37496
+ jumpToPage(page, origin) {
37488
37497
  if (this.ready) {
37489
37498
  page = clamp$1(page, 1, this.pageCount);
37499
+ this.onNavigate(page, origin);
37490
37500
  this.slide.renderSlide(page);
37491
37501
  }
37492
37502
  }
@@ -38325,7 +38335,13 @@ if (runningOnBrowser) {
38325
38335
  autoInitialize(LazyLoad, window.lazyLoadOptions);
38326
38336
  }
38327
38337
  class DocsViewer {
38328
- constructor({ readonly, onNewPageIndex, onPlay, onPagesReady, urlInterrupter }) {
38338
+ constructor({
38339
+ readonly,
38340
+ onNewPageIndex,
38341
+ onPlay,
38342
+ onPagesReady,
38343
+ urlInterrupter
38344
+ }) {
38329
38345
  this._pages = [];
38330
38346
  this.pageIndex = 0;
38331
38347
  this.setPaused = () => {
@@ -38425,7 +38441,7 @@ class DocsViewer {
38425
38441
  ev.preventDefault();
38426
38442
  ev.stopPropagation();
38427
38443
  ev.stopImmediatePropagation();
38428
- this.onNewPageIndex(Number(pageIndex));
38444
+ this.onNewPageIndex(Number(pageIndex), "preview");
38429
38445
  this.togglePreview(false);
38430
38446
  }
38431
38447
  });
@@ -38522,7 +38538,7 @@ class DocsViewer {
38522
38538
  if (this.readonly) {
38523
38539
  return;
38524
38540
  }
38525
- this.onNewPageIndex(this.pageIndex - 1);
38541
+ this.onNewPageIndex(this.pageIndex - 1, "navigation");
38526
38542
  });
38527
38543
  $pageJumps.appendChild($btnPageBack);
38528
38544
  if (this.onPlay) {
@@ -38544,7 +38560,7 @@ class DocsViewer {
38544
38560
  if (this.readonly) {
38545
38561
  return;
38546
38562
  }
38547
- this.onNewPageIndex(this.pageIndex + 1);
38563
+ this.onNewPageIndex(this.pageIndex + 1, "navigation");
38548
38564
  });
38549
38565
  $pageJumps.appendChild($btnPageNext);
38550
38566
  const $pageNumber = document.createElement("div");
@@ -38564,7 +38580,7 @@ class DocsViewer {
38564
38580
  return;
38565
38581
  }
38566
38582
  if ($pageNumberInput.value) {
38567
- this.onNewPageIndex(Number($pageNumberInput.value) - 1);
38583
+ this.onNewPageIndex(Number($pageNumberInput.value) - 1, "input");
38568
38584
  }
38569
38585
  });
38570
38586
  const $totalPage = document.createElement("span");
@@ -38606,6 +38622,8 @@ class DocsViewer {
38606
38622
  }
38607
38623
  }
38608
38624
  const ClickThroughAppliances = /* @__PURE__ */ new Set(["clicker"]);
38625
+ const noop = function noop22() {
38626
+ };
38609
38627
  class SlideDocsViewer {
38610
38628
  constructor({
38611
38629
  box,
@@ -38615,7 +38633,8 @@ class SlideDocsViewer {
38615
38633
  baseScenePath,
38616
38634
  appId,
38617
38635
  urlInterrupter,
38618
- onPagesReady
38636
+ onPagesReady,
38637
+ onNavigate
38619
38638
  }) {
38620
38639
  this.slideController = null;
38621
38640
  this.isViewMounted = false;
@@ -38686,9 +38705,9 @@ class SlideDocsViewer {
38686
38705
  this.slideController.slide.nextStep();
38687
38706
  }
38688
38707
  };
38689
- this.onNewPageIndex = (index) => {
38708
+ this.onNewPageIndex = (index, origin) => {
38690
38709
  if (this.slideController) {
38691
- this.slideController.jumpToPage(index + 1);
38710
+ this.slideController.jumpToPage(index + 1, origin);
38692
38711
  }
38693
38712
  };
38694
38713
  this.sideEffect = new SideEffectManager();
@@ -38771,6 +38790,7 @@ class SlideDocsViewer {
38771
38790
  this.whiteboardView = view;
38772
38791
  this.mountSlideController = mountSlideController;
38773
38792
  this.mountWhiteboard = mountWhiteboard;
38793
+ this.onNavigate = onNavigate || noop;
38774
38794
  this.baseScenePath = baseScenePath;
38775
38795
  this.appId = appId;
38776
38796
  this.viewer = new DocsViewer({
@@ -38810,11 +38830,13 @@ class SlideDocsViewer {
38810
38830
  case "ArrowUp":
38811
38831
  case "ArrowLeft": {
38812
38832
  this.slideController.slide.prevStep();
38833
+ this.onNavigate(this.slideController.page, "keydown");
38813
38834
  break;
38814
38835
  }
38815
38836
  case "ArrowRight":
38816
38837
  case "ArrowDown": {
38817
38838
  this.slideController.slide.nextStep();
38839
+ this.onNavigate(this.slideController.page, "keydown");
38818
38840
  break;
38819
38841
  }
38820
38842
  }
@@ -38855,6 +38877,7 @@ class SlideDocsViewer {
38855
38877
  onTransitionStart: this.viewer.setPlaying,
38856
38878
  onTransitionEnd: this.viewer.setPaused,
38857
38879
  onReady: this.refreshPages,
38880
+ onNavigate: this.onNavigate,
38858
38881
  onError: this.onError
38859
38882
  });
38860
38883
  this.scaleDocsToFit();
@@ -39144,7 +39167,7 @@ class SlidePreviewer {
39144
39167
  }
39145
39168
  }
39146
39169
  const usePlugin = /* @__PURE__ */ Slide.Slide.usePlugin.bind(Slide.Slide);
39147
- const version = "0.2.51";
39170
+ const version = "0.2.53-alpha.0";
39148
39171
  const SlideApp = {
39149
39172
  kind: "Slide",
39150
39173
  setup(context) {
@@ -39193,6 +39216,7 @@ const SlideApp = {
39193
39216
  context
39194
39217
  }, options), {
39195
39218
  onPageChanged,
39219
+ onNavigate: options.onNavigate,
39196
39220
  onRenderError: appOptions.onRenderError,
39197
39221
  showRenderError: appOptions.showRenderError
39198
39222
  }));
@@ -39223,6 +39247,9 @@ const SlideApp = {
39223
39247
  onPagesReady: ({ length }) => {
39224
39248
  const index = (docsViewer == null ? void 0 : docsViewer.viewer.pageIndex) || 0;
39225
39249
  context.dispatchAppEvent("pageStateChange", { index, length });
39250
+ },
39251
+ onNavigate: (page, origin) => {
39252
+ log("[Slide] user navigate to", page, origin ? `(${origin})` : "");
39226
39253
  }
39227
39254
  });
39228
39255
  const room = context.getRoom();