@netless/forge-whiteboard 1.1.5 → 1.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.md +1 -13
- package/dist/LiveCursor.d.ts +1 -2
- package/dist/LiveCursor.d.ts.map +1 -1
- package/dist/Whiteboard.d.ts +0 -10
- package/dist/Whiteboard.d.ts.map +1 -1
- package/dist/WhiteboardApplication.d.ts +0 -6
- package/dist/WhiteboardApplication.d.ts.map +1 -1
- package/dist/edit/Editor.d.ts.map +1 -1
- package/dist/model/RenderableModel.d.ts +1 -13
- package/dist/model/RenderableModel.d.ts.map +1 -1
- package/dist/model/renderable/CurveModel.d.ts +3 -6
- package/dist/model/renderable/CurveModel.d.ts.map +1 -1
- package/dist/model/renderable/ElementModel.d.ts +1 -20
- package/dist/model/renderable/ElementModel.d.ts.map +1 -1
- package/dist/model/renderable/EraserModel.d.ts +1 -5
- package/dist/model/renderable/EraserModel.d.ts.map +1 -1
- package/dist/model/renderable/ImageModel.d.ts +1 -4
- package/dist/model/renderable/ImageModel.d.ts.map +1 -1
- package/dist/model/renderable/LaserPointerModel.d.ts +2 -8
- package/dist/model/renderable/LaserPointerModel.d.ts.map +1 -1
- package/dist/model/renderable/LineModel.d.ts +1 -5
- package/dist/model/renderable/LineModel.d.ts.map +1 -1
- package/dist/model/renderable/PointTextModel.d.ts +1 -6
- package/dist/model/renderable/PointTextModel.d.ts.map +1 -1
- package/dist/model/renderable/RectangleModel.d.ts +1 -5
- package/dist/model/renderable/RectangleModel.d.ts.map +1 -1
- package/dist/model/renderable/SegmentsModel.d.ts +1 -5
- package/dist/model/renderable/SegmentsModel.d.ts.map +1 -1
- package/dist/model/renderable/SelectorModel.d.ts +1 -5
- package/dist/model/renderable/SelectorModel.d.ts.map +1 -1
- package/dist/model/renderable/StraightLineModel.d.ts +1 -5
- package/dist/model/renderable/StraightLineModel.d.ts.map +1 -1
- package/dist/model/renderable/TriangleModel.d.ts +1 -5
- package/dist/model/renderable/TriangleModel.d.ts.map +1 -1
- package/dist/tool/CurveTool.d.ts +0 -3
- package/dist/tool/CurveTool.d.ts.map +1 -1
- package/dist/tool/LaserPointerTool.d.ts.map +1 -1
- package/dist/tool/WhiteboardTool.d.ts +0 -4
- package/dist/tool/WhiteboardTool.d.ts.map +1 -1
- package/dist/utils/paperjs.d.ts.map +1 -1
- package/dist/whiteboard.esm.js +272 -741
- package/dist/whiteboard.esm.js.map +3 -3
- package/dist/whiteboard.js +308 -777
- package/dist/whiteboard.js.map +3 -3
- package/package.json +2 -2
package/dist/whiteboard.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,72 +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
|
-
isPressureValue(value) {
|
|
26244
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
26245
|
-
}
|
|
26246
|
-
pointStride(points) {
|
|
26247
|
-
if (points.length >= 3 && points.length % 3 === 0) {
|
|
26248
|
-
let hasPressureSlot = false;
|
|
26249
|
-
for (let i = 2; i < points.length; i += 3) {
|
|
26250
|
-
if (!this.isPressureValue(points[i])) {
|
|
26251
|
-
return 2;
|
|
26252
|
-
}
|
|
26253
|
-
hasPressureSlot = true;
|
|
26254
|
-
}
|
|
26255
|
-
if (hasPressureSlot) {
|
|
26256
|
-
return 3;
|
|
26257
|
-
}
|
|
26258
|
-
}
|
|
26259
|
-
return 2;
|
|
26260
|
-
}
|
|
26261
26113
|
matrixedPoints() {
|
|
26262
|
-
const points = this.
|
|
26114
|
+
const points = this.points;
|
|
26263
26115
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26264
26116
|
const output = [];
|
|
26265
|
-
|
|
26266
|
-
for (let i = 0, len = points.length; i + 1 < len; i += stride) {
|
|
26117
|
+
for (let i = 0, len = points.length; i < len; i += 2) {
|
|
26267
26118
|
const p = new this.scope.Point(points[i], points[i + 1]);
|
|
26268
26119
|
const tp = p.transform(matrix);
|
|
26269
|
-
|
|
26270
|
-
output.push([tp.x, tp.y, pressure]);
|
|
26120
|
+
output.push([tp.x, tp.y]);
|
|
26271
26121
|
}
|
|
26272
26122
|
return output;
|
|
26273
26123
|
}
|
|
@@ -26296,30 +26146,34 @@ var CurveModel = class extends ElementModel {
|
|
|
26296
26146
|
}
|
|
26297
26147
|
return path;
|
|
26298
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
|
+
}
|
|
26299
26163
|
onVectorUpdate() {
|
|
26300
26164
|
if (!this.item) {
|
|
26301
26165
|
return;
|
|
26302
26166
|
}
|
|
26303
|
-
const matrixedPts = this.matrixedPoints();
|
|
26304
26167
|
if (this.debug) {
|
|
26305
|
-
|
|
26306
|
-
|
|
26307
|
-
|
|
26308
|
-
|
|
26309
|
-
|
|
26310
|
-
|
|
26311
|
-
|
|
26312
|
-
|
|
26313
|
-
|
|
26314
|
-
this.item.removeSegments();
|
|
26315
|
-
this.item.addSegments(path.segments);
|
|
26316
|
-
this.item.fillColor = null;
|
|
26317
|
-
this.item.strokeWidth = this.strokeWidth;
|
|
26318
|
-
} else {
|
|
26319
|
-
const points = this.parsePoints(matrixedPts);
|
|
26320
|
-
const path = this.createPath(points);
|
|
26321
|
-
this.item.removeSegments();
|
|
26322
|
-
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);
|
|
26323
26177
|
}
|
|
26324
26178
|
}
|
|
26325
26179
|
createPaperItem() {
|
|
@@ -26342,13 +26196,11 @@ var CurveModel = class extends ElementModel {
|
|
|
26342
26196
|
}
|
|
26343
26197
|
liveCursorPoint() {
|
|
26344
26198
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
26345
|
-
|
|
26346
|
-
const stride = this.pointStride(points);
|
|
26347
|
-
if (points.length < stride) {
|
|
26199
|
+
if (yArray.length < 2) {
|
|
26348
26200
|
return null;
|
|
26349
26201
|
}
|
|
26350
|
-
const len =
|
|
26351
|
-
const point = new this.scope.Point(
|
|
26202
|
+
const len = yArray.length;
|
|
26203
|
+
const point = new this.scope.Point(yArray.get(len - 2), yArray.get(len - 1));
|
|
26352
26204
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
26353
26205
|
}
|
|
26354
26206
|
onStyleKeyUpdate(key) {
|
|
@@ -26386,24 +26238,15 @@ function _toPrimitive4(t, r) {
|
|
|
26386
26238
|
return ("string" === r ? String : Number)(t);
|
|
26387
26239
|
}
|
|
26388
26240
|
var SelectorModel = class extends ElementModel {
|
|
26389
|
-
|
|
26390
|
-
|
|
26391
|
-
return this.localPoints;
|
|
26392
|
-
}
|
|
26393
|
-
return this.points;
|
|
26394
|
-
}
|
|
26395
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
26396
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26241
|
+
constructor(root, scope, liveCursor) {
|
|
26242
|
+
super(root, scope, liveCursor);
|
|
26397
26243
|
_defineProperty4(this, "item", null);
|
|
26398
|
-
|
|
26399
|
-
_defineProperty4(this, "shouldUseLocalPoints", true);
|
|
26400
|
-
_defineProperty4(this, "localPointsPick", 4);
|
|
26401
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26244
|
+
if (!this.root.has("type")) {
|
|
26402
26245
|
this.root.set("type", "selector");
|
|
26403
26246
|
}
|
|
26404
|
-
if (
|
|
26247
|
+
if (!this.root.has("points")) {
|
|
26405
26248
|
const initPoints = new Y3.Array();
|
|
26406
|
-
initPoints.push([0, 0, 0, 0]);
|
|
26249
|
+
initPoints.push([0, 0, 0, 0, 0]);
|
|
26407
26250
|
this.root.set("points", initPoints);
|
|
26408
26251
|
}
|
|
26409
26252
|
}
|
|
@@ -26414,8 +26257,8 @@ var SelectorModel = class extends ElementModel {
|
|
|
26414
26257
|
}
|
|
26415
26258
|
createPaperRect() {
|
|
26416
26259
|
const scope = this.scope;
|
|
26417
|
-
const bounds = new scope.Rectangle(new scope.Point(this.
|
|
26418
|
-
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]));
|
|
26419
26262
|
}
|
|
26420
26263
|
onVectorUpdate() {
|
|
26421
26264
|
if (!this.item) {
|
|
@@ -26449,8 +26292,7 @@ var SelectorModel = class extends ElementModel {
|
|
|
26449
26292
|
var Y4 = __toESM(require("yjs"), 1);
|
|
26450
26293
|
|
|
26451
26294
|
// src/utils/paperjs.ts
|
|
26452
|
-
var
|
|
26453
|
-
var import_forge_room2 = require("@netless/forge-room");
|
|
26295
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
26454
26296
|
function _defineProperty5(e, r, t) {
|
|
26455
26297
|
return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26456
26298
|
}
|
|
@@ -26483,7 +26325,7 @@ function serializePath(path) {
|
|
|
26483
26325
|
}, []);
|
|
26484
26326
|
}
|
|
26485
26327
|
function deserializePath(points, scope, matrix) {
|
|
26486
|
-
const segmentGroup = (0,
|
|
26328
|
+
const segmentGroup = (0, import_lodash2.chunk)(points, 6);
|
|
26487
26329
|
const path = new scope.Path();
|
|
26488
26330
|
path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
|
|
26489
26331
|
return path;
|
|
@@ -26493,27 +26335,7 @@ var AnimationFrame = class {
|
|
|
26493
26335
|
_defineProperty5(this, "callbacks", []);
|
|
26494
26336
|
_defineProperty5(this, "lastTime", 0);
|
|
26495
26337
|
_defineProperty5(this, "fps", 45);
|
|
26496
|
-
_defineProperty5(this, "lastCallbackTime", 0);
|
|
26497
|
-
_defineProperty5(this, "fpsBuffer", []);
|
|
26498
|
-
_defineProperty5(this, "FPS_REPORT_INTERVAL", 2700);
|
|
26499
26338
|
_defineProperty5(this, "handleCallbacks", () => {
|
|
26500
|
-
const now = performance.now();
|
|
26501
|
-
if (this.lastCallbackTime > 0) {
|
|
26502
|
-
const actualFps = 1e3 / (now - this.lastCallbackTime);
|
|
26503
|
-
this.fpsBuffer.push(actualFps);
|
|
26504
|
-
if (this.fpsBuffer.length >= this.FPS_REPORT_INTERVAL) {
|
|
26505
|
-
const avg = this.fpsBuffer.reduce((a2, b2) => a2 + b2, 0) / this.fpsBuffer.length;
|
|
26506
|
-
const min = Math.min(...this.fpsBuffer);
|
|
26507
|
-
const sorted = [...this.fpsBuffer].sort((a2, b2) => a2 - b2);
|
|
26508
|
-
const p90 = sorted[Math.floor(sorted.length * 0.9)];
|
|
26509
|
-
(0, import_forge_room2.metrics)().gauge("fps", Math.round(avg), {
|
|
26510
|
-
min: Math.round(min),
|
|
26511
|
-
p90: Math.round(p90)
|
|
26512
|
-
});
|
|
26513
|
-
this.fpsBuffer = [];
|
|
26514
|
-
}
|
|
26515
|
-
}
|
|
26516
|
-
this.lastCallbackTime = now;
|
|
26517
26339
|
const functions = this.callbacks;
|
|
26518
26340
|
this.callbacks = [];
|
|
26519
26341
|
for (let i = 0, l2 = functions.length; i < l2; i++) {
|
|
@@ -26557,22 +26379,13 @@ function _toPrimitive6(t, r) {
|
|
|
26557
26379
|
return ("string" === r ? String : Number)(t);
|
|
26558
26380
|
}
|
|
26559
26381
|
var SegmentsModel = class extends ElementModel {
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
return this.localPoints;
|
|
26563
|
-
}
|
|
26564
|
-
return this.points;
|
|
26565
|
-
}
|
|
26566
|
-
constructor(root, scope, type, liveCursor, isPerformanceMode) {
|
|
26567
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26382
|
+
constructor(root, scope, type, liveCursor) {
|
|
26383
|
+
super(root, scope, liveCursor);
|
|
26568
26384
|
_defineProperty6(this, "item", null);
|
|
26569
|
-
|
|
26570
|
-
_defineProperty6(this, "shouldUseLocalPoints", true);
|
|
26571
|
-
_defineProperty6(this, "localPointsPick", 24);
|
|
26572
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26385
|
+
if (!this.root.has("type")) {
|
|
26573
26386
|
this.root.set("type", type);
|
|
26574
26387
|
}
|
|
26575
|
-
if (
|
|
26388
|
+
if (!this.root.has("points")) {
|
|
26576
26389
|
this.root.set("points", new Y4.Array());
|
|
26577
26390
|
}
|
|
26578
26391
|
}
|
|
@@ -26592,13 +26405,13 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26592
26405
|
}
|
|
26593
26406
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26594
26407
|
this.item.removeSegments();
|
|
26595
|
-
const next = deserializePath(this.
|
|
26408
|
+
const next = deserializePath(this.points, this.scope, matrix);
|
|
26596
26409
|
this.item.addSegments(next.segments);
|
|
26597
26410
|
this.item.closePath();
|
|
26598
26411
|
}
|
|
26599
26412
|
createPaperItem() {
|
|
26600
26413
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26601
|
-
this.item = deserializePath(this.
|
|
26414
|
+
this.item = deserializePath(this.points, this.scope, matrix);
|
|
26602
26415
|
this.item.strokeColor = new this.scope.Color(this.strokeColor);
|
|
26603
26416
|
this.item.dashArray = this.dashArray;
|
|
26604
26417
|
this.item.strokeWidth = this.strokeWidth;
|
|
@@ -26626,7 +26439,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26626
26439
|
|
|
26627
26440
|
// src/model/renderable/LineModel.ts
|
|
26628
26441
|
var Y5 = __toESM(require("yjs"), 1);
|
|
26629
|
-
var
|
|
26442
|
+
var import_lodash4 = __toESM(require_lodash(), 1);
|
|
26630
26443
|
|
|
26631
26444
|
// src/tool/WhiteboardTool.ts
|
|
26632
26445
|
function _defineProperty7(e, r, t) {
|
|
@@ -26646,8 +26459,6 @@ function _toPrimitive7(t, r) {
|
|
|
26646
26459
|
}
|
|
26647
26460
|
return ("string" === r ? String : Number)(t);
|
|
26648
26461
|
}
|
|
26649
|
-
var DRAG_FPS = 10;
|
|
26650
|
-
var DRAG_FRAME_MS = 1e3 / DRAG_FPS;
|
|
26651
26462
|
var WhiteboardTool = class {
|
|
26652
26463
|
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
26653
26464
|
_defineProperty7(this, "modelGetter", void 0);
|
|
@@ -26656,60 +26467,24 @@ var WhiteboardTool = class {
|
|
|
26656
26467
|
_defineProperty7(this, "shadowEmitter", void 0);
|
|
26657
26468
|
_defineProperty7(this, "enableToolEvent", void 0);
|
|
26658
26469
|
_defineProperty7(this, "eventAvailable", false);
|
|
26659
|
-
_defineProperty7(this, "lastDragTime", 0);
|
|
26660
|
-
_defineProperty7(this, "dragRafId", 0);
|
|
26661
|
-
_defineProperty7(this, "pendingDragEvent", null);
|
|
26662
26470
|
_defineProperty7(this, "onMouseDownSelf", (event) => {
|
|
26663
26471
|
this.eventAvailable = this.enableToolEvent();
|
|
26664
26472
|
if (!this.eventAvailable) {
|
|
26665
26473
|
return;
|
|
26666
26474
|
}
|
|
26667
|
-
this.lastDragTime = 0;
|
|
26668
|
-
if (this.dragRafId) {
|
|
26669
|
-
cancelAnimationFrame(this.dragRafId);
|
|
26670
|
-
this.dragRafId = 0;
|
|
26671
|
-
}
|
|
26672
|
-
this.pendingDragEvent = null;
|
|
26673
26475
|
this.shadowEmitter.setActive(true);
|
|
26674
26476
|
this.onMouseDown(event);
|
|
26675
26477
|
});
|
|
26676
|
-
_defineProperty7(this, "flushPendingDrag", () => {
|
|
26677
|
-
this.dragRafId = 0;
|
|
26678
|
-
if (this.pendingDragEvent) {
|
|
26679
|
-
this.lastDragTime = performance.now();
|
|
26680
|
-
const event = this.pendingDragEvent;
|
|
26681
|
-
this.pendingDragEvent = null;
|
|
26682
|
-
this.onMouseDrag(event);
|
|
26683
|
-
}
|
|
26684
|
-
});
|
|
26685
26478
|
_defineProperty7(this, "onMouseDragSelf", (event) => {
|
|
26686
26479
|
if (!this.eventAvailable) {
|
|
26687
26480
|
return;
|
|
26688
26481
|
}
|
|
26689
|
-
|
|
26690
|
-
if (now - this.lastDragTime >= DRAG_FRAME_MS) {
|
|
26691
|
-
this.lastDragTime = now;
|
|
26692
|
-
this.pendingDragEvent = null;
|
|
26693
|
-
this.onMouseDrag(event);
|
|
26694
|
-
} else {
|
|
26695
|
-
this.pendingDragEvent = event;
|
|
26696
|
-
if (!this.dragRafId) {
|
|
26697
|
-
this.dragRafId = requestAnimationFrame(this.flushPendingDrag);
|
|
26698
|
-
}
|
|
26699
|
-
}
|
|
26482
|
+
this.onMouseDrag(event);
|
|
26700
26483
|
});
|
|
26701
26484
|
_defineProperty7(this, "onMouseUpSelf", (event) => {
|
|
26702
26485
|
if (!this.eventAvailable) {
|
|
26703
26486
|
return;
|
|
26704
26487
|
}
|
|
26705
|
-
if (this.dragRafId) {
|
|
26706
|
-
cancelAnimationFrame(this.dragRafId);
|
|
26707
|
-
this.dragRafId = 0;
|
|
26708
|
-
}
|
|
26709
|
-
if (this.pendingDragEvent) {
|
|
26710
|
-
this.onMouseDrag(this.pendingDragEvent);
|
|
26711
|
-
this.pendingDragEvent = null;
|
|
26712
|
-
}
|
|
26713
26488
|
this.onMouseUp(event);
|
|
26714
26489
|
this.shadowEmitter.setActive(false);
|
|
26715
26490
|
});
|
|
@@ -26725,7 +26500,7 @@ var WhiteboardTool = class {
|
|
|
26725
26500
|
};
|
|
26726
26501
|
|
|
26727
26502
|
// src/tool/LineTool.ts
|
|
26728
|
-
var
|
|
26503
|
+
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
26729
26504
|
function _defineProperty8(e, r, t) {
|
|
26730
26505
|
return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26731
26506
|
}
|
|
@@ -26774,7 +26549,7 @@ var LineTool = class extends WhiteboardTool {
|
|
|
26774
26549
|
const point = path.getPointAt(distance);
|
|
26775
26550
|
return [point.x, point.y];
|
|
26776
26551
|
});
|
|
26777
|
-
this.elementModel.setPoints((0,
|
|
26552
|
+
this.elementModel.setPoints((0, import_lodash3.flattenDeep)(points));
|
|
26778
26553
|
}
|
|
26779
26554
|
}
|
|
26780
26555
|
onMouseUp(_event) {
|
|
@@ -26804,12 +26579,6 @@ function _toPrimitive9(t, r) {
|
|
|
26804
26579
|
return ("string" === r ? String : Number)(t);
|
|
26805
26580
|
}
|
|
26806
26581
|
var LineModel = class extends ElementModel {
|
|
26807
|
-
get drawPoints() {
|
|
26808
|
-
if (this.localPoints.length > 0) {
|
|
26809
|
-
return this.localPoints;
|
|
26810
|
-
}
|
|
26811
|
-
return this.points;
|
|
26812
|
-
}
|
|
26813
26582
|
get arrowSize() {
|
|
26814
26583
|
return this.strokeWidth * 5 + 15;
|
|
26815
26584
|
}
|
|
@@ -26825,23 +26594,20 @@ var LineModel = class extends ElementModel {
|
|
|
26825
26594
|
set tailArrow(value) {
|
|
26826
26595
|
this.root.set("tailArrow", value);
|
|
26827
26596
|
}
|
|
26828
|
-
constructor(root, scope, liveCursor
|
|
26829
|
-
super(root, scope, liveCursor
|
|
26597
|
+
constructor(root, scope, liveCursor) {
|
|
26598
|
+
super(root, scope, liveCursor);
|
|
26830
26599
|
_defineProperty9(this, "controlledPoints", []);
|
|
26831
|
-
_defineProperty9(this, "clearLocalPointsWhenYPointsChange", true);
|
|
26832
|
-
_defineProperty9(this, "shouldUseLocalPoints", true);
|
|
26833
|
-
_defineProperty9(this, "localPointsPick", 99);
|
|
26834
26600
|
_defineProperty9(this, "item", null);
|
|
26835
|
-
if (
|
|
26601
|
+
if (!this.root.has("type")) {
|
|
26836
26602
|
this.root.set("type", "arrow");
|
|
26837
26603
|
}
|
|
26838
|
-
if (
|
|
26604
|
+
if (!this.root.has("points")) {
|
|
26839
26605
|
this.root.set("points", new Y5.Array());
|
|
26840
26606
|
}
|
|
26841
|
-
if (
|
|
26607
|
+
if (!this.root.has("headArrow")) {
|
|
26842
26608
|
this.root.set("headArrow", "none");
|
|
26843
26609
|
}
|
|
26844
|
-
if (
|
|
26610
|
+
if (!this.root.has("tailArrow")) {
|
|
26845
26611
|
this.root.set("tailArrow", "normal");
|
|
26846
26612
|
}
|
|
26847
26613
|
}
|
|
@@ -26857,7 +26623,7 @@ var LineModel = class extends ElementModel {
|
|
|
26857
26623
|
}
|
|
26858
26624
|
renderLine() {
|
|
26859
26625
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26860
|
-
const papperPoints = (0,
|
|
26626
|
+
const papperPoints = (0, import_lodash4.chunk)(this.points, 2).map((item) => {
|
|
26861
26627
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
26862
26628
|
});
|
|
26863
26629
|
const path = new this.scope.Path();
|
|
@@ -26971,14 +26737,13 @@ var LineControlPoint = class {
|
|
|
26971
26737
|
if (this.position) {
|
|
26972
26738
|
return this.model.scope.project.view.projectToView(this.position.transform(matrix));
|
|
26973
26739
|
}
|
|
26974
|
-
const points = this.model["drawPoints"];
|
|
26975
26740
|
const from = {
|
|
26976
|
-
x: points[0],
|
|
26977
|
-
y: points[1]
|
|
26741
|
+
x: this.model.points[0],
|
|
26742
|
+
y: this.model.points[1]
|
|
26978
26743
|
};
|
|
26979
26744
|
const to = {
|
|
26980
|
-
x: points[points.length - 2],
|
|
26981
|
-
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]
|
|
26982
26747
|
};
|
|
26983
26748
|
const clonedPath = new this.scope.Path.Line(from, to);
|
|
26984
26749
|
this.position = clonedPath.getPointAt(clonedPath.length * distance);
|
|
@@ -26991,9 +26756,9 @@ var LineControlPoint = class {
|
|
|
26991
26756
|
}
|
|
26992
26757
|
const pointsMatrix = new this.model.scope.Matrix(this.model.pointsMatrix);
|
|
26993
26758
|
const invertedPoint = point.transform(pointsMatrix.inverted());
|
|
26994
|
-
const points = this.model
|
|
26759
|
+
const points = this.model.points;
|
|
26995
26760
|
this.position = invertedPoint;
|
|
26996
|
-
const clonedPoints = (0,
|
|
26761
|
+
const clonedPoints = (0, import_lodash4.cloneDeep)(points);
|
|
26997
26762
|
clonedPoints[this.options.index * 2] = invertedPoint.x;
|
|
26998
26763
|
clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
|
|
26999
26764
|
this.model.setPoints(clonedPoints);
|
|
@@ -27002,7 +26767,7 @@ var LineControlPoint = class {
|
|
|
27002
26767
|
|
|
27003
26768
|
// src/model/renderable/PointTextModel.ts
|
|
27004
26769
|
var Y6 = __toESM(require("yjs"), 1);
|
|
27005
|
-
var
|
|
26770
|
+
var import_forge_room2 = require("@netless/forge-room");
|
|
27006
26771
|
function _defineProperty10(e, r, t) {
|
|
27007
26772
|
return (r = _toPropertyKey10(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27008
26773
|
}
|
|
@@ -27039,18 +26804,9 @@ var PointTextModel = class extends ElementModel {
|
|
|
27039
26804
|
set fontFamily(value) {
|
|
27040
26805
|
this.root.set("font-family", value);
|
|
27041
26806
|
}
|
|
27042
|
-
|
|
27043
|
-
|
|
27044
|
-
return this.localPoints;
|
|
27045
|
-
}
|
|
27046
|
-
return this.points;
|
|
27047
|
-
}
|
|
27048
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27049
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26807
|
+
constructor(root, scope, liveCursor) {
|
|
26808
|
+
super(root, scope, liveCursor);
|
|
27050
26809
|
_defineProperty10(this, "item", null);
|
|
27051
|
-
_defineProperty10(this, "clearLocalPointsWhenYPointsChange", true);
|
|
27052
|
-
_defineProperty10(this, "shouldUseLocalPoints", false);
|
|
27053
|
-
_defineProperty10(this, "localPointsPick", 2);
|
|
27054
26810
|
_defineProperty10(this, "handleTextPropChange", (event) => {
|
|
27055
26811
|
if (!this.item) {
|
|
27056
26812
|
return;
|
|
@@ -27067,27 +26823,21 @@ var PointTextModel = class extends ElementModel {
|
|
|
27067
26823
|
}
|
|
27068
26824
|
}
|
|
27069
26825
|
});
|
|
27070
|
-
if (
|
|
26826
|
+
if (!this.root.has("type")) {
|
|
27071
26827
|
this.root.set("type", "point-text");
|
|
27072
26828
|
}
|
|
27073
|
-
if (
|
|
26829
|
+
if (!this.root.has(ElementModel.KEYS.points)) {
|
|
27074
26830
|
this.root.set(ElementModel.KEYS.points, new Y6.Array());
|
|
27075
26831
|
}
|
|
27076
26832
|
this.root.observe(this.handleTextPropChange);
|
|
27077
|
-
|
|
27078
|
-
|
|
27079
|
-
|
|
27080
|
-
|
|
27081
|
-
|
|
27082
|
-
}
|
|
27083
|
-
}, 60);
|
|
26833
|
+
if (this.root.has("font-size")) {
|
|
26834
|
+
setTimeout(() => {
|
|
26835
|
+
this.updateTextPosition();
|
|
26836
|
+
}, 60);
|
|
26837
|
+
}
|
|
27084
26838
|
}
|
|
27085
26839
|
subDispose() {
|
|
27086
|
-
(0,
|
|
27087
|
-
}
|
|
27088
|
-
subBindObserver() {
|
|
27089
|
-
(0, import_forge_room3.removeObserver)(this.root, this.handleTextPropChange);
|
|
27090
|
-
this.root.observe(this.handleTextPropChange);
|
|
26840
|
+
(0, import_forge_room2.removeObserver)(this.root, this.handleTextPropChange);
|
|
27091
26841
|
}
|
|
27092
26842
|
liveCursorPoint() {
|
|
27093
26843
|
const points = this.points;
|
|
@@ -27102,11 +26852,10 @@ var PointTextModel = class extends ElementModel {
|
|
|
27102
26852
|
if (!this.item) {
|
|
27103
26853
|
return null;
|
|
27104
26854
|
}
|
|
27105
|
-
console.log("[][][] drawPoints", this.drawPoints);
|
|
27106
26855
|
const bounds = this.item.internalBounds;
|
|
27107
26856
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27108
|
-
const topLeft = new this.scope.Point(this.
|
|
27109
|
-
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);
|
|
27110
26859
|
let scaleX = topRight.getDistance(topLeft) / bounds.width;
|
|
27111
26860
|
scaleX = Number.isNaN(scaleX) ? 1 : scaleX;
|
|
27112
26861
|
const angle = topRight.subtract(topLeft).angle;
|
|
@@ -27194,22 +26943,13 @@ function _toPrimitive11(t, r) {
|
|
|
27194
26943
|
return ("string" === r ? String : Number)(t);
|
|
27195
26944
|
}
|
|
27196
26945
|
var TriangleModel = class extends ElementModel {
|
|
27197
|
-
|
|
27198
|
-
|
|
27199
|
-
return this.localPoints;
|
|
27200
|
-
}
|
|
27201
|
-
return this.points;
|
|
27202
|
-
}
|
|
27203
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27204
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
26946
|
+
constructor(root, scope, liveCursor) {
|
|
26947
|
+
super(root, scope, liveCursor);
|
|
27205
26948
|
_defineProperty11(this, "item", null);
|
|
27206
|
-
|
|
27207
|
-
_defineProperty11(this, "shouldUseLocalPoints", true);
|
|
27208
|
-
_defineProperty11(this, "localPointsPick", 6);
|
|
27209
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
26949
|
+
if (!this.root.has("type")) {
|
|
27210
26950
|
this.root.set("type", "triangle");
|
|
27211
26951
|
}
|
|
27212
|
-
if (
|
|
26952
|
+
if (!this.root.has("points")) {
|
|
27213
26953
|
this.root.set("points", new Y7.Array());
|
|
27214
26954
|
}
|
|
27215
26955
|
}
|
|
@@ -27241,9 +26981,9 @@ var TriangleModel = class extends ElementModel {
|
|
|
27241
26981
|
return;
|
|
27242
26982
|
}
|
|
27243
26983
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27244
|
-
const p1 = new this.scope.Point(this.
|
|
27245
|
-
const p2 = new this.scope.Point(this.
|
|
27246
|
-
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);
|
|
27247
26987
|
this.item.removeSegments();
|
|
27248
26988
|
this.item.moveTo(p1);
|
|
27249
26989
|
this.item.lineTo(p2);
|
|
@@ -27255,7 +26995,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
27255
26995
|
config.controlPoints.push({
|
|
27256
26996
|
name: "triangle",
|
|
27257
26997
|
getPosition: () => {
|
|
27258
|
-
const point = new this.scope.Point(this.
|
|
26998
|
+
const point = new this.scope.Point(this.points[0], this.points[1]);
|
|
27259
26999
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27260
27000
|
return this.scope.project.view.projectToView(point.transform(pointsMatrix));
|
|
27261
27001
|
},
|
|
@@ -27265,7 +27005,7 @@ var TriangleModel = class extends ElementModel {
|
|
|
27265
27005
|
}
|
|
27266
27006
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27267
27007
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27268
|
-
const oldPoints = this.
|
|
27008
|
+
const oldPoints = this.points;
|
|
27269
27009
|
this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3], oldPoints[4], oldPoints[5]]);
|
|
27270
27010
|
}
|
|
27271
27011
|
});
|
|
@@ -27304,34 +27044,25 @@ function _toPrimitive12(t, r) {
|
|
|
27304
27044
|
return ("string" === r ? String : Number)(t);
|
|
27305
27045
|
}
|
|
27306
27046
|
var RectangleModel = class extends ElementModel {
|
|
27307
|
-
|
|
27308
|
-
|
|
27309
|
-
return this.localPoints;
|
|
27310
|
-
}
|
|
27311
|
-
return this.points;
|
|
27312
|
-
}
|
|
27313
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27314
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27047
|
+
constructor(root, scope, liveCursor) {
|
|
27048
|
+
super(root, scope, liveCursor);
|
|
27315
27049
|
_defineProperty12(this, "item", null);
|
|
27316
|
-
|
|
27317
|
-
_defineProperty12(this, "shouldUseLocalPoints", true);
|
|
27318
|
-
_defineProperty12(this, "localPointsPick", 4);
|
|
27319
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27050
|
+
if (!this.root.has("type")) {
|
|
27320
27051
|
this.root.set("type", "rectangle");
|
|
27321
27052
|
}
|
|
27322
|
-
if (
|
|
27053
|
+
if (!this.root.has("points")) {
|
|
27323
27054
|
const initPoints = new Y8.Array();
|
|
27324
27055
|
initPoints.push([0, 0, 0, 0]);
|
|
27325
27056
|
this.root.set("points", initPoints);
|
|
27326
27057
|
}
|
|
27327
|
-
if (
|
|
27058
|
+
if (!this.root.has("radius")) {
|
|
27328
27059
|
this.root.set("radius", 0);
|
|
27329
27060
|
}
|
|
27330
27061
|
}
|
|
27331
27062
|
subDispose() {
|
|
27332
27063
|
}
|
|
27333
27064
|
liveCursorPoint() {
|
|
27334
|
-
const points = this.
|
|
27065
|
+
const points = this.points;
|
|
27335
27066
|
if (points.length < 4) {
|
|
27336
27067
|
return null;
|
|
27337
27068
|
}
|
|
@@ -27339,7 +27070,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27339
27070
|
return new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
27340
27071
|
}
|
|
27341
27072
|
createSegments() {
|
|
27342
|
-
const [a2, b2, c, d] = this.
|
|
27073
|
+
const [a2, b2, c, d] = this.points;
|
|
27343
27074
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27344
27075
|
const maxRadius = this.maxRadiusLength();
|
|
27345
27076
|
const radius = this.root.get("radius") * maxRadius;
|
|
@@ -27404,7 +27135,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27404
27135
|
}
|
|
27405
27136
|
maxRadiusLength() {
|
|
27406
27137
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27407
|
-
const points = this.
|
|
27138
|
+
const points = this.points;
|
|
27408
27139
|
const topLeft = new this.scope.Point(points[0], points[1]).transform(pointsMatrix);
|
|
27409
27140
|
const topRight = new this.scope.Point(points[2], points[1]).transform(pointsMatrix);
|
|
27410
27141
|
const bottomLeft = new this.scope.Point(points[0], points[3]).transform(pointsMatrix);
|
|
@@ -27429,7 +27160,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27429
27160
|
name: "rect-radius",
|
|
27430
27161
|
getPosition: () => {
|
|
27431
27162
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27432
|
-
const points = this.
|
|
27163
|
+
const points = this.points;
|
|
27433
27164
|
const radius = this.root.get("radius") * this.maxRadiusLength();
|
|
27434
27165
|
let c1 = new this.scope.Point(points[0], points[1]).transform(matrix);
|
|
27435
27166
|
const c3 = new this.scope.Point(points[2], points[3]).transform(matrix);
|
|
@@ -27448,7 +27179,7 @@ var RectangleModel = class extends ElementModel {
|
|
|
27448
27179
|
if (!this.item) {
|
|
27449
27180
|
return;
|
|
27450
27181
|
}
|
|
27451
|
-
const points = this.
|
|
27182
|
+
const points = this.points;
|
|
27452
27183
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27453
27184
|
const maxRadius = Math.min(points[2] - points[0], points[3] - points[1]) / 2;
|
|
27454
27185
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
@@ -27478,7 +27209,7 @@ var elementsUndoOrigin = "elementsUndoOrigin";
|
|
|
27478
27209
|
|
|
27479
27210
|
// src/model/renderable/EraserModel.ts
|
|
27480
27211
|
var Y9 = __toESM(require("yjs"), 1);
|
|
27481
|
-
var
|
|
27212
|
+
var import_lodash5 = __toESM(require_lodash(), 1);
|
|
27482
27213
|
function _defineProperty13(e, r, t) {
|
|
27483
27214
|
return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27484
27215
|
}
|
|
@@ -27497,23 +27228,14 @@ function _toPrimitive13(t, r) {
|
|
|
27497
27228
|
return ("string" === r ? String : Number)(t);
|
|
27498
27229
|
}
|
|
27499
27230
|
var EraserModel = class extends ElementModel {
|
|
27500
|
-
|
|
27501
|
-
|
|
27502
|
-
return this.localPoints;
|
|
27503
|
-
}
|
|
27504
|
-
return this.points;
|
|
27505
|
-
}
|
|
27506
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27507
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27231
|
+
constructor(root, scope, liveCursor) {
|
|
27232
|
+
super(root, scope, liveCursor);
|
|
27508
27233
|
_defineProperty13(this, "item", null);
|
|
27509
27234
|
_defineProperty13(this, "sliceBegin", 0);
|
|
27510
|
-
|
|
27511
|
-
_defineProperty13(this, "shouldUseLocalPoints", true);
|
|
27512
|
-
_defineProperty13(this, "localPointsPick", 4);
|
|
27513
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27235
|
+
if (!this.root.has("type")) {
|
|
27514
27236
|
this.root.set("type", "eraser");
|
|
27515
27237
|
}
|
|
27516
|
-
if (
|
|
27238
|
+
if (!this.root.has("points")) {
|
|
27517
27239
|
this.root.set("points", new Y9.Array());
|
|
27518
27240
|
}
|
|
27519
27241
|
}
|
|
@@ -27546,7 +27268,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27546
27268
|
return path;
|
|
27547
27269
|
}
|
|
27548
27270
|
parsePoints(points) {
|
|
27549
|
-
const groupPoints = (0,
|
|
27271
|
+
const groupPoints = (0, import_lodash5.chunk)(points, 2);
|
|
27550
27272
|
return ae(groupPoints, {
|
|
27551
27273
|
size: this.strokeWidth,
|
|
27552
27274
|
smoothing: 0.5,
|
|
@@ -27564,7 +27286,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27564
27286
|
});
|
|
27565
27287
|
}
|
|
27566
27288
|
matrixedPoints() {
|
|
27567
|
-
const currentPoints = (0,
|
|
27289
|
+
const currentPoints = (0, import_lodash5.chunk)(this.points, 2).slice(this.sliceBegin);
|
|
27568
27290
|
return currentPoints.map((_ref) => {
|
|
27569
27291
|
let [x, y] = _ref;
|
|
27570
27292
|
return new this.scope.Point(x, y);
|
|
@@ -27592,11 +27314,11 @@ var EraserModel = class extends ElementModel {
|
|
|
27592
27314
|
this.item.fillColor = new this.scope.Color(this.strokeColor);
|
|
27593
27315
|
this.onVectorUpdate();
|
|
27594
27316
|
this.item.onFrame = () => {
|
|
27595
|
-
if (!this.
|
|
27317
|
+
if (!this.points) {
|
|
27596
27318
|
return;
|
|
27597
27319
|
}
|
|
27598
|
-
if (this.
|
|
27599
|
-
this.sliceBegin = this.
|
|
27320
|
+
if (this.points.length / 2 > 50) {
|
|
27321
|
+
this.sliceBegin = this.points.length / 2 - 50;
|
|
27600
27322
|
}
|
|
27601
27323
|
};
|
|
27602
27324
|
}
|
|
@@ -27630,8 +27352,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27630
27352
|
|
|
27631
27353
|
// src/model/renderable/LaserPointerModel.ts
|
|
27632
27354
|
var Y10 = __toESM(require("yjs"), 1);
|
|
27633
|
-
var
|
|
27634
|
-
var import_forge_room4 = require("@netless/forge-room");
|
|
27355
|
+
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
27635
27356
|
function _defineProperty14(e, r, t) {
|
|
27636
27357
|
return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27637
27358
|
}
|
|
@@ -27650,18 +27371,24 @@ function _toPrimitive14(t, r) {
|
|
|
27650
27371
|
return ("string" === r ? String : Number)(t);
|
|
27651
27372
|
}
|
|
27652
27373
|
var LaserPointerModel = class extends ElementModel {
|
|
27653
|
-
constructor(clientId, root, scope, liveCursor, removeElement
|
|
27654
|
-
super(root, scope, liveCursor
|
|
27374
|
+
constructor(clientId, root, scope, liveCursor, removeElement) {
|
|
27375
|
+
super(root, scope, liveCursor);
|
|
27655
27376
|
_defineProperty14(this, "item", null);
|
|
27656
27377
|
_defineProperty14(this, "clientId", void 0);
|
|
27657
27378
|
_defineProperty14(this, "sliceBegin", 0);
|
|
27658
27379
|
_defineProperty14(this, "displayStrokeWidth", 8);
|
|
27659
27380
|
_defineProperty14(this, "cachedPoints", null);
|
|
27660
|
-
|
|
27661
|
-
|
|
27662
|
-
|
|
27663
|
-
|
|
27664
|
-
|
|
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) => {
|
|
27665
27392
|
if (!this.item) {
|
|
27666
27393
|
return;
|
|
27667
27394
|
}
|
|
@@ -27679,31 +27406,13 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27679
27406
|
this.onVectorUpdate();
|
|
27680
27407
|
if (evt.count >= 30) {
|
|
27681
27408
|
if (this.ownerId === this.clientId) {
|
|
27682
|
-
|
|
27409
|
+
removeElement(this.uuid);
|
|
27683
27410
|
}
|
|
27684
27411
|
}
|
|
27685
27412
|
};
|
|
27686
27413
|
}
|
|
27687
27414
|
}
|
|
27688
27415
|
});
|
|
27689
|
-
this.clientId = clientId;
|
|
27690
|
-
this.removeElement = removeElement;
|
|
27691
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27692
|
-
this.root.set("type", "laser");
|
|
27693
|
-
}
|
|
27694
|
-
if (this.root.doc && !this.root.has("points")) {
|
|
27695
|
-
this.root.set("points", new Y10.Array());
|
|
27696
|
-
}
|
|
27697
|
-
if (this.root.doc && !this.root.has("removed")) {
|
|
27698
|
-
this.root.set("removed", false);
|
|
27699
|
-
}
|
|
27700
|
-
}
|
|
27701
|
-
subBindObserver() {
|
|
27702
|
-
(0, import_forge_room4.removeObserver)(this.root, this.handleLaserPropChange);
|
|
27703
|
-
this.root.observe(this.handleLaserPropChange);
|
|
27704
|
-
}
|
|
27705
|
-
subDispose() {
|
|
27706
|
-
(0, import_forge_room4.removeObserver)(this.root, this.handleLaserPropChange);
|
|
27707
27416
|
}
|
|
27708
27417
|
beginRemoveAnimate() {
|
|
27709
27418
|
this.root.set("removed", true);
|
|
@@ -27756,8 +27465,7 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27756
27465
|
matrixedPoints() {
|
|
27757
27466
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27758
27467
|
const points = this.cachedPoints || this.points;
|
|
27759
|
-
|
|
27760
|
-
const groupPoints = (0, import_lodash5.chunk)(points, 2).slice(this.sliceBegin);
|
|
27468
|
+
const groupPoints = (0, import_lodash6.chunk)(points, 2).slice(this.sliceBegin);
|
|
27761
27469
|
return groupPoints.map((_ref) => {
|
|
27762
27470
|
let [x, y] = _ref;
|
|
27763
27471
|
return matrix.transform([x, y]);
|
|
@@ -27799,6 +27507,8 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27799
27507
|
onStyleKeyUpdate(_key) {
|
|
27800
27508
|
return;
|
|
27801
27509
|
}
|
|
27510
|
+
subDispose() {
|
|
27511
|
+
}
|
|
27802
27512
|
liveCursorPoint() {
|
|
27803
27513
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
27804
27514
|
if (yArray.length < 2) {
|
|
@@ -27811,7 +27521,7 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27811
27521
|
};
|
|
27812
27522
|
|
|
27813
27523
|
// src/WhitePermissions.ts
|
|
27814
|
-
var
|
|
27524
|
+
var import_forge_room3 = require("@netless/forge-room");
|
|
27815
27525
|
var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
27816
27526
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["none"] = 0] = "none";
|
|
27817
27527
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["draw"] = 1] = "draw";
|
|
@@ -27824,7 +27534,7 @@ var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
|
27824
27534
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["all"] = WhiteboardPermissionFlag2.draw | WhiteboardPermissionFlag2.editSelf | WhiteboardPermissionFlag2.editOthers | WhiteboardPermissionFlag2.deleteSelf | WhiteboardPermissionFlag2.deleteOthers | WhiteboardPermissionFlag2.mainView | WhiteboardPermissionFlag2.setOthersView] = "all";
|
|
27825
27535
|
return WhiteboardPermissionFlag2;
|
|
27826
27536
|
}({});
|
|
27827
|
-
var WhiteboardPermissions = class extends
|
|
27537
|
+
var WhiteboardPermissions = class extends import_forge_room3.AbstractApplicationPermissions {
|
|
27828
27538
|
/**
|
|
27829
27539
|
* 解析权限列表组合
|
|
27830
27540
|
* @param {number} value - 权限数字值
|
|
@@ -27837,7 +27547,7 @@ var WhiteboardPermissions = class extends import_forge_room5.AbstractApplication
|
|
|
27837
27547
|
|
|
27838
27548
|
// src/model/renderable/StraightLineModel.ts
|
|
27839
27549
|
var Y11 = __toESM(require("yjs"), 1);
|
|
27840
|
-
var
|
|
27550
|
+
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
27841
27551
|
function _defineProperty15(e, r, t) {
|
|
27842
27552
|
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27843
27553
|
}
|
|
@@ -27856,22 +27566,13 @@ function _toPrimitive15(t, r) {
|
|
|
27856
27566
|
return ("string" === r ? String : Number)(t);
|
|
27857
27567
|
}
|
|
27858
27568
|
var StraightLineModel = class extends ElementModel {
|
|
27859
|
-
|
|
27860
|
-
|
|
27861
|
-
return this.localPoints;
|
|
27862
|
-
}
|
|
27863
|
-
return this.points;
|
|
27864
|
-
}
|
|
27865
|
-
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
27866
|
-
super(root, scope, liveCursor, isPerformanceMode);
|
|
27569
|
+
constructor(root, scope, liveCursor) {
|
|
27570
|
+
super(root, scope, liveCursor);
|
|
27867
27571
|
_defineProperty15(this, "item", null);
|
|
27868
|
-
|
|
27869
|
-
_defineProperty15(this, "shouldUseLocalPoints", true);
|
|
27870
|
-
_defineProperty15(this, "localPointsPick", 4);
|
|
27871
|
-
if (this.root.doc && !this.root.has("type")) {
|
|
27572
|
+
if (!this.root.has("type")) {
|
|
27872
27573
|
this.root.set("type", "line");
|
|
27873
27574
|
}
|
|
27874
|
-
if (
|
|
27575
|
+
if (!this.root.has("points")) {
|
|
27875
27576
|
this.root.set("points", new Y11.Array());
|
|
27876
27577
|
}
|
|
27877
27578
|
}
|
|
@@ -27896,7 +27597,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27896
27597
|
}
|
|
27897
27598
|
renderLine() {
|
|
27898
27599
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27899
|
-
const papperPoints = (0,
|
|
27600
|
+
const papperPoints = (0, import_lodash7.chunk)(this.points, 2).map((item) => {
|
|
27900
27601
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
27901
27602
|
});
|
|
27902
27603
|
const path = new this.scope.Path();
|
|
@@ -27918,7 +27619,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27918
27619
|
name: "line-start",
|
|
27919
27620
|
getPosition: () => {
|
|
27920
27621
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27921
|
-
const points = this.
|
|
27622
|
+
const points = this.points;
|
|
27922
27623
|
const start = new this.scope.Point(points[0], points[1]);
|
|
27923
27624
|
return this.scope.project.view.projectToView(start.transform(matrix));
|
|
27924
27625
|
},
|
|
@@ -27928,15 +27629,14 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27928
27629
|
}
|
|
27929
27630
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27930
27631
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27931
|
-
|
|
27932
|
-
this.setPoints([trPoint.x, trPoint.y, oldPoints[2], oldPoints[3]]);
|
|
27632
|
+
this.setPoints([trPoint.x, trPoint.y, this.points[2], this.points[3]]);
|
|
27933
27633
|
}
|
|
27934
27634
|
});
|
|
27935
27635
|
cfg.controlPoints.push({
|
|
27936
27636
|
name: "line-end",
|
|
27937
27637
|
getPosition: () => {
|
|
27938
27638
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27939
|
-
const points = this.
|
|
27639
|
+
const points = this.points;
|
|
27940
27640
|
const end = new this.scope.Point(points[2], points[3]);
|
|
27941
27641
|
return this.scope.project.view.projectToView(end.transform(matrix));
|
|
27942
27642
|
},
|
|
@@ -27946,8 +27646,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27946
27646
|
}
|
|
27947
27647
|
const pointsMatrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27948
27648
|
const trPoint = point.transform(pointsMatrix.inverted());
|
|
27949
|
-
|
|
27950
|
-
this.setPoints([oldPoints[0], oldPoints[1], trPoint.x, trPoint.y]);
|
|
27649
|
+
this.setPoints([this.points[0], this.points[1], trPoint.x, trPoint.y]);
|
|
27951
27650
|
}
|
|
27952
27651
|
});
|
|
27953
27652
|
return cfg;
|
|
@@ -27993,13 +27692,10 @@ var ImageModel = class extends ElementModel {
|
|
|
27993
27692
|
get src() {
|
|
27994
27693
|
return this.root.get("src");
|
|
27995
27694
|
}
|
|
27996
|
-
constructor(root, scope, imageSets, liveCursor
|
|
27997
|
-
super(root, scope, liveCursor
|
|
27695
|
+
constructor(root, scope, imageSets, liveCursor) {
|
|
27696
|
+
super(root, scope, liveCursor);
|
|
27998
27697
|
_defineProperty16(this, "item", null);
|
|
27999
27698
|
_defineProperty16(this, "imageSets", void 0);
|
|
28000
|
-
_defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
|
|
28001
|
-
_defineProperty16(this, "shouldUseLocalPoints", true);
|
|
28002
|
-
_defineProperty16(this, "localPointsPick", 4);
|
|
28003
27699
|
this.imageSets = imageSets;
|
|
28004
27700
|
if (!this.root.has("type")) {
|
|
28005
27701
|
this.root.set("type", "image");
|
|
@@ -28082,7 +27778,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28082
27778
|
get uuid() {
|
|
28083
27779
|
return (0, import_uuid.v4)().replace(/-/g, "");
|
|
28084
27780
|
}
|
|
28085
|
-
constructor(
|
|
27781
|
+
constructor(layerId, shadowEmitter, elements, scope, toolbarModel, userManager, imageSets, liveCursor, hasPermission) {
|
|
28086
27782
|
super();
|
|
28087
27783
|
_defineProperty17(this, "scope", void 0);
|
|
28088
27784
|
_defineProperty17(this, "toolbarModel", void 0);
|
|
@@ -28095,7 +27791,6 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28095
27791
|
_defineProperty17(this, "shadowEmitter", void 0);
|
|
28096
27792
|
_defineProperty17(this, "imageSets", void 0);
|
|
28097
27793
|
_defineProperty17(this, "liveCursor", void 0);
|
|
28098
|
-
_defineProperty17(this, "isPerformanceMode", void 0);
|
|
28099
27794
|
_defineProperty17(this, "onElementsChange", (event) => {
|
|
28100
27795
|
for (const [key, value] of event.changes.keys.entries()) {
|
|
28101
27796
|
if (value.action === "add") {
|
|
@@ -28114,16 +27809,15 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28114
27809
|
}
|
|
28115
27810
|
}
|
|
28116
27811
|
});
|
|
28117
|
-
this.
|
|
28118
|
-
this.
|
|
28119
|
-
this.
|
|
28120
|
-
this.
|
|
28121
|
-
this.
|
|
28122
|
-
this.
|
|
28123
|
-
this.
|
|
28124
|
-
this.
|
|
28125
|
-
this.
|
|
28126
|
-
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;
|
|
28127
27821
|
this.elementModels = /* @__PURE__ */ new Map();
|
|
28128
27822
|
for (const key of this.elements.keys()) {
|
|
28129
27823
|
const type = this.elements.get(key)?.get("type");
|
|
@@ -28154,43 +27848,33 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28154
27848
|
convertToModel(yMap) {
|
|
28155
27849
|
const type = yMap.get("type");
|
|
28156
27850
|
let model = null;
|
|
28157
|
-
const uuid = yMap.get(ElementModel.KEYS.uuid);
|
|
28158
|
-
if (uuid) {
|
|
28159
|
-
const existingModel = this.elementModels.get(uuid);
|
|
28160
|
-
if (existingModel) {
|
|
28161
|
-
existingModel.shadowEmitter = this.shadowEmitter;
|
|
28162
|
-
existingModel.bindObserver();
|
|
28163
|
-
return existingModel;
|
|
28164
|
-
}
|
|
28165
|
-
}
|
|
28166
27851
|
if (type === "curve") {
|
|
28167
|
-
model = new CurveModel(yMap, this.scope, this.liveCursor
|
|
27852
|
+
model = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
28168
27853
|
} else if (["ellipse"].indexOf(type) >= 0) {
|
|
28169
|
-
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor
|
|
27854
|
+
model = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
28170
27855
|
} else if (type === "selector") {
|
|
28171
|
-
model = new SelectorModel(yMap, this.scope, this.liveCursor
|
|
27856
|
+
model = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
28172
27857
|
} else if (type === "arrow") {
|
|
28173
|
-
model = new LineModel(yMap, this.scope, this.liveCursor
|
|
27858
|
+
model = new LineModel(yMap, this.scope, this.liveCursor);
|
|
28174
27859
|
} else if (type === "line") {
|
|
28175
|
-
model = new StraightLineModel(yMap, this.scope, this.liveCursor
|
|
27860
|
+
model = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
28176
27861
|
} else if (type === "point-text") {
|
|
28177
|
-
model = new PointTextModel(yMap, this.scope, this.liveCursor
|
|
27862
|
+
model = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
28178
27863
|
} else if (type === "triangle") {
|
|
28179
|
-
model = new TriangleModel(yMap, this.scope, this.liveCursor
|
|
27864
|
+
model = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
28180
27865
|
} else if (type === "rectangle") {
|
|
28181
|
-
model = new RectangleModel(yMap, this.scope, this.liveCursor
|
|
27866
|
+
model = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
28182
27867
|
} else if (type === "eraser") {
|
|
28183
|
-
model = new EraserModel(yMap, this.scope, this.liveCursor
|
|
27868
|
+
model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
28184
27869
|
} else if (type === "laser") {
|
|
28185
|
-
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (
|
|
28186
|
-
this.removeElementItem(
|
|
28187
|
-
}
|
|
27870
|
+
model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
27871
|
+
this.removeElementItem(uuid);
|
|
27872
|
+
});
|
|
28188
27873
|
} else if (type === "image") {
|
|
28189
|
-
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor
|
|
27874
|
+
model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
28190
27875
|
}
|
|
28191
27876
|
if (model) {
|
|
28192
27877
|
model.shadowEmitter = this.shadowEmitter;
|
|
28193
|
-
model.bindObserver();
|
|
28194
27878
|
this.elementModels.set(model.uuid, model);
|
|
28195
27879
|
}
|
|
28196
27880
|
return model;
|
|
@@ -28204,7 +27888,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28204
27888
|
confirmPermission() {
|
|
28205
27889
|
const hasPermission = this.hasPermission(WhiteboardPermissionFlag.draw);
|
|
28206
27890
|
if (!hasPermission) {
|
|
28207
|
-
(0,
|
|
27891
|
+
(0, import_forge_room4.log)("[@netless/forge-whiteboard] no permission to draw", {}, "warn");
|
|
28208
27892
|
}
|
|
28209
27893
|
return hasPermission;
|
|
28210
27894
|
}
|
|
@@ -28221,8 +27905,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28221
27905
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28222
27906
|
this.elements.set(uuid, yMap);
|
|
28223
27907
|
}, elementsUndoOrigin);
|
|
28224
|
-
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor
|
|
28225
|
-
model.bindObserver();
|
|
27908
|
+
const model = new ImageModel(yMap, this.scope, this.imageSets, this.liveCursor);
|
|
28226
27909
|
model.root.set("src", src);
|
|
28227
27910
|
const initMatrix = new this.scope.Matrix();
|
|
28228
27911
|
const center = this.scope.project.view.center;
|
|
@@ -28239,10 +27922,8 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28239
27922
|
return null;
|
|
28240
27923
|
}
|
|
28241
27924
|
const yMap = new Y12.Map();
|
|
28242
|
-
const uuid = this.uuid;
|
|
28243
|
-
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28244
|
-
this.elementModels.set(uuid, curveModel);
|
|
28245
27925
|
this.elements.doc?.transact(() => {
|
|
27926
|
+
const uuid = this.uuid;
|
|
28246
27927
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28247
27928
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28248
27929
|
yMap.set("type", "curve");
|
|
@@ -28255,7 +27936,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28255
27936
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28256
27937
|
this.elements.set(uuid, yMap);
|
|
28257
27938
|
}, elementsUndoOrigin);
|
|
28258
|
-
curveModel.
|
|
27939
|
+
const curveModel = new CurveModel(yMap, this.scope, this.liveCursor);
|
|
28259
27940
|
this.initElement(curveModel);
|
|
28260
27941
|
return curveModel;
|
|
28261
27942
|
}
|
|
@@ -28264,17 +27945,11 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28264
27945
|
return null;
|
|
28265
27946
|
}
|
|
28266
27947
|
const yMap = new Y12.Map();
|
|
28267
|
-
const uuid = this.uuid;
|
|
28268
|
-
const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid2) => {
|
|
28269
|
-
this.removeElementItem(uuid2);
|
|
28270
|
-
}, this.isPerformanceMode);
|
|
28271
|
-
this.elementModels.set(uuid, model);
|
|
28272
27948
|
this.elements.doc?.transact(() => {
|
|
27949
|
+
const uuid = this.uuid;
|
|
28273
27950
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28274
27951
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28275
27952
|
yMap.set("type", "laser");
|
|
28276
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28277
|
-
yMap.set("removed", false);
|
|
28278
27953
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28279
27954
|
yMap.set(ElementModel.KEYS.strokeWidth, 8);
|
|
28280
27955
|
yMap.set(ElementModel.KEYS.strokeColor, "#F44336");
|
|
@@ -28282,8 +27957,9 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28282
27957
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28283
27958
|
this.elements.set(uuid, yMap);
|
|
28284
27959
|
}, elementsUndoOrigin);
|
|
28285
|
-
model.
|
|
28286
|
-
|
|
27960
|
+
const model = new LaserPointerModel(this.userManager.selfId, yMap, this.scope, this.liveCursor, (uuid) => {
|
|
27961
|
+
this.removeElementItem(uuid);
|
|
27962
|
+
});
|
|
28287
27963
|
return model;
|
|
28288
27964
|
}
|
|
28289
27965
|
createEraser() {
|
|
@@ -28291,14 +27967,11 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28291
27967
|
return null;
|
|
28292
27968
|
}
|
|
28293
27969
|
const yMap = new Y12.Map();
|
|
28294
|
-
const uuid = this.uuid;
|
|
28295
|
-
const model = new EraserModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28296
|
-
this.elementModels.set(uuid, model);
|
|
28297
27970
|
this.elements.doc?.transact(() => {
|
|
27971
|
+
const uuid = this.uuid;
|
|
28298
27972
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28299
27973
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28300
27974
|
yMap.set("type", "eraser");
|
|
28301
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28302
27975
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28303
27976
|
yMap.set(ElementModel.KEYS.strokeWidth, 4);
|
|
28304
27977
|
yMap.set(ElementModel.KEYS.strokeColor, "#9E9E9E");
|
|
@@ -28306,7 +27979,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28306
27979
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28307
27980
|
this.elements.set(uuid, yMap);
|
|
28308
27981
|
}, elementsUndoOrigin);
|
|
28309
|
-
model.
|
|
27982
|
+
const model = new EraserModel(yMap, this.scope, this.liveCursor);
|
|
28310
27983
|
return model;
|
|
28311
27984
|
}
|
|
28312
27985
|
createTriangle(shadow) {
|
|
@@ -28314,54 +27987,45 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28314
27987
|
return null;
|
|
28315
27988
|
}
|
|
28316
27989
|
const yMap = new Y12.Map();
|
|
28317
|
-
const uuid = this.uuid;
|
|
28318
|
-
const triangleModel = new TriangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28319
|
-
this.elementModels.set(uuid, triangleModel);
|
|
28320
27990
|
this.elements.doc?.transact(() => {
|
|
27991
|
+
const uuid = this.uuid;
|
|
28321
27992
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28322
27993
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28323
27994
|
yMap.set("type", "triangle");
|
|
28324
27995
|
if (shadow) {
|
|
28325
27996
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28326
27997
|
}
|
|
28327
|
-
yMap.set("points", new Y12.Array());
|
|
28328
27998
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28329
27999
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28330
28000
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28331
28001
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28332
28002
|
this.elements.set(uuid, yMap);
|
|
28333
28003
|
}, elementsUndoOrigin);
|
|
28334
|
-
|
|
28335
|
-
this.initElement(
|
|
28336
|
-
|
|
28337
|
-
return
|
|
28004
|
+
const triangle = new TriangleModel(yMap, this.scope, this.liveCursor);
|
|
28005
|
+
this.initElement(triangle);
|
|
28006
|
+
triangle.dashArray = this.toolbarModel.dashArray;
|
|
28007
|
+
return triangle;
|
|
28338
28008
|
}
|
|
28339
28009
|
createRectangle(shadow) {
|
|
28340
28010
|
if (!this.confirmPermission()) {
|
|
28341
28011
|
return null;
|
|
28342
28012
|
}
|
|
28343
28013
|
const yMap = new Y12.Map();
|
|
28344
|
-
const uuid = this.uuid;
|
|
28345
|
-
const rect = new RectangleModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28346
|
-
this.elementModels.set(uuid, rect);
|
|
28347
28014
|
this.elements.doc?.transact(() => {
|
|
28015
|
+
const uuid = this.uuid;
|
|
28348
28016
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28349
28017
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28350
28018
|
yMap.set("type", "rectangle");
|
|
28351
28019
|
if (shadow) {
|
|
28352
28020
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28353
28021
|
}
|
|
28354
|
-
const initPoints = new Y12.Array();
|
|
28355
|
-
initPoints.push([0, 0, 0, 0]);
|
|
28356
|
-
yMap.set("points", initPoints);
|
|
28357
|
-
yMap.set("radius", 0);
|
|
28358
28022
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28359
28023
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28360
28024
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28361
28025
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28362
28026
|
this.elements.set(uuid, yMap);
|
|
28363
28027
|
}, elementsUndoOrigin);
|
|
28364
|
-
rect.
|
|
28028
|
+
const rect = new RectangleModel(yMap, this.scope, this.liveCursor);
|
|
28365
28029
|
this.initElement(rect);
|
|
28366
28030
|
rect.dashArray = this.toolbarModel.dashArray;
|
|
28367
28031
|
return rect;
|
|
@@ -28371,24 +28035,21 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28371
28035
|
return null;
|
|
28372
28036
|
}
|
|
28373
28037
|
const yMap = new Y12.Map();
|
|
28374
|
-
const uuid = this.uuid;
|
|
28375
|
-
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor, this.isPerformanceMode);
|
|
28376
|
-
this.elementModels.set(uuid, segmentsModel);
|
|
28377
28038
|
this.elements.doc?.transact(() => {
|
|
28039
|
+
const uuid = this.uuid;
|
|
28378
28040
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28379
28041
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28380
28042
|
yMap.set("type", type);
|
|
28381
28043
|
if (shadow) {
|
|
28382
28044
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28383
28045
|
}
|
|
28384
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28385
28046
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28386
28047
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28387
28048
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28388
28049
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28389
28050
|
this.elements.set(uuid, yMap);
|
|
28390
28051
|
}, elementsUndoOrigin);
|
|
28391
|
-
segmentsModel.
|
|
28052
|
+
const segmentsModel = new SegmentsModel(yMap, this.scope, type, this.liveCursor);
|
|
28392
28053
|
this.initElement(segmentsModel);
|
|
28393
28054
|
segmentsModel.dashArray = this.toolbarModel.dashArray;
|
|
28394
28055
|
return segmentsModel;
|
|
@@ -28399,21 +28060,16 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28399
28060
|
return null;
|
|
28400
28061
|
}
|
|
28401
28062
|
const yMap = new Y12.Map();
|
|
28402
|
-
const uuid = this.uuid;
|
|
28403
|
-
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28404
|
-
this.elementModels.set(uuid, selectorModel);
|
|
28405
28063
|
this.elements.doc?.transact(() => {
|
|
28064
|
+
const uuid = this.uuid;
|
|
28406
28065
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28407
28066
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28408
28067
|
yMap.set("type", "selector");
|
|
28409
|
-
const initPoints = new Y12.Array();
|
|
28410
|
-
initPoints.push([0, 0, 0, 0]);
|
|
28411
|
-
yMap.set(ElementModel.KEYS.points, initPoints);
|
|
28412
28068
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28413
28069
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28414
28070
|
this.elements.set(uuid, yMap);
|
|
28415
28071
|
}, elementsUndoOrigin);
|
|
28416
|
-
selectorModel.
|
|
28072
|
+
const selectorModel = new SelectorModel(yMap, this.scope, this.liveCursor);
|
|
28417
28073
|
selectorModel.shadow = "layer";
|
|
28418
28074
|
return selectorModel;
|
|
28419
28075
|
}
|
|
@@ -28422,24 +28078,21 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28422
28078
|
return null;
|
|
28423
28079
|
}
|
|
28424
28080
|
const yMap = new Y12.Map();
|
|
28425
|
-
const uuid = this.uuid;
|
|
28426
|
-
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28427
|
-
this.elementModels.set(uuid, straightLineModel);
|
|
28428
28081
|
this.elements.doc?.transact(() => {
|
|
28082
|
+
const uuid = this.uuid;
|
|
28429
28083
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28430
28084
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28431
28085
|
yMap.set("type", "line");
|
|
28432
28086
|
if (shadow) {
|
|
28433
28087
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28434
28088
|
}
|
|
28435
|
-
yMap.set("points", new Y12.Array());
|
|
28436
28089
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28437
28090
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28438
28091
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28439
28092
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28440
28093
|
this.elements.set(uuid, yMap);
|
|
28441
28094
|
}, elementsUndoOrigin);
|
|
28442
|
-
straightLineModel.
|
|
28095
|
+
const straightLineModel = new StraightLineModel(yMap, this.scope, this.liveCursor);
|
|
28443
28096
|
this.initElement(straightLineModel);
|
|
28444
28097
|
straightLineModel.dashArray = this.toolbarModel.dashArray;
|
|
28445
28098
|
return straightLineModel;
|
|
@@ -28449,26 +28102,21 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28449
28102
|
return null;
|
|
28450
28103
|
}
|
|
28451
28104
|
const yMap = new Y12.Map();
|
|
28452
|
-
const uuid = this.uuid;
|
|
28453
|
-
const lineModel = new LineModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28454
|
-
this.elementModels.set(uuid, lineModel);
|
|
28455
28105
|
this.elements.doc?.transact(() => {
|
|
28106
|
+
const uuid = this.uuid;
|
|
28456
28107
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28457
28108
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28458
28109
|
yMap.set("type", "arrow");
|
|
28459
28110
|
if (shadow) {
|
|
28460
28111
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28461
28112
|
}
|
|
28462
|
-
yMap.set("headArrow", "none");
|
|
28463
|
-
yMap.set("tailArrow", "normal");
|
|
28464
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28465
28113
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28466
28114
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28467
28115
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28468
28116
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28469
28117
|
this.elements.set(uuid, yMap);
|
|
28470
28118
|
}, elementsUndoOrigin);
|
|
28471
|
-
lineModel.
|
|
28119
|
+
const lineModel = new LineModel(yMap, this.scope, this.liveCursor);
|
|
28472
28120
|
this.initElement(lineModel);
|
|
28473
28121
|
lineModel.dashArray = this.toolbarModel.dashArray;
|
|
28474
28122
|
return lineModel;
|
|
@@ -28478,24 +28126,21 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28478
28126
|
return null;
|
|
28479
28127
|
}
|
|
28480
28128
|
const yMap = new Y12.Map();
|
|
28481
|
-
const uuid = this.uuid;
|
|
28482
|
-
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor, this.isPerformanceMode);
|
|
28483
|
-
this.elementModels.set(uuid, pointTextModel);
|
|
28484
28129
|
this.elements.doc?.transact(() => {
|
|
28130
|
+
const uuid = this.uuid;
|
|
28485
28131
|
yMap.set(ElementModel.KEYS.index, ++this.maxIndex);
|
|
28486
28132
|
yMap.set(ElementModel.KEYS.uuid, uuid);
|
|
28487
28133
|
yMap.set("type", "point-text");
|
|
28488
28134
|
if (shadow) {
|
|
28489
28135
|
yMap.set(ElementModel.KEYS.shadow, "layer");
|
|
28490
28136
|
}
|
|
28491
|
-
yMap.set(ElementModel.KEYS.points, new Y12.Array());
|
|
28492
28137
|
yMap.set(ElementModel.KEYS.strokeWidth, this.toolbarModel.strokeWidth);
|
|
28493
28138
|
yMap.set(ElementModel.KEYS.strokeColor, this.toolbarModel.strokeColor);
|
|
28494
28139
|
yMap.set(ElementModel.KEYS.fillColor, this.toolbarModel.fillColor);
|
|
28495
28140
|
yMap.set(ElementModel.KEYS.ownerId, this.userManager.selfId);
|
|
28496
28141
|
this.elements.set(uuid, yMap);
|
|
28497
28142
|
}, elementsUndoOrigin);
|
|
28498
|
-
pointTextModel.
|
|
28143
|
+
const pointTextModel = new PointTextModel(yMap, this.scope, this.liveCursor);
|
|
28499
28144
|
pointTextModel.setPoints([x, y]);
|
|
28500
28145
|
pointTextModel.fontSize = this.toolbarModel.fontSize;
|
|
28501
28146
|
pointTextModel.fontFamily = this.toolbarModel.fontFamily;
|
|
@@ -28518,19 +28163,18 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28518
28163
|
});
|
|
28519
28164
|
}
|
|
28520
28165
|
dispose(clearElements) {
|
|
28521
|
-
(0,
|
|
28166
|
+
(0, import_forge_room4.removeObserver)(this.elements, this.onElementsChange);
|
|
28522
28167
|
if (clearElements) {
|
|
28523
28168
|
this.elements.clear();
|
|
28524
28169
|
}
|
|
28525
28170
|
Array.from(this.elementModels.values()).forEach((model) => {
|
|
28526
28171
|
model.dispose();
|
|
28527
|
-
model.disposeObserver();
|
|
28528
28172
|
});
|
|
28529
28173
|
}
|
|
28530
28174
|
};
|
|
28531
28175
|
|
|
28532
28176
|
// src/utils/Recognizer.ts
|
|
28533
|
-
var
|
|
28177
|
+
var import_lodash8 = __toESM(require_lodash(), 1);
|
|
28534
28178
|
|
|
28535
28179
|
// src/utils/UnistrokeRecognizer.js
|
|
28536
28180
|
function Point(x, y) {
|
|
@@ -28777,7 +28421,7 @@ var Recognizer = class {
|
|
|
28777
28421
|
let maxX = -Number.MAX_VALUE;
|
|
28778
28422
|
let minY = Number.MAX_VALUE;
|
|
28779
28423
|
let maxY = -Number.MAX_VALUE;
|
|
28780
|
-
const result = this.dollar.Recognize((0,
|
|
28424
|
+
const result = this.dollar.Recognize((0, import_lodash8.chunk)(points, 2).map((v) => {
|
|
28781
28425
|
minX = Math.min(minX, v[0]);
|
|
28782
28426
|
maxX = Math.max(maxX, v[0]);
|
|
28783
28427
|
minY = Math.min(minY, v[1]);
|
|
@@ -28821,24 +28465,11 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28821
28465
|
_defineProperty19(this, "elementModel", null);
|
|
28822
28466
|
_defineProperty19(this, "recognizer", new Recognizer());
|
|
28823
28467
|
_defineProperty19(this, "pointCount", 0);
|
|
28824
|
-
_defineProperty19(this, "pendingPoints", []);
|
|
28825
|
-
_defineProperty19(this, "flushRafId", 0);
|
|
28826
28468
|
_defineProperty19(this, "showLiveCursor", true);
|
|
28827
|
-
|
|
28828
|
-
this.flushRafId = 0;
|
|
28829
|
-
if (this.elementModel && this.pendingPoints.length > 0) {
|
|
28830
|
-
this.elementModel.appendPoints(this.pendingPoints);
|
|
28831
|
-
this.pendingPoints = [];
|
|
28832
|
-
}
|
|
28833
|
-
});
|
|
28469
|
+
this.tool.minDistance = 5;
|
|
28834
28470
|
}
|
|
28835
28471
|
onMouseDown(_event) {
|
|
28836
28472
|
this.pointCount = 0;
|
|
28837
|
-
this.pendingPoints = [];
|
|
28838
|
-
if (this.flushRafId) {
|
|
28839
|
-
cancelAnimationFrame(this.flushRafId);
|
|
28840
|
-
this.flushRafId = 0;
|
|
28841
|
-
}
|
|
28842
28473
|
if (this.elementModel) {
|
|
28843
28474
|
this.elementModel.dispose();
|
|
28844
28475
|
}
|
|
@@ -28853,38 +28484,27 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28853
28484
|
if (this.pointCount > 1024) {
|
|
28854
28485
|
return;
|
|
28855
28486
|
}
|
|
28856
|
-
const MIN_DISTANCE =
|
|
28487
|
+
const MIN_DISTANCE = 4;
|
|
28857
28488
|
if (this.elementModel) {
|
|
28858
|
-
|
|
28859
|
-
let
|
|
28860
|
-
|
|
28861
|
-
|
|
28862
|
-
|
|
28863
|
-
|
|
28864
|
-
|
|
28865
|
-
|
|
28866
|
-
|
|
28867
|
-
|
|
28868
|
-
}
|
|
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
|
+
};
|
|
28869
28499
|
}
|
|
28870
|
-
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));
|
|
28871
28501
|
if (dist >= MIN_DISTANCE) {
|
|
28872
28502
|
this.pointCount += 1;
|
|
28873
|
-
|
|
28874
|
-
const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
|
|
28875
|
-
this.pendingPoints.push(event.point.x, event.point.y, pressure);
|
|
28876
|
-
if (!this.flushRafId) {
|
|
28877
|
-
this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
|
|
28878
|
-
}
|
|
28503
|
+
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
28879
28504
|
}
|
|
28880
28505
|
}
|
|
28881
28506
|
}
|
|
28882
28507
|
onMouseUp(event) {
|
|
28883
|
-
if (this.flushRafId) {
|
|
28884
|
-
cancelAnimationFrame(this.flushRafId);
|
|
28885
|
-
this.flushRafId = 0;
|
|
28886
|
-
}
|
|
28887
|
-
this.flushPendingPoints();
|
|
28888
28508
|
this.modelGetter().then((model) => {
|
|
28889
28509
|
if (!model) {
|
|
28890
28510
|
return;
|
|
@@ -28985,7 +28605,7 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28985
28605
|
|
|
28986
28606
|
// src/model/ToolbarModel.ts
|
|
28987
28607
|
var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
|
|
28988
|
-
var
|
|
28608
|
+
var import_forge_room5 = require("@netless/forge-room");
|
|
28989
28609
|
function _defineProperty21(e, r, t) {
|
|
28990
28610
|
return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28991
28611
|
}
|
|
@@ -29082,7 +28702,7 @@ var ToolbarModel = class extends import_eventemitter32.default {
|
|
|
29082
28702
|
});
|
|
29083
28703
|
}
|
|
29084
28704
|
dispose() {
|
|
29085
|
-
(0,
|
|
28705
|
+
(0, import_forge_room5.removeObserver)(this.root, this.handleRootUpdate);
|
|
29086
28706
|
this.removeAllListeners();
|
|
29087
28707
|
}
|
|
29088
28708
|
};
|
|
@@ -29181,7 +28801,7 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
29181
28801
|
// src/model/SelectElementsModel.ts
|
|
29182
28802
|
var Y13 = __toESM(require("yjs"), 1);
|
|
29183
28803
|
var import_eventemitter33 = __toESM(require("eventemitter3"), 1);
|
|
29184
|
-
var
|
|
28804
|
+
var import_forge_room6 = require("@netless/forge-room");
|
|
29185
28805
|
|
|
29186
28806
|
// src/WhiteboardKeys.ts
|
|
29187
28807
|
var WhiteboardKeys = {
|
|
@@ -29231,7 +28851,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29231
28851
|
}
|
|
29232
28852
|
const cb = this.observers.get(user.id);
|
|
29233
28853
|
if (cb) {
|
|
29234
|
-
(0,
|
|
28854
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
29235
28855
|
this.observers.delete(user.id);
|
|
29236
28856
|
}
|
|
29237
28857
|
});
|
|
@@ -29240,7 +28860,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29240
28860
|
this.handleUserSelectElementsChange(user.id, evts);
|
|
29241
28861
|
};
|
|
29242
28862
|
if (this.observers.has(user.id)) {
|
|
29243
|
-
(0,
|
|
28863
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
29244
28864
|
this.observers.delete(user.id);
|
|
29245
28865
|
}
|
|
29246
28866
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
@@ -29263,7 +28883,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29263
28883
|
this.handleUserSelectElementsChange(userId, evts);
|
|
29264
28884
|
};
|
|
29265
28885
|
if (this.observers.has(userId)) {
|
|
29266
|
-
(0,
|
|
28886
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(userId), this.observers.get(userId));
|
|
29267
28887
|
}
|
|
29268
28888
|
this.requestUserMap(userId).observeDeep(observer);
|
|
29269
28889
|
this.observers.set(userId, observer);
|
|
@@ -29327,7 +28947,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29327
28947
|
}
|
|
29328
28948
|
dispose() {
|
|
29329
28949
|
for (const [key, value] of this.observers.entries()) {
|
|
29330
|
-
(0,
|
|
28950
|
+
(0, import_forge_room6.removeDeepObserver)(this.requestUserMap(key), value);
|
|
29331
28951
|
}
|
|
29332
28952
|
this.observers.clear();
|
|
29333
28953
|
this.userManager.off("leave", this.handleUserLeave);
|
|
@@ -30016,7 +29636,6 @@ var Editor = class extends import_eventemitter35.default {
|
|
|
30016
29636
|
this.shadowContainer.remove();
|
|
30017
29637
|
this.shadowScope.project.activeLayer.addChild(this.shadowContainer);
|
|
30018
29638
|
this.targets.forEach((model) => {
|
|
30019
|
-
console.log("[][][] translateShadow model", model.root._dEH);
|
|
30020
29639
|
model.shadow = this.shadowContainer.data.uuid;
|
|
30021
29640
|
});
|
|
30022
29641
|
}
|
|
@@ -30243,7 +29862,7 @@ var Gesture = class extends import_eventemitter36.default {
|
|
|
30243
29862
|
};
|
|
30244
29863
|
|
|
30245
29864
|
// src/Camera.ts
|
|
30246
|
-
var
|
|
29865
|
+
var import_forge_room7 = require("@netless/forge-room");
|
|
30247
29866
|
function _defineProperty28(e, r, t) {
|
|
30248
29867
|
return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30249
29868
|
}
|
|
@@ -30320,14 +29939,14 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30320
29939
|
}
|
|
30321
29940
|
const cb = this.observers.get(user.id);
|
|
30322
29941
|
if (cb) {
|
|
30323
|
-
(0,
|
|
29942
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(user.id), cb);
|
|
30324
29943
|
}
|
|
30325
29944
|
});
|
|
30326
29945
|
_defineProperty28(this, "handleUserJoin", (user) => {
|
|
30327
29946
|
if (this.observers.has(user.id)) {
|
|
30328
29947
|
const cb = this.observers.get(user.id);
|
|
30329
29948
|
if (cb) {
|
|
30330
|
-
(0,
|
|
29949
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(user.id), cb);
|
|
30331
29950
|
this.observers.delete(user.id);
|
|
30332
29951
|
}
|
|
30333
29952
|
}
|
|
@@ -30439,7 +30058,7 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30439
30058
|
this.handleViewMatrixUpdate(userId, evt);
|
|
30440
30059
|
};
|
|
30441
30060
|
if (this.observers.has(userId)) {
|
|
30442
|
-
(0,
|
|
30061
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(userId), observer);
|
|
30443
30062
|
}
|
|
30444
30063
|
this.requestUserMap(userId).observe(observer);
|
|
30445
30064
|
this.observers.set(userId, observer);
|
|
@@ -30636,10 +30255,10 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30636
30255
|
Array.from(this.observers.keys()).forEach((userId) => {
|
|
30637
30256
|
const cb = this.observers.get(userId);
|
|
30638
30257
|
if (cb) {
|
|
30639
|
-
(0,
|
|
30258
|
+
(0, import_forge_room7.removeObserver)(this.requestUserMap(userId), cb);
|
|
30640
30259
|
}
|
|
30641
30260
|
});
|
|
30642
|
-
(0,
|
|
30261
|
+
(0, import_forge_room7.removeObserver)(this.whiteboardAttrsMap, this.handleMainCameraChange);
|
|
30643
30262
|
this.userManager.off("join", this.handleUserJoin);
|
|
30644
30263
|
this.userManager.off("leave", this.handleUserLeave);
|
|
30645
30264
|
this.gesture.removeAllListeners();
|
|
@@ -30810,8 +30429,6 @@ var Whiteboard = class extends import_eventemitter38.default {
|
|
|
30810
30429
|
_defineProperty31(this, "enableCameraBoundaryHighlight", void 0);
|
|
30811
30430
|
_defineProperty31(this, "getElementAttribute", void 0);
|
|
30812
30431
|
_defineProperty31(this, "setElementAttribute", void 0);
|
|
30813
|
-
_defineProperty31(this, "setPerformanceMode", void 0);
|
|
30814
|
-
_defineProperty31(this, "isPerformanceMode", void 0);
|
|
30815
30432
|
_defineProperty31(this, "removeElement", void 0);
|
|
30816
30433
|
_defineProperty31(this, "getCurrentTool", void 0);
|
|
30817
30434
|
_defineProperty31(this, "setCurrentTool", void 0);
|
|
@@ -30932,7 +30549,7 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
30932
30549
|
// src/model/TrashedElementsModel.ts
|
|
30933
30550
|
var Y14 = __toESM(require("yjs"), 1);
|
|
30934
30551
|
var import_eventemitter39 = __toESM(require("eventemitter3"), 1);
|
|
30935
|
-
var
|
|
30552
|
+
var import_forge_room8 = require("@netless/forge-room");
|
|
30936
30553
|
function _defineProperty33(e, r, t) {
|
|
30937
30554
|
return (r = _toPropertyKey33(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30938
30555
|
}
|
|
@@ -30969,14 +30586,14 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30969
30586
|
}
|
|
30970
30587
|
const cb = this.observers.get(user.id);
|
|
30971
30588
|
if (cb) {
|
|
30972
|
-
(0,
|
|
30589
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
30973
30590
|
}
|
|
30974
30591
|
});
|
|
30975
30592
|
_defineProperty33(this, "handleUserJoin", (user) => {
|
|
30976
30593
|
if (this.observers.has(user.id)) {
|
|
30977
30594
|
const cb = this.observers.get(user.id);
|
|
30978
30595
|
if (cb) {
|
|
30979
|
-
(0,
|
|
30596
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
30980
30597
|
this.observers.delete(user.id);
|
|
30981
30598
|
}
|
|
30982
30599
|
}
|
|
@@ -30984,7 +30601,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30984
30601
|
this.handleUserTrashElementsChange(user.id, evts);
|
|
30985
30602
|
};
|
|
30986
30603
|
if (this.observers.has(user.id)) {
|
|
30987
|
-
(0,
|
|
30604
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
30988
30605
|
}
|
|
30989
30606
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
30990
30607
|
this.observers.set(user.id, observer);
|
|
@@ -30998,7 +30615,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30998
30615
|
this.handleUserTrashElementsChange(userId, evts);
|
|
30999
30616
|
};
|
|
31000
30617
|
if (this.observers.has(userId)) {
|
|
31001
|
-
(0,
|
|
30618
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(userId), userId);
|
|
31002
30619
|
}
|
|
31003
30620
|
this.requestUserMap(userId).observeDeep(observer);
|
|
31004
30621
|
this.observers.set(userId, observer);
|
|
@@ -31060,7 +30677,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
31060
30677
|
}
|
|
31061
30678
|
dispose() {
|
|
31062
30679
|
for (const [key, value] of this.observers.entries()) {
|
|
31063
|
-
(0,
|
|
30680
|
+
(0, import_forge_room8.removeDeepObserver)(this.requestUserMap(key), value);
|
|
31064
30681
|
}
|
|
31065
30682
|
this.observers.clear();
|
|
31066
30683
|
this.userManager.off("leave", this.handleUserLeave);
|
|
@@ -31110,24 +30727,9 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
31110
30727
|
if (this.pointCount > 1024) {
|
|
31111
30728
|
return;
|
|
31112
30729
|
}
|
|
31113
|
-
const MIN_DISTANCE = 4;
|
|
31114
30730
|
if (this.elementModel) {
|
|
31115
|
-
|
|
31116
|
-
|
|
31117
|
-
x: 0,
|
|
31118
|
-
y: 0
|
|
31119
|
-
};
|
|
31120
|
-
if (len >= 2) {
|
|
31121
|
-
last = {
|
|
31122
|
-
x: this.elementModel.points[len - 2],
|
|
31123
|
-
y: this.elementModel.points[len - 1]
|
|
31124
|
-
};
|
|
31125
|
-
}
|
|
31126
|
-
const dist = Math.max(Math.abs(last.x - event.point.x), Math.abs(last.y - event.point.y));
|
|
31127
|
-
if (dist >= MIN_DISTANCE) {
|
|
31128
|
-
this.pointCount += 1;
|
|
31129
|
-
this.elementModel.appendPoints([Math.round(event.point.x), Math.round(event.point.y)]);
|
|
31130
|
-
}
|
|
30731
|
+
this.pointCount += 1;
|
|
30732
|
+
this.elementModel.appendPoints([event.point.x, event.point.y]);
|
|
31131
30733
|
}
|
|
31132
30734
|
}
|
|
31133
30735
|
onMouseUp(_event) {
|
|
@@ -31139,7 +30741,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
31139
30741
|
|
|
31140
30742
|
// src/model/PageModel.ts
|
|
31141
30743
|
var import_eventemitter310 = __toESM(require("eventemitter3"), 1);
|
|
31142
|
-
var
|
|
30744
|
+
var import_forge_room9 = require("@netless/forge-room");
|
|
31143
30745
|
function _defineProperty35(e, r, t) {
|
|
31144
30746
|
return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
31145
30747
|
}
|
|
@@ -31172,7 +30774,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31172
30774
|
}
|
|
31173
30775
|
const cb = this.observers.get(user.id);
|
|
31174
30776
|
if (cb) {
|
|
31175
|
-
(0,
|
|
30777
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(user.id), cb);
|
|
31176
30778
|
}
|
|
31177
30779
|
});
|
|
31178
30780
|
_defineProperty35(this, "handleUserJoin", (user) => {
|
|
@@ -31186,7 +30788,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31186
30788
|
if (cameraMode === "main") {
|
|
31187
30789
|
const targetPage = this.whiteboardAttrsMap.get(WhiteboardKeys.currentPage);
|
|
31188
30790
|
if (!this.pageMap.has(targetPage) && targetPage !== "_i_") {
|
|
31189
|
-
(0,
|
|
30791
|
+
(0, import_forge_room9.log)(`main page {${targetPage}} not found.`, {}, "error");
|
|
31190
30792
|
return;
|
|
31191
30793
|
}
|
|
31192
30794
|
this.requestUserMap(this.userManager.selfId).set(WhiteboardKeys.currentPage, targetPage);
|
|
@@ -31233,7 +30835,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31233
30835
|
if (this.observers.has(userId)) {
|
|
31234
30836
|
const cb = this.observers.get(userId);
|
|
31235
30837
|
if (cb) {
|
|
31236
|
-
(0,
|
|
30838
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(userId), cb);
|
|
31237
30839
|
this.observers.delete(userId);
|
|
31238
30840
|
}
|
|
31239
30841
|
}
|
|
@@ -31322,12 +30924,12 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31322
30924
|
dispose() {
|
|
31323
30925
|
for (const entry of this.observers.entries()) {
|
|
31324
30926
|
const [userId, observer] = entry;
|
|
31325
|
-
(0,
|
|
30927
|
+
(0, import_forge_room9.removeObserver)(this.requestUserMap(userId), observer);
|
|
31326
30928
|
}
|
|
31327
30929
|
this.userManager.off("join", this.handleUserJoin);
|
|
31328
30930
|
this.userManager.off("leave", this.handleUserLeave);
|
|
31329
|
-
(0,
|
|
31330
|
-
(0,
|
|
30931
|
+
(0, import_forge_room9.removeObserver)(this.whiteboardAttrsMap, this.handleMainPageChange);
|
|
30932
|
+
(0, import_forge_room9.removeObserver)(this.pageMap, this.handlePageMapChange);
|
|
31331
30933
|
}
|
|
31332
30934
|
};
|
|
31333
30935
|
|
|
@@ -31342,8 +30944,8 @@ async function waitUntil(fn, timeout) {
|
|
|
31342
30944
|
|
|
31343
30945
|
// src/IndexedNavigation.ts
|
|
31344
30946
|
var import_eventemitter311 = __toESM(require("eventemitter3"), 1);
|
|
31345
|
-
var
|
|
31346
|
-
var
|
|
30947
|
+
var import_forge_room10 = require("@netless/forge-room");
|
|
30948
|
+
var import_forge_room11 = require("@netless/forge-room");
|
|
31347
30949
|
function _defineProperty36(e, r, t) {
|
|
31348
30950
|
return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
31349
30951
|
}
|
|
@@ -31370,7 +30972,7 @@ var IndexedNavigation = class extends import_eventemitter311.default {
|
|
|
31370
30972
|
return this.list[key] && this.list[key].prev === "";
|
|
31371
30973
|
});
|
|
31372
30974
|
if (!headId) {
|
|
31373
|
-
(0,
|
|
30975
|
+
(0, import_forge_room10.log)("indexed navigation confusion", {
|
|
31374
30976
|
list: JSON.stringify(this.list)
|
|
31375
30977
|
}, "error");
|
|
31376
30978
|
throw new Error("indexed navigation confusion");
|
|
@@ -31686,7 +31288,7 @@ var IndexedNavigation = class extends import_eventemitter311.default {
|
|
|
31686
31288
|
}
|
|
31687
31289
|
}
|
|
31688
31290
|
dispose() {
|
|
31689
|
-
(0,
|
|
31291
|
+
(0, import_forge_room11.removeObserver)(this.indexedPageMap, this.handleIndexedPageMapUpdate);
|
|
31690
31292
|
this.pageModel.off("switchPage");
|
|
31691
31293
|
this.pageModel.off("pagesChange");
|
|
31692
31294
|
}
|
|
@@ -31907,7 +31509,7 @@ var SequenceExecutor = class {
|
|
|
31907
31509
|
};
|
|
31908
31510
|
|
|
31909
31511
|
// src/WhiteboardApplication.ts
|
|
31910
|
-
var
|
|
31512
|
+
var import_forge_room13 = require("@netless/forge-room");
|
|
31911
31513
|
|
|
31912
31514
|
// src/LiveCursor.ts
|
|
31913
31515
|
function _defineProperty42(e, r, t) {
|
|
@@ -31962,19 +31564,9 @@ var LiveCursor = class {
|
|
|
31962
31564
|
cursor.style.fontSize = "12px";
|
|
31963
31565
|
cursor.style.padding = "2px 4px";
|
|
31964
31566
|
cursor.style.borderRadius = "4px";
|
|
31965
|
-
this.
|
|
31567
|
+
cursor.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
|
|
31966
31568
|
return cursor;
|
|
31967
31569
|
}
|
|
31968
|
-
updateCursorLabel(userId, cursor) {
|
|
31969
|
-
const target = cursor ?? this.cursors.get(userId);
|
|
31970
|
-
if (!target) {
|
|
31971
|
-
return;
|
|
31972
|
-
}
|
|
31973
|
-
if (target.textContent && target.textContent !== userId) {
|
|
31974
|
-
return;
|
|
31975
|
-
}
|
|
31976
|
-
target.textContent = this.userManager.getUser(userId)?.nickName ?? userId;
|
|
31977
|
-
}
|
|
31978
31570
|
isOnSamePage(userId) {
|
|
31979
31571
|
const otherPage = this.requestUserMap(userId).get(WhiteboardKeys.currentPage);
|
|
31980
31572
|
const selfPage = this.requestUserMap(this.userManager.selfId).get(WhiteboardKeys.currentPage);
|
|
@@ -32010,7 +31602,6 @@ var LiveCursor = class {
|
|
|
32010
31602
|
}
|
|
32011
31603
|
const cursor = this.cursors.get(userId);
|
|
32012
31604
|
if (cursor) {
|
|
32013
|
-
this.updateCursorLabel(userId, cursor);
|
|
32014
31605
|
const viewPoint = this.paperScope.project.view.projectToView(point);
|
|
32015
31606
|
cursor.style.left = viewPoint.x + "px";
|
|
32016
31607
|
cursor.style.top = viewPoint.y + "px";
|
|
@@ -32075,7 +31666,7 @@ var AsyncMap = class {
|
|
|
32075
31666
|
if (!window.__forge_gl_wb_status__) {
|
|
32076
31667
|
window.__forge_gl_wb_status__ = new AsyncMap();
|
|
32077
31668
|
}
|
|
32078
|
-
var WhiteboardApplication = class _WhiteboardApplication extends
|
|
31669
|
+
var WhiteboardApplication = class _WhiteboardApplication extends import_forge_room12.AbstractApplication {
|
|
32079
31670
|
get undoManager() {
|
|
32080
31671
|
const page = this.pageModel.getCurrentPage(this.userId);
|
|
32081
31672
|
if (page) {
|
|
@@ -32126,7 +31717,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32126
31717
|
_defineProperty43(this, "permissions", void 0);
|
|
32127
31718
|
_defineProperty43(this, "inputType", "any");
|
|
32128
31719
|
_defineProperty43(this, "isPenEvent", false);
|
|
32129
|
-
_defineProperty43(this, "activePenPointerId", null);
|
|
32130
31720
|
_defineProperty43(this, "hasPenInput", null);
|
|
32131
31721
|
_defineProperty43(this, "disableViewModelUpdate", false);
|
|
32132
31722
|
_defineProperty43(this, "internalResizeObserver", true);
|
|
@@ -32222,7 +31812,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32222
31812
|
}
|
|
32223
31813
|
} else {
|
|
32224
31814
|
console.warn(`[@netless/forge-whiteboard] page ${pageId} not found`);
|
|
32225
|
-
(0,
|
|
31815
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "warn");
|
|
32226
31816
|
}
|
|
32227
31817
|
await waitUntil(() => this.undoManagers.has(pageId), 1e3);
|
|
32228
31818
|
if (this.undoManagers.has(pageId)) {
|
|
@@ -32234,7 +31824,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32234
31824
|
this.undoManagers.get(pageId).on("stack-item-popped", this.handleStackItemPopped);
|
|
32235
31825
|
} else {
|
|
32236
31826
|
console.warn(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`);
|
|
32237
|
-
(0,
|
|
31827
|
+
(0, import_forge_room12.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "warn");
|
|
32238
31828
|
}
|
|
32239
31829
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
32240
31830
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
@@ -32243,9 +31833,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32243
31833
|
_defineProperty43(this, "hasPermission", (flag) => {
|
|
32244
31834
|
return this.permissions.hasPermission(flag, this.userId);
|
|
32245
31835
|
});
|
|
32246
|
-
_defineProperty43(this, "isPerformanceMode", () => {
|
|
32247
|
-
return this.option.performance ?? false;
|
|
32248
|
-
});
|
|
32249
31836
|
_defineProperty43(this, "handleStackItemAdded", () => {
|
|
32250
31837
|
this.selectElementsModel.clearSelectElementForSelf();
|
|
32251
31838
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
@@ -32260,18 +31847,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32260
31847
|
const id = ids[i];
|
|
32261
31848
|
if (!this.layers.has(id)) {
|
|
32262
31849
|
const elementsMap = this.getMap(`layer/${id}/elements`);
|
|
32263
|
-
const renderableModel = new RenderableModel(
|
|
32264
|
-
layerId: id,
|
|
32265
|
-
shadowEmitter: this.shadowEmitter,
|
|
32266
|
-
elements: elementsMap,
|
|
32267
|
-
scope: this.paperScope,
|
|
32268
|
-
toolbarModel: this.toolbarModel,
|
|
32269
|
-
userManager: this.userManager,
|
|
32270
|
-
imageSets: this.imageSets,
|
|
32271
|
-
liveCursor: this.liveCursor,
|
|
32272
|
-
hasPermission: this.hasPermission,
|
|
32273
|
-
isPerformanceMode: this.isPerformanceMode
|
|
32274
|
-
});
|
|
31850
|
+
const renderableModel = new RenderableModel(id, this.shadowEmitter, elementsMap, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission);
|
|
32275
31851
|
this.layers.set(id, renderableModel);
|
|
32276
31852
|
}
|
|
32277
31853
|
if (!this.undoManagers.has(id)) {
|
|
@@ -32455,34 +32031,11 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32455
32031
|
this.imageSets.setAttribute("data-image-sets", "");
|
|
32456
32032
|
this.rootElement.appendChild(this.imageSets);
|
|
32457
32033
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
32458
|
-
|
|
32459
|
-
|
|
32460
|
-
this.
|
|
32461
|
-
|
|
32462
|
-
|
|
32463
|
-
this.inputType = "pen";
|
|
32464
|
-
this.emitter.emit("inputTypeChange", this.inputType);
|
|
32465
|
-
}
|
|
32466
|
-
} else {
|
|
32467
|
-
if (this.activePenPointerId === null) {
|
|
32468
|
-
this.isPenEvent = false;
|
|
32469
|
-
}
|
|
32470
|
-
}
|
|
32471
|
-
}, {
|
|
32472
|
-
capture: true
|
|
32473
|
-
});
|
|
32474
|
-
document.body.addEventListener("pointerup", (evt) => {
|
|
32475
|
-
if (evt.pointerId === this.activePenPointerId) {
|
|
32476
|
-
this.activePenPointerId = null;
|
|
32477
|
-
this.isPenEvent = false;
|
|
32478
|
-
}
|
|
32479
|
-
}, {
|
|
32480
|
-
capture: true
|
|
32481
|
-
});
|
|
32482
|
-
document.body.addEventListener("pointercancel", (evt) => {
|
|
32483
|
-
if (evt.pointerId === this.activePenPointerId) {
|
|
32484
|
-
this.activePenPointerId = null;
|
|
32485
|
-
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);
|
|
32486
32039
|
}
|
|
32487
32040
|
}, {
|
|
32488
32041
|
capture: true
|
|
@@ -32538,7 +32091,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32538
32091
|
this.emitter.setViewModeToFree = (userId) => {
|
|
32539
32092
|
if (that.disableViewModelUpdate) {
|
|
32540
32093
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32541
|
-
(0,
|
|
32094
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32542
32095
|
return;
|
|
32543
32096
|
}
|
|
32544
32097
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32549,7 +32102,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32549
32102
|
this.emitter.setViewModeToFlow = (flowId, userId) => {
|
|
32550
32103
|
if (that.disableViewModelUpdate) {
|
|
32551
32104
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32552
|
-
(0,
|
|
32105
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32553
32106
|
return;
|
|
32554
32107
|
}
|
|
32555
32108
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32561,16 +32114,10 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32561
32114
|
this.camera.resetViewMatrixToFlow(flowId);
|
|
32562
32115
|
}
|
|
32563
32116
|
};
|
|
32564
|
-
this.emitter.setPerformanceMode = (enabled) => {
|
|
32565
|
-
this.option.performance = enabled;
|
|
32566
|
-
};
|
|
32567
|
-
this.emitter.isPerformanceMode = () => {
|
|
32568
|
-
return this.isPerformanceMode();
|
|
32569
|
-
};
|
|
32570
32117
|
this.emitter.setViewModeToMain = (userId) => {
|
|
32571
32118
|
if (that.disableViewModelUpdate) {
|
|
32572
32119
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32573
|
-
(0,
|
|
32120
|
+
(0, import_forge_room12.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32574
32121
|
return;
|
|
32575
32122
|
}
|
|
32576
32123
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32584,7 +32131,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32584
32131
|
};
|
|
32585
32132
|
this.emitter.insertImage = (src, pageId) => {
|
|
32586
32133
|
if (!/https/.test(src)) {
|
|
32587
|
-
(0,
|
|
32134
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] invalid image url, src needs to be in the HTTPS protocol.", {
|
|
32588
32135
|
src
|
|
32589
32136
|
}, "warn");
|
|
32590
32137
|
return;
|
|
@@ -32594,14 +32141,14 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32594
32141
|
targetPageId = this.pageModel.getCurrentPage(this.userManager.selfId);
|
|
32595
32142
|
}
|
|
32596
32143
|
if (!targetPageId) {
|
|
32597
|
-
(0,
|
|
32144
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warn");
|
|
32598
32145
|
return;
|
|
32599
32146
|
}
|
|
32600
32147
|
this.layers.get(targetPageId)?.createImage(src);
|
|
32601
32148
|
};
|
|
32602
32149
|
this.emitter.removeElement = (pageId, elementId) => {
|
|
32603
32150
|
if (!this.layers.has(pageId)) {
|
|
32604
|
-
(0,
|
|
32151
|
+
(0, import_forge_room12.log)("[@netless/forge-whiteboard] page not found", {}, "warn");
|
|
32605
32152
|
return;
|
|
32606
32153
|
}
|
|
32607
32154
|
this.layers.get(pageId)?.removeElementItem(elementId);
|
|
@@ -32621,18 +32168,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32621
32168
|
const source = this.getMap(`layer/${sourceId}/elements`);
|
|
32622
32169
|
const target = this.getMap(`layer/${targetId}/elements`);
|
|
32623
32170
|
if (!this.layers.has(targetId)) {
|
|
32624
|
-
this.layers.set(targetId, new RenderableModel(
|
|
32625
|
-
layerId: targetId,
|
|
32626
|
-
shadowEmitter: this.shadowEmitter,
|
|
32627
|
-
elements: target,
|
|
32628
|
-
scope: this.paperScope,
|
|
32629
|
-
toolbarModel: this.toolbarModel,
|
|
32630
|
-
userManager: this.userManager,
|
|
32631
|
-
imageSets: this.imageSets,
|
|
32632
|
-
liveCursor: this.liveCursor,
|
|
32633
|
-
hasPermission: this.hasPermission,
|
|
32634
|
-
isPerformanceMode: this.isPerformanceMode
|
|
32635
|
-
}));
|
|
32171
|
+
this.layers.set(targetId, new RenderableModel(targetId, this.shadowEmitter, target, this.paperScope, this.toolbarModel, this.userManager, this.imageSets, this.liveCursor, this.hasPermission));
|
|
32636
32172
|
}
|
|
32637
32173
|
if (!this.undoManagers.has(targetId)) {
|
|
32638
32174
|
const undoManager = new Y15.UndoManager(target, {
|
|
@@ -32701,15 +32237,15 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32701
32237
|
this.liveCursor.showLiveCursor = value;
|
|
32702
32238
|
};
|
|
32703
32239
|
this.emitter.updateViewport = (width, height) => {
|
|
32704
|
-
(0,
|
|
32240
|
+
(0, import_forge_room12.log)(`call updateViewport with width: ${width}, height: ${height}`);
|
|
32705
32241
|
this.updateOptionSize(width, height);
|
|
32706
32242
|
};
|
|
32707
32243
|
this.emitter.__setMainCanvasVisible = (visible) => {
|
|
32708
|
-
(0,
|
|
32244
|
+
(0, import_forge_room12.log)(`call __setMainCanvasVisible with visible: ${visible}`);
|
|
32709
32245
|
this.canvasElement.style.opacity = visible ? "1" : "0";
|
|
32710
32246
|
};
|
|
32711
32247
|
this.emitter.on("error", (errorCode, errorMessage) => {
|
|
32712
|
-
(0,
|
|
32248
|
+
(0, import_forge_room12.log)("WhiteboardApplicationError", {
|
|
32713
32249
|
errorCode,
|
|
32714
32250
|
errorMessage
|
|
32715
32251
|
});
|
|
@@ -32719,7 +32255,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32719
32255
|
return that.delayTranslateOut;
|
|
32720
32256
|
},
|
|
32721
32257
|
set(value) {
|
|
32722
|
-
(0,
|
|
32258
|
+
(0, import_forge_room12.log)(`call __delayTranslateOut with value: ${value}`);
|
|
32723
32259
|
that.delayTranslateOut = value;
|
|
32724
32260
|
}
|
|
32725
32261
|
});
|
|
@@ -32822,7 +32358,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32822
32358
|
}
|
|
32823
32359
|
async initialize(option) {
|
|
32824
32360
|
_WhiteboardApplication.instanceCount.set(this.appId, (_WhiteboardApplication.instanceCount.get(this.appId) ?? 0) + 1);
|
|
32825
|
-
(0,
|
|
32361
|
+
(0, import_forge_room12.log)(`whiteboard ${this.appId} initialize. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
|
|
32826
32362
|
this.appDoc.transact(() => {
|
|
32827
32363
|
this.permissions = new WhiteboardPermissions(this.writableManager, this.userManager, (userId) => {
|
|
32828
32364
|
return this.userMap(userId);
|
|
@@ -32867,11 +32403,6 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32867
32403
|
this.editors.forEach((editor) => {
|
|
32868
32404
|
editor.updateBounds();
|
|
32869
32405
|
});
|
|
32870
|
-
const area = this.paperScope.project.view.size.width * this.paperScope.project.view.size.height;
|
|
32871
|
-
const minDistance = Math.ceil(area / 4e5);
|
|
32872
|
-
Object.keys(this.tools).forEach((key) => {
|
|
32873
|
-
this.tools[key].tool.minDistance = minDistance;
|
|
32874
|
-
});
|
|
32875
32406
|
});
|
|
32876
32407
|
this.camera.on("userPageChange", (userId, pageId) => {
|
|
32877
32408
|
this.emitter.emit("activePageChange", userId, pageId);
|
|
@@ -32933,7 +32464,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32933
32464
|
this.paperScope.tool = this.tools[this.toolbarModel.currentTool].tool;
|
|
32934
32465
|
} else {
|
|
32935
32466
|
this.paperScope.tool = this.tools["curve"].tool;
|
|
32936
|
-
(0,
|
|
32467
|
+
(0, import_forge_room12.log)(`${this.toolbarModel.currentTool} not supported, backup to curve`);
|
|
32937
32468
|
}
|
|
32938
32469
|
this.selectElementsModel.on("elementsChange", this.handleElementsSelect);
|
|
32939
32470
|
this.trashedElementsModel.on("elementsChange", this.handleElementsTrash);
|
|
@@ -33220,8 +32751,8 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
33220
32751
|
this.toolbarModel.dispose();
|
|
33221
32752
|
this.emitter.indexedNavigation.dispose();
|
|
33222
32753
|
this.permissions.dispose();
|
|
33223
|
-
(0,
|
|
33224
|
-
(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");
|
|
33225
32756
|
}
|
|
33226
32757
|
};
|
|
33227
32758
|
_defineProperty43(WhiteboardApplication, "instanceCount", /* @__PURE__ */ new Map());
|