@netless/forge-slide 0.1.1-alpha.10 → 0.1.1-alpha.11

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/index.js CHANGED
@@ -35185,33 +35185,42 @@ var Y15 = __toESM(require("yjs"), 1);
35185
35185
  var Y12 = __toESM(require("yjs"), 1);
35186
35186
  var import_eventemitter3 = __toESM(require("eventemitter3"), 1);
35187
35187
  var import_uuid = require("uuid");
35188
+ var import_forge_room2 = require("@netless/forge-room");
35188
35189
  var Y2 = __toESM(require("yjs"), 1);
35189
35190
  var Y = __toESM(require("yjs"), 1);
35191
+ var import_forge_room3 = require("@netless/forge-room");
35190
35192
  var Y3 = __toESM(require("yjs"), 1);
35191
35193
  var Y4 = __toESM(require("yjs"), 1);
35192
35194
  var Y5 = __toESM(require("yjs"), 1);
35193
35195
  var Y6 = __toESM(require("yjs"), 1);
35196
+ var import_forge_room4 = require("@netless/forge-room");
35194
35197
  var Y7 = __toESM(require("yjs"), 1);
35195
35198
  var Y8 = __toESM(require("yjs"), 1);
35196
35199
  var Y9 = __toESM(require("yjs"), 1);
35197
35200
  var Y10 = __toESM(require("yjs"), 1);
35198
- var import_forge_room2 = require("@netless/forge-room");
35201
+ var import_forge_room5 = require("@netless/forge-room");
35199
35202
  var Y11 = __toESM(require("yjs"), 1);
35200
35203
  var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
35204
+ var import_forge_room6 = require("@netless/forge-room");
35201
35205
  var Y13 = __toESM(require("yjs"), 1);
35202
35206
  var import_eventemitter33 = __toESM(require("eventemitter3"), 1);
35207
+ var import_forge_room7 = require("@netless/forge-room");
35203
35208
  var import_eventemitter34 = __toESM(require("eventemitter3"), 1);
35204
35209
  var import_eventemitter35 = require("eventemitter3");
35205
35210
  var import_eventemitter36 = __toESM(require("eventemitter3"), 1);
35206
35211
  var import_eventemitter37 = __toESM(require("eventemitter3"), 1);
35212
+ var import_forge_room8 = require("@netless/forge-room");
35207
35213
  var import_eventemitter38 = __toESM(require("eventemitter3"), 1);
35208
35214
  var Y14 = __toESM(require("yjs"), 1);
35209
35215
  var import_eventemitter39 = __toESM(require("eventemitter3"), 1);
35216
+ var import_forge_room9 = require("@netless/forge-room");
35210
35217
  var import_eventemitter310 = __toESM(require("eventemitter3"), 1);
35211
- var import_forge_room3 = require("@netless/forge-room");
35218
+ var import_forge_room10 = require("@netless/forge-room");
35212
35219
  var import_eventemitter311 = __toESM(require("eventemitter3"), 1);
35213
- var import_forge_room4 = require("@netless/forge-room");
35220
+ var import_forge_room11 = require("@netless/forge-room");
35221
+ var import_forge_room12 = require("@netless/forge-room");
35214
35222
  var import_eventemitter312 = __toESM(require("eventemitter3"), 1);
35223
+ var import_forge_room13 = require("@netless/forge-room");
35215
35224
  var __create2 = Object.create;
35216
35225
  var __defProp2 = Object.defineProperty;
