@netless/app-slide 0.2.81 → 0.2.82

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/app-slide",
3
- "version": "0.2.81",
3
+ "version": "0.2.82",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "README-zh.md"
11
11
  ],
12
12
  "devDependencies": {
13
- "@netless/slide": "1.4.38",
13
+ "@netless/slide": "1.4.40",
14
14
  "@types/color-string": "^1.5.2",
15
15
  "color-string": "^1.9.1",
16
16
  "jspdf": "2.5.1",
@@ -62,22 +62,22 @@ export class SlideController {
62
62
  public readonly onRenderError?: (error: Error, pageIndex: number) => void;
63
63
  public readonly onNavigate: (index: number, origin?: string) => void;
64
64
 
65
- private readonly room?: Room;
66
- private readonly player?: Player;
67
- private readonly sideEffect = new SideEffectManager();
65
+ protected readonly room?: Room;
66
+ protected readonly player?: Player;
67
+ protected readonly sideEffect = new SideEffectManager();
68
68
 
69
- private readonly onRenderStart: SlideControllerOptions["onRenderStart"];
70
- private readonly onPageChanged: SlideControllerOptions["onPageChanged"];
71
- private readonly onTransitionStart: SlideControllerOptions["onTransitionStart"];
72
- private readonly onTransitionEnd: SlideControllerOptions["onTransitionEnd"];
73
- private readonly onError: SlideControllerOptions["onError"];
69
+ protected readonly onRenderStart: SlideControllerOptions["onRenderStart"];
70
+ protected readonly onPageChanged: SlideControllerOptions["onPageChanged"];
71
+ protected readonly onTransitionStart: SlideControllerOptions["onTransitionStart"];
72
+ protected readonly onTransitionEnd: SlideControllerOptions["onTransitionEnd"];
73
+ protected readonly onError: SlideControllerOptions["onError"];
74
74
 
75
- private syncStateOnceFlag: boolean;
75
+ protected syncStateOnceFlag: boolean;
76
76
 
77
- private visible: boolean;
78
- private savedIsFrozen: boolean;
77
+ protected visible: boolean;
78
+ protected savedIsFrozen: boolean;
79
79
 
80
- private invisibleBehavior: "frozen" | "pause";
80
+ protected invisibleBehavior: "frozen" | "pause";
81
81
 
82
82
  // 签名后的预览图
83
83
  public previewList: string[] = [];
@@ -121,7 +121,7 @@ export class SlideController {
121
121
  }
122
122
 
123
123
  public ready = false;
124
- private resolveReady!: (index: number) => void;
124
+ protected resolveReady!: (index: number) => void;
125
125
  public readonly readyPromise = new Promise<void>(resolve => {
126
126
  this.resolveReady = slideIndex => {
127
127
  if (this.ready) {
@@ -149,12 +149,12 @@ export class SlideController {
149
149
  }
150
150
  }
151
151
 
152
- private initialize() {
152
+ protected initialize() {
153
153
  this.registerEventListeners();
154
154
  this.kickStart();
155
155
  }
156
156
 
157
- private kickStart() {
157
+ protected kickStart() {
158
158
  const { context, slide } = this;
159
159
  if (context.getIsWritable()) {
160
160
  context.storage.ensureState(EmptyAttributes);
@@ -182,7 +182,7 @@ export class SlideController {
182
182
  this.pollReadyState();
183
183
  }
184
184
 
185
- private registerEventListeners() {
185
+ protected registerEventListeners() {
186
186
  const { context, slide } = this;
187
187
 
188
188
  // it is possible that we miss the first `renderSlide(1)` event
@@ -220,7 +220,7 @@ export class SlideController {
220
220
  });
221
221
  }
222
222
 
223
- private onSyncDispatch = (event: SyncEvent) => {
223
+ protected onSyncDispatch = (event: SyncEvent) => {
224
224
  if (this.context.getIsWritable() && this.room) {
225
225
  const payload: MagixPayload = {
226
226
  type: SLIDE_EVENTS.syncDispatch,
@@ -231,7 +231,7 @@ export class SlideController {
231
231
  }
232
232
  };
233
233
 
234
- private magixEventListener: MagixEventListener = ev => {
234
+ protected magixEventListener: MagixEventListener = ev => {
235
235
  const { type, payload } = ev.payload;
236
236
  if (type === SLIDE_EVENTS.syncDispatch) {
237
237
  this.syncStateOnce();
@@ -240,7 +240,7 @@ export class SlideController {
240
240
  }
241
241
  };
242
242
 
243
- private syncStateOnce() {
243
+ protected syncStateOnce() {
244
244
  // sync state before the first event, so that they can be in the correct order
245
245
  if (this.syncStateOnceFlag) {
246
246
  if (this.context.getIsWritable()) {
@@ -255,15 +255,15 @@ export class SlideController {
255
255
  }
256
256
  }
257
257
 
258
- private onStateChange = (state: SlideState) => {
258
+ protected onStateChange = (state: SlideState) => {
259
259
  if (this.context.getIsWritable()) {
260
260
  verbose("[Slide] state change", JSON.stringify(state, null, 2));
261
261
  this.context.storage.setState({ state });
262
262
  }
263
263
  };
264
264
 
265
- private pollCount = 0;
266
- private pollReadyState = () => {
265
+ protected pollCount = 0;
266
+ protected pollReadyState = () => {
267
267
  if (this.ready) {
268
268
  if (this._toFreeze === 1) {
269
269
  this.freeze();
@@ -281,7 +281,7 @@ export class SlideController {
281
281
 
282
282
  // cache `slideCount`, because once the slide is frozen,
283
283
  // the `slideCount` will be 0
284
- private _pageCount = 0;
284
+ protected _pageCount = 0;
285
285
  public get pageCount() {
286
286
  if (this._pageCount > 0) return this._pageCount;
287
287
  this._pageCount = this.slide.slideCount;
@@ -292,7 +292,7 @@ export class SlideController {
292
292
  return this.slide.slideState.currentSlideIndex;
293
293
  }
294
294
 
295
- private createSlide(anchor: HTMLDivElement, defaults: Partial<ISlideConfig> = {}) {
295
+ protected createSlide(anchor: HTMLDivElement, defaults: Partial<ISlideConfig> = {}) {
296
296
  const options = this.context.getAppOptions() || {};
297
297
  const attribute = this.context.storage.state;
298
298
  const slide = new Slide({
@@ -332,7 +332,7 @@ export class SlideController {
332
332
  return slide;
333
333
  }
334
334
 
335
- private destroyed = false;
335
+ protected destroyed = false;
336
336
 
337
337
  public destroy() {
338
338
  this.sideEffect.flushAll();
@@ -354,7 +354,7 @@ export class SlideController {
354
354
  };
355
355
 
356
356
  public isFrozen = false;
357
- private _toFreeze: -1 | 0 | 1 = 0; // -1: unfreeze, 0: no change, 1: freeze
357
+ protected _toFreeze: -1 | 0 | 1 = 0; // -1: unfreeze, 0: no change, 1: freeze
358
358
 
359
359
  public freeze = () => {
360
360
  this.isFrozen = true;
@@ -394,7 +394,7 @@ export class SlideController {
394
394
  }
395
395
  };
396
396
 
397
- private onVisibilityChange = async () => {
397
+ protected onVisibilityChange = async () => {
398
398
  if (!(this.visible = document.visibilityState === "visible")) {
399
399
  this.savedIsFrozen = this.isFrozen;
400
400
  log("[Slide] freeze because tab becomes invisible");
@@ -48,10 +48,10 @@ export class SlideDocsViewer {
48
48
  protected readonly mountSlideController: SlideDocsViewerConfig["mountSlideController"];
49
49
  protected readonly mountWhiteboard: SlideDocsViewerConfig["mountWhiteboard"];
50
50
  protected readonly onNavigate: (index: number, origin?: string) => void;
51
- private readonly baseScenePath: string;
52
- private readonly appId: string;
53
- private isViewMounted = false;
54
- private justSildeReadonly = false;
51
+ protected readonly baseScenePath: string;
52
+ protected readonly appId: string;
53
+ protected isViewMounted = false;
54
+ protected justSildeReadonly = false;
55
55
 
56
56
  public constructor({
57
57
  context,
@@ -221,8 +221,8 @@ export class SlideDocsViewer {
221
221
  this._onPageChangedTimer = setTimeout(this._onPageChanged, 200) as unknown as number;
222
222
  };
223
223
 
224
- private _onPageChangedTimer = 0;
225
- private _onPageChanged = () => {
224
+ protected _onPageChangedTimer = 0;
225
+ protected _onPageChanged = () => {
226
226
  this.$overlay.style.opacity = "";
227
227
  this.$whiteboardView.classList.remove(this.wrapClassName("wb-view-hidden"));
228
228
  };
@@ -315,7 +315,7 @@ export class SlideDocsViewer {
315
315
 
316
316
  protected namespace = "netless-app-slide";
317
317
 
318
- private async getWhiteSnapshot(
318
+ protected async getWhiteSnapshot(
319
319
  pageIndex: number,
320
320
  canvas: HTMLCanvasElement,
321
321
  ctx: CanvasRenderingContext2D,
@@ -344,7 +344,7 @@ export class SlideDocsViewer {
344
344
  }
345
345
  }
346
346
 
347
- private reportProgress(progress: number, result: { pdf: ArrayBuffer; title: string } | null) {
347
+ protected reportProgress(progress: number, result: { pdf: ArrayBuffer; title: string } | null) {
348
348
  window.postMessage({
349
349
  type: "@netless/_result_save_pdf_",
350
350
  appId: this.appId,
@@ -353,7 +353,7 @@ export class SlideDocsViewer {
353
353
  });
354
354
  }
355
355
 
356
- private toPdf = async () => {
356
+ protected toPdf = async () => {
357
357
  if (!this.slideController) {
358
358
  this.reportProgress(100, null);
359
359
  return;
@@ -48,12 +48,12 @@ export class SlidePreviewer {
48
48
 
49
49
  public $slide!: HTMLDivElement;
50
50
 
51
- private previewList: string[] = [];
51
+ protected previewList: string[] = [];
52
52
 
53
- private readonly sideEffect = new SideEffectManager();
53
+ protected readonly sideEffect = new SideEffectManager();
54
54
 
55
55
  public ready = false;
56
- private resolveReady!: () => void;
56
+ protected resolveReady!: () => void;
57
57
  public readonly readyPromise = new Promise<void>(resolve => {
58
58
  this.resolveReady = () => {
59
59
  this.ready = true;
@@ -94,7 +94,7 @@ export class SlidePreviewer {
94
94
  );
95
95
  }
96
96
 
97
- private hotkeyListener = (ev: KeyboardEvent) => {
97
+ protected hotkeyListener = (ev: KeyboardEvent) => {
98
98
  if (this.slide) {
99
99
  switch (ev.key) {
100
100
  case "ArrowUp":
@@ -183,7 +183,7 @@ export class SlidePreviewer {
183
183
  console.warn("[Slide] render error", error);
184
184
  };
185
185
 
186
- private destroyed = false;
186
+ protected destroyed = false;
187
187
  public destroy() {
188
188
  this.sideEffect.flushAll();
189
189
  if (this.slide && !this.destroyed) {