@idraw/core 0.4.0-beta.6 → 0.4.0-beta.8

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.
@@ -358,7 +358,7 @@ var __privateMethod = (obj, member, method) => {
358
358
  fontWeight: fontWeight$1,
359
359
  strokeWidth
360
360
  };
361
- var __classPrivateFieldSet$3 = 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$3 = 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,17 @@ 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$3(this, _Context2D_ctx, ctx, "f");
383
- __classPrivateFieldSet$3(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$3(this, _Context2D_opts, "f").devicePixelRatio;
386
+ return num / __classPrivateFieldGet$9(this, _Context2D_opts, "f").devicePixelRatio;
387
387
  }
388
388
  $doPixelRatio(num) {
389
- return __classPrivateFieldGet$3(this, _Context2D_opts, "f").devicePixelRatio * num;
389
+ return __classPrivateFieldGet$9(this, _Context2D_opts, "f").devicePixelRatio * num;
390
390
  }
391
391
  $getContext() {
392
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f");
392
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f");
393
393
  }
394
394
  $setFont(opts) {
395
395
  const strList = [];
@@ -398,17 +398,17 @@ var __privateMethod = (obj, member, method) => {
398
398
  }
399
399
  strList.push(`${this.$doPixelRatio(opts.fontSize || 12)}px`);
400
400
  strList.push(`${opts.fontFamily || "sans-serif"}`);
401
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").font = `${strList.join(" ")}`;
401
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").font = `${strList.join(" ")}`;
402
402
  }
403
403
  $getOffscreenCanvas() {
404
- return __classPrivateFieldGet$3(this, _Context2D_opts, "f").offscreenCanvas;
404
+ return __classPrivateFieldGet$9(this, _Context2D_opts, "f").offscreenCanvas;
405
405
  }
406
406
  $resize(opts) {
407
407
  const { width, height, devicePixelRatio, resetStyle } = opts;
408
- const { canvas } = __classPrivateFieldGet$3(this, _Context2D_ctx, "f");
408
+ const { canvas } = __classPrivateFieldGet$9(this, _Context2D_ctx, "f");
409
409
  canvas.width = width * devicePixelRatio;
410
410
  canvas.height = height * devicePixelRatio;
411
- __classPrivateFieldSet$3(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet$3(this, _Context2D_opts, "f")), {
411
+ __classPrivateFieldSet$9(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet$9(this, _Context2D_opts, "f")), {
412
412
  devicePixelRatio
413
413
  }), "f");
414
414
  if (resetStyle === true) {
@@ -417,8 +417,8 @@ var __privateMethod = (obj, member, method) => {
417
417
  }
418
418
  }
419
419
  $getSize() {
420
- const { devicePixelRatio } = __classPrivateFieldGet$3(this, _Context2D_opts, "f");
421
- const { width, height } = __classPrivateFieldGet$3(this, _Context2D_ctx, "f").canvas;
420
+ const { devicePixelRatio } = __classPrivateFieldGet$9(this, _Context2D_opts, "f");
421
+ const { width, height } = __classPrivateFieldGet$9(this, _Context2D_ctx, "f").canvas;
422
422
  return {
423
423
  width: width / devicePixelRatio,
424
424
  height: height / devicePixelRatio,
@@ -426,125 +426,125 @@ var __privateMethod = (obj, member, method) => {
426
426
  };
427
427
  }
428
428
  get canvas() {
429
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").canvas;
429
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").canvas;
430
430
  }
431
431
  get fillStyle() {
432
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").fillStyle;
432
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillStyle;
433
433
  }
434
434
  set fillStyle(value) {
435
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").fillStyle = value;
435
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillStyle = value;
436
436
  }
437
437
  get strokeStyle() {
438
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").strokeStyle;
438
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeStyle;
439
439
  }
440
440
  set strokeStyle(color2) {
441
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").strokeStyle = color2;
441
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeStyle = color2;
442
442
  }
443
443
  get lineWidth() {
444
- return this.$undoPixelRatio(__classPrivateFieldGet$3(this, _Context2D_ctx, "f").lineWidth);
444
+ return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineWidth);
445
445
  }
446
446
  set lineWidth(w2) {
447
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").lineWidth = this.$doPixelRatio(w2);
447
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineWidth = this.$doPixelRatio(w2);
448
448
  }
449
449
  get textAlign() {
450
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").textAlign;
450
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textAlign;
451
451
  }
452
452
  set textAlign(align) {
453
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").textAlign = align;
453
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textAlign = align;
454
454
  }
455
455
  get textBaseline() {
456
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").textBaseline;
456
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textBaseline;
457
457
  }
458
458
  set textBaseline(baseline) {
459
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").textBaseline = baseline;
459
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").textBaseline = baseline;
460
460
  }
461
461
  get globalAlpha() {
462
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").globalAlpha;
462
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalAlpha;
463
463
  }
464
464
  set globalAlpha(alpha) {
465
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").globalAlpha = alpha;
465
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalAlpha = alpha;
466
466
  }
467
467
  get shadowColor() {
468
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").shadowColor;
468
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowColor;
469
469
  }
470
470
  set shadowColor(color2) {
471
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").shadowColor = color2;
471
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowColor = color2;
472
472
  }
473
473
  get shadowOffsetX() {
474
- return this.$undoPixelRatio(__classPrivateFieldGet$3(this, _Context2D_ctx, "f").shadowOffsetX);
474
+ return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetX);
475
475
  }
476
476
  set shadowOffsetX(offsetX) {
477
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").shadowOffsetX = this.$doPixelRatio(offsetX);
477
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetX = this.$doPixelRatio(offsetX);
478
478
  }
479
479
  get shadowOffsetY() {
480
- return this.$undoPixelRatio(__classPrivateFieldGet$3(this, _Context2D_ctx, "f").shadowOffsetY);
480
+ return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetY);
481
481
  }
482
482
  set shadowOffsetY(offsetY) {
483
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").shadowOffsetY = this.$doPixelRatio(offsetY);
483
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowOffsetY = this.$doPixelRatio(offsetY);
484
484
  }
485
485
  get shadowBlur() {
486
- return this.$undoPixelRatio(__classPrivateFieldGet$3(this, _Context2D_ctx, "f").shadowBlur);
486
+ return this.$undoPixelRatio(__classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowBlur);
487
487
  }
488
488
  set shadowBlur(blur) {
489
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").shadowBlur = this.$doPixelRatio(blur);
489
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").shadowBlur = this.$doPixelRatio(blur);
490
490
  }
491
491
  get lineCap() {
492
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").lineCap;
492
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineCap;
493
493
  }
494
494
  set lineCap(lineCap) {
495
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").lineCap = lineCap;
495
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineCap = lineCap;
496
496
  }
497
497
  get globalCompositeOperation() {
498
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").globalCompositeOperation;
498
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalCompositeOperation;
499
499
  }
500
500
  set globalCompositeOperation(operations) {
501
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
501
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
502
502
  }
503
503
  fill(...args) {
504
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").fill(...args);
504
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fill(...args);
505
505
  }
506
506
  arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
507
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
507
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
508
508
  }
509
509
  rect(x2, y2, w2, h2) {
510
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
510
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
511
511
  }
512
512
  fillRect(x2, y2, w2, h2) {
513
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
513
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
514
514
  }
515
515
  clearRect(x2, y2, w2, h2) {
516
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
516
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
517
517
  }
518
518
  beginPath() {
519
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").beginPath();
519
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").beginPath();
520
520
  }
521
521
  closePath() {
522
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").closePath();
522
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").closePath();
523
523
  }
524
524
  lineTo(x2, y2) {
525
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
525
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
526
526
  }
527
527
  moveTo(x2, y2) {
528
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
528
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
529
529
  }
530
530
  arcTo(x1, y1, x2, y2, radius) {
531
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
531
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
532
532
  }
533
533
  getLineDash() {
534
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").getLineDash();
534
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").getLineDash();
535
535
  }
536
536
  setLineDash(nums) {
537
537
  const dash = nums.map((n) => this.$doPixelRatio(n));
538
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").setLineDash(dash);
538
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").setLineDash(dash);
539
539
  }
540
540
  stroke(path) {
541
- return path ? __classPrivateFieldGet$3(this, _Context2D_ctx, "f").stroke(path) : __classPrivateFieldGet$3(this, _Context2D_ctx, "f").stroke();
541
+ return path ? __classPrivateFieldGet$9(this, _Context2D_ctx, "f").stroke(path) : __classPrivateFieldGet$9(this, _Context2D_ctx, "f").stroke();
542
542
  }