35217
35226
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -60791,11 +60800,12 @@ var ElementModel = class _ElementModel {
60791
60800
  set shadow(value) {
60792
60801
  this.root.set(_ElementModel.KEYS.shadow, value);
60793
60802
  }
60794
- constructor(root, scope) {
60803
+ constructor(root, scope, liveCursor) {
60795
60804
  _defineProperty(this, "shadowEmitter", null);
60796
60805
  _defineProperty(this, "root", void 0);
60797
60806
  _defineProperty(this, "scope", void 0);
60798
60807
  _defineProperty(this, "item", void 0);
60808
+ _defineProperty(this, "liveCursor", void 0);
60799
60809
  _defineProperty(this, "handlePropChange", (events) => {
60800
60810
  if (!this.item) {
60801
60811
  return;
@@ -60804,7 +60814,7 @@ var ElementModel = class _ElementModel {
60804
60814
  if (event.target === this.root) {
60805
60815
  const updatePaperItemKeys = this.vectorKeys().concat([_ElementModel.KEYS.pointsMatrix]);
60806
60816
  for (const [key, value] of event.changes.keys.entries()) {
60807
- if (value.action === "update") {
60817
+ if (value.action === "update" || value.action == "add") {
60808
60818
  const includeKeys = this.styleKeys().include;
60809
60819
  if (includeKeys.indexOf(key) >= 0) {
60810
60820
  this.onStyleKeyUpdate(key);
@@ -60824,6 +60834,10 @@ var ElementModel = class _ElementModel {
60824
60834
  if (this.shadow !== "") {
60825
60835
  this.shadowEmitter?.emit("translateIn", [this.uuid], this.shadow);
60826
60836
  } else {
60837
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
60838
+ if (ownerId) {
60839
+ this.liveCursor.updateCursorVisible(false, ownerId);
60840
+ }
60827
60841
  this.shadowEmitter?.emit("translateOut", [this.uuid], value.oldValue);
60828
60842
  }
60829
60843
  }
@@ -60831,11 +60845,17 @@ var ElementModel = class _ElementModel {
60831
60845
  }
60832
60846
  } else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
60833
60847
  this.onVectorUpdate();
60848
+ const liveCursorPoint = this.liveCursorPoint();
60849
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
60850
+ if (liveCursorPoint && ownerId) {
60851
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
60852
+ }
60834
60853
  } else {
60835
60854
  }
60836
60855
  }
60837
60856
  });
60838
60857
  this.scope = scope;
60858
+ this.liveCursor = liveCursor;
60839
60859
  this.root = root;
60840
60860
  if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
60841
60861
  this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
@@ -60895,7 +60915,7 @@ var ElementModel = class _ElementModel {
60895
60915
  }
60896
60916
  dispose() {
60897
60917
  this.subDispose();
60898
- this.root.unobserveDeep(this.handlePropChange);
60918
+ (0, import_forge_room3.removeDeepObserver)(this.root, this.handlePropChange);
60899
60919
  }
60900
60920
  };
60901
60921
  _defineProperty(ElementModel, "KEYS", {
@@ -60963,8 +60983,8 @@ function _toPrimitive3(t, r) {
60963
60983
  return ("string" === r ? String : Number)(t);
60964
60984
  }
60965
60985
  var CurveModel = class extends ElementModel {
60966
- constructor(root, scope) {
60967
- super(root, scope);
60986
+ constructor(root, scope, liveCursor) {
60987
+ super(root, scope, liveCursor);
60968
60988
  _defineProperty3(this, "item", null);
60969
60989
  _defineProperty3(this, "debugPath", void 0);
60970
60990
  _defineProperty3(this, "debug", false);
@@ -60980,8 +61000,7 @@ var CurveModel = class extends ElementModel {
60980
61000
  return (a2 + b2) / 2;
60981
61001
  }
60982
61002
  parsePoints(points) {
60983
- const groupPoints = (0, import_lodash.chunk)(points, 2);
60984
- return ae(groupPoints, {
61003
+ return ae(points, {
60985
61004
  size: this.strokeWidth,
60986
61005
  smoothing: 0.5,
60987
61006
  thinning: -0.5,
@@ -60998,15 +61017,15 @@ var CurveModel = class extends ElementModel {
60998
61017
  });
60999
61018
  }
61000
61019
  matrixedPoints() {
61001
- const currentPoints = (0, import_lodash.chunk)(this.points, 2);
61002
- return currentPoints.map((_ref) => {
61003
- let [x, y] = _ref;
61004
- return new this.scope.Point(x, y);
61005
- }).map((p) => p.transform(new this.scope.Matrix(this.pointsMatrix))).reduce((result, next) => {
61006
- result.push(next.x);
61007
- result.push(next.y);
61008
- return result;
61009
- }, []);
61020
+ const points = this.points;
61021
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
61022
+ const output = [];
61023
+ for (let i = 0, len = points.length; i < len; i += 2) {
61024
+ const p = new this.scope.Point(points[i], points[i + 1]);
61025
+ const tp = p.transform(matrix);
61026
+ output.push([tp.x, tp.y]);
61027
+ }
61028
+ return output;
61010
61029
  }
61011
61030
  createPath(points) {
61012
61031
  const path = new this.scope.Path();
@@ -61081,6 +61100,15 @@ var CurveModel = class extends ElementModel {
61081
61100
  exclude: ["dashArray", "fillColor"]
61082
61101
  };
61083
61102
  }
61103
+ liveCursorPoint() {
61104
+ const yArray = this.root.get(ElementModel.KEYS.points);
61105
+ if (yArray.length < 2) {
61106
+ return null;
61107
+ }
61108
+ const len = yArray.length;
61109
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
61110
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
61111
+ }
61084
61112
  onStyleKeyUpdate(key) {
61085
61113
  if (!this.item) {
61086
61114
  return;
@@ -61113,8 +61141,8 @@ function _toPrimitive4(t, r) {
61113
61141
  return ("string" === r ? String : Number)(t);
61114
61142
  }
61115
61143
  var SelectorModel = class extends ElementModel {
61116
- constructor(root, scope) {
61117
- super(root, scope);
61144
+ constructor(root, scope, liveCursor) {
61145
+ super(root, scope, liveCursor);
61118
61146
  _defineProperty4(this, "item", null);
61119
61147
  if (!this.root.has("type")) {
61120
61148
  this.root.set("type", "selector");
@@ -61125,6 +61153,9 @@ var SelectorModel = class extends ElementModel {
61125
61153
  this.root.set("points", initPoints);
61126
61154
  }
61127
61155
  }
61156
+ liveCursorPoint() {
61157
+ return null;
61158
+ }
61128
61159
  subDispose() {
61129
61160
  }
61130
61161
  createPaperRect() {
@@ -61244,8 +61275,8 @@ function _toPrimitive6(t, r) {
61244
61275
  return ("string" === r ? String : Number)(t);
61245
61276
  }
61246
61277
  var SegmentsModel = class extends ElementModel {
61247
- constructor(root, scope, type) {
61248
- super(root, scope);
61278
+ constructor(root, scope, type, liveCursor) {
61279
+ super(root, scope, liveCursor);
61249
61280
  _defineProperty6(this, "item", null);
61250
61281
  if (!this.root.has("type")) {
61251
61282
  this.root.set("type", type);
@@ -61256,6 +61287,14 @@ var SegmentsModel = class extends ElementModel {
61256
61287
  }
61257
61288
  subDispose() {
61258
61289
  }
61290
+ liveCursorPoint() {
61291
+ const yArray = this.root.get(ElementModel.KEYS.points);
61292
+ if (yArray.length < 2) {
61293
+ return null;
61294
+ }
61295
+ const point = new this.scope.Point(yArray.get(0), yArray.get(1));
61296
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
61297
+ }
61259
61298
  onVectorUpdate() {
61260
61299
  if (!this.item) {
61261
61300
  return;
@@ -61374,6 +61413,7 @@ var LineTool = class extends WhiteboardTool {
61374
61413
  _defineProperty8(this, "elementModel", null);
61375
61414
  _defineProperty8(this, "from", null);
61376
61415
  _defineProperty8(this, "to", null);
61416
+ _defineProperty8(this, "showLiveCursor", true);
61377
61417
  this.tool.minDistance = 1;
61378
61418
  }
61379
61419
  onMouseDown(event) {
@@ -61436,8 +61476,8 @@ var LineModel = class extends ElementModel {
61436
61476
  set tailArrow(value) {
61437
61477
  this.root.set("tailArrow", value);
61438
61478
  }
61439
- constructor(root, scope) {
61440
- super(root, scope);
61479
+ constructor(root, scope, liveCursor) {
61480
+ super(root, scope, liveCursor);
61441
61481
  _defineProperty9(this, "controlledPoints", []);
61442
61482
  _defineProperty9(this, "item", null);
61443
61483
  if (!this.root.has("type")) {
@@ -61486,6 +61526,15 @@ var LineModel = class extends ElementModel {
61486
61526
  });
61487
61527
  return [head, path, tail];
61488
61528
  }
61529
+ liveCursorPoint() {
61530
+ const yArray = this.root.get(ElementModel.KEYS.points);
61531
+ if (yArray.length < 2) {
61532
+ return null;
61533
+ }
61534
+ const len = yArray.length;
61535
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
61536
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
61537
+ }
61489
61538
  createPaperItem() {
61490
61539
  this.item = new this.scope.Group();
61491
61540
  this.item.addChildren(this.renderLine());
@@ -61633,8 +61682,8 @@ var PointTextModel = class extends ElementModel {
61633
61682
  set fontFamily(value) {
61634
61683
  this.root.set("font-family", value);
61635
61684
  }
61636
- constructor(root, scope) {
61637
- super(root, scope);
61685
+ constructor(root, scope, liveCursor) {
61686
+ super(root, scope, liveCursor);
61638
61687
  _defineProperty10(this, "item", null);
61639
61688
  _defineProperty10(this, "handleTextPropChange", (event) => {
61640
61689
  if (!this.item) {
@@ -61666,7 +61715,16 @@ var PointTextModel = class extends ElementModel {
61666
61715
  }
61667
61716
  }
61668
61717
  subDispose() {
61669
- this.root.unobserve(this.handleTextPropChange);
61718
+ (0, import_forge_room4.removeObserver)(this.root, this.handleTextPropChange);
61719
+ }
61720
+ liveCursorPoint() {
61721
+ const points = this.points;
61722
+ if (points.length < 1) {
61723
+ return null;
61724
+ }
61725
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
61726
+ const topLeft = new this.scope.Point(points[0], points[1]).transform(matrix);
61727
+ return topLeft;
61670
61728
  }
61671
61729
  getInternalMeasurement() {
61672
61730
  if (!this.item) {
@@ -61760,8 +61818,8 @@ function _toPrimitive11(t, r) {
61760
61818
  return ("string" === r ? String : Number)(t);
61761
61819
  }
61762
61820
  var TriangleModel = class extends ElementModel {
61763
- constructor(root, scope) {
61764
- super(root, scope);
61821
+ constructor(root, scope, liveCursor) {
61822
+ super(root, scope, liveCursor);
61765
61823
  _defineProperty11(this, "item", null);
61766
61824
  if (!this.root.has("type")) {
61767
61825
  this.root.set("type", "triangle");
@@ -61770,6 +61828,15 @@ var TriangleModel = class extends ElementModel {
61770
61828
  this.root.set("points", new Y7.Array());
61771
61829
  }
61772
61830
  }
61831
+ liveCursorPoint() {
61832
+ const yArray = this.root.get(ElementModel.KEYS.points);
61833
+ if (yArray.length < 6) {
61834
+ return null;
61835
+ }
61836
+ const len = yArray.length;
61837
+ const point = new this.scope.Point(yArray.get(len - 4), yArray.get(len - 3));
61838
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
61839
+ }
61773
61840
  subDispose() {
61774
61841
  }
61775
61842
  createPaperItem() {
@@ -61849,8 +61916,8 @@ function _toPrimitive12(t, r) {
61849
61916
  return ("string" === r ? String : Number)(t);
61850
61917
  }
61851
61918
  var RectangleModel = class extends ElementModel {
61852
- constructor(root, scope) {
61853
- super(root, scope);
61919
+ constructor(root, scope, liveCursor) {
61920
+ super(root, scope, liveCursor);
61854
61921
  _defineProperty12(this, "item", null);
61855
61922
  if (!this.root.has("type")) {
61856
61923
  this.root.set("type", "rectangle");
@@ -61866,6 +61933,14 @@ var RectangleModel = class extends ElementModel {
61866
61933
  }
61867
61934
  subDispose() {
61868
61935
  }
61936
+ liveCursorPoint() {
61937
+ const points = this.points;
61938
+ if (points.length < 4) {
61939
+ return null;
61940
+ }
61941
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
61942
+ return new this.scope.Point(points[2], points[3]).transform(matrix);
61943
+ }
61869
61944
  createSegments() {
61870
61945
  const [a2, b2, c, d] = this.points;
61871
61946
  const matrix = new this.scope.Matrix(this.pointsMatrix);
@@ -62020,8 +62095,8 @@ function _toPrimitive13(t, r) {
62020
62095
  return ("string" === r ? String : Number)(t);
62021
62096
  }
62022
62097
  var EraserModel = class extends ElementModel {
62023
- constructor(root, scope) {
62024
- super(root, scope);
62098
+ constructor(root, scope, liveCursor) {
62099
+ super(root, scope, liveCursor);
62025
62100
  _defineProperty13(this, "item", null);
62026
62101
  _defineProperty13(this, "sliceBegin", 0);
62027
62102
  if (!this.root.has("type")) {
@@ -62060,41 +62135,42 @@ var EraserModel = class extends ElementModel {
62060
62135
  return path;
62061
62136
  }
62062
62137
  parsePoints(points) {
62063
- return ae(points, {
62138
+ const groupPoints = (0, import_lodash5.chunk)(points, 2);
62139
+ return ae(groupPoints, {
62064
62140
  size: this.strokeWidth,
62065
- smoothing: 0,
62066
- thinning: 0.5,
62141
+ smoothing: 0.5,
62142
+ thinning: -0.5,
62067
62143
  streamline: 0.5,
62068
62144
  simulatePressure: true,
62069
62145
  start: {
62070
- taper: true,
62146
+ taper: this.strokeWidth * 10,
62071
62147
  cap: true
62072
62148
  },
62073
62149
  end: {
62074
- taper: 0,
62150
+ taper: this.strokeWidth * 20,
62075
62151
  cap: true
62076
62152
  }
62077
62153
  });
62078
62154
  }
62079
62155
  matrixedPoints() {
62080
- const matrix = new this.scope.Matrix(this.pointsMatrix);
62081
- const groupPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
62082
- return groupPoints.map((_ref) => {
62156
+ const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
62157
+ return currentPoints.map((_ref) => {
62083
62158
  let [x, y] = _ref;
62084
- return matrix.transform([x, y]);
62085
- }).map((p) => [p.x, p.y]);
62086
- }
62087
- getNextSegments() {
62088
- const points = this.parsePoints(this.matrixedPoints());
62089
- const path = this.createPath(points);
62090
- return path.segments;
62159
+ return new this.scope.Point(x, y);
62160
+ }).map((p) => p.transform(new this.scope.Matrix(this.pointsMatrix))).reduce((result, next) => {
62161
+ result.push(next.x);
62162
+ result.push(next.y);
62163
+ return result;
62164
+ }, []);
62091
62165
  }
62092
62166
  onVectorUpdate() {
62093
62167
  if (!this.item) {
62094
62168
  return;
62095
62169
  }
62170
+ const points = this.parsePoints(this.matrixedPoints());
62171
+ const path = this.createPath(points);
62096
62172
  this.item.removeSegments();
62097
- this.item.addSegments(this.getNextSegments());
62173
+ this.item.addSegments(path.segments);
62098
62174
  }
62099
62175
  createPaperItem() {
62100
62176
  this.item = new this.scope.Path();
@@ -62103,21 +62179,13 @@ var EraserModel = class extends ElementModel {
62103
62179
  this.item.strokeScaling = false;
62104
62180
  this.item.strokeColor = new this.scope.Color(this.strokeColor);
62105
62181
  this.item.fillColor = new this.scope.Color(this.strokeColor);
62106
- this.item.addSegments(this.getNextSegments());
62107
- let isBegin = false;
62182
+ this.onVectorUpdate();
62108
62183
  this.item.onFrame = () => {
62109
62184
  if (!this.points) {
62110
62185
  return;
62111
62186
  }
62112
- if (this.points.length / 2 - this.sliceBegin >= 10 && !isBegin) {
62113
- isBegin = true;
62114
- }
62115
- if (this.points.length / 2 <= this.sliceBegin) {
62116
- isBegin = false;
62117
- }
62118
- if (isBegin) {
62119
- this.sliceBegin += 1;
62120
- this.onVectorUpdate();
62187
+ if (this.points.length / 2 > 50) {
62188
+ this.sliceBegin = this.points.length / 2 - 50;
62121
62189
  }
62122
62190
  };
62123
62191
  }
@@ -62138,6 +62206,15 @@ var EraserModel = class extends ElementModel {
62138
62206
  }
62139
62207
  subDispose() {
62140
62208
  }
62209
+ liveCursorPoint() {
62210
+ const yArray = this.root.get(ElementModel.KEYS.points);
62211
+ if (yArray.length < 2) {
62212
+ return null;
62213
+ }
62214
+ const len = yArray.length;
62215
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
62216
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
62217
+ }
62141
62218
  };
62142
62219
  var import_lodash6 = __toESM2(require_lodash(), 1);
62143
62220
  function _defineProperty14(e, r, t) {
@@ -62158,8 +62235,8 @@ function _toPrimitive14(t, r) {
62158
62235
  return ("string" === r ? String : Number)(t);
62159
62236
  }
62160
62237
  var LaserPointerModel = class extends ElementModel {
62161
- constructor(clientId, root, scope, removeElement) {
62162
- super(root, scope);
62238
+ constructor(clientId, root, scope, liveCursor, removeElement) {
62239
+ super(root, scope, liveCursor);
62163
62240
  _defineProperty14(this, "item", null);
62164
62241
  _defineProperty14(this, "clientId", void 0);
62165
62242
  _defineProperty14(this, "sliceBegin", 0);
@@ -62296,6 +62373,15 @@ var LaserPointerModel = class extends ElementModel {
62296
62373
  }
62297
62374
  subDispose() {
62298
62375
  }
62376
+ liveCursorPoint() {
62377
+ const yArray = this.root.get(ElementModel.KEYS.points);
62378
+ if (yArray.length < 2) {
62379
+ return null;
62380
+ }
62381
+ const len = yArray.length;
62382
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
62383
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
62384
+ }
62299
62385
  };
62300
62386
  var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
62301
62387
  WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["none"] = 0] = "none";
@@ -62309,7 +62395,7 @@ var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
62309
62395
  WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["all"] = WhiteboardPermissionFlag2.draw | WhiteboardPermissionFlag2.editSelf | WhiteboardPermissionFlag2.editOthers | WhiteboardPermissionFlag2.deleteSelf | WhiteboardPermissionFlag2.deleteOthers | WhiteboardPermissionFlag2.mainView | WhiteboardPermissionFlag2.setOthersView] = "all";
62310
62396
  return WhiteboardPermissionFlag2;
62311
62397
  }({});
62312
- var WhiteboardPermissions = class extends import_forge_room2.AbstractApplicationPermissions {
62398
+ var WhiteboardPermissions = class extends import_forge_room5.AbstractApplicationPermissions {
62313
62399
  /**
62314
62400
  * 解析权限列表组合
62315
62401
  * @param {number} value - 权限数字值
@@ -62338,8 +62424,8 @@ function _toPrimitive15(t, r) {
62338
62424
  return ("string" === r ? String : Number)(t);
62339
62425
  }
62340
62426
  var StraightLineModel = class extends ElementModel {
62341
- constructor(root, scope) {
62342
- super(root, scope);
62427
+ constructor(root, scope, liveCursor) {
62428
+ super(root, scope, liveCursor);
62343
62429
  _defineProperty15(this, "item", null);
62344
62430
  if (!this.root.has("type")) {
62345
62431
  this.root.set("type", "line");
@@ -62348,6 +62434,15 @@ var StraightLineModel = class extends ElementModel {
62348
62434
  this.root.set("points", new Y11.Array());
62349
62435
  }
62350
62436
  }
62437
+ liveCursorPoint() {
62438
+ const yArray = this.root.get(ElementModel.KEYS.points);
62439
+ if (yArray.length < 2) {
62440
+ return null;
62441
+ }
62442
+ const len = yArray.length;
62443
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
62444
+ return point.transform(new this.scope.Matrix(this.pointsMatrix));
62445
+ }
62351
62446
  subDispose() {
62352
62447
  }
62353
62448
  onVectorUpdate() {
@@ -62449,29 +62544,111 @@ function _toPrimitive16(t, r) {
62449
62544
  }
62450
62545
  return ("string" === r ? String : Number)(t);
62451
62546
  }
62547
+ var ImageModel = class extends ElementModel {
62548
+ get src() {
62549
+ return this.root.get("src");
62550
+ }
62551
+ constructor(root, scope, imageSets, liveCursor) {
62552
+ super(root, scope, liveCursor);
62553
+ _defineProperty16(this, "item", null);
62554
+ _defineProperty16(this, "imageSets", void 0);
62555
+ this.imageSets = imageSets;
62556
+ if (!this.root.has("type")) {
62557
+ this.root.set("type", "image");
62558
+ }
62559
+ this.root.set(ElementModel.KEYS.shadow, "");
62560
+ }
62561
+ subDispose() {
62562
+ const img = this.imageSets.querySelector(`[id='${this.uuid}']`);
62563
+ if (img) {
62564
+ img.remove();
62565
+ }
62566
+ }
62567
+ createPaperItem() {
62568
+ if (this.item) {
62569
+ return;
62570
+ }
62571
+ if (!this.imageSets.querySelector(`[id='${this.uuid}']`)) {
62572
+ const img = document.createElement("img");
62573
+ img.src = this.src;
62574
+ img.id = this.uuid;
62575
+ this.imageSets.appendChild(img);
62576
+ }
62577
+ this.item = new this.scope.Raster(this.uuid);
62578
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
62579
+ this.item.matrix = matrix;
62580
+ }
62581
+ onVectorUpdate() {
62582
+ const matrix = new this.scope.Matrix(this.pointsMatrix);
62583
+ if (this.item) {
62584
+ this.item.matrix = matrix;
62585
+ }
62586
+ }
62587
+ vectorKeys() {
62588
+ return [];
62589
+ }
62590
+ styleKeys() {
62591
+ return {
62592
+ include: [],
62593
+ exclude: ["dashArray", "strokeColor", "fillColor", "strokeWidth"]
62594
+ };
62595
+ }
62596
+ onStyleKeyUpdate(_key) {
62597
+ }
62598
+ editorConfig() {
62599
+ const cfg = new EditorConfig();
62600
+ cfg.resizeModel = () => "four-corner";
62601
+ cfg.uniformScale = () => true;
62602
+ return cfg;
62603
+ }
62604
+ liveCursorPoint() {
62605
+ return null;
62606
+ }
62607
+ };
62608
+ function _defineProperty17(e, r, t) {
62609
+ return (r = _toPropertyKey17(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62610
+ }
62611
+ function _toPropertyKey17(t) {
62612
+ var i = _toPrimitive17(t, "string");
62613
+ return "symbol" == typeof i ? i : i + "";
62614
+ }
62615
+ function _toPrimitive17(t, r) {
62616
+ if ("object" != typeof t || !t) return t;
62617
+ var e = t[Symbol.toPrimitive];
62618
+ if (void 0 !== e) {
62619
+ var i = e.call(t, r || "default");
62620
+ if ("object" != typeof i) return i;
62621
+ throw new TypeError("@@toPrimitive must return a primitive value.");
62622
+ }
62623
+ return ("string" === r ? String : Number)(t);
62624
+ }
62452
62625
  var RenderableModel = class extends import_eventemitter3.default {
62453
62626
  get uuid() {
62454
- return (0, import_uuid.v4)();
62627
+ return (0, import_uuid.v4)().replace(/-/g, "");
62455
62628
  }
62456
- constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, hasPermission) {
62629
+ constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
62457
62630
  super();
62458
- _defineProperty16(this, "scope", void 0);
62459
- _defineProperty16(this, "toolbarModel", void 0);
62460
- _defineProperty16(this, "userManager", void 0);
62461
- _defineProperty16(this, "elementModels", void 0);
62462
- _defineProperty16(this, "elements", void 0);
62463
- _defineProperty16(this, "layerId", void 0);
62464
- _defineProperty16(this, "maxIndex", -1);
62465
- _defineProperty16(this, "hasPermission", void 0);
62466
- _defineProperty16(this, "shadowEmitter", void 0);
62467
- _defineProperty16(this, "onElementsChange", (event) => {
62631
+ _defineProperty17(this, "scope", void 0);
62632
+ _defineProperty17(this, "toolbarModel", void 0);
62633
+ _defineProperty17(this, "userManager", void 0);
62634
+ _defineProperty17(this, "elementModels", void 0);
62635
+ _defineProperty17(this, "elements", void 0);
62636
+ _defineProperty17(this, "layerId", void 0);
62637
+ _defineProperty17(this, "maxIndex", -1);
62638
+ _defineProperty17(this, "hasPermission", void 0);
62639
+ _defineProperty17(this, "shadowEmitter", void 0);
62640
+ _defineProperty17(this, "imageSets", void 0);
62641
+ _defineProperty17(this, "liveCursor", void 0);
62642
+ _defineProperty17(this, "onElementsChange", (event) => {
62468
62643
  for (const [key, value] of event.changes.keys.entries()) {
62469
62644
  if (value.action === "add") {
62470
62645
  const root = this.elements.get(key);
62471
62646
  if (root) {
62472
62647
  const model = this.convertToModel(root);
62473
62648
  if (model) {
62474
- this.emit("elementInsert", [model]);
62649
+ setTimeout(() => {
62650
+ this.emit("elementInsert", [model]);
62651
+ });
62475
62652
  }
62476
62653
  }
62477
62654
  } else if (value.action === "delete") {
@@ -62479,6 +62656,8 @@ var RenderableModel = class extends import_eventemitter3.default {
62479
62656
  }
62480
62657
  }
62481
62658
  });
62659
+ this.liveCursor = liveCursor;
62660
+ this.imageSets = imageSets;
62482
62661
  this.hasPermission = hasPermission;
62483
62662
  this.shadowEmitter = shadowEmitter;
62484
62663
  this.layerId = layerId;
@@ -62517,27 +62696,29 @@ var RenderableModel = class extends import_eventemitter3.default {
62517
62696
  const type = yMap.get("type");
62518
62697
  let model = null;
62519
62698
  if (type === "curve") {
62520
- model = new CurveModel(yMap, this.scope);
62699
+ model = new CurveModel(yMap, this.scope, this.liveCursor);
62521
62700
  } else if (["ellipse"].indexOf(type) >= 0) {
62522
- model = new SegmentsModel(yMap, this.scope, type);
62701
+ model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
62523
62702
  } else if (type === "selector") {
62524
- model = new SelectorModel(yMap, this.scope);
62703
+ model = new SelectorModel(yMap, this.scope, this.liveCursor);
62525
62704
  } else if (type === "arrow") {
62526
- model = new LineModel(yMap, this.scope);
62705
+ model = new LineModel(yMap, this.scope, this.liveCursor);
62527
62706
  } else if (type === "line") {
62528
- model = new StraightLineModel(yMap, this.scope);
62707
+ model = new StraightLineModel(yMap, this.scope, this.liveCursor);
62529
62708
  } else if (type === "point-text") {
62530
- model = new PointTextModel(yMap, this.scope);
62709
+ model = new PointTextModel(yMap, this.scope, this.liveCursor);
62531
62710
  } else if (type === "triangle") {
62532
- model = new TriangleModel(yMap, this.scope);
62711
+ model = new TriangleModel(yMap, this.scope, this.liveCursor);
62533
62712
  } else if (type === "rectangle") {
62534
- model = new RectangleModel(yMap, this.scope);
62713
+ model = new RectangleModel(yMap, this.scope, this.liveCursor);
62535
62714
  } else if (type === "eraser") {
62536
- model = new EraserModel(yMap, this.scope);
62715
+ model = new EraserModel(yMap, this.scope, this.liveCursor);
62537
62716
  } else if (type === "laser") {
62538
- model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, (uuid) => {
62717
+ model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
62539
62718
  this.removeElementItem(uuid);
62540
62719
  });
62720
+ } else if (type === "image") {
62721
+ model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
62541
62722
  }
62542
62723
  if (model) {
62543
62724
  model.shadowEmitter = this.shadowEmitter;
@@ -62546,100 +62727,178 @@ var RenderableModel = class extends import_eventemitter3.default {
62546
62727
  return model;
62547
62728
  }
62548
62729
  initElement(element) {
62549
- let shadow = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
62550
- if (shadow) {
62551
- element.shadow = "layer";
62552
- }
62553
- element.strokeWidth = this.toolbarModel.strokeWidth;
62554
- element.strokeColor = this.toolbarModel.strokeColor;
62555
- element.fillColor = this.toolbarModel.fillColor;
62556
- element.ownerId = this.userManager.selfId;
62557
62730
  element.shadowEmitter = this.shadowEmitter;
62558
62731
  }
62559
62732
  removeElementItem(uuid) {
62560
62733
  this.elements.delete(uuid);
62561
62734
  }
62562
- addElementToDoc(map) {
62563
- this.elements.doc?.transact(() => {
62564
- const uuid = this.uuid;
62565
- map.set(ElementModel.KEYS.index, ++this.maxIndex);
62566
- map.set(ElementModel.KEYS.uuid, uuid);
62567
- this.elements.set(uuid, map);
62568
- }, elementsUndoOrigin);
62569
- }
62570
62735
  confirmPermission() {
62571
62736
  const hasPermission = this.hasPermission(WhiteboardPermissionFlag.draw);
62572
62737
  if (!hasPermission) {
62573
- console.warn("[@netless/forge-whiteboard] no permission to draw");
62738
+ (0, import_forge_room2.log)("[@netless/forge-whiteboard] no permission to draw", {}, "warning");
62574
62739
  }
62575
62740
  return hasPermission;
62576
62741
  }
62742
+ createImage(src) {
62743
+ if (!this.confirmPermission()) {
62744
+ return;
62745
+ }
62746
+ const yMap = new Y12.Map();
62747
+ this.elements.doc?.transact(() => {
62748
+ const uuid = this.uuid;
62749
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62750
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62751
+ yMap.set("type", "image");
62752
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62753
+ this.elements.set(uuid, yMap);
62754
+ }, elementsUndoOrigin);
62755
+ const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
62756
+ model.root.set("src", src);
62757
+ const initMatrix = new this.scope.Matrix();
62758
+ const center = this.scope.project.view.center;
62759
+ initMatrix.translate({
62760
+ x: center.x,
62761
+ y: center.y
62762
+ });
62763
+ model.appendPointsMatrix(initMatrix);
62764
+ model.ownerId = this.userManager.selfId;
62765
+ }
62577
62766
  createCurve() {
62578
62767
  let shadow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
62579
62768
  if (!this.confirmPermission()) {
62580
62769
  return null;
62581
62770
  }
62582
- const curveModel = new CurveModel(new Y12.Map(), this.scope);
62583
- this.initElement(curveModel, shadow);
62584
- this.addElementToDoc(curveModel.root);
62771
+ const yMap = new Y12.Map();
62772
+ this.elements.doc?.transact(() => {
62773
+ const uuid = this.uuid;
62774
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62775
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62776
+ yMap.set("type", "curve");
62777
+ if (shadow) {
62778
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62779
+ }
62780
+ yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
62781
+ yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
62782
+ yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
62783
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62784
+ this.elements.set(uuid, yMap);
62785
+ }, elementsUndoOrigin);
62786
+ const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
62787
+ this.initElement(curveModel);
62585
62788
  return curveModel;
62586
62789
  }
62587
62790
  createLaserPointer() {
62588
62791
  if (!this.confirmPermission()) {
62589
62792
  return null;
62590
62793
  }
62591
- const model = new LaserPointerModel(this.userManager.selfId, new Y12.Map(), this.scope, (uuid) => {
62794
+ const yMap = new Y12.Map();
62795
+ this.elements.doc?.transact(() => {
62796
+ const uuid = this.uuid;
62797
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62798
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62799
+ yMap.set("type", "laser");
62800
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62801
+ yMap.set(ElementModel.KEYS.strokeWidth, 8);
62802
+ yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
62803
+ yMap.set(ElementModel.KEYS.fillColor, "#F44336");
62804
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62805
+ this.elements.set(uuid, yMap);
62806
+ }, elementsUndoOrigin);
62807
+ const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
62592
62808
  this.removeElementItem(uuid);
62593
62809
  });
62594
- model.strokeWidth = 8;
62595
- model.strokeColor = "#F44336";
62596
- model.fillColor = "#F44336";
62597
- model.ownerId = this.userManager.selfId;
62598
- model.shadow = "layer";
62599
- this.addElementToDoc(model.root);
62600
62810
  return model;
62601
62811
  }
62602
62812
  createEraser() {
62603
62813
  if (!this.hasPermission(WhiteboardPermissionFlag.deleteSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
62604
62814
  return null;
62605
62815
  }
62606
- const model = new EraserModel(new Y12.Map(), this.scope);
62607
- model.strokeWidth = 12;
62608
- model.strokeColor = "#9E9E9E";
62609
- model.fillColor = "#9E9E9E";
62610
- model.ownerId = this.userManager.selfId;
62611
- model.shadow = "layer";
62612
- this.addElementToDoc(model.root);
62816
+ const yMap = new Y12.Map();
62817
+ this.elements.doc?.transact(() => {
62818
+ const uuid = this.uuid;
62819
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62820
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62821
+ yMap.set("type", "eraser");
62822
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62823
+ yMap.set(ElementModel.KEYS.strokeWidth, 4);
62824
+ yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
62825
+ yMap.set(ElementModel.KEYS.fillColor, "#9E9E9E");
62826
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62827
+ this.elements.set(uuid, yMap);
62828
+ }, elementsUndoOrigin);
62829
+ const model = new EraserModel(yMap, this.scope, this.liveCursor);
62613
62830
  return model;
62614
62831
  }
62615
62832
  createTriangle(shadow) {
62616
62833
  if (!this.confirmPermission()) {
62617
62834
  return null;
62618
62835
  }
62619
- const triangle = new TriangleModel(new Y12.Map(), this.scope);
62620
- this.initElement(triangle, shadow);
62836
+ const yMap = new Y12.Map();
62837
+ this.elements.doc?.transact(() => {
62838
+ const uuid = this.uuid;
62839
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62840
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62841
+ yMap.set("type", "triangle");
62842
+ if (shadow) {
62843
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62844
+ }
62845
+ yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
62846
+ yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
62847
+ yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
62848
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62849
+ this.elements.set(uuid, yMap);
62850
+ }, elementsUndoOrigin);
62851
+ const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
62852
+ this.initElement(triangle);
62621
62853
  triangle.dashArray = this.toolbarModel.dashArray;
62622
- this.addElementToDoc(triangle.root);
62623
62854
  return triangle;
62624
62855
  }
62625
62856
  createRectangle(shadow) {
62626
62857
  if (!this.confirmPermission()) {
62627
62858
  return null;
62628
62859
  }
62629
- const rect = new RectangleModel(new Y12.Map(), this.scope);
62630
- this.initElement(rect, shadow);
62860
+ const yMap = new Y12.Map();
62861
+ this.elements.doc?.transact(() => {
62862
+ const uuid = this.uuid;
62863
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62864
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62865
+ yMap.set("type", "rectangle");
62866
+ if (shadow) {
62867
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62868
+ }
62869
+ yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
62870
+ yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
62871
+ yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
62872
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62873
+ this.elements.set(uuid, yMap);
62874
+ }, elementsUndoOrigin);
62875
+ const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
62876
+ this.initElement(rect);
62631
62877
  rect.dashArray = this.toolbarModel.dashArray;
62632
- this.addElementToDoc(rect.root);
62633
62878
  return rect;
62634
62879
  }
62635
62880
  createSegmentedPath(type, shadow) {
62636
62881
  if (!this.confirmPermission()) {
62637
62882
  return null;
62638
62883
  }
62639
- const segmentsModel = new SegmentsModel(new Y12.Map(), this.scope, type);
62640
- this.initElement(segmentsModel, shadow);
62884
+ const yMap = new Y12.Map();
62885
+ this.elements.doc?.transact(() => {
62886
+ const uuid = this.uuid;
62887
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62888
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62889
+ yMap.set("type", type);
62890
+ if (shadow) {
62891
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62892
+ }
62893
+ yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
62894
+ yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
62895
+ yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
62896
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62897
+ this.elements.set(uuid, yMap);
62898
+ }, elementsUndoOrigin);
62899
+ const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
62900
+ this.initElement(segmentsModel);
62641
62901
  segmentsModel.dashArray = this.toolbarModel.dashArray;
62642
- this.addElementToDoc(segmentsModel.root);
62643
62902
  return segmentsModel;
62644
62903
  }
62645
62904
  createSelector() {
@@ -62647,41 +62906,92 @@ var RenderableModel = class extends import_eventemitter3.default {
62647
62906
  if (!this.hasPermission(WhiteboardPermissionFlag.editSelf) && !this.hasPermission(WhiteboardPermissionFlag.deleteOthers)) {
62648
62907
  return null;
62649
62908
  }
62650
- const selectorModel = new SelectorModel(new Y12.Map(), this.scope);
62909
+ const yMap = new Y12.Map();
62910
+ this.elements.doc?.transact(() => {
62911
+ const uuid = this.uuid;
62912
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62913
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62914
+ yMap.set("type", "selector");
62915
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62916
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62917
+ this.elements.set(uuid, yMap);
62918
+ }, elementsUndoOrigin);
62919
+ const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
62651
62920
  selectorModel.shadow = "layer";
62652
- this.addElementToDoc(selectorModel.root);
62653
62921
  return selectorModel;
62654
62922
  }
62655
62923
  createStraightLine(shadow) {
62656
62924
  if (!this.confirmPermission()) {
62657
62925
  return null;
62658
62926
  }
62659
- const straightLineModel = new StraightLineModel(new Y12.Map(), this.scope);
62660
- this.initElement(straightLineModel, shadow);
62927
+ const yMap = new Y12.Map();
62928
+ this.elements.doc?.transact(() => {
62929
+ const uuid = this.uuid;
62930
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62931
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62932
+ yMap.set("type", "line");
62933
+ if (shadow) {
62934
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62935
+ }
62936
+ yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
62937
+ yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
62938
+ yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
62939
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62940
+ this.elements.set(uuid, yMap);
62941
+ }, elementsUndoOrigin);
62942
+ const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
62943
+ this.initElement(straightLineModel);
62661
62944
  straightLineModel.dashArray = this.toolbarModel.dashArray;
62662
- this.addElementToDoc(straightLineModel.root);
62663
62945
  return straightLineModel;
62664
62946
  }
62665
62947
  createLinePath(shadow) {
62666
62948
  if (!this.confirmPermission()) {
62667
62949
  return null;
62668
62950
  }
62669
- const lineModel = new LineModel(new Y12.Map(), this.scope);
62670
- this.initElement(lineModel, shadow);
62951
+ const yMap = new Y12.Map();
62952
+ this.elements.doc?.transact(() => {
62953
+ const uuid = this.uuid;
62954
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62955
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62956
+ yMap.set("type", "arrow");
62957
+ if (shadow) {
62958
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62959
+ }
62960
+ yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
62961
+ yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
62962
+ yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
62963
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62964
+ this.elements.set(uuid, yMap);
62965
+ }, elementsUndoOrigin);
62966
+ const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
62967
+ this.initElement(lineModel);
62671
62968
  lineModel.dashArray = this.toolbarModel.dashArray;
62672
- this.addElementToDoc(lineModel.root);
62673
62969
  return lineModel;
62674
62970
  }
62675
62971
  createPointText(x, y, shadow) {
62676
62972
  if (!this.confirmPermission()) {
62677
62973
  return null;
62678
62974
  }
62679
- const pointTextModel = new PointTextModel(new Y12.Map(), this.scope);
62975
+ const yMap = new Y12.Map();
62976
+ this.elements.doc?.transact(() => {
62977
+ const uuid = this.uuid;
62978
+ yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
62979
+ yMap.set(ElementModel.KEYS.uuid, uuid);
62980
+ yMap.set("type", "point-text");
62981
+ if (shadow) {
62982
+ yMap.set(ElementModel.KEYS.shadow, "layer");
62983
+ }
62984
+ yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
62985
+ yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
62986
+ yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
62987
+ yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
62988
+ this.elements.set(uuid, yMap);
62989
+ }, elementsUndoOrigin);
62990
+ const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
62680
62991
  pointTextModel.setPoints([x, y]);
62681
62992
  pointTextModel.fontSize = this.toolbarModel.fontSize;
62682
62993
  pointTextModel.fontFamily = this.toolbarModel.fontFamily;
62683
- this.initElement(pointTextModel, shadow);
62684
- this.addElementToDoc(pointTextModel.root);
62994
+ this.initElement(pointTextModel);
62685
62995
  return pointTextModel;
62686
62996
  }
62687
62997
  clearElement() {
@@ -62699,9 +63009,11 @@ var RenderableModel = class extends import_eventemitter3.default {
62699
63009
  removeIds.forEach((id) => this.elements.delete(id));
62700
63010
  });
62701
63011
  }
62702
- dispose() {
62703
- this.elements.unobserve(this.onElementsChange);
62704
- this.elements.clear();
63012
+ dispose(clearElements) {
63013
+ (0, import_forge_room2.removeObserver)(this.elements, this.onElementsChange);
63014
+ if (clearElements) {
63015
+ this.elements.clear();
63016
+ }
62705
63017
  Array.from(this.elementModels.values()).forEach((model) => {
62706
63018
  model.dispose();
62707
63019
  });
@@ -62924,14 +63236,14 @@ function Distance(p1, p2) {
62924
63236
  function Deg2Rad(d) {
62925
63237
  return d * Math.PI / 180;
62926
63238
  }
62927
- function _defineProperty17(e, r, t) {
62928
- return (r = _toPropertyKey17(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63239
+ function _defineProperty18(e, r, t) {
63240
+ return (r = _toPropertyKey18(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62929
63241
  }
62930
- function _toPropertyKey17(t) {
62931
- var i = _toPrimitive17(t, "string");
63242
+ function _toPropertyKey18(t) {
63243
+ var i = _toPrimitive18(t, "string");
62932
63244
  return "symbol" == typeof i ? i : i + "";
62933
63245
  }
62934
- function _toPrimitive17(t, r) {
63246
+ function _toPrimitive18(t, r) {
62935
63247
  if ("object" != typeof t || !t) return t;
62936
63248
  var e = t[Symbol.toPrimitive];
62937
63249
  if (void 0 !== e) {
@@ -62943,7 +63255,7 @@ function _toPrimitive17(t, r) {
62943
63255
  }
62944
63256
  var Recognizer = class {
62945
63257
  constructor() {
62946
- _defineProperty17(this, "dollar", new DollarRecognizer());
63258
+ _defineProperty18(this, "dollar", new DollarRecognizer());
62947
63259
  }
62948
63260
  recognize(points) {
62949
63261
  let minX = Number.MAX_VALUE;
@@ -62969,14 +63281,14 @@ var Recognizer = class {
62969
63281
  return null;
62970
63282
  }
62971
63283
  };
62972
- function _defineProperty18(e, r, t) {
62973
- return (r = _toPropertyKey18(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63284
+ function _defineProperty19(e, r, t) {
63285
+ return (r = _toPropertyKey19(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62974
63286
  }
62975
- function _toPropertyKey18(t) {
62976
- var i = _toPrimitive18(t, "string");
63287
+ function _toPropertyKey19(t) {
63288
+ var i = _toPrimitive19(t, "string");
62977
63289
  return "symbol" == typeof i ? i : i + "";
62978
63290
  }
62979
- function _toPrimitive18(t, r) {
63291
+ function _toPrimitive19(t, r) {
62980
63292
  if ("object" != typeof t || !t) return t;
62981
63293
  var e = t[Symbol.toPrimitive];
62982
63294
  if (void 0 !== e) {
@@ -62989,10 +63301,11 @@ function _toPrimitive18(t, r) {
62989
63301
  var CurveTool = class extends WhiteboardTool {
62990
63302
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
62991
63303
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
62992
- _defineProperty18(this, "elementModel", null);
62993
- _defineProperty18(this, "recognizer", new Recognizer());
62994
- _defineProperty18(this, "pointCount", 0);
62995
- this.tool.minDistance = 1;
63304
+ _defineProperty19(this, "elementModel", null);
63305
+ _defineProperty19(this, "recognizer", new Recognizer());
63306
+ _defineProperty19(this, "pointCount", 0);
63307
+ _defineProperty19(this, "showLiveCursor", true);
63308
+ this.tool.minDistance = 5;
62996
63309
  }
62997
63310
  onMouseDown(_event) {
62998
63311
  this.pointCount = 0;
@@ -63056,14 +63369,14 @@ var CurveTool = class extends WhiteboardTool {
63056
63369
  }
63057
63370
  }
63058
63371
  };
63059
- function _defineProperty19(e, r, t) {
63060
- return (r = _toPropertyKey19(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63372
+ function _defineProperty20(e, r, t) {
63373
+ return (r = _toPropertyKey20(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63061
63374
  }
63062
- function _toPropertyKey19(t) {
63063
- var i = _toPrimitive19(t, "string");
63375
+ function _toPropertyKey20(t) {
63376
+ var i = _toPrimitive20(t, "string");
63064
63377
  return "symbol" == typeof i ? i : i + "";
63065
63378
  }
63066
- function _toPrimitive19(t, r) {
63379
+ function _toPrimitive20(t, r) {
63067
63380
  if ("object" != typeof t || !t) return t;
63068
63381
  var e = t[Symbol.toPrimitive];
63069
63382
  if (void 0 !== e) {
@@ -63076,9 +63389,10 @@ function _toPrimitive19(t, r) {
63076
63389
  var RectangleTool = class extends WhiteboardTool {
63077
63390
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
63078
63391
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
63079
- _defineProperty19(this, "elementModel", null);
63080
- _defineProperty19(this, "from", null);
63081
- _defineProperty19(this, "to", null);
63392
+ _defineProperty20(this, "elementModel", null);
63393
+ _defineProperty20(this, "from", null);
63394
+ _defineProperty20(this, "to", null);
63395
+ _defineProperty20(this, "showLiveCursor", true);
63082
63396
  this.tool.minDistance = 1;
63083
63397
  }
63084
63398
  onMouseDown(event) {
@@ -63104,14 +63418,14 @@ var RectangleTool = class extends WhiteboardTool {
63104
63418
  }
63105
63419
  }
63106
63420
  };
63107
- function _defineProperty20(e, r, t) {
63108
- return (r = _toPropertyKey20(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63421
+ function _defineProperty21(e, r, t) {
63422
+ return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63109
63423
  }
63110
- function _toPropertyKey20(t) {
63111
- var i = _toPrimitive20(t, "string");
63424
+ function _toPropertyKey21(t) {
63425
+ var i = _toPrimitive21(t, "string");
63112
63426
  return "symbol" == typeof i ? i : i + "";
63113
63427
  }
63114
- function _toPrimitive20(t, r) {
63428
+ function _toPrimitive21(t, r) {
63115
63429
  if ("object" != typeof t || !t) return t;
63116
63430
  var e = t[Symbol.toPrimitive];
63117
63431
  if (void 0 !== e) {
@@ -63175,8 +63489,8 @@ var ToolbarModel = class extends import_eventemitter32.default {
63175
63489
  }
63176
63490
  constructor(root, defaultStyle) {
63177
63491
  super();
63178
- _defineProperty20(this, "root", void 0);
63179
- _defineProperty20(this, "handleRootUpdate", (evt) => {
63492
+ _defineProperty21(this, "root", void 0);
63493
+ _defineProperty21(this, "handleRootUpdate", (evt) => {
63180
63494
  for (const [key, value] of evt.changes.keys.entries()) {
63181
63495
  if (Object.keys(TOOLBAR_KEYS).indexOf(key) >= 0 && (value.action === "add" || value.action === "update")) {
63182
63496
  this.emit("update", {
@@ -63200,18 +63514,18 @@ var ToolbarModel = class extends import_eventemitter32.default {
63200
63514
  });
63201
63515
  }
63202
63516
  dispose() {
63203
- this.root.unobserve(this.handleRootUpdate);
63517
+ (0, import_forge_room6.removeObserver)(this.root, this.handleRootUpdate);
63204
63518
  this.removeAllListeners();
63205
63519
  }
63206
63520
  };
63207
- function _defineProperty21(e, r, t) {
63208
- return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63521
+ function _defineProperty22(e, r, t) {
63522
+ return (r = _toPropertyKey22(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63209
63523
  }
63210
- function _toPropertyKey21(t) {
63211
- var i = _toPrimitive21(t, "string");
63524
+ function _toPropertyKey22(t) {
63525
+ var i = _toPrimitive22(t, "string");
63212
63526
  return "symbol" == typeof i ? i : i + "";
63213
63527
  }
63214
- function _toPrimitive21(t, r) {
63528
+ function _toPrimitive22(t, r) {
63215
63529
  if ("object" != typeof t || !t) return t;
63216
63530
  var e = t[Symbol.toPrimitive];
63217
63531
  if (void 0 !== e) {
@@ -63224,11 +63538,12 @@ function _toPrimitive21(t, r) {
63224
63538
  var SelectorTool = class extends WhiteboardTool {
63225
63539
  constructor(enableToolEvent, renderableModel, shadowEmitter, scope, selectElementsModel) {
63226
63540
  super(enableToolEvent, renderableModel, shadowEmitter, scope);
63227
- _defineProperty21(this, "elementModel", null);
63228
- _defineProperty21(this, "from", null);
63229
- _defineProperty21(this, "to", null);
63230
- _defineProperty21(this, "selectElementsModel", void 0);
63231
- _defineProperty21(this, "selectElements", /* @__PURE__ */ new Map());
63541
+ _defineProperty22(this, "elementModel", null);
63542
+ _defineProperty22(this, "from", null);
63543
+ _defineProperty22(this, "to", null);
63544
+ _defineProperty22(this, "selectElementsModel", void 0);
63545
+ _defineProperty22(this, "selectElements", /* @__PURE__ */ new Map());
63546
+ _defineProperty22(this, "showLiveCursor", false);
63232
63547
  this.selectElementsModel = selectElementsModel;
63233
63548
  }
63234
63549
  onMouseDown(event) {
@@ -63292,14 +63607,14 @@ var WhiteboardKeys = {
63292
63607
  viewMatrix: "viewMatrix",
63293
63608
  cameraMode: "cameraMode"
63294
63609
  };
63295
- function _defineProperty22(e, r, t) {
63296
- return (r = _toPropertyKey22(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63610
+ function _defineProperty23(e, r, t) {
63611
+ return (r = _toPropertyKey23(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63297
63612
  }
63298
- function _toPropertyKey22(t) {
63299
- var i = _toPrimitive22(t, "string");
63613
+ function _toPropertyKey23(t) {
63614
+ var i = _toPrimitive23(t, "string");
63300
63615
  return "symbol" == typeof i ? i : i + "";
63301
63616
  }
63302
- function _toPrimitive22(t, r) {
63617
+ function _toPrimitive23(t, r) {
63303
63618
  if ("object" != typeof t || !t) return t;
63304
63619
  var e = t[Symbol.toPrimitive];
63305
63620
  if (void 0 !== e) {
@@ -63318,28 +63633,28 @@ var SelectElementsModel = class extends import_eventemitter33.default {
63318
63633
  }
63319
63634
  constructor(userManager, requestUserMap, hasPermission) {
63320
63635
  super();
63321
- _defineProperty22(this, "requestUserMap", void 0);
63322
- _defineProperty22(this, "userManager", void 0);
63323
- _defineProperty22(this, "hasPermission", void 0);
63324
- _defineProperty22(this, "observers", /* @__PURE__ */ new Map());
63325
- _defineProperty22(this, "handleUserLeave", (user) => {
63636
+ _defineProperty23(this, "requestUserMap", void 0);
63637
+ _defineProperty23(this, "userManager", void 0);
63638
+ _defineProperty23(this, "hasPermission", void 0);
63639
+ _defineProperty23(this, "observers", /* @__PURE__ */ new Map());
63640
+ _defineProperty23(this, "handleUserLeave", (user) => {
63326
63641
  const cb = this.observers.get(user.id);
63327
63642
  if (cb) {
63328
- this.requestUserMap(user.id).unobserveDeep(cb);
63643
+ (0, import_forge_room7.removeDeepObserver)(this.requestUserMap(user.id), cb);
63329
63644
  this.observers.delete(user.id);
63330
63645
  }
63331
63646
  });
63332
- _defineProperty22(this, "handleUserJoin", (user) => {
63647
+ _defineProperty23(this, "handleUserJoin", (user) => {
63333
63648
  const observer = (evts) => {
63334
63649
  this.handleUserSelectElementsChange(user.id, evts);
63335
63650
  };
63336
63651
  if (this.observers.has(user.id)) {
63337
- this.requestUserMap(user.id).unobserveDeep(this.observers.get(user.id));
63652
+ (0, import_forge_room7.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
63338
63653
  }
63339
63654
  this.requestUserMap(user.id).observeDeep(observer);
63340
63655
  this.observers.set(user.id, observer);
63341
63656
  });
63342
- _defineProperty22(this, "handleUserSelectElementsChange", (userId, evts) => {
63657
+ _defineProperty23(this, "handleUserSelectElementsChange", (userId, evts) => {
63343
63658
  for (const evt of evts) {
63344
63659
  if (evt.target.get("inner-map-id") === WhiteboardKeys.selectElements) {
63345
63660
  const elementIds = Array.from(evt.target.keys()).filter((v) => v !== "inner-map-id");
@@ -63356,7 +63671,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
63356
63671
  this.handleUserSelectElementsChange(userId, evts);
63357
63672
  };
63358
63673
  if (this.observers.has(userId)) {
63359
- this.requestUserMap(userId).unobserveDeep(this.observers.get(userId));
63674
+ (0, import_forge_room7.removeDeepObserver)(this.requestUserMap(userId), this.observers.get(userId));
63360
63675
  }
63361
63676
  this.requestUserMap(userId).observeDeep(observer);
63362
63677
  this.observers.set(userId, observer);
@@ -63413,21 +63728,21 @@ var SelectElementsModel = class extends import_eventemitter33.default {
63413
63728
  }
63414
63729
  dispose() {
63415
63730
  for (const [key, value] of this.observers.entries()) {
63416
- this.requestUserMap(key).unobserveDeep(value);
63731
+ (0, import_forge_room7.removeDeepObserver)(this.requestUserMap(key), value);
63417
63732
  }
63418
63733
  this.observers.clear();
63419
63734
  this.userManager.off("leave", this.handleUserLeave);
63420
63735
  this.userManager.off("join", this.handleUserJoin);
63421
63736
  }
63422
63737
  };
63423
- function _defineProperty23(e, r, t) {
63424
- return (r = _toPropertyKey23(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63738
+ function _defineProperty24(e, r, t) {
63739
+ return (r = _toPropertyKey24(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63425
63740
  }
63426
- function _toPropertyKey23(t) {
63427
- var i = _toPrimitive23(t, "string");
63741
+ function _toPropertyKey24(t) {
63742
+ var i = _toPrimitive24(t, "string");
63428
63743
  return "symbol" == typeof i ? i : i + "";
63429
63744
  }
63430
- function _toPrimitive23(t, r) {
63745
+ function _toPrimitive24(t, r) {
63431
63746
  if ("object" != typeof t || !t) return t;
63432
63747
  var e = t[Symbol.toPrimitive];
63433
63748
  if (void 0 !== e) {
@@ -63440,28 +63755,28 @@ function _toPrimitive23(t, r) {
63440
63755
  var TextEditor = class extends import_eventemitter35.EventEmitter {
63441
63756
  constructor(camera) {
63442
63757
  super();
63443
- _defineProperty23(this, "rootView", void 0);
63444
- _defineProperty23(this, "content", void 0);
63445
- _defineProperty23(this, "camera", void 0);
63446
- _defineProperty23(this, "originX", 0);
63447
- _defineProperty23(this, "originY", 0);
63448
- _defineProperty23(this, "rotation", 0);
63449
- _defineProperty23(this, "scale", 1);
63450
- _defineProperty23(this, "handleContentInput", () => {
63758
+ _defineProperty24(this, "rootView", void 0);
63759
+ _defineProperty24(this, "content", void 0);
63760
+ _defineProperty24(this, "camera", void 0);
63761
+ _defineProperty24(this, "originX", 0);
63762
+ _defineProperty24(this, "originY", 0);
63763
+ _defineProperty24(this, "rotation", 0);
63764
+ _defineProperty24(this, "scale", 1);
63765
+ _defineProperty24(this, "handleContentInput", () => {
63451
63766
  this.emit("change", this.content.textContent ?? "");
63452
63767
  this.translateCaretIntoView();
63453
63768
  });
63454
- _defineProperty23(this, "handleContentKeydown", (evt) => {
63769
+ _defineProperty24(this, "handleContentKeydown", (evt) => {
63455
63770
  if (/^Arrow/.test(evt.key)) {
63456
63771
  setTimeout(() => {
63457
63772
  this.translateCaretIntoView();
63458
63773
  }, 50);
63459
63774
  }
63460
63775
  });
63461
- _defineProperty23(this, "handleContentBlur", () => {
63776
+ _defineProperty24(this, "handleContentBlur", () => {
63462
63777
  this.emit("done", this.content.textContent ?? "");
63463
63778
  });
63464
- _defineProperty23(this, "handleRootClick", (evt) => {
63779
+ _defineProperty24(this, "handleRootClick", (evt) => {
63465
63780
  if (evt.target === this.rootView) {
63466
63781
  evt.stopPropagation();
63467
63782
  evt.preventDefault();
@@ -63551,14 +63866,14 @@ var TextEditor = class extends import_eventemitter35.EventEmitter {
63551
63866
  this.rootView.removeEventListener("pointerdown", this.handleRootClick);
63552
63867
  }
63553
63868
  };
63554
- function _defineProperty24(e, r, t) {
63555
- return (r = _toPropertyKey24(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63869
+ function _defineProperty25(e, r, t) {
63870
+ return (r = _toPropertyKey25(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63556
63871
  }
63557
- function _toPropertyKey24(t) {
63558
- var i = _toPrimitive24(t, "string");
63872
+ function _toPropertyKey25(t) {
63873
+ var i = _toPrimitive25(t, "string");
63559
63874
  return "symbol" == typeof i ? i : i + "";
63560
63875
  }
63561
- function _toPrimitive24(t, r) {
63876
+ function _toPrimitive25(t, r) {
63562
63877
  if ("object" != typeof t || !t) return t;
63563
63878
  var e = t[Symbol.toPrimitive];
63564
63879
  if (void 0 !== e) {
@@ -63593,12 +63908,12 @@ var Bounds = class extends import_eventemitter34.default {
63593
63908
  }
63594
63909
  constructor(binding, scope) {
63595
63910
  super();
63596
- _defineProperty24(this, "minX", 0);
63597
- _defineProperty24(this, "minY", 0);
63598
- _defineProperty24(this, "maxX", 0);
63599
- _defineProperty24(this, "maxY", 0);
63600
- _defineProperty24(this, "binding", void 0);
63601
- _defineProperty24(this, "scope", void 0);
63911
+ _defineProperty25(this, "minX", 0);
63912
+ _defineProperty25(this, "minY", 0);
63913
+ _defineProperty25(this, "maxX", 0);
63914
+ _defineProperty25(this, "maxY", 0);
63915
+ _defineProperty25(this, "binding", void 0);
63916
+ _defineProperty25(this, "scope", void 0);
63602
63917
  this.binding = binding;
63603
63918
  this.scope = scope;
63604
63919
  }
@@ -63720,32 +64035,32 @@ var Bounds = class extends import_eventemitter34.default {
63720
64035
  var Editor = class extends import_eventemitter34.default {
63721
64036
  constructor(scope, shadowScope, shadowEmitter, canvasElement, camera, initConfig) {
63722
64037
  super();
63723
- _defineProperty24(this, "rootView", void 0);
63724
- _defineProperty24(this, "frame", void 0);
63725
- _defineProperty24(this, "rotator", void 0);
63726
- _defineProperty24(this, "scope", void 0);
63727
- _defineProperty24(this, "shadowScope", void 0);
63728
- _defineProperty24(this, "shadowContainer", void 0);
63729
- _defineProperty24(this, "ctrlUserMap", void 0);
63730
- _defineProperty24(this, "viewerId", void 0);
63731
- _defineProperty24(this, "ctrlId", void 0);
63732
- _defineProperty24(this, "ctrlNickName", void 0);
63733
- _defineProperty24(this, "editMode", null);
63734
- _defineProperty24(this, "editCtrlName", null);
63735
- _defineProperty24(this, "editAnchor", null);
63736
- _defineProperty24(this, "lastEditPoint", null);
63737
- _defineProperty24(this, "bounds", void 0);
63738
- _defineProperty24(this, "targets", []);
63739
- _defineProperty24(this, "editorConfig", null);
63740
- _defineProperty24(this, "aspectRatio", -1);
63741
- _defineProperty24(this, "uniformScale", false);
63742
- _defineProperty24(this, "camera", void 0);
63743
- _defineProperty24(this, "canvasElement", void 0);
63744
- _defineProperty24(this, "resizeObserver", void 0);
63745
- _defineProperty24(this, "anchors", []);
63746
- _defineProperty24(this, "title", null);
63747
- _defineProperty24(this, "shadowEmitter", void 0);
63748
- _defineProperty24(this, "handleMatrix", (matrix) => {
64038
+ _defineProperty25(this, "rootView", void 0);
64039
+ _defineProperty25(this, "frame", void 0);
64040
+ _defineProperty25(this, "rotator", void 0);
64041
+ _defineProperty25(this, "scope", void 0);
64042
+ _defineProperty25(this, "shadowScope", void 0);
64043
+ _defineProperty25(this, "shadowContainer", void 0);
64044
+ _defineProperty25(this, "ctrlUserMap", void 0);
64045
+ _defineProperty25(this, "viewerId", void 0);
64046
+ _defineProperty25(this, "ctrlId", void 0);
64047
+ _defineProperty25(this, "ctrlNickName", void 0);
64048
+ _defineProperty25(this, "editMode", null);
64049
+ _defineProperty25(this, "editCtrlName", null);
64050
+ _defineProperty25(this, "editAnchor", null);
64051
+ _defineProperty25(this, "lastEditPoint", null);
64052
+ _defineProperty25(this, "bounds", void 0);
64053
+ _defineProperty25(this, "targets", []);
64054
+ _defineProperty25(this, "editorConfig", null);
64055
+ _defineProperty25(this, "aspectRatio", -1);
64056
+ _defineProperty25(this, "uniformScale", false);
64057
+ _defineProperty25(this, "camera", void 0);
64058
+ _defineProperty25(this, "canvasElement", void 0);
64059
+ _defineProperty25(this, "resizeObserver", void 0);
64060
+ _defineProperty25(this, "anchors", []);
64061
+ _defineProperty25(this, "title", null);
64062
+ _defineProperty25(this, "shadowEmitter", void 0);
64063
+ _defineProperty25(this, "handleMatrix", (matrix) => {
63749
64064
  if (this.shadowContainer) {
63750
64065
  const next = matrix.appended(this.shadowContainer.data.shadowMatrix ?? new this.shadowScope.Matrix());
63751
64066
  this.shadowContainer.data.shadowMatrix = next;
@@ -63755,7 +64070,7 @@ var Editor = class extends import_eventemitter34.default {
63755
64070
  this.targets.forEach((target) => target.appendPointsMatrix(matrix));
63756
64071
  }
63757
64072
  });
63758
- _defineProperty24(this, "handlePointerDown", (evt) => {
64073
+ _defineProperty25(this, "handlePointerDown", (evt) => {
63759
64074
  if (!evt.target) {
63760
64075
  return;
63761
64076
  }
@@ -63811,7 +64126,7 @@ var Editor = class extends import_eventemitter34.default {
63811
64126
  };
63812
64127
  }
63813
64128
  });
63814
- _defineProperty24(this, "handlePointerMove", (evt) => {
64129
+ _defineProperty25(this, "handlePointerMove", (evt) => {
63815
64130
  evt.preventDefault();
63816
64131
  if (!evt.target) {
63817
64132
  return;
@@ -63862,7 +64177,7 @@ var Editor = class extends import_eventemitter34.default {
63862
64177
  }
63863
64178
  }
63864
64179
  });
63865
- _defineProperty24(this, "handlePointerUp", (evt) => {
64180
+ _defineProperty25(this, "handlePointerUp", (evt) => {
63866
64181
  evt.preventDefault();
63867
64182
  this.resetShadow();
63868
64183
  this.shadowEmitter.setActive(false);
@@ -63879,7 +64194,7 @@ var Editor = class extends import_eventemitter34.default {
63879
64194
  this.lastEditPoint = null;
63880
64195
  this.uniformScale = false;
63881
64196
  });
63882
- _defineProperty24(this, "handleFrameDBClick", (evt) => {
64197
+ _defineProperty25(this, "handleFrameDBClick", (evt) => {
63883
64198
  if (evt.target === this.frame && this.targets.length === 1) {
63884
64199
  if (this.targets[0].type === "point-text") {
63885
64200
  this.frame.style.display = "none";
@@ -63887,7 +64202,7 @@ var Editor = class extends import_eventemitter34.default {
63887
64202
  }
63888
64203
  }
63889
64204
  });
63890
- _defineProperty24(this, "updateBounds", () => {
64205
+ _defineProperty25(this, "updateBounds", () => {
63891
64206
  let minX = Number.MAX_VALUE;
63892
64207
  let maxX = -Number.MAX_VALUE;
63893
64208
  let minY = Number.MAX_VALUE;
@@ -63920,7 +64235,7 @@ var Editor = class extends import_eventemitter34.default {
63920
64235
  this.ctrlId = initConfig.ctrlId;
63921
64236
  this.ctrlNickName = initConfig.ctrlNickName;
63922
64237
  this.rootView = document.createElement("div");
63923
- this.rootView.style.cssText = "position:absolute;display:none;width:100%;height:100%;top:50%;left:50%;transform:translate(-50%,-50%);";
64238
+ this.rootView.style.cssText = "overflow:hidden;position:absolute;display:none;width:100%;height:100%;top:50%;left:50%;transform:translate(-50%,-50%);";
63924
64239
  this.frame = document.createElement("div");
63925
64240
  this.frame.style.position = "absolute";
63926
64241
  this.frame.style.padding = "8px";
@@ -64137,14 +64452,14 @@ var Editor = class extends import_eventemitter34.default {
64137
64452
  this.resizeObserver.disconnect();
64138
64453
  }
64139
64454
  };
64140
- function _defineProperty25(e, r, t) {
64141
- return (r = _toPropertyKey25(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64455
+ function _defineProperty26(e, r, t) {
64456
+ return (r = _toPropertyKey26(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64142
64457
  }
64143
- function _toPropertyKey25(t) {
64144
- var i = _toPrimitive25(t, "string");
64458
+ function _toPropertyKey26(t) {
64459
+ var i = _toPrimitive26(t, "string");
64145
64460
  return "symbol" == typeof i ? i : i + "";
64146
64461
  }
64147
- function _toPrimitive25(t, r) {
64462
+ function _toPrimitive26(t, r) {
64148
64463
  if ("object" != typeof t || !t) return t;
64149
64464
  var e = t[Symbol.toPrimitive];
64150
64465
  if (void 0 !== e) {
@@ -64157,13 +64472,14 @@ function _toPrimitive25(t, r) {
64157
64472
  var TextTool = class extends WhiteboardTool {
64158
64473
  constructor(enableToolEvent, model, shadowEmitter, scope, rootView, canvasElement, toolbarModel, camera) {
64159
64474
  super(enableToolEvent, model, shadowEmitter, scope);
64160
- _defineProperty25(this, "from", null);
64161
- _defineProperty25(this, "to", null);
64162
- _defineProperty25(this, "rootView", void 0);
64163
- _defineProperty25(this, "canvasElement", void 0);
64164
- _defineProperty25(this, "elementModel", null);
64165
- _defineProperty25(this, "toolbarModel", void 0);
64166
- _defineProperty25(this, "camera", void 0);
64475
+ _defineProperty26(this, "from", null);
64476
+ _defineProperty26(this, "to", null);
64477
+ _defineProperty26(this, "rootView", void 0);
64478
+ _defineProperty26(this, "canvasElement", void 0);
64479
+ _defineProperty26(this, "elementModel", null);
64480
+ _defineProperty26(this, "toolbarModel", void 0);
64481
+ _defineProperty26(this, "camera", void 0);
64482
+ _defineProperty26(this, "showLiveCursor", false);
64167
64483
  this.rootView = rootView;
64168
64484
  this.canvasElement = canvasElement;
64169
64485
  this.toolbarModel = toolbarModel;
@@ -64225,14 +64541,14 @@ var TextTool = class extends WhiteboardTool {
64225
64541
  }, 30);
64226
64542
  }
64227
64543
  };
64228
- function _defineProperty26(e, r, t) {
64229
- return (r = _toPropertyKey26(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64544
+ function _defineProperty27(e, r, t) {
64545
+ return (r = _toPropertyKey27(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64230
64546
  }
64231
- function _toPropertyKey26(t) {
64232
- var i = _toPrimitive26(t, "string");
64547
+ function _toPropertyKey27(t) {
64548
+ var i = _toPrimitive27(t, "string");
64233
64549
  return "symbol" == typeof i ? i : i + "";
64234
64550
  }
64235
- function _toPrimitive26(t, r) {
64551
+ function _toPrimitive27(t, r) {
64236
64552
  if ("object" != typeof t || !t) return t;
64237
64553
  var e = t[Symbol.toPrimitive];
64238
64554
  if (void 0 !== e) {
@@ -64245,11 +64561,11 @@ function _toPrimitive26(t, r) {
64245
64561
  var Gesture = class extends import_eventemitter37.default {
64246
64562
  constructor(element, scope) {
64247
64563
  super();
64248
- _defineProperty26(this, "element", void 0);
64249
- _defineProperty26(this, "scope", void 0);
64250
- _defineProperty26(this, "lastVector", null);
64251
- _defineProperty26(this, "lastPoint", null);
64252
- _defineProperty26(this, "onTouchStart", (evt) => {
64564
+ _defineProperty27(this, "element", void 0);
64565
+ _defineProperty27(this, "scope", void 0);
64566
+ _defineProperty27(this, "lastVector", null);
64567
+ _defineProperty27(this, "lastPoint", null);
64568
+ _defineProperty27(this, "onTouchStart", (evt) => {
64253
64569
  if (evt.touches.length > 1) {
64254
64570
  evt.preventDefault();
64255
64571
  evt.stopPropagation();
@@ -64262,7 +64578,7 @@ var Gesture = class extends import_eventemitter37.default {
64262
64578
  this.lastVector = p2.subtract(p1);
64263
64579
  this.lastPoint = p1;
64264
64580
  });
64265
- _defineProperty26(this, "onTouchMove", (evt) => {
64581
+ _defineProperty27(this, "onTouchMove", (evt) => {
64266
64582
  if (this.lastVector && this.lastPoint && evt.touches.length === 2) {
64267
64583
  evt.preventDefault();
64268
64584
  evt.stopPropagation();
@@ -64293,7 +64609,7 @@ var Gesture = class extends import_eventemitter37.default {
64293
64609
  this.lastPoint = null;
64294
64610
  }
64295
64611
  });
64296
- _defineProperty26(this, "onTouchEnd", () => {
64612
+ _defineProperty27(this, "onTouchEnd", () => {
64297
64613
  this.lastVector = null;
64298
64614
  this.lastPoint = null;
64299
64615
  });
@@ -64304,14 +64620,14 @@ var Gesture = class extends import_eventemitter37.default {
64304
64620
  this.element.addEventListener("touchend", this.onTouchEnd);
64305
64621
  }
64306
64622
  };
64307
- function _defineProperty27(e, r, t) {
64308
- return (r = _toPropertyKey27(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64623
+ function _defineProperty28(e, r, t) {
64624
+ return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64309
64625
  }
64310
- function _toPropertyKey27(t) {
64311
- var i = _toPrimitive27(t, "string");
64626
+ function _toPropertyKey28(t) {
64627
+ var i = _toPrimitive28(t, "string");
64312
64628
  return "symbol" == typeof i ? i : i + "";
64313
64629
  }
64314
- function _toPrimitive27(t, r) {
64630
+ function _toPrimitive28(t, r) {
64315
64631
  if ("object" != typeof t || !t) return t;
64316
64632
  var e = t[Symbol.toPrimitive];
64317
64633
  if (void 0 !== e) {
@@ -64333,31 +64649,31 @@ var Camera = class extends import_eventemitter36.default {
64333
64649
  }
64334
64650
  constructor(initSize, maxScale, dom, userManager, scope, whiteboardAttrsMap, hasPermission, requestUserMap, _paperSize, _domSize) {
64335
64651
  super();
64336
- _defineProperty27(this, "scope", void 0);
64337
- _defineProperty27(this, "dom", void 0);
64338
- _defineProperty27(this, "lastTriggerTime", 0);
64339
- _defineProperty27(this, "lastDelta", {
64652
+ _defineProperty28(this, "scope", void 0);
64653
+ _defineProperty28(this, "dom", void 0);
64654
+ _defineProperty28(this, "lastTriggerTime", 0);
64655
+ _defineProperty28(this, "lastDelta", {
64340
64656
  x: 0,
64341
64657
  y: 0
64342
64658
  });
64343
- _defineProperty27(this, "requestUserMap", void 0);
64344
- _defineProperty27(this, "userManager", void 0);
64345
- _defineProperty27(this, "observers", /* @__PURE__ */ new Map());
64346
- _defineProperty27(this, "whiteboardAttrsMap", void 0);
64347
- _defineProperty27(this, "paperSize", void 0);
64348
- _defineProperty27(this, "domSize", void 0);
64349
- _defineProperty27(this, "hasPermission", void 0);
64350
- _defineProperty27(this, "gesture", void 0);
64351
- _defineProperty27(this, "inherentScale", 1);
64352
- _defineProperty27(this, "maxScale", void 0);
64353
- _defineProperty27(this, "initSize", void 0);
64354
- _defineProperty27(this, "bound", void 0);
64355
- _defineProperty27(this, "boundTiemoutId", void 0);
64356
- _defineProperty27(this, "enableByMouse", true);
64357
- _defineProperty27(this, "enableByTouch", true);
64358
- _defineProperty27(this, "boundaryColor", "#F44336");
64359
- _defineProperty27(this, "enableBoundaryHighlight", true);
64360
- _defineProperty27(this, "handleMainCameraChange", (evt) => {
64659
+ _defineProperty28(this, "requestUserMap", void 0);
64660
+ _defineProperty28(this, "userManager", void 0);
64661
+ _defineProperty28(this, "observers", /* @__PURE__ */ new Map());
64662
+ _defineProperty28(this, "whiteboardAttrsMap", void 0);
64663
+ _defineProperty28(this, "paperSize", void 0);
64664
+ _defineProperty28(this, "domSize", void 0);
64665
+ _defineProperty28(this, "hasPermission", void 0);
64666
+ _defineProperty28(this, "gesture", void 0);
64667
+ _defineProperty28(this, "inherentScale", 1);
64668
+ _defineProperty28(this, "maxScale", void 0);
64669
+ _defineProperty28(this, "initSize", void 0);
64670
+ _defineProperty28(this, "bound", void 0);
64671
+ _defineProperty28(this, "boundTiemoutId", void 0);
64672
+ _defineProperty28(this, "enableByMouse", true);
64673
+ _defineProperty28(this, "enableByTouch", true);
64674
+ _defineProperty28(this, "boundaryColor", "#F44336");
64675
+ _defineProperty28(this, "enableBoundaryHighlight", true);
64676
+ _defineProperty28(this, "handleMainCameraChange", (evt) => {
64361
64677
  const userMap = this.requestUserMap(this.userManager.selfId);
64362
64678
  const cameraMode = userMap.get(WhiteboardKeys.cameraMode);
64363
64679
  if (cameraMode !== "main") {
@@ -64374,23 +64690,23 @@ var Camera = class extends import_eventemitter36.default {
64374
64690
  }
64375
64691
  }
64376
64692
  });
64377
- _defineProperty27(this, "handleUserLeave", (user) => {
64693
+ _defineProperty28(this, "handleUserLeave", (user) => {
64378
64694
  const cb = this.observers.get(user.id);
64379
64695
  if (cb) {
64380
- this.requestUserMap(user.id).unobserve(cb);
64696
+ (0, import_forge_room8.removeObserver)(this.requestUserMap(user.id), cb);
64381
64697
  }
64382
64698
  });
64383
- _defineProperty27(this, "handleUserJoin", (user) => {
64699
+ _defineProperty28(this, "handleUserJoin", (user) => {
64384
64700
  const observer = (evt) => {
64385
64701
  this.handleViewMatrixUpdate(user.id, evt);
64386
64702
  };
64387
64703
  if (this.observers.has(user.id)) {
64388
- this.requestUserMap(user.id).unobserve(observer);
64704
+ (0, import_forge_room8.removeObserver)(this.requestUserMap(user.id), observer);
64389
64705
  }
64390
64706
  this.requestUserMap(user.id).observe(observer);
64391
64707
  this.observers.set(user.id, observer);
64392
64708
  });
64393
- _defineProperty27(this, "handleViewMatrixUpdate", (userId, evt) => {
64709
+ _defineProperty28(this, "handleViewMatrixUpdate", (userId, evt) => {
64394
64710
  const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
64395
64711
  for (const [key, value] of evt.changes.keys.entries()) {
64396
64712
  if (value.action === "update") {
@@ -64417,7 +64733,7 @@ var Camera = class extends import_eventemitter36.default {
64417
64733
  }
64418
64734
  }
64419
64735
  });
64420
- _defineProperty27(this, "handleWheel", (evt) => {
64736
+ _defineProperty28(this, "handleWheel", (evt) => {
64421
64737
  if (!this.enableByMouse) {
64422
64738
  return;
64423
64739
  }
@@ -64492,7 +64808,7 @@ var Camera = class extends import_eventemitter36.default {
64492
64808
  this.handleViewMatrixUpdate(userId, evt);
64493
64809
  };
64494
64810
  if (this.observers.has(userId)) {
64495
- this.requestUserMap(userId).unobserve(observer);
64811
+ (0, import_forge_room8.removeObserver)(this.requestUserMap(userId), observer);
64496
64812
  }
64497
64813
  this.requestUserMap(userId).observe(observer);
64498
64814
  this.observers.set(userId, observer);
@@ -64689,24 +65005,24 @@ var Camera = class extends import_eventemitter36.default {
64689
65005
  Array.from(this.observers.keys()).forEach((userId) => {
64690
65006
  const cb = this.observers.get(userId);
64691
65007
  if (cb) {
64692
- this.requestUserMap(userId).unobserve(cb);
65008
+ (0, import_forge_room8.removeObserver)(this.requestUserMap(userId), cb);
64693
65009
  }
64694
65010
  });
64695
- this.whiteboardAttrsMap.unobserve(this.handleMainCameraChange);
65011
+ (0, import_forge_room8.removeObserver)(this.whiteboardAttrsMap, this.handleMainCameraChange);
64696
65012
  this.userManager.off("join", this.handleUserJoin);
64697
65013
  this.userManager.off("leave", this.handleUserLeave);
64698
65014
  this.gesture.removeAllListeners();
64699
65015
  this.removeAllListeners();
64700
65016
  }
64701
65017
  };
64702
- function _defineProperty28(e, r, t) {
64703
- return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65018
+ function _defineProperty29(e, r, t) {
65019
+ return (r = _toPropertyKey29(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64704
65020
  }
64705
- function _toPropertyKey28(t) {
64706
- var i = _toPrimitive28(t, "string");
65021
+ function _toPropertyKey29(t) {
65022
+ var i = _toPrimitive29(t, "string");
64707
65023
  return "symbol" == typeof i ? i : i + "";
64708
65024
  }
64709
- function _toPrimitive28(t, r) {
65025
+ function _toPrimitive29(t, r) {
64710
65026
  if ("object" != typeof t || !t) return t;
64711
65027
  var e = t[Symbol.toPrimitive];
64712
65028
  if (void 0 !== e) {
@@ -64719,9 +65035,10 @@ function _toPrimitive28(t, r) {
64719
65035
  var EllipseTool = class extends WhiteboardTool {
64720
65036
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
64721
65037
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
64722
- _defineProperty28(this, "elementModel", null);
64723
- _defineProperty28(this, "from", null);
64724
- _defineProperty28(this, "to", null);
65038
+ _defineProperty29(this, "elementModel", null);
65039
+ _defineProperty29(this, "from", null);
65040
+ _defineProperty29(this, "to", null);
65041
+ _defineProperty29(this, "showLiveCursor", true);
64725
65042
  this.tool.minDistance = 1;
64726
65043
  }
64727
65044
  onMouseDown(event) {
@@ -64751,14 +65068,14 @@ var EllipseTool = class extends WhiteboardTool {
64751
65068
  }
64752
65069
  }
64753
65070
  };
64754
- function _defineProperty29(e, r, t) {
64755
- return (r = _toPropertyKey29(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65071
+ function _defineProperty30(e, r, t) {
65072
+ return (r = _toPropertyKey30(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64756
65073
  }
64757
- function _toPropertyKey29(t) {
64758
- var i = _toPrimitive29(t, "string");
65074
+ function _toPropertyKey30(t) {
65075
+ var i = _toPrimitive30(t, "string");
64759
65076
  return "symbol" == typeof i ? i : i + "";
64760
65077
  }
64761
- function _toPrimitive29(t, r) {
65078
+ function _toPrimitive30(t, r) {
64762
65079
  if ("object" != typeof t || !t) return t;
64763
65080
  var e = t[Symbol.toPrimitive];
64764
65081
  if (void 0 !== e) {
@@ -64771,9 +65088,10 @@ function _toPrimitive29(t, r) {
64771
65088
  var TriangleTool = class extends WhiteboardTool {
64772
65089
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
64773
65090
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
64774
- _defineProperty29(this, "elementModel", null);
64775
- _defineProperty29(this, "from", null);
64776
- _defineProperty29(this, "to", null);
65091
+ _defineProperty30(this, "elementModel", null);
65092
+ _defineProperty30(this, "from", null);
65093
+ _defineProperty30(this, "to", null);
65094
+ _defineProperty30(this, "showLiveCursor", true);
64777
65095
  this.tool.minDistance = 1;
64778
65096
  }
64779
65097
  onMouseDown(event) {
@@ -64799,14 +65117,14 @@ var TriangleTool = class extends WhiteboardTool {
64799
65117
  }
64800
65118
  }
64801
65119
  };
64802
- function _defineProperty30(e, r, t) {
64803
- return (r = _toPropertyKey30(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65120
+ function _defineProperty31(e, r, t) {
65121
+ return (r = _toPropertyKey31(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64804
65122
  }
64805
- function _toPropertyKey30(t) {
64806
- var i = _toPrimitive30(t, "string");
65123
+ function _toPropertyKey31(t) {
65124
+ var i = _toPrimitive31(t, "string");
64807
65125
  return "symbol" == typeof i ? i : i + "";
64808
65126
  }
64809
- function _toPrimitive30(t, r) {
65127
+ function _toPrimitive31(t, r) {
64810
65128
  if ("object" != typeof t || !t) return t;
64811
65129
  var e = t[Symbol.toPrimitive];
64812
65130
  if (void 0 !== e) {
@@ -64817,62 +65135,65 @@ function _toPrimitive30(t, r) {
64817
65135
  return ("string" === r ? String : Number)(t);
64818
65136
  }
64819
65137
  var Whiteboard = class extends import_eventemitter38.default {
64820
- // public insertImage!: (src: string) => void;
64821
65138
  constructor(view) {
64822
65139
  super();
64823
- _defineProperty30(this, "view", void 0);
64824
- _defineProperty30(this, "selfUserId", void 0);
64825
- _defineProperty30(this, "permissions", void 0);
64826
- _defineProperty30(this, "tool", void 0);
64827
- _defineProperty30(this, "fontSize", void 0);
64828
- _defineProperty30(this, "dashArray", void 0);
64829
- _defineProperty30(this, "fontFamily", void 0);
64830
- _defineProperty30(this, "strokeColor", void 0);
64831
- _defineProperty30(this, "fillColor", void 0);
64832
- _defineProperty30(this, "strokeWidth", void 0);
64833
- _defineProperty30(this, "enableCameraByMouse", void 0);
64834
- _defineProperty30(this, "enableCameraByTouch", void 0);
64835
- _defineProperty30(this, "cameraBoundaryColor", void 0);
64836
- _defineProperty30(this, "enableCameraBoundaryHighlight", void 0);
64837
- _defineProperty30(this, "getElementAttribute", void 0);
64838
- _defineProperty30(this, "setElementAttribute", void 0);
64839
- _defineProperty30(this, "getCurrentTool", void 0);
64840
- _defineProperty30(this, "setCurrentTool", void 0);
64841
- _defineProperty30(this, "setCanvasBackgroundColor", void 0);
64842
- _defineProperty30(this, "setThemeColor", void 0);
64843
- _defineProperty30(this, "gotoPage", void 0);
64844
- _defineProperty30(this, "addPage", void 0);
64845
- _defineProperty30(this, "deletePage", void 0);
64846
- _defineProperty30(this, "pageList", void 0);
64847
- _defineProperty30(this, "currentPageId", void 0);
64848
- _defineProperty30(this, "clonePage", void 0);
64849
- _defineProperty30(this, "clearPage", void 0);
64850
- _defineProperty30(this, "translateCamera", void 0);
64851
- _defineProperty30(this, "scaleCamera", void 0);
64852
- _defineProperty30(this, "resetCamera", void 0);
64853
- _defineProperty30(this, "setFreeModelUserPage", void 0);
64854
- _defineProperty30(this, "indexedNavigation", void 0);
64855
- _defineProperty30(this, "setViewModeToFree", void 0);
64856
- _defineProperty30(this, "setViewModeToFlow", void 0);
64857
- _defineProperty30(this, "setViewModeToMain", void 0);
64858
- _defineProperty30(this, "getViewModel", void 0);
64859
- _defineProperty30(this, "undo", void 0);
64860
- _defineProperty30(this, "redo", void 0);
64861
- _defineProperty30(this, "rasterizeViewport", void 0);
64862
- _defineProperty30(this, "rasterizeElementsBounds", void 0);
64863
- _defineProperty30(this, "rasterizeMaxBounds", void 0);
64864
- _defineProperty30(this, "setInputType", void 0);
65140
+ _defineProperty31(this, "view", void 0);
65141
+ _defineProperty31(this, "selfUserId", void 0);
65142
+ _defineProperty31(this, "permissions", void 0);
65143
+ _defineProperty31(this, "tool", void 0);
65144
+ _defineProperty31(this, "fontSize", void 0);
65145
+ _defineProperty31(this, "dashArray", void 0);
65146
+ _defineProperty31(this, "fontFamily", void 0);
65147
+ _defineProperty31(this, "strokeColor", void 0);
65148
+ _defineProperty31(this, "fillColor", void 0);
65149
+ _defineProperty31(this, "strokeWidth", void 0);
65150
+ _defineProperty31(this, "enableCameraByMouse", void 0);
65151
+ _defineProperty31(this, "enableCameraByTouch", void 0);
65152
+ _defineProperty31(this, "cameraBoundaryColor", void 0);
65153
+ _defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
65154
+ _defineProperty31(this, "getElementAttribute", void 0);
65155
+ _defineProperty31(this, "setElementAttribute", void 0);
65156
+ _defineProperty31(this, "removeElement", void 0);
65157
+ _defineProperty31(this, "getCurrentTool", void 0);
65158
+ _defineProperty31(this, "setCurrentTool", void 0);
65159
+ _defineProperty31(this, "setCanvasBackgroundColor", void 0);
65160
+ _defineProperty31(this, "setThemeColor", void 0);
65161
+ _defineProperty31(this, "gotoPage", void 0);
65162
+ _defineProperty31(this, "addPage", void 0);
65163
+ _defineProperty31(this, "deletePage", void 0);
65164
+ _defineProperty31(this, "pageList", void 0);
65165
+ _defineProperty31(this, "currentPageId", void 0);
65166
+ _defineProperty31(this, "clonePage", void 0);
65167
+ _defineProperty31(this, "clearPage", void 0);
65168
+ _defineProperty31(this, "translateCamera", void 0);
65169
+ _defineProperty31(this, "scaleCamera", void 0);
65170
+ _defineProperty31(this, "resetCamera", void 0);
65171
+ _defineProperty31(this, "showLiveCursor", void 0);
65172
+ _defineProperty31(this, "updateViewport", void 0);
65173
+ _defineProperty31(this, "setFreeModelUserPage", void 0);
65174
+ _defineProperty31(this, "indexedNavigation", void 0);
65175
+ _defineProperty31(this, "setViewModeToFree", void 0);
65176
+ _defineProperty31(this, "setViewModeToFlow", void 0);
65177
+ _defineProperty31(this, "setViewModeToMain", void 0);
65178
+ _defineProperty31(this, "getViewModel", void 0);
65179
+ _defineProperty31(this, "undo", void 0);
65180
+ _defineProperty31(this, "redo", void 0);
65181
+ _defineProperty31(this, "rasterizeViewport", void 0);
65182
+ _defineProperty31(this, "rasterizeElementsBounds", void 0);
65183
+ _defineProperty31(this, "rasterizeMaxBounds", void 0);
65184
+ _defineProperty31(this, "setInputType", void 0);
65185
+ _defineProperty31(this, "insertImage", void 0);
64865
65186
  this.view = view;
64866
65187
  }
64867
65188
  };
64868
- function _defineProperty31(e, r, t) {
64869
- return (r = _toPropertyKey31(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65189
+ function _defineProperty32(e, r, t) {
65190
+ return (r = _toPropertyKey32(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64870
65191
  }
64871
- function _toPropertyKey31(t) {
64872
- var i = _toPrimitive31(t, "string");
65192
+ function _toPropertyKey32(t) {
65193
+ var i = _toPrimitive32(t, "string");
64873
65194
  return "symbol" == typeof i ? i : i + "";
64874
65195
  }
64875
- function _toPrimitive31(t, r) {
65196
+ function _toPrimitive32(t, r) {
64876
65197
  if ("object" != typeof t || !t) return t;
64877
65198
  var e = t[Symbol.toPrimitive];
64878
65199
  if (void 0 !== e) {
@@ -64883,13 +65204,16 @@ function _toPrimitive31(t, r) {
64883
65204
  return ("string" === r ? String : Number)(t);
64884
65205
  }
64885
65206
  var EraserTool = class extends WhiteboardTool {
64886
- constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel) {
65207
+ constructor(enableToolEvent, renderableModel, shadowEmitter, scope, trashedElementsModel, shadowScope) {
64887
65208
  super(enableToolEvent, renderableModel, shadowEmitter, scope);
64888
- _defineProperty31(this, "elementModel", null);
64889
- _defineProperty31(this, "trashedElementsModel", void 0);
64890
- _defineProperty31(this, "pointCount", 0);
65209
+ _defineProperty32(this, "elementModel", null);
65210
+ _defineProperty32(this, "trashedElementsModel", void 0);
65211
+ _defineProperty32(this, "pointCount", 0);
65212
+ _defineProperty32(this, "showLiveCursor", true);
65213
+ _defineProperty32(this, "shadowScope", void 0);
64891
65214
  this.trashedElementsModel = trashedElementsModel;
64892
- this.tool.minDistance = 1;
65215
+ this.tool.minDistance = 2;
65216
+ this.shadowScope = shadowScope;
64893
65217
  }
64894
65218
  onMouseDown(_event) {
64895
65219
  this.pointCount = 0;
@@ -64916,6 +65240,16 @@ var EraserTool = class extends WhiteboardTool {
64916
65240
  this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
64917
65241
  }
64918
65242
  });
65243
+ this.shadowScope.project.activeLayer.children.forEach((item) => {
65244
+ if (item.data.type && ["selector", "eraser", "laser"].indexOf(item.data.type) < 0 && item.hitTest(event.point, {
65245
+ segments: true,
65246
+ stroke: true,
65247
+ fill: true,
65248
+ tolerance: 5
65249
+ })) {
65250
+ this.trashedElementsModel.addTrashedElementForSelf(item.data.uuid, item.data.ownerId);
65251
+ }
65252
+ });
64919
65253
  }
64920
65254
  onMouseUp(_event) {
64921
65255
  if (this.elementModel) {
@@ -64924,14 +65258,14 @@ var EraserTool = class extends WhiteboardTool {
64924
65258
  this.trashedElementsModel.removeAllTrashedElementsForSelf();
64925
65259
  }
64926
65260
  };
64927
- function _defineProperty32(e, r, t) {
64928
- return (r = _toPropertyKey32(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65261
+ function _defineProperty33(e, r, t) {
65262
+ return (r = _toPropertyKey33(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
64929
65263
  }
64930
- function _toPropertyKey32(t) {
64931
- var i = _toPrimitive32(t, "string");
65264
+ function _toPropertyKey33(t) {
65265
+ var i = _toPrimitive33(t, "string");
64932
65266
  return "symbol" == typeof i ? i : i + "";
64933
65267
  }
64934
- function _toPrimitive32(t, r) {
65268
+ function _toPrimitive33(t, r) {
64935
65269
  if ("object" != typeof t || !t) return t;
64936
65270
  var e = t[Symbol.toPrimitive];
64937
65271
  if (void 0 !== e) {
@@ -64950,22 +65284,22 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
64950
65284
  }
64951
65285
  constructor(userManager, requestUserMap, hasPermission) {
64952
65286
  super();
64953
- _defineProperty32(this, "requestUserMap", void 0);
64954
- _defineProperty32(this, "userManager", void 0);
64955
- _defineProperty32(this, "hasPermission", void 0);
64956
- _defineProperty32(this, "observers", /* @__PURE__ */ new Map());
64957
- _defineProperty32(this, "handleUserLeave", (user) => {
65287
+ _defineProperty33(this, "requestUserMap", void 0);
65288
+ _defineProperty33(this, "userManager", void 0);
65289
+ _defineProperty33(this, "hasPermission", void 0);
65290
+ _defineProperty33(this, "observers", /* @__PURE__ */ new Map());
65291
+ _defineProperty33(this, "handleUserLeave", (user) => {
64958
65292
  const cb = this.observers.get(user.id);
64959
65293
  if (cb) {
64960
- this.requestUserMap(user.id).unobserveDeep(cb);
65294
+ (0, import_forge_room9.removeDeepObserver)(this.requestUserMap(user.id), cb);
64961
65295
  }
64962
65296
  });
64963
- _defineProperty32(this, "handleUserJoin", (user) => {
65297
+ _defineProperty33(this, "handleUserJoin", (user) => {
64964
65298
  const observer = (evts) => {
64965
65299
  this.handleUserTrashElementsChange(user.id, evts);
64966
65300
  };
64967
65301
  if (this.observers.has(user.id)) {
64968
- this.requestUserMap(user.id).unobserveDeep(this.observers.get(user.id));
65302
+ (0, import_forge_room9.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
64969
65303
  }
64970
65304
  this.requestUserMap(user.id).observeDeep(observer);
64971
65305
  this.observers.set(user.id, observer);
@@ -64979,7 +65313,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
64979
65313
  this.handleUserTrashElementsChange(userId, evts);
64980
65314
  };
64981
65315
  if (this.observers.has(userId)) {
64982
- this.requestUserMap(userId).unobserveDeep(this.observers.get(userId));
65316
+ (0, import_forge_room9.removeDeepObserver)(this.requestUserMap(userId), userId);
64983
65317
  }
64984
65318
  this.requestUserMap(userId).observeDeep(observer);
64985
65319
  this.observers.set(userId, observer);
@@ -65036,21 +65370,21 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
65036
65370
  }
65037
65371
  dispose() {
65038
65372
  for (const [key, value] of this.observers.entries()) {
65039
- this.requestUserMap(key).unobserveDeep(value);
65373
+ (0, import_forge_room9.removeDeepObserver)(this.requestUserMap(key), value);
65040
65374
  }
65041
65375
  this.observers.clear();
65042
65376
  this.userManager.off("leave", this.handleUserLeave);
65043
65377
  this.userManager.off("join", this.handleUserJoin);
65044
65378
  }
65045
65379
  };
65046
- function _defineProperty33(e, r, t) {
65047
- return (r = _toPropertyKey33(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65380
+ function _defineProperty34(e, r, t) {
65381
+ return (r = _toPropertyKey34(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65048
65382
  }
65049
- function _toPropertyKey33(t) {
65050
- var i = _toPrimitive33(t, "string");
65383
+ function _toPropertyKey34(t) {
65384
+ var i = _toPrimitive34(t, "string");
65051
65385
  return "symbol" == typeof i ? i : i + "";
65052
65386
  }
65053
- function _toPrimitive33(t, r) {
65387
+ function _toPrimitive34(t, r) {
65054
65388
  if ("object" != typeof t || !t) return t;
65055
65389
  var e = t[Symbol.toPrimitive];
65056
65390
  if (void 0 !== e) {
@@ -65063,8 +65397,9 @@ function _toPrimitive33(t, r) {
65063
65397
  var LaserPointerTool = class extends WhiteboardTool {
65064
65398
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
65065
65399
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
65066
- _defineProperty33(this, "elementModel", null);
65067
- _defineProperty33(this, "pointCount", 0);
65400
+ _defineProperty34(this, "elementModel", null);
65401
+ _defineProperty34(this, "pointCount", 0);
65402
+ _defineProperty34(this, "showLiveCursor", true);
65068
65403
  this.tool.minDistance = 5;
65069
65404
  }
65070
65405
  onMouseDown(_event) {
@@ -65089,14 +65424,14 @@ var LaserPointerTool = class extends WhiteboardTool {
65089
65424
  }
65090
65425
  }
65091
65426
  };
65092
- function _defineProperty34(e, r, t) {
65093
- return (r = _toPropertyKey34(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65427
+ function _defineProperty35(e, r, t) {
65428
+ return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65094
65429
  }
65095
- function _toPropertyKey34(t) {
65096
- var i = _toPrimitive34(t, "string");
65430
+ function _toPropertyKey35(t) {
65431
+ var i = _toPrimitive35(t, "string");
65097
65432
  return "symbol" == typeof i ? i : i + "";
65098
65433
  }
65099
- function _toPrimitive34(t, r) {
65434
+ function _toPrimitive35(t, r) {
65100
65435
  if ("object" != typeof t || !t) return t;
65101
65436
  var e = t[Symbol.toPrimitive];
65102
65437
  if (void 0 !== e) {
@@ -65109,22 +65444,22 @@ function _toPrimitive34(t, r) {
65109
65444
  var PageModel = class extends import_eventemitter310.default {
65110
65445
  constructor(whiteboardAttrsMap, userManager, requestUserMap, pageMap, hasPermission) {
65111
65446
  super();
65112
- _defineProperty34(this, "whiteboardAttrsMap", void 0);
65113
- _defineProperty34(this, "pageMap", void 0);
65114
- _defineProperty34(this, "requestUserMap", void 0);
65115
- _defineProperty34(this, "userManager", void 0);
65116
- _defineProperty34(this, "observers", /* @__PURE__ */ new Map());
65117
- _defineProperty34(this, "hasPermission", void 0);
65118
- _defineProperty34(this, "handleUserLeave", (user) => {
65447
+ _defineProperty35(this, "whiteboardAttrsMap", void 0);
65448
+ _defineProperty35(this, "pageMap", void 0);
65449
+ _defineProperty35(this, "requestUserMap", void 0);
65450
+ _defineProperty35(this, "userManager", void 0);
65451
+ _defineProperty35(this, "observers", /* @__PURE__ */ new Map());
65452
+ _defineProperty35(this, "hasPermission", void 0);
65453
+ _defineProperty35(this, "handleUserLeave", (user) => {
65119
65454
  const cb = this.observers.get(user.id);
65120
65455
  if (cb) {
65121
- this.requestUserMap(user.id).unobserve(cb);
65456
+ (0, import_forge_room10.removeObserver)(this.requestUserMap(user.id), cb);
65122
65457
  }
65123
65458
  });
65124
- _defineProperty34(this, "handleUserJoin", (user) => {
65459
+ _defineProperty35(this, "handleUserJoin", (user) => {
65125
65460
  this.createCurrentPageObserver(user.id);
65126
65461
  });
65127
- _defineProperty34(this, "handleMainPageChange", (evt) => {
65462
+ _defineProperty35(this, "handleMainPageChange", (evt) => {
65128
65463
  for (const [key, value] of evt.changes.keys.entries()) {
65129
65464
  if (key === WhiteboardKeys.currentPage) {
65130
65465
  const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
@@ -65132,7 +65467,7 @@ var PageModel = class extends import_eventemitter310.default {
65132
65467
  if (cameraMode === "main") {
65133
65468
  const targetPage = this.whiteboardAttrsMap.get(WhiteboardKeys.currentPage);
65134
65469
  if (!this.pageMap.has(targetPage) && targetPage !== "_i_") {
65135
- (0, import_forge_room3.log)(`main page {${targetPage}} not found.`, {}, "error");
65470
+ (0, import_forge_room10.log)(`main page {${targetPage}} not found.`, {}, "error");
65136
65471
  return;
65137
65472
  }
65138
65473
  this.requestUserMap(this.userManager.selfId).set(WhiteboardKeys.currentPage, targetPage);
@@ -65142,7 +65477,7 @@ var PageModel = class extends import_eventemitter310.default {
65142
65477
  }
65143
65478
  }
65144
65479
  });
65145
- _defineProperty34(this, "handleUserCurrentPageChange", (userId, evt) => {
65480
+ _defineProperty35(this, "handleUserCurrentPageChange", (userId, evt) => {
65146
65481
  for (const [key, value] of evt.changes.keys.entries()) {
65147
65482
  if (key === WhiteboardKeys.currentPage) {
65148
65483
  const cameraMode = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.cameraMode);
@@ -65159,7 +65494,7 @@ var PageModel = class extends import_eventemitter310.default {
65159
65494
  }
65160
65495
  }
65161
65496
  });
65162
- _defineProperty34(this, "handlePageMapChange", () => {
65497
+ _defineProperty35(this, "handlePageMapChange", () => {
65163
65498
  this.emit("pagesChange", Array.from(this.pageMap.keys()));
65164
65499
  });
65165
65500
  this.hasPermission = hasPermission;
@@ -65260,12 +65595,12 @@ var PageModel = class extends import_eventemitter310.default {
65260
65595
  dispose() {
65261
65596
  for (const entry of this.observers.entries()) {
65262
65597
  const [userId, observer] = entry;
65263
- this.requestUserMap(userId).unobserve(observer);
65598
+ (0, import_forge_room10.removeObserver)(this.requestUserMap(userId), observer);
65264
65599
  }
65265
65600
  this.userManager.off("join", this.handleUserJoin);
65266
65601
  this.userManager.off("leave", this.handleUserLeave);
65267
- this.whiteboardAttrsMap.unobserve(this.handleMainPageChange);
65268
- this.pageMap.unobserve(this.handlePageMapChange);
65602
+ (0, import_forge_room10.removeObserver)(this.whiteboardAttrsMap, this.handleMainPageChange);
65603
+ (0, import_forge_room10.removeObserver)(this.pageMap, this.handlePageMapChange);
65269
65604
  }
65270
65605
  };
65271
65606
  var delay = (value) => new Promise((resolve) => setTimeout(resolve, value));
@@ -65275,14 +65610,14 @@ async function waitUntil(fn, timeout) {
65275
65610
  await delay(50);
65276
65611
  }
65277
65612
  }
65278
- function _defineProperty35(e, r, t) {
65279
- return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65613
+ function _defineProperty36(e, r, t) {
65614
+ return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65280
65615
  }
65281
- function _toPropertyKey35(t) {
65282
- var i = _toPrimitive35(t, "string");
65616
+ function _toPropertyKey36(t) {
65617
+ var i = _toPrimitive36(t, "string");
65283
65618
  return "symbol" == typeof i ? i : i + "";
65284
65619
  }
65285
- function _toPrimitive35(t, r) {
65620
+ function _toPrimitive36(t, r) {
65286
65621
  if ("object" != typeof t || !t) return t;
65287
65622
  var e = t[Symbol.toPrimitive];
65288
65623
  if (void 0 !== e) {
@@ -65301,7 +65636,7 @@ var IndexedNavigation = class extends import_eventemitter311.default {
65301
65636
  return this.list[key] && this.list[key].prev === "";
65302
65637
  });
65303
65638
  if (!headId) {
65304
- (0, import_forge_room4.log)("indexed navigation confusion", {
65639
+ (0, import_forge_room11.log)("indexed navigation confusion", {
65305
65640
  list: JSON.stringify(this.list)
65306
65641
  }, "error");
65307
65642
  throw new Error("indexed navigation confusion");
@@ -65319,13 +65654,13 @@ var IndexedNavigation = class extends import_eventemitter311.default {
65319
65654
  }
65320
65655
  constructor(pageModel, userMap, indexedPageMap, hasPermission) {
65321
65656
  super();
65322
- _defineProperty35(this, "idPool", /* @__PURE__ */ new Set());
65323
- _defineProperty35(this, "pageModel", void 0);
65324
- _defineProperty35(this, "userMap", void 0);
65325
- _defineProperty35(this, "indexedPageMap", void 0);
65326
- _defineProperty35(this, "list", {});
65327
- _defineProperty35(this, "hasPermission", void 0);
65328
- _defineProperty35(this, "handleIndexedPageMapUpdate", (_evt) => {
65657
+ _defineProperty36(this, "idPool", /* @__PURE__ */ new Set());
65658
+ _defineProperty36(this, "pageModel", void 0);
65659
+ _defineProperty36(this, "userMap", void 0);
65660
+ _defineProperty36(this, "indexedPageMap", void 0);
65661
+ _defineProperty36(this, "list", {});
65662
+ _defineProperty36(this, "hasPermission", void 0);
65663
+ _defineProperty36(this, "handleIndexedPageMapUpdate", (_evt) => {
65329
65664
  this.list = this.indexedPageMap.get("list");
65330
65665
  const needRemoveList = this.pageModel.pageList().filter((v) => /^_i_/.test(v) && Object.keys(this.list).indexOf(v) < 0);
65331
65666
  const needAddList = Object.keys(this.list).filter((v) => this.pageModel.pageList().indexOf(v) < 0);
@@ -65403,6 +65738,9 @@ var IndexedNavigation = class extends import_eventemitter311.default {
65403
65738
  const userPageId = this.userMap.get(WhiteboardKeys.currentPage);
65404
65739
  return this.getPageIndex(userPageId);
65405
65740
  }
65741
+ get currentPageId() {
65742
+ return this.userMap.get(WhiteboardKeys.currentPage);
65743
+ }
65406
65744
  getPageIndex(pageId) {
65407
65745
  let i = 0;
65408
65746
  let currentId = this.head;
@@ -65573,9 +65911,7 @@ var IndexedNavigation = class extends import_eventemitter311.default {
65573
65911
  if (this.pageCount <= 1) {
65574
65912
  return this.pageCount;
65575
65913
  }
65576
- const cameraMode = this.userMap.get(WhiteboardKeys.cameraMode);
65577
- if (cameraMode !== "main") {
65578
- console.warn("cannot modify pages in non-main view mode.");
65914
+ if (!this.modifyDetect()) {
65579
65915
  return this.pageCount;
65580
65916
  }
65581
65917
  const targetId = this.getPageId(index);
@@ -65616,19 +65952,19 @@ var IndexedNavigation = class extends import_eventemitter311.default {
65616
65952
  }
65617
65953
  }
65618
65954
  dispose() {
65619
- this.indexedPageMap.unobserve(this.handleIndexedPageMapUpdate);
65955
+ (0, import_forge_room12.removeObserver)(this.indexedPageMap, this.handleIndexedPageMapUpdate);
65620
65956
  this.pageModel.off("switchPage");
65621
65957
  this.pageModel.off("pagesChange");
65622
65958
  }
65623
65959
  };
65624
- function _defineProperty36(e, r, t) {
65625
- return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65960
+ function _defineProperty37(e, r, t) {
65961
+ return (r = _toPropertyKey37(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65626
65962
  }
65627
- function _toPropertyKey36(t) {
65628
- var i = _toPrimitive36(t, "string");
65963
+ function _toPropertyKey37(t) {
65964
+ var i = _toPrimitive37(t, "string");
65629
65965
  return "symbol" == typeof i ? i : i + "";
65630
65966
  }
65631
- function _toPrimitive36(t, r) {
65967
+ function _toPrimitive37(t, r) {
65632
65968
  if ("object" != typeof t || !t) return t;
65633
65969
  var e = t[Symbol.toPrimitive];
65634
65970
  if (void 0 !== e) {
@@ -65641,7 +65977,7 @@ function _toPrimitive36(t, r) {
65641
65977
  var ShadowEmitter = class extends import_eventemitter312.default {
65642
65978
  constructor(userMap) {
65643
65979
  super();
65644
- _defineProperty36(this, "userMap", void 0);
65980
+ _defineProperty37(this, "userMap", void 0);
65645
65981
  this.userMap = userMap;
65646
65982
  }
65647
65983
  getActive() {
@@ -65651,14 +65987,14 @@ var ShadowEmitter = class extends import_eventemitter312.default {
65651
65987
  return this.userMap.set("shadowActive", value);
65652
65988
  }
65653
65989
  };
65654
- function _defineProperty37(e, r, t) {
65655
- return (r = _toPropertyKey37(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65990
+ function _defineProperty38(e, r, t) {
65991
+ return (r = _toPropertyKey38(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65656
65992
  }
65657
- function _toPropertyKey37(t) {
65658
- var i = _toPrimitive37(t, "string");
65993
+ function _toPropertyKey38(t) {
65994
+ var i = _toPrimitive38(t, "string");
65659
65995
  return "symbol" == typeof i ? i : i + "";
65660
65996
  }
65661
- function _toPrimitive37(t, r) {
65997
+ function _toPrimitive38(t, r) {
65662
65998
  if ("object" != typeof t || !t) return t;
65663
65999
  var e = t[Symbol.toPrimitive];
65664
66000
  if (void 0 !== e) {
@@ -65671,9 +66007,10 @@ function _toPrimitive37(t, r) {
65671
66007
  var StraightLineTool = class extends WhiteboardTool {
65672
66008
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
65673
66009
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
65674
- _defineProperty37(this, "elementModel", null);
65675
- _defineProperty37(this, "from", null);
65676
- _defineProperty37(this, "to", null);
66010
+ _defineProperty38(this, "elementModel", null);
66011
+ _defineProperty38(this, "from", null);
66012
+ _defineProperty38(this, "to", null);
66013
+ _defineProperty38(this, "showLiveCursor", true);
65677
66014
  this.tool.minDistance = 1;
65678
66015
  }
65679
66016
  onMouseDown(event) {
@@ -65699,14 +66036,14 @@ var StraightLineTool = class extends WhiteboardTool {
65699
66036
  }
65700
66037
  }
65701
66038
  };
65702
- function _defineProperty38(e, r, t) {
65703
- return (r = _toPropertyKey38(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
66039
+ function _defineProperty39(e, r, t) {
66040
+ return (r = _toPropertyKey39(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65704
66041
  }
65705
- function _toPropertyKey38(t) {
65706
- var i = _toPrimitive38(t, "string");
66042
+ function _toPropertyKey39(t) {
66043
+ var i = _toPrimitive39(t, "string");
65707
66044
  return "symbol" == typeof i ? i : i + "";
65708
66045
  }
65709
- function _toPrimitive38(t, r) {
66046
+ function _toPrimitive39(t, r) {
65710
66047
  if ("object" != typeof t || !t) return t;
65711
66048
  var e = t[Symbol.toPrimitive];
65712
66049
  if (void 0 !== e) {
@@ -65719,8 +66056,9 @@ function _toPrimitive38(t, r) {
65719
66056
  var GrabTool = class extends WhiteboardTool {
65720
66057
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope, camera) {
65721
66058
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
65722
- _defineProperty38(this, "camera", void 0);
65723
- _defineProperty38(this, "downPoint", null);
66059
+ _defineProperty39(this, "camera", void 0);
66060
+ _defineProperty39(this, "downPoint", null);
66061
+ _defineProperty39(this, "showLiveCursor", false);
65724
66062
  this.camera = camera;
65725
66063
  }
65726
66064
  onMouseDown(event) {
@@ -65739,9 +66077,27 @@ var GrabTool = class extends WhiteboardTool {
65739
66077
  this.shadowEmitter.emit("grabUp");
65740
66078
  }
65741
66079
  };
66080
+ function _defineProperty40(e, r, t) {
66081
+ return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
66082
+ }
66083
+ function _toPropertyKey40(t) {
66084
+ var i = _toPrimitive40(t, "string");
66085
+ return "symbol" == typeof i ? i : i + "";
66086
+ }
66087
+ function _toPrimitive40(t, r) {
66088
+ if ("object" != typeof t || !t) return t;
66089
+ var e = t[Symbol.toPrimitive];
66090
+ if (void 0 !== e) {
66091
+ var i = e.call(t, r || "default");
66092
+ if ("object" != typeof i) return i;
66093
+ throw new TypeError("@@toPrimitive must return a primitive value.");
66094
+ }
66095
+ return ("string" === r ? String : Number)(t);
66096
+ }
65742
66097
  var PointerTool = class extends WhiteboardTool {
65743
66098
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
65744
66099
  super(enableToolEvent, modelGetter, shadowEmitter, scope);
66100
+ _defineProperty40(this, "showLiveCursor", false);
65745
66101
  }
65746
66102
  onMouseDown(_event) {
65747
66103
  }
@@ -65750,14 +66106,14 @@ var PointerTool = class extends WhiteboardTool {
65750
66106
  onMouseUp() {
65751
66107
  }
65752
66108
  };
65753
- function _defineProperty39(e, r, t) {
65754
- return (r = _toPropertyKey39(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
66109
+ function _defineProperty41(e, r, t) {
66110
+ return (r = _toPropertyKey41(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65755
66111
  }
65756
- function _toPropertyKey39(t) {
65757
- var i = _toPrimitive39(t, "string");
66112
+ function _toPropertyKey41(t) {
66113
+ var i = _toPrimitive41(t, "string");
65758
66114
  return "symbol" == typeof i ? i : i + "";
65759
66115
  }
65760
- function _toPrimitive39(t, r) {
66116
+ function _toPrimitive41(t, r) {
65761
66117
  if ("object" != typeof t || !t) return t;
65762
66118
  var e = t[Symbol.toPrimitive];
65763
66119
  if (void 0 !== e) {
@@ -65769,8 +66125,8 @@ function _toPrimitive39(t, r) {
65769
66125
  }
65770
66126
  var SequenceExecutor = class {
65771
66127
  constructor() {
65772
- _defineProperty39(this, "tasks", []);
65773
- _defineProperty39(this, "isRunning", false);
66128
+ _defineProperty41(this, "tasks", []);
66129
+ _defineProperty41(this, "isRunning", false);
65774
66130
  }
65775
66131
  addTask(task) {
65776
66132
  this.tasks.push(task);
@@ -65795,14 +66151,133 @@ var SequenceExecutor = class {
65795
66151
  this.isRunning = false;
65796
66152
  }
65797
66153
  };
65798
- function _defineProperty40(e, r, t) {
65799
- return (r = _toPropertyKey40(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
66154
+ function _defineProperty42(e, r, t) {
66155
+ return (r = _toPropertyKey42(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
65800
66156
  }
65801
- function _toPropertyKey40(t) {
65802
- var i = _toPrimitive40(t, "string");
66157
+ function _toPropertyKey42(t) {
66158
+ var i = _toPrimitive42(t, "string");
65803
66159
  return "symbol" == typeof i ? i : i + "";
65804
66160
  }
65805
- function _toPrimitive40(t, r) {
66161
+ function _toPrimitive42(t, r) {
66162
+ if ("object" != typeof t || !t) return t;
66163
+ var e = t[Symbol.toPrimitive];
66164
+ if (void 0 !== e) {
66165
+ var i = e.call(t, r || "default");
66166
+ if ("object" != typeof i) return i;
66167
+ throw new TypeError("@@toPrimitive must return a primitive value.");
66168
+ }
66169
+ return ("string" === r ? String : Number)(t);
66170
+ }
66171
+ var LiveCursor = class {
66172
+ constructor(canvasElement, paperScope, userManager, requestUserMap) {
66173
+ _defineProperty42(this, "container", document.createElement("div"));
66174
+ _defineProperty42(this, "showLiveCursor", true);
66175
+ _defineProperty42(this, "userManager", void 0);
66176
+ _defineProperty42(this, "requestUserMap", void 0);
66177
+ _defineProperty42(this, "cursors", /* @__PURE__ */ new Map());
66178
+ _defineProperty42(this, "paperScope", void 0);
66179
+ _defineProperty42(this, "resizeobserver", void 0);
66180
+ _defineProperty42(this, "timeoutIdMap", /* @__PURE__ */ new Map());
66181
+ _defineProperty42(this, "lastVisibleChangeTimes", /* @__PURE__ */ new Map());
66182
+ this.userManager = userManager;
66183
+ this.paperScope = paperScope;
66184
+ this.requestUserMap = requestUserMap;
66185
+ this.container.setAttribute("data-forge-cursors", "");
66186
+ this.container.style.cssText = "overflow:hidden;pointer-events:none;z-index:999;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);";
66187
+ this.container.style.pointerEvents = "none";
66188
+ this.resizeobserver = new ResizeObserver(() => {
66189
+ const bounds = canvasElement.getBoundingClientRect();
66190
+ this.container.style.width = bounds.width + "px";
66191
+ this.container.style.height = bounds.height + "px";
66192
+ });
66193
+ this.resizeobserver.observe(canvasElement);
66194
+ }
66195
+ createCursor(userId) {
66196
+ const cursor = document.createElement("fcursor");
66197
+ cursor.setAttribute("data-forge-cursor", userId);
66198
+ cursor.style.backgroundColor = this.requestUserMap(userId).get(WhiteboardKeys.themeColor);
66199
+ cursor.style.color = "#fff";
66200
+ cursor.style.position = "absolute";
66201
+ cursor.style.whiteSpace = "nowrap";
66202
+ cursor.style.display = "block";
66203
+ cursor.style.fontSize = "12px";
66204
+ cursor.style.padding = "2px 4px";
66205
+ cursor.style.borderRadius = "4px";
66206
+ cursor.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
66207
+ return cursor;
66208
+ }
66209
+ isOnSamePage(userId) {
66210
+ const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
66211
+ const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
66212
+ if (otherPage !== selfPage) {
66213
+ return false;
66214
+ }
66215
+ return true;
66216
+ }
66217
+ detectEnable(userId) {
66218
+ if (!this.showLiveCursor) {
66219
+ const cursor = this.cursors.get(userId);
66220
+ if (cursor) {
66221
+ cursor.style.display = "none";
66222
+ }
66223
+ }
66224
+ return this.showLiveCursor;
66225
+ }
66226
+ updateCursorPosition(point, userId) {
66227
+ if (!this.isOnSamePage(userId) || userId === this.userManager.selfId) {
66228
+ return;
66229
+ }
66230
+ if (!this.detectEnable(userId)) {
66231
+ return;
66232
+ }
66233
+ const lastVisibleChangeTime = this.lastVisibleChangeTimes.get(userId);
66234
+ if (lastVisibleChangeTime && Date.now() - lastVisibleChangeTime < 100) {
66235
+ return;
66236
+ }
66237
+ if (!this.cursors.has(userId)) {
66238
+ const cursor2 = this.createCursor(userId);
66239
+ this.cursors.set(userId, cursor2);
66240
+ this.container.appendChild(cursor2);
66241
+ }
66242
+ const cursor = this.cursors.get(userId);
66243
+ if (cursor) {
66244
+ const viewPoint = this.paperScope.project.view.projectToView(point);
66245
+ cursor.style.left = viewPoint.x + "px";
66246
+ cursor.style.top = viewPoint.y + "px";
66247
+ cursor.style.display = "block";
66248
+ }
66249
+ if (this.timeoutIdMap.has(userId)) {
66250
+ clearTimeout(this.timeoutIdMap.get(userId));
66251
+ }
66252
+ this.timeoutIdMap.set(userId, setTimeout(() => {
66253
+ const cursor2 = this.cursors.get(userId);
66254
+ if (cursor2) {
66255
+ cursor2.style.display = "none";
66256
+ }
66257
+ }, 5e3));
66258
+ }
66259
+ updateCursorVisible(visible, userId) {
66260
+ if (!this.isOnSamePage(userId) || userId === this.userManager.selfId) {
66261
+ return;
66262
+ }
66263
+ if (!this.detectEnable(userId)) {
66264
+ return;
66265
+ }
66266
+ this.lastVisibleChangeTimes.set(userId, Date.now());
66267
+ const cursor = this.cursors.get(userId);
66268
+ if (cursor) {
66269
+ cursor.style.display = visible ? "block" : "none";
66270
+ }
66271
+ }
66272
+ };
66273
+ function _defineProperty43(e, r, t) {
66274
+ return (r = _toPropertyKey43(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
66275
+ }
66276
+ function _toPropertyKey43(t) {
66277
+ var i = _toPrimitive43(t, "string");
66278
+ return "symbol" == typeof i ? i : i + "";
66279
+ }
66280
+ function _toPrimitive43(t, r) {
65806
66281
  if ("object" != typeof t || !t) return t;
65807
66282
  var e = t[Symbol.toPrimitive];
65808
66283
  if (void 0 !== e) {
@@ -65813,6 +66288,21 @@ function _toPrimitive40(t, r) {
65813
66288
  return ("string" === r ? String : Number)(t);
65814
66289
  }
65815
66290
  var WHITEBOARD_APP_NAME = "whiteboard";
66291
+ var AsyncMap = class {
66292
+ constructor() {
66293
+ _defineProperty43(this, "map", void 0);
66294
+ this.map = /* @__PURE__ */ new Map();
66295
+ }
66296
+ get(key) {
66297
+ return Promise.resolve(this.map.get(key));
66298
+ }
66299
+ set(key, value) {
66300
+ this.map.set(key, value);
66301
+ }
66302
+ };
66303
+ if (!window.__forge_gl_wb_status__) {
66304
+ window.__forge_gl_wb_status__ = new AsyncMap();
66305
+ }
65816
66306
  var WhiteboardApplication = class extends import_forge_room.AbstractApplication {
65817
66307
  get undoManager() {
65818
66308
  const page = this.pageModel.getCurrentPage(this.userId);
@@ -65821,43 +66311,110 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
65821
66311
  }
65822
66312
  return null;
65823
66313
  }
66314
+ get viewportWidth() {
66315
+ const vw = this.getMap("attrs").get("viewportWidth");
66316
+ if (vw) {
66317
+ return vw;
66318
+ }
66319
+ return this.option.width;
66320
+ }
66321
+ get viewportHeight() {
66322
+ const vh = this.getMap("attrs").get("viewportHeight");
66323
+ if (vh) {
66324
+ return vh;
66325
+ }
66326
+ return this.option.height;
66327
+ }
65824
66328
  constructor() {
65825
66329
  var _this;
65826
66330
  super();
65827
66331
  _this = this;
65828
- _defineProperty40(this, "name", WHITEBOARD_APP_NAME);
65829
- _defineProperty40(this, "emitter", void 0);
65830
- _defineProperty40(this, "toolbarModel", void 0);
65831
- _defineProperty40(this, "selectElementsModel", void 0);
65832
- _defineProperty40(this, "trashedElementsModel", void 0);
65833
- _defineProperty40(this, "pageModel", void 0);
65834
- _defineProperty40(this, "layers", /* @__PURE__ */ new Map());
65835
- _defineProperty40(this, "undoManagers", /* @__PURE__ */ new Map());
65836
- _defineProperty40(this, "rootElement", document.createElement("div"));
65837
- _defineProperty40(this, "paperScope", new import_paper.default.PaperScope());
65838
- _defineProperty40(this, "canvasElement", document.createElement("canvas"));
65839
- _defineProperty40(this, "shadowScope", new import_paper.default.PaperScope());
65840
- _defineProperty40(this, "snapshotCanvasElement", document.createElement("canvas"));
65841
- _defineProperty40(this, "snapshotScope", new import_paper.default.PaperScope());
65842
- _defineProperty40(this, "shadowCanvasElement", document.createElement("canvas"));
65843
- _defineProperty40(this, "shadowEmitter", void 0);
65844
- _defineProperty40(this, "tools", void 0);
65845
- _defineProperty40(this, "editors", /* @__PURE__ */ new Map());
65846
- _defineProperty40(this, "camera", void 0);
65847
- _defineProperty40(this, "resizeObserver", void 0);
65848
- _defineProperty40(this, "option", void 0);
65849
- _defineProperty40(this, "permissions", void 0);
65850
- _defineProperty40(this, "inputType", "any");
65851
- _defineProperty40(this, "isPenEvent", false);
65852
- _defineProperty40(this, "hasPenInput", null);
65853
- _defineProperty40(this, "disableViewModelUpdate", false);
65854
- _defineProperty40(this, "internalResizeObserver", true);
65855
- _defineProperty40(this, "sequenceExecutor", new SequenceExecutor());
65856
- _defineProperty40(this, "linkTarget", null);
65857
- _defineProperty40(this, "enableToolEvent", () => {
66332
+ _defineProperty43(this, "name", WHITEBOARD_APP_NAME);
66333
+ _defineProperty43(this, "emitter", void 0);
66334
+ _defineProperty43(this, "toolbarModel", void 0);
66335
+ _defineProperty43(this, "selectElementsModel", void 0);
66336
+ _defineProperty43(this, "trashedElementsModel", void 0);
66337
+ _defineProperty43(this, "pageModel", void 0);
66338
+ _defineProperty43(this, "layers", /* @__PURE__ */ new Map());
66339
+ _defineProperty43(this, "undoManagers", /* @__PURE__ */ new Map());
66340
+ _defineProperty43(this, "imageSets", document.createElement("div"));
66341
+ _defineProperty43(this, "rootElement", document.createElement("div"));
66342
+ _defineProperty43(this, "paperScope", new import_paper.default.PaperScope());
66343
+ _defineProperty43(this, "canvasElement", document.createElement("canvas"));
66344
+ _defineProperty43(this, "shadowScope", new import_paper.default.PaperScope());
66345
+ _defineProperty43(this, "snapshotCanvasElement", document.createElement("canvas"));
66346
+ _defineProperty43(this, "snapshotScope", new import_paper.default.PaperScope());
66347
+ _defineProperty43(this, "shadowCanvasElement", document.createElement("canvas"));
66348
+ _defineProperty43(this, "shadowEmitter", void 0);
66349
+ _defineProperty43(this, "tools", void 0);
66350
+ _defineProperty43(this, "editors", /* @__PURE__ */ new Map());
66351
+ _defineProperty43(this, "camera", void 0);
66352
+ _defineProperty43(this, "resizeObserver", void 0);
66353
+ _defineProperty43(this, "option", void 0);
66354
+ _defineProperty43(this, "permissions", void 0);
66355
+ _defineProperty43(this, "inputType", "any");
66356
+ _defineProperty43(this, "isPenEvent", false);
66357
+ _defineProperty43(this, "hasPenInput", null);
66358
+ _defineProperty43(this, "disableViewModelUpdate", false);
66359
+ _defineProperty43(this, "internalResizeObserver", true);
66360
+ _defineProperty43(this, "sequenceExecutor", new SequenceExecutor());
66361
+ _defineProperty43(this, "linkWhiteboardId", null);
66362
+ _defineProperty43(this, "liveCursor", void 0);
66363
+ _defineProperty43(this, "delayTranslateOut", -1);
66364
+ _defineProperty43(this, "addWhiteboardStatus", (evt) => {
66365
+ if (evt.detail.whiteboardAppId && evt.detail.status) {
66366
+ if (this.linkWhiteboardId === evt.detail.whiteboardAppId) {
66367
+ this.toolbarModel.currentTool = evt.detail.status.currentTool;
66368
+ this.toolbarModel.strokeColor = evt.detail.status.strokeColor;
66369
+ this.toolbarModel.fillColor = evt.detail.status.fillColor;
66370
+ this.toolbarModel.fontSize = evt.detail.status.fontSize;
66371
+ this.toolbarModel.fontFamily = evt.detail.status.fontFamily;
66372
+ this.toolbarModel.strokeWidth = evt.detail.status.strokeWidth;
66373
+ this.toolbarModel.dashArray = evt.detail.status.dashArray;
66374
+ this.permissions.removePermission(WhiteboardPermissionFlag.all);
66375
+ this.permissions.addPermission(evt.detail.status.permission);
66376
+ }
66377
+ }
66378
+ });
66379
+ _defineProperty43(this, "enableToolEvent", () => {
65858
66380
  return !(this.inputType === "pen" && !this.isPenEvent);
65859
66381
  });
65860
- _defineProperty40(this, "handlePageSwitch", (pageId) => {
66382
+ _defineProperty43(this, "handleViewportUpdate", (evt) => {
66383
+ if (evt.keysChanged.has("viewportWidth") || evt.keysChanged.has("viewportHeight")) {
66384
+ const rect = this.rootElement.getBoundingClientRect();
66385
+ this.adjustByOutFrame(rect.width, rect.height);
66386
+ }
66387
+ });
66388
+ _defineProperty43(this, "handleElementTranslateOut", (ids, container) => {
66389
+ const shadowLayer = this.shadowScope.project.activeLayer;
66390
+ let parent = null;
66391
+ if (container === "layer") {
66392
+ parent = shadowLayer;
66393
+ } else {
66394
+ parent = shadowLayer.children.find((child) => child.data.uuid === container) ?? null;
66395
+ }
66396
+ if (parent) {
66397
+ ids.forEach((id) => {
66398
+ const target = parent.children.find((child) => child.data.uuid === id);
66399
+ if (target) {
66400
+ target.remove();
66401
+ this.insertElementToParent(target, this.paperScope.project.activeLayer);
66402
+ } else {
66403
+ const pageId = this.pageModel.getCurrentPage(this.userId);
66404
+ if (pageId) {
66405
+ const page = this.layers.get(pageId);
66406
+ if (page) {
66407
+ const model = page.elementModels.get(id);
66408
+ if (model && model.item) {
66409
+ this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
66410
+ }
66411
+ }
66412
+ }
66413
+ }
66414
+ });
66415
+ }
66416
+ });
66417
+ _defineProperty43(this, "handlePageSwitch", (pageId) => {
65861
66418
  this.sequenceExecutor.addTask(async () => {
65862
66419
  for (const editor of this.editors.values()) {
65863
66420
  editor.hidden();
@@ -65905,24 +66462,24 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
65905
66462
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
65906
66463
  });
65907
66464
  });
65908
- _defineProperty40(this, "hasPermission", (flag) => {
66465
+ _defineProperty43(this, "hasPermission", (flag) => {
65909
66466
  return this.permissions.hasPermission(flag, this.userId);
65910
66467
  });
65911
- _defineProperty40(this, "handleStackItemAdded", () => {
66468
+ _defineProperty43(this, "handleStackItemAdded", () => {
65912
66469
  this.selectElementsModel.clearSelectElementForSelf();
65913
66470
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
65914
66471
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
65915
66472
  });
65916
- _defineProperty40(this, "handleStackItemPopped", () => {
66473
+ _defineProperty43(this, "handleStackItemPopped", () => {
65917
66474
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
65918
66475
  this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
65919
66476
  });
65920
- _defineProperty40(this, "handleLayersChange", (ids) => {
66477
+ _defineProperty43(this, "handleLayersChange", (ids) => {
65921
66478
  for (let i = 0, len = ids.length; i < len; i++) {
65922
66479
  const id = ids[i];
65923
66480
  if (!this.layers.has(id)) {
65924
66481
  const elementsMap = this.getMap(`layer/${id}/elements`);
65925
- const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.hasPermission);
66482
+ const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
65926
66483
  this.layers.set(id, renderableModel);
65927
66484
  }
65928
66485
  if (!this.undoManagers.has(id)) {
@@ -65938,7 +66495,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
65938
66495
  const renderableModel = this.layers.get(entry[0]);
65939
66496
  this.layers.delete(entry[0]);
65940
66497
  if (renderableModel) {
65941
- renderableModel.dispose();
66498
+ renderableModel.dispose(true);
65942
66499
  }
65943
66500
  const cameraMode = this.userMap(this.userId).get(WhiteboardKeys.cameraMode);
65944
66501
  const currentPage = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
@@ -65949,17 +66506,18 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
65949
66506
  }
65950
66507
  }
65951
66508
  });
65952
- _defineProperty40(this, "getCurrentRenderableModel", () => {
66509
+ _defineProperty43(this, "getCurrentRenderableModel", () => {
65953
66510
  const layerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
65954
66511
  if (!this.layers.has(layerId)) {
65955
66512
  this.emitter.emit("error", 300002, `target page: ${layerId} not found`);
65956
66513
  }
65957
66514
  return this.layers.get(layerId);
65958
66515
  });
65959
- _defineProperty40(this, "handleElementClear", () => {
66516
+ _defineProperty43(this, "handleElementClear", () => {
66517
+ this.shadowScope.project.activeLayer.removeChildren();
65960
66518
  this.paperScope.project.activeLayer.removeChildren();
65961
66519
  });
65962
- _defineProperty40(this, "handleElementInsert", (elements) => {
66520
+ _defineProperty43(this, "handleElementInsert", (elements) => {
65963
66521
  for (const element of elements) {
65964
66522
  element.createPaperElement();
65965
66523
  const scope = element.shadow === "" ? this.paperScope : this.shadowScope;
@@ -65971,7 +66529,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
65971
66529
  this.insertElementToParent(element.item, scope.project.activeLayer);
65972
66530
  }
65973
66531
  });
65974
- _defineProperty40(this, "handleElementRemove", (elementId, layerId) => {
66532
+ _defineProperty43(this, "handleElementRemove", (elementId, layerId) => {
65975
66533
  const layerModel = this.layers.get(layerId);
65976
66534
  if (!layerModel) {
65977
66535
  return;
@@ -65982,11 +66540,11 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
65982
66540
  }
65983
66541
  layerModel.elementModels.delete(elementId);
65984
66542
  });
65985
- _defineProperty40(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
66543
+ _defineProperty43(this, "handleRemoveTrashedElementForSelf", (userId, elementId) => {
65986
66544
  const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
65987
66545
  this.layers.get(selfLayerId)?.removeElementItem(elementId);
65988
66546
  });
65989
- _defineProperty40(this, "handleElementsTrash", (userId, elements) => {
66547
+ _defineProperty43(this, "handleElementsTrash", (userId, elements) => {
65990
66548
  const targetLayerId = this.userMap(userId).get(WhiteboardKeys.currentPage);
65991
66549
  const selfLayerId = this.userMap(this.userId).get(WhiteboardKeys.currentPage);
65992
66550
  if (targetLayerId !== selfLayerId || !this.layers.has(targetLayerId)) {
@@ -65999,7 +66557,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
65999
66557
  }
66000
66558
  });
66001
66559
  });
66002
- _defineProperty40(this, "handleElementsSelect", (userId, elements) => {
66560
+ _defineProperty43(this, "handleElementsSelect", (userId, elements) => {
66003
66561
  if (!this.editors.has(userId)) {
66004
66562
  const ctrl = this.userManager.getUser(userId);
66005
66563
  const editor2 = new Editor(this.paperScope, this.shadowScope, this.shadowEmitter, this.canvasElement, this.camera, {
@@ -66042,34 +66600,44 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66042
66600
  this.emitter.emit("elementDeselected", userId);
66043
66601
  }
66044
66602
  });
66045
- _defineProperty40(this, "handleLinkedMapChange", (evt) => {
66046
- for (const [key, value] of evt.changes.keys.entries()) {
66047
- if (Object.keys(TOOLBAR_KEYS).indexOf(key) >= 0 && (value.action === "add" || value.action === "update")) {
66048
- this.toolbarModel.currentTool = evt.target.get(TOOLBAR_KEYS.tool);
66049
- this.toolbarModel.strokeColor = evt.target.get(TOOLBAR_KEYS.strokeColor);
66050
- this.toolbarModel.fillColor = evt.target.get(TOOLBAR_KEYS.fillColor);
66051
- this.toolbarModel.fontSize = evt.target.get(TOOLBAR_KEYS.fontSize);
66052
- this.toolbarModel.fontFamily = evt.target.get(TOOLBAR_KEYS.fontFamily);
66053
- this.toolbarModel.strokeWidth = evt.target.get(TOOLBAR_KEYS.strokeWidth);
66054
- this.toolbarModel.dashArray = evt.target.get(TOOLBAR_KEYS.dashArray);
66055
- }
66056
- if (key === "permission" && (value.action === "add" || value.action === "update")) {
66057
- this.permissions.removePermission(WhiteboardPermissionFlag.all);
66058
- this.permissions.addPermission(evt.target.get("permission"), this.userId);
66059
- }
66603
+ _defineProperty43(this, "handleSyncedWhiteboardStatusChange", (evt) => {
66604
+ if ([TOOLBAR_KEYS.tool, TOOLBAR_KEYS.strokeColor, TOOLBAR_KEYS.fillColor, TOOLBAR_KEYS.fontSize, TOOLBAR_KEYS.fontFamily, TOOLBAR_KEYS.strokeWidth, TOOLBAR_KEYS.dashArray, "permission"].some((key) => evt.keysChanged.has(key))) {
66605
+ const nextState = {
66606
+ currentTool: evt.target.get(TOOLBAR_KEYS.tool),
66607
+ strokeColor: evt.target.get(TOOLBAR_KEYS.strokeColor),
66608
+ fillColor: evt.target.get(TOOLBAR_KEYS.fillColor),
66609
+ fontSize: evt.target.get(TOOLBAR_KEYS.fontSize),
66610
+ fontFamily: evt.target.get(TOOLBAR_KEYS.fontFamily),
66611
+ strokeWidth: evt.target.get(TOOLBAR_KEYS.strokeWidth),
66612
+ dashArray: evt.target.get(TOOLBAR_KEYS.dashArray),
66613
+ permission: evt.target.get("permission")
66614
+ };
66615
+ window.__forge_gl_wb_status__.set(this.appId, nextState);
66616
+ window.dispatchEvent(new CustomEvent("forge-whiteboard-synced-status", {
66617
+ detail: {
66618
+ whiteboardAppId: this.appId,
66619
+ status: nextState,
66620
+ userId: this.userId
66621
+ }
66622
+ }));
66060
66623
  }
66061
66624
  });
66062
- _defineProperty40(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
66063
- if (this.option.width > 0 && this.option.height > 0) {
66625
+ _defineProperty43(this, "adjustByOutFrame", (frameWidth, frameHeight) => {
66626
+ if (!this.paperScope.project.view || !this.shadowScope.project.view) {
66627
+ return;
66628
+ }
66629
+ const viewportWidth = this.viewportWidth;
66630
+ const viewportHeight = this.viewportHeight;
66631
+ if (viewportWidth > 0 && viewportHeight > 0) {
66064
66632
  const minWidth = Math.max(frameWidth, 10);
66065
66633
  const minHeight = Math.max(frameHeight, 10);
66066
66634
  let width = minWidth;
66067
- let height = width * this.option.height / this.option.width;
66635
+ let height = width * viewportHeight / viewportWidth;
66068
66636
  if (height > minHeight) {
66069
66637
  height = minHeight;
66070
- width = height * this.option.width / this.option.height;
66638
+ width = height * viewportWidth / viewportHeight;
66071
66639
  }
66072
- this.camera.updateInherentScale(width / this.option.width);
66640
+ this.camera.updateInherentScale(width / viewportWidth);
66073
66641
  this.paperScope.project.view.viewSize = new this.paperScope.Size(width, height);
66074
66642
  this.shadowScope.project.view.viewSize = new this.paperScope.Size(width, height);
66075
66643
  this.camera.triggerZoom();
@@ -66079,6 +66647,9 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66079
66647
  requestAnimationFrameHook(this.shadowScope);
66080
66648
  const that = this;
66081
66649
  this.rootElement.setAttribute("data-forge-app", "whiteboard");
66650
+ this.imageSets.style.display = "none";
66651
+ this.imageSets.setAttribute("data-image-sets", "");
66652
+ this.rootElement.appendChild(this.imageSets);
66082
66653
  document.body.addEventListener("pointerdown", (evt) => {
66083
66654
  this.isPenEvent = evt.pointerType === "pen";
66084
66655
  if (evt.pointerType === "pen" && this.hasPenInput === null) {
@@ -66178,6 +66749,30 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66178
66749
  this.camera.resetViewMatrixToMain();
66179
66750
  }
66180
66751
  };
66752
+ this.emitter.insertImage = (src, pageId) => {
66753
+ if (!/https/.test(src)) {
66754
+ (0, import_forge_room.log)("[@netless/forge-whiteboard] invalid image url, src needs to be in the HTTPS protocol.", {
66755
+ src
66756
+ }, "warning");
66757
+ return;
66758
+ }
66759
+ let targetPageId = pageId;
66760
+ if (!targetPageId) {
66761
+ targetPageId = this.pageModel.getCurrentPage(this.userManager.selfId);
66762
+ }
66763
+ if (!targetPageId) {
66764
+ (0, import_forge_room.log)("[@netless/forge-whiteboard] page not found", {}, "warning");
66765
+ return;
66766
+ }
66767
+ this.layers.get(targetPageId)?.createImage(src);
66768
+ };
66769
+ this.emitter.removeElement = (pageId, elementId) => {
66770
+ if (!this.layers.has(pageId)) {
66771
+ (0, import_forge_room.log)("[@netless/forge-whiteboard] page not found", {}, "warning");
66772
+ return;
66773
+ }
66774
+ this.layers.get(pageId)?.removeElementItem(elementId);
66775
+ };
66181
66776
  this.emitter.getViewModel = (userId) => {
66182
66777
  const targetId = userId ? userId : this.userId;
66183
66778
  return this.userMap(targetId).get(WhiteboardKeys.cameraMode);
@@ -66193,7 +66788,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66193
66788
  const source = this.getMap(`layer/${sourceId}/elements`);
66194
66789
  const target = this.getMap(`layer/${targetId}/elements`);
66195
66790
  if (!this.layers.has(targetId)) {
66196
- this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.hasPermission));
66791
+ this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
66197
66792
  }
66198
66793
  if (!this.undoManagers.has(targetId)) {
66199
66794
  const undoManager = new Y15.UndoManager(target, {
@@ -66243,12 +66838,29 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66243
66838
  this.emitter.resetCamera = () => {
66244
66839
  this.camera.reset();
66245
66840
  };
66841
+ this.emitter.showLiveCursor = (value) => {
66842
+ this.liveCursor.showLiveCursor = value;
66843
+ };
66844
+ this.emitter.updateViewport = (width, height) => {
66845
+ this.updateOptionSize(width, height);
66846
+ };
66847
+ this.emitter.__setMainCanvasVisible = (visible) => {
66848
+ this.canvasElement.style.opacity = visible ? "1" : "0";
66849
+ };
66246
66850
  this.emitter.on("error", (errorCode, errorMessage) => {
66247
66851
  (0, import_forge_room.log)("WhiteboardApplicationError", {
66248
66852
  errorCode,
66249
66853
  errorMessage
66250
66854
  });
66251
66855
  });
66856
+ Object.defineProperty(this.emitter, "__delayTranslateOut", {
66857
+ get() {
66858
+ return that.delayTranslateOut;
66859
+ },
66860
+ set(value) {
66861
+ that.delayTranslateOut = value;
66862
+ }
66863
+ });
66252
66864
  Object.defineProperty(this.emitter, "tool", {
66253
66865
  get() {
66254
66866
  return that.toolbarModel.currentTool;
@@ -66337,6 +66949,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66337
66949
  that.camera.enableBoundaryHighlight = value;
66338
66950
  }
66339
66951
  });
66952
+ window.addEventListener("forge-whiteboard-synced-status", this.addWhiteboardStatus);
66340
66953
  }
66341
66954
  userMap(userId) {
66342
66955
  return this.getMap(`user/${userId}`);
@@ -66349,7 +66962,19 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66349
66962
  this.emitter["permissions"] = this.permissions;
66350
66963
  this.emitter["selfUserId"] = this.userId;
66351
66964
  this.option = option;
66965
+ if (this.option.stretchToFill) {
66966
+ this.getMap("attrs").set("viewportWidth", -1);
66967
+ this.getMap("attrs").set("viewportHeight", -1);
66968
+ } else {
66969
+ if (!this.getMap("attrs").has("viewportWidth")) {
66970
+ this.getMap("attrs").set("viewportWidth", option.width);
66971
+ }
66972
+ if (!this.getMap("attrs").has("viewportHeight")) {
66973
+ this.getMap("attrs").set("viewportHeight", option.height);
66974
+ }
66975
+ }
66352
66976
  this.userMap(this.userId).set(WhiteboardKeys.themeColor, "#009688");
66977
+ this.userMap(this.userId).observe(this.handleSyncedWhiteboardStatusChange);
66353
66978
  this.shadowEmitter = new ShadowEmitter(this.userMap(this.userId));
66354
66979
  this.pageModel = new PageModel(this.getMap("attrs"), this.userManager, (userId) => {
66355
66980
  return this.userMap(userId);
@@ -66397,6 +67022,9 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66397
67022
  this.selectElementsModel = new SelectElementsModel(this.userManager, (userId) => {
66398
67023
  return this.userMap(userId);
66399
67024
  }, this.hasPermission);
67025
+ this.liveCursor = new LiveCursor(this.canvasElement, this.paperScope, this.userManager, (userId) => {
67026
+ return this.userMap(userId);
67027
+ });
66400
67028
  this.tools = {
66401
67029
  pointer: new PointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
66402
67030
  curve: new CurveTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
@@ -66407,7 +67035,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66407
67035
  text: new TextTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.rootElement, this.canvasElement, this.toolbarModel, this.camera),
66408
67036
  ellipse: new EllipseTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
66409
67037
  triangle: new TriangleTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
66410
- eraser: new EraserTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel),
67038
+ eraser: new EraserTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.trashedElementsModel, this.shadowScope),
66411
67039
  laser: new LaserPointerTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope),
66412
67040
  grab: new GrabTool(this.enableToolEvent, this.getCurrentRenderableModel, this.shadowEmitter, this.paperScope, this.camera)
66413
67041
  };
@@ -66479,32 +67107,12 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66479
67107
  }
66480
67108
  });
66481
67109
  this.shadowEmitter.on("translateOut", (ids, container) => {
66482
- const shadowLayer = this.shadowScope.project.activeLayer;
66483
- let parent = null;
66484
- if (container === "layer") {
66485
- parent = shadowLayer;
67110
+ if (this.delayTranslateOut > 0) {
67111
+ setTimeout(() => {
67112
+ this.handleElementTranslateOut(ids, container);
67113
+ }, this.delayTranslateOut);
66486
67114
  } else {
66487
- parent = shadowLayer.children.find((child) => child.data.uuid === container) ?? null;
66488
- }
66489
- if (parent) {
66490
- ids.forEach((id) => {
66491
- const target = parent.children.find((child) => child.data.uuid === id);
66492
- if (target) {
66493
- target.remove();
66494
- this.insertElementToParent(target, this.paperScope.project.activeLayer);
66495
- } else {
66496
- const pageId = this.pageModel.getCurrentPage(this.userId);
66497
- if (pageId) {
66498
- const page = this.layers.get(pageId);
66499
- if (page) {
66500
- const model = page.elementModels.get(id);
66501
- if (model && model.item) {
66502
- this.insertElementToParent(model.item, this.paperScope.project.activeLayer);
66503
- }
66504
- }
66505
- }
66506
- }
66507
- });
67115
+ this.handleElementTranslateOut(ids, container);
66508
67116
  }
66509
67117
  });
66510
67118
  this.shadowEmitter.on("translateIn", (ids, container) => {
@@ -66531,6 +67139,15 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66531
67139
  this.emitter.emit("grabUp");
66532
67140
  });
66533
67141
  this.clearElements();
67142
+ if (this.option.stretchToFill) {
67143
+ window.addEventListener("resize", () => {
67144
+ const bounds = this.rootElement.getBoundingClientRect();
67145
+ this.updateOptionSize(bounds.width, bounds.height);
67146
+ this.adjustByOutFrame(bounds.width, bounds.height);
67147
+ });
67148
+ }
67149
+ this.rootElement.appendChild(this.liveCursor.container);
67150
+ this.getMap("attrs").observe(this.handleViewportUpdate);
66534
67151
  }
66535
67152
  clearElements() {
66536
67153
  const userIds = this.userManager.userIdList();
@@ -66626,10 +67243,10 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66626
67243
  this.snapshotScope.view.viewSize = bounds.size.multiply(scale2);
66627
67244
  this.snapshotScope.view.matrix = matrix;
66628
67245
  } else if (area === "maxScale" && this.option.maxScaleRatio && this.option.maxScaleRatio !== -1) {
66629
- const width = this.option.width * this.option.maxScaleRatio;
66630
- const height = this.option.height * this.option.maxScaleRatio;
66631
- const offsetX = this.option.width * (this.option.maxScaleRatio - 1) / 2;
66632
- const offsetY = this.option.height * (this.option.maxScaleRatio - 1) / 2;
67246
+ const width = this.viewportWidth * this.option.maxScaleRatio;
67247
+ const height = this.viewportHeight * this.option.maxScaleRatio;
67248
+ const offsetX = this.viewportWidth * (this.option.maxScaleRatio - 1) / 2;
67249
+ const offsetY = this.viewportHeight * (this.option.maxScaleRatio - 1) / 2;
66633
67250
  const matrix = new this.paperScope.Matrix();
66634
67251
  matrix.scale(scale);
66635
67252
  matrix.translate({
@@ -66653,28 +67270,23 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66653
67270
  this.disableViewModelUpdate = true;
66654
67271
  }
66655
67272
  linkToWhiteboard(targetId) {
66656
- if (this.linkTarget) {
66657
- this.unlink();
66658
- }
66659
- this.userMap(this.userId);
66660
- this.linkTarget = this.roomDoc.getMap(`@app/${this.name}/${targetId}/user/${this.userId}`);
66661
- if (this.linkTarget) {
66662
- this.toolbarModel.currentTool = this.linkTarget.get(TOOLBAR_KEYS.tool);
66663
- this.toolbarModel.strokeColor = this.linkTarget.get(TOOLBAR_KEYS.strokeColor);
66664
- this.toolbarModel.fillColor = this.linkTarget.get(TOOLBAR_KEYS.fillColor);
66665
- this.toolbarModel.fontSize = this.linkTarget.get(TOOLBAR_KEYS.fontSize);
66666
- this.toolbarModel.fontFamily = this.linkTarget.get(TOOLBAR_KEYS.fontFamily);
66667
- this.toolbarModel.strokeWidth = this.linkTarget.get(TOOLBAR_KEYS.strokeWidth);
66668
- this.toolbarModel.dashArray = this.linkTarget.get(TOOLBAR_KEYS.dashArray);
66669
- this.permissions.removePermission(WhiteboardPermissionFlag.all);
66670
- this.permissions.addPermission(this.linkTarget.get("permission"), this.userId);
66671
- this.linkTarget.observe(this.handleLinkedMapChange);
66672
- }
67273
+ this.linkWhiteboardId = targetId;
67274
+ window.__forge_gl_wb_status__.get(targetId).then((currentStatus) => {
67275
+ if (currentStatus) {
67276
+ this.toolbarModel.currentTool = currentStatus.currentTool;
67277
+ this.toolbarModel.strokeColor = currentStatus.strokeColor;
67278
+ this.toolbarModel.fillColor = currentStatus.fillColor;
67279
+ this.toolbarModel.fontSize = currentStatus.fontSize;
67280
+ this.toolbarModel.fontFamily = currentStatus.fontFamily;
67281
+ this.toolbarModel.strokeWidth = currentStatus.strokeWidth;
67282
+ this.toolbarModel.dashArray = currentStatus.dashArray;
67283
+ this.permissions.removePermission(WhiteboardPermissionFlag.all);
67284
+ this.permissions.addPermission(currentStatus.permission);
67285
+ }
67286
+ });
66673
67287
  }
66674
67288
  unlink() {
66675
- if (this.linkTarget) {
66676
- this.linkTarget.unobserve(this.handleLinkedMapChange);
66677
- }
67289
+ this.linkWhiteboardId = null;
66678
67290
  }
66679
67291
  setViewSize(width, height) {
66680
67292
  this.paperScope.project.view.viewSize = new this.paperScope.Size(width, height);
@@ -66691,11 +67303,14 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66691
67303
  this.internalResizeObserver = value;
66692
67304
  }
66693
67305
  updateOptionSize(width, height) {
66694
- this.option.width = width;
66695
- this.option.height = height;
67306
+ this.getMap("attrs").set("viewportWidth", width);
67307
+ this.getMap("attrs").set("viewportHeight", height);
66696
67308
  this.camera.updateInitSize(new import_paper.default.Size(width, height));
66697
67309
  }
66698
- async dispose() {
67310
+ async dispose(removeSubDoc) {
67311
+ if (removeSubDoc) {
67312
+ this.deleteSubDoc(this.appId);
67313
+ }
66699
67314
  this.selectElementsModel.dispose();
66700
67315
  this.trashedElementsModel.dispose();
66701
67316
  this.paperScope.view.remove();
@@ -66712,7 +67327,7 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66712
67327
  entry[1].off("stack-item-popped", this.handleStackItemPopped);
66713
67328
  }
66714
67329
  for (const entry of this.layers.entries()) {
66715
- entry[1].dispose();
67330
+ entry[1].dispose(removeSubDoc);
66716
67331
  entry[1].removeAllListeners();
66717
67332
  }
66718
67333
  this.camera.dispose();
@@ -66724,13 +67339,14 @@ var WhiteboardApplication = class extends import_forge_room.AbstractApplication
66724
67339
  this.toolbarModel.dispose();
66725
67340
  this.emitter.indexedNavigation.dispose();
66726
67341
  this.permissions.dispose();
67342
+ (0, import_forge_room13.removeObserver)(this.userMap(this.userId), this.handleSyncedWhiteboardStatusChange);
66727
67343
  }
66728
67344
  };
66729
- _defineProperty40(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
67345
+ _defineProperty43(WhiteboardApplication, "applicationName", WHITEBOARD_APP_NAME);
66730
67346
 
66731
67347
  // src/SlideApplication.ts
66732
67348
  var import_slide = __toESM(require_Slide());
66733
- var import_forge_room6 = require("@netless/forge-room");
67349
+ var import_forge_room16 = require("@netless/forge-room");
66734
67350
 
66735
67351
  // src/Slide.ts
66736
67352
  var import_eventemitter313 = __toESM(require("eventemitter3"));
@@ -66790,7 +67406,7 @@ var SlideForge = class extends import_eventemitter313.default {
66790
67406
  };
66791
67407
 
66792
67408
  // src/ForgeSlidePermession.ts
66793
- var import_forge_room5 = require("@netless/forge-room");
67409
+ var import_forge_room14 = require("@netless/forge-room");
66794
67410
  var ForgeSlidePermissionFlag = /* @__PURE__ */ ((ForgeSlidePermissionFlag2) => {
66795
67411
  ForgeSlidePermissionFlag2[ForgeSlidePermissionFlag2["none"] = 0] = "none";
66796
67412
  ForgeSlidePermissionFlag2[ForgeSlidePermissionFlag2["changeStep"] = 1] = "changeStep";
@@ -66799,7 +67415,7 @@ var ForgeSlidePermissionFlag = /* @__PURE__ */ ((ForgeSlidePermissionFlag2) => {
66799
67415
  ForgeSlidePermissionFlag2[ForgeSlidePermissionFlag2["all"] = 7] = "all";
66800
67416
  return ForgeSlidePermissionFlag2;
66801
67417
  })(ForgeSlidePermissionFlag || {});
66802
- var ForgeSlidePermissions = class extends import_forge_room5.AbstractApplicationPermissions {
67418
+ var ForgeSlidePermissions = class extends import_forge_room14.AbstractApplicationPermissions {
66803
67419
  /**
66804
67420
  * 解析权限列表组合
66805
67421
  * @param {number} value - 权限数字值
@@ -66950,10 +67566,16 @@ var FooterView = class extends import_eventemitter314.default {
66950
67566
 
66951
67567
  // src/SiderBarView.ts
66952
67568
  var import_eventemitter315 = __toESM(require("eventemitter3"));
67569
+ var import_forge_room15 = require("@netless/forge-room");
66953
67570
  var SideBarView = class extends import_eventemitter315.default {
66954
67571
  root = document.createElement("div");
66955
67572
  isShow = false;
66956
67573
  eventsMap = /* @__PURE__ */ new Map();
67574
+ taskId = "";
67575
+ prefix = "";
67576
+ addImagesPool = [];
67577
+ scheduleId = 0;
67578
+ isSchedule = false;
66957
67579
  constructor() {
66958
67580
  super();
66959
67581
  this.root.style.backgroundColor = "#eee";
@@ -66974,49 +67596,110 @@ var SideBarView = class extends import_eventemitter315.default {
66974
67596
  get isShowSideBar() {
66975
67597
  return this.isShow;
66976
67598
  }
67599
+ async getPreviewImage(imageUrl) {
67600
+ const image = await fetch(imageUrl);
67601
+ const blob = await image.blob();
67602
+ return new Promise((resolve) => {
67603
+ const reader = new FileReader();
67604
+ reader.onloadend = () => {
67605
+ const base64Data = reader.result;
67606
+ const img = document.createElement("img");
67607
+ img.src = base64Data;
67608
+ img.onload = () => {
67609
+ resolve({
67610
+ url: imageUrl,
67611
+ src: base64Data,
67612
+ width: img.width,
67613
+ height: img.height
67614
+ });
67615
+ };
67616
+ };
67617
+ reader.readAsDataURL(blob);
67618
+ });
67619
+ }
67620
+ async appendPreviewImage(pageIndex) {
67621
+ const itemContainer = document.createElement("div");
67622
+ itemContainer.style.width = "60%";
67623
+ itemContainer.style.display = "flex";
67624
+ itemContainer.style.justifyContent = "center";
67625
+ itemContainer.style.alignItems = "flex-start";
67626
+ itemContainer.style.position = "relative";
67627
+ itemContainer.style.borderRadius = "4px";
67628
+ itemContainer.style.transition = "border-color .3s";
67629
+ itemContainer.style.marginBottom = "10px";
67630
+ const onMouseOverHandle = () => {
67631
+ itemContainer.style.borderColor = "#ccc";
67632
+ };
67633
+ const onMouseOutHandle = () => {
67634
+ itemContainer.style.borderColor = "transparent";
67635
+ };
67636
+ const onClickHandle = () => {
67637
+ this.emit("pageChange", pageIndex);
67638
+ };
67639
+ itemContainer.addEventListener("click", onClickHandle);
67640
+ itemContainer.addEventListener("mouseover", onMouseOverHandle);
67641
+ itemContainer.addEventListener("mouseout", onMouseOutHandle);
67642
+ this.eventsMap.set(itemContainer, [onClickHandle, onMouseOverHandle, onMouseOutHandle]);
67643
+ const pageIndexContainer = document.createElement("span");
67644
+ pageIndexContainer.textContent = `${pageIndex}`;
67645
+ pageIndexContainer.style.position = "absolute";
67646
+ pageIndexContainer.style.top = "1px";
67647
+ pageIndexContainer.style.left = "-10px";
67648
+ pageIndexContainer.style.transform = "translate(-100%)";
67649
+ pageIndexContainer.style.fontSize = "12px";
67650
+ pageIndexContainer.style.color = "#5f5f5f";
67651
+ const previewUrl = `${this.prefix}/${this.taskId}/preview/${pageIndex}.png`;
67652
+ const preview = document.createElement("img");
67653
+ const cachePreview = await import_forge_room15.kvStore.getItem(previewUrl);
67654
+ if (cachePreview) {
67655
+ const { src } = JSON.parse(cachePreview);
67656
+ preview.src = src;
67657
+ } else {
67658
+ const previewInfo = await this.getPreviewImage(previewUrl);
67659
+ await import_forge_room15.kvStore.setItem(previewUrl, JSON.stringify(previewInfo));
67660
+ const { src } = previewInfo;
67661
+ preview.src = src;
67662
+ }
67663
+ preview.style.width = "100%";
67664
+ preview.style.display = "inline-block";
67665
+ itemContainer.appendChild(preview);
67666
+ itemContainer.appendChild(pageIndexContainer);
67667
+ this.root.appendChild(itemContainer);
67668
+ }
67669
+ async scheduleGetPreviewImage() {
67670
+ if (!this.isSchedule) {
67671
+ this.scheduleId = setTimeout(async () => {
67672
+ await this.scheduleGetPreviewImage();
67673
+ }, 32);
67674
+ return;
67675
+ }
67676
+ const pageIndex = this.addImagesPool.shift();
67677
+ if (!pageIndex) {
67678
+ clearTimeout(this.scheduleId);
67679
+ this.scheduleId = 0;
67680
+ return;
67681
+ }
67682
+ await this.appendPreviewImage(pageIndex);
67683
+ this.scheduleId = setTimeout(async () => {
67684
+ await this.scheduleGetPreviewImage();
67685
+ }, 32);
67686
+ }
67687
+ async startGetPreviewImageSchedule() {
67688
+ this.isSchedule = true;
67689
+ }
67690
+ pauseGetPreviewImageSchedule() {
67691
+ this.isSchedule = false;
67692
+ }
66977
67693
  initialize(slideCount, option) {
67694
+ this.taskId = option.taskId;
67695
+ this.prefix = option.prefix;
66978
67696
  for (let i = 1; i <= slideCount; i++) {
66979
- const itemContainer = document.createElement("div");
66980
- itemContainer.style.width = "60%";
66981
- itemContainer.style.display = "flex";
66982
- itemContainer.style.justifyContent = "center";
66983
- itemContainer.style.alignItems = "flex-start";
66984
- itemContainer.style.position = "relative";
66985
- itemContainer.style.borderRadius = "4px";
66986
- itemContainer.style.transition = "border-color .3s";
66987
- itemContainer.style.marginBottom = "10px";
66988
- const onMouseOverHandle = () => {
66989
- itemContainer.style.borderColor = "#ccc";
66990
- };
66991
- const onMouseOutHandle = () => {
66992
- itemContainer.style.borderColor = "transparent";
66993
- };
66994
- const onClickHandle = () => {
66995
- this.emit("pageChange", i);
66996
- };
66997
- itemContainer.addEventListener("click", onClickHandle);
66998
- itemContainer.addEventListener("mouseover", onMouseOverHandle);
66999
- itemContainer.addEventListener("mouseout", onMouseOutHandle);
67000
- this.eventsMap.set(itemContainer, [onClickHandle, onMouseOverHandle, onMouseOutHandle]);
67001
- const pageIndex = document.createElement("span");
67002
- pageIndex.textContent = `${i}`;
67003
- pageIndex.style.position = "absolute";
67004
- pageIndex.style.top = "1px";
67005
- pageIndex.style.left = "-10px";
67006
- pageIndex.style.transform = "translate(-100%)";
67007
- pageIndex.style.fontSize = "12px";
67008
- pageIndex.style.color = "#5f5f5f";
67009
- const preview = document.createElement("img");
67010
- preview.style.width = "100%";
67011
- preview.style.display = "inline-block";
67012
- preview.src = `${option.prefix}/${option.taskId}/preview/${i}.png`;
67013
- itemContainer.appendChild(preview);
67014
- itemContainer.appendChild(pageIndex);
67015
- this.root.appendChild(itemContainer);
67697
+ this.addImagesPool.push(i);
67016
67698
  }
67699
+ this.scheduleGetPreviewImage();
67017
67700
  }
67018
67701
  hidden() {
67019
- if (!this.root) {
67702
+ if (!this.root || !this.isShow) {
67020
67703
  return;
67021
67704
  }
67022
67705
  this.root.style.left = "-240px";
@@ -67045,7 +67728,7 @@ var SideBarView = class extends import_eventemitter315.default {
67045
67728
  };
67046
67729
 
67047
67730
  // src/utils.ts
67048
- function deepEqual(a2, b2, excludeKeys = ["time"]) {
67731
+ function deepEqual(a2, b2, excludeKeys = ["mediaState"]) {
67049
67732
  if (a2 === b2) return true;
67050
67733
  if (typeof a2 !== "object" || a2 === null || typeof b2 !== "object" || b2 === null) return false;
67051
67734
  if (a2.constructor !== b2.constructor) return false;
@@ -67081,7 +67764,7 @@ function arrayEqual(arr1, arr2) {
67081
67764
 
67082
67765
  // src/SlideApplication.ts
67083
67766
  var Slide_APP_NAME = "forge_slide";
67084
- var SlideApplication = class extends import_forge_room6.AbstractApplication {
67767
+ var SlideApplication = class extends import_forge_room16.AbstractApplication {
67085
67768
  static applicationName = Slide_APP_NAME;
67086
67769
  name = Slide_APP_NAME;
67087
67770
  emitter = new SlideForge();
@@ -67106,7 +67789,7 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67106
67789
  super();
67107
67790
  window.emitter = this.emitter;
67108
67791
  this.rootView.setAttribute("data-forge-app", Slide_APP_NAME);
67109
- this.rootView.style.background = "#f0f0f0f0";
67792
+ this.rootView.style.background = "#f9f9fc";
67110
67793
  this.rootView.style.overflow = "hidden";
67111
67794
  this.contentContainer.style.width = "100%";
67112
67795
  this.contentContainer.style.height = "100%";
@@ -67279,28 +67962,6 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67279
67962
  }
67280
67963
  return `${this.prefix}/${this.taskId}/preview/${pageIndex}.png`;
67281
67964
  }
67282
- async getPreviewImage(imageUrl) {
67283
- const image = fetch(imageUrl);
67284
- return await image.then((res) => res.blob()).then((blob) => {
67285
- return new Promise((resolve) => {
67286
- const reader = new FileReader();
67287
- reader.onloadend = () => {
67288
- const base64Data = reader.result;
67289
- const img = document.createElement("img");
67290
- img.src = base64Data;
67291
- img.onload = () => {
67292
- resolve({
67293
- url: imageUrl,
67294
- src: base64Data,
67295
- width: img.width,
67296
- height: img.height
67297
- });
67298
- };
67299
- };
67300
- reader.readAsDataURL(blob);
67301
- });
67302
- });
67303
- }
67304
67965
  async getImageUrl(pageIndex) {
67305
67966
  return this.getPreviewImageUrl(pageIndex);
67306
67967
  }
@@ -67308,7 +67969,7 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67308
67969
  const imageUrl = this.getPreviewImageUrl(pageIndex);
67309
67970
  let preview = null;
67310
67971
  try {
67311
- const result = await import_forge_room6.kvStore.getItem(imageUrl);
67972
+ const result = await import_forge_room16.kvStore.getItem(imageUrl);
67312
67973
  preview = result ? JSON.parse(result) : null;
67313
67974
  } catch (e) {
67314
67975
  console.warn("kvStore getItem error", e);
@@ -67316,15 +67977,15 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67316
67977
  if (preview) {
67317
67978
  return { width: preview.width, height: preview.height };
67318
67979
  }
67319
- preview = await this.getPreviewImage(imageUrl);
67320
- await import_forge_room6.kvStore.setItem(imageUrl, JSON.stringify(preview));
67980
+ preview = await this.sideBar.getPreviewImage(imageUrl);
67981
+ await import_forge_room16.kvStore.setItem(imageUrl, JSON.stringify(preview));
67321
67982
  return { width: preview.width, height: preview.height };
67322
67983
  }
67323
67984
  async getImageContent(pageIndex) {
67324
67985
  const imageUrl = this.getPreviewImageUrl(pageIndex);
67325
67986
  let preview = null;
67326
67987
  try {
67327
- const result = await import_forge_room6.kvStore.getItem(imageUrl);
67988
+ const result = await import_forge_room16.kvStore.getItem(imageUrl);
67328
67989
  preview = result ? JSON.parse(result) : null;
67329
67990
  } catch (e) {
67330
67991
  console.warn("kvStore getItem error", e);
@@ -67332,8 +67993,8 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67332
67993
  if (preview) {
67333
67994
  return preview.src;
67334
67995
  }
67335
- preview = await this.getPreviewImage(imageUrl);
67336
- await import_forge_room6.kvStore.setItem(imageUrl, JSON.stringify(preview));
67996
+ preview = await this.sideBar.getPreviewImage(imageUrl);
67997
+ await import_forge_room16.kvStore.setItem(imageUrl, JSON.stringify(preview));
67337
67998
  return preview.src;
67338
67999
  }
67339
68000
  nextTick = () => {
@@ -67355,10 +68016,14 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67355
68016
  this.syncMessageQueue = [];
67356
68017
  this.isSyncing = true;
67357
68018
  const { state, dispatch } = lastSyncMessage;
67358
- if (this.slide.slideState.currentSlideIndex < 0) {
68019
+ let ignoreKeys = void 0;
68020
+ if (dispatch.type === "mediaPlay" || dispatch.type === "mediaPause" || dispatch.type === "mediaFullscreen") {
68021
+ ignoreKeys = [dispatch.id];
68022
+ }
68023
+ if (this.slide.slideState.currentSlideIndex < 0 || state.currentSlideIndex < 0) {
67359
68024
  await this.slide.receiveSyncHandler(dispatch);
67360
68025
  return this.nextTick();
67361
- } else if (!deepEqual(this.slide.slideState, state)) {
68026
+ } else if (!deepEqual(this.slide.slideState, state, ignoreKeys)) {
67362
68027
  await this.slide.setSlideState(state);
67363
68028
  await this.slide.receiveSyncHandler(dispatch);
67364
68029
  } else {
@@ -67411,11 +68076,11 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67411
68076
  this.prefix = option.prefix;
67412
68077
  this.taskId = option.taskId;
67413
68078
  const whiteboardApp = new WhiteboardApplication();
67414
- whiteboardApp.roomDoc = this.roomDoc;
67415
- whiteboardApp.appId = `${option.taskId}_${this.appId}_wb`;
68079
+ whiteboardApp.appDoc = this.appDoc;
68080
+ whiteboardApp.appId = `${this.appId}_wb`;
67416
68081
  whiteboardApp.userId = this.userId;
67417
68082
  whiteboardApp.userManager = this.userManager;
67418
- whiteboardApp.applicationManager = this.applicationManager;
68083
+ whiteboardApp.deleteSubDoc = this.deleteSubDoc;
67419
68084
  const json = await fetch(`${option.prefix}/${option.taskId}/jsonOutput/slide-1.json`).then((res) => res.json());
67420
68085
  this.slideCount = json.slideCount;
67421
68086
  await whiteboardApp.initialize({
@@ -67453,7 +68118,13 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67453
68118
  ...option.options,
67454
68119
  interactive: true,
67455
68120
  anchor: this.slideContainer,
67456
- mode: "interactive"
68121
+ mode: "interactive",
68122
+ clientId: Math.random().toString(36).substring(2, 15),
68123
+ timestamp: () => {
68124
+ console.log("timestamp");
68125
+ console.log(Date.now, this.calibrationTimestamp, Date.now() - this.calibrationTimestamp);
68126
+ return this.calibrationTimestamp;
68127
+ }
67457
68128
  // logger: {
67458
68129
  // info: console.log,
67459
68130
  // warn: console.warn,
@@ -67474,25 +68145,28 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67474
68145
  this.slide.on(import_slide.SLIDE_EVENTS.mainSeqStepEnd, (animateIndex) => {
67475
68146
  this.emitter.emit("mainSeqStepEnd", animateIndex);
67476
68147
  });
67477
- this.slide.on(import_slide.SLIDE_EVENTS.animateStart, () => {
67478
- this.sideBar.hidden();
67479
- });
67480
68148
  this.slide.on(import_slide.SLIDE_EVENTS.renderError, ({ error, index }) => {
67481
68149
  if (error.errorType === "CANVAS_CRASH") {
67482
68150
  this.slide.renderSlide(index);
67483
68151
  }
67484
68152
  });
67485
68153
  this.slide.on(import_slide.SLIDE_EVENTS.renderStart, (slideIndex) => {
67486
- this.whiteboardApp.emitter.view.style.opacity = "0";
67487
- this.whiteboardApp.emitter.addPage(`${slideIndex}`);
67488
- this.whiteboardApp.emitter.gotoPage(`${slideIndex}`);
67489
- this.sideBar.hidden();
67490
- this.emitter.emit("renderStart", slideIndex);
68154
+ if (slideIndex >= 0) {
68155
+ this.sideBar.pauseGetPreviewImageSchedule();
68156
+ this.whiteboardApp.emitter.view.style.opacity = "0";
68157
+ this.whiteboardApp.emitter.addPage(`${slideIndex}`);
68158
+ this.whiteboardApp.emitter.gotoPage(`${slideIndex}`);
68159
+ this.sideBar.hidden();
68160
+ this.emitter.emit("renderStart", slideIndex);
68161
+ }
67491
68162
  });
67492
68163
  this.slide.on(import_slide.SLIDE_EVENTS.renderEnd, (slideIndex) => {
67493
- this.currentSlideIndex = slideIndex;
67494
- this.whiteboardApp.emitter.view.style.opacity = "1";
67495
- this.emitter.emit("renderEnd", slideIndex);
68164
+ if (slideIndex >= 0) {
68165
+ this.sideBar.startGetPreviewImageSchedule();
68166
+ this.currentSlideIndex = slideIndex;
68167
+ this.whiteboardApp.emitter.view.style.opacity = "1";
68168
+ this.emitter.emit("renderEnd", slideIndex);
68169
+ }
67496
68170
  });
67497
68171
  this.slide.on(import_slide.SLIDE_EVENTS.stateChange, (state) => {
67498
68172
  this.getMap(this.name).set("slideState", state);
@@ -67501,6 +68175,9 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67501
68175
  window.slide = this.slide;
67502
68176
  window.slideWhiteboard = this.whiteboardApp;
67503
68177
  window.forgeSlide = this;
68178
+ this.whiteboardContainer.addEventListener("click", () => {
68179
+ this.sideBar.hidden();
68180
+ }, false);
67504
68181
  const syncSlide = this.getMap(this.name).get("slideState");
67505
68182
  if (syncSlide && syncSlide.taskId === option.taskId) {
67506
68183
  this.slide.setSlideState(syncSlide);
@@ -67544,6 +68221,7 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67544
68221
  this.onRefocusInstance();
67545
68222
  }
67546
68223
  });
68224
+ this.bindKeyBoardEvent();
67547
68225
  }
67548
68226
  window.__forge_slide = this;
67549
68227
  window.slidePermissions = this.permissions;
@@ -67552,8 +68230,11 @@ var SlideApplication = class extends import_forge_room6.AbstractApplication {
67552
68230
  userMap(userId) {
67553
68231
  return this.getMap(`user/${userId}`);
67554
68232
  }
67555
- async dispose() {
67556
- await this.whiteboardApp.dispose();
68233
+ async dispose(removeSubDoc) {
68234
+ if (removeSubDoc) {
68235
+ this.deleteSubDoc(this.appId);
68236
+ }
68237
+ await this.whiteboardApp.dispose(removeSubDoc);
67557
68238
  this.rootView.parentElement?.removeChild(this.rootView);
67558
68239
  this.slide.destroy();
67559
68240
  this.sideBar.dispose();