@netless/app-slide 0.1.0 → 0.1.1
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/main.cjs.js +113 -113
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +1090 -1059
- package/dist/main.es.js.map +1 -1
- package/dist/main.iife.js +114 -114
- package/dist/main.iife.js.map +1 -1
- package/package.json +3 -3
- package/src/SlideController/index.ts +19 -18
- package/src/SlideDocsViewer/index.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/app-slide",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "dist/main.cjs.js",
|
|
5
5
|
"module": "dist/main.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
],
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@netless/app-shared": "^0.1.1",
|
|
14
|
-
"@netless/slide": "^0.2.
|
|
14
|
+
"@netless/slide": "^0.2.9",
|
|
15
15
|
"@types/color-string": "^1.5.2",
|
|
16
16
|
"color-string": "^1.9.0",
|
|
17
17
|
"side-effect-manager": "^0.1.5",
|
|
18
|
-
"vanilla-lazyload": "^17.
|
|
18
|
+
"vanilla-lazyload": "^17.6.1"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"types": "cross-env NODE_ENV=production tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
@@ -14,7 +14,7 @@ import type { Attributes, MagixEvents, MagixPayload, SlideState } from "../typin
|
|
|
14
14
|
|
|
15
15
|
import { SideEffectManager } from "side-effect-manager";
|
|
16
16
|
import { Slide, SLIDE_EVENTS } from "@netless/slide";
|
|
17
|
-
import { clamp
|
|
17
|
+
import { clamp } from "../utils/helpers";
|
|
18
18
|
import { cachedGetBgColor } from "../utils/bgcolor";
|
|
19
19
|
import { logger, log, verbose } from "../utils/logger";
|
|
20
20
|
export { syncSceneWithSlide, createDocsViewerPages } from "./helpers";
|
|
@@ -100,13 +100,16 @@ export class SlideController {
|
|
|
100
100
|
|
|
101
101
|
private kickStart() {
|
|
102
102
|
const { context, slide } = this;
|
|
103
|
-
|
|
103
|
+
if (context.getIsWritable()) {
|
|
104
|
+
context.storage.ensureState(EmptyAttributes);
|
|
105
|
+
}
|
|
106
|
+
const { taskId, url, state } = context.storage.state;
|
|
104
107
|
slide.setResource(taskId, url || DefaultUrl);
|
|
105
108
|
if (state) {
|
|
106
109
|
// if we already have state, try restore from it
|
|
107
|
-
log("[Slide] init with state",
|
|
110
|
+
log("[Slide] init with state", state);
|
|
108
111
|
this.syncStateOnceFlag = false;
|
|
109
|
-
slide.setSlideState(
|
|
112
|
+
slide.setSlideState(state);
|
|
110
113
|
} else if (context.isAddApp) {
|
|
111
114
|
// otherwise, maybe this slide is just added, let the adder kick start first render
|
|
112
115
|
log("[Slide] init by renderSlide", 1);
|
|
@@ -124,19 +127,14 @@ export class SlideController {
|
|
|
124
127
|
// it is possible that we miss the first `renderSlide(1)` event
|
|
125
128
|
// and the attributes has no value yet, so we need to sync state
|
|
126
129
|
// when there's state change. we only have to do it once
|
|
127
|
-
this.sideEffect.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
() => context.getAttributes()!.state,
|
|
131
|
-
() => {
|
|
130
|
+
const disposerId = this.sideEffect.addDisposer(
|
|
131
|
+
context.storage.addStateChangedListener(() => {
|
|
132
|
+
if (context.storage.state.state) {
|
|
132
133
|
this.syncStateOnce();
|
|
133
|
-
|
|
134
|
+
this.sideEffect.flush(disposerId);
|
|
134
135
|
}
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
// so we don't need to check it here
|
|
138
|
-
return disposer;
|
|
139
|
-
});
|
|
136
|
+
})
|
|
137
|
+
);
|
|
140
138
|
|
|
141
139
|
this.sideEffect.add(() =>
|
|
142
140
|
context.addMagixEventListener(SLIDE_EVENTS.syncDispatch, this.magixEventListener, {
|
|
@@ -179,10 +177,13 @@ export class SlideController {
|
|
|
179
177
|
private syncStateOnce() {
|
|
180
178
|
// sync state before the first event, so that they can be in the correct order
|
|
181
179
|
if (this.syncStateOnceFlag) {
|
|
182
|
-
|
|
180
|
+
if (this.context.getIsWritable()) {
|
|
181
|
+
this.context.storage.ensureState(EmptyAttributes);
|
|
182
|
+
}
|
|
183
|
+
const { state } = this.context.storage.state;
|
|
183
184
|
if (state) {
|
|
184
|
-
log("[Slide] sync with state (once)",
|
|
185
|
-
this.slide.setSlideState(
|
|
185
|
+
log("[Slide] sync with state (once)", state);
|
|
186
|
+
this.slide.setSlideState(state);
|
|
186
187
|
this.syncStateOnceFlag = false;
|
|
187
188
|
}
|
|
188
189
|
}
|
|
@@ -169,6 +169,15 @@ export class SlideDocsViewer {
|
|
|
169
169
|
height,
|
|
170
170
|
animationMode: "immediately" as AnimationMode.Immediately,
|
|
171
171
|
});
|
|
172
|
+
this.whiteboardView.setCameraBound({
|
|
173
|
+
damping: 1,
|
|
174
|
+
maxContentMode: () => this.whiteboardView.camera.scale,
|
|
175
|
+
minContentMode: () => this.whiteboardView.camera.scale,
|
|
176
|
+
centerX: 0,
|
|
177
|
+
centerY: 0,
|
|
178
|
+
width,
|
|
179
|
+
height,
|
|
180
|
+
});
|
|
172
181
|
if (!this.isViewMounted) {
|
|
173
182
|
this.isViewMounted = true;
|
|
174
183
|
console.log("[Slide] mount whiteboard view");
|