@netless/forge-whiteboard 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/changelog.md +5 -1
  2. package/dist/LiveCursor.d.ts +1 -1
  3. package/dist/LiveCursor.d.ts.map +1 -1
  4. package/dist/Whiteboard.d.ts +10 -0
  5. package/dist/Whiteboard.d.ts.map +1 -1
  6. package/dist/WhiteboardApplication.d.ts +5 -0
  7. package/dist/WhiteboardApplication.d.ts.map +1 -1
  8. package/dist/model/RenderableModel.d.ts +13 -1
  9. package/dist/model/RenderableModel.d.ts.map +1 -1
  10. package/dist/model/renderable/CurveModel.d.ts +4 -1
  11. package/dist/model/renderable/CurveModel.d.ts.map +1 -1
  12. package/dist/model/renderable/ElementModel.d.ts +17 -1
  13. package/dist/model/renderable/ElementModel.d.ts.map +1 -1
  14. package/dist/model/renderable/EraserModel.d.ts +5 -1
  15. package/dist/model/renderable/EraserModel.d.ts.map +1 -1
  16. package/dist/model/renderable/ImageModel.d.ts +4 -1
  17. package/dist/model/renderable/ImageModel.d.ts.map +1 -1
  18. package/dist/model/renderable/LaserPointerModel.d.ts +4 -1
  19. package/dist/model/renderable/LaserPointerModel.d.ts.map +1 -1
  20. package/dist/model/renderable/LineModel.d.ts +5 -1
  21. package/dist/model/renderable/LineModel.d.ts.map +1 -1
  22. package/dist/model/renderable/PointTextModel.d.ts +5 -1
  23. package/dist/model/renderable/PointTextModel.d.ts.map +1 -1
  24. package/dist/model/renderable/RectangleModel.d.ts +5 -1
  25. package/dist/model/renderable/RectangleModel.d.ts.map +1 -1
  26. package/dist/model/renderable/SegmentsModel.d.ts +5 -1
  27. package/dist/model/renderable/SegmentsModel.d.ts.map +1 -1
  28. package/dist/model/renderable/SelectorModel.d.ts +5 -1
  29. package/dist/model/renderable/SelectorModel.d.ts.map +1 -1
  30. package/dist/model/renderable/StraightLineModel.d.ts +5 -1
  31. package/dist/model/renderable/StraightLineModel.d.ts.map +1 -1
  32. package/dist/model/renderable/TriangleModel.d.ts +5 -1
  33. package/dist/model/renderable/TriangleModel.d.ts.map +1 -1
  34. package/dist/tool/LaserPointerTool.d.ts.map +1 -1
  35. package/dist/tool/WhiteboardTool.d.ts.map +1 -1
  36. package/dist/whiteboard.esm.js +458 -167
  37. package/dist/whiteboard.esm.js.map +3 -3
  38. package/dist/whiteboard.js +458 -167
  39. package/dist/whiteboard.js.map +3 -3
  40. package/package.json +2 -2
