@idraw/core 0.4.0-beta.1 → 0.4.0-beta.11
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/esm/index.d.ts +9 -2
- package/dist/esm/index.js +29 -7
- package/dist/esm/lib/cursor-image.d.ts +2 -0
- package/dist/esm/lib/cursor-image.js +2 -0
- package/dist/esm/lib/cursor.d.ts +1 -10
- package/dist/esm/lib/cursor.js +129 -105
- package/dist/esm/middleware/dragger/index.d.ts +7 -0
- package/dist/esm/middleware/dragger/index.js +43 -0
- package/dist/esm/middleware/ruler/index.js +11 -7
- package/dist/esm/middleware/scaler/index.js +1 -3
- package/dist/esm/middleware/scroller/index.js +5 -5
- package/dist/esm/middleware/selector/config.d.ts +1 -0
- package/dist/esm/middleware/selector/config.js +1 -0
- package/dist/esm/middleware/selector/draw-wrapper.d.ts +5 -0
- package/dist/esm/middleware/selector/draw-wrapper.js +39 -1
- package/dist/esm/middleware/selector/index.d.ts +1 -0
- package/dist/esm/middleware/selector/index.js +131 -55
- package/dist/esm/middleware/selector/util.js +7 -2
- package/dist/esm/middleware/text-editor/index.js +18 -11
- package/dist/index.global.js +1607 -881
- package/dist/index.global.min.js +1 -1
- package/package.json +5 -5
package/dist/index.global.js
CHANGED
|
@@ -22,11 +22,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
22
22
|
return method;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var _eventHub, _container, _cursorType, _resizeCursorBaseImage, _cursorImageMap, _init, init_fn, _loadResizeCursorBaseImage, loadResizeCursorBaseImage_fn, _resetCursor, resetCursor_fn, _setCursorResize, setCursorResize_fn, _appendRotateResizeImage, appendRotateResizeImage_fn, _board, _canvas, _container2, _initContainer, initContainer_fn;
|
|
26
26
|
function throttle(fn, timeout) {
|
|
27
27
|
let timer = -1;
|
|
28
28
|
return function(...args) {
|
|
29
|
-
if (timer
|
|
29
|
+
if (timer >= 0) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
timer = setTimeout(() => {
|
|
@@ -358,7 +358,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
358
358
|
fontWeight: fontWeight$1,
|
|
359
359
|
strokeWidth
|
|
360
360
|
};
|
|
361
|
-
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
361
|
+
var __classPrivateFieldSet$9 = function(receiver, state, value, kind, f) {
|
|
362
362
|
if (kind === "m")
|
|
363
363
|
throw new TypeError("Private method is not writable");
|
|
364
364
|
if (kind === "a" && !f)
|
|
@@ -367,7 +367,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
367
367
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
368
368
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
369
369
|
};
|
|
370
|
-
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
370
|
+
var __classPrivateFieldGet$9 = function(receiver, state, kind, f) {
|
|
371
371
|
if (kind === "a" && !f)
|
|
372
372
|
throw new TypeError("Private accessor was defined without a getter");
|
|
373
373
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
@@ -379,17 +379,20 @@ var __privateMethod = (obj, member, method) => {
|
|
|
379
379
|
constructor(ctx, opts) {
|
|
380
380
|
_Context2D_ctx.set(this, void 0);
|
|
381
381
|
_Context2D_opts.set(this, void 0);
|
|
382
|
-
__classPrivateFieldSet(this, _Context2D_ctx, ctx, "f");
|
|
383
|
-
__classPrivateFieldSet(this, _Context2D_opts, Object.assign({ devicePixelRatio: 1, offscreenCanvas: null }, opts), "f");
|
|
382
|
+
__classPrivateFieldSet$9(this, _Context2D_ctx, ctx, "f");
|
|
383
|
+
__classPrivateFieldSet$9(this, _Context2D_opts, Object.assign({ devicePixelRatio: 1, offscreenCanvas: null }, opts), "f");
|
|
384
384
|
}
|
|
385
385
|
$undoPixelRatio(num) {
|
|
386
|
-
return num / __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio;
|
|
386
|
+
return num / __classPrivateFieldGet$9(this, _Context2D_opts, "f").devicePixelRatio;
|
|
387
387
|
}
|
|
388
388
|
$doPixelRatio(num) {
|
|
389
|
-
return __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio * num;
|
|
389
|
+
return __classPrivateFieldGet$9(this, _Context2D_opts, "f").devicePixelRatio * num;
|
|
390
390
|
}
|
|
391
391
|
$getContext() {
|
|
392
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f");
|
|
392
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f");
|
|
393
|
+
}
|
|
394
|
+
$setContext(ctx) {
|
|
395
|
+
__classPrivateFieldSet$9(this, _Context2D_ctx, ctx, "f");
|
|
393
396
|
}
|
|
394
397
|
$setFont(opts) {
|
|
395
398
|
const strList = [];
|
|
@@ -398,17 +401,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
398
401
|
}
|
|
399
402
|
strList.push(`${this.$doPixelRatio(opts.fontSize || 12)}px`);
|
|
400
403
|
strList.push(`${opts.fontFamily || "sans-serif"}`);
|
|
401
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").font = `${strList.join(" ")}`;
|
|
404
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").font = `${strList.join(" ")}`;
|
|
402
405
|
}
|
|
403
406
|
$getOffscreenCanvas() {
|
|
404
|
-
return __classPrivateFieldGet(this, _Context2D_opts, "f").offscreenCanvas;
|
|
407
|
+
return __classPrivateFieldGet$9(this, _Context2D_opts, "f").offscreenCanvas;
|
|
405
408
|
}
|
|
406
409
|
$resize(opts) {
|
|
407
410
|
const { width, height, devicePixelRatio, resetStyle } = opts;
|
|
408
|
-
const { canvas } = __classPrivateFieldGet(this, _Context2D_ctx, "f");
|
|
411
|
+
const { canvas } = __classPrivateFieldGet$9(this, _Context2D_ctx, "f");
|
|
409
412
|
canvas.width = width * devicePixelRatio;
|
|
410
413
|
canvas.height = height * devicePixelRatio;
|
|
411
|
-
__classPrivateFieldSet(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Context2D_opts, "f")), {
|
|
414
|
+
__classPrivateFieldSet$9(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet$9(this, _Context2D_opts, "f")), {
|
|
412
415
|
devicePixelRatio
|
|
413
416
|
}), "f");
|
|
414
417
|
if (resetStyle === true) {
|
|
@@ -417,8 +420,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
417
420
|
}
|
|
418
421
|
}
|
|
419
422
|
$getSize() {
|
|
420
|
-
const { devicePixelRatio } = __classPrivateFieldGet(this, _Context2D_opts, "f");
|
|
421
|
-
const { width, height } = __classPrivateFieldGet(this, _Context2D_ctx, "f").canvas;
|
|
423
|
+
const { devicePixelRatio } = __classPrivateFieldGet$9(this, _Context2D_opts, "f");
|
|
424
|
+
const { width, height } = __classPrivateFieldGet$9(this, _Context2D_ctx, "f").canvas;
|
|
422
425
|
return {
|
|
423
426
|
width: width / devicePixelRatio,
|
|
424
427
|
height: height / devicePixelRatio,
|
|
@@ -426,125 +429,125 @@ var __privateMethod = (obj, member, method) => {
|
|
|
426
429
|
};
|
|
427
430
|
}
|
|
428
431
|
get canvas() {
|
|
429
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").canvas;
|
|
432
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").canvas;
|
|
430
433
|
}
|
|
431
434
|
get fillStyle() {
|
|
432
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillStyle;
|
|
435
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillStyle;
|
|
433
436
|
}
|
|
434
437
|
set fillStyle(value) {
|
|
435
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").fillStyle = value;
|
|
438
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillStyle = value;
|
|
436
439
|
}
|
|
437
440
|
get strokeStyle() {
|
|
438
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeStyle;
|
|
441
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeStyle;
|
|
439
442
|
}
|
|
440
443
|
set strokeStyle(color2) {
|
|
441
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").strokeStyle = color2;
|
|
444
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeStyle = color2;
|
|
442
445
|
}
|
|
443
446
|
get lineWidth() {
|
|
444
|
-
return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").lineWidth);
|
|
447
|
+
return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineWidth);
|
|
445
448
|
}
|
|
446
449
|
set lineWidth(w2) {
|
|
447
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").lineWidth = this.$doPixelRatio(w2);
|
|
450
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineWidth = this.$doPixelRatio(w2);
|
|
448
451
|
}
|
|
449
452
|
get textAlign() {
|
|
450
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").textAlign;
|
|
453
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textAlign;
|
|
451
454
|
}
|
|
452
455
|
set textAlign(align) {
|
|
453
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").textAlign = align;
|
|
456
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").textAlign = align;
|
|
454
457
|
}
|
|
455
458
|
get textBaseline() {
|
|
456
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").textBaseline;
|
|
459
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textBaseline;
|
|
457
460
|
}
|
|
458
461
|
set textBaseline(baseline) {
|
|
459
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").textBaseline = baseline;
|
|
462
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").textBaseline = baseline;
|
|
460
463
|
}
|
|
461
464
|
get globalAlpha() {
|
|
462
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalAlpha;
|
|
465
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalAlpha;
|
|
463
466
|
}
|
|
464
467
|
set globalAlpha(alpha) {
|
|
465
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").globalAlpha = alpha;
|
|
468
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalAlpha = alpha;
|
|
466
469
|
}
|
|
467
470
|
get shadowColor() {
|
|
468
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowColor;
|
|
471
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowColor;
|
|
469
472
|
}
|
|
470
473
|
set shadowColor(color2) {
|
|
471
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowColor = color2;
|
|
474
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowColor = color2;
|
|
472
475
|
}
|
|
473
476
|
get shadowOffsetX() {
|
|
474
|
-
return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetX);
|
|
477
|
+
return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetX);
|
|
475
478
|
}
|
|
476
479
|
set shadowOffsetX(offsetX) {
|
|
477
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetX = this.$doPixelRatio(offsetX);
|
|
480
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetX = this.$doPixelRatio(offsetX);
|
|
478
481
|
}
|
|
479
482
|
get shadowOffsetY() {
|
|
480
|
-
return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetY);
|
|
483
|
+
return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetY);
|
|
481
484
|
}
|
|
482
485
|
set shadowOffsetY(offsetY) {
|
|
483
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetY = this.$doPixelRatio(offsetY);
|
|
486
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetY = this.$doPixelRatio(offsetY);
|
|
484
487
|
}
|
|
485
488
|
get shadowBlur() {
|
|
486
|
-
return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowBlur);
|
|
489
|
+
return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowBlur);
|
|
487
490
|
}
|
|
488
491
|
set shadowBlur(blur) {
|
|
489
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowBlur = this.$doPixelRatio(blur);
|
|
492
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowBlur = this.$doPixelRatio(blur);
|
|
490
493
|
}
|
|
491
494
|
get lineCap() {
|
|
492
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap;
|
|
495
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineCap;
|
|
493
496
|
}
|
|
494
497
|
set lineCap(lineCap) {
|
|
495
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap = lineCap;
|
|
498
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineCap = lineCap;
|
|
496
499
|
}
|
|
497
500
|
get globalCompositeOperation() {
|
|
498
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation;
|
|
501
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalCompositeOperation;
|
|
499
502
|
}
|
|
500
503
|
set globalCompositeOperation(operations) {
|
|
501
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
|
|
504
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
|
|
502
505
|
}
|
|
503
506
|
fill(...args) {
|
|
504
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fill(...args);
|
|
507
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fill(...args);
|
|
505
508
|
}
|
|
506
509
|
arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
|
|
507
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
|
|
510
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
|
|
508
511
|
}
|
|
509
512
|
rect(x2, y2, w2, h2) {
|
|
510
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
513
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
511
514
|
}
|
|
512
515
|
fillRect(x2, y2, w2, h2) {
|
|
513
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
516
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
514
517
|
}
|
|
515
518
|
clearRect(x2, y2, w2, h2) {
|
|
516
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
519
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
|
|
517
520
|
}
|
|
518
521
|
beginPath() {
|
|
519
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").beginPath();
|
|
522
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").beginPath();
|
|
520
523
|
}
|
|
521
524
|
closePath() {
|
|
522
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").closePath();
|
|
525
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").closePath();
|
|
523
526
|
}
|
|
524
527
|
lineTo(x2, y2) {
|
|
525
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
528
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
526
529
|
}
|
|
527
530
|
moveTo(x2, y2) {
|
|
528
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
531
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
529
532
|
}
|
|
530
533
|
arcTo(x1, y1, x2, y2, radius) {
|
|
531
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
|
|
534
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
|
|
532
535
|
}
|
|
533
536
|
getLineDash() {
|
|
534
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").getLineDash();
|
|
537
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").getLineDash();
|
|
535
538
|
}
|
|
536
539
|
setLineDash(nums) {
|
|
537
540
|
const dash = nums.map((n) => this.$doPixelRatio(n));
|
|
538
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").setLineDash(dash);
|
|
541
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").setLineDash(dash);
|
|
539
542
|
}
|
|
540
543
|
stroke(path) {
|
|
541
|
-
return path ? __classPrivateFieldGet(this, _Context2D_ctx, "f").stroke(path) : __classPrivateFieldGet(this, _Context2D_ctx, "f").stroke();
|
|
544
|
+
return path ? __classPrivateFieldGet$9(this, _Context2D_ctx, "f").stroke(path) : __classPrivateFieldGet$9(this, _Context2D_ctx, "f").stroke();
|
|
542
545
|
}
|
|
543
546
|
translate(x2, y2) {
|
|
544
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
547
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
545
548
|
}
|
|
546
549
|
rotate(angle2) {
|
|
547
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").rotate(angle2);
|
|
550
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").rotate(angle2);
|
|
548
551
|
}
|
|
549
552
|
drawImage(...args) {
|
|
550
553
|
const image = args[0];
|
|
@@ -557,64 +560,64 @@ var __privateMethod = (obj, member, method) => {
|
|
|
557
560
|
const dw = args[args.length - 2];
|
|
558
561
|
const dh = args[args.length - 1];
|
|
559
562
|
if (args.length === 9) {
|
|
560
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(sx), this.$doPixelRatio(sy), this.$doPixelRatio(sw), this.$doPixelRatio(sh), this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
|
|
563
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(sx), this.$doPixelRatio(sy), this.$doPixelRatio(sw), this.$doPixelRatio(sh), this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
|
|
561
564
|
} else {
|
|
562
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
|
|
565
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
|
|
563
566
|
}
|
|
564
567
|
}
|
|
565
568
|
createPattern(image, repetition) {
|
|
566
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").createPattern(image, repetition);
|
|
569
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createPattern(image, repetition);
|
|
567
570
|
}
|
|
568
571
|
measureText(text2) {
|
|
569
|
-
const textMetrics = __classPrivateFieldGet(this, _Context2D_ctx, "f").measureText(text2);
|
|
572
|
+
const textMetrics = __classPrivateFieldGet$9(this, _Context2D_ctx, "f").measureText(text2);
|
|
570
573
|
return textMetrics;
|
|
571
574
|
}
|
|
572
575
|
fillText(text2, x2, y2, maxWidth) {
|
|
573
576
|
if (maxWidth !== void 0) {
|
|
574
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
|
|
577
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
|
|
575
578
|
} else {
|
|
576
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
579
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
577
580
|
}
|
|
578
581
|
}
|
|
579
582
|
strokeText(text2, x2, y2, maxWidth) {
|
|
580
583
|
if (maxWidth !== void 0) {
|
|
581
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
|
|
584
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
|
|
582
585
|
} else {
|
|
583
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
586
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
584
587
|
}
|
|
585
588
|
}
|
|
586
589
|
save() {
|
|
587
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").save();
|
|
590
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").save();
|
|
588
591
|
}
|
|
589
592
|
restore() {
|
|
590
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").restore();
|
|
593
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").restore();
|
|
591
594
|
}
|
|
592
595
|
scale(ratioX, ratioY) {
|
|
593
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").scale(ratioX, ratioY);
|
|
596
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").scale(ratioX, ratioY);
|
|
594
597
|
}
|
|
595
598
|
circle(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
|
|
596
|
-
__classPrivateFieldGet(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
|
|
599
|
+
__classPrivateFieldGet$9(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
|
|
597
600
|
}
|
|
598
601
|
isPointInPath(x2, y2) {
|
|
599
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
602
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
600
603
|
}
|
|
601
604
|
clip(...args) {
|
|
602
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").clip(...args);
|
|
605
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").clip(...args);
|
|
603
606
|
}
|
|
604
607
|
setTransform(a, b, c, d, e, f) {
|
|
605
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
|
|
608
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
|
|
606
609
|
}
|
|
607
610
|
getTransform() {
|
|
608
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").getTransform();
|
|
611
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").getTransform();
|
|
609
612
|
}
|
|
610
613
|
createLinearGradient(x0, y0, x1, y1) {
|
|
611
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
|
|
614
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
|
|
612
615
|
}
|
|
613
616
|
createRadialGradient(x0, y0, r0, x1, y1, r1) {
|
|
614
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").createRadialGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(r0), this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(r1));
|
|
617
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createRadialGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(r0), this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(r1));
|
|
615
618
|
}
|
|
616
619
|
createConicGradient(startAngle, x2, y2) {
|
|
617
|
-
return __classPrivateFieldGet(this, _Context2D_ctx, "f").createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
620
|
+
return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
|
|
618
621
|
}
|
|
619
622
|
}
|
|
620
623
|
_Context2D_ctx = /* @__PURE__ */ new WeakMap(), _Context2D_opts = /* @__PURE__ */ new WeakMap();
|
|
@@ -641,15 +644,39 @@ var __privateMethod = (obj, member, method) => {
|
|
|
641
644
|
});
|
|
642
645
|
return context2d;
|
|
643
646
|
}
|
|
644
|
-
function
|
|
645
|
-
const { width, height, devicePixelRatio, offscreen } = opts;
|
|
647
|
+
function createBoardContent(canvas, opts) {
|
|
648
|
+
const { width, height, devicePixelRatio, offscreen, createCustomContext2D } = opts;
|
|
646
649
|
const ctxOpts = {
|
|
647
650
|
width,
|
|
648
651
|
height,
|
|
649
652
|
devicePixelRatio
|
|
650
653
|
};
|
|
654
|
+
const ctx = canvas.getContext("2d");
|
|
655
|
+
if (createCustomContext2D) {
|
|
656
|
+
const viewContext = createCustomContext2D(ctxOpts);
|
|
657
|
+
const helperContext = createCustomContext2D(ctxOpts);
|
|
658
|
+
const underContext = createCustomContext2D(ctxOpts);
|
|
659
|
+
const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
|
|
660
|
+
const drawView = () => {
|
|
661
|
+
const { width: w2, height: h2 } = viewContext.$getSize();
|
|
662
|
+
boardContext.clearRect(0, 0, w2, h2);
|
|
663
|
+
boardContext.drawImage(underContext.canvas, 0, 0, w2, h2);
|
|
664
|
+
boardContext.drawImage(viewContext.canvas, 0, 0, w2, h2);
|
|
665
|
+
boardContext.drawImage(helperContext.canvas, 0, 0, w2, h2);
|
|
666
|
+
underContext.clearRect(0, 0, w2, h2);
|
|
667
|
+
viewContext.clearRect(0, 0, w2, h2);
|
|
668
|
+
helperContext.clearRect(0, 0, w2, h2);
|
|
669
|
+
};
|
|
670
|
+
const content = {
|
|
671
|
+
underContext,
|
|
672
|
+
viewContext,
|
|
673
|
+
helperContext,
|
|
674
|
+
boardContext,
|
|
675
|
+
drawView
|
|
676
|
+
};
|
|
677
|
+
return content;
|
|
678
|
+
}
|
|
651
679
|
if (offscreen === true) {
|
|
652
|
-
const ctx = canvas.getContext("2d");
|
|
653
680
|
const viewContext = createOffscreenContext2D(ctxOpts);
|
|
654
681
|
const helperContext = createOffscreenContext2D(ctxOpts);
|
|
655
682
|
const underContext = createOffscreenContext2D(ctxOpts);
|
|
@@ -673,7 +700,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
673
700
|
};
|
|
674
701
|
return content;
|
|
675
702
|
} else {
|
|
676
|
-
const ctx = canvas.getContext("2d");
|
|
677
703
|
const viewContext = createContext2D(ctxOpts);
|
|
678
704
|
const helperContext = createContext2D(ctxOpts);
|
|
679
705
|
const underContext = createContext2D(ctxOpts);
|
|
@@ -697,22 +723,40 @@ var __privateMethod = (obj, member, method) => {
|
|
|
697
723
|
return content;
|
|
698
724
|
}
|
|
699
725
|
}
|
|
726
|
+
var __classPrivateFieldSet$8 = function(receiver, state, value, kind, f) {
|
|
727
|
+
if (kind === "m")
|
|
728
|
+
throw new TypeError("Private method is not writable");
|
|
729
|
+
if (kind === "a" && !f)
|
|
730
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
731
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
732
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
733
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
734
|
+
};
|
|
735
|
+
var __classPrivateFieldGet$8 = function(receiver, state, kind, f) {
|
|
736
|
+
if (kind === "a" && !f)
|
|
737
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
738
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
739
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
740
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
741
|
+
};
|
|
742
|
+
var _EventEmitter_listeners;
|
|
700
743
|
class EventEmitter {
|
|
701
744
|
constructor() {
|
|
702
|
-
this
|
|
745
|
+
_EventEmitter_listeners.set(this, void 0);
|
|
746
|
+
__classPrivateFieldSet$8(this, _EventEmitter_listeners, /* @__PURE__ */ new Map(), "f");
|
|
703
747
|
}
|
|
704
748
|
on(eventKey, callback) {
|
|
705
|
-
if (this.
|
|
706
|
-
const callbacks = this.
|
|
749
|
+
if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(eventKey)) {
|
|
750
|
+
const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey) || [];
|
|
707
751
|
callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
|
|
708
|
-
this.
|
|
752
|
+
__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, callbacks);
|
|
709
753
|
} else {
|
|
710
|
-
this.
|
|
754
|
+
__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, [callback]);
|
|
711
755
|
}
|
|
712
756
|
}
|
|
713
757
|
off(eventKey, callback) {
|
|
714
|
-
if (this.
|
|
715
|
-
const callbacks = this.
|
|
758
|
+
if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(eventKey)) {
|
|
759
|
+
const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey);
|
|
716
760
|
if (Array.isArray(callbacks)) {
|
|
717
761
|
for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
|
|
718
762
|
if (callbacks[i] === callback) {
|
|
@@ -721,11 +765,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
721
765
|
}
|
|
722
766
|
}
|
|
723
767
|
}
|
|
724
|
-
this.
|
|
768
|
+
__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, callbacks || []);
|
|
725
769
|
}
|
|
726
770
|
}
|
|
727
771
|
trigger(eventKey, e) {
|
|
728
|
-
const callbacks = this.
|
|
772
|
+
const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey);
|
|
729
773
|
if (Array.isArray(callbacks)) {
|
|
730
774
|
callbacks.forEach((cb) => {
|
|
731
775
|
cb(e);
|
|
@@ -736,15 +780,22 @@ var __privateMethod = (obj, member, method) => {
|
|
|
736
780
|
}
|
|
737
781
|
}
|
|
738
782
|
has(name) {
|
|
739
|
-
if (this.
|
|
740
|
-
const list = this.
|
|
783
|
+
if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(name)) {
|
|
784
|
+
const list = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(name);
|
|
741
785
|
if (Array.isArray(list) && list.length > 0) {
|
|
742
786
|
return true;
|
|
743
787
|
}
|
|
744
788
|
}
|
|
745
789
|
return false;
|
|
746
790
|
}
|
|
791
|
+
destroy() {
|
|
792
|
+
this.clear();
|
|
793
|
+
}
|
|
794
|
+
clear() {
|
|
795
|
+
__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").clear();
|
|
796
|
+
}
|
|
747
797
|
}
|
|
798
|
+
_EventEmitter_listeners = /* @__PURE__ */ new WeakMap();
|
|
748
799
|
function calcDistance(start, end) {
|
|
749
800
|
const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
|
|
750
801
|
return distance === 0 ? distance : Math.sqrt(distance);
|
|
@@ -755,27 +806,50 @@ var __privateMethod = (obj, member, method) => {
|
|
|
755
806
|
y: p1.y + (p2.y - p1.y) / 2
|
|
756
807
|
};
|
|
757
808
|
}
|
|
809
|
+
var __classPrivateFieldSet$7 = function(receiver, state, value, kind, f) {
|
|
810
|
+
if (kind === "m")
|
|
811
|
+
throw new TypeError("Private method is not writable");
|
|
812
|
+
if (kind === "a" && !f)
|
|
813
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
814
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
815
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
816
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
817
|
+
};
|
|
818
|
+
var __classPrivateFieldGet$7 = function(receiver, state, kind, f) {
|
|
819
|
+
if (kind === "a" && !f)
|
|
820
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
821
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
822
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
823
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
824
|
+
};
|
|
825
|
+
var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_createTempStorage;
|
|
758
826
|
class Store {
|
|
759
827
|
constructor(opts) {
|
|
760
|
-
|
|
761
|
-
this
|
|
828
|
+
_Store_instances.add(this);
|
|
829
|
+
_Store_temp.set(this, void 0);
|
|
830
|
+
_Store_backUpDefaultStorage.set(this, void 0);
|
|
831
|
+
__classPrivateFieldSet$7(this, _Store_backUpDefaultStorage, deepClone(opts.defaultStorage), "f");
|
|
832
|
+
__classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
762
833
|
}
|
|
763
834
|
set(name, value) {
|
|
764
|
-
this
|
|
835
|
+
__classPrivateFieldGet$7(this, _Store_temp, "f")[name] = value;
|
|
765
836
|
}
|
|
766
837
|
get(name) {
|
|
767
|
-
return this
|
|
838
|
+
return __classPrivateFieldGet$7(this, _Store_temp, "f")[name];
|
|
768
839
|
}
|
|
769
840
|
getSnapshot() {
|
|
770
|
-
return deepClone(this
|
|
841
|
+
return deepClone(__classPrivateFieldGet$7(this, _Store_temp, "f"));
|
|
771
842
|
}
|
|
772
843
|
clear() {
|
|
773
|
-
this
|
|
844
|
+
__classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
|
|
774
845
|
}
|
|
775
|
-
|
|
776
|
-
|
|
846
|
+
destroy() {
|
|
847
|
+
__classPrivateFieldSet$7(this, _Store_temp, null, "f");
|
|
777
848
|
}
|
|
778
849
|
}
|
|
850
|
+
_Store_temp = /* @__PURE__ */ new WeakMap(), _Store_backUpDefaultStorage = /* @__PURE__ */ new WeakMap(), _Store_instances = /* @__PURE__ */ new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage2() {
|
|
851
|
+
return deepClone(__classPrivateFieldGet$7(this, _Store_backUpDefaultStorage, "f"));
|
|
852
|
+
};
|
|
779
853
|
function getViewScaleInfoFromSnapshot(snapshot) {
|
|
780
854
|
const { activeStore } = snapshot;
|
|
781
855
|
const sacelInfo = {
|
|
@@ -1428,6 +1502,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1428
1502
|
const topRightCenter = vertexes[1];
|
|
1429
1503
|
const bottomRightCenter = vertexes[2];
|
|
1430
1504
|
const bottomLeftCenter = vertexes[3];
|
|
1505
|
+
const topMiddleSize = createControllerElementSizeFromCenter(topCenter, { size: ctrlSize, angle: totalAngle });
|
|
1506
|
+
const rightMiddleSize = createControllerElementSizeFromCenter(rightCenter, { size: ctrlSize, angle: totalAngle });
|
|
1507
|
+
const bottomMiddleSize = createControllerElementSizeFromCenter(bottomCenter, { size: ctrlSize, angle: totalAngle });
|
|
1508
|
+
const leftMiddleSize = createControllerElementSizeFromCenter(leftCenter, { size: ctrlSize, angle: totalAngle });
|
|
1431
1509
|
const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
1432
1510
|
const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
|
|
1433
1511
|
const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
@@ -1440,6 +1518,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1440
1518
|
const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
|
|
1441
1519
|
const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
|
|
1442
1520
|
const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
|
|
1521
|
+
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
1522
|
+
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
1523
|
+
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
1524
|
+
const leftMiddleVertexes = calcElementVertexes(leftMiddleSize);
|
|
1443
1525
|
const sizeController = {
|
|
1444
1526
|
elementWrapper: vertexes,
|
|
1445
1527
|
left: {
|
|
@@ -1481,6 +1563,26 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1481
1563
|
type: "bottom-right",
|
|
1482
1564
|
vertexes: bottomRightVertexes,
|
|
1483
1565
|
center: bottomRightCenter
|
|
1566
|
+
},
|
|
1567
|
+
leftMiddle: {
|
|
1568
|
+
type: "left-middle",
|
|
1569
|
+
vertexes: leftMiddleVertexes,
|
|
1570
|
+
center: leftCenter
|
|
1571
|
+
},
|
|
1572
|
+
rightMiddle: {
|
|
1573
|
+
type: "right-middle",
|
|
1574
|
+
vertexes: rightMiddleVertexes,
|
|
1575
|
+
center: rightCenter
|
|
1576
|
+
},
|
|
1577
|
+
topMiddle: {
|
|
1578
|
+
type: "top-middle",
|
|
1579
|
+
vertexes: topMiddleVertexes,
|
|
1580
|
+
center: topCenter
|
|
1581
|
+
},
|
|
1582
|
+
bottomMiddle: {
|
|
1583
|
+
type: "bottom-middle",
|
|
1584
|
+
vertexes: bottomMiddleVertexes,
|
|
1585
|
+
center: bottomCenter
|
|
1484
1586
|
}
|
|
1485
1587
|
};
|
|
1486
1588
|
return sizeController;
|
|
@@ -1526,8 +1628,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1526
1628
|
function calcViewBoxSize(viewElem, opts) {
|
|
1527
1629
|
const { viewScaleInfo } = opts;
|
|
1528
1630
|
const { scale } = viewScaleInfo;
|
|
1529
|
-
let { borderRadius: borderRadius2
|
|
1530
|
-
|
|
1631
|
+
let { borderRadius: borderRadius2 } = viewElem.detail;
|
|
1632
|
+
const { boxSizing = defaultElemConfig$1.boxSizing, borderWidth: borderWidth2 } = viewElem.detail;
|
|
1633
|
+
if (Array.isArray(borderWidth2)) {
|
|
1531
1634
|
borderRadius2 = 0;
|
|
1532
1635
|
}
|
|
1533
1636
|
let { x: x2, y: y2, w: w2, h: h2 } = viewElem;
|
|
@@ -1571,6 +1674,103 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1571
1674
|
radiusList
|
|
1572
1675
|
};
|
|
1573
1676
|
}
|
|
1677
|
+
const doNum = (n) => {
|
|
1678
|
+
return formatNumber(n, { decimalPlaces: 4 });
|
|
1679
|
+
};
|
|
1680
|
+
function resizeElementBaseDetail(elem, opts) {
|
|
1681
|
+
const { detail } = elem;
|
|
1682
|
+
const { xRatio, yRatio, maxRatio } = opts;
|
|
1683
|
+
const middleRatio = (xRatio + yRatio) / 2;
|
|
1684
|
+
const { borderWidth: borderWidth2, borderRadius: borderRadius2, borderDash, shadowOffsetX, shadowOffsetY, shadowBlur } = detail;
|
|
1685
|
+
if (typeof borderWidth2 === "number") {
|
|
1686
|
+
detail.borderWidth = doNum(borderWidth2 * middleRatio);
|
|
1687
|
+
} else if (Array.isArray(detail.borderWidth)) {
|
|
1688
|
+
const bw = borderWidth2;
|
|
1689
|
+
detail.borderWidth = [doNum(bw[0] * yRatio), doNum(bw[1] * xRatio), doNum(bw[2] * yRatio), doNum(bw[3] * xRatio)];
|
|
1690
|
+
}
|
|
1691
|
+
if (typeof borderRadius2 === "number") {
|
|
1692
|
+
detail.borderRadius = doNum(borderRadius2 * middleRatio);
|
|
1693
|
+
} else if (Array.isArray(detail.borderRadius)) {
|
|
1694
|
+
const br = borderRadius2;
|
|
1695
|
+
detail.borderRadius = [br[0] * xRatio, br[1] * xRatio, br[2] * yRatio, br[3] * yRatio];
|
|
1696
|
+
}
|
|
1697
|
+
if (Array.isArray(borderDash)) {
|
|
1698
|
+
borderDash.forEach((dash, i) => {
|
|
1699
|
+
detail.borderDash[i] = doNum(dash * maxRatio);
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
if (typeof shadowOffsetX === "number") {
|
|
1703
|
+
detail.shadowOffsetX = doNum(shadowOffsetX * maxRatio);
|
|
1704
|
+
}
|
|
1705
|
+
if (typeof shadowOffsetY === "number") {
|
|
1706
|
+
detail.shadowOffsetX = doNum(shadowOffsetY * maxRatio);
|
|
1707
|
+
}
|
|
1708
|
+
if (typeof shadowBlur === "number") {
|
|
1709
|
+
detail.shadowOffsetX = doNum(shadowBlur * maxRatio);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
function resizeElementBase(elem, opts) {
|
|
1713
|
+
const { xRatio, yRatio } = opts;
|
|
1714
|
+
const { x: x2, y: y2, w: w2, h: h2 } = elem;
|
|
1715
|
+
elem.x = doNum(x2 * xRatio);
|
|
1716
|
+
elem.y = doNum(y2 * yRatio);
|
|
1717
|
+
elem.w = doNum(w2 * xRatio);
|
|
1718
|
+
elem.h = doNum(h2 * yRatio);
|
|
1719
|
+
resizeElementBaseDetail(elem, opts);
|
|
1720
|
+
}
|
|
1721
|
+
function resizeTextElementDetail(elem, opts) {
|
|
1722
|
+
const { minRatio, maxRatio } = opts;
|
|
1723
|
+
const { fontSize: fontSize2, lineHeight: lineHeight2 } = elem.detail;
|
|
1724
|
+
const ratio = (minRatio + maxRatio) / 2;
|
|
1725
|
+
if (fontSize2 && fontSize2 > 0) {
|
|
1726
|
+
elem.detail.fontSize = doNum(fontSize2 * ratio);
|
|
1727
|
+
}
|
|
1728
|
+
if (lineHeight2 && lineHeight2 > 0) {
|
|
1729
|
+
elem.detail.lineHeight = doNum(lineHeight2 * ratio);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
function resizeElement$1(elem, opts) {
|
|
1733
|
+
const { type } = elem;
|
|
1734
|
+
resizeElementBase(elem, opts);
|
|
1735
|
+
if (type === "circle")
|
|
1736
|
+
;
|
|
1737
|
+
else if (type === "text") {
|
|
1738
|
+
resizeTextElementDetail(elem, opts);
|
|
1739
|
+
} else if (type === "image")
|
|
1740
|
+
;
|
|
1741
|
+
else if (type === "svg")
|
|
1742
|
+
;
|
|
1743
|
+
else if (type === "html")
|
|
1744
|
+
;
|
|
1745
|
+
else if (type === "path")
|
|
1746
|
+
;
|
|
1747
|
+
else if (type === "group" && Array.isArray(elem.detail.children)) {
|
|
1748
|
+
elem.detail.children.forEach((child) => {
|
|
1749
|
+
resizeElement$1(child, opts);
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
function deepResizeGroupElement(elem, size) {
|
|
1754
|
+
const resizeW = size.w && size.w > 0 ? size.w : elem.w;
|
|
1755
|
+
const resizeH = size.h && size.h > 0 ? size.h : elem.h;
|
|
1756
|
+
const xRatio = resizeW / elem.w;
|
|
1757
|
+
const yRatio = resizeH / elem.h;
|
|
1758
|
+
if (xRatio === yRatio && xRatio === 1) {
|
|
1759
|
+
return elem;
|
|
1760
|
+
}
|
|
1761
|
+
const minRatio = Math.min(xRatio, yRatio);
|
|
1762
|
+
const maxRatio = Math.max(xRatio, yRatio);
|
|
1763
|
+
elem.w = resizeW;
|
|
1764
|
+
elem.h = resizeH;
|
|
1765
|
+
const opts = { xRatio, yRatio, minRatio, maxRatio };
|
|
1766
|
+
if (elem.type === "group" && Array.isArray(elem.detail.children)) {
|
|
1767
|
+
elem.detail.children.forEach((child) => {
|
|
1768
|
+
resizeElement$1(child, opts);
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1771
|
+
resizeElementBaseDetail(elem, opts);
|
|
1772
|
+
return elem;
|
|
1773
|
+
}
|
|
1574
1774
|
function createColorStyle(ctx, color2, opts) {
|
|
1575
1775
|
if (typeof color2 === "string") {
|
|
1576
1776
|
return color2;
|
|
@@ -1615,30 +1815,35 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1615
1815
|
return "#000000";
|
|
1616
1816
|
}
|
|
1617
1817
|
const defaultElemConfig = getDefaultElementDetailConfig();
|
|
1818
|
+
function getOpacity(elem) {
|
|
1819
|
+
var _a, _b, _c, _d;
|
|
1820
|
+
let opacity = 1;
|
|
1821
|
+
if (((_a = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== void 0 && ((_b = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0 && ((_c = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _c === void 0 ? void 0 : _c.opacity) <= 1) {
|
|
1822
|
+
opacity = (_d = elem === null || elem === void 0 ? void 0 : elem.detail) === null || _d === void 0 ? void 0 : _d.opacity;
|
|
1823
|
+
}
|
|
1824
|
+
return opacity;
|
|
1825
|
+
}
|
|
1618
1826
|
function drawBox(ctx, viewElem, opts) {
|
|
1619
1827
|
const { pattern, renderContent, originElem, calcElemSize, viewScaleInfo, viewSizeInfo } = opts || {};
|
|
1828
|
+
const { parentOpacity } = opts;
|
|
1829
|
+
const opacity = getOpacity(originElem) * parentOpacity;
|
|
1620
1830
|
drawClipPath(ctx, viewElem, {
|
|
1621
1831
|
originElem,
|
|
1622
1832
|
calcElemSize,
|
|
1623
1833
|
viewScaleInfo,
|
|
1624
1834
|
viewSizeInfo,
|
|
1625
1835
|
renderContent: () => {
|
|
1626
|
-
|
|
1627
|
-
if (((_a = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== void 0 && ((_b = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0) {
|
|
1628
|
-
ctx.globalAlpha = viewElem.detail.opacity;
|
|
1629
|
-
} else {
|
|
1630
|
-
ctx.globalAlpha = 1;
|
|
1631
|
-
}
|
|
1836
|
+
ctx.globalAlpha = opacity;
|
|
1632
1837
|
drawBoxBackground(ctx, viewElem, { pattern, viewScaleInfo, viewSizeInfo });
|
|
1633
1838
|
renderContent === null || renderContent === void 0 ? void 0 : renderContent();
|
|
1634
1839
|
drawBoxBorder(ctx, viewElem, { viewScaleInfo, viewSizeInfo });
|
|
1635
|
-
ctx.globalAlpha =
|
|
1840
|
+
ctx.globalAlpha = parentOpacity;
|
|
1636
1841
|
}
|
|
1637
1842
|
});
|
|
1638
1843
|
}
|
|
1639
1844
|
function drawClipPath(ctx, viewElem, opts) {
|
|
1640
|
-
const { renderContent, originElem, calcElemSize,
|
|
1641
|
-
const totalScale =
|
|
1845
|
+
const { renderContent, originElem, calcElemSize, viewSizeInfo } = opts;
|
|
1846
|
+
const totalScale = viewSizeInfo.devicePixelRatio;
|
|
1642
1847
|
const { clipPath } = (originElem === null || originElem === void 0 ? void 0 : originElem.detail) || {};
|
|
1643
1848
|
if (clipPath && calcElemSize && clipPath.commands) {
|
|
1644
1849
|
const { x: x2, y: y2, w: w2, h: h2 } = calcElemSize;
|
|
@@ -1647,8 +1852,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1647
1852
|
const scaleH = h2 / originH;
|
|
1648
1853
|
const viewOriginX = originX * scaleW;
|
|
1649
1854
|
const viewOriginY = originY * scaleH;
|
|
1650
|
-
|
|
1651
|
-
|
|
1855
|
+
const internalX = x2 - viewOriginX;
|
|
1856
|
+
const internalY = y2 - viewOriginY;
|
|
1652
1857
|
ctx.save();
|
|
1653
1858
|
ctx.translate(internalX, internalY);
|
|
1654
1859
|
ctx.scale(totalScale * scaleW, totalScale * scaleH);
|
|
@@ -1668,8 +1873,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1668
1873
|
function drawBoxBackground(ctx, viewElem, opts) {
|
|
1669
1874
|
var _a, _b;
|
|
1670
1875
|
const { pattern, viewScaleInfo, viewSizeInfo } = opts;
|
|
1671
|
-
|
|
1672
|
-
viewElem.detail;
|
|
1876
|
+
const transform = [];
|
|
1673
1877
|
if (viewElem.detail.background || pattern) {
|
|
1674
1878
|
const { x: x2, y: y2, w: w2, h: h2, radiusList } = calcViewBoxSize(viewElem, {
|
|
1675
1879
|
viewScaleInfo,
|
|
@@ -1722,18 +1926,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1722
1926
|
}
|
|
1723
1927
|
}
|
|
1724
1928
|
function drawBoxBorder(ctx, viewElem, opts) {
|
|
1725
|
-
var _a, _b;
|
|
1726
1929
|
if (viewElem.detail.borderWidth === 0) {
|
|
1727
1930
|
return;
|
|
1728
1931
|
}
|
|
1729
1932
|
if (!isColorStr(viewElem.detail.borderColor)) {
|
|
1730
1933
|
return;
|
|
1731
1934
|
}
|
|
1732
|
-
if (((_a = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _a === void 0 ? void 0 : _a.opacity) !== void 0 && ((_b = viewElem === null || viewElem === void 0 ? void 0 : viewElem.detail) === null || _b === void 0 ? void 0 : _b.opacity) >= 0) {
|
|
1733
|
-
ctx.globalAlpha = viewElem.detail.opacity;
|
|
1734
|
-
} else {
|
|
1735
|
-
ctx.globalAlpha = 1;
|
|
1736
|
-
}
|
|
1737
1935
|
const { viewScaleInfo } = opts;
|
|
1738
1936
|
const { scale } = viewScaleInfo;
|
|
1739
1937
|
let borderColor2 = defaultElemConfig.borderColor;
|
|
@@ -1857,7 +2055,6 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1857
2055
|
ctx.arcTo(x2, y2, x2 + w2, y2, radiusList[0]);
|
|
1858
2056
|
ctx.closePath();
|
|
1859
2057
|
ctx.stroke();
|
|
1860
|
-
ctx.globalAlpha = 1;
|
|
1861
2058
|
}
|
|
1862
2059
|
ctx.setLineDash([]);
|
|
1863
2060
|
}
|
|
@@ -1879,53 +2076,69 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1879
2076
|
}
|
|
1880
2077
|
function drawCircle(ctx, elem, opts) {
|
|
1881
2078
|
const { detail, angle: angle2 } = elem;
|
|
1882
|
-
const { background: background2 = "#000000", borderColor: borderColor2 = "#000000", borderWidth: borderWidth2 = 0 } = detail;
|
|
1883
|
-
|
|
1884
|
-
|
|
2079
|
+
const { background: background2 = "#000000", borderColor: borderColor2 = "#000000", boxSizing, borderWidth: borderWidth2 = 0 } = detail;
|
|
2080
|
+
let bw = 0;
|
|
2081
|
+
if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
|
|
2082
|
+
bw = borderWidth2;
|
|
2083
|
+
} else if (Array.isArray(borderWidth2) && typeof borderWidth2[0] === "number" && borderWidth2[0] > 0) {
|
|
2084
|
+
bw = borderWidth2[0];
|
|
2085
|
+
}
|
|
2086
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2087
|
+
const { x: x2, y: y2, w: w2, h: h2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h }, viewScaleInfo, viewSizeInfo)) || elem;
|
|
1885
2088
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1886
2089
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1887
2090
|
drawBoxShadow(ctx, viewElem, {
|
|
1888
2091
|
viewScaleInfo,
|
|
1889
2092
|
viewSizeInfo,
|
|
1890
2093
|
renderContent: () => {
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
const b = h2 / 2;
|
|
2094
|
+
let a = w2 / 2;
|
|
2095
|
+
let b = h2 / 2;
|
|
1894
2096
|
const centerX = x2 + a;
|
|
1895
2097
|
const centerY = y2 + b;
|
|
1896
|
-
if (
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
2098
|
+
if (bw > 0) {
|
|
2099
|
+
if (boxSizing === "border-box") {
|
|
2100
|
+
a = a - bw;
|
|
2101
|
+
b = b - bw;
|
|
2102
|
+
} else if (boxSizing === "center-line") {
|
|
2103
|
+
a = a - bw / 2;
|
|
2104
|
+
b = b - bw / 2;
|
|
2105
|
+
} else {
|
|
2106
|
+
a = a - bw;
|
|
2107
|
+
b = b - bw;
|
|
2108
|
+
}
|
|
1900
2109
|
}
|
|
1901
|
-
if (
|
|
1902
|
-
const
|
|
1903
|
-
|
|
2110
|
+
if (a >= 0 && b >= 0) {
|
|
2111
|
+
const opacity = getOpacity(viewElem) * parentOpacity;
|
|
2112
|
+
ctx.globalAlpha = opacity;
|
|
2113
|
+
if (typeof borderWidth2 === "number" && borderWidth2 > 0) {
|
|
2114
|
+
const ba = borderWidth2 / 2 + a;
|
|
2115
|
+
const bb = borderWidth2 / 2 + b;
|
|
2116
|
+
ctx.beginPath();
|
|
2117
|
+
ctx.strokeStyle = borderColor2;
|
|
2118
|
+
ctx.lineWidth = borderWidth2;
|
|
2119
|
+
ctx.circle(centerX, centerY, ba, bb, 0, 0, 2 * Math.PI);
|
|
2120
|
+
ctx.closePath();
|
|
2121
|
+
ctx.stroke();
|
|
2122
|
+
}
|
|
1904
2123
|
ctx.beginPath();
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2124
|
+
const fillStyle = createColorStyle(ctx, background2, {
|
|
2125
|
+
viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
|
|
2126
|
+
viewScaleInfo,
|
|
2127
|
+
opacity: ctx.globalAlpha
|
|
2128
|
+
});
|
|
2129
|
+
ctx.fillStyle = fillStyle;
|
|
2130
|
+
ctx.circle(centerX, centerY, a, b, 0, 0, 2 * Math.PI);
|
|
1908
2131
|
ctx.closePath();
|
|
1909
|
-
ctx.
|
|
2132
|
+
ctx.fill();
|
|
2133
|
+
ctx.globalAlpha = parentOpacity;
|
|
1910
2134
|
}
|
|
1911
|
-
ctx.beginPath();
|
|
1912
|
-
const fillStyle = createColorStyle(ctx, background2, {
|
|
1913
|
-
viewElementSize: { x: x2, y: y2, w: w2, h: h2 },
|
|
1914
|
-
viewScaleInfo,
|
|
1915
|
-
opacity: ctx.globalAlpha
|
|
1916
|
-
});
|
|
1917
|
-
ctx.fillStyle = fillStyle;
|
|
1918
|
-
ctx.circle(centerX, centerY, a, b, 0, 0, 2 * Math.PI);
|
|
1919
|
-
ctx.closePath();
|
|
1920
|
-
ctx.fill();
|
|
1921
|
-
ctx.globalAlpha = 1;
|
|
1922
2135
|
}
|
|
1923
2136
|
});
|
|
1924
2137
|
});
|
|
1925
2138
|
}
|
|
1926
2139
|
function drawRect(ctx, elem, opts) {
|
|
1927
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
1928
|
-
|
|
2140
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2141
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
1929
2142
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1930
2143
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1931
2144
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -1937,6 +2150,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1937
2150
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
1938
2151
|
viewScaleInfo,
|
|
1939
2152
|
viewSizeInfo,
|
|
2153
|
+
parentOpacity,
|
|
1940
2154
|
renderContent: () => {
|
|
1941
2155
|
}
|
|
1942
2156
|
});
|
|
@@ -1946,8 +2160,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1946
2160
|
}
|
|
1947
2161
|
function drawImage(ctx, elem, opts) {
|
|
1948
2162
|
const content = opts.loader.getContent(elem);
|
|
1949
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
1950
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
|
|
2163
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2164
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
1951
2165
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
1952
2166
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1953
2167
|
drawBoxShadow(ctx, viewElem, {
|
|
@@ -1959,13 +2173,13 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1959
2173
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
1960
2174
|
viewScaleInfo,
|
|
1961
2175
|
viewSizeInfo,
|
|
2176
|
+
parentOpacity,
|
|
1962
2177
|
renderContent: () => {
|
|
1963
|
-
if (!content) {
|
|
2178
|
+
if (!content && !opts.loader.isDestroyed()) {
|
|
1964
2179
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
1965
2180
|
}
|
|
1966
2181
|
if (elem.type === "image" && content) {
|
|
1967
|
-
|
|
1968
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
2182
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
1969
2183
|
const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem, {
|
|
1970
2184
|
viewScaleInfo,
|
|
1971
2185
|
viewSizeInfo
|
|
@@ -1982,7 +2196,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1982
2196
|
ctx.fill();
|
|
1983
2197
|
ctx.clip();
|
|
1984
2198
|
ctx.drawImage(content, x3, y3, w3, h3);
|
|
1985
|
-
ctx.globalAlpha =
|
|
2199
|
+
ctx.globalAlpha = parentOpacity;
|
|
1986
2200
|
ctx.restore();
|
|
1987
2201
|
}
|
|
1988
2202
|
}
|
|
@@ -1993,40 +2207,38 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1993
2207
|
}
|
|
1994
2208
|
function drawSVG(ctx, elem, opts) {
|
|
1995
2209
|
const content = opts.loader.getContent(elem);
|
|
1996
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
1997
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
|
|
2210
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2211
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
1998
2212
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
1999
|
-
if (!content) {
|
|
2213
|
+
if (!content && !opts.loader.isDestroyed()) {
|
|
2000
2214
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
2001
2215
|
}
|
|
2002
2216
|
if (elem.type === "svg" && content) {
|
|
2003
|
-
|
|
2004
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
2217
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
2005
2218
|
ctx.drawImage(content, x2, y2, w2, h2);
|
|
2006
|
-
ctx.globalAlpha =
|
|
2219
|
+
ctx.globalAlpha = parentOpacity;
|
|
2007
2220
|
}
|
|
2008
2221
|
});
|
|
2009
2222
|
}
|
|
2010
2223
|
function drawHTML(ctx, elem, opts) {
|
|
2011
2224
|
const content = opts.loader.getContent(elem);
|
|
2012
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
2013
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
|
|
2225
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2226
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
2014
2227
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2015
|
-
if (!content) {
|
|
2228
|
+
if (!content && !opts.loader.isDestroyed()) {
|
|
2016
2229
|
opts.loader.load(elem, opts.elementAssets || {});
|
|
2017
2230
|
}
|
|
2018
2231
|
if (elem.type === "html" && content) {
|
|
2019
|
-
|
|
2020
|
-
ctx.globalAlpha = opacity ? opacity : 1;
|
|
2232
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
2021
2233
|
ctx.drawImage(content, x2, y2, w2, h2);
|
|
2022
|
-
ctx.globalAlpha =
|
|
2234
|
+
ctx.globalAlpha = parentOpacity;
|
|
2023
2235
|
}
|
|
2024
2236
|
});
|
|
2025
2237
|
}
|
|
2026
2238
|
const detailConfig = getDefaultElementDetailConfig();
|
|
2027
2239
|
function drawText(ctx, elem, opts) {
|
|
2028
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
2029
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
|
|
2240
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2241
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
2030
2242
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2031
2243
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2032
2244
|
drawBox(ctx, viewElem, {
|
|
@@ -2034,6 +2246,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2034
2246
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2035
2247
|
viewScaleInfo,
|
|
2036
2248
|
viewSizeInfo,
|
|
2249
|
+
parentOpacity,
|
|
2037
2250
|
renderContent: () => {
|
|
2038
2251
|
const detail = Object.assign(Object.assign({}, detailConfig), elem.detail);
|
|
2039
2252
|
const fontSize2 = (detail.fontSize || detailConfig.fontSize) * viewScaleInfo.scale;
|
|
@@ -2128,8 +2341,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2128
2341
|
function drawPath(ctx, elem, opts) {
|
|
2129
2342
|
const { detail } = elem;
|
|
2130
2343
|
const { originX, originY, originW, originH } = detail;
|
|
2131
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
2132
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
|
|
2344
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2345
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
2133
2346
|
const scaleW = w2 / originW;
|
|
2134
2347
|
const scaleH = h2 / originH;
|
|
2135
2348
|
const viewOriginX = originX * scaleW;
|
|
@@ -2144,6 +2357,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2144
2357
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2145
2358
|
viewScaleInfo,
|
|
2146
2359
|
viewSizeInfo,
|
|
2360
|
+
parentOpacity,
|
|
2147
2361
|
renderContent: () => {
|
|
2148
2362
|
drawBoxShadow(ctx, viewElem, {
|
|
2149
2363
|
viewScaleInfo,
|
|
@@ -2177,6 +2391,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2177
2391
|
if (((_a = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _a === void 0 ? void 0 : _a.invisible) === true) {
|
|
2178
2392
|
return;
|
|
2179
2393
|
}
|
|
2394
|
+
const { w: w2, h: h2 } = elem;
|
|
2395
|
+
const { scale } = opts.viewScaleInfo;
|
|
2396
|
+
if (scale < 1 && (w2 * scale < 1 || h2 * scale < 1) || opts.parentOpacity === 0) {
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2180
2399
|
try {
|
|
2181
2400
|
switch (elem.type) {
|
|
2182
2401
|
case "rect": {
|
|
@@ -2221,10 +2440,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2221
2440
|
}
|
|
2222
2441
|
}
|
|
2223
2442
|
function drawGroup(ctx, elem, opts) {
|
|
2224
|
-
const { calculator, viewScaleInfo, viewSizeInfo } = opts;
|
|
2225
|
-
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, viewScaleInfo, viewSizeInfo);
|
|
2443
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2444
|
+
const { x: x2, y: y2, w: w2, h: h2, angle: angle2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize({ x: elem.x, y: elem.y, w: elem.w, h: elem.h, angle: elem.angle }, viewScaleInfo, viewSizeInfo)) || elem;
|
|
2226
2445
|
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2227
2446
|
rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
|
|
2447
|
+
ctx.globalAlpha = getOpacity(elem) * parentOpacity;
|
|
2228
2448
|
drawBoxShadow(ctx, viewElem, {
|
|
2229
2449
|
viewScaleInfo,
|
|
2230
2450
|
viewSizeInfo,
|
|
@@ -2234,6 +2454,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2234
2454
|
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2235
2455
|
viewScaleInfo,
|
|
2236
2456
|
viewSizeInfo,
|
|
2457
|
+
parentOpacity,
|
|
2237
2458
|
renderContent: () => {
|
|
2238
2459
|
const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem, {
|
|
2239
2460
|
viewScaleInfo,
|
|
@@ -2268,44 +2489,74 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2268
2489
|
x: newParentSize.x + child.x,
|
|
2269
2490
|
y: newParentSize.y + child.y
|
|
2270
2491
|
});
|
|
2271
|
-
if (
|
|
2272
|
-
|
|
2492
|
+
if (opts.forceDrawAll !== true) {
|
|
2493
|
+
if (!(calculator2 === null || calculator2 === void 0 ? void 0 : calculator2.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo))) {
|
|
2494
|
+
continue;
|
|
2495
|
+
}
|
|
2273
2496
|
}
|
|
2274
2497
|
try {
|
|
2275
|
-
drawElement(ctx, child, Object.assign({}, opts));
|
|
2498
|
+
drawElement(ctx, child, Object.assign(Object.assign({}, opts), { parentOpacity: parentOpacity * getOpacity(elem) }));
|
|
2276
2499
|
} catch (err) {
|
|
2277
2500
|
console.error(err);
|
|
2278
2501
|
}
|
|
2279
2502
|
}
|
|
2280
2503
|
}
|
|
2281
2504
|
if (elem.detail.overflow === "hidden") {
|
|
2282
|
-
ctx.globalAlpha = 1;
|
|
2283
2505
|
ctx.restore();
|
|
2284
2506
|
}
|
|
2285
2507
|
}
|
|
2286
2508
|
});
|
|
2287
2509
|
}
|
|
2288
2510
|
});
|
|
2511
|
+
ctx.globalAlpha = parentOpacity;
|
|
2289
2512
|
});
|
|
2290
2513
|
}
|
|
2291
2514
|
const defaultDetail = getDefaultElementDetailConfig();
|
|
2292
2515
|
function drawElementList(ctx, data, opts) {
|
|
2516
|
+
var _a;
|
|
2293
2517
|
const { elements = [] } = data;
|
|
2518
|
+
const { parentOpacity } = opts;
|
|
2294
2519
|
for (let i = 0; i < elements.length; i++) {
|
|
2295
2520
|
const element = elements[i];
|
|
2296
2521
|
const elem = Object.assign(Object.assign({}, element), {
|
|
2297
2522
|
detail: Object.assign(Object.assign({}, defaultDetail), element === null || element === void 0 ? void 0 : element.detail)
|
|
2298
2523
|
});
|
|
2299
|
-
if (
|
|
2300
|
-
|
|
2524
|
+
if (opts.forceDrawAll !== true) {
|
|
2525
|
+
if (!((_a = opts.calculator) === null || _a === void 0 ? void 0 : _a.isElementInView(elem, opts.viewScaleInfo, opts.viewSizeInfo))) {
|
|
2526
|
+
continue;
|
|
2527
|
+
}
|
|
2301
2528
|
}
|
|
2302
2529
|
try {
|
|
2303
|
-
drawElement(ctx, elem, opts)
|
|
2530
|
+
drawElement(ctx, elem, Object.assign(Object.assign({}, opts), {
|
|
2531
|
+
parentOpacity
|
|
2532
|
+
}));
|
|
2304
2533
|
} catch (err) {
|
|
2305
2534
|
console.error(err);
|
|
2306
2535
|
}
|
|
2307
2536
|
}
|
|
2308
2537
|
}
|
|
2538
|
+
function drawUnderlay(ctx, underlay, opts) {
|
|
2539
|
+
const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
|
|
2540
|
+
const elem = Object.assign({ uuid: "underlay" }, underlay);
|
|
2541
|
+
const { x: x2, y: y2, w: w2, h: h2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
|
|
2542
|
+
const angle2 = 0;
|
|
2543
|
+
const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
|
|
2544
|
+
drawBoxShadow(ctx, viewElem, {
|
|
2545
|
+
viewScaleInfo,
|
|
2546
|
+
viewSizeInfo,
|
|
2547
|
+
renderContent: () => {
|
|
2548
|
+
drawBox(ctx, viewElem, {
|
|
2549
|
+
originElem: elem,
|
|
2550
|
+
calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
|
|
2551
|
+
viewScaleInfo,
|
|
2552
|
+
viewSizeInfo,
|
|
2553
|
+
parentOpacity,
|
|
2554
|
+
renderContent: () => {
|
|
2555
|
+
}
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2309
2560
|
var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
2310
2561
|
function adopt(value) {
|
|
2311
2562
|
return value instanceof P ? value : new P(function(resolve) {
|
|
@@ -2333,6 +2584,23 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2333
2584
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2334
2585
|
});
|
|
2335
2586
|
};
|
|
2587
|
+
var __classPrivateFieldGet$6 = function(receiver, state, kind, f) {
|
|
2588
|
+
if (kind === "a" && !f)
|
|
2589
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
2590
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
2591
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2592
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2593
|
+
};
|
|
2594
|
+
var __classPrivateFieldSet$6 = function(receiver, state, value, kind, f) {
|
|
2595
|
+
if (kind === "m")
|
|
2596
|
+
throw new TypeError("Private method is not writable");
|
|
2597
|
+
if (kind === "a" && !f)
|
|
2598
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
2599
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
2600
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2601
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
2602
|
+
};
|
|
2603
|
+
var _Loader_instances, _Loader_loadFuncMap, _Loader_currentLoadItemMap, _Loader_storageLoadItemMap, _Loader_hasDestroyed, _Loader_registerLoadFunc, _Loader_getLoadElementSource, _Loader_createLoadItem, _Loader_emitLoad, _Loader_emitError, _Loader_loadResource, _Loader_isExistingErrorStorage;
|
|
2336
2604
|
const supportElementTypes = ["image", "svg", "html"];
|
|
2337
2605
|
const getAssetIdFromElement = (element) => {
|
|
2338
2606
|
var _a, _b, _c;
|
|
@@ -2355,10 +2623,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2355
2623
|
class Loader extends EventEmitter {
|
|
2356
2624
|
constructor() {
|
|
2357
2625
|
super();
|
|
2358
|
-
this
|
|
2359
|
-
this
|
|
2360
|
-
this
|
|
2361
|
-
|
|
2626
|
+
_Loader_instances.add(this);
|
|
2627
|
+
_Loader_loadFuncMap.set(this, {});
|
|
2628
|
+
_Loader_currentLoadItemMap.set(this, {});
|
|
2629
|
+
_Loader_storageLoadItemMap.set(this, {});
|
|
2630
|
+
_Loader_hasDestroyed.set(this, false);
|
|
2631
|
+
__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "image", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
|
|
2362
2632
|
var _a;
|
|
2363
2633
|
const src = ((_a = assets[elem.detail.src]) === null || _a === void 0 ? void 0 : _a.value) || elem.detail.src;
|
|
2364
2634
|
const content = yield loadImage(src);
|
|
@@ -2368,12 +2638,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2368
2638
|
content
|
|
2369
2639
|
};
|
|
2370
2640
|
}));
|
|
2371
|
-
this.
|
|
2641
|
+
__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "html", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
|
|
2372
2642
|
var _b;
|
|
2373
2643
|
const html2 = ((_b = assets[elem.detail.html]) === null || _b === void 0 ? void 0 : _b.value) || elem.detail.html;
|
|
2374
2644
|
const content = yield loadHTML(html2, {
|
|
2375
|
-
width: elem.detail.
|
|
2376
|
-
height: elem.detail.
|
|
2645
|
+
width: elem.detail.originW || elem.w,
|
|
2646
|
+
height: elem.detail.originH || elem.h
|
|
2377
2647
|
});
|
|
2378
2648
|
return {
|
|
2379
2649
|
uuid: elem.uuid,
|
|
@@ -2381,7 +2651,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2381
2651
|
content
|
|
2382
2652
|
};
|
|
2383
2653
|
}));
|
|
2384
|
-
this.
|
|
2654
|
+
__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "svg", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
|
|
2385
2655
|
var _c;
|
|
2386
2656
|
const svg2 = ((_c = assets[elem.detail.svg]) === null || _c === void 0 ? void 0 : _c.value) || elem.detail.svg;
|
|
2387
2657
|
const content = yield loadSVG(svg2);
|
|
@@ -2392,124 +2662,166 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2392
2662
|
};
|
|
2393
2663
|
}));
|
|
2394
2664
|
}
|
|
2395
|
-
|
|
2396
|
-
this
|
|
2665
|
+
isDestroyed() {
|
|
2666
|
+
return __classPrivateFieldGet$6(this, _Loader_hasDestroyed, "f");
|
|
2397
2667
|
}
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2668
|
+
destroy() {
|
|
2669
|
+
__classPrivateFieldSet$6(this, _Loader_hasDestroyed, true, "f");
|
|
2670
|
+
this.clear();
|
|
2671
|
+
__classPrivateFieldSet$6(this, _Loader_loadFuncMap, null, "f");
|
|
2672
|
+
__classPrivateFieldSet$6(this, _Loader_currentLoadItemMap, null, "f");
|
|
2673
|
+
__classPrivateFieldSet$6(this, _Loader_storageLoadItemMap, null, "f");
|
|
2674
|
+
}
|
|
2675
|
+
load(element, assets) {
|
|
2676
|
+
if (__classPrivateFieldGet$6(this, _Loader_hasDestroyed, "f") === true) {
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
if (__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_isExistingErrorStorage).call(this, element)) {
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2682
|
+
if (supportElementTypes.includes(element.type)) {
|
|
2683
|
+
__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_loadResource).call(this, element, assets);
|
|
2407
2684
|
}
|
|
2408
|
-
return source;
|
|
2409
2685
|
}
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2686
|
+
getContent(element) {
|
|
2687
|
+
var _a, _b;
|
|
2688
|
+
const assetId = getAssetIdFromElement(element);
|
|
2689
|
+
return ((_b = (_a = __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId]) === null || _b === void 0 ? void 0 : _b.content) || null;
|
|
2690
|
+
}
|
|
2691
|
+
getLoadItemMap() {
|
|
2692
|
+
return __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f");
|
|
2693
|
+
}
|
|
2694
|
+
setLoadItemMap(itemMap) {
|
|
2695
|
+
__classPrivateFieldSet$6(this, _Loader_storageLoadItemMap, itemMap, "f");
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
_Loader_loadFuncMap = /* @__PURE__ */ new WeakMap(), _Loader_currentLoadItemMap = /* @__PURE__ */ new WeakMap(), _Loader_storageLoadItemMap = /* @__PURE__ */ new WeakMap(), _Loader_hasDestroyed = /* @__PURE__ */ new WeakMap(), _Loader_instances = /* @__PURE__ */ new WeakSet(), _Loader_registerLoadFunc = function _Loader_registerLoadFunc2(type, func) {
|
|
2699
|
+
__classPrivateFieldGet$6(this, _Loader_loadFuncMap, "f")[type] = func;
|
|
2700
|
+
}, _Loader_getLoadElementSource = function _Loader_getLoadElementSource2(element) {
|
|
2701
|
+
var _a, _b, _c;
|
|
2702
|
+
let source = null;
|
|
2703
|
+
if (element.type === "image") {
|
|
2704
|
+
source = ((_a = element === null || element === void 0 ? void 0 : element.detail) === null || _a === void 0 ? void 0 : _a.src) || null;
|
|
2705
|
+
} else if (element.type === "svg") {
|
|
2706
|
+
source = ((_b = element === null || element === void 0 ? void 0 : element.detail) === null || _b === void 0 ? void 0 : _b.svg) || null;
|
|
2707
|
+
} else if (element.type === "html") {
|
|
2708
|
+
source = ((_c = element === null || element === void 0 ? void 0 : element.detail) === null || _c === void 0 ? void 0 : _c.html) || null;
|
|
2420
2709
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2710
|
+
return source;
|
|
2711
|
+
}, _Loader_createLoadItem = function _Loader_createLoadItem2(element) {
|
|
2712
|
+
return {
|
|
2713
|
+
element,
|
|
2714
|
+
status: "null",
|
|
2715
|
+
content: null,
|
|
2716
|
+
error: null,
|
|
2717
|
+
startTime: -1,
|
|
2718
|
+
endTime: -1,
|
|
2719
|
+
source: __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_getLoadElementSource).call(this, element)
|
|
2720
|
+
};
|
|
2721
|
+
}, _Loader_emitLoad = function _Loader_emitLoad2(item) {
|
|
2722
|
+
const assetId = getAssetIdFromElement(item.element);
|
|
2723
|
+
const storageItem = __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId];
|
|
2724
|
+
if (!__classPrivateFieldGet$6(this, _Loader_hasDestroyed, "f")) {
|
|
2424
2725
|
if (storageItem) {
|
|
2425
2726
|
if (storageItem.startTime < item.startTime) {
|
|
2426
|
-
this
|
|
2727
|
+
__classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
|
|
2427
2728
|
this.trigger("load", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
|
|
2428
2729
|
}
|
|
2429
2730
|
} else {
|
|
2430
|
-
this
|
|
2731
|
+
__classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
|
|
2431
2732
|
this.trigger("load", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
|
|
2432
2733
|
}
|
|
2433
2734
|
}
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2735
|
+
}, _Loader_emitError = function _Loader_emitError2(item) {
|
|
2736
|
+
var _a;
|
|
2737
|
+
const assetId = getAssetIdFromElement(item.element);
|
|
2738
|
+
const storageItem = (_a = __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId];
|
|
2739
|
+
if (!__classPrivateFieldGet$6(this, _Loader_hasDestroyed, "f")) {
|
|
2437
2740
|
if (storageItem) {
|
|
2438
2741
|
if (storageItem.startTime < item.startTime) {
|
|
2439
|
-
this
|
|
2742
|
+
__classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
|
|
2440
2743
|
this.trigger("error", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
|
|
2441
2744
|
}
|
|
2442
2745
|
} else {
|
|
2443
|
-
this
|
|
2746
|
+
__classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
|
|
2444
2747
|
this.trigger("error", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
|
|
2445
2748
|
}
|
|
2446
2749
|
}
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2750
|
+
}, _Loader_loadResource = function _Loader_loadResource2(element, assets) {
|
|
2751
|
+
const item = __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_createLoadItem).call(this, element);
|
|
2752
|
+
const assetId = getAssetIdFromElement(element);
|
|
2753
|
+
__classPrivateFieldGet$6(this, _Loader_currentLoadItemMap, "f")[assetId] = item;
|
|
2754
|
+
const loadFunc = __classPrivateFieldGet$6(this, _Loader_loadFuncMap, "f")[element.type];
|
|
2755
|
+
if (typeof loadFunc === "function" && !__classPrivateFieldGet$6(this, _Loader_hasDestroyed, "f")) {
|
|
2756
|
+
item.startTime = Date.now();
|
|
2757
|
+
loadFunc(element, assets).then((result) => {
|
|
2758
|
+
if (!__classPrivateFieldGet$6(this, _Loader_hasDestroyed, "f")) {
|
|
2455
2759
|
item.content = result.content;
|
|
2456
2760
|
item.endTime = Date.now();
|
|
2457
2761
|
item.status = "load";
|
|
2458
|
-
this.
|
|
2459
|
-
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
_isExistingErrorStorage(element) {
|
|
2469
|
-
var _a;
|
|
2470
|
-
const assetId = getAssetIdFromElement(element);
|
|
2471
|
-
const existItem = (_a = this._currentLoadItemMap) === null || _a === void 0 ? void 0 : _a[assetId];
|
|
2472
|
-
if (existItem && existItem.status === "error" && existItem.source && existItem.source === this._getLoadElementSource(element)) {
|
|
2473
|
-
return true;
|
|
2474
|
-
}
|
|
2475
|
-
return false;
|
|
2476
|
-
}
|
|
2477
|
-
load(element, assets) {
|
|
2478
|
-
if (this._isExistingErrorStorage(element)) {
|
|
2479
|
-
return;
|
|
2480
|
-
}
|
|
2481
|
-
if (supportElementTypes.includes(element.type)) {
|
|
2482
|
-
this._loadResource(element, assets);
|
|
2483
|
-
}
|
|
2762
|
+
__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_emitLoad).call(this, item);
|
|
2763
|
+
}
|
|
2764
|
+
}).catch((err) => {
|
|
2765
|
+
console.warn(`Load element source "${item.source}" fail`, err, element);
|
|
2766
|
+
item.endTime = Date.now();
|
|
2767
|
+
item.status = "error";
|
|
2768
|
+
item.error = err;
|
|
2769
|
+
__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_emitError).call(this, item);
|
|
2770
|
+
});
|
|
2484
2771
|
}
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2772
|
+
}, _Loader_isExistingErrorStorage = function _Loader_isExistingErrorStorage2(element) {
|
|
2773
|
+
var _a;
|
|
2774
|
+
const assetId = getAssetIdFromElement(element);
|
|
2775
|
+
const existItem = (_a = __classPrivateFieldGet$6(this, _Loader_currentLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId];
|
|
2776
|
+
if (existItem && existItem.status === "error" && existItem.source && existItem.source === __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_getLoadElementSource).call(this, element)) {
|
|
2777
|
+
return true;
|
|
2489
2778
|
}
|
|
2490
|
-
|
|
2779
|
+
return false;
|
|
2780
|
+
};
|
|
2781
|
+
var __classPrivateFieldSet$5 = function(receiver, state, value, kind, f) {
|
|
2782
|
+
if (kind === "m")
|
|
2783
|
+
throw new TypeError("Private method is not writable");
|
|
2784
|
+
if (kind === "a" && !f)
|
|
2785
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
2786
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
2787
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2788
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
2789
|
+
};
|
|
2790
|
+
var __classPrivateFieldGet$5 = function(receiver, state, kind, f) {
|
|
2791
|
+
if (kind === "a" && !f)
|
|
2792
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
2793
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
2794
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2795
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2796
|
+
};
|
|
2797
|
+
var _Renderer_instances, _Renderer_opts, _Renderer_loader, _Renderer_hasDestroyed, _Renderer_init;
|
|
2491
2798
|
class Renderer extends EventEmitter {
|
|
2492
2799
|
constructor(opts) {
|
|
2493
2800
|
super();
|
|
2494
|
-
|
|
2495
|
-
this
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2801
|
+
_Renderer_instances.add(this);
|
|
2802
|
+
_Renderer_opts.set(this, void 0);
|
|
2803
|
+
_Renderer_loader.set(this, new Loader());
|
|
2804
|
+
_Renderer_hasDestroyed.set(this, false);
|
|
2805
|
+
__classPrivateFieldSet$5(this, _Renderer_opts, opts, "f");
|
|
2806
|
+
__classPrivateFieldGet$5(this, _Renderer_instances, "m", _Renderer_init).call(this);
|
|
2807
|
+
}
|
|
2808
|
+
isDestroyed() {
|
|
2809
|
+
return __classPrivateFieldGet$5(this, _Renderer_hasDestroyed, "f");
|
|
2810
|
+
}
|
|
2811
|
+
destroy() {
|
|
2812
|
+
this.clear();
|
|
2813
|
+
__classPrivateFieldSet$5(this, _Renderer_opts, null, "f");
|
|
2814
|
+
__classPrivateFieldGet$5(this, _Renderer_loader, "f").destroy();
|
|
2815
|
+
__classPrivateFieldSet$5(this, _Renderer_loader, null, "f");
|
|
2816
|
+
__classPrivateFieldSet$5(this, _Renderer_hasDestroyed, true, "f");
|
|
2505
2817
|
}
|
|
2506
2818
|
updateOptions(opts) {
|
|
2507
|
-
this
|
|
2819
|
+
__classPrivateFieldSet$5(this, _Renderer_opts, opts, "f");
|
|
2508
2820
|
}
|
|
2509
2821
|
drawData(data, opts) {
|
|
2510
|
-
const
|
|
2511
|
-
const { calculator } = this
|
|
2512
|
-
const
|
|
2822
|
+
const loader = __classPrivateFieldGet$5(this, _Renderer_loader, "f");
|
|
2823
|
+
const { calculator } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
|
|
2824
|
+
const viewContext = __classPrivateFieldGet$5(this, _Renderer_opts, "f").viewContext;
|
|
2513
2825
|
viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
|
|
2514
2826
|
const parentElementSize = {
|
|
2515
2827
|
x: 0,
|
|
@@ -2517,15 +2829,27 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2517
2829
|
w: opts.viewSizeInfo.width,
|
|
2518
2830
|
h: opts.viewSizeInfo.height
|
|
2519
2831
|
};
|
|
2832
|
+
if (data.underlay) {
|
|
2833
|
+
drawUnderlay(viewContext, data.underlay, Object.assign({
|
|
2834
|
+
loader,
|
|
2835
|
+
calculator,
|
|
2836
|
+
parentElementSize,
|
|
2837
|
+
parentOpacity: 1
|
|
2838
|
+
}, opts));
|
|
2839
|
+
}
|
|
2520
2840
|
drawElementList(viewContext, data, Object.assign({
|
|
2521
2841
|
loader,
|
|
2522
2842
|
calculator,
|
|
2523
2843
|
parentElementSize,
|
|
2524
|
-
elementAssets: data.assets
|
|
2844
|
+
elementAssets: data.assets,
|
|
2845
|
+
parentOpacity: 1
|
|
2525
2846
|
}, opts));
|
|
2526
2847
|
}
|
|
2527
2848
|
scale(num) {
|
|
2528
|
-
const { sharer } = this
|
|
2849
|
+
const { sharer } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
|
|
2850
|
+
if (!sharer) {
|
|
2851
|
+
return;
|
|
2852
|
+
}
|
|
2529
2853
|
const { data, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = sharer.getActiveStoreSnapshot();
|
|
2530
2854
|
if (data) {
|
|
2531
2855
|
this.drawData(data, {
|
|
@@ -2546,10 +2870,48 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2546
2870
|
});
|
|
2547
2871
|
}
|
|
2548
2872
|
}
|
|
2873
|
+
setLoadItemMap(itemMap) {
|
|
2874
|
+
__classPrivateFieldGet$5(this, _Renderer_loader, "f").setLoadItemMap(itemMap);
|
|
2875
|
+
}
|
|
2876
|
+
getLoadItemMap() {
|
|
2877
|
+
return __classPrivateFieldGet$5(this, _Renderer_loader, "f").getLoadItemMap();
|
|
2878
|
+
}
|
|
2879
|
+
getLoader() {
|
|
2880
|
+
return __classPrivateFieldGet$5(this, _Renderer_loader, "f");
|
|
2881
|
+
}
|
|
2549
2882
|
}
|
|
2883
|
+
_Renderer_opts = /* @__PURE__ */ new WeakMap(), _Renderer_loader = /* @__PURE__ */ new WeakMap(), _Renderer_hasDestroyed = /* @__PURE__ */ new WeakMap(), _Renderer_instances = /* @__PURE__ */ new WeakSet(), _Renderer_init = function _Renderer_init2() {
|
|
2884
|
+
const loader = __classPrivateFieldGet$5(this, _Renderer_loader, "f");
|
|
2885
|
+
loader.on("load", (e) => {
|
|
2886
|
+
this.trigger("load", e);
|
|
2887
|
+
});
|
|
2888
|
+
loader.on("error", () => {
|
|
2889
|
+
});
|
|
2890
|
+
};
|
|
2891
|
+
var __classPrivateFieldSet$4 = function(receiver, state, value, kind, f) {
|
|
2892
|
+
if (kind === "m")
|
|
2893
|
+
throw new TypeError("Private method is not writable");
|
|
2894
|
+
if (kind === "a" && !f)
|
|
2895
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
2896
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
2897
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2898
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
2899
|
+
};
|
|
2900
|
+
var __classPrivateFieldGet$4 = function(receiver, state, kind, f) {
|
|
2901
|
+
if (kind === "a" && !f)
|
|
2902
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
2903
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
2904
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2905
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2906
|
+
};
|
|
2907
|
+
var _Calculator_opts;
|
|
2550
2908
|
class Calculator {
|
|
2551
2909
|
constructor(opts) {
|
|
2552
|
-
this
|
|
2910
|
+
_Calculator_opts.set(this, void 0);
|
|
2911
|
+
__classPrivateFieldSet$4(this, _Calculator_opts, opts, "f");
|
|
2912
|
+
}
|
|
2913
|
+
destroy() {
|
|
2914
|
+
__classPrivateFieldSet$4(this, _Calculator_opts, null, "f");
|
|
2553
2915
|
}
|
|
2554
2916
|
elementSize(size, viewScaleInfo, viewSizeInfo) {
|
|
2555
2917
|
return calcViewElementSize(size, { viewScaleInfo, viewSizeInfo });
|
|
@@ -2558,7 +2920,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2558
2920
|
return isElementInView(elem, { viewScaleInfo, viewSizeInfo });
|
|
2559
2921
|
}
|
|
2560
2922
|
isPointInElement(p, elem, viewScaleInfo, viewSizeInfo) {
|
|
2561
|
-
const context2d = this.
|
|
2923
|
+
const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
|
|
2562
2924
|
return isViewPointInElement(p, {
|
|
2563
2925
|
context2d,
|
|
2564
2926
|
element: elem,
|
|
@@ -2567,151 +2929,218 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2567
2929
|
});
|
|
2568
2930
|
}
|
|
2569
2931
|
getPointElement(p, opts) {
|
|
2570
|
-
const context2d = this.
|
|
2932
|
+
const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
|
|
2571
2933
|
return getViewPointAtElement(p, Object.assign(Object.assign({}, opts), { context2d }));
|
|
2572
2934
|
}
|
|
2573
2935
|
}
|
|
2936
|
+
_Calculator_opts = /* @__PURE__ */ new WeakMap();
|
|
2937
|
+
var __classPrivateFieldSet$3 = function(receiver, state, value, kind, f) {
|
|
2938
|
+
if (kind === "m")
|
|
2939
|
+
throw new TypeError("Private method is not writable");
|
|
2940
|
+
if (kind === "a" && !f)
|
|
2941
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
2942
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
2943
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2944
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
2945
|
+
};
|
|
2946
|
+
var __classPrivateFieldGet$3 = function(receiver, state, kind, f) {
|
|
2947
|
+
if (kind === "a" && !f)
|
|
2948
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
2949
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
2950
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2951
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2952
|
+
};
|
|
2953
|
+
var _BoardWatcher_instances, _BoardWatcher_opts, _BoardWatcher_store, _BoardWatcher_hasDestroyed, _BoardWatcher_init, _BoardWatcher_onWheel, _BoardWatcher_onContextMenu, _BoardWatcher_onClick, _BoardWatcher_onPointLeave, _BoardWatcher_onPointEnd, _BoardWatcher_onPointMove, _BoardWatcher_onPointStart, _BoardWatcher_onHover, _BoardWatcher_isInTarget, _BoardWatcher_getPoint, _BoardWatcher_isVaildPoint;
|
|
2574
2954
|
function isBoardAvailableNum(num) {
|
|
2575
2955
|
return num > 0 || num < 0 || num === 0;
|
|
2576
2956
|
}
|
|
2577
2957
|
class BoardWatcher extends EventEmitter {
|
|
2578
2958
|
constructor(opts) {
|
|
2579
2959
|
super();
|
|
2580
|
-
|
|
2581
|
-
this
|
|
2582
|
-
this
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
const container = window;
|
|
2587
|
-
container.addEventListener("mousemove", (e) => {
|
|
2588
|
-
if (!this._isInTarget(e)) {
|
|
2960
|
+
_BoardWatcher_instances.add(this);
|
|
2961
|
+
_BoardWatcher_opts.set(this, void 0);
|
|
2962
|
+
_BoardWatcher_store.set(this, void 0);
|
|
2963
|
+
_BoardWatcher_hasDestroyed.set(this, false);
|
|
2964
|
+
_BoardWatcher_onWheel.set(this, (e) => {
|
|
2965
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
|
|
2589
2966
|
return;
|
|
2590
2967
|
}
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
if (!this._isVaildPoint(point)) {
|
|
2968
|
+
const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
|
|
2969
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
|
|
2594
2970
|
return;
|
|
2595
2971
|
}
|
|
2596
|
-
|
|
2972
|
+
e.preventDefault();
|
|
2973
|
+
e.stopPropagation();
|
|
2974
|
+
const deltaX = e.deltaX > 0 || e.deltaX < 0 ? e.deltaX : 0;
|
|
2975
|
+
const deltaY = e.deltaY > 0 || e.deltaY < 0 ? e.deltaY : 0;
|
|
2976
|
+
if (e.ctrlKey === true && this.has("wheelScale")) {
|
|
2977
|
+
this.trigger("wheelScale", { deltaX, deltaY, point });
|
|
2978
|
+
} else if (this.has("wheel")) {
|
|
2979
|
+
this.trigger("wheel", { deltaX, deltaY, point });
|
|
2980
|
+
}
|
|
2597
2981
|
});
|
|
2598
|
-
|
|
2599
|
-
if (!this.
|
|
2982
|
+
_BoardWatcher_onContextMenu.set(this, (e) => {
|
|
2983
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
|
|
2600
2984
|
return;
|
|
2601
2985
|
}
|
|
2602
2986
|
e.preventDefault();
|
|
2603
|
-
const point = this.
|
|
2604
|
-
if (!this.
|
|
2987
|
+
const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
|
|
2988
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
|
|
2605
2989
|
return;
|
|
2606
2990
|
}
|
|
2607
|
-
this._store.set("hasPointDown", true);
|
|
2608
|
-
this.trigger("pointStart", { point });
|
|
2609
2991
|
});
|
|
2610
|
-
|
|
2611
|
-
if (!this.
|
|
2992
|
+
_BoardWatcher_onClick.set(this, (e) => {
|
|
2993
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
|
|
2612
2994
|
return;
|
|
2613
2995
|
}
|
|
2614
2996
|
e.preventDefault();
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
if (!this._isVaildPoint(point)) {
|
|
2618
|
-
if (this._store.get("hasPointDown")) {
|
|
2619
|
-
this.trigger("pointLeave", { point });
|
|
2620
|
-
this._store.set("hasPointDown", false);
|
|
2621
|
-
}
|
|
2997
|
+
const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
|
|
2998
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
|
|
2622
2999
|
return;
|
|
2623
3000
|
}
|
|
2624
|
-
|
|
2625
|
-
|
|
3001
|
+
const maxLimitTime = 500;
|
|
3002
|
+
const t = Date.now();
|
|
3003
|
+
const preClickPoint = __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("prevClickPoint");
|
|
3004
|
+
if (preClickPoint && t - preClickPoint.t <= maxLimitTime && Math.abs(preClickPoint.x - point.x) <= 5 && Math.abs(preClickPoint.y - point.y) <= 5) {
|
|
3005
|
+
this.trigger("doubleClick", { point });
|
|
3006
|
+
} else {
|
|
3007
|
+
__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("prevClickPoint", point);
|
|
2626
3008
|
}
|
|
2627
|
-
this.trigger("pointMove", { point });
|
|
2628
3009
|
});
|
|
2629
|
-
|
|
2630
|
-
this.
|
|
2631
|
-
if (!this.
|
|
3010
|
+
_BoardWatcher_onPointLeave.set(this, (e) => {
|
|
3011
|
+
__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
|
|
3012
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
|
|
2632
3013
|
return;
|
|
2633
3014
|
}
|
|
2634
3015
|
e.preventDefault();
|
|
2635
|
-
const point = this.
|
|
2636
|
-
this.trigger("
|
|
3016
|
+
const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
|
|
3017
|
+
this.trigger("pointLeave", { point });
|
|
2637
3018
|
});
|
|
2638
|
-
|
|
2639
|
-
this.
|
|
2640
|
-
if (!this.
|
|
3019
|
+
_BoardWatcher_onPointEnd.set(this, (e) => {
|
|
3020
|
+
__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
|
|
3021
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
|
|
2641
3022
|
return;
|
|
2642
3023
|
}
|
|
2643
3024
|
e.preventDefault();
|
|
2644
|
-
const point = this.
|
|
2645
|
-
this.trigger("
|
|
3025
|
+
const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
|
|
3026
|
+
this.trigger("pointEnd", { point });
|
|
2646
3027
|
});
|
|
2647
|
-
|
|
2648
|
-
if (!this.
|
|
3028
|
+
_BoardWatcher_onPointMove.set(this, (e) => {
|
|
3029
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
|
|
2649
3030
|
return;
|
|
2650
3031
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
3032
|
+
e.preventDefault();
|
|
3033
|
+
e.stopPropagation();
|
|
3034
|
+
const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
|
|
3035
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
|
|
3036
|
+
if (__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("hasPointDown")) {
|
|
3037
|
+
this.trigger("pointLeave", { point });
|
|
3038
|
+
__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
|
|
3039
|
+
}
|
|
2653
3040
|
return;
|
|
2654
3041
|
}
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
const deltaY = e.deltaY > 0 || e.deltaY < 0 ? e.deltaY : 0;
|
|
2658
|
-
if (e.ctrlKey === true && this.has("wheelScale")) {
|
|
2659
|
-
this.trigger("wheelScale", { deltaX, deltaY, point });
|
|
2660
|
-
} else if (this.has("wheel")) {
|
|
2661
|
-
this.trigger("wheel", { deltaX, deltaY, point });
|
|
3042
|
+
if (__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("hasPointDown") !== true) {
|
|
3043
|
+
return;
|
|
2662
3044
|
}
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
3045
|
+
this.trigger("pointMove", { point });
|
|
3046
|
+
});
|
|
3047
|
+
_BoardWatcher_onPointStart.set(this, (e) => {
|
|
3048
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
|
|
2666
3049
|
return;
|
|
2667
3050
|
}
|
|
2668
3051
|
e.preventDefault();
|
|
2669
|
-
const point = this.
|
|
2670
|
-
if (!this.
|
|
3052
|
+
const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
|
|
3053
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
|
|
2671
3054
|
return;
|
|
2672
3055
|
}
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
const preClickPoint = this._store.get("prevClickPoint");
|
|
2676
|
-
if (preClickPoint && t - preClickPoint.t <= maxLimitTime && Math.abs(preClickPoint.x - point.x) <= 5 && Math.abs(preClickPoint.y - point.y) <= 5) {
|
|
2677
|
-
this.trigger("doubleClick", { point });
|
|
2678
|
-
} else {
|
|
2679
|
-
this._store.set("prevClickPoint", point);
|
|
2680
|
-
}
|
|
3056
|
+
__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", true);
|
|
3057
|
+
this.trigger("pointStart", { point });
|
|
2681
3058
|
});
|
|
2682
|
-
|
|
2683
|
-
if (!this.
|
|
3059
|
+
_BoardWatcher_onHover.set(this, (e) => {
|
|
3060
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
|
|
2684
3061
|
return;
|
|
2685
3062
|
}
|
|
2686
3063
|
e.preventDefault();
|
|
2687
|
-
const point = this.
|
|
2688
|
-
if (!this.
|
|
3064
|
+
const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
|
|
3065
|
+
if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
|
|
2689
3066
|
return;
|
|
2690
3067
|
}
|
|
3068
|
+
this.trigger("hover", { point });
|
|
2691
3069
|
});
|
|
3070
|
+
const store = new Store({ defaultStorage: { hasPointDown: false, prevClickPoint: null } });
|
|
3071
|
+
__classPrivateFieldSet$3(this, _BoardWatcher_store, store, "f");
|
|
3072
|
+
__classPrivateFieldSet$3(this, _BoardWatcher_opts, opts, "f");
|
|
3073
|
+
__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_init).call(this);
|
|
2692
3074
|
}
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
_getPoint(e) {
|
|
2697
|
-
const boardCanvas = this._opts.viewContent.boardContext.canvas;
|
|
2698
|
-
const rect = boardCanvas.getBoundingClientRect();
|
|
2699
|
-
const p = {
|
|
2700
|
-
x: e.clientX - rect.left,
|
|
2701
|
-
y: e.clientY - rect.top,
|
|
2702
|
-
t: Date.now()
|
|
2703
|
-
};
|
|
2704
|
-
return p;
|
|
2705
|
-
}
|
|
2706
|
-
_isVaildPoint(p) {
|
|
2707
|
-
const viewSize = this._opts.sharer.getActiveViewSizeInfo();
|
|
2708
|
-
const { width, height } = viewSize;
|
|
2709
|
-
if (isBoardAvailableNum(p.x) && isBoardAvailableNum(p.y) && p.x <= width && p.y <= height) {
|
|
2710
|
-
return true;
|
|
3075
|
+
onEvents() {
|
|
3076
|
+
if (__classPrivateFieldGet$3(this, _BoardWatcher_hasDestroyed, "f")) {
|
|
3077
|
+
return;
|
|
2711
3078
|
}
|
|
2712
|
-
|
|
3079
|
+
const container = window;
|
|
3080
|
+
container.addEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onHover, "f"));
|
|
3081
|
+
container.addEventListener("mousedown", __classPrivateFieldGet$3(this, _BoardWatcher_onPointStart, "f"));
|
|
3082
|
+
container.addEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onPointMove, "f"));
|
|
3083
|
+
container.addEventListener("mouseup", __classPrivateFieldGet$3(this, _BoardWatcher_onPointEnd, "f"));
|
|
3084
|
+
container.addEventListener("mouseleave", __classPrivateFieldGet$3(this, _BoardWatcher_onPointLeave, "f"));
|
|
3085
|
+
container.addEventListener("wheel", __classPrivateFieldGet$3(this, _BoardWatcher_onWheel, "f"), { passive: false });
|
|
3086
|
+
container.addEventListener("click", __classPrivateFieldGet$3(this, _BoardWatcher_onClick, "f"));
|
|
3087
|
+
container.addEventListener("contextmenu", __classPrivateFieldGet$3(this, _BoardWatcher_onContextMenu, "f"));
|
|
3088
|
+
}
|
|
3089
|
+
offEvents() {
|
|
3090
|
+
const container = window;
|
|
3091
|
+
container.removeEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onHover, "f"));
|
|
3092
|
+
container.removeEventListener("mousedown", __classPrivateFieldGet$3(this, _BoardWatcher_onPointStart, "f"));
|
|
3093
|
+
container.removeEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onPointMove, "f"));
|
|
3094
|
+
container.removeEventListener("mouseup", __classPrivateFieldGet$3(this, _BoardWatcher_onPointEnd, "f"));
|
|
3095
|
+
container.removeEventListener("mouseleave", __classPrivateFieldGet$3(this, _BoardWatcher_onPointLeave, "f"));
|
|
3096
|
+
container.removeEventListener("wheel", __classPrivateFieldGet$3(this, _BoardWatcher_onWheel, "f"));
|
|
3097
|
+
container.removeEventListener("click", __classPrivateFieldGet$3(this, _BoardWatcher_onClick, "f"));
|
|
3098
|
+
container.removeEventListener("contextmenu", __classPrivateFieldGet$3(this, _BoardWatcher_onContextMenu, "f"));
|
|
3099
|
+
}
|
|
3100
|
+
destroy() {
|
|
3101
|
+
this.offEvents();
|
|
3102
|
+
__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").destroy();
|
|
3103
|
+
__classPrivateFieldSet$3(this, _BoardWatcher_hasDestroyed, true, "f");
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
_BoardWatcher_opts = /* @__PURE__ */ new WeakMap(), _BoardWatcher_store = /* @__PURE__ */ new WeakMap(), _BoardWatcher_hasDestroyed = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onWheel = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onContextMenu = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onClick = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onPointLeave = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onPointEnd = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onPointMove = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onPointStart = /* @__PURE__ */ new WeakMap(), _BoardWatcher_onHover = /* @__PURE__ */ new WeakMap(), _BoardWatcher_instances = /* @__PURE__ */ new WeakSet(), _BoardWatcher_init = function _BoardWatcher_init2() {
|
|
3107
|
+
this.onEvents();
|
|
3108
|
+
}, _BoardWatcher_isInTarget = function _BoardWatcher_isInTarget2(e) {
|
|
3109
|
+
return e.target === __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").boardContent.boardContext.canvas;
|
|
3110
|
+
}, _BoardWatcher_getPoint = function _BoardWatcher_getPoint2(e) {
|
|
3111
|
+
const boardCanvas = __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").boardContent.boardContext.canvas;
|
|
3112
|
+
const rect = boardCanvas.getBoundingClientRect();
|
|
3113
|
+
const p = {
|
|
3114
|
+
x: e.clientX - rect.left,
|
|
3115
|
+
y: e.clientY - rect.top,
|
|
3116
|
+
t: Date.now()
|
|
3117
|
+
};
|
|
3118
|
+
return p;
|
|
3119
|
+
}, _BoardWatcher_isVaildPoint = function _BoardWatcher_isVaildPoint2(p) {
|
|
3120
|
+
const viewSize = __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").sharer.getActiveViewSizeInfo();
|
|
3121
|
+
const { width, height } = viewSize;
|
|
3122
|
+
if (isBoardAvailableNum(p.x) && isBoardAvailableNum(p.y) && p.x <= width && p.y <= height) {
|
|
3123
|
+
return true;
|
|
2713
3124
|
}
|
|
2714
|
-
|
|
3125
|
+
return false;
|
|
3126
|
+
};
|
|
3127
|
+
var __classPrivateFieldSet$2 = function(receiver, state, value, kind, f) {
|
|
3128
|
+
if (kind === "m")
|
|
3129
|
+
throw new TypeError("Private method is not writable");
|
|
3130
|
+
if (kind === "a" && !f)
|
|
3131
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
3132
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
3133
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3134
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
3135
|
+
};
|
|
3136
|
+
var __classPrivateFieldGet$2 = function(receiver, state, kind, f) {
|
|
3137
|
+
if (kind === "a" && !f)
|
|
3138
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
3139
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
3140
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
3141
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
3142
|
+
};
|
|
3143
|
+
var _Sharer_activeStore, _Sharer_sharedStore;
|
|
2715
3144
|
const defaultActiveStorage = {
|
|
2716
3145
|
width: 0,
|
|
2717
3146
|
height: 0,
|
|
@@ -2727,139 +3156,113 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2727
3156
|
};
|
|
2728
3157
|
class Sharer {
|
|
2729
3158
|
constructor() {
|
|
3159
|
+
_Sharer_activeStore.set(this, void 0);
|
|
3160
|
+
_Sharer_sharedStore.set(this, void 0);
|
|
2730
3161
|
const activeStore = new Store({
|
|
2731
3162
|
defaultStorage: defaultActiveStorage
|
|
2732
3163
|
});
|
|
2733
3164
|
const sharedStore = new Store({
|
|
2734
3165
|
defaultStorage: {}
|
|
2735
3166
|
});
|
|
2736
|
-
this
|
|
2737
|
-
this
|
|
3167
|
+
__classPrivateFieldSet$2(this, _Sharer_activeStore, activeStore, "f");
|
|
3168
|
+
__classPrivateFieldSet$2(this, _Sharer_sharedStore, sharedStore, "f");
|
|
2738
3169
|
}
|
|
2739
3170
|
getActiveStorage(key2) {
|
|
2740
|
-
return this.
|
|
3171
|
+
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get(key2);
|
|
2741
3172
|
}
|
|
2742
3173
|
setActiveStorage(key2, storage) {
|
|
2743
|
-
return this.
|
|
3174
|
+
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set(key2, storage);
|
|
2744
3175
|
}
|
|
2745
3176
|
getActiveStoreSnapshot() {
|
|
2746
|
-
return this.
|
|
3177
|
+
return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").getSnapshot();
|
|
2747
3178
|
}
|
|
2748
3179
|
getSharedStorage(key2) {
|
|
2749
|
-
return this.
|
|
3180
|
+
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").get(key2);
|
|
2750
3181
|
}
|
|
2751
3182
|
setSharedStorage(key2, storage) {
|
|
2752
|
-
return this.
|
|
3183
|
+
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").set(key2, storage);
|
|
2753
3184
|
}
|
|
2754
3185
|
getSharedStoreSnapshot() {
|
|
2755
|
-
return this.
|
|
3186
|
+
return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").getSnapshot();
|
|
2756
3187
|
}
|
|
2757
3188
|
getActiveViewScaleInfo() {
|
|
2758
3189
|
const viewScaleInfo = {
|
|
2759
|
-
scale: this.
|
|
2760
|
-
offsetTop: this.
|
|
2761
|
-
offsetBottom: this.
|
|
2762
|
-
offsetLeft: this.
|
|
2763
|
-
offsetRight: this.
|
|
3190
|
+
scale: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("scale"),
|
|
3191
|
+
offsetTop: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetTop"),
|
|
3192
|
+
offsetBottom: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetBottom"),
|
|
3193
|
+
offsetLeft: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetLeft"),
|
|
3194
|
+
offsetRight: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetRight")
|
|
2764
3195
|
};
|
|
2765
3196
|
return viewScaleInfo;
|
|
2766
3197
|
}
|
|
2767
3198
|
setActiveViewScaleInfo(viewScaleInfo) {
|
|
2768
3199
|
const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight } = viewScaleInfo;
|
|
2769
|
-
this.
|
|
2770
|
-
this.
|
|
2771
|
-
this.
|
|
2772
|
-
this.
|
|
2773
|
-
this.
|
|
3200
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("scale", scale);
|
|
3201
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetTop", offsetTop);
|
|
3202
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetBottom", offsetBottom);
|
|
3203
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetLeft", offsetLeft);
|
|
3204
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetRight", offsetRight);
|
|
2774
3205
|
}
|
|
2775
3206
|
setActiveViewSizeInfo(size) {
|
|
2776
|
-
this.
|
|
2777
|
-
this.
|
|
2778
|
-
this.
|
|
2779
|
-
this.
|
|
2780
|
-
this.
|
|
3207
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("width", size.width);
|
|
3208
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("height", size.height);
|
|
3209
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("devicePixelRatio", size.devicePixelRatio);
|
|
3210
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("contextWidth", size.contextWidth);
|
|
3211
|
+
__classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("contextHeight", size.contextHeight);
|
|
2781
3212
|
}
|
|
2782
3213
|
getActiveViewSizeInfo() {
|
|
2783
3214
|
const sizeInfo = {
|
|
2784
|
-
width: this.
|
|
2785
|
-
height: this.
|
|
2786
|
-
devicePixelRatio: this.
|
|
2787
|
-
contextWidth: this.
|
|
2788
|
-
contextHeight: this.
|
|
3215
|
+
width: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("width"),
|
|
3216
|
+
height: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("height"),
|
|
3217
|
+
devicePixelRatio: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("devicePixelRatio"),
|
|
3218
|
+
contextWidth: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("contextWidth"),
|
|
3219
|
+
contextHeight: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("contextHeight")
|
|
2789
3220
|
};
|
|
2790
3221
|
return sizeInfo;
|
|
2791
3222
|
}
|
|
2792
3223
|
}
|
|
3224
|
+
_Sharer_activeStore = /* @__PURE__ */ new WeakMap(), _Sharer_sharedStore = /* @__PURE__ */ new WeakMap();
|
|
3225
|
+
var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
|
|
3226
|
+
if (kind === "m")
|
|
3227
|
+
throw new TypeError("Private method is not writable");
|
|
3228
|
+
if (kind === "a" && !f)
|
|
3229
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
3230
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
3231
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3232
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
3233
|
+
};
|
|
3234
|
+
var __classPrivateFieldGet$1 = function(receiver, state, kind, f) {
|
|
3235
|
+
if (kind === "a" && !f)
|
|
3236
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
3237
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
3238
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
3239
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
3240
|
+
};
|
|
3241
|
+
var _Viewer_instances, _Viewer_opts, _Viewer_drawFrameSnapshotQueue, _Viewer_drawFrameStatus, _Viewer_init, _Viewer_drawAnimationFrame;
|
|
2793
3242
|
const { requestAnimationFrame } = window;
|
|
2794
3243
|
class Viewer extends EventEmitter {
|
|
2795
3244
|
constructor(opts) {
|
|
2796
3245
|
super();
|
|
2797
|
-
this
|
|
2798
|
-
this
|
|
2799
|
-
this
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
const { renderer } = this._opts;
|
|
2804
|
-
renderer.on("load", () => {
|
|
2805
|
-
this.drawFrame();
|
|
2806
|
-
});
|
|
2807
|
-
}
|
|
2808
|
-
_drawAnimationFrame() {
|
|
2809
|
-
if (this._drawFrameStatus === "DRAWING" || this._drawFrameSnapshotQueue.length === 0) {
|
|
2810
|
-
return;
|
|
2811
|
-
} else {
|
|
2812
|
-
this._drawFrameStatus = "DRAWING";
|
|
2813
|
-
}
|
|
2814
|
-
const snapshot = this._drawFrameSnapshotQueue.shift();
|
|
2815
|
-
const { renderer, viewContent, beforeDrawFrame, afterDrawFrame } = this._opts;
|
|
2816
|
-
if (snapshot) {
|
|
2817
|
-
const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = snapshot.activeStore;
|
|
2818
|
-
if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.activeStore.data) {
|
|
2819
|
-
renderer.drawData(snapshot.activeStore.data, {
|
|
2820
|
-
viewScaleInfo: {
|
|
2821
|
-
scale,
|
|
2822
|
-
offsetTop,
|
|
2823
|
-
offsetBottom,
|
|
2824
|
-
offsetLeft,
|
|
2825
|
-
offsetRight
|
|
2826
|
-
},
|
|
2827
|
-
viewSizeInfo: {
|
|
2828
|
-
width,
|
|
2829
|
-
height,
|
|
2830
|
-
contextHeight,
|
|
2831
|
-
contextWidth,
|
|
2832
|
-
devicePixelRatio
|
|
2833
|
-
}
|
|
2834
|
-
});
|
|
2835
|
-
}
|
|
2836
|
-
beforeDrawFrame({ snapshot });
|
|
2837
|
-
viewContent.drawView();
|
|
2838
|
-
afterDrawFrame({ snapshot });
|
|
2839
|
-
}
|
|
2840
|
-
if (this._drawFrameSnapshotQueue.length === 0) {
|
|
2841
|
-
this._drawFrameStatus = "COMPLETE";
|
|
2842
|
-
return;
|
|
2843
|
-
}
|
|
2844
|
-
if (this._drawFrameStatus = "DRAWING") {
|
|
2845
|
-
requestAnimationFrame(() => {
|
|
2846
|
-
this._drawAnimationFrame();
|
|
2847
|
-
});
|
|
2848
|
-
}
|
|
3246
|
+
_Viewer_instances.add(this);
|
|
3247
|
+
_Viewer_opts.set(this, void 0);
|
|
3248
|
+
_Viewer_drawFrameSnapshotQueue.set(this, []);
|
|
3249
|
+
_Viewer_drawFrameStatus.set(this, "FREE");
|
|
3250
|
+
__classPrivateFieldSet$1(this, _Viewer_opts, opts, "f");
|
|
3251
|
+
__classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_init).call(this);
|
|
2849
3252
|
}
|
|
2850
3253
|
drawFrame() {
|
|
2851
|
-
const { sharer } = this
|
|
3254
|
+
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
2852
3255
|
const activeStore = sharer.getActiveStoreSnapshot();
|
|
2853
3256
|
const sharedStore = sharer.getSharedStoreSnapshot();
|
|
2854
|
-
this.
|
|
3257
|
+
__classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").push({
|
|
2855
3258
|
activeStore,
|
|
2856
3259
|
sharedStore
|
|
2857
3260
|
});
|
|
2858
|
-
this.
|
|
3261
|
+
__classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_drawAnimationFrame).call(this);
|
|
2859
3262
|
}
|
|
2860
3263
|
scale(opts) {
|
|
2861
3264
|
const { scale, point } = opts;
|
|
2862
|
-
const { sharer } = this
|
|
3265
|
+
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
2863
3266
|
const { moveX, moveY } = viewScale({
|
|
2864
3267
|
scale,
|
|
2865
3268
|
point,
|
|
@@ -2870,7 +3273,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2870
3273
|
return { moveX, moveY };
|
|
2871
3274
|
}
|
|
2872
3275
|
scroll(opts) {
|
|
2873
|
-
const { sharer } = this
|
|
3276
|
+
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
2874
3277
|
const prevViewScaleInfo = sharer.getActiveViewScaleInfo();
|
|
2875
3278
|
const { moveX, moveY } = opts;
|
|
2876
3279
|
const viewSizeInfo = sharer.getActiveViewSizeInfo();
|
|
@@ -2884,7 +3287,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2884
3287
|
return viewScaleInfo;
|
|
2885
3288
|
}
|
|
2886
3289
|
updateViewScaleInfo(opts) {
|
|
2887
|
-
const { sharer } = this
|
|
3290
|
+
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
2888
3291
|
const viewScaleInfo = calcViewScaleInfo(opts, {
|
|
2889
3292
|
viewSizeInfo: sharer.getActiveViewSizeInfo()
|
|
2890
3293
|
});
|
|
@@ -2892,11 +3295,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2892
3295
|
return viewScaleInfo;
|
|
2893
3296
|
}
|
|
2894
3297
|
resize(viewSize = {}) {
|
|
2895
|
-
const { sharer } = this
|
|
3298
|
+
const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
2896
3299
|
const originViewSize = sharer.getActiveViewSizeInfo();
|
|
2897
3300
|
const newViewSize = Object.assign(Object.assign({}, originViewSize), viewSize);
|
|
2898
3301
|
const { width, height, devicePixelRatio } = newViewSize;
|
|
2899
|
-
const { underContext, boardContext, helperContext, viewContext } = this.
|
|
3302
|
+
const { underContext, boardContext, helperContext, viewContext } = __classPrivateFieldGet$1(this, _Viewer_opts, "f").boardContent;
|
|
2900
3303
|
boardContext.canvas.width = width * devicePixelRatio;
|
|
2901
3304
|
boardContext.canvas.height = height * devicePixelRatio;
|
|
2902
3305
|
boardContext.canvas.style.width = `${width}px`;
|
|
@@ -2911,401 +3314,538 @@ var __privateMethod = (obj, member, method) => {
|
|
|
2911
3314
|
return newViewSize;
|
|
2912
3315
|
}
|
|
2913
3316
|
}
|
|
3317
|
+
_Viewer_opts = /* @__PURE__ */ new WeakMap(), _Viewer_drawFrameSnapshotQueue = /* @__PURE__ */ new WeakMap(), _Viewer_drawFrameStatus = /* @__PURE__ */ new WeakMap(), _Viewer_instances = /* @__PURE__ */ new WeakSet(), _Viewer_init = function _Viewer_init2() {
|
|
3318
|
+
const { renderer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3319
|
+
renderer.on("load", () => {
|
|
3320
|
+
this.drawFrame();
|
|
3321
|
+
});
|
|
3322
|
+
}, _Viewer_drawAnimationFrame = function _Viewer_drawAnimationFrame2() {
|
|
3323
|
+
if (__classPrivateFieldGet$1(this, _Viewer_drawFrameStatus, "f") === "DRAWING" || __classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").length === 0) {
|
|
3324
|
+
return;
|
|
3325
|
+
} else {
|
|
3326
|
+
__classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "DRAWING", "f");
|
|
3327
|
+
}
|
|
3328
|
+
const snapshot = __classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").shift();
|
|
3329
|
+
const { renderer, boardContent, beforeDrawFrame, afterDrawFrame } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
|
|
3330
|
+
if (snapshot) {
|
|
3331
|
+
const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = snapshot.activeStore;
|
|
3332
|
+
const viewScaleInfo = {
|
|
3333
|
+
scale,
|
|
3334
|
+
offsetTop,
|
|
3335
|
+
offsetBottom,
|
|
3336
|
+
offsetLeft,
|
|
3337
|
+
offsetRight
|
|
3338
|
+
};
|
|
3339
|
+
const viewSizeInfo = {
|
|
3340
|
+
width,
|
|
3341
|
+
height,
|
|
3342
|
+
contextHeight,
|
|
3343
|
+
contextWidth,
|
|
3344
|
+
devicePixelRatio
|
|
3345
|
+
};
|
|
3346
|
+
if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.activeStore.data) {
|
|
3347
|
+
renderer.drawData(snapshot.activeStore.data, {
|
|
3348
|
+
viewScaleInfo,
|
|
3349
|
+
viewSizeInfo
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
beforeDrawFrame({ snapshot });
|
|
3353
|
+
boardContent.drawView();
|
|
3354
|
+
afterDrawFrame({ snapshot });
|
|
3355
|
+
}
|
|
3356
|
+
if (__classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").length === 0) {
|
|
3357
|
+
__classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "COMPLETE", "f");
|
|
3358
|
+
return;
|
|
3359
|
+
}
|
|
3360
|
+
if (__classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "DRAWING", "f")) {
|
|
3361
|
+
requestAnimationFrame(() => {
|
|
3362
|
+
__classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_drawAnimationFrame2).call(this);
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
};
|
|
3366
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
3367
|
+
if (kind === "m")
|
|
3368
|
+
throw new TypeError("Private method is not writable");
|
|
3369
|
+
if (kind === "a" && !f)
|
|
3370
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
3371
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
3372
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3373
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
3374
|
+
};
|
|
3375
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
3376
|
+
if (kind === "a" && !f)
|
|
3377
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
3378
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
3379
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
3380
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
3381
|
+
};
|
|
3382
|
+
var _Board_instances, _Board_opts, _Board_middlewareMap, _Board_middlewares, _Board_activeMiddlewareObjs, _Board_watcher, _Board_renderer, _Board_sharer, _Board_viewer, _Board_calculator, _Board_eventHub, _Board_hasDestroyed, _Board_init, _Board_handlePointStart, _Board_handlePointEnd, _Board_handlePointMove, _Board_handleHover, _Board_handleDoubleClick, _Board_handleWheel, _Board_handleWheelScale, _Board_handleScrollX, _Board_handleScrollY, _Board_handleResize, _Board_handleClear, _Board_handleBeforeDrawFrame, _Board_handleAfterDrawFrame, _Board_resetActiveMiddlewareObjs;
|
|
2914
3383
|
const throttleTime = 10;
|
|
2915
|
-
const LOCK_MODES = ["RULER"];
|
|
2916
3384
|
class Board {
|
|
2917
3385
|
constructor(opts) {
|
|
2918
|
-
this
|
|
2919
|
-
this
|
|
2920
|
-
this
|
|
2921
|
-
this
|
|
2922
|
-
this
|
|
2923
|
-
|
|
3386
|
+
_Board_instances.add(this);
|
|
3387
|
+
_Board_opts.set(this, void 0);
|
|
3388
|
+
_Board_middlewareMap.set(this, /* @__PURE__ */ new WeakMap());
|
|
3389
|
+
_Board_middlewares.set(this, []);
|
|
3390
|
+
_Board_activeMiddlewareObjs.set(this, []);
|
|
3391
|
+
_Board_watcher.set(this, void 0);
|
|
3392
|
+
_Board_renderer.set(this, void 0);
|
|
3393
|
+
_Board_sharer.set(this, void 0);
|
|
3394
|
+
_Board_viewer.set(this, void 0);
|
|
3395
|
+
_Board_calculator.set(this, void 0);
|
|
3396
|
+
_Board_eventHub.set(this, new EventEmitter());
|
|
3397
|
+
_Board_hasDestroyed.set(this, false);
|
|
3398
|
+
const { boardContent } = opts;
|
|
2924
3399
|
const sharer = new Sharer();
|
|
2925
|
-
const calculator = new Calculator({
|
|
3400
|
+
const calculator = new Calculator({ viewContext: boardContent.viewContext });
|
|
2926
3401
|
const watcher = new BoardWatcher({
|
|
2927
|
-
|
|
3402
|
+
boardContent,
|
|
2928
3403
|
sharer
|
|
2929
3404
|
});
|
|
2930
3405
|
const renderer = new Renderer({
|
|
2931
|
-
|
|
3406
|
+
viewContext: boardContent.viewContext,
|
|
2932
3407
|
sharer,
|
|
2933
3408
|
calculator
|
|
2934
3409
|
});
|
|
2935
|
-
this
|
|
2936
|
-
this
|
|
2937
|
-
this
|
|
2938
|
-
this
|
|
2939
|
-
this
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
});
|
|
2951
|
-
this._init();
|
|
2952
|
-
this._resetActiveMiddlewareObjs();
|
|
2953
|
-
}
|
|
2954
|
-
_init() {
|
|
2955
|
-
this._watcher.on("pointStart", this._handlePointStart.bind(this));
|
|
2956
|
-
this._watcher.on("pointEnd", this._handlePointEnd.bind(this));
|
|
2957
|
-
this._watcher.on("pointMove", throttle((e) => {
|
|
2958
|
-
this._handlePointMove(e);
|
|
2959
|
-
}, throttleTime));
|
|
2960
|
-
this._watcher.on("hover", throttle((e) => {
|
|
2961
|
-
this._handleHover(e);
|
|
2962
|
-
}, throttleTime));
|
|
2963
|
-
this._watcher.on("wheel", throttle((e) => {
|
|
2964
|
-
this._handleWheel(e);
|
|
2965
|
-
}, throttleTime));
|
|
2966
|
-
this._watcher.on("wheelScale", throttle((e) => {
|
|
2967
|
-
this._handleWheelScale(e);
|
|
2968
|
-
}, throttleTime));
|
|
2969
|
-
this._watcher.on("scrollX", this._handleScrollX.bind(this));
|
|
2970
|
-
this._watcher.on("scrollY", this._handleScrollY.bind(this));
|
|
2971
|
-
this._watcher.on("resize", this._handleResize.bind(this));
|
|
2972
|
-
this._watcher.on("doubleClick", this._handleDoubleClick.bind(this));
|
|
2973
|
-
}
|
|
2974
|
-
_handlePointStart(e) {
|
|
2975
|
-
var _a;
|
|
2976
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
2977
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
2978
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointStart) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
2979
|
-
if (result === false) {
|
|
2980
|
-
return;
|
|
2981
|
-
}
|
|
2982
|
-
}
|
|
2983
|
-
}
|
|
2984
|
-
_handlePointEnd(e) {
|
|
2985
|
-
var _a;
|
|
2986
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
2987
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
2988
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointEnd) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
2989
|
-
if (result === false) {
|
|
2990
|
-
return;
|
|
2991
|
-
}
|
|
2992
|
-
}
|
|
2993
|
-
}
|
|
2994
|
-
_handlePointMove(e) {
|
|
2995
|
-
var _a;
|
|
2996
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
2997
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
2998
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointMove) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
2999
|
-
if (result === false) {
|
|
3000
|
-
return;
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
}
|
|
3004
|
-
_handleHover(e) {
|
|
3005
|
-
var _a;
|
|
3006
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3007
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3008
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.hover) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3009
|
-
if (result === false) {
|
|
3010
|
-
return;
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
|
-
_handleDoubleClick(e) {
|
|
3015
|
-
var _a;
|
|
3016
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3017
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3018
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.doubleClick) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3019
|
-
if (result === false) {
|
|
3020
|
-
return;
|
|
3021
|
-
}
|
|
3022
|
-
}
|
|
3023
|
-
}
|
|
3024
|
-
_handleWheel(e) {
|
|
3025
|
-
var _a;
|
|
3026
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3027
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3028
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheel) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3029
|
-
if (result === false) {
|
|
3030
|
-
return;
|
|
3031
|
-
}
|
|
3032
|
-
}
|
|
3033
|
-
}
|
|
3034
|
-
_handleWheelScale(e) {
|
|
3035
|
-
var _a;
|
|
3036
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3037
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3038
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheelScale) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3039
|
-
if (result === false) {
|
|
3040
|
-
return;
|
|
3041
|
-
}
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
_handleScrollX(e) {
|
|
3045
|
-
var _a;
|
|
3046
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3047
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3048
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.scrollX) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3049
|
-
if (result === false) {
|
|
3050
|
-
return;
|
|
3051
|
-
}
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
_handleScrollY(e) {
|
|
3055
|
-
var _a;
|
|
3056
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3057
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3058
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.scrollY) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3059
|
-
if (result === false) {
|
|
3060
|
-
return;
|
|
3061
|
-
}
|
|
3062
|
-
}
|
|
3063
|
-
}
|
|
3064
|
-
_handleResize(e) {
|
|
3065
|
-
var _a;
|
|
3066
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3067
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3068
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.resize) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3069
|
-
if (result === false) {
|
|
3070
|
-
return;
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
}
|
|
3074
|
-
_handleClear(e) {
|
|
3075
|
-
var _a;
|
|
3076
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3077
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3078
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.clear) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3079
|
-
if (result === false) {
|
|
3080
|
-
return;
|
|
3081
|
-
}
|
|
3082
|
-
}
|
|
3083
|
-
}
|
|
3084
|
-
_handleBeforeDrawFrame(e) {
|
|
3085
|
-
var _a;
|
|
3086
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3087
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3088
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.beforeDrawFrame) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3089
|
-
if (result === false) {
|
|
3090
|
-
return;
|
|
3410
|
+
__classPrivateFieldSet(this, _Board_opts, opts, "f");
|
|
3411
|
+
__classPrivateFieldSet(this, _Board_sharer, sharer, "f");
|
|
3412
|
+
__classPrivateFieldSet(this, _Board_watcher, watcher, "f");
|
|
3413
|
+
__classPrivateFieldSet(this, _Board_renderer, renderer, "f");
|
|
3414
|
+
__classPrivateFieldSet(this, _Board_calculator, calculator, "f");
|
|
3415
|
+
__classPrivateFieldSet(this, _Board_viewer, new Viewer({
|
|
3416
|
+
boardContent: opts.boardContent,
|
|
3417
|
+
sharer,
|
|
3418
|
+
renderer,
|
|
3419
|
+
calculator: __classPrivateFieldGet(this, _Board_calculator, "f"),
|
|
3420
|
+
beforeDrawFrame: (e) => {
|
|
3421
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleBeforeDrawFrame).call(this, e);
|
|
3422
|
+
},
|
|
3423
|
+
afterDrawFrame: (e) => {
|
|
3424
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleAfterDrawFrame).call(this, e);
|
|
3091
3425
|
}
|
|
3092
|
-
}
|
|
3426
|
+
}), "f");
|
|
3427
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_init).call(this);
|
|
3428
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
|
|
3093
3429
|
}
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
|
|
3097
|
-
const obj = this._activeMiddlewareObjs[i];
|
|
3098
|
-
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.afterDrawFrame) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3099
|
-
if (result === false) {
|
|
3100
|
-
return;
|
|
3101
|
-
}
|
|
3102
|
-
}
|
|
3430
|
+
isDestroyed() {
|
|
3431
|
+
return __classPrivateFieldGet(this, _Board_hasDestroyed, "f");
|
|
3103
3432
|
}
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
this.
|
|
3109
|
-
|
|
3110
|
-
activeMiddlewareObjs.push(m);
|
|
3111
|
-
} else if (modes.includes(m.mode)) {
|
|
3112
|
-
activeMiddlewareObjs.push(m);
|
|
3113
|
-
}
|
|
3114
|
-
});
|
|
3115
|
-
this._activeMiddlewareObjs = activeMiddlewareObjs;
|
|
3433
|
+
destroy() {
|
|
3434
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").destroy();
|
|
3435
|
+
__classPrivateFieldGet(this, _Board_renderer, "f").destroy();
|
|
3436
|
+
__classPrivateFieldGet(this, _Board_calculator, "f").destroy();
|
|
3437
|
+
__classPrivateFieldGet(this, _Board_eventHub, "f").destroy();
|
|
3438
|
+
__classPrivateFieldSet(this, _Board_hasDestroyed, true, "f");
|
|
3116
3439
|
}
|
|
3117
3440
|
getSharer() {
|
|
3118
|
-
return this
|
|
3441
|
+
return __classPrivateFieldGet(this, _Board_sharer, "f");
|
|
3119
3442
|
}
|
|
3120
3443
|
getViewer() {
|
|
3121
|
-
return this
|
|
3444
|
+
return __classPrivateFieldGet(this, _Board_viewer, "f");
|
|
3445
|
+
}
|
|
3446
|
+
getRenderer() {
|
|
3447
|
+
return __classPrivateFieldGet(this, _Board_renderer, "f");
|
|
3122
3448
|
}
|
|
3123
3449
|
setData(data) {
|
|
3124
|
-
const sharer = this
|
|
3125
|
-
this.
|
|
3450
|
+
const sharer = __classPrivateFieldGet(this, _Board_sharer, "f");
|
|
3451
|
+
__classPrivateFieldGet(this, _Board_sharer, "f").setActiveStorage("data", data);
|
|
3126
3452
|
const viewSizeInfo = sharer.getActiveViewSizeInfo();
|
|
3127
3453
|
const newViewContextSize = calcElementsContextSize(data.elements, {
|
|
3128
3454
|
viewWidth: viewSizeInfo.width,
|
|
3129
3455
|
viewHeight: viewSizeInfo.height,
|
|
3130
3456
|
extend: true
|
|
3131
3457
|
});
|
|
3132
|
-
this.
|
|
3458
|
+
__classPrivateFieldGet(this, _Board_viewer, "f").drawFrame();
|
|
3133
3459
|
const newViewSizeInfo = Object.assign(Object.assign({}, viewSizeInfo), newViewContextSize);
|
|
3134
|
-
this.
|
|
3460
|
+
__classPrivateFieldGet(this, _Board_sharer, "f").setActiveViewSizeInfo(newViewSizeInfo);
|
|
3135
3461
|
return { viewSizeInfo: newViewSizeInfo };
|
|
3136
3462
|
}
|
|
3137
3463
|
getData() {
|
|
3138
|
-
const { data } = this.
|
|
3464
|
+
const { data } = __classPrivateFieldGet(this, _Board_sharer, "f").getActiveStoreSnapshot();
|
|
3139
3465
|
return data;
|
|
3140
3466
|
}
|
|
3141
3467
|
use(middleware) {
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3468
|
+
var _a, _b, _c;
|
|
3469
|
+
if (__classPrivateFieldGet(this, _Board_middlewareMap, "f").has(middleware)) {
|
|
3470
|
+
const item = __classPrivateFieldGet(this, _Board_middlewareMap, "f").get(middleware);
|
|
3471
|
+
if (item) {
|
|
3472
|
+
(_b = (_a = item.middlewareObject).use) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3473
|
+
item.status = "enable";
|
|
3474
|
+
__classPrivateFieldGet(this, _Board_middlewareMap, "f").set(middleware, item);
|
|
3475
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
|
|
3476
|
+
return;
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
const { boardContent, container } = __classPrivateFieldGet(this, _Board_opts, "f");
|
|
3480
|
+
const sharer = __classPrivateFieldGet(this, _Board_sharer, "f");
|
|
3481
|
+
const viewer = __classPrivateFieldGet(this, _Board_viewer, "f");
|
|
3482
|
+
const calculator = __classPrivateFieldGet(this, _Board_calculator, "f");
|
|
3483
|
+
const eventHub = __classPrivateFieldGet(this, _Board_eventHub, "f");
|
|
3484
|
+
const obj = middleware({ boardContent, sharer, viewer, calculator, eventHub, container });
|
|
3485
|
+
(_c = obj.use) === null || _c === void 0 ? void 0 : _c.call(obj);
|
|
3486
|
+
__classPrivateFieldGet(this, _Board_middlewares, "f").push(middleware);
|
|
3487
|
+
__classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").push(obj);
|
|
3488
|
+
__classPrivateFieldGet(this, _Board_middlewareMap, "f").set(middleware, {
|
|
3489
|
+
status: "enable",
|
|
3490
|
+
middlewareObject: obj
|
|
3491
|
+
});
|
|
3492
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
|
|
3493
|
+
}
|
|
3494
|
+
disuse(middleware) {
|
|
3495
|
+
var _a, _b;
|
|
3496
|
+
const item = __classPrivateFieldGet(this, _Board_middlewareMap, "f").get(middleware);
|
|
3497
|
+
if (item) {
|
|
3498
|
+
(_b = (_a = item.middlewareObject).disuse) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3499
|
+
item.status = "disable";
|
|
3500
|
+
__classPrivateFieldGet(this, _Board_middlewareMap, "f").set(middleware, item);
|
|
3501
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
|
|
3502
|
+
}
|
|
3147
3503
|
}
|
|
3148
3504
|
scale(opts) {
|
|
3149
|
-
const
|
|
3505
|
+
const viewer = __classPrivateFieldGet(this, _Board_viewer, "f");
|
|
3150
3506
|
const { moveX, moveY } = viewer.scale(opts);
|
|
3151
3507
|
viewer.scroll({ moveX, moveY });
|
|
3152
3508
|
}
|
|
3153
3509
|
scroll(opts) {
|
|
3154
|
-
return this.
|
|
3510
|
+
return __classPrivateFieldGet(this, _Board_viewer, "f").scroll(opts);
|
|
3155
3511
|
}
|
|
3156
3512
|
updateViewScaleInfo(opts) {
|
|
3157
|
-
return this.
|
|
3513
|
+
return __classPrivateFieldGet(this, _Board_viewer, "f").updateViewScaleInfo(opts);
|
|
3158
3514
|
}
|
|
3159
3515
|
resize(newViewSize) {
|
|
3160
|
-
const viewSize = this.
|
|
3516
|
+
const viewSize = __classPrivateFieldGet(this, _Board_viewer, "f").resize(newViewSize);
|
|
3161
3517
|
const { width, height, devicePixelRatio } = newViewSize;
|
|
3162
|
-
const {
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
this
|
|
3168
|
-
this.
|
|
3518
|
+
const { boardContent } = __classPrivateFieldGet(this, _Board_opts, "f");
|
|
3519
|
+
boardContent.viewContext.$resize({ width, height, devicePixelRatio });
|
|
3520
|
+
boardContent.helperContext.$resize({ width, height, devicePixelRatio });
|
|
3521
|
+
boardContent.boardContext.$resize({ width, height, devicePixelRatio });
|
|
3522
|
+
boardContent.underContext.$resize({ width, height, devicePixelRatio });
|
|
3523
|
+
__classPrivateFieldGet(this, _Board_viewer, "f").drawFrame();
|
|
3524
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").trigger("resize", viewSize);
|
|
3525
|
+
__classPrivateFieldGet(this, _Board_sharer, "f").setActiveViewSizeInfo(newViewSize);
|
|
3169
3526
|
}
|
|
3170
3527
|
clear() {
|
|
3171
|
-
const {
|
|
3172
|
-
const { underContext, helperContext, viewContext, boardContext } =
|
|
3528
|
+
const { boardContent } = __classPrivateFieldGet(this, _Board_opts, "f");
|
|
3529
|
+
const { underContext, helperContext, viewContext, boardContext } = boardContent;
|
|
3173
3530
|
underContext.clearRect(0, 0, underContext.canvas.width, underContext.canvas.height);
|
|
3174
3531
|
helperContext.clearRect(0, 0, helperContext.canvas.width, helperContext.canvas.height);
|
|
3175
3532
|
viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
|
|
3176
3533
|
boardContext.clearRect(0, 0, boardContext.canvas.width, boardContext.canvas.height);
|
|
3177
|
-
this.
|
|
3534
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleClear).call(this);
|
|
3178
3535
|
}
|
|
3179
3536
|
getEventHub() {
|
|
3180
|
-
return this
|
|
3537
|
+
return __classPrivateFieldGet(this, _Board_eventHub, "f");
|
|
3538
|
+
}
|
|
3539
|
+
onWatcherEvents() {
|
|
3540
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").onEvents();
|
|
3541
|
+
}
|
|
3542
|
+
offWatcherEvents() {
|
|
3543
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").offEvents();
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
_Board_opts = /* @__PURE__ */ new WeakMap(), _Board_middlewareMap = /* @__PURE__ */ new WeakMap(), _Board_middlewares = /* @__PURE__ */ new WeakMap(), _Board_activeMiddlewareObjs = /* @__PURE__ */ new WeakMap(), _Board_watcher = /* @__PURE__ */ new WeakMap(), _Board_renderer = /* @__PURE__ */ new WeakMap(), _Board_sharer = /* @__PURE__ */ new WeakMap(), _Board_viewer = /* @__PURE__ */ new WeakMap(), _Board_calculator = /* @__PURE__ */ new WeakMap(), _Board_eventHub = /* @__PURE__ */ new WeakMap(), _Board_hasDestroyed = /* @__PURE__ */ new WeakMap(), _Board_instances = /* @__PURE__ */ new WeakSet(), _Board_init = function _Board_init2() {
|
|
3547
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("pointStart", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointStart).bind(this));
|
|
3548
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("pointEnd", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointEnd).bind(this));
|
|
3549
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("pointMove", throttle((e) => {
|
|
3550
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handlePointMove).call(this, e);
|
|
3551
|
+
}, throttleTime));
|
|
3552
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("hover", throttle((e) => {
|
|
3553
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleHover).call(this, e);
|
|
3554
|
+
}, throttleTime));
|
|
3555
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("wheel", throttle((e) => {
|
|
3556
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheel).call(this, e);
|
|
3557
|
+
}, throttleTime));
|
|
3558
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("wheelScale", throttle((e) => {
|
|
3559
|
+
__classPrivateFieldGet(this, _Board_instances, "m", _Board_handleWheelScale).call(this, e);
|
|
3560
|
+
}, throttleTime));
|
|
3561
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("scrollX", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleScrollX).bind(this));
|
|
3562
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("scrollY", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleScrollY).bind(this));
|
|
3563
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("resize", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleResize).bind(this));
|
|
3564
|
+
__classPrivateFieldGet(this, _Board_watcher, "f").on("doubleClick", __classPrivateFieldGet(this, _Board_instances, "m", _Board_handleDoubleClick).bind(this));
|
|
3565
|
+
}, _Board_handlePointStart = function _Board_handlePointStart2(e) {
|
|
3566
|
+
var _a;
|
|
3567
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3568
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3569
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointStart) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3570
|
+
if (result === false) {
|
|
3571
|
+
return;
|
|
3572
|
+
}
|
|
3181
3573
|
}
|
|
3182
|
-
}
|
|
3574
|
+
}, _Board_handlePointEnd = function _Board_handlePointEnd2(e) {
|
|
3575
|
+
var _a;
|
|
3576
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3577
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3578
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointEnd) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3579
|
+
if (result === false) {
|
|
3580
|
+
return;
|
|
3581
|
+
}
|
|
3582
|
+
}
|
|
3583
|
+
}, _Board_handlePointMove = function _Board_handlePointMove2(e) {
|
|
3584
|
+
var _a;
|
|
3585
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3586
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3587
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.pointMove) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3588
|
+
if (result === false) {
|
|
3589
|
+
return;
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
}, _Board_handleHover = function _Board_handleHover2(e) {
|
|
3593
|
+
var _a;
|
|
3594
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3595
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3596
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.hover) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3597
|
+
if (result === false) {
|
|
3598
|
+
return;
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
}, _Board_handleDoubleClick = function _Board_handleDoubleClick2(e) {
|
|
3602
|
+
var _a;
|
|
3603
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3604
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3605
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.doubleClick) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3606
|
+
if (result === false) {
|
|
3607
|
+
return;
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
}, _Board_handleWheel = function _Board_handleWheel2(e) {
|
|
3611
|
+
var _a;
|
|
3612
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3613
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3614
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheel) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3615
|
+
if (result === false) {
|
|
3616
|
+
return;
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
}, _Board_handleWheelScale = function _Board_handleWheelScale2(e) {
|
|
3620
|
+
var _a;
|
|
3621
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3622
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3623
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheelScale) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3624
|
+
if (result === false) {
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
}, _Board_handleScrollX = function _Board_handleScrollX2(e) {
|
|
3629
|
+
var _a;
|
|
3630
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3631
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3632
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.scrollX) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3633
|
+
if (result === false) {
|
|
3634
|
+
return;
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
}, _Board_handleScrollY = function _Board_handleScrollY2(e) {
|
|
3638
|
+
var _a;
|
|
3639
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3640
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3641
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.scrollY) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3642
|
+
if (result === false) {
|
|
3643
|
+
return;
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
}, _Board_handleResize = function _Board_handleResize2(e) {
|
|
3647
|
+
var _a;
|
|
3648
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3649
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3650
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.resize) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3651
|
+
if (result === false) {
|
|
3652
|
+
return;
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
}, _Board_handleClear = function _Board_handleClear2(e) {
|
|
3656
|
+
var _a;
|
|
3657
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3658
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3659
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.clear) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3660
|
+
if (result === false) {
|
|
3661
|
+
return;
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
}, _Board_handleBeforeDrawFrame = function _Board_handleBeforeDrawFrame2(e) {
|
|
3665
|
+
var _a;
|
|
3666
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3667
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3668
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.beforeDrawFrame) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3669
|
+
if (result === false) {
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
}, _Board_handleAfterDrawFrame = function _Board_handleAfterDrawFrame2(e) {
|
|
3674
|
+
var _a;
|
|
3675
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f").length; i++) {
|
|
3676
|
+
const obj = __classPrivateFieldGet(this, _Board_activeMiddlewareObjs, "f")[i];
|
|
3677
|
+
const result = (_a = obj === null || obj === void 0 ? void 0 : obj.afterDrawFrame) === null || _a === void 0 ? void 0 : _a.call(obj, e);
|
|
3678
|
+
if (result === false) {
|
|
3679
|
+
return;
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
}, _Board_resetActiveMiddlewareObjs = function _Board_resetActiveMiddlewareObjs2() {
|
|
3683
|
+
const activeMiddlewareObjs = [];
|
|
3684
|
+
const middlewareMap = __classPrivateFieldGet(this, _Board_middlewareMap, "f");
|
|
3685
|
+
__classPrivateFieldGet(this, _Board_middlewares, "f").forEach((middleware) => {
|
|
3686
|
+
const item = middlewareMap.get(middleware);
|
|
3687
|
+
if ((item === null || item === void 0 ? void 0 : item.status) === "enable" && (item === null || item === void 0 ? void 0 : item.middlewareObject)) {
|
|
3688
|
+
activeMiddlewareObjs.push(item.middlewareObject);
|
|
3689
|
+
}
|
|
3690
|
+
});
|
|
3691
|
+
__classPrivateFieldSet(this, _Board_activeMiddlewareObjs, activeMiddlewareObjs, "f");
|
|
3692
|
+
};
|
|
3183
3693
|
const CURSOR = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjMtMDktMTdUMTY6MDc6MjYrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyIgcGhvdG9zaG9wOklDQ1Byb2ZpbGU9InNSR0IgSUVDNjE5NjYtMi4xIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjliMGM0MzI2LWU4ZTQtNDlkNy04MmUzLTgxODkwYTE2ZmU1YSIgeG1wTU06RG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjMzOGFhZDBmLWZkZjMtODE0MS1iMTZmLWNiZWIzNTQyYTJhMCIgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOjUwODAxNzc1LWZlNGEtNDQyMy05NDQ3LThkYWRhNzZhYTllOSI+IDx4bXBNTTpIaXN0b3J5PiA8cmRmOlNlcT4gPHJkZjpsaSBzdEV2dDphY3Rpb249ImNyZWF0ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NTA4MDE3NzUtZmU0YS00NDIzLTk0NDctOGRhZGE3NmFhOWU5IiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjA3OjI2KzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6OWIwYzQzMjYtZThlNC00OWQ3LTgyZTMtODE4OTBhMTZmZTVhIiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjEyOjUwKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7W6XrzAAAGLklEQVRYhb2Xf2iUdRzHX/txtfXLplZ6Wblm6fzRmG6r7Uou1AxKRjQKYUqgaLBACFogppcK1h8aLRkMSYaJIA5hYMomZpskEfPOufCaDpZ6t7rbre263U3vzn3643meu+eu3XNzvz7w4bbdc/e89nl/Pu/v50HUCAQCx1tbW0uAx4CHgSwggxkKERkziUQif2mQ0WjU53a7vwSeBB4BTEDmTICmBBwYGDivVlDjlFAo9KvT6dwIPAHkANkq6MwDXr169bCISENDg9TX14s+BgcHf2hubi5mBmRPCXj06NFPREQ6OjoEkPLycrl06VIMMhKJeFwu1xdMs+wpAYuLi9eIiIyOjkpeXp4AAsj27dvF7/fHQIPB4C9dXV0fME2ypwQEXvX7/bdFRNauXRsDBMRkMsnhw4cTZB8YGGhsamp6hSmW3Qhw1Y0bN86LiNTW1iYAallWViZtbW162ftcLtdO/i/7tAAWtba2ficicvLkyTEBtdy6dasMDg7GQIeHh9s7OzvfBx5nkrIbAS7du3fvxyIiPT09hoBa1tXVJcv+fWNj4zLgUeAhJiC7EeDLwOsiMioisnDhwnFBrlixQi5evKiX/c6tW7c+R5E9lweU3QjwReDV/v7+bhGRqqqqcQFquWnTJvH5fHrZLzocjkoSZU9bTSPA54GV165daxYROXDgwAMBannw4MFk2RsaGhqWME7ZjQDNwIrTp09/JSLS0tIyIUBACgoK5MKFCzHIcDj85+3btz8FZpFGdiPAZ4DCmpqaTSIiPp9vwoBaVlVVidfr1ct+/sqVK+9iILsR4FzgJcASDoeHRUSKioomDQnI/v37E2T3+Xz1hw4dWjSW7EaAeUA+UNbX12cXEdmyZcuUAAJiNpvlzJkzetl73G53rVrN2EmUCjATuA9EgYjL5eoGKCkpGatNHijmz5/Pxo0b2blzJ2azOfZ3k8lUYDabv45Go/Y7d+6sIY0VZQOjGqDT6bxeWlrKqlWrJgRlsVhYv349FRUVWCwWcnJyEt4PBoOuoaEhu9frvdzR0fHTtm3buolvRpLqe3OBp4EllZWV74mIRKNRyc3NTSvf7Nmzpbq6Wk6cOCFut1uSY2RkJOB0Ou3Nzc3Ha2trPwPWAGXAEuBZFFPPAbKMevBhYA6wCKgIBoP9IiKrV682hLPZbP8DEpH7vb29N1paWn602WwHFyxYsAX4EKgE3gIsQBFQgOIeT6j3z0wFqEkc60OPx9Odn58/t6SkhPb29jFLbrVa2bNnDwBer7fv5s2bPQ6Ho7upqcnZ1tbmASJq3gPC6utdYESXYfWeo6mkBaUHRQ/odrv/yM/Pt5SWlqb8kAbncDh+W7lyZYN683u6DOvAwipsOOnniA4wZf9lqhdoVYzY7fbrQMpBsdlsWK1WRkZGAtXV1d8D/wA+wKNLr5o+YEC9ZggIAEHiFbyfDhCUCcoFngIWFxYWrtMaat68eQl9V15eHmu2+vr6OuAd4A2gGFgMLERp/mdQ+noWyuadi9Jr2aQ4k42GBPXDs1Ga97WhoaFbIiIbNmxIANTWq87Ozp9VuApgGfACihPkoRjwI+p3mlSgtA9ZRkYNYwwKJBr2rl27sFqthEKhwZqamqOAX5f/AsPE5btLvM/GJWO6yFb/82eBonPnztWJiJw9e1YAWb58eUzaI0eOfAO8CbwCPIfiZZN+eEoncSaKLPOApbt3794uIuL1ehOktdvtF4C3gRKURXcOSn9lTRRsvIAZKI4+l/gjQFREZMeOHSIiEggE+tetW/cRitkuRhmERxnnxjxZQFDWnzzURwCv1+vUHxHHjh37lri0C1Am9KGpgDMC1G8SQnxxCHs8Hqf2RldX10+bN28+i+JjwyT62KSaP13oAfWTHO7t7f0dIBQK/b1v375GlEnVjPYuyoQaHlNTDahVMALca29vdwBcvnz5+KlTp26OATft1UuODBS7yEOxj0K/329HOSWWopjxlE1tchhtM7FriPfgXSDDbrfXo0gbJr4QzIi0WiRPYBbKZJrUV23b0dYn7XSYcsBkS9EiO/k6lApq1cwiPjzaAM1Y9cYC1G6uAWrPCtrvMwoHqU02Q5caIEzj1KaS+D+vIjxtLug31gAAAABJRU5ErkJggg==";
|
|
3184
3694
|
const CURSOR_RESIZE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjMtMDktMTdUMTY6MzE6MjMrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDIzLTA5LTE3VDE2OjQ0OjIyKzA4OjAwIiB4bXA6TWV0YWRhdGFEYXRlPSIyMDIzLTA5LTE3VDE2OjQ0OjIyKzA4OjAwIiBkYzpmb3JtYXQ9ImltYWdlL3BuZyIgcGhvdG9zaG9wOkNvbG9yTW9kZT0iMyIgcGhvdG9zaG9wOklDQ1Byb2ZpbGU9InNSR0IgSUVDNjE5NjYtMi4xIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjY0MTBhYjUzLWM0ZjEtNDVhNS04MjhkLTIxOTczOWFjOTk3MSIgeG1wTU06RG9jdW1lbnRJRD0iYWRvYmU6ZG9jaWQ6cGhvdG9zaG9wOjBkMDNmNjM5LTE5MzctY2Y0MC1hMTg0LTIyMjg0NzczNWNmYSIgeG1wTU06T3JpZ2luYWxEb2N1bWVudElEPSJ4bXAuZGlkOjgyYjQwZGRmLWE0ZGEtNDY3MC1iYzc2LTBhYjY3ZmI5M2I0ZSI+IDx4bXBNTTpIaXN0b3J5PiA8cmRmOlNlcT4gPHJkZjpsaSBzdEV2dDphY3Rpb249ImNyZWF0ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6ODJiNDBkZGYtYTRkYS00NjcwLWJjNzYtMGFiNjdmYjkzYjRlIiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjMxOjIzKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIvPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0ic2F2ZWQiIHN0RXZ0Omluc3RhbmNlSUQ9InhtcC5paWQ6NjQxMGFiNTMtYzRmMS00NWE1LTgyOGQtMjE5NzM5YWM5OTcxIiBzdEV2dDp3aGVuPSIyMDIzLTA5LTE3VDE2OjQ0OjIyKzA4OjAwIiBzdEV2dDpzb2Z0d2FyZUFnZW50PSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgc3RFdnQ6Y2hhbmdlZD0iLyIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz57vRudAAAEk0lEQVRYhe3ZW0jbVxzA8e8/MX+NYnG9uI4xE3bvoLt0FzradRfGBtsYo32YdAhb6WQyBqV7KOylpYjzZShDGfjmyxgbgjjwyRm16SYMhgiNKDhbL3VtNF4xJOnf3x7+59i/Wf4aTbInf3AwJMdzPjnnf/n9/jFEhGzDMIxMb3uAIsDs6ek5urS05Dtz5syE+uwekAQS6u89YD19gC0NIpJ1c8GZQHlXV9fJRCIxGo/HxxoaGj4CngWOAEGgEihXfT07MeQC3MB1dna+lkgkRkXF6urq3xcuXPgUOAE8DzwGPOiGLARwEy4ej4+JiITD4elr167NiIgsLi7eqq2trQPeBI4Bj7sh8w10xZmmeds0zdn+/v5/RERisdjUuXPnvgLeAl50Q+YTaAA+oKy7u/uE3laNAwSQ4uLiu6FQ6G4G5DG13YeAMjWWkU+gBygJhULHNe769etTTpwDGXUiz58//yXwujp5qoAHgBLAk0+gNxKJHEulUiMKN2ma5gwgPp/vjhOXjlxYWJisq6urBV5RW30IKAW8eQPGYrGjlmXdEBEZHBy8aZrmFCCmac729fVtAHt7e6MO5N2+vr47IiJLS0s3L126dBZ4Sh2LZUBRwVdwYGBgVuwOYh/zsoF0bnPBVzDTMRgOh6dFhROokSIi8/Pz0+pEeaPQx+DGWdzV1XVSX2LcgCIic3NzMzU1NV8D7wIvq9WrLNRZvOk62NHRccqJTAdGo9Hb1dXV3wAfYt9VjgAPFfI66EQWAxU9PT0fuwEvXrzYBJwF3gFeAAJAhfrfrO4k/7lxZxnr2JlJqry8POnWyePx6H4JR0vhktVkHGOXQI20SkpKLLcOhmGsA5YCaZiVLS5XoADi9XpdkznDMERhnE0fCgUHZhvOW+CO4/8A5hR7wFxjD5hr7AFzjZyBlmVlrOYdYaS1HUUuQA/gWV9fd51URDyqn1c1j6MVFGjoidfW1oq2ABrYj0V82OmVzwHNajVdB88C5wOKTdM87NaxsrKyQsFKHC2BnTDo+/TWt8Bd5INeVC44NDT0xXYZdXNz8w/AaeyS8yjwCPdzQu92ht2m/OUjIyOfS1pkAoqItLS0fA+8D7wKPA0cxs6qC1O4T0xMfKYnb21tnXEDNjc3z+nXbW1t3wFvYz9dCAL7KUThHovFPtGTNjU1jQFSX18/lg68cuXKLUAaGxs3vkB7e/u3wHHgCQpUdnpTqdQvesJgMDisUVevXh3Xry9fvnxTv66qqprQ/cfHx/vVNj/J/couv0DAv7q6+pMDeYPNSalkwkUikX7s4ukl4FHgAODPN1CXnPsWFxd/dCAjW+GGhoZCwAfYpeczwMPAPjVW3gv3IvXN98disZ8dyBGNCwQC4/r94eHhfuy6+JS6zATUCeJXY+W9cNfIUuDAwsLCr05kIBDYeBQ8Ojr6h8Lpx25BtbWlGpfv62BG5PLy8m+SFpOTk38C76mVe84NVyhgOvLgysrK7xoXjUb/Uqt2XG1rEDiYCbcd0MgwsWtk+J1EI03An0wmw5Zlefx+/2n1eRKIO5r+rWTTpFsZ/gWFrGMmeObuqwAAAABJRU5ErkJggg==";
|
|
3695
|
+
const CURSOR_DRAG_DEFAULT = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAEvUlEQVRYhc2Y20/cVRDHP8v+uKzAWkpDCtZq8BYhJkq8PBoJxgj7I2m0ryaSyFN9IT74pI8+8WJiggRj/APApFkSTGRJ+qKGUiyxbGPEWsUSuVhYC12Wy8+HmeMeYPe3d3WSye/k/M7le+bMzJkZ+J9ToEJreGVYN+vihcytstjQocUlAw0WCSoIVCv3Ae8CXwIt+u8XHVeOG8qLqgAHqAFCQCNwGugCthBJGd7S/tM6LqTzHI5KuqzgaoAHgEvAtwrkG2AG8FzXvep5nue67lX9N6P/PR1/SefXlBtkFXKNDUA/RyX1D9uUbYzOb9D1ygbSQU7eDMxhSSsSiVz3AxiJRK57nuf19/fPad8coqONFCBJPyUOIKc1OvcbgiY9ICDT8+0DHge2gR0gBeyTtviM5HeKAGlrrfMZVwhdAVaAr4F3KNF4gkA9cBbowOc68+3LwDn1Mhdy4/OcYk54nPr6+m54nofruvPa9SFQ6wfQTweNgTwInAGuQWk6mEUvHwb+Au4Dexx7ffK9+0q+CHWIBIOZ9skHYKWfK9tQ8gZoLDjIyWCg3ORY+2T8aYOyg4EaRIFrkCs4QU1NTSvabC20zyIDzuyfkYzEahHX8jHwE/LwXwHeJ4P7KIVIu5ouxFDC+HgLAy4MfEF2v1UpgOezATSiNVf6EvAWsD01NXVtdnb2bk9Pz81sp/q3KIi8t83Ae4DX0tJy0z7t8PDwD4FAYIX/WILVwKMAzc3Nu/agoaGhzmg0ugcsV0hIvlSNoH8IuIiebHJycrls4sotwaxGYvueAPAjEg3jum79yMjIr5WUjFLOxMpBIopWoBN4GfhOJ+4NDg4ulVt6i4uLm7r+BvAscA4fCXrAAfJQJ5Fg8gPgMuCMjo62d3V1LW1sbKRKlpXSxMTEmjZ/5qQrOwHwUAGmkIjiHhJdfKrM/Pz8Y+3t7RvT09Ob5QAYi8X2tbmke2cEZwAaCdoAt5QvIzEbiUSitbe3tyoej++UCnBhYSGkzdu6d1aQxkgOkfwgieQMCeCu8iwSnpNKpcIdHR3BZDJ5UCy4SCSyvL6+/giiSou67wE+eYmhAKKkIaAJUdynkdflNcQF3dFTpooxjmg0aozDAz4DXkB8bxPy1OYM7QzIOuAU0AY8pQu9CrwJ3AK8UCj0RyHgZmZmli1w3wOvAM/oHo1kiZiygbSDh7PAE8DzQA/wBqKnnuM4a2NjY7dygbtw4cICRy31deBFJA09o7eWsU7kJ1KTLJmyRyOSn5zS70fAkwBtbW2/DwwMHHR3d9d3dnY2rK6u7o2Pj2/GYrH9eDzurK2tndM1vwI+QXT7T2BTD5skQz6SCyAcLRoZkGEFGQbeRqpbubK+BPA5MI14h00L3I6Cy2h4+eQbJsKuRa6iQcGFFfB5oBt4DpFsI+Ky7iDBxW3gBhBH/GtC+R7i1lKk3UxRAG2QpvxWr0AbtB3SA5jkx36djH/dVlDbyibN3M8GDvJPyI2PSulixm/u6kZ1OQCaJ/S+tndJX6tvsFBIxcCUdA3vW5ubxMrObc0hDMhd/Rqp5QQHxeW8dubnHGM7tzVv/IECMlxQ/bpcRfRMqaNRheNcUGG9XFWDACfzWs/6Fl3t/xtO//8gpbCORQAAAABJRU5ErkJggg==`;
|
|
3696
|
+
const CURSOR_DRAG_ACTIVE = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAER0lEQVRYhe2YT2hjRRjAf8lL22xsNsm6EWKrSKvuIkIh+O9QRFxEW18KUsoe7FHoRaWCN1FPetOrIHgVKS0q9P5OxaJbodkalgVrtVZjS7Ntd02z6abPw3yzmaT585q+elj2g2HmvZn35jffN/PNNwP35R6XgM/fuif4n+dO2klQvgsaZRc4NJJvoJbHdhrIAkJAN2ADHwFfAw9J3ZoB/b9I0AA6A0SBc0Aa2EVpSqddeZ+QdmfkO+u0gIPSQQR4HfhRQH4AHMDNZDJXXNd1M5nMFalzdB3wJTAOPAD0yEB9066G6wXepVZTd5MpTdporZ6jVqsatmMJoTR3HvgJQ1u2bS+3ArRte9l1XXdsbGyJo1pdBN6Wf3d3ChlAmSQO9LeC8fquQRpDWaerHWSjSr1iu4BkJyOsF9u2s67rkslkluTVxygltAVsJBZqdCngEj5osIlW+4EYytRNF04jeu3vulCT+7QkLH20dEOhumft97pQI4s3+iiRSPwtxVSbd39J8eEGvzFXc1NAs8KSFAZeBt4AHgNeBFDWObkEAne7HAK2gT2gCFQatdca1GbtBj4E3veFprVYVLXXcg4GqM6588BbAMlkcm1qamqzr6/v6ikBet5RgiizJoDPAXdgYGDZXHkzMzPrrk9CdRWngUeAsxxdCzVwpgZ/BigWiz1mo4mJif7jqMajeJrU5hywgGvAej6fvzA0NLThN1Eul9uT4g5VTbYFNKUIfAbsZ7PZvuHh4Wt+As7Ozu5IcY2j219TQB0NV4A7qODgO4CFhYWLg4ODOb8AHccpG4A68m6pRQ1YAQ6A28A+8BXwBcDq6upTqVTquh+AuVyuW4q/opRRaQdZD1gCbgE3ge+BT4HdfD7/ZDwe/z2bzRY6hRsfH1/e3Nx8FDX/sgbgoZfvg6jo4ixqW7oIPA+8CrwHrAJuJBLJd+JaHMf5k6qmPgGeQe1SCenXk0/U21xcIC8AzwGvAJPAEuAmEon1xcXFba9w8/Pz5oqdB14CnpY+oij35km0qwmjwqAU8ISM9hIwBeQA17KsG9PT07+1gxsZGdmgdqW+BjwLDAAPoo4ALU+W9arVwWoIpXp9kouKZpPAO8AwQCwW+2d0dLQ0OTkZSafT0UKhUJ6bm9t2HKeysrIS3tra0g7+KvABUJC0g5rrJdRcbLpImtleRzYashc1P2OSXwbebDVykX3gW+Ab1AHqhuQ3pe6AJlFMO0CoPROHDcio5I8DL1A9C8dQbmod+APYAK4DvwjQnsDdErgyVTfTEaCG1GFYGHXG7TVSo2OkdvhlAflXoHSuNdfStFqaRhEi2kfdprrj6M5LAt0I8EDaaMdflPal48CB95hMr3Bt8h4jD0kyL5E0pN6dysZzW7N2AqjbmhdIZjJvufTOpE19x3g+9s1XJ/ck5tVbfdhu+rxDfLiSO+lFToCjZwrXyH2/0Lwv95z8B1jAqXmDnj4YAAAAAElFTkSuQmCC`;
|
|
3185
3697
|
class Cursor {
|
|
3186
3698
|
constructor(container, opts) {
|
|
3187
|
-
this
|
|
3188
|
-
this
|
|
3189
|
-
this
|
|
3699
|
+
__privateAdd(this, _init);
|
|
3700
|
+
__privateAdd(this, _loadResizeCursorBaseImage);
|
|
3701
|
+
__privateAdd(this, _resetCursor);
|
|
3702
|
+
__privateAdd(this, _setCursorResize);
|
|
3703
|
+
__privateAdd(this, _appendRotateResizeImage);
|
|
3704
|
+
__privateAdd(this, _eventHub, void 0);
|
|
3705
|
+
__privateAdd(this, _container, void 0);
|
|
3706
|
+
__privateAdd(this, _cursorType, null);
|
|
3707
|
+
__privateAdd(this, _resizeCursorBaseImage, null);
|
|
3708
|
+
__privateAdd(this, _cursorImageMap, {
|
|
3190
3709
|
auto: CURSOR,
|
|
3710
|
+
"drag-default": CURSOR_DRAG_DEFAULT,
|
|
3711
|
+
"drag-active": CURSOR_DRAG_ACTIVE,
|
|
3191
3712
|
"rotate-0": CURSOR_RESIZE
|
|
3192
|
-
};
|
|
3193
|
-
this._container = container;
|
|
3194
|
-
this._eventHub = opts.eventHub;
|
|
3195
|
-
this._init();
|
|
3196
|
-
this._loadResizeCursorBaseImage();
|
|
3197
|
-
}
|
|
3198
|
-
_init() {
|
|
3199
|
-
const { _eventHub: eventHub } = this;
|
|
3200
|
-
this._resetCursor("auto");
|
|
3201
|
-
eventHub.on("cursor", (e) => {
|
|
3202
|
-
var _a;
|
|
3203
|
-
if (e.type === "over-element" || !e.type) {
|
|
3204
|
-
this._resetCursor("auto");
|
|
3205
|
-
} else if (typeof e.type === "string" && ((_a = e.type) == null ? void 0 : _a.startsWith("resize-"))) {
|
|
3206
|
-
this._setCursorResize(e);
|
|
3207
|
-
} else {
|
|
3208
|
-
this._resetCursor("auto");
|
|
3209
|
-
}
|
|
3210
|
-
});
|
|
3211
|
-
}
|
|
3212
|
-
_loadResizeCursorBaseImage() {
|
|
3213
|
-
loadImage(CURSOR_RESIZE).then((img) => {
|
|
3214
|
-
this._resizeCursorBaseImage = img;
|
|
3215
|
-
}).catch((err) => {
|
|
3216
|
-
console.error(err);
|
|
3217
3713
|
});
|
|
3714
|
+
__privateSet(this, _container, container);
|
|
3715
|
+
__privateSet(this, _eventHub, opts.eventHub);
|
|
3716
|
+
__privateMethod(this, _init, init_fn).call(this);
|
|
3717
|
+
__privateMethod(this, _loadResizeCursorBaseImage, loadResizeCursorBaseImage_fn).call(this);
|
|
3218
3718
|
}
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
}
|
|
3231
|
-
this._container.style.cursor = `image-set(url(${image})2x) ${offsetX} ${offsetY}, auto`;
|
|
3232
|
-
}
|
|
3233
|
-
_setCursorResize(e) {
|
|
3719
|
+
}
|
|
3720
|
+
_eventHub = new WeakMap();
|
|
3721
|
+
_container = new WeakMap();
|
|
3722
|
+
_cursorType = new WeakMap();
|
|
3723
|
+
_resizeCursorBaseImage = new WeakMap();
|
|
3724
|
+
_cursorImageMap = new WeakMap();
|
|
3725
|
+
_init = new WeakSet();
|
|
3726
|
+
init_fn = function() {
|
|
3727
|
+
const eventHub = __privateGet(this, _eventHub);
|
|
3728
|
+
__privateMethod(this, _resetCursor, resetCursor_fn).call(this, "default");
|
|
3729
|
+
eventHub.on("cursor", (e) => {
|
|
3234
3730
|
var _a;
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
totalAngle += 180;
|
|
3246
|
-
} else if (e.type === "resize-bottom-left") {
|
|
3247
|
-
totalAngle += 225;
|
|
3248
|
-
} else if (e.type === "resize-left") {
|
|
3249
|
-
totalAngle += 270;
|
|
3250
|
-
} else if (e.type === "resize-top-left") {
|
|
3251
|
-
totalAngle += 315;
|
|
3252
|
-
}
|
|
3253
|
-
totalAngle += limitAngle(((_a = e == null ? void 0 : e.element) == null ? void 0 : _a.angle) || 0);
|
|
3254
|
-
if (Array.isArray(e.groupQueue) && e.groupQueue.length > 0) {
|
|
3255
|
-
e.groupQueue.forEach((group) => {
|
|
3256
|
-
totalAngle += limitAngle(group.angle || 0);
|
|
3257
|
-
});
|
|
3258
|
-
}
|
|
3259
|
-
totalAngle = limitAngle(totalAngle);
|
|
3260
|
-
const cursorKey = this._appendRotateResizeImage(totalAngle);
|
|
3261
|
-
this._resetCursor(cursorKey);
|
|
3262
|
-
}
|
|
3263
|
-
_appendRotateResizeImage(angle2) {
|
|
3264
|
-
const key2 = `rotate-${angle2}`;
|
|
3265
|
-
if (!this._cursorImageMap[key2]) {
|
|
3266
|
-
const baseImage = this._resizeCursorBaseImage;
|
|
3267
|
-
if (baseImage) {
|
|
3268
|
-
const canvas = document.createElement("canvas");
|
|
3269
|
-
const w2 = baseImage.width;
|
|
3270
|
-
const h2 = baseImage.height;
|
|
3271
|
-
const center = {
|
|
3272
|
-
x: w2 / 2,
|
|
3273
|
-
y: h2 / 2
|
|
3274
|
-
};
|
|
3275
|
-
canvas.width = w2;
|
|
3276
|
-
canvas.height = h2;
|
|
3277
|
-
const ctx = canvas.getContext("2d");
|
|
3278
|
-
const radian = parseAngleToRadian(angle2);
|
|
3279
|
-
ctx.translate(center.x, center.y);
|
|
3280
|
-
ctx.rotate(radian);
|
|
3281
|
-
ctx.translate(-center.x, -center.y);
|
|
3282
|
-
ctx.drawImage(baseImage, 0, 0, w2, h2);
|
|
3283
|
-
ctx.translate(center.x, center.y);
|
|
3284
|
-
ctx.rotate(-radian);
|
|
3285
|
-
ctx.translate(-center.x, -center.y);
|
|
3286
|
-
const base = canvas.toDataURL("image/png");
|
|
3287
|
-
this._cursorImageMap[key2] = base;
|
|
3288
|
-
}
|
|
3731
|
+
if (e.type === "over-element" || !e.type) {
|
|
3732
|
+
__privateMethod(this, _resetCursor, resetCursor_fn).call(this, "auto");
|
|
3733
|
+
} else if (typeof e.type === "string" && ((_a = e.type) == null ? void 0 : _a.startsWith("resize-"))) {
|
|
3734
|
+
__privateMethod(this, _setCursorResize, setCursorResize_fn).call(this, e);
|
|
3735
|
+
} else if (e.type === "drag-default") {
|
|
3736
|
+
__privateMethod(this, _resetCursor, resetCursor_fn).call(this, "drag-default");
|
|
3737
|
+
} else if (e.type === "drag-active") {
|
|
3738
|
+
__privateMethod(this, _resetCursor, resetCursor_fn).call(this, "drag-active");
|
|
3739
|
+
} else {
|
|
3740
|
+
__privateMethod(this, _resetCursor, resetCursor_fn).call(this, "auto");
|
|
3289
3741
|
}
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3742
|
+
});
|
|
3743
|
+
};
|
|
3744
|
+
_loadResizeCursorBaseImage = new WeakSet();
|
|
3745
|
+
loadResizeCursorBaseImage_fn = function() {
|
|
3746
|
+
loadImage(CURSOR_RESIZE).then((img) => {
|
|
3747
|
+
__privateSet(this, _resizeCursorBaseImage, img);
|
|
3748
|
+
}).catch((err) => {
|
|
3749
|
+
console.error(err);
|
|
3750
|
+
});
|
|
3751
|
+
};
|
|
3752
|
+
_resetCursor = new WeakSet();
|
|
3753
|
+
resetCursor_fn = function(cursorKey) {
|
|
3754
|
+
if (__privateGet(this, _cursorType) === cursorKey) {
|
|
3755
|
+
return;
|
|
3756
|
+
}
|
|
3757
|
+
__privateSet(this, _cursorType, cursorKey);
|
|
3758
|
+
const image = __privateGet(this, _cursorImageMap)[__privateGet(this, _cursorType)] || __privateGet(this, _cursorImageMap)["auto"];
|
|
3759
|
+
let offsetX = 0;
|
|
3760
|
+
let offsetY = 0;
|
|
3761
|
+
if (cursorKey.startsWith("rotate-") && __privateGet(this, _cursorImageMap)[__privateGet(this, _cursorType)]) {
|
|
3762
|
+
offsetX = 10;
|
|
3763
|
+
offsetY = 10;
|
|
3764
|
+
}
|
|
3765
|
+
if (cursorKey === "default") {
|
|
3766
|
+
__privateGet(this, _container).style.cursor = "default";
|
|
3767
|
+
} else {
|
|
3768
|
+
__privateGet(this, _container).style.cursor = `image-set(url(${image})2x) ${offsetX} ${offsetY}, auto`;
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
_setCursorResize = new WeakSet();
|
|
3772
|
+
setCursorResize_fn = function(e) {
|
|
3773
|
+
var _a;
|
|
3774
|
+
let totalAngle = 0;
|
|
3775
|
+
if (e.type === "resize-top") {
|
|
3776
|
+
totalAngle += 0;
|
|
3777
|
+
} else if (e.type === "resize-top-right") {
|
|
3778
|
+
totalAngle += 45;
|
|
3779
|
+
} else if (e.type === "resize-right") {
|
|
3780
|
+
totalAngle += 90;
|
|
3781
|
+
} else if (e.type === "resize-bottom-right") {
|
|
3782
|
+
totalAngle += 135;
|
|
3783
|
+
} else if (e.type === "resize-bottom") {
|
|
3784
|
+
totalAngle += 180;
|
|
3785
|
+
} else if (e.type === "resize-bottom-left") {
|
|
3786
|
+
totalAngle += 225;
|
|
3787
|
+
} else if (e.type === "resize-left") {
|
|
3788
|
+
totalAngle += 270;
|
|
3789
|
+
} else if (e.type === "resize-top-left") {
|
|
3790
|
+
totalAngle += 315;
|
|
3791
|
+
}
|
|
3792
|
+
totalAngle += limitAngle(((_a = e == null ? void 0 : e.element) == null ? void 0 : _a.angle) || 0);
|
|
3793
|
+
if (Array.isArray(e.groupQueue) && e.groupQueue.length > 0) {
|
|
3794
|
+
e.groupQueue.forEach((group) => {
|
|
3795
|
+
totalAngle += limitAngle(group.angle || 0);
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
totalAngle = limitAngle(totalAngle);
|
|
3799
|
+
const cursorKey = __privateMethod(this, _appendRotateResizeImage, appendRotateResizeImage_fn).call(this, totalAngle);
|
|
3800
|
+
__privateMethod(this, _resetCursor, resetCursor_fn).call(this, cursorKey);
|
|
3801
|
+
};
|
|
3802
|
+
_appendRotateResizeImage = new WeakSet();
|
|
3803
|
+
appendRotateResizeImage_fn = function(angle2) {
|
|
3804
|
+
const key2 = `rotate-${angle2}`;
|
|
3805
|
+
if (!__privateGet(this, _cursorImageMap)[key2]) {
|
|
3806
|
+
const baseImage = __privateGet(this, _resizeCursorBaseImage);
|
|
3807
|
+
if (baseImage) {
|
|
3808
|
+
const canvas = document.createElement("canvas");
|
|
3809
|
+
const w2 = baseImage.width;
|
|
3810
|
+
const h2 = baseImage.height;
|
|
3811
|
+
const center = {
|
|
3812
|
+
x: w2 / 2,
|
|
3813
|
+
y: h2 / 2
|
|
3814
|
+
};
|
|
3815
|
+
canvas.width = w2;
|
|
3816
|
+
canvas.height = h2;
|
|
3817
|
+
const ctx = canvas.getContext("2d");
|
|
3818
|
+
const radian = parseAngleToRadian(angle2);
|
|
3819
|
+
ctx.translate(center.x, center.y);
|
|
3820
|
+
ctx.rotate(radian);
|
|
3821
|
+
ctx.translate(-center.x, -center.y);
|
|
3822
|
+
ctx.drawImage(baseImage, 0, 0, w2, h2);
|
|
3823
|
+
ctx.translate(center.x, center.y);
|
|
3824
|
+
ctx.rotate(-radian);
|
|
3825
|
+
ctx.translate(-center.x, -center.y);
|
|
3826
|
+
const base = canvas.toDataURL("image/png");
|
|
3827
|
+
__privateGet(this, _cursorImageMap)[key2] = base;
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
return key2;
|
|
3831
|
+
};
|
|
3832
|
+
const key$2 = "SELECT";
|
|
3833
|
+
const keyActionType = Symbol(`${key$2}_actionType`);
|
|
3834
|
+
const keyResizeType = Symbol(`${key$2}_resizeType`);
|
|
3835
|
+
const keyAreaStart = Symbol(`${key$2}_areaStart`);
|
|
3836
|
+
const keyAreaEnd = Symbol(`${key$2}_areaEnd`);
|
|
3837
|
+
const keyHoverElement = Symbol(`${key$2}_hoverElement`);
|
|
3838
|
+
const keyHoverElementVertexes = Symbol(`${key$2}_hoverElementVertexes`);
|
|
3839
|
+
const keySelectedElementList = Symbol(`${key$2}_selectedElementList`);
|
|
3840
|
+
const keySelectedElementListVertexes = Symbol(`${key$2}_selectedElementListVertexes`);
|
|
3841
|
+
const keySelectedElementController = Symbol(`${key$2}_selectedElementController`);
|
|
3842
|
+
const keyGroupQueue = Symbol(`${key$2}_groupQueue`);
|
|
3843
|
+
const keyGroupQueueVertexesList = Symbol(`${key$2}_groupQueueVertexesList`);
|
|
3305
3844
|
const selectWrapperBorderWidth = 2;
|
|
3306
3845
|
const resizeControllerBorderWidth = 4;
|
|
3307
3846
|
const areaBorderWidth = 1;
|
|
3308
3847
|
const wrapperColor = "#1973ba";
|
|
3848
|
+
const lockColor = "#5b5959b5";
|
|
3309
3849
|
function drawVertexes(ctx, vertexes, opts) {
|
|
3310
3850
|
const { borderColor: borderColor2, borderWidth: borderWidth2, background: background2, lineDash } = opts;
|
|
3311
3851
|
ctx.setLineDash([]);
|
|
@@ -3330,6 +3870,44 @@ var __privateMethod = (obj, member, method) => {
|
|
|
3330
3870
|
const wrapperOpts = { borderColor: wrapperColor, borderWidth: 1, background: "transparent", lineDash: [] };
|
|
3331
3871
|
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
3332
3872
|
}
|
|
3873
|
+
function drawCrossVertexes(ctx, vertexes, opts) {
|
|
3874
|
+
const { borderColor: borderColor2, borderWidth: borderWidth2, background: background2, lineDash } = opts;
|
|
3875
|
+
ctx.setLineDash([]);
|
|
3876
|
+
ctx.lineWidth = borderWidth2;
|
|
3877
|
+
ctx.strokeStyle = borderColor2;
|
|
3878
|
+
ctx.fillStyle = background2;
|
|
3879
|
+
ctx.setLineDash(lineDash);
|
|
3880
|
+
ctx.beginPath();
|
|
3881
|
+
ctx.moveTo(vertexes[0].x, vertexes[0].y);
|
|
3882
|
+
ctx.lineTo(vertexes[2].x, vertexes[2].y);
|
|
3883
|
+
ctx.closePath();
|
|
3884
|
+
ctx.stroke();
|
|
3885
|
+
ctx.beginPath();
|
|
3886
|
+
ctx.moveTo(vertexes[1].x, vertexes[1].y);
|
|
3887
|
+
ctx.lineTo(vertexes[3].x, vertexes[3].y);
|
|
3888
|
+
ctx.closePath();
|
|
3889
|
+
ctx.stroke();
|
|
3890
|
+
}
|
|
3891
|
+
function drawLockVertexesWrapper(ctx, vertexes, opts) {
|
|
3892
|
+
if (!vertexes) {
|
|
3893
|
+
return;
|
|
3894
|
+
}
|
|
3895
|
+
const wrapperOpts = { borderColor: lockColor, borderWidth: 1, background: "transparent", lineDash: [] };
|
|
3896
|
+
drawVertexes(ctx, calcViewVertexes(vertexes, opts), wrapperOpts);
|
|
3897
|
+
const { controller } = opts;
|
|
3898
|
+
if (controller) {
|
|
3899
|
+
const { topLeft, topRight, bottomLeft, bottomRight, topMiddle, bottomMiddle, leftMiddle, rightMiddle } = controller;
|
|
3900
|
+
const ctrlOpts = { ...wrapperOpts, borderWidth: 1, background: lockColor };
|
|
3901
|
+
drawCrossVertexes(ctx, calcViewVertexes(topMiddle.vertexes, opts), ctrlOpts);
|
|
3902
|
+
drawCrossVertexes(ctx, calcViewVertexes(bottomMiddle.vertexes, opts), ctrlOpts);
|
|
3903
|
+
drawCrossVertexes(ctx, calcViewVertexes(leftMiddle.vertexes, opts), ctrlOpts);
|
|
3904
|
+
drawCrossVertexes(ctx, calcViewVertexes(rightMiddle.vertexes, opts), ctrlOpts);
|
|
3905
|
+
drawCrossVertexes(ctx, calcViewVertexes(topLeft.vertexes, opts), ctrlOpts);
|
|
3906
|
+
drawCrossVertexes(ctx, calcViewVertexes(topRight.vertexes, opts), ctrlOpts);
|
|
3907
|
+
drawCrossVertexes(ctx, calcViewVertexes(bottomLeft.vertexes, opts), ctrlOpts);
|
|
3908
|
+
drawCrossVertexes(ctx, calcViewVertexes(bottomRight.vertexes, opts), ctrlOpts);
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3333
3911
|
function drawSelectedElementControllersVertexes(ctx, controller, opts) {
|
|
3334
3912
|
if (!controller) {
|
|
3335
3913
|
return;
|
|
@@ -4013,6 +4591,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4013
4591
|
return { x: x2, y: y2, w: w2, h: h2, angle: elem.angle };
|
|
4014
4592
|
}
|
|
4015
4593
|
function getSelectedListArea(data, opts) {
|
|
4594
|
+
var _a;
|
|
4016
4595
|
const indexes = [];
|
|
4017
4596
|
const uuids = [];
|
|
4018
4597
|
const elements = [];
|
|
@@ -4024,7 +4603,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4024
4603
|
const endX = Math.max(start.x, end.x);
|
|
4025
4604
|
const startY = Math.min(start.y, end.y);
|
|
4026
4605
|
const endY = Math.max(start.y, end.y);
|
|
4027
|
-
data.elements.
|
|
4606
|
+
for (let idx = 0; idx < data.elements.length; idx++) {
|
|
4607
|
+
const elem = data.elements[idx];
|
|
4608
|
+
if (((_a = elem == null ? void 0 : elem.operations) == null ? void 0 : _a.lock) === true) {
|
|
4609
|
+
continue;
|
|
4610
|
+
}
|
|
4028
4611
|
const elemSize = calculator.elementSize(elem, viewScaleInfo, viewSizeInfo);
|
|
4029
4612
|
const center = calcElementCenter(elemSize);
|
|
4030
4613
|
if (center.x >= startX && center.x <= endX && center.y >= startY && center.y <= endY) {
|
|
@@ -4043,7 +4626,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4043
4626
|
}
|
|
4044
4627
|
}
|
|
4045
4628
|
}
|
|
4046
|
-
}
|
|
4629
|
+
}
|
|
4047
4630
|
return { indexes, uuids, elements };
|
|
4048
4631
|
}
|
|
4049
4632
|
function calcSelectedElementsArea(elements, opts) {
|
|
@@ -4130,9 +4713,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4130
4713
|
const middlewareEventTextEdit = "@middleware/text-edit";
|
|
4131
4714
|
const defaultElementDetail = getDefaultElementDetailConfig();
|
|
4132
4715
|
const MiddlewareTextEditor = (opts) => {
|
|
4133
|
-
const
|
|
4134
|
-
const
|
|
4135
|
-
const canvas = viewContent.boardContext.canvas;
|
|
4716
|
+
const { eventHub, boardContent, viewer } = opts;
|
|
4717
|
+
const canvas = boardContent.boardContext.canvas;
|
|
4136
4718
|
const textarea = document.createElement("textarea");
|
|
4137
4719
|
const canvasWrapper = document.createElement("div");
|
|
4138
4720
|
const container = opts.container || document.body;
|
|
@@ -4217,10 +4799,10 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4217
4799
|
elemH = element.h * scale;
|
|
4218
4800
|
}
|
|
4219
4801
|
textarea.style.position = "absolute";
|
|
4220
|
-
textarea.style.left = `${elemX}px`;
|
|
4221
|
-
textarea.style.top = `${elemY}px`;
|
|
4222
|
-
textarea.style.width = `${elemW}px`;
|
|
4223
|
-
textarea.style.height = `${elemH}px`;
|
|
4802
|
+
textarea.style.left = `${elemX - 1}px`;
|
|
4803
|
+
textarea.style.top = `${elemY - 1}px`;
|
|
4804
|
+
textarea.style.width = `${elemW + 2}px`;
|
|
4805
|
+
textarea.style.height = `${elemH + 2}px`;
|
|
4224
4806
|
textarea.style.transform = `rotate(${limitAngle(element.angle || 0)}deg)`;
|
|
4225
4807
|
textarea.style.boxSizing = "border-box";
|
|
4226
4808
|
textarea.style.border = "1px solid #1973ba";
|
|
@@ -4233,6 +4815,9 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4233
4815
|
textarea.style.lineHeight = `${detail.lineHeight * scale}px`;
|
|
4234
4816
|
textarea.style.fontFamily = detail.fontFamily;
|
|
4235
4817
|
textarea.style.fontWeight = `${detail.fontWeight}`;
|
|
4818
|
+
textarea.style.padding = "0";
|
|
4819
|
+
textarea.style.margin = "0";
|
|
4820
|
+
textarea.style.outline = "none";
|
|
4236
4821
|
textarea.value = detail.text || "";
|
|
4237
4822
|
parent.appendChild(textarea);
|
|
4238
4823
|
};
|
|
@@ -4260,48 +4845,30 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4260
4845
|
textarea.addEventListener("blur", () => {
|
|
4261
4846
|
hideTextArea();
|
|
4262
4847
|
});
|
|
4263
|
-
|
|
4848
|
+
const textEditCallback = (e) => {
|
|
4264
4849
|
var _a;
|
|
4265
4850
|
if ((e == null ? void 0 : e.element) && ((_a = e == null ? void 0 : e.element) == null ? void 0 : _a.type) === "text") {
|
|
4266
4851
|
activeElem = e.element;
|
|
4267
4852
|
}
|
|
4268
4853
|
showTextArea(e);
|
|
4269
|
-
}
|
|
4854
|
+
};
|
|
4270
4855
|
return {
|
|
4271
|
-
|
|
4272
|
-
|
|
4856
|
+
name: "@middleware/text-editor",
|
|
4857
|
+
use() {
|
|
4858
|
+
eventHub.on(middlewareEventTextEdit, textEditCallback);
|
|
4859
|
+
},
|
|
4860
|
+
disuse() {
|
|
4861
|
+
eventHub.off(middlewareEventTextEdit, textEditCallback);
|
|
4862
|
+
}
|
|
4273
4863
|
};
|
|
4274
4864
|
};
|
|
4275
4865
|
const middlewareEventSelect = "@middleware/select";
|
|
4866
|
+
const middlewareEventSelectClear = "@middleware/select-clear";
|
|
4276
4867
|
const MiddlewareSelector = (opts) => {
|
|
4277
|
-
const { viewer, sharer,
|
|
4278
|
-
const { helperContext } =
|
|
4868
|
+
const { viewer, sharer, boardContent, calculator, eventHub } = opts;
|
|
4869
|
+
const { helperContext } = boardContent;
|
|
4279
4870
|
let prevPoint = null;
|
|
4280
4871
|
let inBusyMode = null;
|
|
4281
|
-
eventHub.on(middlewareEventSelect, ({ uuids, positions }) => {
|
|
4282
|
-
let elements = [];
|
|
4283
|
-
const actionType = sharer.getSharedStorage(keyActionType);
|
|
4284
|
-
const data = sharer.getActiveStorage("data");
|
|
4285
|
-
if (positions && Array.isArray(positions)) {
|
|
4286
|
-
elements = findElementsFromListByPositions(positions, (data == null ? void 0 : data.elements) || []);
|
|
4287
|
-
} else {
|
|
4288
|
-
elements = findElementsFromList(uuids, (data == null ? void 0 : data.elements) || []);
|
|
4289
|
-
}
|
|
4290
|
-
let needRefresh = false;
|
|
4291
|
-
if (!actionType && elements.length === 1) {
|
|
4292
|
-
sharer.setSharedStorage(keyActionType, "select");
|
|
4293
|
-
needRefresh = true;
|
|
4294
|
-
} else if (actionType === "select" && elements.length === 1) {
|
|
4295
|
-
needRefresh = true;
|
|
4296
|
-
}
|
|
4297
|
-
if (needRefresh) {
|
|
4298
|
-
const elem = elements[0];
|
|
4299
|
-
const groupQueue = getGroupQueueFromList(elem.uuid, (data == null ? void 0 : data.elements) || []);
|
|
4300
|
-
sharer.setSharedStorage(keyGroupQueue, groupQueue);
|
|
4301
|
-
updateSelectedElementList(elements);
|
|
4302
|
-
viewer.drawFrame();
|
|
4303
|
-
}
|
|
4304
|
-
});
|
|
4305
4872
|
sharer.setSharedStorage(keyActionType, null);
|
|
4306
4873
|
const getActiveElements = () => {
|
|
4307
4874
|
return sharer.getSharedStorage(keySelectedElementList);
|
|
@@ -4378,15 +4945,51 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4378
4945
|
sharer.setSharedStorage(keySelectedElementController, null);
|
|
4379
4946
|
};
|
|
4380
4947
|
clear();
|
|
4948
|
+
const selectCallback = ({ uuids, positions }) => {
|
|
4949
|
+
let elements = [];
|
|
4950
|
+
const actionType = sharer.getSharedStorage(keyActionType);
|
|
4951
|
+
const data = sharer.getActiveStorage("data");
|
|
4952
|
+
if (positions && Array.isArray(positions)) {
|
|
4953
|
+
elements = findElementsFromListByPositions(positions, (data == null ? void 0 : data.elements) || []);
|
|
4954
|
+
} else {
|
|
4955
|
+
elements = findElementsFromList(uuids, (data == null ? void 0 : data.elements) || []);
|
|
4956
|
+
}
|
|
4957
|
+
let needRefresh = false;
|
|
4958
|
+
if (!actionType && elements.length === 1) {
|
|
4959
|
+
sharer.setSharedStorage(keyActionType, "select");
|
|
4960
|
+
needRefresh = true;
|
|
4961
|
+
} else if (actionType === "select" && elements.length === 1) {
|
|
4962
|
+
needRefresh = true;
|
|
4963
|
+
}
|
|
4964
|
+
if (needRefresh) {
|
|
4965
|
+
const elem = elements[0];
|
|
4966
|
+
const groupQueue = getGroupQueueFromList(elem.uuid, (data == null ? void 0 : data.elements) || []);
|
|
4967
|
+
sharer.setSharedStorage(keyGroupQueue, groupQueue);
|
|
4968
|
+
updateSelectedElementList(elements);
|
|
4969
|
+
viewer.drawFrame();
|
|
4970
|
+
}
|
|
4971
|
+
};
|
|
4972
|
+
const selectClearCallback = () => {
|
|
4973
|
+
clear();
|
|
4974
|
+
viewer.drawFrame();
|
|
4975
|
+
};
|
|
4381
4976
|
return {
|
|
4382
|
-
|
|
4977
|
+
name: "@middleware/selector",
|
|
4978
|
+
use() {
|
|
4979
|
+
eventHub.on(middlewareEventSelect, selectCallback);
|
|
4980
|
+
eventHub.on(middlewareEventSelectClear, selectClearCallback);
|
|
4981
|
+
},
|
|
4982
|
+
disuse() {
|
|
4983
|
+
eventHub.off(middlewareEventSelect, selectCallback);
|
|
4984
|
+
eventHub.off(middlewareEventSelectClear, selectClearCallback);
|
|
4985
|
+
},
|
|
4383
4986
|
hover: (e) => {
|
|
4384
|
-
var _a, _b;
|
|
4987
|
+
var _a, _b, _c, _d, _e;
|
|
4385
4988
|
const resizeType = sharer.getSharedStorage(keyResizeType);
|
|
4386
4989
|
const actionType = sharer.getSharedStorage(keyActionType);
|
|
4387
4990
|
const groupQueue = sharer.getSharedStorage(keyGroupQueue);
|
|
4388
4991
|
const triggerCursor = (target2) => {
|
|
4389
|
-
|
|
4992
|
+
const cursor = target2.type;
|
|
4390
4993
|
if (inBusyMode === null) {
|
|
4391
4994
|
eventHub.trigger("cursor", {
|
|
4392
4995
|
type: cursor,
|
|
@@ -4443,8 +5046,16 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4443
5046
|
})
|
|
4444
5047
|
});
|
|
4445
5048
|
triggerCursor(target);
|
|
4446
|
-
if (target.type ===
|
|
4447
|
-
|
|
5049
|
+
if (target.type === null) {
|
|
5050
|
+
return;
|
|
5051
|
+
}
|
|
5052
|
+
if (target.type === "over-element" && sharer.getSharedStorage(keyActionType) === "select" && target.elements.length === 1 && target.elements[0].uuid === ((_c = (_b = getActiveElements()) == null ? void 0 : _b[0]) == null ? void 0 : _c.uuid)) {
|
|
5053
|
+
return;
|
|
5054
|
+
}
|
|
5055
|
+
if (target.type === "over-element" && sharer.getSharedStorage(keyActionType) === null && target.elements.length === 1 && target.elements[0].uuid === ((_d = sharer.getSharedStorage(keyHoverElement)) == null ? void 0 : _d.uuid)) {
|
|
5056
|
+
return;
|
|
5057
|
+
}
|
|
5058
|
+
if (target.type === "over-element" && ((_e = target == null ? void 0 : target.elements) == null ? void 0 : _e.length) === 1) {
|
|
4448
5059
|
updateHoverElement(target.elements[0]);
|
|
4449
5060
|
viewer.drawFrame();
|
|
4450
5061
|
return;
|
|
@@ -4456,9 +5067,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4456
5067
|
}
|
|
4457
5068
|
},
|
|
4458
5069
|
pointStart: (e) => {
|
|
4459
|
-
var _a, _b, _c, _d;
|
|
5070
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4460
5071
|
prevPoint = e.point;
|
|
4461
|
-
updateHoverElement(null);
|
|
4462
5072
|
const groupQueue = sharer.getSharedStorage(keyGroupQueue);
|
|
4463
5073
|
if ((groupQueue == null ? void 0 : groupQueue.length) > 0) {
|
|
4464
5074
|
if (isPointInViewActiveGroup(e.point, {
|
|
@@ -4468,11 +5078,15 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4468
5078
|
groupQueue
|
|
4469
5079
|
})) {
|
|
4470
5080
|
const target2 = getPointTarget(e.point, pointTargetBaseOptions());
|
|
4471
|
-
|
|
4472
|
-
|
|
5081
|
+
if (((_a = target2 == null ? void 0 : target2.elements) == null ? void 0 : _a.length) === 1 && ((_c = (_b = target2.elements[0]) == null ? void 0 : _b.operations) == null ? void 0 : _c.lock) === true) {
|
|
5082
|
+
return;
|
|
5083
|
+
} else {
|
|
5084
|
+
updateHoverElement(null);
|
|
5085
|
+
}
|
|
5086
|
+
if (target2.type === "over-element" && ((_d = target2 == null ? void 0 : target2.elements) == null ? void 0 : _d.length) === 1) {
|
|
4473
5087
|
updateSelectedElementList([target2.elements[0]], { triggerEvent: true });
|
|
4474
5088
|
sharer.setSharedStorage(keyActionType, "drag");
|
|
4475
|
-
} else if ((
|
|
5089
|
+
} else if ((_e = target2.type) == null ? void 0 : _e.startsWith("resize-")) {
|
|
4476
5090
|
sharer.setSharedStorage(keyResizeType, target2.type);
|
|
4477
5091
|
sharer.setSharedStorage(keyActionType, "resize");
|
|
4478
5092
|
} else {
|
|
@@ -4494,12 +5108,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4494
5108
|
areaSize: listAreaSize,
|
|
4495
5109
|
groupQueue: []
|
|
4496
5110
|
});
|
|
5111
|
+
if (((_f = target == null ? void 0 : target.elements) == null ? void 0 : _f.length) === 1 && ((_h = (_g = target.elements[0]) == null ? void 0 : _g.operations) == null ? void 0 : _h.lock) === true) {
|
|
5112
|
+
return;
|
|
5113
|
+
} else {
|
|
5114
|
+
updateHoverElement(null);
|
|
5115
|
+
}
|
|
4497
5116
|
if (target.type === "list-area") {
|
|
4498
5117
|
sharer.setSharedStorage(keyActionType, "drag-list");
|
|
4499
|
-
} else if (target.type === "over-element" && ((
|
|
5118
|
+
} else if (target.type === "over-element" && ((_i = target == null ? void 0 : target.elements) == null ? void 0 : _i.length) === 1) {
|
|
4500
5119
|
updateSelectedElementList([target.elements[0]], { triggerEvent: true });
|
|
4501
5120
|
sharer.setSharedStorage(keyActionType, "drag");
|
|
4502
|
-
} else if ((
|
|
5121
|
+
} else if ((_j = target.type) == null ? void 0 : _j.startsWith("resize-")) {
|
|
4503
5122
|
sharer.setSharedStorage(keyResizeType, target.type);
|
|
4504
5123
|
sharer.setSharedStorage(keyActionType, "resize");
|
|
4505
5124
|
} else {
|
|
@@ -4511,6 +5130,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4511
5130
|
viewer.drawFrame();
|
|
4512
5131
|
},
|
|
4513
5132
|
pointMove: (e) => {
|
|
5133
|
+
var _a, _b, _c;
|
|
4514
5134
|
const data = sharer.getActiveStorage("data");
|
|
4515
5135
|
const elems = getActiveElements();
|
|
4516
5136
|
const scale = sharer.getActiveStorage("scale") || 1;
|
|
@@ -4521,7 +5141,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4521
5141
|
const groupQueue = sharer.getSharedStorage(keyGroupQueue);
|
|
4522
5142
|
if (actionType === "drag") {
|
|
4523
5143
|
inBusyMode = "drag";
|
|
4524
|
-
if (data && (elems == null ? void 0 : elems.length) === 1 && start && end) {
|
|
5144
|
+
if (data && (elems == null ? void 0 : elems.length) === 1 && start && end && ((_b = (_a = elems[0]) == null ? void 0 : _a.operations) == null ? void 0 : _b.lock) !== true) {
|
|
4525
5145
|
const { moveX, moveY } = calcMoveInGroup(start, end, groupQueue);
|
|
4526
5146
|
elems[0].x += moveX / scale;
|
|
4527
5147
|
elems[0].y += moveY / scale;
|
|
@@ -4534,7 +5154,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4534
5154
|
const moveX = (end.x - start.x) / scale;
|
|
4535
5155
|
const moveY = (end.y - start.y) / scale;
|
|
4536
5156
|
elems.forEach((elem) => {
|
|
4537
|
-
|
|
5157
|
+
var _a2;
|
|
5158
|
+
if (elem && ((_a2 = elem == null ? void 0 : elem.operations) == null ? void 0 : _a2.lock) !== true) {
|
|
4538
5159
|
elem.x += moveX;
|
|
4539
5160
|
elem.y += moveY;
|
|
4540
5161
|
}
|
|
@@ -4565,8 +5186,15 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4565
5186
|
const resizedElemSize = resizeElement(elems[0], { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
|
|
4566
5187
|
elems[0].x = resizedElemSize.x;
|
|
4567
5188
|
elems[0].y = resizedElemSize.y;
|
|
4568
|
-
elems[0].
|
|
4569
|
-
|
|
5189
|
+
if (elems[0].type === "group" && ((_c = elems[0].operations) == null ? void 0 : _c.deepResize) === true) {
|
|
5190
|
+
deepResizeGroupElement(elems[0], {
|
|
5191
|
+
w: resizedElemSize.w,
|
|
5192
|
+
h: resizedElemSize.h
|
|
5193
|
+
});
|
|
5194
|
+
} else {
|
|
5195
|
+
elems[0].w = resizedElemSize.w;
|
|
5196
|
+
elems[0].h = resizedElemSize.h;
|
|
5197
|
+
}
|
|
4570
5198
|
updateSelectedElementList([elems[0]]);
|
|
4571
5199
|
viewer.drawFrame();
|
|
4572
5200
|
}
|
|
@@ -4638,7 +5266,8 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4638
5266
|
sharer.setActiveStorage("contextWidth", viewInfo.contextSize.contextWidth);
|
|
4639
5267
|
}
|
|
4640
5268
|
if (data && ["drag", "drag-list", "drag-list-end", "resize"].includes(actionType)) {
|
|
4641
|
-
|
|
5269
|
+
let type = "drag-element";
|
|
5270
|
+
eventHub.trigger("change", { data, type });
|
|
4642
5271
|
}
|
|
4643
5272
|
viewer.drawFrame();
|
|
4644
5273
|
};
|
|
@@ -4650,16 +5279,21 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4650
5279
|
viewer.drawFrame();
|
|
4651
5280
|
},
|
|
4652
5281
|
doubleClick(e) {
|
|
4653
|
-
var _a, _b;
|
|
5282
|
+
var _a, _b, _c, _d;
|
|
4654
5283
|
const target = getPointTarget(e.point, pointTargetBaseOptions());
|
|
4655
|
-
|
|
5284
|
+
sharer.setSharedStorage(keySelectedElementController, null);
|
|
5285
|
+
sharer.setSharedStorage(keySelectedElementList, []);
|
|
5286
|
+
if (target.elements.length === 1 && ((_b = (_a = target.elements[0]) == null ? void 0 : _a.operations) == null ? void 0 : _b.lock) === true) {
|
|
5287
|
+
return;
|
|
5288
|
+
}
|
|
5289
|
+
if (target.elements.length === 1 && ((_c = target.elements[0]) == null ? void 0 : _c.type) === "group") {
|
|
4656
5290
|
const pushResult = pushGroupQueue(target.elements[0]);
|
|
4657
5291
|
if (pushResult === true) {
|
|
4658
5292
|
sharer.setSharedStorage(keyActionType, null);
|
|
4659
5293
|
viewer.drawFrame();
|
|
4660
5294
|
return;
|
|
4661
5295
|
}
|
|
4662
|
-
} else if (target.elements.length === 1 && ((
|
|
5296
|
+
} else if (target.elements.length === 1 && ((_d = target.elements[0]) == null ? void 0 : _d.type) === "text") {
|
|
4663
5297
|
eventHub.trigger(middlewareEventTextEdit, {
|
|
4664
5298
|
element: target.elements[0],
|
|
4665
5299
|
groupQueue: sharer.getSharedStorage(keyGroupQueue) || [],
|
|
@@ -4669,6 +5303,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4669
5303
|
sharer.setSharedStorage(keyActionType, null);
|
|
4670
5304
|
},
|
|
4671
5305
|
beforeDrawFrame({ snapshot }) {
|
|
5306
|
+
var _a;
|
|
4672
5307
|
const { activeStore, sharedStore } = snapshot;
|
|
4673
5308
|
const { scale, offsetLeft, offsetTop, offsetRight, offsetBottom, width, height, contextHeight, contextWidth, devicePixelRatio } = activeStore;
|
|
4674
5309
|
const sharer2 = opts.sharer;
|
|
@@ -4689,19 +5324,42 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4689
5324
|
controllerSize: 10,
|
|
4690
5325
|
viewScaleInfo
|
|
4691
5326
|
}) : null;
|
|
5327
|
+
const isLock = !!((_a = hoverElement == null ? void 0 : hoverElement.operations) == null ? void 0 : _a.lock);
|
|
4692
5328
|
if ((groupQueue == null ? void 0 : groupQueue.length) > 0) {
|
|
4693
5329
|
drawGroupQueueVertexesWrappers(helperContext, groupQueueVertexesList, drawBaseOpts);
|
|
4694
5330
|
if (hoverElement && actionType !== "drag") {
|
|
4695
|
-
|
|
5331
|
+
if (isLock) {
|
|
5332
|
+
drawLockVertexesWrapper(helperContext, hoverElementVertexes, {
|
|
5333
|
+
...drawBaseOpts,
|
|
5334
|
+
controller: calcElementSizeController(hoverElement, {
|
|
5335
|
+
groupQueue,
|
|
5336
|
+
controllerSize: 10,
|
|
5337
|
+
viewScaleInfo
|
|
5338
|
+
})
|
|
5339
|
+
});
|
|
5340
|
+
} else {
|
|
5341
|
+
drawHoverVertexesWrapper(helperContext, hoverElementVertexes, drawBaseOpts);
|
|
5342
|
+
}
|
|
4696
5343
|
}
|
|
4697
|
-
if (elem && ["select", "drag", "resize"].includes(actionType)) {
|
|
5344
|
+
if (!isLock && elem && ["select", "drag", "resize"].includes(actionType)) {
|
|
4698
5345
|
drawSelectedElementControllersVertexes(helperContext, selectedElementController, { ...drawBaseOpts });
|
|
4699
5346
|
}
|
|
4700
5347
|
} else {
|
|
4701
5348
|
if (hoverElement && actionType !== "drag") {
|
|
4702
|
-
|
|
5349
|
+
if (isLock) {
|
|
5350
|
+
drawLockVertexesWrapper(helperContext, hoverElementVertexes, {
|
|
5351
|
+
...drawBaseOpts,
|
|
5352
|
+
controller: calcElementSizeController(hoverElement, {
|
|
5353
|
+
groupQueue,
|
|
5354
|
+
controllerSize: 10,
|
|
5355
|
+
viewScaleInfo
|
|
5356
|
+
})
|
|
5357
|
+
});
|
|
5358
|
+
} else {
|
|
5359
|
+
drawHoverVertexesWrapper(helperContext, hoverElementVertexes, drawBaseOpts);
|
|
5360
|
+
}
|
|
4703
5361
|
}
|
|
4704
|
-
if (elem && ["select", "drag", "resize"].includes(actionType)) {
|
|
5362
|
+
if (!isLock && elem && ["select", "drag", "resize"].includes(actionType)) {
|
|
4705
5363
|
drawSelectedElementControllersVertexes(helperContext, selectedElementController, { ...drawBaseOpts });
|
|
4706
5364
|
} else if (actionType === "area" && areaStart && areaEnd) {
|
|
4707
5365
|
drawArea(helperContext, { start: areaStart, end: areaEnd });
|
|
@@ -4719,12 +5377,12 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4719
5377
|
}
|
|
4720
5378
|
};
|
|
4721
5379
|
};
|
|
4722
|
-
const key = "SCROLL";
|
|
4723
|
-
const keyXThumbRect = Symbol(`${key}_xThumbRect`);
|
|
4724
|
-
const keyYThumbRect = Symbol(`${key}_yThumbRect`);
|
|
4725
|
-
const keyPrevPoint = Symbol(`${key}_prevPoint`);
|
|
4726
|
-
const keyActivePoint = Symbol(`${key}_activePoint`);
|
|
4727
|
-
const keyActiveThumbType = Symbol(`${key}_activeThumbType`);
|
|
5380
|
+
const key$1 = "SCROLL";
|
|
5381
|
+
const keyXThumbRect = Symbol(`${key$1}_xThumbRect`);
|
|
5382
|
+
const keyYThumbRect = Symbol(`${key$1}_yThumbRect`);
|
|
5383
|
+
const keyPrevPoint$1 = Symbol(`${key$1}_prevPoint`);
|
|
5384
|
+
const keyActivePoint = Symbol(`${key$1}_activePoint`);
|
|
5385
|
+
const keyActiveThumbType = Symbol(`${key$1}_activeThumbType`);
|
|
4728
5386
|
const minScrollerWidth = 12;
|
|
4729
5387
|
const scrollerLineWidth = 16;
|
|
4730
5388
|
const scrollerThumbAlpha = 0.36;
|
|
@@ -4759,7 +5417,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4759
5417
|
const { sharedStore } = snapshot;
|
|
4760
5418
|
const info = {
|
|
4761
5419
|
activePoint: sharedStore[keyActivePoint] || null,
|
|
4762
|
-
prevPoint: sharedStore[keyPrevPoint] || null,
|
|
5420
|
+
prevPoint: sharedStore[keyPrevPoint$1] || null,
|
|
4763
5421
|
activeThumbType: sharedStore[keyActiveThumbType] || null,
|
|
4764
5422
|
xThumbRect: sharedStore[keyXThumbRect] || null,
|
|
4765
5423
|
yThumbRect: sharedStore[keyYThumbRect] || null
|
|
@@ -4917,18 +5575,18 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4917
5575
|
return { xThumbRect, yThumbRect };
|
|
4918
5576
|
}
|
|
4919
5577
|
const MiddlewareScroller = (opts) => {
|
|
4920
|
-
const { viewer,
|
|
4921
|
-
const { helperContext } =
|
|
5578
|
+
const { viewer, boardContent, sharer } = opts;
|
|
5579
|
+
const { helperContext } = boardContent;
|
|
4922
5580
|
sharer.setSharedStorage(keyXThumbRect, null);
|
|
4923
5581
|
sharer.setSharedStorage(keyYThumbRect, null);
|
|
4924
5582
|
const clear = () => {
|
|
4925
|
-
sharer.setSharedStorage(keyPrevPoint, null);
|
|
5583
|
+
sharer.setSharedStorage(keyPrevPoint$1, null);
|
|
4926
5584
|
sharer.setSharedStorage(keyActivePoint, null);
|
|
4927
5585
|
sharer.setSharedStorage(keyActiveThumbType, null);
|
|
4928
5586
|
};
|
|
4929
5587
|
clear();
|
|
4930
5588
|
const scrollX = (p) => {
|
|
4931
|
-
const prevPoint = sharer.getSharedStorage(keyPrevPoint);
|
|
5589
|
+
const prevPoint = sharer.getSharedStorage(keyPrevPoint$1);
|
|
4932
5590
|
if (prevPoint) {
|
|
4933
5591
|
const { offsetLeft, offsetRight } = sharer.getActiveViewScaleInfo();
|
|
4934
5592
|
const { width } = sharer.getActiveViewSizeInfo();
|
|
@@ -4940,7 +5598,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4940
5598
|
}
|
|
4941
5599
|
};
|
|
4942
5600
|
const scrollY = (p) => {
|
|
4943
|
-
const prevPoint = sharer.getSharedStorage(keyPrevPoint);
|
|
5601
|
+
const prevPoint = sharer.getSharedStorage(keyPrevPoint$1);
|
|
4944
5602
|
if (prevPoint) {
|
|
4945
5603
|
const { offsetTop, offsetBottom } = sharer.getActiveViewScaleInfo();
|
|
4946
5604
|
const { height } = sharer.getActiveViewSizeInfo();
|
|
@@ -4958,7 +5616,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4958
5616
|
});
|
|
4959
5617
|
};
|
|
4960
5618
|
return {
|
|
4961
|
-
|
|
5619
|
+
name: "@middleware/scroller",
|
|
4962
5620
|
wheel: (e) => {
|
|
4963
5621
|
viewer.scroll({
|
|
4964
5622
|
moveX: 0 - e.deltaX,
|
|
@@ -4971,7 +5629,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4971
5629
|
const thumbType = getThumbType(point);
|
|
4972
5630
|
if (thumbType === "X" || thumbType === "Y") {
|
|
4973
5631
|
sharer.setSharedStorage(keyActiveThumbType, thumbType);
|
|
4974
|
-
sharer.setSharedStorage(keyPrevPoint, point);
|
|
5632
|
+
sharer.setSharedStorage(keyPrevPoint$1, point);
|
|
4975
5633
|
return false;
|
|
4976
5634
|
}
|
|
4977
5635
|
},
|
|
@@ -4985,11 +5643,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
4985
5643
|
} else if (activeThumbType === "Y") {
|
|
4986
5644
|
scrollY(point);
|
|
4987
5645
|
}
|
|
4988
|
-
sharer.setSharedStorage(keyPrevPoint, point);
|
|
5646
|
+
sharer.setSharedStorage(keyPrevPoint$1, point);
|
|
4989
5647
|
return false;
|
|
4990
5648
|
}
|
|
4991
5649
|
},
|
|
4992
|
-
pointEnd: (
|
|
5650
|
+
pointEnd: () => {
|
|
4993
5651
|
const activeThumbType = sharer.getSharedStorage(keyActiveThumbType);
|
|
4994
5652
|
clear();
|
|
4995
5653
|
if (activeThumbType === "X" || activeThumbType === "Y") {
|
|
@@ -5007,13 +5665,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5007
5665
|
};
|
|
5008
5666
|
const middlewareEventScale = "@middleware/scale";
|
|
5009
5667
|
const MiddlewareScaler = (opts) => {
|
|
5010
|
-
const key2 = "SCALE";
|
|
5011
5668
|
const { viewer, sharer, eventHub } = opts;
|
|
5012
5669
|
const maxScale = 50;
|
|
5013
5670
|
const minScale = 0.05;
|
|
5014
5671
|
return {
|
|
5015
|
-
|
|
5016
|
-
isDefault: true,
|
|
5672
|
+
name: "@middleware/scaler",
|
|
5017
5673
|
wheelScale(e) {
|
|
5018
5674
|
const { deltaY, point } = e;
|
|
5019
5675
|
const { scale } = sharer.getActiveViewScaleInfo();
|
|
@@ -5220,12 +5876,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5220
5876
|
}
|
|
5221
5877
|
const middlewareEventRuler = "@middleware/show-ruler";
|
|
5222
5878
|
const MiddlewareRuler = (opts) => {
|
|
5223
|
-
const
|
|
5224
|
-
const {
|
|
5225
|
-
const { helperContext, underContext } = viewContent;
|
|
5879
|
+
const { boardContent, viewer, eventHub } = opts;
|
|
5880
|
+
const { helperContext, underContext } = boardContent;
|
|
5226
5881
|
let show = true;
|
|
5227
5882
|
let showGrid = true;
|
|
5228
|
-
|
|
5883
|
+
const rulerCallback = (e) => {
|
|
5229
5884
|
if (typeof (e == null ? void 0 : e.show) === "boolean") {
|
|
5230
5885
|
show = e.show;
|
|
5231
5886
|
}
|
|
@@ -5235,10 +5890,15 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5235
5890
|
if (typeof (e == null ? void 0 : e.show) === "boolean" || typeof (e == null ? void 0 : e.showGrid) === "boolean") {
|
|
5236
5891
|
viewer.drawFrame();
|
|
5237
5892
|
}
|
|
5238
|
-
}
|
|
5893
|
+
};
|
|
5239
5894
|
return {
|
|
5240
|
-
|
|
5241
|
-
|
|
5895
|
+
name: "@middleware/ruler",
|
|
5896
|
+
use() {
|
|
5897
|
+
eventHub.on(middlewareEventRuler, rulerCallback);
|
|
5898
|
+
},
|
|
5899
|
+
disuse() {
|
|
5900
|
+
eventHub.off(middlewareEventRuler, rulerCallback);
|
|
5901
|
+
},
|
|
5242
5902
|
beforeDrawFrame: ({ snapshot }) => {
|
|
5243
5903
|
if (show === true) {
|
|
5244
5904
|
const viewScaleInfo = getViewScaleInfoFromSnapshot(snapshot);
|
|
@@ -5260,20 +5920,64 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5260
5920
|
}
|
|
5261
5921
|
};
|
|
5262
5922
|
};
|
|
5923
|
+
const key = "DRAG";
|
|
5924
|
+
const keyPrevPoint = Symbol(`${key}_prevPoint`);
|
|
5925
|
+
const MiddlewareDragger = (opts) => {
|
|
5926
|
+
const { eventHub, sharer, viewer } = opts;
|
|
5927
|
+
let isDragging = false;
|
|
5928
|
+
return {
|
|
5929
|
+
name: "@middleware/dragger",
|
|
5930
|
+
hover() {
|
|
5931
|
+
if (isDragging === true) {
|
|
5932
|
+
return;
|
|
5933
|
+
}
|
|
5934
|
+
eventHub.trigger("cursor", {
|
|
5935
|
+
type: "drag-default"
|
|
5936
|
+
});
|
|
5937
|
+
},
|
|
5938
|
+
pointStart(e) {
|
|
5939
|
+
const { point } = e;
|
|
5940
|
+
sharer.setSharedStorage(keyPrevPoint, point);
|
|
5941
|
+
isDragging = true;
|
|
5942
|
+
eventHub.trigger("cursor", {
|
|
5943
|
+
type: "drag-active"
|
|
5944
|
+
});
|
|
5945
|
+
},
|
|
5946
|
+
pointMove(e) {
|
|
5947
|
+
const { point } = e;
|
|
5948
|
+
const prevPoint = sharer.getSharedStorage(keyPrevPoint);
|
|
5949
|
+
if (point && prevPoint) {
|
|
5950
|
+
const moveX = point.x - prevPoint.x;
|
|
5951
|
+
const moveY = point.y - prevPoint.y;
|
|
5952
|
+
viewer.scroll({ moveX, moveY });
|
|
5953
|
+
viewer.drawFrame();
|
|
5954
|
+
}
|
|
5955
|
+
sharer.setSharedStorage(keyPrevPoint, point);
|
|
5956
|
+
},
|
|
5957
|
+
pointEnd() {
|
|
5958
|
+
isDragging = false;
|
|
5959
|
+
sharer.setSharedStorage(keyPrevPoint, null);
|
|
5960
|
+
eventHub.trigger("cursor", {
|
|
5961
|
+
type: "drag-default"
|
|
5962
|
+
});
|
|
5963
|
+
}
|
|
5964
|
+
};
|
|
5965
|
+
};
|
|
5263
5966
|
class Core {
|
|
5264
5967
|
constructor(container, opts) {
|
|
5265
5968
|
__privateAdd(this, _initContainer);
|
|
5266
5969
|
__privateAdd(this, _board, void 0);
|
|
5267
5970
|
// #opts: CoreOptions;
|
|
5268
|
-
|
|
5269
|
-
__privateAdd(this,
|
|
5270
|
-
const { devicePixelRatio = 1, width, height } = opts;
|
|
5271
|
-
__privateSet(this,
|
|
5971
|
+
__privateAdd(this, _canvas, void 0);
|
|
5972
|
+
__privateAdd(this, _container2, void 0);
|
|
5973
|
+
const { devicePixelRatio = 1, width, height, createCustomContext2D } = opts;
|
|
5974
|
+
__privateSet(this, _container2, container);
|
|
5272
5975
|
const canvas = document.createElement("canvas");
|
|
5976
|
+
__privateSet(this, _canvas, canvas);
|
|
5273
5977
|
__privateMethod(this, _initContainer, initContainer_fn).call(this);
|
|
5274
5978
|
container.appendChild(canvas);
|
|
5275
|
-
const
|
|
5276
|
-
const board = new Board({
|
|
5979
|
+
const boardContent = createBoardContent(canvas, { width, height, devicePixelRatio, offscreen: true, createCustomContext2D });
|
|
5980
|
+
const board = new Board({ boardContent, container });
|
|
5277
5981
|
const sharer = board.getSharer();
|
|
5278
5982
|
sharer.setActiveViewSizeInfo({
|
|
5279
5983
|
width,
|
|
@@ -5289,9 +5993,19 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5289
5993
|
eventHub
|
|
5290
5994
|
});
|
|
5291
5995
|
}
|
|
5996
|
+
isDestroyed() {
|
|
5997
|
+
return __privateGet(this, _board).isDestroyed();
|
|
5998
|
+
}
|
|
5999
|
+
destroy() {
|
|
6000
|
+
__privateGet(this, _board).destroy();
|
|
6001
|
+
__privateGet(this, _canvas).remove();
|
|
6002
|
+
}
|
|
5292
6003
|
use(middleware) {
|
|
5293
6004
|
__privateGet(this, _board).use(middleware);
|
|
5294
6005
|
}
|
|
6006
|
+
disuse(middleware) {
|
|
6007
|
+
__privateGet(this, _board).disuse(middleware);
|
|
6008
|
+
}
|
|
5295
6009
|
setData(data) {
|
|
5296
6010
|
validateElements((data == null ? void 0 : data.elements) || []);
|
|
5297
6011
|
__privateGet(this, _board).setData(data);
|
|
@@ -5344,15 +6058,26 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5344
6058
|
setViewScale(opts) {
|
|
5345
6059
|
__privateGet(this, _board).updateViewScaleInfo(opts);
|
|
5346
6060
|
}
|
|
6061
|
+
getLoadItemMap() {
|
|
6062
|
+
return __privateGet(this, _board).getRenderer().getLoadItemMap();
|
|
6063
|
+
}
|
|
6064
|
+
onBoardWatcherEvents() {
|
|
6065
|
+
__privateGet(this, _board).onWatcherEvents();
|
|
6066
|
+
}
|
|
6067
|
+
offBoardWatcherEvents() {
|
|
6068
|
+
__privateGet(this, _board).offWatcherEvents();
|
|
6069
|
+
}
|
|
5347
6070
|
}
|
|
5348
6071
|
_board = new WeakMap();
|
|
5349
|
-
|
|
6072
|
+
_canvas = new WeakMap();
|
|
6073
|
+
_container2 = new WeakMap();
|
|
5350
6074
|
_initContainer = new WeakSet();
|
|
5351
6075
|
initContainer_fn = function() {
|
|
5352
|
-
const container = __privateGet(this,
|
|
6076
|
+
const container = __privateGet(this, _container2);
|
|
5353
6077
|
container.style.position = "relative";
|
|
5354
6078
|
};
|
|
5355
6079
|
exports.Core = Core;
|
|
6080
|
+
exports.MiddlewareDragger = MiddlewareDragger;
|
|
5356
6081
|
exports.MiddlewareRuler = MiddlewareRuler;
|
|
5357
6082
|
exports.MiddlewareScaler = MiddlewareScaler;
|
|
5358
6083
|
exports.MiddlewareScroller = MiddlewareScroller;
|
|
@@ -5361,6 +6086,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
5361
6086
|
exports.middlewareEventRuler = middlewareEventRuler;
|
|
5362
6087
|
exports.middlewareEventScale = middlewareEventScale;
|
|
5363
6088
|
exports.middlewareEventSelect = middlewareEventSelect;
|
|
6089
|
+
exports.middlewareEventSelectClear = middlewareEventSelectClear;
|
|
5364
6090
|
exports.middlewareEventTextEdit = middlewareEventTextEdit;
|
|
5365
6091
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5366
6092
|
return exports;
|