@netless/app-slide 0.2.2 → 0.2.5
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/SlideController/index.d.ts +0 -2
- package/dist/index.d.ts +12 -2
- package/dist/main.cjs.js +229 -229
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +5888 -6907
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +229 -229
- package/dist/main.iife.js.map +1 -1
- package/dist/typings.d.ts +0 -2
- package/package.json +4 -4
- package/src/SlideController/index.ts +20 -36
- package/src/index.ts +24 -2
- package/src/typings.ts +0 -2
package/dist/typings.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/app-slide",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"main": "dist/main.cjs.js",
|
|
5
5
|
"module": "dist/main.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
],
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@netless/app-shared": "0.1.2",
|
|
14
|
-
"@netless/slide": "^0.
|
|
14
|
+
"@netless/slide": "^0.5.13",
|
|
15
15
|
"@types/color-string": "^1.5.2",
|
|
16
16
|
"color-string": "^1.9.1",
|
|
17
|
-
"side-effect-manager": "^1.1.
|
|
18
|
-
"vanilla-lazyload": "^17.8.
|
|
17
|
+
"side-effect-manager": "^1.1.1",
|
|
18
|
+
"vanilla-lazyload": "^17.8.3"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
@@ -247,6 +247,7 @@ export class SlideController {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
private createSlide(anchor: HTMLDivElement) {
|
|
250
|
+
const options = this.context.getAppOptions() || {};
|
|
250
251
|
const slide = new Slide({
|
|
251
252
|
anchor,
|
|
252
253
|
interactive: true,
|
|
@@ -255,13 +256,21 @@ export class SlideController {
|
|
|
255
256
|
controller: logger.enable,
|
|
256
257
|
enableGlobalClick: true,
|
|
257
258
|
renderOptions: {
|
|
258
|
-
minFPS:
|
|
259
|
-
maxFPS:
|
|
260
|
-
autoFPS:
|
|
261
|
-
autoResolution:
|
|
262
|
-
resolution:
|
|
263
|
-
transactionBgColor:
|
|
259
|
+
minFPS: options.minFPS || 25,
|
|
260
|
+
maxFPS: options.maxFPS || 30,
|
|
261
|
+
autoFPS: options.autoFPS ?? true,
|
|
262
|
+
autoResolution: options.autoResolution ?? true,
|
|
263
|
+
resolution: options.resolution,
|
|
264
|
+
transactionBgColor: options.bgColor || cachedGetBgColor(anchor),
|
|
265
|
+
maxResolutionLevel: options.maxResolutionLevel,
|
|
264
266
|
},
|
|
267
|
+
fixedFrameSize: options.fixedFrameSize,
|
|
268
|
+
loaderDelegate: options.loaderDelegate,
|
|
269
|
+
navigatorDelegate: options.navigatorDelegate,
|
|
270
|
+
resourceTimeout: options.resourceTimeout,
|
|
271
|
+
rtcAudio: options.rtcAudio,
|
|
272
|
+
useLocalCache: options.useLocalCache,
|
|
273
|
+
logger: options.logger,
|
|
265
274
|
timestamp: this.timestamp,
|
|
266
275
|
});
|
|
267
276
|
if (import.meta.env.DEV) {
|
|
@@ -294,33 +303,12 @@ export class SlideController {
|
|
|
294
303
|
|
|
295
304
|
public isFrozen = false;
|
|
296
305
|
private _toFreeze: -1 | 0 | 1 = 0; // -1: unfreeze, 0: no change, 1: freeze
|
|
297
|
-
private freezePromise: Promise<void> | null = null;
|
|
298
|
-
|
|
299
|
-
private afterFreeze(from: -1 | 1) {
|
|
300
|
-
if (from === 1) {
|
|
301
|
-
this.isFrozen = true;
|
|
302
|
-
this.freezePromise = null;
|
|
303
|
-
if (this._toFreeze === -1) {
|
|
304
|
-
this.unfreeze();
|
|
305
|
-
}
|
|
306
|
-
} else if (from === -1) {
|
|
307
|
-
this.isFrozen = false;
|
|
308
|
-
this.freezePromise = null;
|
|
309
|
-
if (this._toFreeze === 1) {
|
|
310
|
-
this.freeze();
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
306
|
|
|
315
307
|
public freeze = () => {
|
|
308
|
+
this.isFrozen = true;
|
|
316
309
|
if (this.ready) {
|
|
317
310
|
log("[Slide] freeze", this.context.appId);
|
|
318
|
-
|
|
319
|
-
this._toFreeze = 1;
|
|
320
|
-
} else if (!this.isFrozen) {
|
|
321
|
-
this._toFreeze = 0;
|
|
322
|
-
this.freezePromise = this.slide.frozen().then(this.afterFreeze.bind(this, 1));
|
|
323
|
-
}
|
|
311
|
+
this.slide.frozen();
|
|
324
312
|
} else {
|
|
325
313
|
this._toFreeze = 1;
|
|
326
314
|
}
|
|
@@ -328,14 +316,10 @@ export class SlideController {
|
|
|
328
316
|
|
|
329
317
|
public unfreeze = async () => {
|
|
330
318
|
if (!this.visible) return;
|
|
319
|
+
this.isFrozen = false;
|
|
331
320
|
if (this.ready) {
|
|
332
321
|
log("[Slide] unfreeze", this.context.appId);
|
|
333
|
-
|
|
334
|
-
this._toFreeze = -1;
|
|
335
|
-
} else if (this.isFrozen) {
|
|
336
|
-
this._toFreeze = 0;
|
|
337
|
-
this.freezePromise = this.slide.release().then(this.afterFreeze.bind(this, -1));
|
|
338
|
-
}
|
|
322
|
+
this.slide.release();
|
|
339
323
|
} else {
|
|
340
324
|
this._toFreeze = -1;
|
|
341
325
|
}
|
|
@@ -343,7 +327,7 @@ export class SlideController {
|
|
|
343
327
|
|
|
344
328
|
private onVisibilityChange = async () => {
|
|
345
329
|
if (!(this.visible = document.visibilityState === "visible")) {
|
|
346
|
-
this.savedIsFrozen = this.
|
|
330
|
+
this.savedIsFrozen = this.isFrozen;
|
|
347
331
|
log("[Slide] freeze because tab becomes invisible");
|
|
348
332
|
this.freeze();
|
|
349
333
|
} else {
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { NetlessApp } from "@netless/window-manager";
|
|
2
2
|
import type { RoomState } from "white-web-sdk";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ISlideConfig } from "@netless/slide";
|
|
4
4
|
import type { MountSlideOptions } from "./SlideDocsViewer";
|
|
5
5
|
import type { Attributes, MagixEvents } from "./typings";
|
|
6
6
|
import type { AddHooks, FreezableSlide } from "./utils/freezer";
|
|
7
7
|
|
|
8
|
+
import { Slide } from "@netless/slide";
|
|
8
9
|
import { SideEffectManager } from "side-effect-manager";
|
|
9
10
|
import {
|
|
10
11
|
DefaultUrl,
|
|
@@ -21,12 +22,25 @@ export type { PreviewParams } from "./SlidePreviewer";
|
|
|
21
22
|
export { SlidePreviewer, default as previewSlide } from "./SlidePreviewer";
|
|
22
23
|
|
|
23
24
|
export type { Attributes, AddHooks, FreezableSlide };
|
|
25
|
+
export { Slide };
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
export const usePlugin: (plugin: any) => any = /* @__PURE__ */ Slide.usePlugin.bind(Slide);
|
|
24
28
|
|
|
25
29
|
export const version = __APP_VERSION__;
|
|
26
30
|
|
|
27
31
|
export { DefaultUrl, apps, FreezerLength, addHooks };
|
|
28
32
|
|
|
29
|
-
export interface AppOptions
|
|
33
|
+
export interface AppOptions
|
|
34
|
+
extends Pick<
|
|
35
|
+
ISlideConfig,
|
|
36
|
+
| "rtcAudio"
|
|
37
|
+
| "useLocalCache"
|
|
38
|
+
| "resourceTimeout"
|
|
39
|
+
| "loaderDelegate"
|
|
40
|
+
| "navigatorDelegate"
|
|
41
|
+
| "fixedFrameSize"
|
|
42
|
+
| "logger"
|
|
43
|
+
> {
|
|
30
44
|
/** show debug controller */
|
|
31
45
|
debug?: boolean;
|
|
32
46
|
/** scale */
|
|
@@ -41,6 +55,14 @@ export interface AppOptions {
|
|
|
41
55
|
autoFPS?: boolean;
|
|
42
56
|
/** whether to re-scale automatically @default true */
|
|
43
57
|
autoResolution?: boolean;
|
|
58
|
+
/** 1~4, default: 3 */
|
|
59
|
+
maxResolutionLevel?: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ILogger {
|
|
63
|
+
info?(msg: string): void;
|
|
64
|
+
error?(msg: string): void;
|
|
65
|
+
warn?(msg: string): void;
|
|
44
66
|
}
|
|
45
67
|
|
|
46
68
|
export interface Controller {
|