@@ -20839,8 +20839,8 @@ var require_lodash = __commonJS({
20839
20839
  }
20840
20840
  var runInContext = function runInContext2(context) {
20841
20841
  context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
20842
- var Array13 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String2 = context.String, TypeError2 = context.TypeError;
20843
- var arrayProto = Array13.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
20842
+ var Array14 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String2 = context.String, TypeError2 = context.TypeError;
20843
+ var arrayProto = Array14.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
20844
20844
  var coreJsData = context["__core-js_shared__"];
20845
20845
  var funcToString = funcProto.toString;
20846
20846
  var hasOwnProperty = objectProto.hasOwnProperty;
@@ -21263,7 +21263,7 @@ var require_lodash = __commonJS({
21263
21263
  }
21264
21264
  }
21265
21265
  function baseAt(object, paths) {
21266
- var index = -1, length = paths.length, result2 = Array13(length), skip = object == null;
21266
+ var index = -1, length = paths.length, result2 = Array14(length), skip = object == null;
21267
21267
  while (++index < length) {
21268
21268
  result2[index] = skip ? undefined2 : get(object, paths[index]);
21269
21269
  }
@@ -21509,7 +21509,7 @@ var require_lodash = __commonJS({
21509
21509
  return number >= nativeMin(start, end) && number < nativeMax(start, end);
21510
21510
  }
21511
21511
  function baseIntersection(arrays, iteratee2, comparator) {
21512
- var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array13(othLength), maxLength = Infinity, result2 = [];
21512
+ var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array14(othLength), maxLength = Infinity, result2 = [];
21513
21513
  while (othIndex--) {
21514
21514
  var array = arrays[othIndex];
21515
21515
  if (othIndex && iteratee2) {
@@ -21690,7 +21690,7 @@ var require_lodash = __commonJS({
21690
21690
  return value < other;
21691
21691
  }
21692
21692
  function baseMap(collection, iteratee2) {
21693
- var index = -1, result2 = isArrayLike(collection) ? Array13(collection.length) : [];
21693
+ var index = -1, result2 = isArrayLike(collection) ? Array14(collection.length) : [];
21694
21694
  baseEach(collection, function(value, key, collection2) {
21695
21695
  result2[++index] = iteratee2(value, key, collection2);
21696
21696
  });
@@ -21865,7 +21865,7 @@ var require_lodash = __commonJS({
21865
21865
  return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
21866
21866
  }
21867
21867
  function baseRange(start, end, step, fromRight) {
21868
- var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array13(length);
21868
+ var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array14(length);
21869
21869
  while (length--) {
21870
21870
  result2[fromRight ? length : ++index] = start;
21871
21871
  start += step;
@@ -21947,7 +21947,7 @@ var require_lodash = __commonJS({
21947
21947
  }
21948
21948
  length = start > end ? 0 : end - start >>> 0;
21949
21949
  start >>>= 0;
21950
- var result2 = Array13(length);
21950
+ var result2 = Array14(length);
21951
21951
  while (++index < length) {
21952
21952
  result2[index] = array[index + start];
21953
21953
  }
@@ -22107,7 +22107,7 @@ var require_lodash = __commonJS({
22107
22107
  if (length < 2) {
22108
22108
  return length ? baseUniq(arrays[0]) : [];
22109
22109
  }
22110
- var index = -1, result2 = Array13(length);
22110
+ var index = -1, result2 = Array14(length);
22111
22111
  while (++index < length) {
22112
22112
  var array = arrays[index], othIndex = -1;
22113
22113
  while (++othIndex < length) {
@@ -22204,7 +22204,7 @@ var require_lodash = __commonJS({
22204
22204
  return object.index - other.index;
22205
22205
  }
22206
22206
  function composeArgs(args, partials, holders, isCurried) {
22207
- var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 = Array13(leftLength + rangeLength), isUncurried = !isCurried;
22207
+ var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 = Array14(leftLength + rangeLength), isUncurried = !isCurried;
22208
22208
  while (++leftIndex < leftLength) {
22209
22209
  result2[leftIndex] = partials[leftIndex];
22210
22210
  }
@@ -22219,7 +22219,7 @@ var require_lodash = __commonJS({
22219
22219
  return result2;
22220
22220
  }
22221
22221
  function composeArgsRight(args, partials, holders, isCurried) {
22222
- var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 = Array13(rangeLength + rightLength), isUncurried = !isCurried;
22222
+ var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 = Array14(rangeLength + rightLength), isUncurried = !isCurried;
22223
22223
  while (++argsIndex < rangeLength) {
22224
22224
  result2[argsIndex] = args[argsIndex];
22225
22225
  }
@@ -22236,7 +22236,7 @@ var require_lodash = __commonJS({
22236
22236
  }
22237
22237
  function copyArray(source, array) {
22238
22238
  var index = -1, length = source.length;
22239
- array || (array = Array13(length));
22239
+ array || (array = Array14(length));
22240
22240
  while (++index < length) {
22241
22241
  array[index] = source[index];
22242
22242
  }
@@ -22369,7 +22369,7 @@ var require_lodash = __commonJS({
22369
22369
  function createCurry(func, bitmask, arity) {
22370
22370
  var Ctor = createCtor(func);
22371
22371
  function wrapper() {
22372
- var length = arguments.length, args = Array13(length), index = length, placeholder = getHolder(wrapper);
22372
+ var length = arguments.length, args = Array14(length), index = length, placeholder = getHolder(wrapper);
22373
22373
  while (index--) {
22374
22374
  args[index] = arguments[index];
22375
22375
  }
@@ -22449,7 +22449,7 @@ var require_lodash = __commonJS({
22449
22449
  function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
22450
22450
  var isAry = bitmask & WRAP_ARY_FLAG, isBind = bitmask & WRAP_BIND_FLAG, isBindKey = bitmask & WRAP_BIND_KEY_FLAG, isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), isFlip = bitmask & WRAP_FLIP_FLAG, Ctor = isBindKey ? undefined2 : createCtor(func);
22451
22451
  function wrapper() {
22452
- var length = arguments.length, args = Array13(length), index = length;
22452
+ var length = arguments.length, args = Array14(length), index = length;
22453
22453
  while (index--) {
22454
22454
  args[index] = arguments[index];
22455
22455
  }
@@ -22548,7 +22548,7 @@ var require_lodash = __commonJS({
22548
22548
  function createPartial(func, bitmask, thisArg, partials) {
22549
22549
  var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
22550
22550
  function wrapper() {
22551
- var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array13(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
22551
+ var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array14(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
22552
22552
  while (++leftIndex < leftLength) {
22553
22553
  args[leftIndex] = partials[leftIndex];
22554
22554
  }
@@ -23161,12 +23161,12 @@ var require_lodash = __commonJS({
23161
23161
  function overRest(func, start, transform2) {
23162
23162
  start = nativeMax(start === undefined2 ? func.length - 1 : start, 0);
23163
23163
  return function() {
23164
- var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array13(length);
23164
+ var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array14(length);
23165
23165
  while (++index < length) {
23166
23166
  array[index] = args[start + index];
23167
23167
  }
23168
23168
  index = -1;
23169
- var otherArgs = Array13(start + 1);
23169
+ var otherArgs = Array14(start + 1);
23170
23170
  while (++index < start) {
23171
23171
  otherArgs[index] = args[index];
23172
23172
  }
@@ -23288,7 +23288,7 @@ var require_lodash = __commonJS({
23288
23288
  if (!length || size2 < 1) {
23289
23289
  return [];
23290
23290
  }
23291
- var index = 0, resIndex = 0, result2 = Array13(nativeCeil(length / size2));
23291
+ var index = 0, resIndex = 0, result2 = Array14(nativeCeil(length / size2));
23292
23292
  while (index < length) {
23293
23293
  result2[resIndex++] = baseSlice(array, index, index += size2);
23294
23294
  }
@@ -23309,7 +23309,7 @@ var require_lodash = __commonJS({
23309
23309
  if (!length) {
23310
23310
  return [];
23311
23311
  }
23312
- var args = Array13(length - 1), array = arguments[0], index = length;
23312
+ var args = Array14(length - 1), array = arguments[0], index = length;
23313
23313
  while (index--) {
23314
23314
  args[index - 1] = arguments[index];
23315
23315
  }
@@ -23811,7 +23811,7 @@ var require_lodash = __commonJS({
23811
23811
  return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
23812
23812
  }
23813
23813
  var invokeMap = baseRest(function(collection, path, args) {
23814
- var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array13(collection.length) : [];
23814
+ var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array14(collection.length) : [];
23815
23815
  baseEach(collection, function(value) {
23816
23816
  result2[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
23817
23817
  });
@@ -24194,7 +24194,7 @@ var require_lodash = __commonJS({
24194
24194
  }()) ? baseIsArguments : function(value) {
24195
24195
  return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
24196
24196
  };
24197
- var isArray = Array13.isArray;
24197
+ var isArray = Array14.isArray;
24198
24198
  var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
24199
24199
  function isArrayLike(value) {
24200
24200
  return value != null && isLength(value.length) && !isFunction(value);
@@ -25880,12 +25880,23 @@ var ElementModel = class _ElementModel {
25880
25880
  set shadow(value) {
25881
25881
  this.root.set(_ElementModel.KEYS.shadow, value);
25882
25882
  }
25883
- constructor(root, scope, liveCursor) {
25883
+ get isPerformanceEnvironment() {
25884
+ return this.isPerformanceMode() && this.shouldUseLocalPoints;
25885
+ }
25886
+ constructor(root, scope, liveCursor, isPerformanceMode) {
25884
25887
  _defineProperty(this, "shadowEmitter", null);
25885
25888
  _defineProperty(this, "root", void 0);
25886
25889
  _defineProperty(this, "scope", void 0);
25887
25890
  _defineProperty(this, "item", void 0);
25891
+ _defineProperty(this, "clearLocalPointsWhenYPointsChange", void 0);
25892
+ _defineProperty(this, "shouldUseLocalPoints", void 0);
25893
+ _defineProperty(this, "localPointsPick", void 0);
25888
25894
  _defineProperty(this, "liveCursor", void 0);
25895
+ _defineProperty(this, "appendPointsTimer", null);
25896
+ _defineProperty(this, "setPointsTimer", null);
25897
+ _defineProperty(this, "pointsUpdateTimer", null);
25898
+ _defineProperty(this, "isPerformanceMode", void 0);
25899
+ _defineProperty(this, "localPoints", []);
25889
25900
  _defineProperty(this, "handlePropChange", (events) => {
25890
25901
  if (!this.item) {
25891
25902
  return;
@@ -25924,24 +25935,68 @@ var ElementModel = class _ElementModel {
25924
25935
  }
25925
25936
  }
25926
25937
  } else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
25927
- this.onVectorUpdate();
25928
- const liveCursorPoint = this.liveCursorPoint();
25929
- const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25930
- if (liveCursorPoint && ownerId) {
25931
- this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
25938
+ if (this.isPerformanceEnvironment) {
25939
+ this.handlePointsChangePerformance();
25940
+ } else {
25941
+ this.handlePointsChangeDirect();
25932
25942
  }
25933
25943
  } else {
25934
25944
  }
25935
25945
  }
25936
25946
  });
25947
+ _defineProperty(this, "onPointsArrayChange", (points) => {
25948
+ if (this.localPoints.length >= points.length) {
25949
+ return;
25950
+ }
25951
+ const pointsChunk = points.slice(this.localPoints.length, this.localPoints.length + this.localPointsPick);
25952
+ this.localPoints = this.localPoints.concat(pointsChunk);
25953
+ this.onVectorUpdate();
25954
+ this.pointsUpdateTimer = window.requestAnimationFrame(() => {
25955
+ this.onPointsArrayChange(points);
25956
+ });
25957
+ });
25958
+ this.isPerformanceMode = isPerformanceMode;
25937
25959
  this.scope = scope;
25938
25960
  this.liveCursor = liveCursor;
25939
25961
  this.root = root;
25940
- if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
25962
+ if (this.root.doc) {
25963
+ if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
25964
+ this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
25965
+ }
25966
+ } else {
25941
25967
  this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
25942
25968
  }
25943
25969
  this.root.observeDeep(this.handlePropChange);
25944
25970
  }
25971
+ handlePointsChangeDirect() {
25972
+ this.onVectorUpdate();
25973
+ const liveCursorPoint = this.liveCursorPoint();
25974
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25975
+ if (liveCursorPoint && ownerId) {
25976
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
25977
+ }
25978
+ }
25979
+ handlePointsChangePerformance() {
25980
+ const liveCursorPoint = this.liveCursorPoint();
25981
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25982
+ if (liveCursorPoint && ownerId) {
25983
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
25984
+ }
25985
+ if (this.liveCursor.userManager.selfId !== ownerId || this.localPoints.length === 0) {
25986
+ if (this.pointsUpdateTimer) {
25987
+ window.cancelAnimationFrame(this.pointsUpdateTimer);
25988
+ }
25989
+ if (this.shadow == "") {
25990
+ this.localPoints = this.points;
25991
+ this.onVectorUpdate();
25992
+ } else {
25993
+ if (this.clearLocalPointsWhenYPointsChange) {
25994
+ this.localPoints = [];
25995
+ }
25996
+ this.onPointsArrayChange(this.points);
25997
+ }
25998
+ }
25999
+ }
25945
26000
  createPaperElement() {
25946
26001
  this.createPaperItem();
25947
26002
  if (this.item) {
@@ -25953,14 +26008,48 @@ var ElementModel = class _ElementModel {
25953
26008
  }
25954
26009
  }
25955
26010
  appendPoints(points) {
26011
+ if (this.isPerformanceEnvironment) {
26012
+ this.appendPointsPerformance(points);
26013
+ } else {
26014
+ this.appendPointsDirect(points);
26015
+ }
26016
+ }
26017
+ appendPointsDirect(points) {
25956
26018
  this.root.get(_ElementModel.KEYS.points).push(points);
25957
26019
  }
26020
+ appendPointsPerformance(points) {
26021
+ this.localPoints = this.localPoints.concat(points);
26022
+ this.onVectorUpdate();
26023
+ if (this.appendPointsTimer) {
26024
+ window.clearTimeout(this.appendPointsTimer);
26025
+ }
26026
+ if (this.localPoints.length % 80 === 0) {
26027
+ const yArray = this.root.get(_ElementModel.KEYS.points);
26028
+ yArray?.push(this.localPoints.slice(yArray.length));
26029
+ }
26030
+ this.appendPointsTimer = window.setTimeout(() => {
26031
+ this.appendPointsTimer = null;
26032
+ if (this.localPoints.length > 0) {
26033
+ const yArray = this.root.get(_ElementModel.KEYS.points);
26034
+ yArray?.push(this.localPoints.slice(yArray.length));
26035
+ }
26036
+ }, 100);
26037
+ }
25958
26038
  setPoints(points) {
26039
+ if (this.isPerformanceEnvironment) {
26040
+ this.setPointsPerformance(points);
26041
+ } else {
26042
+ this.setPointsDirect(points);
26043
+ }
26044
+ }
26045
+ setPointsDirect(points) {
25959
26046
  if (this.root.doc) {
25960
26047
  this.root.doc.transact(() => {
25961
26048
  const yArray = this.root.get(_ElementModel.KEYS.points);
25962
- yArray.delete(0, yArray.length);
25963
- yArray.push(points);
26049
+ if (yArray) {
26050
+ yArray.delete(0, yArray.length);
26051
+ yArray.push(points);
26052
+ }
25964
26053
  });
25965
26054
  } else {
25966
26055
  const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
@@ -25969,6 +26058,29 @@ var ElementModel = class _ElementModel {
25969
26058
  this.root.set(_ElementModel.KEYS.points, yArray);
25970
26059
  }
25971
26060
  }
26061
+ setPointsPerformance(points) {
26062
+ this.localPoints = points;
26063
+ this.onVectorUpdate();
26064
+ if (this.setPointsTimer) {
26065
+ window.clearTimeout(this.setPointsTimer);
26066
+ }
26067
+ this.setPointsTimer = window.setTimeout(() => {
26068
+ if (this.root.doc) {
26069
+ this.root.doc.transact(() => {
26070
+ const yArray = this.root.get(_ElementModel.KEYS.points);
26071
+ if (yArray) {
26072
+ yArray.delete(0, yArray.length);
26073
+ yArray.push(points);
26074
+ }
26075
+ });
26076
+ } else {
26077
+ const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
26078
+ yArray.delete(0, yArray.length);
26079
+ yArray.push(points);
26080
+ this.root.set(_ElementModel.KEYS.points, yArray);
26081
+ }
26082
+ }, 100);
26083
+ }
25972
26084
  appendPointsMatrix(matrix) {
25973
26085
  const current = new this.scope.Matrix(this.pointsMatrix);
25974
26086
  const next = matrix.appended(current);
@@ -26067,15 +26179,18 @@ function _toPrimitive3(t, r) {
26067
26179
  return ("string" === r ? String : Number)(t);
26068
26180
  }
26069
26181
  var CurveModel = class extends ElementModel {
26070
- constructor(root, scope, liveCursor) {
26071
- super(root, scope, liveCursor);
26182
+ constructor(root, scope, liveCursor, isPerformanceMode) {
26183
+ super(root, scope, liveCursor, isPerformanceMode);
26072
26184
  _defineProperty3(this, "item", null);
26073
26185
  _defineProperty3(this, "debugPath", void 0);
26074
26186
  _defineProperty3(this, "debug", false);
26075
- if (!this.root.has("type")) {
26187
+ _defineProperty3(this, "clearLocalPointsWhenYPointsChange", false);
26188
+ _defineProperty3(this, "shouldUseLocalPoints", true);
26189
+ _defineProperty3(this, "localPointsPick", 4);
26190
+ if (!this.root.doc || !this.root.has("type")) {
26076
26191
  this.root.set("type", "curve");
26077
26192
  }
26078
- if (!this.root.has("points")) {
26193
+ if (!this.root.doc || !this.root.has("points")) {
26079
26194
  this.root.set("points", new Y2.Array());
26080
26195
  }
26081
26196
  this.debugPath = new scope.Path();
@@ -26101,7 +26216,7 @@ var CurveModel = class extends ElementModel {
26101
26216
  });
26102
26217
  }
26103
26218
  matrixedPoints() {
26104
- const points = this.points;
26219
+ const points = this.localPoints.length === 0 ? this.points : this.localPoints;
26105
26220
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26106
26221
  const output = [];
26107
26222
  for (let i = 0, len = points.length; i < len; i += 2) {
@@ -26228,15 +26343,24 @@ function _toPrimitive4(t, r) {
26228
26343
  return ("string" === r ? String : Number)(t);
26229
26344
  }
26230
26345
  var SelectorModel = class extends ElementModel {
26231
- constructor(root, scope, liveCursor) {
26232
- super(root, scope, liveCursor);
26346
+ get drawPoints() {
26347
+ if (this.localPoints.length >= 4) {
26348
+ return this.localPoints;
26349
+ }
26350
+ return this.points;
26351
+ }
26352
+ constructor(root, scope, liveCursor, isPerformanceMode) {
26353
+ super(root, scope, liveCursor, isPerformanceMode);
26233
26354
  _defineProperty4(this, "item", null);
26234
- if (!this.root.has("type")) {
26355
+ _defineProperty4(this, "clearLocalPointsWhenYPointsChange", true);
26356
+ _defineProperty4(this, "shouldUseLocalPoints", true);
26357
+ _defineProperty4(this, "localPointsPick", 4);
26358
+ if (this.root.doc && !this.root.has("type")) {
26235
26359
  this.root.set("type", "selector");
26236
26360
  }
26237
- if (!this.root.has("points")) {
26361
+ if (this.root.doc && !this.root.has("points")) {
26238
26362
  const initPoints = new Y3.Array();
26239
- initPoints.push([0, 0, 0, 0, 0]);
26363
+ initPoints.push([0, 0, 0, 0]);
26240
26364
  this.root.set("points", initPoints);
26241
26365
  }
26242
26366
  }
@@ -26247,8 +26371,8 @@ var SelectorModel = class extends ElementModel {
26247
26371
  }
26248
26372
  createPaperRect() {
26249
26373
  const scope = this.scope;
26250
- const bounds = new scope.Rectangle(new scope.Point(this.points[0], this.points[1]), new scope.Size(this.points[2], this.points[3]));
26251
- return new scope.Path.Rectangle(bounds, new scope.Point(this.points[4], this.points[4]));
26374
+ const bounds = new scope.Rectangle(new scope.Point(this.drawPoints[0], this.drawPoints[1]), new scope.Size(this.drawPoints[2], this.drawPoints[3]));
26375
+ return new scope.Path.Rectangle(bounds);
26252
26376
  }
26253
26377
  onVectorUpdate() {
26254
26378
  if (!this.item) {
@@ -26369,13 +26493,22 @@ function _toPrimitive6(t, r) {
26369
26493
  return ("string" === r ? String : Number)(t);
26370
26494
  }
26371
26495
  var SegmentsModel = class extends ElementModel {
26372
- constructor(root, scope, type, liveCursor) {
26373
- super(root, scope, liveCursor);
26496
+ get drawPoints() {
26497
+ if (this.localPoints.length >= 4) {
26498
+ return this.localPoints;
26499
+ }
26500
+ return this.points;
26501
+ }
26502
+ constructor(root, scope, type, liveCursor, isPerformanceMode) {
26503
+ super(root, scope, liveCursor, isPerformanceMode);
26374
26504
  _defineProperty6(this, "item", null);
26375
- if (!this.root.has("type")) {
26505
+ _defineProperty6(this, "clearLocalPointsWhenYPointsChange", true);
26506
+ _defineProperty6(this, "shouldUseLocalPoints", true);
26507
+ _defineProperty6(this, "localPointsPick", 24);
26508
+ if (this.root.doc && !this.root.has("type")) {
26376
26509
  this.root.set("type", type);
26377
26510
  }
26378
- if (!this.root.has("points")) {
26511
+ if (this.root.doc && !this.root.has("points")) {
26379
26512
  this.root.set("points", new Y4.Array());
26380
26513
  }
26381
26514
  }
@@ -26395,13 +26528,13 @@ var SegmentsModel = class extends ElementModel {
26395
26528
  }
26396
26529
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26397
26530
  this.item.removeSegments();
26398
- const next = deserializePath(this.points, this.scope, matrix);
26531
+ const next = deserializePath(this.drawPoints, this.scope, matrix);
26399
26532
  this.item.addSegments(next.segments);
26400
26533
  this.item.closePath();
26401
26534
  }
26402
26535
  createPaperItem() {
26403
26536
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26404
- this.item = deserializePath(this.points, this.scope, matrix);
26537
+ this.item = deserializePath(this.drawPoints, this.scope, matrix);
26405
26538
  this.item.strokeColor = new this.scope.Color(this.strokeColor);
26406
26539
  this.item.dashArray = this.dashArray;
26407
26540
  this.item.strokeWidth = this.strokeWidth;
@@ -26569,6 +26702,12 @@ function _toPrimitive9(t, r) {
26569
26702
  return ("string" === r ? String : Number)(t);
26570
26703
  }
26571
26704
  var LineModel = class extends ElementModel {
26705
+ get drawPoints() {
26706
+ if (this.localPoints.length > 0) {
26707
+ return this.localPoints;
26708
+ }
26709
+ return this.points;
26710
+ }
26572
26711
  get arrowSize() {
26573
26712
  return this.strokeWidth * 5 + 15;
26574
26713
  }
@@ -26584,20 +26723,23 @@ var LineModel = class extends ElementModel {
26584
26723
  set tailArrow(value) {
26585
26724
  this.root.set("tailArrow", value);
26586
26725
  }
26587
- constructor(root, scope, liveCursor) {
26588
- super(root, scope, liveCursor);
26726
+ constructor(root, scope, liveCursor, isPerformanceMode) {
26727
+ super(root, scope, liveCursor, isPerformanceMode);
26589
26728
  _defineProperty9(this, "controlledPoints", []);
26729
+ _defineProperty9(this, "clearLocalPointsWhenYPointsChange", true);
26730
+ _defineProperty9(this, "shouldUseLocalPoints", true);
26731
+ _defineProperty9(this, "localPointsPick", 99);
26590
26732
  _defineProperty9(this, "item", null);
26591
- if (!this.root.has("type")) {
26733
+ if (this.root.doc && !this.root.has("type")) {
26592
26734
  this.root.set("type", "arrow");
26593
26735
  }
26594
- if (!this.root.has("points")) {
26736
+ if (this.root.doc && !this.root.has("points")) {
26595
26737
  this.root.set("points", new Y5.Array());
26596
26738
  }
26597
- if (!this.root.has("headArrow")) {
26739
+ if (this.root.doc && !this.root.has("headArrow")) {
26598
26740
  this.root.set("headArrow", "none");
26599
26741
  }
26600
- if (!this.root.has("tailArrow")) {
26742
+ if (this.root.doc && !this.root.has("tailArrow")) {
26601
26743
  this.root.set("tailArrow", "normal");
26602
26744
  }
26603
26745
  }
@@ -26613,7 +26755,7 @@ var LineModel = class extends ElementModel {
26613
26755
  }
26614
26756
  renderLine() {
26615
26757
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26616
- const papperPoints = (0, import_lodash4.chunk)(this.points, 2).map((item) => {
26758
+ const papperPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).map((item) => {
26617
26759
  return new this.scope.Point(item[0], item[1]).transform(matrix);
26618
26760
  });
26619
26761
  const path = new this.scope.Path();
@@ -26727,13 +26869,14 @@ var LineControlPoint = class {
26727
26869
  if (this.position) {
26728
26870
  return this.model.scope.project.view.projectToView(this.position.transform(matrix));
26729
26871
  }
26872
+ const points = this.model["drawPoints"];
26730
26873
  const from = {
26731
- x: this.model.points[0],
26732
- y: this.model.points[1]
26874
+ x: points[0],
26875
+ y: points[1]
26733
26876
  };
26734
26877
  const to = {
26735
- x: this.model.points[this.model.points.length - 2],
26736
- y: this.model.points[this.model.points.length - 1]
26878
+ x: points[points.length - 2],
26879
+ y: points[points.length - 1]
26737
26880
  };
26738
26881
  const clonedPath = new this.scope.Path.Line(from, to);
26739
26882
  this.position = clonedPath.getPointAt(clonedPath.length * distance);
@@ -26746,7 +26889,7 @@ var LineControlPoint = class {
26746
26889
  }
26747
26890
  const pointsMatrix = new this.model.scope.Matrix(this.model.pointsMatrix);
26748
26891
  const invertedPoint = point.transform(pointsMatrix.inverted());
26749
- const points = this.model.points;
26892
+ const points = this.model["drawPoints"];
26750
26893
  this.position = invertedPoint;
26751
26894
  const clonedPoints = (0, import_lodash4.cloneDeep)(points);
26752
26895
  clonedPoints[this.options.index * 2] = invertedPoint.x;
@@ -26794,9 +26937,18 @@ var PointTextModel = class extends ElementModel {
26794
26937
  set fontFamily(value) {
26795
26938
  this.root.set("font-family", value);
26796
26939
  }
26797
- constructor(root, scope, liveCursor) {
26798
- super(root, scope, liveCursor);
26940
+ get drawPoints() {
26941
+ if (this.localPoints.length > 1) {
26942
+ return this.localPoints;
26943
+ }
26944
+ return this.points;
26945
+ }
26946
+ constructor(root, scope, liveCursor, isPerformanceMode) {
26947
+ super(root, scope, liveCursor, isPerformanceMode);
26799
26948
  _defineProperty10(this, "item", null);
26949
+ _defineProperty10(this, "clearLocalPointsWhenYPointsChange", true);
26950
+ _defineProperty10(this, "shouldUseLocalPoints", false);
26951
+ _defineProperty10(this, "localPointsPick", 2);
26800
26952
  _defineProperty10(this, "handleTextPropChange", (event) => {
26801
26953
  if (!this.item) {
26802
26954
  return;
@@ -26813,18 +26965,20 @@ var PointTextModel = class extends ElementModel {
26813
26965
  }
26814
26966
  }
26815
26967
  });
26816
- if (!this.root.has("type")) {
26968
+ if (this.root.doc && !this.root.has("type")) {
26817
26969
  this.root.set("type", "point-text");
26818
26970
  }
26819
- if (!this.root.has(ElementModel.KEYS.points)) {
26971
+ if (this.root.doc && !this.root.has(ElementModel.KEYS.points)) {
26820
26972
  this.root.set(ElementModel.KEYS.points, new Y6.Array());
26821
26973
  }
26822
26974
  this.root.observe(this.handleTextPropChange);
26823
- if (this.root.has("font-size")) {
26824
- setTimeout(() => {
26825
- this.updateTextPosition();
26826
- }, 60);
26827
- }
26975
+ setTimeout(() => {
26976
+ if (this.root && this.root.has("font-size")) {
26977
+ setTimeout(() => {
26978
+ this.updateTextPosition();
26979
+ }, 60);
26980
+ }
26981
+ }, 60);
26828
26982
  }
26829
26983
  subDispose() {
26830
26984
  removeObserver(this.root, this.handleTextPropChange);
@@ -26842,10 +26996,11 @@ var PointTextModel = class extends ElementModel {
26842
26996
  if (!this.item) {
26843
26997
  return null;
26844
26998
  }
26999
+ console.log("[][][] drawPoints", this.drawPoints);
26845
27000
  const bounds = this.item.internalBounds;
26846
27001
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26847
- const topLeft = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
26848
- const topRight = new this.scope.Point(this.points[0] + bounds.width, this.points[1]).transform(matrix);
27002
+ const topLeft = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
27003
+ const topRight = new this.scope.Point(this.drawPoints[0] + bounds.width, this.drawPoints[1]).transform(matrix);
26849
27004
  let scaleX = topRight.getDistance(topLeft) / bounds.width;
26850
27005
  scaleX = Number.isNaN(scaleX) ? 1 : scaleX;
26851
27006
  const angle = topRight.subtract(topLeft).angle;
@@ -26933,13 +27088,22 @@ function _toPrimitive11(t, r) {
26933
27088
  return ("string" === r ? String : Number)(t);
26934
27089
  }
26935
27090
  var TriangleModel = class extends ElementModel {
26936
- constructor(root, scope, liveCursor) {
26937
- super(root, scope, liveCursor);
27091
+ get drawPoints() {
27092
+ if (this.localPoints.length >= 6) {
27093
+ return this.localPoints;
27094
+ }
27095
+ return this.points;
27096
+ }
27097
+ constructor(root, scope, liveCursor, isPerformanceMode) {
27098
+ super(root, scope, liveCursor, isPerformanceMode);
26938
27099
  _defineProperty11(this, "item", null);
26939
- if (!this.root.has("type")) {
27100
+ _defineProperty11(this, "clearLocalPointsWhenYPointsChange", true);
27101
+ _defineProperty11(this, "shouldUseLocalPoints", true);
27102
+ _defineProperty11(this, "localPointsPick", 6);
27103
+ if (this.root.doc && !this.root.has("type")) {
26940
27104
  this.root.set("type", "triangle");
26941
27105
  }
26942
- if (!this.root.has("points")) {
27106
+ if (this.root.doc && !this.root.has("points")) {
26943
27107
  this.root.set("points", new Y7.Array());
26944
27108
  }
26945
27109
  }
@@ -26971,9 +27135,9 @@ var TriangleModel = class extends ElementModel {
26971
27135
  return;
26972
27136
  }
26973
27137
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26974
- const p1 = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
26975
- const p2 = new this.scope.Point(this.points[2], this.points[3]).transform(matrix);
26976
- const p3 = new this.scope.Point(this.points[4], this.points[5]).transform(matrix);
27138
+ const p1 = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
27139
+ const p2 = new this.scope.Point(this.drawPoints[2], this.drawPoints[3]).transform(matrix);
27140
+ const p3 = new this.scope.Point(this.drawPoints[4], this.drawPoints[5]).transform(matrix);
26977
27141
  this.item.removeSegments();
26978
27142
  this.item.moveTo(p1);
26979
27143
  this.item.lineTo(p2);
@@ -26985,7 +27149,7 @@ var TriangleModel = class extends ElementModel {
26985
27149
  config.controlPoints.push({
26986
27150
  name: "triangle",
26987
27151
  getPosition: () => {
26988
- const point = new this.scope.Point(this.points[0], this.points[1]);
27152
+ const point = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]);
26989
27153
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
26990
27154
  return this.scope.project.view.projectToView(point.transform(pointsMatrix));
26991
27155
  },
@@ -26995,7 +27159,7 @@ var TriangleModel = class extends ElementModel {
26995
27159
  }
26996
27160
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
26997
27161
  const trPoint = point.transform(pointsMatrix.inverted());
26998
- const oldPoints = this.points;
27162
+ const oldPoints = this.drawPoints;
26999
27163
  this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3], oldPoints[4], oldPoints[5]]);
27000
27164
  }
27001
27165
  });
@@ -27034,25 +27198,34 @@ function _toPrimitive12(t, r) {
27034
27198
  return ("string" === r ? String : Number)(t);
27035
27199
  }
27036
27200
  var RectangleModel = class extends ElementModel {
27037
- constructor(root, scope, liveCursor) {
27038
- super(root, scope, liveCursor);
27201
+ get drawPoints() {
27202
+ if (this.localPoints.length >= 4) {
27203
+ return this.localPoints;
27204
+ }
27205
+ return this.points;
27206
+ }
27207
+ constructor(root, scope, liveCursor, isPerformanceMode) {
27208
+ super(root, scope, liveCursor, isPerformanceMode);
27039
27209
  _defineProperty12(this, "item", null);
27040
- if (!this.root.has("type")) {
27210
+ _defineProperty12(this, "clearLocalPointsWhenYPointsChange", true);
27211
+ _defineProperty12(this, "shouldUseLocalPoints", true);
27212
+ _defineProperty12(this, "localPointsPick", 4);
27213
+ if (this.root.doc && !this.root.has("type")) {
27041
27214
  this.root.set("type", "rectangle");
27042
27215
  }
27043
- if (!this.root.has("points")) {
27216
+ if (this.root.doc && !this.root.has("points")) {
27044
27217
  const initPoints = new Y8.Array();
27045
27218
  initPoints.push([0, 0, 0, 0]);
27046
27219
  this.root.set("points", initPoints);
27047
27220
  }
27048
- if (!this.root.has("radius")) {
27221
+ if (this.root.doc && !this.root.has("radius")) {
27049
27222
  this.root.set("radius", 0);
27050
27223
  }
27051
27224
  }
27052
27225
  subDispose() {
27053
27226
  }
27054
27227
  liveCursorPoint() {
27055
- const points = this.points;
27228
+ const points = this.drawPoints;
27056
27229
  if (points.length < 4) {
27057
27230
  return null;
27058
27231
  }
@@ -27060,7 +27233,7 @@ var RectangleModel = class extends ElementModel {
27060
27233
  return new this.scope.Point(points[2], points[3]).transform(matrix);
27061
27234
  }
27062
27235
  createSegments() {
27063
- const [a2, b2, c, d] = this.points;
27236
+ const [a2, b2, c, d] = this.drawPoints;
27064
27237
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27065
27238
  const maxRadius = this.maxRadiusLength();
27066
27239
  const radius = this.root.get("radius") * maxRadius;
@@ -27125,7 +27298,7 @@ var RectangleModel = class extends ElementModel {
27125
27298
  }
27126
27299
  maxRadiusLength() {
27127
27300
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27128
- const points = this.points;
27301
+ const points = this.drawPoints;
27129
27302
  const topLeft = new this.scope.Point(points[0], points[1]).transform(pointsMatrix);
27130
27303
  const topRight = new this.scope.Point(points[2], points[1]).transform(pointsMatrix);
27131
27304
  const bottomLeft = new this.scope.Point(points[0], points[3]).transform(pointsMatrix);
@@ -27150,7 +27323,7 @@ var RectangleModel = class extends ElementModel {
27150
27323
  name: "rect-radius",
27151
27324
  getPosition: () => {
27152
27325
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27153
- const points = this.points;
27326
+ const points = this.drawPoints;
27154
27327
  const radius = this.root.get("radius") * this.maxRadiusLength();
27155
27328
  let c1 = new this.scope.Point(points[0], points[1]).transform(matrix);
27156
27329
  const c3 = new this.scope.Point(points[2], points[3]).transform(matrix);
@@ -27169,7 +27342,7 @@ var RectangleModel = class extends ElementModel {
27169
27342
  if (!this.item) {
27170
27343
  return;
27171
27344
  }
27172
- const points = this.points;
27345
+ const points = this.drawPoints;
27173
27346
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27174
27347
  const maxRadius = Math.min(points[2] - points[0], points[3] - points[1]) / 2;
27175
27348
  const trPoint = point.transform(pointsMatrix.inverted());
@@ -27218,14 +27391,23 @@ function _toPrimitive13(t, r) {
27218
27391
  return ("string" === r ? String : Number)(t);
27219
27392
  }
27220
27393
  var EraserModel = class extends ElementModel {
27221
- constructor(root, scope, liveCursor) {
27222
- super(root, scope, liveCursor);
27394
+ get drawPoints() {
27395
+ if (this.localPoints.length > 0) {
27396
+ return this.localPoints;
27397
+ }
27398
+ return this.points;
27399
+ }
27400
+ constructor(root, scope, liveCursor, isPerformanceMode) {
27401
+ super(root, scope, liveCursor, isPerformanceMode);
27223
27402
  _defineProperty13(this, "item", null);
27224
27403
  _defineProperty13(this, "sliceBegin", 0);
27225
- if (!this.root.has("type")) {
27404
+ _defineProperty13(this, "clearLocalPointsWhenYPointsChange", false);
27405
+ _defineProperty13(this, "shouldUseLocalPoints", true);
27406
+ _defineProperty13(this, "localPointsPick", 4);
27407
+ if (this.root.doc && !this.root.has("type")) {
27226
27408
  this.root.set("type", "eraser");
27227
27409
  }
27228
- if (!this.root.has("points")) {
27410
+ if (this.root.doc && !this.root.has("points")) {
27229
27411
  this.root.set("points", new Y9.Array());
27230
27412
  }
27231
27413
  }
@@ -27276,7 +27458,7 @@ var EraserModel = class extends ElementModel {
27276
27458
  });
27277
27459
  }
27278
27460
  matrixedPoints() {
27279
- const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
27461
+ const currentPoints = (0, import_lodash5.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
27280
27462
  return currentPoints.map((_ref) => {
27281
27463
  let [x, y] = _ref;
27282
27464
  return new this.scope.Point(x, y);
@@ -27304,11 +27486,11 @@ var EraserModel = class extends ElementModel {
27304
27486
  this.item.fillColor = new this.scope.Color(this.strokeColor);
27305
27487
  this.onVectorUpdate();
27306
27488
  this.item.onFrame = () => {
27307
- if (!this.points) {
27489
+ if (!this.drawPoints) {
27308
27490
  return;
27309
27491
  }
27310
- if (this.points.length / 2 > 50) {
27311
- this.sliceBegin = this.points.length / 2 - 50;
27492
+ if (this.drawPoints.length / 2 > 50) {
27493
+ this.sliceBegin = this.drawPoints.length / 2 - 50;
27312
27494
  }
27313
27495
  };
27314
27496
  }
@@ -27361,21 +27543,24 @@ function _toPrimitive14(t, r) {
27361
27543
  return ("string" === r ? String : Number)(t);
27362
27544
  }
27363
27545
  var LaserPointerModel = class extends ElementModel {
27364
- constructor(clientId, root, scope, liveCursor, removeElement) {
27365
- super(root, scope, liveCursor);
27546
+ constructor(clientId, root, scope, liveCursor, removeElement, isPerformanceMode) {
27547
+ super(root, scope, liveCursor, isPerformanceMode);
27366
27548
  _defineProperty14(this, "item", null);
27367
27549
  _defineProperty14(this, "clientId", void 0);
27368
27550
  _defineProperty14(this, "sliceBegin", 0);
27369
27551
  _defineProperty14(this, "displayStrokeWidth", 8);
27370
27552
  _defineProperty14(this, "cachedPoints", null);
27553
+ _defineProperty14(this, "clearLocalPointsWhenYPointsChange", false);
27554
+ _defineProperty14(this, "shouldUseLocalPoints", false);
27555
+ _defineProperty14(this, "localPointsPick", 4);
27371
27556
  this.clientId = clientId;
27372
- if (!this.root.has("type")) {
27557
+ if (this.root.doc && !this.root.has("type")) {
27373
27558
  this.root.set("type", "laser");
27374
27559
  }
27375
- if (!this.root.has("points")) {
27560
+ if (this.root.doc && !this.root.has("points")) {
27376
27561
  this.root.set("points", new Y10.Array());
27377
27562
  }
27378
- if (!this.root.has("removed")) {
27563
+ if (this.root.doc && !this.root.has("removed")) {
27379
27564
  this.root.set("removed", false);
27380
27565
  }
27381
27566
  this.root.observe((event) => {
@@ -27455,6 +27640,7 @@ var LaserPointerModel = class extends ElementModel {
27455
27640
  matrixedPoints() {
27456
27641
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27457
27642
  const points = this.cachedPoints || this.points;
27643
+ console.log("[][][] ,", this.points.length, this.cachedPoints?.length, this.localPoints.length);
27458
27644
  const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
27459
27645
  return groupPoints.map((_ref) => {
27460
27646
  let [x, y] = _ref;
@@ -27556,13 +27742,22 @@ function _toPrimitive15(t, r) {
27556
27742
  return ("string" === r ? String : Number)(t);
27557
27743
  }
27558
27744
  var StraightLineModel = class extends ElementModel {
27559
- constructor(root, scope, liveCursor) {
27560
- super(root, scope, liveCursor);
27745
+ get drawPoints() {
27746
+ if (this.localPoints.length >= 4) {
27747
+ return this.localPoints;
27748
+ }
27749
+ return this.points;
27750
+ }
27751
+ constructor(root, scope, liveCursor, isPerformanceMode) {
27752
+ super(root, scope, liveCursor, isPerformanceMode);
27561
27753
  _defineProperty15(this, "item", null);
27562
- if (!this.root.has("type")) {
27754
+ _defineProperty15(this, "clearLocalPointsWhenYPointsChange", true);
27755
+ _defineProperty15(this, "shouldUseLocalPoints", true);
27756
+ _defineProperty15(this, "localPointsPick", 4);
27757
+ if (this.root.doc && !this.root.has("type")) {
27563
27758
  this.root.set("type", "line");
27564
27759
  }
27565
- if (!this.root.has("points")) {
27760
+ if (this.root.doc && !this.root.has("points")) {
27566
27761
  this.root.set("points", new Y11.Array());
27567
27762
  }
27568
27763
  }
@@ -27587,7 +27782,7 @@ var StraightLineModel = class extends ElementModel {
27587
27782
  }
27588
27783
  renderLine() {
27589
27784
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27590
- const papperPoints = (0, import_lodash7.chunk)(this.points, 2).map((item) => {
27785
+ const papperPoints = (0, import_lodash7.chunk)(this.drawPoints, 2).map((item) => {
27591
27786
  return new this.scope.Point(item[0], item[1]).transform(matrix);
27592
27787
  });
27593
27788
  const path = new this.scope.Path();
@@ -27609,7 +27804,7 @@ var StraightLineModel = class extends ElementModel {
27609
27804
  name: "line-start",
27610
27805
  getPosition: () => {
27611
27806
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27612
- const points = this.points;
27807
+ const points = this.drawPoints;
27613
27808
  const start = new this.scope.Point(points[0], points[1]);
27614
27809
  return this.scope.project.view.projectToView(start.transform(matrix));
27615
27810
  },
@@ -27619,14 +27814,15 @@ var StraightLineModel = class extends ElementModel {
27619
27814
  }
27620
27815
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27621
27816
  const trPoint = point.transform(pointsMatrix.inverted());
27622
- this.setPoints([trPoint.x, trPoint.y, this.points[2], this.points[3]]);
27817
+ const oldPoints = this.drawPoints;
27818
+ this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3]]);
27623
27819
  }
27624
27820
  });
27625
27821
  cfg.controlPoints.push({
27626
27822
  name: "line-end",
27627
27823
  getPosition: () => {
27628
27824
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27629
- const points = this.points;
27825
+ const points = this.drawPoints;
27630
27826
  const end = new this.scope.Point(points[2], points[3]);
27631
27827
  return this.scope.project.view.projectToView(end.transform(matrix));
27632
27828
  },
@@ -27636,7 +27832,8 @@ var StraightLineModel = class extends ElementModel {
27636
27832
  }
27637
27833
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27638
27834
  const trPoint = point.transform(pointsMatrix.inverted());
27639
- this.setPoints([this.points[0], this.points[1], trPoint.x, trPoint.y]);
27835
+ const oldPoints = this.drawPoints;
27836
+ this.setPoints([oldPoints[0], oldPoints[1], trPoint.x, trPoint.y]);
27640
27837
  }
27641
27838
  });
27642
27839
  return cfg;
@@ -27682,10 +27879,13 @@ var ImageModel = class extends ElementModel {
27682
27879
  get src() {
27683
27880
  return this.root.get("src");
27684
27881
  }
27685
- constructor(root, scope, imageSets, liveCursor) {
27686
- super(root, scope, liveCursor);
27882
+ constructor(root, scope, imageSets, liveCursor, isPerformanceMode) {
27883
+ super(root, scope, liveCursor, isPerformanceMode);
27687
27884
  _defineProperty16(this, "item", null);
27688
27885
  _defineProperty16(this, "imageSets", void 0);
27886
+ _defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
27887
+ _defineProperty16(this, "shouldUseLocalPoints", true);
27888
+ _defineProperty16(this, "localPointsPick", 4);
27689
27889
  this.imageSets = imageSets;
27690
27890
  if (!this.root.has("type")) {
27691
27891
  this.root.set("type", "image");
@@ -27768,7 +27968,7 @@ var RenderableModel = class extends EventEmitter {
27768
27968
  get uuid() {
27769
27969
  return uuidv4().replace(/-/g, "");
27770
27970
  }
27771
- constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
27971
+ constructor(options) {
27772
27972
  super();
27773
27973
  _defineProperty17(this, "scope", void 0);
27774
27974
  _defineProperty17(this, "toolbarModel", void 0);
@@ -27781,6 +27981,7 @@ var RenderableModel = class extends EventEmitter {
27781
27981
  _defineProperty17(this, "shadowEmitter", void 0);
27782
27982
  _defineProperty17(this, "imageSets", void 0);
27783
27983
  _defineProperty17(this, "liveCursor", void 0);
27984
+ _defineProperty17(this, "isPerformanceMode", void 0);
27784
27985
  _defineProperty17(this, "onElementsChange", (event) => {
27785
27986
  for (const [key, value] of event.changes.keys.entries()) {
27786
27987
  if (value.action === "add") {
@@ -27799,15 +28000,16 @@ var RenderableModel = class extends EventEmitter {
27799
28000
  }
27800
28001
  }
27801
28002
  });
27802
- this.liveCursor = liveCursor;
27803
- this.imageSets = imageSets;
27804
- this.hasPermission = hasPermission;
27805
- this.shadowEmitter = shadowEmitter;
27806
- this.layerId = layerId;
27807
- this.userManager = userManager;
27808
- this.elements = elements;
27809
- this.scope = scope;
27810
- this.toolbarModel = toolbarModel;
28003
+ this.isPerformanceMode = options.isPerformanceMode;
28004
+ this.liveCursor = options.liveCursor;
28005
+ this.imageSets = options.imageSets;
28006
+ this.hasPermission = options.hasPermission;
28007
+ this.shadowEmitter = options.shadowEmitter;
28008
+ this.layerId = options.layerId;
28009
+ this.userManager = options.userManager;
28010
+ this.elements = options.elements;
28011
+ this.scope = options.scope;
28012
+ this.toolbarModel = options.toolbarModel;
27811
28013
  this.elementModels = /* @__PURE__ */ new Map();
27812
28014
  for (const key of this.elements.keys()) {
27813
28015
  const type = this.elements.get(key)?.get("type");
@@ -27838,30 +28040,38 @@ var RenderableModel = class extends EventEmitter {
27838
28040
  convertToModel(yMap) {
27839
28041
  const type = yMap.get("type");
27840
28042
  let model = null;
28043
+ const uuid = yMap.get(ElementModel.KEYS.uuid);
28044
+ if (uuid) {
28045
+ const existingModel = this.elementModels.get(uuid);
28046
+ if (existingModel) {
28047
+ existingModel.shadowEmitter = this.shadowEmitter;
28048
+ return existingModel;
28049
+ }
28050
+ }
27841
28051
  if (type === "curve") {
27842
- model = new CurveModel(yMap, this.scope, this.liveCursor);
28052
+ model = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27843
28053
  } else if (["ellipse"].indexOf(type) >= 0) {
27844
- model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
28054
+ model = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
27845
28055
  } else if (type === "selector") {
27846
- model = new SelectorModel(yMap, this.scope, this.liveCursor);
28056
+ model = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27847
28057
  } else if (type === "arrow") {
27848
- model = new LineModel(yMap, this.scope, this.liveCursor);
28058
+ model = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27849
28059
  } else if (type === "line") {
27850
- model = new StraightLineModel(yMap, this.scope, this.liveCursor);
28060
+ model = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27851
28061
  } else if (type === "point-text") {
27852
- model = new PointTextModel(yMap, this.scope, this.liveCursor);
28062
+ model = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27853
28063
  } else if (type === "triangle") {
27854
- model = new TriangleModel(yMap, this.scope, this.liveCursor);
28064
+ model = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27855
28065
  } else if (type === "rectangle") {
27856
- model = new RectangleModel(yMap, this.scope, this.liveCursor);
28066
+ model = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27857
28067
  } else if (type === "eraser") {
27858
- model = new EraserModel(yMap, this.scope, this.liveCursor);
28068
+ model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27859
28069
  } else if (type === "laser") {
27860
- model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
27861
- this.removeElementItem(uuid);
27862
- });
28070
+ model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
28071
+ this.removeElementItem(uuid2);
28072
+ }, this.isPerformanceMode);
27863
28073
  } else if (type === "image") {
27864
- model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
28074
+ model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
27865
28075
  }
27866
28076
  if (model) {
27867
28077
  model.shadowEmitter = this.shadowEmitter;
@@ -27895,7 +28105,7 @@ var RenderableModel = class extends EventEmitter {
27895
28105
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
27896
28106
  this.elements.set(uuid, yMap);
27897
28107
  }, elementsUndoOrigin);
27898
- const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
28108
+ const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
27899
28109
  model.root.set("src", src);
27900
28110
  const initMatrix = new this.scope.Matrix();
27901
28111
  const center = this.scope.project.view.center;
@@ -27912,8 +28122,10 @@ var RenderableModel = class extends EventEmitter {
27912
28122
  return null;
27913
28123
  }
27914
28124
  const yMap = new Y12.Map();
28125
+ const uuid = this.uuid;
28126
+ const curveModel = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28127
+ this.elementModels.set(uuid, curveModel);
27915
28128
  this.elements.doc?.transact(() => {
27916
- const uuid = this.uuid;
27917
28129
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
27918
28130
  yMap.set(ElementModel.KEYS.uuid, uuid);
27919
28131
  yMap.set("type", "curve");
@@ -27926,7 +28138,6 @@ var RenderableModel = class extends EventEmitter {
27926
28138
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
27927
28139
  this.elements.set(uuid, yMap);
27928
28140
  }, elementsUndoOrigin);
27929
- const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
27930
28141
  this.initElement(curveModel);
27931
28142
  return curveModel;
27932
28143
  }
@@ -27935,11 +28146,17 @@ var RenderableModel = class extends EventEmitter {
27935
28146
  return null;
27936
28147
  }
27937
28148
  const yMap = new Y12.Map();
28149
+ const uuid = this.uuid;
28150
+ const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
28151
+ this.removeElementItem(uuid2);
28152
+ }, this.isPerformanceMode);
28153
+ this.elementModels.set(uuid, model);
27938
28154
  this.elements.doc?.transact(() => {
27939
- const uuid = this.uuid;
27940
28155
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
27941
28156
  yMap.set(ElementModel.KEYS.uuid, uuid);
27942
28157
  yMap.set("type", "laser");
28158
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
28159
+ yMap.set("removed", false);
27943
28160
  yMap.set(ElementModel.KEYS.shadow, "layer");
27944
28161
  yMap.set(ElementModel.KEYS.strokeWidth, 8);
27945
28162
  yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
@@ -27947,9 +28164,7 @@ var RenderableModel = class extends EventEmitter {
27947
28164
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
27948
28165
  this.elements.set(uuid, yMap);
27949
28166
  }, elementsUndoOrigin);
27950
- const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
27951
- this.removeElementItem(uuid);
27952
- });
28167
+ this.initElement(model);
27953
28168
  return model;
27954
28169
  }
27955
28170
  createEraser() {
@@ -27957,11 +28172,14 @@ var RenderableModel = class extends EventEmitter {
27957
28172
  return null;
27958
28173
  }
27959
28174
  const yMap = new Y12.Map();
28175
+ const uuid = this.uuid;
28176
+ const model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28177
+ this.elementModels.set(uuid, model);
27960
28178
  this.elements.doc?.transact(() => {
27961
- const uuid = this.uuid;
27962
28179
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
27963
28180
  yMap.set(ElementModel.KEYS.uuid, uuid);
27964
28181
  yMap.set("type", "eraser");
28182
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
27965
28183
  yMap.set(ElementModel.KEYS.shadow, "layer");
27966
28184
  yMap.set(ElementModel.KEYS.strokeWidth, 4);
27967
28185
  yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
@@ -27969,7 +28187,6 @@ var RenderableModel = class extends EventEmitter {
27969
28187
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
27970
28188
  this.elements.set(uuid, yMap);
27971
28189
  }, elementsUndoOrigin);
27972
- const model = new EraserModel(yMap, this.scope, this.liveCursor);
27973
28190
  return model;
27974
28191
  }
27975
28192
  createTriangle(shadow) {
@@ -27977,45 +28194,52 @@ var RenderableModel = class extends EventEmitter {
27977
28194
  return null;
27978
28195
  }
27979
28196
  const yMap = new Y12.Map();
28197
+ const uuid = this.uuid;
28198
+ const triangleModel = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28199
+ this.elementModels.set(uuid, triangleModel);
27980
28200
  this.elements.doc?.transact(() => {
27981
- const uuid = this.uuid;
27982
28201
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
27983
28202
  yMap.set(ElementModel.KEYS.uuid, uuid);
27984
28203
  yMap.set("type", "triangle");
27985
28204
  if (shadow) {
27986
28205
  yMap.set(ElementModel.KEYS.shadow, "layer");
27987
28206
  }
28207
+ yMap.set("points", new Y12.Array());
27988
28208
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
27989
28209
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
27990
28210
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
27991
28211
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
27992
28212
  this.elements.set(uuid, yMap);
27993
28213
  }, elementsUndoOrigin);
27994
- const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
27995
- this.initElement(triangle);
27996
- triangle.dashArray = this.toolbarModel.dashArray;
27997
- return triangle;
28214
+ this.initElement(triangleModel);
28215
+ triangleModel.dashArray = this.toolbarModel.dashArray;
28216
+ return triangleModel;
27998
28217
  }
27999
28218
  createRectangle(shadow) {
28000
28219
  if (!this.confirmPermission()) {
28001
28220
  return null;
28002
28221
  }
28003
28222
  const yMap = new Y12.Map();
28223
+ const uuid = this.uuid;
28224
+ const rect = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28225
+ this.elementModels.set(uuid, rect);
28004
28226
  this.elements.doc?.transact(() => {
28005
- const uuid = this.uuid;
28006
28227
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28007
28228
  yMap.set(ElementModel.KEYS.uuid, uuid);
28008
28229
  yMap.set("type", "rectangle");
28009
28230
  if (shadow) {
28010
28231
  yMap.set(ElementModel.KEYS.shadow, "layer");
28011
28232
  }
28233
+ const initPoints = new Y12.Array();
28234
+ initPoints.push([0, 0, 0, 0]);
28235
+ yMap.set("points", initPoints);
28236
+ yMap.set("radius", 0);
28012
28237
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28013
28238
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28014
28239
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28015
28240
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28016
28241
  this.elements.set(uuid, yMap);
28017
28242
  }, elementsUndoOrigin);
28018
- const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
28019
28243
  this.initElement(rect);
28020
28244
  rect.dashArray = this.toolbarModel.dashArray;
28021
28245
  return rect;
@@ -28025,21 +28249,23 @@ var RenderableModel = class extends EventEmitter {
28025
28249
  return null;
28026
28250
  }
28027
28251
  const yMap = new Y12.Map();
28252
+ const uuid = this.uuid;
28253
+ const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
28254
+ this.elementModels.set(uuid, segmentsModel);
28028
28255
  this.elements.doc?.transact(() => {
28029
- const uuid = this.uuid;
28030
28256
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28031
28257
  yMap.set(ElementModel.KEYS.uuid, uuid);
28032
28258
  yMap.set("type", type);
28033
28259
  if (shadow) {
28034
28260
  yMap.set(ElementModel.KEYS.shadow, "layer");
28035
28261
  }
28262
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
28036
28263
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28037
28264
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28038
28265
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28039
28266
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28040
28267
  this.elements.set(uuid, yMap);
28041
28268
  }, elementsUndoOrigin);
28042
- const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
28043
28269
  this.initElement(segmentsModel);
28044
28270
  segmentsModel.dashArray = this.toolbarModel.dashArray;
28045
28271
  return segmentsModel;
@@ -28050,16 +28276,20 @@ var RenderableModel = class extends EventEmitter {
28050
28276
  return null;
28051
28277
  }
28052
28278
  const yMap = new Y12.Map();
28279
+ const uuid = this.uuid;
28280
+ const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28281
+ this.elementModels.set(uuid, selectorModel);
28053
28282
  this.elements.doc?.transact(() => {
28054
- const uuid = this.uuid;
28055
28283
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28056
28284
  yMap.set(ElementModel.KEYS.uuid, uuid);
28057
28285
  yMap.set("type", "selector");
28286
+ const initPoints = new Y12.Array();
28287
+ initPoints.push([0, 0, 0, 0]);
28288
+ yMap.set(ElementModel.KEYS.points, initPoints);
28058
28289
  yMap.set(ElementModel.KEYS.shadow, "layer");
28059
28290
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28060
28291
  this.elements.set(uuid, yMap);
28061
28292
  }, elementsUndoOrigin);
28062
- const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
28063
28293
  selectorModel.shadow = "layer";
28064
28294
  return selectorModel;
28065
28295
  }
@@ -28068,21 +28298,23 @@ var RenderableModel = class extends EventEmitter {
28068
28298
  return null;
28069
28299
  }
28070
28300
  const yMap = new Y12.Map();
28301
+ const uuid = this.uuid;
28302
+ const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28303
+ this.elementModels.set(uuid, straightLineModel);
28071
28304
  this.elements.doc?.transact(() => {
28072
- const uuid = this.uuid;
28073
28305
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28074
28306
  yMap.set(ElementModel.KEYS.uuid, uuid);
28075
28307
  yMap.set("type", "line");
28076
28308
  if (shadow) {
28077
28309
  yMap.set(ElementModel.KEYS.shadow, "layer");
28078
28310
  }
28311
+ yMap.set("points", new Y12.Array());
28079
28312
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28080
28313
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28081
28314
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28082
28315
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28083
28316
  this.elements.set(uuid, yMap);
28084
28317
  }, elementsUndoOrigin);
28085
- const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
28086
28318
  this.initElement(straightLineModel);
28087
28319
  straightLineModel.dashArray = this.toolbarModel.dashArray;
28088
28320
  return straightLineModel;
@@ -28092,21 +28324,25 @@ var RenderableModel = class extends EventEmitter {
28092
28324
  return null;
28093
28325
  }
28094
28326
  const yMap = new Y12.Map();
28327
+ const uuid = this.uuid;
28328
+ const lineModel = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28329
+ this.elementModels.set(uuid, lineModel);
28095
28330
  this.elements.doc?.transact(() => {
28096
- const uuid = this.uuid;
28097
28331
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28098
28332
  yMap.set(ElementModel.KEYS.uuid, uuid);
28099
28333
  yMap.set("type", "arrow");
28100
28334
  if (shadow) {
28101
28335
  yMap.set(ElementModel.KEYS.shadow, "layer");
28102
28336
  }
28337
+ yMap.set("headArrow", "none");
28338
+ yMap.set("tailArrow", "normal");
28339
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
28103
28340
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28104
28341
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28105
28342
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28106
28343
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28107
28344
  this.elements.set(uuid, yMap);
28108
28345
  }, elementsUndoOrigin);
28109
- const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
28110
28346
  this.initElement(lineModel);
28111
28347
  lineModel.dashArray = this.toolbarModel.dashArray;
28112
28348
  return lineModel;
@@ -28116,21 +28352,23 @@ var RenderableModel = class extends EventEmitter {
28116
28352
  return null;
28117
28353
  }
28118
28354
  const yMap = new Y12.Map();
28355
+ const uuid = this.uuid;
28356
+ const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28357
+ this.elementModels.set(uuid, pointTextModel);
28119
28358
  this.elements.doc?.transact(() => {
28120
- const uuid = this.uuid;
28121
28359
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28122
28360
  yMap.set(ElementModel.KEYS.uuid, uuid);
28123
28361
  yMap.set("type", "point-text");
28124
28362
  if (shadow) {
28125
28363
  yMap.set(ElementModel.KEYS.shadow, "layer");
28126
28364
  }
28365
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
28127
28366
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28128
28367
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28129
28368
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28130
28369
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28131
28370
  this.elements.set(uuid, yMap);
28132
28371
  }, elementsUndoOrigin);
28133
- const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
28134
28372
  pointTextModel.setPoints([x, y]);
28135
28373
  pointTextModel.fontSize = this.toolbarModel.fontSize;
28136
28374
  pointTextModel.fontFamily = this.toolbarModel.fontFamily;
@@ -28456,7 +28694,7 @@ var CurveTool = class extends WhiteboardTool {
28456
28694
  _defineProperty19(this, "recognizer", new Recognizer());
28457
28695
  _defineProperty19(this, "pointCount", 0);
28458
28696
  _defineProperty19(this, "showLiveCursor", true);
28459
- this.tool.minDistance = 5;
28697
+ this.tool.minDistance = 20;
28460
28698
  }
28461
28699
  onMouseDown(_event) {
28462
28700
  this.pointCount = 0;
@@ -30419,6 +30657,8 @@ var Whiteboard = class extends EventEmitter8 {
30419
30657
  _defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
30420
30658
  _defineProperty31(this, "getElementAttribute", void 0);
30421
30659
  _defineProperty31(this, "setElementAttribute", void 0);
30660
+ _defineProperty31(this, "setPerformanceMode", void 0);
30661
+ _defineProperty31(this, "isPerformanceMode", void 0);
30422
30662
  _defineProperty31(this, "removeElement", void 0);
30423
30663
  _defineProperty31(this, "getCurrentTool", void 0);
30424
30664
  _defineProperty31(this, "setCurrentTool", void 0);
@@ -30717,9 +30957,24 @@ var LaserPointerTool = class extends WhiteboardTool {
30717
30957
  if (this.pointCount > 1024) {
30718
30958
  return;
30719
30959
  }
30960
+ const MIN_DISTANCE = 4;
30720
30961
  if (this.elementModel) {
30721
- this.pointCount += 1;
30722
- this.elementModel.appendPoints([event.point.x, event.point.y]);
30962
+ const len = this.elementModel.points.length;
30963
+ let last = {
30964
+ x: 0,
30965
+ y: 0
30966
+ };
30967
+ if (len >= 2) {
30968
+ last = {
30969
+ x: this.elementModel.points[len - 2],
30970
+ y: this.elementModel.points[len - 1]
30971
+ };
30972
+ }
30973
+ const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
30974
+ if (dist >= MIN_DISTANCE) {
30975
+ this.pointCount += 1;
30976
+ this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
30977
+ }
30723
30978
  }
30724
30979
  }
30725
30980
  onMouseUp(_event) {
@@ -31823,6 +32078,9 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
31823
32078
  _defineProperty43(this, "hasPermission", (flag) => {
31824
32079
  return this.permissions.hasPermission(flag, this.userId);
31825
32080
  });
32081
+ _defineProperty43(this, "isPerformanceMode", () => {
32082
+ return this.option.performance ?? false;
32083
+ });
31826
32084
  _defineProperty43(this, "handleStackItemAdded", () => {
31827
32085
  this.selectElementsModel.clearSelectElementForSelf();
31828
32086
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
@@ -31837,7 +32095,18 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
31837
32095
  const id = ids[i];
31838
32096
  if (!this.layers.has(id)) {
31839
32097
  const elementsMap = this.getMap(`layer/${id}/elements`);
31840
- const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
32098
+ const renderableModel = new RenderableModel({
32099
+ layerId: id,
32100
+ shadowEmitter: this.shadowEmitter,
32101
+ elements: elementsMap,
32102
+ scope: this.paperScope,
32103
+ toolbarModel: this.toolbarModel,
32104
+ userManager: this.userManager,
32105
+ imageSets: this.imageSets,
32106
+ liveCursor: this.liveCursor,
32107
+ hasPermission: this.hasPermission,
32108
+ isPerformanceMode: this.isPerformanceMode
32109
+ });
31841
32110
  this.layers.set(id, renderableModel);
31842
32111
  }
31843
32112
  if (!this.undoManagers.has(id)) {
@@ -32104,6 +32373,12 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32104
32373
  this.camera.resetViewMatrixToFlow(flowId);
32105
32374
  }
32106
32375
  };
32376
+ this.emitter.setPerformanceMode = (enabled) => {
32377
+ this.option.performance = enabled;
32378
+ };
32379
+ this.emitter.isPerformanceMode = () => {
32380
+ return this.isPerformanceMode();
32381
+ };
32107
32382
  this.emitter.setViewModeToMain = (userId) => {
32108
32383
  if (that.disableViewModelUpdate) {
32109
32384
  console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
@@ -32158,7 +32433,18 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32158
32433
  const source = this.getMap(`layer/${sourceId}/elements`);
32159
32434
  const target = this.getMap(`layer/${targetId}/elements`);
32160
32435
  if (!this.layers.has(targetId)) {
32161
- this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
32436
+ this.layers.set(targetId, new RenderableModel({
32437
+ layerId: targetId,
32438
+ shadowEmitter: this.shadowEmitter,
32439
+ elements: target,
32440
+ scope: this.paperScope,
32441
+ toolbarModel: this.toolbarModel,
32442
+ userManager: this.userManager,
32443
+ imageSets: this.imageSets,
32444
+ liveCursor: this.liveCursor,
32445
+ hasPermission: this.hasPermission,
32446
+ isPerformanceMode: this.isPerformanceMode
32447
+ }));
32162
32448
  }
32163
32449
  if (!this.undoManagers.has(targetId)) {
32164
32450
  const undoManager = new Y15.UndoManager(target, {
@@ -32393,6 +32679,11 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32393
32679
  this.editors.forEach((editor) => {
32394
32680
  editor.updateBounds();
32395
32681
  });
32682
+ const area = this.paperScope.project.view.size.width * this.paperScope.project.view.size.height;
32683
+ const minDistance = Math.ceil(area / 4e5);
32684
+ Object.keys(this.tools).forEach((key) => {
32685
+ this.tools[key].tool.minDistance = minDistance;
32686
+ });
32396
32687
  });
32397
32688
  this.camera.on("userPageChange", (userId, pageId) => {
32398
32689
  this.emitter.emit("activePageChange", userId, pageId);