@idraw/core 0.4.0-alpha.5 → 0.4.0-alpha.7

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,21 +358,38 @@ var __privateMethod = (obj, member, method) => {
358
358
  fontWeight: fontWeight$1,
359
359
  strokeWidth
360
360
  };
361
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
362
+ if (kind === "m")
363
+ throw new TypeError("Private method is not writable");
364
+ if (kind === "a" && !f)
365
+ throw new TypeError("Private accessor was defined without a setter");
366
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
367
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
368
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
369
+ };
370
+ var __classPrivateFieldGet = function(receiver, state, kind, f) {
371
+ if (kind === "a" && !f)
372
+ throw new TypeError("Private accessor was defined without a getter");
373
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
374
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
375
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
376
+ };
377
+ var _Context2D_ctx, _Context2D_opts;
361
378
  class Context2D {
362
379
  constructor(ctx, opts) {
363
- this._devicePixelRatio = 1;
364
- const { devicePixelRatio = 1 } = opts;
365
- this._ctx = ctx;
366
- this._devicePixelRatio = devicePixelRatio;
380
+ _Context2D_ctx.set(this, void 0);
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");
367
384
  }
368
385
  $undoPixelRatio(num) {
369
- return num / this._devicePixelRatio;
386
+ return num / __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio;
370
387
  }
371
388
  $doPixelRatio(num) {
372
- return this._devicePixelRatio * num;
389
+ return __classPrivateFieldGet(this, _Context2D_opts, "f").devicePixelRatio * num;
373
390
  }
374
391
  $getContext() {
375
- return this._ctx;
392
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f");
376
393
  }
377
394
  $setFont(opts) {
378
395
  const strList = [];
@@ -381,135 +398,153 @@ var __privateMethod = (obj, member, method) => {
381
398
  }
382
399
  strList.push(`${this.$doPixelRatio(opts.fontSize || 12)}px`);
383
400
  strList.push(`${opts.fontFamily || "sans-serif"}`);
384
- this._ctx.font = `${strList.join(" ")}`;
401
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").font = `${strList.join(" ")}`;
402
+ }
403
+ $getOffscreenCanvas() {
404
+ return __classPrivateFieldGet(this, _Context2D_opts, "f").offscreenCanvas;
385
405
  }
386
406
  $resize(opts) {
387
- const { width, height, devicePixelRatio } = opts;
388
- const { canvas } = this._ctx;
407
+ const { width, height, devicePixelRatio, resetStyle } = opts;
408
+ const { canvas } = __classPrivateFieldGet(this, _Context2D_ctx, "f");
389
409
  canvas.width = width * devicePixelRatio;
390
410
  canvas.height = height * devicePixelRatio;
391
- this._devicePixelRatio = devicePixelRatio;
411
+ __classPrivateFieldSet(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Context2D_opts, "f")), {
412
+ devicePixelRatio
413
+ }), "f");
414
+ if (resetStyle === true) {
415
+ canvas.style.width = `${width}px`;
416
+ canvas.style.height = `${height}px`;
417
+ }
418
+ }
419
+ $getSize() {
420
+ const { devicePixelRatio } = __classPrivateFieldGet(this, _Context2D_opts, "f");
421
+ const { width, height } = __classPrivateFieldGet(this, _Context2D_ctx, "f").canvas;
422
+ return {
423
+ width: width / devicePixelRatio,
424
+ height: height / devicePixelRatio,
425
+ devicePixelRatio
426
+ };
392
427
  }
393
428
  get canvas() {
394
- return this._ctx.canvas;
429
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").canvas;
395
430
  }
396
431
  get fillStyle() {
397
- return this._ctx.fillStyle;
432
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillStyle;
398
433
  }
399
434
  set fillStyle(value) {
400
- this._ctx.fillStyle = value;
435
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").fillStyle = value;
401
436
  }
402
437
  get strokeStyle() {
403
- return this._ctx.strokeStyle;
438
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeStyle;
404
439
  }
405
440
  set strokeStyle(color2) {
406
- this._ctx.strokeStyle = color2;
441
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeStyle = color2;
407
442
  }
408
443
  get lineWidth() {
409
- return this.$undoPixelRatio(this._ctx.lineWidth);
444
+ return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").lineWidth);
410
445
  }
411
446
  set lineWidth(w2) {
412
- this._ctx.lineWidth = this.$doPixelRatio(w2);
447
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").lineWidth = this.$doPixelRatio(w2);
413
448
  }
414
449
  get textAlign() {
415
- return this._ctx.textAlign;
450
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").textAlign;
416
451
  }
417
452
  set textAlign(align) {
418
- this._ctx.textAlign = align;
453
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").textAlign = align;
419
454
  }
420
455
  get textBaseline() {
421
- return this._ctx.textBaseline;
456
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").textBaseline;
422
457
  }
423
458
  set textBaseline(baseline) {
424
- this._ctx.textBaseline = baseline;
459
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").textBaseline = baseline;
425
460
  }
426
461
  get globalAlpha() {
427
- return this._ctx.globalAlpha;
462
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalAlpha;
428
463
  }
429
464
  set globalAlpha(alpha) {
430
- this._ctx.globalAlpha = alpha;
465
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").globalAlpha = alpha;
431
466
  }
