@visactor/vue-vtable 1.17.1 → 1.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/cjs/{packages/vue-vtable/src/components → components}/custom/vtable-vue-attribute-plugin.js +6 -7
  2. package/cjs/{packages/vue-vtable/src/hooks → hooks}/useCellRender.js +2 -2
  3. package/cjs/index.d.ts +1 -1
  4. package/cjs/{packages/vue-vtable/src/index.js → index.js} +1 -1
  5. package/dist/vue-vtable.js +11 -1795
  6. package/dist/vue-vtable.min.js +1 -1
  7. package/es/{packages/vue-vtable/src/components → components}/custom/vtable-vue-attribute-plugin.js +1 -2
  8. package/es/{packages/vue-vtable/src/hooks → hooks}/useCellRender.js +2 -2
  9. package/es/index.d.ts +1 -1
  10. package/es/{packages/vue-vtable/src/index.js → index.js} +1 -1
  11. package/package.json +3 -3
  12. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/application.js +0 -7
  13. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/bezier-utils.js +0 -33
  14. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/bounds-context.js +0 -57
  15. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/custom-path2d.js +0 -291
  16. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/enums.js +0 -38
  17. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/generator.js +0 -10
  18. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/path-svg.js +0 -58
  19. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/render-command-list.js +0 -16
  20. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/seg-context.js +0 -94
  21. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/basis.js +0 -63
  22. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/catmull-rom-close.js +0 -73
  23. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/catmull-rom.js +0 -99
  24. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/common.js +0 -17
  25. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/curve/base.js +0 -9
  26. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/curve/cubic-bezier.js +0 -34
  27. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/curve/line.js +0 -29
  28. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/curve/path.js +0 -26
  29. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/index.js +0 -57
  30. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/linear-closed.js +0 -27
  31. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/linear.js +0 -55
  32. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/monotone.js +0 -121
  33. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/step.js +0 -63
  34. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/shape/arc.js +0 -100
  35. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/text.js +0 -16
  36. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/graphic/config.js +0 -305
  37. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/graphic/theme.js +0 -121
  38. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/interface/graphic/text.js +0 -6
  39. package/cjs/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/plugins/builtin-plugin/html-attribute-plugin.js +0 -194
  40. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/application.js +0 -4
  41. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/bezier-utils.js +0 -28
  42. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/bounds-context.js +0 -55
  43. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/custom-path2d.js +0 -289
  44. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/enums.js +0 -38
  45. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/generator.js +0 -8
  46. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/path-svg.js +0 -55
  47. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/render-command-list.js +0 -14
  48. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/seg-context.js +0 -91
  49. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/basis.js +0 -58
  50. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/catmull-rom-close.js +0 -70
  51. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/catmull-rom.js +0 -94
  52. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/common.js +0 -14
  53. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/curve/base.js +0 -7
  54. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/curve/cubic-bezier.js +0 -32
  55. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/curve/line.js +0 -27
  56. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/curve/path.js +0 -24
  57. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/index.js +0 -41
  58. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/linear-closed.js +0 -23
  59. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/linear.js +0 -51
  60. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/monotone.js +0 -114
  61. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/segment/step.js +0 -59
  62. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/shape/arc.js +0 -95
  63. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/common/text.js +0 -14
  64. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/graphic/config.js +0 -280
  65. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/graphic/theme.js +0 -115
  66. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/interface/graphic/text.js +0 -6
  67. package/es/common/temp/node_modules/.pnpm/@visactor_vrender-core@0.21.9-alpha.2/node_modules/@visactor/vrender-core/es/plugins/builtin-plugin/html-attribute-plugin.js +0 -192
  68. /package/cjs/{packages/vue-vtable/src/components → components}/component/menu.js +0 -0
  69. /package/cjs/{packages/vue-vtable/src/components → components}/component/tooltip.js +0 -0
  70. /package/cjs/{packages/vue-vtable/src/components → components}/custom/checkBox.js +0 -0
  71. /package/cjs/{packages/vue-vtable/src/components → components}/custom/group.js +0 -0
  72. /package/cjs/{packages/vue-vtable/src/components → components}/custom/image.js +0 -0
  73. /package/cjs/{packages/vue-vtable/src/components → components}/custom/radio.js +0 -0
  74. /package/cjs/{packages/vue-vtable/src/components → components}/custom/tag.js +0 -0
  75. /package/cjs/{packages/vue-vtable/src/components → components}/custom/text.js +0 -0
  76. /package/cjs/{packages/vue-vtable/src/components → components}/list/list-column.js +0 -0
  77. /package/cjs/{packages/vue-vtable/src/components → components}/pivot/pivot-column-dimension.js +0 -0
  78. /package/cjs/{packages/vue-vtable/src/components → components}/pivot/pivot-column-header-title.js +0 -0
  79. /package/cjs/{packages/vue-vtable/src/components → components}/pivot/pivot-corner.js +0 -0
  80. /package/cjs/{packages/vue-vtable/src/components → components}/pivot/pivot-indicator.js +0 -0
  81. /package/cjs/{packages/vue-vtable/src/components → components}/pivot/pivot-row-dimension.js +0 -0
  82. /package/cjs/{packages/vue-vtable/src/components → components}/pivot/pivot-row-header-title.js +0 -0
  83. /package/cjs/{packages/vue-vtable/src/edit → edit}/editor.js +0 -0
  84. /package/cjs/{packages/vue-vtable/src/edit → edit}/util.js +0 -0
  85. /package/cjs/{packages/vue-vtable/src/eventsUtils.js → eventsUtils.js} +0 -0
  86. /package/cjs/{packages/vue-vtable/src/hooks → hooks}/useEditorRender.js +0 -0
  87. /package/cjs/{packages/vue-vtable/src/tables → tables}/base-table.vue.js +0 -0
  88. /package/cjs/{packages/vue-vtable/src/tables → tables}/base-table.vue2.js +0 -0
  89. /package/cjs/{packages/vue-vtable/src/tables → tables}/chartModule.js +0 -0
  90. /package/cjs/{packages/vue-vtable/src/tables → tables}/list-table.vue.js +0 -0
  91. /package/cjs/{packages/vue-vtable/src/tables → tables}/list-table.vue2.js +0 -0
  92. /package/cjs/{packages/vue-vtable/src/tables → tables}/pivot-chart.vue.js +0 -0
  93. /package/cjs/{packages/vue-vtable/src/tables → tables}/pivot-chart.vue2.js +0 -0
  94. /package/cjs/{packages/vue-vtable/src/tables → tables}/pivot-table.vue.js +0 -0
  95. /package/cjs/{packages/vue-vtable/src/tables → tables}/pivot-table.vue2.js +0 -0
  96. /package/cjs/{packages/vue-vtable/src/utils → utils}/customLayoutUtils.js +0 -0
  97. /package/cjs/{packages/vue-vtable/src/utils → utils}/slotUtils.js +0 -0
  98. /package/cjs/{packages/vue-vtable/src/utils → utils}/stringUtils.js +0 -0
  99. /package/cjs/{packages/vue-vtable/src/utils → utils}/vnodeUtils.js +0 -0
  100. /package/es/{packages/vue-vtable/src/components → components}/component/menu.js +0 -0
  101. /package/es/{packages/vue-vtable/src/components → components}/component/tooltip.js +0 -0
  102. /package/es/{packages/vue-vtable/src/components → components}/custom/checkBox.js +0 -0
  103. /package/es/{packages/vue-vtable/src/components → components}/custom/group.js +0 -0
  104. /package/es/{packages/vue-vtable/src/components → components}/custom/image.js +0 -0
  105. /package/es/{packages/vue-vtable/src/components → components}/custom/radio.js +0 -0
  106. /package/es/{packages/vue-vtable/src/components → components}/custom/tag.js +0 -0
  107. /package/es/{packages/vue-vtable/src/components → components}/custom/text.js +0 -0
  108. /package/es/{packages/vue-vtable/src/components → components}/list/list-column.js +0 -0
  109. /package/es/{packages/vue-vtable/src/components → components}/pivot/pivot-column-dimension.js +0 -0
  110. /package/es/{packages/vue-vtable/src/components → components}/pivot/pivot-column-header-title.js +0 -0
  111. /package/es/{packages/vue-vtable/src/components → components}/pivot/pivot-corner.js +0 -0
  112. /package/es/{packages/vue-vtable/src/components → components}/pivot/pivot-indicator.js +0 -0
  113. /package/es/{packages/vue-vtable/src/components → components}/pivot/pivot-row-dimension.js +0 -0
  114. /package/es/{packages/vue-vtable/src/components → components}/pivot/pivot-row-header-title.js +0 -0
  115. /package/es/{packages/vue-vtable/src/edit → edit}/editor.js +0 -0
  116. /package/es/{packages/vue-vtable/src/edit → edit}/util.js +0 -0
  117. /package/es/{packages/vue-vtable/src/eventsUtils.js → eventsUtils.js} +0 -0
  118. /package/es/{packages/vue-vtable/src/hooks → hooks}/useEditorRender.js +0 -0
  119. /package/es/{packages/vue-vtable/src/tables → tables}/base-table.vue.js +0 -0
  120. /package/es/{packages/vue-vtable/src/tables → tables}/base-table.vue2.js +0 -0
  121. /package/es/{packages/vue-vtable/src/tables → tables}/chartModule.js +0 -0
  122. /package/es/{packages/vue-vtable/src/tables → tables}/list-table.vue.js +0 -0
  123. /package/es/{packages/vue-vtable/src/tables → tables}/list-table.vue2.js +0 -0
  124. /package/es/{packages/vue-vtable/src/tables → tables}/pivot-chart.vue.js +0 -0
  125. /package/es/{packages/vue-vtable/src/tables → tables}/pivot-chart.vue2.js +0 -0
  126. /package/es/{packages/vue-vtable/src/tables → tables}/pivot-table.vue.js +0 -0
  127. /package/es/{packages/vue-vtable/src/tables → tables}/pivot-table.vue2.js +0 -0
  128. /package/es/{packages/vue-vtable/src/utils → utils}/customLayoutUtils.js +0 -0
  129. /package/es/{packages/vue-vtable/src/utils → utils}/slotUtils.js +0 -0
  130. /package/es/{packages/vue-vtable/src/utils → utils}/stringUtils.js +0 -0
  131. /package/es/{packages/vue-vtable/src/utils → utils}/vnodeUtils.js +0 -0
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@visactor/vtable'), require('vue'), require('@visactor/vutils')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@visactor/vtable', 'vue', '@visactor/vutils'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VueVTable = {}, global.VTable, global.vue, global.vutils));
5
- })(this, (function (exports, VTable, vue, vutils) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@visactor/vtable'), require('vue'), require('@visactor/vutils'), require('@visactor/vtable/es/vrender')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@visactor/vtable', 'vue', '@visactor/vutils', '@visactor/vtable/es/vrender'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VueVTable = {}, global.VTable, global.Vue, global.VUtils, global.VTable.vrender));
5
+ })(this, (function (exports, VTable, vue, vutils, vrender) { 'use strict';
6
6
 
7
7
  function _interopNamespaceDefault(e) {
8
8
  var n = Object.create(null);
@@ -515,1791 +515,7 @@
515
515
  }
516
516
  }
517
517
 
518
- class Generator {
519
- static GenAutoIncrementId() {
520
- return Generator.auto_increment_id++;
521
- }
522
- }
523
- Generator.auto_increment_id = 0;
524
-
525
- var MeasureModeEnum;
526
- !function (MeasureModeEnum) {
527
- MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
528
- }(MeasureModeEnum || (MeasureModeEnum = {}));
529
-
530
- const circleThreshold = vutils.tau - 1e-8;
531
- class BoundsContext {
532
- constructor(bounds) {
533
- this.init(bounds);
534
- }
535
- init(bounds) {
536
- this.bounds = bounds;
537
- }
538
- arc(cx, cy, r, sa, ea, ccw) {
539
- if (Math.abs(ea - sa) > circleThreshold) return this.bounds.add(cx - r, cy - r), void this.bounds.add(cx + r, cy + r);
540
- let s,
541
- i,
542
- x,
543
- y,
544
- xmin = 1 / 0,
545
- xmax = -1 / 0,
546
- ymin = 1 / 0,
547
- ymax = -1 / 0;
548
- function update(a) {
549
- x = r * Math.cos(a), y = r * Math.sin(a), x < xmin && (xmin = x), x > xmax && (xmax = x), y < ymin && (ymin = y), y > ymax && (ymax = y);
550
- }
551
- if (update(sa), update(ea), ea !== sa) if ((sa %= vutils.tau) < 0 && (sa += vutils.tau), (ea %= vutils.tau) < 0 && (ea += vutils.tau), ea < sa && (ccw = !ccw, s = sa, sa = ea, ea = s), ccw) for (ea -= vutils.tau, s = sa - sa % vutils.halfPi, i = 0; i < 4 && s > ea; ++i, s -= vutils.halfPi) update(s);else for (s = sa - sa % vutils.halfPi + vutils.halfPi, i = 0; i < 4 && s < ea; ++i, s += vutils.halfPi) update(s);
552
- this.bounds.add(cx + xmin, cy + ymin), this.bounds.add(cx + xmax, cy + ymax);
553
- }
554
- arcTo(x1, y1, x2, y2, radius) {
555
- this.bounds.add(x1, y1);
556
- }
557
- bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
558
- this.bounds.add(cp1x, cp1y), this.bounds.add(cp2x, cp2y), this.bounds.add(x, y);
559
- }
560
- closePath() {}
561
- ellipse() {
562
- throw new Error("不支持ellipse");
563
- }
564
- lineTo(x, y) {
565
- this.bounds.add(x, y);
566
- }
567
- moveTo(x, y) {
568
- this.bounds.add(x, y);
569
- }
570
- quadraticCurveTo(cpx, cpy, x, y) {
571
- this.bounds.add(cpx, cpy), this.bounds.add(x, y);
572
- }
573
- rect(x, y, w, h) {
574
- this.bounds.add(x, y), this.bounds.add(x + w, y + h);
575
- }
576
- clear() {
577
- this.bounds.clear();
578
- }
579
- release() {}
580
- }
581
-
582
- class CurvePath {
583
- constructor() {
584
- this.curves = [], this.bounds = new vutils.AABBBounds();
585
- }
586
- getCurveLengths() {
587
- return this.curves.map(curve => curve.getLength());
588
- }
589
- getPointAt(t) {
590
- return {
591
- x: 0,
592
- y: 0
593
- };
594
- }
595
- getLength() {
596
- return 0;
597
- }
598
- getBounds() {
599
- return this.bounds;
600
- }
601
- }
602
-
603
- const rePathCommand = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/gi,
604
- commandLengths = {
605
- m: 2,
606
- l: 2,
607
- h: 1,
608
- v: 1,
609
- c: 6,
610
- s: 4,
611
- q: 4,
612
- t: 2,
613
- a: 7,
614
- M: 2,
615
- L: 2,
616
- H: 1,
617
- V: 1,
618
- C: 6,
619
- S: 4,
620
- Q: 4,
621
- T: 2,
622
- A: 7
623
- };
624
- const enumCommandMap = {
625
- A: 0,
626
- AT: 1,
627
- C: 2,
628
- Z: 3,
629
- E: 4,
630
- L: 5,
631
- M: 6,
632
- Q: 7,
633
- R: 8
634
- };
635
- let currPath, coordsStr, commandChar, coordStr, coordNumber, standardCommandLen;
636
- function parseSvgPath(str) {
637
- if (!str) return [];
638
- const paths = str.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);
639
- if (null === paths) return [];
640
- let currCommandData, coordsStrArr;
641
- const result = [];
642
- for (let i = 0, len = paths.length; i < len; i++) if (currPath = paths[i], coordsStr = currPath.slice(1), commandChar = currPath[0], currCommandData = [commandChar], coordsStrArr = coordsStr.match(rePathCommand), null !== coordsStrArr) {
643
- for (let i = 0, len = coordsStrArr.length; i < len; i++) coordStr = coordsStrArr[i], coordNumber = parseFloat(coordStr), Number.isNaN(coordNumber) || currCommandData.push(coordNumber);
644
- if (standardCommandLen = commandLengths[commandChar], currCommandData.length - 1 > standardCommandLen) {
645
- let subCommand,
646
- bestCommandChar = commandChar;
647
- for (let i = 1, len = currCommandData.length; i < len; i += standardCommandLen) {
648
- subCommand = [bestCommandChar];
649
- for (let j = i, subLen = i + standardCommandLen; j < subLen; j++) subCommand.push(currCommandData[j]);
650
- result.push(subCommand), "m" === bestCommandChar ? bestCommandChar = "l" : "M" === bestCommandChar && (bestCommandChar = "L");
651
- }
652
- } else result.push(currCommandData);
653
- } else result.push(currCommandData);
654
- return result;
655
- }
656
-
657
- var UpdateTag;
658
- !function (UpdateTag) {
659
- UpdateTag[UpdateTag.NONE = 0] = "NONE", UpdateTag[UpdateTag.UPDATE_BOUNDS = 1] = "UPDATE_BOUNDS", UpdateTag[UpdateTag.UPDATE_SHAPE = 2] = "UPDATE_SHAPE", UpdateTag[UpdateTag.CLEAR_SHAPE = 253] = "CLEAR_SHAPE", UpdateTag[UpdateTag.UPDATE_SHAPE_AND_BOUNDS = 3] = "UPDATE_SHAPE_AND_BOUNDS", UpdateTag[UpdateTag.INIT = 179] = "INIT", UpdateTag[UpdateTag.CLEAR_BOUNDS = 254] = "CLEAR_BOUNDS", UpdateTag[UpdateTag.UPDATE_GLOBAL_MATRIX = 32] = "UPDATE_GLOBAL_MATRIX", UpdateTag[UpdateTag.CLEAR_GLOBAL_MATRIX = 223] = "CLEAR_GLOBAL_MATRIX", UpdateTag[UpdateTag.UPDATE_LOCAL_MATRIX = 16] = "UPDATE_LOCAL_MATRIX", UpdateTag[UpdateTag.CLEAR_LOCAL_MATRIX = 239] = "CLEAR_LOCAL_MATRIX", UpdateTag[UpdateTag.UPDATE_GLOBAL_LOCAL_MATRIX = 48] = "UPDATE_GLOBAL_LOCAL_MATRIX", UpdateTag[UpdateTag.UPDATE_LAYOUT = 128] = "UPDATE_LAYOUT", UpdateTag[UpdateTag.CLEAR_LAYOUT = 127] = "CLEAR_LAYOUT";
660
- }(UpdateTag || (UpdateTag = {}));
661
- var IContainPointMode;
662
- !function (IContainPointMode) {
663
- IContainPointMode[IContainPointMode.GLOBAL = 1] = "GLOBAL", IContainPointMode[IContainPointMode.LOCAL = 16] = "LOCAL", IContainPointMode[IContainPointMode.GLOBAL_ACCURATE = 3] = "GLOBAL_ACCURATE", IContainPointMode[IContainPointMode.LOCAL_ACCURATE = 48] = "LOCAL_ACCURATE";
664
- }(IContainPointMode || (IContainPointMode = {}));
665
- var AttributeUpdateType;
666
- !function (AttributeUpdateType) {
667
- AttributeUpdateType[AttributeUpdateType.INIT = 0] = "INIT", AttributeUpdateType[AttributeUpdateType.DEFAULT = 1] = "DEFAULT", AttributeUpdateType[AttributeUpdateType.STATE = 2] = "STATE", AttributeUpdateType[AttributeUpdateType.ANIMATE_BIND = 10] = "ANIMATE_BIND", AttributeUpdateType[AttributeUpdateType.ANIMATE_PLAY = 11] = "ANIMATE_PLAY", AttributeUpdateType[AttributeUpdateType.ANIMATE_START = 12] = "ANIMATE_START", AttributeUpdateType[AttributeUpdateType.ANIMATE_UPDATE = 13] = "ANIMATE_UPDATE", AttributeUpdateType[AttributeUpdateType.ANIMATE_END = 14] = "ANIMATE_END", AttributeUpdateType[AttributeUpdateType.TRANSLATE = 20] = "TRANSLATE", AttributeUpdateType[AttributeUpdateType.TRANSLATE_TO = 21] = "TRANSLATE_TO", AttributeUpdateType[AttributeUpdateType.SCALE = 22] = "SCALE", AttributeUpdateType[AttributeUpdateType.SCALE_TO = 23] = "SCALE_TO", AttributeUpdateType[AttributeUpdateType.ROTATE = 24] = "ROTATE", AttributeUpdateType[AttributeUpdateType.ROTATE_TO = 25] = "ROTATE_TO";
668
- }(AttributeUpdateType || (AttributeUpdateType = {}));
669
- var AnimateStatus;
670
- !function (AnimateStatus) {
671
- AnimateStatus[AnimateStatus.INITIAL = 0] = "INITIAL", AnimateStatus[AnimateStatus.RUNNING = 1] = "RUNNING", AnimateStatus[AnimateStatus.PAUSED = 2] = "PAUSED", AnimateStatus[AnimateStatus.END = 3] = "END";
672
- }(AnimateStatus || (AnimateStatus = {}));
673
- var AnimateMode;
674
- !function (AnimateMode) {
675
- AnimateMode[AnimateMode.NORMAL = 0] = "NORMAL", AnimateMode[AnimateMode.SET_ATTR_IMMEDIATELY = 1] = "SET_ATTR_IMMEDIATELY";
676
- }(AnimateMode || (AnimateMode = {}));
677
- var AnimateStepType;
678
- !function (AnimateStepType) {
679
- AnimateStepType.wait = "wait", AnimateStepType.from = "from", AnimateStepType.to = "to", AnimateStepType.customAnimate = "customAnimate";
680
- }(AnimateStepType || (AnimateStepType = {}));
681
- var Direction;
682
- !function (Direction) {
683
- Direction[Direction.ROW = 1] = "ROW", Direction[Direction.COLUMN = 2] = "COLUMN";
684
- }(Direction || (Direction = {}));
685
- var CurveTypeEnum;
686
- !function (CurveTypeEnum) {
687
- CurveTypeEnum[CurveTypeEnum.CubicBezierCurve = 0] = "CubicBezierCurve", CurveTypeEnum[CurveTypeEnum.QuadraticBezierCurve = 1] = "QuadraticBezierCurve", CurveTypeEnum[CurveTypeEnum.ArcCurve = 2] = "ArcCurve", CurveTypeEnum[CurveTypeEnum.LineCurve = 3] = "LineCurve", CurveTypeEnum[CurveTypeEnum.EllipseCurve = 4] = "EllipseCurve", CurveTypeEnum[CurveTypeEnum.MoveCurve = 5] = "MoveCurve";
688
- }(CurveTypeEnum || (CurveTypeEnum = {}));
689
- var BaseRenderContributionTime;
690
- !function (BaseRenderContributionTime) {
691
- BaseRenderContributionTime[BaseRenderContributionTime.beforeFillStroke = 0] = "beforeFillStroke", BaseRenderContributionTime[BaseRenderContributionTime.afterFillStroke = 1] = "afterFillStroke";
692
- }(BaseRenderContributionTime || (BaseRenderContributionTime = {}));
693
-
694
- function segments(x, y, rx, ry, large, sweep, rotateX, ox, oy) {
695
- const th = vutils.degreeToRadian(rotateX),
696
- sin_th = Math.sin(th),
697
- cos_th = Math.cos(th),
698
- px = cos_th * (ox - x) * .5 + sin_th * (oy - y) * .5,
699
- py = cos_th * (oy - y) * .5 - sin_th * (ox - x) * .5;
700
- let pl = px * px / ((rx = Math.abs(rx)) * rx) + py * py / ((ry = Math.abs(ry)) * ry);
701
- pl > 1 && (pl = Math.sqrt(pl), rx *= pl, ry *= pl);
702
- const a00 = cos_th / rx,
703
- a01 = sin_th / rx,
704
- a10 = -sin_th / ry,
705
- a11 = cos_th / ry,
706
- x0 = a00 * ox + a01 * oy,
707
- y0 = a10 * ox + a11 * oy,
708
- x1 = a00 * x + a01 * y,
709
- y1 = a10 * x + a11 * y;
710
- let sfactor_sq = 1 / ((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) - .25;
711
- sfactor_sq < 0 && (sfactor_sq = 0);
712
- let sfactor = Math.sqrt(sfactor_sq);
713
- sweep === large && (sfactor = -sfactor);
714
- const xc = .5 * (x0 + x1) - sfactor * (y1 - y0),
715
- yc = .5 * (y0 + y1) + sfactor * (x1 - x0),
716
- th0 = Math.atan2(y0 - yc, x0 - xc);
717
- let th_arc = Math.atan2(y1 - yc, x1 - xc) - th0;
718
- th_arc < 0 && 1 === sweep ? th_arc += vutils.tau : th_arc > 0 && 0 === sweep && (th_arc -= vutils.tau);
719
- const segs = Math.ceil(Math.abs(th_arc / (vutils.halfPi + .001))),
720
- result = [];
721
- for (let i = 0; i < segs; ++i) {
722
- const th2 = th0 + i * th_arc / segs,
723
- th3 = th0 + (i + 1) * th_arc / segs;
724
- result[i] = [xc, yc, th2, th3, rx, ry, sin_th, cos_th];
725
- }
726
- return result;
727
- }
728
- function bezier(params) {
729
- const cx = params[0],
730
- cy = params[1],
731
- th0 = params[2],
732
- th1 = params[3],
733
- rx = params[4],
734
- ry = params[5],
735
- sin_th = params[6],
736
- cos_th = params[7],
737
- a00 = cos_th * rx,
738
- a01 = -sin_th * ry,
739
- a10 = sin_th * rx,
740
- a11 = cos_th * ry,
741
- cos_th0 = Math.cos(th0),
742
- sin_th0 = Math.sin(th0),
743
- cos_th1 = Math.cos(th1),
744
- sin_th1 = Math.sin(th1),
745
- th_half = .5 * (th1 - th0),
746
- sin_th_h2 = Math.sin(.5 * th_half),
747
- t = 8 / 3 * sin_th_h2 * sin_th_h2 / Math.sin(th_half),
748
- x1 = cx + cos_th0 - t * sin_th0,
749
- y1 = cy + sin_th0 + t * cos_th0,
750
- x3 = cx + cos_th1,
751
- y3 = cy + sin_th1,
752
- x2 = x3 + t * sin_th1,
753
- y2 = y3 - t * cos_th1;
754
- return [a00 * x1 + a01 * y1, a10 * x1 + a11 * y1, a00 * x2 + a01 * y2, a10 * x2 + a11 * y2, a00 * x3 + a01 * y3, a10 * x3 + a11 * y3];
755
- }
756
- function drawArc(context, x, y, coords) {
757
- const seg = segments(coords[5], coords[6], coords[0], coords[1], coords[3], coords[4], coords[2], x, y);
758
- for (let i = 0; i < seg.length; ++i) {
759
- const bez = bezier(seg[i]);
760
- context.bezierCurveTo(bez[0], bez[1], bez[2], bez[3], bez[4], bez[5]);
761
- }
762
- }
763
- const addArcToBezierPath = (bezierPath, startAngle, endAngle, cx, cy, rx, ry) => {
764
- const delta = Math.abs(endAngle - startAngle),
765
- count = delta > .5 * Math.PI ? Math.ceil(2 * delta / Math.PI) : 1,
766
- stepAngle = (endAngle - startAngle) / count;
767
- for (let i = 0; i < count; i++) {
768
- const sa = startAngle + stepAngle * i,
769
- ea = startAngle + stepAngle * (i + 1),
770
- len = 4 * Math.tan(Math.abs(stepAngle) / 4) / 3,
771
- dir = ea < sa ? -1 : 1,
772
- c1 = Math.cos(sa),
773
- s1 = Math.sin(sa),
774
- c2 = Math.cos(ea),
775
- s2 = Math.sin(ea),
776
- x1 = c1 * rx + cx,
777
- y1 = s1 * ry + cy,
778
- x4 = c2 * rx + cx,
779
- y4 = s2 * ry + cy,
780
- hx = rx * len * dir,
781
- hy = ry * len * dir;
782
- bezierPath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
783
- }
784
- };
785
-
786
- const commandFuncs = [(command, context, x, y, sx, sy, z) => context.arc(command[1] * sx + x, command[2] * sy + y, command[3] * (sx + sy) / 2, command[4], command[5], command[6], z), (command, context, x, y, sx, sy, z) => context.arcTo(command[1] * sx + x, command[2] * sy + y, command[3] * sx + x, command[4] * sy + y, command[5] * (sx + sy) / 2, z), (command, context, x, y, sx, sy, z) => context.bezierCurveTo(command[1] * sx + x, command[2] * sy + y, command[3] * sx + x, command[4] * sy + y, command[5] * sx + x, command[6] * sy + y, z), (command, context, x, y) => context.closePath(), (command, context, x, y, sx, sy) => context.ellipse(command[1] * sx + x, command[2] * sy + y, command[3] * sx, command[4] * sy, command[5], command[6], command[7], command[8]), (command, context, x, y, sx, sy, z) => context.lineTo(command[1] * sx + x, command[2] * sy + y, z), (command, context, x, y, sx, sy, z) => context.moveTo(command[1] * sx + x, command[2] * sy + y, z), (command, context, x, y, sx, sy, z) => context.quadraticCurveTo(command[1] * sx + x, command[2] * sy + y, command[3] * sx + x, command[4] * sy + y, z), (command, context, x, y, sx, sy, z) => context.rect(command[1] * sx + x, command[2] * sy + y, command[3] * sx, command[4] * sy, z)];
787
- function renderCommandList(commandList, context) {
788
- let x = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
789
- let y = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
790
- let sx = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
791
- let sy = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
792
- let z = arguments.length > 6 ? arguments[6] : undefined;
793
- for (let i = 0; i < commandList.length; i++) {
794
- const command = commandList[i];
795
- commandFuncs[command[0]](command, context, x, y, sx, sy, z);
796
- }
797
- }
798
-
799
- class Curve {
800
- getLength(direction) {
801
- return null != direction ? this.calcProjLength(direction) : (Number.isFinite(this.length) || (this.length = this.calcLength()), this.length);
802
- }
803
- }
804
-
805
- function snapLength(xArr, yArr) {
806
- let totalLength = 0;
807
- const count = xArr.length;
808
- for (let i = 0; i < count; i++) {
809
- const x = xArr[i],
810
- y = yArr[i],
811
- nextX = xArr[(i + 1) % count],
812
- nextY = yArr[(i + 1) % count];
813
- totalLength += vutils.PointService.distanceNN(x, y, nextX, nextY);
814
- }
815
- return totalLength / 2;
816
- }
817
- function cubicLength(p0, p1, p2, p3, iterationCount) {
818
- return snapLength([p0.x, p1.x, p2.x, p3.x], [p0.y, p1.y, p2.y, p3.y]);
819
- }
820
- function cubicCalc(p0, p1, p2, p3, t) {
821
- const one = 1 - t;
822
- return one * one * one * p0 + 3 * p1 * t * one * one + 3 * p2 * t * t * one + p3 * t * t * t;
823
- }
824
- function cubicPointAt(p0, p1, p2, p3, t) {
825
- const x = cubicCalc(p0.x, p1.x, p2.x, p3.x, t),
826
- y = cubicCalc(p0.y, p1.y, p2.y, p3.y, t);
827
- return new vutils.Point(x, y);
828
- }
829
-
830
- class CubicBezierCurve extends Curve {
831
- constructor(p0, p1, p2, p3) {
832
- super(), this.type = CurveTypeEnum.CubicBezierCurve, this.p0 = p0, this.p1 = p1, this.p2 = p2, this.p3 = p3;
833
- }
834
- _validPoint() {
835
- return Number.isFinite(this.p0.x + this.p0.y + this.p1.x + this.p1.y + this.p2.x + this.p2.y + this.p3.x + this.p3.y);
836
- }
837
- getPointAt(t) {
838
- if (!1 !== this.defined) return cubicPointAt(this.p0, this.p1, this.p2, this.p3, t);
839
- throw new Error("defined为false的点不能getPointAt");
840
- }
841
- calcLength() {
842
- return this._validPoint() ? cubicLength(this.p0, this.p1, this.p2, this.p3) : 60;
843
- }
844
- calcProjLength(direction) {
845
- return direction === Direction.ROW ? vutils.abs(this.p0.x - this.p3.x) : direction === Direction.COLUMN ? vutils.abs(this.p0.y - this.p3.y) : 0;
846
- }
847
- getAngleAt(t) {
848
- const minT = vutils.max(t - .01, 0),
849
- maxT = vutils.min(t + .01, 1),
850
- minP = this.getPointAt(minT),
851
- maxP = this.getPointAt(maxT);
852
- return vutils.atan2(maxP.y - minP.y, maxP.x - minP.x);
853
- }
854
- }
855
-
856
- class LineCurve extends Curve {
857
- constructor(p0, p1) {
858
- super(), this.type = CurveTypeEnum.LineCurve, this.p0 = p0, this.p1 = p1;
859
- }
860
- getPointAt(t) {
861
- if (!1 !== this.defined) return vutils.PointService.pointAtPP(this.p0, this.p1, t);
862
- throw new Error("defined为false的点不能getPointAt");
863
- }
864
- getAngleAt(t) {
865
- return null == this.angle && (this.angle = vutils.atan2(this.p1.y - this.p0.y, this.p1.x - this.p0.x)), this.angle;
866
- }
867
- _validPoint() {
868
- return Number.isFinite(this.p0.x + this.p0.y + this.p1.x + this.p1.y);
869
- }
870
- calcLength() {
871
- return this._validPoint() ? vutils.PointService.distancePP(this.p0, this.p1) : 60;
872
- }
873
- calcProjLength(direction) {
874
- return direction === Direction.ROW ? vutils.abs(this.p0.x - this.p1.x) : direction === Direction.COLUMN ? vutils.abs(this.p0.y - this.p1.y) : 0;
875
- }
876
- }
877
-
878
- class SegContext {
879
- get endX() {
880
- return this._lastX;
881
- }
882
- get endY() {
883
- return this._lastY;
884
- }
885
- constructor(curveType, direction) {
886
- this.init(curveType, direction);
887
- }
888
- init(curveType, direction) {
889
- this._lastX = this._lastY = this._startX = this._startY = 0, this.curveType = curveType, this.direction = direction, this.curves = [];
890
- }
891
- bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, defined, p) {
892
- const curve = new CubicBezierCurve(new vutils.Point(this._lastX, this._lastY), new vutils.Point(cp1x, cp1y), new vutils.Point(cp2x, cp2y), new vutils.Point(x, y));
893
- curve.originP1 = this._lastOriginP, curve.originP2 = p, curve.defined = defined, this.curves.push(curve), this._lastX = x, this._lastY = y, this._lastOriginP = p;
894
- }
895
- closePath() {
896
- if (this.curves.length < 2) return;
897
- const lastCurve = this.curves[this.curves.length - 1];
898
- this.lineTo(this._startX, this._startY, lastCurve.defined, this._startOriginP);
899
- }
900
- ellipse() {
901
- throw new Error("SegContext不支持调用ellipse");
902
- }
903
- lineTo(x, y, defined, p) {
904
- const curve = this.addLinearCurve(x, y, defined, this._lastOriginP, p);
905
- this.curves.push(curve), this._lastX = x, this._lastY = y, this._lastOriginP = p;
906
- }
907
- moveTo(x, y, p) {
908
- return this._lastX = this._startX = x, this._lastY = this._startY = y, this._lastOriginP = p, this._startOriginP = p, this;
909
- }
910
- quadraticCurveTo(cpx, cpy, x, y) {
911
- throw new Error("SegContext不支持调用quadraticCurveTo");
912
- }
913
- clear() {
914
- this.curves = [], this.length = NaN;
915
- }
916
- tryUpdateLength(direction) {
917
- return this.getLength(direction);
918
- }
919
- addLinearCurve(x, y, defined, p1, p2) {
920
- const curve = new LineCurve(new vutils.Point(this._lastX, this._lastY), new vutils.Point(x, y));
921
- return curve.originP1 = p1, curve.originP2 = p2, curve.defined = defined, curve;
922
- }
923
- getPointAt(t) {
924
- throw new Error("暂未实现");
925
- }
926
- getCurveLengths() {
927
- return [];
928
- }
929
- getLength(direction) {
930
- var _a, _b;
931
- if (direction === Direction.COLUMN) {
932
- if (!this.curves.length) return 0;
933
- const sc = this.curves[0],
934
- ec = this.curves[this.curves.length - 1],
935
- endP = null !== (_a = ec.p3) && void 0 !== _a ? _a : ec.p1;
936
- return vutils.abs(sc.p0.y - endP.y);
937
- }
938
- if (direction === Direction.ROW) {
939
- if (!this.curves.length) return 0;
940
- const sc = this.curves[0],
941
- ec = this.curves[this.curves.length - 1],
942
- endP = null !== (_b = ec.p3) && void 0 !== _b ? _b : ec.p1;
943
- return vutils.abs(sc.p0.x - endP.x);
944
- }
945
- return Number.isFinite(this.length) || (this.length = this.curves.reduce((l, c) => l + c.getLength(), 0)), this.length;
946
- }
947
- }
948
- class ReflectSegContext extends SegContext {
949
- bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, defined, p) {
950
- return super.bezierCurveTo(cp1y, cp1x, cp2y, cp2x, y, x, defined, p);
951
- }
952
- lineTo(x, y, defined, p) {
953
- return super.lineTo(y, x, defined, p);
954
- }
955
- moveTo(x, y, p) {
956
- return super.moveTo(y, x, p);
957
- }
958
- clear() {
959
- return super.clear();
960
- }
961
- }
962
-
963
- function genCurveSegments(path, points) {
964
- let defined0 = !1;
965
- for (let i = 0, n = points.length; i <= n; i++) i >= n === defined0 && ((defined0 = !defined0) ? path.lineStart() : path.lineEnd()), defined0 && path.point(points[i]);
966
- }
967
- function genSegContext(curveType, direction, points) {
968
- const curveDirection = null != direction ? direction : vutils.abs(points[points.length - 1].x - points[0].x) > vutils.abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN;
969
- return "monotoneY" === curveType ? new ReflectSegContext(curveType, curveDirection) : new SegContext(curveType, curveDirection);
970
- }
971
-
972
- class Linear {
973
- constructor(context, startPoint) {
974
- this.context = context, startPoint && (this.startPoint = startPoint);
975
- }
976
- areaStart() {
977
- this._line = 0;
978
- }
979
- areaEnd() {
980
- this._line = NaN;
981
- }
982
- lineStart() {
983
- this._point = 0, this.startPoint && this.point(this.startPoint);
984
- }
985
- lineEnd() {
986
- (this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(), this._line = 1 - this._line;
987
- }
988
- point(p) {
989
- const x = p.x,
990
- y = p.y;
991
- switch (this._point) {
992
- case 0:
993
- this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined, p) : this.context.moveTo(x, y, p);
994
- break;
995
- case 1:
996
- this._point = 2;
997
- default:
998
- this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined, p);
999
- }
1000
- this._lastDefined = p.defined;
1001
- }
1002
- tryUpdateLength() {
1003
- return this.context.tryUpdateLength();
1004
- }
1005
- }
1006
- function genLinearSegments(points) {
1007
- let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1008
- const {
1009
- direction: direction,
1010
- startPoint: startPoint
1011
- } = params;
1012
- if (points.length < 2 - Number(!!startPoint)) return null;
1013
- const segContext = genSegContext("linear", direction, points);
1014
- return genLinearTypeSegments(new Linear(segContext, startPoint), points), segContext;
1015
- }
1016
- function genLinearTypeSegments(path, points) {
1017
- return genCurveSegments(path, points);
1018
- }
1019
-
1020
- function point$2(curveClass, x, y, defined, p) {
1021
- curveClass.context.bezierCurveTo((2 * curveClass._x0 + curveClass._x1) / 3, (2 * curveClass._y0 + curveClass._y1) / 3, (curveClass._x0 + 2 * curveClass._x1) / 3, (curveClass._y0 + 2 * curveClass._y1) / 3, (curveClass._x0 + 4 * curveClass._x1 + x) / 6, (curveClass._y0 + 4 * curveClass._y1 + y) / 6, defined, curveClass.lastPoint1);
1022
- }
1023
- class Basis {
1024
- constructor(context, startPoint) {
1025
- this.context = context, this.startPoint = startPoint;
1026
- }
1027
- areaStart() {
1028
- this._line = 0;
1029
- }
1030
- areaEnd() {
1031
- this._line = NaN;
1032
- }
1033
- lineStart() {
1034
- this._x0 = this._x1 = this._y0 = this._y1 = NaN, this._point = 0, this.startPoint && this.point(this.startPoint);
1035
- }
1036
- lineEnd() {
1037
- if (2 === this._point) point$2(this, 6 * this._x1 - (this._x0 + 4 * this._x1), 6 * this._y1 - (this._y0 + 4 * this._y1), !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1);
1038
- (this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(), this._line = 1 - this._line;
1039
- }
1040
- point(p) {
1041
- const x = p.x,
1042
- y = p.y;
1043
- switch (this._point) {
1044
- case 0:
1045
- this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined1 && !1 !== this._lastDefined2, p) : this.context.moveTo(x, y, p);
1046
- break;
1047
- case 1:
1048
- this._point = 2;
1049
- break;
1050
- default:
1051
- point$2(this, x, y, !1 !== this._lastDefined1 && !1 !== this._lastDefined2);
1052
- }
1053
- this._x0 = this._x1, this._x1 = x, this._y0 = this._y1, this._y1 = y, this._lastDefined1 = this._lastDefined2, this._lastDefined2 = p.defined, this.lastPoint0 = this.lastPoint1, this.lastPoint1 = p;
1054
- }
1055
- tryUpdateLength() {
1056
- return this.context.tryUpdateLength();
1057
- }
1058
- }
1059
- function genBasisTypeSegments(path, points) {
1060
- return genCurveSegments(path, points);
1061
- }
1062
- function genBasisSegments(points) {
1063
- let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1064
- const {
1065
- direction: direction,
1066
- startPoint: startPoint
1067
- } = params;
1068
- if (points.length < 2 - Number(!!startPoint)) return null;
1069
- if (points.length < 3 - Number(!!startPoint)) return genLinearSegments(points, params);
1070
- const segContext = genSegContext("basis", direction, points);
1071
- return genBasisTypeSegments(new Basis(segContext, startPoint), points), segContext;
1072
- }
1073
-
1074
- function sign(x) {
1075
- return x < 0 ? -1 : 1;
1076
- }
1077
- function slope3(curveClass, x2, y2) {
1078
- const h0 = curveClass._x1 - curveClass._x0,
1079
- h1 = x2 - curveClass._x1,
1080
- s0 = (curveClass._y1 - curveClass._y0) / (h0 || Number(h1 < 0 && -0)),
1081
- s1 = (y2 - curveClass._y1) / (h1 || Number(h0 < 0 && -0)),
1082
- p = (s0 * h1 + s1 * h0) / (h0 + h1);
1083
- return (sign(s0) + sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), .5 * Math.abs(p)) || 0;
1084
- }
1085
- function slope2(curveClass, t) {
1086
- const h = curveClass._x1 - curveClass._x0;
1087
- return h ? (3 * (curveClass._y1 - curveClass._y0) / h - t) / 2 : t;
1088
- }
1089
- function point$1(curveClass, t0, t1, defined, p) {
1090
- const x0 = curveClass._x0,
1091
- y0 = curveClass._y0,
1092
- x1 = curveClass._x1,
1093
- y1 = curveClass._y1,
1094
- dx = (x1 - x0) / 3;
1095
- curveClass.context.bezierCurveTo(x0 + dx, y0 + dx * t0, x1 - dx, y1 - dx * t1, x1, y1, defined, curveClass.lastPoint1);
1096
- }
1097
- class MonotoneX {
1098
- constructor(context, startPoint) {
1099
- this.context = context, this.startPoint = startPoint;
1100
- }
1101
- areaStart() {
1102
- this._line = 0;
1103
- }
1104
- areaEnd() {
1105
- this._line = NaN;
1106
- }
1107
- lineStart() {
1108
- this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN, this._point = 0, this.startPoint && this.point(this.startPoint);
1109
- }
1110
- lineEnd() {
1111
- switch (this._point) {
1112
- case 2:
1113
- this.context.lineTo(this._x1, this._y1, !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1);
1114
- break;
1115
- case 3:
1116
- point$1(this, this._t0, slope2(this, this._t0), !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1);
1117
- }
1118
- (this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(), this._line = 1 - this._line;
1119
- }
1120
- point(p) {
1121
- let t1 = NaN;
1122
- const x = p.x,
1123
- y = p.y;
1124
- switch (this._point) {
1125
- case 0:
1126
- this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined1 && !1 !== this._lastDefined2, p) : this.context.moveTo(x, y, p);
1127
- break;
1128
- case 1:
1129
- this._point = 2;
1130
- break;
1131
- case 2:
1132
- this._point = 3, point$1(this, slope2(this, t1 = slope3(this, x, y)), t1, !1 !== this._lastDefined1 && !1 !== this._lastDefined2);
1133
- break;
1134
- default:
1135
- point$1(this, this._t0, t1 = slope3(this, x, y), !1 !== this._lastDefined1 && !1 !== this._lastDefined2);
1136
- }
1137
- this._x0 = this._x1, this._x1 = x, this._y0 = this._y1, this._y1 = y, this._t0 = t1, this._lastDefined1 = this._lastDefined2, this._lastDefined2 = !1 !== p.defined, this.lastPoint0 = this.lastPoint1, this.lastPoint1 = p;
1138
- }
1139
- tryUpdateLength() {
1140
- return this.context.tryUpdateLength();
1141
- }
1142
- }
1143
- class MonotoneY extends MonotoneX {
1144
- constructor(context, startPoint) {
1145
- super(context, startPoint);
1146
- }
1147
- point(p) {
1148
- return super.point({
1149
- y: p.x,
1150
- x: p.y,
1151
- defined: p.defined
1152
- });
1153
- }
1154
- }
1155
- function genMonotoneXTypeSegments(path, points) {
1156
- return genCurveSegments(path, points);
1157
- }
1158
- function genMonotoneXSegments(points) {
1159
- let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1160
- const {
1161
- direction: direction,
1162
- startPoint: startPoint
1163
- } = params;
1164
- if (points.length < 2 - Number(!!startPoint)) return null;
1165
- if (points.length < 3 - Number(!!startPoint)) return genLinearSegments(points, params);
1166
- const segContext = genSegContext("monotoneX", direction, points);
1167
- return genMonotoneXTypeSegments(new MonotoneX(segContext, startPoint), points), segContext;
1168
- }
1169
- function genMonotoneYTypeSegments(path, points) {
1170
- return genCurveSegments(path, points);
1171
- }
1172
- function genMonotoneYSegments(points) {
1173
- let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1174
- const {
1175
- direction: direction,
1176
- startPoint: startPoint
1177
- } = params;
1178
- if (points.length < 2 - Number(!!startPoint)) return null;
1179
- if (points.length < 3 - Number(!!startPoint)) return genLinearSegments(points, params);
1180
- const segContext = genSegContext("monotoneY", direction, points);
1181
- return genMonotoneYTypeSegments(new MonotoneY(segContext, startPoint), points), segContext;
1182
- }
1183
-
1184
- class Step {
1185
- constructor(context) {
1186
- let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : .5;
1187
- let startPoint = arguments.length > 2 ? arguments[2] : undefined;
1188
- this.context = context, this._t = t, this.startPoint = startPoint;
1189
- }
1190
- areaStart() {
1191
- this._line = 0;
1192
- }
1193
- areaEnd() {
1194
- this._line = NaN;
1195
- }
1196
- lineStart() {
1197
- this._x = this._y = NaN, this._point = 0, this.startPoint && this.point(this.startPoint);
1198
- }
1199
- lineEnd() {
1200
- 0 < this._t && this._t < 1 && 2 === this._point && this.context.lineTo(this._x, this._y, !1 !== this._lastDefined, this.lastPoint), (this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(), this._line >= 0 && (this._t = 1 - this._t, this._line = 1 - this._line);
1201
- }
1202
- point(p) {
1203
- const x = p.x,
1204
- y = p.y;
1205
- switch (this._point) {
1206
- case 0:
1207
- this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined, p) : this.context.moveTo(x, y, p);
1208
- break;
1209
- case 1:
1210
- this._point = 2;
1211
- default:
1212
- if (this._t <= 0) this.context.lineTo(this._x, y, !1 !== this._lastDefined && !1 !== p.defined, this.lastPoint), this.context.lineTo(x, y, !1 !== this._lastDefined && !1 !== p.defined, p);else {
1213
- const x1 = this._x * (1 - this._t) + x * this._t;
1214
- this.context.lineTo(x1, this._y, !1 !== this._lastDefined && !1 !== p.defined, this.lastPoint), this.context.lineTo(x1, y, !1 !== this._lastDefined && !1 !== p.defined, p);
1215
- }
1216
- }
1217
- this._lastDefined = p.defined, this._x = x, this._y = y, this.lastPoint = p;
1218
- }
1219
- tryUpdateLength() {
1220
- return this.context.tryUpdateLength();
1221
- }
1222
- }
1223
- function genStepSegments(points, t) {
1224
- let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1225
- const {
1226
- direction: direction,
1227
- startPoint: startPoint
1228
- } = params;
1229
- if (points.length < 2 - Number(!!startPoint)) return null;
1230
- const segContext = new SegContext("step", null != direction ? direction : vutils.abs(points[points.length - 1].x - points[0].x) > vutils.abs(points[points.length - 1].y - points[0].y) ? Direction.ROW : Direction.COLUMN);
1231
- return genStepTypeSegments(new Step(segContext, t, startPoint), points), segContext;
1232
- }
1233
- function genStepTypeSegments(path, points) {
1234
- return genCurveSegments(path, points);
1235
- }
1236
-
1237
- class LinearClosed extends Linear {
1238
- lineEnd() {
1239
- this.context.closePath();
1240
- }
1241
- }
1242
- function genLinearClosedSegments(points) {
1243
- let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1244
- const {
1245
- direction: direction,
1246
- startPoint: startPoint
1247
- } = params;
1248
- if (points.length < 2 - Number(!!startPoint)) return null;
1249
- const segContext = genSegContext("linear", direction, points);
1250
- return genLinearClosedTypeSegments(new LinearClosed(segContext, startPoint), points), segContext;
1251
- }
1252
- function genLinearClosedTypeSegments(path, points) {
1253
- return genCurveSegments(path, points);
1254
- }
1255
-
1256
- function point(curveClass, x, y, defined, p) {
1257
- let x1 = curveClass._x1,
1258
- y1 = curveClass._y1,
1259
- x2 = curveClass._x2,
1260
- y2 = curveClass._y2;
1261
- if (curveClass._l01_a > vutils.epsilon) {
1262
- const a = 2 * curveClass._l01_2a + 3 * curveClass._l01_a * curveClass._l12_a + curveClass._l12_2a,
1263
- n = 3 * curveClass._l01_a * (curveClass._l01_a + curveClass._l12_a);
1264
- x1 = (x1 * a - curveClass._x0 * curveClass._l12_2a + curveClass._x2 * curveClass._l01_2a) / n, y1 = (y1 * a - curveClass._y0 * curveClass._l12_2a + curveClass._y2 * curveClass._l01_2a) / n;
1265
- }
1266
- if (curveClass._l23_a > vutils.epsilon) {
1267
- const b = 2 * curveClass._l23_2a + 3 * curveClass._l23_a * curveClass._l12_a + curveClass._l12_2a,
1268
- m = 3 * curveClass._l23_a * (curveClass._l23_a + curveClass._l12_a);
1269
- x2 = (x2 * b + curveClass._x1 * curveClass._l23_2a - x * curveClass._l12_2a) / m, y2 = (y2 * b + curveClass._y1 * curveClass._l23_2a - y * curveClass._l12_2a) / m;
1270
- }
1271
- curveClass.context.bezierCurveTo(x1, y1, x2, y2, curveClass._x2, curveClass._y2, defined, curveClass.lastPoint1);
1272
- }
1273
- class CatmullRom {
1274
- constructor(context) {
1275
- let alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : .5;
1276
- let startPoint = arguments.length > 2 ? arguments[2] : undefined;
1277
- this.context = context, this.startPoint = startPoint, this._alpha = alpha;
1278
- }
1279
- areaStart() {
1280
- this._line = 0;
1281
- }
1282
- areaEnd() {
1283
- this._line = NaN;
1284
- }
1285
- lineStart() {
1286
- this._x0 = this._x1 = this._x2 = this._y0 = this._y1 = this._y2 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
1287
- }
1288
- lineEnd() {
1289
- switch (this._point) {
1290
- case 2:
1291
- this.context.lineTo(this._x2, this._y2, !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1);
1292
- break;
1293
- case 3:
1294
- this.point({
1295
- x: this._x2,
1296
- y: this._y2
1297
- });
1298
- }
1299
- (this._line || 0 !== this._line && 1 === this._point) && this.context.closePath(), this._line = 1 - this._line;
1300
- }
1301
- point(p) {
1302
- const {
1303
- x: x,
1304
- y: y
1305
- } = p;
1306
- if (this._point) {
1307
- const x23 = this._x2 - x,
1308
- y23 = this._y2 - y;
1309
- this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
1310
- }
1311
- switch (this._point) {
1312
- case 0:
1313
- this._point = 1, this._line ? this.context.lineTo(x, y, !1 !== this._lastDefined1 && !1 !== this._lastDefined2) : this.context.moveTo(x, y);
1314
- break;
1315
- case 1:
1316
- this._point = 2;
1317
- break;
1318
- case 2:
1319
- this._point = 3;
1320
- default:
1321
- point(this, x, y, !1 !== this._lastDefined1 && !1 !== this._lastDefined2);
1322
- }
1323
- this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = x, this._y0 = this._y1, this._y1 = this._y2, this._y2 = y, this._lastDefined1 = this._lastDefined2, this._lastDefined2 = p.defined, this.lastPoint0 = this.lastPoint1, this.lastPoint1 = p;
1324
- }
1325
- tryUpdateLength() {
1326
- return this.context.tryUpdateLength();
1327
- }
1328
- }
1329
- function commonGenCatmullRomSegments(type, cons) {
1330
- return function (points, alpha) {
1331
- let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1332
- const {
1333
- direction: direction,
1334
- startPoint: startPoint
1335
- } = params;
1336
- if (points.length < 2 - Number(!!startPoint)) return null;
1337
- if (points.length < 3 - Number(!!startPoint)) return genLinearSegments(points, params);
1338
- const segContext = genSegContext(type, direction, points),
1339
- gatmullRom = new cons(segContext, alpha, startPoint);
1340
- return genCurveSegments(gatmullRom, points), segContext;
1341
- };
1342
- }
1343
- const genCatmullRomSegments = commonGenCatmullRomSegments("catmullRom", CatmullRom);
1344
-
1345
- class CatmullRomClosed {
1346
- constructor(context) {
1347
- let alpha = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : .5;
1348
- let startPoint = arguments.length > 2 ? arguments[2] : undefined;
1349
- this.context = context, this.startPoint = startPoint, this._alpha = alpha;
1350
- }
1351
- areaStart() {
1352
- this._line = 0;
1353
- }
1354
- areaEnd() {
1355
- this._line = NaN;
1356
- }
1357
- lineStart() {
1358
- this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN, this._l01_a = this._l12_a = this._l23_a = this._l01_2a = this._l12_2a = this._l23_2a = this._point = 0;
1359
- }
1360
- lineEnd() {
1361
- switch (this._point) {
1362
- case 1:
1363
- this.context.moveTo(this._x3, this._y3, this.lastPoint1), this.context.closePath();
1364
- break;
1365
- case 2:
1366
- this.context.lineTo(this._x3, this._y3, !1 !== this._lastDefined1 && !1 !== this._lastDefined2, this.lastPoint1), this.context.closePath();
1367
- break;
1368
- case 3:
1369
- this.point({
1370
- x: this._x3,
1371
- y: this._y3
1372
- }), this.point({
1373
- x: this._x4,
1374
- y: this._y4
1375
- }), this.point({
1376
- x: this._x5,
1377
- y: this._y5
1378
- });
1379
- }
1380
- }
1381
- point(p) {
1382
- const {
1383
- x: x,
1384
- y: y
1385
- } = p;
1386
- if (this._point) {
1387
- const x23 = this._x2 - x,
1388
- y23 = this._y2 - y;
1389
- this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha));
1390
- }
1391
- switch (this._point) {
1392
- case 0:
1393
- this._point = 1, this._x3 = x, this._y3 = y;
1394
- break;
1395
- case 1:
1396
- this._point = 2, this.context.moveTo(this._x4 = x, this._y4 = y, p);
1397
- break;
1398
- case 2:
1399
- this._point = 3, this._x5 = x, this._y5 = y;
1400
- break;
1401
- default:
1402
- point(this, x, y, !1 !== this._lastDefined1 && !1 !== this._lastDefined2);
1403
- }
1404
- this._l01_a = this._l12_a, this._l12_a = this._l23_a, this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a, this._x0 = this._x1, this._x1 = this._x2, this._x2 = x, this._y0 = this._y1, this._y1 = this._y2, this._y2 = y, this._lastDefined1 = this._lastDefined2, this._lastDefined2 = p.defined, this.lastPoint0 = this.lastPoint1, this.lastPoint1 = p;
1405
- }
1406
- tryUpdateLength() {
1407
- return this.context.tryUpdateLength();
1408
- }
1409
- }
1410
- const genCatmullRomClosedSegments = commonGenCatmullRomSegments("catmullRomClosed", CatmullRomClosed);
1411
-
1412
- function calcLineCache(points, curveType, params) {
1413
- var _a, _b;
1414
- switch (curveType) {
1415
- case "linear":
1416
- default:
1417
- return genLinearSegments(points, params);
1418
- case "basis":
1419
- return genBasisSegments(points, params);
1420
- case "monotoneX":
1421
- return genMonotoneXSegments(points, params);
1422
- case "monotoneY":
1423
- return genMonotoneYSegments(points, params);
1424
- case "step":
1425
- return genStepSegments(points, .5, params);
1426
- case "stepBefore":
1427
- return genStepSegments(points, 0, params);
1428
- case "stepAfter":
1429
- return genStepSegments(points, 1, params);
1430
- case "catmullRom":
1431
- return genCatmullRomSegments(points, null !== (_a = null == params ? void 0 : params.curveTension) && void 0 !== _a ? _a : .5, params);
1432
- case "catmullRomClosed":
1433
- return genCatmullRomClosedSegments(points, null !== (_b = null == params ? void 0 : params.curveTension) && void 0 !== _b ? _b : .5, params);
1434
- case "linearClosed":
1435
- return genLinearClosedSegments(points, params);
1436
- }
1437
- }
1438
-
1439
- class CustomPath2D extends CurvePath {
1440
- constructor(ctx) {
1441
- super(), this.commandList = [], ctx && (this._ctx = ctx), this._boundsContext = new BoundsContext(this.bounds);
1442
- }
1443
- setCtx(ctx) {
1444
- this._ctx = ctx;
1445
- }
1446
- moveTo(x, y) {
1447
- return this.commandList.push([enumCommandMap.M, x, y]), this._ctx && this._ctx.moveTo(x, y), this;
1448
- }
1449
- lineTo(x, y) {
1450
- return this.commandList.push([enumCommandMap.L, x, y]), this._ctx && this._ctx.lineTo(x, y), this;
1451
- }
1452
- quadraticCurveTo(aCPx, aCPy, aX, aY) {
1453
- return this.commandList.push([enumCommandMap.Q, aCPx, aCPy, aX, aY]), this._ctx && this._ctx.quadraticCurveTo(aCPx, aCPy, aX, aY), this;
1454
- }
1455
- bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {
1456
- return this.commandList.push([enumCommandMap.C, aCP1x, aCP1y, aCP2x, aCP2y, aX, aY]), this._ctx && this._ctx.bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY), this;
1457
- }
1458
- arcTo(aX1, aY1, aX2, aY2, aRadius) {
1459
- return this.commandList.push([enumCommandMap.AT, aX1, aY1, aX2, aY2, aRadius]), this._ctx && this._ctx.arcTo(aX1, aY1, aX2, aY2, aRadius), this;
1460
- }
1461
- ellipse(aX, aY, xRadius, yRadius, aRotation, aStartAngle, aEndAngle, aClockwise) {
1462
- return this.commandList.push([enumCommandMap.E, aX, aY, xRadius, yRadius, aRotation, aStartAngle, aEndAngle, aClockwise]), this._ctx && this._ctx.ellipse(aX, aY, xRadius, yRadius, aRotation, aStartAngle, aEndAngle, aClockwise), this;
1463
- }
1464
- rect(x, y, w, h) {
1465
- return this.commandList.push([enumCommandMap.R, x, y, w, h]), this._ctx && this._ctx.rect(x, y, w, h), this;
1466
- }
1467
- arc(x, y, radius, startAngle, endAngle, counterclockwise) {
1468
- return this.commandList.push([enumCommandMap.A, x, y, radius, startAngle, endAngle, counterclockwise]), this._ctx && this._ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise), this;
1469
- }
1470
- closePath() {
1471
- return this.commandList.push([enumCommandMap.Z]), this._ctx && this._ctx.closePath(), this;
1472
- }
1473
- addCurve(curve) {
1474
- this.curves.push(curve);
1475
- }
1476
- clear() {
1477
- this.transformCbList = null, this.commandList.length = 0, this.curves.length = 0;
1478
- }
1479
- beginPath() {
1480
- this.clear();
1481
- }
1482
- toString() {
1483
- if (!this.toStringCbList) {
1484
- const list = [];
1485
- list[enumCommandMap.M] = cmd => `M${cmd[1]} ${cmd[2]}`, list[enumCommandMap.L] = cmd => `L${cmd[1]} ${cmd[2]}`, list[enumCommandMap.Q] = cmd => `Q${cmd[1]} ${cmd[2]} ${cmd[3]} ${cmd[4]}`, list[enumCommandMap.C] = cmd => `C${cmd[1]} ${cmd[2]} ${cmd[3]} ${cmd[4]} ${cmd[5]} ${cmd[6]}`, list[enumCommandMap.A] = cmd => {
1486
- const bezierPathList = [];
1487
- addArcToBezierPath(bezierPathList, cmd[4], cmd[5], cmd[1], cmd[2], cmd[3], cmd[3]);
1488
- let path = "";
1489
- for (let i = 0; i < bezierPathList.length; i += 6) path += `C${bezierPathList[i]} ${bezierPathList[i + 1]} ${bezierPathList[i + 2]} ${bezierPathList[i + 3]} ${bezierPathList[i + 4]} ${bezierPathList[i + 5]}`;
1490
- return path;
1491
- }, list[enumCommandMap.R] = cmd => `M${cmd[1]} ${cmd[2]} h${cmd[3]} v${cmd[4]} H${cmd[1]}Z`, list[enumCommandMap.Z] = cmd => "Z", this.toStringCbList = list;
1492
- }
1493
- const list = this.toStringCbList;
1494
- let path = "";
1495
- return this.commandList.forEach(c => {
1496
- path += list[c[0]](c);
1497
- }), path;
1498
- }
1499
- fromString(str, x, y, sX, sY) {
1500
- this.clear();
1501
- const commandStrList = parseSvgPath(str);
1502
- return this._runCommandStrList(commandStrList, x, y, sX, sY), this._updateBounds(), this;
1503
- }
1504
- fromLine(line) {
1505
- const {
1506
- points: points,
1507
- curveType: curveType,
1508
- clipRangeByDimension: clipRangeByDimension
1509
- } = line.attribute;
1510
- if (!points) return;
1511
- const cache = calcLineCache(points, curveType);
1512
- "x" === clipRangeByDimension ? this.direction = Direction.ROW : "y" === clipRangeByDimension ? this.direction = Direction.COLUMN : "auto" === clipRangeByDimension && (this.direction = cache.direction), this.curves = cache.curves;
1513
- }
1514
- fromCustomPath2D(path, x, y, sX, sY) {
1515
- return this.clear(), this._runCommandList(path.commandList, x, y, sX, sY), this._updateBounds(), this;
1516
- }
1517
- transform(x, y, sx, sy) {
1518
- const commandList = this.commandList;
1519
- if (!this.transformCbList) {
1520
- const list = [];
1521
- list[enumCommandMap.M] = this.moveToTransform, list[enumCommandMap.L] = this.lineToTransform, list[enumCommandMap.Q] = this.quadraticCurveToTransform, list[enumCommandMap.C] = this.bezierCurveToTransform, list[enumCommandMap.AT] = this.arcToTransform, list[enumCommandMap.E] = this.ellipseTransform, list[enumCommandMap.R] = this.rectTransform, list[enumCommandMap.A] = this.arcTransform, list[enumCommandMap.Z] = this.closePathTransform, this.transformCbList = list;
1522
- }
1523
- commandList.forEach(cmd => {
1524
- this.transformCbList[cmd[0]](cmd, x, y, sx, sy);
1525
- }), this._updateBounds();
1526
- }
1527
- moveToTransform(cmd, x, y, sx, sy) {
1528
- cmd[1] = cmd[1] * sx + x, cmd[2] = cmd[2] * sy + y;
1529
- }
1530
- lineToTransform(cmd, x, y, sx, sy) {
1531
- cmd[1] = cmd[1] * sx + x, cmd[2] = cmd[2] * sy + y;
1532
- }
1533
- quadraticCurveToTransform(cmd, x, y, sx, sy) {
1534
- cmd[1] = cmd[1] * sx + x, cmd[2] = cmd[2] * sy + y, cmd[3] = cmd[3] * sx + x, cmd[4] = cmd[4] * sy + y;
1535
- }
1536
- bezierCurveToTransform(cmd, x, y, sx, sy) {
1537
- cmd[1] = cmd[1] * sx + x, cmd[2] = cmd[2] * sy + y, cmd[3] = cmd[3] * sx + x, cmd[4] = cmd[4] * sy + y, cmd[5] = cmd[5] * sx + x, cmd[6] = cmd[6] * sy + y;
1538
- }
1539
- arcToTransform(cmd, x, y, sx, sy) {
1540
- cmd[1] = cmd[1] * sx + x, cmd[2] = cmd[2] * sy + y, cmd[3] = cmd[3] * sx + x, cmd[4] = cmd[4] * sy + y, cmd[5] = cmd[5] * (sx + sy) / 2;
1541
- }
1542
- ellipseTransform(cmd, x, y, sx, sy) {
1543
- cmd[1] = cmd[1] * sx + x, cmd[2] = cmd[2] * sy + y, cmd[3] = cmd[3] * sx, cmd[4] = cmd[4] * sy;
1544
- }
1545
- rectTransform(cmd, x, y, sx, sy) {
1546
- cmd[1] = cmd[1] * sx + x, cmd[2] = cmd[2] * sy + y, cmd[3] = cmd[3] * sx, cmd[4] = cmd[4] * sy;
1547
- }
1548
- arcTransform(cmd, x, y, sx, sy) {
1549
- cmd[1] = cmd[1] * sx + x, cmd[2] = cmd[2] * sy + y, cmd[3] = cmd[3] * (sx + sy) / 2;
1550
- }
1551
- closePathTransform() {}
1552
- _runCommandStrList(commandStrList) {
1553
- let l = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1554
- let t = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1555
- let sX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
1556
- let sY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
1557
- let current,
1558
- tempX,
1559
- tempY,
1560
- tempControlX,
1561
- tempControlY,
1562
- previous = null,
1563
- x = 0,
1564
- y = 0,
1565
- controlX = 0,
1566
- controlY = 0;
1567
- for (let i = 0, len = commandStrList.length; i < len; ++i) {
1568
- switch (current = commandStrList[i], 1 === sX && 1 === sY || (current = scale(current, sX, sY)), current[0]) {
1569
- case "l":
1570
- x += current[1], y += current[2], this.lineTo(x + l, y + t);
1571
- break;
1572
- case "L":
1573
- x = current[1], y = current[2], this.lineTo(x + l, y + t);
1574
- break;
1575
- case "h":
1576
- x += current[1], this.lineTo(x + l, y + t);
1577
- break;
1578
- case "H":
1579
- x = current[1], this.lineTo(x + l, y + t);
1580
- break;
1581
- case "v":
1582
- y += current[1], this.lineTo(x + l, y + t);
1583
- break;
1584
- case "V":
1585
- y = current[1], this.lineTo(x + l, y + t);
1586
- break;
1587
- case "m":
1588
- x += current[1], y += current[2], this.moveTo(x + l, y + t);
1589
- break;
1590
- case "M":
1591
- x = current[1], y = current[2], this.moveTo(x + l, y + t);
1592
- break;
1593
- case "c":
1594
- tempX = x + current[5], tempY = y + current[6], controlX = x + current[3], controlY = y + current[4], this.bezierCurveTo(x + current[1] + l, y + current[2] + t, controlX + l, controlY + t, tempX + l, tempY + t), x = tempX, y = tempY;
1595
- break;
1596
- case "C":
1597
- x = current[5], y = current[6], controlX = current[3], controlY = current[4], this.bezierCurveTo(current[1] + l, current[2] + t, controlX + l, controlY + t, x + l, y + t);
1598
- break;
1599
- case "s":
1600
- tempX = x + current[3], tempY = y + current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t, x + current[1] + l, y + current[2] + t, tempX + l, tempY + t), controlX = x + current[1], controlY = y + current[2], x = tempX, y = tempY;
1601
- break;
1602
- case "S":
1603
- tempX = current[3], tempY = current[4], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.bezierCurveTo(controlX + l, controlY + t, current[1] + l, current[2] + t, tempX + l, tempY + t), x = tempX, y = tempY, controlX = current[1], controlY = current[2];
1604
- break;
1605
- case "q":
1606
- tempX = x + current[3], tempY = y + current[4], controlX = x + current[1], controlY = y + current[2], this.quadraticCurveTo(controlX + l, controlY + t, tempX + l, tempY + t), x = tempX, y = tempY;
1607
- break;
1608
- case "Q":
1609
- tempX = current[3], tempY = current[4], this.quadraticCurveTo(current[1] + l, current[2] + t, tempX + l, tempY + t), x = tempX, y = tempY, controlX = current[1], controlY = current[2];
1610
- break;
1611
- case "t":
1612
- tempX = x + current[1], tempY = y + current[2], null === previous[0].match(/[QqTt]/) ? (controlX = x, controlY = y) : "t" === previous[0] ? (controlX = 2 * x - tempControlX, controlY = 2 * y - tempControlY) : "q" === previous[0] && (controlX = 2 * x - controlX, controlY = 2 * y - controlY), tempControlX = controlX, tempControlY = controlY, this.quadraticCurveTo(controlX + l, controlY + t, tempX + l, tempY + t), x = tempX, y = tempY, controlX = x + current[1], controlY = y + current[2];
1613
- break;
1614
- case "T":
1615
- tempX = current[1], tempY = current[2], controlX = 2 * x - controlX, controlY = 2 * y - controlY, this.quadraticCurveTo(controlX + l, controlY + t, tempX + l, tempY + t), x = tempX, y = tempY;
1616
- break;
1617
- case "a":
1618
- drawArc(this, x + l, y + t, [current[1], current[2], current[3], current[4], current[5], current[6] + x + l, current[7] + y + t]), x += current[6], y += current[7];
1619
- break;
1620
- case "A":
1621
- drawArc(this, x + l, y + t, [current[1], current[2], current[3], current[4], current[5], current[6] + l, current[7] + t]), x = current[6], y = current[7];
1622
- break;
1623
- case "z":
1624
- case "Z":
1625
- this.closePath();
1626
- }
1627
- previous = current;
1628
- }
1629
- }
1630
- _runCommandList(commandList) {
1631
- let l = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1632
- let t = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1633
- let sX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
1634
- let sY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
1635
- if (0 !== l || 0 !== t || 1 !== sX || 1 !== sY) for (let i = 0, len = commandList.length; i < len; ++i) {
1636
- const current = commandList[i].slice();
1637
- switch (current[0]) {
1638
- case enumCommandMap.L:
1639
- this.lineToTransform(current, l, t, sX, sY);
1640
- break;
1641
- case enumCommandMap.M:
1642
- this.moveToTransform(current, l, t, sX, sY);
1643
- break;
1644
- case enumCommandMap.C:
1645
- this.bezierCurveToTransform(current, l, t, sX, sY);
1646
- break;
1647
- case enumCommandMap.Q:
1648
- this.quadraticCurveToTransform(current, l, t, sX, sY);
1649
- break;
1650
- case enumCommandMap.A:
1651
- this.arcToTransform(current, l, t, sX, sY);
1652
- break;
1653
- case enumCommandMap.E:
1654
- this.ellipseTransform(current, l, t, sX, sY);
1655
- break;
1656
- case enumCommandMap.R:
1657
- this.rectTransform(current, l, t, sX, sY);
1658
- break;
1659
- case enumCommandMap.AT:
1660
- this.arcToTransform(current, l, t, sX, sY);
1661
- break;
1662
- case enumCommandMap.Z:
1663
- this.closePath();
1664
- }
1665
- } else this.commandList = commandList.map(entry => entry.slice());
1666
- }
1667
- _updateBounds() {
1668
- this.bounds.clear(), renderCommandList(this.commandList, this._boundsContext);
1669
- }
1670
- release() {
1671
- this.commandList = [], this._boundsContext = null, this._ctx = null;
1672
- }
1673
- getLength() {
1674
- if (this.direction === Direction.COLUMN) {
1675
- if (!this.curves.length) return 0;
1676
- const sc = this.curves[0],
1677
- ec = this.curves[this.curves.length - 1];
1678
- return vutils.abs(sc.p0.y - ec.p1.y);
1679
- }
1680
- if (this.direction === Direction.ROW) {
1681
- if (!this.curves.length) return 0;
1682
- const sc = this.curves[0],
1683
- ec = this.curves[this.curves.length - 1];
1684
- return vutils.abs(sc.p0.x - ec.p1.x);
1685
- }
1686
- return this.curves.reduce((l, c) => l + c.getLength(), 0);
1687
- }
1688
- getAttrAt(distance) {
1689
- if (!this.curves) return {
1690
- pos: {
1691
- x: 0,
1692
- y: 0
1693
- },
1694
- angle: 0
1695
- };
1696
- let curve,
1697
- _dis = 0;
1698
- for (let i = 0; i < this.curves.length; i++) {
1699
- curve = this.curves[i];
1700
- const cl = curve.getLength(this.direction);
1701
- if (_dis + cl >= distance) break;
1702
- _dis += cl;
1703
- }
1704
- const t = (distance - _dis) / curve.getLength(this.direction);
1705
- return {
1706
- pos: curve.getPointAt(t),
1707
- angle: curve.getAngleAt(t)
1708
- };
1709
- }
1710
- }
1711
- const temp = ["l", 0, 0, 0, 0, 0, 0, 0];
1712
- function scale(current, sX, sY) {
1713
- const c = temp[0] = current[0];
1714
- if ("a" === c || "A" === c) temp[1] = sX * current[1], temp[2] = sY * current[2], temp[3] = current[3], temp[4] = current[4], temp[5] = current[5], temp[6] = sX * current[6], temp[7] = sY * current[7];else if ("h" === c || "H" === c) temp[1] = sX * current[1];else if ("v" === c || "V" === c) temp[1] = sY * current[1];else for (let i = 1, n = current.length; i < n; ++i) temp[i] = (i % 2 == 1 ? sX : sY) * current[i];
1715
- return temp;
1716
- }
1717
-
1718
- const DefaultLayout = {
1719
- alignSelf: "auto"
1720
- };
1721
- const DefaultTransform = {
1722
- x: 0,
1723
- y: 0,
1724
- z: 0,
1725
- dx: 0,
1726
- dy: 0,
1727
- dz: 0,
1728
- scrollX: 0,
1729
- scrollY: 0,
1730
- scaleX: 1,
1731
- scaleY: 1,
1732
- scaleZ: 1,
1733
- angle: 0,
1734
- alpha: 0,
1735
- beta: 0,
1736
- scaleCenter: [0, 0],
1737
- anchor: [0, 0],
1738
- anchor3d: [0, 0],
1739
- postMatrix: new vutils.Matrix()
1740
- };
1741
- const DefaultFillStyle = {
1742
- fillOpacity: 1,
1743
- fill: !1,
1744
- shadowBlur: 0,
1745
- shadowColor: "black",
1746
- shadowOffsetX: 0,
1747
- shadowOffsetY: 0
1748
- };
1749
- const commonStroke = {
1750
- strokeOpacity: 1,
1751
- lineDash: [],
1752
- lineDashOffset: 0,
1753
- lineWidth: 1,
1754
- lineCap: "butt",
1755
- lineJoin: "miter",
1756
- miterLimit: 10,
1757
- strokeBoundsBuffer: 2,
1758
- stroke: !1
1759
- };
1760
- const DefaultStrokeStyle = Object.assign({
1761
- outerBorder: Object.assign(Object.assign({}, commonStroke), {
1762
- distance: 0
1763
- }),
1764
- innerBorder: Object.assign(Object.assign({}, commonStroke), {
1765
- distance: 0
1766
- })
1767
- }, commonStroke);
1768
- const DefaultTextStyle = {
1769
- text: "",
1770
- maxLineWidth: 1 / 0,
1771
- maxWidth: 1 / 0,
1772
- textAlign: "left",
1773
- textBaseline: "alphabetic",
1774
- fontSize: 16,
1775
- fontFamily: "PingFang SC,Microsoft Yahei,system-ui,-apple-system,segoe ui,\n Roboto,Helvetica,Arial,sans-serif, apple color emoji,segoe ui emoji,segoe ui symbol",
1776
- fontWeight: "",
1777
- ellipsis: "…",
1778
- fontVariant: "",
1779
- fontStyle: "",
1780
- lineHeight: void 0,
1781
- underline: 0,
1782
- lineThrough: 0,
1783
- scaleIn3d: !1,
1784
- direction: "horizontal",
1785
- wordBreak: "break-all",
1786
- ignoreBuf: !1,
1787
- verticalMode: 0,
1788
- wrap: !1,
1789
- whiteSpace: "no-wrap",
1790
- heightLimit: 1 / 0,
1791
- lineClamp: 1 / 0,
1792
- suffixPosition: "end",
1793
- underlineDash: [],
1794
- underlineOffset: 0,
1795
- disableAutoClipedPoptip: void 0,
1796
- measureMode: MeasureModeEnum.fontBounding,
1797
- keepCenterInLine: !1
1798
- };
1799
- const DefaultPickStyle = {
1800
- pickStrokeBuffer: 0
1801
- };
1802
- const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({
1803
- forceBoundsWidth: void 0,
1804
- forceBoundsHeight: void 0,
1805
- opacity: 1,
1806
- background: null,
1807
- backgroundOpacity: 1,
1808
- backgroundCornerRadius: 0,
1809
- texture: null,
1810
- textureColor: "black",
1811
- textureSize: 10,
1812
- texturePadding: 2,
1813
- backgroundMode: "no-repeat",
1814
- backgroundFit: !0,
1815
- blur: 0,
1816
- cursor: null,
1817
- html: null,
1818
- react: null
1819
- }, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout), DefaultPickStyle);
1820
- const DefaultConnectAttribute = {
1821
- connectedType: "none",
1822
- connectedStyle: {},
1823
- connectedX: NaN,
1824
- connectedY: NaN
1825
- };
1826
- const DefaultDebugAttribute = {
1827
- _debug_bounds: !1
1828
- };
1829
- const DefaultAttribute = Object.assign(Object.assign(Object.assign({
1830
- strokeSeg: null,
1831
- renderable: !0,
1832
- pickable: !0,
1833
- shadowGraphic: void 0,
1834
- childrenPickable: !0,
1835
- fillPickable: !0,
1836
- strokePickable: !0,
1837
- visible: !0,
1838
- zIndex: 0,
1839
- layout: null,
1840
- boundsPadding: 0,
1841
- fillStrokeOrder: 0,
1842
- renderStyle: "default",
1843
- pickMode: "accurate",
1844
- customPickShape: null,
1845
- boundsMode: "accurate",
1846
- keepDirIn3d: !0,
1847
- shadowRootIdx: 1,
1848
- globalZIndex: 1,
1849
- globalCompositeOperation: "",
1850
- overflow: "hidden",
1851
- shadowPickMode: "graphic",
1852
- keepStrokeScale: !1
1853
- }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
1854
- const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
1855
- startAngle: 0,
1856
- endAngle: vutils.pi2,
1857
- innerRadius: 0,
1858
- outerRadius: 1,
1859
- innerPadding: 0,
1860
- outerPadding: 0,
1861
- cornerRadius: 0,
1862
- padRadius: 0,
1863
- padAngle: 0,
1864
- cap: !1,
1865
- forceShowCap: !1
1866
- });
1867
- const DefaultAreaAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultConnectAttribute), {
1868
- points: [],
1869
- segments: [],
1870
- curveType: "linear",
1871
- clipRange: 1,
1872
- closePath: !1,
1873
- curveTension: 1
1874
- });
1875
- const DefaultCircleAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
1876
- radius: 1,
1877
- startAngle: 0,
1878
- endAngle: vutils.pi2
1879
- });
1880
- const DefaultGroupAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
1881
- width: 0,
1882
- height: 0,
1883
- cornerRadius: 0,
1884
- path: [],
1885
- clip: !1,
1886
- visibleAll: !0,
1887
- display: "relative",
1888
- flexDirection: "row",
1889
- flexWrap: "wrap",
1890
- justifyContent: "flex-start",
1891
- alignItems: "flex-start",
1892
- alignContent: "flex-start",
1893
- baseOpacity: 1
1894
- });
1895
- const DefaultGlyphAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
1896
- path: "",
1897
- width: 0,
1898
- height: 0,
1899
- cornerRadius: 0,
1900
- clip: !1
1901
- });
1902
- const DefaultLineAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultConnectAttribute), {
1903
- points: [],
1904
- segments: [],
1905
- curveType: "linear",
1906
- clipRange: 1,
1907
- clipRangeByDimension: "default",
1908
- closePath: !1,
1909
- curveTension: 1
1910
- });
1911
- const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
1912
- path: new CustomPath2D(),
1913
- fillStrokeOrder: 1,
1914
- customPath: () => {
1915
- vutils.Logger.getInstance().warn("空函数");
1916
- }
1917
- });
1918
- const DefaultPolygonAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
1919
- points: [],
1920
- cornerRadius: 0,
1921
- closePath: !0
1922
- });
1923
- const DefaultRectAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
1924
- width: 0,
1925
- height: 0,
1926
- x1: 0,
1927
- y1: 0,
1928
- strokeBoundsBuffer: 0,
1929
- cornerRadius: 0
1930
- });
1931
- Object.assign(Object.assign({}, DefaultAttribute), {
1932
- width: 0,
1933
- height: 0,
1934
- x1: 0,
1935
- y1: 0,
1936
- cornerRadius: 0,
1937
- length: 0
1938
- });
1939
- const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
1940
- symbolType: "circle",
1941
- size: 10,
1942
- keepDirIn3d: !0
1943
- });
1944
- const DefaultTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), {
1945
- strokeBoundsBuffer: 0,
1946
- keepDirIn3d: !0
1947
- });
1948
- const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultTextStyle), {
1949
- editable: !1,
1950
- width: 300,
1951
- height: 300,
1952
- ellipsis: !0,
1953
- wordBreak: "break-word",
1954
- verticalDirection: "top",
1955
- textAlign: "left",
1956
- textBaseline: "top",
1957
- layoutDirection: "horizontal",
1958
- textConfig: [],
1959
- disableAutoWrapLine: !1,
1960
- maxHeight: void 0,
1961
- maxWidth: void 0,
1962
- singleLine: !1
1963
- });
1964
- const DefaultImageAttribute = Object.assign(Object.assign({
1965
- repeatX: "no-repeat",
1966
- repeatY: "no-repeat",
1967
- image: "",
1968
- width: 0,
1969
- height: 0
1970
- }, DefaultAttribute), {
1971
- fill: !0,
1972
- cornerRadius: 0
1973
- });
1974
- const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImageAttribute), {
1975
- backgroundShowMode: "never",
1976
- backgroundWidth: 0,
1977
- backgroundHeight: 0,
1978
- textAlign: "left",
1979
- textBaseline: "middle",
1980
- direction: "horizontal",
1981
- margin: 0,
1982
- id: "",
1983
- width: 20,
1984
- height: 20,
1985
- backgroundFill: "rgba(101, 117, 168, 0.1)",
1986
- backgroundFillOpacity: 1,
1987
- backgroundStroke: !1,
1988
- backgroundStrokeOpacity: 1,
1989
- backgroundRadius: 4,
1990
- opacity: 1
1991
- });
1992
-
1993
- class Application {}
1994
- const application = new Application();
1995
-
1996
- const defaultThemeObj = {
1997
- arc: DefaultArcAttribute,
1998
- area: DefaultAreaAttribute,
1999
- circle: DefaultCircleAttribute,
2000
- line: DefaultLineAttribute,
2001
- path: DefaultPathAttribute,
2002
- symbol: DefaultSymbolAttribute,
2003
- text: DefaultTextAttribute,
2004
- rect: DefaultRectAttribute,
2005
- polygon: DefaultPolygonAttribute,
2006
- richtext: DefaultRichTextAttribute,
2007
- richtextIcon: DefaultRichTextIconAttribute,
2008
- image: DefaultImageAttribute,
2009
- group: DefaultGroupAttribute,
2010
- glyph: DefaultGlyphAttribute
2011
- },
2012
- themeKeys = Object.keys(defaultThemeObj);
2013
- function newThemeObj() {
2014
- return {
2015
- arc: Object.assign({}, defaultThemeObj.arc),
2016
- area: Object.assign({}, defaultThemeObj.area),
2017
- circle: Object.assign({}, defaultThemeObj.circle),
2018
- line: Object.assign({}, defaultThemeObj.line),
2019
- path: Object.assign({}, defaultThemeObj.path),
2020
- symbol: Object.assign({}, defaultThemeObj.symbol),
2021
- text: Object.assign({}, defaultThemeObj.text),
2022
- rect: Object.assign({}, defaultThemeObj.rect),
2023
- polygon: Object.assign({}, defaultThemeObj.polygon),
2024
- richtext: Object.assign({}, defaultThemeObj.richtext),
2025
- richtextIcon: Object.assign({}, defaultThemeObj.richtextIcon),
2026
- image: Object.assign({}, defaultThemeObj.image),
2027
- group: Object.assign({}, defaultThemeObj.group),
2028
- glyph: Object.assign({}, defaultThemeObj.glyph)
2029
- };
2030
- }
2031
- function combine(out, t) {
2032
- Object.keys(t).forEach(k => {
2033
- out[k] = t[k];
2034
- });
2035
- }
2036
- const globalThemeObj = newThemeObj();
2037
- class Theme {
2038
- constructor() {
2039
- this.initTheme(), this.dirty = !1;
2040
- }
2041
- initTheme() {
2042
- this._defaultTheme = {}, themeKeys.forEach(key => {
2043
- this._defaultTheme[key] = Object.create(globalThemeObj[key]);
2044
- }), this.combinedTheme = this._defaultTheme;
2045
- }
2046
- getTheme(group) {
2047
- if (!group) return this.combinedTheme;
2048
- if (!this.dirty) return this.combinedTheme;
2049
- let parentTheme = {};
2050
- const parentGroup = this.getParentWithTheme(group);
2051
- return parentGroup && (parentTheme = parentGroup.theme), this.applyTheme(group, parentTheme), this.combinedTheme;
2052
- }
2053
- getParentWithTheme(group) {
2054
- for (; group.parent;) if ((group = group.parent).theme) return group;
2055
- return null;
2056
- }
2057
- applyTheme(group, pt) {
2058
- let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
2059
- if (this.dirty) {
2060
- const parentGroup = this.getParentWithTheme(group);
2061
- if (parentGroup) {
2062
- const parentTheme = parentGroup.theme;
2063
- (parentTheme.dirty || force) && parentTheme.applyTheme(parentGroup, pt, !0);
2064
- }
2065
- this.userTheme ? this.doCombine(parentGroup && parentGroup.theme.combinedTheme) : (parentGroup ? this.combinedTheme = parentGroup.theme.combinedTheme : (this.combinedTheme = this._defaultTheme, vutils.Logger.getInstance().warn("未知错误,走到不应该走的区域里")), this.dirty = !1);
2066
- }
2067
- return this.combinedTheme;
2068
- }
2069
- doCombine(parentCombinedTheme) {
2070
- const userTheme = this.userTheme,
2071
- combinedTheme = this.combinedTheme;
2072
- themeKeys.forEach(k => {
2073
- const obj = Object.create(globalThemeObj[k]);
2074
- parentCombinedTheme && parentCombinedTheme[k] && combine(obj, parentCombinedTheme[k]), combinedTheme[k] && combine(obj, combinedTheme[k]), userTheme[k] && combine(obj, userTheme[k]), this.combinedTheme[k] = obj;
2075
- }), userTheme.common && themeKeys.forEach(k => {
2076
- combine(this.combinedTheme[k], userTheme.common);
2077
- }), this.dirty = !1;
2078
- }
2079
- setTheme(t, g) {
2080
- let userTheme = this.userTheme;
2081
- userTheme ? Object.keys(t).forEach(k => {
2082
- userTheme[k] ? Object.assign(userTheme[k], t[k]) : userTheme[k] = Object.assign({}, t[k]);
2083
- }) : userTheme = t, this.userTheme = userTheme, this.dirty = !0, this.dirtyChildren(g);
2084
- }
2085
- resetTheme(t, g) {
2086
- this.userTheme = t, this.dirty = !0, this.dirtyChildren(g);
2087
- }
2088
- dirtyChildren(g) {
2089
- g.forEachChildren(item => {
2090
- item.isContainer && (item.theme && (item.theme.dirty = !0), this.dirtyChildren(item));
2091
- });
2092
- }
2093
- }
2094
- const globalTheme = new Theme();
2095
- function getTheme(graphic, theme) {
2096
- return graphic.glyphHost ? getTheme(graphic.glyphHost) : theme ? (graphic.isContainer, theme) : getThemeFromGroup(graphic) || graphic.attachedThemeGraphic && getTheme(graphic.attachedThemeGraphic) || globalTheme.getTheme();
2097
- }
2098
- function getThemeFromGroup(graphic) {
2099
- let g;
2100
- if (g = graphic.isContainer ? graphic : graphic.parent, g) {
2101
- for (; g && !g.theme;) g = g.parent;
2102
- return g ? (g.theme || g.createTheme(), g.theme.getTheme(g)) : globalTheme.getTheme();
2103
- }
2104
- return null;
2105
- }
2106
-
2107
- function textAttributesToStyle(attrs) {
2108
- const style = {},
2109
- parsePxValue = value => /^\d+(\.\d+)?$/.test(`${value}`) ? `${value}px` : `${value}`;
2110
- return ["textAlign", "fontFamily", "fontVariant", "fontStyle", "fontWeight"].forEach(key => {
2111
- attrs[key] && (style[vutils.lowerCamelCaseToMiddle(key)] = attrs[key]);
2112
- }), ["fontSize", "lineHeight"].forEach(key => {
2113
- const styleKey = vutils.lowerCamelCaseToMiddle(key);
2114
- vutils.isNil(attrs[key]) || (style[styleKey] = parsePxValue(attrs[key]));
2115
- }), vutils.isValid(attrs.maxLineWidth) && (style["max-width"] = parsePxValue(attrs.maxLineWidth)), attrs.underline ? style["text-decoration"] = "underline" : attrs.lineThrough && (style["text-decoration"] = "line-through"), attrs.fill && vutils.isString(attrs.fill) && (style.color = attrs.fill), style;
2116
- }
2117
-
2118
- class HtmlAttributePlugin {
2119
- constructor() {
2120
- this.name = "HtmlAttributePlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.htmlMap = {}, this.renderId = 0, this.onWheel = ev => {
2121
- try {
2122
- const newEvent = new ev.constructor(ev.type, ev);
2123
- this.pluginService.stage.window.getContext().getCanvas().nativeCanvas.dispatchEvent(newEvent);
2124
- } catch (err) {
2125
- return;
2126
- }
2127
- };
2128
- }
2129
- activate(context) {
2130
- this.pluginService = context, context.stage.hooks.afterRender.tap(this.key, stage => {
2131
- stage && stage === this.pluginService.stage && this.drawHTML([...context.stage.getChildren()]);
2132
- });
2133
- }
2134
- deactivate(context) {
2135
- context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => item.name !== this.key), application.graphicService.hooks.onRemove.unTap(this.key), application.graphicService.hooks.onRelease.unTap(this.key), this.release();
2136
- }
2137
- getWrapContainer(stage, userContainer, domParams) {
2138
- let nativeContainer;
2139
- return nativeContainer = userContainer ? "string" == typeof userContainer ? application.global.getElementById(userContainer) : userContainer : stage.window.getContainer(), {
2140
- wrapContainer: application.global.createDom(Object.assign({
2141
- tagName: "div",
2142
- parent: nativeContainer
2143
- }, domParams)),
2144
- nativeContainer: nativeContainer
2145
- };
2146
- }
2147
- parseDefaultStyleFromGraphic(graphic) {
2148
- const attrs = "text" === graphic.type && graphic.attribute ? graphic.attribute : getTheme(graphic).text;
2149
- return textAttributesToStyle(attrs);
2150
- }
2151
- getTransformOfText(graphic) {
2152
- const textTheme = getTheme(graphic).text,
2153
- {
2154
- textAlign = textTheme.textAlign,
2155
- textBaseline = textTheme.textBaseline
2156
- } = graphic.attribute,
2157
- cssAttrs = graphic.globalTransMatrix.toTransformAttrs(),
2158
- {
2159
- rotateDeg: rotateDeg,
2160
- scaleX: scaleX,
2161
- scaleY: scaleY
2162
- } = cssAttrs,
2163
- translateMap = {
2164
- left: "0",
2165
- start: "0",
2166
- end: "-100%",
2167
- center: "-50%",
2168
- right: "-100%",
2169
- top: "0",
2170
- middle: "-50%",
2171
- bottom: "-100%",
2172
- alphabetic: "-79%"
2173
- },
2174
- originMap = {
2175
- left: "0",
2176
- start: "0",
2177
- end: "100%",
2178
- center: "50%",
2179
- right: "100%",
2180
- top: "0",
2181
- middle: "50%",
2182
- bottom: "100%",
2183
- alphabetic: "79%"
2184
- };
2185
- return {
2186
- textAlign: textAlign,
2187
- transform: `translate(${translateMap[textAlign]},${translateMap[textBaseline]}) rotate(${rotateDeg}deg) scaleX(${scaleX}) scaleY(${scaleY})`,
2188
- transformOrigin: `${originMap[textAlign]} ${originMap[textBaseline]}`
2189
- };
2190
- }
2191
- updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, options) {
2192
- const {
2193
- pointerEvents: pointerEvents,
2194
- penetrateEventList = []
2195
- } = options;
2196
- let calculateStyle = this.parseDefaultStyleFromGraphic(graphic);
2197
- calculateStyle.display = !1 !== graphic.attribute.visible ? "block" : "none", calculateStyle.pointerEvents = !0 === pointerEvents ? "all" : pointerEvents || "none", "none" !== calculateStyle.pointerEvents && (this.removeWrapContainerEventListener(wrapContainer), penetrateEventList.forEach(event => {
2198
- "wheel" === event && wrapContainer.addEventListener("wheel", this.onWheel);
2199
- })), wrapContainer.style.position || (wrapContainer.style.position = "absolute", nativeContainer.style.position = "relative");
2200
- let left = 0,
2201
- top = 0;
2202
- const b = graphic.globalAABBBounds;
2203
- let anchorType = options.anchorType;
2204
- if (vutils.isNil(anchorType) && (anchorType = "text" === graphic.type ? "position" : "boundsLeftTop"), "boundsLeftTop" === anchorType && (anchorType = "top-left"), "position" === anchorType || b.empty()) {
2205
- const matrix = graphic.globalTransMatrix;
2206
- left = matrix.e, top = matrix.f;
2207
- } else {
2208
- const anchor = vutils.calculateAnchorOfBounds(b, anchorType);
2209
- left = anchor.x, top = anchor.y;
2210
- }
2211
- const containerTL = application.global.getElementTopLeft(nativeContainer, !1),
2212
- windowTL = stage.window.getTopLeft(!1),
2213
- viewBox = stage.viewBox,
2214
- offsetX = left + windowTL.left - containerTL.left + viewBox.x1,
2215
- offsetTop = top + windowTL.top - containerTL.top + viewBox.y1;
2216
- if (calculateStyle.left = `${offsetX}px`, calculateStyle.top = `${offsetTop}px`, "text" === graphic.type && "position" === anchorType && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), this.getTransformOfText(graphic))), vutils.isFunction(options.style)) {
2217
- const userStyle = options.style({
2218
- top: offsetTop,
2219
- left: offsetX,
2220
- width: b.width(),
2221
- height: b.height()
2222
- }, graphic, wrapContainer);
2223
- userStyle && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), userStyle));
2224
- } else vutils.isObject(options.style) ? calculateStyle = Object.assign(Object.assign({}, calculateStyle), options.style) : vutils.isString(options.style) && options.style && (calculateStyle = Object.assign(Object.assign({}, calculateStyle), vutils.styleStringToObject(options.style)));
2225
- application.global.updateDom(wrapContainer, {
2226
- width: options.width,
2227
- height: options.height,
2228
- style: calculateStyle
2229
- });
2230
- }
2231
- clearCacheContainer() {
2232
- this.htmlMap && Object.keys(this.htmlMap).forEach(key => {
2233
- this.htmlMap[key] && this.htmlMap[key].renderId !== this.renderId && this.removeElement(key);
2234
- }), this.renderId += 1;
2235
- }
2236
- drawHTML(layers) {
2237
- "browser" === application.global.env && (layers.sort((a, b) => {
2238
- var _a, _b;
2239
- return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
2240
- }).forEach(group => {
2241
- this.renderGroupHTML(group);
2242
- }), this.clearCacheContainer());
2243
- }
2244
- renderGroupHTML(group) {
2245
- this.renderGraphicHTML(group), group.forEachChildren(g => {
2246
- g.isContainer ? this.renderGroupHTML(g) : this.renderGraphicHTML(g);
2247
- });
2248
- }
2249
- removeElement(id) {
2250
- if (!this.htmlMap || !this.htmlMap[id]) return;
2251
- const {
2252
- wrapContainer: wrapContainer
2253
- } = this.htmlMap[id];
2254
- wrapContainer && application.global.removeDom(wrapContainer), this.htmlMap[id] = null;
2255
- }
2256
- removeWrapContainerEventListener(wrapContainer) {
2257
- wrapContainer.removeEventListener("wheel", this.onWheel);
2258
- }
2259
- renderGraphicHTML(graphic) {
2260
- var _a;
2261
- const {
2262
- html: html
2263
- } = graphic.attribute;
2264
- if (!html) return;
2265
- const stage = graphic.stage;
2266
- if (!stage) return;
2267
- const {
2268
- dom: dom,
2269
- container: container
2270
- } = html;
2271
- if (!dom) return;
2272
- const id = vutils.isNil(html.id) ? `${null !== (_a = graphic.id) && void 0 !== _a ? _a : graphic._uid}_react` : html.id;
2273
- if (this.htmlMap && this.htmlMap[id] && container && container !== this.htmlMap[id].container && this.removeElement(id), this.htmlMap && this.htmlMap[id]) "string" == typeof dom ? this.htmlMap[id].wrapContainer.innerHTML = dom : dom !== this.htmlMap[id].wrapContainer.firstChild && (this.htmlMap[id].wrapContainer.removeChild(this.htmlMap[id].wrapContainer.firstChild), this.htmlMap[id].wrapContainer.appendChild(dom));else {
2274
- const {
2275
- wrapContainer: wrapContainer,
2276
- nativeContainer: nativeContainer
2277
- } = this.getWrapContainer(stage, container);
2278
- wrapContainer && ("string" == typeof dom ? wrapContainer.innerHTML = dom : wrapContainer.appendChild(dom), this.htmlMap || (this.htmlMap = {}), this.htmlMap[id] = {
2279
- wrapContainer: wrapContainer,
2280
- nativeContainer: nativeContainer,
2281
- container: container,
2282
- renderId: this.renderId
2283
- });
2284
- }
2285
- if (!this.htmlMap || !this.htmlMap[id]) return;
2286
- const {
2287
- wrapContainer: wrapContainer,
2288
- nativeContainer: nativeContainer
2289
- } = this.htmlMap[id];
2290
- this.updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, html), this.htmlMap[id].renderId = this.renderId;
2291
- }
2292
- release() {
2293
- "browser" === application.global.env && this.removeAllDom(this.pluginService.stage.defaultLayer);
2294
- }
2295
- removeAllDom(g) {
2296
- this.htmlMap && (Object.keys(this.htmlMap).forEach(key => {
2297
- this.removeElement(key);
2298
- }), this.htmlMap = null);
2299
- }
2300
- }
2301
-
2302
- class VTableVueAttributePlugin extends HtmlAttributePlugin {
518
+ class VTableVueAttributePlugin extends vrender.HtmlAttributePlugin {
2303
519
  renderQueue = new Set();
2304
520
  isRendering = false;
2305
521
  renderGraphicHTML(graphic) {
@@ -2441,7 +657,7 @@
2441
657
  let nativeContainer;
2442
658
  if (userContainer) {
2443
659
  nativeContainer =
2444
- typeof userContainer === 'string' ? application.global.getElementById(userContainer) : userContainer;
660
+ typeof userContainer === 'string' ? vrender.application.global.getElementById(userContainer) : userContainer;
2445
661
  }
2446
662
  else {
2447
663
  nativeContainer = stage.window.getContainer();
@@ -2459,7 +675,7 @@
2459
675
  };
2460
676
  }
2461
677
  return {
2462
- wrapContainer: application.global.createDom({ tagName: 'div', parent: nativeContainer }),
678
+ wrapContainer: vrender.application.global.createDom({ tagName: 'div', parent: nativeContainer }),
2463
679
  nativeContainer
2464
680
  };
2465
681
  }
@@ -2505,7 +721,7 @@
2505
721
  this.applyUserStyles(options, calculateStyle, { offsetX, offsetTop, graphic, wrapContainer });
2506
722
  const styleChanged = !vutils.isEqual(record.lastStyle, calculateStyle);
2507
723
  if (styleChanged) {
2508
- application.global.updateDom(wrapContainer, {
724
+ vrender.application.global.updateDom(wrapContainer, {
2509
725
  width,
2510
726
  height,
2511
727
  style: calculateStyle
@@ -2534,7 +750,7 @@
2534
750
  return vutils.calculateAnchorOfBounds(bounds, anchorType || 'top-left');
2535
751
  }
2536
752
  calculateOffset(stage, nativeContainer, x, y) {
2537
- const containerTL = application.global.getElementTopLeft(nativeContainer, false);
753
+ const containerTL = vrender.application.global.getElementTopLeft(nativeContainer, false);
2538
754
  const windowTL = stage.window.getTopLeft(false);
2539
755
  return {
2540
756
  left: x + windowTL.left - containerTL.left,
@@ -2603,7 +819,7 @@
2603
819
 
2604
820
  function useCellRender(props, tableRef) {
2605
821
  vue.watchEffect(() => {
2606
- if (!props?.customConfig?.createReactContainer) {
822
+ if (!props?.options?.customConfig?.createReactContainer) {
2607
823
  return;
2608
824
  }
2609
825
  if (!tableRef.value) {
@@ -3041,7 +1257,7 @@
3041
1257
  }
3042
1258
  CheckBox.symbol = 'CheckBox';
3043
1259
 
3044
- const version = "1.17.1";
1260
+ const version = "1.17.2";
3045
1261
 
3046
1262
  exports.VTable = VTable__namespace;
3047
1263
  Object.defineProperty(exports, 'register', {