@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/dist/index.d.ts +47 -42
- package/dist/main.cjs.js +34 -34
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +21 -8
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +34 -34
- package/dist/main.iife.js.map +1 -1
- package/package.json +2 -2
- package/src/SlideController/index.ts +27 -27
- package/src/SlideDocsViewer/index.ts +9 -9
- package/src/SlidePreviewer/index.ts +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/app-slide",
|
|
3
|
-
"version": "0.2.
|
|
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.
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
protected readonly room?: Room;
|
|
66
|
+
protected readonly player?: Player;
|
|
67
|
+
protected readonly sideEffect = new SideEffectManager();
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
75
|
+
protected syncStateOnceFlag: boolean;
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
protected visible: boolean;
|
|
78
|
+
protected savedIsFrozen: boolean;
|
|
79
79
|
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
152
|
+
protected initialize() {
|
|
153
153
|
this.registerEventListeners();
|
|
154
154
|
this.kickStart();
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
266
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
225
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
51
|
+
protected previewList: string[] = [];
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
protected readonly sideEffect = new SideEffectManager();
|
|
54
54
|
|
|
55
55
|
public ready = false;
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
186
|
+
protected destroyed = false;
|
|
187
187
|
public destroy() {
|
|
188
188
|
this.sideEffect.flushAll();
|
|
189
189
|
if (this.slide && !this.destroyed) {
|