432
467
  get shadowColor() {
433
- return this._ctx.shadowColor;
468
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowColor;
434
469
  }
435
470
  set shadowColor(color2) {
436
- this._ctx.shadowColor = color2;
471
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowColor = color2;
437
472
  }
438
473
  get shadowOffsetX() {
439
- return this.$undoPixelRatio(this._ctx.shadowOffsetX);
474
+ return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetX);
440
475
  }
441
476
  set shadowOffsetX(offsetX) {
442
- this._ctx.shadowOffsetX = this.$doPixelRatio(offsetX);
477
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetX = this.$doPixelRatio(offsetX);
443
478
  }
444
479
  get shadowOffsetY() {
445
- return this.$undoPixelRatio(this._ctx.shadowOffsetY);
480
+ return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetY);
446
481
  }
447
482
  set shadowOffsetY(offsetY) {
448
- this._ctx.shadowOffsetY = this.$doPixelRatio(offsetY);
483
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowOffsetY = this.$doPixelRatio(offsetY);
449
484
  }
450
485
  get shadowBlur() {
451
- return this.$undoPixelRatio(this._ctx.shadowBlur);
486
+ return this.$undoPixelRatio(__classPrivateFieldGet(this, _Context2D_ctx, "f").shadowBlur);
452
487
  }
453
488
  set shadowBlur(blur) {
454
- this._ctx.shadowBlur = this.$doPixelRatio(blur);
489
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").shadowBlur = this.$doPixelRatio(blur);
455
490
  }
456
491
  get lineCap() {
457
- return this._ctx.lineCap;
492
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap;
458
493
  }
459
494
  set lineCap(lineCap) {
460
- this._ctx.lineCap = lineCap;
495
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap = lineCap;
461
496
  }
462
497
  get globalCompositeOperation() {
463
- return this._ctx.globalCompositeOperation;
498
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation;
464
499
  }
465
500
  set globalCompositeOperation(operations) {
466
- this._ctx.globalCompositeOperation = operations;
501
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
467
502
  }
468
503
  fill(...args) {
469
- return this._ctx.fill(...args);
504
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").fill(...args);
470
505
  }
471
506
  arc(x2, y2, radius, startAngle, endAngle, anticlockwise) {
472
- return this._ctx.arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
507
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
473
508
  }
474
509
  rect(x2, y2, w2, h2) {
475
- return this._ctx.rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
510
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").rect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
476
511
  }
477
512
  fillRect(x2, y2, w2, h2) {
478
- return this._ctx.fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
513
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
479
514
  }
480
515
  clearRect(x2, y2, w2, h2) {
481
- return this._ctx.clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
516
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").clearRect(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(w2), this.$doPixelRatio(h2));
482
517
  }
483
518
  beginPath() {
484
- return this._ctx.beginPath();
519
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").beginPath();
485
520
  }
486
521
  closePath() {
487
- return this._ctx.closePath();
522
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").closePath();
488
523
  }
489
524
  lineTo(x2, y2) {
490
- return this._ctx.lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
525
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
491
526
  }
492
527
  moveTo(x2, y2) {
493
- return this._ctx.moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
528
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").moveTo(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
494
529
  }
495
530
  arcTo(x1, y1, x2, y2, radius) {
496
- return this._ctx.arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
531
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").arcTo(this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radius));
497
532
  }
498
533
  getLineDash() {
499
- return this._ctx.getLineDash();
534
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").getLineDash();
500
535
  }
501
536
  setLineDash(nums) {
502
537
  const dash = nums.map((n) => this.$doPixelRatio(n));
503
- return this._ctx.setLineDash(dash);
538
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").setLineDash(dash);
504
539
  }
505
540
  stroke(path) {
506
- return path ? this._ctx.stroke(path) : this._ctx.stroke();
541
+ return path ? __classPrivateFieldGet(this, _Context2D_ctx, "f").stroke(path) : __classPrivateFieldGet(this, _Context2D_ctx, "f").stroke();
507
542
  }
508
543
  translate(x2, y2) {
509
- return this._ctx.translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
544
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").translate(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
510
545
  }
511
546
  rotate(angle2) {
512
- return this._ctx.rotate(angle2);
547
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").rotate(angle2);
513
548
  }
514
549
  drawImage(...args) {
515
550
  const image = args[0];
@@ -522,66 +557,67 @@ var __privateMethod = (obj, member, method) => {
522
557
  const dw = args[args.length - 2];
523
558
  const dh = args[args.length - 1];
524
559
  if (args.length === 9) {
525
- return this._ctx.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(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));
526
561
  } else {
527
- return this._ctx.drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
562
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
528
563
  }
529
564
  }
530
565
  createPattern(image, repetition) {
531
- return this._ctx.createPattern(image, repetition);
566
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").createPattern(image, repetition);
532
567
  }
533
568
  measureText(text2) {
534
- const textMetrics = this._ctx.measureText(text2);
569
+ const textMetrics = __classPrivateFieldGet(this, _Context2D_ctx, "f").measureText(text2);
535
570
  return textMetrics;
536
571
  }
537
572
  fillText(text2, x2, y2, maxWidth) {
538
573
  if (maxWidth !== void 0) {
539
- return this._ctx.fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
574
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
540
575
  } else {
541
- return this._ctx.fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
576
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").fillText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
542
577
  }
543
578
  }
