@netless/app-slide 0.0.21 → 0.0.25
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 +209 -309
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +22512 -22502
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +127 -227
- 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 +27 -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.25",
|
|
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.30",
|
|
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
|
|
|
@@ -109,6 +113,23 @@ export class SlideController {
|
|
|
109
113
|
private registerEventListeners() {
|
|
110
114
|
const { context, slide } = this;
|
|
111
115
|
|
|
116
|
+
// it is possible that we miss the first `renderSlide(1)` event
|
|
117
|
+
// and the attributes has no value yet, so we need to sync state
|
|
118
|
+
// when there's state change. we only have to do it once
|
|
119
|
+
this.sideEffect.add(() => {
|
|
120
|
+
const disposer = context.mobxUtils.reaction(
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
122
|
+
() => context.getAttributes()!.state,
|
|
123
|
+
() => {
|
|
124
|
+
this.syncStateOnce();
|
|
125
|
+
disposer();
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
// mobx already has a "disposed" flag in reaction,
|
|
129
|
+
// so we don't need to check it here
|
|
130
|
+
return disposer;
|
|
131
|
+
});
|
|
132
|
+
|
|
112
133
|
this.sideEffect.add(() => {
|
|
113
134
|
const displayer = context.getDisplayer();
|
|
114
135
|
displayer.addMagixEventListener(this.channel, this.magixEventListener, {
|
|
@@ -150,12 +171,14 @@ export class SlideController {
|
|
|
150
171
|
if (this.debug) {
|
|
151
172
|
console.log("[Slide] receive", payload);
|
|
152
173
|
}
|
|
153
|
-
|
|
174
|
+
// only emit the event if the slide state is sync-ed
|
|
175
|
+
if (!this.syncStateOnceFlag) {
|
|
176
|
+
this.slide.emit(SLIDE_EVENTS.syncReceive, payload);
|
|
177
|
+
}
|
|
154
178
|
}
|
|
155
179
|
}
|
|
156
180
|
};
|
|
157
181
|
|
|
158
|
-
private syncStateOnceFlag = true;
|
|
159
182
|
private syncStateOnce() {
|
|
160
183
|
// sync state before the first event, so that they can be in the correct order
|
|
161
184
|
if (this.syncStateOnceFlag) {
|
|
@@ -222,6 +245,7 @@ export class SlideController {
|
|
|
222
245
|
autoFPS: true,
|
|
223
246
|
autoResolution: true,
|
|
224
247
|
resolution: this.context.getAppOptions()?.resolution,
|
|
248
|
+
transactionBgColor: "#f9f9fc",
|
|
225
249
|
},
|
|
226
250
|
timestamp: this.timestamp,
|
|
227
251
|
});
|
|
@@ -238,7 +262,7 @@ export class SlideController {
|
|
|
238
262
|
this.sideEffect.flushAll();
|
|
239
263
|
if (!this.destroyed) {
|
|
240
264
|
if (this.debug) {
|
|
241
|
-
console.log("[Slide] destroy (once)");
|
|
265
|
+
console.log("[Slide] destroy slide (once)");
|
|
242
266
|
}
|
|
243
267
|
this.slide.destroy();
|
|
244
268
|
this.destroyed = true;
|