543
543
  translate(x2, y2) {
544
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
544
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
545
545
  }
546
546
  rotate(angle2) {
547
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").rotate(angle2);
547
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").rotate(angle2);
548
548
  }
549
549
  drawImage(...args) {
550
550
  const image = args[0];
@@ -557,64 +557,64 @@ var __privateMethod = (obj, member, method) => {
557
557
  const dw = args[args.length - 2];
558
558
  const dh = args[args.length - 1];
559
559
  if (args.length === 9) {
560
- return __classPrivateFieldGet$3(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));
560
+ 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
561
  } else {
562
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
562
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
563
563
  }
564
564
  }
565
565
  createPattern(image, repetition) {
566
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").createPattern(image, repetition);
566
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createPattern(image, repetition);
567
567
  }
568
568
  measureText(text2) {
569
- const textMetrics = __classPrivateFieldGet$3(this, _Context2D_ctx, "f").measureText(text2);
569
+ const textMetrics = __classPrivateFieldGet$9(this, _Context2D_ctx, "f").measureText(text2);
570
570
  return textMetrics;
571
571
  }
572
572
  fillText(text2, x2, y2, maxWidth) {
573
573
  if (maxWidth !== void 0) {
574
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
574
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
575
575
  } else {
576
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
576
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
577
577
  }
578
578
  }
579
579
  strokeText(text2, x2, y2, maxWidth) {
580
580
  if (maxWidth !== void 0) {
581
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
581
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
582
582
  } else {
583
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
583
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
584
584
  }
585
585
  }
586
586
  save() {
587
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").save();
587
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").save();
588
588
  }
589
589
  restore() {
590
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").restore();
590
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").restore();
591
591
  }
592
592
  scale(ratioX, ratioY) {
593
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").scale(ratioX, ratioY);
593
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").scale(ratioX, ratioY);
594
594
  }
595
595
  circle(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
596
- __classPrivateFieldGet$3(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
596
+ __classPrivateFieldGet$9(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
597
597
  }
598
598
  isPointInPath(x2, y2) {
599
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
599
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
600
600
  }
601
601
  clip(...args) {
602
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").clip(...args);
602
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").clip(...args);
603
603
  }
604
604
  setTransform(a, b, c, d, e, f) {
605
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
605
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
606
606
  }
607
607
  getTransform() {
608
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").getTransform();
608
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").getTransform();
609
609
  }
610
610
  createLinearGradient(x0, y0, x1, y1) {
611
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
611
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
612
612
  }
613
613
  createRadialGradient(x0, y0, r0, x1, y1, r1) {
614
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").createRadialGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(r0), this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(r1));
614
+ 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
615
  }
616
616
  createConicGradient(startAngle, x2, y2) {
617
- return __classPrivateFieldGet$3(this, _Context2D_ctx, "f").createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
617
+ return __classPrivateFieldGet$9(this, _Context2D_ctx, "f").createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
618
618
  }
619
619
  }
620
620
  _Context2D_ctx = /* @__PURE__ */ new WeakMap(), _Context2D_opts = /* @__PURE__ */ new WeakMap();
@@ -697,22 +697,40 @@ var __privateMethod = (obj, member, method) => {
697
697
  return content;
698
698
  }
699
699
  }
700
+ var __classPrivateFieldSet$8 = function(receiver, state, value, kind, f) {
701
+ if (kind === "m")
702
+ throw new TypeError("Private method is not writable");
703
+ if (kind === "a" && !f)
704
+ throw new TypeError("Private accessor was defined without a setter");
705
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
706
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
707
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
708
+ };
709
+ var __classPrivateFieldGet$8 = function(receiver, state, kind, f) {
710
+ if (kind === "a" && !f)
711
+ throw new TypeError("Private accessor was defined without a getter");
712
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
713
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
714
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
715
+ };
716
+ var _EventEmitter_listeners;
700
717
  class EventEmitter {
701
718
  constructor() {
702
- this._listeners = /* @__PURE__ */ new Map();
719
+ _EventEmitter_listeners.set(this, void 0);
720
+ __classPrivateFieldSet$8(this, _EventEmitter_listeners, /* @__PURE__ */ new Map(), "f");
703
721
  }
704
722
  on(eventKey, callback) {
705
- if (this._listeners.has(eventKey)) {
706
- const callbacks = this._listeners.get(eventKey) || [];
723
+ if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(eventKey)) {
724
+ const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey) || [];
707
725
  callbacks === null || callbacks === void 0 ? void 0 : callbacks.push(callback);
708
- this._listeners.set(eventKey, callbacks);
726
+ __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, callbacks);
709
727
  } else {
710
- this._listeners.set(eventKey, [callback]);
728
+ __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, [callback]);
711
729
  }
712
730
  }
713
731
  off(eventKey, callback) {
714
- if (this._listeners.has(eventKey)) {
715
- const callbacks = this._listeners.get(eventKey);
732
+ if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(eventKey)) {
733
+ const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey);
716
734
  if (Array.isArray(callbacks)) {
717
735
  for (let i = 0; i < (callbacks === null || callbacks === void 0 ? void 0 : callbacks.length); i++) {
718
736
  if (callbacks[i] === callback) {
@@ -721,11 +739,11 @@ var __privateMethod = (obj, member, method) => {
721
739
  }
722
740
  }
723
741
  }
724
- this._listeners.set(eventKey, callbacks || []);
742
+ __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").set(eventKey, callbacks || []);
725
743
  }
726
744
  }