544
579
  strokeText(text2, x2, y2, maxWidth) {
545
580
  if (maxWidth !== void 0) {
546
- return this._ctx.strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
581
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(maxWidth));
547
582
  } else {
548
- return this._ctx.strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
583
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").strokeText(text2, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
549
584
  }
550
585
  }
551
586
  save() {
552
- this._ctx.save();
587
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").save();
553
588
  }
554
589
  restore() {
555
- this._ctx.restore();
590
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").restore();
556
591
  }
557
592
  scale(ratioX, ratioY) {
558
- this._ctx.scale(ratioX, ratioY);
593
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").scale(ratioX, ratioY);
559
594
  }
560
595
  circle(x2, y2, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
561
- this._ctx.ellipse(this.$doPixelRatio(x2), this.$doPixelRatio(y2), this.$doPixelRatio(radiusX), this.$doPixelRatio(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);
562
597
  }
563
598
  isPointInPath(x2, y2) {
564
- return this._ctx.isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
599
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x2), this.$doPixelRatio(y2));
565
600
  }
566
601
  clip(...args) {
567
- return this._ctx.clip(...args);
602
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").clip(...args);
568
603
  }
569
604
  setTransform(a, b, c, d, e, f) {
570
- return this._ctx.setTransform(a, b, c, d, e, f);
605
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
571
606
  }
572
607
  getTransform() {
573
- return this._ctx.getTransform();
608
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").getTransform();
574
609
  }
575
610
  createLinearGradient(x0, y0, x1, y1) {
576
- return this._ctx.createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
611
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").createLinearGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(x1), this.$doPixelRatio(y1));
577
612
  }
578
613
  createRadialGradient(x0, y0, r0, x1, y1, r1) {
579
- return this._ctx.createRadialGradient(this.$doPixelRatio(x0), this.$doPixelRatio(y0), this.$doPixelRatio(r0), this.$doPixelRatio(x1), this.$doPixelRatio(y1), this.$doPixelRatio(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));
580
615
  }
581
616
  createConicGradient(startAngle, x2, y2) {
582
- return this._ctx.createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
617
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").createConicGradient(startAngle, this.$doPixelRatio(x2), this.$doPixelRatio(y2));
583
618
  }
584
619
  }
