@netless/app-presentation 0.1.9-beta.5 → 0.1.9-beta.7

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/build.ts CHANGED
@@ -68,6 +68,9 @@ let bundle = await rollup.rollup({
68
68
  },
69
69
  external: Object.keys({
70
70
  '@netless/window-manager': '*',
71
+ '@netless/appliance-plugin': '*',
72
+ '@netless/fastboard': '*',
73
+ 'white-web-sdk': '*',
71
74
  ...peerDependencies,
72
75
  })
73
76
  })
package/dist/index.d.ts CHANGED
@@ -1,13 +1,12 @@
1
- import { View, AppContext, NetlessApp, WindowManager } from '@netless/window-manager';
1
+ import { View, NetlessApp, AppContext, WindowManager } from '@netless/window-manager';
2
+ import * as lodash from 'lodash';
2
3
 
3
4
  /**
4
- * A function that can be called to dispose resources.
5
- */
6
- type Disposer<T = any> = () => T;
7
- /**
8
- * An object that has a `dispose` method to dispose resources.
5
+ * A combination of {@link Disposer} and {@link IDisposable}.
6
+ * It can be called to dispose resources or call the `dispose` method to dispose resources.
9
7
  */
10
- interface IDisposable<T = any> {
8
+ interface DisposableDisposer<T = any> {
9
+ (): T;
11
10
  dispose(): T;
12
11
  }
13
12
  /**
@@ -15,11 +14,13 @@ interface IDisposable<T = any> {
15
14
  */
16
15
  type DisposableType<T = any> = Disposer<T> | IDisposable<T>;
17
16
  /**
18
- * A combination of {@link Disposer} and {@link IDisposable}.
19
- * It can be called to dispose resources or call the `dispose` method to dispose resources.
17
+ * A function that can be called to dispose resources.
20
18
  */
21
- interface DisposableDisposer<T = any> {
22
- (): T;
19
+ type Disposer<T = any> = () => T;
20
+ /**
21
+ * An object that has a `dispose` method to dispose resources.
22
+ */
23
+ interface IDisposable<T = any> {
23
24
  dispose(): T;
24
25
  }
25
26
 
@@ -35,13 +36,13 @@ interface DisposableDisposer<T = any> {
35
36
  */
36
37
  interface DisposableStore extends DisposableDisposer {
37
38
  /**
38
- * Flush and clear all of the {@link Disposer}s and {@link IDisposable}s in the store.
39
+ * @internal
39
40
  */
40
- (): void;
41
+ _disposables_?: Set<DisposableType>;
41
42
  /**
42
- * Get the number of {@link DisposableType}s in the store.
43
+ * Flush and clear all of the {@link Disposer}s and {@link IDisposable}s in the store.
43
44
  */
44
- size(): number;
45
+ (): void;
45
46
  /**
46
47
  * Add a {@link DisposableType} to the store.
47
48
  *
@@ -69,6 +70,23 @@ interface DisposableStore extends DisposableDisposer {
69
70
  * @returns The same array of {@link DisposableType}s.
70
71
  */
71
72
  add<T extends DisposableType>(disposables: T | T[]): T | T[];
73
+ /**
74
+ * Flush and clear all of the {@link Disposer}s and {@link IDisposable}s in the store.
75
+ */
76
+ dispose(this: void): void;
77
+ /**
78
+ * Invoke the {@link DisposableType} and remove it from the store at the specific key.
79
+ *
80
+ * @param disposable The {@link DisposableType} to be flushed. Flush all if omitted.
81
+ */
82
+ flush(disposable?: DisposableType): void;
83
+ /**
84
+ * Check if a {@link DisposableType} is in the store.
85
+ *
86
+ * @param disposable The {@link DisposableType}.
87
+ * @returns `true` if the {@link DisposableType} is in the store, otherwise `false`.
88
+ */
89
+ has(disposable: DisposableType): boolean;
72
90
  /**
73
91
  * Invoke the executor function and add the returned {@link DisposableType} to the store.
74
92
  *
@@ -83,10 +101,10 @@ interface DisposableStore extends DisposableDisposer {
83
101
  *
84
102
  * Do nothing if `null | undefined` is returned or the returned {@link DisposableType} is already in the store.
85
103
  *
86
- * @param executor A function that returns either a {@link DisposableType} or `null`.
87
- * @returns The returned {@link DisposableType}, or `undefined` if the executor returns `null`.
104
+ * @param executor A function that returns either a {@link DisposableType} or `undefined | null`.
105
+ * @returns The returned {@link DisposableType}, or `undefined` if the executor returns `undefined | null`.
88
106
  */
89
- make<T extends DisposableType>(executor: () => T | null | undefined | void): T | void;
107
+ make<T extends DisposableType>(executor: () => null | T | undefined | void): T | void;
90
108
  /**
91
109
  * Invoke the executor function and add each {@link DisposableType} in the returned array to the store.
92
110
  *
@@ -104,7 +122,7 @@ interface DisposableStore extends DisposableDisposer {
104
122
  * @param executor A function that returns either an array of {@link DisposableType}s or `undefined | null`.
105
123
  * @returns The returned array of {@link DisposableType}s, or `undefined` if the executor returns `undefined | null`.
106
124
  */
107
- make<T extends DisposableType[]>(executor: () => T | null | void | undefined): T | void;
125
+ make<T extends DisposableType[]>(executor: () => null | T | undefined | void): T | void;
108
126
  /**
109
127
  * Invoke the executor function and the returned {@link DisposableType}s to the store. Do nothing if `undefined | null` is returned.
110
128
  *
@@ -113,31 +131,18 @@ interface DisposableStore extends DisposableDisposer {
113
131
  * @param executor A function that returns either an array of {@link DisposableType}s or `undefined | null`.
114
132
  * @returns The returned array of {@link DisposableType}s, or `undefined` if the executor returns `undefined | null`.
115
133
  */
116
- make<T extends DisposableType>(executor: () => T | T[] | null | void | undefined): T | T[] | void;
117
- /**
118
- * Check if a {@link DisposableType} is in the store.
119
- *
120
- * @param disposable The {@link DisposableType}.
121
- * @returns `true` if the {@link DisposableType} is in the store, otherwise `false`.
122
- */
123
- has(disposable: DisposableType): boolean;
134
+ make<T extends DisposableType>(executor: () => null | T | T[] | undefined | void): T | T[] | void;
124
135
  /**
125
136
  * Remove the {@link DisposableType} from the store. Does not invoke the removed {@link DisposableType}.
126
137
  *
127
- * @param disposable The {@link DisposableType} to be flushed.
138
+ * @param disposable The {@link DisposableType} to be removed.
128
139
  * @returns `true` if the {@link DisposableType} is found and removed, otherwise `false`.
129
140
  */
130
141
  remove(disposable: DisposableType): boolean;
131
142
  /**
132
- * Invoke the {@link DisposableType} and remove it from the store at the specific key.
133
- *
134
- * @param disposable The {@link DisposableType} to be flushed. Flush all if omitted.
135
- */
136
- flush(disposable?: DisposableType): void;
137
- /**
138
- * Flush and clear all of the {@link Disposer}s and {@link IDisposable}s in the store.
143
+ * Get the number of {@link DisposableType}s in the store.
139
144
  */
140
- dispose(this: void): void;
145
+ size(): number;
141
146
  }
142
147
 
143
148
  interface ILazyLoadInstance {
@@ -304,8 +309,18 @@ declare class Presentation implements IDisposable<void> {
304
309
  private isEditable;
305
310
  }
306
311
 
307
- declare const __inline: string;
308
-
312
+ interface ScrollbarOption {
313
+ appId: string;
314
+ readonly?: boolean;
315
+ getPageSize: () => {
316
+ width: number;
317
+ height: number;
318
+ };
319
+ getWritable: () => boolean;
320
+ getOriginScale: () => number;
321
+ syncView: () => void;
322
+ scrollbarEventCallback?: ScrollbarEventCallback;
323
+ }
309
324
  interface ScrollbarEventCallback {
310
325
  onScrollbarDragStart?: () => void;
311
326
  onScrollbarDragEnd?: () => void;
@@ -313,6 +328,55 @@ interface ScrollbarEventCallback {
313
328
  onScrollbarDragY?: (y: number) => void;
314
329
  onScrollCameraUpdated?: (appid: string, originScale: number, scale: number) => void;
315
330
  }
331
+ declare class Scrollbar {
332
+ readonly namespace = "netless-app-presentation";
333
+ readonly appId: string;
334
+ private container;
335
+ private scrollContainer;
336
+ private option;
337
+ private view;
338
+ private scrollbarContainerX?;
339
+ private scrollbarContainerY?;
340
+ private scrollbarX?;
341
+ private scrollbarY?;
342
+ private draggableX?;
343
+ private draggableY?;
344
+ private cameraCache?;
345
+ private readonly;
346
+ constructor(container: HTMLElement, option: ScrollbarOption, view: View);
347
+ private c;
348
+ setReadonly(bol: boolean): void;
349
+ onCameraUpdated: lodash.DebouncedFunc<() => void>;
350
+ onDragStart: () => void;
351
+ getScrollXRange(camera: {
352
+ scale: number;
353
+ }): {
354
+ minX: number;
355
+ maxX: number;
356
+ };
357
+ getScrollYRange(camera: {
358
+ scale: number;
359
+ }): {
360
+ minY: number;
361
+ maxY: number;
362
+ };
363
+ onDragX: (transformedDrag: {
364
+ x: number;
365
+ y: number;
366
+ }) => void;
367
+ onDragY: (transformedDrag: {
368
+ x: number;
369
+ y: number;
370
+ }) => void;
371
+ onDragEnd: () => void;
372
+ private init;
373
+ destroy(): void;
374
+ moveCamera: (camera: {
375
+ centerX: number;
376
+ centerY: number;
377
+ scale: number;
378
+ }) => void;
379
+ }
316
380
 
317
381
  type Logger = (...data: any[]) => void;
318
382
  interface Viewport {
@@ -347,6 +411,10 @@ interface PresentationAppOptions {
347
411
  /** debounceSync is used to set the presentation debounce sync, it will be used in the presentation, and the presentation will be debounce sync when the app is initialized */
348
412
  debounceSync?: boolean;
349
413
  scrollbarEventCallback?: ScrollbarEventCallback;
414
+ /** goToPageByClick is used to set the presentation go to page by click, it will be used in the presentation, and the presentation will be go to page by click when the app is initialized */
415
+ goToPageByClick?: boolean;
416
+ /** useClipView is used to set the presentation use clip view, it will be used in the presentation, and the presentation will be use clip view when the app is initialized */
417
+ useClipView?: boolean;
350
418
  }
351
419
  interface PresentationController {
352
420
  readonly app: Presentation;
@@ -382,8 +450,14 @@ interface PresentationController {
382
450
  getOriginScale: () => number;
383
451
  /** get the view scale */
384
452
  getScale: () => number;
453
+ /** get the page size */
454
+ getPageSize: () => {
455
+ width: number;
456
+ height: number;
457
+ };
458
+ /** screenshot the current page */
459
+ screenshotCurrentPageAsync: (context: CanvasRenderingContext2D, width?: number, height?: number) => Promise<void>;
385
460
  }
386
-
387
461
  declare const NetlessAppPresentation: NetlessApp<{}, {}, PresentationAppOptions, PresentationController>;
388
462
  type RegisterFn = typeof WindowManager["register"];
389
463
  interface InstallOptions {
@@ -409,4 +483,5 @@ declare const install: (register: RegisterFn, options?: InstallOptions) => Promi
409
483
 
410
484
  declare const version: string;
411
485
 
412
- export { type InstallOptions, type Logger, NetlessAppPresentation, Presentation, type PresentationAppOptions, type PresentationConfig, type PresentationController, type PresentationPage, type RegisterFn, NetlessAppPresentation as default, install, __inline as styles, version };
486
+ export { NetlessAppPresentation, Presentation, Scrollbar, NetlessAppPresentation as default, install, version };
487
+ export type { InstallOptions, Logger, PresentationAppOptions, PresentationConfig, PresentationController, PresentationPage, RegisterFn, ScrollbarEventCallback, ScrollbarOption };