@netless/app-slide 0.2.1 → 0.2.4

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.1",
3
+ "version": "0.2.4",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,12 +10,12 @@
10
10
  "README-zh.md"
11
11
  ],
12
12
  "devDependencies": {
13
- "@netless/app-shared": "^0.1.1",
14
- "@netless/slide": "^0.3.6",
13
+ "@netless/app-shared": "0.1.2",
14
+ "@netless/slide": "^0.5.10",
15
15
  "@types/color-string": "^1.5.2",
16
- "color-string": "^1.9.0",
17
- "side-effect-manager": "^0.1.5",
18
- "vanilla-lazyload": "^17.8.2"
16
+ "color-string": "^1.9.1",
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,12 +256,13 @@ export class SlideController {
255
256
  controller: logger.enable,
256
257
  enableGlobalClick: true,
257
258
  renderOptions: {
258
- minFPS: this.context.getAppOptions()?.minFPS || 25,
259
- maxFPS: this.context.getAppOptions()?.maxFPS || 30,
260
- autoFPS: this.context.getAppOptions()?.autoFPS ?? true,
261
- autoResolution: this.context.getAppOptions()?.autoResolution ?? true,
262
- resolution: this.context.getAppOptions()?.resolution,
263
- transactionBgColor: this.context.getAppOptions()?.bgColor || cachedGetBgColor(anchor),
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
  },
265
267
  timestamp: this.timestamp,
266
268
  });
@@ -294,33 +296,12 @@ export class SlideController {
294
296
 
295
297
  public isFrozen = false;
296
298
  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
299
 
315
300
  public freeze = () => {
301
+ this.isFrozen = true;
316
302
  if (this.ready) {
317
303
  log("[Slide] freeze", this.context.appId);
318
- if (this.freezePromise) {
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
- }
304
+ this.slide.frozen();
324
305
  } else {
325
306
  this._toFreeze = 1;
326
307
  }
@@ -328,14 +309,10 @@ export class SlideController {
328
309
 
329
310
  public unfreeze = async () => {
330
311
  if (!this.visible) return;
312
+ this.isFrozen = false;
331
313
  if (this.ready) {
332
314
  log("[Slide] unfreeze", this.context.appId);
333
- if (this.freezePromise) {
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
- }
315
+ this.slide.release();
339
316
  } else {
340
317
  this._toFreeze = -1;
341
318
  }
@@ -343,7 +320,7 @@ export class SlideController {
343
320
 
344
321
  private onVisibilityChange = async () => {
345
322
  if (!(this.visible = document.visibilityState === "visible")) {
346
- this.savedIsFrozen = this.freezePromise ? this._toFreeze === 1 : this.isFrozen;
323
+ this.savedIsFrozen = this.isFrozen;
347
324
  log("[Slide] freeze because tab becomes invisible");
348
325
  this.freeze();
349
326
  } else {
@@ -117,7 +117,7 @@ export class SlidePreviewer {
117
117
 
118
118
  this.slide = new Slide({
119
119
  anchor: this.$slide,
120
- interactive: false,
120
+ interactive: true,
121
121
  mode: "local",
122
122
  resize: true,
123
123
  controller: this.debug,
package/src/index.ts CHANGED
@@ -41,6 +41,8 @@ export interface AppOptions {
41
41
  autoFPS?: boolean;
42
42
  /** whether to re-scale automatically @default true */
43
43
  autoResolution?: boolean;
44
+ /** 1~4, default: 3 */
45
+ maxResolutionLevel?: number;
44
46
  }
45
47
 
46
48
  export interface Controller {