@netless/forge-imagery-doc 0.1.3 → 1.0.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.
@@ -70,7 +70,7 @@ var ImageryDoc = class extends import_eventemitter3.default {
70
70
  };
71
71
 
72
72
  // src/ImageryDocApplication.ts
73
- var import_forge_room2 = require("@netless/forge-room");
73
+ var import_forge_room4 = require("@netless/forge-room");
74
74
  var import_forge_whiteboard = require("@netless/forge-whiteboard");
75
75
 
76
76
  // src/LazyImage.ts
@@ -149,24 +149,7 @@ var LazyImage = class {
149
149
  };
150
150
 
151
151
  // src/ImageryDocPermissions.ts
152
- var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
153
- function _defineProperty3(e, r, t) {
154
- return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
155
- }
156
- function _toPropertyKey3(t) {
157
- var i = _toPrimitive3(t, "string");
158
- return "symbol" == typeof i ? i : i + "";
159
- }
160
- function _toPrimitive3(t, r) {
161
- if ("object" != typeof t || !t) return t;
162
- var e = t[Symbol.toPrimitive];
163
- if (void 0 !== e) {
164
- var i = e.call(t, r || "default");
165
- if ("object" != typeof i) return i;
166
- throw new TypeError("@@toPrimitive must return a primitive value.");
167
- }
168
- return ("string" === r ? String : Number)(t);
169
- }
152
+ var import_forge_room2 = require("@netless/forge-room");
170
153
  var ImageryDocPermissionFlag = function(ImageryDocPermissionFlag2) {
171
154
  ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["none"] = 0] = "none";
172
155
  ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["switchPage"] = 1] = "switchPage";
@@ -175,53 +158,7 @@ var ImageryDocPermissionFlag = function(ImageryDocPermissionFlag2) {
175
158
  ImageryDocPermissionFlag2[ImageryDocPermissionFlag2["all"] = ImageryDocPermissionFlag2.switchPage | ImageryDocPermissionFlag2.camera | ImageryDocPermissionFlag2.sideBar] = "all";
176
159
  return ImageryDocPermissionFlag2;
177
160
  }({});
