@netless/forge-whiteboard 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WhiteboardApplication.d.ts +1 -0
- package/dist/WhiteboardApplication.d.ts.map +1 -1
- package/dist/model/renderable/CurveModel.d.ts +0 -2
- package/dist/model/renderable/CurveModel.d.ts.map +1 -1
- package/dist/tool/CurveTool.d.ts +3 -0
- package/dist/tool/CurveTool.d.ts.map +1 -1
- package/dist/tool/WhiteboardTool.d.ts +4 -0
- package/dist/tool/WhiteboardTool.d.ts.map +1 -1
- package/dist/utils/paperjs.d.ts.map +1 -1
- package/dist/whiteboard.esm.js +180 -77
- package/dist/whiteboard.esm.js.map +3 -3
- package/dist/whiteboard.js +235 -132
- package/dist/whiteboard.js.map +3 -3
- package/package.json +2 -2
package/dist/whiteboard.js
CHANGED
|
@@ -23278,7 +23278,7 @@ var require_lodash = __commonJS({
|
|
|
23278
23278
|
result2.__values__ = wrapper.__values__;
|
|
23279
23279
|
return result2;
|
|
23280
23280
|
}
|
|
23281
|
-
function
|
|
23281
|
+
function chunk7(array, size2, guard) {
|
|
23282
23282
|
if (guard ? isIterateeCall(array, size2, guard) : size2 === undefined2) {
|
|
23283
23283
|
size2 = 1;
|
|
23284
23284
|
} else {
|
|
@@ -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 = chunk7;
|
|
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_room13 = 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_room5 = require("@netless/forge-room");
|
|
25651
25651
|
|
|
25652
25652
|
// src/model/renderable/CurveModel.ts
|
|
25653
25653
|
var Y2 = __toESM(require("yjs"), 1);
|
|
@@ -25800,9 +25800,6 @@ 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
|
-
|
|
25806
25803
|
// src/model/renderable/ElementModel.ts
|
|
25807
25804
|
var Y = __toESM(require("yjs"), 1);
|
|
25808
25805
|
var import_forge_room = require("@netless/forge-room");
|
|
@@ -26192,35 +26189,37 @@ var CurveModel = class extends ElementModel {
|
|
|
26192
26189
|
constructor(root, scope, liveCursor, isPerformanceMode) {
|
|
26193
26190
|
super(root, scope, liveCursor, isPerformanceMode);
|
|
26194
26191
|
_defineProperty3(this, "item", null);
|
|
26195
|
-
_defineProperty3(this, "debugPath", void 0);
|
|
26196
26192
|
_defineProperty3(this, "debug", false);
|
|
26197
26193
|
_defineProperty3(this, "clearLocalPointsWhenYPointsChange", false);
|
|
26198
26194
|
_defineProperty3(this, "shouldUseLocalPoints", true);
|
|
26199
|
-
_defineProperty3(this, "localPointsPick",
|
|
26195
|
+
_defineProperty3(this, "localPointsPick", 6);
|
|
26200
26196
|
if (!this.root.doc || !this.root.has("type")) {
|
|
26201
26197
|
this.root.set("type", "curve");
|
|
26202
26198
|
}
|
|
26203
26199
|
if (!this.root.doc || !this.root.has("points")) {
|
|
26204
26200
|
this.root.set("points", new Y2.Array());
|
|
26205
26201
|
}
|
|
26206
|
-
this.debugPath = new scope.Path();
|
|
26207
26202
|
}
|
|
26208
26203
|
average(a2, b2) {
|
|
26209
26204
|
return (a2 + b2) / 2;
|
|
26210
26205
|
}
|
|
26211
26206
|
parsePoints(points) {
|
|
26207
|
+
const hasRealPressure = points.some((p) => p.length >= 3 && p[2] > 0);
|
|
26208
|
+
const viewScale = this.scope.project.view.matrix.scaling.x || 1;
|
|
26209
|
+
const taper = this.strokeWidth * 5 / viewScale;
|
|
26210
|
+
const streamline = Math.min(0.7, 0.7 * viewScale);
|
|
26212
26211
|
return ae(points, {
|
|
26213
26212
|
size: this.strokeWidth,
|
|
26214
|
-
smoothing: 0.
|
|
26215
|
-
thinning:
|
|
26216
|
-
streamline
|
|
26217
|
-
simulatePressure:
|
|
26213
|
+
smoothing: 0.7,
|
|
26214
|
+
thinning: 0.5,
|
|
26215
|
+
streamline,
|
|
26216
|
+
simulatePressure: !hasRealPressure,
|
|
26218
26217
|
start: {
|
|
26219
|
-
taper
|
|
26218
|
+
taper,
|
|
26220
26219
|
cap: true
|
|
26221
26220
|
},
|
|
26222
26221
|
end: {
|
|
26223
|
-
taper
|
|
26222
|
+
taper,
|
|
26224
26223
|
cap: true
|
|
26225
26224
|
}
|
|
26226
26225
|
});
|
|
@@ -26229,10 +26228,11 @@ var CurveModel = class extends ElementModel {
|
|
|
26229
26228
|
const points = this.localPoints.length === 0 ? this.points : this.localPoints;
|
|
26230
26229
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26231
26230
|
const output = [];
|
|
26232
|
-
for (let i = 0, len = points.length; i < len; i +=
|
|
26231
|
+
for (let i = 0, len = points.length; i < len; i += 3) {
|
|
26233
26232
|
const p = new this.scope.Point(points[i], points[i + 1]);
|
|
26234
26233
|
const tp = p.transform(matrix);
|
|
26235
|
-
|
|
26234
|
+
const pressure = points[i + 2] ?? 0;
|
|
26235
|
+
output.push([tp.x, tp.y, pressure]);
|
|
26236
26236
|
}
|
|
26237
26237
|
return output;
|
|
26238
26238
|
}
|
|
@@ -26261,34 +26261,30 @@ var CurveModel = class extends ElementModel {
|
|
|
26261
26261
|
}
|
|
26262
26262
|
return path;
|
|
26263
26263
|
}
|
|
26264
|
-
updateDebugPath() {
|
|
26265
|
-
this.debugPath = new this.scope.Path();
|
|
26266
|
-
const points = (0, import_lodash.chunk)(this.points, 2);
|
|
26267
|
-
for (let i = 0, len = points.length; i < len; i++) {
|
|
26268
|
-
const point = new this.scope.Point(points[i][0], points[i][1]);
|
|
26269
|
-
if (i === 0) {
|
|
26270
|
-
this.debugPath.moveTo(point);
|
|
26271
|
-
} else {
|
|
26272
|
-
this.debugPath.lineTo(point);
|
|
26273
|
-
}
|
|
26274
|
-
this.debugPath.strokeWidth = 1;
|
|
26275
|
-
this.debugPath.strokeColor = new this.scope.Color(1, 0, 0, 1);
|
|
26276
|
-
}
|
|
26277
|
-
}
|
|
26278
26264
|
onVectorUpdate() {
|
|
26279
26265
|
if (!this.item) {
|
|
26280
26266
|
return;
|
|
26281
26267
|
}
|
|
26268
|
+
const matrixedPts = this.matrixedPoints();
|
|
26282
26269
|
if (this.debug) {
|
|
26283
|
-
this.
|
|
26284
|
-
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
|
|
26291
|
-
|
|
26270
|
+
const path = new this.scope.Path();
|
|
26271
|
+
for (let i = 0; i < matrixedPts.length; i++) {
|
|
26272
|
+
const p = new this.scope.Point(matrixedPts[i][0], matrixedPts[i][1]);
|
|
26273
|
+
if (i === 0) {
|
|
26274
|
+
path.moveTo(p);
|
|
26275
|
+
} else {
|
|
26276
|
+
path.lineTo(p);
|
|
26277
|
+
}
|
|
26278
|
+
}
|
|
26279
|
+
this.item.removeSegments();
|
|
26280
|
+
this.item.addSegments(path.segments);
|
|
26281
|
+
this.item.fillColor = null;
|
|
26282
|
+
this.item.strokeWidth = this.strokeWidth;
|
|
26283
|
+
} else {
|
|
26284
|
+
const points = this.parsePoints(matrixedPts);
|
|
26285
|
+
const path = this.createPath(points);
|
|
26286
|
+
this.item.removeSegments();
|
|
26287
|
+
this.item.addSegments(path.segments);
|
|
26292
26288
|
}
|
|
26293
26289
|
}
|
|
26294
26290
|
createPaperItem() {
|
|
@@ -26311,11 +26307,11 @@ var CurveModel = class extends ElementModel {
|
|
|
26311
26307
|
}
|
|
26312
26308
|
liveCursorPoint() {
|
|
26313
26309
|
const yArray = this.root.get(ElementModel.KEYS.points);
|
|
26314
|
-
if (yArray.length <
|
|
26310
|
+
if (yArray.length < 3) {
|
|
26315
26311
|
return null;
|
|
26316
26312
|
}
|
|
26317
26313
|
const len = yArray.length;
|
|
26318
|
-
const point = new this.scope.Point(yArray.get(len -
|
|
26314
|
+
const point = new this.scope.Point(yArray.get(len - 3), yArray.get(len - 2));
|
|
26319
26315
|
return point.transform(new this.scope.Matrix(this.pointsMatrix));
|
|
26320
26316
|
}
|
|
26321
26317
|
onStyleKeyUpdate(key) {
|
|
@@ -26416,7 +26412,8 @@ var SelectorModel = class extends ElementModel {
|
|
|
26416
26412
|
var Y4 = __toESM(require("yjs"), 1);
|
|
26417
26413
|
|
|
26418
26414
|
// src/utils/paperjs.ts
|
|
26419
|
-
var
|
|
26415
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
26416
|
+
var import_forge_room2 = require("@netless/forge-room");
|
|
26420
26417
|
function _defineProperty5(e, r, t) {
|
|
26421
26418
|
return (r = _toPropertyKey5(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26422
26419
|
}
|
|
@@ -26449,7 +26446,7 @@ function serializePath(path) {
|
|
|
26449
26446
|
}, []);
|
|
26450
26447
|
}
|
|
26451
26448
|
function deserializePath(points, scope, matrix) {
|
|
26452
|
-
const segmentGroup = (0,
|
|
26449
|
+
const segmentGroup = (0, import_lodash.chunk)(points, 6);
|
|
26453
26450
|
const path = new scope.Path();
|
|
26454
26451
|
path.segments = segmentGroup.map((v) => deserializeSegment(v, scope, matrix));
|
|
26455
26452
|
return path;
|
|
@@ -26459,7 +26456,27 @@ var AnimationFrame = class {
|
|
|
26459
26456
|
_defineProperty5(this, "callbacks", []);
|
|
26460
26457
|
_defineProperty5(this, "lastTime", 0);
|
|
26461
26458
|
_defineProperty5(this, "fps", 45);
|
|
26459
|
+
_defineProperty5(this, "lastCallbackTime", 0);
|
|
26460
|
+
_defineProperty5(this, "fpsBuffer", []);
|
|
26461
|
+
_defineProperty5(this, "FPS_REPORT_INTERVAL", 2700);
|
|
26462
26462
|
_defineProperty5(this, "handleCallbacks", () => {
|
|
26463
|
+
const now = performance.now();
|
|
26464
|
+
if (this.lastCallbackTime > 0) {
|
|
26465
|
+
const actualFps = 1e3 / (now - this.lastCallbackTime);
|
|
26466
|
+
this.fpsBuffer.push(actualFps);
|
|
26467
|
+
if (this.fpsBuffer.length >= this.FPS_REPORT_INTERVAL) {
|
|
26468
|
+
const avg = this.fpsBuffer.reduce((a2, b2) => a2 + b2, 0) / this.fpsBuffer.length;
|
|
26469
|
+
const min = Math.min(...this.fpsBuffer);
|
|
26470
|
+
const sorted = [...this.fpsBuffer].sort((a2, b2) => a2 - b2);
|
|
26471
|
+
const p90 = sorted[Math.floor(sorted.length * 0.9)];
|
|
26472
|
+
(0, import_forge_room2.metrics)().gauge("fps", Math.round(avg), {
|
|
26473
|
+
min: Math.round(min),
|
|
26474
|
+
p90: Math.round(p90)
|
|
26475
|
+
});
|
|
26476
|
+
this.fpsBuffer = [];
|
|
26477
|
+
}
|
|
26478
|
+
}
|
|
26479
|
+
this.lastCallbackTime = now;
|
|
26463
26480
|
const functions = this.callbacks;
|
|
26464
26481
|
this.callbacks = [];
|
|
26465
26482
|
for (let i = 0, l2 = functions.length; i < l2; i++) {
|
|
@@ -26572,7 +26589,7 @@ var SegmentsModel = class extends ElementModel {
|
|
|
26572
26589
|
|
|
26573
26590
|
// src/model/renderable/LineModel.ts
|
|
26574
26591
|
var Y5 = __toESM(require("yjs"), 1);
|
|
26575
|
-
var
|
|
26592
|
+
var import_lodash3 = __toESM(require_lodash(), 1);
|
|
26576
26593
|
|
|
26577
26594
|
// src/tool/WhiteboardTool.ts
|
|
26578
26595
|
function _defineProperty7(e, r, t) {
|
|
@@ -26592,6 +26609,8 @@ function _toPrimitive7(t, r) {
|
|
|
26592
26609
|
}
|
|
26593
26610
|
return ("string" === r ? String : Number)(t);
|
|
26594
26611
|
}
|
|
26612
|
+
var DRAG_FPS = 10;
|
|
26613
|
+
var DRAG_FRAME_MS = 1e3 / DRAG_FPS;
|
|
26595
26614
|
var WhiteboardTool = class {
|
|
26596
26615
|
constructor(enableToolEvent, modelGetter, shadowEmitter, scope) {
|
|
26597
26616
|
_defineProperty7(this, "modelGetter", void 0);
|
|
@@ -26600,24 +26619,60 @@ var WhiteboardTool = class {
|
|
|
26600
26619
|
_defineProperty7(this, "shadowEmitter", void 0);
|
|
26601
26620
|
_defineProperty7(this, "enableToolEvent", void 0);
|
|
26602
26621
|
_defineProperty7(this, "eventAvailable", false);
|
|
26622
|
+
_defineProperty7(this, "lastDragTime", 0);
|
|
26623
|
+
_defineProperty7(this, "dragRafId", 0);
|
|
26624
|
+
_defineProperty7(this, "pendingDragEvent", null);
|
|
26603
26625
|
_defineProperty7(this, "onMouseDownSelf", (event) => {
|
|
26604
26626
|
this.eventAvailable = this.enableToolEvent();
|
|
26605
26627
|
if (!this.eventAvailable) {
|
|
26606
26628
|
return;
|
|
26607
26629
|
}
|
|
26630
|
+
this.lastDragTime = 0;
|
|
26631
|
+
if (this.dragRafId) {
|
|
26632
|
+
cancelAnimationFrame(this.dragRafId);
|
|
26633
|
+
this.dragRafId = 0;
|
|
26634
|
+
}
|
|
26635
|
+
this.pendingDragEvent = null;
|
|
26608
26636
|
this.shadowEmitter.setActive(true);
|
|
26609
26637
|
this.onMouseDown(event);
|
|
26610
26638
|
});
|
|
26639
|
+
_defineProperty7(this, "flushPendingDrag", () => {
|
|
26640
|
+
this.dragRafId = 0;
|
|
26641
|
+
if (this.pendingDragEvent) {
|
|
26642
|
+
this.lastDragTime = performance.now();
|
|
26643
|
+
const event = this.pendingDragEvent;
|
|
26644
|
+
this.pendingDragEvent = null;
|
|
26645
|
+
this.onMouseDrag(event);
|
|
26646
|
+
}
|
|
26647
|
+
});
|
|
26611
26648
|
_defineProperty7(this, "onMouseDragSelf", (event) => {
|
|
26612
26649
|
if (!this.eventAvailable) {
|
|
26613
26650
|
return;
|
|
26614
26651
|
}
|
|
26615
|
-
|
|
26652
|
+
const now = performance.now();
|
|
26653
|
+
if (now - this.lastDragTime >= DRAG_FRAME_MS) {
|
|
26654
|
+
this.lastDragTime = now;
|
|
26655
|
+
this.pendingDragEvent = null;
|
|
26656
|
+
this.onMouseDrag(event);
|
|
26657
|
+
} else {
|
|
26658
|
+
this.pendingDragEvent = event;
|
|
26659
|
+
if (!this.dragRafId) {
|
|
26660
|
+
this.dragRafId = requestAnimationFrame(this.flushPendingDrag);
|
|
26661
|
+
}
|
|
26662
|
+
}
|
|
26616
26663
|
});
|
|
26617
26664
|
_defineProperty7(this, "onMouseUpSelf", (event) => {
|
|
26618
26665
|
if (!this.eventAvailable) {
|
|
26619
26666
|
return;
|
|
26620
26667
|
}
|
|
26668
|
+
if (this.dragRafId) {
|
|
26669
|
+
cancelAnimationFrame(this.dragRafId);
|
|
26670
|
+
this.dragRafId = 0;
|
|
26671
|
+
}
|
|
26672
|
+
if (this.pendingDragEvent) {
|
|
26673
|
+
this.onMouseDrag(this.pendingDragEvent);
|
|
26674
|
+
this.pendingDragEvent = null;
|
|
26675
|
+
}
|
|
26621
26676
|
this.onMouseUp(event);
|
|
26622
26677
|
this.shadowEmitter.setActive(false);
|
|
26623
26678
|
});
|
|
@@ -26633,7 +26688,7 @@ var WhiteboardTool = class {
|
|
|
26633
26688
|
};
|
|
26634
26689
|
|
|
26635
26690
|
// src/tool/LineTool.ts
|
|
26636
|
-
var
|
|
26691
|
+
var import_lodash2 = __toESM(require_lodash(), 1);
|
|
26637
26692
|
function _defineProperty8(e, r, t) {
|
|
26638
26693
|
return (r = _toPropertyKey8(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26639
26694
|
}
|
|
@@ -26682,7 +26737,7 @@ var LineTool = class extends WhiteboardTool {
|
|
|
26682
26737
|
const point = path.getPointAt(distance);
|
|
26683
26738
|
return [point.x, point.y];
|
|
26684
26739
|
});
|
|
26685
|
-
this.elementModel.setPoints((0,
|
|
26740
|
+
this.elementModel.setPoints((0, import_lodash2.flattenDeep)(points));
|
|
26686
26741
|
}
|
|
26687
26742
|
}
|
|
26688
26743
|
onMouseUp(_event) {
|
|
@@ -26765,7 +26820,7 @@ var LineModel = class extends ElementModel {
|
|
|
26765
26820
|
}
|
|
26766
26821
|
renderLine() {
|
|
26767
26822
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
26768
|
-
const papperPoints = (0,
|
|
26823
|
+
const papperPoints = (0, import_lodash3.chunk)(this.drawPoints, 2).map((item) => {
|
|
26769
26824
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
26770
26825
|
});
|
|
26771
26826
|
const path = new this.scope.Path();
|
|
@@ -26901,7 +26956,7 @@ var LineControlPoint = class {
|
|
|
26901
26956
|
const invertedPoint = point.transform(pointsMatrix.inverted());
|
|
26902
26957
|
const points = this.model["drawPoints"];
|
|
26903
26958
|
this.position = invertedPoint;
|
|
26904
|
-
const clonedPoints = (0,
|
|
26959
|
+
const clonedPoints = (0, import_lodash3.cloneDeep)(points);
|
|
26905
26960
|
clonedPoints[this.options.index * 2] = invertedPoint.x;
|
|
26906
26961
|
clonedPoints[this.options.index * 2 + 1] = invertedPoint.y;
|
|
26907
26962
|
this.model.setPoints(clonedPoints);
|
|
@@ -26910,7 +26965,7 @@ var LineControlPoint = class {
|
|
|
26910
26965
|
|
|
26911
26966
|
// src/model/renderable/PointTextModel.ts
|
|
26912
26967
|
var Y6 = __toESM(require("yjs"), 1);
|
|
26913
|
-
var
|
|
26968
|
+
var import_forge_room3 = require("@netless/forge-room");
|
|
26914
26969
|
function _defineProperty10(e, r, t) {
|
|
26915
26970
|
return (r = _toPropertyKey10(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
26916
26971
|
}
|
|
@@ -26991,7 +27046,7 @@ var PointTextModel = class extends ElementModel {
|
|
|
26991
27046
|
}, 60);
|
|
26992
27047
|
}
|
|
26993
27048
|
subDispose() {
|
|
26994
|
-
(0,
|
|
27049
|
+
(0, import_forge_room3.removeObserver)(this.root, this.handleTextPropChange);
|
|
26995
27050
|
}
|
|
26996
27051
|
liveCursorPoint() {
|
|
26997
27052
|
const points = this.points;
|
|
@@ -27382,7 +27437,7 @@ var elementsUndoOrigin = "elementsUndoOrigin";
|
|
|
27382
27437
|
|
|
27383
27438
|
// src/model/renderable/EraserModel.ts
|
|
27384
27439
|
var Y9 = __toESM(require("yjs"), 1);
|
|
27385
|
-
var
|
|
27440
|
+
var import_lodash4 = __toESM(require_lodash(), 1);
|
|
27386
27441
|
function _defineProperty13(e, r, t) {
|
|
27387
27442
|
return (r = _toPropertyKey13(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27388
27443
|
}
|
|
@@ -27450,7 +27505,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27450
27505
|
return path;
|
|
27451
27506
|
}
|
|
27452
27507
|
parsePoints(points) {
|
|
27453
|
-
const groupPoints = (0,
|
|
27508
|
+
const groupPoints = (0, import_lodash4.chunk)(points, 2);
|
|
27454
27509
|
return ae(groupPoints, {
|
|
27455
27510
|
size: this.strokeWidth,
|
|
27456
27511
|
smoothing: 0.5,
|
|
@@ -27468,7 +27523,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27468
27523
|
});
|
|
27469
27524
|
}
|
|
27470
27525
|
matrixedPoints() {
|
|
27471
|
-
const currentPoints = (0,
|
|
27526
|
+
const currentPoints = (0, import_lodash4.chunk)(this.drawPoints, 2).slice(this.sliceBegin);
|
|
27472
27527
|
return currentPoints.map((_ref) => {
|
|
27473
27528
|
let [x, y] = _ref;
|
|
27474
27529
|
return new this.scope.Point(x, y);
|
|
@@ -27534,7 +27589,7 @@ var EraserModel = class extends ElementModel {
|
|
|
27534
27589
|
|
|
27535
27590
|
// src/model/renderable/LaserPointerModel.ts
|
|
27536
27591
|
var Y10 = __toESM(require("yjs"), 1);
|
|
27537
|
-
var
|
|
27592
|
+
var import_lodash5 = __toESM(require_lodash(), 1);
|
|
27538
27593
|
function _defineProperty14(e, r, t) {
|
|
27539
27594
|
return (r = _toPropertyKey14(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27540
27595
|
}
|
|
@@ -27651,7 +27706,7 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27651
27706
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27652
27707
|
const points = this.cachedPoints || this.points;
|
|
27653
27708
|
console.log("[][][] ,", this.points.length, this.cachedPoints?.length, this.localPoints.length);
|
|
27654
|
-
const groupPoints = (0,
|
|
27709
|
+
const groupPoints = (0, import_lodash5.chunk)(points, 2).slice(this.sliceBegin);
|
|
27655
27710
|
return groupPoints.map((_ref) => {
|
|
27656
27711
|
let [x, y] = _ref;
|
|
27657
27712
|
return matrix.transform([x, y]);
|
|
@@ -27707,7 +27762,7 @@ var LaserPointerModel = class extends ElementModel {
|
|
|
27707
27762
|
};
|
|
27708
27763
|
|
|
27709
27764
|
// src/WhitePermissions.ts
|
|
27710
|
-
var
|
|
27765
|
+
var import_forge_room4 = require("@netless/forge-room");
|
|
27711
27766
|
var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
27712
27767
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["none"] = 0] = "none";
|
|
27713
27768
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["draw"] = 1] = "draw";
|
|
@@ -27720,7 +27775,7 @@ var WhiteboardPermissionFlag = function(WhiteboardPermissionFlag2) {
|
|
|
27720
27775
|
WhiteboardPermissionFlag2[WhiteboardPermissionFlag2["all"] = WhiteboardPermissionFlag2.draw | WhiteboardPermissionFlag2.editSelf | WhiteboardPermissionFlag2.editOthers | WhiteboardPermissionFlag2.deleteSelf | WhiteboardPermissionFlag2.deleteOthers | WhiteboardPermissionFlag2.mainView | WhiteboardPermissionFlag2.setOthersView] = "all";
|
|
27721
27776
|
return WhiteboardPermissionFlag2;
|
|
27722
27777
|
}({});
|
|
27723
|
-
var WhiteboardPermissions = class extends
|
|
27778
|
+
var WhiteboardPermissions = class extends import_forge_room4.AbstractApplicationPermissions {
|
|
27724
27779
|
/**
|
|
27725
27780
|
* 解析权限列表组合
|
|
27726
27781
|
* @param {number} value - 权限数字值
|
|
@@ -27733,7 +27788,7 @@ var WhiteboardPermissions = class extends import_forge_room3.AbstractApplication
|
|
|
27733
27788
|
|
|
27734
27789
|
// src/model/renderable/StraightLineModel.ts
|
|
27735
27790
|
var Y11 = __toESM(require("yjs"), 1);
|
|
27736
|
-
var
|
|
27791
|
+
var import_lodash6 = __toESM(require_lodash(), 1);
|
|
27737
27792
|
function _defineProperty15(e, r, t) {
|
|
27738
27793
|
return (r = _toPropertyKey15(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
27739
27794
|
}
|
|
@@ -27792,7 +27847,7 @@ var StraightLineModel = class extends ElementModel {
|
|
|
27792
27847
|
}
|
|
27793
27848
|
renderLine() {
|
|
27794
27849
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
27795
|
-
const papperPoints = (0,
|
|
27850
|
+
const papperPoints = (0, import_lodash6.chunk)(this.drawPoints, 2).map((item) => {
|
|
27796
27851
|
return new this.scope.Point(item[0], item[1]).transform(matrix);
|
|
27797
27852
|
});
|
|
27798
27853
|
const path = new this.scope.Path();
|
|
@@ -28098,7 +28153,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28098
28153
|
confirmPermission() {
|
|
28099
28154
|
const hasPermission = this.hasPermission(WhiteboardPermissionFlag.draw);
|
|
28100
28155
|
if (!hasPermission) {
|
|
28101
|
-
(0,
|
|
28156
|
+
(0, import_forge_room5.log)("[@netless/forge-whiteboard] no permission to draw", {}, "warn");
|
|
28102
28157
|
}
|
|
28103
28158
|
return hasPermission;
|
|
28104
28159
|
}
|
|
@@ -28401,7 +28456,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28401
28456
|
});
|
|
28402
28457
|
}
|
|
28403
28458
|
dispose(clearElements) {
|
|
28404
|
-
(0,
|
|
28459
|
+
(0, import_forge_room5.removeObserver)(this.elements, this.onElementsChange);
|
|
28405
28460
|
if (clearElements) {
|
|
28406
28461
|
this.elements.clear();
|
|
28407
28462
|
}
|
|
@@ -28412,7 +28467,7 @@ var RenderableModel = class extends import_eventemitter3.default {
|
|
|
28412
28467
|
};
|
|
28413
28468
|
|
|
28414
28469
|
// src/utils/Recognizer.ts
|
|
28415
|
-
var
|
|
28470
|
+
var import_lodash7 = __toESM(require_lodash(), 1);
|
|
28416
28471
|
|
|
28417
28472
|
// src/utils/UnistrokeRecognizer.js
|
|
28418
28473
|
function Point(x, y) {
|
|
@@ -28659,7 +28714,7 @@ var Recognizer = class {
|
|
|
28659
28714
|
let maxX = -Number.MAX_VALUE;
|
|
28660
28715
|
let minY = Number.MAX_VALUE;
|
|
28661
28716
|
let maxY = -Number.MAX_VALUE;
|
|
28662
|
-
const result = this.dollar.Recognize((0,
|
|
28717
|
+
const result = this.dollar.Recognize((0, import_lodash7.chunk)(points, 3).map((v) => {
|
|
28663
28718
|
minX = Math.min(minX, v[0]);
|
|
28664
28719
|
maxX = Math.max(maxX, v[0]);
|
|
28665
28720
|
minY = Math.min(minY, v[1]);
|
|
@@ -28703,11 +28758,24 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28703
28758
|
_defineProperty19(this, "elementModel", null);
|
|
28704
28759
|
_defineProperty19(this, "recognizer", new Recognizer());
|
|
28705
28760
|
_defineProperty19(this, "pointCount", 0);
|
|
28761
|
+
_defineProperty19(this, "pendingPoints", []);
|
|
28762
|
+
_defineProperty19(this, "flushRafId", 0);
|
|
28706
28763
|
_defineProperty19(this, "showLiveCursor", true);
|
|
28707
|
-
this
|
|
28764
|
+
_defineProperty19(this, "flushPendingPoints", () => {
|
|
28765
|
+
this.flushRafId = 0;
|
|
28766
|
+
if (this.elementModel && this.pendingPoints.length > 0) {
|
|
28767
|
+
this.elementModel.appendPoints(this.pendingPoints);
|
|
28768
|
+
this.pendingPoints = [];
|
|
28769
|
+
}
|
|
28770
|
+
});
|
|
28708
28771
|
}
|
|
28709
28772
|
onMouseDown(_event) {
|
|
28710
28773
|
this.pointCount = 0;
|
|
28774
|
+
this.pendingPoints = [];
|
|
28775
|
+
if (this.flushRafId) {
|
|
28776
|
+
cancelAnimationFrame(this.flushRafId);
|
|
28777
|
+
this.flushRafId = 0;
|
|
28778
|
+
}
|
|
28711
28779
|
if (this.elementModel) {
|
|
28712
28780
|
this.elementModel.dispose();
|
|
28713
28781
|
}
|
|
@@ -28722,27 +28790,38 @@ var CurveTool = class extends WhiteboardTool {
|
|
|
28722
28790
|
if (this.pointCount > 1024) {
|
|
28723
28791
|
return;
|
|
28724
28792
|
}
|
|
28725
|
-
const MIN_DISTANCE =
|
|
28793
|
+
const MIN_DISTANCE = 2;
|
|
28726
28794
|
if (this.elementModel) {
|
|
28727
|
-
|
|
28728
|
-
let
|
|
28729
|
-
|
|
28730
|
-
|
|
28731
|
-
|
|
28732
|
-
|
|
28733
|
-
|
|
28734
|
-
|
|
28735
|
-
|
|
28736
|
-
|
|
28795
|
+
let lastX = 0;
|
|
28796
|
+
let lastY = 0;
|
|
28797
|
+
if (this.pendingPoints.length >= 3) {
|
|
28798
|
+
lastX = this.pendingPoints[this.pendingPoints.length - 3];
|
|
28799
|
+
lastY = this.pendingPoints[this.pendingPoints.length - 2];
|
|
28800
|
+
} else {
|
|
28801
|
+
const len = this.elementModel.points.length;
|
|
28802
|
+
if (len >= 3) {
|
|
28803
|
+
lastX = this.elementModel.points[len - 3];
|
|
28804
|
+
lastY = this.elementModel.points[len - 2];
|
|
28805
|
+
}
|
|
28737
28806
|
}
|
|
28738
|
-
const dist = Math.max(Math.abs(
|
|
28807
|
+
const dist = Math.max(Math.abs(lastX - event.point.x), Math.abs(lastY - event.point.y));
|
|
28739
28808
|
if (dist >= MIN_DISTANCE) {
|
|
28740
28809
|
this.pointCount += 1;
|
|
28741
|
-
|
|
28810
|
+
const nativeEvent = event.event;
|
|
28811
|
+
const pressure = nativeEvent.pointerType === "pen" && nativeEvent.pressure > 0 ? nativeEvent.pressure : 0;
|
|
28812
|
+
this.pendingPoints.push(event.point.x, event.point.y, pressure);
|
|
28813
|
+
if (!this.flushRafId) {
|
|
28814
|
+
this.flushRafId = requestAnimationFrame(this.flushPendingPoints);
|
|
28815
|
+
}
|
|
28742
28816
|
}
|
|
28743
28817
|
}
|
|
28744
28818
|
}
|
|
28745
28819
|
onMouseUp(event) {
|
|
28820
|
+
if (this.flushRafId) {
|
|
28821
|
+
cancelAnimationFrame(this.flushRafId);
|
|
28822
|
+
this.flushRafId = 0;
|
|
28823
|
+
}
|
|
28824
|
+
this.flushPendingPoints();
|
|
28746
28825
|
this.modelGetter().then((model) => {
|
|
28747
28826
|
if (!model) {
|
|
28748
28827
|
return;
|
|
@@ -28843,7 +28922,7 @@ var RectangleTool = class extends WhiteboardTool {
|
|
|
28843
28922
|
|
|
28844
28923
|
// src/model/ToolbarModel.ts
|
|
28845
28924
|
var import_eventemitter32 = __toESM(require("eventemitter3"), 1);
|
|
28846
|
-
var
|
|
28925
|
+
var import_forge_room6 = require("@netless/forge-room");
|
|
28847
28926
|
function _defineProperty21(e, r, t) {
|
|
28848
28927
|
return (r = _toPropertyKey21(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
28849
28928
|
}
|
|
@@ -28940,7 +29019,7 @@ var ToolbarModel = class extends import_eventemitter32.default {
|
|
|
28940
29019
|
});
|
|
28941
29020
|
}
|
|
28942
29021
|
dispose() {
|
|
28943
|
-
(0,
|
|
29022
|
+
(0, import_forge_room6.removeObserver)(this.root, this.handleRootUpdate);
|
|
28944
29023
|
this.removeAllListeners();
|
|
28945
29024
|
}
|
|
28946
29025
|
};
|
|
@@ -29039,7 +29118,7 @@ var SelectorTool = class extends WhiteboardTool {
|
|
|
29039
29118
|
// src/model/SelectElementsModel.ts
|
|
29040
29119
|
var Y13 = __toESM(require("yjs"), 1);
|
|
29041
29120
|
var import_eventemitter33 = __toESM(require("eventemitter3"), 1);
|
|
29042
|
-
var
|
|
29121
|
+
var import_forge_room7 = require("@netless/forge-room");
|
|
29043
29122
|
|
|
29044
29123
|
// src/WhiteboardKeys.ts
|
|
29045
29124
|
var WhiteboardKeys = {
|
|
@@ -29089,7 +29168,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29089
29168
|
}
|
|
29090
29169
|
const cb = this.observers.get(user.id);
|
|
29091
29170
|
if (cb) {
|
|
29092
|
-
(0,
|
|
29171
|
+
(0, import_forge_room7.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
29093
29172
|
this.observers.delete(user.id);
|
|
29094
29173
|
}
|
|
29095
29174
|
});
|
|
@@ -29098,7 +29177,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29098
29177
|
this.handleUserSelectElementsChange(user.id, evts);
|
|
29099
29178
|
};
|
|
29100
29179
|
if (this.observers.has(user.id)) {
|
|
29101
|
-
(0,
|
|
29180
|
+
(0, import_forge_room7.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
29102
29181
|
this.observers.delete(user.id);
|
|
29103
29182
|
}
|
|
29104
29183
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
@@ -29121,7 +29200,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29121
29200
|
this.handleUserSelectElementsChange(userId, evts);
|
|
29122
29201
|
};
|
|
29123
29202
|
if (this.observers.has(userId)) {
|
|
29124
|
-
(0,
|
|
29203
|
+
(0, import_forge_room7.removeDeepObserver)(this.requestUserMap(userId), this.observers.get(userId));
|
|
29125
29204
|
}
|
|
29126
29205
|
this.requestUserMap(userId).observeDeep(observer);
|
|
29127
29206
|
this.observers.set(userId, observer);
|
|
@@ -29185,7 +29264,7 @@ var SelectElementsModel = class extends import_eventemitter33.default {
|
|
|
29185
29264
|
}
|
|
29186
29265
|
dispose() {
|
|
29187
29266
|
for (const [key, value] of this.observers.entries()) {
|
|
29188
|
-
(0,
|
|
29267
|
+
(0, import_forge_room7.removeDeepObserver)(this.requestUserMap(key), value);
|
|
29189
29268
|
}
|
|
29190
29269
|
this.observers.clear();
|
|
29191
29270
|
this.userManager.off("leave", this.handleUserLeave);
|
|
@@ -30100,7 +30179,7 @@ var Gesture = class extends import_eventemitter36.default {
|
|
|
30100
30179
|
};
|
|
30101
30180
|
|
|
30102
30181
|
// src/Camera.ts
|
|
30103
|
-
var
|
|
30182
|
+
var import_forge_room8 = require("@netless/forge-room");
|
|
30104
30183
|
function _defineProperty28(e, r, t) {
|
|
30105
30184
|
return (r = _toPropertyKey28(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30106
30185
|
}
|
|
@@ -30177,14 +30256,14 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30177
30256
|
}
|
|
30178
30257
|
const cb = this.observers.get(user.id);
|
|
30179
30258
|
if (cb) {
|
|
30180
|
-
(0,
|
|
30259
|
+
(0, import_forge_room8.removeObserver)(this.requestUserMap(user.id), cb);
|
|
30181
30260
|
}
|
|
30182
30261
|
});
|
|
30183
30262
|
_defineProperty28(this, "handleUserJoin", (user) => {
|
|
30184
30263
|
if (this.observers.has(user.id)) {
|
|
30185
30264
|
const cb = this.observers.get(user.id);
|
|
30186
30265
|
if (cb) {
|
|
30187
|
-
(0,
|
|
30266
|
+
(0, import_forge_room8.removeObserver)(this.requestUserMap(user.id), cb);
|
|
30188
30267
|
this.observers.delete(user.id);
|
|
30189
30268
|
}
|
|
30190
30269
|
}
|
|
@@ -30296,7 +30375,7 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30296
30375
|
this.handleViewMatrixUpdate(userId, evt);
|
|
30297
30376
|
};
|
|
30298
30377
|
if (this.observers.has(userId)) {
|
|
30299
|
-
(0,
|
|
30378
|
+
(0, import_forge_room8.removeObserver)(this.requestUserMap(userId), observer);
|
|
30300
30379
|
}
|
|
30301
30380
|
this.requestUserMap(userId).observe(observer);
|
|
30302
30381
|
this.observers.set(userId, observer);
|
|
@@ -30493,10 +30572,10 @@ var Camera = class extends import_eventemitter37.default {
|
|
|
30493
30572
|
Array.from(this.observers.keys()).forEach((userId) => {
|
|
30494
30573
|
const cb = this.observers.get(userId);
|
|
30495
30574
|
if (cb) {
|
|
30496
|
-
(0,
|
|
30575
|
+
(0, import_forge_room8.removeObserver)(this.requestUserMap(userId), cb);
|
|
30497
30576
|
}
|
|
30498
30577
|
});
|
|
30499
|
-
(0,
|
|
30578
|
+
(0, import_forge_room8.removeObserver)(this.whiteboardAttrsMap, this.handleMainCameraChange);
|
|
30500
30579
|
this.userManager.off("join", this.handleUserJoin);
|
|
30501
30580
|
this.userManager.off("leave", this.handleUserLeave);
|
|
30502
30581
|
this.gesture.removeAllListeners();
|
|
@@ -30789,7 +30868,7 @@ var EraserTool = class extends WhiteboardTool {
|
|
|
30789
30868
|
// src/model/TrashedElementsModel.ts
|
|
30790
30869
|
var Y14 = __toESM(require("yjs"), 1);
|
|
30791
30870
|
var import_eventemitter39 = __toESM(require("eventemitter3"), 1);
|
|
30792
|
-
var
|
|
30871
|
+
var import_forge_room9 = require("@netless/forge-room");
|
|
30793
30872
|
function _defineProperty33(e, r, t) {
|
|
30794
30873
|
return (r = _toPropertyKey33(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
30795
30874
|
}
|
|
@@ -30826,14 +30905,14 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30826
30905
|
}
|
|
30827
30906
|
const cb = this.observers.get(user.id);
|
|
30828
30907
|
if (cb) {
|
|
30829
|
-
(0,
|
|
30908
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
30830
30909
|
}
|
|
30831
30910
|
});
|
|
30832
30911
|
_defineProperty33(this, "handleUserJoin", (user) => {
|
|
30833
30912
|
if (this.observers.has(user.id)) {
|
|
30834
30913
|
const cb = this.observers.get(user.id);
|
|
30835
30914
|
if (cb) {
|
|
30836
|
-
(0,
|
|
30915
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(user.id), cb);
|
|
30837
30916
|
this.observers.delete(user.id);
|
|
30838
30917
|
}
|
|
30839
30918
|
}
|
|
@@ -30841,7 +30920,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30841
30920
|
this.handleUserTrashElementsChange(user.id, evts);
|
|
30842
30921
|
};
|
|
30843
30922
|
if (this.observers.has(user.id)) {
|
|
30844
|
-
(0,
|
|
30923
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(user.id), this.observers.get(user.id));
|
|
30845
30924
|
}
|
|
30846
30925
|
this.requestUserMap(user.id).observeDeep(observer);
|
|
30847
30926
|
this.observers.set(user.id, observer);
|
|
@@ -30855,7 +30934,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30855
30934
|
this.handleUserTrashElementsChange(userId, evts);
|
|
30856
30935
|
};
|
|
30857
30936
|
if (this.observers.has(userId)) {
|
|
30858
|
-
(0,
|
|
30937
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(userId), userId);
|
|
30859
30938
|
}
|
|
30860
30939
|
this.requestUserMap(userId).observeDeep(observer);
|
|
30861
30940
|
this.observers.set(userId, observer);
|
|
@@ -30917,7 +30996,7 @@ var TrashedElementsModel = class extends import_eventemitter39.default {
|
|
|
30917
30996
|
}
|
|
30918
30997
|
dispose() {
|
|
30919
30998
|
for (const [key, value] of this.observers.entries()) {
|
|
30920
|
-
(0,
|
|
30999
|
+
(0, import_forge_room9.removeDeepObserver)(this.requestUserMap(key), value);
|
|
30921
31000
|
}
|
|
30922
31001
|
this.observers.clear();
|
|
30923
31002
|
this.userManager.off("leave", this.handleUserLeave);
|
|
@@ -30996,7 +31075,7 @@ var LaserPointerTool = class extends WhiteboardTool {
|
|
|
30996
31075
|
|
|
30997
31076
|
// src/model/PageModel.ts
|
|
30998
31077
|
var import_eventemitter310 = __toESM(require("eventemitter3"), 1);
|
|
30999
|
-
var
|
|
31078
|
+
var import_forge_room10 = require("@netless/forge-room");
|
|
31000
31079
|
function _defineProperty35(e, r, t) {
|
|
31001
31080
|
return (r = _toPropertyKey35(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
31002
31081
|
}
|
|
@@ -31029,7 +31108,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31029
31108
|
}
|
|
31030
31109
|
const cb = this.observers.get(user.id);
|
|
31031
31110
|
if (cb) {
|
|
31032
|
-
(0,
|
|
31111
|
+
(0, import_forge_room10.removeObserver)(this.requestUserMap(user.id), cb);
|
|
31033
31112
|
}
|
|
31034
31113
|
});
|
|
31035
31114
|
_defineProperty35(this, "handleUserJoin", (user) => {
|
|
@@ -31043,7 +31122,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31043
31122
|
if (cameraMode === "main") {
|
|
31044
31123
|
const targetPage = this.whiteboardAttrsMap.get(WhiteboardKeys.currentPage);
|
|
31045
31124
|
if (!this.pageMap.has(targetPage) && targetPage !== "_i_") {
|
|
31046
|
-
(0,
|
|
31125
|
+
(0, import_forge_room10.log)(`main page {${targetPage}} not found.`, {}, "error");
|
|
31047
31126
|
return;
|
|
31048
31127
|
}
|
|
31049
31128
|
this.requestUserMap(this.userManager.selfId).set(WhiteboardKeys.currentPage, targetPage);
|
|
@@ -31090,7 +31169,7 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31090
31169
|
if (this.observers.has(userId)) {
|
|
31091
31170
|
const cb = this.observers.get(userId);
|
|
31092
31171
|
if (cb) {
|
|
31093
|
-
(0,
|
|
31172
|
+
(0, import_forge_room10.removeObserver)(this.requestUserMap(userId), cb);
|
|
31094
31173
|
this.observers.delete(userId);
|
|
31095
31174
|
}
|
|
31096
31175
|
}
|
|
@@ -31179,12 +31258,12 @@ var PageModel = class extends import_eventemitter310.default {
|
|
|
31179
31258
|
dispose() {
|
|
31180
31259
|
for (const entry of this.observers.entries()) {
|
|
31181
31260
|
const [userId, observer] = entry;
|
|
31182
|
-
(0,
|
|
31261
|
+
(0, import_forge_room10.removeObserver)(this.requestUserMap(userId), observer);
|
|
31183
31262
|
}
|
|
31184
31263
|
this.userManager.off("join", this.handleUserJoin);
|
|
31185
31264
|
this.userManager.off("leave", this.handleUserLeave);
|
|
31186
|
-
(0,
|
|
31187
|
-
(0,
|
|
31265
|
+
(0, import_forge_room10.removeObserver)(this.whiteboardAttrsMap, this.handleMainPageChange);
|
|
31266
|
+
(0, import_forge_room10.removeObserver)(this.pageMap, this.handlePageMapChange);
|
|
31188
31267
|
}
|
|
31189
31268
|
};
|
|
31190
31269
|
|
|
@@ -31199,8 +31278,8 @@ async function waitUntil(fn, timeout) {
|
|
|
31199
31278
|
|
|
31200
31279
|
// src/IndexedNavigation.ts
|
|
31201
31280
|
var import_eventemitter311 = __toESM(require("eventemitter3"), 1);
|
|
31202
|
-
var import_forge_room10 = require("@netless/forge-room");
|
|
31203
31281
|
var import_forge_room11 = require("@netless/forge-room");
|
|
31282
|
+
var import_forge_room12 = require("@netless/forge-room");
|
|
31204
31283
|
function _defineProperty36(e, r, t) {
|
|
31205
31284
|
return (r = _toPropertyKey36(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
|
|
31206
31285
|
}
|
|
@@ -31227,7 +31306,7 @@ var IndexedNavigation = class extends import_eventemitter311.default {
|
|
|
31227
31306
|
return this.list[key] && this.list[key].prev === "";
|
|
31228
31307
|
});
|
|
31229
31308
|
if (!headId) {
|
|
31230
|
-
(0,
|
|
31309
|
+
(0, import_forge_room11.log)("indexed navigation confusion", {
|
|
31231
31310
|
list: JSON.stringify(this.list)
|
|
31232
31311
|
}, "error");
|
|
31233
31312
|
throw new Error("indexed navigation confusion");
|
|
@@ -31543,7 +31622,7 @@ var IndexedNavigation = class extends import_eventemitter311.default {
|
|
|
31543
31622
|
}
|
|
31544
31623
|
}
|
|
31545
31624
|
dispose() {
|
|
31546
|
-
(0,
|
|
31625
|
+
(0, import_forge_room12.removeObserver)(this.indexedPageMap, this.handleIndexedPageMapUpdate);
|
|
31547
31626
|
this.pageModel.off("switchPage");
|
|
31548
31627
|
this.pageModel.off("pagesChange");
|
|
31549
31628
|
}
|
|
@@ -31764,7 +31843,7 @@ var SequenceExecutor = class {
|
|
|
31764
31843
|
};
|
|
31765
31844
|
|
|
31766
31845
|
// src/WhiteboardApplication.ts
|
|
31767
|
-
var
|
|
31846
|
+
var import_forge_room14 = require("@netless/forge-room");
|
|
31768
31847
|
|
|
31769
31848
|
// src/LiveCursor.ts
|
|
31770
31849
|
function _defineProperty42(e, r, t) {
|
|
@@ -31921,7 +32000,7 @@ var AsyncMap = class {
|
|
|
31921
32000
|
if (!window.__forge_gl_wb_status__) {
|
|
31922
32001
|
window.__forge_gl_wb_status__ = new AsyncMap();
|
|
31923
32002
|
}
|
|
31924
|
-
var WhiteboardApplication = class _WhiteboardApplication extends
|
|
32003
|
+
var WhiteboardApplication = class _WhiteboardApplication extends import_forge_room13.AbstractApplication {
|
|
31925
32004
|
get undoManager() {
|
|
31926
32005
|
const page = this.pageModel.getCurrentPage(this.userId);
|
|
31927
32006
|
if (page) {
|
|
@@ -31972,6 +32051,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
31972
32051
|
_defineProperty43(this, "permissions", void 0);
|
|
31973
32052
|
_defineProperty43(this, "inputType", "any");
|
|
31974
32053
|
_defineProperty43(this, "isPenEvent", false);
|
|
32054
|
+
_defineProperty43(this, "activePenPointerId", null);
|
|
31975
32055
|
_defineProperty43(this, "hasPenInput", null);
|
|
31976
32056
|
_defineProperty43(this, "disableViewModelUpdate", false);
|
|
31977
32057
|
_defineProperty43(this, "internalResizeObserver", true);
|
|
@@ -32067,7 +32147,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32067
32147
|
}
|
|
32068
32148
|
} else {
|
|
32069
32149
|
console.warn(`[@netless/forge-whiteboard] page ${pageId} not found`);
|
|
32070
|
-
(0,
|
|
32150
|
+
(0, import_forge_room13.log)(`[@netless/forge-whiteboard] page ${pageId} not found`, {}, "warn");
|
|
32071
32151
|
}
|
|
32072
32152
|
await waitUntil(() => this.undoManagers.has(pageId), 1e3);
|
|
32073
32153
|
if (this.undoManagers.has(pageId)) {
|
|
@@ -32079,7 +32159,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32079
32159
|
this.undoManagers.get(pageId).on("stack-item-popped", this.handleStackItemPopped);
|
|
32080
32160
|
} else {
|
|
32081
32161
|
console.warn(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`);
|
|
32082
|
-
(0,
|
|
32162
|
+
(0, import_forge_room13.log)(`[@netless/forge-whiteboard] undo manager for page ${pageId} not found`, {}, "warn");
|
|
32083
32163
|
}
|
|
32084
32164
|
this.emitter.emit("redoStackLength", this.undoManager?.redoStack.length ?? 0);
|
|
32085
32165
|
this.emitter.emit("undoStackLength", this.undoManager?.undoStack.length ?? 0);
|
|
@@ -32300,11 +32380,34 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32300
32380
|
this.imageSets.setAttribute("data-image-sets", "");
|
|
32301
32381
|
this.rootElement.appendChild(this.imageSets);
|
|
32302
32382
|
document.body.addEventListener("pointerdown", (evt) => {
|
|
32303
|
-
|
|
32304
|
-
|
|
32305
|
-
this.
|
|
32306
|
-
this.
|
|
32307
|
-
|
|
32383
|
+
if (evt.pointerType === "pen") {
|
|
32384
|
+
this.isPenEvent = true;
|
|
32385
|
+
this.activePenPointerId = evt.pointerId;
|
|
32386
|
+
if (this.hasPenInput === null) {
|
|
32387
|
+
this.hasPenInput = true;
|
|
32388
|
+
this.inputType = "pen";
|
|
32389
|
+
this.emitter.emit("inputTypeChange", this.inputType);
|
|
32390
|
+
}
|
|
32391
|
+
} else {
|
|
32392
|
+
if (this.activePenPointerId === null) {
|
|
32393
|
+
this.isPenEvent = false;
|
|
32394
|
+
}
|
|
32395
|
+
}
|
|
32396
|
+
}, {
|
|
32397
|
+
capture: true
|
|
32398
|
+
});
|
|
32399
|
+
document.body.addEventListener("pointerup", (evt) => {
|
|
32400
|
+
if (evt.pointerId === this.activePenPointerId) {
|
|
32401
|
+
this.activePenPointerId = null;
|
|
32402
|
+
this.isPenEvent = false;
|
|
32403
|
+
}
|
|
32404
|
+
}, {
|
|
32405
|
+
capture: true
|
|
32406
|
+
});
|
|
32407
|
+
document.body.addEventListener("pointercancel", (evt) => {
|
|
32408
|
+
if (evt.pointerId === this.activePenPointerId) {
|
|
32409
|
+
this.activePenPointerId = null;
|
|
32410
|
+
this.isPenEvent = false;
|
|
32308
32411
|
}
|
|
32309
32412
|
}, {
|
|
32310
32413
|
capture: true
|
|
@@ -32360,7 +32463,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32360
32463
|
this.emitter.setViewModeToFree = (userId) => {
|
|
32361
32464
|
if (that.disableViewModelUpdate) {
|
|
32362
32465
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32363
|
-
(0,
|
|
32466
|
+
(0, import_forge_room13.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32364
32467
|
return;
|
|
32365
32468
|
}
|
|
32366
32469
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32371,7 +32474,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32371
32474
|
this.emitter.setViewModeToFlow = (flowId, userId) => {
|
|
32372
32475
|
if (that.disableViewModelUpdate) {
|
|
32373
32476
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32374
|
-
(0,
|
|
32477
|
+
(0, import_forge_room13.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32375
32478
|
return;
|
|
32376
32479
|
}
|
|
32377
32480
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32392,7 +32495,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32392
32495
|
this.emitter.setViewModeToMain = (userId) => {
|
|
32393
32496
|
if (that.disableViewModelUpdate) {
|
|
32394
32497
|
console.warn("Operation failed. Perspective mode switching is disabled in the current environment.");
|
|
32395
|
-
(0,
|
|
32498
|
+
(0, import_forge_room13.log)("Operation failed. Perspective mode switching is disabled in the current environment.", {}, "warn");
|
|
32396
32499
|
return;
|
|
32397
32500
|
}
|
|
32398
32501
|
const targetId = userId ? this.hasPermission(WhiteboardPermissionFlag.setOthersView) ? userId : null : this.userId;
|
|
@@ -32406,7 +32509,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32406
32509
|
};
|
|
32407
32510
|
this.emitter.insertImage = (src, pageId) => {
|
|
32408
32511
|
if (!/https/.test(src)) {
|
|
32409
|
-
(0,
|
|
32512
|
+
(0, import_forge_room13.log)("[@netless/forge-whiteboard] invalid image url, src needs to be in the HTTPS protocol.", {
|
|
32410
32513
|
src
|
|
32411
32514
|
}, "warn");
|
|
32412
32515
|
return;
|
|
@@ -32416,14 +32519,14 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32416
32519
|
targetPageId = this.pageModel.getCurrentPage(this.userManager.selfId);
|
|
32417
32520
|
}
|
|
32418
32521
|
if (!targetPageId) {
|
|
32419
|
-
(0,
|
|
32522
|
+
(0, import_forge_room13.log)("[@netless/forge-whiteboard] page not found", {}, "warn");
|
|
32420
32523
|
return;
|
|
32421
32524
|
}
|
|
32422
32525
|
this.layers.get(targetPageId)?.createImage(src);
|
|
32423
32526
|
};
|
|
32424
32527
|
this.emitter.removeElement = (pageId, elementId) => {
|
|
32425
32528
|
if (!this.layers.has(pageId)) {
|
|
32426
|
-
(0,
|
|
32529
|
+
(0, import_forge_room13.log)("[@netless/forge-whiteboard] page not found", {}, "warn");
|
|
32427
32530
|
return;
|
|
32428
32531
|
}
|
|
32429
32532
|
this.layers.get(pageId)?.removeElementItem(elementId);
|
|
@@ -32523,15 +32626,15 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32523
32626
|
this.liveCursor.showLiveCursor = value;
|
|
32524
32627
|
};
|
|
32525
32628
|
this.emitter.updateViewport = (width, height) => {
|
|
32526
|
-
(0,
|
|
32629
|
+
(0, import_forge_room13.log)(`call updateViewport with width: ${width}, height: ${height}`);
|
|
32527
32630
|
this.updateOptionSize(width, height);
|
|
32528
32631
|
};
|
|
32529
32632
|
this.emitter.__setMainCanvasVisible = (visible) => {
|
|
32530
|
-
(0,
|
|
32633
|
+
(0, import_forge_room13.log)(`call __setMainCanvasVisible with visible: ${visible}`);
|
|
32531
32634
|
this.canvasElement.style.opacity = visible ? "1" : "0";
|
|
32532
32635
|
};
|
|
32533
32636
|
this.emitter.on("error", (errorCode, errorMessage) => {
|
|
32534
|
-
(0,
|
|
32637
|
+
(0, import_forge_room13.log)("WhiteboardApplicationError", {
|
|
32535
32638
|
errorCode,
|
|
32536
32639
|
errorMessage
|
|
32537
32640
|
});
|
|
@@ -32541,7 +32644,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32541
32644
|
return that.delayTranslateOut;
|
|
32542
32645
|
},
|
|
32543
32646
|
set(value) {
|
|
32544
|
-
(0,
|
|
32647
|
+
(0, import_forge_room13.log)(`call __delayTranslateOut with value: ${value}`);
|
|
32545
32648
|
that.delayTranslateOut = value;
|
|
32546
32649
|
}
|
|
32547
32650
|
});
|
|
@@ -32644,7 +32747,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32644
32747
|
}
|
|
32645
32748
|
async initialize(option) {
|
|
32646
32749
|
_WhiteboardApplication.instanceCount.set(this.appId, (_WhiteboardApplication.instanceCount.get(this.appId) ?? 0) + 1);
|
|
32647
|
-
(0,
|
|
32750
|
+
(0, import_forge_room13.log)(`whiteboard ${this.appId} initialize. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
|
|
32648
32751
|
this.appDoc.transact(() => {
|
|
32649
32752
|
this.permissions = new WhiteboardPermissions(this.writableManager, this.userManager, (userId) => {
|
|
32650
32753
|
return this.userMap(userId);
|
|
@@ -32755,7 +32858,7 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
32755
32858
|
this.paperScope.tool = this.tools[this.toolbarModel.currentTool].tool;
|
|
32756
32859
|
} else {
|
|
32757
32860
|
this.paperScope.tool = this.tools["curve"].tool;
|
|
32758
|
-
(0,
|
|
32861
|
+
(0, import_forge_room13.log)(`${this.toolbarModel.currentTool} not supported, backup to curve`);
|
|
32759
32862
|
}
|
|
32760
32863
|
this.selectElementsModel.on("elementsChange", this.handleElementsSelect);
|
|
32761
32864
|
this.trashedElementsModel.on("elementsChange", this.handleElementsTrash);
|
|
@@ -33042,8 +33145,8 @@ var WhiteboardApplication = class _WhiteboardApplication extends import_forge_ro
|
|
|
33042
33145
|
this.toolbarModel.dispose();
|
|
33043
33146
|
this.emitter.indexedNavigation.dispose();
|
|
33044
33147
|
this.permissions.dispose();
|
|
33045
|
-
(0,
|
|
33046
|
-
(0,
|
|
33148
|
+
(0, import_forge_room14.removeObserver)(this.userMap(this.userId), this.handleSyncedWhiteboardStatusChange);
|
|
33149
|
+
(0, import_forge_room13.log)(`whiteboard ${this.appId} disposed. instance count: ${_WhiteboardApplication.instanceCount.get(this.appId) ?? 0}`, {}, "info");
|
|
33047
33150
|
}
|
|
33048
33151
|
};
|
|
33049
33152
|
_defineProperty43(WhiteboardApplication, "instanceCount", /* @__PURE__ */ new Map());
|