@netless/forge-whiteboard 1.1.5 → 1.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +1 -13
- package/dist/LiveCursor.d.ts +1 -2
- package/dist/LiveCursor.d.ts.map +1 -1
- package/dist/Whiteboard.d.ts +0 -10
- package/dist/Whiteboard.d.ts.map +1 -1
- package/dist/WhiteboardApplication.d.ts +0 -6
- package/dist/WhiteboardApplication.d.ts.map +1 -1
- package/dist/edit/Editor.d.ts.map +1 -1
- package/dist/model/RenderableModel.d.ts +1 -13
- package/dist/model/RenderableModel.d.ts.map +1 -1
- package/dist/model/renderable/CurveModel.d.ts +3 -6
- package/dist/model/renderable/CurveModel.d.ts.map +1 -1
- package/dist/model/renderable/ElementModel.d.ts +1 -20
- package/dist/model/renderable/ElementModel.d.ts.map +1 -1
- package/dist/model/renderable/EraserModel.d.ts +1 -5
- package/dist/model/renderable/EraserModel.d.ts.map +1 -1
- package/dist/model/renderable/ImageModel.d.ts +1 -4
- package/dist/model/renderable/ImageModel.d.ts.map +1 -1
- package/dist/model/renderable/LaserPointerModel.d.ts +2 -8
- package/dist/model/renderable/LaserPointerModel.d.ts.map +1 -1
- package/dist/model/renderable/LineModel.d.ts +1 -5
- package/dist/model/renderable/LineModel.d.ts.map +1 -1
- package/dist/model/renderable/PointTextModel.d.ts +1 -6
- package/dist/model/renderable/PointTextModel.d.ts.map +1 -1
- package/dist/model/renderable/RectangleModel.d.ts +1 -5
- package/dist/model/renderable/RectangleModel.d.ts.map +1 -1
- package/dist/model/renderable/SegmentsModel.d.ts +1 -5
- package/dist/model/renderable/SegmentsModel.d.ts.map +1 -1
- package/dist/model/renderable/SelectorModel.d.ts +1 -5
- package/dist/model/renderable/SelectorModel.d.ts.map +1 -1
- package/dist/model/renderable/StraightLineModel.d.ts +1 -5
- package/dist/model/renderable/StraightLineModel.d.ts.map +1 -1
- package/dist/model/renderable/TriangleModel.d.ts +1 -5
- package/dist/model/renderable/TriangleModel.d.ts.map +1 -1
- package/dist/tool/CurveTool.d.ts +0 -3
- package/dist/tool/CurveTool.d.ts.map +1 -1
- package/dist/tool/LaserPointerTool.d.ts.map +1 -1
- package/dist/tool/WhiteboardTool.d.ts +0 -4
- package/dist/tool/WhiteboardTool.d.ts.map +1 -1
- package/dist/utils/paperjs.d.ts.map +1 -1
- package/dist/whiteboard.esm.js +272 -741
- package/dist/whiteboard.esm.js.map +3 -3
- package/dist/whiteboard.js +308 -777
- package/dist/whiteboard.js.map +3 -3
- package/package.json +2 -2
package/dist/whiteboard.esm.js
CHANGED
|
@@ -20839,8 +20839,8 @@ var require_lodash = __commonJS({
|
|
|
20839
20839
|
}
|
|
20840
20840
|
var runInContext = function runInContext2(context) {
|
|
20841
20841
|
context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
|
|
20842
|
-
var
|
|
20843
|
-
var arrayProto =
|
|
20842
|
+
var Array13 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String2 = context.String, TypeError2 = context.TypeError;
|
|
20843
|
+
var arrayProto = Array13.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
|
|
20844
20844
|
var coreJsData = context["__core-js_shared__"];
|
|
20845
20845
|
var funcToString = funcProto.toString;
|
|
20846
20846
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
@@ -21263,7 +21263,7 @@ var require_lodash = __commonJS({
|
|
|
21263
21263
|
}
|
|
21264
21264
|
}
|
|
21265
21265
|
function baseAt(object, paths) {
|
|
21266
|
-
var index = -1, length = paths.length, result2 =
|
|
21266
|
+
var index = -1, length = paths.length, result2 = Array13(length), skip = object == null;
|
|
21267
21267
|
while (++index < length) {
|
|
21268
21268
|
result2[index] = skip ? undefined2 : get(object, paths[index]);
|
|
21269
21269
|
}
|
|
@@ -21509,7 +21509,7 @@ var require_lodash = __commonJS({
|
|
|
21509
21509
|
return number >= nativeMin(start, end) && number < nativeMax(start, end);
|
|
21510
21510
|
}
|
|
21511
21511
|
function baseIntersection(arrays, iteratee2, comparator) {
|
|
21512
|
-
var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches =
|
|
21512
|
+
var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array13(othLength), maxLength = Infinity, result2 = [];
|
|
21513
21513
|
while (othIndex--) {
|
|
21514
21514
|
var array = arrays[othIndex];
|
|
21515
21515
|
if (othIndex && iteratee2) {
|
|
@@ -21690,7 +21690,7 @@ var require_lodash = __commonJS({
|
|
|
21690
21690
|
return value < other;
|
|
21691
21691
|
}
|
|
21692
21692
|
function baseMap(collection, iteratee2) {
|
|
21693
|
-
var index = -1, result2 = isArrayLike(collection) ?
|
|
21693
|
+
var index = -1, result2 = isArrayLike(collection) ? Array13(collection.length) : [];
|
|
21694
21694
|
baseEach(collection, function(value, key, collection2) {
|
|
21695
21695
|
result2[++index] = iteratee2(value, key, collection2);
|
|
21696
21696
|
});
|
|
@@ -21865,7 +21865,7 @@ var require_lodash = __commonJS({
|
|
|
21865
21865
|
return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
|
|
21866
21866
|
}
|
|
21867
21867
|
function baseRange(start, end, step, fromRight) {
|
|
21868
|
-
var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 =
|
|
21868
|
+
var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result2 = Array13(length);
|
|
21869
21869
|
while (length--) {
|
|
21870
21870
|
result2[fromRight ? length : ++index] = start;
|
|
21871
21871
|
start += step;
|
|
@@ -21947,7 +21947,7 @@ var require_lodash = __commonJS({
|
|
|
21947
21947
|
}
|
|
21948
21948
|
length = start > end ? 0 : end - start >>> 0;
|
|
21949
21949
|
start >>>= 0;
|
|
21950
|
-
var result2 =
|
|
21950
|
+
var result2 = Array13(length);
|
|
21951
21951
|
while (++index < length) {
|
|
21952
21952
|
result2[index] = array[index + start];
|
|
21953
21953
|
}
|
|
@@ -22107,7 +22107,7 @@ var require_lodash = __commonJS({
|
|
|
22107
22107
|
if (length < 2) {
|
|
22108
22108
|
return length ? baseUniq(arrays[0]) : [];
|
|
22109
22109
|
}
|
|
22110
|
-
var index = -1, result2 =
|
|
22110
|
+
var index = -1, result2 = Array13(length);
|
|
22111
22111
|
while (++index < length) {
|
|
22112
22112
|
var array = arrays[index], othIndex = -1;
|
|
22113
22113
|
while (++othIndex < length) {
|
|
@@ -22204,7 +22204,7 @@ var require_lodash = __commonJS({
|
|
|
22204
22204
|
return object.index - other.index;
|
|
22205
22205
|
}
|
|
22206
22206
|
function composeArgs(args, partials, holders, isCurried) {
|
|
22207
|
-
var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 =
|
|
22207
|
+
var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 = Array13(leftLength + rangeLength), isUncurried = !isCurried;
|
|
22208
22208
|
while (++leftIndex < leftLength) {
|
|
22209
22209
|
result2[leftIndex] = partials[leftIndex];
|
|
22210
22210
|
}
|
|
@@ -22219,7 +22219,7 @@ var require_lodash = __commonJS({
|
|
|
22219
22219
|
return result2;
|
|
22220
22220
|
}
|
|
22221
22221
|
function composeArgsRight(args, partials, holders, isCurried) {
|
|
22222
|
-
var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 =
|
|
22222
|
+
var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax(argsLength - holdersLength, 0), result2 = Array13(rangeLength + rightLength), isUncurried = !isCurried;
|
|
22223
22223
|
while (++argsIndex < rangeLength) {
|
|
22224
22224
|
result2[argsIndex] = args[argsIndex];
|
|
22225
22225
|
}
|
|
@@ -22236,7 +22236,7 @@ var require_lodash = __commonJS({
|
|
|
22236
22236
|
}
|
|
22237
22237
|
function copyArray(source, array) {
|
|
22238
22238
|
var index = -1, length = source.length;
|
|
22239
|
-
array || (array =
|
|
22239
|
+
array || (array = Array13(length));
|
|
22240
22240
|
while (++index < length) {
|
|
22241
22241
|
array[index] = source[index];
|
|
22242
22242
|
}
|
|
@@ -22369,7 +22369,7 @@ var require_lodash = __commonJS({
|
|
|
22369
22369
|
function createCurry(func, bitmask, arity) {
|
|
22370
22370
|
var Ctor = createCtor(func);
|
|
22371
22371
|
function wrapper() {
|
|
22372
|
-
var length = arguments.length, args =
|
|
22372
|
+
var length = arguments.length, args = Array13(length), index = length, placeholder = getHolder(wrapper);
|
|
22373
22373
|
while (index--) {
|
|
22374
22374
|
args[index] = arguments[index];
|
|
22375
22375
|
}
|
|
@@ -22449,7 +22449,7 @@ var require_lodash = __commonJS({
|
|
|
22449
22449
|
function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
|
|
22450
22450
|
var isAry = bitmask & WRAP_ARY_FLAG, isBind = bitmask & WRAP_BIND_FLAG, isBindKey = bitmask & WRAP_BIND_KEY_FLAG, isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), isFlip = bitmask & WRAP_FLIP_FLAG, Ctor = isBindKey ? undefined2 : createCtor(func);
|
|
22451
22451
|
function wrapper() {
|
|
22452
|
-
var length = arguments.length, args =
|
|
22452
|
+
var length = arguments.length, args = Array13(length), index = length;
|
|
22453
22453
|
while (index--) {
|
|
22454
22454
|
args[index] = arguments[index];
|
|
22455
22455
|
}
|
|
@@ -22548,7 +22548,7 @@ var require_lodash = __commonJS({
|
|
|
22548
22548
|
function createPartial(func, bitmask, thisArg, partials) {
|
|
22549
22549
|
var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
|
|
22550
22550
|
function wrapper() {
|
|
22551
|
-
var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args =
|
|
22551
|
+
var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array13(leftLength + argsLength), fn = this && this !== root && this instanceof wrapper ? Ctor : func;
|
|
22552
22552
|
while (++leftIndex < leftLength) {
|
|
22553
22553
|
args[leftIndex] = partials[leftIndex];
|
|
22554
22554
|
}
|
|
@@ -23161,12 +23161,12 @@ var require_lodash = __commonJS({
|
|
|
23161
23161
|
function overRest(func, start, transform2) {
|
|
23162
23162
|
start = nativeMax(start === undefined2 ? func.length - 1 : start, 0);
|
|
23163
23163
|
return function() {
|
|
23164
|
-
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array =
|
|
23164
|
+
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array13(length);
|
|
23165
23165
|
while (++index < length) {
|
|
23166
23166
|
array[index] = args[start + index];
|
|
23167
23167
|
}
|
|
23168
23168
|
index = -1;
|
|
23169
|
-
var otherArgs =
|
|
23169
|
+
var otherArgs = Array13(start + 1);
|
|
23170
23170
|
while (++index < start) {
|
|
23171
23171
|
otherArgs[index] = args[index];
|
|
23172
23172
|
}
|
|
@@ -23278,7 +23278,7 @@ var require_lodash = __commonJS({
|
|
|
23278
23278
|
result2.__values__ = wrapper.__values__;
|
|
23279
23279
|
return result2;
|
|
23280
23280
|
}
|
|
23281
|
-
function
|
|
23281
|
+
function chunk8(array, size2, guard) {
|
|
23282
23282
|
if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
|
|
23283
23283
|
size2 = 1;
|
|
23284
23284
|
} else {
|
|
@@ -23288,7 +23288,7 @@ var require_lodash = __commonJS({
|
|
|
23288
23288
|
if (!length || size2 < 1) {
|
|
23289
23289
|
return [];
|
|
23290
23290
|
}
|
|
23291
|
-
var index = 0, resIndex = 0, result2 =
|
|
23291
|
+
var index = 0, resIndex = 0, result2 = Array13(nativeCeil(length / size2));
|
|
23292
23292
|
while (index < length) {
|
|
23293
23293
|
result2[resIndex++] = baseSlice(array, index, index += size2);
|
|
23294
23294
|
}
|
|
@@ -23309,7 +23309,7 @@ var require_lodash = __commonJS({
|
|
|
23309
23309
|
if (!length) {
|
|
23310
23310
|
return [];
|
|
23311
23311
|
}
|
|
23312
|
-
var args =
|
|
23312
|
+
var args = Array13(length - 1), array = arguments[0], index = length;
|
|
23313
23313
|
while (index--) {
|
|
23314
23314
|
args[index - 1] = arguments[index];
|
|
23315
23315
|
}
|
|
@@ -23811,7 +23811,7 @@ var require_lodash = __commonJS({
|
|
|
23811
23811
|
return isString(collection) ? fromIndex <= length && collection.indexOf(value, fromIndex) > -1 : !!length && baseIndexOf(collection, value, fromIndex) > -1;
|
|
23812
23812
|
}
|
|
23813
23813
|
var invokeMap = baseRest(function(collection, path, args) {
|
|
23814
|
-
var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ?
|
|
23814
|
+
var index = -1, isFunc = typeof path == "function", result2 = isArrayLike(collection) ? Array13(collection.length) : [];
|
|
23815
23815
|
baseEach(collection, function(value) {
|
|
23816
23816
|
result2[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
|
|
23817
23817
|
});
|
|
@@ -24194,7 +24194,7 @@ var require_lodash = __commonJS({
|
|
|
24194
24194
|
}()) ? baseIsArguments : function(value) {
|
|
24195
24195
|
return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
|
|
24196
24196
|
};
|
|
24197
|
-
var isArray =
|
|
24197
|
+
var isArray = Array13.isArray;
|
|
24198
24198
|
var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
|
|
24199
24199
|
function isArrayLike(value) {
|
|
24200
24200
|
return value != null && isLength(value.length) && !isFunction(value);
|
|
@@ -25150,7 +25150,7 @@ var require_lodash = __commonJS({
|
|
|
25150
25150
|
lodash.bindKey = bindKey;
|
|
25151
25151
|
lodash.castArray = castArray;
|
|
25152
25152
|
lodash.chain = chain;
|
|
25153
|
-
lodash.chunk =
|
|
25153
|
+
lodash.chunk = chunk8;
|
|
25154
25154
|
lodash.compact = compact;
|
|
25155
25155
|
lodash.concat = concat;
|
|
25156
25156
|
lodash.cond = cond;
|
|
@@ -25637,7 +25637,7 @@ import * as Y15 from "yjs";
|
|
|
25637
25637
|
import * as Y12 from "yjs";
|
|
25638
25638
|
import EventEmitter from "eventemitter3";
|
|
25639
25639
|
import { v4 as uuidv4 } from "uuid";
|
|
25640
|
-
import { log, removeObserver as
|
|
25640
|
+
import { log, removeObserver as removeObserver2 } from "@netless/forge-room";
|
|
25641
25641
|
|
|
25642
25642
|
// src/model/renderable/CurveModel.ts
|
|
25643
25643
|
import * as Y2 from "yjs";
|
|
@@ -25790,6 +25790,9 @@ function ae(e, t = {}) {
|
|
|
25790
25790
|
return ce(me(e, t), t);
|
|
25791
25791
|
}
|
|
25792
25792
|
|
|
25793
|
+
// src/model/renderable/CurveModel.ts
|
|
25794
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
25795
|
+
|
|
25793
25796
|
// src/model/renderable/ElementModel.ts
|
|
25794
25797
|
import * as Y from "yjs";
|
|
25795
25798
|
import { removeDeepObserver } from "@netless/forge-room";
|
|
@@ -25877,23 +25880,12 @@ var ElementModel = class _ElementModel {
|
|
|
25877
25880
|
set shadow(value) {
|
|
25878
25881
|
this.root.set(_ElementModel.KEYS.shadow, value);
|
|
25879
25882
|
}
|
|
25880
|
-
|
|
25881
|
-
return this.isPerformanceMode() && this.shouldUseLocalPoints;
|
|
25882
|
-
}
|
|
25883
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
25883
|
+
constructor(root, scope, liveCursor) {
|
|
25884
25884
|
_defineProperty(this, "shadowEmitter", null);
|
|
25885
25885
|
_defineProperty(this, "root", void 0);
|
|
25886
25886
|
_defineProperty(this, "scope", void 0);
|
|
25887
25887
|
_defineProperty(this, "item", void 0);
|
|
25888
|
-
_defineProperty(this, "clearLocalPointsWhenYPointsChange", void 0);
|
|
25889
|
-
_defineProperty(this, "shouldUseLocalPoints", void 0);
|
|
25890
|
-
_defineProperty(this, "localPointsPick", void 0);
|
|
25891
25888
|
_defineProperty(this, "liveCursor", void 0);
|
|
25892
|
-
_defineProperty(this, "appendPointsTimer", null);
|
|
25893
|
-
_defineProperty(this, "setPointsTimer", null);
|
|
25894
|
-
_defineProperty(this, "pointsUpdateTimer", null);
|
|
25895
|
-
_defineProperty(this, "isPerformanceMode", void 0);
|
|
25896
|
-
_defineProperty(this, "localPoints", []);
|
|
25897
25889
|
_defineProperty(this, "handlePropChange", (events) => {
|
|
25898
25890
|
if (!this.item) {
|
|
25899
25891
|
return;
|
|
@@ -25932,80 +25924,23 @@ var ElementModel = class _ElementModel {
|
|
|
25932
25924
|
}
|
|
25933
25925
|
}
|
|
25934
25926
|
} else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
|
|
25935
|
-
|
|
25936
|
-
|
|
25937
|
-
|
|
25938
|
-
|
|
25927
|
+
this.onVectorUpdate();
|
|
25928
|
+
const liveCursorPoint = this.liveCursorPoint();
|
|
25929
|
+
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
25930
|
+
if (liveCursorPoint && ownerId) {
|
|
25931
|
+
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
25939
25932
|
}
|
|
25940
25933
|
} else {
|
|
25941
25934
|
}
|
|
25942
25935
|
}
|
|
25943
25936
|
});
|
|
25944
|
-
_defineProperty(this, "onPointsArrayChange", (points) => {
|
|
25945
|
-
if (this.localPoints.length >= points.length) {
|
|
25946
|
-
return;
|
|
25947
|
-
}
|
|
25948
|
-
const pointsChunk = points.slice(this.localPoints.length, this.localPoints.length + this.localPointsPick);
|
|
25949
|
-
this.localPoints = this.localPoints.concat(pointsChunk);
|
|
25950
|
-
this.onVectorUpdate();
|
|
25951
|
-
this.pointsUpdateTimer = window.requestAnimationFrame(() => {
|
|
25952
|
-
this.onPointsArrayChange(points);
|
|
25953
|
-
});
|
|
25954
|
-
});
|
|
25955
|
-
this.isPerformanceMode = isPerformanceMode;
|
|
25956
25937
|
this.scope = scope;
|
|
25957
25938
|
this.liveCursor = liveCursor;
|
|
25958
25939
|
this.root = root;
|
|
25959
|
-
if (this.root.
|
|
25960
|
-
if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
|
|
25961
|
-
this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
|
|
25962
|
-
}
|
|
25963
|
-
} else {
|
|
25940
|
+
if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
|
|
25964
25941
|
this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
|
|
25965
25942
|
}
|
|
25966
|
-
}
|
|
25967
|
-
bindObserver() {
|
|
25968
|
-
const beforeL = this.root._eH?.l?.length ?? -1;
|
|
25969
|
-
const beforeDL = this.root._dEH?.l?.length ?? -1;
|
|
25970
|
-
removeDeepObserver(this.root, this.handlePropChange);
|
|
25971
|
-
this.subBindObserver();
|
|
25972
|
-
const afterRemoveL = this.root._eH?.l?.length ?? -1;
|
|
25973
|
-
const afterRemoveDL = this.root._dEH?.l?.length ?? -1;
|
|
25974
25943
|
this.root.observeDeep(this.handlePropChange);
|
|
25975
|
-
const afterAddL = this.root._eH?.l?.length ?? -1;
|
|
25976
|
-
const afterAddDL = this.root._dEH?.l?.length ?? -1;
|
|
25977
|
-
console.log(`[][][] bindObserver uuid=${this.uuid} doc=${!!this.root.doc} _eH: ${beforeL}->${afterRemoveL}->${afterAddL} _dEH: ${beforeDL}->${afterRemoveDL}->${afterAddDL}`);
|
|
25978
|
-
}
|
|
25979
|
-
subBindObserver() {
|
|
25980
|
-
}
|
|
25981
|
-
handlePointsChangeDirect() {
|
|
25982
|
-
this.onVectorUpdate();
|
|
25983
|
-
const liveCursorPoint = this.liveCursorPoint();
|
|
25984
|
-
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
25985
|
-
if (liveCursorPoint && ownerId) {
|
|
25986
|
-
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
25987
|
-
}
|
|
25988
|
-
}
|
|
25989
|
-
handlePointsChangePerformance() {
|
|
25990
|
-
const liveCursorPoint = this.liveCursorPoint();
|
|
25991
|
-
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
25992
|
-
if (liveCursorPoint && ownerId) {
|
|
25993
|
-
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
25994
|
-
}
|
|
25995
|
-
if (this.liveCursor.userManager.selfId !== ownerId || this.localPoints.length === 0) {
|
|
25996
|
-
if (this.pointsUpdateTimer) {
|
|
25997
|
-
window.cancelAnimationFrame(this.pointsUpdateTimer);
|
|
25998
|
-
}
|
|
25999
|
-
if (this.shadow == "") {
|
|
26000
|
-
this.localPoints = this.points;
|
|
26001
|
-
this.onVectorUpdate();
|
|
26002
|
-
} else {
|
|
26003
|
-
if (this.clearLocalPointsWhenYPointsChange) {
|
|
26004
|
-
this.localPoints = [];
|
|
26005
|
-
}
|
|
26006
|
-
this.onPointsArrayChange(this.points);
|
|
26007
|
-
}
|
|
26008
|
-
}
|
|
26009
25944
|
}
|
|
26010
25945
|
createPaperElement() {
|
|
26011
25946
|
this.createPaperItem();
|
|
@@ -26018,48 +25953,14 @@ var ElementModel = class _ElementModel {
|
|
|
26018
25953
|
}
|
|
26019
25954
|
}
|
|
26020
25955
|
appendPoints(points) {
|
|
26021
|
-
if (this.isPerformanceEnvironment) {
|
|
26022
|
-
this.appendPointsPerformance(points);
|
|
26023
|
-
} else {
|
|
26024
|
-
this.appendPointsDirect(points);
|
|
26025
|
-
}
|
|
26026
|
-
}
|
|
26027
|
-
appendPointsDirect(points) {
|
|
26028
25956
|
this.root.get(_ElementModel.KEYS.points).push(points);
|
|
26029
25957
|
}
|
|
26030
|
-
appendPointsPerformance(points) {
|
|
26031
|
-
this.localPoints = this.localPoints.concat(points);
|
|
26032
|
-
this.onVectorUpdate();
|
|
26033
|
-
if (this.appendPointsTimer) {
|
|
26034
|
-
window.clearTimeout(this.appendPointsTimer);
|
|
26035
|
-
}
|
|
26036
|
-
if (this.localPoints.length % 80 === 0) {
|
|
26037
|
-
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26038
|
-
yArray?.push(this.localPoints.slice(yArray.length));
|
|
26039
|
-
}
|
|
26040
|
-
this.appendPointsTimer = window.setTimeout(() => {
|
|
26041
|
-
this.appendPointsTimer = null;
|
|
26042
|
-
if (this.localPoints.length > 0) {
|
|
26043
|
-
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26044
|
-
yArray?.push(this.localPoints.slice(yArray.length));
|
|
26045
|
-
}
|
|
26046
|
-
}, 100);
|
|
26047
|
-
}
|
|
26048
25958
|
setPoints(points) {
|
|
26049
|
-
if (this.isPerformanceEnvironment) {
|
|
26050
|
-
this.setPointsPerformance(points);
|
|
26051
|
-
} else {
|
|
26052
|
-
this.setPointsDirect(points);
|
|
26053
|
-
}
|
|
26054
|
-
}
|
|
26055
|
-
setPointsDirect(points) {
|
|
26056
25959
|
if (this.root.doc) {
|
|
26057
25960
|
this.root.doc.transact(() => {
|
|
26058
25961
|
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26059
|
-
|
|
26060
|
-
|
|
26061
|
-
yArray.push(points);
|
|
26062
|
-
}
|
|
25962
|
+
yArray.delete(0, yArray.length);
|
|
25963
|
+
yArray.push(points);
|
|
26063
25964
|
});
|
|
26064
25965
|
} else {
|
|
26065
25966
|
const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
|
|
@@ -26068,29 +25969,6 @@ var ElementModel = class _ElementModel {
|
|
|
26068
25969
|
this.root.set(_ElementModel.KEYS.points, yArray);
|
|
26069
25970
|
}
|
|
26070
25971
|
}
|
|
26071
|
-
setPointsPerformance(points) {
|
|
26072
|
-
this.localPoints = points;
|
|
26073
|
-
this.onVectorUpdate();
|
|
26074
|
-
if (this.setPointsTimer) {
|
|
26075
|
-
window.clearTimeout(this.setPointsTimer);
|
|
26076
|
-
}
|
|
26077
|
-
this.setPointsTimer = window.setTimeout(() => {
|
|
26078
|
-
if (this.root.doc) {
|
|
26079
|
-
this.root.doc.transact(() => {
|
|
26080
|
-
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26081
|
-
if (yArray) {
|
|
26082
|
-
yArray.delete(0, yArray.length);
|
|
26083
|
-
yArray.push(points);
|
|
26084
|
-
}
|
|
26085
|
-
});
|
|
26086
|
-
} else {
|
|
26087
|
-
const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
|
|
26088
|
-
yArray.delete(0, yArray.length);
|
|
26089
|
-
yArray.push(points);
|
|
26090
|
-
this.root.set(_ElementModel.KEYS.points, yArray);
|
|
26091
|
-
}
|
|
26092
|
-
}, 100);
|
|
26093
|
-
}
|
|
26094
25972
|
appendPointsMatrix(matrix) {
|
|
26095
25973
|
const current = new this.scope.Matrix(this.pointsMatrix);
|
|
26096
25974
|
const next = matrix.appended(current);
|
|
@@ -26117,9 +25995,6 @@ var ElementModel = class _ElementModel {
|
|
|
26117
25995
|
}
|
|
26118
25996
|
dispose() {
|
|
26119
25997
|
this.subDispose();
|
|
26120
|
-
}
|
|
26121
|
-
disposeObserver() {
|
|
26122
|
-
console.log(`[][][] disposeObserver uuid=${this.uuid}`);
|
|
26123
25998
|
removeDeepObserver(this.root, this.handlePropChange);
|
|
26124
25999
|
}
|
|
26125
26000
|
};
|
|
@@ -26192,72 +26067,47 @@ function _toPrimitive3(t, r) {
|
|
|
26192
26067
|
return ("string" === r ? String : Number)(t);
|
|
26193
26068
|
}
|
|
26194
26069
|
var CurveModel = class extends ElementModel {
|
|
26195
|
-
constructor(root, scope, liveCursor
|
|
26196
|
-
super(root, scope, liveCursor
|
|
26070
|
+
constructor(root, scope, liveCursor) {
|
|
26071
|
+
super(root, scope, liveCursor);
|
|
26197
26072
|
_defineProperty3(this, "item", null);
|
|
26073
|
+
_defineProperty3(this, "debugPath", void 0);
|
|
26198
26074
|
_defineProperty3(this, "debug", false);
|
|
26199
|
-
|
|
26200
|
-
_defineProperty3(this, "shouldUseLocalPoints", true);
|
|
26201
|
-
_defineProperty3(this, "localPointsPick", 6);
|
|
26202
|
-
if (!this.root.doc || !this.root.has("type")) {
|
|
26075
|
+
if (!this.root.has("type")) {
|
|
26203
26076
|
this.root.set("type", "curve");
|
|
26204
26077
|
}
|
|
26205
|
-
if (!this.root.
|
|
26078
|
+
if (!this.root.has("points")) {
|
|
26206
26079
|
this.root.set("points", new Y2.Array());
|
|
26207
26080
|
}
|
|
26081
|
+
this.debugPath = new scope.Path();
|
|
26208
26082
|
}
|
|
26209
26083
|
average(a2, b2) {
|
|
26210
26084
|
return (a2 + b2) / 2;
|
|
26211
26085
|
}
|
|
26212
26086
|
parsePoints(points) {
|
|
26213
|
-
const hasRealPressure = points.some((p) => p.length >= 3 && p[2] > 0);
|
|
26214
|
-
const viewScale = this.scope.project.view.matrix.scaling.x || 1;
|
|
26215
|
-
const taper = this.strokeWidth * 5 / viewScale;
|
|
26216
|
-
const streamline = Math.min(0.7, 0.7 * viewScale);
|
|
26217
26087
|
return ae(points, {
|
|
26218
26088
|
size: this.strokeWidth,
|
|
26219
|
-
smoothing: 0.
|
|
26220
|
-
thinning: 0.5,
|
|
26221
|
-
streamline,
|
|
26222
|
-
simulatePressure:
|
|
26089
|
+
smoothing: 0.5,
|
|
26090
|
+
thinning: -0.5,
|
|
26091
|
+
streamline: 0.5,
|
|
26092
|
+
simulatePressure: true,
|
|
26223
26093
|
start: {
|
|
26224
|
-
taper,
|
|
26094
|
+
taper: this.strokeWidth * 10,
|
|
26225
26095
|
cap: true
|
|
26226
26096
|
},
|
|
26227
26097
|
end: {
|
|
26228
|
-
taper,
|
|
26098
|
+
taper: this.strokeWidth * 20,
|
|
26229
26099
|
cap: true
|
|
26230
26100
|
}
|
|
26231
26101
|
});
|
|
26232
26102
|
}
|
|
26233
|
-
isPressureValue(value) {
|
|
26234
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
26235
|
-
}
|
|
26236
|
-
pointStride(points) {
|
|
26237
|
-
if (points.length >= 3 && points.length % 3 === 0) {
|
|
26238
|
-
let hasPressureSlot = false;
|
|
26239
|
-
for (let i = 2; i < points.length; i += 3) {
|
|
26240
|
-
if (!this.isPressureValue(points[i])) {
|
|
26241
|
-
return 2;
|
|
26242
|
-
}
|
|
26243
|
-
hasPressureSlot = true;
|
|
26244
|
-
}
|
|
26245
|
-
if (hasPressureSlot) {
|
|
26246
|
-
return 3;
|
|
26247
|
-
}
|
|
26248
|
-
}
|
|
26249
|
-
return 2;
|
|
26250
|
-
}
|
|
26251
26103
|
matrixedPoints() {
|
|
26252
|
-
const points = this.
|
|
26104
|
+
const points = this.points;
|
|
26253
26105
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26254
26106
|
const output = [];
|
|
26255
|
-
|
|
26256
|
-
for (let i = 0, len = points.length; i + 1 < len; i += stride) {
|
|
26107
|
+
for (let i = 0, len = points.length; i < len; i += 2) {
|
|
26257
26108
|
const p = new this.scope.Point(points[i], points[i + 1]);
|
|
26258
26109
|
const tp = p.transform(matrix);
|
|
26259
|
-
|
|
26260
|
-
output.push([tp.x, tp.y, pressure]);
|
|
26110
|
+
output.push([tp.x, tp.y]);
|
|
26261
26111
|
}
|
|
26262
26112
|
return output;
|
|
26263
26113
|
}
|
|
@@ -26286,30 +26136,34 @@ var CurveModel = class extends ElementModel {
|
|
|
26286
26136
|
}
|
|
26287
26137
|
return path;
|
|
26288
26138
|
}
|
|
26139
|
+
updateDebugPath() {
|
|
26140
|
+
this.debugPath = new this.scope.Path();
|
|
26141
|
+
const points = (0, import_lodash.chunk)(this.points, 2);
|
|
26142
|
+
for (let i = 0, len = points.length; i < len; i++) {
|
|
26143
|
+
const point = new this.scope.Point(points[i][0], points[i][1]);
|
|
26144
|
+
if (i === 0) {
|
|
26145
|
+
this.debugPath.moveTo(point);
|
|
26146
|
+
} else {
|
|
26147
|
+
this.debugPath.lineTo(point);
|
|
26148
|
+
}
|
|
26149
|
+
this.debugPath.strokeWidth = 1;
|
|
26150
|
+
this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
|
|
26151
|
+
}
|
|
26152
|
+
}
|
|
26289
26153
|
onVectorUpdate() {
|
|
26290
26154
|
if (!this.item) {
|
|
26291
26155
|
return;
|
|
26292
26156
|
}
|
|
26293
|
-
const matrixedPts = this.matrixedPoints();
|
|
26294
26157
|
if (this.debug) {
|
|
26295
|
-
|
|
26296
|
-
|
|
26297
|
-
|
|
26298
|
-
|
|
26299
|
-
|
|
26300
|
-
|
|
26301
|
-
|
|
26302
|
-
|
|
26303
|
-
|
|
26304
|
-
this.item.removeSegments();
|
|
26305
|
-
this.item.addSegments(path.segments);
|
|
26306
|
-
this.item.fillColor = null;
|
|
26307
|
-
this.item.strokeWidth = this.strokeWidth;
|
|
26308
|
-
} else {
|
|
26309
|
-
const points = this.parsePoints(matrixedPts);
|
|
26310
|
-
const path = this.createPath(points);
|
|
26311
|
-
this.item.removeSegments();
|
|
26312
|
-
this.item.addSegments(path.segments);
|
|
26158
|
+
this.debugPath.remove();
|
|
26159
|
+
this.updateDebugPath();
|
|
26160
|
+
}
|
|
26161
|
+
const points = this.parsePoints(this.matrixedPoints());
|
|
26162
|
+
const path = this.createPath(points);
|
|
26163
|
+
this.item.removeSegments();
|
|
26164
|
+
this.item.addSegments(path.segments);
|
|
26165
|
+
if (this.debug) {
|
|
26166
|
+
this.item.addChild(this.debugPath);
|
|
26313
26167
|
}
|
|
26314
26168
|
}
|
|
26315
26169
|
createPaperItem() {
|
|
@@ -26332,13 +26186,11 @@ var CurveModel = class extends ElementModel {
|
|
|
26332
26186
|
}
|
|
26333
26187
|
liveCursorPoint() {
|
|
26334
26188
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
26335
|
-
|
|
26336
|
-
const stride = this.pointStride(points);
|
|
26337
|
-
if (points.length < stride) {
|
|
26189
|
+
if (yArray.length < 2) {
|
|
26338
26190
|
return null;
|
|
26339
26191
|
}
|
|
26340
|
-
const len =
|
|
26341
|
-
const point = new this.scope.Point(
|
|
26192
|
+
const len = yArray.length;
|
|
26193
|
+
const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
|
|
26342
26194
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
26343
26195
|
}
|
|
26344
26196
|
onStyleKeyUpdate(key) {
|
|
@@ -26376,24 +26228,15 @@ function _toPrimitive4(t, r) {
|
|
|
26376
26228
|
return ("string" === r ? String : Number)(t);
|
|
26377
26229
|
}
|
|
26378
26230
|
var SelectorModel = class extends ElementModel {
|
|
26379
|
-
|
|
26380
|
-
|
|
26381
|
-
return this.localPoints;
|
|
26382
|
-
}
|
|
26383
|
-
return this.points;
|
|
26384
|
-
}
|
|
26385
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
26386
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26231
|
+
constructor(root, scope, liveCursor) {
|
|
26232
|
+
super(root, scope, liveCursor);
|
|
26387
26233
|
_defineProperty4(this, "item", null);
|
|
26388
|
-
|
|
26389
|
-
_defineProperty4(this, "shouldUseLocalPoints", true);
|
|
26390
|
-
_defineProperty4(this, "localPointsPick", 4);
|
|
26391
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26234
|
+
if (!this.root.has("type")) {
|
|
26392
26235
|
this.root.set("type", "selector");
|
|
26393
26236
|
}
|
|
26394
|
-
if (
|
|
26237
|
+
if (!this.root.has("points")) {
|
|
26395
26238
|
const initPoints = new Y3.Array();
|
|
26396
|
-
initPoints.push([0, 0, 0, 0]);
|
|
26239
|
+
initPoints.push([0, 0, 0, 0, 0]);
|
|
26397
26240
|
this.root.set("points", initPoints);
|
|
26398
26241
|
}
|
|
26399
26242
|
}
|
|
@@ -26404,8 +26247,8 @@ var SelectorModel = class extends ElementModel {
|
|
|
26404
26247
|
}
|
|
26405
26248
|
createPaperRect() {
|
|
26406
26249
|
const scope = this.scope;
|
|
26407
|
-
const bounds = new scope.Rectangle(new scope.Point(this.
|
|
26408
|
-
return new scope.Path.Rectangle(bounds);
|
|
26250
|
+
const bounds = new scope.Rectangle(new scope.Point(this.points[0], this.points[1]), new scope.Size(this.points[2], this.points[3]));
|
|
26251
|
+
return new scope.Path.Rectangle(bounds, new scope.Point(this.points[4], this.points[4]));
|
|
26409
26252
|
}
|
|
26410
26253
|
onVectorUpdate() {
|
|
26411
26254
|
if (!this.item) {
|
|
@@ -26439,8 +26282,7 @@ var SelectorModel = class extends ElementModel {
|
|
|
26439
26282
|
import * as Y4 from "yjs";
|
|
26440
26283
|
|
|
26441
26284
|
// src/utils/paperjs.ts
|
|
26442
|
-
var
|
|
26443
|
-
import { metrics } from "@netless/forge-room";
|
|
26285
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
26444
26286
|
function _defineProperty5(e, r, t) {
|
|
26445
26287
|
return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26446
26288
|
}
|
|
@@ -26473,7 +26315,7 @@ function serializePath(path) {
|
|
|
26473
26315
|
}, []);
|
|
26474
26316
|
}
|
|
26475
26317
|
function deserializePath(points, scope, matrix) {
|
|
26476
|
-
const segmentGroup = (0,
|
|
26318
|
+
const segmentGroup = (0, import_lodash2.chunk)(points, 6);
|
|
26477
26319
|
const path = new scope.Path();
|
|
26478
26320
|
path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
|
|
26479
26321
|
return path;
|
|
@@ -26483,27 +26325,7 @@ var AnimationFrame = class {
|
|
|
26483
26325
|
_defineProperty5(this, "callbacks", []);
|
|
26484
26326
|
_defineProperty5(this, "lastTime", 0);
|
|
26485
26327
|
_defineProperty5(this, "fps", 45);
|
|
26486
|
-
_defineProperty5(this, "lastCallbackTime", 0);
|
|
26487
|
-
_defineProperty5(this, "fpsBuffer", []);
|
|
26488
|
-
_defineProperty5(this, "FPS_REPORT_INTERVAL", 2700);
|
|
26489
26328
|
_defineProperty5(this, "handleCallbacks", () => {
|
|
26490
|
-
const now = performance.now();
|
|
26491
|
-
if (this.lastCallbackTime > 0) {
|
|
26492
|
-
const actualFps = 1e3 / (now - this.lastCallbackTime);
|
|
26493
|
-
this.fpsBuffer.push(actualFps);
|
|
26494
|
-
if (this.fpsBuffer.length >= this.FPS_REPORT_INTERVAL) {
|
|
26495
|
-
const avg = this.fpsBuffer.reduce((a2, b2) => a2 + b2, 0) / this.fpsBuffer.length;
|
|
26496
|
-
const min = Math.min(...this.fpsBuffer);
|
|
26497
|
-
const sorted = [...this.fpsBuffer].sort((a2, b2) => a2 - b2);
|
|
26498
|
-
const p90 = sorted[Math.floor(sorted.length * 0.9)];
|
|
26499
|
-
metrics().gauge("fps", Math.round(avg), {
|
|
26500
|
-
min: Math.round(min),
|
|
26501
|
-
p90: Math.round(p90)
|
|
26502
|
-
});
|
|
26503
|
-
this.fpsBuffer = [];
|
|
26504
|
-
}
|
|
26505
|
-
}
|
|
26506
|
-
this.lastCallbackTime = now;
|
|
26507
26329
|
const functions = this.callbacks;
|
|
26508
26330
|
this.callbacks = [];
|
|
26509
26331
|
for (let i = 0, l2 = functions.length; i < l2; i++) {
|
|
@@ -26547,22 +26369,13 @@ function _toPrimitive6(t, r) {
|
|
|
26547
26369
|
return ("string" === r ? String : Number)(t);
|
|
26548
26370
|
}
|
|
26549
26371
|
var SegmentsModel = class extends ElementModel {
|
|
26550
|
-
|
|
26551
|
-
|
|
26552
|
-
return this.localPoints;
|
|
26553
|
-
}
|
|
26554
|
-
return this.points;
|
|
26555
|
-
}
|
|
26556
|
-
constructor(root, scope, type, liveCursor, isPerformanceMode) {
|
|
26557
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26372
|
+
constructor(root, scope, type, liveCursor) {
|
|
26373
|
+
super(root, scope, liveCursor);
|
|
26558
26374
|
_defineProperty6(this, "item", null);
|
|
26559
|
-
|
|
26560
|
-
_defineProperty6(this, "shouldUseLocalPoints", true);
|
|
26561
|
-
_defineProperty6(this, "localPointsPick", 24);
|
|
26562
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26375
|
+
if (!this.root.has("type")) {
|
|
26563
26376
|
this.root.set("type", type);
|
|
26564
26377
|
}
|
|
26565
|
-
if (
|
|
26378
|
+
if (!this.root.has("points")) {
|
|
26566
26379
|
this.root.set("points", new Y4.Array());
|
|
26567
26380
|
}
|
|
26568
26381
|
}
|
|
@@ -26582,13 +26395,13 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26582
26395
|
}
|
|
26583
26396
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26584
26397
|
this.item.removeSegments();
|
|
26585
|
-
const next = deserializePath(this.
|
|
26398
|
+
const next = deserializePath(this.points, this.scope, matrix);
|
|
26586
26399
|
this.item.addSegments(next.segments);
|
|
26587
26400
|
this.item.closePath();
|
|
26588
26401
|
}
|
|
26589
26402
|
createPaperItem() {
|
|
26590
26403
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26591
|
-
this.item = deserializePath(this.
|
|
26404
|
+
this.item = deserializePath(this.points, this.scope, matrix);
|
|
26592
26405
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
26593
26406
|
this.item.dashArray = this.dashArray;
|
|
26594
26407
|
this.item.strokeWidth = this.strokeWidth;
|
|
@@ -26615,7 +26428,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26615
26428
|
};
|
|
26616
26429
|
|
|
26617
26430
|
// src/model/renderable/LineModel.ts
|
|
26618
|
-
var
|
|
26431
|
+
var import_lodash4 = __toESM(require_lodash(), 1);
|
|
26619
26432
|
import * as Y5 from "yjs";
|
|
26620
26433
|
|
|
26621
26434
|
// src/tool/WhiteboardTool.ts
|
|
@@ -26636,8 +26449,6 @@ function _toPrimitive7(t, r) {
|
|
|
26636
26449
|
}
|
|
26637
26450
|
return ("string" === r ? String : Number)(t);
|
|
26638
26451
|
}
|
|
26639
|
-
var DRAG_FPS = 10;
|
|
26640
|
-
var DRAG_FRAME_MS = 1e3 / DRAG_FPS;
|
|
26641
26452
|
var WhiteboardTool = class {
|
|
26642
26453
|
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
26643
26454
|
_defineProperty7(this, "modelGetter", void 0);
|
|
@@ -26646,60 +26457,24 @@ var WhiteboardTool = class {
|
|
|
26646
26457
|
_defineProperty7(this, "shadowEmitter", void 0);
|
|
26647
26458
|
_defineProperty7(this, "enableToolEvent", void 0);
|
|
26648
26459
|
_defineProperty7(this, "eventAvailable", false);
|
|
26649
|
-
_defineProperty7(this, "lastDragTime", 0);
|
|
26650
|
-
_defineProperty7(this, "dragRafId", 0);
|
|
26651
|
-
_defineProperty7(this, "pendingDragEvent", null);
|
|
26652
26460
|
_defineProperty7(this, "onMouseDownSelf", (event) => {
|
|
26653
26461
|
this.eventAvailable = this.enableToolEvent();
|
|
26654
26462
|
if (!this.eventAvailable) {
|
|
26655
26463
|
return;
|
|
26656
26464
|
}
|
|
26657
|
-
this.lastDragTime = 0;
|
|
26658
|
-
if (this.dragRafId) {
|
|
26659
|
-
cancelAnimationFrame(this.dragRafId);
|
|
26660
|
-
this.dragRafId = 0;
|
|
26661
|
-
}
|
|
26662
|
-
this.pendingDragEvent = null;
|
|
26663
26465
|
this.shadowEmitter.setActive(true);
|
|
26664
26466
|
this.onMouseDown(event);
|
|
26665
26467
|
});
|
|
26666
|
-
_defineProperty7(this, "flushPendingDrag", () => {
|
|
26667
|
-
this.dragRafId = 0;
|
|
26668
|
-
if (this.pendingDragEvent) {
|
|
26669
|
-
this.lastDragTime = performance.now();
|
|
26670
|
-
const event = this.pendingDragEvent;
|
|
26671
|
-
this.pendingDragEvent = null;
|
|
26672
|
-
this.onMouseDrag(event);
|
|
26673
|
-
}
|
|
26674
|
-
});
|
|
26675
26468
|
_defineProperty7(this, "onMouseDragSelf", (event) => {
|
|
26676
26469
|
if (!this.eventAvailable) {
|
|
26677
26470
|
return;
|
|
26678
26471
|
}
|
|
26679
|
-
|
|
26680
|
-
if (now - this.lastDragTime >= DRAG_FRAME_MS) {
|
|
26681
|
-
this.lastDragTime = now;
|
|
26682
|
-
this.pendingDragEvent = null;
|
|
26683
|
-
this.onMouseDrag(event);
|
|
26684
|
-
} else {
|
|
26685
|
-
this.pendingDragEvent = event;
|
|
26686
|
-
if (!this.dragRafId) {
|
|
26687
|
-
this.dragRafId = requestAnimationFrame(this.flushPendingDrag);
|
|
26688
|
-
}
|
|
26689
|
-
}
|
|
26472
|
+
this.onMouseDrag(event);
|
|
26690
26473
|
});
|
|
26691
26474
|
_defineProperty7(this, "onMouseUpSelf", (event) => {
|
|
26692
26475
|
if (!this.eventAvailable) {
|
|
26693
26476
|
return;
|
|
26694
26477
|
}
|
|
26695
|
-
if (this.dragRafId) {
|
|
26696
|
-
cancelAnimationFrame(this.dragRafId);
|
|
26697
|
-
this.dragRafId = 0;
|
|
26698
|
-
}
|
|
26699
|
-
if (this.pendingDragEvent) {
|
|
26700
|
-
this.onMouseDrag(this.pendingDragEvent);
|
|
26701
|
-
this.pendingDragEvent = null;
|
|
26702
|
-
}
|
|
26703
26478
|
this.onMouseUp(event);
|
|
26704
26479
|
this.shadowEmitter.setActive(false);
|
|
26705
26480
|
});
|
|
@@ -26715,7 +26490,7 @@ var WhiteboardTool = class {
|
|
|
26715
26490
|
};
|
|
26716
26491
|
|
|
26717
26492
|
// src/tool/LineTool.ts
|
|
26718
|
-
var
|
|
26493
|
+
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
26719
26494
|
function _defineProperty8(e, r, t) {
|
|
26720
26495
|
return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26721
26496
|
}
|
|
@@ -26764,7 +26539,7 @@ var LineTool = class extends WhiteboardTool {
|
|
|
26764
26539
|
const point = path.getPointAt(distance);
|
|
26765
26540
|
return [point.x, point.y];
|
|
26766
26541
|
});
|
|
26767
|
-
this.elementModel.setPoints((0,
|
|
26542
|
+
this.elementModel.setPoints((0, import_lodash3.flattenDeep)(points));
|
|
26768
26543
|
}
|
|
26769
26544
|
}
|
|
26770
26545
|
onMouseUp(_event) {
|
|
@@ -26794,12 +26569,6 @@ function _toPrimitive9(t, r) {
|
|
|
26794
26569
|
return ("string" === r ? String : Number)(t);
|
|
26795
26570
|
}
|
|
26796
26571
|
var LineModel = class extends ElementModel {
|
|
26797
|
-
get drawPoints() {
|
|
26798
|
-
if (this.localPoints.length > 0) {
|
|
26799
|
-
return this.localPoints;
|
|
26800
|
-
}
|
|
26801
|
-
return this.points;
|
|
26802
|
-
}
|
|
26803
26572
|
get arrowSize() {
|
|
26804
26573
|
return this.strokeWidth * 5 + 15;
|
|
26805
26574
|
}
|
|
@@ -26815,23 +26584,20 @@ var LineModel = class extends ElementModel {
|
|
|
26815
26584
|
set tailArrow(value) {
|
|
26816
26585
|
this.root.set("tailArrow", value);
|
|
26817
26586
|
}
|
|
26818
|
-
constructor(root, scope, liveCursor
|
|
26819
|
-
super(root, scope, liveCursor
|
|
26587
|
+
constructor(root, scope, liveCursor) {
|
|
26588
|
+
super(root, scope, liveCursor);
|
|
26820
26589
|
_defineProperty9(this, "controlledPoints", []);
|
|
26821
|
-
_defineProperty9(this, "clearLocalPointsWhenYPointsChange", true);
|
|
26822
|
-
_defineProperty9(this, "shouldUseLocalPoints", true);
|
|
26823
|
-
_defineProperty9(this, "localPointsPick", 99);
|
|
26824
26590
|
_defineProperty9(this, "item", null);
|
|
26825
|
-
if (
|
|
26591
|
+
if (!this.root.has("type")) {
|
|
26826
26592
|
this.root.set("type", "arrow");
|
|
26827
26593
|
}
|
|
26828
|
-
if (
|
|
26594
|
+
if (!this.root.has("points")) {
|
|
26829
26595
|
this.root.set("points", new Y5.Array());
|
|
26830
26596
|
}
|
|
26831
|
-
if (
|
|
26597
|
+
if (!this.root.has("headArrow")) {
|
|
26832
26598
|
this.root.set("headArrow", "none");
|
|
26833
26599
|
}
|
|
26834
|
-
if (
|
|
26600
|
+
if (!this.root.has("tailArrow")) {
|
|
26835
26601
|
this.root.set("tailArrow", "normal");
|
|
26836
26602
|
}
|
|
26837
26603
|
}
|
|
@@ -26847,7 +26613,7 @@ var LineModel = class extends ElementModel {
|
|
|
26847
26613
|
}
|
|
26848
26614
|
renderLine() {
|
|
26849
26615
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26850
|
-
const papperPoints = (0,
|
|
26616
|
+
const papperPoints = (0, import_lodash4.chunk)(this.points, 2).map((item) => {
|
|
26851
26617
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
26852
26618
|
});
|
|
26853
26619
|
const path = new this.scope.Path();
|
|
@@ -26961,14 +26727,13 @@ var LineControlPoint = class {
|
|
|
26961
26727
|
if (this.position) {
|
|
26962
26728
|
return this.model.scope.project.view.projectToView(this.position.transform(matrix));
|
|
26963
26729
|
}
|
|
26964
|
-
const points = this.model["drawPoints"];
|
|
26965
26730
|
const from = {
|
|
26966
|
-
x: points[0],
|
|
26967
|
-
y: points[1]
|
|
26731
|
+
x: this.model.points[0],
|
|
26732
|
+
y: this.model.points[1]
|
|
26968
26733
|
};
|
|
26969
26734
|
const to = {
|
|
26970
|
-
x: points[points.length - 2],
|
|
26971
|
-
y: points[points.length - 1]
|
|
26735
|
+
x: this.model.points[this.model.points.length - 2],
|
|
26736
|
+
y: this.model.points[this.model.points.length - 1]
|
|
26972
26737
|
};
|
|
26973
26738
|
const clonedPath = new this.scope.Path.Line(from, to);
|
|
26974
26739
|
this.position = clonedPath.getPointAt(clonedPath.length * distance);
|
|
@@ -26981,9 +26746,9 @@ var LineControlPoint = class {
|
|
|
26981
26746
|
}
|
|
26982
26747
|
const pointsMatrix = new this.model.scope.Matrix(this.model.pointsMatrix);
|
|
26983
26748
|
const invertedPoint = point.transform(pointsMatrix.inverted());
|
|
26984
|
-
const points = this.model
|
|
26749
|
+
const points = this.model.points;
|
|
26985
26750
|
this.position = invertedPoint;
|
|
26986
|
-
const clonedPoints = (0,
|
|
26751
|
+
const clonedPoints = (0, import_lodash4.cloneDeep)(points);
|
|
26987
26752
|
clonedPoints[this.options.index * 2] = invertedPoint.x;
|
|
26988
26753
|
clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
|
|
26989
26754
|
this.model.setPoints(clonedPoints);
|
|
@@ -27029,18 +26794,9 @@ var PointTextModel = class extends ElementModel {
|
|
|
27029
26794
|
set fontFamily(value) {
|
|
27030
26795
|
this.root.set("font-family", value);
|
|
27031
26796
|
}
|
|
27032
|
-
|
|
27033
|
-
|
|
27034
|
-
return this.localPoints;
|
|
27035
|
-
}
|
|
27036
|
-
return this.points;
|
|
27037
|
-
}
|
|
27038
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27039
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26797
|
+
constructor(root, scope, liveCursor) {
|
|
26798
|
+
super(root, scope, liveCursor);
|
|
27040
26799
|
_defineProperty10(this, "item", null);
|
|
27041
|
-
_defineProperty10(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27042
|
-
_defineProperty10(this, "shouldUseLocalPoints", false);
|
|
27043
|
-
_defineProperty10(this, "localPointsPick", 2);
|
|
27044
26800
|
_defineProperty10(this, "handleTextPropChange", (event) => {
|
|
27045
26801
|
if (!this.item) {
|
|
27046
26802
|
return;
|
|
@@ -27057,28 +26813,22 @@ var PointTextModel = class extends ElementModel {
|
|
|
27057
26813
|
}
|
|
27058
26814
|
}
|
|
27059
26815
|
});
|
|
27060
|
-
if (
|
|
26816
|
+
if (!this.root.has("type")) {
|
|
27061
26817
|
this.root.set("type", "point-text");
|
|
27062
26818
|
}
|
|
27063
|
-
if (
|
|
26819
|
+
if (!this.root.has(ElementModel.KEYS.points)) {
|
|
27064
26820
|
this.root.set(ElementModel.KEYS.points, new Y6.Array());
|
|
27065
26821
|
}
|
|
27066
26822
|
this.root.observe(this.handleTextPropChange);
|
|
27067
|
-
|
|
27068
|
-
|
|
27069
|
-
|
|
27070
|
-
|
|
27071
|
-
|
|
27072
|
-
}
|
|
27073
|
-
}, 60);
|
|
26823
|
+
if (this.root.has("font-size")) {
|
|
26824
|
+
setTimeout(() => {
|
|
26825
|
+
this.updateTextPosition();
|
|
26826
|
+
}, 60);
|
|
26827
|
+
}
|
|
27074
26828
|
}
|
|
27075
26829
|
subDispose() {
|
|
27076
26830
|
removeObserver(this.root, this.handleTextPropChange);
|
|
27077
26831
|
}
|
|
27078
|
-
subBindObserver() {
|
|
27079
|
-
removeObserver(this.root, this.handleTextPropChange);
|
|
27080
|
-
this.root.observe(this.handleTextPropChange);
|
|
27081
|
-
}
|
|
27082
26832
|
liveCursorPoint() {
|
|
27083
26833
|
const points = this.points;
|
|
27084
26834
|
if (points.length < 1) {
|
|
@@ -27092,11 +26842,10 @@ var PointTextModel = class extends ElementModel {
|
|
|
27092
26842
|
if (!this.item) {
|
|
27093
26843
|
return null;
|
|
27094
26844
|
}
|
|
27095
|
-
console.log("[][][] drawPoints", this.drawPoints);
|
|
27096
26845
|
const bounds = this.item.internalBounds;
|
|
27097
26846
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27098
|
-
const topLeft = new this.scope.Point(this.
|
|
27099
|
-
const topRight = new this.scope.Point(this.
|
|
26847
|
+
const topLeft = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
|
|
26848
|
+
const topRight = new this.scope.Point(this.points[0] + bounds.width, this.points[1]).transform(matrix);
|
|
27100
26849
|
let scaleX = topRight.getDistance(topLeft) / bounds.width;
|
|
27101
26850
|
scaleX = Number.isNaN(scaleX) ? 1 : scaleX;
|
|
27102
26851
|
const angle = topRight.subtract(topLeft).angle;
|
|
@@ -27184,22 +26933,13 @@ function _toPrimitive11(t, r) {
|
|
|
27184
26933
|
return ("string" === r ? String : Number)(t);
|
|
27185
26934
|
}
|
|
27186
26935
|
var TriangleModel = class extends ElementModel {
|
|
27187
|
-
|
|
27188
|
-
|
|
27189
|
-
return this.localPoints;
|
|
27190
|
-
}
|
|
27191
|
-
return this.points;
|
|
27192
|
-
}
|
|
27193
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27194
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26936
|
+
constructor(root, scope, liveCursor) {
|
|
26937
|
+
super(root, scope, liveCursor);
|
|
27195
26938
|
_defineProperty11(this, "item", null);
|
|
27196
|
-
|
|
27197
|
-
_defineProperty11(this, "shouldUseLocalPoints", true);
|
|
27198
|
-
_defineProperty11(this, "localPointsPick", 6);
|
|
27199
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26939
|
+
if (!this.root.has("type")) {
|
|
27200
26940
|
this.root.set("type", "triangle");
|
|
27201
26941
|
}
|
|
27202
|
-
if (
|
|
26942
|
+
if (!this.root.has("points")) {
|
|
27203
26943
|
this.root.set("points", new Y7.Array());
|
|
27204
26944
|
}
|
|
27205
26945
|
}
|
|
@@ -27231,9 +26971,9 @@ var TriangleModel = class extends ElementModel {
|
|
|
27231
26971
|
return;
|
|
27232
26972
|
}
|
|
27233
26973
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27234
|
-
const p1 = new this.scope.Point(this.
|
|
27235
|
-
const p2 = new this.scope.Point(this.
|
|
27236
|
-
const p3 = new this.scope.Point(this.
|
|
26974
|
+
const p1 = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
|
|
26975
|
+
const p2 = new this.scope.Point(this.points[2], this.points[3]).transform(matrix);
|
|
26976
|
+
const p3 = new this.scope.Point(this.points[4], this.points[5]).transform(matrix);
|
|
27237
26977
|
this.item.removeSegments();
|
|
27238
26978
|
this.item.moveTo(p1);
|
|
27239
26979
|
this.item.lineTo(p2);
|
|
@@ -27245,7 +26985,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
27245
26985
|
config.controlPoints.push({
|
|
27246
26986
|
name: "triangle",
|
|
27247
26987
|
getPosition: () => {
|
|
27248
|
-
const point = new this.scope.Point(this.
|
|
26988
|
+
const point = new this.scope.Point(this.points[0], this.points[1]);
|
|
27249
26989
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27250
26990
|
return this.scope.project.view.projectToView(point.transform(pointsMatrix));
|
|
27251
26991
|
},
|
|
@@ -27255,7 +26995,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
27255
26995
|
}
|
|
27256
26996
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27257
26997
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27258
|
-
const oldPoints = this.
|
|
26998
|
+
const oldPoints = this.points;
|
|
27259
26999
|
this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3], oldPoints[4], oldPoints[5]]);
|
|
27260
27000
|
}
|
|
27261
27001
|
});
|
|
@@ -27294,34 +27034,25 @@ function _toPrimitive12(t, r) {
|
|
|
27294
27034
|
return ("string" === r ? String : Number)(t);
|
|
27295
27035
|
}
|
|
27296
27036
|
var RectangleModel = class extends ElementModel {
|
|
27297
|
-
|
|
27298
|
-
|
|
27299
|
-
return this.localPoints;
|
|
27300
|
-
}
|
|
27301
|
-
return this.points;
|
|
27302
|
-
}
|
|
27303
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27304
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27037
|
+
constructor(root, scope, liveCursor) {
|
|
27038
|
+
super(root, scope, liveCursor);
|
|
27305
27039
|
_defineProperty12(this, "item", null);
|
|
27306
|
-
|
|
27307
|
-
_defineProperty12(this, "shouldUseLocalPoints", true);
|
|
27308
|
-
_defineProperty12(this, "localPointsPick", 4);
|
|
27309
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27040
|
+
if (!this.root.has("type")) {
|
|
27310
27041
|
this.root.set("type", "rectangle");
|
|
27311
27042
|
}
|
|
27312
|
-
if (
|
|
27043
|
+
if (!this.root.has("points")) {
|
|
27313
27044
|
const initPoints = new Y8.Array();
|
|
27314
27045
|
initPoints.push([0, 0, 0, 0]);
|
|
27315
27046
|
this.root.set("points", initPoints);
|
|
27316
27047
|
}
|
|
27317
|
-
if (
|
|
27048
|
+
if (!this.root.has("radius")) {
|
|
27318
27049
|
this.root.set("radius", 0);
|
|
27319
27050
|
}
|
|
27320
27051
|
}
|
|
27321
27052
|
subDispose() {
|
|
27322
27053
|
}
|
|
27323
27054
|
liveCursorPoint() {
|
|
27324
|
-
const points = this.
|
|
27055
|
+
const points = this.points;
|
|
27325
27056
|
if (points.length < 4) {
|
|
27326
27057
|
return null;
|
|
27327
27058
|
}
|
|
@@ -27329,7 +27060,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27329
27060
|
return new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
27330
27061
|
}
|
|
27331
27062
|
createSegments() {
|
|
27332
|
-
const [a2, b2, c, d] = this.
|
|
27063
|
+
const [a2, b2, c, d] = this.points;
|
|
27333
27064
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27334
27065
|
const maxRadius = this.maxRadiusLength();
|
|
27335
27066
|
const radius = this.root.get("radius") * maxRadius;
|
|
@@ -27394,7 +27125,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27394
27125
|
}
|
|
27395
27126
|
maxRadiusLength() {
|
|
27396
27127
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27397
|
-
const points = this.
|
|
27128
|
+
const points = this.points;
|
|
27398
27129
|
const topLeft = new this.scope.Point(points[0], points[1]).transform(pointsMatrix);
|
|
27399
27130
|
const topRight = new this.scope.Point(points[2], points[1]).transform(pointsMatrix);
|
|
27400
27131
|
const bottomLeft = new this.scope.Point(points[0], points[3]).transform(pointsMatrix);
|
|
@@ -27419,7 +27150,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27419
27150
|
name: "rect-radius",
|
|
27420
27151
|
getPosition: () => {
|
|
27421
27152
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27422
|
-
const points = this.
|
|
27153
|
+
const points = this.points;
|
|
27423
27154
|
const radius = this.root.get("radius") * this.maxRadiusLength();
|
|
27424
27155
|
let c1 = new this.scope.Point(points[0], points[1]).transform(matrix);
|
|
27425
27156
|
const c3 = new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
@@ -27438,7 +27169,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27438
27169
|
if (!this.item) {
|
|
27439
27170
|
return;
|
|
27440
27171
|
}
|
|
27441
|
-
const points = this.
|
|
27172
|
+
const points = this.points;
|
|
27442
27173
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27443
27174
|
const maxRadius = Math.min(points[2] - points[0], points[3] - points[1]) / 2;
|
|
27444
27175
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
@@ -27467,7 +27198,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27467
27198
|
var elementsUndoOrigin = "elementsUndoOrigin";
|
|
27468
27199
|
|
|
27469
27200
|
// src/model/renderable/EraserModel.ts
|
|
27470
|
-
var
|
|
27201
|
+
var import_lodash5 = __toESM(require_lodash(), 1);
|
|
27471
27202
|
import * as Y9 from "yjs";
|
|
27472
27203
|
function _defineProperty13(e, r, t) {
|
|
27473
27204
|
return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -27487,23 +27218,14 @@ function _toPrimitive13(t, r) {
|
|
|
27487
27218
|
return ("string" === r ? String : Number)(t);
|
|
27488
27219
|
}
|
|
27489
27220
|
var EraserModel = class extends ElementModel {
|
|
27490
|
-
|
|
27491
|
-
|
|
27492
|
-
return this.localPoints;
|
|
27493
|
-
}
|
|
27494
|
-
return this.points;
|
|
27495
|
-
}
|
|
27496
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27497
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27221
|
+
constructor(root, scope, liveCursor) {
|
|
27222
|
+
super(root, scope, liveCursor);
|
|
27498
27223
|
_defineProperty13(this, "item", null);
|
|
27499
27224
|
_defineProperty13(this, "sliceBegin", 0);
|
|
27500
|
-
|
|
27501
|
-
_defineProperty13(this, "shouldUseLocalPoints", true);
|
|
27502
|
-
_defineProperty13(this, "localPointsPick", 4);
|
|
27503
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27225
|
+
if (!this.root.has("type")) {
|
|
27504
27226
|
this.root.set("type", "eraser");
|
|
27505
27227
|
}
|
|
27506
|
-
if (
|
|
27228
|
+
if (!this.root.has("points")) {
|
|
27507
27229
|
this.root.set("points", new Y9.Array());
|
|
27508
27230
|
}
|
|
27509
27231
|
}
|
|
@@ -27536,7 +27258,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27536
27258
|
return path;
|
|
27537
27259
|
}
|
|
27538
27260
|
parsePoints(points) {
|
|
27539
|
-
const groupPoints = (0,
|
|
27261
|
+
const groupPoints = (0, import_lodash5.chunk)(points, 2);
|
|
27540
27262
|
return ae(groupPoints, {
|
|
27541
27263
|
size: this.strokeWidth,
|
|
27542
27264
|
smoothing: 0.5,
|
|
@@ -27554,7 +27276,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27554
27276
|
});
|
|
27555
27277
|
}
|
|
27556
27278
|
matrixedPoints() {
|
|
27557
|
-
const currentPoints = (0,
|
|
27279
|
+
const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
|
|
27558
27280
|
return currentPoints.map((_ref) => {
|
|
27559
27281
|
let [x, y] = _ref;
|
|
27560
27282
|
return new this.scope.Point(x, y);
|
|
@@ -27582,11 +27304,11 @@ var EraserModel = class extends ElementModel {
|
|
|
27582
27304
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
27583
27305
|
this.onVectorUpdate();
|
|
27584
27306
|
this.item.onFrame = () => {
|
|
27585
|
-
if (!this.
|
|
27307
|
+
if (!this.points) {
|
|
27586
27308
|
return;
|
|
27587
27309
|
}
|
|
27588
|
-
if (this.
|
|
27589
|
-
this.sliceBegin = this.
|
|
27310
|
+
if (this.points.length / 2 > 50) {
|
|
27311
|
+
this.sliceBegin = this.points.length / 2 - 50;
|
|
27590
27312
|
}
|
|
27591
27313
|
};
|
|
27592
27314
|
}
|
|
@@ -27619,9 +27341,8 @@ var EraserModel = class extends ElementModel {
|
|
|
27619
27341
|
};
|
|
27620
27342
|
|
|
27621
27343
|
// src/model/renderable/LaserPointerModel.ts
|
|
27622
|
-
var
|
|
27344
|
+
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
27623
27345
|
import * as Y10 from "yjs";
|
|
27624
|
-
import { removeObserver as removeObserver2 } from "@netless/forge-room";
|
|
27625
27346
|
function _defineProperty14(e, r, t) {
|
|
27626
27347
|
return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27627
27348
|
}
|
|
@@ -27640,18 +27361,24 @@ function _toPrimitive14(t, r) {
|
|
|
27640
27361
|
return ("string" === r ? String : Number)(t);
|
|
27641
27362
|
}
|
|
27642
27363
|
var LaserPointerModel = class extends ElementModel {
|
|
27643
|
-
constructor(clientId, root, scope, liveCursor, removeElement
|
|
27644
|
-
super(root, scope, liveCursor
|
|
27364
|
+
constructor(clientId, root, scope, liveCursor, removeElement) {
|
|
27365
|
+
super(root, scope, liveCursor);
|
|
27645
27366
|
_defineProperty14(this, "item", null);
|
|
27646
27367
|
_defineProperty14(this, "clientId", void 0);
|
|
27647
27368
|
_defineProperty14(this, "sliceBegin", 0);
|
|
27648
27369
|
_defineProperty14(this, "displayStrokeWidth", 8);
|
|
27649
27370
|
_defineProperty14(this, "cachedPoints", null);
|
|
27650
|
-
|
|
27651
|
-
|
|
27652
|
-
|
|
27653
|
-
|
|
27654
|
-
|
|
27371
|
+
this.clientId = clientId;
|
|
27372
|
+
if (!this.root.has("type")) {
|
|
27373
|
+
this.root.set("type", "laser");
|
|
27374
|
+
}
|
|
27375
|
+
if (!this.root.has("points")) {
|
|
27376
|
+
this.root.set("points", new Y10.Array());
|
|
27377
|
+
}
|
|
27378
|
+
if (!this.root.has("removed")) {
|
|
27379
|
+
this.root.set("removed", false);
|
|
27380
|
+
}
|
|
27381
|
+
this.root.observe((event) => {
|
|
27655
27382
|
if (!this.item) {
|
|
27656
27383
|
return;
|
|
27657
27384
|
}
|
|
@@ -27669,31 +27396,13 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27669
27396
|
this.onVectorUpdate();
|
|
27670
27397
|
if (evt.count >= 30) {
|
|
27671
27398
|
if (this.ownerId === this.clientId) {
|
|
27672
|
-
|
|
27399
|
+
removeElement(this.uuid);
|
|
27673
27400
|
}
|
|
27674
27401
|
}
|
|
27675
27402
|
};
|
|
27676
27403
|
}
|
|
27677
27404
|
}
|
|
27678
27405
|
});
|
|
27679
|
-
this.clientId = clientId;
|
|
27680
|
-
this.removeElement = removeElement;
|
|
27681
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27682
|
-
this.root.set("type", "laser");
|
|
27683
|
-
}
|
|
27684
|
-
if (this.root.doc && !this.root.has("points")) {
|
|
27685
|
-
this.root.set("points", new Y10.Array());
|
|
27686
|
-
}
|
|
27687
|
-
if (this.root.doc && !this.root.has("removed")) {
|
|
27688
|
-
this.root.set("removed", false);
|
|
27689
|
-
}
|
|
27690
|
-
}
|
|
27691
|
-
subBindObserver() {
|
|
27692
|
-
removeObserver2(this.root, this.handleLaserPropChange);
|
|
27693
|
-
this.root.observe(this.handleLaserPropChange);
|
|
27694
|
-
}
|
|
27695
|
-
subDispose() {
|
|
27696
|
-
removeObserver2(this.root, this.handleLaserPropChange);
|
|
27697
27406
|
}
|
|
27698
27407
|
beginRemoveAnimate() {
|
|
27699
27408
|
this.root.set("removed", true);
|
|
@@ -27746,8 +27455,7 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27746
27455
|
matrixedPoints() {
|
|
27747
27456
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27748
27457
|
const points = this.cachedPoints || this.points;
|
|
27749
|
-
|
|
27750
|
-
const groupPoints = (0, import_lodash5.chunk)(points, 2).slice(this.sliceBegin);
|
|
27458
|
+
const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
|
|
27751
27459
|
return groupPoints.map((_ref) => {
|
|
27752
27460
|
let [x, y] = _ref;
|
|
27753
27461
|
return matrix.transform([x, y]);
|
|
@@ -27789,6 +27497,8 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27789
27497
|
onStyleKeyUpdate(_key) {
|
|
27790
27498
|
return;
|
|
27791
27499
|
}
|
|
27500
|
+
subDispose() {
|
|
27501
|
+
}
|
|
27792
27502
|
liveCursorPoint() {
|
|
27793
27503
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
27794
27504
|
if (yArray.length < 2) {
|
|
@@ -27826,7 +27536,7 @@ var WhiteboardPermissions = class extends AbstractApplicationPermissions {
|
|
|
27826
27536
|
};
|
|
27827
27537
|
|
|
27828
27538
|
// src/model/renderable/StraightLineModel.ts
|
|
27829
|
-
var
|
|
27539
|
+
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
27830
27540
|
import * as Y11 from "yjs";
|
|
27831
27541
|
function _defineProperty15(e, r, t) {
|
|
27832
27542
|
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
@@ -27846,22 +27556,13 @@ function _toPrimitive15(t, r) {
|
|
|
27846
27556
|
return ("string" === r ? String : Number)(t);
|
|
27847
27557
|
}
|
|
27848
27558
|
var StraightLineModel = class extends ElementModel {
|
|
27849
|
-
|
|
27850
|
-
|
|
27851
|
-
return this.localPoints;
|
|
27852
|
-
}
|
|
27853
|
-
return this.points;
|
|
27854
|
-
}
|
|
27855
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27856
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27559
|
+
constructor(root, scope, liveCursor) {
|
|
27560
|
+
super(root, scope, liveCursor);
|
|
27857
27561
|
_defineProperty15(this, "item", null);
|
|
27858
|
-
|
|
27859
|
-
_defineProperty15(this, "shouldUseLocalPoints", true);
|
|
27860
|
-
_defineProperty15(this, "localPointsPick", 4);
|
|
27861
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27562
|
+
if (!this.root.has("type")) {
|
|
27862
27563
|
this.root.set("type", "line");
|
|
27863
27564
|
}
|
|
27864
|
-
if (
|
|
27565
|
+
if (!this.root.has("points")) {
|
|
27865
27566
|
this.root.set("points", new Y11.Array());
|
|
27866
27567
|
}
|
|
27867
27568
|
}
|
|
@@ -27886,7 +27587,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27886
27587
|
}
|
|
27887
27588
|
renderLine() {
|
|
27888
27589
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27889
|
-
const papperPoints = (0,
|
|
27590
|
+
const papperPoints = (0, import_lodash7.chunk)(this.points, 2).map((item) => {
|
|
27890
27591
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
27891
27592
|
});
|
|
27892
27593
|
const path = new this.scope.Path();
|
|
@@ -27908,7 +27609,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27908
27609
|
name: "line-start",
|
|
27909
27610
|
getPosition: () => {
|
|
27910
27611
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27911
|
-
const points = this.
|
|
27612
|
+
const points = this.points;
|
|
27912
27613
|
const start = new this.scope.Point(points[0], points[1]);
|
|
27913
27614
|
return this.scope.project.view.projectToView(start.transform(matrix));
|
|
27914
27615
|
},
|
|
@@ -27918,15 +27619,14 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27918
27619
|
}
|
|
27919
27620
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27920
27621
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27921
|
-
|
|
27922
|
-
this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3]]);
|
|
27622
|
+
this.setPoints([trPoint.x, trPoint.y, this.points[2], this.points[3]]);
|
|
27923
27623
|
}
|
|
27924
27624
|
});
|
|
27925
27625
|
cfg.controlPoints.push({
|
|
27926
27626
|
name: "line-end",
|
|
27927
27627
|
getPosition: () => {
|
|
27928
27628
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27929
|
-
const points = this.
|
|
27629
|
+
const points = this.points;
|
|
27930
27630
|
const end = new this.scope.Point(points[2], points[3]);
|
|
27931
27631
|
return this.scope.project.view.projectToView(end.transform(matrix));
|
|
27932
27632
|
},
|
|
@@ -27936,8 +27636,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27936
27636
|
}
|
|
27937
27637
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27938
27638
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27939
|
-
|
|
27940
|
-
this.setPoints([oldPoints[0], oldPoints[1], trPoint.x, trPoint.y]);
|
|
27639
|
+
this.setPoints([this.points[0], this.points[1], trPoint.x, trPoint.y]);
|
|
27941
27640
|
}
|
|
27942
27641
|
});
|
|
27943
27642
|
return cfg;
|
|
@@ -27983,13 +27682,10 @@ var ImageModel = class extends ElementModel {
|
|
|
27983
27682
|
get src() {
|
|
27984
27683
|
return this.root.get("src");
|
|
27985
27684
|
}
|
|
27986
|
-
constructor(root, scope, imageSets, liveCursor
|
|
27987
|
-
super(root, scope, liveCursor
|
|
27685
|
+
constructor(root, scope, imageSets, liveCursor) {
|
|
27686
|
+
super(root, scope, liveCursor);
|
|
27988
27687
|
_defineProperty16(this, "item", null);
|
|
27989
27688
|
_defineProperty16(this, "imageSets", void 0);
|
|
27990
|
-
_defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27991
|
-
_defineProperty16(this, "shouldUseLocalPoints", true);
|
|
27992
|
-
_defineProperty16(this, "localPointsPick", 4);
|
|
27993
27689
|
this.imageSets = imageSets;
|
|
27994
27690
|
if (!this.root.has("type")) {
|
|
27995
27691
|
this.root.set("type", "image");
|
|
@@ -28072,7 +27768,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28072
27768
|
get uuid() {
|
|
28073
27769
|
return uuidv4().replace(/-/g, "");
|
|
28074
27770
|
}
|
|
28075
|
-
constructor(
|
|
27771
|
+
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
|
|
28076
27772
|
super();
|
|
28077
27773
|
_defineProperty17(this, "scope", void 0);
|
|
28078
27774
|
_defineProperty17(this, "toolbarModel", void 0);
|
|
@@ -28085,7 +27781,6 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28085
27781
|
_defineProperty17(this, "shadowEmitter", void 0);
|
|
28086
27782
|
_defineProperty17(this, "imageSets", void 0);
|
|
28087
27783
|
_defineProperty17(this, "liveCursor", void 0);
|
|
28088
|
-
_defineProperty17(this, "isPerformanceMode", void 0);
|
|
28089
27784
|
_defineProperty17(this, "onElementsChange", (event) => {
|
|
28090
27785
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
28091
27786
|
if (value.action === "add") {
|
|
@@ -28104,16 +27799,15 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28104
27799
|
}
|
|
28105
27800
|
}
|
|
28106
27801
|
});
|
|
28107
|
-
this.
|
|
28108
|
-
this.
|
|
28109
|
-
this.
|
|
28110
|
-
this.
|
|
28111
|
-
this.
|
|
28112
|
-
this.
|
|
28113
|
-
this.
|
|
28114
|
-
this.
|
|
28115
|
-
this.
|
|
28116
|
-
this.toolbarModel = options.toolbarModel;
|
|
27802
|
+
this.liveCursor = liveCursor;
|
|
27803
|
+
this.imageSets = imageSets;
|
|
27804
|
+
this.hasPermission = hasPermission;
|
|
27805
|
+
this.shadowEmitter = shadowEmitter;
|
|
27806
|
+
this.layerId = layerId;
|
|
27807
|
+
this.userManager = userManager;
|
|
27808
|
+
this.elements = elements;
|
|
27809
|
+
this.scope = scope;
|
|
27810
|
+
this.toolbarModel = toolbarModel;
|
|
28117
27811
|
this.elementModels = /* @__PURE__ */ new Map();
|
|
28118
27812
|
for (const key of this.elements.keys()) {
|
|
28119
27813
|
const type = this.elements.get(key)?.get("type");
|
|
@@ -28144,43 +27838,33 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28144
27838
|
convertToModel(yMap) {
|
|
28145
27839
|
const type = yMap.get("type");
|
|
28146
27840
|
let model = null;
|
|
28147
|
-
const uuid = yMap.get(ElementModel.KEYS.uuid);
|
|
28148
|
-
if (uuid) {
|
|
28149
|
-
const existingModel = this.elementModels.get(uuid);
|
|
28150
|
-
if (existingModel) {
|
|
28151
|
-
existingModel.shadowEmitter = this.shadowEmitter;
|
|
28152
|
-
existingModel.bindObserver();
|
|
28153
|
-
return existingModel;
|
|
28154
|
-
}
|
|
28155
|
-
}
|
|
28156
27841
|
if (type === "curve") {
|
|
28157
|
-
model = new CurveModel(yMap, this.scope, this.liveCursor
|
|
27842
|
+
model = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
28158
27843
|
} else if (["ellipse"].indexOf(type) >= 0) {
|
|
28159
|
-
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor
|
|
27844
|
+
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
28160
27845
|
} else if (type === "selector") {
|
|
28161
|
-
model = new SelectorModel(yMap, this.scope, this.liveCursor
|
|
27846
|
+
model = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
28162
27847
|
} else if (type === "arrow") {
|
|
28163
|
-
model = new LineModel(yMap, this.scope, this.liveCursor
|
|
27848
|
+
model = new LineModel(yMap, this.scope, this.liveCursor);
|
|
28164
27849
|
} else if (type === "line") {
|
|
28165
|
-
model = new StraightLineModel(yMap, this.scope, this.liveCursor
|
|
27850
|
+
model = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
28166
27851
|
} else if (type === "point-text") {
|
|
28167
|
-
model = new PointTextModel(yMap, this.scope, this.liveCursor
|
|
27852
|
+
model = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
28168
27853
|
} else if (type === "triangle") {
|
|
28169
|
-
model = new TriangleModel(yMap, this.scope, this.liveCursor
|
|
27854
|
+
model = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
28170
27855
|
} else if (type === "rectangle") {
|
|
28171
|
-
model = new RectangleModel(yMap, this.scope, this.liveCursor
|
|
27856
|
+
model = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
28172
27857
|
} else if (type === "eraser") {
|
|
28173
|
-
model = new EraserModel(yMap, this.scope, this.liveCursor
|
|
27858
|
+
model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
28174
27859
|
} else if (type === "laser") {
|
|
28175
|
-
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (
|
|
28176
|
-
this.removeElementItem(
|
|
28177
|
-
}
|
|
27860
|
+
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
27861
|
+
this.removeElementItem(uuid);
|
|
27862
|
+
});
|
|
28178
27863
|
} else if (type === "image") {
|
|
28179
|
-
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor
|
|
27864
|
+
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
28180
27865
|
}
|
|
28181
27866
|
if (model) {
|
|
28182
27867
|
model.shadowEmitter = this.shadowEmitter;
|
|
28183
|
-
model.bindObserver();
|
|
28184
27868
|
this.elementModels.set(model.uuid, model);
|
|
28185
27869
|
}
|
|
28186
27870
|
return model;
|
|
@@ -28211,8 +27895,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28211
27895
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28212
27896
|
this.elements.set(uuid, yMap);
|
|
28213
27897
|
}, elementsUndoOrigin);
|
|
28214
|
-
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor
|
|
28215
|
-
model.bindObserver();
|
|
27898
|
+
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
28216
27899
|
model.root.set("src", src);
|
|
28217
27900
|
const initMatrix = new this.scope.Matrix();
|
|
28218
27901
|
const center = this.scope.project.view.center;
|
|
@@ -28229,10 +27912,8 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28229
27912
|
return null;
|
|
28230
27913
|
}
|
|
28231
27914
|
const yMap = new Y12.Map();
|
|
28232
|
-
const uuid = this.uuid;
|
|
28233
|
-
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28234
|
-
this.elementModels.set(uuid, curveModel);
|
|
28235
27915
|
this.elements.doc?.transact(() => {
|
|
27916
|
+
const uuid = this.uuid;
|
|
28236
27917
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28237
27918
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28238
27919
|
yMap.set("type", "curve");
|
|
@@ -28245,7 +27926,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28245
27926
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28246
27927
|
this.elements.set(uuid, yMap);
|
|
28247
27928
|
}, elementsUndoOrigin);
|
|
28248
|
-
curveModel.
|
|
27929
|
+
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
28249
27930
|
this.initElement(curveModel);
|
|
28250
27931
|
return curveModel;
|
|
28251
27932
|
}
|
|
@@ -28254,17 +27935,11 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28254
27935
|
return null;
|
|
28255
27936
|
}
|
|
28256
27937
|
const yMap = new Y12.Map();
|
|
28257
|
-
const uuid = this.uuid;
|
|
28258
|
-
const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
|
|
28259
|
-
this.removeElementItem(uuid2);
|
|
28260
|
-
}, this.isPerformanceMode);
|
|
28261
|
-
this.elementModels.set(uuid, model);
|
|
28262
27938
|
this.elements.doc?.transact(() => {
|
|
27939
|
+
const uuid = this.uuid;
|
|
28263
27940
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28264
27941
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28265
27942
|
yMap.set("type", "laser");
|
|
28266
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28267
|
-
yMap.set("removed", false);
|
|
28268
27943
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28269
27944
|
yMap.set(ElementModel.KEYS.strokeWidth, 8);
|
|
28270
27945
|
yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
|
|
@@ -28272,8 +27947,9 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28272
27947
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28273
27948
|
this.elements.set(uuid, yMap);
|
|
28274
27949
|
}, elementsUndoOrigin);
|
|
28275
|
-
model.
|
|
28276
|
-
|
|
27950
|
+
const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
27951
|
+
this.removeElementItem(uuid);
|
|
27952
|
+
});
|
|
28277
27953
|
return model;
|
|
28278
27954
|
}
|
|
28279
27955
|
createEraser() {
|
|
@@ -28281,14 +27957,11 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28281
27957
|
return null;
|
|
28282
27958
|
}
|
|
28283
27959
|
const yMap = new Y12.Map();
|
|
28284
|
-
const uuid = this.uuid;
|
|
28285
|
-
const model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28286
|
-
this.elementModels.set(uuid, model);
|
|
28287
27960
|
this.elements.doc?.transact(() => {
|
|
27961
|
+
const uuid = this.uuid;
|
|
28288
27962
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28289
27963
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28290
27964
|
yMap.set("type", "eraser");
|
|
28291
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28292
27965
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28293
27966
|
yMap.set(ElementModel.KEYS.strokeWidth, 4);
|
|
28294
27967
|
yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
|
|
@@ -28296,7 +27969,7 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28296
27969
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28297
27970
|
this.elements.set(uuid, yMap);
|
|
28298
27971
|
}, elementsUndoOrigin);
|
|
28299
|
-
model.
|
|
27972
|
+
const model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
28300
27973
|
return model;
|
|
28301
27974
|
}
|
|
28302
27975
|
createTriangle(shadow) {
|
|
@@ -28304,54 +27977,45 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28304
27977
|
return null;
|
|
28305
27978
|
}
|
|
28306
27979
|
const yMap = new Y12.Map();
|
|
28307
|
-
const uuid = this.uuid;
|
|
28308
|
-
const triangleModel = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28309
|
-
this.elementModels.set(uuid, triangleModel);
|
|
28310
27980
|
this.elements.doc?.transact(() => {
|
|
27981
|
+
const uuid = this.uuid;
|
|
28311
27982
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28312
27983
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28313
27984
|
yMap.set("type", "triangle");
|
|
28314
27985
|
if (shadow) {
|
|
28315
27986
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28316
27987
|
}
|
|
28317
|
-
yMap.set("points", new Y12.Array());
|
|
28318
27988
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28319
27989
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28320
27990
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28321
27991
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28322
27992
|
this.elements.set(uuid, yMap);
|
|
28323
27993
|
}, elementsUndoOrigin);
|
|
28324
|
-
|
|
28325
|
-
this.initElement(
|
|
28326
|
-
|
|
28327
|
-
return
|
|
27994
|
+
const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
27995
|
+
this.initElement(triangle);
|
|
27996
|
+
triangle.dashArray = this.toolbarModel.dashArray;
|
|
27997
|
+
return triangle;
|
|
28328
27998
|
}
|
|
28329
27999
|
createRectangle(shadow) {
|
|
28330
28000
|
if (!this.confirmPermission()) {
|
|
28331
28001
|
return null;
|
|
28332
28002
|
}
|
|
28333
28003
|
const yMap = new Y12.Map();
|
|
28334
|
-
const uuid = this.uuid;
|
|
28335
|
-
const rect = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28336
|
-
this.elementModels.set(uuid, rect);
|
|
28337
28004
|
this.elements.doc?.transact(() => {
|
|
28005
|
+
const uuid = this.uuid;
|
|
28338
28006
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28339
28007
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28340
28008
|
yMap.set("type", "rectangle");
|
|
28341
28009
|
if (shadow) {
|
|
28342
28010
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28343
28011
|
}
|
|
28344
|
-
const initPoints = new Y12.Array();
|
|
28345
|
-
initPoints.push([0, 0, 0, 0]);
|
|
28346
|
-
yMap.set("points", initPoints);
|
|
28347
|
-
yMap.set("radius", 0);
|
|
28348
28012
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28349
28013
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28350
28014
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28351
28015
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28352
28016
|
this.elements.set(uuid, yMap);
|
|
28353
28017
|
}, elementsUndoOrigin);
|
|
28354
|
-
rect.
|
|
28018
|
+
const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
28355
28019
|
this.initElement(rect);
|
|
28356
28020
|
rect.dashArray = this.toolbarModel.dashArray;
|
|
28357
28021
|
return rect;
|
|
@@ -28361,24 +28025,21 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28361
28025
|
return null;
|
|
28362
28026
|
}
|
|
28363
28027
|
const yMap = new Y12.Map();
|
|
28364
|
-
const uuid = this.uuid;
|
|
28365
|
-
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
|
|
28366
|
-
this.elementModels.set(uuid, segmentsModel);
|
|
28367
28028
|
this.elements.doc?.transact(() => {
|
|
28029
|
+
const uuid = this.uuid;
|
|
28368
28030
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28369
28031
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28370
28032
|
yMap.set("type", type);
|
|
28371
28033
|
if (shadow) {
|
|
28372
28034
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28373
28035
|
}
|
|
28374
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28375
28036
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28376
28037
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28377
28038
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28378
28039
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28379
28040
|
this.elements.set(uuid, yMap);
|
|
28380
28041
|
}, elementsUndoOrigin);
|
|
28381
|
-
segmentsModel.
|
|
28042
|
+
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
28382
28043
|
this.initElement(segmentsModel);
|
|
28383
28044
|
segmentsModel.dashArray = this.toolbarModel.dashArray;
|
|
28384
28045
|
return segmentsModel;
|
|
@@ -28389,21 +28050,16 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28389
28050
|
return null;
|
|
28390
28051
|
}
|
|
28391
28052
|
const yMap = new Y12.Map();
|
|
28392
|
-
const uuid = this.uuid;
|
|
28393
|
-
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28394
|
-
this.elementModels.set(uuid, selectorModel);
|
|
28395
28053
|
this.elements.doc?.transact(() => {
|
|
28054
|
+
const uuid = this.uuid;
|
|
28396
28055
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28397
28056
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28398
28057
|
yMap.set("type", "selector");
|
|
28399
|
-
const initPoints = new Y12.Array();
|
|
28400
|
-
initPoints.push([0, 0, 0, 0]);
|
|
28401
|
-
yMap.set(ElementModel.KEYS.points, initPoints);
|
|
28402
28058
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28403
28059
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28404
28060
|
this.elements.set(uuid, yMap);
|
|
28405
28061
|
}, elementsUndoOrigin);
|
|
28406
|
-
selectorModel.
|
|
28062
|
+
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
28407
28063
|
selectorModel.shadow = "layer";
|
|
28408
28064
|
return selectorModel;
|
|
28409
28065
|
}
|
|
@@ -28412,24 +28068,21 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28412
28068
|
return null;
|
|
28413
28069
|
}
|
|
28414
28070
|
const yMap = new Y12.Map();
|
|
28415
|
-
const uuid = this.uuid;
|
|
28416
|
-
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28417
|
-
this.elementModels.set(uuid, straightLineModel);
|
|
28418
28071
|
this.elements.doc?.transact(() => {
|
|
28072
|
+
const uuid = this.uuid;
|
|
28419
28073
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28420
28074
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28421
28075
|
yMap.set("type", "line");
|
|
28422
28076
|
if (shadow) {
|
|
28423
28077
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28424
28078
|
}
|
|
28425
|
-
yMap.set("points", new Y12.Array());
|
|
28426
28079
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28427
28080
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28428
28081
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28429
28082
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28430
28083
|
this.elements.set(uuid, yMap);
|
|
28431
28084
|
}, elementsUndoOrigin);
|
|
28432
|
-
straightLineModel.
|
|
28085
|
+
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
28433
28086
|
this.initElement(straightLineModel);
|
|
28434
28087
|
straightLineModel.dashArray = this.toolbarModel.dashArray;
|
|
28435
28088
|
return straightLineModel;
|
|
@@ -28439,26 +28092,21 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28439
28092
|
return null;
|
|
28440
28093
|
}
|
|
28441
28094
|
const yMap = new Y12.Map();
|
|
28442
|
-
const uuid = this.uuid;
|
|
28443
|
-
const lineModel = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28444
|
-
this.elementModels.set(uuid, lineModel);
|
|
28445
28095
|
this.elements.doc?.transact(() => {
|
|
28096
|
+
const uuid = this.uuid;
|
|
28446
28097
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28447
28098
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28448
28099
|
yMap.set("type", "arrow");
|
|
28449
28100
|
if (shadow) {
|
|
28450
28101
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28451
28102
|
}
|
|
28452
|
-
yMap.set("headArrow", "none");
|
|
28453
|
-
yMap.set("tailArrow", "normal");
|
|
28454
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28455
28103
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28456
28104
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28457
28105
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28458
28106
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28459
28107
|
this.elements.set(uuid, yMap);
|
|
28460
28108
|
}, elementsUndoOrigin);
|
|
28461
|
-
lineModel.
|
|
28109
|
+
const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
|
|
28462
28110
|
this.initElement(lineModel);
|
|
28463
28111
|
lineModel.dashArray = this.toolbarModel.dashArray;
|
|
28464
28112
|
return lineModel;
|
|
@@ -28468,24 +28116,21 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28468
28116
|
return null;
|
|
28469
28117
|
}
|
|
28470
28118
|
const yMap = new Y12.Map();
|
|
28471
|
-
const uuid = this.uuid;
|
|
28472
|
-
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28473
|
-
this.elementModels.set(uuid, pointTextModel);
|
|
28474
28119
|
this.elements.doc?.transact(() => {
|
|
28120
|
+
const uuid = this.uuid;
|
|
28475
28121
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28476
28122
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28477
28123
|
yMap.set("type", "point-text");
|
|
28478
28124
|
if (shadow) {
|
|
28479
28125
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28480
28126
|
}
|
|
28481
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28482
28127
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28483
28128
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28484
28129
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28485
28130
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28486
28131
|
this.elements.set(uuid, yMap);
|
|
28487
28132
|
}, elementsUndoOrigin);
|
|
28488
|
-
pointTextModel.
|
|
28133
|
+
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
28489
28134
|
pointTextModel.setPoints([x, y]);
|
|
28490
28135
|
pointTextModel.fontSize = this.toolbarModel.fontSize;
|
|
28491
28136
|
pointTextModel.fontFamily = this.toolbarModel.fontFamily;
|
|
@@ -28508,19 +28153,18 @@ var RenderableModel = class extends EventEmitter {
|
|
|
28508
28153
|
});
|
|
28509
28154
|
}
|
|
28510
28155
|
dispose(clearElements) {
|
|
28511
|
-
|
|
28156
|
+
removeObserver2(this.elements, this.onElementsChange);
|
|
28512
28157
|
if (clearElements) {
|
|
28513
28158
|
this.elements.clear();
|
|
28514
28159
|
}
|
|
28515
28160
|
Array.from(this.elementModels.values()).forEach((model) => {
|
|
28516
28161
|
model.dispose();
|
|
28517
|
-
model.disposeObserver();
|
|
28518
28162
|
});
|
|
28519
28163
|
}
|
|
28520
28164
|
};
|
|
28521
28165
|
|
|
28522
28166
|
// src/utils/Recognizer.ts
|
|
28523
|
-
var
|
|
28167
|
+
var import_lodash8 = __toESM(require_lodash(), 1);
|
|
28524
28168
|
|
|
28525
28169
|
// src/utils/UnistrokeRecognizer.js
|
|
28526
28170
|
function Point(x, y) {
|
|
@@ -28767,7 +28411,7 @@ var Recognizer = class {
|
|
|
28767
28411
|
let maxX = -Number.MAX_VALUE;
|
|
28768
28412
|
let minY = Number.MAX_VALUE;
|
|
28769
28413
|
let maxY = -Number.MAX_VALUE;
|
|
28770
|
-
const result = this.dollar.Recognize((0,
|
|
28414
|
+
const result = this.dollar.Recognize((0, import_lodash8.chunk)(points, 2).map((v) => {
|
|
28771
28415
|
minX = Math.min(minX, v[0]);
|
|
28772
28416
|
maxX = Math.max(maxX, v[0]);
|
|
28773
28417
|
minY = Math.min(minY, v[1]);
|
|
@@ -28811,24 +28455,11 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28811
28455
|
_defineProperty19(this, "elementModel", null);
|
|
28812
28456
|
_defineProperty19(this, "recognizer", new Recognizer());
|
|
28813
28457
|
_defineProperty19(this, "pointCount", 0);
|
|
28814
|
-
_defineProperty19(this, "pendingPoints", []);
|
|
28815
|
-
_defineProperty19(this, "flushRafId", 0);
|
|
28816
28458
|
_defineProperty19(this, "showLiveCursor", true);
|
|
28817
|
-
|
|
28818
|
-
this.flushRafId = 0;
|
|
28819
|
-
if (this.elementModel && this.pendingPoints.length > 0) {
|
|
28820
|
-
this.elementModel.appendPoints(this.pendingPoints);
|
|
28821
|
-
this.pendingPoints = [];
|
|
28822
|
-
}
|
|
28823
|
-
});
|
|
28459
|
+
this.tool.minDistance = 5;
|
|
28824
28460
|
}
|
|
28825
28461
|
onMouseDown(_event) {
|
|
28826
28462
|
this.pointCount = 0;
|
|
28827
|
-
this.pendingPoints = [];
|
|
28828
|
-
if (this.flushRafId) {
|
|
28829
|
-
cancelAnimationFrame(this.flushRafId);
|
|
28830
|
-
this.flushRafId = 0;
|
|
28831
|
-
}
|
|
28832
28463
|
if (this.elementModel) {
|
|
28833
28464
|
this.elementModel.dispose();
|
|
28834
28465
|
}
|
|
@@ -28843,38 +28474,27 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28843
28474
|
if (this.pointCount > 1024) {
|
|
28844
28475
|
return;
|
|
28845
28476
|
}
|
|
28846
|
-
const MIN_DISTANCE =
|
|
28477
|
+
const MIN_DISTANCE = 4;
|
|
28847
28478
|
if (this.elementModel) {
|
|
28848
|
-
|
|
28849
|
-
let
|
|
28850
|
-
|
|
28851
|
-
|
|
28852
|
-
|
|
28853
|
-
|
|
28854
|
-
|
|
28855
|
-
|
|
28856
|
-
|
|
28857
|
-
|
|
28858
|
-
}
|
|
28479
|
+
const len = this.elementModel.points.length;
|
|
28480
|
+
let last = {
|
|
28481
|
+
x: 0,
|
|
28482
|
+
y: 0
|
|
28483
|
+
};
|
|
28484
|
+
if (len >= 2) {
|
|
28485
|
+
last = {
|
|
28486
|
+
x: this.elementModel.points[len - 2],
|
|
28487
|
+
y: this.elementModel.points[len - 1]
|
|
28488
|
+
};
|
|
28859
28489
|
}
|
|
28860
|
-
const dist = Math.max(Math.abs(
|
|
28490
|
+
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
28861
28491
|
if (dist >= MIN_DISTANCE) {
|
|
28862
28492
|
this.pointCount += 1;
|
|
28863
|
-
|
|
28864
|
-
const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
|
|
28865
|
-
this.pendingPoints.push(event.point.x, event.point.y, pressure);
|
|
28866
|
-
if (!this.flushRafId) {
|
|
28867
|
-
this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
|
|
28868
|
-
}
|
|
28493
|
+
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
28869
28494
|
}
|
|
28870
28495
|
}
|
|
28871
28496
|
}
|
|
28872
28497
|
onMouseUp(event) {
|
|
28873
|
-
if (this.flushRafId) {
|
|
28874
|
-
cancelAnimationFrame(this.flushRafId);
|
|
28875
|
-
this.flushRafId = 0;
|
|
28876
|
-
}
|
|
28877
|
-
this.flushPendingPoints();
|
|
28878
28498
|
this.modelGetter().then((model) => {
|
|
28879
28499
|
if (!model) {
|
|
28880
28500
|
return;
|
|
@@ -28975,7 +28595,7 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28975
28595
|
|
|
28976
28596
|
// src/model/ToolbarModel.ts
|
|
28977
28597
|
import EventEmitter2 from "eventemitter3";
|
|
28978
|
-
import { removeObserver as
|
|
28598
|
+
import { removeObserver as removeObserver3 } from "@netless/forge-room";
|
|
28979
28599
|
function _defineProperty21(e, r, t) {
|
|
28980
28600
|
return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28981
28601
|
}
|
|
@@ -29072,7 +28692,7 @@ var ToolbarModel = class extends EventEmitter2 {
|
|
|
29072
28692
|
});
|
|
29073
28693
|
}
|
|
29074
28694
|
dispose() {
|
|
29075
|
-
|
|
28695
|
+
removeObserver3(this.root, this.handleRootUpdate);
|
|
29076
28696
|
this.removeAllListeners();
|
|
29077
28697
|
}
|
|
29078
28698
|
};
|
|
@@ -30006,7 +29626,6 @@ var Editor = class extends EventEmitter5 {
|
|
|
30006
29626
|
this.shadowContainer.remove();
|
|
30007
29627
|
this.shadowScope.project.activeLayer.addChild(this.shadowContainer);
|
|
30008
29628
|
this.targets.forEach((model) => {
|
|
30009
|
-
console.log("[][][] translateShadow model", model.root._dEH);
|
|
30010
29629
|
model.shadow = this.shadowContainer.data.uuid;
|
|
30011
29630
|
});
|
|
30012
29631
|
}
|
|
@@ -30233,7 +29852,7 @@ var Gesture = class extends EventEmitter6 {
|
|
|
30233
29852
|
};
|
|
30234
29853
|
|
|
30235
29854
|
// src/Camera.ts
|
|
30236
|
-
import { removeObserver as
|
|
29855
|
+
import { removeObserver as removeObserver4 } from "@netless/forge-room";
|
|
30237
29856
|
function _defineProperty28(e, r, t) {
|
|
30238
29857
|
return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30239
29858
|
}
|
|
@@ -30310,14 +29929,14 @@ var Camera = class extends EventEmitter7 {
|
|
|
30310
29929
|
}
|
|
30311
29930
|
const cb = this.observers.get(user.id);
|
|
30312
29931
|
if (cb) {
|
|
30313
|
-
|
|
29932
|
+
removeObserver4(this.requestUserMap(user.id), cb);
|
|
30314
29933
|
}
|
|
30315
29934
|
});
|
|
30316
29935
|
_defineProperty28(this, "handleUserJoin", (user) => {
|
|
30317
29936
|
if (this.observers.has(user.id)) {
|
|
30318
29937
|
const cb = this.observers.get(user.id);
|
|
30319
29938
|
if (cb) {
|
|
30320
|
-
|
|
29939
|
+
removeObserver4(this.requestUserMap(user.id), cb);
|
|
30321
29940
|
this.observers.delete(user.id);
|
|
30322
29941
|
}
|
|
30323
29942
|
}
|
|
@@ -30429,7 +30048,7 @@ var Camera = class extends EventEmitter7 {
|
|
|
30429
30048
|
this.handleViewMatrixUpdate(userId, evt);
|
|
30430
30049
|
};
|
|
30431
30050
|
if (this.observers.has(userId)) {
|
|
30432
|
-
|
|
30051
|
+
removeObserver4(this.requestUserMap(userId), observer);
|
|
30433
30052
|
}
|
|
30434
30053
|
this.requestUserMap(userId).observe(observer);
|
|
30435
30054
|
this.observers.set(userId, observer);
|
|
@@ -30626,10 +30245,10 @@ var Camera = class extends EventEmitter7 {
|
|
|
30626
30245
|
Array.from(this.observers.keys()).forEach((userId) => {
|
|
30627
30246
|
const cb = this.observers.get(userId);
|
|
30628
30247
|
if (cb) {
|
|
30629
|
-
|
|
30248
|
+
removeObserver4(this.requestUserMap(userId), cb);
|
|
30630
30249
|
}
|
|
30631
30250
|
});
|
|
30632
|
-
|
|
30251
|
+
removeObserver4(this.whiteboardAttrsMap, this.handleMainCameraChange);
|
|
30633
30252
|
this.userManager.off("join", this.handleUserJoin);
|
|
30634
30253
|
this.userManager.off("leave", this.handleUserLeave);
|
|
30635
30254
|
this.gesture.removeAllListeners();
|
|
@@ -30800,8 +30419,6 @@ var Whiteboard = class extends EventEmitter8 {
|
|
|
30800
30419
|
_defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
|
|
30801
30420
|
_defineProperty31(this, "getElementAttribute", void 0);
|
|
30802
30421
|
_defineProperty31(this, "setElementAttribute", void 0);
|
|
30803
|
-
_defineProperty31(this, "setPerformanceMode", void 0);
|
|
30804
|
-
_defineProperty31(this, "isPerformanceMode", void 0);
|
|
30805
30422
|
_defineProperty31(this, "removeElement", void 0);
|
|
30806
30423
|
_defineProperty31(this, "getCurrentTool", void 0);
|
|
30807
30424
|
_defineProperty31(this, "setCurrentTool", void 0);
|
|
@@ -31100,24 +30717,9 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
31100
30717
|
if (this.pointCount > 1024) {
|
|
31101
30718
|
return;
|
|
31102
30719
|
}
|
|
31103
|
-
const MIN_DISTANCE = 4;
|
|
31104
30720
|
if (this.elementModel) {
|
|
31105
|
-
|
|
31106
|
-
|
|
31107
|
-
x: 0,
|
|
31108
|
-
y: 0
|
|
31109
|
-
};
|
|
31110
|
-
if (len >= 2) {
|
|
31111
|
-
last = {
|
|
31112
|
-
x: this.elementModel.points[len - 2],
|
|
31113
|
-
y: this.elementModel.points[len - 1]
|
|
31114
|
-
};
|
|
31115
|
-
}
|
|
31116
|
-
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
31117
|
-
if (dist >= MIN_DISTANCE) {
|
|
31118
|
-
this.pointCount += 1;
|
|
31119
|
-
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
31120
|
-
}
|
|
30721
|
+
this.pointCount += 1;
|
|
30722
|
+
this.elementModel.appendPoints([event.point.x, event.point.y]);
|
|
31121
30723
|
}
|
|
31122
30724
|
}
|
|
31123
30725
|
onMouseUp(_event) {
|
|
@@ -31129,7 +30731,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
31129
30731
|
|
|
31130
30732
|
// src/model/PageModel.ts
|
|
31131
30733
|
import EventEmitter10 from "eventemitter3";
|
|
31132
|
-
import { log as log2, removeObserver as
|
|
30734
|
+
import { log as log2, removeObserver as removeObserver5 } from "@netless/forge-room";
|
|
31133
30735
|
function _defineProperty35(e, r, t) {
|
|
31134
30736
|
return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
31135
30737
|
}
|
|
@@ -31162,7 +30764,7 @@ var PageModel = class extends EventEmitter10 {
|
|
|
31162
30764
|
}
|
|
31163
30765
|
const cb = this.observers.get(user.id);
|
|
31164
30766
|
if (cb) {
|
|
31165
|
-
|
|
30767
|
+
removeObserver5(this.requestUserMap(user.id), cb);
|
|
31166
30768
|
}
|
|
31167
30769
|
});
|
|
31168
30770
|
_defineProperty35(this, "handleUserJoin", (user) => {
|
|
@@ -31223,7 +30825,7 @@ var PageModel = class extends EventEmitter10 {
|
|
|
31223
30825
|
if (this.observers.has(userId)) {
|
|
31224
30826
|
const cb = this.observers.get(userId);
|
|
31225
30827
|
if (cb) {
|
|
31226
|
-
|
|
30828
|
+
removeObserver5(this.requestUserMap(userId), cb);
|
|
31227
30829
|
this.observers.delete(userId);
|
|
31228
30830
|
}
|
|
31229
30831
|
}
|
|
@@ -31312,12 +30914,12 @@ var PageModel = class extends EventEmitter10 {
|
|
|
31312
30914
|
dispose() {
|
|
31313
30915
|
for (const entry of this.observers.entries()) {
|
|
31314
30916
|
const [userId, observer] = entry;
|
|
31315
|
-
|
|
30917
|
+
removeObserver5(this.requestUserMap(userId), observer);
|
|
31316
30918
|
}
|
|
31317
30919
|
this.userManager.off("join", this.handleUserJoin);
|
|
31318
30920
|
this.userManager.off("leave", this.handleUserLeave);
|
|
31319
|
-
|
|
31320
|
-
|
|
30921
|
+
removeObserver5(this.whiteboardAttrsMap, this.handleMainPageChange);
|
|
30922
|
+
removeObserver5(this.pageMap, this.handlePageMapChange);
|
|
31321
30923
|
}
|
|
31322
30924
|
};
|
|
31323
30925
|
|
|
@@ -31333,7 +30935,7 @@ async function waitUntil(fn, timeout) {
|
|
|
31333
30935
|
// src/IndexedNavigation.ts
|
|
31334
30936
|
import EventEmitter11 from "eventemitter3";
|
|
31335
30937
|
import { log as log3 } from "@netless/forge-room";
|
|
31336
|
-
import { removeObserver as
|
|
30938
|
+
import { removeObserver as removeObserver6 } from "@netless/forge-room";
|
|
31337
30939
|
function _defineProperty36(e, r, t) {
|
|
31338
30940
|
return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
31339
30941
|
}
|
|
@@ -31676,7 +31278,7 @@ var IndexedNavigation = class extends EventEmitter11 {
|
|
|
31676
31278
|
}
|
|
31677
31279
|
}
|
|
31678
31280
|
dispose() {
|
|
31679
|
-
|
|
31281
|
+
removeObserver6(this.indexedPageMap, this.handleIndexedPageMapUpdate);
|
|
31680
31282
|
this.pageModel.off("switchPage");
|
|
31681
31283
|
this.pageModel.off("pagesChange");
|
|
31682
31284
|
}
|
|
@@ -31897,7 +31499,7 @@ var SequenceExecutor = class {
|
|
|
31897
31499
|
};
|
|
31898
31500
|
|
|
31899
31501
|
// src/WhiteboardApplication.ts
|
|
31900
|
-
import { removeObserver as
|
|
31502
|
+
import { removeObserver as removeObserver7 } from "@netless/forge-room";
|
|
31901
31503
|
|
|
31902
31504
|
// src/LiveCursor.ts
|
|
31903
31505
|
function _defineProperty42(e, r, t) {
|
|
@@ -31952,19 +31554,9 @@ var LiveCursor = class {
|
|
|
31952
31554
|
cursor.style.fontSize = "12px";
|
|
31953
31555
|
cursor.style.padding = "2px 4px";
|
|
31954
31556
|
cursor.style.borderRadius = "4px";
|
|
31955
|
-
this.
|
|
31557
|
+
cursor.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
|
|
31956
31558
|
return cursor;
|
|
31957
31559
|
}
|
|
31958
|
-
updateCursorLabel(userId, cursor) {
|
|
31959
|
-
const target = cursor ?? this.cursors.get(userId);
|
|
31960
|
-
if (!target) {
|
|
31961
|
-
return;
|
|
31962
|
-
}
|
|
31963
|
-
if (target.textContent && target.textContent !== userId) {
|
|
31964
|
-
return;
|
|
31965
|
-
}
|
|
31966
|
-
target.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
|
|
31967
|
-
}
|
|
31968
31560
|
isOnSamePage(userId) {
|
|
31969
31561
|
const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
|
|
31970
31562
|
const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
|
|
@@ -32000,7 +31592,6 @@ var LiveCursor = class {
|
|
|
32000
31592
|
}
|
|
32001
31593
|
const cursor = this.cursors.get(userId);
|
|
32002
31594
|
if (cursor) {
|
|
32003
|
-
this.updateCursorLabel(userId, cursor);
|
|
32004
31595
|
const viewPoint = this.paperScope.project.view.projectToView(point);
|
|
32005
31596
|
cursor.style.left = viewPoint.x + "px";
|
|
32006
31597
|
cursor.style.top = viewPoint.y + "px";
|
|
@@ -32116,7 +31707,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32116
31707
|
_defineProperty43(this, "permissions", void 0);
|
|
32117
31708
|
_defineProperty43(this, "inputType", "any");
|
|
32118
31709
|
_defineProperty43(this, "isPenEvent", false);
|
|
32119
|
-
_defineProperty43(this, "activePenPointerId", null);
|
|
32120
31710
|
_defineProperty43(this, "hasPenInput", null);
|
|
32121
31711
|
_defineProperty43(this, "disableViewModelUpdate", false);
|
|
32122
31712
|
_defineProperty43(this, "internalResizeObserver", true);
|
|
@@ -32233,9 +31823,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32233
31823
|
_defineProperty43(this, "hasPermission", (flag) => {
|
|
32234
31824
|
return this.permissions.hasPermission(flag, this.userId);
|
|
32235
31825
|
});
|
|
32236
|
-
_defineProperty43(this, "isPerformanceMode", () => {
|
|
32237
|
-
return this.option.performance ?? false;
|
|
32238
|
-
});
|
|
32239
31826
|
_defineProperty43(this, "handleStackItemAdded", () => {
|
|
32240
31827
|
this.selectElementsModel.clearSelectElementForSelf();
|
|
32241
31828
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
@@ -32250,18 +31837,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32250
31837
|
const id = ids[i];
|
|
32251
31838
|
if (!this.layers.has(id)) {
|
|
32252
31839
|
const elementsMap = this.getMap(`layer/${id}/elements`);
|
|
32253
|
-
const renderableModel = new RenderableModel(
|
|
32254
|
-
layerId: id,
|
|
32255
|
-
shadowEmitter: this.shadowEmitter,
|
|
32256
|
-
elements: elementsMap,
|
|
32257
|
-
scope: this.paperScope,
|
|
32258
|
-
toolbarModel: this.toolbarModel,
|
|
32259
|
-
userManager: this.userManager,
|
|
32260
|
-
imageSets: this.imageSets,
|
|
32261
|
-
liveCursor: this.liveCursor,
|
|
32262
|
-
hasPermission: this.hasPermission,
|
|
32263
|
-
isPerformanceMode: this.isPerformanceMode
|
|
32264
|
-
});
|
|
31840
|
+
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
|
|
32265
31841
|
this.layers.set(id, renderableModel);
|
|
32266
31842
|
}
|
|
32267
31843
|
if (!this.undoManagers.has(id)) {
|
|
@@ -32445,34 +32021,11 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32445
32021
|
this.imageSets.setAttribute("data-image-sets", "");
|
|
32446
32022
|
this.rootElement.appendChild(this.imageSets);
|
|
32447
32023
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
32448
|
-
|
|
32449
|
-
|
|
32450
|
-
this.
|
|
32451
|
-
|
|
32452
|
-
|
|
32453
|
-
this.inputType = "pen";
|
|
32454
|
-
this.emitter.emit("inputTypeChange", this.inputType);
|
|
32455
|
-
}
|
|
32456
|
-
} else {
|
|
32457
|
-
if (this.activePenPointerId === null) {
|
|
32458
|
-
this.isPenEvent = false;
|
|
32459
|
-
}
|
|
32460
|
-
}
|
|
32461
|
-
}, {
|
|
32462
|
-
capture: true
|
|
32463
|
-
});
|
|
32464
|
-
document.body.addEventListener("pointerup", (evt) => {
|
|
32465
|
-
if (evt.pointerId === this.activePenPointerId) {
|
|
32466
|
-
this.activePenPointerId = null;
|
|
32467
|
-
this.isPenEvent = false;
|
|
32468
|
-
}
|
|
32469
|
-
}, {
|
|
32470
|
-
capture: true
|
|
32471
|
-
});
|
|
32472
|
-
document.body.addEventListener("pointercancel", (evt) => {
|
|
32473
|
-
if (evt.pointerId === this.activePenPointerId) {
|
|
32474
|
-
this.activePenPointerId = null;
|
|
32475
|
-
this.isPenEvent = false;
|
|
32024
|
+
this.isPenEvent = evt.pointerType === "pen";
|
|
32025
|
+
if (evt.pointerType === "pen" && this.hasPenInput === null) {
|
|
32026
|
+
this.hasPenInput = true;
|
|
32027
|
+
this.inputType = "pen";
|
|
32028
|
+
this.emitter.emit("inputTypeChange", this.inputType);
|
|
32476
32029
|
}
|
|
32477
32030
|
}, {
|
|
32478
32031
|
capture: true
|
|
@@ -32551,12 +32104,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32551
32104
|
this.camera.resetViewMatrixToFlow(flowId);
|
|
32552
32105
|
}
|
|
32553
32106
|
};
|
|
32554
|
-
this.emitter.setPerformanceMode = (enabled) => {
|
|
32555
|
-
this.option.performance = enabled;
|
|
32556
|
-
};
|
|
32557
|
-
this.emitter.isPerformanceMode = () => {
|
|
32558
|
-
return this.isPerformanceMode();
|
|
32559
|
-
};
|
|
32560
32107
|
this.emitter.setViewModeToMain = (userId) => {
|
|
32561
32108
|
if (that.disableViewModelUpdate) {
|
|
32562
32109
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
@@ -32611,18 +32158,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32611
32158
|
const source = this.getMap(`layer/${sourceId}/elements`);
|
|
32612
32159
|
const target = this.getMap(`layer/${targetId}/elements`);
|
|
32613
32160
|
if (!this.layers.has(targetId)) {
|
|
32614
|
-
this.layers.set(targetId, new RenderableModel(
|
|
32615
|
-
layerId: targetId,
|
|
32616
|
-
shadowEmitter: this.shadowEmitter,
|
|
32617
|
-
elements: target,
|
|
32618
|
-
scope: this.paperScope,
|
|
32619
|
-
toolbarModel: this.toolbarModel,
|
|
32620
|
-
userManager: this.userManager,
|
|
32621
|
-
imageSets: this.imageSets,
|
|
32622
|
-
liveCursor: this.liveCursor,
|
|
32623
|
-
hasPermission: this.hasPermission,
|
|
32624
|
-
isPerformanceMode: this.isPerformanceMode
|
|
32625
|
-
}));
|
|
32161
|
+
this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
|
|
32626
32162
|
}
|
|
32627
32163
|
if (!this.undoManagers.has(targetId)) {
|
|
32628
32164
|
const undoManager = new Y15.UndoManager(target, {
|
|
@@ -32857,11 +32393,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
32857
32393
|
this.editors.forEach((editor) => {
|
|
32858
32394
|
editor.updateBounds();
|
|
32859
32395
|
});
|
|
32860
|
-
const area = this.paperScope.project.view.size.width * this.paperScope.project.view.size.height;
|
|
32861
|
-
const minDistance = Math.ceil(area / 4e5);
|
|
32862
|
-
Object.keys(this.tools).forEach((key) => {
|
|
32863
|
-
this.tools[key].tool.minDistance = minDistance;
|
|
32864
|
-
});
|
|
32865
32396
|
});
|
|
32866
32397
|
this.camera.on("userPageChange", (userId, pageId) => {
|
|
32867
32398
|
this.emitter.emit("activePageChange", userId, pageId);
|
|
@@ -33210,7 +32741,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends AbstractApplica
|
|
|
33210
32741
|
this.toolbarModel.dispose();
|
|
33211
32742
|
this.emitter.indexedNavigation.dispose();
|
|
33212
32743
|
this.permissions.dispose();
|
|
33213
|
-
|
|
32744
|
+
removeObserver7(this.userMap(this.userId), this.handleSyncedWhiteboardStatusChange);
|
|
33214
32745
|
log4(`whiteboard ${this.appId} disposed. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
|
|
33215
32746
|
}
|
|
33216
32747
|
};
|