@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/dist/SlideController/index.d.ts +1 -1
- package/dist/main.cjs.js +345 -222
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +22607 -22454
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +291 -168
- package/dist/main.iife.js.map +1 -1
- package/package.json +3 -3
- package/src/SlideController/helpers.ts +10 -1
- package/src/SlideController/index.ts +14 -3
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/app-slide",
|
|
3
|
-
"version": "0.0.
|
|
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.
|
|
15
|
-
"side-effect-manager": "^0.1.
|
|
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
|
-
|
|
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
|
-
|
|
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;
|