@netless/forge-slide 0.1.1-alpha.3 → 0.1.1-alpha.4

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/forge-slide",
3
- "version": "0.1.1-alpha.3",
3
+ "version": "0.1.1-alpha.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -8,8 +8,8 @@
8
8
  "dependencies": {
9
9
  "@netless/slide": "^1.4.15",
10
10
  "uuid": "^11.0.5",
11
- "@netless/forge-whiteboard": "0.1.14",
12
- "@netless/forge-room": "0.1.8"
11
+ "@netless/forge-room": "0.1.8",
12
+ "@netless/forge-whiteboard": "0.1.14"
13
13
  },
14
14
  "peerDependencies": {
15
15
  "eventemitter3": "^5.0.1",
@@ -226,6 +226,13 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
226
226
  })
227
227
  }
228
228
 
229
+ private getPreviewImageUrl (pageIndex: number) {
230
+ if (pageIndex < 1 || pageIndex > this.slideCount) {
231
+ throw new Error("pageIndex out of range");
232
+ }
233
+ return `${this.prefix}/${this.taskId}/preview/${pageIndex}.png`;
234
+ }
235
+
229
236
  private async getPreviewImage(imageUrl: string) {
230
237
  const image = fetch(imageUrl);
231
238
  return await image.then(res => res.blob()).then(blob => {
@@ -250,11 +257,11 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
250
257
  }
251
258
 
252
259
  private async getImageUrl(pageIndex: number) {
253
- return `${this.prefix}/${this.taskId}/preview/${pageIndex + 1}.png`;
260
+ return this.getPreviewImageUrl(pageIndex);
254
261
  }
255
262
 
256
263
  private async getImageSize(pageIndex: number) {
257
- const imageUrl = `${this.prefix}/${this.taskId}/preview/${pageIndex + 1}.png`;
264
+ const imageUrl = this.getPreviewImageUrl(pageIndex);
258
265
  let preview: PreviewImage | null = null;
259
266
  try {
260
267
  const result = await kvStore.getItem(imageUrl);
@@ -271,7 +278,7 @@ export class SlideApplication extends AbstractApplication<SlideApplicationOption
271
278
  }
272
279
 
273
280
  private async getImageContent(pageIndex: number) {
274
- const imageUrl = `${this.prefix}/${this.taskId}/preview/${pageIndex + 1}.png`;
281
+ const imageUrl = this.getPreviewImageUrl(pageIndex);
275
282
  let preview: PreviewImage | null = null;
276
283
  try {
277
284
  const result = await kvStore.getItem(imageUrl);