@netless/forge-slide 1.1.0-beta.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/slide.js CHANGED
@@ -56174,8 +56174,8 @@ var require_lodash = __commonJS2({
56174
56174
  }
56175
56175
  var runInContext = function runInContext2(context) {
56176
56176
  context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
56177
- 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;
56178
- var arrayProto = Array13.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
56177
+ 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;
56178
+ var arrayProto = Array14.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
56179
56179
  var coreJsData = context["__core-js_shared__"];
56180
56180
  var funcToString = funcProto.toString;
56181
56181
  var hasOwnProperty = objectProto.hasOwnProperty;
@@ -56598,7 +56598,7 @@ var require_lodash = __commonJS2({
56598
56598
  }
56599
56599
  }
56600
56600
  function baseAt(object, paths) {
56601
- var index = -1, length = paths.length, result2 = Array13(length), skip = object == null;
56601
+ var index = -1, length = paths.length, result2 = Array14(length), skip = object == null;
56602
56602
  while (++index < length) {
56603
56603
  result2[index] = skip ? undefined2 : get(object, paths[index]);
56604
56604
  }
@@ -56844,7 +56844,7 @@ var require_lodash = __commonJS2({
56844
56844
  return number >= nativeMin(start, end) && number < nativeMax(start, end);
56845
56845
  }
56846
56846
  function baseIntersection(arrays, iteratee2, comparator) {
56847
- var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array13(othLength), maxLength = Infinity, result2 = [];
56847
+ var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array14(othLength), maxLength = Infinity, result2 = [];
56848
56848
  while (othIndex--) {
56849
56849
  var array = arrays[othIndex];
56850
56850
  if (othIndex && iteratee2) {
@@ -57025,7 +57025,7 @@ var require_lodash = __commonJS2({
57025
57025
  return value < other;
57026
57026
  }
57027
57027
  function baseMap(collection, iteratee2) {
57028
- var index = -1, result2 = isArrayLike(collection) ? Array13(collection.length) : [];
57028
+ var index = -1, result2 = isArrayLike(collection) ? Array14(collection.length) : [];
57029
57029
  baseEach(collection, function(value, key, collection2) {
57030
57030
  result2[++index] = iteratee2(value, key, collection2);
57031
57031
  });
@@ -57200,7 +57200,7 @@ var require_lodash = __commonJS2({
57200
57200
  return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
57201
57201
  }
57202
57202
  function baseRange(start, end, step, fromRight) {
57203
- var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array13(length);
57203
+ var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array14(length);
57204
57204
  while (length--) {
57205
57205
  result2[fromRight ? length : ++index] = start;
57206
57206
  start += step;
@@ -57282,7 +57282,7 @@ var require_lodash = __commonJS2({
57282
57282
  }
57283
57283
  length = start > end ? 0 : end - start >>> 0;
57284
57284
  start >>>= 0;
57285
- var result2 = Array13(length);
57285
+ var result2 = Array14(length);
57286
57286
  while (++index < length) {
57287
57287
  result2[index] = array[index + start];
57288
57288
  }
@@ -57442,7 +57442,7 @@ var require_lodash = __commonJS2({
57442
57442
  if (length < 2) {
57443
57443
  return length ? baseUniq(arrays[0]) : [];
57444
57444
  }
57445
- var index = -1, result2 = Array13(length);
57445
+ var index = -1, result2 = Array14(length);
57446
57446
  while (++index < length) {
57447
57447
  var array = arrays[index], othIndex = -1;
57448
57448
  while (++othIndex < length) {
@@ -57539,7 +57539,7 @@ var require_lodash = __commonJS2({
57539
57539
  return object.index - other.index;
57540
57540
  }
57541
57541
  function composeArgs(args, partials, holders, isCurried) {
57542
- 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;
57542
+ 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;
57543
57543
  while (++leftIndex < leftLength) {
57544
57544
  result2[leftIndex] = partials[leftIndex];
57545
57545
  }
@@ -57554,7 +57554,7 @@ var require_lodash = __commonJS2({
57554
57554
  return result2;
57555
57555
  }
57556
57556
  function composeArgsRight(args, partials, holders, isCurried) {
57557
- 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;
57557
+ 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;
57558
57558
  while (++argsIndex < rangeLength) {
57559
57559
  result2[argsIndex] = args[argsIndex];
57560
57560
  }
@@ -57571,7 +57571,7 @@ var require_lodash = __commonJS2({
57571
57571
  }
57572
57572
  function copyArray(source, array) {
57573
57573
  var index = -1, length = source.length;
57574
- array || (array = Array13(length));
57574
+ array || (array = Array14(length));
57575
57575
  while (++index < length) {
57576
57576
  array[index] = source[index];
57577
57577
  }
@@ -57704,7 +57704,7 @@ var require_lodash = __commonJS2({
57704
57704
  function createCurry(func, bitmask, arity) {
57705
57705
  var Ctor = createCtor(func);
57706
57706
  function wrapper() {
57707
- var length = arguments.length, args = Array13(length), index = length, placeholder = getHolder(wrapper);
57707
+ var length = arguments.length, args = Array14(length), index = length, placeholder = getHolder(wrapper);
57708
57708
  while (index--) {
57709
57709
  args[index] = arguments[index];
57710
57710
  }
@@ -57784,7 +57784,7 @@ var require_lodash = __commonJS2({
57784
57784
  function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
57785
57785
  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);
57786
57786
  function wrapper() {
57787
- var length = arguments.length, args = Array13(length), index = length;
57787
+ var length = arguments.length, args = Array14(length), index = length;
57788
57788
  while (index--) {
57789
57789
  args[index] = arguments[index];
57790
57790
  }
@@ -57883,7 +57883,7 @@ var require_lodash = __commonJS2({
57883
57883
  function createPartial(func, bitmask, thisArg, partials) {
57884
57884
  var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
57885
57885
  function wrapper() {
57886
- var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array13(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
57886
+ var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array14(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
57887
57887
  while (++leftIndex < leftLength) {
57888
57888
  args[leftIndex] = partials[leftIndex];
57889
57889
  }
@@ -58496,12 +58496,12 @@ var require_lodash = __commonJS2({
58496
58496
  function overRest(func, start, transform2) {
58497
58497
  start = nativeMax(start === undefined2 ? func.length - 1 : start, 0);
58498
58498
  return function() {
58499
- var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array13(length);
58499
+ var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array14(length);
58500
58500
  while (++index < length) {
58501
58501
  array[index] = args[start + index];
58502
58502
  }
58503
58503
  index = -1;
58504
- var otherArgs = Array13(start + 1);
58504
+ var otherArgs = Array14(start + 1);
58505
58505
  while (++index < start) {
58506
58506
  otherArgs[index] = args[index];
58507
58507
  }
@@ -58623,7 +58623,7 @@ var require_lodash = __commonJS2({
58623
58623
  if (!length || size2 < 1) {
58624
58624
  return [];
58625
58625
  }
58626
- var index = 0, resIndex = 0, result2 = Array13(nativeCeil(length / size2));
58626
+ var index = 0, resIndex = 0, result2 = Array14(nativeCeil(length / size2));
58627
58627
  while (index < length) {
58628
58628
  result2[resIndex++] = baseSlice(array, index, index += size2);
58629
58629
  }
@@ -58644,7 +58644,7 @@ var require_lodash = __commonJS2({
58644
58644
  if (!length) {
58645
58645
  return [];
58646
58646
  }
58647
- var args = Array13(length - 1), array = arguments[0], index = length;
58647
+ var args = Array14(length - 1), array = arguments[0], index = length;
58648
58648
  while (index--) {
58649
58649
  args[index - 1] = arguments[index];
58650
58650
  }
@@ -59146,7 +59146,7 @@ var require_lodash = __commonJS2({
59146
59146
  return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
59147
59147
  }
59148
59148
  var invokeMap = baseRest(function(collection, path, args) {
59149
- var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array13(collection.length) : [];
59149
+ var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array14(collection.length) : [];
59150
59150
  baseEach(collection, function(value) {
59151
59151
  result2[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
59152
59152
  });
@@ -59529,7 +59529,7 @@ var require_lodash = __commonJS2({
59529
59529
  }()) ? baseIsArguments : function(value) {
59530
59530
  return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
59531
59531
  };
59532
- var isArray = Array13.isArray;
59532
+ var isArray = Array14.isArray;
59533
59533
  var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
59534
59534
  function isArrayLike(value) {
59535
59535
  return value != null && isLength(value.length) && !isFunction(value);
@@ -61194,12 +61194,23 @@ var ElementModel = class _ElementModel {
61194
61194
  set shadow(value) {
61195
61195
  this.root.set(_ElementModel.KEYS.shadow, value);
61196
61196
  }
61197
- constructor(root, scope, liveCursor) {
61197
+ get isPerformanceEnvironment() {
61198
+ return this.isPerformanceMode() && this.shouldUseLocalPoints;
61199
+ }
61200
+ constructor(root, scope, liveCursor, isPerformanceMode) {
61198
61201
  _defineProperty(this, "shadowEmitter", null);
61199
61202
  _defineProperty(this, "root", void 0);
61200
61203
  _defineProperty(this, "scope", void 0);
61201
61204
  _defineProperty(this, "item", void 0);
61205
+ _defineProperty(this, "clearLocalPointsWhenYPointsChange", void 0);
61206
+ _defineProperty(this, "shouldUseLocalPoints", void 0);
61207
+ _defineProperty(this, "localPointsPick", void 0);
61202
61208
  _defineProperty(this, "liveCursor", void 0);
61209
+ _defineProperty(this, "appendPointsTimer", null);
61210
+ _defineProperty(this, "setPointsTimer", null);
61211
+ _defineProperty(this, "pointsUpdateTimer", null);
61212
+ _defineProperty(this, "isPerformanceMode", void 0);
61213
+ _defineProperty(this, "localPoints", []);
61203
61214
  _defineProperty(this, "handlePropChange", (events) => {
61204
61215
  if (!this.item) {
61205
61216
  return;
@@ -61238,24 +61249,68 @@ var ElementModel = class _ElementModel {
61238
61249
  }
61239
61250
  }
61240
61251
  } else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
61241
- this.onVectorUpdate();
61242
- const liveCursorPoint = this.liveCursorPoint();
61243
- const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
61244
- if (liveCursorPoint && ownerId) {
61245
- this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
61252
+ if (this.isPerformanceEnvironment) {
61253
+ this.handlePointsChangePerformance();
61254
+ } else {
61255
+ this.handlePointsChangeDirect();
61246
61256
  }
61247
61257
  } else {
61248
61258
  }
61249
61259
  }
61250
61260
  });
61261
+ _defineProperty(this, "onPointsArrayChange", (points) => {
61262
+ if (this.localPoints.length >= points.length) {
61263
+ return;
61264
+ }
61265
+ const pointsChunk = points.slice(this.localPoints.length, this.localPoints.length + this.localPointsPick);
61266
+ this.localPoints = this.localPoints.concat(pointsChunk);
61267
+ this.onVectorUpdate();
61268
+ this.pointsUpdateTimer = window.requestAnimationFrame(() => {
61269
+ this.onPointsArrayChange(points);
61270
+ });
61271
+ });
61272
+ this.isPerformanceMode = isPerformanceMode;
61251
61273
  this.scope = scope;
61252
61274
  this.liveCursor = liveCursor;
61253
61275
  this.root = root;
61254
- if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
61276
+ if (this.root.doc) {
61277
+ if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
61278
+ this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
61279
+ }
61280
+ } else {
61255
61281
  this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
61256
61282
  }
61257
61283
  this.root.observeDeep(this.handlePropChange);
61258
61284
  }
61285
+ handlePointsChangeDirect() {
61286
+ this.onVectorUpdate();
61287
+ const liveCursorPoint = this.liveCursorPoint();
61288
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
61289
+ if (liveCursorPoint && ownerId) {
61290
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
61291
+ }
61292
+ }
61293
+ handlePointsChangePerformance() {
61294
+ const liveCursorPoint = this.liveCursorPoint();
61295
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
61296
+ if (liveCursorPoint && ownerId) {
61297
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
61298
+ }
61299
+ if (this.liveCursor.userManager.selfId !== ownerId || this.localPoints.length === 0) {
61300
+ if (this.pointsUpdateTimer) {
61301
+ window.cancelAnimationFrame(this.pointsUpdateTimer);
61302
+ }
61303
+ if (this.shadow == "") {
61304
+ this.localPoints = this.points;
61305
+ this.onVectorUpdate();
61306
+ } else {
61307
+ if (this.clearLocalPointsWhenYPointsChange) {
61308
+ this.localPoints = [];
61309
+ }
61310
+ this.onPointsArrayChange(this.points);
61311
+ }
61312
+ }
61313
+ }
61259
61314
  createPaperElement() {
61260
61315
  this.createPaperItem();
61261
61316
  if (this.item) {
@@ -61267,14 +61322,48 @@ var ElementModel = class _ElementModel {
61267
61322
  }
61268
61323
  }
61269
61324
  appendPoints(points) {
61325
+ if (this.isPerformanceEnvironment) {
61326
+ this.appendPointsPerformance(points);
61327
+ } else {
61328
+ this.appendPointsDirect(points);
61329
+ }
61330
+ }
61331
+ appendPointsDirect(points) {
61270
61332
  this.root.get(_ElementModel.KEYS.points).push(points);
61271
61333
  }
61334
+ appendPointsPerformance(points) {
61335
+ this.localPoints = this.localPoints.concat(points);
61336
+ this.onVectorUpdate();
61337
+ if (this.appendPointsTimer) {
61338
+ window.clearTimeout(this.appendPointsTimer);
61339
+ }
61340
+ if (this.localPoints.length % 80 === 0) {
61341
+ const yArray = this.root.get(_ElementModel.KEYS.points);
61342
+ yArray?.push(this.localPoints.slice(yArray.length));
61343
+ }
61344
+ this.appendPointsTimer = window.setTimeout(() => {
61345
+ this.appendPointsTimer = null;
61346
+ if (this.localPoints.length > 0) {
61347
+ const yArray = this.root.get(_ElementModel.KEYS.points);
61348
+ yArray?.push(this.localPoints.slice(yArray.length));
61349
+ }
61350
+ }, 100);
61351
+ }
61272
61352
  setPoints(points) {
61353
+ if (this.isPerformanceEnvironment) {
61354
+ this.setPointsPerformance(points);
61355
+ } else {
61356
+ this.setPointsDirect(points);
61357
+ }
61358
+ }
61359
+ setPointsDirect(points) {
61273
61360
  if (this.root.doc) {
61274
61361
  this.root.doc.transact(() => {
61275
61362
  const yArray = this.root.get(_ElementModel.KEYS.points);
61276
- yArray.delete(0, yArray.length);
61277
- yArray.push(points);
61363
+ if (yArray) {
61364
+ yArray.delete(0, yArray.length);
61365
+ yArray.push(points);
61366
+ }
61278
61367
  });
61279
61368
  } else {
61280
61369
  const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
@@ -61283,6 +61372,29 @@ var ElementModel = class _ElementModel {
61283
61372
  this.root.set(_ElementModel.KEYS.points, yArray);
61284
61373
  }
61285
61374
  }
61375
+ setPointsPerformance(points) {
61376
+ this.localPoints = points;
61377
+ this.onVectorUpdate();
61378
+ if (this.setPointsTimer) {
61379
+ window.clearTimeout(this.setPointsTimer);
61380
+ }
61381
+ this.setPointsTimer = window.setTimeout(() => {
61382
+ if (this.root.doc) {
61383
+ this.root.doc.transact(() => {
61384
+ const yArray = this.root.get(_ElementModel.KEYS.points);
61385
+ if (yArray) {
61386
+ yArray.delete(0, yArray.length);
61387
+ yArray.push(points);
61388
+ }
61389
+ });
61390
+ } else {
61391
+ const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
61392
+ yArray.delete(0, yArray.length);
61393
+ yArray.push(points);
61394
+ this.root.set(_ElementModel.KEYS.points, yArray);
61395
+ }
61396
+ }, 100);
61397
+ }
61286
61398
  appendPointsMatrix(matrix) {
61287
61399
  const current = new this.scope.Matrix(this.pointsMatrix);
61288
61400
  const next = matrix.appended(current);
@@ -61377,15 +61489,18 @@ function _toPrimitive3(t, r) {
61377
61489
  return ("string" === r ? String : Number)(t);
61378
61490
  }
61379
61491
  var CurveModel = class extends ElementModel {
61380
- constructor(root, scope, liveCursor) {
61381
- super(root, scope, liveCursor);
61492
+ constructor(root, scope, liveCursor, isPerformanceMode) {
61493
+ super(root, scope, liveCursor, isPerformanceMode);
61382
61494
  _defineProperty3(this, "item", null);
61383
61495
  _defineProperty3(this, "debugPath", void 0);
61384
61496
  _defineProperty3(this, "debug", false);
61385
- if (!this.root.has("type")) {
61497
+ _defineProperty3(this, "clearLocalPointsWhenYPointsChange", false);
61498
+ _defineProperty3(this, "shouldUseLocalPoints", true);
61499
+ _defineProperty3(this, "localPointsPick", 4);
61500
+ if (!this.root.doc || !this.root.has("type")) {
61386
61501
  this.root.set("type", "curve");
61387
61502
  }
61388
- if (!this.root.has("points")) {
61503
+ if (!this.root.doc || !this.root.has("points")) {
61389
61504
  this.root.set("points", new Y2.Array());
61390
61505
  }
61391
61506
  this.debugPath = new scope.Path();
@@ -61411,7 +61526,7 @@ var CurveModel = class extends ElementModel {
61411
61526
  });
61412
61527
  }
61413
61528
  matrixedPoints() {
61414
- const points = this.points;
61529
+ const points = this.localPoints.length === 0 ? this.points : this.localPoints;
61415
61530
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61416
61531
  const output = [];
61417
61532
  for (let i = 0, len = points.length; i < len; i += 2) {
@@ -61535,15 +61650,24 @@ function _toPrimitive4(t, r) {
61535
61650
  return ("string" === r ? String : Number)(t);
61536
61651
  }
61537
61652
  var SelectorModel = class extends ElementModel {
61538
- constructor(root, scope, liveCursor) {
61539
- super(root, scope, liveCursor);
61653
+ get drawPoints() {
61654
+ if (this.localPoints.length >= 4) {
61655
+ return this.localPoints;
61656
+ }
61657
+ return this.points;
61658
+ }
61659
+ constructor(root, scope, liveCursor, isPerformanceMode) {
61660
+ super(root, scope, liveCursor, isPerformanceMode);
61540
61661
  _defineProperty4(this, "item", null);
61541
- if (!this.root.has("type")) {
61662
+ _defineProperty4(this, "clearLocalPointsWhenYPointsChange", true);
61663
+ _defineProperty4(this, "shouldUseLocalPoints", true);
61664
+ _defineProperty4(this, "localPointsPick", 4);
61665
+ if (this.root.doc && !this.root.has("type")) {
61542
61666
  this.root.set("type", "selector");
61543
61667
  }
61544
- if (!this.root.has("points")) {
61668
+ if (this.root.doc && !this.root.has("points")) {
61545
61669
  const initPoints = new Y3.Array();
61546
- initPoints.push([0, 0, 0, 0, 0]);
61670
+ initPoints.push([0, 0, 0, 0]);
61547
61671
  this.root.set("points", initPoints);
61548
61672
  }
61549
61673
  }
@@ -61554,8 +61678,8 @@ var SelectorModel = class extends ElementModel {
61554
61678
  }
61555
61679
  createPaperRect() {
61556
61680
  const scope = this.scope;
61557
- const bounds = new scope.Rectangle(new scope.Point(this.points[0], this.points[1]), new scope.Size(this.points[2], this.points[3]));
61558
- return new scope.Path.Rectangle(bounds, new scope.Point(this.points[4], this.points[4]));
61681
+ const bounds = new scope.Rectangle(new scope.Point(this.drawPoints[0], this.drawPoints[1]), new scope.Size(this.drawPoints[2], this.drawPoints[3]));
61682
+ return new scope.Path.Rectangle(bounds);
61559
61683
  }
61560
61684
  onVectorUpdate() {
61561
61685
  if (!this.item) {
@@ -61669,13 +61793,22 @@ function _toPrimitive6(t, r) {
61669
61793
  return ("string" === r ? String : Number)(t);
61670
61794
  }
61671
61795
  var SegmentsModel = class extends ElementModel {
61672
- constructor(root, scope, type, liveCursor) {
61673
- super(root, scope, liveCursor);
61796
+ get drawPoints() {
61797
+ if (this.localPoints.length >= 4) {
61798
+ return this.localPoints;
61799
+ }
61800
+ return this.points;
61801
+ }
61802
+ constructor(root, scope, type, liveCursor, isPerformanceMode) {
61803
+ super(root, scope, liveCursor, isPerformanceMode);
61674
61804
  _defineProperty6(this, "item", null);
61675
- if (!this.root.has("type")) {
61805
+ _defineProperty6(this, "clearLocalPointsWhenYPointsChange", true);
61806
+ _defineProperty6(this, "shouldUseLocalPoints", true);
61807
+ _defineProperty6(this, "localPointsPick", 24);
61808
+ if (this.root.doc && !this.root.has("type")) {
61676
61809
  this.root.set("type", type);
61677
61810
  }
61678
- if (!this.root.has("points")) {
61811
+ if (this.root.doc && !this.root.has("points")) {
61679
61812
  this.root.set("points", new Y4.Array());
61680
61813
  }
61681
61814
  }
@@ -61695,13 +61828,13 @@ var SegmentsModel = class extends ElementModel {
61695
61828
  }
61696
61829
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61697
61830
  this.item.removeSegments();
61698
- const next = deserializePath(this.points, this.scope, matrix);
61831
+ const next = deserializePath(this.drawPoints, this.scope, matrix);
61699
61832
  this.item.addSegments(next.segments);
61700
61833
  this.item.closePath();
61701
61834
  }
61702
61835
  createPaperItem() {
61703
61836
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61704
- this.item = deserializePath(this.points, this.scope, matrix);
61837
+ this.item = deserializePath(this.drawPoints, this.scope, matrix);
61705
61838
  this.item.strokeColor = new this.scope.Color(this.strokeColor);
61706
61839
  this.item.dashArray = this.dashArray;
61707
61840
  this.item.strokeWidth = this.strokeWidth;
@@ -61860,6 +61993,12 @@ function _toPrimitive9(t, r) {
61860
61993
  return ("string" === r ? String : Number)(t);
61861
61994
  }
61862
61995
  var LineModel = class extends ElementModel {
61996
+ get drawPoints() {
61997
+ if (this.localPoints.length > 0) {
61998
+ return this.localPoints;
61999
+ }
62000
+ return this.points;
62001
+ }
61863
62002
  get arrowSize() {
61864
62003
  return this.strokeWidth * 5 + 15;
61865
62004
  }
@@ -61875,20 +62014,23 @@ var LineModel = class extends ElementModel {
61875
62014
  set tailArrow(value) {
61876
62015
  this.root.set("tailArrow", value);
61877
62016
  }
61878
- constructor(root, scope, liveCursor) {
61879
- super(root, scope, liveCursor);
62017
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62018
+ super(root, scope, liveCursor, isPerformanceMode);
61880
62019
  _defineProperty9(this, "controlledPoints", []);
62020
+ _defineProperty9(this, "clearLocalPointsWhenYPointsChange", true);
62021
+ _defineProperty9(this, "shouldUseLocalPoints", true);
62022
+ _defineProperty9(this, "localPointsPick", 99);
61881
62023
  _defineProperty9(this, "item", null);
61882
- if (!this.root.has("type")) {
62024
+ if (this.root.doc && !this.root.has("type")) {
61883
62025
  this.root.set("type", "arrow");
61884
62026
  }
61885
- if (!this.root.has("points")) {
62027
+ if (this.root.doc && !this.root.has("points")) {
61886
62028
  this.root.set("points", new Y5.Array());
61887
62029
  }
61888
- if (!this.root.has("headArrow")) {
62030
+ if (this.root.doc && !this.root.has("headArrow")) {
61889
62031
  this.root.set("headArrow", "none");
61890
62032
  }
61891
- if (!this.root.has("tailArrow")) {
62033
+ if (this.root.doc && !this.root.has("tailArrow")) {
61892
62034
  this.root.set("tailArrow", "normal");
61893
62035
  }
61894
62036
  }
@@ -61904,7 +62046,7 @@ var LineModel = class extends ElementModel {
61904
62046
  }
61905
62047
  renderLine() {
61906
62048
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61907
- const papperPoints = (0, import_lodash4.chunk)(this.points, 2).map((item) => {
62049
+ const papperPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).map((item) => {
61908
62050
  return new this.scope.Point(item[0], item[1]).transform(matrix);
61909
62051
  });
61910
62052
  const path = new this.scope.Path();
@@ -62018,13 +62160,14 @@ var LineControlPoint = class {
62018
62160
  if (this.position) {
62019
62161
  return this.model.scope.project.view.projectToView(this.position.transform(matrix));
62020
62162
  }
62163
+ const points = this.model["drawPoints"];
62021
62164
  const from = {
62022
- x: this.model.points[0],
62023
- y: this.model.points[1]
62165
+ x: points[0],
62166
+ y: points[1]
62024
62167
  };
62025
62168
  const to = {
62026
- x: this.model.points[this.model.points.length - 2],
62027
- y: this.model.points[this.model.points.length - 1]
62169
+ x: points[points.length - 2],
62170
+ y: points[points.length - 1]
62028
62171
  };
62029
62172
  const clonedPath = new this.scope.Path.Line(from, to);
62030
62173
  this.position = clonedPath.getPointAt(clonedPath.length * distance);
@@ -62037,7 +62180,7 @@ var LineControlPoint = class {
62037
62180
  }
62038
62181
  const pointsMatrix = new this.model.scope.Matrix(this.model.pointsMatrix);
62039
62182
  const invertedPoint = point.transform(pointsMatrix.inverted());
62040
- const points = this.model.points;
62183
+ const points = this.model["drawPoints"];
62041
62184
  this.position = invertedPoint;
62042
62185
  const clonedPoints = (0, import_lodash4.cloneDeep)(points);
62043
62186
  clonedPoints[this.options.index * 2] = invertedPoint.x;
@@ -62081,9 +62224,18 @@ var PointTextModel = class extends ElementModel {
62081
62224
  set fontFamily(value) {
62082
62225
  this.root.set("font-family", value);
62083
62226
  }
62084
- constructor(root, scope, liveCursor) {
62085
- super(root, scope, liveCursor);
62227
+ get drawPoints() {
62228
+ if (this.localPoints.length > 1) {
62229
+ return this.localPoints;
62230
+ }
62231
+ return this.points;
62232
+ }
62233
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62234
+ super(root, scope, liveCursor, isPerformanceMode);
62086
62235
  _defineProperty10(this, "item", null);
62236
+ _defineProperty10(this, "clearLocalPointsWhenYPointsChange", true);
62237
+ _defineProperty10(this, "shouldUseLocalPoints", false);
62238
+ _defineProperty10(this, "localPointsPick", 2);
62087
62239
  _defineProperty10(this, "handleTextPropChange", (event) => {
62088
62240
  if (!this.item) {
62089
62241
  return;
@@ -62100,18 +62252,20 @@ var PointTextModel = class extends ElementModel {
62100
62252
  }
62101
62253
  }
62102
62254
  });
62103
- if (!this.root.has("type")) {
62255
+ if (this.root.doc && !this.root.has("type")) {
62104
62256
  this.root.set("type", "point-text");
62105
62257
  }
62106
- if (!this.root.has(ElementModel.KEYS.points)) {
62258
+ if (this.root.doc && !this.root.has(ElementModel.KEYS.points)) {
62107
62259
  this.root.set(ElementModel.KEYS.points, new Y6.Array());
62108
62260
  }
62109
62261
  this.root.observe(this.handleTextPropChange);
62110
- if (this.root.has("font-size")) {
62111
- setTimeout(() => {
62112
- this.updateTextPosition();
62113
- }, 60);
62114
- }
62262
+ setTimeout(() => {
62263
+ if (this.root && this.root.has("font-size")) {
62264
+ setTimeout(() => {
62265
+ this.updateTextPosition();
62266
+ }, 60);
62267
+ }
62268
+ }, 60);
62115
62269
  }
62116
62270
  subDispose() {
62117
62271
  (0, import_forge_room4.removeObserver)(this.root, this.handleTextPropChange);
@@ -62129,10 +62283,11 @@ var PointTextModel = class extends ElementModel {
62129
62283
  if (!this.item) {
62130
62284
  return null;
62131
62285
  }
62286
+ console.log("[][][] drawPoints", this.drawPoints);
62132
62287
  const bounds = this.item.internalBounds;
62133
62288
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62134
- const topLeft = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
62135
- const topRight = new this.scope.Point(this.points[0] + bounds.width, this.points[1]).transform(matrix);
62289
+ const topLeft = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
62290
+ const topRight = new this.scope.Point(this.drawPoints[0] + bounds.width, this.drawPoints[1]).transform(matrix);
62136
62291
  let scaleX = topRight.getDistance(topLeft) / bounds.width;
62137
62292
  scaleX = Number.isNaN(scaleX) ? 1 : scaleX;
62138
62293
  const angle = topRight.subtract(topLeft).angle;
@@ -62217,13 +62372,22 @@ function _toPrimitive11(t, r) {
62217
62372
  return ("string" === r ? String : Number)(t);
62218
62373
  }
62219
62374
  var TriangleModel = class extends ElementModel {
62220
- constructor(root, scope, liveCursor) {
62221
- super(root, scope, liveCursor);
62375
+ get drawPoints() {
62376
+ if (this.localPoints.length >= 6) {
62377
+ return this.localPoints;
62378
+ }
62379
+ return this.points;
62380
+ }
62381
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62382
+ super(root, scope, liveCursor, isPerformanceMode);
62222
62383
  _defineProperty11(this, "item", null);
62223
- if (!this.root.has("type")) {
62384
+ _defineProperty11(this, "clearLocalPointsWhenYPointsChange", true);
62385
+ _defineProperty11(this, "shouldUseLocalPoints", true);
62386
+ _defineProperty11(this, "localPointsPick", 6);
62387
+ if (this.root.doc && !this.root.has("type")) {
62224
62388
  this.root.set("type", "triangle");
62225
62389
  }
62226
- if (!this.root.has("points")) {
62390
+ if (this.root.doc && !this.root.has("points")) {
62227
62391
  this.root.set("points", new Y7.Array());
62228
62392
  }
62229
62393
  }
@@ -62255,9 +62419,9 @@ var TriangleModel = class extends ElementModel {
62255
62419
  return;
62256
62420
  }
62257
62421
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62258
- const p1 = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
62259
- const p2 = new this.scope.Point(this.points[2], this.points[3]).transform(matrix);
62260
- const p3 = new this.scope.Point(this.points[4], this.points[5]).transform(matrix);
62422
+ const p1 = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
62423
+ const p2 = new this.scope.Point(this.drawPoints[2], this.drawPoints[3]).transform(matrix);
62424
+ const p3 = new this.scope.Point(this.drawPoints[4], this.drawPoints[5]).transform(matrix);
62261
62425
  this.item.removeSegments();
62262
62426
  this.item.moveTo(p1);
62263
62427
  this.item.lineTo(p2);
@@ -62269,7 +62433,7 @@ var TriangleModel = class extends ElementModel {
62269
62433
  config.controlPoints.push({
62270
62434
  name: "triangle",
62271
62435
  getPosition: () => {
62272
- const point = new this.scope.Point(this.points[0], this.points[1]);
62436
+ const point = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]);
62273
62437
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62274
62438
  return this.scope.project.view.projectToView(point.transform(pointsMatrix));
62275
62439
  },
@@ -62279,7 +62443,7 @@ var TriangleModel = class extends ElementModel {
62279
62443
  }
62280
62444
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62281
62445
  const trPoint = point.transform(pointsMatrix.inverted());
62282
- const oldPoints = this.points;
62446
+ const oldPoints = this.drawPoints;
62283
62447
  this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3], oldPoints[4], oldPoints[5]]);
62284
62448
  }
62285
62449
  });
@@ -62315,25 +62479,34 @@ function _toPrimitive12(t, r) {
62315
62479
  return ("string" === r ? String : Number)(t);
62316
62480
  }
62317
62481
  var RectangleModel = class extends ElementModel {
62318
- constructor(root, scope, liveCursor) {
62319
- super(root, scope, liveCursor);
62482
+ get drawPoints() {
62483
+ if (this.localPoints.length >= 4) {
62484
+ return this.localPoints;
62485
+ }
62486
+ return this.points;
62487
+ }
62488
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62489
+ super(root, scope, liveCursor, isPerformanceMode);
62320
62490
  _defineProperty12(this, "item", null);
62321
- if (!this.root.has("type")) {
62491
+ _defineProperty12(this, "clearLocalPointsWhenYPointsChange", true);
62492
+ _defineProperty12(this, "shouldUseLocalPoints", true);
62493
+ _defineProperty12(this, "localPointsPick", 4);
62494
+ if (this.root.doc && !this.root.has("type")) {
62322
62495
  this.root.set("type", "rectangle");
62323
62496
  }
62324
- if (!this.root.has("points")) {
62497
+ if (this.root.doc && !this.root.has("points")) {
62325
62498
  const initPoints = new Y8.Array();
62326
62499
  initPoints.push([0, 0, 0, 0]);
62327
62500
  this.root.set("points", initPoints);
62328
62501
  }
62329
- if (!this.root.has("radius")) {
62502
+ if (this.root.doc && !this.root.has("radius")) {
62330
62503
  this.root.set("radius", 0);
62331
62504
  }
62332
62505
  }
62333
62506
  subDispose() {
62334
62507
  }
62335
62508
  liveCursorPoint() {
62336
- const points = this.points;
62509
+ const points = this.drawPoints;
62337
62510
  if (points.length < 4) {
62338
62511
  return null;
62339
62512
  }
@@ -62341,7 +62514,7 @@ var RectangleModel = class extends ElementModel {
62341
62514
  return new this.scope.Point(points[2], points[3]).transform(matrix);
62342
62515
  }
62343
62516
  createSegments() {
62344
- const [a2, b2, c, d] = this.points;
62517
+ const [a2, b2, c, d] = this.drawPoints;
62345
62518
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62346
62519
  const maxRadius = this.maxRadiusLength();
62347
62520
  const radius = this.root.get("radius") * maxRadius;
@@ -62406,7 +62579,7 @@ var RectangleModel = class extends ElementModel {
62406
62579
  }
62407
62580
  maxRadiusLength() {
62408
62581
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62409
- const points = this.points;
62582
+ const points = this.drawPoints;
62410
62583
  const topLeft = new this.scope.Point(points[0], points[1]).transform(pointsMatrix);
62411
62584
  const topRight = new this.scope.Point(points[2], points[1]).transform(pointsMatrix);
62412
62585
  const bottomLeft = new this.scope.Point(points[0], points[3]).transform(pointsMatrix);
@@ -62431,7 +62604,7 @@ var RectangleModel = class extends ElementModel {
62431
62604
  name: "rect-radius",
62432
62605
  getPosition: () => {
62433
62606
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62434
- const points = this.points;
62607
+ const points = this.drawPoints;
62435
62608
  const radius = this.root.get("radius") * this.maxRadiusLength();
62436
62609
  let c1 = new this.scope.Point(points[0], points[1]).transform(matrix);
62437
62610
  const c3 = new this.scope.Point(points[2], points[3]).transform(matrix);
@@ -62450,7 +62623,7 @@ var RectangleModel = class extends ElementModel {
62450
62623
  if (!this.item) {
62451
62624
  return;
62452
62625
  }
62453
- const points = this.points;
62626
+ const points = this.drawPoints;
62454
62627
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62455
62628
  const maxRadius = Math.min(points[2] - points[0], points[3] - points[1]) / 2;
62456
62629
  const trPoint = point.transform(pointsMatrix.inverted());
@@ -62494,14 +62667,23 @@ function _toPrimitive13(t, r) {
62494
62667
  return ("string" === r ? String : Number)(t);
62495
62668
  }
62496
62669
  var EraserModel = class extends ElementModel {
62497
- constructor(root, scope, liveCursor) {
62498
- super(root, scope, liveCursor);
62670
+ get drawPoints() {
62671
+ if (this.localPoints.length > 0) {
62672
+ return this.localPoints;
62673
+ }
62674
+ return this.points;
62675
+ }
62676
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62677
+ super(root, scope, liveCursor, isPerformanceMode);
62499
62678
  _defineProperty13(this, "item", null);
62500
62679
  _defineProperty13(this, "sliceBegin", 0);
62501
- if (!this.root.has("type")) {
62680
+ _defineProperty13(this, "clearLocalPointsWhenYPointsChange", false);
62681
+ _defineProperty13(this, "shouldUseLocalPoints", true);
62682
+ _defineProperty13(this, "localPointsPick", 4);
62683
+ if (this.root.doc && !this.root.has("type")) {
62502
62684
  this.root.set("type", "eraser");
62503
62685
  }
62504
- if (!this.root.has("points")) {
62686
+ if (this.root.doc && !this.root.has("points")) {
62505
62687
  this.root.set("points", new Y9.Array());
62506
62688
  }
62507
62689
  }
@@ -62552,7 +62734,7 @@ var EraserModel = class extends ElementModel {
62552
62734
  });
62553
62735
  }
62554
62736
  matrixedPoints() {
62555
- const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
62737
+ const currentPoints = (0, import_lodash5.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
62556
62738
  return currentPoints.map((_ref) => {
62557
62739
  let [x, y] = _ref;
62558
62740
  return new this.scope.Point(x, y);
@@ -62580,11 +62762,11 @@ var EraserModel = class extends ElementModel {
62580
62762
  this.item.fillColor = new this.scope.Color(this.strokeColor);
62581
62763
  this.onVectorUpdate();
62582
62764
  this.item.onFrame = () => {
62583
- if (!this.points) {
62765
+ if (!this.drawPoints) {
62584
62766
  return;
62585
62767
  }
62586
- if (this.points.length / 2 > 50) {
62587
- this.sliceBegin = this.points.length / 2 - 50;
62768
+ if (this.drawPoints.length / 2 > 50) {
62769
+ this.sliceBegin = this.drawPoints.length / 2 - 50;
62588
62770
  }
62589
62771
  };
62590
62772
  }
@@ -62634,21 +62816,24 @@ function _toPrimitive14(t, r) {
62634
62816
  return ("string" === r ? String : Number)(t);
62635
62817
  }
62636
62818
  var LaserPointerModel = class extends ElementModel {
62637
- constructor(clientId, root, scope, liveCursor, removeElement) {
62638
- super(root, scope, liveCursor);
62819
+ constructor(clientId, root, scope, liveCursor, removeElement, isPerformanceMode) {
62820
+ super(root, scope, liveCursor, isPerformanceMode);
62639
62821
  _defineProperty14(this, "item", null);
62640
62822
  _defineProperty14(this, "clientId", void 0);
62641
62823
  _defineProperty14(this, "sliceBegin", 0);
62642
62824
  _defineProperty14(this, "displayStrokeWidth", 8);
62643
62825
  _defineProperty14(this, "cachedPoints", null);
62826
+ _defineProperty14(this, "clearLocalPointsWhenYPointsChange", false);
62827
+ _defineProperty14(this, "shouldUseLocalPoints", false);
62828
+ _defineProperty14(this, "localPointsPick", 4);
62644
62829
  this.clientId = clientId;
62645
- if (!this.root.has("type")) {
62830
+ if (this.root.doc && !this.root.has("type")) {
62646
62831
  this.root.set("type", "laser");
62647
62832
  }
62648
- if (!this.root.has("points")) {
62833
+ if (this.root.doc && !this.root.has("points")) {
62649
62834
  this.root.set("points", new Y10.Array());
62650
62835
  }
62651
- if (!this.root.has("removed")) {
62836
+ if (this.root.doc && !this.root.has("removed")) {
62652
62837
  this.root.set("removed", false);
62653
62838
  }
62654
62839
  this.root.observe((event) => {
@@ -62728,6 +62913,7 @@ var LaserPointerModel = class extends ElementModel {
62728
62913
  matrixedPoints() {
62729
62914
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62730
62915
  const points = this.cachedPoints || this.points;
62916
+ console.log("[][][] ,", this.points.length, this.cachedPoints?.length, this.localPoints.length);
62731
62917
  const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
62732
62918
  return groupPoints.map((_ref) => {
62733
62919
  let [x, y] = _ref;
@@ -62823,13 +63009,22 @@ function _toPrimitive15(t, r) {
62823
63009
  return ("string" === r ? String : Number)(t);
62824
63010
  }
62825
63011
  var StraightLineModel = class extends ElementModel {
62826
- constructor(root, scope, liveCursor) {
62827
- super(root, scope, liveCursor);
63012
+ get drawPoints() {
63013
+ if (this.localPoints.length >= 4) {
63014
+ return this.localPoints;
63015
+ }
63016
+ return this.points;
63017
+ }
63018
+ constructor(root, scope, liveCursor, isPerformanceMode) {
63019
+ super(root, scope, liveCursor, isPerformanceMode);
62828
63020
  _defineProperty15(this, "item", null);
62829
- if (!this.root.has("type")) {
63021
+ _defineProperty15(this, "clearLocalPointsWhenYPointsChange", true);
63022
+ _defineProperty15(this, "shouldUseLocalPoints", true);
63023
+ _defineProperty15(this, "localPointsPick", 4);
63024
+ if (this.root.doc && !this.root.has("type")) {
62830
63025
  this.root.set("type", "line");
62831
63026
  }
62832
- if (!this.root.has("points")) {
63027
+ if (this.root.doc && !this.root.has("points")) {
62833
63028
  this.root.set("points", new Y11.Array());
62834
63029
  }
62835
63030
  }
@@ -62854,7 +63049,7 @@ var StraightLineModel = class extends ElementModel {
62854
63049
  }
62855
63050
  renderLine() {
62856
63051
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62857
- const papperPoints = (0, import_lodash7.chunk)(this.points, 2).map((item) => {
63052
+ const papperPoints = (0, import_lodash7.chunk)(this.drawPoints, 2).map((item) => {
62858
63053
  return new this.scope.Point(item[0], item[1]).transform(matrix);
62859
63054
  });
62860
63055
  const path = new this.scope.Path();
@@ -62876,7 +63071,7 @@ var StraightLineModel = class extends ElementModel {
62876
63071
  name: "line-start",
62877
63072
  getPosition: () => {
62878
63073
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62879
- const points = this.points;
63074
+ const points = this.drawPoints;
62880
63075
  const start = new this.scope.Point(points[0], points[1]);
62881
63076
  return this.scope.project.view.projectToView(start.transform(matrix));
62882
63077
  },
@@ -62886,14 +63081,15 @@ var StraightLineModel = class extends ElementModel {
62886
63081
  }
62887
63082
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62888
63083
  const trPoint = point.transform(pointsMatrix.inverted());
62889
- this.setPoints([trPoint.x, trPoint.y, this.points[2], this.points[3]]);
63084
+ const oldPoints = this.drawPoints;
63085
+ this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3]]);
62890
63086
  }
62891
63087
  });
62892
63088
  cfg.controlPoints.push({
62893
63089
  name: "line-end",
62894
63090
  getPosition: () => {
62895
63091
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62896
- const points = this.points;
63092
+ const points = this.drawPoints;
62897
63093
  const end = new this.scope.Point(points[2], points[3]);
62898
63094
  return this.scope.project.view.projectToView(end.transform(matrix));
62899
63095
  },
@@ -62903,7 +63099,8 @@ var StraightLineModel = class extends ElementModel {
62903
63099
  }
62904
63100
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62905
63101
  const trPoint = point.transform(pointsMatrix.inverted());
62906
- this.setPoints([this.points[0], this.points[1], trPoint.x, trPoint.y]);
63102
+ const oldPoints = this.drawPoints;
63103
+ this.setPoints([oldPoints[0], oldPoints[1], trPoint.x, trPoint.y]);
62907
63104
  }
62908
63105
  });
62909
63106
  return cfg;
@@ -62947,10 +63144,13 @@ var ImageModel = class extends ElementModel {
62947
63144
  get src() {
62948
63145
  return this.root.get("src");
62949
63146
  }
62950
- constructor(root, scope, imageSets, liveCursor) {
62951
- super(root, scope, liveCursor);
63147
+ constructor(root, scope, imageSets, liveCursor, isPerformanceMode) {
63148
+ super(root, scope, liveCursor, isPerformanceMode);
62952
63149
  _defineProperty16(this, "item", null);
62953
63150
  _defineProperty16(this, "imageSets", void 0);
63151
+ _defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
63152
+ _defineProperty16(this, "shouldUseLocalPoints", true);
63153
+ _defineProperty16(this, "localPointsPick", 4);
62954
63154
  this.imageSets = imageSets;
62955
63155
  if (!this.root.has("type")) {
62956
63156
  this.root.set("type", "image");
@@ -63031,7 +63231,7 @@ var RenderableModel = class extends import_eventemitter3.default {
63031
63231
  get uuid() {
63032
63232
  return (0, import_uuid.v4)().replace(/-/g, "");
63033
63233
  }
63034
- constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
63234
+ constructor(options) {
63035
63235
  super();
63036
63236
  _defineProperty17(this, "scope", void 0);
63037
63237
  _defineProperty17(this, "toolbarModel", void 0);
@@ -63044,6 +63244,7 @@ var RenderableModel = class extends import_eventemitter3.default {
63044
63244
  _defineProperty17(this, "shadowEmitter", void 0);
63045
63245
  _defineProperty17(this, "imageSets", void 0);
63046
63246
  _defineProperty17(this, "liveCursor", void 0);
63247
+ _defineProperty17(this, "isPerformanceMode", void 0);
63047
63248
  _defineProperty17(this, "onElementsChange", (event) => {
63048
63249
  for (const [key, value] of event.changes.keys.entries()) {
63049
63250
  if (value.action === "add") {
@@ -63062,15 +63263,16 @@ var RenderableModel = class extends import_eventemitter3.default {
63062
63263
  }
63063
63264
  }
63064
63265
  });
63065
- this.liveCursor = liveCursor;
63066
- this.imageSets = imageSets;
63067
- this.hasPermission = hasPermission;
63068
- this.shadowEmitter = shadowEmitter;
63069
- this.layerId = layerId;
63070
- this.userManager = userManager;
63071
- this.elements = elements;
63072
- this.scope = scope;
63073
- this.toolbarModel = toolbarModel;
63266
+ this.isPerformanceMode = options.isPerformanceMode;
63267
+ this.liveCursor = options.liveCursor;
63268
+ this.imageSets = options.imageSets;
63269
+ this.hasPermission = options.hasPermission;
63270
+ this.shadowEmitter = options.shadowEmitter;
63271
+ this.layerId = options.layerId;
63272
+ this.userManager = options.userManager;
63273
+ this.elements = options.elements;
63274
+ this.scope = options.scope;
63275
+ this.toolbarModel = options.toolbarModel;
63074
63276
  this.elementModels = /* @__PURE__ */ new Map();
63075
63277
  for (const key of this.elements.keys()) {
63076
63278
  const type = this.elements.get(key)?.get("type");
@@ -63101,30 +63303,38 @@ var RenderableModel = class extends import_eventemitter3.default {
63101
63303
  convertToModel(yMap) {
63102
63304
  const type = yMap.get("type");
63103
63305
  let model = null;
63306
+ const uuid = yMap.get(ElementModel.KEYS.uuid);
63307
+ if (uuid) {
63308
+ const existingModel = this.elementModels.get(uuid);
63309
+ if (existingModel) {
63310
+ existingModel.shadowEmitter = this.shadowEmitter;
63311
+ return existingModel;
63312
+ }
63313
+ }
63104
63314
  if (type === "curve") {
63105
- model = new CurveModel(yMap, this.scope, this.liveCursor);
63315
+ model = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63106
63316
  } else if (["ellipse"].indexOf(type) >= 0) {
63107
- model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
63317
+ model = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
63108
63318
  } else if (type === "selector") {
63109
- model = new SelectorModel(yMap, this.scope, this.liveCursor);
63319
+ model = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63110
63320
  } else if (type === "arrow") {
63111
- model = new LineModel(yMap, this.scope, this.liveCursor);
63321
+ model = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63112
63322
  } else if (type === "line") {
63113
- model = new StraightLineModel(yMap, this.scope, this.liveCursor);
63323
+ model = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63114
63324
  } else if (type === "point-text") {
63115
- model = new PointTextModel(yMap, this.scope, this.liveCursor);
63325
+ model = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63116
63326
  } else if (type === "triangle") {
63117
- model = new TriangleModel(yMap, this.scope, this.liveCursor);
63327
+ model = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63118
63328
  } else if (type === "rectangle") {
63119
- model = new RectangleModel(yMap, this.scope, this.liveCursor);
63329
+ model = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63120
63330
  } else if (type === "eraser") {
63121
- model = new EraserModel(yMap, this.scope, this.liveCursor);
63331
+ model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63122
63332
  } else if (type === "laser") {
63123
- model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
63124
- this.removeElementItem(uuid);
63125
- });
63333
+ model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
63334
+ this.removeElementItem(uuid2);
63335
+ }, this.isPerformanceMode);
63126
63336
  } else if (type === "image") {
63127
- model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
63337
+ model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
63128
63338
  }
63129
63339
  if (model) {
63130
63340
  model.shadowEmitter = this.shadowEmitter;
@@ -63158,7 +63368,7 @@ var RenderableModel = class extends import_eventemitter3.default {
63158
63368
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63159
63369
  this.elements.set(uuid, yMap);
63160
63370
  }, elementsUndoOrigin);
63161
- const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
63371
+ const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
63162
63372
  model.root.set("src", src);
63163
63373
  const initMatrix = new this.scope.Matrix();
63164
63374
  const center = this.scope.project.view.center;
@@ -63175,8 +63385,10 @@ var RenderableModel = class extends import_eventemitter3.default {
63175
63385
  return null;
63176
63386
  }
63177
63387
  const yMap = new Y12.Map();
63388
+ const uuid = this.uuid;
63389
+ const curveModel = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63390
+ this.elementModels.set(uuid, curveModel);
63178
63391
  this.elements.doc?.transact(() => {
63179
- const uuid = this.uuid;
63180
63392
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63181
63393
  yMap.set(ElementModel.KEYS.uuid, uuid);
63182
63394
  yMap.set("type", "curve");
@@ -63189,7 +63401,6 @@ var RenderableModel = class extends import_eventemitter3.default {
63189
63401
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63190
63402
  this.elements.set(uuid, yMap);
63191
63403
  }, elementsUndoOrigin);
63192
- const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
63193
63404
  this.initElement(curveModel);
63194
63405
  return curveModel;
63195
63406
  }
@@ -63198,11 +63409,17 @@ var RenderableModel = class extends import_eventemitter3.default {
63198
63409
  return null;
63199
63410
  }
63200
63411
  const yMap = new Y12.Map();
63412
+ const uuid = this.uuid;
63413
+ const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
63414
+ this.removeElementItem(uuid2);
63415
+ }, this.isPerformanceMode);
63416
+ this.elementModels.set(uuid, model);
63201
63417
  this.elements.doc?.transact(() => {
63202
- const uuid = this.uuid;
63203
63418
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63204
63419
  yMap.set(ElementModel.KEYS.uuid, uuid);
63205
63420
  yMap.set("type", "laser");
63421
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63422
+ yMap.set("removed", false);
63206
63423
  yMap.set(ElementModel.KEYS.shadow, "layer");
63207
63424
  yMap.set(ElementModel.KEYS.strokeWidth, 8);
63208
63425
  yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
@@ -63210,9 +63427,7 @@ var RenderableModel = class extends import_eventemitter3.default {
63210
63427
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63211
63428
  this.elements.set(uuid, yMap);
63212
63429
  }, elementsUndoOrigin);
63213
- const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
63214
- this.removeElementItem(uuid);
63215
- });
63430
+ this.initElement(model);
63216
63431
  return model;
63217
63432
  }
63218
63433
  createEraser() {
@@ -63220,11 +63435,14 @@ var RenderableModel = class extends import_eventemitter3.default {
63220
63435
  return null;
63221
63436
  }
63222
63437
  const yMap = new Y12.Map();
63438
+ const uuid = this.uuid;
63439
+ const model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63440
+ this.elementModels.set(uuid, model);
63223
63441
  this.elements.doc?.transact(() => {
63224
- const uuid = this.uuid;
63225
63442
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63226
63443
  yMap.set(ElementModel.KEYS.uuid, uuid);
63227
63444
  yMap.set("type", "eraser");
63445
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63228
63446
  yMap.set(ElementModel.KEYS.shadow, "layer");
63229
63447
  yMap.set(ElementModel.KEYS.strokeWidth, 4);
63230
63448
  yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
@@ -63232,7 +63450,6 @@ var RenderableModel = class extends import_eventemitter3.default {
63232
63450
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63233
63451
  this.elements.set(uuid, yMap);
63234
63452
  }, elementsUndoOrigin);
63235
- const model = new EraserModel(yMap, this.scope, this.liveCursor);
63236
63453
  return model;
63237
63454
  }
63238
63455
  createTriangle(shadow) {
@@ -63240,45 +63457,52 @@ var RenderableModel = class extends import_eventemitter3.default {
63240
63457
  return null;
63241
63458
  }
63242
63459
  const yMap = new Y12.Map();
63460
+ const uuid = this.uuid;
63461
+ const triangleModel = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63462
+ this.elementModels.set(uuid, triangleModel);
63243
63463
  this.elements.doc?.transact(() => {
63244
- const uuid = this.uuid;
63245
63464
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63246
63465
  yMap.set(ElementModel.KEYS.uuid, uuid);
63247
63466
  yMap.set("type", "triangle");
63248
63467
  if (shadow) {
63249
63468
  yMap.set(ElementModel.KEYS.shadow, "layer");
63250
63469
  }
63470
+ yMap.set("points", new Y12.Array());
63251
63471
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63252
63472
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63253
63473
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63254
63474
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63255
63475
  this.elements.set(uuid, yMap);
63256
63476
  }, elementsUndoOrigin);
63257
- const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
63258
- this.initElement(triangle);
63259
- triangle.dashArray = this.toolbarModel.dashArray;
63260
- return triangle;
63477
+ this.initElement(triangleModel);
63478
+ triangleModel.dashArray = this.toolbarModel.dashArray;
63479
+ return triangleModel;
63261
63480
  }
63262
63481
  createRectangle(shadow) {
63263
63482
  if (!this.confirmPermission()) {
63264
63483
  return null;
63265
63484
  }
63266
63485
  const yMap = new Y12.Map();
63486
+ const uuid = this.uuid;
63487
+ const rect = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63488
+ this.elementModels.set(uuid, rect);
63267
63489
  this.elements.doc?.transact(() => {
63268
- const uuid = this.uuid;
63269
63490
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63270
63491
  yMap.set(ElementModel.KEYS.uuid, uuid);
63271
63492
  yMap.set("type", "rectangle");
63272
63493
  if (shadow) {
63273
63494
  yMap.set(ElementModel.KEYS.shadow, "layer");
63274
63495
  }
63496
+ const initPoints = new Y12.Array();
63497
+ initPoints.push([0, 0, 0, 0]);
63498
+ yMap.set("points", initPoints);
63499
+ yMap.set("radius", 0);
63275
63500
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63276
63501
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63277
63502
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63278
63503
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63279
63504
  this.elements.set(uuid, yMap);
63280
63505
  }, elementsUndoOrigin);
63281
- const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
63282
63506
  this.initElement(rect);
63283
63507
  rect.dashArray = this.toolbarModel.dashArray;
63284
63508
  return rect;
@@ -63288,21 +63512,23 @@ var RenderableModel = class extends import_eventemitter3.default {
63288
63512
  return null;
63289
63513
  }
63290
63514
  const yMap = new Y12.Map();
63515
+ const uuid = this.uuid;
63516
+ const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
63517
+ this.elementModels.set(uuid, segmentsModel);
63291
63518
  this.elements.doc?.transact(() => {
63292
- const uuid = this.uuid;
63293
63519
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63294
63520
  yMap.set(ElementModel.KEYS.uuid, uuid);
63295
63521
  yMap.set("type", type);
63296
63522
  if (shadow) {
63297
63523
  yMap.set(ElementModel.KEYS.shadow, "layer");
63298
63524
  }
63525
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63299
63526
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63300
63527
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63301
63528
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63302
63529
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63303
63530
  this.elements.set(uuid, yMap);
63304
63531
  }, elementsUndoOrigin);
63305
- const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
63306
63532
  this.initElement(segmentsModel);
63307
63533
  segmentsModel.dashArray = this.toolbarModel.dashArray;
63308
63534
  return segmentsModel;
@@ -63313,16 +63539,20 @@ var RenderableModel = class extends import_eventemitter3.default {
63313
63539
  return null;
63314
63540
  }
63315
63541
  const yMap = new Y12.Map();
63542
+ const uuid = this.uuid;
63543
+ const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63544
+ this.elementModels.set(uuid, selectorModel);
63316
63545
  this.elements.doc?.transact(() => {
63317
- const uuid = this.uuid;
63318
63546
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63319
63547
  yMap.set(ElementModel.KEYS.uuid, uuid);
63320
63548
  yMap.set("type", "selector");
63549
+ const initPoints = new Y12.Array();
63550
+ initPoints.push([0, 0, 0, 0]);
63551
+ yMap.set(ElementModel.KEYS.points, initPoints);
63321
63552
  yMap.set(ElementModel.KEYS.shadow, "layer");
63322
63553
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63323
63554
  this.elements.set(uuid, yMap);
63324
63555
  }, elementsUndoOrigin);
63325
- const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
63326
63556
  selectorModel.shadow = "layer";
63327
63557
  return selectorModel;
63328
63558
  }
@@ -63331,21 +63561,23 @@ var RenderableModel = class extends import_eventemitter3.default {
63331
63561
  return null;
63332
63562
  }
63333
63563
  const yMap = new Y12.Map();
63564
+ const uuid = this.uuid;
63565
+ const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63566
+ this.elementModels.set(uuid, straightLineModel);
63334
63567
  this.elements.doc?.transact(() => {
63335
- const uuid = this.uuid;
63336
63568
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63337
63569
  yMap.set(ElementModel.KEYS.uuid, uuid);
63338
63570
  yMap.set("type", "line");
63339
63571
  if (shadow) {
63340
63572
  yMap.set(ElementModel.KEYS.shadow, "layer");
63341
63573
  }
63574
+ yMap.set("points", new Y12.Array());
63342
63575
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63343
63576
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63344
63577
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63345
63578
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63346
63579
  this.elements.set(uuid, yMap);
63347
63580
  }, elementsUndoOrigin);
63348
- const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
63349
63581
  this.initElement(straightLineModel);
63350
63582
  straightLineModel.dashArray = this.toolbarModel.dashArray;
63351
63583
  return straightLineModel;
@@ -63355,21 +63587,25 @@ var RenderableModel = class extends import_eventemitter3.default {
63355
63587
  return null;
63356
63588
  }
63357
63589
  const yMap = new Y12.Map();
63590
+ const uuid = this.uuid;
63591
+ const lineModel = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63592
+ this.elementModels.set(uuid, lineModel);
63358
63593
  this.elements.doc?.transact(() => {
63359
- const uuid = this.uuid;
63360
63594
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63361
63595
  yMap.set(ElementModel.KEYS.uuid, uuid);
63362
63596
  yMap.set("type", "arrow");
63363
63597
  if (shadow) {
63364
63598
  yMap.set(ElementModel.KEYS.shadow, "layer");
63365
63599
  }
63600
+ yMap.set("headArrow", "none");
63601
+ yMap.set("tailArrow", "normal");
63602
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63366
63603
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63367
63604
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63368
63605
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63369
63606
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63370
63607
  this.elements.set(uuid, yMap);
63371
63608
  }, elementsUndoOrigin);
63372
- const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
63373
63609
  this.initElement(lineModel);
63374
63610
  lineModel.dashArray = this.toolbarModel.dashArray;
63375
63611
  return lineModel;
@@ -63379,21 +63615,23 @@ var RenderableModel = class extends import_eventemitter3.default {
63379
63615
  return null;
63380
63616
  }
63381
63617
  const yMap = new Y12.Map();
63618
+ const uuid = this.uuid;
63619
+ const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63620
+ this.elementModels.set(uuid, pointTextModel);
63382
63621
  this.elements.doc?.transact(() => {
63383
- const uuid = this.uuid;
63384
63622
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63385
63623
  yMap.set(ElementModel.KEYS.uuid, uuid);
63386
63624
  yMap.set("type", "point-text");
63387
63625
  if (shadow) {
63388
63626
  yMap.set(ElementModel.KEYS.shadow, "layer");
63389
63627
  }
63628
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63390
63629
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63391
63630
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63392
63631
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63393
63632
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63394
63633
  this.elements.set(uuid, yMap);
63395
63634
  }, elementsUndoOrigin);
63396
- const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
63397
63635
  pointTextModel.setPoints([x, y]);
63398
63636
  pointTextModel.fontSize = this.toolbarModel.fontSize;
63399
63637
  pointTextModel.fontFamily = this.toolbarModel.fontFamily;
@@ -63711,7 +63949,7 @@ var CurveTool = class extends WhiteboardTool {
63711
63949
  _defineProperty19(this, "recognizer", new Recognizer());
63712
63950
  _defineProperty19(this, "pointCount", 0);
63713
63951
  _defineProperty19(this, "showLiveCursor", true);
63714
- this.tool.minDistance = 5;
63952
+ this.tool.minDistance = 20;
63715
63953
  }
63716
63954
  onMouseDown(_event) {
63717
63955
  this.pointCount = 0;
@@ -65631,6 +65869,8 @@ var Whiteboard = class extends import_eventemitter38.default {
65631
65869
  _defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
65632
65870
  _defineProperty31(this, "getElementAttribute", void 0);
65633
65871
  _defineProperty31(this, "setElementAttribute", void 0);
65872
+ _defineProperty31(this, "setPerformanceMode", void 0);
65873
+ _defineProperty31(this, "isPerformanceMode", void 0);
65634
65874
  _defineProperty31(this, "removeElement", void 0);
65635
65875
  _defineProperty31(this, "getCurrentTool", void 0);
65636
65876
  _defineProperty31(this, "setCurrentTool", void 0);
@@ -65920,9 +66160,24 @@ var LaserPointerTool = class extends WhiteboardTool {
65920
66160
  if (this.pointCount > 1024) {
65921
66161
  return;
65922
66162
  }
66163
+ const MIN_DISTANCE = 4;
65923
66164
  if (this.elementModel) {
65924
- this.pointCount += 1;
65925
- this.elementModel.appendPoints([event.point.x, event.point.y]);
66165
+ const len = this.elementModel.points.length;
66166
+ let last = {
66167
+ x: 0,
66168
+ y: 0
66169
+ };
66170
+ if (len >= 2) {
66171
+ last = {
66172
+ x: this.elementModel.points[len - 2],
66173
+ y: this.elementModel.points[len - 1]
66174
+ };
66175
+ }
66176
+ const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
66177
+ if (dist >= MIN_DISTANCE) {
66178
+ this.pointCount += 1;
66179
+ this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
66180
+ }
65926
66181
  }
65927
66182
  }
65928
66183
  onMouseUp(_event) {
@@ -66997,6 +67252,9 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
66997
67252
  _defineProperty43(this, "hasPermission", (flag) => {
66998
67253
  return this.permissions.hasPermission(flag, this.userId);
66999
67254
  });
67255
+ _defineProperty43(this, "isPerformanceMode", () => {
67256
+ return this.option.performance ?? false;
67257
+ });
67000
67258
  _defineProperty43(this, "handleStackItemAdded", () => {
67001
67259
  this.selectElementsModel.clearSelectElementForSelf();
67002
67260
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
@@ -67011,7 +67269,18 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
67011
67269
  const id = ids[i];
67012
67270
  if (!this.layers.has(id)) {
67013
67271
  const elementsMap = this.getMap(`layer/${id}/elements`);
67014
- const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
67272
+ const renderableModel = new RenderableModel({
67273
+ layerId: id,
67274
+ shadowEmitter: this.shadowEmitter,
67275
+ elements: elementsMap,
67276
+ scope: this.paperScope,
67277
+ toolbarModel: this.toolbarModel,
67278
+ userManager: this.userManager,
67279
+ imageSets: this.imageSets,
67280
+ liveCursor: this.liveCursor,
67281
+ hasPermission: this.hasPermission,
67282
+ isPerformanceMode: this.isPerformanceMode
67283
+ });
67015
67284
  this.layers.set(id, renderableModel);
67016
67285
  }
67017
67286
  if (!this.undoManagers.has(id)) {
@@ -67278,6 +67547,12 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
67278
67547
  this.camera.resetViewMatrixToFlow(flowId);
67279
67548
  }
67280
67549
  };
67550
+ this.emitter.setPerformanceMode = (enabled) => {
67551
+ this.option.performance = enabled;
67552
+ };
67553
+ this.emitter.isPerformanceMode = () => {
67554
+ return this.isPerformanceMode();
67555
+ };
67281
67556
  this.emitter.setViewModeToMain = (userId) => {
67282
67557
  if (that.disableViewModelUpdate) {
67283
67558
  console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
@@ -67332,7 +67607,18 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
67332
67607
  const source = this.getMap(`layer/${sourceId}/elements`);
67333
67608
  const target = this.getMap(`layer/${targetId}/elements`);
67334
67609
  if (!this.layers.has(targetId)) {
67335
- this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
67610
+ this.layers.set(targetId, new RenderableModel({
67611
+ layerId: targetId,
67612
+ shadowEmitter: this.shadowEmitter,
67613
+ elements: target,
67614
+ scope: this.paperScope,
67615
+ toolbarModel: this.toolbarModel,
67616
+ userManager: this.userManager,
67617
+ imageSets: this.imageSets,
67618
+ liveCursor: this.liveCursor,
67619
+ hasPermission: this.hasPermission,
67620
+ isPerformanceMode: this.isPerformanceMode
67621
+ }));
67336
67622
  }
67337
67623
  if (!this.undoManagers.has(targetId)) {
67338
67624
  const undoManager = new Y15.UndoManager(target, {
@@ -67567,6 +67853,11 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
67567
67853
  this.editors.forEach((editor) => {
67568
67854
  editor.updateBounds();
67569
67855
  });
67856
+ const area = this.paperScope.project.view.size.width * this.paperScope.project.view.size.height;
67857
+ const minDistance = Math.ceil(area / 4e5);
67858
+ Object.keys(this.tools).forEach((key) => {
67859
+ this.tools[key].tool.minDistance = minDistance;
67860
+ });
67570
67861
  });
67571
67862
  this.camera.on("userPageChange", (userId, pageId) => {
67572
67863
  this.emitter.emit("activePageChange", userId, pageId);