@netless/forge-slide 1.2.0-beta.0 → 1.2.0-beta.3

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
@@ -58615,7 +58615,7 @@ var require_lodash = __commonJS2({
58615
58615
  result2.__values__ = wrapper.__values__;
58616
58616
  return result2;
58617
58617
  }
58618
- function chunk7(array, size2, guard) {
58618
+ function chunk8(array, size2, guard) {
58619
58619
  if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
58620
58620
  size2 = 1;
58621
58621
  } else {
@@ -60487,7 +60487,7 @@ var require_lodash = __commonJS2({
60487
60487
  lodash.bindKey = bindKey;
60488
60488
  lodash.castArray = castArray;
60489
60489
  lodash.chain = chain;
60490
- lodash.chunk = chunk7;
60490
+ lodash.chunk = chunk8;
60491
60491
  lodash.compact = compact;
60492
60492
  lodash.concat = concat;
60493
60493
  lodash.cond = cond;
@@ -60965,6 +60965,7 @@ var require_lodash = __commonJS2({
60965
60965
  }
60966
60966
  });
60967
60967
  var import_paper = __toESM2(require_paper_full(), 1);
60968
+ var import_lodash = __toESM2(require_lodash(), 1);
60968
60969
  function $(e, t, u, x = (h) => h) {
60969
60970
  return e * x(0.5 - t * (0.5 - u));
60970
60971
  }
@@ -61512,7 +61513,7 @@ var CurveModel = class extends ElementModel {
61512
61513
  _defineProperty3(this, "debug", false);
61513
61514
  _defineProperty3(this, "clearLocalPointsWhenYPointsChange", false);
61514
61515
  _defineProperty3(this, "shouldUseLocalPoints", true);
61515
- _defineProperty3(this, "localPointsPick", 6);
61516
+ _defineProperty3(this, "localPointsPick", 4);
61516
61517
  if (!this.root.doc || !this.root.has("type")) {
61517
61518
  this.root.set("type", "curve");
61518
61519
  }
@@ -61524,7 +61525,6 @@ var CurveModel = class extends ElementModel {
61524
61525
  return (a2 + b2) / 2;
61525
61526
  }
61526
61527
  parsePoints(points) {
61527
- const hasRealPressure = points.some((p) => p.length >= 3 && p[2] > 0);
61528
61528
  const viewScale = this.scope.project.view.matrix.scaling.x || 1;
61529
61529
  const taper = this.strokeWidth * 5 / viewScale;
61530
61530
  const streamline = Math.min(0.7, 0.7 * viewScale);
@@ -61533,7 +61533,7 @@ var CurveModel = class extends ElementModel {
61533
61533
  smoothing: 0.7,
61534
61534
  thinning: 0.5,
61535
61535
  streamline,
61536
- simulatePressure: !hasRealPressure,
61536
+ simulatePressure: true,
61537
61537
  start: {
61538
61538
  taper,
61539
61539
  cap: true
@@ -61544,36 +61544,13 @@ var CurveModel = class extends ElementModel {
61544
61544
  }
61545
61545
  });
61546
61546
  }
61547
- isPressureValue(value) {
61548
- return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
61549
- }
61550
- pointStride(points) {
61551
- if (points.length >= 3 && points.length % 3 === 0) {
61552
- let hasPressureSlot = false;
61553
- for (let i = 2; i < points.length; i += 3) {
61554
- if (!this.isPressureValue(points[i])) {
61555
- return 2;
61556
- }
61557
- hasPressureSlot = true;
61558
- }
61559
- if (hasPressureSlot) {
61560
- return 3;
61561
- }
61562
- }
61563
- return 2;
61564
- }
61565
61547
  matrixedPoints() {
61566
61548
  const points = this.localPoints.length === 0 ? this.points : this.localPoints;
61567
61549
  const matrix = new this.scope.Matrix(this.pointsMatrix);
61568
- const output = [];
61569
- const stride = this.pointStride(points);
61570
- for (let i = 0, len = points.length; i + 1 < len; i += stride) {
61571
- const p = new this.scope.Point(points[i], points[i + 1]);
61572
- const tp = p.transform(matrix);
61573
- const pressure = stride === 3 ? points[i + 2] ?? 0 : 0;
61574
- output.push([tp.x, tp.y, pressure]);
61575
- }
61576
- return output;
61550
+ return (0, import_lodash.chunk)(points, 2).filter((point) => point.length === 2).map((_ref) => {
61551
+ let [x, y] = _ref;
61552
+ return new this.scope.Point(x, y).transform(matrix);
61553
+ }).map((point) => [point.x, point.y]);
61577
61554
  }
61578
61555
  createPath(points) {
61579
61556
  const path = new this.scope.Path();
@@ -61647,12 +61624,11 @@ var CurveModel = class extends ElementModel {
61647
61624
  liveCursorPoint() {
61648
61625
  const yArray = this.root.get(ElementModel.KEYS.points);
61649
61626
  const points = yArray.toArray();
61650
- const stride = this.pointStride(points);
61651
- if (points.length < stride) {
61627
+ if (points.length < 2) {
61652
61628
  return null;
61653
61629
  }
61654
61630
  const len = points.length;
61655
- const point = new this.scope.Point(points[len - stride], points[len - stride + 1]);
61631
+ const point = new this.scope.Point(points[len - 2], points[len - 1]);
61656
61632
  return point.transform(new this.scope.Matrix(this.pointsMatrix));
61657
61633
  }
61658
61634
  onStyleKeyUpdate(key) {
@@ -61745,7 +61721,7 @@ var SelectorModel = class extends ElementModel {
61745
61721
  onStyleKeyUpdate(_key) {
61746
61722
  }
61747
61723
  };
61748
- var import_lodash = __toESM2(require_lodash(), 1);
61724
+ var import_lodash2 = __toESM2(require_lodash(), 1);
61749
61725
  function _defineProperty5(e, r, t) {
61750
61726
  return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
61751
61727
  }
@@ -61778,7 +61754,7 @@ function serializePath(path) {
61778
61754
  }, []);
61779
61755
  }
61780
61756
  function deserializePath(points, scope, matrix) {
61781
- const segmentGroup = (0, import_lodash.chunk)(points, 6);
61757
+ const segmentGroup = (0, import_lodash2.chunk)(points, 6);
61782
61758
  const path = new scope.Path();
61783
61759
  path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
61784
61760
  return path;
@@ -61916,7 +61892,7 @@ var SegmentsModel = class extends ElementModel {
61916
61892
  onStyleKeyUpdate(_key) {
61917
61893
  }
61918
61894
  };
61919
- var import_lodash3 = __toESM2(require_lodash(), 1);
61895
+ var import_lodash4 = __toESM2(require_lodash(), 1);
61920
61896
  function _defineProperty7(e, r, t) {
61921
61897
  return (r = _toPropertyKey7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
61922
61898
  }
@@ -62011,7 +61987,7 @@ var WhiteboardTool = class {
62011
61987
  this.tool.onMouseUp = this.onMouseUpSelf;
62012
61988
  }
62013
61989
  };
62014
- var import_lodash2 = __toESM2(require_lodash(), 1);
61990
+ var import_lodash3 = __toESM2(require_lodash(), 1);
62015
61991
  function _defineProperty8(e, r, t) {
62016
61992
  return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62017
61993
  }
@@ -62060,7 +62036,7 @@ var LineTool = class extends WhiteboardTool {
62060
62036
  const point = path.getPointAt(distance);
62061
62037
  return [point.x, point.y];
62062
62038
  });
62063
- this.elementModel.setPoints((0, import_lodash2.flattenDeep)(points));
62039
+ this.elementModel.setPoints((0, import_lodash3.flattenDeep)(points));
62064
62040
  }
62065
62041
  }
62066
62042
  onMouseUp(_event) {
@@ -62141,7 +62117,7 @@ var LineModel = class extends ElementModel {
62141
62117
  }
62142
62118
  renderLine() {
62143
62119
  const matrix = new this.scope.Matrix(this.pointsMatrix);
62144
- const papperPoints = (0, import_lodash3.chunk)(this.drawPoints, 2).map((item) => {
62120
+ const papperPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).map((item) => {
62145
62121
  return new this.scope.Point(item[0], item[1]).transform(matrix);
62146
62122
  });
62147
62123
  const path = new this.scope.Path();
@@ -62277,7 +62253,7 @@ var LineControlPoint = class {
62277
62253
  const invertedPoint = point.transform(pointsMatrix.inverted());
62278
62254
  const points = this.model["drawPoints"];
62279
62255
  this.position = invertedPoint;
62280
- const clonedPoints = (0, import_lodash3.cloneDeep)(points);
62256
+ const clonedPoints = (0, import_lodash4.cloneDeep)(points);
62281
62257
  clonedPoints[this.options.index * 2] = invertedPoint.x;
62282
62258
  clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
62283
62259
  this.model.setPoints(clonedPoints);
@@ -62747,7 +62723,7 @@ var RectangleModel = class extends ElementModel {
62747
62723
  }
62748
62724
  };
62749
62725
  var elementsUndoOrigin = "elementsUndoOrigin";
62750
- var import_lodash4 = __toESM2(require_lodash(), 1);
62726
+ var import_lodash5 = __toESM2(require_lodash(), 1);
62751
62727
  function _defineProperty13(e, r, t) {
62752
62728
  return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62753
62729
  }
@@ -62815,7 +62791,7 @@ var EraserModel = class extends ElementModel {
62815
62791
  return path;
62816
62792
  }
62817
62793
  parsePoints(points) {
62818
- const groupPoints = (0, import_lodash4.chunk)(points, 2);
62794
+ const groupPoints = (0, import_lodash5.chunk)(points, 2);
62819
62795
  return ae(groupPoints, {
62820
62796
  size: this.strokeWidth,
62821
62797
  smoothing: 0.5,
@@ -62833,7 +62809,7 @@ var EraserModel = class extends ElementModel {
62833
62809
  });
62834
62810
  }
62835
62811
  matrixedPoints() {
62836
- const currentPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
62812
+ const currentPoints = (0, import_lodash5.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
62837
62813
  return currentPoints.map((_ref) => {
62838
62814
  let [x, y] = _ref;
62839
62815
  return new this.scope.Point(x, y);
@@ -62896,7 +62872,7 @@ var EraserModel = class extends ElementModel {
62896
62872
  return point.transform(new this.scope.Matrix(this.pointsMatrix));
62897
62873
  }
62898
62874
  };
62899
- var import_lodash5 = __toESM2(require_lodash(), 1);
62875
+ var import_lodash6 = __toESM2(require_lodash(), 1);
62900
62876
  function _defineProperty14(e, r, t) {
62901
62877
  return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
62902
62878
  }
@@ -63022,7 +62998,7 @@ var LaserPointerModel = class extends ElementModel {
63022
62998
  const matrix = new this.scope.Matrix(this.pointsMatrix);
63023
62999
  const points = this.cachedPoints || this.points;
63024
63000
  console.log("[][][] ,", this.points.length, this.cachedPoints?.length, this.localPoints.length);
63025
- const groupPoints = (0, import_lodash5.chunk)(points, 2).slice(this.sliceBegin);
63001
+ const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
63026
63002
  return groupPoints.map((_ref) => {
63027
63003
  let [x, y] = _ref;
63028
63004
  return matrix.transform([x, y]);
@@ -63096,7 +63072,7 @@ var WhiteboardPermissions = class extends import_forge_room7.AbstractApplication
63096
63072
  return [WhiteboardPermissionFlag.draw, WhiteboardPermissionFlag.editSelf, WhiteboardPermissionFlag.editOthers, WhiteboardPermissionFlag.deleteSelf, WhiteboardPermissionFlag.deleteOthers, WhiteboardPermissionFlag.mainView, WhiteboardPermissionFlag.setOthersView].filter((v) => (v & value) !== 0);
63097
63073
  }
63098
63074
  };
63099
- var import_lodash6 = __toESM2(require_lodash(), 1);
63075
+ var import_lodash7 = __toESM2(require_lodash(), 1);
63100
63076
  function _defineProperty15(e, r, t) {
63101
63077
  return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
63102
63078
  }
@@ -63155,7 +63131,7 @@ var StraightLineModel = class extends ElementModel {
63155
63131
  }
63156
63132
  renderLine() {
63157
63133
  const matrix = new this.scope.Matrix(this.pointsMatrix);
63158
- const papperPoints = (0, import_lodash6.chunk)(this.drawPoints, 2).map((item) => {
63134
+ const papperPoints = (0, import_lodash7.chunk)(this.drawPoints, 2).map((item) => {
63159
63135
  return new this.scope.Point(item[0], item[1]).transform(matrix);
63160
63136
  });
63161
63137
  const path = new this.scope.Path();
@@ -63785,7 +63761,7 @@ var RenderableModel = class extends import_eventemitter3.default {
63785
63761
  if (shadow) {
63786
63762
  yMap.set(ElementModel.KEYS.shadow, "layer");
63787
63763
  }
63788
- yMap.set(ElementModel.KEYS.points, new Y12.Array());
63764
+ yMap.set(ElementModel.KEYS.points, Y12.Array.from([x, y]));
63789
63765
  yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
63790
63766
  yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
63791
63767
  yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
@@ -63793,7 +63769,6 @@ var RenderableModel = class extends import_eventemitter3.default {
63793
63769
  this.elements.set(uuid, yMap);
63794
63770
  }, elementsUndoOrigin);
63795
63771
  pointTextModel.bindObserver();
63796
- pointTextModel.setPoints([x, y]);
63797
63772
  pointTextModel.fontSize = this.toolbarModel.fontSize;
63798
63773
  pointTextModel.fontFamily = this.toolbarModel.fontFamily;
63799
63774
  this.initElement(pointTextModel);
@@ -63825,7 +63800,7 @@ var RenderableModel = class extends import_eventemitter3.default {
63825
63800
  });
63826
63801
  }
63827
63802
  };
63828
- var import_lodash7 = __toESM2(require_lodash(), 1);
63803
+ var import_lodash8 = __toESM2(require_lodash(), 1);
63829
63804
  function Point(x, y) {
63830
63805
  this.X = x;
63831
63806
  this.Y = y;
@@ -64068,7 +64043,7 @@ var Recognizer = class {
64068
64043
  let maxX = -Number.MAX_VALUE;
64069
64044
  let minY = Number.MAX_VALUE;
64070
64045
  let maxY = -Number.MAX_VALUE;
64071
- const result = this.dollar.Recognize((0, import_lodash7.chunk)(points, 3).map((v) => {
64046
+ const result = this.dollar.Recognize((0, import_lodash8.chunk)(points, 2).map((v) => {
64072
64047
  minX = Math.min(minX, v[0]);
64073
64048
  maxX = Math.max(maxX, v[0]);
64074
64049
  minY = Math.min(minY, v[1]);
@@ -64146,22 +64121,20 @@ var CurveTool = class extends WhiteboardTool {
64146
64121
  if (this.elementModel) {
64147
64122
  let lastX = 0;
64148
64123
  let lastY = 0;
64149
- if (this.pendingPoints.length >= 3) {
64150
- lastX = this.pendingPoints[this.pendingPoints.length - 3];
64151
- lastY = this.pendingPoints[this.pendingPoints.length - 2];
64124
+ if (this.pendingPoints.length >= 2) {
64125
+ lastX = this.pendingPoints[this.pendingPoints.length - 2];
64126
+ lastY = this.pendingPoints[this.pendingPoints.length - 1];
64152
64127
  } else {
64153
64128
  const len = this.elementModel.points.length;
64154
- if (len >= 3) {
64155
- lastX = this.elementModel.points[len - 3];
64156
- lastY = this.elementModel.points[len - 2];
64129
+ if (len >= 2) {
64130
+ lastX = this.elementModel.points[len - 2];
64131
+ lastY = this.elementModel.points[len - 1];
64157
64132
  }
64158
64133
  }
64159
64134
  const dist = Math.max(Math.abs(lastX - event.point.x), Math.abs(lastY - event.point.y));
64160
64135
  if (dist >= MIN_DISTANCE) {
64161
64136
  this.pointCount += 1;
64162
- const nativeEvent = event.event;
64163
- const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
64164
- this.pendingPoints.push(event.point.x, event.point.y, pressure);
64137
+ this.pendingPoints.push(event.point.x, event.point.y);
64165
64138
  if (!this.flushRafId) {
64166
64139
  this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
64167
64140
  }