@netless/app-slide 0.2.98 → 0.2.100-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/index.d.ts CHANGED
@@ -2,6 +2,8 @@ import { RegisterParams, ReadonlyTeleBox, Room, AppContext, Player, View, Netles
2
2
  import { SlideError, VolumeAdjuster } from '@netless/ppt-player';
3
3
  import { IPlugin } from '@netless/plugin-system';
4
4
 
5
+ declare type SyncEventQueuePolicy = "fifo" | "latest-pending-render";
6
+
5
7
  declare class AliTrackLogger {
6
8
  private logList;
7
9
  private checkTimer;
@@ -235,6 +237,12 @@ interface ISlideConfig {
235
237
  * "local" Local mode, no synchronization events will be triggered
236
238
  */
237
239
  mode: "interactive" | "sync" | "local" | "addLink";
240
+ /**
241
+ * Queue policy for received synchronization events.
242
+ * Default is "fifo". "latest-pending-render" lets interactive clients skip pending intermediate pages.
243
+ * Non-interactive modes always use "fifo".
244
+ */
245
+ syncEventQueuePolicy?: SyncEventQueuePolicy;
238
246
  /**
239
247
  * Whether to enable global clicking, after turning on, as long as you click within the ppt viewport range,
240
248
  * and do not trigger interactive elements inside ppt, it will trigger the next action.
@@ -303,13 +311,18 @@ interface ISlideConfig {
303
311
  skipActionWhenFrozen?: boolean;
304
312
  enableAutoForward?: boolean;
305
313
  customLinks?: CustomLink[];
314
+ /**
315
+ * Disable the built-in ResizeObserver and rely on external notifyFrameResize() calls.
316
+ * Set this to true when using window-manager's boxSizeChange event as the resize signal.
317
+ * @default false
318
+ */
319
+ disableFrameResizeObserver?: boolean;
306
320
  resourceMaxRetries?: number;
307
321
  onResourceMaxRetries?: (url: string, error: Error) => void;
308
322
  }
309
323
  interface MediaState {
310
324
  type: "pause" | "play";
311
325
  time: number;
312
- frozenTime?: number;
313
326
  fullscreen?: boolean;
314
327
  }
315
328
  interface TimeNodeSeqState {
@@ -460,12 +473,14 @@ declare class Slide extends Slide_base {
460
473
  private userInputTime;
461
474
  private isSyncingSlideState;
462
475
  private frozenTaskManager;
476
+ private frozenMediaTimes;
463
477
  private randomId;
464
478
  private resize;
465
479
  private isAnimating;
466
480
  private renderingTaskManager;
467
481
  private isLoading;
468
482
  private interactive;
483
+ private syncCatchUpInputBlocked;
469
484
  private anchor;
470
485
  private tracker;
471
486
  private player?;
@@ -481,6 +496,7 @@ declare class Slide extends Slide_base {
481
496
  private enableGlobalClick;
482
497
  private lastEmitedState;
483
498
  private syncQueue;
499
+ private selfSyncEvents;
484
500
  private playerController;
485
501
  private lock;
486
502
  private isInitResized;
@@ -504,6 +520,10 @@ declare class Slide extends Slide_base {
504
520
  private get dispatchIncrId();
505
521
  constructor(initConfig: ISlideConfig);
506
522
  private _updateVolumeByStaticAdjuster;
523
+ private handleSyncQueueCompact;
524
+ private handleSyncQueueCompactRenderComplete;
525
+ private handleSyncQueueCatchUpStateChange;
526
+ private updatePlayerInteractive;
507
527
  private recoverHandler;
508
528
  private reportError;
509
529
  initSlideConfig(config: ISlideConfig): ISlideConfig;
@@ -522,6 +542,12 @@ declare class Slide extends Slide_base {
522
542
  private updateStageCountLimit;
523
543
  private setMedianControllerAttribute;
524
544
  private frameResizeHandler;
545
+ /**
546
+ * Notify the slide that its frame container may have changed size.
547
+ * Call this when using an external resize signal (e.g. window-manager's boxSizeChange event)
548
+ * instead of the built-in ResizeObserver.
549
+ */
550
+ notifyFrameResize(): void;
525
551
  /**
526
552
  * Update ppt fixed height and width, this method only takes effect when the fixedFrameSize configuration item is set.
527
553
  * @param width Width value that needs to be updated, unit px.
@@ -644,6 +670,7 @@ declare class Slide extends Slide_base {
644
670
  * @param isForward Whether to flip forward or backward, affecting the page transition animation.
645
671
  */
646
672
  doRenderSlide(index: number, isForward?: boolean): Promise<void>;
673
+ private enqueueRenderSlide;
647
674
  getSnapshot(): string | null;
648
675
  /**
649
676
  * 执行下一个主序列动画
@@ -669,6 +696,11 @@ declare class Slide extends Slide_base {
669
696
  * @param val boolean
670
697
  */
671
698
  setInteractive(val: boolean): void;
699
+ /**
700
+ * Set how received synchronization events are scheduled.
701
+ * Changing the policy does not reorder or clear the current pending queue by itself.
702
+ */
703
+ setSyncEventQueuePolicy(policy: SyncEventQueuePolicy): void;
672
704
  /**
673
705
  * Pause playback, asynchronous operation.
674
706
  */
@@ -689,6 +721,10 @@ declare class Slide extends Slide_base {
689
721
  release(callback?: () => void): void;
690
722
  private _doDestroy;
691
723
  private waitLoadEnd;
724
+ /**
725
+ * Preload a slide. Destroying or evicting the pending slide rejects with
726
+ * PreloadCancelledError.
727
+ */
692
728
  preload(index: number): Promise<void>;
693
729
  preloadResource(index: number): Promise<void>;
694
730
  /**
@@ -1008,7 +1044,6 @@ declare class ResizableContainer {
1008
1044
  private whiteboardContainer;
1009
1045
  private slide;
1010
1046
  private scale;
1011
- private resizeObserver;
1012
1047
  private slideWidth;
1013
1048
  private slideHeight;
1014
1049
  private scrollBar;
@@ -1016,7 +1051,7 @@ declare class ResizableContainer {
1016
1051
  private translateX;
1017
1052
  private translateY;
1018
1053
  private enableResize;
1019
- constructor(parent: HTMLElement, context: AppContext<Attributes, MagixEvents, AppOptions>, enableResize: boolean);
1054
+ constructor(parent: HTMLElement, context: AppContext<Attributes, MagixEvents, AppOptions>, enableResize: boolean, _box?: ReadonlyTeleBox);
1020
1055
  getTranslate(): {
1021
1056
  x: number;
1022
1057
  y: number;
@@ -1034,7 +1069,7 @@ declare class ResizableContainer {
1034
1069
  addSlideContainer(slideContainer: HTMLDivElement): void;
1035
1070
  addWhiteboardContainer(whiteboardContainer: HTMLDivElement): void;
1036
1071
  getCurrentScale(): number;
1037
- destroy(): void;
1072
+ destroy(_box?: ReadonlyTeleBox): void;
1038
1073
  }
1039
1074
 
1040
1075
  type MountSlideOptions = Omit<SlideControllerOptions, "context" | "onPageChanged"> & {
@@ -1066,18 +1101,36 @@ declare class SlideDocsViewer {
1066
1101
  protected readonly appId: string;
1067
1102
  protected isViewMounted: boolean;
1068
1103
  protected justSildeReadonly: boolean;
1104
+ protected syncEventQueuePolicy: SyncEventQueuePolicy;
1069
1105
  private enableScale;
1106
+ private boxSizeEventCount;
1107
+ private latestBoxSize;
1108
+ private lastObserverSize;
1109
+ private lastAppliedSize;
1110
+ private lastAppliedSource;
1111
+ private offBoxSizeChange;
1112
+ private contentResizeObserver;
1070
1113
  constructor({ context, box, view, mountSlideController, mountWhiteboard, baseScenePath, appId, urlInterrupter, enableScale, onPagesReady, onNavigate, }: SlideDocsViewerConfig);
1071
1114
  $slide: HTMLDivElement;
1072
1115
  $whiteboardView: HTMLDivElement;
1073
1116
  $overlay: HTMLDivElement;
1074
1117
  resizableContainer: ResizableContainer;
1075
1118
  setJustSildeReadonly(justSildeReadonly: boolean): void;
1119
+ setSyncEventQueuePolicy(policy: SyncEventQueuePolicy): void;
1120
+ protected applyInteractionState(): void;
1076
1121
  render(): void;
1077
1122
  protected renderOverlay(): HTMLDivElement;
1078
1123
  protected renderSlideContainer(): HTMLDivElement;
1079
1124
  protected renderWhiteboardView(): HTMLDivElement;
1080
1125
  mount(): this;
1126
+ private _getContentSize;
1127
+ private _applyResize;
1128
+ private _applyCurrentBoxSize;
1129
+ private _onObserverSize;
1130
+ private _reconnectContentObserver;
1131
+ private _observeContentSize;
1132
+ private _onContextBoxSizeChange;
1133
+ private _registerBoxSizeChange;
1081
1134
  protected onError: ({ error, index }: {
1082
1135
  error: Error;
1083
1136
  index: number;
@@ -1198,7 +1251,7 @@ declare class SlidePreviewer {
1198
1251
  declare const usePlugin: (plugin: any) => any;
1199
1252
  declare const version: string;
1200
1253
 
1201
- interface AppOptions extends Pick<ISlideConfig, "rtcAudio" | "useLocalCache" | "resourceTimeout" | "loaderDelegate" | "urlInterrupter" | "navigatorDelegate" | "fixedFrameSize" | "logger" | "enableGlobalClick" | "skipActionWhenFrozen"> {
1254
+ interface AppOptions extends Pick<ISlideConfig, "rtcAudio" | "useLocalCache" | "resourceTimeout" | "loaderDelegate" | "urlInterrupter" | "navigatorDelegate" | "fixedFrameSize" | "logger" | "enableGlobalClick" | "skipActionWhenFrozen" | "syncEventQueuePolicy"> {
1202
1255
  /** show debug controller */
1203
1256
  debug?: boolean;
1204
1257
  /** scale */
@@ -1247,6 +1300,7 @@ interface AppResult {
1247
1300
  prevPage: () => boolean;
1248
1301
  jumpToPage: (page: number) => boolean;
1249
1302
  setSildeReadonly: (bol: boolean) => void;
1303
+ setSyncEventQueuePolicy: (policy: NonNullable<ISlideConfig["syncEventQueuePolicy"]>) => void;
1250
1304
  onScaleChanged: (cb: (scale: number) => void) => void;
1251
1305
  scaleView: (to: number) => void;
1252
1306
  getViewScale: () => number | undefined;