727
745
  trigger(eventKey, e) {
728
- const callbacks = this._listeners.get(eventKey);
746
+ const callbacks = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(eventKey);
729
747
  if (Array.isArray(callbacks)) {
730
748
  callbacks.forEach((cb) => {
731
749
  cb(e);
@@ -736,15 +754,19 @@ var __privateMethod = (obj, member, method) => {
736
754
  }
737
755
  }
738
756
  has(name) {
739
- if (this._listeners.has(name)) {
740
- const list = this._listeners.get(name);
757
+ if (__classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").has(name)) {
758
+ const list = __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").get(name);
741
759
  if (Array.isArray(list) && list.length > 0) {
742
760
  return true;
743
761
  }
744
762
  }
745
763
  return false;
746
764
  }
765
+ destroy() {
766
+ __classPrivateFieldGet$8(this, _EventEmitter_listeners, "f").clear();
767
+ }
747
768
  }
769
+ _EventEmitter_listeners = /* @__PURE__ */ new WeakMap();
748
770
  function calcDistance(start, end) {
749
771
  const distance = (start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y);
750
772
  return distance === 0 ? distance : Math.sqrt(distance);
@@ -755,27 +777,50 @@ var __privateMethod = (obj, member, method) => {
755
777
  y: p1.y + (p2.y - p1.y) / 2
756
778
  };
757
779
  }
780
+ var __classPrivateFieldSet$7 = function(receiver, state, value, kind, f) {
781
+ if (kind === "m")
782
+ throw new TypeError("Private method is not writable");
783
+ if (kind === "a" && !f)
784
+ throw new TypeError("Private accessor was defined without a setter");
785
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
786
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
787
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
788
+ };
789
+ var __classPrivateFieldGet$7 = function(receiver, state, kind, f) {
790
+ if (kind === "a" && !f)
791
+ throw new TypeError("Private accessor was defined without a getter");
792
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
793
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
794
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
795
+ };
796
+ var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_createTempStorage;
758
797
  class Store {
759
798
  constructor(opts) {
760
- this._backUpDefaultStorage = deepClone(opts.defaultStorage);
761
- this._temp = this._createTempStorage();
799
+ _Store_instances.add(this);
800
+ _Store_temp.set(this, void 0);
801
+ _Store_backUpDefaultStorage.set(this, void 0);
802
+ __classPrivateFieldSet$7(this, _Store_backUpDefaultStorage, deepClone(opts.defaultStorage), "f");
803
+ __classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
762
804
  }
763
805
  set(name, value) {
764
- this._temp[name] = value;
806
+ __classPrivateFieldGet$7(this, _Store_temp, "f")[name] = value;
765
807
  }
766
808
  get(name) {
767
- return this._temp[name];
809
+ return __classPrivateFieldGet$7(this, _Store_temp, "f")[name];
768
810
  }
769
811
  getSnapshot() {
770
- return deepClone(this._temp);
812
+ return deepClone(__classPrivateFieldGet$7(this, _Store_temp, "f"));
771
813
  }
772
814
  clear() {
773
- this._temp = this._createTempStorage();
815
+ __classPrivateFieldSet$7(this, _Store_temp, __classPrivateFieldGet$7(this, _Store_instances, "m", _Store_createTempStorage).call(this), "f");
774
816
  }
775
- _createTempStorage() {
776
- return deepClone(this._backUpDefaultStorage);
817
+ destroy() {
818
+ __classPrivateFieldSet$7(this, _Store_temp, null, "f");
777
819
  }
778
820
  }
821
+ _Store_temp = /* @__PURE__ */ new WeakMap(), _Store_backUpDefaultStorage = /* @__PURE__ */ new WeakMap(), _Store_instances = /* @__PURE__ */ new WeakSet(), _Store_createTempStorage = function _Store_createTempStorage2() {
822
+ return deepClone(__classPrivateFieldGet$7(this, _Store_backUpDefaultStorage, "f"));
823
+ };
779
824
  function getViewScaleInfoFromSnapshot(snapshot) {
780
825
  const { activeStore } = snapshot;
781
826
  const sacelInfo = {
@@ -2426,6 +2471,28 @@ var __privateMethod = (obj, member, method) => {
2426
2471
  }
2427
2472
  }
2428
2473
  }
2474
+ function drawUnderlay(ctx, underlay, opts) {
2475
+ const { calculator, viewScaleInfo, viewSizeInfo, parentOpacity } = opts;
2476
+ const elem = Object.assign({ uuid: "underlay" }, underlay);
2477
+ const { x: x2, y: y2, w: w2, h: h2 } = (calculator === null || calculator === void 0 ? void 0 : calculator.elementSize(elem, viewScaleInfo, viewSizeInfo)) || elem;
2478
+ const angle2 = 0;
2479
+ const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
2480
+ drawBoxShadow(ctx, viewElem, {
2481
+ viewScaleInfo,
2482
+ viewSizeInfo,
2483
+ renderContent: () => {
2484
+ drawBox(ctx, viewElem, {
2485
+ originElem: elem,
2486
+ calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
2487
+ viewScaleInfo,
2488
+ viewSizeInfo,
2489
+ parentOpacity,
2490
+ renderContent: () => {
2491
+ }
2492
+ });
2493
+ }
2494
+ });
2495
+ }
2429
2496
  var __awaiter = function(thisArg, _arguments, P, generator) {
2430
2497
  function adopt(value) {
2431
2498
  return value instanceof P ? value : new P(function(resolve) {
@@ -2453,14 +2520,14 @@ var __privateMethod = (obj, member, method) => {
2453
2520
  step((generator = generator.apply(thisArg, _arguments || [])).next());
2454
2521
  });
2455
2522
  };
2456
- var __classPrivateFieldGet$2 = function(receiver, state, kind, f) {
2523
+ var __classPrivateFieldGet$6 = function(receiver, state, kind, f) {
2457
2524
  if (kind === "a" && !f)
2458
2525
  throw new TypeError("Private accessor was defined without a getter");
2459
2526
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2460
2527
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
2461
2528
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2462
2529
  };
2463
- var __classPrivateFieldSet$2 = function(receiver, state, value, kind, f) {
2530
+ var __classPrivateFieldSet$6 = function(receiver, state, value, kind, f) {
2464
2531
  if (kind === "m")
2465
2532
  throw new TypeError("Private method is not writable");
2466
2533
  if (kind === "a" && !f)
@@ -2496,7 +2563,7 @@ var __privateMethod = (obj, member, method) => {
2496
2563
  _Loader_loadFuncMap.set(this, {});
2497
2564
  _Loader_currentLoadItemMap.set(this, {});
2498
2565
  _Loader_storageLoadItemMap.set(this, {});
2499
- __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "image", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2566
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "image", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2500
2567
  var _a;
2501
2568
  const src = ((_a = assets[elem.detail.src]) === null || _a === void 0 ? void 0 : _a.value) || elem.detail.src;
2502
2569
  const content = yield loadImage(src);
@@ -2506,7 +2573,7 @@ var __privateMethod = (obj, member, method) => {
2506
2573
  content
2507
2574
  };
2508
2575
  }));
2509
- __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "html", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2576
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "html", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2510
2577
  var _b;
2511
2578
  const html2 = ((_b = assets[elem.detail.html]) === null || _b === void 0 ? void 0 : _b.value) || elem.detail.html;
2512
2579
  const content = yield loadHTML(html2, {
@@ -2519,7 +2586,7 @@ var __privateMethod = (obj, member, method) => {
2519
2586
  content
2520
2587
  };
2521
2588
  }));
2522
- __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "svg", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2589
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_registerLoadFunc).call(this, "svg", (elem, assets) => __awaiter(this, void 0, void 0, function* () {
2523
2590
  var _c;
2524
2591
  const svg2 = ((_c = assets[elem.detail.svg]) === null || _c === void 0 ? void 0 : _c.value) || elem.detail.svg;
2525
2592
  const content = yield loadSVG(svg2);
@@ -2530,28 +2597,33 @@ var __privateMethod = (obj, member, method) => {
2530
2597
  };
2531
2598
  }));
2532
2599
  }
2600
+ destroy() {
2601
+ __classPrivateFieldSet$6(this, _Loader_loadFuncMap, null, "f");
2602
+ __classPrivateFieldSet$6(this, _Loader_currentLoadItemMap, null, "f");
2603
+ __classPrivateFieldSet$6(this, _Loader_storageLoadItemMap, null, "f");
2604
+ }
2533
2605
  load(element, assets) {
2534
- if (__classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_isExistingErrorStorage).call(this, element)) {
2606
+ if (__classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_isExistingErrorStorage).call(this, element)) {
2535
2607
  return;
2536
2608
  }
2537
2609
  if (supportElementTypes.includes(element.type)) {
2538
- __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_loadResource).call(this, element, assets);
2610
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_loadResource).call(this, element, assets);
2539
2611
  }
2540
2612
  }
2541
2613
  getContent(element) {
2542
2614
  var _a, _b;
2543
2615
  const assetId = getAssetIdFromElement(element);
2544
- return ((_b = (_a = __classPrivateFieldGet$2(this, _Loader_storageLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId]) === null || _b === void 0 ? void 0 : _b.content) || null;
2616
+ 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;
2545
2617
  }
2546
2618
  getLoadItemMap() {
2547
- return __classPrivateFieldGet$2(this, _Loader_storageLoadItemMap, "f");
2619
+ return __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f");
2548
2620
  }
2549
2621
  setLoadItemMap(itemMap) {
2550
- __classPrivateFieldSet$2(this, _Loader_storageLoadItemMap, itemMap, "f");
2622
+ __classPrivateFieldSet$6(this, _Loader_storageLoadItemMap, itemMap, "f");
2551
2623
  }
2552
2624
  }
2553
2625
  _Loader_loadFuncMap = /* @__PURE__ */ new WeakMap(), _Loader_currentLoadItemMap = /* @__PURE__ */ new WeakMap(), _Loader_storageLoadItemMap = /* @__PURE__ */ new WeakMap(), _Loader_instances = /* @__PURE__ */ new WeakSet(), _Loader_registerLoadFunc = function _Loader_registerLoadFunc2(type, func) {
2554
- __classPrivateFieldGet$2(this, _Loader_loadFuncMap, "f")[type] = func;
2626
+ __classPrivateFieldGet$6(this, _Loader_loadFuncMap, "f")[type] = func;
2555
2627
  }, _Loader_getLoadElementSource = function _Loader_getLoadElementSource2(element) {
2556
2628
  var _a, _b, _c;
2557
2629
  let source = null;
@@ -2571,62 +2643,62 @@ var __privateMethod = (obj, member, method) => {
2571
2643
  error: null,
2572
2644
  startTime: -1,
2573
2645
  endTime: -1,
2574
- source: __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_getLoadElementSource).call(this, element)
2646
+ source: __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_getLoadElementSource).call(this, element)
2575
2647
  };
