@netless/forge-slide 0.1.0-alpha.0 → 0.1.1-alpha.0
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/Slide.d.ts +35 -6
- package/dist/Slide.d.ts.map +1 -1
- package/dist/SlideApplication.d.ts +6 -0
- package/dist/SlideApplication.d.ts.map +1 -1
- package/dist/index.esm.js +116 -3
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +116 -3
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/Slide.ts +35 -6
- package/src/SlideApplication.ts +119 -6
package/dist/index.js
CHANGED
|
@@ -66594,6 +66594,7 @@ var import_eventemitter314 = __toESM(require("eventemitter3"));
|
|
|
66594
66594
|
var SlideForge = class extends import_eventemitter314.default {
|
|
66595
66595
|
view;
|
|
66596
66596
|
permissions;
|
|
66597
|
+
footView;
|
|
66597
66598
|
/**
|
|
66598
66599
|
* 当前页面索引, 从 0 开始
|
|
66599
66600
|
*/
|
|
@@ -66627,6 +66628,21 @@ var SlideForge = class extends import_eventemitter314.default {
|
|
|
66627
66628
|
* 切换侧栏显示状态
|
|
66628
66629
|
*/
|
|
66629
66630
|
sideBarToggle;
|
|
66631
|
+
/**
|
|
66632
|
+
* 获取预览图图片内容, base64 编码
|
|
66633
|
+
* @param {number} index 页面索引
|
|
66634
|
+
*/
|
|
66635
|
+
imgContent;
|
|
66636
|
+
/**
|
|
66637
|
+
* 获取预览图图片链接
|
|
66638
|
+
* @param {number} index 页面索引
|
|
66639
|
+
*/
|
|
66640
|
+
imgUrl;
|
|
66641
|
+
/**
|
|
66642
|
+
* 获取预览图图片尺寸
|
|
66643
|
+
* @param {number} index 页面索引
|
|
66644
|
+
*/
|
|
66645
|
+
imgSize;
|
|
66630
66646
|
};
|
|
66631
66647
|
|
|
66632
66648
|
// src/ForgeSlidePermession.ts
|
|
@@ -66970,6 +66986,7 @@ async function delay2(time) {
|
|
|
66970
66986
|
}
|
|
66971
66987
|
|
|
66972
66988
|
// src/SlideApplication.ts
|
|
66989
|
+
var import_forge_room5 = require("@netless/forge-room");
|
|
66973
66990
|
var Slide_APP_NAME = "forge_slide";
|
|
66974
66991
|
var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
66975
66992
|
static applicationName = Slide_APP_NAME;
|
|
@@ -66986,6 +67003,8 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
66986
67003
|
sideBar;
|
|
66987
67004
|
slide;
|
|
66988
67005
|
currentSlideIndex = 0;
|
|
67006
|
+
taskId = "";
|
|
67007
|
+
prefix = "";
|
|
66989
67008
|
constructor() {
|
|
66990
67009
|
super();
|
|
66991
67010
|
window.emitter = this.emitter;
|
|
@@ -67058,6 +67077,9 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67058
67077
|
}
|
|
67059
67078
|
});
|
|
67060
67079
|
this.rootView.appendChild(this.contentContainer);
|
|
67080
|
+
this.permissions.on("change", (userId, flags, value) => {
|
|
67081
|
+
this.emitter.emit("permissionChange", userId, flags, value);
|
|
67082
|
+
});
|
|
67061
67083
|
this.emitter.on("renderStart", (pageIndex) => {
|
|
67062
67084
|
this.footer.prevPageState(pageIndex !== 0);
|
|
67063
67085
|
});
|
|
@@ -67072,6 +67094,11 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67072
67094
|
return that.permissions;
|
|
67073
67095
|
}
|
|
67074
67096
|
});
|
|
67097
|
+
Object.defineProperty(this.emitter, "footView", {
|
|
67098
|
+
get() {
|
|
67099
|
+
return that.footer.root;
|
|
67100
|
+
}
|
|
67101
|
+
});
|
|
67075
67102
|
Object.defineProperty(this.emitter, "pageIndex", {
|
|
67076
67103
|
get() {
|
|
67077
67104
|
return that.currentSlideIndex;
|
|
@@ -67124,13 +67151,90 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67124
67151
|
this.footer.emit("sideBarToggle");
|
|
67125
67152
|
}
|
|
67126
67153
|
});
|
|
67154
|
+
Object.defineProperty(this.emitter, "imgContent", {
|
|
67155
|
+
writable: false,
|
|
67156
|
+
enumerable: false,
|
|
67157
|
+
value: (pageIndex) => {
|
|
67158
|
+
return this.getImageContent(pageIndex);
|
|
67159
|
+
}
|
|
67160
|
+
});
|
|
67161
|
+
Object.defineProperty(this.emitter, "imgUrl", {
|
|
67162
|
+
writable: false,
|
|
67163
|
+
enumerable: false,
|
|
67164
|
+
value: (pageIndex) => {
|
|
67165
|
+
return this.getImageUrl(pageIndex);
|
|
67166
|
+
}
|
|
67167
|
+
});
|
|
67168
|
+
Object.defineProperty(this.emitter, "imgSize", {
|
|
67169
|
+
writable: false,
|
|
67170
|
+
enumerable: false,
|
|
67171
|
+
value: (pageIndex) => {
|
|
67172
|
+
return this.getImageSize(pageIndex);
|
|
67173
|
+
}
|
|
67174
|
+
});
|
|
67175
|
+
}
|
|
67176
|
+
async getPreviewImage(imageUrl) {
|
|
67177
|
+
const image = fetch(imageUrl);
|
|
67178
|
+
return await image.then((res) => res.blob()).then((blob) => {
|
|
67179
|
+
return new Promise((resolve) => {
|
|
67180
|
+
const reader = new FileReader();
|
|
67181
|
+
reader.onloadend = () => {
|
|
67182
|
+
const base64Data = reader.result;
|
|
67183
|
+
const img = document.createElement("img");
|
|
67184
|
+
img.src = base64Data;
|
|
67185
|
+
img.onload = () => {
|
|
67186
|
+
resolve({
|
|
67187
|
+
url: imageUrl,
|
|
67188
|
+
src: base64Data,
|
|
67189
|
+
width: img.width,
|
|
67190
|
+
height: img.height
|
|
67191
|
+
});
|
|
67192
|
+
};
|
|
67193
|
+
};
|
|
67194
|
+
reader.readAsDataURL(blob);
|
|
67195
|
+
});
|
|
67196
|
+
});
|
|
67197
|
+
}
|
|
67198
|
+
async getImageUrl(pageIndex) {
|
|
67199
|
+
return `${this.prefix}/${this.taskId}/preview/${pageIndex + 1}.png`;
|
|
67200
|
+
}
|
|
67201
|
+
async getImageSize(pageIndex) {
|
|
67202
|
+
const imageUrl = `${this.prefix}/${this.taskId}/preview/${pageIndex + 1}.png`;
|
|
67203
|
+
let preview = null;
|
|
67204
|
+
try {
|
|
67205
|
+
const result = await import_forge_room5.kvStore.getItem(imageUrl);
|
|
67206
|
+
preview = result ? JSON.parse(result) : null;
|
|
67207
|
+
} catch (e) {
|
|
67208
|
+
console.warn("kvStore getItem error", e);
|
|
67209
|
+
}
|
|
67210
|
+
if (preview) {
|
|
67211
|
+
return { width: preview.width, height: preview.height };
|
|
67212
|
+
}
|
|
67213
|
+
preview = await this.getPreviewImage(imageUrl);
|
|
67214
|
+
await import_forge_room5.kvStore.setItem(imageUrl, JSON.stringify(preview));
|
|
67215
|
+
return { width: preview.width, height: preview.height };
|
|
67216
|
+
}
|
|
67217
|
+
async getImageContent(pageIndex) {
|
|
67218
|
+
const imageUrl = `${this.prefix}/${this.taskId}/preview/${pageIndex + 1}.png`;
|
|
67219
|
+
let preview = null;
|
|
67220
|
+
try {
|
|
67221
|
+
const result = await import_forge_room5.kvStore.getItem(imageUrl);
|
|
67222
|
+
preview = result ? JSON.parse(result) : null;
|
|
67223
|
+
} catch (e) {
|
|
67224
|
+
console.warn("kvStore getItem error", e);
|
|
67225
|
+
}
|
|
67226
|
+
if (preview) {
|
|
67227
|
+
return preview.src;
|
|
67228
|
+
}
|
|
67229
|
+
preview = await this.getPreviewImage(imageUrl);
|
|
67230
|
+
await import_forge_room5.kvStore.setItem(imageUrl, JSON.stringify(preview));
|
|
67231
|
+
return preview.src;
|
|
67127
67232
|
}
|
|
67128
67233
|
applySlideState = async (slideState, lastDispatch) => {
|
|
67129
67234
|
if (this.slide.slideState.currentSlideIndex < 0) {
|
|
67130
67235
|
this.slide.emit(import_slide.SLIDE_EVENTS.syncReceive, lastDispatch);
|
|
67131
67236
|
return;
|
|
67132
67237
|
}
|
|
67133
|
-
console.log("%cisEqual", "color: blue; font-size: 20px;", deepEqual(this.slide.slideState, slideState));
|
|
67134
67238
|
if (this.slide.slideState.currentSlideIndex > 0 && deepEqual(this.slide.slideState, slideState)) {
|
|
67135
67239
|
this.slide.emit(import_slide.SLIDE_EVENTS.syncReceive, lastDispatch);
|
|
67136
67240
|
} else {
|
|
@@ -67150,6 +67254,8 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67150
67254
|
}
|
|
67151
67255
|
};
|
|
67152
67256
|
async initialize(option) {
|
|
67257
|
+
this.prefix = option.prefix;
|
|
67258
|
+
this.taskId = option.taskId;
|
|
67153
67259
|
const whiteboardApp = new WhiteboardApplication();
|
|
67154
67260
|
whiteboardApp.roomDoc = this.roomDoc;
|
|
67155
67261
|
whiteboardApp.appId = `${option.taskId}_wb`;
|
|
@@ -67183,7 +67289,6 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67183
67289
|
this.contentContainer.appendChild(this.sideBar.root);
|
|
67184
67290
|
if (option.inheritWhiteboardId) {
|
|
67185
67291
|
whiteboardApp.linkToWhiteboard(option.inheritWhiteboardId);
|
|
67186
|
-
console.log("inheritWhiteboardId", option.inheritWhiteboardId);
|
|
67187
67292
|
}
|
|
67188
67293
|
this.whiteboard.setViewModeToMain();
|
|
67189
67294
|
this.slideContainer.setAttribute("builder", "slide-builder");
|
|
@@ -67206,14 +67311,22 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67206
67311
|
dispatch: event
|
|
67207
67312
|
});
|
|
67208
67313
|
});
|
|
67314
|
+
this.slide.on("mainSeqStepStart", (animateIndex) => {
|
|
67315
|
+
this.emitter.emit("mainSeqStepStart", animateIndex);
|
|
67316
|
+
});
|
|
67317
|
+
this.slide.on("mainSeqStepEnd", (animateIndex) => {
|
|
67318
|
+
this.emitter.emit("mainSeqStepEnd", animateIndex);
|
|
67319
|
+
});
|
|
67209
67320
|
this.slide.on("renderStart", (slideIndex) => {
|
|
67210
67321
|
this.whiteboardApp.emitter.view.style.opacity = "0";
|
|
67211
67322
|
this.whiteboardApp.emitter.addPage(`${slideIndex}`);
|
|
67212
67323
|
this.whiteboardApp.emitter.gotoPage(`${slideIndex}`);
|
|
67324
|
+
this.emitter.emit("renderStart", slideIndex);
|
|
67213
67325
|
});
|
|
67214
67326
|
this.slide.on("renderEnd", (slideIndex) => {
|
|
67215
67327
|
this.currentSlideIndex = slideIndex;
|
|
67216
67328
|
this.whiteboardApp.emitter.view.style.opacity = "1";
|
|
67329
|
+
this.emitter.emit("renderEnd", slideIndex);
|
|
67217
67330
|
});
|
|
67218
67331
|
this.slide.on("stateChange", (state) => {
|
|
67219
67332
|
this.getMap(this.name).set("slideState", state);
|
|
@@ -67221,6 +67334,7 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67221
67334
|
this.getMap(this.name).observe(this.onSlideEventHandler);
|
|
67222
67335
|
window.slide = this.slide;
|
|
67223
67336
|
window.slideWhiteboard = this.whiteboardApp;
|
|
67337
|
+
window.forgeSlide = this;
|
|
67224
67338
|
const syncSlide = this.getMap(this.name).get("slideState");
|
|
67225
67339
|
if (syncSlide && syncSlide.taskId === option.taskId) {
|
|
67226
67340
|
await this.slide.setSlideState(syncSlide);
|
|
@@ -67231,7 +67345,6 @@ var SlideApplication = class extends import_forge_room4.AbstractApplication {
|
|
|
67231
67345
|
return this.userMap(userId);
|
|
67232
67346
|
});
|
|
67233
67347
|
this.permissions.on("change", (userId, flags, value) => {
|
|
67234
|
-
console.log(userId, flags, value);
|
|
67235
67348
|
if (this.userId === userId) {
|
|
67236
67349
|
if (flags.includes(4 /* clickAnim */)) {
|
|
67237
67350
|
this.slideContainer.style.pointerEvents = "auto";
|