@netless/forge-whiteboard 1.1.4 → 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 -4
- 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 +271 -719
- package/dist/whiteboard.esm.js.map +3 -3
- package/dist/whiteboard.js +307 -755
- package/dist/whiteboard.js.map +3 -3
- package/package.json +2 -2
package/dist/whiteboard.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;
|
|
@@ -25639,7 +25639,7 @@ __export(src_exports, {
|
|
|
25639
25639
|
module.exports = __toCommonJS(src_exports);
|
|
25640
25640
|
|
|
25641
25641
|
// src/WhiteboardApplication.ts
|
|
25642
|
-
var
|
|
25642
|
+
var import_forge_room12 = require("@netless/forge-room");
|
|
25643
25643
|
var Y15 = __toESM(require("yjs"), 1);
|
|
25644
25644
|
var import_paper = __toESM(require_paper_full(), 1);
|
|
25645
25645
|
|
|
@@ -25647,7 +25647,7 @@ var import_paper = __toESM(require_paper_full(), 1);
|
|
|
25647
25647
|
var Y12 = __toESM(require("yjs"), 1);
|
|
25648
25648
|
var import_eventemitter3 = __toESM(require("eventemitter3"), 1);
|
|
25649
25649
|
var import_uuid = require("uuid");
|
|
25650
|
-
var
|
|
25650
|
+
var import_forge_room4 = require("@netless/forge-room");
|
|
25651
25651
|
|
|
25652
25652
|
// src/model/renderable/CurveModel.ts
|
|
25653
25653
|
var Y2 = __toESM(require("yjs"), 1);
|
|
@@ -25800,6 +25800,9 @@ function ae(e, t = {}) {
|
|
|
25800
25800
|
return ce(me(e, t), t);
|
|
25801
25801
|
}
|
|
25802
25802
|
|
|
25803
|
+
// src/model/renderable/CurveModel.ts
|
|
25804
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
25805
|
+
|
|
25803
25806
|
// src/model/renderable/ElementModel.ts
|
|
25804
25807
|
var Y = __toESM(require("yjs"), 1);
|
|
25805
25808
|
var import_forge_room = require("@netless/forge-room");
|
|
@@ -25887,23 +25890,12 @@ var ElementModel = class _ElementModel {
|
|
|
25887
25890
|
set shadow(value) {
|
|
25888
25891
|
this.root.set(_ElementModel.KEYS.shadow, value);
|
|
25889
25892
|
}
|
|
25890
|
-
|
|
25891
|
-
return this.isPerformanceMode() && this.shouldUseLocalPoints;
|
|
25892
|
-
}
|
|
25893
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
25893
|
+
constructor(root, scope, liveCursor) {
|
|
25894
25894
|
_defineProperty(this, "shadowEmitter", null);
|
|
25895
25895
|
_defineProperty(this, "root", void 0);
|
|
25896
25896
|
_defineProperty(this, "scope", void 0);
|
|
25897
25897
|
_defineProperty(this, "item", void 0);
|
|
25898
|
-
_defineProperty(this, "clearLocalPointsWhenYPointsChange", void 0);
|
|
25899
|
-
_defineProperty(this, "shouldUseLocalPoints", void 0);
|
|
25900
|
-
_defineProperty(this, "localPointsPick", void 0);
|
|
25901
25898
|
_defineProperty(this, "liveCursor", void 0);
|
|
25902
|
-
_defineProperty(this, "appendPointsTimer", null);
|
|
25903
|
-
_defineProperty(this, "setPointsTimer", null);
|
|
25904
|
-
_defineProperty(this, "pointsUpdateTimer", null);
|
|
25905
|
-
_defineProperty(this, "isPerformanceMode", void 0);
|
|
25906
|
-
_defineProperty(this, "localPoints", []);
|
|
25907
25899
|
_defineProperty(this, "handlePropChange", (events) => {
|
|
25908
25900
|
if (!this.item) {
|
|
25909
25901
|
return;
|
|
@@ -25942,80 +25934,23 @@ var ElementModel = class _ElementModel {
|
|
|
25942
25934
|
}
|
|
25943
25935
|
}
|
|
25944
25936
|
} else if (event.target === this.root.get(_ElementModel.KEYS.points)) {
|
|
25945
|
-
|
|
25946
|
-
|
|
25947
|
-
|
|
25948
|
-
|
|
25937
|
+
this.onVectorUpdate();
|
|
25938
|
+
const liveCursorPoint = this.liveCursorPoint();
|
|
25939
|
+
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
25940
|
+
if (liveCursorPoint && ownerId) {
|
|
25941
|
+
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
25949
25942
|
}
|
|
25950
25943
|
} else {
|
|
25951
25944
|
}
|
|
25952
25945
|
}
|
|
25953
25946
|
});
|
|
25954
|
-
_defineProperty(this, "onPointsArrayChange", (points) => {
|
|
25955
|
-
if (this.localPoints.length >= points.length) {
|
|
25956
|
-
return;
|
|
25957
|
-
}
|
|
25958
|
-
const pointsChunk = points.slice(this.localPoints.length, this.localPoints.length + this.localPointsPick);
|
|
25959
|
-
this.localPoints = this.localPoints.concat(pointsChunk);
|
|
25960
|
-
this.onVectorUpdate();
|
|
25961
|
-
this.pointsUpdateTimer = window.requestAnimationFrame(() => {
|
|
25962
|
-
this.onPointsArrayChange(points);
|
|
25963
|
-
});
|
|
25964
|
-
});
|
|
25965
|
-
this.isPerformanceMode = isPerformanceMode;
|
|
25966
25947
|
this.scope = scope;
|
|
25967
25948
|
this.liveCursor = liveCursor;
|
|
25968
25949
|
this.root = root;
|
|
25969
|
-
if (this.root.
|
|
25970
|
-
if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
|
|
25971
|
-
this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
|
|
25972
|
-
}
|
|
25973
|
-
} else {
|
|
25950
|
+
if (!this.root.has(_ElementModel.KEYS.pointsMatrix)) {
|
|
25974
25951
|
this.root.set(_ElementModel.KEYS.pointsMatrix, [1, 0, 0, 1, 0, 0]);
|
|
25975
25952
|
}
|
|
25976
|
-
}
|
|
25977
|
-
bindObserver() {
|
|
25978
|
-
const beforeL = this.root._eH?.l?.length ?? -1;
|
|
25979
|
-
const beforeDL = this.root._dEH?.l?.length ?? -1;
|
|
25980
|
-
(0, import_forge_room.removeDeepObserver)(this.root, this.handlePropChange);
|
|
25981
|
-
this.subBindObserver();
|
|
25982
|
-
const afterRemoveL = this.root._eH?.l?.length ?? -1;
|
|
25983
|
-
const afterRemoveDL = this.root._dEH?.l?.length ?? -1;
|
|
25984
25953
|
this.root.observeDeep(this.handlePropChange);
|
|
25985
|
-
const afterAddL = this.root._eH?.l?.length ?? -1;
|
|
25986
|
-
const afterAddDL = this.root._dEH?.l?.length ?? -1;
|
|
25987
|
-
console.log(`[][][] bindObserver uuid=${this.uuid} doc=${!!this.root.doc} _eH: ${beforeL}->${afterRemoveL}->${afterAddL} _dEH: ${beforeDL}->${afterRemoveDL}->${afterAddDL}`);
|
|
25988
|
-
}
|
|
25989
|
-
subBindObserver() {
|
|
25990
|
-
}
|
|
25991
|
-
handlePointsChangeDirect() {
|
|
25992
|
-
this.onVectorUpdate();
|
|
25993
|
-
const liveCursorPoint = this.liveCursorPoint();
|
|
25994
|
-
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
25995
|
-
if (liveCursorPoint && ownerId) {
|
|
25996
|
-
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
25997
|
-
}
|
|
25998
|
-
}
|
|
25999
|
-
handlePointsChangePerformance() {
|
|
26000
|
-
const liveCursorPoint = this.liveCursorPoint();
|
|
26001
|
-
const ownerId = this.root.get(_ElementModel.KEYS.ownerId);
|
|
26002
|
-
if (liveCursorPoint && ownerId) {
|
|
26003
|
-
this.liveCursor.updateCursorPosition(liveCursorPoint, this.root.get(_ElementModel.KEYS.ownerId));
|
|
26004
|
-
}
|
|
26005
|
-
if (this.liveCursor.userManager.selfId !== ownerId || this.localPoints.length === 0) {
|
|
26006
|
-
if (this.pointsUpdateTimer) {
|
|
26007
|
-
window.cancelAnimationFrame(this.pointsUpdateTimer);
|
|
26008
|
-
}
|
|
26009
|
-
if (this.shadow == "") {
|
|
26010
|
-
this.localPoints = this.points;
|
|
26011
|
-
this.onVectorUpdate();
|
|
26012
|
-
} else {
|
|
26013
|
-
if (this.clearLocalPointsWhenYPointsChange) {
|
|
26014
|
-
this.localPoints = [];
|
|
26015
|
-
}
|
|
26016
|
-
this.onPointsArrayChange(this.points);
|
|
26017
|
-
}
|
|
26018
|
-
}
|
|
26019
25954
|
}
|
|
26020
25955
|
createPaperElement() {
|
|
26021
25956
|
this.createPaperItem();
|
|
@@ -26028,48 +25963,14 @@ var ElementModel = class _ElementModel {
|
|
|
26028
25963
|
}
|
|
26029
25964
|
}
|
|
26030
25965
|
appendPoints(points) {
|
|
26031
|
-
if (this.isPerformanceEnvironment) {
|
|
26032
|
-
this.appendPointsPerformance(points);
|
|
26033
|
-
} else {
|
|
26034
|
-
this.appendPointsDirect(points);
|
|
26035
|
-
}
|
|
26036
|
-
}
|
|
26037
|
-
appendPointsDirect(points) {
|
|
26038
25966
|
this.root.get(_ElementModel.KEYS.points).push(points);
|
|
26039
25967
|
}
|
|
26040
|
-
appendPointsPerformance(points) {
|
|
26041
|
-
this.localPoints = this.localPoints.concat(points);
|
|
26042
|
-
this.onVectorUpdate();
|
|
26043
|
-
if (this.appendPointsTimer) {
|
|
26044
|
-
window.clearTimeout(this.appendPointsTimer);
|
|
26045
|
-
}
|
|
26046
|
-
if (this.localPoints.length % 80 === 0) {
|
|
26047
|
-
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26048
|
-
yArray?.push(this.localPoints.slice(yArray.length));
|
|
26049
|
-
}
|
|
26050
|
-
this.appendPointsTimer = window.setTimeout(() => {
|
|
26051
|
-
this.appendPointsTimer = null;
|
|
26052
|
-
if (this.localPoints.length > 0) {
|
|
26053
|
-
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26054
|
-
yArray?.push(this.localPoints.slice(yArray.length));
|
|
26055
|
-
}
|
|
26056
|
-
}, 100);
|
|
26057
|
-
}
|
|
26058
25968
|
setPoints(points) {
|
|
26059
|
-
if (this.isPerformanceEnvironment) {
|
|
26060
|
-
this.setPointsPerformance(points);
|
|
26061
|
-
} else {
|
|
26062
|
-
this.setPointsDirect(points);
|
|
26063
|
-
}
|
|
26064
|
-
}
|
|
26065
|
-
setPointsDirect(points) {
|
|
26066
25969
|
if (this.root.doc) {
|
|
26067
25970
|
this.root.doc.transact(() => {
|
|
26068
25971
|
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26069
|
-
|
|
26070
|
-
|
|
26071
|
-
yArray.push(points);
|
|
26072
|
-
}
|
|
25972
|
+
yArray.delete(0, yArray.length);
|
|
25973
|
+
yArray.push(points);
|
|
26073
25974
|
});
|
|
26074
25975
|
} else {
|
|
26075
25976
|
const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
|
|
@@ -26078,29 +25979,6 @@ var ElementModel = class _ElementModel {
|
|
|
26078
25979
|
this.root.set(_ElementModel.KEYS.points, yArray);
|
|
26079
25980
|
}
|
|
26080
25981
|
}
|
|
26081
|
-
setPointsPerformance(points) {
|
|
26082
|
-
this.localPoints = points;
|
|
26083
|
-
this.onVectorUpdate();
|
|
26084
|
-
if (this.setPointsTimer) {
|
|
26085
|
-
window.clearTimeout(this.setPointsTimer);
|
|
26086
|
-
}
|
|
26087
|
-
this.setPointsTimer = window.setTimeout(() => {
|
|
26088
|
-
if (this.root.doc) {
|
|
26089
|
-
this.root.doc.transact(() => {
|
|
26090
|
-
const yArray = this.root.get(_ElementModel.KEYS.points);
|
|
26091
|
-
if (yArray) {
|
|
26092
|
-
yArray.delete(0, yArray.length);
|
|
26093
|
-
yArray.push(points);
|
|
26094
|
-
}
|
|
26095
|
-
});
|
|
26096
|
-
} else {
|
|
26097
|
-
const yArray = this.root.get(_ElementModel.KEYS.points) || new Y.Array();
|
|
26098
|
-
yArray.delete(0, yArray.length);
|
|
26099
|
-
yArray.push(points);
|
|
26100
|
-
this.root.set(_ElementModel.KEYS.points, yArray);
|
|
26101
|
-
}
|
|
26102
|
-
}, 100);
|
|
26103
|
-
}
|
|
26104
25982
|
appendPointsMatrix(matrix) {
|
|
26105
25983
|
const current = new this.scope.Matrix(this.pointsMatrix);
|
|
26106
25984
|
const next = matrix.appended(current);
|
|
@@ -26127,9 +26005,6 @@ var ElementModel = class _ElementModel {
|
|
|
26127
26005
|
}
|
|
26128
26006
|
dispose() {
|
|
26129
26007
|
this.subDispose();
|
|
26130
|
-
}
|
|
26131
|
-
disposeObserver() {
|
|
26132
|
-
console.log(`[][][] disposeObserver uuid=${this.uuid}`);
|
|
26133
26008
|
(0, import_forge_room.removeDeepObserver)(this.root, this.handlePropChange);
|
|
26134
26009
|
}
|
|
26135
26010
|
};
|
|
@@ -26202,53 +26077,47 @@ function _toPrimitive3(t, r) {
|
|
|
26202
26077
|
return ("string" === r ? String : Number)(t);
|
|
26203
26078
|
}
|
|
26204
26079
|
var CurveModel = class extends ElementModel {
|
|
26205
|
-
constructor(root, scope, liveCursor
|
|
26206
|
-
super(root, scope, liveCursor
|
|
26080
|
+
constructor(root, scope, liveCursor) {
|
|
26081
|
+
super(root, scope, liveCursor);
|
|
26207
26082
|
_defineProperty3(this, "item", null);
|
|
26083
|
+
_defineProperty3(this, "debugPath", void 0);
|
|
26208
26084
|
_defineProperty3(this, "debug", false);
|
|
26209
|
-
|
|
26210
|
-
_defineProperty3(this, "shouldUseLocalPoints", true);
|
|
26211
|
-
_defineProperty3(this, "localPointsPick", 6);
|
|
26212
|
-
if (!this.root.doc || !this.root.has("type")) {
|
|
26085
|
+
if (!this.root.has("type")) {
|
|
26213
26086
|
this.root.set("type", "curve");
|
|
26214
26087
|
}
|
|
26215
|
-
if (!this.root.
|
|
26088
|
+
if (!this.root.has("points")) {
|
|
26216
26089
|
this.root.set("points", new Y2.Array());
|
|
26217
26090
|
}
|
|
26091
|
+
this.debugPath = new scope.Path();
|
|
26218
26092
|
}
|
|
26219
26093
|
average(a2, b2) {
|
|
26220
26094
|
return (a2 + b2) / 2;
|
|
26221
26095
|
}
|
|
26222
26096
|
parsePoints(points) {
|
|
26223
|
-
const hasRealPressure = points.some((p) => p.length >= 3 && p[2] > 0);
|
|
26224
|
-
const viewScale = this.scope.project.view.matrix.scaling.x || 1;
|
|
26225
|
-
const taper = this.strokeWidth * 5 / viewScale;
|
|
26226
|
-
const streamline = Math.min(0.7, 0.7 * viewScale);
|
|
26227
26097
|
return ae(points, {
|
|
26228
26098
|
size: this.strokeWidth,
|
|
26229
|
-
smoothing: 0.
|
|
26230
|
-
thinning: 0.5,
|
|
26231
|
-
streamline,
|
|
26232
|
-
simulatePressure:
|
|
26099
|
+
smoothing: 0.5,
|
|
26100
|
+
thinning: -0.5,
|
|
26101
|
+
streamline: 0.5,
|
|
26102
|
+
simulatePressure: true,
|
|
26233
26103
|
start: {
|
|
26234
|
-
taper,
|
|
26104
|
+
taper: this.strokeWidth * 10,
|
|
26235
26105
|
cap: true
|
|
26236
26106
|
},
|
|
26237
26107
|
end: {
|
|
26238
|
-
taper,
|
|
26108
|
+
taper: this.strokeWidth * 20,
|
|
26239
26109
|
cap: true
|
|
26240
26110
|
}
|
|
26241
26111
|
});
|
|
26242
26112
|
}
|
|
26243
26113
|
matrixedPoints() {
|
|
26244
|
-
const points = this.
|
|
26114
|
+
const points = this.points;
|
|
26245
26115
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26246
26116
|
const output = [];
|
|
26247
|
-
for (let i = 0, len = points.length; i < len; i +=
|
|
26117
|
+
for (let i = 0, len = points.length; i < len; i += 2) {
|
|
26248
26118
|
const p = new this.scope.Point(points[i], points[i + 1]);
|
|
26249
26119
|
const tp = p.transform(matrix);
|
|
26250
|
-
|
|
26251
|
-
output.push([tp.x, tp.y, pressure]);
|
|
26120
|
+
output.push([tp.x, tp.y]);
|
|
26252
26121
|
}
|
|
26253
26122
|
return output;
|
|
26254
26123
|
}
|
|
@@ -26277,30 +26146,34 @@ var CurveModel = class extends ElementModel {
|
|
|
26277
26146
|
}
|
|
26278
26147
|
return path;
|
|
26279
26148
|
}
|
|
26149
|
+
updateDebugPath() {
|
|
26150
|
+
this.debugPath = new this.scope.Path();
|
|
26151
|
+
const points = (0, import_lodash.chunk)(this.points, 2);
|
|
26152
|
+
for (let i = 0, len = points.length; i < len; i++) {
|
|
26153
|
+
const point = new this.scope.Point(points[i][0], points[i][1]);
|
|
26154
|
+
if (i === 0) {
|
|
26155
|
+
this.debugPath.moveTo(point);
|
|
26156
|
+
} else {
|
|
26157
|
+
this.debugPath.lineTo(point);
|
|
26158
|
+
}
|
|
26159
|
+
this.debugPath.strokeWidth = 1;
|
|
26160
|
+
this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
|
|
26161
|
+
}
|
|
26162
|
+
}
|
|
26280
26163
|
onVectorUpdate() {
|
|
26281
26164
|
if (!this.item) {
|
|
26282
26165
|
return;
|
|
26283
26166
|
}
|
|
26284
|
-
const matrixedPts = this.matrixedPoints();
|
|
26285
26167
|
if (this.debug) {
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
|
|
26291
|
-
|
|
26292
|
-
|
|
26293
|
-
|
|
26294
|
-
|
|
26295
|
-
this.item.removeSegments();
|
|
26296
|
-
this.item.addSegments(path.segments);
|
|
26297
|
-
this.item.fillColor = null;
|
|
26298
|
-
this.item.strokeWidth = this.strokeWidth;
|
|
26299
|
-
} else {
|
|
26300
|
-
const points = this.parsePoints(matrixedPts);
|
|
26301
|
-
const path = this.createPath(points);
|
|
26302
|
-
this.item.removeSegments();
|
|
26303
|
-
this.item.addSegments(path.segments);
|
|
26168
|
+
this.debugPath.remove();
|
|
26169
|
+
this.updateDebugPath();
|
|
26170
|
+
}
|
|
26171
|
+
const points = this.parsePoints(this.matrixedPoints());
|
|
26172
|
+
const path = this.createPath(points);
|
|
26173
|
+
this.item.removeSegments();
|
|
26174
|
+
this.item.addSegments(path.segments);
|
|
26175
|
+
if (this.debug) {
|
|
26176
|
+
this.item.addChild(this.debugPath);
|
|
26304
26177
|
}
|
|
26305
26178
|
}
|
|
26306
26179
|
createPaperItem() {
|
|
@@ -26323,11 +26196,11 @@ var CurveModel = class extends ElementModel {
|
|
|
26323
26196
|
}
|
|
26324
26197
|
liveCursorPoint() {
|
|
26325
26198
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
26326
|
-
if (yArray.length <
|
|
26199
|
+
if (yArray.length < 2) {
|
|
26327
26200
|
return null;
|
|
26328
26201
|
}
|
|
26329
26202
|
const len = yArray.length;
|
|
26330
|
-
const point = new this.scope.Point(yArray.get(len -
|
|
26203
|
+
const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
|
|
26331
26204
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
26332
26205
|
}
|
|
26333
26206
|
onStyleKeyUpdate(key) {
|
|
@@ -26365,24 +26238,15 @@ function _toPrimitive4(t, r) {
|
|
|
26365
26238
|
return ("string" === r ? String : Number)(t);
|
|
26366
26239
|
}
|
|
26367
26240
|
var SelectorModel = class extends ElementModel {
|
|
26368
|
-
|
|
26369
|
-
|
|
26370
|
-
return this.localPoints;
|
|
26371
|
-
}
|
|
26372
|
-
return this.points;
|
|
26373
|
-
}
|
|
26374
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
26375
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26241
|
+
constructor(root, scope, liveCursor) {
|
|
26242
|
+
super(root, scope, liveCursor);
|
|
26376
26243
|
_defineProperty4(this, "item", null);
|
|
26377
|
-
|
|
26378
|
-
_defineProperty4(this, "shouldUseLocalPoints", true);
|
|
26379
|
-
_defineProperty4(this, "localPointsPick", 4);
|
|
26380
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26244
|
+
if (!this.root.has("type")) {
|
|
26381
26245
|
this.root.set("type", "selector");
|
|
26382
26246
|
}
|
|
26383
|
-
if (
|
|
26247
|
+
if (!this.root.has("points")) {
|
|
26384
26248
|
const initPoints = new Y3.Array();
|
|
26385
|
-
initPoints.push([0, 0, 0, 0]);
|
|
26249
|
+
initPoints.push([0, 0, 0, 0, 0]);
|
|
26386
26250
|
this.root.set("points", initPoints);
|
|
26387
26251
|
}
|
|
26388
26252
|
}
|
|
@@ -26393,8 +26257,8 @@ var SelectorModel = class extends ElementModel {
|
|
|
26393
26257
|
}
|
|
26394
26258
|
createPaperRect() {
|
|
26395
26259
|
const scope = this.scope;
|
|
26396
|
-
const bounds = new scope.Rectangle(new scope.Point(this.
|
|
26397
|
-
return new scope.Path.Rectangle(bounds);
|
|
26260
|
+
const bounds = new scope.Rectangle(new scope.Point(this.points[0], this.points[1]), new scope.Size(this.points[2], this.points[3]));
|
|
26261
|
+
return new scope.Path.Rectangle(bounds, new scope.Point(this.points[4], this.points[4]));
|
|
26398
26262
|
}
|
|
26399
26263
|
onVectorUpdate() {
|
|
26400
26264
|
if (!this.item) {
|
|
@@ -26428,8 +26292,7 @@ var SelectorModel = class extends ElementModel {
|
|
|
26428
26292
|
var Y4 = __toESM(require("yjs"), 1);
|
|
26429
26293
|
|
|
26430
26294
|
// src/utils/paperjs.ts
|
|
26431
|
-
var
|
|
26432
|
-
var import_forge_room2 = require("@netless/forge-room");
|
|
26295
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
26433
26296
|
function _defineProperty5(e, r, t) {
|
|
26434
26297
|
return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26435
26298
|
}
|
|
@@ -26462,7 +26325,7 @@ function serializePath(path) {
|
|
|
26462
26325
|
}, []);
|
|
26463
26326
|
}
|
|
26464
26327
|
function deserializePath(points, scope, matrix) {
|
|
26465
|
-
const segmentGroup = (0,
|
|
26328
|
+
const segmentGroup = (0, import_lodash2.chunk)(points, 6);
|
|
26466
26329
|
const path = new scope.Path();
|
|
26467
26330
|
path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
|
|
26468
26331
|
return path;
|
|
@@ -26472,27 +26335,7 @@ var AnimationFrame = class {
|
|
|
26472
26335
|
_defineProperty5(this, "callbacks", []);
|
|
26473
26336
|
_defineProperty5(this, "lastTime", 0);
|
|
26474
26337
|
_defineProperty5(this, "fps", 45);
|
|
26475
|
-
_defineProperty5(this, "lastCallbackTime", 0);
|
|
26476
|
-
_defineProperty5(this, "fpsBuffer", []);
|
|
26477
|
-
_defineProperty5(this, "FPS_REPORT_INTERVAL", 2700);
|
|
26478
26338
|
_defineProperty5(this, "handleCallbacks", () => {
|
|
26479
|
-
const now = performance.now();
|
|
26480
|
-
if (this.lastCallbackTime > 0) {
|
|
26481
|
-
const actualFps = 1e3 / (now - this.lastCallbackTime);
|
|
26482
|
-
this.fpsBuffer.push(actualFps);
|
|
26483
|
-
if (this.fpsBuffer.length >= this.FPS_REPORT_INTERVAL) {
|
|
26484
|
-
const avg = this.fpsBuffer.reduce((a2, b2) => a2 + b2, 0) / this.fpsBuffer.length;
|
|
26485
|
-
const min = Math.min(...this.fpsBuffer);
|
|
26486
|
-
const sorted = [...this.fpsBuffer].sort((a2, b2) => a2 - b2);
|
|
26487
|
-
const p90 = sorted[Math.floor(sorted.length * 0.9)];
|
|
26488
|
-
(0, import_forge_room2.metrics)().gauge("fps", Math.round(avg), {
|
|
26489
|
-
min: Math.round(min),
|
|
26490
|
-
p90: Math.round(p90)
|
|
26491
|
-
});
|
|
26492
|
-
this.fpsBuffer = [];
|
|
26493
|
-
}
|
|
26494
|
-
}
|
|
26495
|
-
this.lastCallbackTime = now;
|
|
26496
26339
|
const functions = this.callbacks;
|
|
26497
26340
|
this.callbacks = [];
|
|
26498
26341
|
for (let i = 0, l2 = functions.length; i < l2; i++) {
|
|
@@ -26536,22 +26379,13 @@ function _toPrimitive6(t, r) {
|
|
|
26536
26379
|
return ("string" === r ? String : Number)(t);
|
|
26537
26380
|
}
|
|
26538
26381
|
var SegmentsModel = class extends ElementModel {
|
|
26539
|
-
|
|
26540
|
-
|
|
26541
|
-
return this.localPoints;
|
|
26542
|
-
}
|
|
26543
|
-
return this.points;
|
|
26544
|
-
}
|
|
26545
|
-
constructor(root, scope, type, liveCursor, isPerformanceMode) {
|
|
26546
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26382
|
+
constructor(root, scope, type, liveCursor) {
|
|
26383
|
+
super(root, scope, liveCursor);
|
|
26547
26384
|
_defineProperty6(this, "item", null);
|
|
26548
|
-
|
|
26549
|
-
_defineProperty6(this, "shouldUseLocalPoints", true);
|
|
26550
|
-
_defineProperty6(this, "localPointsPick", 24);
|
|
26551
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26385
|
+
if (!this.root.has("type")) {
|
|
26552
26386
|
this.root.set("type", type);
|
|
26553
26387
|
}
|
|
26554
|
-
if (
|
|
26388
|
+
if (!this.root.has("points")) {
|
|
26555
26389
|
this.root.set("points", new Y4.Array());
|
|
26556
26390
|
}
|
|
26557
26391
|
}
|
|
@@ -26571,13 +26405,13 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26571
26405
|
}
|
|
26572
26406
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26573
26407
|
this.item.removeSegments();
|
|
26574
|
-
const next = deserializePath(this.
|
|
26408
|
+
const next = deserializePath(this.points, this.scope, matrix);
|
|
26575
26409
|
this.item.addSegments(next.segments);
|
|
26576
26410
|
this.item.closePath();
|
|
26577
26411
|
}
|
|
26578
26412
|
createPaperItem() {
|
|
26579
26413
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26580
|
-
this.item = deserializePath(this.
|
|
26414
|
+
this.item = deserializePath(this.points, this.scope, matrix);
|
|
26581
26415
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
26582
26416
|
this.item.dashArray = this.dashArray;
|
|
26583
26417
|
this.item.strokeWidth = this.strokeWidth;
|
|
@@ -26605,7 +26439,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26605
26439
|
|
|
26606
26440
|
// src/model/renderable/LineModel.ts
|
|
26607
26441
|
var Y5 = __toESM(require("yjs"), 1);
|
|
26608
|
-
var
|
|
26442
|
+
var import_lodash4 = __toESM(require_lodash(), 1);
|
|
26609
26443
|
|
|
26610
26444
|
// src/tool/WhiteboardTool.ts
|
|
26611
26445
|
function _defineProperty7(e, r, t) {
|
|
@@ -26625,8 +26459,6 @@ function _toPrimitive7(t, r) {
|
|
|
26625
26459
|
}
|
|
26626
26460
|
return ("string" === r ? String : Number)(t);
|
|
26627
26461
|
}
|
|
26628
|
-
var DRAG_FPS = 10;
|
|
26629
|
-
var DRAG_FRAME_MS = 1e3 / DRAG_FPS;
|
|
26630
26462
|
var WhiteboardTool = class {
|
|
26631
26463
|
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
26632
26464
|
_defineProperty7(this, "modelGetter", void 0);
|
|
@@ -26635,60 +26467,24 @@ var WhiteboardTool = class {
|
|
|
26635
26467
|
_defineProperty7(this, "shadowEmitter", void 0);
|
|
26636
26468
|
_defineProperty7(this, "enableToolEvent", void 0);
|
|
26637
26469
|
_defineProperty7(this, "eventAvailable", false);
|
|
26638
|
-
_defineProperty7(this, "lastDragTime", 0);
|
|
26639
|
-
_defineProperty7(this, "dragRafId", 0);
|
|
26640
|
-
_defineProperty7(this, "pendingDragEvent", null);
|
|
26641
26470
|
_defineProperty7(this, "onMouseDownSelf", (event) => {
|
|
26642
26471
|
this.eventAvailable = this.enableToolEvent();
|
|
26643
26472
|
if (!this.eventAvailable) {
|
|
26644
26473
|
return;
|
|
26645
26474
|
}
|
|
26646
|
-
this.lastDragTime = 0;
|
|
26647
|
-
if (this.dragRafId) {
|
|
26648
|
-
cancelAnimationFrame(this.dragRafId);
|
|
26649
|
-
this.dragRafId = 0;
|
|
26650
|
-
}
|
|
26651
|
-
this.pendingDragEvent = null;
|
|
26652
26475
|
this.shadowEmitter.setActive(true);
|
|
26653
26476
|
this.onMouseDown(event);
|
|
26654
26477
|
});
|
|
26655
|
-
_defineProperty7(this, "flushPendingDrag", () => {
|
|
26656
|
-
this.dragRafId = 0;
|
|
26657
|
-
if (this.pendingDragEvent) {
|
|
26658
|
-
this.lastDragTime = performance.now();
|
|
26659
|
-
const event = this.pendingDragEvent;
|
|
26660
|
-
this.pendingDragEvent = null;
|
|
26661
|
-
this.onMouseDrag(event);
|
|
26662
|
-
}
|
|
26663
|
-
});
|
|
26664
26478
|
_defineProperty7(this, "onMouseDragSelf", (event) => {
|
|
26665
26479
|
if (!this.eventAvailable) {
|
|
26666
26480
|
return;
|
|
26667
26481
|
}
|
|
26668
|
-
|
|
26669
|
-
if (now - this.lastDragTime >= DRAG_FRAME_MS) {
|
|
26670
|
-
this.lastDragTime = now;
|
|
26671
|
-
this.pendingDragEvent = null;
|
|
26672
|
-
this.onMouseDrag(event);
|
|
26673
|
-
} else {
|
|
26674
|
-
this.pendingDragEvent = event;
|
|
26675
|
-
if (!this.dragRafId) {
|
|
26676
|
-
this.dragRafId = requestAnimationFrame(this.flushPendingDrag);
|
|
26677
|
-
}
|
|
26678
|
-
}
|
|
26482
|
+
this.onMouseDrag(event);
|
|
26679
26483
|
});
|
|
26680
26484
|
_defineProperty7(this, "onMouseUpSelf", (event) => {
|
|
26681
26485
|
if (!this.eventAvailable) {
|
|
26682
26486
|
return;
|
|
26683
26487
|
}
|
|
26684
|
-
if (this.dragRafId) {
|
|
26685
|
-
cancelAnimationFrame(this.dragRafId);
|
|
26686
|
-
this.dragRafId = 0;
|
|
26687
|
-
}
|
|
26688
|
-
if (this.pendingDragEvent) {
|
|
26689
|
-
this.onMouseDrag(this.pendingDragEvent);
|
|
26690
|
-
this.pendingDragEvent = null;
|
|
26691
|
-
}
|
|
26692
26488
|
this.onMouseUp(event);
|
|
26693
26489
|
this.shadowEmitter.setActive(false);
|
|
26694
26490
|
});
|
|
@@ -26704,7 +26500,7 @@ var WhiteboardTool = class {
|
|
|
26704
26500
|
};
|
|
26705
26501
|
|
|
26706
26502
|
// src/tool/LineTool.ts
|
|
26707
|
-
var
|
|
26503
|
+
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
26708
26504
|
function _defineProperty8(e, r, t) {
|
|
26709
26505
|
return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26710
26506
|
}
|
|
@@ -26753,7 +26549,7 @@ var LineTool = class extends WhiteboardTool {
|
|
|
26753
26549
|
const point = path.getPointAt(distance);
|
|
26754
26550
|
return [point.x, point.y];
|
|
26755
26551
|
});
|
|
26756
|
-
this.elementModel.setPoints((0,
|
|
26552
|
+
this.elementModel.setPoints((0, import_lodash3.flattenDeep)(points));
|
|
26757
26553
|
}
|
|
26758
26554
|
}
|
|
26759
26555
|
onMouseUp(_event) {
|
|
@@ -26783,12 +26579,6 @@ function _toPrimitive9(t, r) {
|
|
|
26783
26579
|
return ("string" === r ? String : Number)(t);
|
|
26784
26580
|
}
|
|
26785
26581
|
var LineModel = class extends ElementModel {
|
|
26786
|
-
get drawPoints() {
|
|
26787
|
-
if (this.localPoints.length > 0) {
|
|
26788
|
-
return this.localPoints;
|
|
26789
|
-
}
|
|
26790
|
-
return this.points;
|
|
26791
|
-
}
|
|
26792
26582
|
get arrowSize() {
|
|
26793
26583
|
return this.strokeWidth * 5 + 15;
|
|
26794
26584
|
}
|
|
@@ -26804,23 +26594,20 @@ var LineModel = class extends ElementModel {
|
|
|
26804
26594
|
set tailArrow(value) {
|
|
26805
26595
|
this.root.set("tailArrow", value);
|
|
26806
26596
|
}
|
|
26807
|
-
constructor(root, scope, liveCursor
|
|
26808
|
-
super(root, scope, liveCursor
|
|
26597
|
+
constructor(root, scope, liveCursor) {
|
|
26598
|
+
super(root, scope, liveCursor);
|
|
26809
26599
|
_defineProperty9(this, "controlledPoints", []);
|
|
26810
|
-
_defineProperty9(this, "clearLocalPointsWhenYPointsChange", true);
|
|
26811
|
-
_defineProperty9(this, "shouldUseLocalPoints", true);
|
|
26812
|
-
_defineProperty9(this, "localPointsPick", 99);
|
|
26813
26600
|
_defineProperty9(this, "item", null);
|
|
26814
|
-
if (
|
|
26601
|
+
if (!this.root.has("type")) {
|
|
26815
26602
|
this.root.set("type", "arrow");
|
|
26816
26603
|
}
|
|
26817
|
-
if (
|
|
26604
|
+
if (!this.root.has("points")) {
|
|
26818
26605
|
this.root.set("points", new Y5.Array());
|
|
26819
26606
|
}
|
|
26820
|
-
if (
|
|
26607
|
+
if (!this.root.has("headArrow")) {
|
|
26821
26608
|
this.root.set("headArrow", "none");
|
|
26822
26609
|
}
|
|
26823
|
-
if (
|
|
26610
|
+
if (!this.root.has("tailArrow")) {
|
|
26824
26611
|
this.root.set("tailArrow", "normal");
|
|
26825
26612
|
}
|
|
26826
26613
|
}
|
|
@@ -26836,7 +26623,7 @@ var LineModel = class extends ElementModel {
|
|
|
26836
26623
|
}
|
|
26837
26624
|
renderLine() {
|
|
26838
26625
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26839
|
-
const papperPoints = (0,
|
|
26626
|
+
const papperPoints = (0, import_lodash4.chunk)(this.points, 2).map((item) => {
|
|
26840
26627
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
26841
26628
|
});
|
|
26842
26629
|
const path = new this.scope.Path();
|
|
@@ -26950,14 +26737,13 @@ var LineControlPoint = class {
|
|
|
26950
26737
|
if (this.position) {
|
|
26951
26738
|
return this.model.scope.project.view.projectToView(this.position.transform(matrix));
|
|
26952
26739
|
}
|
|
26953
|
-
const points = this.model["drawPoints"];
|
|
26954
26740
|
const from = {
|
|
26955
|
-
x: points[0],
|
|
26956
|
-
y: points[1]
|
|
26741
|
+
x: this.model.points[0],
|
|
26742
|
+
y: this.model.points[1]
|
|
26957
26743
|
};
|
|
26958
26744
|
const to = {
|
|
26959
|
-
x: points[points.length - 2],
|
|
26960
|
-
y: points[points.length - 1]
|
|
26745
|
+
x: this.model.points[this.model.points.length - 2],
|
|
26746
|
+
y: this.model.points[this.model.points.length - 1]
|
|
26961
26747
|
};
|
|
26962
26748
|
const clonedPath = new this.scope.Path.Line(from, to);
|
|
26963
26749
|
this.position = clonedPath.getPointAt(clonedPath.length * distance);
|
|
@@ -26970,9 +26756,9 @@ var LineControlPoint = class {
|
|
|
26970
26756
|
}
|
|
26971
26757
|
const pointsMatrix = new this.model.scope.Matrix(this.model.pointsMatrix);
|
|
26972
26758
|
const invertedPoint = point.transform(pointsMatrix.inverted());
|
|
26973
|
-
const points = this.model
|
|
26759
|
+
const points = this.model.points;
|
|
26974
26760
|
this.position = invertedPoint;
|
|
26975
|
-
const clonedPoints = (0,
|
|
26761
|
+
const clonedPoints = (0, import_lodash4.cloneDeep)(points);
|
|
26976
26762
|
clonedPoints[this.options.index * 2] = invertedPoint.x;
|
|
26977
26763
|
clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
|
|
26978
26764
|
this.model.setPoints(clonedPoints);
|
|
@@ -26981,7 +26767,7 @@ var LineControlPoint = class {
|
|
|
26981
26767
|
|
|
26982
26768
|
// src/model/renderable/PointTextModel.ts
|
|
26983
26769
|
var Y6 = __toESM(require("yjs"), 1);
|
|
26984
|
-
var
|
|
26770
|
+
var import_forge_room2 = require("@netless/forge-room");
|
|
26985
26771
|
function _defineProperty10(e, r, t) {
|
|
26986
26772
|
return (r = _toPropertyKey10(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26987
26773
|
}
|
|
@@ -27018,18 +26804,9 @@ var PointTextModel = class extends ElementModel {
|
|
|
27018
26804
|
set fontFamily(value) {
|
|
27019
26805
|
this.root.set("font-family", value);
|
|
27020
26806
|
}
|
|
27021
|
-
|
|
27022
|
-
|
|
27023
|
-
return this.localPoints;
|
|
27024
|
-
}
|
|
27025
|
-
return this.points;
|
|
27026
|
-
}
|
|
27027
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27028
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26807
|
+
constructor(root, scope, liveCursor) {
|
|
26808
|
+
super(root, scope, liveCursor);
|
|
27029
26809
|
_defineProperty10(this, "item", null);
|
|
27030
|
-
_defineProperty10(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27031
|
-
_defineProperty10(this, "shouldUseLocalPoints", false);
|
|
27032
|
-
_defineProperty10(this, "localPointsPick", 2);
|
|
27033
26810
|
_defineProperty10(this, "handleTextPropChange", (event) => {
|
|
27034
26811
|
if (!this.item) {
|
|
27035
26812
|
return;
|
|
@@ -27046,27 +26823,21 @@ var PointTextModel = class extends ElementModel {
|
|
|
27046
26823
|
}
|
|
27047
26824
|
}
|
|
27048
26825
|
});
|
|
27049
|
-
if (
|
|
26826
|
+
if (!this.root.has("type")) {
|
|
27050
26827
|
this.root.set("type", "point-text");
|
|
27051
26828
|
}
|
|
27052
|
-
if (
|
|
26829
|
+
if (!this.root.has(ElementModel.KEYS.points)) {
|
|
27053
26830
|
this.root.set(ElementModel.KEYS.points, new Y6.Array());
|
|
27054
26831
|
}
|
|
27055
26832
|
this.root.observe(this.handleTextPropChange);
|
|
27056
|
-
|
|
27057
|
-
|
|
27058
|
-
|
|
27059
|
-
|
|
27060
|
-
|
|
27061
|
-
}
|
|
27062
|
-
}, 60);
|
|
26833
|
+
if (this.root.has("font-size")) {
|
|
26834
|
+
setTimeout(() => {
|
|
26835
|
+
this.updateTextPosition();
|
|
26836
|
+
}, 60);
|
|
26837
|
+
}
|
|
27063
26838
|
}
|
|
27064
26839
|
subDispose() {
|
|
27065
|
-
(0,
|
|
27066
|
-
}
|
|
27067
|
-
subBindObserver() {
|
|
27068
|
-
(0, import_forge_room3.removeObserver)(this.root, this.handleTextPropChange);
|
|
27069
|
-
this.root.observe(this.handleTextPropChange);
|
|
26840
|
+
(0, import_forge_room2.removeObserver)(this.root, this.handleTextPropChange);
|
|
27070
26841
|
}
|
|
27071
26842
|
liveCursorPoint() {
|
|
27072
26843
|
const points = this.points;
|
|
@@ -27081,11 +26852,10 @@ var PointTextModel = class extends ElementModel {
|
|
|
27081
26852
|
if (!this.item) {
|
|
27082
26853
|
return null;
|
|
27083
26854
|
}
|
|
27084
|
-
console.log("[][][] drawPoints", this.drawPoints);
|
|
27085
26855
|
const bounds = this.item.internalBounds;
|
|
27086
26856
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27087
|
-
const topLeft = new this.scope.Point(this.
|
|
27088
|
-
const topRight = new this.scope.Point(this.
|
|
26857
|
+
const topLeft = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
|
|
26858
|
+
const topRight = new this.scope.Point(this.points[0] + bounds.width, this.points[1]).transform(matrix);
|
|
27089
26859
|
let scaleX = topRight.getDistance(topLeft) / bounds.width;
|
|
27090
26860
|
scaleX = Number.isNaN(scaleX) ? 1 : scaleX;
|
|
27091
26861
|
const angle = topRight.subtract(topLeft).angle;
|
|
@@ -27173,22 +26943,13 @@ function _toPrimitive11(t, r) {
|
|
|
27173
26943
|
return ("string" === r ? String : Number)(t);
|
|
27174
26944
|
}
|
|
27175
26945
|
var TriangleModel = class extends ElementModel {
|
|
27176
|
-
|
|
27177
|
-
|
|
27178
|
-
return this.localPoints;
|
|
27179
|
-
}
|
|
27180
|
-
return this.points;
|
|
27181
|
-
}
|
|
27182
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27183
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26946
|
+
constructor(root, scope, liveCursor) {
|
|
26947
|
+
super(root, scope, liveCursor);
|
|
27184
26948
|
_defineProperty11(this, "item", null);
|
|
27185
|
-
|
|
27186
|
-
_defineProperty11(this, "shouldUseLocalPoints", true);
|
|
27187
|
-
_defineProperty11(this, "localPointsPick", 6);
|
|
27188
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26949
|
+
if (!this.root.has("type")) {
|
|
27189
26950
|
this.root.set("type", "triangle");
|
|
27190
26951
|
}
|
|
27191
|
-
if (
|
|
26952
|
+
if (!this.root.has("points")) {
|
|
27192
26953
|
this.root.set("points", new Y7.Array());
|
|
27193
26954
|
}
|
|
27194
26955
|
}
|
|
@@ -27220,9 +26981,9 @@ var TriangleModel = class extends ElementModel {
|
|
|
27220
26981
|
return;
|
|
27221
26982
|
}
|
|
27222
26983
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27223
|
-
const p1 = new this.scope.Point(this.
|
|
27224
|
-
const p2 = new this.scope.Point(this.
|
|
27225
|
-
const p3 = new this.scope.Point(this.
|
|
26984
|
+
const p1 = new this.scope.Point(this.points[0], this.points[1]).transform(matrix);
|
|
26985
|
+
const p2 = new this.scope.Point(this.points[2], this.points[3]).transform(matrix);
|
|
26986
|
+
const p3 = new this.scope.Point(this.points[4], this.points[5]).transform(matrix);
|
|
27226
26987
|
this.item.removeSegments();
|
|
27227
26988
|
this.item.moveTo(p1);
|
|
27228
26989
|
this.item.lineTo(p2);
|
|
@@ -27234,7 +26995,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
27234
26995
|
config.controlPoints.push({
|
|
27235
26996
|
name: "triangle",
|
|
27236
26997
|
getPosition: () => {
|
|
27237
|
-
const point = new this.scope.Point(this.
|
|
26998
|
+
const point = new this.scope.Point(this.points[0], this.points[1]);
|
|
27238
26999
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27239
27000
|
return this.scope.project.view.projectToView(point.transform(pointsMatrix));
|
|
27240
27001
|
},
|
|
@@ -27244,7 +27005,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
27244
27005
|
}
|
|
27245
27006
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27246
27007
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27247
|
-
const oldPoints = this.
|
|
27008
|
+
const oldPoints = this.points;
|
|
27248
27009
|
this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3], oldPoints[4], oldPoints[5]]);
|
|
27249
27010
|
}
|
|
27250
27011
|
});
|
|
@@ -27283,34 +27044,25 @@ function _toPrimitive12(t, r) {
|
|
|
27283
27044
|
return ("string" === r ? String : Number)(t);
|
|
27284
27045
|
}
|
|
27285
27046
|
var RectangleModel = class extends ElementModel {
|
|
27286
|
-
|
|
27287
|
-
|
|
27288
|
-
return this.localPoints;
|
|
27289
|
-
}
|
|
27290
|
-
return this.points;
|
|
27291
|
-
}
|
|
27292
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27293
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27047
|
+
constructor(root, scope, liveCursor) {
|
|
27048
|
+
super(root, scope, liveCursor);
|
|
27294
27049
|
_defineProperty12(this, "item", null);
|
|
27295
|
-
|
|
27296
|
-
_defineProperty12(this, "shouldUseLocalPoints", true);
|
|
27297
|
-
_defineProperty12(this, "localPointsPick", 4);
|
|
27298
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27050
|
+
if (!this.root.has("type")) {
|
|
27299
27051
|
this.root.set("type", "rectangle");
|
|
27300
27052
|
}
|
|
27301
|
-
if (
|
|
27053
|
+
if (!this.root.has("points")) {
|
|
27302
27054
|
const initPoints = new Y8.Array();
|
|
27303
27055
|
initPoints.push([0, 0, 0, 0]);
|
|
27304
27056
|
this.root.set("points", initPoints);
|
|
27305
27057
|
}
|
|
27306
|
-
if (
|
|
27058
|
+
if (!this.root.has("radius")) {
|
|
27307
27059
|
this.root.set("radius", 0);
|
|
27308
27060
|
}
|
|
27309
27061
|
}
|
|
27310
27062
|
subDispose() {
|
|
27311
27063
|
}
|
|
27312
27064
|
liveCursorPoint() {
|
|
27313
|
-
const points = this.
|
|
27065
|
+
const points = this.points;
|
|
27314
27066
|
if (points.length < 4) {
|
|
27315
27067
|
return null;
|
|
27316
27068
|
}
|
|
@@ -27318,7 +27070,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27318
27070
|
return new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
27319
27071
|
}
|
|
27320
27072
|
createSegments() {
|
|
27321
|
-
const [a2, b2, c, d] = this.
|
|
27073
|
+
const [a2, b2, c, d] = this.points;
|
|
27322
27074
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27323
27075
|
const maxRadius = this.maxRadiusLength();
|
|
27324
27076
|
const radius = this.root.get("radius") * maxRadius;
|
|
@@ -27383,7 +27135,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27383
27135
|
}
|
|
27384
27136
|
maxRadiusLength() {
|
|
27385
27137
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27386
|
-
const points = this.
|
|
27138
|
+
const points = this.points;
|
|
27387
27139
|
const topLeft = new this.scope.Point(points[0], points[1]).transform(pointsMatrix);
|
|
27388
27140
|
const topRight = new this.scope.Point(points[2], points[1]).transform(pointsMatrix);
|
|
27389
27141
|
const bottomLeft = new this.scope.Point(points[0], points[3]).transform(pointsMatrix);
|
|
@@ -27408,7 +27160,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27408
27160
|
name: "rect-radius",
|
|
27409
27161
|
getPosition: () => {
|
|
27410
27162
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27411
|
-
const points = this.
|
|
27163
|
+
const points = this.points;
|
|
27412
27164
|
const radius = this.root.get("radius") * this.maxRadiusLength();
|
|
27413
27165
|
let c1 = new this.scope.Point(points[0], points[1]).transform(matrix);
|
|
27414
27166
|
const c3 = new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
@@ -27427,7 +27179,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27427
27179
|
if (!this.item) {
|
|
27428
27180
|
return;
|
|
27429
27181
|
}
|
|
27430
|
-
const points = this.
|
|
27182
|
+
const points = this.points;
|
|
27431
27183
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27432
27184
|
const maxRadius = Math.min(points[2] - points[0], points[3] - points[1]) / 2;
|
|
27433
27185
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
@@ -27457,7 +27209,7 @@ var elementsUndoOrigin = "elementsUndoOrigin";
|
|
|
27457
27209
|
|
|
27458
27210
|
// src/model/renderable/EraserModel.ts
|
|
27459
27211
|
var Y9 = __toESM(require("yjs"), 1);
|
|
27460
|
-
var
|
|
27212
|
+
var import_lodash5 = __toESM(require_lodash(), 1);
|
|
27461
27213
|
function _defineProperty13(e, r, t) {
|
|
27462
27214
|
return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27463
27215
|
}
|
|
@@ -27476,23 +27228,14 @@ function _toPrimitive13(t, r) {
|
|
|
27476
27228
|
return ("string" === r ? String : Number)(t);
|
|
27477
27229
|
}
|
|
27478
27230
|
var EraserModel = class extends ElementModel {
|
|
27479
|
-
|
|
27480
|
-
|
|
27481
|
-
return this.localPoints;
|
|
27482
|
-
}
|
|
27483
|
-
return this.points;
|
|
27484
|
-
}
|
|
27485
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27486
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27231
|
+
constructor(root, scope, liveCursor) {
|
|
27232
|
+
super(root, scope, liveCursor);
|
|
27487
27233
|
_defineProperty13(this, "item", null);
|
|
27488
27234
|
_defineProperty13(this, "sliceBegin", 0);
|
|
27489
|
-
|
|
27490
|
-
_defineProperty13(this, "shouldUseLocalPoints", true);
|
|
27491
|
-
_defineProperty13(this, "localPointsPick", 4);
|
|
27492
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27235
|
+
if (!this.root.has("type")) {
|
|
27493
27236
|
this.root.set("type", "eraser");
|
|
27494
27237
|
}
|
|
27495
|
-
if (
|
|
27238
|
+
if (!this.root.has("points")) {
|
|
27496
27239
|
this.root.set("points", new Y9.Array());
|
|
27497
27240
|
}
|
|
27498
27241
|
}
|
|
@@ -27525,7 +27268,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27525
27268
|
return path;
|
|
27526
27269
|
}
|
|
27527
27270
|
parsePoints(points) {
|
|
27528
|
-
const groupPoints = (0,
|
|
27271
|
+
const groupPoints = (0, import_lodash5.chunk)(points, 2);
|
|
27529
27272
|
return ae(groupPoints, {
|
|
27530
27273
|
size: this.strokeWidth,
|
|
27531
27274
|
smoothing: 0.5,
|
|
@@ -27543,7 +27286,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27543
27286
|
});
|
|
27544
27287
|
}
|
|
27545
27288
|
matrixedPoints() {
|
|
27546
|
-
const currentPoints = (0,
|
|
27289
|
+
const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
|
|
27547
27290
|
return currentPoints.map((_ref) => {
|
|
27548
27291
|
let [x, y] = _ref;
|
|
27549
27292
|
return new this.scope.Point(x, y);
|
|
@@ -27571,11 +27314,11 @@ var EraserModel = class extends ElementModel {
|
|
|
27571
27314
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
27572
27315
|
this.onVectorUpdate();
|
|
27573
27316
|
this.item.onFrame = () => {
|
|
27574
|
-
if (!this.
|
|
27317
|
+
if (!this.points) {
|
|
27575
27318
|
return;
|
|
27576
27319
|
}
|
|
27577
|
-
if (this.
|
|
27578
|
-
this.sliceBegin = this.
|
|
27320
|
+
if (this.points.length / 2 > 50) {
|
|
27321
|
+
this.sliceBegin = this.points.length / 2 - 50;
|
|
27579
27322
|
}
|
|
27580
27323
|
};
|
|
27581
27324
|
}
|
|
@@ -27609,8 +27352,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27609
27352
|
|
|
27610
27353
|
// src/model/renderable/LaserPointerModel.ts
|
|
27611
27354
|
var Y10 = __toESM(require("yjs"), 1);
|
|
27612
|
-
var
|
|
27613
|
-
var import_forge_room4 = require("@netless/forge-room");
|
|
27355
|
+
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
27614
27356
|
function _defineProperty14(e, r, t) {
|
|
27615
27357
|
return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27616
27358
|
}
|
|
@@ -27629,18 +27371,24 @@ function _toPrimitive14(t, r) {
|
|
|
27629
27371
|
return ("string" === r ? String : Number)(t);
|
|
27630
27372
|
}
|
|
27631
27373
|
var LaserPointerModel = class extends ElementModel {
|
|
27632
|
-
constructor(clientId, root, scope, liveCursor, removeElement
|
|
27633
|
-
super(root, scope, liveCursor
|
|
27374
|
+
constructor(clientId, root, scope, liveCursor, removeElement) {
|
|
27375
|
+
super(root, scope, liveCursor);
|
|
27634
27376
|
_defineProperty14(this, "item", null);
|
|
27635
27377
|
_defineProperty14(this, "clientId", void 0);
|
|
27636
27378
|
_defineProperty14(this, "sliceBegin", 0);
|
|
27637
27379
|
_defineProperty14(this, "displayStrokeWidth", 8);
|
|
27638
27380
|
_defineProperty14(this, "cachedPoints", null);
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
|
|
27642
|
-
|
|
27643
|
-
|
|
27381
|
+
this.clientId = clientId;
|
|
27382
|
+
if (!this.root.has("type")) {
|
|
27383
|
+
this.root.set("type", "laser");
|
|
27384
|
+
}
|
|
27385
|
+
if (!this.root.has("points")) {
|
|
27386
|
+
this.root.set("points", new Y10.Array());
|
|
27387
|
+
}
|
|
27388
|
+
if (!this.root.has("removed")) {
|
|
27389
|
+
this.root.set("removed", false);
|
|
27390
|
+
}
|
|
27391
|
+
this.root.observe((event) => {
|
|
27644
27392
|
if (!this.item) {
|
|
27645
27393
|
return;
|
|
27646
27394
|
}
|
|
@@ -27658,31 +27406,13 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27658
27406
|
this.onVectorUpdate();
|
|
27659
27407
|
if (evt.count >= 30) {
|
|
27660
27408
|
if (this.ownerId === this.clientId) {
|
|
27661
|
-
|
|
27409
|
+
removeElement(this.uuid);
|
|
27662
27410
|
}
|
|
27663
27411
|
}
|
|
27664
27412
|
};
|
|
27665
27413
|
}
|
|
27666
27414
|
}
|
|
27667
27415
|
});
|
|
27668
|
-
this.clientId = clientId;
|
|
27669
|
-
this.removeElement = removeElement;
|
|
27670
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27671
|
-
this.root.set("type", "laser");
|
|
27672
|
-
}
|
|
27673
|
-
if (this.root.doc && !this.root.has("points")) {
|
|
27674
|
-
this.root.set("points", new Y10.Array());
|
|
27675
|
-
}
|
|
27676
|
-
if (this.root.doc && !this.root.has("removed")) {
|
|
27677
|
-
this.root.set("removed", false);
|
|
27678
|
-
}
|
|
27679
|
-
}
|
|
27680
|
-
subBindObserver() {
|
|
27681
|
-
(0, import_forge_room4.removeObserver)(this.root, this.handleLaserPropChange);
|
|
27682
|
-
this.root.observe(this.handleLaserPropChange);
|
|
27683
|
-
}
|
|
27684
|
-
subDispose() {
|
|
27685
|
-
(0, import_forge_room4.removeObserver)(this.root, this.handleLaserPropChange);
|
|
27686
27416
|
}
|
|
27687
27417
|
beginRemoveAnimate() {
|
|
27688
27418
|
this.root.set("removed", true);
|
|
@@ -27735,8 +27465,7 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27735
27465
|
matrixedPoints() {
|
|
27736
27466
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27737
27467
|
const points = this.cachedPoints || this.points;
|
|
27738
|
-
|
|
27739
|
-
const groupPoints = (0, import_lodash5.chunk)(points, 2).slice(this.sliceBegin);
|
|
27468
|
+
const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
|
|
27740
27469
|
return groupPoints.map((_ref) => {
|
|
27741
27470
|
let [x, y] = _ref;
|
|
27742
27471
|
return matrix.transform([x, y]);
|
|
@@ -27778,6 +27507,8 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27778
27507
|
onStyleKeyUpdate(_key) {
|
|
27779
27508
|
return;
|
|
27780
27509
|
}
|
|
27510
|
+
subDispose() {
|
|
27511
|
+
}
|
|
27781
27512
|
liveCursorPoint() {
|
|
27782
27513
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
27783
27514
|
if (yArray.length < 2) {
|
|
@@ -27790,7 +27521,7 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27790
27521
|
};
|
|
27791
27522
|
|
|
27792
27523
|
// src/WhitePermissions.ts
|
|
27793
|
-
var
|
|
27524
|
+
var import_forge_room3 = require("@netless/forge-room");
|
|
27794
27525
|
var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
27795
27526
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["none"] = 0] = "none";
|
|
27796
27527
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["draw"] = 1] = "draw";
|
|
@@ -27803,7 +27534,7 @@ var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
|
27803
27534
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["all"] = WhiteboardPermissionFlag2.draw | WhiteboardPermissionFlag2.editSelf | WhiteboardPermissionFlag2.editOthers | WhiteboardPermissionFlag2.deleteSelf | WhiteboardPermissionFlag2.deleteOthers | WhiteboardPermissionFlag2.mainView | WhiteboardPermissionFlag2.setOthersView] = "all";
|
|
27804
27535
|
return WhiteboardPermissionFlag2;
|
|
27805
27536
|
}({});
|
|
27806
|
-
var WhiteboardPermissions = class extends
|
|
27537
|
+
var WhiteboardPermissions = class extends import_forge_room3.AbstractApplicationPermissions {
|
|
27807
27538
|
/**
|
|
27808
27539
|
* 解析权限列表组合
|
|
27809
27540
|
* @param {number} value - 权限数字值
|
|
@@ -27816,7 +27547,7 @@ var WhiteboardPermissions = class extends import_forge_room5.AbstractApplication
|
|
|
27816
27547
|
|
|
27817
27548
|
// src/model/renderable/StraightLineModel.ts
|
|
27818
27549
|
var Y11 = __toESM(require("yjs"), 1);
|
|
27819
|
-
var
|
|
27550
|
+
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
27820
27551
|
function _defineProperty15(e, r, t) {
|
|
27821
27552
|
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27822
27553
|
}
|
|
@@ -27835,22 +27566,13 @@ function _toPrimitive15(t, r) {
|
|
|
27835
27566
|
return ("string" === r ? String : Number)(t);
|
|
27836
27567
|
}
|
|
27837
27568
|
var StraightLineModel = class extends ElementModel {
|
|
27838
|
-
|
|
27839
|
-
|
|
27840
|
-
return this.localPoints;
|
|
27841
|
-
}
|
|
27842
|
-
return this.points;
|
|
27843
|
-
}
|
|
27844
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27845
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27569
|
+
constructor(root, scope, liveCursor) {
|
|
27570
|
+
super(root, scope, liveCursor);
|
|
27846
27571
|
_defineProperty15(this, "item", null);
|
|
27847
|
-
|
|
27848
|
-
_defineProperty15(this, "shouldUseLocalPoints", true);
|
|
27849
|
-
_defineProperty15(this, "localPointsPick", 4);
|
|
27850
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27572
|
+
if (!this.root.has("type")) {
|
|
27851
27573
|
this.root.set("type", "line");
|
|
27852
27574
|
}
|
|
27853
|
-
if (
|
|
27575
|
+
if (!this.root.has("points")) {
|
|
27854
27576
|
this.root.set("points", new Y11.Array());
|
|
27855
27577
|
}
|
|
27856
27578
|
}
|
|
@@ -27875,7 +27597,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27875
27597
|
}
|
|
27876
27598
|
renderLine() {
|
|
27877
27599
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27878
|
-
const papperPoints = (0,
|
|
27600
|
+
const papperPoints = (0, import_lodash7.chunk)(this.points, 2).map((item) => {
|
|
27879
27601
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
27880
27602
|
});
|
|
27881
27603
|
const path = new this.scope.Path();
|
|
@@ -27897,7 +27619,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27897
27619
|
name: "line-start",
|
|
27898
27620
|
getPosition: () => {
|
|
27899
27621
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27900
|
-
const points = this.
|
|
27622
|
+
const points = this.points;
|
|
27901
27623
|
const start = new this.scope.Point(points[0], points[1]);
|
|
27902
27624
|
return this.scope.project.view.projectToView(start.transform(matrix));
|
|
27903
27625
|
},
|
|
@@ -27907,15 +27629,14 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27907
27629
|
}
|
|
27908
27630
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27909
27631
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27910
|
-
|
|
27911
|
-
this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3]]);
|
|
27632
|
+
this.setPoints([trPoint.x, trPoint.y, this.points[2], this.points[3]]);
|
|
27912
27633
|
}
|
|
27913
27634
|
});
|
|
27914
27635
|
cfg.controlPoints.push({
|
|
27915
27636
|
name: "line-end",
|
|
27916
27637
|
getPosition: () => {
|
|
27917
27638
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27918
|
-
const points = this.
|
|
27639
|
+
const points = this.points;
|
|
27919
27640
|
const end = new this.scope.Point(points[2], points[3]);
|
|
27920
27641
|
return this.scope.project.view.projectToView(end.transform(matrix));
|
|
27921
27642
|
},
|
|
@@ -27925,8 +27646,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27925
27646
|
}
|
|
27926
27647
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27927
27648
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27928
|
-
|
|
27929
|
-
this.setPoints([oldPoints[0], oldPoints[1], trPoint.x, trPoint.y]);
|
|
27649
|
+
this.setPoints([this.points[0], this.points[1], trPoint.x, trPoint.y]);
|
|
27930
27650
|
}
|
|
27931
27651
|
});
|
|
27932
27652
|
return cfg;
|
|
@@ -27972,13 +27692,10 @@ var ImageModel = class extends ElementModel {
|
|
|
27972
27692
|
get src() {
|
|
27973
27693
|
return this.root.get("src");
|
|
27974
27694
|
}
|
|
27975
|
-
constructor(root, scope, imageSets, liveCursor
|
|
27976
|
-
super(root, scope, liveCursor
|
|
27695
|
+
constructor(root, scope, imageSets, liveCursor) {
|
|
27696
|
+
super(root, scope, liveCursor);
|
|
27977
27697
|
_defineProperty16(this, "item", null);
|
|
27978
27698
|
_defineProperty16(this, "imageSets", void 0);
|
|
27979
|
-
_defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27980
|
-
_defineProperty16(this, "shouldUseLocalPoints", true);
|
|
27981
|
-
_defineProperty16(this, "localPointsPick", 4);
|
|
27982
27699
|
this.imageSets = imageSets;
|
|
27983
27700
|
if (!this.root.has("type")) {
|
|
27984
27701
|
this.root.set("type", "image");
|
|
@@ -28061,7 +27778,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28061
27778
|
get uuid() {
|
|
28062
27779
|
return (0, import_uuid.v4)().replace(/-/g, "");
|
|
28063
27780
|
}
|
|
28064
|
-
constructor(
|
|
27781
|
+
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
|
|
28065
27782
|
super();
|
|
28066
27783
|
_defineProperty17(this, "scope", void 0);
|
|
28067
27784
|
_defineProperty17(this, "toolbarModel", void 0);
|
|
@@ -28074,7 +27791,6 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28074
27791
|
_defineProperty17(this, "shadowEmitter", void 0);
|
|
28075
27792
|
_defineProperty17(this, "imageSets", void 0);
|
|
28076
27793
|
_defineProperty17(this, "liveCursor", void 0);
|
|
28077
|
-
_defineProperty17(this, "isPerformanceMode", void 0);
|
|
28078
27794
|
_defineProperty17(this, "onElementsChange", (event) => {
|
|
28079
27795
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
28080
27796
|
if (value.action === "add") {
|
|
@@ -28093,16 +27809,15 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28093
27809
|
}
|
|
28094
27810
|
}
|
|
28095
27811
|
});
|
|
28096
|
-
this.
|
|
28097
|
-
this.
|
|
28098
|
-
this.
|
|
28099
|
-
this.
|
|
28100
|
-
this.
|
|
28101
|
-
this.
|
|
28102
|
-
this.
|
|
28103
|
-
this.
|
|
28104
|
-
this.
|
|
28105
|
-
this.toolbarModel = options.toolbarModel;
|
|
27812
|
+
this.liveCursor = liveCursor;
|
|
27813
|
+
this.imageSets = imageSets;
|
|
27814
|
+
this.hasPermission = hasPermission;
|
|
27815
|
+
this.shadowEmitter = shadowEmitter;
|
|
27816
|
+
this.layerId = layerId;
|
|
27817
|
+
this.userManager = userManager;
|
|
27818
|
+
this.elements = elements;
|
|
27819
|
+
this.scope = scope;
|
|
27820
|
+
this.toolbarModel = toolbarModel;
|
|
28106
27821
|
this.elementModels = /* @__PURE__ */ new Map();
|
|
28107
27822
|
for (const key of this.elements.keys()) {
|
|
28108
27823
|
const type = this.elements.get(key)?.get("type");
|
|
@@ -28133,43 +27848,33 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28133
27848
|
convertToModel(yMap) {
|
|
28134
27849
|
const type = yMap.get("type");
|
|
28135
27850
|
let model = null;
|
|
28136
|
-
const uuid = yMap.get(ElementModel.KEYS.uuid);
|
|
28137
|
-
if (uuid) {
|
|
28138
|
-
const existingModel = this.elementModels.get(uuid);
|
|
28139
|
-
if (existingModel) {
|
|
28140
|
-
existingModel.shadowEmitter = this.shadowEmitter;
|
|
28141
|
-
existingModel.bindObserver();
|
|
28142
|
-
return existingModel;
|
|
28143
|
-
}
|
|
28144
|
-
}
|
|
28145
27851
|
if (type === "curve") {
|
|
28146
|
-
model = new CurveModel(yMap, this.scope, this.liveCursor
|
|
27852
|
+
model = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
28147
27853
|
} else if (["ellipse"].indexOf(type) >= 0) {
|
|
28148
|
-
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor
|
|
27854
|
+
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
28149
27855
|
} else if (type === "selector") {
|
|
28150
|
-
model = new SelectorModel(yMap, this.scope, this.liveCursor
|
|
27856
|
+
model = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
28151
27857
|
} else if (type === "arrow") {
|
|
28152
|
-
model = new LineModel(yMap, this.scope, this.liveCursor
|
|
27858
|
+
model = new LineModel(yMap, this.scope, this.liveCursor);
|
|
28153
27859
|
} else if (type === "line") {
|
|
28154
|
-
model = new StraightLineModel(yMap, this.scope, this.liveCursor
|
|
27860
|
+
model = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
28155
27861
|
} else if (type === "point-text") {
|
|
28156
|
-
model = new PointTextModel(yMap, this.scope, this.liveCursor
|
|
27862
|
+
model = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
28157
27863
|
} else if (type === "triangle") {
|
|
28158
|
-
model = new TriangleModel(yMap, this.scope, this.liveCursor
|
|
27864
|
+
model = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
28159
27865
|
} else if (type === "rectangle") {
|
|
28160
|
-
model = new RectangleModel(yMap, this.scope, this.liveCursor
|
|
27866
|
+
model = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
28161
27867
|
} else if (type === "eraser") {
|
|
28162
|
-
model = new EraserModel(yMap, this.scope, this.liveCursor
|
|
27868
|
+
model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
28163
27869
|
} else if (type === "laser") {
|
|
28164
|
-
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (
|
|
28165
|
-
this.removeElementItem(
|
|
28166
|
-
}
|
|
27870
|
+
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
27871
|
+
this.removeElementItem(uuid);
|
|
27872
|
+
});
|
|
28167
27873
|
} else if (type === "image") {
|
|
28168
|
-
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor
|
|
27874
|
+
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
28169
27875
|
}
|
|
28170
27876
|
if (model) {
|
|
28171
27877
|
model.shadowEmitter = this.shadowEmitter;
|
|
28172
|
-
model.bindObserver();
|
|
28173
27878
|
this.elementModels.set(model.uuid, model);
|
|
28174
27879
|
}
|
|
28175
27880
|
return model;
|
|
@@ -28183,7 +27888,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28183
27888
|
confirmPermission() {
|
|
28184
27889
|
const hasPermission = this.hasPermission(WhiteboardPermissionFlag.draw);
|
|
28185
27890
|
if (!hasPermission) {
|
|
28186
|
-
(0,
|
|
27891
|
+
(0, import_forge_room4.log)("[@netless/forge-whiteboard] no permission to draw", {}, "warn");
|
|
28187
27892
|
}
|
|
28188
27893
|
return hasPermission;
|
|
28189
27894
|
}
|
|
@@ -28200,8 +27905,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28200
27905
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28201
27906
|
this.elements.set(uuid, yMap);
|
|
28202
27907
|
}, elementsUndoOrigin);
|
|
28203
|
-
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor
|
|
28204
|
-
model.bindObserver();
|
|
27908
|
+
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
28205
27909
|
model.root.set("src", src);
|
|
28206
27910
|
const initMatrix = new this.scope.Matrix();
|
|
28207
27911
|
const center = this.scope.project.view.center;
|
|
@@ -28218,10 +27922,8 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28218
27922
|
return null;
|
|
28219
27923
|
}
|
|
28220
27924
|
const yMap = new Y12.Map();
|
|
28221
|
-
const uuid = this.uuid;
|
|
28222
|
-
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28223
|
-
this.elementModels.set(uuid, curveModel);
|
|
28224
27925
|
this.elements.doc?.transact(() => {
|
|
27926
|
+
const uuid = this.uuid;
|
|
28225
27927
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28226
27928
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28227
27929
|
yMap.set("type", "curve");
|
|
@@ -28234,7 +27936,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28234
27936
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28235
27937
|
this.elements.set(uuid, yMap);
|
|
28236
27938
|
}, elementsUndoOrigin);
|
|
28237
|
-
curveModel.
|
|
27939
|
+
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
28238
27940
|
this.initElement(curveModel);
|
|
28239
27941
|
return curveModel;
|
|
28240
27942
|
}
|
|
@@ -28243,17 +27945,11 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28243
27945
|
return null;
|
|
28244
27946
|
}
|
|
28245
27947
|
const yMap = new Y12.Map();
|
|
28246
|
-
const uuid = this.uuid;
|
|
28247
|
-
const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
|
|
28248
|
-
this.removeElementItem(uuid2);
|
|
28249
|
-
}, this.isPerformanceMode);
|
|
28250
|
-
this.elementModels.set(uuid, model);
|
|
28251
27948
|
this.elements.doc?.transact(() => {
|
|
27949
|
+
const uuid = this.uuid;
|
|
28252
27950
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28253
27951
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28254
27952
|
yMap.set("type", "laser");
|
|
28255
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28256
|
-
yMap.set("removed", false);
|
|
28257
27953
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28258
27954
|
yMap.set(ElementModel.KEYS.strokeWidth, 8);
|
|
28259
27955
|
yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
|
|
@@ -28261,8 +27957,9 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28261
27957
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28262
27958
|
this.elements.set(uuid, yMap);
|
|
28263
27959
|
}, elementsUndoOrigin);
|
|
28264
|
-
model.
|
|
28265
|
-
|
|
27960
|
+
const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
27961
|
+
this.removeElementItem(uuid);
|
|
27962
|
+
});
|
|
28266
27963
|
return model;
|
|
28267
27964
|
}
|
|
28268
27965
|
createEraser() {
|
|
@@ -28270,14 +27967,11 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28270
27967
|
return null;
|
|
28271
27968
|
}
|
|
28272
27969
|
const yMap = new Y12.Map();
|
|
28273
|
-
const uuid = this.uuid;
|
|
28274
|
-
const model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28275
|
-
this.elementModels.set(uuid, model);
|
|
28276
27970
|
this.elements.doc?.transact(() => {
|
|
27971
|
+
const uuid = this.uuid;
|
|
28277
27972
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28278
27973
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28279
27974
|
yMap.set("type", "eraser");
|
|
28280
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28281
27975
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28282
27976
|
yMap.set(ElementModel.KEYS.strokeWidth, 4);
|
|
28283
27977
|
yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
|
|
@@ -28285,7 +27979,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28285
27979
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28286
27980
|
this.elements.set(uuid, yMap);
|
|
28287
27981
|
}, elementsUndoOrigin);
|
|
28288
|
-
model.
|
|
27982
|
+
const model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
28289
27983
|
return model;
|
|
28290
27984
|
}
|
|
28291
27985
|
createTriangle(shadow) {
|
|
@@ -28293,54 +27987,45 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28293
27987
|
return null;
|
|
28294
27988
|
}
|
|
28295
27989
|
const yMap = new Y12.Map();
|
|
28296
|
-
const uuid = this.uuid;
|
|
28297
|
-
const triangleModel = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28298
|
-
this.elementModels.set(uuid, triangleModel);
|
|
28299
27990
|
this.elements.doc?.transact(() => {
|
|
27991
|
+
const uuid = this.uuid;
|
|
28300
27992
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28301
27993
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28302
27994
|
yMap.set("type", "triangle");
|
|
28303
27995
|
if (shadow) {
|
|
28304
27996
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28305
27997
|
}
|
|
28306
|
-
yMap.set("points", new Y12.Array());
|
|
28307
27998
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28308
27999
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28309
28000
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28310
28001
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28311
28002
|
this.elements.set(uuid, yMap);
|
|
28312
28003
|
}, elementsUndoOrigin);
|
|
28313
|
-
|
|
28314
|
-
this.initElement(
|
|
28315
|
-
|
|
28316
|
-
return
|
|
28004
|
+
const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
28005
|
+
this.initElement(triangle);
|
|
28006
|
+
triangle.dashArray = this.toolbarModel.dashArray;
|
|
28007
|
+
return triangle;
|
|
28317
28008
|
}
|
|
28318
28009
|
createRectangle(shadow) {
|
|
28319
28010
|
if (!this.confirmPermission()) {
|
|
28320
28011
|
return null;
|
|
28321
28012
|
}
|
|
28322
28013
|
const yMap = new Y12.Map();
|
|
28323
|
-
const uuid = this.uuid;
|
|
28324
|
-
const rect = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28325
|
-
this.elementModels.set(uuid, rect);
|
|
28326
28014
|
this.elements.doc?.transact(() => {
|
|
28015
|
+
const uuid = this.uuid;
|
|
28327
28016
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28328
28017
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28329
28018
|
yMap.set("type", "rectangle");
|
|
28330
28019
|
if (shadow) {
|
|
28331
28020
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28332
28021
|
}
|
|
28333
|
-
const initPoints = new Y12.Array();
|
|
28334
|
-
initPoints.push([0, 0, 0, 0]);
|
|
28335
|
-
yMap.set("points", initPoints);
|
|
28336
|
-
yMap.set("radius", 0);
|
|
28337
28022
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28338
28023
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28339
28024
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28340
28025
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28341
28026
|
this.elements.set(uuid, yMap);
|
|
28342
28027
|
}, elementsUndoOrigin);
|
|
28343
|
-
rect.
|
|
28028
|
+
const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
28344
28029
|
this.initElement(rect);
|
|
28345
28030
|
rect.dashArray = this.toolbarModel.dashArray;
|
|
28346
28031
|
return rect;
|
|
@@ -28350,24 +28035,21 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28350
28035
|
return null;
|
|
28351
28036
|
}
|
|
28352
28037
|
const yMap = new Y12.Map();
|
|
28353
|
-
const uuid = this.uuid;
|
|
28354
|
-
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
|
|
28355
|
-
this.elementModels.set(uuid, segmentsModel);
|
|
28356
28038
|
this.elements.doc?.transact(() => {
|
|
28039
|
+
const uuid = this.uuid;
|
|
28357
28040
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28358
28041
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28359
28042
|
yMap.set("type", type);
|
|
28360
28043
|
if (shadow) {
|
|
28361
28044
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28362
28045
|
}
|
|
28363
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28364
28046
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28365
28047
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28366
28048
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28367
28049
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28368
28050
|
this.elements.set(uuid, yMap);
|
|
28369
28051
|
}, elementsUndoOrigin);
|
|
28370
|
-
segmentsModel.
|
|
28052
|
+
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
28371
28053
|
this.initElement(segmentsModel);
|
|
28372
28054
|
segmentsModel.dashArray = this.toolbarModel.dashArray;
|
|
28373
28055
|
return segmentsModel;
|
|
@@ -28378,21 +28060,16 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28378
28060
|
return null;
|
|
28379
28061
|
}
|
|
28380
28062
|
const yMap = new Y12.Map();
|
|
28381
|
-
const uuid = this.uuid;
|
|
28382
|
-
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28383
|
-
this.elementModels.set(uuid, selectorModel);
|
|
28384
28063
|
this.elements.doc?.transact(() => {
|
|
28064
|
+
const uuid = this.uuid;
|
|
28385
28065
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28386
28066
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28387
28067
|
yMap.set("type", "selector");
|
|
28388
|
-
const initPoints = new Y12.Array();
|
|
28389
|
-
initPoints.push([0, 0, 0, 0]);
|
|
28390
|
-
yMap.set(ElementModel.KEYS.points, initPoints);
|
|
28391
28068
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28392
28069
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28393
28070
|
this.elements.set(uuid, yMap);
|
|
28394
28071
|
}, elementsUndoOrigin);
|
|
28395
|
-
selectorModel.
|
|
28072
|
+
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
28396
28073
|
selectorModel.shadow = "layer";
|
|
28397
28074
|
return selectorModel;
|
|
28398
28075
|
}
|
|
@@ -28401,24 +28078,21 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28401
28078
|
return null;
|
|
28402
28079
|
}
|
|
28403
28080
|
const yMap = new Y12.Map();
|
|
28404
|
-
const uuid = this.uuid;
|
|
28405
|
-
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28406
|
-
this.elementModels.set(uuid, straightLineModel);
|
|
28407
28081
|
this.elements.doc?.transact(() => {
|
|
28082
|
+
const uuid = this.uuid;
|
|
28408
28083
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28409
28084
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28410
28085
|
yMap.set("type", "line");
|
|
28411
28086
|
if (shadow) {
|
|
28412
28087
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28413
28088
|
}
|
|
28414
|
-
yMap.set("points", new Y12.Array());
|
|
28415
28089
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28416
28090
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28417
28091
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28418
28092
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28419
28093
|
this.elements.set(uuid, yMap);
|
|
28420
28094
|
}, elementsUndoOrigin);
|
|
28421
|
-
straightLineModel.
|
|
28095
|
+
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
28422
28096
|
this.initElement(straightLineModel);
|
|
28423
28097
|
straightLineModel.dashArray = this.toolbarModel.dashArray;
|
|
28424
28098
|
return straightLineModel;
|
|
@@ -28428,26 +28102,21 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28428
28102
|
return null;
|
|
28429
28103
|
}
|
|
28430
28104
|
const yMap = new Y12.Map();
|
|
28431
|
-
const uuid = this.uuid;
|
|
28432
|
-
const lineModel = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28433
|
-
this.elementModels.set(uuid, lineModel);
|
|
28434
28105
|
this.elements.doc?.transact(() => {
|
|
28106
|
+
const uuid = this.uuid;
|
|
28435
28107
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28436
28108
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28437
28109
|
yMap.set("type", "arrow");
|
|
28438
28110
|
if (shadow) {
|
|
28439
28111
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28440
28112
|
}
|
|
28441
|
-
yMap.set("headArrow", "none");
|
|
28442
|
-
yMap.set("tailArrow", "normal");
|
|
28443
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28444
28113
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28445
28114
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28446
28115
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28447
28116
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28448
28117
|
this.elements.set(uuid, yMap);
|
|
28449
28118
|
}, elementsUndoOrigin);
|
|
28450
|
-
lineModel.
|
|
28119
|
+
const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
|
|
28451
28120
|
this.initElement(lineModel);
|
|
28452
28121
|
lineModel.dashArray = this.toolbarModel.dashArray;
|
|
28453
28122
|
return lineModel;
|
|
@@ -28457,24 +28126,21 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28457
28126
|
return null;
|
|
28458
28127
|
}
|
|
28459
28128
|
const yMap = new Y12.Map();
|
|
28460
|
-
const uuid = this.uuid;
|
|
28461
|
-
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28462
|
-
this.elementModels.set(uuid, pointTextModel);
|
|
28463
28129
|
this.elements.doc?.transact(() => {
|
|
28130
|
+
const uuid = this.uuid;
|
|
28464
28131
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28465
28132
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28466
28133
|
yMap.set("type", "point-text");
|
|
28467
28134
|
if (shadow) {
|
|
28468
28135
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28469
28136
|
}
|
|
28470
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28471
28137
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28472
28138
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28473
28139
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28474
28140
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28475
28141
|
this.elements.set(uuid, yMap);
|
|
28476
28142
|
}, elementsUndoOrigin);
|
|
28477
|
-
pointTextModel.
|
|
28143
|
+
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
28478
28144
|
pointTextModel.setPoints([x, y]);
|
|
28479
28145
|
pointTextModel.fontSize = this.toolbarModel.fontSize;
|
|
28480
28146
|
pointTextModel.fontFamily = this.toolbarModel.fontFamily;
|
|
@@ -28497,19 +28163,18 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28497
28163
|
});
|
|
28498
28164
|
}
|
|
28499
28165
|
dispose(clearElements) {
|
|
28500
|
-
(0,
|
|
28166
|
+
(0, import_forge_room4.removeObserver)(this.elements, this.onElementsChange);
|
|
28501
28167
|
if (clearElements) {
|
|
28502
28168
|
this.elements.clear();
|
|
28503
28169
|
}
|
|
28504
28170
|
Array.from(this.elementModels.values()).forEach((model) => {
|
|
28505
28171
|
model.dispose();
|
|
28506
|
-
model.disposeObserver();
|
|
28507
28172
|
});
|
|
28508
28173
|
}
|
|
28509
28174
|
};
|
|
28510
28175
|
|
|
28511
28176
|
// src/utils/Recognizer.ts
|
|
28512
|
-
var
|
|
28177
|
+
var import_lodash8 = __toESM(require_lodash(), 1);
|
|
28513
28178
|
|
|
28514
28179
|
// src/utils/UnistrokeRecognizer.js
|
|
28515
28180
|
function Point(x, y) {
|
|
@@ -28756,7 +28421,7 @@ var Recognizer = class {
|
|
|
28756
28421
|
let maxX = -Number.MAX_VALUE;
|
|
28757
28422
|
let minY = Number.MAX_VALUE;
|
|
28758
28423
|
let maxY = -Number.MAX_VALUE;
|
|
28759
|
-
const result = this.dollar.Recognize((0,
|
|
28424
|
+
const result = this.dollar.Recognize((0, import_lodash8.chunk)(points, 2).map((v) => {
|
|
28760
28425
|
minX = Math.min(minX, v[0]);
|
|
28761
28426
|
maxX = Math.max(maxX, v[0]);
|
|
28762
28427
|
minY = Math.min(minY, v[1]);
|
|
@@ -28800,24 +28465,11 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28800
28465
|
_defineProperty19(this, "elementModel", null);
|
|
28801
28466
|
_defineProperty19(this, "recognizer", new Recognizer());
|
|
28802
28467
|
_defineProperty19(this, "pointCount", 0);
|
|
28803
|
-
_defineProperty19(this, "pendingPoints", []);
|
|
28804
|
-
_defineProperty19(this, "flushRafId", 0);
|
|
28805
28468
|
_defineProperty19(this, "showLiveCursor", true);
|
|
28806
|
-
|
|
28807
|
-
this.flushRafId = 0;
|
|
28808
|
-
if (this.elementModel && this.pendingPoints.length > 0) {
|
|
28809
|
-
this.elementModel.appendPoints(this.pendingPoints);
|
|
28810
|
-
this.pendingPoints = [];
|
|
28811
|
-
}
|
|
28812
|
-
});
|
|
28469
|
+
this.tool.minDistance = 5;
|
|
28813
28470
|
}
|
|
28814
28471
|
onMouseDown(_event) {
|
|
28815
28472
|
this.pointCount = 0;
|
|
28816
|
-
this.pendingPoints = [];
|
|
28817
|
-
if (this.flushRafId) {
|
|
28818
|
-
cancelAnimationFrame(this.flushRafId);
|
|
28819
|
-
this.flushRafId = 0;
|
|
28820
|
-
}
|
|
28821
28473
|
if (this.elementModel) {
|
|
28822
28474
|
this.elementModel.dispose();
|
|
28823
28475
|
}
|
|
@@ -28832,38 +28484,27 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28832
28484
|
if (this.pointCount > 1024) {
|
|
28833
28485
|
return;
|
|
28834
28486
|
}
|
|
28835
|
-
const MIN_DISTANCE =
|
|
28487
|
+
const MIN_DISTANCE = 4;
|
|
28836
28488
|
if (this.elementModel) {
|
|
28837
|
-
|
|
28838
|
-
let
|
|
28839
|
-
|
|
28840
|
-
|
|
28841
|
-
|
|
28842
|
-
|
|
28843
|
-
|
|
28844
|
-
|
|
28845
|
-
|
|
28846
|
-
|
|
28847
|
-
}
|
|
28489
|
+
const len = this.elementModel.points.length;
|
|
28490
|
+
let last = {
|
|
28491
|
+
x: 0,
|
|
28492
|
+
y: 0
|
|
28493
|
+
};
|
|
28494
|
+
if (len >= 2) {
|
|
28495
|
+
last = {
|
|
28496
|
+
x: this.elementModel.points[len - 2],
|
|
28497
|
+
y: this.elementModel.points[len - 1]
|
|
28498
|
+
};
|
|
28848
28499
|
}
|
|
28849
|
-
const dist = Math.max(Math.abs(
|
|
28500
|
+
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
28850
28501
|
if (dist >= MIN_DISTANCE) {
|
|
28851
28502
|
this.pointCount += 1;
|
|
28852
|
-
|
|
28853
|
-
const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
|
|
28854
|
-
this.pendingPoints.push(event.point.x, event.point.y, pressure);
|
|
28855
|
-
if (!this.flushRafId) {
|
|
28856
|
-
this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
|
|
28857
|
-
}
|
|
28503
|
+
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
28858
28504
|
}
|
|
28859
28505
|
}
|
|
28860
28506
|
}
|
|
28861
28507
|
onMouseUp(event) {
|
|
28862
|
-
if (this.flushRafId) {
|
|
28863
|
-
cancelAnimationFrame(this.flushRafId);
|
|
28864
|
-
this.flushRafId = 0;
|
|
28865
|
-
}
|
|
28866
|
-
this.flushPendingPoints();
|
|
28867
28508
|
this.modelGetter().then((model) => {
|
|
28868
28509
|
if (!model) {
|
|
28869
28510
|
return;
|
|
@@ -28964,7 +28605,7 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28964
28605
|
|
|
28965
28606
|
// src/model/ToolbarModel.ts
|
|
28966
28607
|
var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
|
|
28967
|
-
var
|
|
28608
|
+
var import_forge_room5 = require("@netless/forge-room");
|
|
28968
28609
|
function _defineProperty21(e, r, t) {
|
|
28969
28610
|
return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28970
28611
|
}
|
|
@@ -29061,7 +28702,7 @@ var ToolbarModel = class extends import_eventemitter32.default {
|
|
|
29061
28702
|
});
|
|
29062
28703
|
}
|
|
29063
28704
|
dispose() {
|
|
29064
|
-
(0,
|
|
28705
|
+
(0, import_forge_room5.removeObserver)(this.root, this.handleRootUpdate);
|
|
29065
28706
|
this.removeAllListeners();
|
|
29066
28707
|
}
|
|
29067
28708
|
};
|
|
@@ -29160,7 +28801,7 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
29160
28801
|
// src/model/SelectElementsModel.ts
|
|
29161
28802
|
var Y13 = __toESM(require("yjs"), 1);
|
|
29162
28803
|
var import_eventemitter33 = __toESM(require("eventemitter3"), 1);
|
|
29163
|
-
var
|
|
28804
|
+
var import_forge_room6 = require("@netless/forge-room");
|
|
29164
28805
|
|
|
29165
28806
|
// src/WhiteboardKeys.ts
|
|
29166
28807
|
var WhiteboardKeys = {
|
|
@@ -29210,7 +28851,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29210
28851
|
}
|
|
29211
28852
|
const cb = this.observers.get(user.id);
|
|
29212
28853
|
if (cb) {
|
|
29213
|
-
(0,
|
|
28854
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
29214
28855
|
this.observers.delete(user.id);
|
|
29215
28856
|
}
|
|
29216
28857
|
});
|
|
@@ -29219,7 +28860,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29219
28860
|
this.handleUserSelectElementsChange(user.id, evts);
|
|
29220
28861
|
};
|
|
29221
28862
|
if (this.observers.has(user.id)) {
|
|
29222
|
-
(0,
|
|
28863
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
29223
28864
|
this.observers.delete(user.id);
|
|
29224
28865
|
}
|
|
29225
28866
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
@@ -29242,7 +28883,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29242
28883
|
this.handleUserSelectElementsChange(userId, evts);
|
|
29243
28884
|
};
|
|
29244
28885
|
if (this.observers.has(userId)) {
|
|
29245
|
-
(0,
|
|
28886
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(userId), this.observers.get(userId));
|
|
29246
28887
|
}
|
|
29247
28888
|
this.requestUserMap(userId).observeDeep(observer);
|
|
29248
28889
|
this.observers.set(userId, observer);
|
|
@@ -29306,7 +28947,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29306
28947
|
}
|
|
29307
28948
|
dispose() {
|
|
29308
28949
|
for (const [key, value] of this.observers.entries()) {
|
|
29309
|
-
(0,
|
|
28950
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(key), value);
|
|
29310
28951
|
}
|
|
29311
28952
|
this.observers.clear();
|
|
29312
28953
|
this.userManager.off("leave", this.handleUserLeave);
|
|
@@ -29995,7 +29636,6 @@ var Editor = class extends import_eventemitter35.default {
|
|
|
29995
29636
|
this.shadowContainer.remove();
|
|
29996
29637
|
this.shadowScope.project.activeLayer.addChild(this.shadowContainer);
|
|
29997
29638
|
this.targets.forEach((model) => {
|
|
29998
|
-
console.log("[][][] translateShadow model", model.root._dEH);
|
|
29999
29639
|
model.shadow = this.shadowContainer.data.uuid;
|
|
30000
29640
|
});
|
|
30001
29641
|
}
|
|
@@ -30222,7 +29862,7 @@ var Gesture = class extends import_eventemitter36.default {
|
|
|
30222
29862
|
};
|
|
30223
29863
|
|
|
30224
29864
|
// src/Camera.ts
|
|
30225
|
-
var
|
|
29865
|
+
var import_forge_room7 = require("@netless/forge-room");
|
|
30226
29866
|
function _defineProperty28(e, r, t) {
|
|
30227
29867
|
return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30228
29868
|
}
|
|
@@ -30299,14 +29939,14 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30299
29939
|
}
|
|
30300
29940
|
const cb = this.observers.get(user.id);
|
|
30301
29941
|
if (cb) {
|
|
30302
|
-
(0,
|
|
29942
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(user.id), cb);
|
|
30303
29943
|
}
|
|
30304
29944
|
});
|
|
30305
29945
|
_defineProperty28(this, "handleUserJoin", (user) => {
|
|
30306
29946
|
if (this.observers.has(user.id)) {
|
|
30307
29947
|
const cb = this.observers.get(user.id);
|
|
30308
29948
|
if (cb) {
|
|
30309
|
-
(0,
|
|
29949
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(user.id), cb);
|
|
30310
29950
|
this.observers.delete(user.id);
|
|
30311
29951
|
}
|
|
30312
29952
|
}
|
|
@@ -30418,7 +30058,7 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30418
30058
|
this.handleViewMatrixUpdate(userId, evt);
|
|
30419
30059
|
};
|
|
30420
30060
|
if (this.observers.has(userId)) {
|
|
30421
|
-
(0,
|
|
30061
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(userId), observer);
|
|
30422
30062
|
}
|
|
30423
30063
|
this.requestUserMap(userId).observe(observer);
|
|
30424
30064
|
this.observers.set(userId, observer);
|
|
@@ -30615,10 +30255,10 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30615
30255
|
Array.from(this.observers.keys()).forEach((userId) => {
|
|
30616
30256
|
const cb = this.observers.get(userId);
|
|
30617
30257
|
if (cb) {
|
|
30618
|
-
(0,
|
|
30258
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(userId), cb);
|
|
30619
30259
|
}
|
|
30620
30260
|
});
|
|
30621
|
-
(0,
|
|
30261
|
+
(0, import_forge_room7.removeObserver)(this.whiteboardAttrsMap, this.handleMainCameraChange);
|
|
30622
30262
|
this.userManager.off("join", this.handleUserJoin);
|
|
30623
30263
|
this.userManager.off("leave", this.handleUserLeave);
|
|
30624
30264
|
this.gesture.removeAllListeners();
|
|
@@ -30789,8 +30429,6 @@ var Whiteboard = class extends import_eventemitter38.default {
|
|
|
30789
30429
|
_defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
|
|
30790
30430
|
_defineProperty31(this, "getElementAttribute", void 0);
|
|
30791
30431
|
_defineProperty31(this, "setElementAttribute", void 0);
|
|
30792
|
-
_defineProperty31(this, "setPerformanceMode", void 0);
|
|
30793
|
-
_defineProperty31(this, "isPerformanceMode", void 0);
|
|
30794
30432
|
_defineProperty31(this, "removeElement", void 0);
|
|
30795
30433
|
_defineProperty31(this, "getCurrentTool", void 0);
|
|
30796
30434
|
_defineProperty31(this, "setCurrentTool", void 0);
|
|
@@ -30911,7 +30549,7 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
30911
30549
|
// src/model/TrashedElementsModel.ts
|
|
30912
30550
|
var Y14 = __toESM(require("yjs"), 1);
|
|
30913
30551
|
var import_eventemitter39 = __toESM(require("eventemitter3"), 1);
|
|
30914
|
-
var
|
|
30552
|
+
var import_forge_room8 = require("@netless/forge-room");
|
|
30915
30553
|
function _defineProperty33(e, r, t) {
|
|
30916
30554
|
return (r = _toPropertyKey33(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30917
30555
|
}
|
|
@@ -30948,14 +30586,14 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30948
30586
|
}
|
|
30949
30587
|
const cb = this.observers.get(user.id);
|
|
30950
30588
|
if (cb) {
|
|
30951
|
-
(0,
|
|
30589
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
30952
30590
|
}
|
|
30953
30591
|
});
|
|
30954
30592
|
_defineProperty33(this, "handleUserJoin", (user) => {
|
|
30955
30593
|
if (this.observers.has(user.id)) {
|
|
30956
30594
|
const cb = this.observers.get(user.id);
|
|
30957
30595
|
if (cb) {
|
|
30958
|
-
(0,
|
|
30596
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
30959
30597
|
this.observers.delete(user.id);
|
|
30960
30598
|
}
|
|
30961
30599
|
}
|
|
@@ -30963,7 +30601,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30963
30601
|
this.handleUserTrashElementsChange(user.id, evts);
|
|
30964
30602
|
};
|
|
30965
30603
|
if (this.observers.has(user.id)) {
|
|
30966
|
-
(0,
|
|
30604
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
30967
30605
|
}
|
|
30968
30606
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
30969
30607
|
this.observers.set(user.id, observer);
|
|
@@ -30977,7 +30615,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30977
30615
|
this.handleUserTrashElementsChange(userId, evts);
|
|
30978
30616
|
};
|
|
30979
30617
|
if (this.observers.has(userId)) {
|
|
30980
|
-
(0,
|
|
30618
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(userId), userId);
|
|
30981
30619
|
}
|
|
30982
30620
|
this.requestUserMap(userId).observeDeep(observer);
|
|
30983
30621
|
this.observers.set(userId, observer);
|
|
@@ -31039,7 +30677,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
31039
30677
|
}
|
|
31040
30678
|
dispose() {
|
|
31041
30679
|
for (const [key, value] of this.observers.entries()) {
|
|
31042
|
-
(0,
|
|
30680
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(key), value);
|
|
31043
30681
|
}
|
|
31044
30682
|
this.observers.clear();
|
|
31045
30683
|
this.userManager.off("leave", this.handleUserLeave);
|
|
@@ -31089,24 +30727,9 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
31089
30727
|
if (this.pointCount > 1024) {
|
|
31090
30728
|
return;
|
|
31091
30729
|
}
|
|
31092
|
-
const MIN_DISTANCE = 4;
|
|
31093
30730
|
if (this.elementModel) {
|
|
31094
|
-
|
|
31095
|
-
|
|
31096
|
-
x: 0,
|
|
31097
|
-
y: 0
|
|
31098
|
-
};
|
|
31099
|
-
if (len >= 2) {
|
|
31100
|
-
last = {
|
|
31101
|
-
x: this.elementModel.points[len - 2],
|
|
31102
|
-
y: this.elementModel.points[len - 1]
|
|
31103
|
-
};
|
|
31104
|
-
}
|
|
31105
|
-
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
31106
|
-
if (dist >= MIN_DISTANCE) {
|
|
31107
|
-
this.pointCount += 1;
|
|
31108
|
-
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
31109
|
-
}
|
|
30731
|
+
this.pointCount += 1;
|
|
30732
|
+
this.elementModel.appendPoints([event.point.x, event.point.y]);
|
|
31110
30733
|
}
|
|
31111
30734
|
}
|
|
31112
30735
|
onMouseUp(_event) {
|
|
@@ -31118,7 +30741,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
31118
30741
|
|
|
31119
30742
|
// src/model/PageModel.ts
|
|
31120
30743
|
var import_eventemitter310 = __toESM(require("eventemitter3"), 1);
|
|
31121
|
-
var
|
|
30744
|
+
var import_forge_room9 = require("@netless/forge-room");
|
|
31122
30745
|
function _defineProperty35(e, r, t) {
|
|
31123
30746
|
return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
31124
30747
|
}
|
|
@@ -31151,7 +30774,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31151
30774
|
}
|
|
31152
30775
|
const cb = this.observers.get(user.id);
|
|
31153
30776
|
if (cb) {
|
|
31154
|
-
(0,
|
|
30777
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(user.id), cb);
|
|
31155
30778
|
}
|
|
31156
30779
|
});
|
|
31157
30780
|
_defineProperty35(this, "handleUserJoin", (user) => {
|
|
@@ -31165,7 +30788,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31165
30788
|
if (cameraMode === "main") {
|
|
31166
30789
|
const targetPage = this.whiteboardAttrsMap.get(WhiteboardKeys.currentPage);
|
|
31167
30790
|
if (!this.pageMap.has(targetPage) && targetPage !== "_i_") {
|
|
31168
|
-
(0,
|
|
30791
|
+
(0, import_forge_room9.log)(`main page {${targetPage}} not found.`, {}, "error");
|
|
31169
30792
|
return;
|
|
31170
30793
|
}
|
|
31171
30794
|
this.requestUserMap(this.userManager.selfId).set(WhiteboardKeys.currentPage, targetPage);
|
|
@@ -31212,7 +30835,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31212
30835
|
if (this.observers.has(userId)) {
|
|
31213
30836
|
const cb = this.observers.get(userId);
|
|
31214
30837
|
if (cb) {
|
|
31215
|
-
(0,
|
|
30838
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(userId), cb);
|
|
31216
30839
|
this.observers.delete(userId);
|
|
31217
30840
|
}
|
|
31218
30841
|
}
|
|
@@ -31301,12 +30924,12 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31301
30924
|
dispose() {
|
|
31302
30925
|
for (const entry of this.observers.entries()) {
|
|
31303
30926
|
const [userId, observer] = entry;
|
|
31304
|
-
(0,
|
|
30927
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(userId), observer);
|
|
31305
30928
|
}
|
|
31306
30929
|
this.userManager.off("join", this.handleUserJoin);
|
|
31307
30930
|
this.userManager.off("leave", this.handleUserLeave);
|
|
31308
|
-
(0,
|
|
31309
|
-
(0,
|
|
30931
|
+
(0, import_forge_room9.removeObserver)(this.whiteboardAttrsMap, this.handleMainPageChange);
|
|
30932
|
+
(0, import_forge_room9.removeObserver)(this.pageMap, this.handlePageMapChange);
|
|
31310
30933
|
}
|
|
31311
30934
|
};
|
|
31312
30935
|
|
|
@@ -31321,8 +30944,8 @@ async function waitUntil(fn, timeout) {
|
|
|
31321
30944
|
|
|
31322
30945
|
// src/IndexedNavigation.ts
|
|
31323
30946
|
var import_eventemitter311 = __toESM(require("eventemitter3"), 1);
|
|
31324
|
-
var
|
|
31325
|
-
var
|
|
30947
|
+
var import_forge_room10 = require("@netless/forge-room");
|
|
30948
|
+
var import_forge_room11 = require("@netless/forge-room");
|
|
31326
30949
|
function _defineProperty36(e, r, t) {
|
|
31327
30950
|
return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
31328
30951
|
}
|
|
@@ -31349,7 +30972,7 @@ var IndexedNavigation = class extends import_eventemitter311.default {
|
|
|
31349
30972
|
return this.list[key] && this.list[key].prev === "";
|
|
31350
30973
|
});
|
|
31351
30974
|
if (!headId) {
|
|
31352
|
-
(0,
|
|
30975
|
+
(0, import_forge_room10.log)("indexed navigation confusion", {
|
|
31353
30976
|
list: JSON.stringify(this.list)
|
|
31354
30977
|
}, "error");
|
|
31355
30978
|
throw new Error("indexed navigation confusion");
|
|
@@ -31665,7 +31288,7 @@ var IndexedNavigation = class extends import_eventemitter311.default {
|
|
|
31665
31288
|
}
|
|
31666
31289
|
}
|
|
31667
31290
|
dispose() {
|
|
31668
|
-
(0,
|
|
31291
|
+
(0, import_forge_room11.removeObserver)(this.indexedPageMap, this.handleIndexedPageMapUpdate);
|
|
31669
31292
|
this.pageModel.off("switchPage");
|
|
31670
31293
|
this.pageModel.off("pagesChange");
|
|
31671
31294
|
}
|
|
@@ -31886,7 +31509,7 @@ var SequenceExecutor = class {
|
|
|
31886
31509
|
};
|
|
31887
31510
|
|
|
31888
31511
|
// src/WhiteboardApplication.ts
|
|
31889
|
-
var
|
|
31512
|
+
var import_forge_room13 = require("@netless/forge-room");
|
|
31890
31513
|
|
|
31891
31514
|
// src/LiveCursor.ts
|
|
31892
31515
|
function _defineProperty42(e, r, t) {
|
|
@@ -31941,19 +31564,9 @@ var LiveCursor = class {
|
|
|
31941
31564
|
cursor.style.fontSize = "12px";
|
|
31942
31565
|
cursor.style.padding = "2px 4px";
|
|
31943
31566
|
cursor.style.borderRadius = "4px";
|
|
31944
|
-
this.
|
|
31567
|
+
cursor.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
|
|
31945
31568
|
return cursor;
|
|
31946
31569
|
}
|
|
31947
|
-
updateCursorLabel(userId, cursor) {
|
|
31948
|
-
const target = cursor ?? this.cursors.get(userId);
|
|
31949
|
-
if (!target) {
|
|
31950
|
-
return;
|
|
31951
|
-
}
|
|
31952
|
-
if (target.textContent && target.textContent !== userId) {
|
|
31953
|
-
return;
|
|
31954
|
-
}
|
|
31955
|
-
target.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
|
|
31956
|
-
}
|
|
31957
31570
|
isOnSamePage(userId) {
|
|
31958
31571
|
const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
|
|
31959
31572
|
const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
|
|
@@ -31989,7 +31602,6 @@ var LiveCursor = class {
|
|
|
31989
31602
|
}
|
|
31990
31603
|
const cursor = this.cursors.get(userId);
|
|
31991
31604
|
if (cursor) {
|
|
31992
|
-
this.updateCursorLabel(userId, cursor);
|
|
31993
31605
|
const viewPoint = this.paperScope.project.view.projectToView(point);
|
|
31994
31606
|
cursor.style.left = viewPoint.x + "px";
|
|
31995
31607
|
cursor.style.top = viewPoint.y + "px";
|
|
@@ -32054,7 +31666,7 @@ var AsyncMap = class {
|
|
|
32054
31666
|
if (!window.__forge_gl_wb_status__) {
|
|
32055
31667
|
window.__forge_gl_wb_status__ = new AsyncMap();
|
|
32056
31668
|
}
|
|
32057
|
-
var WhiteboardApplication = class _WhiteboardApplication extends
|
|
31669
|
+
var WhiteboardApplication = class _WhiteboardApplication extends import_forge_room12.AbstractApplication {
|
|
32058
31670
|
get undoManager() {
|
|
32059
31671
|
const page = this.pageModel.getCurrentPage(this.userId);
|
|
32060
31672
|
if (page) {
|
|
@@ -32105,7 +31717,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32105
31717
|
_defineProperty43(this, "permissions", void 0);
|
|
32106
31718
|
_defineProperty43(this, "inputType", "any");
|
|
32107
31719
|
_defineProperty43(this, "isPenEvent", false);
|
|
32108
|
-
_defineProperty43(this, "activePenPointerId", null);
|
|
32109
31720
|
_defineProperty43(this, "hasPenInput", null);
|
|
32110
31721
|
_defineProperty43(this, "disableViewModelUpdate", false);
|
|
32111
31722
|
_defineProperty43(this, "internalResizeObserver", true);
|
|
@@ -32201,7 +31812,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32201
31812
|
}
|
|
32202
31813
|
} else {
|
|
32203
31814
|
console.warn(`[@netless/forge-whiteboard] page ${pageId} not found`);
|
|
32204
|
-
(0,
|
|
31815
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "warn");
|
|
32205
31816
|
}
|
|
32206
31817
|
await waitUntil(() => this.undoManagers.has(pageId), 1e3);
|
|
32207
31818
|
if (this.undoManagers.has(pageId)) {
|
|
@@ -32213,7 +31824,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32213
31824
|
this.undoManagers.get(pageId).on("stack-item-popped", this.handleStackItemPopped);
|
|
32214
31825
|
} else {
|
|
32215
31826
|
console.warn(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`);
|
|
32216
|
-
(0,
|
|
31827
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "warn");
|
|
32217
31828
|
}
|
|
32218
31829
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
32219
31830
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
@@ -32222,9 +31833,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32222
31833
|
_defineProperty43(this, "hasPermission", (flag) => {
|
|
32223
31834
|
return this.permissions.hasPermission(flag, this.userId);
|
|
32224
31835
|
});
|
|
32225
|
-
_defineProperty43(this, "isPerformanceMode", () => {
|
|
32226
|
-
return this.option.performance ?? false;
|
|
32227
|
-
});
|
|
32228
31836
|
_defineProperty43(this, "handleStackItemAdded", () => {
|
|
32229
31837
|
this.selectElementsModel.clearSelectElementForSelf();
|
|
32230
31838
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
@@ -32239,18 +31847,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32239
31847
|
const id = ids[i];
|
|
32240
31848
|
if (!this.layers.has(id)) {
|
|
32241
31849
|
const elementsMap = this.getMap(`layer/${id}/elements`);
|
|
32242
|
-
const renderableModel = new RenderableModel(
|
|
32243
|
-
layerId: id,
|
|
32244
|
-
shadowEmitter: this.shadowEmitter,
|
|
32245
|
-
elements: elementsMap,
|
|
32246
|
-
scope: this.paperScope,
|
|
32247
|
-
toolbarModel: this.toolbarModel,
|
|
32248
|
-
userManager: this.userManager,
|
|
32249
|
-
imageSets: this.imageSets,
|
|
32250
|
-
liveCursor: this.liveCursor,
|
|
32251
|
-
hasPermission: this.hasPermission,
|
|
32252
|
-
isPerformanceMode: this.isPerformanceMode
|
|
32253
|
-
});
|
|
31850
|
+
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
|
|
32254
31851
|
this.layers.set(id, renderableModel);
|
|
32255
31852
|
}
|
|
32256
31853
|
if (!this.undoManagers.has(id)) {
|
|
@@ -32434,34 +32031,11 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32434
32031
|
this.imageSets.setAttribute("data-image-sets", "");
|
|
32435
32032
|
this.rootElement.appendChild(this.imageSets);
|
|
32436
32033
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
32437
|
-
|
|
32438
|
-
|
|
32439
|
-
this.
|
|
32440
|
-
|
|
32441
|
-
|
|
32442
|
-
this.inputType = "pen";
|
|
32443
|
-
this.emitter.emit("inputTypeChange", this.inputType);
|
|
32444
|
-
}
|
|
32445
|
-
} else {
|
|
32446
|
-
if (this.activePenPointerId === null) {
|
|
32447
|
-
this.isPenEvent = false;
|
|
32448
|
-
}
|
|
32449
|
-
}
|
|
32450
|
-
}, {
|
|
32451
|
-
capture: true
|
|
32452
|
-
});
|
|
32453
|
-
document.body.addEventListener("pointerup", (evt) => {
|
|
32454
|
-
if (evt.pointerId === this.activePenPointerId) {
|
|
32455
|
-
this.activePenPointerId = null;
|
|
32456
|
-
this.isPenEvent = false;
|
|
32457
|
-
}
|
|
32458
|
-
}, {
|
|
32459
|
-
capture: true
|
|
32460
|
-
});
|
|
32461
|
-
document.body.addEventListener("pointercancel", (evt) => {
|
|
32462
|
-
if (evt.pointerId === this.activePenPointerId) {
|
|
32463
|
-
this.activePenPointerId = null;
|
|
32464
|
-
this.isPenEvent = false;
|
|
32034
|
+
this.isPenEvent = evt.pointerType === "pen";
|
|
32035
|
+
if (evt.pointerType === "pen" && this.hasPenInput === null) {
|
|
32036
|
+
this.hasPenInput = true;
|
|
32037
|
+
this.inputType = "pen";
|
|
32038
|
+
this.emitter.emit("inputTypeChange", this.inputType);
|
|
32465
32039
|
}
|
|
32466
32040
|
}, {
|
|
32467
32041
|
capture: true
|
|
@@ -32517,7 +32091,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32517
32091
|
this.emitter.setViewModeToFree = (userId) => {
|
|
32518
32092
|
if (that.disableViewModelUpdate) {
|
|
32519
32093
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32520
|
-
(0,
|
|
32094
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32521
32095
|
return;
|
|
32522
32096
|
}
|
|
32523
32097
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32528,7 +32102,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32528
32102
|
this.emitter.setViewModeToFlow = (flowId, userId) => {
|
|
32529
32103
|
if (that.disableViewModelUpdate) {
|
|
32530
32104
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32531
|
-
(0,
|
|
32105
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32532
32106
|
return;
|
|
32533
32107
|
}
|
|
32534
32108
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32540,16 +32114,10 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32540
32114
|
this.camera.resetViewMatrixToFlow(flowId);
|
|
32541
32115
|
}
|
|
32542
32116
|
};
|
|
32543
|
-
this.emitter.setPerformanceMode = (enabled) => {
|
|
32544
|
-
this.option.performance = enabled;
|
|
32545
|
-
};
|
|
32546
|
-
this.emitter.isPerformanceMode = () => {
|
|
32547
|
-
return this.isPerformanceMode();
|
|
32548
|
-
};
|
|
32549
32117
|
this.emitter.setViewModeToMain = (userId) => {
|
|
32550
32118
|
if (that.disableViewModelUpdate) {
|
|
32551
32119
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32552
|
-
(0,
|
|
32120
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32553
32121
|
return;
|
|
32554
32122
|
}
|
|
32555
32123
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32563,7 +32131,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32563
32131
|
};
|
|
32564
32132
|
this.emitter.insertImage = (src, pageId) => {
|
|
32565
32133
|
if (!/https/.test(src)) {
|
|
32566
|
-
(0,
|
|
32134
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] invalid image url, src needs to be in the HTTPS protocol.", {
|
|
32567
32135
|
src
|
|
32568
32136
|
}, "warn");
|
|
32569
32137
|
return;
|
|
@@ -32573,14 +32141,14 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32573
32141
|
targetPageId = this.pageModel.getCurrentPage(this.userManager.selfId);
|
|
32574
32142
|
}
|
|
32575
32143
|
if (!targetPageId) {
|
|
32576
|
-
(0,
|
|
32144
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warn");
|
|
32577
32145
|
return;
|
|
32578
32146
|
}
|
|
32579
32147
|
this.layers.get(targetPageId)?.createImage(src);
|
|
32580
32148
|
};
|
|
32581
32149
|
this.emitter.removeElement = (pageId, elementId) => {
|
|
32582
32150
|
if (!this.layers.has(pageId)) {
|
|
32583
|
-
(0,
|
|
32151
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warn");
|
|
32584
32152
|
return;
|
|
32585
32153
|
}
|
|
32586
32154
|
this.layers.get(pageId)?.removeElementItem(elementId);
|
|
@@ -32600,18 +32168,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32600
32168
|
const source = this.getMap(`layer/${sourceId}/elements`);
|
|
32601
32169
|
const target = this.getMap(`layer/${targetId}/elements`);
|
|
32602
32170
|
if (!this.layers.has(targetId)) {
|
|
32603
|
-
this.layers.set(targetId, new RenderableModel(
|
|
32604
|
-
layerId: targetId,
|
|
32605
|
-
shadowEmitter: this.shadowEmitter,
|
|
32606
|
-
elements: target,
|
|
32607
|
-
scope: this.paperScope,
|
|
32608
|
-
toolbarModel: this.toolbarModel,
|
|
32609
|
-
userManager: this.userManager,
|
|
32610
|
-
imageSets: this.imageSets,
|
|
32611
|
-
liveCursor: this.liveCursor,
|
|
32612
|
-
hasPermission: this.hasPermission,
|
|
32613
|
-
isPerformanceMode: this.isPerformanceMode
|
|
32614
|
-
}));
|
|
32171
|
+
this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
|
|
32615
32172
|
}
|
|
32616
32173
|
if (!this.undoManagers.has(targetId)) {
|
|
32617
32174
|
const undoManager = new Y15.UndoManager(target, {
|
|
@@ -32680,15 +32237,15 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32680
32237
|
this.liveCursor.showLiveCursor = value;
|
|
32681
32238
|
};
|
|
32682
32239
|
this.emitter.updateViewport = (width, height) => {
|
|
32683
|
-
(0,
|
|
32240
|
+
(0, import_forge_room12.log)(`call updateViewport with width: ${width}, height: ${height}`);
|
|
32684
32241
|
this.updateOptionSize(width, height);
|
|
32685
32242
|
};
|
|
32686
32243
|
this.emitter.__setMainCanvasVisible = (visible) => {
|
|
32687
|
-
(0,
|
|
32244
|
+
(0, import_forge_room12.log)(`call __setMainCanvasVisible with visible: ${visible}`);
|
|
32688
32245
|
this.canvasElement.style.opacity = visible ? "1" : "0";
|
|
32689
32246
|
};
|
|
32690
32247
|
this.emitter.on("error", (errorCode, errorMessage) => {
|
|
32691
|
-
(0,
|
|
32248
|
+
(0, import_forge_room12.log)("WhiteboardApplicationError", {
|
|
32692
32249
|
errorCode,
|
|
32693
32250
|
errorMessage
|
|
32694
32251
|
});
|
|
@@ -32698,7 +32255,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32698
32255
|
return that.delayTranslateOut;
|
|
32699
32256
|
},
|
|
32700
32257
|
set(value) {
|
|
32701
|
-
(0,
|
|
32258
|
+
(0, import_forge_room12.log)(`call __delayTranslateOut with value: ${value}`);
|
|
32702
32259
|
that.delayTranslateOut = value;
|
|
32703
32260
|
}
|
|
32704
32261
|
});
|
|
@@ -32801,7 +32358,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32801
32358
|
}
|
|
32802
32359
|
async initialize(option) {
|
|
32803
32360
|
_WhiteboardApplication.instanceCount.set(this.appId, (_WhiteboardApplication.instanceCount.get(this.appId) ?? 0) + 1);
|
|
32804
|
-
(0,
|
|
32361
|
+
(0, import_forge_room12.log)(`whiteboard ${this.appId} initialize. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
|
|
32805
32362
|
this.appDoc.transact(() => {
|
|
32806
32363
|
this.permissions = new WhiteboardPermissions(this.writableManager, this.userManager, (userId) => {
|
|
32807
32364
|
return this.userMap(userId);
|
|
@@ -32846,11 +32403,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32846
32403
|
this.editors.forEach((editor) => {
|
|
32847
32404
|
editor.updateBounds();
|
|
32848
32405
|
});
|
|
32849
|
-
const area = this.paperScope.project.view.size.width * this.paperScope.project.view.size.height;
|
|
32850
|
-
const minDistance = Math.ceil(area / 4e5);
|
|
32851
|
-
Object.keys(this.tools).forEach((key) => {
|
|
32852
|
-
this.tools[key].tool.minDistance = minDistance;
|
|
32853
|
-
});
|
|
32854
32406
|
});
|
|
32855
32407
|
this.camera.on("userPageChange", (userId, pageId) => {
|
|
32856
32408
|
this.emitter.emit("activePageChange", userId, pageId);
|
|
@@ -32912,7 +32464,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32912
32464
|
this.paperScope.tool = this.tools[this.toolbarModel.currentTool].tool;
|
|
32913
32465
|
} else {
|
|
32914
32466
|
this.paperScope.tool = this.tools["curve"].tool;
|
|
32915
|
-
(0,
|
|
32467
|
+
(0, import_forge_room12.log)(`${this.toolbarModel.currentTool} not supported, backup to curve`);
|
|
32916
32468
|
}
|
|
32917
32469
|
this.selectElementsModel.on("elementsChange", this.handleElementsSelect);
|
|
32918
32470
|
this.trashedElementsModel.on("elementsChange", this.handleElementsTrash);
|
|
@@ -33199,8 +32751,8 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
33199
32751
|
this.toolbarModel.dispose();
|
|
33200
32752
|
this.emitter.indexedNavigation.dispose();
|
|
33201
32753
|
this.permissions.dispose();
|
|
33202
|
-
(0,
|
|
33203
|
-
(0,
|
|
32754
|
+
(0, import_forge_room13.removeObserver)(this.userMap(this.userId), this.handleSyncedWhiteboardStatusChange);
|
|
32755
|
+
(0, import_forge_room12.log)(`whiteboard ${this.appId} disposed. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
|
|
33204
32756
|
}
|
|
33205
32757
|
};
|
|
33206
32758
|
_defineProperty43(WhiteboardApplication, "instanceCount", /* @__PURE__ */ new Map());
|