@netless/app-slide 0.0.22 → 0.0.26

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.0.22",
3
+ "version": "0.0.26",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,8 +11,8 @@
11
11
  ],
12
12
  "devDependencies": {
13
13
  "@netless/app-shared": "^0.1.1",
14
- "@netless/slide": "^0.1.27",
15
- "side-effect-manager": "^0.1.3",
14
+ "@netless/slide": "^0.1.32",
15
+ "side-effect-manager": "^0.1.5",
16
16
  "vanilla-lazyload": "^17.5.0"
17
17
  },
18
18
  "scripts": {
@@ -35,5 +35,14 @@ export function syncSceneWithSlide(
35
35
  room.putScenes(baseScenePath, scenes);
36
36
  }
37
37
 
38
- context.setScenePath(scenePath);
38
+ let currentScenePath: string;
39
+ if (context.getBox().focus) {
40
+ currentScenePath = room.state.sceneState.scenePath;
41
+ } else {
42
+ currentScenePath = context.getView()?.focusScenePath || "";
43
+ }
44
+
45
+ if (currentScenePath !== scenePath) {
46
+ context.setScenePath(scenePath);
47
+ }
39
48
  }
@@ -50,6 +50,8 @@ export class SlideController {
50
50
  private readonly onTransitionEnd: SlideControllerOptions["onTransitionEnd"];
51
51
  private readonly onError: SlideControllerOptions["onError"];
52
52
 
53
+ private syncStateOnceFlag: boolean;
54
+
53
55
  public constructor({
54
56
  context,
55
57
  anchor,
@@ -68,6 +70,8 @@ export class SlideController {
68
70
  this.player = this.room ? undefined : (context.getDisplayer() as Player);
69
71
  this.debug = import.meta.env.DEV || !!context.getAppOptions()?.debug;
70
72
  this.slide = this.createSlide(anchor);
73
+ // the adder does not need to sync state
74
+ this.syncStateOnceFlag = !this.context.isAddApp;
71
75
  this.initialize();
72
76
  }
73
77
 
@@ -92,6 +96,7 @@ export class SlideController {
92
96
  if (this.debug) {
93
97
  console.log("[Slide] init with state", deepClone(state));
94
98
  }
99
+ this.syncStateOnceFlag = false;
95
100
  slide.setSlideState(deepClone(state));
96
101
  } else if (context.isAddApp) {
97
102
  // otherwise, maybe this slide is just added, let the adder kick start first render
@@ -167,12 +172,14 @@ export class SlideController {
167
172
  if (this.debug) {
168
173
  console.log("[Slide] receive", payload);
169
174
  }
170
- this.slide.emit(SLIDE_EVENTS.syncReceive, payload);
175
+ // only emit the event if the slide state is sync-ed
176
+ if (!this.syncStateOnceFlag) {
177
+ this.slide.emit(SLIDE_EVENTS.syncReceive, payload);
178
+ }
171
179
  }
172
180
  }
173
181
  };
174
182
 
175
- private syncStateOnceFlag = true;
176
183
  private syncStateOnce() {
177
184
  // sync state before the first event, so that they can be in the correct order
178
185
  if (this.syncStateOnceFlag) {
@@ -189,6 +196,9 @@ export class SlideController {
189
196
 
190
197
  private onStateChange = (state: SlideState) => {
191
198
  if (this.context.getIsWritable()) {
199
+ if (import.meta.env.DEV) {
200
+ console.log("[Slide] state change", JSON.stringify(state, null, 2));
201
+ }
192
202
  this.context.updateAttributes(["state"], state);
193
203
  }
194
204
  };
@@ -239,6 +249,7 @@ export class SlideController {
239
249
  autoFPS: true,
240
250
  autoResolution: true,
241
251
  resolution: this.context.getAppOptions()?.resolution,
252
+ transactionBgColor: this.context.getAppOptions()?.bgColor || "#f9f9fc",
242
253
  },
243
254
  timestamp: this.timestamp,
244
255
  });
@@ -255,7 +266,7 @@ export class SlideController {
255
266
  this.sideEffect.flushAll();
256
267
  if (!this.destroyed) {
257
268
  if (this.debug) {
258
- console.log("[Slide] destroy (once)");
269
+ console.log("[Slide] destroy slide (once)");
259
270
  }
260
271
  this.slide.destroy();
261
272
  this.destroyed = true;
package/src/index.ts CHANGED
@@ -70,7 +70,7 @@ const SlideApp: NetlessApp<Attributes> = {
70
70
  box,
71
71
  view,
72
72
  mountSlideController,
73
- mountWhiteboard: dom => context.mountView(dom),
73
+ mountWhiteboard: context.mountView.bind(context),
74
74
  });
75
75
 
76
76
  if (import.meta.env.DEV) {