@netless/app-slide 0.2.100-alpha.1 → 0.2.100

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,11 +1,10 @@
1
1
  {
2
2
  "name": "@netless/app-slide",
3
- "version": "0.2.100-alpha.1",
3
+ "version": "0.2.100",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.es.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "test": "node __tests__/recovery.test.js",
9
8
  "types": "node scripts/build-types.mjs",
10
9
  "build": "vite build && npm run types",
11
10
  "build:dev": "vite build --mode development && npm run types",
@@ -17,7 +16,7 @@
17
16
  "README-zh.md"
18
17
  ],
19
18
  "devDependencies": {
20
- "@netless/slide": "1.4.55-alpha.4",
19
+ "@netless/slide": "1.4.55",
21
20
  "@types/color-string": "^1.5.2",
22
21
  "color-string": "^1.9.1",
23
22
  "jspdf": "2.5.1",
@@ -19,7 +19,6 @@ import { clamp } from "../utils/helpers";
19
19
  import { cachedGetBgColor } from "../utils/bgcolor";
20
20
  import { log, verbose, setRoomLogger } from "../utils/logger";
21
21
  import { getRoomTracker } from "../utils/tracker";
22
- import { releaseAndRestoreSlide } from "./recovery";
23
22
  export { syncSceneWithSlide, createDocsViewerPages } from "./helpers";
24
23
 
25
24
  export const DefaultUrl = "https://convertcdn.netless.link/dynamicConvert";
@@ -396,20 +395,20 @@ export class SlideControllerBase {
396
395
  if (!this.visible) return;
397
396
  this.isFrozen = false;
398
397
  if (this.ready) {
398
+ let isNeedSyncState = false;
399
399
  log("[Slide] unfreeze", this.context.appId);
400
- try {
401
- if (this.invisibleBehavior !== "frozen") {
402
- this.slide.resume();
403
- return;
400
+ if (this.invisibleBehavior === "frozen") {
401
+ this.slide.release();
402
+ isNeedSyncState = true;
403
+ } else {
404
+ this.slide.resume();
405
+ }
406
+ if (isNeedSyncState) {
407
+ const state = this.context.storage.state.state;
408
+ if (state) {
409
+ log("[Slide] sync storage", JSON.stringify(state));
410
+ this.slide.setSlideState(state);
404
411
  }
405
-
406
- await releaseAndRestoreSlide(
407
- this.slide,
408
- () => this.context.storage.state.state,
409
- state => log("[Slide] sync storage", JSON.stringify(state))
410
- );
411
- } catch (error) {
412
- log("[Slide] unfreeze failed", error);
413
412
  }
414
413
  } else {
415
414
  this._toFreeze = -1;
@@ -1,17 +0,0 @@
1
- export interface RecoverableSlide<State> {
2
- release: (callback: () => void) => void;
3
- setSlideState: (state: State) => Promise<void>;
4
- }
5
-
6
- export async function releaseAndRestoreSlide<State>(
7
- slide: RecoverableSlide<State>,
8
- getLatestState: () => State | null | undefined,
9
- onRestore?: (state: State) => void
10
- ): Promise<void> {
11
- await new Promise<void>(resolve => slide.release(resolve));
12
- const state = getLatestState();
13
- if (state) {
14
- onRestore?.(state);
15
- await slide.setSlideState(state);
16
- }
17
- }