@netless/app-slide 0.2.62 → 0.2.64
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/LICENSE +21 -0
- package/dist/index.d.ts +3 -2
- package/dist/main.cjs.js +208 -183
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1315 -1274
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +151 -126
- package/dist/main.iife.js.map +1 -1
- package/package.json +9 -9
- package/src/SlideController/index.ts +12 -8
- package/src/SlideDocsViewer/index.ts +22 -22
package/package.json
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/app-slide",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.64",
|
|
4
4
|
"main": "dist/main.cjs.js",
|
|
5
5
|
"module": "dist/main.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"types": "node scripts/build-types.mjs",
|
|
9
|
-
"build": "vite build && npm run types",
|
|
10
|
-
"build:dev": "vite build --mode development && npm run types",
|
|
11
|
-
"cleanup": "rimraf ./dist"
|
|
12
|
-
},
|
|
13
7
|
"files": [
|
|
14
8
|
"src",
|
|
15
9
|
"dist",
|
|
16
10
|
"README-zh.md"
|
|
17
11
|
],
|
|
18
12
|
"devDependencies": {
|
|
19
|
-
"@netless/slide": "^1.4.
|
|
13
|
+
"@netless/slide": "^1.4.18",
|
|
20
14
|
"@types/color-string": "^1.5.2",
|
|
21
15
|
"color-string": "^1.9.1",
|
|
22
16
|
"jspdf": "2.5.1",
|
|
@@ -30,5 +24,11 @@
|
|
|
30
24
|
"jspdf": {
|
|
31
25
|
"optional": true
|
|
32
26
|
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"types": "node scripts/build-types.mjs",
|
|
30
|
+
"build": "vite build && npm run types",
|
|
31
|
+
"build:dev": "vite build --mode development && npm run types",
|
|
32
|
+
"cleanup": "rimraf ./dist"
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
|
@@ -120,11 +120,11 @@ export class SlideController {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
public ready = false;
|
|
123
|
-
private resolveReady!: () => void;
|
|
123
|
+
private resolveReady!: (index: number) => void;
|
|
124
124
|
public readonly readyPromise = new Promise<void>(resolve => {
|
|
125
|
-
this.resolveReady = () => {
|
|
125
|
+
this.resolveReady = (slideIndex) => {
|
|
126
126
|
if (this.ready) {
|
|
127
|
-
log("[Slide] render end");
|
|
127
|
+
log("[Slide] render end", slideIndex);
|
|
128
128
|
} else {
|
|
129
129
|
setTimeout(() => {
|
|
130
130
|
this.ready = true;
|
|
@@ -370,16 +370,20 @@ export class SlideController {
|
|
|
370
370
|
if (!this.visible) return;
|
|
371
371
|
this.isFrozen = false;
|
|
372
372
|
if (this.ready) {
|
|
373
|
+
let isNeedSyncState = false;
|
|
373
374
|
log("[Slide] unfreeze", this.context.appId);
|
|
374
|
-
if (this.invisibleBehavior === "frozen") {
|
|
375
|
+
if (this.invisibleBehavior === "frozen" && !this.slide.view) {
|
|
375
376
|
this.slide.release();
|
|
377
|
+
isNeedSyncState = true;
|
|
376
378
|
} else {
|
|
377
379
|
this.slide.resume();
|
|
378
380
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
381
|
+
if (isNeedSyncState) {
|
|
382
|
+
const currentSlideIndex = this.context.storage.state.state?.currentSlideIndex;
|
|
383
|
+
if (currentSlideIndex) {
|
|
384
|
+
log("[Slide] sync storage", currentSlideIndex);
|
|
385
|
+
this.slide.setSlideState({ currentSlideIndex });
|
|
386
|
+
}
|
|
383
387
|
}
|
|
384
388
|
} else {
|
|
385
389
|
this._toFreeze = -1;
|
|
@@ -39,7 +39,7 @@ export interface SavePdfConfig {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export class SlideDocsViewer {
|
|
42
|
-
readonly context: AppContext<Attributes, MagixEvents, AppOptions
|
|
42
|
+
readonly context: AppContext<Attributes, MagixEvents, AppOptions>;
|
|
43
43
|
public viewer: DocsViewer;
|
|
44
44
|
public slideController: SlideController | null = null;
|
|
45
45
|
|
|
@@ -209,7 +209,7 @@ export class SlideDocsViewer {
|
|
|
209
209
|
|
|
210
210
|
public onPageChanged = () => {
|
|
211
211
|
clearTimeout(this._onPageChangedTimer);
|
|
212
|
-
this._onPageChangedTimer = setTimeout(this._onPageChanged, 200);
|
|
212
|
+
this._onPageChangedTimer = setTimeout(this._onPageChanged, 200) as unknown as number;
|
|
213
213
|
};
|
|
214
214
|
|
|
215
215
|
private _onPageChangedTimer = 0;
|
|
@@ -313,26 +313,26 @@ export class SlideDocsViewer {
|
|
|
313
313
|
slideWidth: number,
|
|
314
314
|
slideHeight: number
|
|
315
315
|
) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
316
|
+
const camera = {
|
|
317
|
+
centerX: 0,
|
|
318
|
+
centerY: 0,
|
|
319
|
+
scale: Math.min(canvas.width / slideWidth, canvas.height / slideHeight),
|
|
320
|
+
};
|
|
321
|
+
const scenePath = `${this.baseScenePath}/${pageIndex}`;
|
|
322
|
+
// appliancePlugin is a performance optimization for whiteboard;
|
|
323
|
+
const windowManger = (this.context as any).manager.windowManger as any;
|
|
324
|
+
if (windowManger._appliancePlugin) {
|
|
325
|
+
await windowManger._appliancePlugin.screenshotToCanvasAsync(
|
|
326
|
+
ctx,
|
|
327
|
+
scenePath,
|
|
328
|
+
canvas.width,
|
|
329
|
+
canvas.height,
|
|
330
|
+
camera
|
|
331
|
+
);
|
|
332
|
+
} else {
|
|
333
|
+
// Render whiteboard into canvas, and it must fit the slide size.
|
|
334
|
+
this.whiteboardView.screenshotToCanvas(ctx, scenePath, canvas.width, canvas.height, camera);
|
|
335
|
+
}
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
private reportProgress(progress: number, result: { pdf: ArrayBuffer; title: string } | null) {
|