178
- var ImageryDocPermissions = class extends import_eventemitter32.default {
179
- constructor(userManager, requestUserMap) {
180
- super();
181
- _defineProperty3(this, "requestUserMap", void 0);
182
- _defineProperty3(this, "userManager", void 0);
183
- _defineProperty3(this, "observers", /* @__PURE__ */ new Map());
184
- _defineProperty3(this, "handleUserLeave", (user) => {
185
- const cb = this.observers.get(user.id);
186
- if (cb) {
187
- this.requestUserMap(user.id).unobserve(cb);
188
- }
189
- });
190
- _defineProperty3(this, "handleUserJoin", (user) => {
191
- this.addObserve(user.id);
192
- });
193
- this.userManager = userManager;
194
- this.requestUserMap = requestUserMap;
195
- this.createModel(this.userManager.selfId);
196
- this.userManager.userIdList().forEach((userId) => {
197
- this.addObserve(userId);
198
- });
199
- this.userManager.on("join", this.handleUserJoin);
200
- this.userManager.on("leave", this.handleUserLeave);
201
- }
202
- addObserve(userId) {
203
- const observer = (evt) => {
204
- this.handleUserPermissionChange(userId, evt);
205
- };
206
- this.observers.set(userId, observer);
207
- this.requestUserMap(userId).observe(observer);
208
- }
209
- createModel(userId) {
210
- const userMap = this.requestUserMap(userId);
211
- if (!userMap.has("permission")) {
212
- userMap.set("permission", 0);
213
- }
214
- }
215
- handleUserPermissionChange(userId, evt) {
216
- for (const [key, value] of evt.changes.keys.entries()) {
217
- if (key === "permission") {
218
- if (value.action === "add" || value.action === "update") {
219
- const newValue = this.requestUserMap(userId).get("permission");
220
- this.emit("change", userId, this.resolveFlags(newValue), newValue);
221
- }
222
- }
223
- }
224
- }
161
+ var ImageryDocPermissions = class extends import_forge_room2.AbstractApplicationPermissions {
225
162
  /**
226
163
  * 解析权限列表组合
227
164
  * @param {number} value - 权限数字值
@@ -230,58 +167,6 @@ var ImageryDocPermissions = class extends import_eventemitter32.default {
230
167
  resolveFlags(value) {
231
168
  return [ImageryDocPermissionFlag.switchPage, ImageryDocPermissionFlag.sideBar, ImageryDocPermissionFlag.camera].filter((v) => (v & value) !== 0);
232
169
  }
233
- /**
234
- * 获取权限列表组合对应的数值
235
- * @param { string } userId 不传表示获取自己
236
- */
237
- getPermissionValue(userId) {
238
- return this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
239
- }
240
- /**
241
- * 获取权限列表
242
- * @param {string=} userId 可选, 不传表示获取自己
243
- */
244
- getPermissionFlags(userId) {
245
- const value = this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0;
246
- return this.resolveFlags(value);
247
- }
248
- /**
249
- * 返回对应 userId 是否有相应权限
250
- * @param {string=} userId 可选, 不传表示返回自己是否有相应权限
251
- * @param {WhiteboardPermissionFlag} flag
252
- */
253
- hasPermission(flag, userId) {
254
- return ((this.requestUserMap(userId ?? this.userManager.selfId).get("permission") ?? 0) & flag) !== 0;
255
- }
256
- /**
257
- * 添加权限
258
- * @param {WhiteboardPermissionFlag} flag 权限标记
259
- * @param {string=} userId 可选, 为 userId 添加权限, 不传表示为自己添加权限
260
- */
261
- addPermission(flag, userId) {
262
- const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
263
- const oldValue = userMap.get("permission") ?? 0;
264
- this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue | flag);
265
- }
266
- /**
267
- * 移除权限
268
- * @param {WhiteboardPermissionFlag} flag 权限标记
269
- * @param {string=} userId 可选, 为 userId 移除权限, 不传表示为自己移除权限
270
- */
271
- removePermission(flag, userId) {
272
- const userMap = this.requestUserMap(userId ?? this.userManager.selfId);
273
- const oldValue = userMap.get("permission") ?? 0;
274
- this.requestUserMap(userId ?? this.userManager.selfId).set("permission", oldValue & ~flag);
275
- }
276
- dispose() {
277
- this.userManager.off("join", this.handleUserJoin);
278
- this.userManager.off("leave", this.handleUserLeave);
279
- for (const [userId, observer] of this.observers) {
280
- this.requestUserMap(userId).unobserve(observer);
281
- }
282
- this.observers.clear();
283
- this.removeAllListeners();
284
- }
285
170
  };
286
171
 
287
172
  // src/icons.ts
@@ -295,14 +180,14 @@ var Icons = {
295
180
  };
296
181
 
297
182
  // src/FooterView.ts