2576
2648
  }, _Loader_emitLoad = function _Loader_emitLoad2(item) {
2577
2649
  const assetId = getAssetIdFromElement(item.element);
2578
- const storageItem = __classPrivateFieldGet$2(this, _Loader_storageLoadItemMap, "f")[assetId];
2650
+ const storageItem = __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId];
2579
2651
  if (storageItem) {
2580
2652
  if (storageItem.startTime < item.startTime) {
2581
- __classPrivateFieldGet$2(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2653
+ __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2582
2654
  this.trigger("load", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2583
2655
  }
2584
2656
  } else {
2585
- __classPrivateFieldGet$2(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2657
+ __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2586
2658
  this.trigger("load", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2587
2659
  }
2588
2660
  }, _Loader_emitError = function _Loader_emitError2(item) {
2589
2661
  const assetId = getAssetIdFromElement(item.element);
2590
- const storageItem = __classPrivateFieldGet$2(this, _Loader_storageLoadItemMap, "f")[assetId];
2662
+ const storageItem = __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId];
2591
2663
  if (storageItem) {
2592
2664
  if (storageItem.startTime < item.startTime) {
2593
- __classPrivateFieldGet$2(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2665
+ __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2594
2666
  this.trigger("error", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2595
2667
  }
2596
2668
  } else {
2597
- __classPrivateFieldGet$2(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2669
+ __classPrivateFieldGet$6(this, _Loader_storageLoadItemMap, "f")[assetId] = item;
2598
2670
  this.trigger("error", Object.assign(Object.assign({}, item), { countTime: item.endTime - item.startTime }));
2599
2671
  }
2600
2672
  }, _Loader_loadResource = function _Loader_loadResource2(element, assets) {
2601
- const item = __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_createLoadItem).call(this, element);
2673
+ const item = __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_createLoadItem).call(this, element);
2602
2674
  const assetId = getAssetIdFromElement(element);
2603
- __classPrivateFieldGet$2(this, _Loader_currentLoadItemMap, "f")[assetId] = item;
2604
- const loadFunc = __classPrivateFieldGet$2(this, _Loader_loadFuncMap, "f")[element.type];
2675
+ __classPrivateFieldGet$6(this, _Loader_currentLoadItemMap, "f")[assetId] = item;
2676
+ const loadFunc = __classPrivateFieldGet$6(this, _Loader_loadFuncMap, "f")[element.type];
2605
2677
  if (typeof loadFunc === "function") {
2606
2678
  item.startTime = Date.now();
2607
2679
  loadFunc(element, assets).then((result) => {
2608
2680
  item.content = result.content;
2609
2681
  item.endTime = Date.now();
2610
2682
  item.status = "load";
2611
- __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_emitLoad).call(this, item);
2683
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_emitLoad).call(this, item);
2612
2684
  }).catch((err) => {
2613
2685
  console.warn(`Load element source "${item.source}" fail`, err, element);
2614
2686
  item.endTime = Date.now();
2615
2687
  item.status = "error";
2616
2688
  item.error = err;
2617
- __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_emitError).call(this, item);
2689
+ __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_emitError).call(this, item);
2618
2690
  });
2619
2691
  }
