@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.esm.js +35 -62
- package/dist/slide.esm.js.map +2 -2
- package/dist/slide.js +35 -62
- package/dist/slide.js.map +2 -2
- package/package.json +3 -3
package/dist/slide.esm.js
CHANGED
|
@@ -58606,7 +58606,7 @@ var require_lodash = __commonJS2({
|
|
|
58606
58606
|
result2.__values__ = wrapper.__values__;
|
|
58607
58607
|
return result2;
|
|
58608
58608
|
}
|
|
58609
|
-
function
|
|
58609
|
+
function chunk8(array, size2, guard) {
|
|
58610
58610
|
if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
|
|
58611
58611
|
size2 = 1;
|
|
58612
58612
|
} else {
|
|
@@ -60478,7 +60478,7 @@ var require_lodash = __commonJS2({
|
|
|
60478
60478
|
lodash.bindKey = bindKey;
|
|
60479
60479
|
lodash.castArray = castArray;
|
|
60480
60480
|
lodash.chain = chain;
|
|
60481
|
-
lodash.chunk =
|
|
60481
|
+
lodash.chunk = chunk8;
|
|
60482
60482
|
lodash.compact = compact;
|
|
60483
60483
|
lodash.concat = concat;
|
|
60484
60484
|
lodash.cond = cond;
|
|
@@ -60956,6 +60956,7 @@ var require_lodash = __commonJS2({
|
|
|
60956
60956
|
}
|
|
60957
60957
|
});
|
|
60958
60958
|
var import_paper = __toESM2(require_paper_full(), 1);
|
|
60959
|
+
var import_lodash = __toESM2(require_lodash(), 1);
|
|
60959
60960
|
function $(e, t, u, x = (h) => h) {
|
|
60960
60961
|
return e * x(0.5 - t * (0.5 - u));
|
|
60961
60962
|
}
|
|
@@ -61503,7 +61504,7 @@ var CurveModel = class extends ElementModel {
|
|
|
61503
61504
|
_defineProperty3(this, "debug", false);
|
|
61504
61505
|
_defineProperty3(this, "clearLocalPointsWhenYPointsChange", false);
|
|
61505
61506
|
_defineProperty3(this, "shouldUseLocalPoints", true);
|
|
61506
|
-
_defineProperty3(this, "localPointsPick",
|
|
61507
|
+
_defineProperty3(this, "localPointsPick", 4);
|
|
61507
61508
|
if (!this.root.doc || !this.root.has("type")) {
|
|
61508
61509
|
this.root.set("type", "curve");
|
|
61509
61510
|
}
|
|
@@ -61515,7 +61516,6 @@ var CurveModel = class extends ElementModel {
|
|
|
61515
61516
|
return (a2 + b2) / 2;
|
|
61516
61517
|
}
|
|
61517
61518
|
parsePoints(points) {
|
|
61518
|
-
const hasRealPressure = points.some((p) => p.length >= 3 && p[2] > 0);
|
|
61519
61519
|
const viewScale = this.scope.project.view.matrix.scaling.x || 1;
|
|
61520
61520
|
const taper = this.strokeWidth * 5 / viewScale;
|
|
61521
61521
|
const streamline = Math.min(0.7, 0.7 * viewScale);
|
|
@@ -61524,7 +61524,7 @@ var CurveModel = class extends ElementModel {
|
|
|
61524
61524
|
smoothing: 0.7,
|
|
61525
61525
|
thinning: 0.5,
|
|
61526
61526
|
streamline,
|
|
61527
|
-
simulatePressure:
|
|
61527
|
+
simulatePressure: true,
|
|
61528
61528
|
start: {
|
|
61529
61529
|
taper,
|
|
61530
61530
|
cap: true
|
|
@@ -61535,36 +61535,13 @@ var CurveModel = class extends ElementModel {
|
|
|
61535
61535
|
}
|
|
61536
61536
|
});
|
|
61537
61537
|
}
|
|
61538
|
-
isPressureValue(value) {
|
|
61539
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
61540
|
-
}
|
|
61541
|
-
pointStride(points) {
|
|
61542
|
-
if (points.length >= 3 && points.length % 3 === 0) {
|
|
61543
|
-
let hasPressureSlot = false;
|
|
61544
|
-
for (let i = 2; i < points.length; i += 3) {
|
|
61545
|
-
if (!this.isPressureValue(points[i])) {
|
|
61546
|
-
return 2;
|
|
61547
|
-
}
|
|
61548
|
-
hasPressureSlot = true;
|
|
61549
|
-
}
|
|
61550
|
-
if (hasPressureSlot) {
|
|
61551
|
-
return 3;
|
|
61552
|
-
}
|
|
61553
|
-
}
|
|
61554
|
-
return 2;
|
|
61555
|
-
}
|
|
61556
61538
|
matrixedPoints() {
|
|
61557
61539
|
const points = this.localPoints.length === 0 ? this.points : this.localPoints;
|
|
61558
61540
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
61559
|
-
|
|
61560
|
-
|
|
61561
|
-
|
|
61562
|
-
|
|
61563
|
-
const tp = p.transform(matrix);
|
|
61564
|
-
const pressure = stride === 3 ? points[i + 2] ?? 0 : 0;
|
|
61565
|
-
output.push([tp.x, tp.y, pressure]);
|
|
61566
|
-
}
|
|
61567
|
-
return output;
|
|
61541
|
+
return (0, import_lodash.chunk)(points, 2).filter((point) => point.length === 2).map((_ref) => {
|
|
61542
|
+
let [x, y] = _ref;
|
|
61543
|
+
return new this.scope.Point(x, y).transform(matrix);
|
|
61544
|
+
}).map((point) => [point.x, point.y]);
|
|
61568
61545
|
}
|
|
61569
61546
|
createPath(points) {
|
|
61570
61547
|
const path = new this.scope.Path();
|
|
@@ -61638,12 +61615,11 @@ var CurveModel = class extends ElementModel {
|
|
|
61638
61615
|
liveCursorPoint() {
|
|
61639
61616
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
61640
61617
|
const points = yArray.toArray();
|
|
61641
|
-
|
|
61642
|
-
if (points.length < stride) {
|
|
61618
|
+
if (points.length < 2) {
|
|
61643
61619
|
return null;
|
|
61644
61620
|
}
|
|
61645
61621
|
const len = points.length;
|
|
61646
|
-
const point = new this.scope.Point(points[len -
|
|
61622
|
+
const point = new this.scope.Point(points[len - 2], points[len - 1]);
|
|
61647
61623
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
61648
61624
|
}
|
|
61649
61625
|
onStyleKeyUpdate(key) {
|
|
@@ -61736,7 +61712,7 @@ var SelectorModel = class extends ElementModel {
|
|
|
61736
61712
|
onStyleKeyUpdate(_key) {
|
|
61737
61713
|
}
|
|
61738
61714
|
};
|
|
61739
|
-
var
|
|
61715
|
+
var import_lodash2 = __toESM2(require_lodash(), 1);
|
|
61740
61716
|
function _defineProperty5(e, r, t) {
|
|
61741
61717
|
return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
61742
61718
|
}
|
|
@@ -61769,7 +61745,7 @@ function serializePath(path) {
|
|
|
61769
61745
|
}, []);
|
|
61770
61746
|
}
|
|
61771
61747
|
function deserializePath(points, scope, matrix) {
|
|
61772
|
-
const segmentGroup = (0,
|
|
61748
|
+
const segmentGroup = (0, import_lodash2.chunk)(points, 6);
|
|
61773
61749
|
const path = new scope.Path();
|
|
61774
61750
|
path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
|
|
61775
61751
|
return path;
|
|
@@ -61907,7 +61883,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
61907
61883
|
onStyleKeyUpdate(_key) {
|
|
61908
61884
|
}
|
|
61909
61885
|
};
|
|
61910
|
-
var
|
|
61886
|
+
var import_lodash4 = __toESM2(require_lodash(), 1);
|
|
61911
61887
|
function _defineProperty7(e, r, t) {
|
|
61912
61888
|
return (r = _toPropertyKey7(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
61913
61889
|
}
|
|
@@ -62002,7 +61978,7 @@ var WhiteboardTool = class {
|
|
|
62002
61978
|
this.tool.onMouseUp = this.onMouseUpSelf;
|
|
62003
61979
|
}
|
|
62004
61980
|
};
|
|
62005
|
-
var
|
|
61981
|
+
var import_lodash3 = __toESM2(require_lodash(), 1);
|
|
62006
61982
|
function _defineProperty8(e, r, t) {
|
|
62007
61983
|
return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62008
61984
|
}
|
|
@@ -62051,7 +62027,7 @@ var LineTool = class extends WhiteboardTool {
|
|
|
62051
62027
|
const point = path.getPointAt(distance);
|
|
62052
62028
|
return [point.x, point.y];
|
|
62053
62029
|
});
|
|
62054
|
-
this.elementModel.setPoints((0,
|
|
62030
|
+
this.elementModel.setPoints((0, import_lodash3.flattenDeep)(points));
|
|
62055
62031
|
}
|
|
62056
62032
|
}
|
|
62057
62033
|
onMouseUp(_event) {
|
|
@@ -62132,7 +62108,7 @@ var LineModel = class extends ElementModel {
|
|
|
62132
62108
|
}
|
|
62133
62109
|
renderLine() {
|
|
62134
62110
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
62135
|
-
const papperPoints = (0,
|
|
62111
|
+
const papperPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).map((item) => {
|
|
62136
62112
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
62137
62113
|
});
|
|
62138
62114
|
const path = new this.scope.Path();
|
|
@@ -62268,7 +62244,7 @@ var LineControlPoint = class {
|
|
|
62268
62244
|
const invertedPoint = point.transform(pointsMatrix.inverted());
|
|
62269
62245
|
const points = this.model["drawPoints"];
|
|
62270
62246
|
this.position = invertedPoint;
|
|
62271
|
-
const clonedPoints = (0,
|
|
62247
|
+
const clonedPoints = (0, import_lodash4.cloneDeep)(points);
|
|
62272
62248
|
clonedPoints[this.options.index * 2] = invertedPoint.x;
|
|
62273
62249
|
clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
|
|
62274
62250
|
this.model.setPoints(clonedPoints);
|
|
@@ -62738,7 +62714,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
62738
62714
|
}
|
|
62739
62715
|
};
|
|
62740
62716
|
var elementsUndoOrigin = "elementsUndoOrigin";
|
|
62741
|
-
var
|
|
62717
|
+
var import_lodash5 = __toESM2(require_lodash(), 1);
|
|
62742
62718
|
function _defineProperty13(e, r, t) {
|
|
62743
62719
|
return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62744
62720
|
}
|
|
@@ -62806,7 +62782,7 @@ var EraserModel = class extends ElementModel {
|
|
|
62806
62782
|
return path;
|
|
62807
62783
|
}
|
|
62808
62784
|
parsePoints(points) {
|
|
62809
|
-
const groupPoints = (0,
|
|
62785
|
+
const groupPoints = (0, import_lodash5.chunk)(points, 2);
|
|
62810
62786
|
return ae(groupPoints, {
|
|
62811
62787
|
size: this.strokeWidth,
|
|
62812
62788
|
smoothing: 0.5,
|
|
@@ -62824,7 +62800,7 @@ var EraserModel = class extends ElementModel {
|
|
|
62824
62800
|
});
|
|
62825
62801
|
}
|
|
62826
62802
|
matrixedPoints() {
|
|
62827
|
-
const currentPoints = (0,
|
|
62803
|
+
const currentPoints = (0, import_lodash5.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
|
|
62828
62804
|
return currentPoints.map((_ref) => {
|
|
62829
62805
|
let [x, y] = _ref;
|
|
62830
62806
|
return new this.scope.Point(x, y);
|
|
@@ -62887,7 +62863,7 @@ var EraserModel = class extends ElementModel {
|
|
|
62887
62863
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
62888
62864
|
}
|
|
62889
62865
|
};
|
|
62890
|
-
var
|
|
62866
|
+
var import_lodash6 = __toESM2(require_lodash(), 1);
|
|
62891
62867
|
function _defineProperty14(e, r, t) {
|
|
62892
62868
|
return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
62893
62869
|
}
|
|
@@ -63013,7 +62989,7 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
63013
62989
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
63014
62990
|
const points = this.cachedPoints || this.points;
|
|
63015
62991
|
console.log("[][][] ,", this.points.length, this.cachedPoints?.length, this.localPoints.length);
|
|
63016
|
-
const groupPoints = (0,
|
|
62992
|
+
const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
|
|
63017
62993
|
return groupPoints.map((_ref) => {
|
|
63018
62994
|
let [x, y] = _ref;
|
|
63019
62995
|
return matrix.transform([x, y]);
|
|
@@ -63087,7 +63063,7 @@ var WhiteboardPermissions = class extends AbstractApplicationPermissions {
|
|
|
63087
63063
|
return [WhiteboardPermissionFlag.draw, WhiteboardPermissionFlag.editSelf, WhiteboardPermissionFlag.editOthers, WhiteboardPermissionFlag.deleteSelf, WhiteboardPermissionFlag.deleteOthers, WhiteboardPermissionFlag.mainView, WhiteboardPermissionFlag.setOthersView].filter((v) => (v & value) !== 0);
|
|
63088
63064
|
}
|
|
63089
63065
|
};
|
|
63090
|
-
var
|
|
63066
|
+
var import_lodash7 = __toESM2(require_lodash(), 1);
|
|
63091
63067
|
function _defineProperty15(e, r, t) {
|
|
63092
63068
|
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
63093
63069
|
}
|
|
@@ -63146,7 +63122,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
63146
63122
|
}
|
|
63147
63123
|
renderLine() {
|
|
63148
63124
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
63149
|
-
const papperPoints = (0,
|
|
63125
|
+
const papperPoints = (0, import_lodash7.chunk)(this.drawPoints, 2).map((item) => {
|
|
63150
63126
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
63151
63127
|
});
|
|
63152
63128
|
const path = new this.scope.Path();
|
|
@@ -63776,7 +63752,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
63776
63752
|
if (shadow) {
|
|
63777
63753
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
63778
63754
|
}
|
|
63779
|
-
yMap.set(ElementModel.KEYS.points,
|
|
63755
|
+
yMap.set(ElementModel.KEYS.points, Y12.Array.from([x, y]));
|
|
63780
63756
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
63781
63757
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
63782
63758
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
@@ -63784,7 +63760,6 @@ var RenderableModel = class extends EventEmitter {
|
|
|
63784
63760
|
this.elements.set(uuid, yMap);
|
|
63785
63761
|
}, elementsUndoOrigin);
|
|
63786
63762
|
pointTextModel.bindObserver();
|
|
63787
|
-
pointTextModel.setPoints([x, y]);
|
|
63788
63763
|
pointTextModel.fontSize = this.toolbarModel.fontSize;
|
|
63789
63764
|
pointTextModel.fontFamily = this.toolbarModel.fontFamily;
|
|
63790
63765
|
this.initElement(pointTextModel);
|
|
@@ -63816,7 +63791,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
63816
63791
|
});
|
|
63817
63792
|
}
|
|
63818
63793
|
};
|
|
63819
|
-
var
|
|
63794
|
+
var import_lodash8 = __toESM2(require_lodash(), 1);
|
|
63820
63795
|
function Point(x, y) {
|
|
63821
63796
|
this.X = x;
|
|
63822
63797
|
this.Y = y;
|
|
@@ -64059,7 +64034,7 @@ var Recognizer = class {
|
|
|
64059
64034
|
let maxX = -Number.MAX_VALUE;
|
|
64060
64035
|
let minY = Number.MAX_VALUE;
|
|
64061
64036
|
let maxY = -Number.MAX_VALUE;
|
|
64062
|
-
const result = this.dollar.Recognize((0,
|
|
64037
|
+
const result = this.dollar.Recognize((0, import_lodash8.chunk)(points, 2).map((v) => {
|
|
64063
64038
|
minX = Math.min(minX, v[0]);
|
|
64064
64039
|
maxX = Math.max(maxX, v[0]);
|
|
64065
64040
|
minY = Math.min(minY, v[1]);
|
|
@@ -64137,22 +64112,20 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
64137
64112
|
if (this.elementModel) {
|
|
64138
64113
|
let lastX = 0;
|
|
64139
64114
|
let lastY = 0;
|
|
64140
|
-
if (this.pendingPoints.length >=
|
|
64141
|
-
lastX = this.pendingPoints[this.pendingPoints.length -
|
|
64142
|
-
lastY = this.pendingPoints[this.pendingPoints.length -
|
|
64115
|
+
if (this.pendingPoints.length >= 2) {
|
|
64116
|
+
lastX = this.pendingPoints[this.pendingPoints.length - 2];
|
|
64117
|
+
lastY = this.pendingPoints[this.pendingPoints.length - 1];
|
|
64143
64118
|
} else {
|
|
64144
64119
|
const len = this.elementModel.points.length;
|
|
64145
|
-
if (len >=
|
|
64146
|
-
lastX = this.elementModel.points[len -
|
|
64147
|
-
lastY = this.elementModel.points[len -
|
|
64120
|
+
if (len >= 2) {
|
|
64121
|
+
lastX = this.elementModel.points[len - 2];
|
|
64122
|
+
lastY = this.elementModel.points[len - 1];
|
|
64148
64123
|
}
|
|
64149
64124
|
}
|
|
64150
64125
|
const dist = Math.max(Math.abs(lastX - event.point.x), Math.abs(lastY - event.point.y));
|
|
64151
64126
|
if (dist >= MIN_DISTANCE) {
|
|
64152
64127
|
this.pointCount += 1;
|
|
64153
|
-
|
|
64154
|
-
const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
|
|
64155
|
-
this.pendingPoints.push(event.point.x, event.point.y, pressure);
|
|
64128
|
+
this.pendingPoints.push(event.point.x, event.point.y);
|
|
64156
64129
|
if (!this.flushRafId) {
|
|
64157
64130
|
this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
|
|
64158
64131
|
}
|