@netless/forge-slide 1.1.0 → 1.1.2

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.esm.js CHANGED
@@ -35304,6 +35304,7 @@ import * as Y from "yjs";
35304
35304
  import { removeDeepObserver } from "@netless/forge-room";
35305
35305
  import * as Y3 from "yjs";
35306
35306
  import * as Y4 from "yjs";
35307
+ import { metrics } from "@netless/forge-room";
35307
35308
  import * as Y5 from "yjs";
35308
35309
  import * as Y6 from "yjs";
35309
35310
  import { removeObserver } from "@netless/forge-room";
@@ -56165,8 +56166,8 @@ var require_lodash = __commonJS2({
56165
56166
  }
56166
56167
  var runInContext = function runInContext2(context) {
56167
56168
  context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
56168
- 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;
56169
- var arrayProto = Array13.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
56169
+ 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;
56170
+ var arrayProto = Array14.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
56170
56171
  var coreJsData = context["__core-js_shared__"];
56171
56172
  var funcToString = funcProto.toString;
56172
56173
  var hasOwnProperty = objectProto.hasOwnProperty;
@@ -56589,7 +56590,7 @@ var require_lodash = __commonJS2({
56589
56590
  }
56590
56591
  }
56591
56592
  function baseAt(object, paths) {
56592
- var index = -1, length = paths.length, result2 = Array13(length), skip = object == null;
56593
+ var index = -1, length = paths.length, result2 = Array14(length), skip = object == null;
56593
56594
  while (++index < length) {
56594
56595
  result2[index] = skip ? undefined2 : get(object, paths[index]);
56595
56596
  }
@@ -56835,7 +56836,7 @@ var require_lodash = __commonJS2({
56835
56836
  return number >= nativeMin(start, end) && number < nativeMax(start, end);
56836
56837
  }
56837
56838
  function baseIntersection(arrays, iteratee2, comparator) {
56838
- var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array13(othLength), maxLength = Infinity, result2 = [];
56839
+ var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array14(othLength), maxLength = Infinity, result2 = [];
56839
56840
  while (othIndex--) {
56840
56841
  var array = arrays[othIndex];
56841
56842
  if (othIndex && iteratee2) {
@@ -57016,7 +57017,7 @@ var require_lodash = __commonJS2({
57016
57017
  return value < other;
57017
57018
  }
57018
57019
  function baseMap(collection, iteratee2) {
57019
- var index = -1, result2 = isArrayLike(collection) ? Array13(collection.length) : [];
57020
+ var index = -1, result2 = isArrayLike(collection) ? Array14(collection.length) : [];
57020
57021
  baseEach(collection, function(value, key, collection2) {
57021
57022
  result2[++index] = iteratee2(value, key, collection2);
57022
57023
  });
@@ -57191,7 +57192,7 @@ var require_lodash = __commonJS2({
57191
57192
  return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
57192
57193
  }
57193
57194
  function baseRange(start, end, step, fromRight) {
57194
- var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array13(length);
57195
+ var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array14(length);
57195
57196
  while (length--) {
57196
57197
  result2[fromRight ? length : ++index] = start;
57197
57198
  start += step;
@@ -57273,7 +57274,7 @@ var require_lodash = __commonJS2({
57273
57274
  }
57274
57275
  length = start > end ? 0 : end - start >>> 0;
57275
57276
  start >>>= 0;
57276
- var result2 = Array13(length);
57277
+ var result2 = Array14(length);
57277
57278
  while (++index < length) {
57278
57279
  result2[index] = array[index + start];
57279
57280
  }
@@ -57433,7 +57434,7 @@ var require_lodash = __commonJS2({
57433
57434
  if (length < 2) {
57434
57435
  return length ? baseUniq(arrays[0]) : [];
57435
57436
  }
57436
- var index = -1, result2 = Array13(length);
57437
+ var index = -1, result2 = Array14(length);
57437
57438
  while (++index < length) {
57438
57439
  var array = arrays[index], othIndex = -1;
57439
57440
  while (++othIndex < length) {
@@ -57530,7 +57531,7 @@ var require_lodash = __commonJS2({
57530
57531
  return object.index - other.index;
57531
57532
  }
57532
57533
  function composeArgs(args, partials, holders, isCurried) {
57533
- 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;
57534
+ 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;
57534
57535
  while (++leftIndex < leftLength) {
57535
57536
  result2[leftIndex] = partials[leftIndex];
57536
57537
  }
@@ -57545,7 +57546,7 @@ var require_lodash = __commonJS2({
57545
57546
  return result2;
57546
57547
  }
57547
57548
  function composeArgsRight(args, partials, holders, isCurried) {
57548
- 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;
57549
+ 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;
57549
57550
  while (++argsIndex < rangeLength) {
57550
57551
  result2[argsIndex] = args[argsIndex];
57551
57552
  }
@@ -57562,7 +57563,7 @@ var require_lodash = __commonJS2({
57562
57563
  }
57563
57564
  function copyArray(source, array) {
57564
57565
  var index = -1, length = source.length;
57565
- array || (array = Array13(length));
57566
+ array || (array = Array14(length));
57566
57567
  while (++index < length) {
57567
57568
  array[index] = source[index];
57568
57569
  }
@@ -57695,7 +57696,7 @@ var require_lodash = __commonJS2({
57695
57696
  function createCurry(func, bitmask, arity) {
57696
57697
  var Ctor = createCtor(func);
57697
57698
  function wrapper() {
57698
- var length = arguments.length, args = Array13(length), index = length, placeholder = getHolder(wrapper);
57699
+ var length = arguments.length, args = Array14(length), index = length, placeholder = getHolder(wrapper);
57699
57700
  while (index--) {
57700
57701
  args[index] = arguments[index];
57701
57702
  }
@@ -57775,7 +57776,7 @@ var require_lodash = __commonJS2({
57775
57776
  function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
57776
57777
  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);
57777
57778
  function wrapper() {
57778
- var length = arguments.length, args = Array13(length), index = length;
57779
+ var length = arguments.length, args = Array14(length), index = length;
57779
57780
  while (index--) {
57780
57781
  args[index] = arguments[index];
57781
57782
  }
@@ -57874,7 +57875,7 @@ var require_lodash = __commonJS2({
57874
57875
  function createPartial(func, bitmask, thisArg, partials) {
57875
57876
  var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
57876
57877
  function wrapper() {
57877
- var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array13(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
57878
+ var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array14(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
57878
57879
  while (++leftIndex < leftLength) {
57879
57880
  args[leftIndex] = partials[leftIndex];
57880
57881
  }
@@ -58487,12 +58488,12 @@ var require_lodash = __commonJS2({
58487
58488
  function overRest(func, start, transform2) {
58488
58489
  start = nativeMax(start === undefined2 ? func.length - 1 : start, 0);
58489
58490
  return function() {
58490
- var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array13(length);
58491
+ var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array14(length);
58491
58492
  while (++index < length) {
58492
58493
  array[index] = args[start + index];
58493
58494
  }
58494
58495
  index = -1;
58495
- var otherArgs = Array13(start + 1);
58496
+ var otherArgs = Array14(start + 1);
58496
58497
  while (++index < start) {
58497
58498
  otherArgs[index] = args[index];
58498
58499
  }
@@ -58604,7 +58605,7 @@ var require_lodash = __commonJS2({
58604
58605
  result2.__values__ = wrapper.__values__;
58605
58606
  return result2;
58606
58607
  }
58607
- function chunk8(array, size2, guard) {
58608
+ function chunk7(array, size2, guard) {
58608
58609
  if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
58609
58610
  size2 = 1;
58610
58611
  } else {
@@ -58614,7 +58615,7 @@ var require_lodash = __commonJS2({
58614
58615
  if (!length || size2 < 1) {
58615
58616
  return [];
58616
58617
  }
58617
- var index = 0, resIndex = 0, result2 = Array13(nativeCeil(length / size2));
58618
+ var index = 0, resIndex = 0, result2 = Array14(nativeCeil(length / size2));
58618
58619
  while (index < length) {
58619
58620
  result2[resIndex++] = baseSlice(array, index, index += size2);
58620
58621
  }
@@ -58635,7 +58636,7 @@ var require_lodash = __commonJS2({
58635
58636
  if (!length) {
58636
58637
  return [];
58637
58638
  }
58638
- var args = Array13(length - 1), array = arguments[0], index = length;
58639
+ var args = Array14(length - 1), array = arguments[0], index = length;
58639
58640
  while (index--) {
58640
58641
  args[index - 1] = arguments[index];
58641
58642
  }
@@ -59137,7 +59138,7 @@ var require_lodash = __commonJS2({
59137
59138
  return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
59138
59139
  }
59139
59140
  var invokeMap = baseRest(function(collection, path, args) {
59140
- var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array13(collection.length) : [];
59141
+ var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array14(collection.length) : [];
59141
59142
  baseEach(collection, function(value) {
59142
59143
  result2[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
59143
59144
  });
@@ -59520,7 +59521,7 @@ var require_lodash = __commonJS2({
59520
59521
  }()) ? baseIsArguments : function(value) {
59521
59522
  return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
59522
59523
  };
59523
- var isArray = Array13.isArray;
59524
+ var isArray = Array14.isArray;
59524
59525
  var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
59525
59526
  function isArrayLike(value) {
59526
59527
  return value != null && isLength(value.length) && !isFunction(value);
@@ -60476,7 +60477,7 @@ var require_lodash = __commonJS2({
60476
60477
  lodash.bindKey = bindKey;
60477
60478
  lodash.castArray = castArray;
60478
60479
  lodash.chain = chain;
60479
- lodash.chunk = chunk8;
60480
+ lodash.chunk = chunk7;
60480
60481
  lodash.compact = compact;
60481
60482
  lodash.concat = concat;
60482
60483
  lodash.cond = cond;
@@ -61100,7 +61101,6 @@ function me(e, t = {}) {
61100
61101
  function ae(e, t = {}) {
61101
61102
  return ce(me(e, t), t);
61102
61103
  }
61103
- var import_lodash = __toESM2(require_lodash(), 1);
61104
61104
  function _defineProperty(e, r, t) {
61105
61105
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
61106
61106
  }
@@ -61185,12 +61185,23 @@ var ElementModel = class _ElementModel {
61185
61185
  set shadow(value) {
61186
61186
  this.root.set(_ElementModel.KEYS.shadow, value);
61187
61187
  }
61188
- constructor(root, scope, liveCursor) {
61188
+ get isPerformanceEnvironment() {
61189
+ return this.isPerformanceMode() && this.shouldUseLocalPoints;
61190
+ }
61191
+ constructor(root, scope, liveCursor, isPerformanceMode) {
61189
61192
  _defineProperty(this, "shadowEmitter", null);
61190
61193
  _defineProperty(this, "root", void 0);
61191
61194
  _defineProperty(this, "scope", void 0);
61192
61195
  _defineProperty(this, "item", void 0);
61196
+ _defineProperty(this, "clearLocalPointsWhenYPointsChange", void 0);
61197
+ _defineProperty(this, "shouldUseLocalPoints", void 0);
61198
+ _defineProperty(this, "localPointsPick", void 0);
61193
61199
  _defineProperty(this, "liveCursor", void 0);
61200
+ _defineProperty(this, "appendPointsTimer", null);
61201
+ _defineProperty(this, "setPointsTimer", null);
61202
+ _defineProperty(this, "pointsUpdateTimer", null);
61203
+ _defineProperty(this, "isPerformanceMode", void 0);
61204
+ _defineProperty(this, "localPoints", []);
61194
61205
  _defineProperty(this, "handlePropChange", (events) => {
61195
61206
  if (!this.item) {
61196
61207
  return;
@@ -61229,24 +61240,68 @@ var ElementModel = class _ElementModel {
61229
61240
  }
61230
61241
  }
61231
61242
  } else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
61232
- this.onVectorUpdate();
61233
- const liveCursorPoint = this.liveCursorPoint();
61234
- const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
61235
- if (liveCursorPoint && ownerId) {
61236
- this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
61243
+ if (this.isPerformanceEnvironment) {
61244
+ this.handlePointsChangePerformance();
61245
+ } else {
61246
+ this.handlePointsChangeDirect();
61237
61247
  }
61238
61248
  } else {
61239
61249
  }
61240
61250
  }
61241
61251
  });
61252
+ _defineProperty(this, "onPointsArrayChange", (points) => {
61253
+ if (this.localPoints.length >= points.length) {
61254
+ return;
61255
+ }
61256
+ const pointsChunk = points.slice(this.localPoints.length, this.localPoints.length + this.localPointsPick);
61257
+ this.localPoints = this.localPoints.concat(pointsChunk);
61258
+ this.onVectorUpdate();
61259
+ this.pointsUpdateTimer = window.requestAnimationFrame(() => {
61260
+ this.onPointsArrayChange(points);
61261
+ });
61262
+ });
61263
+ this.isPerformanceMode = isPerformanceMode;
61242
61264
  this.scope = scope;
61243
61265
  this.liveCursor = liveCursor;
61244
61266
  this.root = root;
61245
- if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
61267
+ if (this.root.doc) {
61268
+ if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
61269
+ this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
61270
+ }
61271
+ } else {
61246
61272
  this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
61247
61273
  }
61248
61274
  this.root.observeDeep(this.handlePropChange);
61249
61275
  }
61276
+ handlePointsChangeDirect() {
61277
+ this.onVectorUpdate();
61278
+ const liveCursorPoint = this.liveCursorPoint();
61279
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
61280
+ if (liveCursorPoint && ownerId) {
61281
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
61282
+ }
61283
+ }
61284
+ handlePointsChangePerformance() {
61285
+ const liveCursorPoint = this.liveCursorPoint();
61286
+ const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
61287
+ if (liveCursorPoint && ownerId) {
61288
+ this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
61289
+ }
61290
+ if (this.liveCursor.userManager.selfId !== ownerId || this.localPoints.length === 0) {
61291
+ if (this.pointsUpdateTimer) {
61292
+ window.cancelAnimationFrame(this.pointsUpdateTimer);
61293
+ }
61294
+ if (this.shadow == "") {
61295
+ this.localPoints = this.points;
61296
+ this.onVectorUpdate();
61297
+ } else {
61298
+ if (this.clearLocalPointsWhenYPointsChange) {
61299
+ this.localPoints = [];
61300
+ }
61301
+ this.onPointsArrayChange(this.points);
61302
+ }
61303
+ }
61304
+ }
61250
61305
  createPaperElement() {
61251
61306
  this.createPaperItem();
61252
61307
  if (this.item) {
@@ -61258,14 +61313,48 @@ var ElementModel = class _ElementModel {
61258
61313
  }
61259
61314
  }
61260
61315
  appendPoints(points) {
61316
+ if (this.isPerformanceEnvironment) {
61317
+ this.appendPointsPerformance(points);
61318
+ } else {
61319
+ this.appendPointsDirect(points);
61320
+ }
61321
+ }
61322
+ appendPointsDirect(points) {
61261
61323
  this.root.get(_ElementModel.KEYS.points).push(points);
61262
61324
  }
61325
+ appendPointsPerformance(points) {
61326
+ this.localPoints = this.localPoints.concat(points);
61327
+ this.onVectorUpdate();
61328
+ if (this.appendPointsTimer) {
61329
+ window.clearTimeout(this.appendPointsTimer);
61330
+ }
61331
+ if (this.localPoints.length % 80 === 0) {
61332
+ const yArray = this.root.get(_ElementModel.KEYS.points);
61333
+ yArray?.push(this.localPoints.slice(yArray.length));
61334
+ }
61335
+ this.appendPointsTimer = window.setTimeout(() => {
61336
+ this.appendPointsTimer = null;
61337
+ if (this.localPoints.length > 0) {
61338
+ const yArray = this.root.get(_ElementModel.KEYS.points);
61339
+ yArray?.push(this.localPoints.slice(yArray.length));
61340
+ }
61341
+ }, 100);
61342
+ }
61263
61343
  setPoints(points) {
61344
+ if (this.isPerformanceEnvironment) {
61345
+ this.setPointsPerformance(points);
61346
+ } else {
61347
+ this.setPointsDirect(points);
61348
+ }
61349
+ }
61350
+ setPointsDirect(points) {
61264
61351
  if (this.root.doc) {
61265
61352
  this.root.doc.transact(() => {
61266
61353
  const yArray = this.root.get(_ElementModel.KEYS.points);
61267
- yArray.delete(0, yArray.length);
61268
- yArray.push(points);
61354
+ if (yArray) {
61355
+ yArray.delete(0, yArray.length);
61356
+ yArray.push(points);
61357
+ }
61269
61358
  });
61270
61359
  } else {
61271
61360
  const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
@@ -61274,6 +61363,29 @@ var ElementModel = class _ElementModel {
61274
61363
  this.root.set(_ElementModel.KEYS.points, yArray);
61275
61364
  }
61276
61365
  }
61366
+ setPointsPerformance(points) {
61367
+ this.localPoints = points;
61368
+ this.onVectorUpdate();
61369
+ if (this.setPointsTimer) {
61370
+ window.clearTimeout(this.setPointsTimer);
61371
+ }
61372
+ this.setPointsTimer = window.setTimeout(() => {
61373
+ if (this.root.doc) {
61374
+ this.root.doc.transact(() => {
61375
+ const yArray = this.root.get(_ElementModel.KEYS.points);
61376
+ if (yArray) {
61377
+ yArray.delete(0, yArray.length);
61378
+ yArray.push(points);
61379
+ }
61380
+ });
61381
+ } else {
61382
+ const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
61383
+ yArray.delete(0, yArray.length);
61384
+ yArray.push(points);
61385
+ this.root.set(_ElementModel.KEYS.points, yArray);
61386
+ }
61387
+ }, 100);
61388
+ }
61277
61389
  appendPointsMatrix(matrix) {
61278
61390
  const current = new this.scope.Matrix(this.pointsMatrix);
61279
61391
  const next = matrix.appended(current);
@@ -61368,47 +61480,53 @@ function _toPrimitive3(t, r) {
61368
61480
  return ("string" === r ? String : Number)(t);
61369
61481
  }
61370
61482
  var CurveModel = class extends ElementModel {
61371
- constructor(root, scope, liveCursor) {
61372
- super(root, scope, liveCursor);
61483
+ constructor(root, scope, liveCursor, isPerformanceMode) {
61484
+ super(root, scope, liveCursor, isPerformanceMode);
61373
61485
  _defineProperty3(this, "item", null);
61374
- _defineProperty3(this, "debugPath", void 0);
61375
61486
  _defineProperty3(this, "debug", false);
61376
- if (!this.root.has("type")) {
61487
+ _defineProperty3(this, "clearLocalPointsWhenYPointsChange", false);
61488
+ _defineProperty3(this, "shouldUseLocalPoints", true);
61489
+ _defineProperty3(this, "localPointsPick", 6);
61490
+ if (!this.root.doc || !this.root.has("type")) {
61377
61491
  this.root.set("type", "curve");
61378
61492
  }
61379
- if (!this.root.has("points")) {
61493
+ if (!this.root.doc || !this.root.has("points")) {
61380
61494
  this.root.set("points", new Y2.Array());
61381
61495
  }
61382
- this.debugPath = new scope.Path();
61383
61496
  }
61384
61497
  average(a2, b2) {
61385
61498
  return (a2 + b2) / 2;
61386
61499
  }
61387
61500
  parsePoints(points) {
61501
+ const hasRealPressure = points.some((p) => p.length >= 3 && p[2] > 0);
61502
+ const viewScale = this.scope.project.view.matrix.scaling.x || 1;
61503
+ const taper = this.strokeWidth * 5 / viewScale;
61504
+ const streamline = Math.min(0.7, 0.7 * viewScale);
61388
61505
  return ae(points, {
61389
61506
  size: this.strokeWidth,
61390
- smoothing: 0.5,
61391
- thinning: -0.5,
61392
- streamline: 0.5,
61393
- simulatePressure: true,
61507
+ smoothing: 0.7,
61508
+ thinning: 0.5,
61509
+ streamline,
61510
+ simulatePressure: !hasRealPressure,
61394
61511
  start: {
61395
- taper: this.strokeWidth * 10,
61512
+ taper,
61396
61513
  cap: true
61397
61514
  },
61398
61515
  end: {
61399
- taper: this.strokeWidth * 20,
61516
+ taper,
61400
61517
  cap: true
61401
61518
  }
61402
61519
  });
61403
61520
  }
61404
61521
  matrixedPoints() {
61405
- const points = this.points;
61522
+ const points = this.localPoints.length === 0 ? this.points : this.localPoints;
61406
61523
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61407
61524
  const output = [];
61408
- for (let i = 0, len = points.length; i < len; i += 2) {
61525
+ for (let i = 0, len = points.length; i < len; i += 3) {
61409
61526
  const p = new this.scope.Point(points[i], points[i + 1]);
61410
61527
  const tp = p.transform(matrix);
61411
- output.push([tp.x, tp.y]);
61528
+ const pressure = points[i + 2] ?? 0;
61529
+ output.push([tp.x, tp.y, pressure]);
61412
61530
  }
61413
61531
  return output;
61414
61532
  }
@@ -61437,34 +61555,30 @@ var CurveModel = class extends ElementModel {
61437
61555
  }
61438
61556
  return path;
61439
61557
  }
61440
- updateDebugPath() {
61441
- this.debugPath = new this.scope.Path();
61442
- const points = (0, import_lodash.chunk)(this.points, 2);
61443
- for (let i = 0, len = points.length; i < len; i++) {
61444
- const point = new this.scope.Point(points[i][0], points[i][1]);
61445
- if (i === 0) {
61446
- this.debugPath.moveTo(point);
61447
- } else {
61448
- this.debugPath.lineTo(point);
61449
- }
61450
- this.debugPath.strokeWidth = 1;
61451
- this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
61452
- }
61453
- }
61454
61558
  onVectorUpdate() {
61455
61559
  if (!this.item) {
61456
61560
  return;
61457
61561
  }
61562
+ const matrixedPts = this.matrixedPoints();
61458
61563
  if (this.debug) {
61459
- this.debugPath.remove();
61460
- this.updateDebugPath();
61461
- }
61462
- const points = this.parsePoints(this.matrixedPoints());
61463
- const path = this.createPath(points);
61464
- this.item.removeSegments();
61465
- this.item.addSegments(path.segments);
61466
- if (this.debug) {
61467
- this.item.addChild(this.debugPath);
61564
+ const path = new this.scope.Path();
61565
+ for (let i = 0; i < matrixedPts.length; i++) {
61566
+ const p = new this.scope.Point(matrixedPts[i][0], matrixedPts[i][1]);
61567
+ if (i === 0) {
61568
+ path.moveTo(p);
61569
+ } else {
61570
+ path.lineTo(p);
61571
+ }
61572
+ }
61573
+ this.item.removeSegments();
61574
+ this.item.addSegments(path.segments);
61575
+ this.item.fillColor = null;
61576
+ this.item.strokeWidth = this.strokeWidth;
61577
+ } else {
61578
+ const points = this.parsePoints(matrixedPts);
61579
+ const path = this.createPath(points);
61580
+ this.item.removeSegments();
61581
+ this.item.addSegments(path.segments);
61468
61582
  }
61469
61583
  }
61470
61584
  createPaperItem() {
@@ -61487,11 +61601,11 @@ var CurveModel = class extends ElementModel {
61487
61601
  }
61488
61602
  liveCursorPoint() {
61489
61603
  const yArray = this.root.get(ElementModel.KEYS.points);
61490
- if (yArray.length < 2) {
61604
+ if (yArray.length < 3) {
61491
61605
  return null;
61492
61606
  }
61493
61607
  const len = yArray.length;
61494
- const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
61608
+ const point = new this.scope.Point(yArray.get(len - 3), yArray.get(len - 2));
61495
61609
  return point.transform(new this.scope.Matrix(this.pointsMatrix));
61496
61610
  }
61497
61611
  onStyleKeyUpdate(key) {
@@ -61526,15 +61640,24 @@ function _toPrimitive4(t, r) {
61526
61640
  return ("string" === r ? String : Number)(t);
61527
61641
  }
61528
61642
  var SelectorModel = class extends ElementModel {
61529
- constructor(root, scope, liveCursor) {
61530
- super(root, scope, liveCursor);
61643
+ get drawPoints() {
61644
+ if (this.localPoints.length >= 4) {
61645
+ return this.localPoints;
61646
+ }
61647
+ return this.points;
61648
+ }
61649
+ constructor(root, scope, liveCursor, isPerformanceMode) {
61650
+ super(root, scope, liveCursor, isPerformanceMode);
61531
61651
  _defineProperty4(this, "item", null);
61532
- if (!this.root.has("type")) {
61652
+ _defineProperty4(this, "clearLocalPointsWhenYPointsChange", true);
61653
+ _defineProperty4(this, "shouldUseLocalPoints", true);
61654
+ _defineProperty4(this, "localPointsPick", 4);
61655
+ if (this.root.doc && !this.root.has("type")) {
61533
61656
  this.root.set("type", "selector");
61534
61657
  }
61535
- if (!this.root.has("points")) {
61658
+ if (this.root.doc && !this.root.has("points")) {
61536
61659
  const initPoints = new Y3.Array();
61537
- initPoints.push([0, 0, 0, 0, 0]);
61660
+ initPoints.push([0, 0, 0, 0]);
61538
61661
  this.root.set("points", initPoints);
61539
61662
  }
61540
61663
  }
@@ -61545,8 +61668,8 @@ var SelectorModel = class extends ElementModel {
61545
61668
  }
61546
61669
  createPaperRect() {
61547
61670
  const scope = this.scope;
61548
- const bounds = new scope.Rectangle(new scope.Point(this.points[0], this.points[1]), new scope.Size(this.points[2], this.points[3]));
61549
- return new scope.Path.Rectangle(bounds, new scope.Point(this.points[4], this.points[4]));
61671
+ const bounds = new scope.Rectangle(new scope.Point(this.drawPoints[0], this.drawPoints[1]), new scope.Size(this.drawPoints[2], this.drawPoints[3]));
61672
+ return new scope.Path.Rectangle(bounds);
61550
61673
  }
61551
61674
  onVectorUpdate() {
61552
61675
  if (!this.item) {
@@ -61575,7 +61698,7 @@ var SelectorModel = class extends ElementModel {
61575
61698
  onStyleKeyUpdate(_key) {
61576
61699
  }
61577
61700
  };
61578
- var import_lodash2 = __toESM2(require_lodash(), 1);
61701
+ var import_lodash = __toESM2(require_lodash(), 1);
61579
61702
  function _defineProperty5(e, r, t) {
61580
61703
  return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
61581
61704
  }
@@ -61608,7 +61731,7 @@ function serializePath(path) {
61608
61731
  }, []);
61609
61732
  }
61610
61733
  function deserializePath(points, scope, matrix) {
61611
- const segmentGroup = (0, import_lodash2.chunk)(points, 6);
61734
+ const segmentGroup = (0, import_lodash.chunk)(points, 6);
61612
61735
  const path = new scope.Path();
61613
61736
  path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
61614
61737
  return path;
@@ -61618,7 +61741,27 @@ var AnimationFrame = class {
61618
61741
  _defineProperty5(this, "callbacks", []);
61619
61742
  _defineProperty5(this, "lastTime", 0);
61620
61743
  _defineProperty5(this, "fps", 45);
61744
+ _defineProperty5(this, "lastCallbackTime", 0);
61745
+ _defineProperty5(this, "fpsBuffer", []);
61746
+ _defineProperty5(this, "FPS_REPORT_INTERVAL", 2700);
61621
61747
  _defineProperty5(this, "handleCallbacks", () => {
61748
+ const now = performance.now();
61749
+ if (this.lastCallbackTime > 0) {
61750
+ const actualFps = 1e3 / (now - this.lastCallbackTime);
61751
+ this.fpsBuffer.push(actualFps);
61752
+ if (this.fpsBuffer.length >= this.FPS_REPORT_INTERVAL) {
61753
+ const avg = this.fpsBuffer.reduce((a2, b2) => a2 + b2, 0) / this.fpsBuffer.length;
61754
+ const min = Math.min(...this.fpsBuffer);
61755
+ const sorted = [...this.fpsBuffer].sort((a2, b2) => a2 - b2);
61756
+ const p90 = sorted[Math.floor(sorted.length * 0.9)];
61757
+ metrics().gauge("fps", Math.round(avg), {
61758
+ min: Math.round(min),
61759
+ p90: Math.round(p90)
61760
+ });
61761
+ this.fpsBuffer = [];
61762
+ }
61763
+ }
61764
+ this.lastCallbackTime = now;
61622
61765
  const functions = this.callbacks;
61623
61766
  this.callbacks = [];
61624
61767
  for (let i = 0, l2 = functions.length; i < l2; i++) {
@@ -61660,13 +61803,22 @@ function _toPrimitive6(t, r) {
61660
61803
  return ("string" === r ? String : Number)(t);
61661
61804
  }
61662
61805
  var SegmentsModel = class extends ElementModel {
61663
- constructor(root, scope, type, liveCursor) {
61664
- super(root, scope, liveCursor);
61806
+ get drawPoints() {
61807
+ if (this.localPoints.length >= 4) {
61808
+ return this.localPoints;
61809
+ }
61810
+ return this.points;
61811
+ }
61812
+ constructor(root, scope, type, liveCursor, isPerformanceMode) {
61813
+ super(root, scope, liveCursor, isPerformanceMode);
61665
61814
  _defineProperty6(this, "item", null);
61666
- if (!this.root.has("type")) {
61815
+ _defineProperty6(this, "clearLocalPointsWhenYPointsChange", true);
61816
+ _defineProperty6(this, "shouldUseLocalPoints", true);
61817
+ _defineProperty6(this, "localPointsPick", 24);
61818
+ if (this.root.doc && !this.root.has("type")) {
61667
61819
  this.root.set("type", type);
61668
61820
  }
61669
- if (!this.root.has("points")) {
61821
+ if (this.root.doc && !this.root.has("points")) {
61670
61822
  this.root.set("points", new Y4.Array());
61671
61823
  }
61672
61824
  }
@@ -61686,13 +61838,13 @@ var SegmentsModel = class extends ElementModel {
61686
61838
  }
61687
61839
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61688
61840
  this.item.removeSegments();
61689
- const next = deserializePath(this.points, this.scope, matrix);
61841
+ const next = deserializePath(this.drawPoints, this.scope, matrix);
61690
61842
  this.item.addSegments(next.segments);
61691
61843
  this.item.closePath();
61692
61844
  }
61693
61845
  createPaperItem() {
61694
61846
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61695
- this.item = deserializePath(this.points, this.scope, matrix);
61847
+ this.item = deserializePath(this.drawPoints, this.scope, matrix);
61696
61848
  this.item.strokeColor = new this.scope.Color(this.strokeColor);
61697
61849
  this.item.dashArray = this.dashArray;
61698
61850
  this.item.strokeWidth = this.strokeWidth;
@@ -61717,7 +61869,7 @@ var SegmentsModel = class extends ElementModel {
61717
61869
  onStyleKeyUpdate(_key) {
61718
61870
  }
61719
61871
  };
61720
- var import_lodash4 = __toESM2(require_lodash(), 1);
61872
+ var import_lodash3 = __toESM2(require_lodash(), 1);
61721
61873
  function _defineProperty7(e, r, t) {
61722
61874
  return (r = _toPropertyKey7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
61723
61875
  }
@@ -61735,6 +61887,8 @@ function _toPrimitive7(t, r) {
61735
61887
  }
61736
61888
  return ("string" === r ? String : Number)(t);
61737
61889
  }
61890
+ var DRAG_FPS = 10;
61891
+ var DRAG_FRAME_MS = 1e3 / DRAG_FPS;
61738
61892
  var WhiteboardTool = class {
61739
61893
  constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
61740
61894
  _defineProperty7(this, "modelGetter", void 0);
@@ -61743,24 +61897,60 @@ var WhiteboardTool = class {
61743
61897
  _defineProperty7(this, "shadowEmitter", void 0);
61744
61898
  _defineProperty7(this, "enableToolEvent", void 0);
61745
61899
  _defineProperty7(this, "eventAvailable", false);
61900
+ _defineProperty7(this, "lastDragTime", 0);
61901
+ _defineProperty7(this, "dragRafId", 0);
61902
+ _defineProperty7(this, "pendingDragEvent", null);
61746
61903
  _defineProperty7(this, "onMouseDownSelf", (event) => {
61747
61904
  this.eventAvailable = this.enableToolEvent();
61748
61905
  if (!this.eventAvailable) {
61749
61906
  return;
61750
61907
  }
61908
+ this.lastDragTime = 0;
61909
+ if (this.dragRafId) {
61910
+ cancelAnimationFrame(this.dragRafId);
61911
+ this.dragRafId = 0;
61912
+ }
61913
+ this.pendingDragEvent = null;
61751
61914
  this.shadowEmitter.setActive(true);
61752
61915
  this.onMouseDown(event);
61753
61916
  });
61917
+ _defineProperty7(this, "flushPendingDrag", () => {
61918
+ this.dragRafId = 0;
61919
+ if (this.pendingDragEvent) {
61920
+ this.lastDragTime = performance.now();
61921
+ const event = this.pendingDragEvent;
61922
+ this.pendingDragEvent = null;
61923
+ this.onMouseDrag(event);
61924
+ }
61925
+ });
61754
61926
  _defineProperty7(this, "onMouseDragSelf", (event) => {
61755
61927
  if (!this.eventAvailable) {
61756
61928
  return;
61757
61929
  }
61758
- this.onMouseDrag(event);
61930
+ const now = performance.now();
61931
+ if (now - this.lastDragTime >= DRAG_FRAME_MS) {
61932
+ this.lastDragTime = now;
61933
+ this.pendingDragEvent = null;
61934
+ this.onMouseDrag(event);
61935
+ } else {
61936
+ this.pendingDragEvent = event;
61937
+ if (!this.dragRafId) {
61938
+ this.dragRafId = requestAnimationFrame(this.flushPendingDrag);
61939
+ }
61940
+ }
61759
61941
  });
61760
61942
  _defineProperty7(this, "onMouseUpSelf", (event) => {
61761
61943
  if (!this.eventAvailable) {
61762
61944
  return;
61763
61945
  }
61946
+ if (this.dragRafId) {
61947
+ cancelAnimationFrame(this.dragRafId);
61948
+ this.dragRafId = 0;
61949
+ }
61950
+ if (this.pendingDragEvent) {
61951
+ this.onMouseDrag(this.pendingDragEvent);
61952
+ this.pendingDragEvent = null;
61953
+ }
61764
61954
  this.onMouseUp(event);
61765
61955
  this.shadowEmitter.setActive(false);
61766
61956
  });
@@ -61774,7 +61964,7 @@ var WhiteboardTool = class {
61774
61964
  this.tool.onMouseUp = this.onMouseUpSelf;
61775
61965
  }
61776
61966
  };
61777
- var import_lodash3 = __toESM2(require_lodash(), 1);
61967
+ var import_lodash2 = __toESM2(require_lodash(), 1);
61778
61968
  function _defineProperty8(e, r, t) {
61779
61969
  return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
61780
61970
  }
@@ -61823,7 +62013,7 @@ var LineTool = class extends WhiteboardTool {
61823
62013
  const point = path.getPointAt(distance);
61824
62014
  return [point.x, point.y];
61825
62015
  });
61826
- this.elementModel.setPoints((0, import_lodash3.flattenDeep)(points));
62016
+ this.elementModel.setPoints((0, import_lodash2.flattenDeep)(points));
61827
62017
  }
61828
62018
  }
61829
62019
  onMouseUp(_event) {
@@ -61851,6 +62041,12 @@ function _toPrimitive9(t, r) {
61851
62041
  return ("string" === r ? String : Number)(t);
61852
62042
  }
61853
62043
  var LineModel = class extends ElementModel {
62044
+ get drawPoints() {
62045
+ if (this.localPoints.length > 0) {
62046
+ return this.localPoints;
62047
+ }
62048
+ return this.points;
62049
+ }
61854
62050
  get arrowSize() {
61855
62051
  return this.strokeWidth * 5 + 15;
61856
62052
  }
@@ -61866,20 +62062,23 @@ var LineModel = class extends ElementModel {
61866
62062
  set tailArrow(value) {
61867
62063
  this.root.set("tailArrow", value);
61868
62064
  }
61869
- constructor(root, scope, liveCursor) {
61870
- super(root, scope, liveCursor);
62065
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62066
+ super(root, scope, liveCursor, isPerformanceMode);
61871
62067
  _defineProperty9(this, "controlledPoints", []);
62068
+ _defineProperty9(this, "clearLocalPointsWhenYPointsChange", true);
62069
+ _defineProperty9(this, "shouldUseLocalPoints", true);
62070
+ _defineProperty9(this, "localPointsPick", 99);
61872
62071
  _defineProperty9(this, "item", null);
61873
- if (!this.root.has("type")) {
62072
+ if (this.root.doc && !this.root.has("type")) {
61874
62073
  this.root.set("type", "arrow");
61875
62074
  }
61876
- if (!this.root.has("points")) {
62075
+ if (this.root.doc && !this.root.has("points")) {
61877
62076
  this.root.set("points", new Y5.Array());
61878
62077
  }
61879
- if (!this.root.has("headArrow")) {
62078
+ if (this.root.doc && !this.root.has("headArrow")) {
61880
62079
  this.root.set("headArrow", "none");
61881
62080
  }
61882
- if (!this.root.has("tailArrow")) {
62081
+ if (this.root.doc && !this.root.has("tailArrow")) {
61883
62082
  this.root.set("tailArrow", "normal");
61884
62083
  }
61885
62084
  }
@@ -61895,7 +62094,7 @@ var LineModel = class extends ElementModel {
61895
62094
  }
61896
62095
  renderLine() {
61897
62096
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61898
- const papperPoints = (0, import_lodash4.chunk)(this.points, 2).map((item) => {
62097
+ const papperPoints = (0, import_lodash3.chunk)(this.drawPoints, 2).map((item) => {
61899
62098
  return new this.scope.Point(item[0], item[1]).transform(matrix);
61900
62099
  });
61901
62100
  const path = new this.scope.Path();
@@ -62009,13 +62208,14 @@ var LineControlPoint = class {
62009
62208
  if (this.position) {
62010
62209
  return this.model.scope.project.view.projectToView(this.position.transform(matrix));
62011
62210
  }
62211
+ const points = this.model["drawPoints"];
62012
62212
  const from = {
62013
- x: this.model.points[0],
62014
- y: this.model.points[1]
62213
+ x: points[0],
62214
+ y: points[1]
62015
62215
  };
62016
62216
  const to = {
62017
- x: this.model.points[this.model.points.length - 2],
62018
- y: this.model.points[this.model.points.length - 1]
62217
+ x: points[points.length - 2],
62218
+ y: points[points.length - 1]
62019
62219
  };
62020
62220
  const clonedPath = new this.scope.Path.Line(from, to);
62021
62221
  this.position = clonedPath.getPointAt(clonedPath.length * distance);
@@ -62028,9 +62228,9 @@ var LineControlPoint = class {
62028
62228
  }
62029
62229
  const pointsMatrix = new this.model.scope.Matrix(this.model.pointsMatrix);
62030
62230
  const invertedPoint = point.transform(pointsMatrix.inverted());
62031
- const points = this.model.points;
62231
+ const points = this.model["drawPoints"];
62032
62232
  this.position = invertedPoint;
62033
- const clonedPoints = (0, import_lodash4.cloneDeep)(points);
62233
+ const clonedPoints = (0, import_lodash3.cloneDeep)(points);
62034
62234
  clonedPoints[this.options.index * 2] = invertedPoint.x;
62035
62235
  clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
62036
62236
  this.model.setPoints(clonedPoints);
@@ -62072,9 +62272,18 @@ var PointTextModel = class extends ElementModel {
62072
62272
  set fontFamily(value) {
62073
62273
  this.root.set("font-family", value);
62074
62274
  }
62075
- constructor(root, scope, liveCursor) {
62076
- super(root, scope, liveCursor);
62275
+ get drawPoints() {
62276
+ if (this.localPoints.length > 1) {
62277
+ return this.localPoints;
62278
+ }
62279
+ return this.points;
62280
+ }
62281
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62282
+ super(root, scope, liveCursor, isPerformanceMode);
62077
62283
  _defineProperty10(this, "item", null);
62284
+ _defineProperty10(this, "clearLocalPointsWhenYPointsChange", true);
62285
+ _defineProperty10(this, "shouldUseLocalPoints", false);
62286
+ _defineProperty10(this, "localPointsPick", 2);
62078
62287
  _defineProperty10(this, "handleTextPropChange", (event) => {
62079
62288
  if (!this.item) {
62080
62289
  return;
@@ -62091,18 +62300,20 @@ var PointTextModel = class extends ElementModel {
62091
62300
  }
62092
62301
  }
62093
62302
  });
62094
- if (!this.root.has("type")) {
62303
+ if (this.root.doc && !this.root.has("type")) {
62095
62304
  this.root.set("type", "point-text");
62096
62305
  }
62097
- if (!this.root.has(ElementModel.KEYS.points)) {
62306
+ if (this.root.doc && !this.root.has(ElementModel.KEYS.points)) {
62098
62307
  this.root.set(ElementModel.KEYS.points, new Y6.Array());
62099
62308
  }
62100
62309
  this.root.observe(this.handleTextPropChange);
62101
- if (this.root.has("font-size")) {
62102
- setTimeout(() => {
62103
- this.updateTextPosition();
62104
- }, 60);
62105
- }
62310
+ setTimeout(() => {
62311
+ if (this.root && this.root.has("font-size")) {
62312
+ setTimeout(() => {
62313
+ this.updateTextPosition();
62314
+ }, 60);
62315
+ }
62316
+ }, 60);
62106
62317
  }
62107
62318
  subDispose() {
62108
62319
  removeObserver(this.root, this.handleTextPropChange);
@@ -62120,10 +62331,11 @@ var PointTextModel = class extends ElementModel {
62120
62331
  if (!this.item) {
62121
62332
  return null;
62122
62333
  }
62334
+ console.log("[][][] drawPoints", this.drawPoints);
62123
62335
  const bounds = this.item.internalBounds;
62124
62336
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62125
- const topLeft = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
62126
- const topRight = new this.scope.Point(this.points[0] + bounds.width, this.points[1]).transform(matrix);
62337
+ const topLeft = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
62338
+ const topRight = new this.scope.Point(this.drawPoints[0] + bounds.width, this.drawPoints[1]).transform(matrix);
62127
62339
  let scaleX = topRight.getDistance(topLeft) / bounds.width;
62128
62340
  scaleX = Number.isNaN(scaleX) ? 1 : scaleX;
62129
62341
  const angle = topRight.subtract(topLeft).angle;
@@ -62208,13 +62420,22 @@ function _toPrimitive11(t, r) {
62208
62420
  return ("string" === r ? String : Number)(t);
62209
62421
  }
62210
62422
  var TriangleModel = class extends ElementModel {
62211
- constructor(root, scope, liveCursor) {
62212
- super(root, scope, liveCursor);
62423
+ get drawPoints() {
62424
+ if (this.localPoints.length >= 6) {
62425
+ return this.localPoints;
62426
+ }
62427
+ return this.points;
62428
+ }
62429
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62430
+ super(root, scope, liveCursor, isPerformanceMode);
62213
62431
  _defineProperty11(this, "item", null);
62214
- if (!this.root.has("type")) {
62432
+ _defineProperty11(this, "clearLocalPointsWhenYPointsChange", true);
62433
+ _defineProperty11(this, "shouldUseLocalPoints", true);
62434
+ _defineProperty11(this, "localPointsPick", 6);
62435
+ if (this.root.doc && !this.root.has("type")) {
62215
62436
  this.root.set("type", "triangle");
62216
62437
  }
62217
- if (!this.root.has("points")) {
62438
+ if (this.root.doc && !this.root.has("points")) {
62218
62439
  this.root.set("points", new Y7.Array());
62219
62440
  }
62220
62441
  }
@@ -62246,9 +62467,9 @@ var TriangleModel = class extends ElementModel {
62246
62467
  return;
62247
62468
  }
62248
62469
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62249
- const p1 = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
62250
- const p2 = new this.scope.Point(this.points[2], this.points[3]).transform(matrix);
62251
- const p3 = new this.scope.Point(this.points[4], this.points[5]).transform(matrix);
62470
+ const p1 = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]).transform(matrix);
62471
+ const p2 = new this.scope.Point(this.drawPoints[2], this.drawPoints[3]).transform(matrix);
62472
+ const p3 = new this.scope.Point(this.drawPoints[4], this.drawPoints[5]).transform(matrix);
62252
62473
  this.item.removeSegments();
62253
62474
  this.item.moveTo(p1);
62254
62475
  this.item.lineTo(p2);
@@ -62260,7 +62481,7 @@ var TriangleModel = class extends ElementModel {
62260
62481
  config.controlPoints.push({
62261
62482
  name: "triangle",
62262
62483
  getPosition: () => {
62263
- const point = new this.scope.Point(this.points[0], this.points[1]);
62484
+ const point = new this.scope.Point(this.drawPoints[0], this.drawPoints[1]);
62264
62485
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62265
62486
  return this.scope.project.view.projectToView(point.transform(pointsMatrix));
62266
62487
  },
@@ -62270,7 +62491,7 @@ var TriangleModel = class extends ElementModel {
62270
62491
  }
62271
62492
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62272
62493
  const trPoint = point.transform(pointsMatrix.inverted());
62273
- const oldPoints = this.points;
62494
+ const oldPoints = this.drawPoints;
62274
62495
  this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3], oldPoints[4], oldPoints[5]]);
62275
62496
  }
62276
62497
  });
@@ -62306,25 +62527,34 @@ function _toPrimitive12(t, r) {
62306
62527
  return ("string" === r ? String : Number)(t);
62307
62528
  }
62308
62529
  var RectangleModel = class extends ElementModel {
62309
- constructor(root, scope, liveCursor) {
62310
- super(root, scope, liveCursor);
62530
+ get drawPoints() {
62531
+ if (this.localPoints.length >= 4) {
62532
+ return this.localPoints;
62533
+ }
62534
+ return this.points;
62535
+ }
62536
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62537
+ super(root, scope, liveCursor, isPerformanceMode);
62311
62538
  _defineProperty12(this, "item", null);
62312
- if (!this.root.has("type")) {
62539
+ _defineProperty12(this, "clearLocalPointsWhenYPointsChange", true);
62540
+ _defineProperty12(this, "shouldUseLocalPoints", true);
62541
+ _defineProperty12(this, "localPointsPick", 4);
62542
+ if (this.root.doc && !this.root.has("type")) {
62313
62543
  this.root.set("type", "rectangle");
62314
62544
  }
62315
- if (!this.root.has("points")) {
62545
+ if (this.root.doc && !this.root.has("points")) {
62316
62546
  const initPoints = new Y8.Array();
62317
62547
  initPoints.push([0, 0, 0, 0]);
62318
62548
  this.root.set("points", initPoints);
62319
62549
  }
62320
- if (!this.root.has("radius")) {
62550
+ if (this.root.doc && !this.root.has("radius")) {
62321
62551
  this.root.set("radius", 0);
62322
62552
  }
62323
62553
  }
62324
62554
  subDispose() {
62325
62555
  }
62326
62556
  liveCursorPoint() {
62327
- const points = this.points;
62557
+ const points = this.drawPoints;
62328
62558
  if (points.length < 4) {
62329
62559
  return null;
62330
62560
  }
@@ -62332,7 +62562,7 @@ var RectangleModel = class extends ElementModel {
62332
62562
  return new this.scope.Point(points[2], points[3]).transform(matrix);
62333
62563
  }
62334
62564
  createSegments() {
62335
- const [a2, b2, c, d] = this.points;
62565
+ const [a2, b2, c, d] = this.drawPoints;
62336
62566
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62337
62567
  const maxRadius = this.maxRadiusLength();
62338
62568
  const radius = this.root.get("radius") * maxRadius;
@@ -62397,7 +62627,7 @@ var RectangleModel = class extends ElementModel {
62397
62627
  }
62398
62628
  maxRadiusLength() {
62399
62629
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62400
- const points = this.points;
62630
+ const points = this.drawPoints;
62401
62631
  const topLeft = new this.scope.Point(points[0], points[1]).transform(pointsMatrix);
62402
62632
  const topRight = new this.scope.Point(points[2], points[1]).transform(pointsMatrix);
62403
62633
  const bottomLeft = new this.scope.Point(points[0], points[3]).transform(pointsMatrix);
@@ -62422,7 +62652,7 @@ var RectangleModel = class extends ElementModel {
62422
62652
  name: "rect-radius",
62423
62653
  getPosition: () => {
62424
62654
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62425
- const points = this.points;
62655
+ const points = this.drawPoints;
62426
62656
  const radius = this.root.get("radius") * this.maxRadiusLength();
62427
62657
  let c1 = new this.scope.Point(points[0], points[1]).transform(matrix);
62428
62658
  const c3 = new this.scope.Point(points[2], points[3]).transform(matrix);
@@ -62441,7 +62671,7 @@ var RectangleModel = class extends ElementModel {
62441
62671
  if (!this.item) {
62442
62672
  return;
62443
62673
  }
62444
- const points = this.points;
62674
+ const points = this.drawPoints;
62445
62675
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62446
62676
  const maxRadius = Math.min(points[2] - points[0], points[3] - points[1]) / 2;
62447
62677
  const trPoint = point.transform(pointsMatrix.inverted());
@@ -62466,7 +62696,7 @@ var RectangleModel = class extends ElementModel {
62466
62696
  }
62467
62697
  };
62468
62698
  var elementsUndoOrigin = "elementsUndoOrigin";
62469
- var import_lodash5 = __toESM2(require_lodash(), 1);
62699
+ var import_lodash4 = __toESM2(require_lodash(), 1);
62470
62700
  function _defineProperty13(e, r, t) {
62471
62701
  return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62472
62702
  }
@@ -62485,14 +62715,23 @@ function _toPrimitive13(t, r) {
62485
62715
  return ("string" === r ? String : Number)(t);
62486
62716
  }
62487
62717
  var EraserModel = class extends ElementModel {
62488
- constructor(root, scope, liveCursor) {
62489
- super(root, scope, liveCursor);
62718
+ get drawPoints() {
62719
+ if (this.localPoints.length > 0) {
62720
+ return this.localPoints;
62721
+ }
62722
+ return this.points;
62723
+ }
62724
+ constructor(root, scope, liveCursor, isPerformanceMode) {
62725
+ super(root, scope, liveCursor, isPerformanceMode);
62490
62726
  _defineProperty13(this, "item", null);
62491
62727
  _defineProperty13(this, "sliceBegin", 0);
62492
- if (!this.root.has("type")) {
62728
+ _defineProperty13(this, "clearLocalPointsWhenYPointsChange", false);
62729
+ _defineProperty13(this, "shouldUseLocalPoints", true);
62730
+ _defineProperty13(this, "localPointsPick", 4);
62731
+ if (this.root.doc && !this.root.has("type")) {
62493
62732
  this.root.set("type", "eraser");
62494
62733
  }
62495
- if (!this.root.has("points")) {
62734
+ if (this.root.doc && !this.root.has("points")) {
62496
62735
  this.root.set("points", new Y9.Array());
62497
62736
  }
62498
62737
  }
@@ -62525,7 +62764,7 @@ var EraserModel = class extends ElementModel {
62525
62764
  return path;
62526
62765
  }
62527
62766
  parsePoints(points) {
62528
- const groupPoints = (0, import_lodash5.chunk)(points, 2);
62767
+ const groupPoints = (0, import_lodash4.chunk)(points, 2);
62529
62768
  return ae(groupPoints, {
62530
62769
  size: this.strokeWidth,
62531
62770
  smoothing: 0.5,
@@ -62543,7 +62782,7 @@ var EraserModel = class extends ElementModel {
62543
62782
  });
62544
62783
  }
62545
62784
  matrixedPoints() {
62546
- const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
62785
+ const currentPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
62547
62786
  return currentPoints.map((_ref) => {
62548
62787
  let [x, y] = _ref;
62549
62788
  return new this.scope.Point(x, y);
@@ -62571,11 +62810,11 @@ var EraserModel = class extends ElementModel {
62571
62810
  this.item.fillColor = new this.scope.Color(this.strokeColor);
62572
62811
  this.onVectorUpdate();
62573
62812
  this.item.onFrame = () => {
62574
- if (!this.points) {
62813
+ if (!this.drawPoints) {
62575
62814
  return;
62576
62815
  }
62577
- if (this.points.length / 2 > 50) {
62578
- this.sliceBegin = this.points.length / 2 - 50;
62816
+ if (this.drawPoints.length / 2 > 50) {
62817
+ this.sliceBegin = this.drawPoints.length / 2 - 50;
62579
62818
  }
62580
62819
  };
62581
62820
  }
@@ -62606,7 +62845,7 @@ var EraserModel = class extends ElementModel {
62606
62845
  return point.transform(new this.scope.Matrix(this.pointsMatrix));
62607
62846
  }
62608
62847
  };
62609
- var import_lodash6 = __toESM2(require_lodash(), 1);
62848
+ var import_lodash5 = __toESM2(require_lodash(), 1);
62610
62849
  function _defineProperty14(e, r, t) {
62611
62850
  return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62612
62851
  }
@@ -62625,21 +62864,24 @@ function _toPrimitive14(t, r) {
62625
62864
  return ("string" === r ? String : Number)(t);
62626
62865
  }
62627
62866
  var LaserPointerModel = class extends ElementModel {
62628
- constructor(clientId, root, scope, liveCursor, removeElement) {
62629
- super(root, scope, liveCursor);
62867
+ constructor(clientId, root, scope, liveCursor, removeElement, isPerformanceMode) {
62868
+ super(root, scope, liveCursor, isPerformanceMode);
62630
62869
  _defineProperty14(this, "item", null);
62631
62870
  _defineProperty14(this, "clientId", void 0);
62632
62871
  _defineProperty14(this, "sliceBegin", 0);
62633
62872
  _defineProperty14(this, "displayStrokeWidth", 8);
62634
62873
  _defineProperty14(this, "cachedPoints", null);
62874
+ _defineProperty14(this, "clearLocalPointsWhenYPointsChange", false);
62875
+ _defineProperty14(this, "shouldUseLocalPoints", false);
62876
+ _defineProperty14(this, "localPointsPick", 4);
62635
62877
  this.clientId = clientId;
62636
- if (!this.root.has("type")) {
62878
+ if (this.root.doc && !this.root.has("type")) {
62637
62879
  this.root.set("type", "laser");
62638
62880
  }
62639
- if (!this.root.has("points")) {
62881
+ if (this.root.doc && !this.root.has("points")) {
62640
62882
  this.root.set("points", new Y10.Array());
62641
62883
  }
62642
- if (!this.root.has("removed")) {
62884
+ if (this.root.doc && !this.root.has("removed")) {
62643
62885
  this.root.set("removed", false);
62644
62886
  }
62645
62887
  this.root.observe((event) => {
@@ -62719,7 +62961,8 @@ var LaserPointerModel = class extends ElementModel {
62719
62961
  matrixedPoints() {
62720
62962
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62721
62963
  const points = this.cachedPoints || this.points;
62722
- const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
62964
+ console.log("[][][] ,", this.points.length, this.cachedPoints?.length, this.localPoints.length);
62965
+ const groupPoints = (0, import_lodash5.chunk)(points, 2).slice(this.sliceBegin);
62723
62966
  return groupPoints.map((_ref) => {
62724
62967
  let [x, y] = _ref;
62725
62968
  return matrix.transform([x, y]);
@@ -62795,7 +63038,7 @@ var WhiteboardPermissions = class extends AbstractApplicationPermissions {
62795
63038
  return [WhiteboardPermissionFlag.draw, WhiteboardPermissionFlag.editSelf, WhiteboardPermissionFlag.editOthers, WhiteboardPermissionFlag.deleteSelf, WhiteboardPermissionFlag.deleteOthers, WhiteboardPermissionFlag.mainView, WhiteboardPermissionFlag.setOthersView].filter((v) => (v & value) !== 0);
62796
63039
  }
62797
63040
  };
62798
- var import_lodash7 = __toESM2(require_lodash(), 1);
63041
+ var import_lodash6 = __toESM2(require_lodash(), 1);
62799
63042
  function _defineProperty15(e, r, t) {
62800
63043
  return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62801
63044
  }
@@ -62814,13 +63057,22 @@ function _toPrimitive15(t, r) {
62814
63057
  return ("string" === r ? String : Number)(t);
62815
63058
  }
62816
63059
  var StraightLineModel = class extends ElementModel {
62817
- constructor(root, scope, liveCursor) {
62818
- super(root, scope, liveCursor);
63060
+ get drawPoints() {
63061
+ if (this.localPoints.length >= 4) {
63062
+ return this.localPoints;
63063
+ }
63064
+ return this.points;
63065
+ }
63066
+ constructor(root, scope, liveCursor, isPerformanceMode) {
63067
+ super(root, scope, liveCursor, isPerformanceMode);
62819
63068
  _defineProperty15(this, "item", null);
62820
- if (!this.root.has("type")) {
63069
+ _defineProperty15(this, "clearLocalPointsWhenYPointsChange", true);
63070
+ _defineProperty15(this, "shouldUseLocalPoints", true);
63071
+ _defineProperty15(this, "localPointsPick", 4);
63072
+ if (this.root.doc && !this.root.has("type")) {
62821
63073
  this.root.set("type", "line");
62822
63074
  }
62823
- if (!this.root.has("points")) {
63075
+ if (this.root.doc && !this.root.has("points")) {
62824
63076
  this.root.set("points", new Y11.Array());
62825
63077
  }
62826
63078
  }
@@ -62845,7 +63097,7 @@ var StraightLineModel = class extends ElementModel {
62845
63097
  }
62846
63098
  renderLine() {
62847
63099
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62848
- const papperPoints = (0, import_lodash7.chunk)(this.points, 2).map((item) => {
63100
+ const papperPoints = (0, import_lodash6.chunk)(this.drawPoints, 2).map((item) => {
62849
63101
  return new this.scope.Point(item[0], item[1]).transform(matrix);
62850
63102
  });
62851
63103
  const path = new this.scope.Path();
@@ -62867,7 +63119,7 @@ var StraightLineModel = class extends ElementModel {
62867
63119
  name: "line-start",
62868
63120
  getPosition: () => {
62869
63121
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62870
- const points = this.points;
63122
+ const points = this.drawPoints;
62871
63123
  const start = new this.scope.Point(points[0], points[1]);
62872
63124
  return this.scope.project.view.projectToView(start.transform(matrix));
62873
63125
  },
@@ -62877,14 +63129,15 @@ var StraightLineModel = class extends ElementModel {
62877
63129
  }
62878
63130
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62879
63131
  const trPoint = point.transform(pointsMatrix.inverted());
62880
- this.setPoints([trPoint.x, trPoint.y, this.points[2], this.points[3]]);
63132
+ const oldPoints = this.drawPoints;
63133
+ this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3]]);
62881
63134
  }
62882
63135
  });
62883
63136
  cfg.controlPoints.push({
62884
63137
  name: "line-end",
62885
63138
  getPosition: () => {
62886
63139
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62887
- const points = this.points;
63140
+ const points = this.drawPoints;
62888
63141
  const end = new this.scope.Point(points[2], points[3]);
62889
63142
  return this.scope.project.view.projectToView(end.transform(matrix));
62890
63143
  },
@@ -62894,7 +63147,8 @@ var StraightLineModel = class extends ElementModel {
62894
63147
  }
62895
63148
  const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
62896
63149
  const trPoint = point.transform(pointsMatrix.inverted());
62897
- this.setPoints([this.points[0], this.points[1], trPoint.x, trPoint.y]);
63150
+ const oldPoints = this.drawPoints;
63151
+ this.setPoints([oldPoints[0], oldPoints[1], trPoint.x, trPoint.y]);
62898
63152
  }
62899
63153
  });
62900
63154
  return cfg;
@@ -62938,10 +63192,13 @@ var ImageModel = class extends ElementModel {
62938
63192
  get src() {
62939
63193
  return this.root.get("src");
62940
63194
  }
62941
- constructor(root, scope, imageSets, liveCursor) {
62942
- super(root, scope, liveCursor);
63195
+ constructor(root, scope, imageSets, liveCursor, isPerformanceMode) {
63196
+ super(root, scope, liveCursor, isPerformanceMode);
62943
63197
  _defineProperty16(this, "item", null);
62944
63198
  _defineProperty16(this, "imageSets", void 0);
63199
+ _defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
63200
+ _defineProperty16(this, "shouldUseLocalPoints", true);
63201
+ _defineProperty16(this, "localPointsPick", 4);
62945
63202
  this.imageSets = imageSets;
62946
63203
  if (!this.root.has("type")) {
62947
63204
  this.root.set("type", "image");
@@ -63022,7 +63279,7 @@ var RenderableModel = class extends EventEmitter {
63022
63279
  get uuid() {
63023
63280
  return uuidv4().replace(/-/g, "");
63024
63281
  }
63025
- constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
63282
+ constructor(options) {
63026
63283
  super();
63027
63284
  _defineProperty17(this, "scope", void 0);
63028
63285
  _defineProperty17(this, "toolbarModel", void 0);
@@ -63035,6 +63292,7 @@ var RenderableModel = class extends EventEmitter {
63035
63292
  _defineProperty17(this, "shadowEmitter", void 0);
63036
63293
  _defineProperty17(this, "imageSets", void 0);
63037
63294
  _defineProperty17(this, "liveCursor", void 0);
63295
+ _defineProperty17(this, "isPerformanceMode", void 0);
63038
63296
  _defineProperty17(this, "onElementsChange", (event) => {
63039
63297
  for (const [key, value] of event.changes.keys.entries()) {
63040
63298
  if (value.action === "add") {
@@ -63053,15 +63311,16 @@ var RenderableModel = class extends EventEmitter {
63053
63311
  }
63054
63312
  }
63055
63313
  });
63056
- this.liveCursor = liveCursor;
63057
- this.imageSets = imageSets;
63058
- this.hasPermission = hasPermission;
63059
- this.shadowEmitter = shadowEmitter;
63060
- this.layerId = layerId;
63061
- this.userManager = userManager;
63062
- this.elements = elements;
63063
- this.scope = scope;
63064
- this.toolbarModel = toolbarModel;
63314
+ this.isPerformanceMode = options.isPerformanceMode;
63315
+ this.liveCursor = options.liveCursor;
63316
+ this.imageSets = options.imageSets;
63317
+ this.hasPermission = options.hasPermission;
63318
+ this.shadowEmitter = options.shadowEmitter;
63319
+ this.layerId = options.layerId;
63320
+ this.userManager = options.userManager;
63321
+ this.elements = options.elements;
63322
+ this.scope = options.scope;
63323
+ this.toolbarModel = options.toolbarModel;
63065
63324
  this.elementModels = /* @__PURE__ */ new Map();
63066
63325
  for (const key of this.elements.keys()) {
63067
63326
  const type = this.elements.get(key)?.get("type");
@@ -63092,30 +63351,38 @@ var RenderableModel = class extends EventEmitter {
63092
63351
  convertToModel(yMap) {
63093
63352
  const type = yMap.get("type");
63094
63353
  let model = null;
63354
+ const uuid = yMap.get(ElementModel.KEYS.uuid);
63355
+ if (uuid) {
63356
+ const existingModel = this.elementModels.get(uuid);
63357
+ if (existingModel) {
63358
+ existingModel.shadowEmitter = this.shadowEmitter;
63359
+ return existingModel;
63360
+ }
63361
+ }
63095
63362
  if (type === "curve") {
63096
- model = new CurveModel(yMap, this.scope, this.liveCursor);
63363
+ model = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63097
63364
  } else if (["ellipse"].indexOf(type) >= 0) {
63098
- model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
63365
+ model = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
63099
63366
  } else if (type === "selector") {
63100
- model = new SelectorModel(yMap, this.scope, this.liveCursor);
63367
+ model = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63101
63368
  } else if (type === "arrow") {
63102
- model = new LineModel(yMap, this.scope, this.liveCursor);
63369
+ model = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63103
63370
  } else if (type === "line") {
63104
- model = new StraightLineModel(yMap, this.scope, this.liveCursor);
63371
+ model = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63105
63372
  } else if (type === "point-text") {
63106
- model = new PointTextModel(yMap, this.scope, this.liveCursor);
63373
+ model = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63107
63374
  } else if (type === "triangle") {
63108
- model = new TriangleModel(yMap, this.scope, this.liveCursor);
63375
+ model = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63109
63376
  } else if (type === "rectangle") {
63110
- model = new RectangleModel(yMap, this.scope, this.liveCursor);
63377
+ model = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63111
63378
  } else if (type === "eraser") {
63112
- model = new EraserModel(yMap, this.scope, this.liveCursor);
63379
+ model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63113
63380
  } else if (type === "laser") {
63114
- model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
63115
- this.removeElementItem(uuid);
63116
- });
63381
+ model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
63382
+ this.removeElementItem(uuid2);
63383
+ }, this.isPerformanceMode);
63117
63384
  } else if (type === "image") {
63118
- model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
63385
+ model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
63119
63386
  }
63120
63387
  if (model) {
63121
63388
  model.shadowEmitter = this.shadowEmitter;
@@ -63149,7 +63416,7 @@ var RenderableModel = class extends EventEmitter {
63149
63416
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63150
63417
  this.elements.set(uuid, yMap);
63151
63418
  }, elementsUndoOrigin);
63152
- const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
63419
+ const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor, this.isPerformanceMode);
63153
63420
  model.root.set("src", src);
63154
63421
  const initMatrix = new this.scope.Matrix();
63155
63422
  const center = this.scope.project.view.center;
@@ -63166,8 +63433,10 @@ var RenderableModel = class extends EventEmitter {
63166
63433
  return null;
63167
63434
  }
63168
63435
  const yMap = new Y12.Map();
63436
+ const uuid = this.uuid;
63437
+ const curveModel = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63438
+ this.elementModels.set(uuid, curveModel);
63169
63439
  this.elements.doc?.transact(() => {
63170
- const uuid = this.uuid;
63171
63440
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63172
63441
  yMap.set(ElementModel.KEYS.uuid, uuid);
63173
63442
  yMap.set("type", "curve");
@@ -63180,7 +63449,6 @@ var RenderableModel = class extends EventEmitter {
63180
63449
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63181
63450
  this.elements.set(uuid, yMap);
63182
63451
  }, elementsUndoOrigin);
63183
- const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
63184
63452
  this.initElement(curveModel);
63185
63453
  return curveModel;
63186
63454
  }
@@ -63189,11 +63457,17 @@ var RenderableModel = class extends EventEmitter {
63189
63457
  return null;
63190
63458
  }
63191
63459
  const yMap = new Y12.Map();
63460
+ const uuid = this.uuid;
63461
+ const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
63462
+ this.removeElementItem(uuid2);
63463
+ }, this.isPerformanceMode);
63464
+ this.elementModels.set(uuid, model);
63192
63465
  this.elements.doc?.transact(() => {
63193
- const uuid = this.uuid;
63194
63466
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63195
63467
  yMap.set(ElementModel.KEYS.uuid, uuid);
63196
63468
  yMap.set("type", "laser");
63469
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63470
+ yMap.set("removed", false);
63197
63471
  yMap.set(ElementModel.KEYS.shadow, "layer");
63198
63472
  yMap.set(ElementModel.KEYS.strokeWidth, 8);
63199
63473
  yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
@@ -63201,9 +63475,7 @@ var RenderableModel = class extends EventEmitter {
63201
63475
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63202
63476
  this.elements.set(uuid, yMap);
63203
63477
  }, elementsUndoOrigin);
63204
- const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
63205
- this.removeElementItem(uuid);
63206
- });
63478
+ this.initElement(model);
63207
63479
  return model;
63208
63480
  }
63209
63481
  createEraser() {
@@ -63211,11 +63483,14 @@ var RenderableModel = class extends EventEmitter {
63211
63483
  return null;
63212
63484
  }
63213
63485
  const yMap = new Y12.Map();
63486
+ const uuid = this.uuid;
63487
+ const model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63488
+ this.elementModels.set(uuid, model);
63214
63489
  this.elements.doc?.transact(() => {
63215
- const uuid = this.uuid;
63216
63490
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63217
63491
  yMap.set(ElementModel.KEYS.uuid, uuid);
63218
63492
  yMap.set("type", "eraser");
63493
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63219
63494
  yMap.set(ElementModel.KEYS.shadow, "layer");
63220
63495
  yMap.set(ElementModel.KEYS.strokeWidth, 4);
63221
63496
  yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
@@ -63223,7 +63498,6 @@ var RenderableModel = class extends EventEmitter {
63223
63498
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63224
63499
  this.elements.set(uuid, yMap);
63225
63500
  }, elementsUndoOrigin);
63226
- const model = new EraserModel(yMap, this.scope, this.liveCursor);
63227
63501
  return model;
63228
63502
  }
63229
63503
  createTriangle(shadow) {
@@ -63231,45 +63505,52 @@ var RenderableModel = class extends EventEmitter {
63231
63505
  return null;
63232
63506
  }
63233
63507
  const yMap = new Y12.Map();
63508
+ const uuid = this.uuid;
63509
+ const triangleModel = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63510
+ this.elementModels.set(uuid, triangleModel);
63234
63511
  this.elements.doc?.transact(() => {
63235
- const uuid = this.uuid;
63236
63512
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63237
63513
  yMap.set(ElementModel.KEYS.uuid, uuid);
63238
63514
  yMap.set("type", "triangle");
63239
63515
  if (shadow) {
63240
63516
  yMap.set(ElementModel.KEYS.shadow, "layer");
63241
63517
  }
63518
+ yMap.set("points", new Y12.Array());
63242
63519
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63243
63520
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63244
63521
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63245
63522
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63246
63523
  this.elements.set(uuid, yMap);
63247
63524
  }, elementsUndoOrigin);
63248
- const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
63249
- this.initElement(triangle);
63250
- triangle.dashArray = this.toolbarModel.dashArray;
63251
- return triangle;
63525
+ this.initElement(triangleModel);
63526
+ triangleModel.dashArray = this.toolbarModel.dashArray;
63527
+ return triangleModel;
63252
63528
  }
63253
63529
  createRectangle(shadow) {
63254
63530
  if (!this.confirmPermission()) {
63255
63531
  return null;
63256
63532
  }
63257
63533
  const yMap = new Y12.Map();
63534
+ const uuid = this.uuid;
63535
+ const rect = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63536
+ this.elementModels.set(uuid, rect);
63258
63537
  this.elements.doc?.transact(() => {
63259
- const uuid = this.uuid;
63260
63538
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63261
63539
  yMap.set(ElementModel.KEYS.uuid, uuid);
63262
63540
  yMap.set("type", "rectangle");
63263
63541
  if (shadow) {
63264
63542
  yMap.set(ElementModel.KEYS.shadow, "layer");
63265
63543
  }
63544
+ const initPoints = new Y12.Array();
63545
+ initPoints.push([0, 0, 0, 0]);
63546
+ yMap.set("points", initPoints);
63547
+ yMap.set("radius", 0);
63266
63548
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63267
63549
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63268
63550
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63269
63551
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63270
63552
  this.elements.set(uuid, yMap);
63271
63553
  }, elementsUndoOrigin);
63272
- const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
63273
63554
  this.initElement(rect);
63274
63555
  rect.dashArray = this.toolbarModel.dashArray;
63275
63556
  return rect;
@@ -63279,21 +63560,23 @@ var RenderableModel = class extends EventEmitter {
63279
63560
  return null;
63280
63561
  }
63281
63562
  const yMap = new Y12.Map();
63563
+ const uuid = this.uuid;
63564
+ const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
63565
+ this.elementModels.set(uuid, segmentsModel);
63282
63566
  this.elements.doc?.transact(() => {
63283
- const uuid = this.uuid;
63284
63567
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63285
63568
  yMap.set(ElementModel.KEYS.uuid, uuid);
63286
63569
  yMap.set("type", type);
63287
63570
  if (shadow) {
63288
63571
  yMap.set(ElementModel.KEYS.shadow, "layer");
63289
63572
  }
63573
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63290
63574
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63291
63575
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63292
63576
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63293
63577
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63294
63578
  this.elements.set(uuid, yMap);
63295
63579
  }, elementsUndoOrigin);
63296
- const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
63297
63580
  this.initElement(segmentsModel);
63298
63581
  segmentsModel.dashArray = this.toolbarModel.dashArray;
63299
63582
  return segmentsModel;
@@ -63304,16 +63587,20 @@ var RenderableModel = class extends EventEmitter {
63304
63587
  return null;
63305
63588
  }
63306
63589
  const yMap = new Y12.Map();
63590
+ const uuid = this.uuid;
63591
+ const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63592
+ this.elementModels.set(uuid, selectorModel);
63307
63593
  this.elements.doc?.transact(() => {
63308
- const uuid = this.uuid;
63309
63594
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63310
63595
  yMap.set(ElementModel.KEYS.uuid, uuid);
63311
63596
  yMap.set("type", "selector");
63597
+ const initPoints = new Y12.Array();
63598
+ initPoints.push([0, 0, 0, 0]);
63599
+ yMap.set(ElementModel.KEYS.points, initPoints);
63312
63600
  yMap.set(ElementModel.KEYS.shadow, "layer");
63313
63601
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63314
63602
  this.elements.set(uuid, yMap);
63315
63603
  }, elementsUndoOrigin);
63316
- const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
63317
63604
  selectorModel.shadow = "layer";
63318
63605
  return selectorModel;
63319
63606
  }
@@ -63322,21 +63609,23 @@ var RenderableModel = class extends EventEmitter {
63322
63609
  return null;
63323
63610
  }
63324
63611
  const yMap = new Y12.Map();
63612
+ const uuid = this.uuid;
63613
+ const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63614
+ this.elementModels.set(uuid, straightLineModel);
63325
63615
  this.elements.doc?.transact(() => {
63326
- const uuid = this.uuid;
63327
63616
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63328
63617
  yMap.set(ElementModel.KEYS.uuid, uuid);
63329
63618
  yMap.set("type", "line");
63330
63619
  if (shadow) {
63331
63620
  yMap.set(ElementModel.KEYS.shadow, "layer");
63332
63621
  }
63622
+ yMap.set("points", new Y12.Array());
63333
63623
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63334
63624
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63335
63625
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63336
63626
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63337
63627
  this.elements.set(uuid, yMap);
63338
63628
  }, elementsUndoOrigin);
63339
- const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
63340
63629
  this.initElement(straightLineModel);
63341
63630
  straightLineModel.dashArray = this.toolbarModel.dashArray;
63342
63631
  return straightLineModel;
@@ -63346,21 +63635,25 @@ var RenderableModel = class extends EventEmitter {
63346
63635
  return null;
63347
63636
  }
63348
63637
  const yMap = new Y12.Map();
63638
+ const uuid = this.uuid;
63639
+ const lineModel = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63640
+ this.elementModels.set(uuid, lineModel);
63349
63641
  this.elements.doc?.transact(() => {
63350
- const uuid = this.uuid;
63351
63642
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63352
63643
  yMap.set(ElementModel.KEYS.uuid, uuid);
63353
63644
  yMap.set("type", "arrow");
63354
63645
  if (shadow) {
63355
63646
  yMap.set(ElementModel.KEYS.shadow, "layer");
63356
63647
  }
63648
+ yMap.set("headArrow", "none");
63649
+ yMap.set("tailArrow", "normal");
63650
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63357
63651
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63358
63652
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63359
63653
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63360
63654
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63361
63655
  this.elements.set(uuid, yMap);
63362
63656
  }, elementsUndoOrigin);
63363
- const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
63364
63657
  this.initElement(lineModel);
63365
63658
  lineModel.dashArray = this.toolbarModel.dashArray;
63366
63659
  return lineModel;
@@ -63370,21 +63663,23 @@ var RenderableModel = class extends EventEmitter {
63370
63663
  return null;
63371
63664
  }
63372
63665
  const yMap = new Y12.Map();
63666
+ const uuid = this.uuid;
63667
+ const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
63668
+ this.elementModels.set(uuid, pointTextModel);
63373
63669
  this.elements.doc?.transact(() => {
63374
- const uuid = this.uuid;
63375
63670
  yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
63376
63671
  yMap.set(ElementModel.KEYS.uuid, uuid);
63377
63672
  yMap.set("type", "point-text");
63378
63673
  if (shadow) {
63379
63674
  yMap.set(ElementModel.KEYS.shadow, "layer");
63380
63675
  }
63676
+ yMap.set(ElementModel.KEYS.points, new Y12.Array());
63381
63677
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63382
63678
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63383
63679
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
63384
63680
  yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
63385
63681
  this.elements.set(uuid, yMap);
63386
63682
  }, elementsUndoOrigin);
63387
- const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
63388
63683
  pointTextModel.setPoints([x, y]);
63389
63684
  pointTextModel.fontSize = this.toolbarModel.fontSize;
63390
63685
  pointTextModel.fontFamily = this.toolbarModel.fontFamily;
@@ -63416,7 +63711,7 @@ var RenderableModel = class extends EventEmitter {
63416
63711
  });
63417
63712
  }
63418
63713
  };
63419
- var import_lodash8 = __toESM2(require_lodash(), 1);
63714
+ var import_lodash7 = __toESM2(require_lodash(), 1);
63420
63715
  function Point(x, y) {
63421
63716
  this.X = x;
63422
63717
  this.Y = y;
@@ -63659,7 +63954,7 @@ var Recognizer = class {
63659
63954
  let maxX = -Number.MAX_VALUE;
63660
63955
  let minY = Number.MAX_VALUE;
63661
63956
  let maxY = -Number.MAX_VALUE;
63662
- const result = this.dollar.Recognize((0, import_lodash8.chunk)(points, 2).map((v) => {
63957
+ const result = this.dollar.Recognize((0, import_lodash7.chunk)(points, 3).map((v) => {
63663
63958
  minX = Math.min(minX, v[0]);
63664
63959
  maxX = Math.max(maxX, v[0]);
63665
63960
  minY = Math.min(minY, v[1]);
@@ -63701,11 +63996,24 @@ var CurveTool = class extends WhiteboardTool {
63701
63996
  _defineProperty19(this, "elementModel", null);
63702
63997
  _defineProperty19(this, "recognizer", new Recognizer());
63703
63998
  _defineProperty19(this, "pointCount", 0);
63999
+ _defineProperty19(this, "pendingPoints", []);
64000
+ _defineProperty19(this, "flushRafId", 0);
63704
64001
  _defineProperty19(this, "showLiveCursor", true);
63705
- this.tool.minDistance = 5;
64002
+ _defineProperty19(this, "flushPendingPoints", () => {
64003
+ this.flushRafId = 0;
64004
+ if (this.elementModel && this.pendingPoints.length > 0) {
64005
+ this.elementModel.appendPoints(this.pendingPoints);
64006
+ this.pendingPoints = [];
64007
+ }
64008
+ });
63706
64009
  }
63707
64010
  onMouseDown(_event) {
63708
64011
  this.pointCount = 0;
64012
+ this.pendingPoints = [];
64013
+ if (this.flushRafId) {
64014
+ cancelAnimationFrame(this.flushRafId);
64015
+ this.flushRafId = 0;
64016
+ }
63709
64017
  if (this.elementModel) {
63710
64018
  this.elementModel.dispose();
63711
64019
  }
@@ -63720,27 +64028,38 @@ var CurveTool = class extends WhiteboardTool {
63720
64028
  if (this.pointCount > 1024) {
63721
64029
  return;
63722
64030
  }
63723
- const MIN_DISTANCE = 4;
64031
+ const MIN_DISTANCE = 2;
63724
64032
  if (this.elementModel) {
63725
- const len = this.elementModel.points.length;
63726
- let last = {
63727
- x: 0,
63728
- y: 0
63729
- };
63730
- if (len >= 2) {
63731
- last = {
63732
- x: this.elementModel.points[len - 2],
63733
- y: this.elementModel.points[len - 1]
63734
- };
64033
+ let lastX = 0;
64034
+ let lastY = 0;
64035
+ if (this.pendingPoints.length >= 3) {
64036
+ lastX = this.pendingPoints[this.pendingPoints.length - 3];
64037
+ lastY = this.pendingPoints[this.pendingPoints.length - 2];
64038
+ } else {
64039
+ const len = this.elementModel.points.length;
64040
+ if (len >= 3) {
64041
+ lastX = this.elementModel.points[len - 3];
64042
+ lastY = this.elementModel.points[len - 2];
64043
+ }
63735
64044
  }
63736
- const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
64045
+ const dist = Math.max(Math.abs(lastX - event.point.x), Math.abs(lastY - event.point.y));
63737
64046
  if (dist >= MIN_DISTANCE) {
63738
64047
  this.pointCount += 1;
63739
- this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
64048
+ const nativeEvent = event.event;
64049
+ const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
64050
+ this.pendingPoints.push(event.point.x, event.point.y, pressure);
64051
+ if (!this.flushRafId) {
64052
+ this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
64053
+ }
63740
64054
  }
63741
64055
  }
63742
64056
  }
63743
64057
  onMouseUp(event) {
64058
+ if (this.flushRafId) {
64059
+ cancelAnimationFrame(this.flushRafId);
64060
+ this.flushRafId = 0;
64061
+ }
64062
+ this.flushPendingPoints();
63744
64063
  this.modelGetter().then((model) => {
63745
64064
  if (!model) {
63746
64065
  return;
@@ -65622,6 +65941,8 @@ var Whiteboard = class extends EventEmitter8 {
65622
65941
  _defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
65623
65942
  _defineProperty31(this, "getElementAttribute", void 0);
65624
65943
  _defineProperty31(this, "setElementAttribute", void 0);
65944
+ _defineProperty31(this, "setPerformanceMode", void 0);
65945
+ _defineProperty31(this, "isPerformanceMode", void 0);
65625
65946
  _defineProperty31(this, "removeElement", void 0);
65626
65947
  _defineProperty31(this, "getCurrentTool", void 0);
65627
65948
  _defineProperty31(this, "setCurrentTool", void 0);
@@ -65911,9 +66232,24 @@ var LaserPointerTool = class extends WhiteboardTool {
65911
66232
  if (this.pointCount > 1024) {
65912
66233
  return;
65913
66234
  }
66235
+ const MIN_DISTANCE = 4;
65914
66236
  if (this.elementModel) {
65915
- this.pointCount += 1;
65916
- this.elementModel.appendPoints([event.point.x, event.point.y]);
66237
+ const len = this.elementModel.points.length;
66238
+ let last = {
66239
+ x: 0,
66240
+ y: 0
66241
+ };
66242
+ if (len >= 2) {
66243
+ last = {
66244
+ x: this.elementModel.points[len - 2],
66245
+ y: this.elementModel.points[len - 1]
66246
+ };
66247
+ }
66248
+ const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
66249
+ if (dist >= MIN_DISTANCE) {
66250
+ this.pointCount += 1;
66251
+ this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
66252
+ }
65917
66253
  }
65918
66254
  }
65919
66255
  onMouseUp(_event) {
@@ -66872,6 +67208,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
66872
67208
  _defineProperty43(this, "permissions", void 0);
66873
67209
  _defineProperty43(this, "inputType", "any");
66874
67210
  _defineProperty43(this, "isPenEvent", false);
67211
+ _defineProperty43(this, "activePenPointerId", null);
66875
67212
  _defineProperty43(this, "hasPenInput", null);
66876
67213
  _defineProperty43(this, "disableViewModelUpdate", false);
66877
67214
  _defineProperty43(this, "internalResizeObserver", true);
@@ -66988,6 +67325,9 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
66988
67325
  _defineProperty43(this, "hasPermission", (flag) => {
66989
67326
  return this.permissions.hasPermission(flag, this.userId);
66990
67327
  });
67328
+ _defineProperty43(this, "isPerformanceMode", () => {
67329
+ return this.option.performance ?? false;
67330
+ });
66991
67331
  _defineProperty43(this, "handleStackItemAdded", () => {
66992
67332
  this.selectElementsModel.clearSelectElementForSelf();
66993
67333
  this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
@@ -67002,7 +67342,18 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
67002
67342
  const id = ids[i];
67003
67343
  if (!this.layers.has(id)) {
67004
67344
  const elementsMap = this.getMap(`layer/${id}/elements`);
67005
- const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
67345
+ const renderableModel = new RenderableModel({
67346
+ layerId: id,
67347
+ shadowEmitter: this.shadowEmitter,
67348
+ elements: elementsMap,
67349
+ scope: this.paperScope,
67350
+ toolbarModel: this.toolbarModel,
67351
+ userManager: this.userManager,
67352
+ imageSets: this.imageSets,
67353
+ liveCursor: this.liveCursor,
67354
+ hasPermission: this.hasPermission,
67355
+ isPerformanceMode: this.isPerformanceMode
67356
+ });
67006
67357
  this.layers.set(id, renderableModel);
67007
67358
  }
67008
67359
  if (!this.undoManagers.has(id)) {
@@ -67186,11 +67537,34 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
67186
67537
  this.imageSets.setAttribute("data-image-sets", "");
67187
67538
  this.rootElement.appendChild(this.imageSets);
67188
67539
  document.body.addEventListener("pointerdown", (evt) => {
67189
- this.isPenEvent = evt.pointerType === "pen";
67190
- if (evt.pointerType === "pen" && this.hasPenInput === null) {
67191
- this.hasPenInput = true;
67192
- this.inputType = "pen";
67193
- this.emitter.emit("inputTypeChange", this.inputType);
67540
+ if (evt.pointerType === "pen") {
67541
+ this.isPenEvent = true;
67542
+ this.activePenPointerId = evt.pointerId;
67543
+ if (this.hasPenInput === null) {
67544
+ this.hasPenInput = true;
67545
+ this.inputType = "pen";
67546
+ this.emitter.emit("inputTypeChange", this.inputType);
67547
+ }
67548
+ } else {
67549
+ if (this.activePenPointerId === null) {
67550
+ this.isPenEvent = false;
67551
+ }
67552
+ }
67553
+ }, {
67554
+ capture: true
67555
+ });
67556
+ document.body.addEventListener("pointerup", (evt) => {
67557
+ if (evt.pointerId === this.activePenPointerId) {
67558
+ this.activePenPointerId = null;
67559
+ this.isPenEvent = false;
67560
+ }
67561
+ }, {
67562
+ capture: true
67563
+ });
67564
+ document.body.addEventListener("pointercancel", (evt) => {
67565
+ if (evt.pointerId === this.activePenPointerId) {
67566
+ this.activePenPointerId = null;
67567
+ this.isPenEvent = false;
67194
67568
  }
67195
67569
  }, {
67196
67570
  capture: true
@@ -67269,6 +67643,12 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
67269
67643
  this.camera.resetViewMatrixToFlow(flowId);
67270
67644
  }
67271
67645
  };
67646
+ this.emitter.setPerformanceMode = (enabled) => {
67647
+ this.option.performance = enabled;
67648
+ };
67649
+ this.emitter.isPerformanceMode = () => {
67650
+ return this.isPerformanceMode();
67651
+ };
67272
67652
  this.emitter.setViewModeToMain = (userId) => {
67273
67653
  if (that.disableViewModelUpdate) {
67274
67654
  console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
@@ -67323,7 +67703,18 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
67323
67703
  const source = this.getMap(`layer/${sourceId}/elements`);
67324
67704
  const target = this.getMap(`layer/${targetId}/elements`);
67325
67705
  if (!this.layers.has(targetId)) {
67326
- this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
67706
+ this.layers.set(targetId, new RenderableModel({
67707
+ layerId: targetId,
67708
+ shadowEmitter: this.shadowEmitter,
67709
+ elements: target,
67710
+ scope: this.paperScope,
67711
+ toolbarModel: this.toolbarModel,
67712
+ userManager: this.userManager,
67713
+ imageSets: this.imageSets,
67714
+ liveCursor: this.liveCursor,
67715
+ hasPermission: this.hasPermission,
67716
+ isPerformanceMode: this.isPerformanceMode
67717
+ }));
67327
67718
  }
67328
67719
  if (!this.undoManagers.has(targetId)) {
67329
67720
  const undoManager = new Y15.UndoManager(target, {
@@ -67558,6 +67949,11 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
67558
67949
  this.editors.forEach((editor) => {
67559
67950
  editor.updateBounds();
67560
67951
  });
67952
+ const area = this.paperScope.project.view.size.width * this.paperScope.project.view.size.height;
67953
+ const minDistance = Math.ceil(area / 4e5);
67954
+ Object.keys(this.tools).forEach((key) => {
67955
+ this.tools[key].tool.minDistance = minDistance;
67956
+ });
67561
67957
  });
67562
67958
  this.camera.on("userPageChange", (userId, pageId) => {
67563
67959
  this.emitter.emit("activePageChange", userId, pageId);