@netless/app-slide 0.0.48 → 0.0.52

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.
@@ -3,6 +3,7 @@ export interface FreezableSlide {
3
3
  freeze: () => void;
4
4
  unfreeze: () => void;
5
5
  }
6
+ export declare let useFreezer: boolean;
6
7
  export declare const FreezerLength = 2;
7
8
  export declare const apps: {
8
9
  map: Map<string, FreezableSlide>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/app-slide",
3
- "version": "0.0.48",
3
+ "version": "0.0.52",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "devDependencies": {
13
13
  "@netless/app-shared": "^0.1.1",
14
- "@netless/slide": "^0.1.51",
14
+ "@netless/slide": "^0.1.56",
15
15
  "@types/color-string": "^1.5.2",
16
16
  "color-string": "^1.9.0",
17
17
  "side-effect-manager": "^0.1.5",
@@ -181,10 +181,7 @@ export class SlideController {
181
181
  if (type === SLIDE_EVENTS.syncDispatch) {
182
182
  this.syncStateOnce();
183
183
  log("[Slide] receive", payload);
184
- // only emit the event if the slide state is sync-ed
185
- if (!this.syncStateOnceFlag) {
186
- this.slide.emit(SLIDE_EVENTS.syncReceive, payload);
187
- }
184
+ this.slide.emit(SLIDE_EVENTS.syncReceive, payload);
188
185
  }
189
186
  }
190
187
  };
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ import type { RoomState } from "white-web-sdk";
3
3
  import type { MountSlideOptions } from "./SlideDocsViewer";
4
4
  import type { Attributes } from "./typings";
5
5
  import type { AddHooks, FreezableSlide } from "./utils/freezer";
6
+ import { useFreezer } from "./utils/freezer";
6
7
 
7
8
  import { SideEffectManager } from "side-effect-manager";
8
9
  import { ensureAttributes } from "@netless/app-shared";
@@ -22,7 +23,7 @@ export { SlidePreviewer, default as previewSlide } from "./SlidePreviewer";
22
23
 
23
24
  export type { Attributes, AddHooks, FreezableSlide };
24
25
 
25
- export const version = "0.0.48";
26
+ export const version = "0.0.52";
26
27
 
27
28
  export { DefaultUrl, apps, FreezerLength, addHooks };
28
29
 
@@ -78,7 +79,7 @@ const SlideApp: NetlessApp<Attributes> = {
78
79
  ...options,
79
80
  onPageChanged,
80
81
  });
81
- apps.set(context.appId, slideController);
82
+ if (useFreezer) apps.set(context.appId, slideController);
82
83
  (logger.apps[context.appId] ||= {}).controller = slideController;
83
84
  if (import.meta.env.DEV) {
84
85
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -125,7 +126,7 @@ const SlideApp: NetlessApp<Attributes> = {
125
126
 
126
127
  context.emitter.on("destroy", () => {
127
128
  log("[Slide]: destroy");
128
- apps.delete(context.appId);
129
+ if (useFreezer) apps.delete(context.appId);
129
130
  sideEffect.flushAll();
130
131
  if (docsViewer) {
131
132
  docsViewer.destroy();
@@ -6,6 +6,7 @@ export interface FreezableSlide {
6
6
  unfreeze: () => void;
7
7
  }
8
8
 
9
+ export let useFreezer = false;
9
10
  export const FreezerLength = 2;
10
11
 
11
12
  export const apps = {
@@ -63,6 +64,7 @@ export type AddHooks = NonNullable<RegisterParams["addHooks"]>;
63
64
  * So that it will automatically freeze the app when it is not in focus.
64
65
  */
65
66
  export const addHooks: AddHooks = emitter => {
67
+ useFreezer = true;
66
68
  emitter.on("focus", ({ appId }) => {
67
69
  apps.focus(appId);
68
70
  });