298
- function _defineProperty4(e, r, t) {
299
- return (r = _toPropertyKey4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
183
+ function _defineProperty3(e, r, t) {
184
+ return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
300
185
  }
301
- function _toPropertyKey4(t) {
302
- var i = _toPrimitive4(t, "string");
186
+ function _toPropertyKey3(t) {
187
+ var i = _toPrimitive3(t, "string");
303
188
  return "symbol" == typeof i ? i : i + "";
304
189
  }
305
- function _toPrimitive4(t, r) {
190
+ function _toPrimitive3(t, r) {
306
191
  if ("object" != typeof t || !t) return t;
307
192
  var e = t[Symbol.toPrimitive];
308
193
  if (void 0 !== e) {
@@ -315,14 +200,23 @@ function _toPrimitive4(t, r) {
315
200
  var EM_COLOR = "#8C8C8C";
316
201
  var FooterView = class {
317
202
  constructor(imageryDoc) {
318
- _defineProperty4(this, "root", void 0);
319
- _defineProperty4(this, "prevPage", void 0);
320
- _defineProperty4(this, "nextPage", void 0);
321
- _defineProperty4(this, "sideBarToggle", void 0);
322
- _defineProperty4(this, "sideBarContainer", document.createElement("div"));
323
- _defineProperty4(this, "isSlideBarVisible", false);
324
- _defineProperty4(this, "imageryDoc", void 0);
325
- _defineProperty4(this, "handleSideBarClick", (evt) => {
203
+ _defineProperty3(this, "root", void 0);
204
+ _defineProperty3(this, "prevPage", void 0);
205
+ _defineProperty3(this, "nextPage", void 0);
206
+ _defineProperty3(this, "sideBarToggle", void 0);
207
+ _defineProperty3(this, "sideBarContainer", document.createElement("div"));
208
+ _defineProperty3(this, "navigator", document.createElement("div"));
209
+ _defineProperty3(this, "navigatorIndex", document.createElement("span"));
210
+ _defineProperty3(this, "navigatorTotal", document.createElement("span"));
211
+ _defineProperty3(this, "isSlideBarVisible", false);
212
+ _defineProperty3(this, "imageryDoc", void 0);
213
+ _defineProperty3(this, "updateIndex", () => {
214
+ this.navigatorIndex.textContent = `${this.imageryDoc.pageIndex + 1}`;
215
+ });
216
+ _defineProperty3(this, "updateTotal", () => {
217
+ this.navigatorTotal.textContent = `/${this.imageryDoc.pageCount}`;
218
+ });
219
+ _defineProperty3(this, "handleSideBarClick", (evt) => {
326
220
  const target = evt.target;
327
221
  const targetIndex = target.getAttribute("data-doc-index");
328
222
  if (targetIndex) {
@@ -357,6 +251,9 @@ var FooterView = class {
357
251
  this.root.appendChild(this.prevPage);
358
252
  this.root.appendChild(this.nextPage);
359
253
  this.root.appendChild(this.createSpacer());
254
+ this.createNavigator();
255
+ this.imageryDoc.addListener("renderEnd", this.updateIndex);
256
+ this.imageryDoc.addListener("ready", this.updateTotal);
360
257
  }
361
258
  prevPageState(enable) {
362
259
  if (enable) {
@@ -399,6 +296,20 @@ var FooterView = class {
399
296
  });
400
297
  return icon;
401
298
  }
299
+ createNavigator() {
300
+ this.navigator.style.height = "24px";
301
+ this.navigator.style.padding = "12px";
302
+ this.navigator.style.display = "flex";
303
+ this.navigator.style.alignItems = "center";
304
+ this.navigator.style.justifyContent = "center";
305
+ this.navigator.style.fontSize = "12px";
306
+ this.navigator.style.color = "#585858";
307
+ this.navigatorIndex.textContent = `${this.imageryDoc.pageIndex + 1}`;
308
+ this.navigatorTotal.textContent = `/${this.imageryDoc.pageCount}`;
309
+ this.navigator.appendChild(this.navigatorIndex);
310
+ this.navigator.appendChild(this.navigatorTotal);
311
+ this.root.appendChild(this.navigator);
312
+ }
402
313
  createSideBar() {
403
314
  if (this.imageryDoc.pageCount === 0) {
404
315
  return;
@@ -410,7 +321,7 @@ var FooterView = class {
410
321
  this.sideBarContainer.style.maxWidth = "180px";
411
322
  this.sideBarContainer.style.height = "calc(100% - 24px)";
412
323
  this.sideBarContainer.style.position = "absolute";
413
- this.sideBarContainer.style.bottom = "24px";
324
+ this.sideBarContainer.style.bottom = "25px";
414
325
  this.sideBarContainer.style.left = "0";
415
326
  this.sideBarContainer.style.fontSize = "0px";
416
327
  this.sideBarContainer.style.overflow = "auto";
@@ -425,7 +336,7 @@ var FooterView = class {
425
336
  reviewIndex.textContent = `${i + 1}`;
426
337
  const reviewImg = document.createElement("img");
427
338
  reviewImg.setAttribute("data-doc-index", `${i}`);
428
- reviewImg.style.cssText = "width:80%;margin:0 10%;box-shadow:1px 1px 5px #9e9e9e";
339
+ reviewImg.style.cssText = "width:80%;margin:0 10%;box-shadow:1px 1px 5px #f9f9fc";
429
340
  this.imageryDoc.imgContent(i).then((base64Data) => {
430
341
  reviewImg.src = base64Data;
431
342
  });
@@ -438,15 +349,15 @@ var FooterView = class {
438
349
  };
439
350
 
440
351
  // src/InfinityScroll.ts
441
- var import_eventemitter33 = __toESM(require("eventemitter3"), 1);
442
- function _defineProperty5(e, r, t) {
443
- return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
352
+ var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
353
+ function _defineProperty4(e, r, t) {
354
+ return (r = _toPropertyKey4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
444
355
  }
445
- function _toPropertyKey5(t) {
446
- var i = _toPrimitive5(t, "string");
356
+ function _toPropertyKey4(t) {
357
+ var i = _toPrimitive4(t, "string");
447
358
  return "symbol" == typeof i ? i : i + "";
448
359
  }
449
- function _toPrimitive5(t, r) {
360
+ function _toPrimitive4(t, r) {
450
361
  if ("object" != typeof t || !t) return t;
451
362
  var e = t[Symbol.toPrimitive];
452
363
  if (void 0 !== e) {
@@ -456,16 +367,16 @@ function _toPrimitive5(t, r) {
456
367
  }
457
368
  return ("string" === r ? String : Number)(t);
458
369
  }
459
- var InfinityScroll = class extends import_eventemitter33.default {
370
+ var InfinityScroll = class extends import_eventemitter32.default {
460
371
  constructor(view) {
461
372
  super();
462
- _defineProperty5(this, "view", void 0);
463
- _defineProperty5(this, "lastDelta", {
373
+ _defineProperty4(this, "view", void 0);
374
+ _defineProperty4(this, "lastDelta", {
464
375
  x: 0,
465
376
  y: 0
466
377
  });
467
- _defineProperty5(this, "lastTriggerTime", 0);
468
- _defineProperty5(this, "handleWheel", (evt) => {
378
+ _defineProperty4(this, "lastTriggerTime", 0);
379
+ _defineProperty4(this, "handleWheel", (evt) => {
469
380
  evt.preventDefault();
470
381
  evt.stopImmediatePropagation();
471
382
  evt.stopPropagation();
@@ -518,14 +429,14 @@ var ContainerKeys = {
518
429
  };
519
430
 
520
431
  // src/ContinuousContainer.ts
521
- function _defineProperty6(e, r, t) {
522
- return (r = _toPropertyKey6(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
432
+ function _defineProperty5(e, r, t) {
433
+ return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
523
434
  }
524
- function _toPropertyKey6(t) {
525
- var i = _toPrimitive6(t, "string");
435
+ function _toPropertyKey5(t) {
436
+ var i = _toPrimitive5(t, "string");
526
437
  return "symbol" == typeof i ? i : i + "";
527
438
  }
528
- function _toPrimitive6(t, r) {
439
+ function _toPrimitive5(t, r) {
529
440
  if ("object" != typeof t || !t) return t;
530
441
  var e = t[Symbol.toPrimitive];
531
442
  if (void 0 !== e) {
@@ -552,22 +463,22 @@ var ContinuousContainer = class {
552
463
  return this.images.length - 1;
553
464
  }
554
465
  constructor(map, whiteboardApp, parentView, imageDoc) {
555
- _defineProperty6(this, "view", void 0);
556
- _defineProperty6(this, "parentView", void 0);
557
- _defineProperty6(this, "resizeObserver", void 0);
558
- _defineProperty6(this, "images", []);
559
- _defineProperty6(this, "scroll", void 0);
560
- _defineProperty6(this, "map", void 0);
561
- _defineProperty6(this, "whiteboardApp", void 0);
562
- _defineProperty6(this, "imageDoc", void 0);
563
- _defineProperty6(this, "totalHeight", 0);
564
- _defineProperty6(this, "localScale", 1);
565
- _defineProperty6(this, "handleMapChange", (event) => {
466
+ _defineProperty5(this, "view", void 0);
467
+ _defineProperty5(this, "parentView", void 0);
468
+ _defineProperty5(this, "resizeObserver", void 0);
469
+ _defineProperty5(this, "images", []);
470
+ _defineProperty5(this, "scroll", void 0);
471
+ _defineProperty5(this, "map", void 0);
472
+ _defineProperty5(this, "whiteboardApp", void 0);
473
+ _defineProperty5(this, "imageDoc", void 0);
474
+ _defineProperty5(this, "totalHeight", 0);
475
+ _defineProperty5(this, "localScale", 1);
476
+ _defineProperty5(this, "handleMapChange", (event) => {
566
477
  if (event.keysChanged.has(ContainerKeys.translateY)) {
567
478
  this.updateSyncedTransform();
568
479
  }
569
480
  });
570
- _defineProperty6(this, "handleResize", () => {
481
+ _defineProperty5(this, "handleResize", () => {
571
482
  const bound = this.view.getBoundingClientRect();
572
483
  let scaledHeight = 0;
573
484
  for (const image of this.images) {
@@ -580,7 +491,7 @@ var ContinuousContainer = class {
580
491
  this.whiteboardApp.adjustByOutFrame(bound.width, bound.height);
581
492
  this.updateSyncedTransform();
582
493
  });
583
- _defineProperty6(this, "updateSyncedTransform", () => {
494
+ _defineProperty5(this, "updateSyncedTransform", () => {
584
495
  const bounds = this.view.getBoundingClientRect();
585
496
  const maxTy = this.totalHeight * this.localScale - bounds.height;
586
497
  let ty = this.translateY * this.totalHeight * this.localScale;
@@ -590,7 +501,6 @@ var ContinuousContainer = class {
590
501
  this.whiteboardApp.emitter.resetCamera();
591
502
  this.whiteboardApp.emitter.translateCamera(0, -ty);
592
503
  this.whiteboardApp.emitter.scaleCamera(this.localScale, "top-left");
593
- console.log("localScale: ", this.localScale, this.translateY);
594
504
  this.handleGoto(this.pageIndex);
595
505
  });
596
506
  this.imageDoc = imageDoc;
@@ -667,14 +577,15 @@ var ContinuousContainer = class {
667
577
  };
668
578
 
669
579
  // src/SingleContainer.ts
670
- function _defineProperty7(e, r, t) {
671
- return (r = _toPropertyKey7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
580
+ var import_forge_room3 = require("@netless/forge-room");
581
+ function _defineProperty6(e, r, t) {
582
+ return (r = _toPropertyKey6(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
672
583
  }
673
- function _toPropertyKey7(t) {
674
- var i = _toPrimitive7(t, "string");
584
+ function _toPropertyKey6(t) {
585
+ var i = _toPrimitive6(t, "string");
675
586
  return "symbol" == typeof i ? i : i + "";
676
587
  }
677
- function _toPrimitive7(t, r) {
588
+ function _toPrimitive6(t, r) {
678
589
  if ("object" != typeof t || !t) return t;
679
590
  var e = t[Symbol.toPrimitive];
680
591
  if (void 0 !== e) {
@@ -715,16 +626,16 @@ var SingleContainer = class {
715
626
  return this.map.get(ContainerKeys.pageIndex);
716
627
  }
717
628
  constructor(map, whiteboardApp, parentView, imageDoc) {
718
- _defineProperty7(this, "view", void 0);
719
- _defineProperty7(this, "parentView", void 0);
720
- _defineProperty7(this, "resizeObserver", void 0);
721
- _defineProperty7(this, "images", []);
722
- _defineProperty7(this, "currentImage", null);
723
- _defineProperty7(this, "scroll", void 0);
724
- _defineProperty7(this, "map", void 0);
725
- _defineProperty7(this, "whiteboardApp", void 0);
726
- _defineProperty7(this, "imageDoc", void 0);
727
- _defineProperty7(this, "handleMapChange", (event) => {
629
+ _defineProperty6(this, "view", void 0);
630
+ _defineProperty6(this, "parentView", void 0);
631
+ _defineProperty6(this, "resizeObserver", void 0);
632
+ _defineProperty6(this, "images", []);
633
+ _defineProperty6(this, "currentImage", null);
634
+ _defineProperty6(this, "scroll", void 0);
635
+ _defineProperty6(this, "map", void 0);
636
+ _defineProperty6(this, "whiteboardApp", void 0);
637
+ _defineProperty6(this, "imageDoc", void 0);
638
+ _defineProperty6(this, "handleMapChange", (event) => {
728
639
  if (event.keysChanged.has(ContainerKeys.scale) || event.keysChanged.has(ContainerKeys.translateX) || event.keysChanged.has(ContainerKeys.translateY)) {
729
640
  this.updateSyncedTransform();
730
641
  }
@@ -733,7 +644,7 @@ var SingleContainer = class {
733
644
  });
734
645
  }
735
646
  });
736
- _defineProperty7(this, "handleResize", () => {
647
+ _defineProperty6(this, "handleResize", () => {
737
648
  const bound = this.parentView.getBoundingClientRect();
738
649
  if (this.currentImage) {
739
650
  let scale = bound.width / this.currentImage.width;
@@ -747,7 +658,7 @@ var SingleContainer = class {
747
658
  this.resetTranslateOnResize();
748
659
  }
749
660
  });
750
- _defineProperty7(this, "updateSyncedTransform", () => {
661
+ _defineProperty6(this, "updateSyncedTransform", () => {
751
662
  if (!this.currentImage) {
752
663
  return;
753
664
  }
@@ -800,10 +711,12 @@ var SingleContainer = class {
800
711
  this.scale = nextScale;
801
712
  this.handleTranslate(0, 0);
802
713
  });
803
- window.__doc = this;
804
714
  }
805
715
  init() {
806
716
  this.handleGoto(this.pageIndex).catch((_error) => {
717
+ console.error(_error);
718
+ }).finally(() => {
719
+ this.handleResize();
807
720
  });
808
721
  this.updateSyncedTransform();
809
722
  }
@@ -892,21 +805,21 @@ var SingleContainer = class {
892
805
  }
893
806
  }
894
807
  dispose() {
895
- this.map.unobserve(this.handleMapChange);
808
+ (0, import_forge_room3.removeObserver)(this.map, this.handleMapChange);
896
809
  this.resizeObserver.disconnect();
897
810
  this.scroll.dispose();
898
811
  }
899
812
  };
900
813
 
901
814
  // src/ImageryDocApplication.ts
902
- function _defineProperty8(e, r, t) {
903
- return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
815
+ function _defineProperty7(e, r, t) {
816
+ return (r = _toPropertyKey7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
904
817
  }
905
- function _toPropertyKey8(t) {
906
- var i = _toPrimitive8(t, "string");
818
+ function _toPropertyKey7(t) {
819
+ var i = _toPrimitive7(t, "string");
907
820
  return "symbol" == typeof i ? i : i + "";
908
821
  }
909
- function _toPrimitive8(t, r) {
822
+ function _toPrimitive7(t, r) {
910
823
  if ("object" != typeof t || !t) return t;
911
824
  var e = t[Symbol.toPrimitive];
912
825
  if (void 0 !== e) {
@@ -917,24 +830,25 @@ function _toPrimitive8(t, r) {
917
830
  return ("string" === r ? String : Number)(t);
918
831
  }
919
832
  var IMAGERY_DOC_APP_NAME = "imagery_doc";
920
- var ImageryDocApplication = class extends import_forge_room2.AbstractApplication {
833
+ var ImageryDocApplication = class extends import_forge_room4.AbstractApplication {
921
834
  constructor() {
922
835
  super();
923
- _defineProperty8(this, "name", IMAGERY_DOC_APP_NAME);
924
- _defineProperty8(this, "emitter", new ImageryDoc());
925
- _defineProperty8(this, "whiteboardApp", void 0);
926
- _defineProperty8(this, "whiteboard", void 0);
927
- _defineProperty8(this, "container", void 0);
928
- _defineProperty8(this, "rootView", document.createElement("div"));
929
- _defineProperty8(this, "contentContainer", document.createElement("div"));
930
- _defineProperty8(this, "whiteboardContainer", document.createElement("div"));
931
- _defineProperty8(this, "footerContainer", document.createElement("div"));
932
- _defineProperty8(this, "permissions", void 0);
933
- _defineProperty8(this, "footer", void 0);
934
- _defineProperty8(this, "images", []);
836
+ _defineProperty7(this, "name", IMAGERY_DOC_APP_NAME);
837
+ _defineProperty7(this, "emitter", new ImageryDoc());
838
+ _defineProperty7(this, "whiteboardApp", void 0);
839
+ _defineProperty7(this, "whiteboard", void 0);
840
+ _defineProperty7(this, "container", void 0);
841
+ _defineProperty7(this, "rootView", document.createElement("div"));
842
+ _defineProperty7(this, "contentContainer", document.createElement("div"));
843
+ _defineProperty7(this, "whiteboardContainer", document.createElement("div"));
844
+ _defineProperty7(this, "footerContainer", document.createElement("div"));
845
+ _defineProperty7(this, "permissions", void 0);
846
+ _defineProperty7(this, "footer", void 0);
847
+ _defineProperty7(this, "images", []);
935
848
  this.rootView.setAttribute("data-forge-app", "imagery-doc");
936
- this.rootView.style.background = "red";
937
849
  this.rootView.style.overflow = "hidden";
850
+ this.rootView.style.userSelect = "none";
851
+ this.rootView.style.backgroundColor = "#f9f9fc";
938
852
  this.contentContainer.style.width = "100%";
939
853
  this.contentContainer.style.height = "100%";
940
854
  this.contentContainer.style.display = "flex";
@@ -1000,17 +914,19 @@ var ImageryDocApplication = class extends import_forge_room2.AbstractApplication
1000
914
  }
1001
915
  async initialize(option) {
1002
916
  const whiteboardApp = new import_forge_whiteboard.WhiteboardApplication();
1003
- whiteboardApp.roomDoc = this.roomDoc;
917
+ whiteboardApp.appDoc = this.appDoc;
1004
918
  whiteboardApp.appId = `${this.appId}_wb`;
1005
919
  whiteboardApp.userId = this.userId;
1006
920
  whiteboardApp.userManager = this.userManager;
1007
- whiteboardApp.applicationManager = this.applicationManager;
921
+ whiteboardApp.deleteSubDoc = this.deleteSubDoc;
1008
922
  await whiteboardApp.initialize({
1009
923
  width: -1,
1010
- height: -1
924
+ height: -1,
925
+ maxScaleRatio: 1
1011
926
  });
1012
927
  this.whiteboardApp = whiteboardApp;
1013
928
  this.whiteboard = whiteboardApp.emitter;
929
+ this.whiteboard.enableCameraBoundaryHighlight = false;
1014
930
  this.whiteboard.enableCameraByMouse = false;
1015
931
  this.whiteboard.enableCameraByTouch = false;
1016
932
  this.whiteboard.view.style.width = "100%";
@@ -1055,51 +971,31 @@ var ImageryDocApplication = class extends import_forge_room2.AbstractApplication
1055
971
  this.permissions.on("change", (userId, flags, value) => {
1056
972
  this.emitter.emit("permissionChange", userId, flags, value);
1057
973
  });
1058
- this.permissions.addPermission(ImageryDocPermissionFlag.all);
974
+ this.permissions.setPermission(ImageryDocPermissionFlag.all);
1059
975
  this.whiteboardApp.disableViewModel();
1060
976
  this.container.init();
1061
977
  this.whiteboard.permissions.removePermission(import_forge_whiteboard.WhiteboardPermissionFlag.mainView);
1062
978
  if (option.inheritWhiteboardId) {
1063
979
  whiteboardApp.linkToWhiteboard(option.inheritWhiteboardId);
1064
980
  }
981
+ this.emitter.emit("ready");
1065
982
  return Promise.resolve(void 0);
1066
983
  }
1067
984
  userMap(userId) {
1068
985
  return this.getMap(`user/${userId}`);
1069
986
  }
1070
- async dispose() {
1071
- await this.whiteboardApp.dispose();
1072
- this.rootView.parentElement?.removeChild(this.rootView);
987
+ async dispose(removeSubDoc) {
988
+ if (removeSubDoc) {
989
+ this.deleteSubDoc(this.appId);
990
+ }
991
+ await this.whiteboardApp.dispose(removeSubDoc);
992
+ this.whiteboardApp.emitter.view.remove();
1073
993
  this.container.dispose();
1074
994
  this.permissions.dispose();
1075
- Object.defineProperty(this.emitter, "footView", {
1076
- value: null
1077
- });
1078
- Object.defineProperty(this.emitter, "view", {
1079
- value: null
1080
- });
1081
- Object.defineProperty(this.emitter, "permissions", {
1082
- value: null
1083
- });
1084
- Object.defineProperty(this.emitter, "pageIndex", {
1085
- value: null
1086
- });
1087
- Object.defineProperty(this.emitter, "pageCount", {
1088
- value: null
1089
- });
1090
- Object.defineProperty(this.emitter, "goto", {
1091
- value: null
1092
- });
1093
- Object.defineProperty(this.emitter, "imgContent", {
1094
- value: null
1095
- });
1096
- Object.defineProperty(this.emitter, "imgSize", {
1097
- value: null
1098
- });
1099
995
  this.emitter.removeAllListeners();
1100
996
  return Promise.resolve(void 0);
1101
997
  }
1102
998
  };
1103
- _defineProperty8(ImageryDocApplication, "applicationName", IMAGERY_DOC_APP_NAME);
999
+ _defineProperty7(ImageryDocApplication, "applicationName", IMAGERY_DOC_APP_NAME);
1104
1000
  window.__ImageryDocApplication = ImageryDocApplication;
1105
1001
  //# sourceMappingURL=imagery-doc.js.map