620
+ _Context2D_ctx = /* @__PURE__ */ new WeakMap(), _Context2D_opts = /* @__PURE__ */ new WeakMap();
585
621
  function createContext2D(opts) {
586
622
  const { width, height, ctx, devicePixelRatio } = opts;
587
623
  let context = ctx;
@@ -594,23 +630,72 @@ var __privateMethod = (obj, member, method) => {
594
630
  const context2d = new Context2D(context, opts);
595
631
  return context2d;
596
632
  }
597
- function createBoardContexts(ctx, opts) {
633
+ function createOffscreenContext2D(opts) {
634
+ const { width, height, devicePixelRatio } = opts;
635
+ const offCanvas = new OffscreenCanvas(width * devicePixelRatio, height * devicePixelRatio);
636
+ const offRenderCtx = offCanvas.getContext("2d");
637
+ const offCtx = offRenderCtx.canvas.getContext("2d");
638
+ const context2d = new Context2D(offCtx, {
639
+ devicePixelRatio,
640
+ offscreenCanvas: offCanvas
641
+ });
642
+ return context2d;
643
+ }
644
+ function createViewContent(canvas, opts) {
645
+ const { width, height, devicePixelRatio, offscreen } = opts;
598
646
  const ctxOpts = {
599
- width: ctx.canvas.width,
600
- height: ctx.canvas.height,
601
- devicePixelRatio: (opts === null || opts === void 0 ? void 0 : opts.devicePixelRatio) || 1
647
+ width,
648
+ height,
649
+ devicePixelRatio
602
650
  };
603
- const viewContext = createContext2D(ctxOpts);
604
- const helperContext = createContext2D(ctxOpts);
605
- const underContext = createContext2D(ctxOpts);
606
- const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
607
- const content = {
608
- underContext,
609
- viewContext,
610
- helperContext,
611
- boardContext
612
- };
613
- return content;
651
+ if (offscreen === true) {
652
+ const ctx = canvas.getContext("2d");
653
+ const viewContext = createOffscreenContext2D(ctxOpts);
654
+ const helperContext = createOffscreenContext2D(ctxOpts);
655
+ const underContext = createOffscreenContext2D(ctxOpts);
656
+ const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
657
+ const drawView = () => {
658
+ const { width: w2, height: h2 } = viewContext.$getSize();
659
+ boardContext.clearRect(0, 0, w2, h2);
660
+ boardContext.drawImage(underContext.canvas, 0, 0, w2, h2);
661
+ boardContext.drawImage(viewContext.canvas, 0, 0, w2, h2);
662
+ boardContext.drawImage(helperContext.canvas, 0, 0, w2, h2);
663
+ underContext.clearRect(0, 0, w2, h2);
664
+ viewContext.clearRect(0, 0, w2, h2);
665
+ helperContext.clearRect(0, 0, w2, h2);
666
+ };
667
+ const content = {
668
+ underContext,
669
+ viewContext,
670
+ helperContext,
671
+ boardContext,
672
+ drawView
673
+ };
674
+ return content;
675
+ } else {
676
+ const ctx = canvas.getContext("2d");
677
+ const viewContext = createContext2D(ctxOpts);
678
+ const helperContext = createContext2D(ctxOpts);
679
+ const underContext = createContext2D(ctxOpts);
680
+ const boardContext = createContext2D(Object.assign({ ctx }, ctxOpts));
681
+ const drawView = () => {
682
+ boardContext.clearRect(0, 0, width, height);
683
+ boardContext.drawImage(underContext.canvas, 0, 0, width, height);
684
+ boardContext.drawImage(viewContext.canvas, 0, 0, width, height);
685
+ boardContext.drawImage(helperContext.canvas, 0, 0, width, height);
686
+ underContext.clearRect(0, 0, width, height);
687
+ viewContext.clearRect(0, 0, width, height);
688
+ helperContext.clearRect(0, 0, width, height);
689
+ };
690
+ const content = {
691
+ underContext,
692
+ viewContext,
693
+ helperContext,
694
+ boardContext,
695
+ drawView
696
+ };
697
+ return content;
698
+ }
614
699
  }
615
700
  class EventEmitter {
616
701
  constructor() {
@@ -1009,6 +1094,32 @@ var __privateMethod = (obj, member, method) => {
1009
1094
  _scan(uuid, elements);
1010
1095
  return groupQueue;
1011
1096
  }
1097
+ function findElementsFromListByPositions(positions, list) {
1098
+ const elements = [];
1099
+ positions.forEach((pos) => {
1100
+ const elem = findElementFromListByPosition(pos, list);
1101
+ if (elem) {
1102
+ elements.push(elem);
1103
+ }
1104
+ });
1105
+ return elements;
1106
+ }
1107
+ function findElementFromListByPosition(position, list) {
1108
+ let result = null;
1109
+ let tempList = list;
1110
+ for (let i = 0; i < position.length; i++) {
1111
+ const pos = position[i];
1112
+ const item = tempList[pos];
1113
+ if (i < position.length - 1 && item.type === "group") {
1114
+ tempList = item.detail.children;
1115
+ } else if (i === position.length - 1) {
1116
+ result = item;
1117
+ } else {
1118
+ break;
1119
+ }
1120
+ }
1121
+ return result;
1122
+ }
1012
1123
  function checkRectIntersect(rect1, rect2) {
1013
1124
  const react1MinX = rect1.x;
1014
1125
  const react1MinY = rect1.y;
@@ -1020,6 +1131,25 @@ var __privateMethod = (obj, member, method) => {
1020
1131
  const react2MaxY = rect2.y + rect2.h;
1021
1132
  return react1MinX <= react2MaxX && react1MaxX >= react2MinX && react1MinY <= react2MaxY && react1MaxY >= react2MinY;
1022
1133
  }
1134
+ function calcViewScaleInfo(info, opts) {
1135
+ const { scale, offsetX, offsetY } = info;
1136
+ const { viewSizeInfo } = opts;
1137
+ const { width, height, contextWidth, contextHeight } = viewSizeInfo;
1138
+ const w2 = contextWidth * scale;
1139
+ const h2 = contextHeight * scale;
1140
+ const offsetLeft = 0 - offsetX * scale;
1141
+ const offsetTop = 0 - offsetY * scale;
1142
+ const offsetRight = width - (w2 + offsetLeft / scale);
1143
+ const offsetBottom = height - (h2 + offsetTop / scale);
1144
+ const newScaleInfo = {
1145
+ scale,
1146
+ offsetLeft,
1147
+ offsetTop,
1148
+ offsetRight,
1149
+ offsetBottom
1150
+ };
1151
+ return newScaleInfo;
1152
+ }
1023
1153
  function viewScale(opts) {
1024
1154
  const { scale, point, viewScaleInfo: prevViewScaleInfo } = opts;
1025
1155
  const { offsetLeft, offsetTop } = prevViewScaleInfo;
@@ -1371,7 +1501,7 @@ var __privateMethod = (obj, member, method) => {
1371
1501
  }
1372
1502
  function getDefaultElementDetailConfig() {
1373
1503
  const config = {
1374
- boxSizing: "center-line",
1504
+ boxSizing: "border-box",
1375
1505
  borderWidth: 0,
1376
1506
  borderColor: "#000000",
1377
1507
  shadowColor: "#000000",
@@ -1387,7 +1517,8 @@ var __privateMethod = (obj, member, method) => {
1387
1517
  fontSize: 16,
1388
1518
  lineHeight: 20,
1389
1519
  fontFamily: "sans-serif",
1390
- fontWeight: 400
1520
+ fontWeight: 400,
1521
+ overflow: "hidden"
1391
1522
  };
1392
1523
  return config;
1393
1524
  }
@@ -1409,7 +1540,7 @@ var __privateMethod = (obj, member, method) => {
1409
1540
  }
1410
1541
  let bw = 0;
1411
1542
  if (typeof borderWidth2 === "number") {
1412
- bw = (borderWidth2 || 1) * scale;
1543
+ bw = (borderWidth2 || 0) * scale;
1413
1544
  }
1414
1545
  if (boxSizing === "border-box") {
1415
1546
  x2 = viewElem.x + bw / 2;
@@ -1427,6 +1558,11 @@ var __privateMethod = (obj, member, method) => {
1427
1558
  w2 = viewElem.w;
1428
1559
  h2 = viewElem.h;
1429
1560
  }
1561
+ w2 = Math.max(w2, 1);
1562
+ h2 = Math.max(h2, 1);
1563
+ radiusList = radiusList.map((r) => {
1564
+ return Math.min(r, w2 / 2, h2 / 2);
1565
+ });
1430
1566
  return {
1431
1567
  x: x2,
1432
1568
  y: y2,
@@ -1706,6 +1842,11 @@ var __privateMethod = (obj, member, method) => {
1706
1842
  } else {
1707
1843
  ctx.lineCap = "square";
1708
1844
  }
1845
+ w2 = Math.max(w2, 1);
1846
+ h2 = Math.max(h2, 1);
1847
+ radiusList = radiusList.map((r) => {
1848
+ return Math.min(r, w2 / 2, h2 / 2);
1849
+ });
1709
1850
  ctx.setLineDash(viewBorderDash);
1710
1851
  ctx.lineWidth = bw;
1711
1852
  ctx.beginPath();
@@ -1830,6 +1971,7 @@ var __privateMethod = (obj, member, method) => {
1830
1971
  viewSizeInfo
1831
1972
  });
1832
1973
  ctx.save();
1974
+ ctx.fillStyle = "transparent";
1833
1975
  ctx.beginPath();
1834
1976
  ctx.moveTo(x3 + radiusList[0], y3);
1835
1977
  ctx.arcTo(x3 + w3, y3, x3 + w3, y3 + h3, radiusList[1]);
@@ -2066,7 +2208,8 @@ var __privateMethod = (obj, member, method) => {
2066
2208
  break;
2067
2209
  }
2068
2210
  case "group": {
2069
- drawGroup(ctx, elem, opts);
2211
+ const assets = Object.assign(Object.assign({}, opts.elementAssets || {}), elem.detail.assets || {});
2212
+ drawGroup(ctx, elem, Object.assign(Object.assign({}, opts), { elementAssets: assets }));
2070
2213
  break;
2071
2214
  }
2072
2215
  default: {
@@ -2082,49 +2225,65 @@ var __privateMethod = (obj, member, method) => {
2082
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);
2083
2226
  const viewElem = Object.assign(Object.assign({}, elem), { x: x2, y: y2, w: w2, h: h2, angle: angle2 });
2084
2227
  rotateElement(ctx, { x: x2, y: y2, w: w2, h: h2, angle: angle2 }, () => {
2085
- drawBox(ctx, viewElem, {
2086
- originElem: elem,
2087
- calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
2228
+ drawBoxShadow(ctx, viewElem, {
2088
2229
  viewScaleInfo,
2089
2230
  viewSizeInfo,
2090
2231
  renderContent: () => {
2091
- if (Array.isArray(elem.detail.children)) {
2092
- const { parentElementSize: parentSize } = opts;
2093
- const newParentSize = {
2094
- x: parentSize.x + elem.x,
2095
- y: parentSize.y + elem.y,
2096
- w: elem.w || parentSize.w,
2097
- h: elem.h || parentSize.h,
2098
- angle: elem.angle
2099
- };
2100
- const { calculator: calculator2 } = opts;
2101
- if (elem.detail.overflow === "hidden") {
2102
- ctx.save();
2103
- ctx.beginPath();
2104
- ctx.moveTo(x2, y2);
2105
- ctx.lineTo(x2 + w2, y2);
2106
- ctx.lineTo(x2 + w2, y2 + h2);
2107
- ctx.lineTo(x2, y2 + h2);
2108
- ctx.closePath();
2109
- ctx.clip();
2110
- }
2111
- for (let i = 0; i < elem.detail.children.length; i++) {
2112
- let child = elem.detail.children[i];
2113
- child = Object.assign(Object.assign({}, child), {
2114
- x: newParentSize.x + child.x,
2115
- y: newParentSize.y + child.y
2232
+ drawBox(ctx, viewElem, {
2233
+ originElem: elem,
2234
+ calcElemSize: { x: x2, y: y2, w: w2, h: h2, angle: angle2 },
2235
+ viewScaleInfo,
2236
+ viewSizeInfo,
2237
+ renderContent: () => {
2238
+ const { x: x3, y: y3, w: w3, h: h3, radiusList } = calcViewBoxSize(viewElem, {
2239
+ viewScaleInfo,
2240
+ viewSizeInfo
2116
2241
  });
2117
- if (!calculator2.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo)) {
2118
- continue;
2242
+ if (elem.detail.overflow === "hidden") {
2243
+ ctx.save();
2244
+ ctx.fillStyle = "transparent";
2245
+ ctx.beginPath();
2246
+ ctx.moveTo(x3 + radiusList[0], y3);
2247
+ ctx.arcTo(x3 + w3, y3, x3 + w3, y3 + h3, radiusList[1]);
2248
+ ctx.arcTo(x3 + w3, y3 + h3, x3, y3 + h3, radiusList[2]);
2249
+ ctx.arcTo(x3, y3 + h3, x3, y3, radiusList[3]);
2250
+ ctx.arcTo(x3, y3, x3 + w3, y3, radiusList[0]);
2251
+ ctx.closePath();
2252
+ ctx.fill();
2253
+ ctx.clip();
2119
2254
  }
2120
- try {
2121
- drawElement(ctx, child, Object.assign({}, opts));
2122
- } catch (err) {
2123
- console.error(err);
2255
+ if (Array.isArray(elem.detail.children)) {
2256
+ const { parentElementSize: parentSize } = opts;
2257
+ const newParentSize = {
2258
+ x: parentSize.x + elem.x,
2259
+ y: parentSize.y + elem.y,
2260
+ w: elem.w || parentSize.w,
2261
+ h: elem.h || parentSize.h,
2262
+ angle: elem.angle
2263
+ };
2264
+ const { calculator: calculator2 } = opts;
2265
+ for (let i = 0; i < elem.detail.children.length; i++) {
2266
+ let child = elem.detail.children[i];
2267
+ child = Object.assign(Object.assign({}, child), {
2268
+ x: newParentSize.x + child.x,
2269
+ y: newParentSize.y + child.y
2270
+ });
2271
+ if (!calculator2.isElementInView(child, opts.viewScaleInfo, opts.viewSizeInfo)) {
2272
+ continue;
2273
+ }
2274
+ try {
2275
+ drawElement(ctx, child, Object.assign({}, opts));
2276
+ } catch (err) {
2277
+ console.error(err);
2278
+ }
2279
+ }
2280
+ }
2281
+ if (elem.detail.overflow === "hidden") {
2282
+ ctx.globalAlpha = 1;
2283
+ ctx.restore();
2124
2284
  }
2125
2285
  }
2126
- ctx.restore();
2127
- }
2286
+ });
2128
2287
  }
2129
2288
  });
2130
2289
  });
@@ -2498,10 +2657,8 @@ var __privateMethod = (obj, member, method) => {
2498
2657
  const deltaY = e.deltaY > 0 || e.deltaY < 0 ? e.deltaY : 0;
2499
2658
  if (e.ctrlKey === true && this.has("wheelScale")) {
2500
2659
  this.trigger("wheelScale", { deltaX, deltaY, point });
2501
- } else if (this.has("wheelX") && deltaX !== 0) {
2502
- this.trigger("wheelX", { deltaX, point });
2503
- } else if (this.has("wheelY") && deltaY !== 0) {
2504
- this.trigger("wheelY", { deltaY, point });
2660
+ } else if (this.has("wheel")) {
2661
+ this.trigger("wheel", { deltaX, deltaY, point });
2505
2662
  }
2506
2663
  }, { passive: false });
2507
2664
  container.addEventListener("click", (e) => {
@@ -2658,7 +2815,6 @@ var __privateMethod = (obj, member, method) => {
2658
2815
  const { renderer, viewContent, beforeDrawFrame, afterDrawFrame } = this._opts;
2659
2816
  if (snapshot) {
2660
2817
  const { scale, offsetTop, offsetBottom, offsetLeft, offsetRight, width, height, contextHeight, contextWidth, devicePixelRatio } = snapshot.activeStore;
2661
- const { underContext, viewContext, helperContext, boardContext } = viewContent;
2662
2818
  if (snapshot === null || snapshot === void 0 ? void 0 : snapshot.activeStore.data) {
2663
2819
  renderer.drawData(snapshot.activeStore.data, {
2664
2820
  viewScaleInfo: {
@@ -2678,13 +2834,7 @@ var __privateMethod = (obj, member, method) => {
2678
2834
  });
2679
2835
  }
2680
2836
  beforeDrawFrame({ snapshot });
2681
- boardContext.clearRect(0, 0, width, height);
2682
- boardContext.drawImage(underContext.canvas, 0, 0, width, height);
2683
- boardContext.drawImage(viewContext.canvas, 0, 0, width, height);
2684
- boardContext.drawImage(helperContext.canvas, 0, 0, width, height);
2685
- underContext.clearRect(0, 0, width, height);
2686
- viewContext.clearRect(0, 0, width, height);
2687
- helperContext.clearRect(0, 0, width, height);
2837
+ viewContent.drawView();
2688
2838
  afterDrawFrame({ snapshot });
2689
2839
  }
2690
2840
  if (this._drawFrameSnapshotQueue.length === 0) {
@@ -2733,6 +2883,14 @@ var __privateMethod = (obj, member, method) => {
2733
2883
  sharer.setActiveViewScaleInfo(viewScaleInfo);
2734
2884
  return viewScaleInfo;
2735
2885
  }
2886
+ updateViewScaleInfo(opts) {
2887
+ const { sharer } = this._opts;
2888
+ const viewScaleInfo = calcViewScaleInfo(opts, {
2889
+ viewSizeInfo: sharer.getActiveViewSizeInfo()
2890
+ });
2891
+ sharer.setActiveViewScaleInfo(viewScaleInfo);
2892
+ return viewScaleInfo;
2893
+ }
2736
2894
  resize(viewSize = {}) {
2737
2895
  const { sharer } = this._opts;
2738
2896
  const originViewSize = sharer.getActiveViewSizeInfo();
@@ -2753,7 +2911,7 @@ var __privateMethod = (obj, member, method) => {
2753
2911
  return newViewSize;
2754
2912
  }
2755
2913
  }
2756
- const frameTime = 16;
2914
+ const throttleTime = 10;
2757
2915
  const LOCK_MODES = ["RULER"];
2758
2916
  class Board {
2759
2917
  constructor(opts) {
@@ -2776,7 +2934,6 @@ var __privateMethod = (obj, member, method) => {
2776
2934
  });
2777
2935
  this._opts = opts;
2778
2936
  this._sharer = sharer;
2779
- this._renderer = renderer;
2780
2937
  this._watcher = watcher;
2781
2938
  this._calculator = calculator;
2782
2939
  this._viewer = new Viewer({
@@ -2799,19 +2956,16 @@ var __privateMethod = (obj, member, method) => {
2799
2956
  this._watcher.on("pointEnd", this._handlePointEnd.bind(this));
2800
2957
  this._watcher.on("pointMove", throttle((e) => {
2801
2958
  this._handlePointMove(e);
2802
- }, frameTime));
2959
+ }, throttleTime));
2803
2960
  this._watcher.on("hover", throttle((e) => {
2804
2961
  this._handleHover(e);
2805
- }, frameTime));
2806
- this._watcher.on("wheelX", throttle((e) => {
2807
- this._handleWheelX(e);
2808
- }, frameTime));
2809
- this._watcher.on("wheelY", throttle((e) => {
2810
- this._handleWheelY(e);
2811
- }, frameTime));
2962
+ }, throttleTime));
2963
+ this._watcher.on("wheel", throttle((e) => {
2964
+ this._handleWheel(e);
2965
+ }, throttleTime));
2812
2966
  this._watcher.on("wheelScale", throttle((e) => {
2813
2967
  this._handleWheelScale(e);
2814
- }, frameTime));
2968
+ }, throttleTime));
2815
2969
  this._watcher.on("scrollX", this._handleScrollX.bind(this));
2816
2970
  this._watcher.on("scrollY", this._handleScrollY.bind(this));
2817
2971
  this._watcher.on("resize", this._handleResize.bind(this));
@@ -2867,21 +3021,11 @@ var __privateMethod = (obj, member, method) => {
2867
3021
  }
2868
3022
  }
2869
3023
  }
2870
- _handleWheelX(e) {
2871
- var _a;
2872
- for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
2873
- const obj = this._activeMiddlewareObjs[i];
2874
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheelX) === null || _a === void 0 ? void 0 : _a.call(obj, e);
2875
- if (result === false) {
2876
- return;
2877
- }
2878
- }
2879
- }
2880
- _handleWheelY(e) {
3024
+ _handleWheel(e) {
2881
3025
  var _a;
2882
3026
  for (let i = 0; i < this._activeMiddlewareObjs.length; i++) {
2883
3027
  const obj = this._activeMiddlewareObjs[i];
2884
- const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheelY) === null || _a === void 0 ? void 0 : _a.call(obj, e);
3028
+ const result = (_a = obj === null || obj === void 0 ? void 0 : obj.wheel) === null || _a === void 0 ? void 0 : _a.call(obj, e);
2885
3029
  if (result === false) {
2886
3030
  return;
2887
3031
  }
@@ -3009,14 +3153,14 @@ var __privateMethod = (obj, member, method) => {
3009
3153
  scroll(opts) {
3010
3154
  return this._viewer.scroll(opts);
3011
3155
  }
3156
+ updateViewScaleInfo(opts) {
3157
+ return this._viewer.updateViewScaleInfo(opts);
3158
+ }
3012
3159
  resize(newViewSize) {
3013
3160
  const viewSize = this._viewer.resize(newViewSize);
3014
3161
  const { width, height, devicePixelRatio } = newViewSize;
3015
3162
  const { viewContent } = this._opts;
3016
3163
  viewContent.viewContext.$resize({ width, height, devicePixelRatio });
3017
- const canvas = viewContent.viewContext.canvas;
3018
- canvas.style.width = `${width}px`;
3019
- canvas.style.height = `${height}px`;
3020
3164
  viewContent.helperContext.$resize({ width, height, devicePixelRatio });
3021
3165
  viewContent.boardContext.$resize({ width, height, devicePixelRatio });
3022
3166
  this._viewer.drawFrame();
@@ -4060,13 +4204,24 @@ var __privateMethod = (obj, member, method) => {
4060
4204
  ...defaultElementDetail,
4061
4205
  ...element.detail
4062
4206
  };
4207
+ let elemX = element.x * scale + offsetLeft;
4208
+ let elemY = element.y * scale + offsetTop;
4209
+ let elemW = element.w * scale;
4210
+ let elemH = element.h * scale;
4211
+ if (groupQueue.length > 0) {
4212
+ elemX = element.x * scale;
4213
+ elemY = element.y * scale;
4214
+ elemW = element.w * scale;
4215
+ elemH = element.h * scale;
4216
+ }
4063
4217
  textarea.style.position = "absolute";
4064
- textarea.style.left = `${element.x * scale}px`;
4065
- textarea.style.top = `${element.y * scale}px`;
4066
- textarea.style.width = `${element.w * scale}px`;
4067
- textarea.style.height = `${element.h * scale}px`;
4218
+ textarea.style.left = `${elemX}px`;
4219
+ textarea.style.top = `${elemY}px`;
4220
+ textarea.style.width = `${elemW}px`;
4221
+ textarea.style.height = `${elemH}px`;
4068
4222
  textarea.style.transform = `rotate(${limitAngle(element.angle || 0)}deg)`;
4069
- textarea.style.border = "none";
4223
+ textarea.style.boxSizing = "border-box";
4224
+ textarea.style.border = "1px solid #1973ba";
4070
4225
  textarea.style.resize = "none";
4071
4226
  textarea.style.overflow = "hidden";
4072
4227
  textarea.style.wordBreak = "break-all";
@@ -4121,10 +4276,15 @@ var __privateMethod = (obj, member, method) => {
4121
4276
  const { helperContext } = viewContent;
4122
4277
  let prevPoint = null;
4123
4278
  let inBusyMode = null;
4124
- eventHub.on(middlewareEventSelect, ({ uuids }) => {
4279
+ eventHub.on(middlewareEventSelect, ({ uuids, positions }) => {
4280
+ let elements = [];
4125
4281
  const actionType = sharer.getSharedStorage(keyActionType);
4126
4282
  const data = sharer.getActiveStorage("data");
4127
- const elements = findElementsFromList(uuids, (data == null ? void 0 : data.elements) || []);
4283
+ if (positions && Array.isArray(positions)) {
4284
+ elements = findElementsFromListByPositions(positions, (data == null ? void 0 : data.elements) || []);
4285
+ } else {
4286
+ elements = findElementsFromList(uuids, (data == null ? void 0 : data.elements) || []);
4287
+ }
4128
4288
  let needRefresh = false;
4129
4289
  if (!actionType && elements.length === 1) {
4130
4290
  sharer.setSharedStorage(keyActionType, "select");
@@ -4797,24 +4957,12 @@ var __privateMethod = (obj, member, method) => {
4797
4957
  };
4798
4958
  return {
4799
4959
  mode: key,
4800
- // hover: (e: PointWatcherEvent) => {
4801
- // const { point } = e;
4802
- // const thumbType = getThumbType(point);
4803
- // if (thumbType === 'X' || thumbType === 'Y') {
4804
- // return false;
4805
- // }
4806
- // },
4807
- wheelX: (e) => {
4808
- if (e.deltaX >= 0 || e.deltaX < 0) {
4809
- viewer.scroll({ moveX: 0 - e.deltaX });
4810
- viewer.drawFrame();
4811
- }
4812
- },
4813
- wheelY: (e) => {
4814
- if (e.deltaY >= 0 || e.deltaY < 0) {
4815
- viewer.scroll({ moveY: 0 - e.deltaY });
4816
- viewer.drawFrame();
4817
- }
4960
+ wheel: (e) => {
4961
+ viewer.scroll({
4962
+ moveX: 0 - e.deltaX,
4963
+ moveY: 0 - e.deltaY
4964
+ });
4965
+ viewer.drawFrame();
4818
4966
  },
4819
4967
  pointStart: (e) => {
4820
4968
  const { point } = e;
@@ -4892,8 +5040,8 @@ var __privateMethod = (obj, member, method) => {
4892
5040
  const fontFamily = "monospace";
4893
5041
  const fontSize = 10;
4894
5042
  const fontWeight = 100;
4895
- const gridColor = "#AAAAAA30";
4896
- const gridKeyColor = "#AAAAAA70";
5043
+ const gridColor = "#AAAAAA20";
5044
+ const gridKeyColor = "#AAAAAA40";
4897
5045
  const lineSize = 1;
4898
5046
  function calcRulerScaleList(opts) {
4899
5047
  const { scale, viewLength, viewOffset } = opts;
@@ -5122,8 +5270,7 @@ var __privateMethod = (obj, member, method) => {
5122
5270
  const canvas = document.createElement("canvas");
5123
5271
  __privateMethod(this, _initContainer, initContainer_fn).call(this);
5124
5272
  container.appendChild(canvas);
5125
- const ctx = canvas.getContext("2d");
5126
- const viewContent = createBoardContexts(ctx, { devicePixelRatio });
5273
+ const viewContent = createViewContent(canvas, { width, height, devicePixelRatio, offscreen: true });
5127
5274
  const board = new Board({ viewContent, container });
5128
5275
  const sharer = board.getSharer();
5129
5276
  sharer.setActiveViewSizeInfo({
@@ -5179,6 +5326,22 @@ var __privateMethod = (obj, member, method) => {
5179
5326
  const eventHub = __privateGet(this, _board).getEventHub();
5180
5327
  eventHub.trigger(name, e);
5181
5328
  }
5329
+ getViewInfo() {
5330
+ const board = __privateGet(this, _board);
5331
+ const sharer = board.getSharer();
5332
+ const viewSizeInfo = sharer.getActiveViewSizeInfo();
5333
+ const viewScaleInfo = sharer.getActiveViewScaleInfo();
5334
+ return {
5335
+ viewSizeInfo,
5336
+ viewScaleInfo
5337
+ };
5338
+ }
5339
+ refresh() {
5340
+ __privateGet(this, _board).getViewer().drawFrame();
5341
+ }
5342
+ setViewScale(opts) {
5343
+ __privateGet(this, _board).updateViewScaleInfo(opts);
5344
+ }
5182
5345
  }
5183
5346
  _board = new WeakMap();
5184
5347
  _container = new WeakMap();