2620
2692
  }, _Loader_isExistingErrorStorage = function _Loader_isExistingErrorStorage2(element) {
2621
2693
  var _a;
2622
2694
  const assetId = getAssetIdFromElement(element);
2623
- const existItem = (_a = __classPrivateFieldGet$2(this, _Loader_currentLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId];
2624
- if (existItem && existItem.status === "error" && existItem.source && existItem.source === __classPrivateFieldGet$2(this, _Loader_instances, "m", _Loader_getLoadElementSource).call(this, element)) {
2695
+ const existItem = (_a = __classPrivateFieldGet$6(this, _Loader_currentLoadItemMap, "f")) === null || _a === void 0 ? void 0 : _a[assetId];
2696
+ if (existItem && existItem.status === "error" && existItem.source && existItem.source === __classPrivateFieldGet$6(this, _Loader_instances, "m", _Loader_getLoadElementSource).call(this, element)) {
2625
2697
  return true;
2626
2698
  }
2627
2699
  return false;
2628
2700
  };
2629
- var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
2701
+ var __classPrivateFieldSet$5 = function(receiver, state, value, kind, f) {
2630
2702
  if (kind === "m")
2631
2703
  throw new TypeError("Private method is not writable");
2632
2704
  if (kind === "a" && !f)
@@ -2635,7 +2707,7 @@ var __privateMethod = (obj, member, method) => {
2635
2707
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
2636
2708
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2637
2709
  };
2638
- var __classPrivateFieldGet$1 = function(receiver, state, kind, f) {
2710
+ var __classPrivateFieldGet$5 = function(receiver, state, kind, f) {
2639
2711
  if (kind === "a" && !f)
2640
2712
  throw new TypeError("Private accessor was defined without a getter");
2641
2713
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -2649,16 +2721,21 @@ var __privateMethod = (obj, member, method) => {
2649
2721
  _Renderer_instances.add(this);
2650
2722
  _Renderer_opts.set(this, void 0);
2651
2723
  _Renderer_loader.set(this, new Loader());
2652
- __classPrivateFieldSet$1(this, _Renderer_opts, opts, "f");
2653
- __classPrivateFieldGet$1(this, _Renderer_instances, "m", _Renderer_init).call(this);
2724
+ __classPrivateFieldSet$5(this, _Renderer_opts, opts, "f");
2725
+ __classPrivateFieldGet$5(this, _Renderer_instances, "m", _Renderer_init).call(this);
2726
+ }
2727
+ destroy() {
2728
+ __classPrivateFieldSet$5(this, _Renderer_opts, null, "f");
2729
+ __classPrivateFieldGet$5(this, _Renderer_loader, "f").destroy();
2730
+ __classPrivateFieldSet$5(this, _Renderer_loader, null, "f");
2654
2731
  }
2655
2732
  updateOptions(opts) {
2656
- __classPrivateFieldSet$1(this, _Renderer_opts, opts, "f");
2733
+ __classPrivateFieldSet$5(this, _Renderer_opts, opts, "f");
2657
2734
  }
2658
2735
  drawData(data, opts) {
2659
- const loader = __classPrivateFieldGet$1(this, _Renderer_loader, "f");
2660
- const { calculator } = __classPrivateFieldGet$1(this, _Renderer_opts, "f");
2661
- const viewContext = __classPrivateFieldGet$1(this, _Renderer_opts, "f").viewContext;
2736
+ const loader = __classPrivateFieldGet$5(this, _Renderer_loader, "f");
2737
+ const { calculator } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
2738
+ const viewContext = __classPrivateFieldGet$5(this, _Renderer_opts, "f").viewContext;
2662
2739
  viewContext.clearRect(0, 0, viewContext.canvas.width, viewContext.canvas.height);
2663
2740
  const parentElementSize = {
2664
2741
  x: 0,
@@ -2666,6 +2743,14 @@ var __privateMethod = (obj, member, method) => {
2666
2743
  w: opts.viewSizeInfo.width,
2667
2744
  h: opts.viewSizeInfo.height
2668
2745
  };
2746
+ if (data.underlay) {
2747
+ drawUnderlay(viewContext, data.underlay, Object.assign({
2748
+ loader,
2749
+ calculator,
2750
+ parentElementSize,
2751
+ parentOpacity: 1
2752
+ }, opts));
2753
+ }
2669
2754
  drawElementList(viewContext, data, Object.assign({
2670
2755
  loader,
2671
2756
  calculator,
@@ -2675,7 +2760,7 @@ var __privateMethod = (obj, member, method) => {
2675
2760
  }, opts));
2676
2761
  }
2677
2762
  scale(num) {
2678
- const { sharer } = __classPrivateFieldGet$1(this, _Renderer_opts, "f");
2763
+ const { sharer } = __classPrivateFieldGet$5(this, _Renderer_opts, "f");
2679
2764
  if (!sharer) {
2680
2765
  return;
2681
2766
  }
@@ -2700,23 +2785,47 @@ var __privateMethod = (obj, member, method) => {
2700
2785
  }
2701
2786
  }
2702
2787
  setLoadItemMap(itemMap) {
2703
- __classPrivateFieldGet$1(this, _Renderer_loader, "f").setLoadItemMap(itemMap);
2788
+ __classPrivateFieldGet$5(this, _Renderer_loader, "f").setLoadItemMap(itemMap);
2704
2789
  }
2705
2790
  getLoadItemMap() {
2706
- return __classPrivateFieldGet$1(this, _Renderer_loader, "f").getLoadItemMap();
2791
+ return __classPrivateFieldGet$5(this, _Renderer_loader, "f").getLoadItemMap();
2792
+ }
2793
+ getLoader() {
2794
+ return __classPrivateFieldGet$5(this, _Renderer_loader, "f");
2707
2795
  }
2708
2796
  }
2709
2797
  _Renderer_opts = /* @__PURE__ */ new WeakMap(), _Renderer_loader = /* @__PURE__ */ new WeakMap(), _Renderer_instances = /* @__PURE__ */ new WeakSet(), _Renderer_init = function _Renderer_init2() {
2710
- const loader = __classPrivateFieldGet$1(this, _Renderer_loader, "f");
2798
+ const loader = __classPrivateFieldGet$5(this, _Renderer_loader, "f");
2711
2799
  loader.on("load", (e) => {
2712
2800
  this.trigger("load", e);
2713
2801
  });
2714
2802
  loader.on("error", () => {
2715
2803
  });
2716
2804
  };
2805
+ var __classPrivateFieldSet$4 = function(receiver, state, value, kind, f) {
2806
+ if (kind === "m")
2807
+ throw new TypeError("Private method is not writable");
2808
+ if (kind === "a" && !f)
2809
+ throw new TypeError("Private accessor was defined without a setter");
2810
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2811
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
2812
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2813
+ };
2814
+ var __classPrivateFieldGet$4 = function(receiver, state, kind, f) {
2815
+ if (kind === "a" && !f)
2816
+ throw new TypeError("Private accessor was defined without a getter");
2817
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2818
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
2819
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2820
+ };
2821
+ var _Calculator_opts;
2717
2822
  class Calculator {
2718
2823
  constructor(opts) {
2719
- this._opts = opts;
2824
+ _Calculator_opts.set(this, void 0);
2825
+ __classPrivateFieldSet$4(this, _Calculator_opts, opts, "f");
2826
+ }
2827
+ destroy() {
2828
+ __classPrivateFieldSet$4(this, _Calculator_opts, null, "f");
2720
2829
  }
2721
2830
  elementSize(size, viewScaleInfo, viewSizeInfo) {
2722
2831
  return calcViewElementSize(size, { viewScaleInfo, viewSizeInfo });
@@ -2725,7 +2834,7 @@ var __privateMethod = (obj, member, method) => {
2725
2834
  return isElementInView(elem, { viewScaleInfo, viewSizeInfo });
2726
2835
  }
2727
2836
  isPointInElement(p, elem, viewScaleInfo, viewSizeInfo) {
2728
- const context2d = this._opts.viewContext;
2837
+ const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
2729
2838
  return isViewPointInElement(p, {
2730
2839
  context2d,
2731
2840
  element: elem,
@@ -2734,152 +2843,207 @@ var __privateMethod = (obj, member, method) => {
2734
2843
  });
2735
2844
  }
2736
2845
  getPointElement(p, opts) {
2737
- const context2d = this._opts.viewContext;
2846
+ const context2d = __classPrivateFieldGet$4(this, _Calculator_opts, "f").viewContext;
2738
2847
  return getViewPointAtElement(p, Object.assign(Object.assign({}, opts), { context2d }));
2739
2848
  }
2740
2849
  }
2850
+ _Calculator_opts = /* @__PURE__ */ new WeakMap();
2851
+ var __classPrivateFieldSet$3 = function(receiver, state, value, kind, f) {
2852
+ if (kind === "m")
2853
+ throw new TypeError("Private method is not writable");
2854
+ if (kind === "a" && !f)
2855
+ throw new TypeError("Private accessor was defined without a setter");
2856
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2857
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
2858
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2859
+ };
2860
+ var __classPrivateFieldGet$3 = function(receiver, state, kind, f) {
2861
+ if (kind === "a" && !f)
2862
+ throw new TypeError("Private accessor was defined without a getter");
2863
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2864
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
2865
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2866
+ };
2867
+ var _BoardWatcher_instances, _BoardWatcher_opts, _BoardWatcher_store, _BoardWatcher_init, _BoardWatcher_onWheel, _BoardWatcher_onContextMenu, _BoardWatcher_onClick, _BoardWatcher_onPointLeave, _BoardWatcher_onPointEnd, _BoardWatcher_onPointMove, _BoardWatcher_onPointStart, _BoardWatcher_onHover, _BoardWatcher_isInTarget, _BoardWatcher_getPoint, _BoardWatcher_isVaildPoint;
2741
2868
  function isBoardAvailableNum(num) {
2742
2869
  return num > 0 || num < 0 || num === 0;
2743
2870
  }
2744
2871
  class BoardWatcher extends EventEmitter {
2745
2872
  constructor(opts) {
2746
2873
  super();
2747
- const store = new Store({ defaultStorage: { hasPointDown: false, prevClickPoint: null } });
2748
- this._store = store;
2749
- this._opts = opts;
2750
- this._init();
2751
- }
2752
- _init() {
2753
- const container = window;
2754
- container.addEventListener("mousemove", (e) => {
2755
- if (!this._isInTarget(e)) {
2874
+ _BoardWatcher_instances.add(this);
2875
+ _BoardWatcher_opts.set(this, void 0);
2876
+ _BoardWatcher_store.set(this, void 0);
2877
+ _BoardWatcher_onWheel.set(this, (e) => {
2878
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2756
2879
  return;
2757
2880
  }
2758
- e.preventDefault();
2759
- const point = this._getPoint(e);
2760
- if (!this._isVaildPoint(point)) {
2881
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2882
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2761
2883
  return;
2762
2884
  }
2763
- this.trigger("hover", { point });
2885
+ e.preventDefault();
2886
+ e.stopPropagation();
2887
+ const deltaX = e.deltaX > 0 || e.deltaX < 0 ? e.deltaX : 0;
2888
+ const deltaY = e.deltaY > 0 || e.deltaY < 0 ? e.deltaY : 0;
2889
+ if (e.ctrlKey === true && this.has("wheelScale")) {
2890
+ this.trigger("wheelScale", { deltaX, deltaY, point });
2891
+ } else if (this.has("wheel")) {
2892
+ this.trigger("wheel", { deltaX, deltaY, point });
2893
+ }
2764
2894
  });
2765
- container.addEventListener("mousedown", (e) => {
2766
- if (!this._isInTarget(e)) {
2895
+ _BoardWatcher_onContextMenu.set(this, (e) => {
2896
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2767
2897
  return;
2768
2898
  }
2769
2899
  e.preventDefault();
2770
- const point = this._getPoint(e);
2771
- if (!this._isVaildPoint(point)) {
2900
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2901
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2772
2902
  return;
2773
2903
  }
2774
- this._store.set("hasPointDown", true);
2775
- this.trigger("pointStart", { point });
2776
2904
  });
2777
- container.addEventListener("mousemove", (e) => {
2778
- if (!this._isInTarget(e)) {
2905
+ _BoardWatcher_onClick.set(this, (e) => {
2906
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2779
2907
  return;
2780
2908
  }
2781
2909
  e.preventDefault();
2782
- e.stopPropagation();
2783
- const point = this._getPoint(e);
2784
- if (!this._isVaildPoint(point)) {
2785
- if (this._store.get("hasPointDown")) {
2786
- this.trigger("pointLeave", { point });
2787
- this._store.set("hasPointDown", false);
2788
- }
2910
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2911
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2789
2912
  return;
2790
2913
  }
2791
- if (this._store.get("hasPointDown") !== true) {
2792
- return;
2914
+ const maxLimitTime = 500;
2915
+ const t = Date.now();
2916
+ const preClickPoint = __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("prevClickPoint");
2917
+ if (preClickPoint && t - preClickPoint.t <= maxLimitTime && Math.abs(preClickPoint.x - point.x) <= 5 && Math.abs(preClickPoint.y - point.y) <= 5) {
2918
+ this.trigger("doubleClick", { point });
2919
+ } else {
2920
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("prevClickPoint", point);
2793
2921
  }
2794
- this.trigger("pointMove", { point });
2795
2922
  });
2796
- container.addEventListener("mouseup", (e) => {
2797
- this._store.set("hasPointDown", false);
2798
- if (!this._isInTarget(e)) {
2923
+ _BoardWatcher_onPointLeave.set(this, (e) => {
2924
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
2925
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2799
2926
  return;
2800
2927
  }
2801
2928
  e.preventDefault();
2802
- const point = this._getPoint(e);
2803
- this.trigger("pointEnd", { point });
2929
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2930
+ this.trigger("pointLeave", { point });
2804
2931
  });
2805
- container.addEventListener("mouseleave", (e) => {
2806
- this._store.set("hasPointDown", false);
2807
- if (!this._isInTarget(e)) {
2932
+ _BoardWatcher_onPointEnd.set(this, (e) => {
2933
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
2934
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2808
2935
  return;
2809
2936
  }
2810
2937
  e.preventDefault();
2811
- const point = this._getPoint(e);
2812
- this.trigger("pointLeave", { point });
2938
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2939
+ this.trigger("pointEnd", { point });
2813
2940
  });
2814
- container.addEventListener("wheel", (e) => {
2815
- if (!this._isInTarget(e)) {
2816
- return;
2817
- }
2818
- const point = this._getPoint(e);
2819
- if (!this._isVaildPoint(point)) {
2941
+ _BoardWatcher_onPointMove.set(this, (e) => {
2942
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2820
2943
  return;
2821
2944
  }
2822
2945
  e.preventDefault();
2823
2946
  e.stopPropagation();
2824
- const deltaX = e.deltaX > 0 || e.deltaX < 0 ? e.deltaX : 0;
2825
- const deltaY = e.deltaY > 0 || e.deltaY < 0 ? e.deltaY : 0;
2826
- if (e.ctrlKey === true && this.has("wheelScale")) {
2827
- this.trigger("wheelScale", { deltaX, deltaY, point });
2828
- } else if (this.has("wheel")) {
2829
- this.trigger("wheel", { deltaX, deltaY, point });
2947
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2948
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2949
+ if (__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("hasPointDown")) {
2950
+ this.trigger("pointLeave", { point });
2951
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", false);
2952
+ }
2953
+ return;
2830
2954
  }
2831
- }, { passive: false });
2832
- container.addEventListener("click", (e) => {
2833
- if (!this._isInTarget(e)) {
2955
+ if (__classPrivateFieldGet$3(this, _BoardWatcher_store, "f").get("hasPointDown") !== true) {
2834
2956
  return;
2835
2957
  }
2836
- e.preventDefault();
2837
- const point = this._getPoint(e);
2838
- if (!this._isVaildPoint(point)) {
2958
+ this.trigger("pointMove", { point });
2959
+ });
2960
+ _BoardWatcher_onPointStart.set(this, (e) => {
2961
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2839
2962
  return;
2840
2963
  }
2841
- const maxLimitTime = 500;
2842
- const t = Date.now();
2843
- const preClickPoint = this._store.get("prevClickPoint");
2844
- if (preClickPoint && t - preClickPoint.t <= maxLimitTime && Math.abs(preClickPoint.x - point.x) <= 5 && Math.abs(preClickPoint.y - point.y) <= 5) {
2845
- this.trigger("doubleClick", { point });
2846
- } else {
2847
- this._store.set("prevClickPoint", point);
2964
+ e.preventDefault();
2965
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2966
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2967
+ return;
2848
2968
  }
2969
+ __classPrivateFieldGet$3(this, _BoardWatcher_store, "f").set("hasPointDown", true);
2970
+ this.trigger("pointStart", { point });
2849
2971
  });
2850
- container.addEventListener("contextmenu", (e) => {
2851
- if (!this._isInTarget(e)) {
2972
+ _BoardWatcher_onHover.set(this, (e) => {
2973
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isInTarget).call(this, e)) {
2852
2974
  return;
2853
2975
  }
2854
2976
  e.preventDefault();
2855
- const point = this._getPoint(e);
2856
- if (!this._isVaildPoint(point)) {
2977
+ const point = __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_getPoint).call(this, e);
2978
+ if (!__classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_isVaildPoint).call(this, point)) {
2857
2979
  return;
2858
2980
  }
2981
+ this.trigger("hover", { point });
2859
2982
  });
2983
+ const store = new Store({ defaultStorage: { hasPointDown: false, prevClickPoint: null } });
2984
+ __classPrivateFieldSet$3(this, _BoardWatcher_store, store, "f");
2985
+ __classPrivateFieldSet$3(this, _BoardWatcher_opts, opts, "f");
2986
+ __classPrivateFieldGet$3(this, _BoardWatcher_instances, "m", _BoardWatcher_init).call(this);
2860
2987
  }
2861
- _isInTarget(e) {
2862
- return e.target === this._opts.boardContent.boardContext.canvas;
2863
- }
2864
- _getPoint(e) {
2865
- const boardCanvas = this._opts.boardContent.boardContext.canvas;
2866
- const rect = boardCanvas.getBoundingClientRect();
2867
- const p = {
2868
- x: e.clientX - rect.left,
2869
- y: e.clientY - rect.top,
2870
- t: Date.now()
2871
- };
2872
- return p;
2873
- }
2874
- _isVaildPoint(p) {
2875
- const viewSize = this._opts.sharer.getActiveViewSizeInfo();
2876
- const { width, height } = viewSize;
2877
- if (isBoardAvailableNum(p.x) && isBoardAvailableNum(p.y) && p.x <= width && p.y <= height) {
2878
- return true;
2879
- }
2880
- return false;
2988
+ destroy() {
2989
+ const container = window;
2990
+ container.removeEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onHover, "f"));
2991
+ container.removeEventListener("mousedown", __classPrivateFieldGet$3(this, _BoardWatcher_onPointStart, "f"));
2992
+ container.removeEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onPointMove, "f"));
2993
+ container.removeEventListener("mouseup", __classPrivateFieldGet$3(this, _BoardWatcher_onPointEnd, "f"));
2994
+ container.removeEventListener("mouseleave", __classPrivateFieldGet$3(this, _BoardWatcher_onPointLeave, "f"));
2995
+ container.removeEventListener("wheel", __classPrivateFieldGet$3(this, _BoardWatcher_onWheel, "f"));
2996
+ container.removeEventListener("click", __classPrivateFieldGet$3(this, _BoardWatcher_onClick, "f"));
2997
+ container.removeEventListener("contextmenu", __classPrivateFieldGet$3(this, _BoardWatcher_onContextMenu, "f"));
2998
+ this.destroy();
2999
+ }
3000
+ }
3001
+ _BoardWatcher_opts = /* @__PURE__ */ new WeakMap(), _BoardWatcher_store = /* @__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() {
3002
+ const container = window;
3003
+ container.addEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onHover, "f"));
3004
+ container.addEventListener("mousedown", __classPrivateFieldGet$3(this, _BoardWatcher_onPointStart, "f"));
3005
+ container.addEventListener("mousemove", __classPrivateFieldGet$3(this, _BoardWatcher_onPointMove, "f"));
3006
+ container.addEventListener("mouseup", __classPrivateFieldGet$3(this, _BoardWatcher_onPointEnd, "f"));
3007
+ container.addEventListener("mouseleave", __classPrivateFieldGet$3(this, _BoardWatcher_onPointLeave, "f"));
3008
+ container.addEventListener("wheel", __classPrivateFieldGet$3(this, _BoardWatcher_onWheel, "f"), { passive: false });
3009
+ container.addEventListener("click", __classPrivateFieldGet$3(this, _BoardWatcher_onClick, "f"));
3010
+ container.addEventListener("contextmenu", __classPrivateFieldGet$3(this, _BoardWatcher_onContextMenu, "f"));
3011
+ }, _BoardWatcher_isInTarget = function _BoardWatcher_isInTarget2(e) {
3012
+ return e.target === __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").boardContent.boardContext.canvas;
3013
+ }, _BoardWatcher_getPoint = function _BoardWatcher_getPoint2(e) {
3014
+ const boardCanvas = __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").boardContent.boardContext.canvas;
3015
+ const rect = boardCanvas.getBoundingClientRect();
3016
+ const p = {
3017
+ x: e.clientX - rect.left,
3018
+ y: e.clientY - rect.top,
3019
+ t: Date.now()
3020
+ };
3021
+ return p;
3022
+ }, _BoardWatcher_isVaildPoint = function _BoardWatcher_isVaildPoint2(p) {
3023
+ const viewSize = __classPrivateFieldGet$3(this, _BoardWatcher_opts, "f").sharer.getActiveViewSizeInfo();
3024
+ const { width, height } = viewSize;
3025
+ if (isBoardAvailableNum(p.x) && isBoardAvailableNum(p.y) && p.x <= width && p.y <= height) {
3026
+ return true;
2881
3027
  }
2882
- }
3028
+ return false;
3029
+ };
3030
+ var __classPrivateFieldSet$2 = function(receiver, state, value, kind, f) {
3031
+ if (kind === "m")
3032
+ throw new TypeError("Private method is not writable");
3033
+ if (kind === "a" && !f)
3034
+ throw new TypeError("Private accessor was defined without a setter");
3035
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3036
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
3037
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3038
+ };
3039
+ var __classPrivateFieldGet$2 = function(receiver, state, kind, f) {
3040
+ if (kind === "a" && !f)
3041
+ throw new TypeError("Private accessor was defined without a getter");
3042
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3043
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
3044
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3045
+ };
3046
+ var _Sharer_activeStore, _Sharer_sharedStore;
2883
3047
  const defaultActiveStorage = {
2884
3048
  width: 0,
2885
3049
  height: 0,
@@ -2895,139 +3059,113 @@ var __privateMethod = (obj, member, method) => {
2895
3059
  };
2896
3060
  class Sharer {
2897
3061
  constructor() {
3062
+ _Sharer_activeStore.set(this, void 0);
3063
+ _Sharer_sharedStore.set(this, void 0);
2898
3064
  const activeStore = new Store({
2899
3065
  defaultStorage: defaultActiveStorage
2900
3066
  });
2901
3067
  const sharedStore = new Store({
2902
3068
  defaultStorage: {}
2903
3069
  });
2904
- this._activeStore = activeStore;
2905
- this._sharedStore = sharedStore;
3070
+ __classPrivateFieldSet$2(this, _Sharer_activeStore, activeStore, "f");
3071
+ __classPrivateFieldSet$2(this, _Sharer_sharedStore, sharedStore, "f");
2906
3072
  }
2907
3073
  getActiveStorage(key2) {
2908
- return this._activeStore.get(key2);
3074
+ return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get(key2);
2909
3075
  }
2910
3076
  setActiveStorage(key2, storage) {
2911
- return this._activeStore.set(key2, storage);
3077
+ return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set(key2, storage);
2912
3078
  }
2913
3079
  getActiveStoreSnapshot() {
2914
- return this._activeStore.getSnapshot();
3080
+ return __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").getSnapshot();
2915
3081
  }
2916
3082
  getSharedStorage(key2) {
2917
- return this._sharedStore.get(key2);
3083
+ return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").get(key2);
2918
3084
  }
2919
3085
  setSharedStorage(key2, storage) {
2920
- return this._sharedStore.set(key2, storage);
3086
+ return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").set(key2, storage);
2921
3087
  }
2922
3088
  getSharedStoreSnapshot() {
2923
- return this._sharedStore.getSnapshot();
3089
+ return __classPrivateFieldGet$2(this, _Sharer_sharedStore, "f").getSnapshot();
2924
3090
  }
2925
3091
  getActiveViewScaleInfo() {
2926
3092
  const viewScaleInfo = {
2927
- scale: this._activeStore.get("scale"),
2928
- offsetTop: this._activeStore.get("offsetTop"),
2929
- offsetBottom: this._activeStore.get("offsetBottom"),
2930
- offsetLeft: this._activeStore.get("offsetLeft"),
2931
- offsetRight: this._activeStore.get("offsetRight")
3093
+ scale: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("scale"),
3094
+ offsetTop: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetTop"),
3095
+ offsetBottom: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetBottom"),
3096
+ offsetLeft: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetLeft"),
3097
+ offsetRight: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("offsetRight")
2932
3098
  };
2933
3099
  return viewScaleInfo;
2934
3100
  }
2935
3101
  setActiveViewScaleInfo(viewScaleInfo) {
2936
3102
  const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight } = viewScaleInfo;
2937
- this._activeStore.set("scale", scale);
2938
- this._activeStore.set("offsetTop", offsetTop);
2939
- this._activeStore.set("offsetBottom", offsetBottom);
2940
- this._activeStore.set("offsetLeft", offsetLeft);
2941
- this._activeStore.set("offsetRight", offsetRight);
3103
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("scale", scale);
3104
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetTop", offsetTop);
3105
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetBottom", offsetBottom);
3106
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetLeft", offsetLeft);
3107
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("offsetRight", offsetRight);
2942
3108
  }
2943
3109
  setActiveViewSizeInfo(size) {
2944
- this._activeStore.set("width", size.width);
2945
- this._activeStore.set("height", size.height);
2946
- this._activeStore.set("devicePixelRatio", size.devicePixelRatio);
2947
- this._activeStore.set("contextWidth", size.contextWidth);
2948
- this._activeStore.set("contextHeight", size.contextHeight);
3110
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("width", size.width);
3111
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("height", size.height);
3112
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("devicePixelRatio", size.devicePixelRatio);
3113
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("contextWidth", size.contextWidth);
3114
+ __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").set("contextHeight", size.contextHeight);
2949
3115
  }
2950
3116
  getActiveViewSizeInfo() {
2951
3117
  const sizeInfo = {
2952
- width: this._activeStore.get("width"),
2953
- height: this._activeStore.get("height"),
2954
- devicePixelRatio: this._activeStore.get("devicePixelRatio"),
2955
- contextWidth: this._activeStore.get("contextWidth"),
2956
- contextHeight: this._activeStore.get("contextHeight")
3118
+ width: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("width"),
3119
+ height: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("height"),
3120
+ devicePixelRatio: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("devicePixelRatio"),
3121
+ contextWidth: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("contextWidth"),
3122
+ contextHeight: __classPrivateFieldGet$2(this, _Sharer_activeStore, "f").get("contextHeight")
2957
3123
  };
2958
3124
  return sizeInfo;
2959
3125
  }
2960
3126
  }
3127
+ _Sharer_activeStore = /* @__PURE__ */ new WeakMap(), _Sharer_sharedStore = /* @__PURE__ */ new WeakMap();
3128
+ var __classPrivateFieldSet$1 = function(receiver, state, value, kind, f) {
3129
+ if (kind === "m")
3130
+ throw new TypeError("Private method is not writable");
3131
+ if (kind === "a" && !f)
3132
+ throw new TypeError("Private accessor was defined without a setter");
3133
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3134
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
3135
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3136
+ };
3137
+ var __classPrivateFieldGet$1 = function(receiver, state, kind, f) {
3138
+ if (kind === "a" && !f)
3139
+ throw new TypeError("Private accessor was defined without a getter");
3140
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3141
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
3142
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3143
+ };
3144
+ var _Viewer_instances, _Viewer_opts, _Viewer_drawFrameSnapshotQueue, _Viewer_drawFrameStatus, _Viewer_init, _Viewer_drawAnimationFrame;
2961
3145
  const { requestAnimationFrame } = window;
2962
3146
  class Viewer extends EventEmitter {
2963
3147
  constructor(opts) {
2964
3148
  super();
2965
- this._drawFrameSnapshotQueue = [];
2966
- this._drawFrameStatus = "FREE";
2967
- this._opts = opts;
2968
- this._init();
2969
- }
2970
- _init() {
2971
- const { renderer } = this._opts;
2972
- renderer.on("load", () => {
2973
- this.drawFrame();
2974
- });
2975
- }
2976
- _drawAnimationFrame() {
2977
- if (this._drawFrameStatus === "DRAWING" || this._drawFrameSnapshotQueue.length === 0) {
2978
- return;
2979
- } else {
2980
- this._drawFrameStatus = "DRAWING";
2981
- }
2982
- const snapshot = this._drawFrameSnapshotQueue.shift();
2983
- const { renderer, boardContent, beforeDrawFrame, afterDrawFrame } = this._opts;
2984
- if (snapshot) {
2985
- const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = snapshot.activeStore;
2986
- if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.activeStore.data) {
2987
- renderer.drawData(snapshot.activeStore.data, {
2988
- viewScaleInfo: {
2989
- scale,
2990
- offsetTop,
2991
- offsetBottom,
2992
- offsetLeft,
2993
- offsetRight
2994
- },
2995
- viewSizeInfo: {
2996
- width,
2997
- height,
2998
- contextHeight,
2999
- contextWidth,
3000
- devicePixelRatio
3001
- }
3002
- });
3003
- }
3004
- beforeDrawFrame({ snapshot });
3005
- boardContent.drawView();
3006
- afterDrawFrame({ snapshot });
3007
- }
3008
- if (this._drawFrameSnapshotQueue.length === 0) {
3009
- this._drawFrameStatus = "COMPLETE";
3010
- return;
3011
- }
3012
- if (this._drawFrameStatus = "DRAWING") {
3013
- requestAnimationFrame(() => {
3014
- this._drawAnimationFrame();
3015
- });
3016
- }
3149
+ _Viewer_instances.add(this);
3150
+ _Viewer_opts.set(this, void 0);
3151
+ _Viewer_drawFrameSnapshotQueue.set(this, []);
3152
+ _Viewer_drawFrameStatus.set(this, "FREE");
3153
+ __classPrivateFieldSet$1(this, _Viewer_opts, opts, "f");
3154
+ __classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_init).call(this);
3017
3155
  }
3018
3156
  drawFrame() {
3019
- const { sharer } = this._opts;
3157
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3020
3158
  const activeStore = sharer.getActiveStoreSnapshot();
3021
3159
  const sharedStore = sharer.getSharedStoreSnapshot();
3022
- this._drawFrameSnapshotQueue.push({
3160
+ __classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").push({
3023
3161
  activeStore,
3024
3162
  sharedStore
3025
3163
  });
3026
- this._drawAnimationFrame();
3164
+ __classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_drawAnimationFrame).call(this);
3027
3165
  }
3028
3166
  scale(opts) {
3029
3167
  const { scale, point } = opts;
3030
- const { sharer } = this._opts;
3168
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3031
3169
  const { moveX, moveY } = viewScale({
3032
3170
  scale,
3033
3171
  point,
@@ -3038,7 +3176,7 @@ var __privateMethod = (obj, member, method) => {
3038
3176
  return { moveX, moveY };
3039
3177
  }
3040
3178
  scroll(opts) {
3041
- const { sharer } = this._opts;
3179
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3042
3180
  const prevViewScaleInfo = sharer.getActiveViewScaleInfo();
3043
3181
  const { moveX, moveY } = opts;
3044
3182
  const viewSizeInfo = sharer.getActiveViewSizeInfo();
@@ -3052,7 +3190,7 @@ var __privateMethod = (obj, member, method) => {
3052
3190
  return viewScaleInfo;
3053
3191
  }
3054
3192
  updateViewScaleInfo(opts) {
3055
- const { sharer } = this._opts;
3193
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3056
3194
  const viewScaleInfo = calcViewScaleInfo(opts, {
3057
3195
  viewSizeInfo: sharer.getActiveViewSizeInfo()
3058
3196
  });
@@ -3060,11 +3198,11 @@ var __privateMethod = (obj, member, method) => {
3060
3198
  return viewScaleInfo;
3061
3199
  }
3062
3200
  resize(viewSize = {}) {
3063
- const { sharer } = this._opts;
3201
+ const { sharer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3064
3202
  const originViewSize = sharer.getActiveViewSizeInfo();
3065
3203
  const newViewSize = Object.assign(Object.assign({}, originViewSize), viewSize);
3066
3204
  const { width, height, devicePixelRatio } = newViewSize;
3067
- const { underContext, boardContext, helperContext, viewContext } = this._opts.boardContent;
3205
+ const { underContext, boardContext, helperContext, viewContext } = __classPrivateFieldGet$1(this, _Viewer_opts, "f").boardContent;
3068
3206
  boardContext.canvas.width = width * devicePixelRatio;
3069
3207
  boardContext.canvas.height = height * devicePixelRatio;
3070
3208
  boardContext.canvas.style.width = `${width}px`;
@@ -3079,6 +3217,55 @@ var __privateMethod = (obj, member, method) => {
3079
3217
  return newViewSize;
3080
3218
  }
3081
3219
  }
3220
+ _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() {
3221
+ const { renderer } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3222
+ renderer.on("load", () => {
3223
+ this.drawFrame();
3224
+ });
3225
+ }, _Viewer_drawAnimationFrame = function _Viewer_drawAnimationFrame2() {
3226
+ if (__classPrivateFieldGet$1(this, _Viewer_drawFrameStatus, "f") === "DRAWING" || __classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").length === 0) {
3227
+ return;
3228
+ } else {
3229
+ __classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "DRAWING", "f");
3230
+ }
3231
+ const snapshot = __classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").shift();
3232
+ const { renderer, boardContent, beforeDrawFrame, afterDrawFrame } = __classPrivateFieldGet$1(this, _Viewer_opts, "f");
3233
+ if (snapshot) {
3234
+ const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = snapshot.activeStore;
3235
+ const viewScaleInfo = {
3236
+ scale,
3237
+ offsetTop,
3238
+ offsetBottom,
3239
+ offsetLeft,
3240
+ offsetRight
3241
+ };
3242
+ const viewSizeInfo = {
3243
+ width,
3244
+ height,
3245
+ contextHeight,
3246
+ contextWidth,
3247
+ devicePixelRatio
3248
+ };
3249
+ if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.activeStore.data) {
3250
+ renderer.drawData(snapshot.activeStore.data, {
3251
+ viewScaleInfo,
3252
+ viewSizeInfo
3253
+ });
3254
+ }
3255
+ beforeDrawFrame({ snapshot });
3256
+ boardContent.drawView();
3257
+ afterDrawFrame({ snapshot });
3258
+ }
3259
+ if (__classPrivateFieldGet$1(this, _Viewer_drawFrameSnapshotQueue, "f").length === 0) {
3260
+ __classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "COMPLETE", "f");
3261
+ return;
3262
+ }
3263
+ if (__classPrivateFieldSet$1(this, _Viewer_drawFrameStatus, "DRAWING", "f")) {
3264
+ requestAnimationFrame(() => {
3265
+ __classPrivateFieldGet$1(this, _Viewer_instances, "m", _Viewer_drawAnimationFrame2).call(this);
3266
+ });
3267
+ }
3268
+ };
3082
3269
  var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
3083
3270
  if (kind === "m")
3084
3271
  throw new TypeError("Private method is not writable");
@@ -3142,6 +3329,12 @@ var __privateMethod = (obj, member, method) => {
3142
3329
  __classPrivateFieldGet(this, _Board_instances, "m", _Board_init).call(this);
3143
3330
  __classPrivateFieldGet(this, _Board_instances, "m", _Board_resetActiveMiddlewareObjs).call(this);
3144
3331
  }
3332
+ destroy() {
3333
+ __classPrivateFieldGet(this, _Board_watcher, "f").destroy();
3334
+ __classPrivateFieldGet(this, _Board_renderer, "f").destroy();
3335
+ __classPrivateFieldGet(this, _Board_calculator, "f").destroy();
3336
+ __classPrivateFieldGet(this, _Board_eventHub, "f").destroy();
3337
+ }
3145
3338
  getSharer() {
3146
3339
  return __classPrivateFieldGet(this, _Board_sharer, "f");
3147
3340
  }
@@ -4484,6 +4677,7 @@ var __privateMethod = (obj, member, method) => {
4484
4677
  showTextArea(e);
4485
4678
  };
4486
4679
  return {
4680
+ name: "@middleware/text-editor",
4487
4681
  use() {
4488
4682
  eventHub.on(middlewareEventTextEdit, textEditCallback);
4489
4683
  },
@@ -4604,6 +4798,7 @@ var __privateMethod = (obj, member, method) => {
4604
4798
  viewer.drawFrame();
4605
4799
  };
4606
4800
  return {
4801
+ name: "@middleware/selector",
4607
4802
  use() {
4608
4803
  eventHub.on(middlewareEventSelect, selectCallback);
4609
4804
  eventHub.on(middlewareEventSelectClear, selectClearCallback);
@@ -5199,6 +5394,7 @@ var __privateMethod = (obj, member, method) => {
5199
5394
  });
5200
5395
  };
5201
5396
  return {
5397
+ name: "@middleware/scroller",
5202
5398
  wheel: (e) => {
5203
5399
  viewer.scroll({
5204
5400
  moveX: 0 - e.deltaX,
@@ -5251,6 +5447,7 @@ var __privateMethod = (obj, member, method) => {
5251
5447
  const maxScale = 50;
5252
5448
  const minScale = 0.05;
5253
5449
  return {
5450
+ name: "@middleware/scaler",
5254
5451
  wheelScale(e) {
5255
5452
  const { deltaY, point } = e;
5256
5453
  const { scale } = sharer.getActiveViewScaleInfo();
@@ -5473,6 +5670,7 @@ var __privateMethod = (obj, member, method) => {
5473
5670
  }
5474
5671
  };
5475
5672
  return {
5673
+ name: "@middleware/ruler",
5476
5674
  use() {
5477
5675
  eventHub.on(middlewareEventRuler, rulerCallback);
5478
5676
  },
@@ -5506,6 +5704,7 @@ var __privateMethod = (obj, member, method) => {
5506
5704
  const { eventHub, sharer, viewer } = opts;
5507
5705
  let isDragging = false;
5508
5706
  return {
5707
+ name: "@middleware/dragger",
5509
5708
  hover() {
5510
5709
  if (isDragging === true) {
5511
5710
  return;
@@ -5571,6 +5770,9 @@ var __privateMethod = (obj, member, method) => {
5571
5770
  eventHub
5572
5771
  });
5573
5772
  }
5773
+ destroy() {
5774
+ __privateGet(this, _board).destroy();
5775
+ }
5574
5776
  use(middleware) {
5575
5777
  __privateGet(this, _board).use(middleware);
5576
5778
  }