@netless/forge-whiteboard 1.1.4 → 1.2.0-alpha.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 (45) hide show
  1. package/changelog.md +1 -13
  2. package/dist/LiveCursor.d.ts +1 -2
  3. package/dist/LiveCursor.d.ts.map +1 -1
  4. package/dist/Whiteboard.d.ts +0 -10
  5. package/dist/Whiteboard.d.ts.map +1 -1
  6. package/dist/WhiteboardApplication.d.ts +0 -6
  7. package/dist/WhiteboardApplication.d.ts.map +1 -1
  8. package/dist/edit/Editor.d.ts.map +1 -1
  9. package/dist/model/RenderableModel.d.ts +1 -13
  10. package/dist/model/RenderableModel.d.ts.map +1 -1
  11. package/dist/model/renderable/CurveModel.d.ts +3 -4
  12. package/dist/model/renderable/CurveModel.d.ts.map +1 -1
  13. package/dist/model/renderable/ElementModel.d.ts +1 -20
  14. package/dist/model/renderable/ElementModel.d.ts.map +1 -1
  15. package/dist/model/renderable/EraserModel.d.ts +1 -5
  16. package/dist/model/renderable/EraserModel.d.ts.map +1 -1
  17. package/dist/model/renderable/ImageModel.d.ts +1 -4
  18. package/dist/model/renderable/ImageModel.d.ts.map +1 -1
  19. package/dist/model/renderable/LaserPointerModel.d.ts +2 -8
  20. package/dist/model/renderable/LaserPointerModel.d.ts.map +1 -1
  21. package/dist/model/renderable/LineModel.d.ts +1 -5
  22. package/dist/model/renderable/LineModel.d.ts.map +1 -1
  23. package/dist/model/renderable/PointTextModel.d.ts +1 -6
  24. package/dist/model/renderable/PointTextModel.d.ts.map +1 -1
  25. package/dist/model/renderable/RectangleModel.d.ts +1 -5
  26. package/dist/model/renderable/RectangleModel.d.ts.map +1 -1
  27. package/dist/model/renderable/SegmentsModel.d.ts +1 -5
  28. package/dist/model/renderable/SegmentsModel.d.ts.map +1 -1
  29. package/dist/model/renderable/SelectorModel.d.ts +1 -5
  30. package/dist/model/renderable/SelectorModel.d.ts.map +1 -1
  31. package/dist/model/renderable/StraightLineModel.d.ts +1 -5
  32. package/dist/model/renderable/StraightLineModel.d.ts.map +1 -1
  33. package/dist/model/renderable/TriangleModel.d.ts +1 -5
  34. package/dist/model/renderable/TriangleModel.d.ts.map +1 -1
  35. package/dist/tool/CurveTool.d.ts +0 -3
  36. package/dist/tool/CurveTool.d.ts.map +1 -1
  37. package/dist/tool/LaserPointerTool.d.ts.map +1 -1
  38. package/dist/tool/WhiteboardTool.d.ts +0 -4
  39. package/dist/tool/WhiteboardTool.d.ts.map +1 -1
  40. package/dist/utils/paperjs.d.ts.map +1 -1
  41. package/dist/whiteboard.esm.js +271 -719
  42. package/dist/whiteboard.esm.js.map +3 -3
  43. package/dist/whiteboard.js +307 -755
  44. package/dist/whiteboard.js.map +3 -3
  45. 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 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;
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;
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 = Array14(length), skip = object == null;
21266
+ var index = -1, length = paths.length, result2 = Array13(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 = Array14(othLength), maxLength = Infinity, result2 = [];
21512
+ var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array13(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) ? Array14(collection.length) : [];
21693
+ var index = -1, result2 = isArrayLike(collection) ? Array13(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 = Array14(length);
21868
+ var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array13(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 = Array14(length);
21950
+ var result2 = Array13(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 = Array14(length);
22110
+ var index = -1, result2 = Array13(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 = Array14(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 = Array13(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 = Array14(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 = Array13(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 = Array14(length));
22239
+ array || (array = Array13(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 = Array14(length), index = length, placeholder = getHolder(wrapper);
22372
+ var length = arguments.length, args = Array13(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 = Array14(length), index = length;
22452
+ var length = arguments.length, args = Array13(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 = Array14(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
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;
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 = Array14(length);
23164
+ var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array13(length);
23165
23165
  while (++index < length) {
23166
23166
  array[index] = args[start + index];
23167
23167
  }
23168
23168
  index = -1;
23169
- var otherArgs = Array14(start + 1);
23169
+ var otherArgs = Array13(start + 1);
23170
23170
  while (++index < start) {
23171
23171
  otherArgs[index] = args[index];
23172
23172
  }
@@ -23278,7 +23278,7 @@ var require_lodash = __commonJS({
23278
23278
  result2.__values__ = wrapper.__values__;
23279
23279
  return result2;
23280
23280
  }
23281
- function chunk7(array, size2, guard) {
23281
+ function chunk8(array, size2, guard) {
23282
23282
  if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
23283
23283
  size2 = 1;
23284
23284
  } else {
@@ -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 = Array14(nativeCeil(length / size2));
23291
+ var index = 0, resIndex = 0, result2 = Array13(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 = Array14(length - 1), array = arguments[0], index = length;
23312
+ var args = Array13(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) ? Array14(collection.length) : [];
23814
+ var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array13(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 = Array14.isArray;
24197
+ var isArray = Array13.isArray;
24198
24198
  var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
24199
24199
  function isArrayLike(value) {
24200
24200
  return value != null && isLength(value.length) && !isFunction(value);
@@ -25150,7 +25150,7 @@ var require_lodash = __commonJS({
25150
25150
  lodash.bindKey = bindKey;
25151
25151
  lodash.castArray = castArray;
25152
25152
  lodash.chain = chain;
25153
- lodash.chunk = chunk7;
25153
+ lodash.chunk = chunk8;
25154
25154
  lodash.compact = compact;
25155
25155
  lodash.concat = concat;
25156
25156
  lodash.cond = cond;
@@ -25637,7 +25637,7 @@ import * as Y15 from "yjs";
25637
25637
  import * as Y12 from "yjs";
25638
25638
  import EventEmitter from "eventemitter3";
25639
25639
  import { v4 as uuidv4 } from "uuid";
25640
- import { log, removeObserver as removeObserver3 } from "@netless/forge-room";
25640
+ import { log, removeObserver as removeObserver2 } from "@netless/forge-room";
25641
25641
 
25642
25642
  // src/model/renderable/CurveModel.ts
25643
25643
  import * as Y2 from "yjs";
@@ -25790,6 +25790,9 @@ function ae(e, t = {}) {
25790
25790
  return ce(me(e, t), t);
25791
25791
  }
25792
25792
 
25793
+ // src/model/renderable/CurveModel.ts
25794
+ var import_lodash = __toESM(require_lodash(), 1);
25795
+
25793
25796
  // src/model/renderable/ElementModel.ts
25794
25797
  import * as Y from "yjs";
25795
25798
  import { removeDeepObserver } from "@netless/forge-room";
@@ -25877,23 +25880,12 @@ var ElementModel = class _ElementModel {
25877
25880
  set shadow(value) {
25878
25881
  this.root.set(_ElementModel.KEYS.shadow, value);
25879
25882
  }
25880
- get isPerformanceEnvironment() {
25881
- return this.isPerformanceMode() && this.shouldUseLocalPoints;
25882
- }
25883
- constructor(root, scope, liveCursor, isPerformanceMode) {
25883
+ constructor(root, scope, liveCursor) {
25884
25884
  _defineProperty(this, "shadowEmitter", null);
25885
25885
  _defineProperty(this, "root", void 0);
25886
25886
  _defineProperty(this, "scope", void 0);
25887
25887
  _defineProperty(this, "item", void 0);
25888
- _defineProperty(this, "clearLocalPointsWhenYPointsChange", void 0);
25889
- _defineProperty(this, "shouldUseLocalPoints", void 0);
25890
- _defineProperty(this, "localPointsPick", void 0);
25891
25888
  _defineProperty(this, "liveCursor", void 0);
25892
- _defineProperty(this, "appendPointsTimer", null);
25893
- _defineProperty(this, "setPointsTimer", null);
25894
- _defineProperty(this, "pointsUpdateTimer", null);
25895
- _defineProperty(this, "isPerformanceMode", void 0);
25896
- _defineProperty(this, "localPoints", []);
25897
25889
  _defineProperty(this, "handlePropChange", (events) => {
25898
25890
  if (!this.item) {
25899
25891
  return;
@@ -25932,80 +25924,23 @@ var ElementModel = class _ElementModel {
25932
25924
  }
25933
25925
  }
25934
25926
  } else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
25935
- if (this.isPerformanceEnvironment) {
25936
- this.handlePointsChangePerformance();
25937
- } else {
25938
- this.handlePointsChangeDirect();
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));
25939
25932
  }
25940
25933
  } else {
25941
25934
  }
25942
25935
  }
25943
25936
  });
25944
- _defineProperty(this, "onPointsArrayChange", (points) => {
25945
- if (this.localPoints.length >= points.length) {
25946
- return;
25947
- }
25948
- const pointsChunk = points.slice(this.localPoints.length, this.localPoints.length + this.localPointsPick);
25949
- this.localPoints = this.localPoints.concat(pointsChunk);
25950
- this.onVectorUpdate();
25951
- this.pointsUpdateTimer = window.requestAnimationFrame(() => {
25952
- this.onPointsArrayChange(points);
25953
- });
25954
- });
25955
- this.isPerformanceMode = isPerformanceMode;
25956
25937
  this.scope = scope;
25957
25938
  this.liveCursor = liveCursor;
25958
25939
  this.root = root;
25959
- if (this.root.doc) {
25960
- if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
25961
- this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
25962
- }
25963
- } else {
25940
+ if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
25964
25941
  this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
25965
25942
  }
25966
- }
25967
- bindObserver() {
25968
- const beforeL = this.root._eH?.l?.length ?? -1;
25969
- const beforeDL = this.root._dEH?.l?.length ?? -1;
25970
- removeDeepObserver(this.root, this.handlePropChange);
25971
- this.subBindObserver();
25972
- const afterRemoveL = this.root._eH?.l?.length ?? -1;
25973
- const afterRemoveDL = this.root._dEH?.l?.length ?? -1;
25974
25943
  this.root.observeDeep(this.handlePropChange);
25975
- const afterAddL = this.root._eH?.l?.length ?? -1;
25976
- const afterAddDL = this.root._dEH?.l?.length ?? -1;
25977
- console.log(`[][][] bindObserver uuid=${this.uuid} doc=${!!this.root.doc} _eH: ${beforeL}->${afterRemoveL}->${afterAddL} _dEH: ${beforeDL}->${afterRemoveDL}->${afterAddDL}`);
25978
- }
25979
- subBindObserver() {
25980
- }
25981
- handlePointsChangeDirect() {
25982
- this.onVectorUpdate();
25983
- const liveCursorPoint = this.liveCursorPoint();
25984
- const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25985
- if (liveCursorPoint && ownerId) {
25986
- this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
25987
- }
25988
- }
25989
- handlePointsChangePerformance() {
25990
- const liveCursorPoint = this.liveCursorPoint();
25991
- const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
25992
- if (liveCursorPoint && ownerId) {
25993
- this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
25994
- }
25995
- if (this.liveCursor.userManager.selfId !== ownerId || this.localPoints.length === 0) {
25996
- if (this.pointsUpdateTimer) {
25997
- window.cancelAnimationFrame(this.pointsUpdateTimer);
25998
- }
25999
- if (this.shadow == "") {
26000
- this.localPoints = this.points;
26001
- this.onVectorUpdate();
26002
- } else {
26003
- if (this.clearLocalPointsWhenYPointsChange) {
26004
- this.localPoints = [];
26005
- }
26006
- this.onPointsArrayChange(this.points);
26007
- }
26008
- }
26009
25944
  }
26010
25945
  createPaperElement() {
26011
25946
  this.createPaperItem();
@@ -26018,48 +25953,14 @@ var ElementModel = class _ElementModel {
26018
25953
  }
26019
25954
  }
26020
25955
  appendPoints(points) {
26021
- if (this.isPerformanceEnvironment) {
26022
- this.appendPointsPerformance(points);
26023
- } else {
26024
- this.appendPointsDirect(points);
26025
- }
26026
- }
26027
- appendPointsDirect(points) {
26028
25956
  this.root.get(_ElementModel.KEYS.points).push(points);
26029
25957
  }
26030
- appendPointsPerformance(points) {
26031
- this.localPoints = this.localPoints.concat(points);
26032
- this.onVectorUpdate();
26033
- if (this.appendPointsTimer) {
26034
- window.clearTimeout(this.appendPointsTimer);
26035
- }
26036
- if (this.localPoints.length % 80 === 0) {
26037
- const yArray = this.root.get(_ElementModel.KEYS.points);
26038
- yArray?.push(this.localPoints.slice(yArray.length));
26039
- }
26040
- this.appendPointsTimer = window.setTimeout(() => {
26041
- this.appendPointsTimer = null;
26042
- if (this.localPoints.length > 0) {
26043
- const yArray = this.root.get(_ElementModel.KEYS.points);
26044
- yArray?.push(this.localPoints.slice(yArray.length));
26045
- }
26046
- }, 100);
26047
- }
26048
25958
  setPoints(points) {
26049
- if (this.isPerformanceEnvironment) {
26050
- this.setPointsPerformance(points);
26051
- } else {
26052
- this.setPointsDirect(points);
26053
- }
26054
- }
26055
- setPointsDirect(points) {
26056
25959
  if (this.root.doc) {
26057
25960
  this.root.doc.transact(() => {
26058
25961
  const yArray = this.root.get(_ElementModel.KEYS.points);
26059
- if (yArray) {
26060
- yArray.delete(0, yArray.length);
26061
- yArray.push(points);
26062
- }
25962
+ yArray.delete(0, yArray.length);
25963
+ yArray.push(points);
26063
25964
  });
26064
25965
  } else {
26065
25966
  const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
@@ -26068,29 +25969,6 @@ var ElementModel = class _ElementModel {
26068
25969
  this.root.set(_ElementModel.KEYS.points, yArray);
26069
25970
  }
26070
25971
  }
26071
- setPointsPerformance(points) {
26072
- this.localPoints = points;
26073
- this.onVectorUpdate();
26074
- if (this.setPointsTimer) {
26075
- window.clearTimeout(this.setPointsTimer);
26076
- }
26077
- this.setPointsTimer = window.setTimeout(() => {
26078
- if (this.root.doc) {
26079
- this.root.doc.transact(() => {
26080
- const yArray = this.root.get(_ElementModel.KEYS.points);
26081
- if (yArray) {
26082
- yArray.delete(0, yArray.length);
26083
- yArray.push(points);
26084
- }
26085
- });
26086
- } else {
26087
- const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
26088
- yArray.delete(0, yArray.length);
26089
- yArray.push(points);
26090
- this.root.set(_ElementModel.KEYS.points, yArray);
26091
- }
26092
- }, 100);
26093
- }
26094
25972
  appendPointsMatrix(matrix) {
26095
25973
  const current = new this.scope.Matrix(this.pointsMatrix);
26096
25974
  const next = matrix.appended(current);
@@ -26117,9 +25995,6 @@ var ElementModel = class _ElementModel {
26117
25995
  }
26118
25996
  dispose() {
26119
25997
  this.subDispose();
26120
- }
26121
- disposeObserver() {
26122
- console.log(`[][][] disposeObserver uuid=${this.uuid}`);
26123
25998
  removeDeepObserver(this.root, this.handlePropChange);
26124
25999
  }
26125
26000
  };
@@ -26192,53 +26067,47 @@ function _toPrimitive3(t, r) {
26192
26067
  return ("string" === r ? String : Number)(t);
26193
26068
  }
26194
26069
  var CurveModel = class extends ElementModel {
26195
- constructor(root, scope, liveCursor, isPerformanceMode) {
26196
- super(root, scope, liveCursor, isPerformanceMode);
26070
+ constructor(root, scope, liveCursor) {
26071
+ super(root, scope, liveCursor);
26197
26072
  _defineProperty3(this, "item", null);
26073
+ _defineProperty3(this, "debugPath", void 0);
26198
26074
  _defineProperty3(this, "debug", false);
26199
- _defineProperty3(this, "clearLocalPointsWhenYPointsChange", false);
26200
- _defineProperty3(this, "shouldUseLocalPoints", true);
26201
- _defineProperty3(this, "localPointsPick", 6);
26202
- if (!this.root.doc || !this.root.has("type")) {
26075
+ if (!this.root.has("type")) {
26203
26076
  this.root.set("type", "curve");
26204
26077
  }
26205
- if (!this.root.doc || !this.root.has("points")) {
26078
+ if (!this.root.has("points")) {
26206
26079
  this.root.set("points", new Y2.Array());
26207
26080
  }
26081
+ this.debugPath = new scope.Path();
26208
26082
  }
26209
26083
  average(a2, b2) {
26210
26084
  return (a2 + b2) / 2;
26211
26085
  }
26212
26086
  parsePoints(points) {
26213
- const hasRealPressure = points.some((p) => p.length >= 3 && p[2] > 0);
26214
- const viewScale = this.scope.project.view.matrix.scaling.x || 1;
26215
- const taper = this.strokeWidth * 5 / viewScale;
26216
- const streamline = Math.min(0.7, 0.7 * viewScale);
26217
26087
  return ae(points, {
26218
26088
  size: this.strokeWidth,
26219
- smoothing: 0.7,
26220
- thinning: 0.5,
26221
- streamline,
26222
- simulatePressure: !hasRealPressure,
26089
+ smoothing: 0.5,
26090
+ thinning: -0.5,
26091
+ streamline: 0.5,
26092
+ simulatePressure: true,
26223
26093
  start: {
26224
- taper,
26094
+ taper: this.strokeWidth * 10,
26225
26095
  cap: true
26226
26096
  },
26227
26097
  end: {
26228
- taper,
26098
+ taper: this.strokeWidth * 20,
26229
26099
  cap: true
26230
26100
  }
26231
26101
  });
26232
26102
  }
26233
26103
  matrixedPoints() {
26234
- const points = this.localPoints.length === 0 ? this.points : this.localPoints;
26104
+ const points = this.points;
26235
26105
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26236
26106
  const output = [];
26237
- for (let i = 0, len = points.length; i < len; i += 3) {
26107
+ for (let i = 0, len = points.length; i < len; i += 2) {
26238
26108
  const p = new this.scope.Point(points[i], points[i + 1]);
26239
26109
  const tp = p.transform(matrix);
26240
- const pressure = points[i + 2] ?? 0;
26241
- output.push([tp.x, tp.y, pressure]);
26110
+ output.push([tp.x, tp.y]);
26242
26111
  }
26243
26112
  return output;
26244
26113
  }
@@ -26267,30 +26136,34 @@ var CurveModel = class extends ElementModel {
26267
26136
  }
26268
26137
  return path;
26269
26138
  }
26139
+ updateDebugPath() {
26140
+ this.debugPath = new this.scope.Path();
26141
+ const points = (0, import_lodash.chunk)(this.points, 2);
26142
+ for (let i = 0, len = points.length; i < len; i++) {
26143
+ const point = new this.scope.Point(points[i][0], points[i][1]);
26144
+ if (i === 0) {
26145
+ this.debugPath.moveTo(point);
26146
+ } else {
26147
+ this.debugPath.lineTo(point);
26148
+ }
26149
+ this.debugPath.strokeWidth = 1;
26150
+ this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
26151
+ }
26152
+ }
26270
26153
  onVectorUpdate() {
26271
26154
  if (!this.item) {
26272
26155
  return;
26273
26156
  }
26274
- const matrixedPts = this.matrixedPoints();
26275
26157
  if (this.debug) {
26276
- const path = new this.scope.Path();
26277
- for (let i = 0; i < matrixedPts.length; i++) {
26278
- const p = new this.scope.Point(matrixedPts[i][0], matrixedPts[i][1]);
26279
- if (i === 0) {
26280
- path.moveTo(p);
26281
- } else {
26282
- path.lineTo(p);
26283
- }
26284
- }
26285
- this.item.removeSegments();
26286
- this.item.addSegments(path.segments);
26287
- this.item.fillColor = null;
26288
- this.item.strokeWidth = this.strokeWidth;
26289
- } else {
26290
- const points = this.parsePoints(matrixedPts);
26291
- const path = this.createPath(points);
26292
- this.item.removeSegments();
26293
- this.item.addSegments(path.segments);
26158
+ this.debugPath.remove();
26159
+ this.updateDebugPath();
26160
+ }
26161
+ const points = this.parsePoints(this.matrixedPoints());
26162
+ const path = this.createPath(points);
26163
+ this.item.removeSegments();
26164
+ this.item.addSegments(path.segments);
26165
+ if (this.debug) {
26166
+ this.item.addChild(this.debugPath);
26294
26167
  }
26295
26168
  }
26296
26169
  createPaperItem() {
@@ -26313,11 +26186,11 @@ var CurveModel = class extends ElementModel {
26313
26186
  }
26314
26187
  liveCursorPoint() {
26315
26188
  const yArray = this.root.get(ElementModel.KEYS.points);
26316
- if (yArray.length < 3) {
26189
+ if (yArray.length < 2) {
26317
26190
  return null;
26318
26191
  }
26319
26192
  const len = yArray.length;
26320
- const point = new this.scope.Point(yArray.get(len - 3), yArray.get(len - 2));
26193
+ const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
26321
26194
  return point.transform(new this.scope.Matrix(this.pointsMatrix));
26322
26195
  }
26323
26196
  onStyleKeyUpdate(key) {
@@ -26355,24 +26228,15 @@ function _toPrimitive4(t, r) {
26355
26228
  return ("string" === r ? String : Number)(t);
26356
26229
  }
26357
26230
  var SelectorModel = class extends ElementModel {
26358
- get drawPoints() {
26359
- if (this.localPoints.length >= 4) {
26360
- return this.localPoints;
26361
- }
26362
- return this.points;
26363
- }
26364
- constructor(root, scope, liveCursor, isPerformanceMode) {
26365
- super(root, scope, liveCursor, isPerformanceMode);
26231
+ constructor(root, scope, liveCursor) {
26232
+ super(root, scope, liveCursor);
26366
26233
  _defineProperty4(this, "item", null);
26367
- _defineProperty4(this, "clearLocalPointsWhenYPointsChange", true);
26368
- _defineProperty4(this, "shouldUseLocalPoints", true);
26369
- _defineProperty4(this, "localPointsPick", 4);
26370
- if (this.root.doc && !this.root.has("type")) {
26234
+ if (!this.root.has("type")) {
26371
26235
  this.root.set("type", "selector");
26372
26236
  }
26373
- if (this.root.doc && !this.root.has("points")) {
26237
+ if (!this.root.has("points")) {
26374
26238
  const initPoints = new Y3.Array();
26375
- initPoints.push([0, 0, 0, 0]);
26239
+ initPoints.push([0, 0, 0, 0, 0]);
26376
26240
  this.root.set("points", initPoints);
26377
26241
  }
26378
26242
  }
@@ -26383,8 +26247,8 @@ var SelectorModel = class extends ElementModel {
26383
26247
  }
26384
26248
  createPaperRect() {
26385
26249
  const scope = this.scope;
26386
- const bounds = new scope.Rectangle(new scope.Point(this.drawPoints[0], this.drawPoints[1]), new scope.Size(this.drawPoints[2], this.drawPoints[3]));
26387
- return new scope.Path.Rectangle(bounds);
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]));
26388
26252
  }
26389
26253
  onVectorUpdate() {
26390
26254
  if (!this.item) {
@@ -26418,8 +26282,7 @@ var SelectorModel = class extends ElementModel {
26418
26282
  import * as Y4 from "yjs";
26419
26283
 
26420
26284
  // src/utils/paperjs.ts
26421
- var import_lodash = __toESM(require_lodash(), 1);
26422
- import { metrics } from "@netless/forge-room";
26285
+ var import_lodash2 = __toESM(require_lodash(), 1);
26423
26286
  function _defineProperty5(e, r, t) {
26424
26287
  return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
26425
26288
  }
@@ -26452,7 +26315,7 @@ function serializePath(path) {
26452
26315
  }, []);
26453
26316
  }
26454
26317
  function deserializePath(points, scope, matrix) {
26455
- const segmentGroup = (0, import_lodash.chunk)(points, 6);
26318
+ const segmentGroup = (0, import_lodash2.chunk)(points, 6);
26456
26319
  const path = new scope.Path();
26457
26320
  path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
26458
26321
  return path;
@@ -26462,27 +26325,7 @@ var AnimationFrame = class {
26462
26325
  _defineProperty5(this, "callbacks", []);
26463
26326
  _defineProperty5(this, "lastTime", 0);
26464
26327
  _defineProperty5(this, "fps", 45);
26465
- _defineProperty5(this, "lastCallbackTime", 0);
26466
- _defineProperty5(this, "fpsBuffer", []);
26467
- _defineProperty5(this, "FPS_REPORT_INTERVAL", 2700);
26468
26328
  _defineProperty5(this, "handleCallbacks", () => {
26469
- const now = performance.now();
26470
- if (this.lastCallbackTime > 0) {
26471
- const actualFps = 1e3 / (now - this.lastCallbackTime);
26472
- this.fpsBuffer.push(actualFps);
26473
- if (this.fpsBuffer.length >= this.FPS_REPORT_INTERVAL) {
26474
- const avg = this.fpsBuffer.reduce((a2, b2) => a2 + b2, 0) / this.fpsBuffer.length;
26475
- const min = Math.min(...this.fpsBuffer);
26476
- const sorted = [...this.fpsBuffer].sort((a2, b2) => a2 - b2);
26477
- const p90 = sorted[Math.floor(sorted.length * 0.9)];
26478
- metrics().gauge("fps", Math.round(avg), {
26479
- min: Math.round(min),
26480
- p90: Math.round(p90)
26481
- });
26482
- this.fpsBuffer = [];
26483
- }
26484
- }
26485
- this.lastCallbackTime = now;
26486
26329
  const functions = this.callbacks;
26487
26330
  this.callbacks = [];
26488
26331
  for (let i = 0, l2 = functions.length; i < l2; i++) {
@@ -26526,22 +26369,13 @@ function _toPrimitive6(t, r) {
26526
26369
  return ("string" === r ? String : Number)(t);
26527
26370
  }
26528
26371
  var SegmentsModel = class extends ElementModel {
26529
- get drawPoints() {
26530
- if (this.localPoints.length >= 4) {
26531
- return this.localPoints;
26532
- }
26533
- return this.points;
26534
- }
26535
- constructor(root, scope, type, liveCursor, isPerformanceMode) {
26536
- super(root, scope, liveCursor, isPerformanceMode);
26372
+ constructor(root, scope, type, liveCursor) {
26373
+ super(root, scope, liveCursor);
26537
26374
  _defineProperty6(this, "item", null);
26538
- _defineProperty6(this, "clearLocalPointsWhenYPointsChange", true);
26539
- _defineProperty6(this, "shouldUseLocalPoints", true);
26540
- _defineProperty6(this, "localPointsPick", 24);
26541
- if (this.root.doc && !this.root.has("type")) {
26375
+ if (!this.root.has("type")) {
26542
26376
  this.root.set("type", type);
26543
26377
  }
26544
- if (this.root.doc && !this.root.has("points")) {
26378
+ if (!this.root.has("points")) {
26545
26379
  this.root.set("points", new Y4.Array());
26546
26380
  }
26547
26381
  }
@@ -26561,13 +26395,13 @@ var SegmentsModel = class extends ElementModel {
26561
26395
  }
26562
26396
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26563
26397
  this.item.removeSegments();
26564
- const next = deserializePath(this.drawPoints, this.scope, matrix);
26398
+ const next = deserializePath(this.points, this.scope, matrix);
26565
26399
  this.item.addSegments(next.segments);
26566
26400
  this.item.closePath();
26567
26401
  }
26568
26402
  createPaperItem() {
26569
26403
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26570
- this.item = deserializePath(this.drawPoints, this.scope, matrix);
26404
+ this.item = deserializePath(this.points, this.scope, matrix);
26571
26405
  this.item.strokeColor = new this.scope.Color(this.strokeColor);
26572
26406
  this.item.dashArray = this.dashArray;
26573
26407
  this.item.strokeWidth = this.strokeWidth;
@@ -26594,7 +26428,7 @@ var SegmentsModel = class extends ElementModel {
26594
26428
  };
26595
26429
 
26596
26430
  // src/model/renderable/LineModel.ts
26597
- var import_lodash3 = __toESM(require_lodash(), 1);
26431
+ var import_lodash4 = __toESM(require_lodash(), 1);
26598
26432
  import * as Y5 from "yjs";
26599
26433
 
26600
26434
  // src/tool/WhiteboardTool.ts
@@ -26615,8 +26449,6 @@ function _toPrimitive7(t, r) {
26615
26449
  }
26616
26450
  return ("string" === r ? String : Number)(t);
26617
26451
  }
26618
- var DRAG_FPS = 10;
26619
- var DRAG_FRAME_MS = 1e3 / DRAG_FPS;
26620
26452
  var WhiteboardTool = class {
26621
26453
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
26622
26454
  _defineProperty7(this, "modelGetter", void 0);
@@ -26625,60 +26457,24 @@ var WhiteboardTool = class {
26625
26457
  _defineProperty7(this, "shadowEmitter", void 0);
26626
26458
  _defineProperty7(this, "enableToolEvent", void 0);
26627
26459
  _defineProperty7(this, "eventAvailable", false);
26628
- _defineProperty7(this, "lastDragTime", 0);
26629
- _defineProperty7(this, "dragRafId", 0);
26630
- _defineProperty7(this, "pendingDragEvent", null);
26631
26460
  _defineProperty7(this, "onMouseDownSelf", (event) => {
26632
26461
  this.eventAvailable = this.enableToolEvent();
26633
26462
  if (!this.eventAvailable) {
26634
26463
  return;
26635
26464
  }
26636
- this.lastDragTime = 0;
26637
- if (this.dragRafId) {
26638
- cancelAnimationFrame(this.dragRafId);
26639
- this.dragRafId = 0;
26640
- }
26641
- this.pendingDragEvent = null;
26642
26465
  this.shadowEmitter.setActive(true);
26643
26466
  this.onMouseDown(event);
26644
26467
  });
26645
- _defineProperty7(this, "flushPendingDrag", () => {
26646
- this.dragRafId = 0;
26647
- if (this.pendingDragEvent) {
26648
- this.lastDragTime = performance.now();
26649
- const event = this.pendingDragEvent;
26650
- this.pendingDragEvent = null;
26651
- this.onMouseDrag(event);
26652
- }
26653
- });
26654
26468
  _defineProperty7(this, "onMouseDragSelf", (event) => {
26655
26469
  if (!this.eventAvailable) {
26656
26470
  return;
26657
26471
  }
26658
- const now = performance.now();
26659
- if (now - this.lastDragTime >= DRAG_FRAME_MS) {
26660
- this.lastDragTime = now;
26661
- this.pendingDragEvent = null;
26662
- this.onMouseDrag(event);
26663
- } else {
26664
- this.pendingDragEvent = event;
26665
- if (!this.dragRafId) {
26666
- this.dragRafId = requestAnimationFrame(this.flushPendingDrag);
26667
- }
26668
- }
26472
+ this.onMouseDrag(event);
26669
26473
  });
26670
26474
  _defineProperty7(this, "onMouseUpSelf", (event) => {
26671
26475
  if (!this.eventAvailable) {
26672
26476
  return;
26673
26477
  }
26674
- if (this.dragRafId) {
26675
- cancelAnimationFrame(this.dragRafId);
26676
- this.dragRafId = 0;
26677
- }
26678
- if (this.pendingDragEvent) {
26679
- this.onMouseDrag(this.pendingDragEvent);
26680
- this.pendingDragEvent = null;
26681
- }
26682
26478
  this.onMouseUp(event);
26683
26479
  this.shadowEmitter.setActive(false);
26684
26480
  });
@@ -26694,7 +26490,7 @@ var WhiteboardTool = class {
26694
26490
  };
26695
26491
 
26696
26492
  // src/tool/LineTool.ts
26697
- var import_lodash2 = __toESM(require_lodash(), 1);
26493
+ var import_lodash3 = __toESM(require_lodash(), 1);
26698
26494
  function _defineProperty8(e, r, t) {
26699
26495
  return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
26700
26496
  }
@@ -26743,7 +26539,7 @@ var LineTool = class extends WhiteboardTool {
26743
26539
  const point = path.getPointAt(distance);
26744
26540
  return [point.x, point.y];
26745
26541
  });
26746
- this.elementModel.setPoints((0, import_lodash2.flattenDeep)(points));
26542
+ this.elementModel.setPoints((0, import_lodash3.flattenDeep)(points));
26747
26543
  }
26748
26544
  }
26749
26545
  onMouseUp(_event) {
@@ -26773,12 +26569,6 @@ function _toPrimitive9(t, r) {
26773
26569
  return ("string" === r ? String : Number)(t);
26774
26570
  }
26775
26571
  var LineModel = class extends ElementModel {
26776
- get drawPoints() {
26777
- if (this.localPoints.length > 0) {
26778
- return this.localPoints;
26779
- }
26780
- return this.points;
26781
- }
26782
26572
  get arrowSize() {
26783
26573
  return this.strokeWidth * 5 + 15;
26784
26574
  }
@@ -26794,23 +26584,20 @@ var LineModel = class extends ElementModel {
26794
26584
  set tailArrow(value) {
26795
26585
  this.root.set("tailArrow", value);
26796
26586
  }
26797
- constructor(root, scope, liveCursor, isPerformanceMode) {
26798
- super(root, scope, liveCursor, isPerformanceMode);
26587
+ constructor(root, scope, liveCursor) {
26588
+ super(root, scope, liveCursor);
26799
26589
  _defineProperty9(this, "controlledPoints", []);
26800
- _defineProperty9(this, "clearLocalPointsWhenYPointsChange", true);
26801
- _defineProperty9(this, "shouldUseLocalPoints", true);
26802
- _defineProperty9(this, "localPointsPick", 99);
26803
26590
  _defineProperty9(this, "item", null);
26804
- if (this.root.doc && !this.root.has("type")) {
26591
+ if (!this.root.has("type")) {
26805
26592
  this.root.set("type", "arrow");
26806
26593
  }
26807
- if (this.root.doc && !this.root.has("points")) {
26594
+ if (!this.root.has("points")) {
26808
26595
  this.root.set("points", new Y5.Array());
26809
26596
  }
26810
- if (this.root.doc && !this.root.has("headArrow")) {
26597
+ if (!this.root.has("headArrow")) {
26811
26598
  this.root.set("headArrow", "none");
26812
26599
  }
26813
- if (this.root.doc && !this.root.has("tailArrow")) {
26600
+ if (!this.root.has("tailArrow")) {
26814
26601
  this.root.set("tailArrow", "normal");
26815
26602
  }
26816
26603
  }
@@ -26826,7 +26613,7 @@ var LineModel = class extends ElementModel {
26826
26613
  }
26827
26614
  renderLine() {
26828
26615
  const matrix = new this.scope.Matrix(this.pointsMatrix);
26829
- const papperPoints = (0, import_lodash3.chunk)(this.drawPoints, 2).map((item) => {
26616
+ const papperPoints = (0, import_lodash4.chunk)(this.points, 2).map((item) => {
26830
26617
  return new this.scope.Point(item[0], item[1]).transform(matrix);
26831
26618
  });
26832
26619
  const path = new this.scope.Path();
@@ -26940,14 +26727,13 @@ var LineControlPoint = class {
26940
26727
  if (this.position) {
26941
26728
  return this.model.scope.project.view.projectToView(this.position.transform(matrix));
26942
26729
  }
26943
- const points = this.model["drawPoints"];
26944
26730
  const from = {
26945
- x: points[0],
26946
- y: points[1]
26731
+ x: this.model.points[0],
26732
+ y: this.model.points[1]
26947
26733
  };
26948
26734
  const to = {
26949
- x: points[points.length - 2],
26950
- y: points[points.length - 1]
26735
+ x: this.model.points[this.model.points.length - 2],
26736
+ y: this.model.points[this.model.points.length - 1]
26951
26737
  };
26952
26738
  const clonedPath = new this.scope.Path.Line(from, to);
26953
26739
  this.position = clonedPath.getPointAt(clonedPath.length * distance);
@@ -26960,9 +26746,9 @@ var LineControlPoint = class {
26960
26746
  }
26961
26747
  const pointsMatrix = new this.model.scope.Matrix(this.model.pointsMatrix);
26962
26748
  const invertedPoint = point.transform(pointsMatrix.inverted());
26963
- const points = this.model["drawPoints"];
26749
+ const points = this.model.points;
26964
26750
  this.position = invertedPoint;
26965
- const clonedPoints = (0, import_lodash3.cloneDeep)(points);
26751
+ const clonedPoints = (0, import_lodash4.cloneDeep)(points);
26966
26752
  clonedPoints[this.options.index * 2] = invertedPoint.x;
26967
26753
  clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
26968
26754
  this.model.setPoints(clonedPoints);
@@ -27008,18 +26794,9 @@ var PointTextModel = class extends ElementModel {
27008
26794
  set fontFamily(value) {
27009
26795
  this.root.set("font-family", value);
27010
26796
  }
27011
- get drawPoints() {
27012
- if (this.localPoints.length > 1) {
27013
- return this.localPoints;
27014
- }
27015
- return this.points;
27016
- }
27017
- constructor(root, scope, liveCursor, isPerformanceMode) {
27018
- super(root, scope, liveCursor, isPerformanceMode);
26797
+ constructor(root, scope, liveCursor) {
26798
+ super(root, scope, liveCursor);
27019
26799
  _defineProperty10(this, "item", null);
27020
- _defineProperty10(this, "clearLocalPointsWhenYPointsChange", true);
27021
- _defineProperty10(this, "shouldUseLocalPoints", false);
27022
- _defineProperty10(this, "localPointsPick", 2);
27023
26800
  _defineProperty10(this, "handleTextPropChange", (event) => {
27024
26801
  if (!this.item) {
27025
26802
  return;
@@ -27036,28 +26813,22 @@ var PointTextModel = class extends ElementModel {
27036
26813
  }
27037
26814
  }
27038
26815
  });
27039
- if (this.root.doc && !this.root.has("type")) {
26816
+ if (!this.root.has("type")) {
27040
26817
  this.root.set("type", "point-text");
27041
26818
  }
27042
- if (this.root.doc && !this.root.has(ElementModel.KEYS.points)) {
26819
+ if (!this.root.has(ElementModel.KEYS.points)) {
27043
26820
  this.root.set(ElementModel.KEYS.points, new Y6.Array());
27044
26821
  }
27045
26822
  this.root.observe(this.handleTextPropChange);
27046
- setTimeout(() => {
27047
- if (this.root && this.root.has("font-size")) {
27048
- setTimeout(() => {
27049
- this.updateTextPosition();
27050
- }, 60);
27051
- }
27052
- }, 60);
26823
+ if (this.root.has("font-size")) {
26824
+ setTimeout(() => {
26825
+ this.updateTextPosition();
26826
+ }, 60);
26827
+ }
27053
26828
  }
27054
26829
  subDispose() {
27055
26830
  removeObserver(this.root, this.handleTextPropChange);
27056
26831
  }
27057
- subBindObserver() {
27058
- removeObserver(this.root, this.handleTextPropChange);
27059
- this.root.observe(this.handleTextPropChange);
27060
- }
27061
26832
  liveCursorPoint() {
27062
26833
  const points = this.points;
27063
26834
  if (points.length < 1) {
@@ -27071,11 +26842,10 @@ var PointTextModel = class extends ElementModel {
27071
26842
  if (!this.item) {
27072
26843
  return null;
27073
26844
  }
27074
- console.log("[][][] drawPoints", this.drawPoints);
27075
26845
  const bounds = this.item.internalBounds;
27076
26846
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27077
- const topLeft = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
27078
- const topRight = new this.scope.Point(this.drawPoints[0] + bounds.width, this.drawPoints[1]).transform(matrix);
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);
27079
26849
  let scaleX = topRight.getDistance(topLeft) / bounds.width;
27080
26850
  scaleX = Number.isNaN(scaleX) ? 1 : scaleX;
27081
26851
  const angle = topRight.subtract(topLeft).angle;
@@ -27163,22 +26933,13 @@ function _toPrimitive11(t, r) {
27163
26933
  return ("string" === r ? String : Number)(t);
27164
26934
  }
27165
26935
  var TriangleModel = class extends ElementModel {
27166
- get drawPoints() {
27167
- if (this.localPoints.length >= 6) {
27168
- return this.localPoints;
27169
- }
27170
- return this.points;
27171
- }
27172
- constructor(root, scope, liveCursor, isPerformanceMode) {
27173
- super(root, scope, liveCursor, isPerformanceMode);
26936
+ constructor(root, scope, liveCursor) {
26937
+ super(root, scope, liveCursor);
27174
26938
  _defineProperty11(this, "item", null);
27175
- _defineProperty11(this, "clearLocalPointsWhenYPointsChange", true);
27176
- _defineProperty11(this, "shouldUseLocalPoints", true);
27177
- _defineProperty11(this, "localPointsPick", 6);
27178
- if (this.root.doc && !this.root.has("type")) {
26939
+ if (!this.root.has("type")) {
27179
26940
  this.root.set("type", "triangle");
27180
26941
  }
27181
- if (this.root.doc && !this.root.has("points")) {
26942
+ if (!this.root.has("points")) {
27182
26943
  this.root.set("points", new Y7.Array());
27183
26944
  }
27184
26945
  }
@@ -27210,9 +26971,9 @@ var TriangleModel = class extends ElementModel {
27210
26971
  return;
27211
26972
  }
27212
26973
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27213
- const p1 = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
27214
- const p2 = new this.scope.Point(this.drawPoints[2], this.drawPoints[3]).transform(matrix);
27215
- const p3 = new this.scope.Point(this.drawPoints[4], this.drawPoints[5]).transform(matrix);
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);
27216
26977
  this.item.removeSegments();
27217
26978
  this.item.moveTo(p1);
27218
26979
  this.item.lineTo(p2);
@@ -27224,7 +26985,7 @@ var TriangleModel = class extends ElementModel {
27224
26985
  config.controlPoints.push({
27225
26986
  name: "triangle",
27226
26987
  getPosition: () => {
27227
- const point = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]);
26988
+ const point = new this.scope.Point(this.points[0], this.points[1]);
27228
26989
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27229
26990
  return this.scope.project.view.projectToView(point.transform(pointsMatrix));
27230
26991
  },
@@ -27234,7 +26995,7 @@ var TriangleModel = class extends ElementModel {
27234
26995
  }
27235
26996
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27236
26997
  const trPoint = point.transform(pointsMatrix.inverted());
27237
- const oldPoints = this.drawPoints;
26998
+ const oldPoints = this.points;
27238
26999
  this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3], oldPoints[4], oldPoints[5]]);
27239
27000
  }
27240
27001
  });
@@ -27273,34 +27034,25 @@ function _toPrimitive12(t, r) {
27273
27034
  return ("string" === r ? String : Number)(t);
27274
27035
  }
27275
27036
  var RectangleModel = class extends ElementModel {
27276
- get drawPoints() {
27277
- if (this.localPoints.length >= 4) {
27278
- return this.localPoints;
27279
- }
27280
- return this.points;
27281
- }
27282
- constructor(root, scope, liveCursor, isPerformanceMode) {
27283
- super(root, scope, liveCursor, isPerformanceMode);
27037
+ constructor(root, scope, liveCursor) {
27038
+ super(root, scope, liveCursor);
27284
27039
  _defineProperty12(this, "item", null);
27285
- _defineProperty12(this, "clearLocalPointsWhenYPointsChange", true);
27286
- _defineProperty12(this, "shouldUseLocalPoints", true);
27287
- _defineProperty12(this, "localPointsPick", 4);
27288
- if (this.root.doc && !this.root.has("type")) {
27040
+ if (!this.root.has("type")) {
27289
27041
  this.root.set("type", "rectangle");
27290
27042
  }
27291
- if (this.root.doc && !this.root.has("points")) {
27043
+ if (!this.root.has("points")) {
27292
27044
  const initPoints = new Y8.Array();
27293
27045
  initPoints.push([0, 0, 0, 0]);
27294
27046
  this.root.set("points", initPoints);
27295
27047
  }
27296
- if (this.root.doc && !this.root.has("radius")) {
27048
+ if (!this.root.has("radius")) {
27297
27049
  this.root.set("radius", 0);
27298
27050
  }
27299
27051
  }
27300
27052
  subDispose() {
27301
27053
  }
27302
27054
  liveCursorPoint() {
27303
- const points = this.drawPoints;
27055
+ const points = this.points;
27304
27056
  if (points.length < 4) {
27305
27057
  return null;
27306
27058
  }
@@ -27308,7 +27060,7 @@ var RectangleModel = class extends ElementModel {
27308
27060
  return new this.scope.Point(points[2], points[3]).transform(matrix);
27309
27061
  }
27310
27062
  createSegments() {
27311
- const [a2, b2, c, d] = this.drawPoints;
27063
+ const [a2, b2, c, d] = this.points;
27312
27064
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27313
27065
  const maxRadius = this.maxRadiusLength();
27314
27066
  const radius = this.root.get("radius") * maxRadius;
@@ -27373,7 +27125,7 @@ var RectangleModel = class extends ElementModel {
27373
27125
  }
27374
27126
  maxRadiusLength() {
27375
27127
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27376
- const points = this.drawPoints;
27128
+ const points = this.points;
27377
27129
  const topLeft = new this.scope.Point(points[0], points[1]).transform(pointsMatrix);
27378
27130
  const topRight = new this.scope.Point(points[2], points[1]).transform(pointsMatrix);
27379
27131
  const bottomLeft = new this.scope.Point(points[0], points[3]).transform(pointsMatrix);
@@ -27398,7 +27150,7 @@ var RectangleModel = class extends ElementModel {
27398
27150
  name: "rect-radius",
27399
27151
  getPosition: () => {
27400
27152
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27401
- const points = this.drawPoints;
27153
+ const points = this.points;
27402
27154
  const radius = this.root.get("radius") * this.maxRadiusLength();
27403
27155
  let c1 = new this.scope.Point(points[0], points[1]).transform(matrix);
27404
27156
  const c3 = new this.scope.Point(points[2], points[3]).transform(matrix);
@@ -27417,7 +27169,7 @@ var RectangleModel = class extends ElementModel {
27417
27169
  if (!this.item) {
27418
27170
  return;
27419
27171
  }
27420
- const points = this.drawPoints;
27172
+ const points = this.points;
27421
27173
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27422
27174
  const maxRadius = Math.min(points[2] - points[0], points[3] - points[1]) / 2;
27423
27175
  const trPoint = point.transform(pointsMatrix.inverted());
@@ -27446,7 +27198,7 @@ var RectangleModel = class extends ElementModel {
27446
27198
  var elementsUndoOrigin = "elementsUndoOrigin";
27447
27199
 
27448
27200
  // src/model/renderable/EraserModel.ts
27449
- var import_lodash4 = __toESM(require_lodash(), 1);
27201
+ var import_lodash5 = __toESM(require_lodash(), 1);
27450
27202
  import * as Y9 from "yjs";
27451
27203
  function _defineProperty13(e, r, t) {
27452
27204
  return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
@@ -27466,23 +27218,14 @@ function _toPrimitive13(t, r) {
27466
27218
  return ("string" === r ? String : Number)(t);
27467
27219
  }
27468
27220
  var EraserModel = class extends ElementModel {
27469
- get drawPoints() {
27470
- if (this.localPoints.length > 0) {
27471
- return this.localPoints;
27472
- }
27473
- return this.points;
27474
- }
27475
- constructor(root, scope, liveCursor, isPerformanceMode) {
27476
- super(root, scope, liveCursor, isPerformanceMode);
27221
+ constructor(root, scope, liveCursor) {
27222
+ super(root, scope, liveCursor);
27477
27223
  _defineProperty13(this, "item", null);
27478
27224
  _defineProperty13(this, "sliceBegin", 0);
27479
- _defineProperty13(this, "clearLocalPointsWhenYPointsChange", false);
27480
- _defineProperty13(this, "shouldUseLocalPoints", true);
27481
- _defineProperty13(this, "localPointsPick", 4);
27482
- if (this.root.doc && !this.root.has("type")) {
27225
+ if (!this.root.has("type")) {
27483
27226
  this.root.set("type", "eraser");
27484
27227
  }
27485
- if (this.root.doc && !this.root.has("points")) {
27228
+ if (!this.root.has("points")) {
27486
27229
  this.root.set("points", new Y9.Array());
27487
27230
  }
27488
27231
  }
@@ -27515,7 +27258,7 @@ var EraserModel = class extends ElementModel {
27515
27258
  return path;
27516
27259
  }
27517
27260
  parsePoints(points) {
27518
- const groupPoints = (0, import_lodash4.chunk)(points, 2);
27261
+ const groupPoints = (0, import_lodash5.chunk)(points, 2);
27519
27262
  return ae(groupPoints, {
27520
27263
  size: this.strokeWidth,
27521
27264
  smoothing: 0.5,
@@ -27533,7 +27276,7 @@ var EraserModel = class extends ElementModel {
27533
27276
  });
27534
27277
  }
27535
27278
  matrixedPoints() {
27536
- const currentPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
27279
+ const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
27537
27280
  return currentPoints.map((_ref) => {
27538
27281
  let [x, y] = _ref;
27539
27282
  return new this.scope.Point(x, y);
@@ -27561,11 +27304,11 @@ var EraserModel = class extends ElementModel {
27561
27304
  this.item.fillColor = new this.scope.Color(this.strokeColor);
27562
27305
  this.onVectorUpdate();
27563
27306
  this.item.onFrame = () => {
27564
- if (!this.drawPoints) {
27307
+ if (!this.points) {
27565
27308
  return;
27566
27309
  }
27567
- if (this.drawPoints.length / 2 > 50) {
27568
- this.sliceBegin = this.drawPoints.length / 2 - 50;
27310
+ if (this.points.length / 2 > 50) {
27311
+ this.sliceBegin = this.points.length / 2 - 50;
27569
27312
  }
27570
27313
  };
27571
27314
  }
@@ -27598,9 +27341,8 @@ var EraserModel = class extends ElementModel {
27598
27341
  };
27599
27342
 
27600
27343
  // src/model/renderable/LaserPointerModel.ts
27601
- var import_lodash5 = __toESM(require_lodash(), 1);
27344
+ var import_lodash6 = __toESM(require_lodash(), 1);
27602
27345
  import * as Y10 from "yjs";
27603
- import { removeObserver as removeObserver2 } from "@netless/forge-room";
27604
27346
  function _defineProperty14(e, r, t) {
27605
27347
  return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
27606
27348
  }
@@ -27619,18 +27361,24 @@ function _toPrimitive14(t, r) {
27619
27361
  return ("string" === r ? String : Number)(t);
27620
27362
  }
27621
27363
  var LaserPointerModel = class extends ElementModel {
27622
- constructor(clientId, root, scope, liveCursor, removeElement, isPerformanceMode) {
27623
- super(root, scope, liveCursor, isPerformanceMode);
27364
+ constructor(clientId, root, scope, liveCursor, removeElement) {
27365
+ super(root, scope, liveCursor);
27624
27366
  _defineProperty14(this, "item", null);
27625
27367
  _defineProperty14(this, "clientId", void 0);
27626
27368
  _defineProperty14(this, "sliceBegin", 0);
27627
27369
  _defineProperty14(this, "displayStrokeWidth", 8);
27628
27370
  _defineProperty14(this, "cachedPoints", null);
27629
- _defineProperty14(this, "clearLocalPointsWhenYPointsChange", false);
27630
- _defineProperty14(this, "shouldUseLocalPoints", false);
27631
- _defineProperty14(this, "localPointsPick", 4);
27632
- _defineProperty14(this, "removeElement", void 0);
27633
- _defineProperty14(this, "handleLaserPropChange", (event) => {
27371
+ this.clientId = clientId;
27372
+ if (!this.root.has("type")) {
27373
+ this.root.set("type", "laser");
27374
+ }
27375
+ if (!this.root.has("points")) {
27376
+ this.root.set("points", new Y10.Array());
27377
+ }
27378
+ if (!this.root.has("removed")) {
27379
+ this.root.set("removed", false);
27380
+ }
27381
+ this.root.observe((event) => {
27634
27382
  if (!this.item) {
27635
27383
  return;
27636
27384
  }
@@ -27648,31 +27396,13 @@ var LaserPointerModel = class extends ElementModel {
27648
27396
  this.onVectorUpdate();
27649
27397
  if (evt.count >= 30) {
27650
27398
  if (this.ownerId === this.clientId) {
27651
- this.removeElement(this.uuid);
27399
+ removeElement(this.uuid);
27652
27400
  }
27653
27401
  }
27654
27402
  };
27655
27403
  }
27656
27404
  }
27657
27405
  });
27658
- this.clientId = clientId;
27659
- this.removeElement = removeElement;
27660
- if (this.root.doc && !this.root.has("type")) {
27661
- this.root.set("type", "laser");
27662
- }
27663
- if (this.root.doc && !this.root.has("points")) {
27664
- this.root.set("points", new Y10.Array());
27665
- }
27666
- if (this.root.doc && !this.root.has("removed")) {
27667
- this.root.set("removed", false);
27668
- }
27669
- }
27670
- subBindObserver() {
27671
- removeObserver2(this.root, this.handleLaserPropChange);
27672
- this.root.observe(this.handleLaserPropChange);
27673
- }
27674
- subDispose() {
27675
- removeObserver2(this.root, this.handleLaserPropChange);
27676
27406
  }
27677
27407
  beginRemoveAnimate() {
27678
27408
  this.root.set("removed", true);
@@ -27725,8 +27455,7 @@ var LaserPointerModel = class extends ElementModel {
27725
27455
  matrixedPoints() {
27726
27456
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27727
27457
  const points = this.cachedPoints || this.points;
27728
- console.log("[][][] ,", this.points.length, this.cachedPoints?.length, this.localPoints.length);
27729
- const groupPoints = (0, import_lodash5.chunk)(points, 2).slice(this.sliceBegin);
27458
+ const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
27730
27459
  return groupPoints.map((_ref) => {
27731
27460
  let [x, y] = _ref;
27732
27461
  return matrix.transform([x, y]);
@@ -27768,6 +27497,8 @@ var LaserPointerModel = class extends ElementModel {
27768
27497
  onStyleKeyUpdate(_key) {
27769
27498
  return;
27770
27499
  }
27500
+ subDispose() {
27501
+ }
27771
27502
  liveCursorPoint() {
27772
27503
  const yArray = this.root.get(ElementModel.KEYS.points);
27773
27504
  if (yArray.length < 2) {
@@ -27805,7 +27536,7 @@ var WhiteboardPermissions = class extends AbstractApplicationPermissions {
27805
27536
  };
27806
27537
 
27807
27538
  // src/model/renderable/StraightLineModel.ts
27808
- var import_lodash6 = __toESM(require_lodash(), 1);
27539
+ var import_lodash7 = __toESM(require_lodash(), 1);
27809
27540
  import * as Y11 from "yjs";
27810
27541
  function _defineProperty15(e, r, t) {
27811
27542
  return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
@@ -27825,22 +27556,13 @@ function _toPrimitive15(t, r) {
27825
27556
  return ("string" === r ? String : Number)(t);
27826
27557
  }
27827
27558
  var StraightLineModel = class extends ElementModel {
27828
- get drawPoints() {
27829
- if (this.localPoints.length >= 4) {
27830
- return this.localPoints;
27831
- }
27832
- return this.points;
27833
- }
27834
- constructor(root, scope, liveCursor, isPerformanceMode) {
27835
- super(root, scope, liveCursor, isPerformanceMode);
27559
+ constructor(root, scope, liveCursor) {
27560
+ super(root, scope, liveCursor);
27836
27561
  _defineProperty15(this, "item", null);
27837
- _defineProperty15(this, "clearLocalPointsWhenYPointsChange", true);
27838
- _defineProperty15(this, "shouldUseLocalPoints", true);
27839
- _defineProperty15(this, "localPointsPick", 4);
27840
- if (this.root.doc && !this.root.has("type")) {
27562
+ if (!this.root.has("type")) {
27841
27563
  this.root.set("type", "line");
27842
27564
  }
27843
- if (this.root.doc && !this.root.has("points")) {
27565
+ if (!this.root.has("points")) {
27844
27566
  this.root.set("points", new Y11.Array());
27845
27567
  }
27846
27568
  }
@@ -27865,7 +27587,7 @@ var StraightLineModel = class extends ElementModel {
27865
27587
  }
27866
27588
  renderLine() {
27867
27589
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27868
- const papperPoints = (0, import_lodash6.chunk)(this.drawPoints, 2).map((item) => {
27590
+ const papperPoints = (0, import_lodash7.chunk)(this.points, 2).map((item) => {
27869
27591
  return new this.scope.Point(item[0], item[1]).transform(matrix);
27870
27592
  });
27871
27593
  const path = new this.scope.Path();
@@ -27887,7 +27609,7 @@ var StraightLineModel = class extends ElementModel {
27887
27609
  name: "line-start",
27888
27610
  getPosition: () => {
27889
27611
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27890
- const points = this.drawPoints;
27612
+ const points = this.points;
27891
27613
  const start = new this.scope.Point(points[0], points[1]);
27892
27614
  return this.scope.project.view.projectToView(start.transform(matrix));
27893
27615
  },
@@ -27897,15 +27619,14 @@ var StraightLineModel = class extends ElementModel {
27897
27619
  }
27898
27620
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27899
27621
  const trPoint = point.transform(pointsMatrix.inverted());
27900
- const oldPoints = this.drawPoints;
27901
- this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3]]);
27622
+ this.setPoints([trPoint.x, trPoint.y, this.points[2], this.points[3]]);
27902
27623
  }
27903
27624
  });
27904
27625
  cfg.controlPoints.push({
27905
27626
  name: "line-end",
27906
27627
  getPosition: () => {
27907
27628
  const matrix = new this.scope.Matrix(this.pointsMatrix);
27908
- const points = this.drawPoints;
27629
+ const points = this.points;
27909
27630
  const end = new this.scope.Point(points[2], points[3]);
27910
27631
  return this.scope.project.view.projectToView(end.transform(matrix));
27911
27632
  },
@@ -27915,8 +27636,7 @@ var StraightLineModel = class extends ElementModel {
27915
27636
  }
27916
27637
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
27917
27638
  const trPoint = point.transform(pointsMatrix.inverted());
27918
- const oldPoints = this.drawPoints;
27919
- this.setPoints([oldPoints[0], oldPoints[1], trPoint.x, trPoint.y]);
27639
+ this.setPoints([this.points[0], this.points[1], trPoint.x, trPoint.y]);
27920
27640
  }
27921
27641
  });
27922
27642
  return cfg;
@@ -27962,13 +27682,10 @@ var ImageModel = class extends ElementModel {
27962
27682
  get src() {
27963
27683
  return this.root.get("src");
27964
27684
  }
27965
- constructor(root, scope, imageSets, liveCursor, isPerformanceMode) {
27966
- super(root, scope, liveCursor, isPerformanceMode);
27685
+ constructor(root, scope, imageSets, liveCursor) {
27686
+ super(root, scope, liveCursor);
27967
27687
  _defineProperty16(this, "item", null);
27968
27688
  _defineProperty16(this, "imageSets", void 0);
27969
- _defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
27970
- _defineProperty16(this, "shouldUseLocalPoints", true);
27971
- _defineProperty16(this, "localPointsPick", 4);
27972
27689
  this.imageSets = imageSets;
27973
27690
  if (!this.root.has("type")) {
27974
27691
  this.root.set("type", "image");
@@ -28051,7 +27768,7 @@ var RenderableModel = class extends EventEmitter {
28051
27768
  get uuid() {
28052
27769
  return uuidv4().replace(/-/g, "");
28053
27770
  }
28054
- constructor(options) {
27771
+ constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
28055
27772
  super();
28056
27773
  _defineProperty17(this, "scope", void 0);
28057
27774
  _defineProperty17(this, "toolbarModel", void 0);
@@ -28064,7 +27781,6 @@ var RenderableModel = class extends EventEmitter {
28064
27781
  _defineProperty17(this, "shadowEmitter", void 0);
28065
27782
  _defineProperty17(this, "imageSets", void 0);
28066
27783
  _defineProperty17(this, "liveCursor", void 0);
28067
- _defineProperty17(this, "isPerformanceMode", void 0);
28068
27784
  _defineProperty17(this, "onElementsChange", (event) => {
28069
27785
  for (const [key, value] of event.changes.keys.entries()) {
28070
27786
  if (value.action === "add") {
@@ -28083,16 +27799,15 @@ var RenderableModel = class extends EventEmitter {
28083
27799
  }
28084
27800
  }
28085
27801
  });
28086
- this.isPerformanceMode = options.isPerformanceMode;
28087
- this.liveCursor = options.liveCursor;
28088
- this.imageSets = options.imageSets;
28089
- this.hasPermission = options.hasPermission;
28090
- this.shadowEmitter = options.shadowEmitter;
28091
- this.layerId = options.layerId;
28092
- this.userManager = options.userManager;
28093
- this.elements = options.elements;
28094
- this.scope = options.scope;
28095
- this.toolbarModel = options.toolbarModel;
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;
28096
27811
  this.elementModels = /* @__PURE__ */ new Map();
28097
27812
  for (const key of this.elements.keys()) {
28098
27813
  const type = this.elements.get(key)?.get("type");
@@ -28123,43 +27838,33 @@ var RenderableModel = class extends EventEmitter {
28123
27838
  convertToModel(yMap) {
28124
27839
  const type = yMap.get("type");
28125
27840
  let model = null;
28126
- const uuid = yMap.get(ElementModel.KEYS.uuid);
28127
- if (uuid) {
28128
- const existingModel = this.elementModels.get(uuid);
28129
- if (existingModel) {
28130
- existingModel.shadowEmitter = this.shadowEmitter;
28131
- existingModel.bindObserver();
28132
- return existingModel;
28133
- }
28134
- }
28135
27841
  if (type === "curve") {
28136
- model = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27842
+ model = new CurveModel(yMap, this.scope, this.liveCursor);
28137
27843
  } else if (["ellipse"].indexOf(type) >= 0) {
28138
- model = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
27844
+ model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
28139
27845
  } else if (type === "selector") {
28140
- model = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27846
+ model = new SelectorModel(yMap, this.scope, this.liveCursor);
28141
27847
  } else if (type === "arrow") {
28142
- model = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27848
+ model = new LineModel(yMap, this.scope, this.liveCursor);
28143
27849
  } else if (type === "line") {
28144
- model = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27850
+ model = new StraightLineModel(yMap, this.scope, this.liveCursor);
28145
27851
  } else if (type === "point-text") {
28146
- model = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27852
+ model = new PointTextModel(yMap, this.scope, this.liveCursor);
28147
27853
  } else if (type === "triangle") {
28148
- model = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27854
+ model = new TriangleModel(yMap, this.scope, this.liveCursor);
28149
27855
  } else if (type === "rectangle") {
28150
- model = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27856
+ model = new RectangleModel(yMap, this.scope, this.liveCursor);
28151
27857
  } else if (type === "eraser") {
28152
- model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
27858
+ model = new EraserModel(yMap, this.scope, this.liveCursor);
28153
27859
  } else if (type === "laser") {
28154
- model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
28155
- this.removeElementItem(uuid2);
28156
- }, this.isPerformanceMode);
27860
+ model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
27861
+ this.removeElementItem(uuid);
27862
+ });
28157
27863
  } else if (type === "image") {
28158
- model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
27864
+ model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
28159
27865
  }
28160
27866
  if (model) {
28161
27867
  model.shadowEmitter = this.shadowEmitter;
28162
- model.bindObserver();
28163
27868
  this.elementModels.set(model.uuid, model);
28164
27869
  }
28165
27870
  return model;
@@ -28190,8 +27895,7 @@ var RenderableModel = class extends EventEmitter {
28190
27895
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28191
27896
  this.elements.set(uuid, yMap);
28192
27897
  }, elementsUndoOrigin);
28193
- const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
28194
- model.bindObserver();
27898
+ const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
28195
27899
  model.root.set("src", src);
28196
27900
  const initMatrix = new this.scope.Matrix();
28197
27901
  const center = this.scope.project.view.center;
@@ -28208,10 +27912,8 @@ var RenderableModel = class extends EventEmitter {
28208
27912
  return null;
28209
27913
  }
28210
27914
  const yMap = new Y12.Map();
28211
- const uuid = this.uuid;
28212
- const curveModel = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28213
- this.elementModels.set(uuid, curveModel);
28214
27915
  this.elements.doc?.transact(() => {
27916
+ const uuid = this.uuid;
28215
27917
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28216
27918
  yMap.set(ElementModel.KEYS.uuid, uuid);
28217
27919
  yMap.set("type", "curve");
@@ -28224,7 +27926,7 @@ var RenderableModel = class extends EventEmitter {
28224
27926
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28225
27927
  this.elements.set(uuid, yMap);
28226
27928
  }, elementsUndoOrigin);
28227
- curveModel.bindObserver();
27929
+ const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
28228
27930
  this.initElement(curveModel);
28229
27931
  return curveModel;
28230
27932
  }
@@ -28233,17 +27935,11 @@ var RenderableModel = class extends EventEmitter {
28233
27935
  return null;
28234
27936
  }
28235
27937
  const yMap = new Y12.Map();
28236
- const uuid = this.uuid;
28237
- const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
28238
- this.removeElementItem(uuid2);
28239
- }, this.isPerformanceMode);
28240
- this.elementModels.set(uuid, model);
28241
27938
  this.elements.doc?.transact(() => {
27939
+ const uuid = this.uuid;
28242
27940
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28243
27941
  yMap.set(ElementModel.KEYS.uuid, uuid);
28244
27942
  yMap.set("type", "laser");
28245
- yMap.set(ElementModel.KEYS.points, new Y12.Array());
28246
- yMap.set("removed", false);
28247
27943
  yMap.set(ElementModel.KEYS.shadow, "layer");
28248
27944
  yMap.set(ElementModel.KEYS.strokeWidth, 8);
28249
27945
  yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
@@ -28251,8 +27947,9 @@ var RenderableModel = class extends EventEmitter {
28251
27947
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28252
27948
  this.elements.set(uuid, yMap);
28253
27949
  }, elementsUndoOrigin);
28254
- model.bindObserver();
28255
- this.initElement(model);
27950
+ const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
27951
+ this.removeElementItem(uuid);
27952
+ });
28256
27953
  return model;
28257
27954
  }
28258
27955
  createEraser() {
@@ -28260,14 +27957,11 @@ var RenderableModel = class extends EventEmitter {
28260
27957
  return null;
28261
27958
  }
28262
27959
  const yMap = new Y12.Map();
28263
- const uuid = this.uuid;
28264
- const model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28265
- this.elementModels.set(uuid, model);
28266
27960
  this.elements.doc?.transact(() => {
27961
+ const uuid = this.uuid;
28267
27962
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28268
27963
  yMap.set(ElementModel.KEYS.uuid, uuid);
28269
27964
  yMap.set("type", "eraser");
28270
- yMap.set(ElementModel.KEYS.points, new Y12.Array());
28271
27965
  yMap.set(ElementModel.KEYS.shadow, "layer");
28272
27966
  yMap.set(ElementModel.KEYS.strokeWidth, 4);
28273
27967
  yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
@@ -28275,7 +27969,7 @@ var RenderableModel = class extends EventEmitter {
28275
27969
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28276
27970
  this.elements.set(uuid, yMap);
28277
27971
  }, elementsUndoOrigin);
28278
- model.bindObserver();
27972
+ const model = new EraserModel(yMap, this.scope, this.liveCursor);
28279
27973
  return model;
28280
27974
  }
28281
27975
  createTriangle(shadow) {
@@ -28283,54 +27977,45 @@ var RenderableModel = class extends EventEmitter {
28283
27977
  return null;
28284
27978
  }
28285
27979
  const yMap = new Y12.Map();
28286
- const uuid = this.uuid;
28287
- const triangleModel = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28288
- this.elementModels.set(uuid, triangleModel);
28289
27980
  this.elements.doc?.transact(() => {
27981
+ const uuid = this.uuid;
28290
27982
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28291
27983
  yMap.set(ElementModel.KEYS.uuid, uuid);
28292
27984
  yMap.set("type", "triangle");
28293
27985
  if (shadow) {
28294
27986
  yMap.set(ElementModel.KEYS.shadow, "layer");
28295
27987
  }
28296
- yMap.set("points", new Y12.Array());
28297
27988
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28298
27989
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28299
27990
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28300
27991
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28301
27992
  this.elements.set(uuid, yMap);
28302
27993
  }, elementsUndoOrigin);
28303
- triangleModel.bindObserver();
28304
- this.initElement(triangleModel);
28305
- triangleModel.dashArray = this.toolbarModel.dashArray;
28306
- return triangleModel;
27994
+ const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
27995
+ this.initElement(triangle);
27996
+ triangle.dashArray = this.toolbarModel.dashArray;
27997
+ return triangle;
28307
27998
  }
28308
27999
  createRectangle(shadow) {
28309
28000
  if (!this.confirmPermission()) {
28310
28001
  return null;
28311
28002
  }
28312
28003
  const yMap = new Y12.Map();
28313
- const uuid = this.uuid;
28314
- const rect = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28315
- this.elementModels.set(uuid, rect);
28316
28004
  this.elements.doc?.transact(() => {
28005
+ const uuid = this.uuid;
28317
28006
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28318
28007
  yMap.set(ElementModel.KEYS.uuid, uuid);
28319
28008
  yMap.set("type", "rectangle");
28320
28009
  if (shadow) {
28321
28010
  yMap.set(ElementModel.KEYS.shadow, "layer");
28322
28011
  }
28323
- const initPoints = new Y12.Array();
28324
- initPoints.push([0, 0, 0, 0]);
28325
- yMap.set("points", initPoints);
28326
- yMap.set("radius", 0);
28327
28012
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28328
28013
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28329
28014
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28330
28015
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28331
28016
  this.elements.set(uuid, yMap);
28332
28017
  }, elementsUndoOrigin);
28333
- rect.bindObserver();
28018
+ const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
28334
28019
  this.initElement(rect);
28335
28020
  rect.dashArray = this.toolbarModel.dashArray;
28336
28021
  return rect;
@@ -28340,24 +28025,21 @@ var RenderableModel = class extends EventEmitter {
28340
28025
  return null;
28341
28026
  }
28342
28027
  const yMap = new Y12.Map();
28343
- const uuid = this.uuid;
28344
- const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
28345
- this.elementModels.set(uuid, segmentsModel);
28346
28028
  this.elements.doc?.transact(() => {
28029
+ const uuid = this.uuid;
28347
28030
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28348
28031
  yMap.set(ElementModel.KEYS.uuid, uuid);
28349
28032
  yMap.set("type", type);
28350
28033
  if (shadow) {
28351
28034
  yMap.set(ElementModel.KEYS.shadow, "layer");
28352
28035
  }
28353
- yMap.set(ElementModel.KEYS.points, new Y12.Array());
28354
28036
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28355
28037
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28356
28038
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28357
28039
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28358
28040
  this.elements.set(uuid, yMap);
28359
28041
  }, elementsUndoOrigin);
28360
- segmentsModel.bindObserver();
28042
+ const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
28361
28043
  this.initElement(segmentsModel);
28362
28044
  segmentsModel.dashArray = this.toolbarModel.dashArray;
28363
28045
  return segmentsModel;
@@ -28368,21 +28050,16 @@ var RenderableModel = class extends EventEmitter {
28368
28050
  return null;
28369
28051
  }
28370
28052
  const yMap = new Y12.Map();
28371
- const uuid = this.uuid;
28372
- const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28373
- this.elementModels.set(uuid, selectorModel);
28374
28053
  this.elements.doc?.transact(() => {
28054
+ const uuid = this.uuid;
28375
28055
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28376
28056
  yMap.set(ElementModel.KEYS.uuid, uuid);
28377
28057
  yMap.set("type", "selector");
28378
- const initPoints = new Y12.Array();
28379
- initPoints.push([0, 0, 0, 0]);
28380
- yMap.set(ElementModel.KEYS.points, initPoints);
28381
28058
  yMap.set(ElementModel.KEYS.shadow, "layer");
28382
28059
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28383
28060
  this.elements.set(uuid, yMap);
28384
28061
  }, elementsUndoOrigin);
28385
- selectorModel.bindObserver();
28062
+ const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
28386
28063
  selectorModel.shadow = "layer";
28387
28064
  return selectorModel;
28388
28065
  }
@@ -28391,24 +28068,21 @@ var RenderableModel = class extends EventEmitter {
28391
28068
  return null;
28392
28069
  }
28393
28070
  const yMap = new Y12.Map();
28394
- const uuid = this.uuid;
28395
- const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28396
- this.elementModels.set(uuid, straightLineModel);
28397
28071
  this.elements.doc?.transact(() => {
28072
+ const uuid = this.uuid;
28398
28073
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28399
28074
  yMap.set(ElementModel.KEYS.uuid, uuid);
28400
28075
  yMap.set("type", "line");
28401
28076
  if (shadow) {
28402
28077
  yMap.set(ElementModel.KEYS.shadow, "layer");
28403
28078
  }
28404
- yMap.set("points", new Y12.Array());
28405
28079
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28406
28080
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28407
28081
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28408
28082
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28409
28083
  this.elements.set(uuid, yMap);
28410
28084
  }, elementsUndoOrigin);
28411
- straightLineModel.bindObserver();
28085
+ const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
28412
28086
  this.initElement(straightLineModel);
28413
28087
  straightLineModel.dashArray = this.toolbarModel.dashArray;
28414
28088
  return straightLineModel;
@@ -28418,26 +28092,21 @@ var RenderableModel = class extends EventEmitter {
28418
28092
  return null;
28419
28093
  }
28420
28094
  const yMap = new Y12.Map();
28421
- const uuid = this.uuid;
28422
- const lineModel = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28423
- this.elementModels.set(uuid, lineModel);
28424
28095
  this.elements.doc?.transact(() => {
28096
+ const uuid = this.uuid;
28425
28097
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28426
28098
  yMap.set(ElementModel.KEYS.uuid, uuid);
28427
28099
  yMap.set("type", "arrow");
28428
28100
  if (shadow) {
28429
28101
  yMap.set(ElementModel.KEYS.shadow, "layer");
28430
28102
  }
28431
- yMap.set("headArrow", "none");
28432
- yMap.set("tailArrow", "normal");
28433
- yMap.set(ElementModel.KEYS.points, new Y12.Array());
28434
28103
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28435
28104
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28436
28105
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28437
28106
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28438
28107
  this.elements.set(uuid, yMap);
28439
28108
  }, elementsUndoOrigin);
28440
- lineModel.bindObserver();
28109
+ const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
28441
28110
  this.initElement(lineModel);
28442
28111
  lineModel.dashArray = this.toolbarModel.dashArray;
28443
28112
  return lineModel;
@@ -28447,24 +28116,21 @@ var RenderableModel = class extends EventEmitter {
28447
28116
  return null;
28448
28117
  }
28449
28118
  const yMap = new Y12.Map();
28450
- const uuid = this.uuid;
28451
- const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
28452
- this.elementModels.set(uuid, pointTextModel);
28453
28119
  this.elements.doc?.transact(() => {
28120
+ const uuid = this.uuid;
28454
28121
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
28455
28122
  yMap.set(ElementModel.KEYS.uuid, uuid);
28456
28123
  yMap.set("type", "point-text");
28457
28124
  if (shadow) {
28458
28125
  yMap.set(ElementModel.KEYS.shadow, "layer");
28459
28126
  }
28460
- yMap.set(ElementModel.KEYS.points, new Y12.Array());
28461
28127
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
28462
28128
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
28463
28129
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
28464
28130
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
28465
28131
  this.elements.set(uuid, yMap);
28466
28132
  }, elementsUndoOrigin);
28467
- pointTextModel.bindObserver();
28133
+ const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
28468
28134
  pointTextModel.setPoints([x, y]);
28469
28135
  pointTextModel.fontSize = this.toolbarModel.fontSize;
28470
28136
  pointTextModel.fontFamily = this.toolbarModel.fontFamily;
@@ -28487,19 +28153,18 @@ var RenderableModel = class extends EventEmitter {
28487
28153
  });
28488
28154
  }
28489
28155
  dispose(clearElements) {
28490
- removeObserver3(this.elements, this.onElementsChange);
28156
+ removeObserver2(this.elements, this.onElementsChange);
28491
28157
  if (clearElements) {
28492
28158
  this.elements.clear();
28493
28159
  }
28494
28160
  Array.from(this.elementModels.values()).forEach((model) => {
28495
28161
  model.dispose();
28496
- model.disposeObserver();
28497
28162
  });
28498
28163
  }
28499
28164
  };
28500
28165
 
28501
28166
  // src/utils/Recognizer.ts
28502
- var import_lodash7 = __toESM(require_lodash(), 1);
28167
+ var import_lodash8 = __toESM(require_lodash(), 1);
28503
28168
 
28504
28169
  // src/utils/UnistrokeRecognizer.js
28505
28170
  function Point(x, y) {
@@ -28746,7 +28411,7 @@ var Recognizer = class {
28746
28411
  let maxX = -Number.MAX_VALUE;
28747
28412
  let minY = Number.MAX_VALUE;
28748
28413
  let maxY = -Number.MAX_VALUE;
28749
- const result = this.dollar.Recognize((0, import_lodash7.chunk)(points, 3).map((v) => {
28414
+ const result = this.dollar.Recognize((0, import_lodash8.chunk)(points, 2).map((v) => {
28750
28415
  minX = Math.min(minX, v[0]);
28751
28416
  maxX = Math.max(maxX, v[0]);
28752
28417
  minY = Math.min(minY, v[1]);
@@ -28790,24 +28455,11 @@ var CurveTool = class extends WhiteboardTool {
28790
28455
  _defineProperty19(this, "elementModel", null);
28791
28456
  _defineProperty19(this, "recognizer", new Recognizer());
28792
28457
  _defineProperty19(this, "pointCount", 0);
28793
- _defineProperty19(this, "pendingPoints", []);
28794
- _defineProperty19(this, "flushRafId", 0);
28795
28458
  _defineProperty19(this, "showLiveCursor", true);
28796
- _defineProperty19(this, "flushPendingPoints", () => {
28797
- this.flushRafId = 0;
28798
- if (this.elementModel && this.pendingPoints.length > 0) {
28799
- this.elementModel.appendPoints(this.pendingPoints);
28800
- this.pendingPoints = [];
28801
- }
28802
- });
28459
+ this.tool.minDistance = 5;
28803
28460
  }
28804
28461
  onMouseDown(_event) {
28805
28462
  this.pointCount = 0;
28806
- this.pendingPoints = [];
28807
- if (this.flushRafId) {
28808
- cancelAnimationFrame(this.flushRafId);
28809
- this.flushRafId = 0;
28810
- }
28811
28463
  if (this.elementModel) {
28812
28464
  this.elementModel.dispose();
28813
28465
  }
@@ -28822,38 +28474,27 @@ var CurveTool = class extends WhiteboardTool {
28822
28474
  if (this.pointCount > 1024) {
28823
28475
  return;
28824
28476
  }
28825
- const MIN_DISTANCE = 2;
28477
+ const MIN_DISTANCE = 4;
28826
28478
  if (this.elementModel) {
28827
- let lastX = 0;
28828
- let lastY = 0;
28829
- if (this.pendingPoints.length >= 3) {
28830
- lastX = this.pendingPoints[this.pendingPoints.length - 3];
28831
- lastY = this.pendingPoints[this.pendingPoints.length - 2];
28832
- } else {
28833
- const len = this.elementModel.points.length;
28834
- if (len >= 3) {
28835
- lastX = this.elementModel.points[len - 3];
28836
- lastY = this.elementModel.points[len - 2];
28837
- }
28479
+ const len = this.elementModel.points.length;
28480
+ let last = {
28481
+ x: 0,
28482
+ y: 0
28483
+ };
28484
+ if (len >= 2) {
28485
+ last = {
28486
+ x: this.elementModel.points[len - 2],
28487
+ y: this.elementModel.points[len - 1]
28488
+ };
28838
28489
  }
28839
- const dist = Math.max(Math.abs(lastX - event.point.x), Math.abs(lastY - event.point.y));
28490
+ const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
28840
28491
  if (dist >= MIN_DISTANCE) {
28841
28492
  this.pointCount += 1;
28842
- const nativeEvent = event.event;
28843
- const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
28844
- this.pendingPoints.push(event.point.x, event.point.y, pressure);
28845
- if (!this.flushRafId) {
28846
- this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
28847
- }
28493
+ this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
28848
28494
  }
28849
28495
  }
28850
28496
  }
28851
28497
  onMouseUp(event) {
28852
- if (this.flushRafId) {
28853
- cancelAnimationFrame(this.flushRafId);
28854
- this.flushRafId = 0;
28855
- }
28856
- this.flushPendingPoints();
28857
28498
  this.modelGetter().then((model) => {
28858
28499
  if (!model) {
28859
28500
  return;
@@ -28954,7 +28595,7 @@ var RectangleTool = class extends WhiteboardTool {
28954
28595
 
28955
28596
  // src/model/ToolbarModel.ts
28956
28597
  import EventEmitter2 from "eventemitter3";
28957
- import { removeObserver as removeObserver4 } from "@netless/forge-room";
28598
+ import { removeObserver as removeObserver3 } from "@netless/forge-room";
28958
28599
  function _defineProperty21(e, r, t) {
28959
28600
  return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
28960
28601
  }
@@ -29051,7 +28692,7 @@ var ToolbarModel = class extends EventEmitter2 {
29051
28692
  });
29052
28693
  }
29053
28694
  dispose() {
29054
- removeObserver4(this.root, this.handleRootUpdate);
28695
+ removeObserver3(this.root, this.handleRootUpdate);
29055
28696
  this.removeAllListeners();
29056
28697
  }
29057
28698
  };
@@ -29985,7 +29626,6 @@ var Editor = class extends EventEmitter5 {
29985
29626
  this.shadowContainer.remove();
29986
29627
  this.shadowScope.project.activeLayer.addChild(this.shadowContainer);
29987
29628
  this.targets.forEach((model) => {
29988
- console.log("[][][] translateShadow model", model.root._dEH);
29989
29629
  model.shadow = this.shadowContainer.data.uuid;
29990
29630
  });
29991
29631
  }
@@ -30212,7 +29852,7 @@ var Gesture = class extends EventEmitter6 {
30212
29852
  };
30213
29853
 
30214
29854
  // src/Camera.ts
30215
- import { removeObserver as removeObserver5 } from "@netless/forge-room";
29855
+ import { removeObserver as removeObserver4 } from "@netless/forge-room";
30216
29856
  function _defineProperty28(e, r, t) {
30217
29857
  return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
30218
29858
  }
@@ -30289,14 +29929,14 @@ var Camera = class extends EventEmitter7 {
30289
29929
  }
30290
29930
  const cb = this.observers.get(user.id);
30291
29931
  if (cb) {
30292
- removeObserver5(this.requestUserMap(user.id), cb);
29932
+ removeObserver4(this.requestUserMap(user.id), cb);
30293
29933
  }
30294
29934
  });
30295
29935
  _defineProperty28(this, "handleUserJoin", (user) => {
30296
29936
  if (this.observers.has(user.id)) {
30297
29937
  const cb = this.observers.get(user.id);
30298
29938
  if (cb) {
30299
- removeObserver5(this.requestUserMap(user.id), cb);
29939
+ removeObserver4(this.requestUserMap(user.id), cb);
30300
29940
  this.observers.delete(user.id);
30301
29941
  }
30302
29942
  }
@@ -30408,7 +30048,7 @@ var Camera = class extends EventEmitter7 {
30408
30048
  this.handleViewMatrixUpdate(userId, evt);
30409
30049
  };
30410
30050
  if (this.observers.has(userId)) {
30411
- removeObserver5(this.requestUserMap(userId), observer);
30051
+ removeObserver4(this.requestUserMap(userId), observer);
30412
30052
  }
30413
30053
  this.requestUserMap(userId).observe(observer);
30414
30054
  this.observers.set(userId, observer);
@@ -30605,10 +30245,10 @@ var Camera = class extends EventEmitter7 {
30605
30245
  Array.from(this.observers.keys()).forEach((userId) => {
30606
30246
  const cb = this.observers.get(userId);
30607
30247
  if (cb) {
30608
- removeObserver5(this.requestUserMap(userId), cb);
30248
+ removeObserver4(this.requestUserMap(userId), cb);
30609
30249
  }
30610
30250
  });
30611
- removeObserver5(this.whiteboardAttrsMap, this.handleMainCameraChange);
30251
+ removeObserver4(this.whiteboardAttrsMap, this.handleMainCameraChange);
30612
30252
  this.userManager.off("join", this.handleUserJoin);
30613
30253
  this.userManager.off("leave", this.handleUserLeave);
30614
30254
  this.gesture.removeAllListeners();
@@ -30779,8 +30419,6 @@ var Whiteboard = class extends EventEmitter8 {
30779
30419
  _defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
30780
30420
  _defineProperty31(this, "getElementAttribute", void 0);
30781
30421
  _defineProperty31(this, "setElementAttribute", void 0);
30782
- _defineProperty31(this, "setPerformanceMode", void 0);
30783
- _defineProperty31(this, "isPerformanceMode", void 0);
30784
30422
  _defineProperty31(this, "removeElement", void 0);
30785
30423
  _defineProperty31(this, "getCurrentTool", void 0);
30786
30424
  _defineProperty31(this, "setCurrentTool", void 0);
@@ -31079,24 +30717,9 @@ var LaserPointerTool = class extends WhiteboardTool {
31079
30717
  if (this.pointCount > 1024) {
31080
30718
  return;
31081
30719
  }
31082
- const MIN_DISTANCE = 4;
31083
30720
  if (this.elementModel) {
31084
- const len = this.elementModel.points.length;
31085
- let last = {
31086
- x: 0,
31087
- y: 0
31088
- };
31089
- if (len >= 2) {
31090
- last = {
31091
- x: this.elementModel.points[len - 2],
31092
- y: this.elementModel.points[len - 1]
31093
- };
31094
- }
31095
- const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
31096
- if (dist >= MIN_DISTANCE) {
31097
- this.pointCount += 1;
31098
- this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
31099
- }
30721
+ this.pointCount += 1;
30722
+ this.elementModel.appendPoints([event.point.x, event.point.y]);
31100
30723
  }
31101
30724
  }
31102
30725
  onMouseUp(_event) {
@@ -31108,7 +30731,7 @@ var LaserPointerTool = class extends WhiteboardTool {
31108
30731
 
31109
30732
  // src/model/PageModel.ts
31110
30733
  import EventEmitter10 from "eventemitter3";
31111
- import { log as log2, removeObserver as removeObserver6 } from "@netless/forge-room";
30734
+ import { log as log2, removeObserver as removeObserver5 } from "@netless/forge-room";
31112
30735
  function _defineProperty35(e, r, t) {
31113
30736
  return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
31114
30737
  }
@@ -31141,7 +30764,7 @@ var PageModel = class extends EventEmitter10 {
31141
30764
  }
31142
30765
  const cb = this.observers.get(user.id);
31143
30766
  if (cb) {
31144
- removeObserver6(this.requestUserMap(user.id), cb);
30767
+ removeObserver5(this.requestUserMap(user.id), cb);
31145
30768
  }
31146
30769
  });
31147
30770
  _defineProperty35(this, "handleUserJoin", (user) => {
@@ -31202,7 +30825,7 @@ var PageModel = class extends EventEmitter10 {
31202
30825
  if (this.observers.has(userId)) {
31203
30826
  const cb = this.observers.get(userId);
31204
30827
  if (cb) {
31205
- removeObserver6(this.requestUserMap(userId), cb);
30828
+ removeObserver5(this.requestUserMap(userId), cb);
31206
30829
  this.observers.delete(userId);
31207
30830
  }
31208
30831
  }
@@ -31291,12 +30914,12 @@ var PageModel = class extends EventEmitter10 {
31291
30914
  dispose() {
31292
30915
  for (const entry of this.observers.entries()) {
31293
30916
  const [userId, observer] = entry;
31294
- removeObserver6(this.requestUserMap(userId), observer);
30917
+ removeObserver5(this.requestUserMap(userId), observer);
31295
30918
  }
31296
30919
  this.userManager.off("join", this.handleUserJoin);
31297
30920
  this.userManager.off("leave", this.handleUserLeave);
31298
- removeObserver6(this.whiteboardAttrsMap, this.handleMainPageChange);
31299
- removeObserver6(this.pageMap, this.handlePageMapChange);
30921
+ removeObserver5(this.whiteboardAttrsMap, this.handleMainPageChange);
30922
+ removeObserver5(this.pageMap, this.handlePageMapChange);
31300
30923
  }
31301
30924
  };
31302
30925
 
@@ -31312,7 +30935,7 @@ async function waitUntil(fn, timeout) {
31312
30935
  // src/IndexedNavigation.ts
31313
30936
  import EventEmitter11 from "eventemitter3";
31314
30937
  import { log as log3 } from "@netless/forge-room";
31315
- import { removeObserver as removeObserver7 } from "@netless/forge-room";
30938
+ import { removeObserver as removeObserver6 } from "@netless/forge-room";
31316
30939
  function _defineProperty36(e, r, t) {
31317
30940
  return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
31318
30941
  }
@@ -31655,7 +31278,7 @@ var IndexedNavigation = class extends EventEmitter11 {
31655
31278
  }
31656
31279
  }
31657
31280
  dispose() {
31658
- removeObserver7(this.indexedPageMap, this.handleIndexedPageMapUpdate);
31281
+ removeObserver6(this.indexedPageMap, this.handleIndexedPageMapUpdate);
31659
31282
  this.pageModel.off("switchPage");
31660
31283
  this.pageModel.off("pagesChange");
31661
31284
  }
@@ -31876,7 +31499,7 @@ var SequenceExecutor = class {
31876
31499
  };
31877
31500
 
31878
31501
  // src/WhiteboardApplication.ts
31879
- import { removeObserver as removeObserver8 } from "@netless/forge-room";
31502
+ import { removeObserver as removeObserver7 } from "@netless/forge-room";
31880
31503
 
31881
31504
  // src/LiveCursor.ts
31882
31505
  function _defineProperty42(e, r, t) {
@@ -31931,19 +31554,9 @@ var LiveCursor = class {
31931
31554
  cursor.style.fontSize = "12px";
31932
31555
  cursor.style.padding = "2px 4px";
31933
31556
  cursor.style.borderRadius = "4px";
31934
- this.updateCursorLabel(userId, cursor);
31557
+ cursor.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
31935
31558
  return cursor;
31936
31559
  }
31937
- updateCursorLabel(userId, cursor) {
31938
- const target = cursor ?? this.cursors.get(userId);
31939
- if (!target) {
31940
- return;
31941
- }
31942
- if (target.textContent && target.textContent !== userId) {
31943
- return;
31944
- }
31945
- target.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
31946
- }
31947
31560
  isOnSamePage(userId) {
31948
31561
  const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
31949
31562
  const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
@@ -31979,7 +31592,6 @@ var LiveCursor = class {
31979
31592
  }
31980
31593
  const cursor = this.cursors.get(userId);
31981
31594
  if (cursor) {
31982
- this.updateCursorLabel(userId, cursor);
31983
31595
  const viewPoint = this.paperScope.project.view.projectToView(point);
31984
31596
  cursor.style.left = viewPoint.x + "px";
31985
31597
  cursor.style.top = viewPoint.y + "px";
@@ -32095,7 +31707,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32095
31707
  _defineProperty43(this, "permissions", void 0);
32096
31708
  _defineProperty43(this, "inputType", "any");
32097
31709
  _defineProperty43(this, "isPenEvent", false);
32098
- _defineProperty43(this, "activePenPointerId", null);
32099
31710
  _defineProperty43(this, "hasPenInput", null);
32100
31711
  _defineProperty43(this, "disableViewModelUpdate", false);
32101
31712
  _defineProperty43(this, "internalResizeObserver", true);
@@ -32212,9 +31823,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32212
31823
  _defineProperty43(this, "hasPermission", (flag) => {
32213
31824
  return this.permissions.hasPermission(flag, this.userId);
32214
31825
  });
32215
- _defineProperty43(this, "isPerformanceMode", () => {
32216
- return this.option.performance ?? false;
32217
- });
32218
31826
  _defineProperty43(this, "handleStackItemAdded", () => {
32219
31827
  this.selectElementsModel.clearSelectElementForSelf();
32220
31828
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
@@ -32229,18 +31837,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32229
31837
  const id = ids[i];
32230
31838
  if (!this.layers.has(id)) {
32231
31839
  const elementsMap = this.getMap(`layer/${id}/elements`);
32232
- const renderableModel = new RenderableModel({
32233
- layerId: id,
32234
- shadowEmitter: this.shadowEmitter,
32235
- elements: elementsMap,
32236
- scope: this.paperScope,
32237
- toolbarModel: this.toolbarModel,
32238
- userManager: this.userManager,
32239
- imageSets: this.imageSets,
32240
- liveCursor: this.liveCursor,
32241
- hasPermission: this.hasPermission,
32242
- isPerformanceMode: this.isPerformanceMode
32243
- });
31840
+ const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
32244
31841
  this.layers.set(id, renderableModel);
32245
31842
  }
32246
31843
  if (!this.undoManagers.has(id)) {
@@ -32424,34 +32021,11 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32424
32021
  this.imageSets.setAttribute("data-image-sets", "");
32425
32022
  this.rootElement.appendChild(this.imageSets);
32426
32023
  document.body.addEventListener("pointerdown", (evt) => {
32427
- if (evt.pointerType === "pen") {
32428
- this.isPenEvent = true;
32429
- this.activePenPointerId = evt.pointerId;
32430
- if (this.hasPenInput === null) {
32431
- this.hasPenInput = true;
32432
- this.inputType = "pen";
32433
- this.emitter.emit("inputTypeChange", this.inputType);
32434
- }
32435
- } else {
32436
- if (this.activePenPointerId === null) {
32437
- this.isPenEvent = false;
32438
- }
32439
- }
32440
- }, {
32441
- capture: true
32442
- });
32443
- document.body.addEventListener("pointerup", (evt) => {
32444
- if (evt.pointerId === this.activePenPointerId) {
32445
- this.activePenPointerId = null;
32446
- this.isPenEvent = false;
32447
- }
32448
- }, {
32449
- capture: true
32450
- });
32451
- document.body.addEventListener("pointercancel", (evt) => {
32452
- if (evt.pointerId === this.activePenPointerId) {
32453
- this.activePenPointerId = null;
32454
- this.isPenEvent = false;
32024
+ this.isPenEvent = evt.pointerType === "pen";
32025
+ if (evt.pointerType === "pen" && this.hasPenInput === null) {
32026
+ this.hasPenInput = true;
32027
+ this.inputType = "pen";
32028
+ this.emitter.emit("inputTypeChange", this.inputType);
32455
32029
  }
32456
32030
  }, {
32457
32031
  capture: true
@@ -32530,12 +32104,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32530
32104
  this.camera.resetViewMatrixToFlow(flowId);
32531
32105
  }
32532
32106
  };
32533
- this.emitter.setPerformanceMode = (enabled) => {
32534
- this.option.performance = enabled;
32535
- };
32536
- this.emitter.isPerformanceMode = () => {
32537
- return this.isPerformanceMode();
32538
- };
32539
32107
  this.emitter.setViewModeToMain = (userId) => {
32540
32108
  if (that.disableViewModelUpdate) {
32541
32109
  console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
@@ -32590,18 +32158,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32590
32158
  const source = this.getMap(`layer/${sourceId}/elements`);
32591
32159
  const target = this.getMap(`layer/${targetId}/elements`);
32592
32160
  if (!this.layers.has(targetId)) {
32593
- this.layers.set(targetId, new RenderableModel({
32594
- layerId: targetId,
32595
- shadowEmitter: this.shadowEmitter,
32596
- elements: target,
32597
- scope: this.paperScope,
32598
- toolbarModel: this.toolbarModel,
32599
- userManager: this.userManager,
32600
- imageSets: this.imageSets,
32601
- liveCursor: this.liveCursor,
32602
- hasPermission: this.hasPermission,
32603
- isPerformanceMode: this.isPerformanceMode
32604
- }));
32161
+ this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
32605
32162
  }
32606
32163
  if (!this.undoManagers.has(targetId)) {
32607
32164
  const undoManager = new Y15.UndoManager(target, {
@@ -32836,11 +32393,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
32836
32393
  this.editors.forEach((editor) => {
32837
32394
  editor.updateBounds();
32838
32395
  });
32839
- const area = this.paperScope.project.view.size.width * this.paperScope.project.view.size.height;
32840
- const minDistance = Math.ceil(area / 4e5);
32841
- Object.keys(this.tools).forEach((key) => {
32842
- this.tools[key].tool.minDistance = minDistance;
32843
- });
32844
32396
  });
32845
32397
  this.camera.on("userPageChange", (userId, pageId) => {
32846
32398
  this.emitter.emit("activePageChange", userId, pageId);
@@ -33189,7 +32741,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
33189
32741
  this.toolbarModel.dispose();
33190
32742
  this.emitter.indexedNavigation.dispose();
33191
32743
  this.permissions.dispose();
33192
- removeObserver8(this.userMap(this.userId), this.handleSyncedWhiteboardStatusChange);
32744
+ removeObserver7(this.userMap(this.userId), this.handleSyncedWhiteboardStatusChange);
33193
32745
  log4(`whiteboard ${this.appId} disposed. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
33194
32746
  }
33195
32747
  };