dcim-topology2d 1.1.6 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. package/activity-diagram/src/final/final.d.ts +1 -1
  2. package/activity-diagram/src/final/final.rect.d.ts +1 -1
  3. package/activity-diagram/src/final/final.rect.js +1 -1
  4. package/activity-diagram/src/fork/fork.anchor.d.ts +1 -1
  5. package/activity-diagram/src/fork/fork.anchor.js +1 -1
  6. package/activity-diagram/src/fork/fork.d.ts +1 -1
  7. package/activity-diagram/src/fork/fork.rect.d.ts +1 -1
  8. package/activity-diagram/src/fork/fork.rect.js +1 -1
  9. package/activity-diagram/src/register.js +1 -1
  10. package/activity-diagram/src/swimlaneH/swimlaneH.d.ts +1 -1
  11. package/activity-diagram/src/swimlaneH/swimlaneH.rect.d.ts +1 -1
  12. package/activity-diagram/src/swimlaneH/swimlaneH.rect.js +1 -1
  13. package/activity-diagram/src/swimlaneV/swimlaneV.d.ts +1 -1
  14. package/activity-diagram/src/swimlaneV/swimlaneV.rect.d.ts +1 -1
  15. package/activity-diagram/src/swimlaneV/swimlaneV.rect.js +1 -1
  16. package/chart-diagram/index.d.ts +0 -2
  17. package/chart-diagram/index.js +0 -1
  18. package/chart-diagram/src/echarts/index.d.ts +2 -1
  19. package/chart-diagram/src/echarts/index.js +104 -106
  20. package/chart-diagram/src/register.js +8 -9
  21. package/class-diagram/src/class/class.d.ts +1 -1
  22. package/class-diagram/src/class/class.rect.d.ts +1 -1
  23. package/class-diagram/src/class/class.rect.js +1 -1
  24. package/class-diagram/src/register.js +1 -1
  25. package/core/index.d.ts +0 -1
  26. package/core/index.js +0 -1
  27. package/core/src/activeLayer.d.ts +10 -2
  28. package/core/src/activeLayer.js +41 -42
  29. package/core/src/animateLayer.d.ts +7 -3
  30. package/core/src/animateLayer.js +12 -10
  31. package/core/src/calling.d.ts +4 -1
  32. package/core/src/calling.js +41 -43
  33. package/core/src/canvas.d.ts +6 -1
  34. package/core/src/canvas.js +18 -17
  35. package/core/src/common.d.ts +5 -5
  36. package/core/src/common.js +202 -172
  37. package/core/src/core.d.ts +4 -3
  38. package/core/src/core.js +321 -339
  39. package/core/src/divLayer.d.ts +33 -2
  40. package/core/src/divLayer.js +292 -41
  41. package/core/src/healps/changeData.d.ts +1 -1
  42. package/core/src/healps/changeData.js +44 -102
  43. package/core/src/hoverLayer.d.ts +9 -2
  44. package/core/src/hoverLayer.js +34 -31
  45. package/core/src/middles/default.d.ts +3 -1
  46. package/core/src/middles/default.js +51 -51
  47. package/core/src/middles/index.js +2 -3
  48. package/core/src/middles/nodes/pentagon.rect.js +1 -1
  49. package/core/src/middles/nodes/rectangle.rect.js +1 -1
  50. package/core/src/models/data.d.ts +26 -0
  51. package/core/src/models/data.js +77 -0
  52. package/core/src/models/data.js.map +1 -0
  53. package/core/src/models/index.d.ts +1 -0
  54. package/core/src/models/index.js +1 -0
  55. package/core/src/models/node.d.ts +0 -6
  56. package/core/src/models/node.js +16 -29
  57. package/core/src/models/pen.js +7 -16
  58. package/core/src/mqtt.d.ts +14 -0
  59. package/core/src/mqtt.js +82 -0
  60. package/core/src/mqtt.js.map +1 -0
  61. package/core/src/offscreen.d.ts +4 -1
  62. package/core/src/offscreen.js +8 -10
  63. package/core/src/options.js +0 -1
  64. package/core/src/poll.js +2 -0
  65. package/core/src/preview.d.ts +13 -1
  66. package/core/src/preview.js +34 -56
  67. package/core/src/renderLayer.d.ts +3 -1
  68. package/core/src/renderLayer.js +31 -26
  69. package/core/src/socket.d.ts +10 -0
  70. package/core/src/socket.js +51 -0
  71. package/core/src/socket.js.map +1 -0
  72. package/core/src/utils/canvas.js +1 -1
  73. package/core/src/utils/conversion.d.ts +0 -7
  74. package/core/src/utils/conversion.js +0 -54
  75. package/core/src/utils/dom.d.ts +5 -6
  76. package/core/src/utils/dom.js +46 -82
  77. package/core/src/utils/index.d.ts +0 -1
  78. package/core/src/utils/index.js +0 -1
  79. package/core/src/utils/onmousevent.js +3 -12
  80. package/flow-diagram/src/comment/comment.anchor.d.ts +1 -1
  81. package/flow-diagram/src/comment/comment.anchor.js +1 -1
  82. package/flow-diagram/src/comment/comment.d.ts +1 -1
  83. package/flow-diagram/src/data/data.anchor.d.ts +1 -1
  84. package/flow-diagram/src/data/data.anchor.js +1 -1
  85. package/flow-diagram/src/data/data.d.ts +1 -1
  86. package/flow-diagram/src/data/data.rect.d.ts +1 -1
  87. package/flow-diagram/src/data/data.rect.js +1 -1
  88. package/flow-diagram/src/db/db.d.ts +1 -1
  89. package/flow-diagram/src/db/db.rect.d.ts +1 -1
  90. package/flow-diagram/src/db/db.rect.js +1 -1
  91. package/flow-diagram/src/display/display.anchor.d.ts +1 -1
  92. package/flow-diagram/src/display/display.anchor.js +1 -1
  93. package/flow-diagram/src/display/display.d.ts +1 -1
  94. package/flow-diagram/src/display/display.rect.d.ts +1 -1
  95. package/flow-diagram/src/display/display.rect.js +1 -1
  96. package/flow-diagram/src/document/document.anchor.d.ts +1 -1
  97. package/flow-diagram/src/document/document.anchor.js +1 -1
  98. package/flow-diagram/src/document/document.d.ts +1 -1
  99. package/flow-diagram/src/document/document.rect.d.ts +1 -1
  100. package/flow-diagram/src/document/document.rect.js +1 -1
  101. package/flow-diagram/src/externStorage/externStorage.anchor.d.ts +1 -1
  102. package/flow-diagram/src/externStorage/externStorage.anchor.js +1 -1
  103. package/flow-diagram/src/externStorage/externStorage.d.ts +1 -1
  104. package/flow-diagram/src/externStorage/externStorage.rect.d.ts +1 -1
  105. package/flow-diagram/src/externStorage/externStorage.rect.js +1 -1
  106. package/flow-diagram/src/internalStorage/internalStorage.d.ts +1 -1
  107. package/flow-diagram/src/internalStorage/internalStorage.rect.d.ts +1 -1
  108. package/flow-diagram/src/internalStorage/internalStorage.rect.js +1 -1
  109. package/flow-diagram/src/manually/manually.anchor.d.ts +1 -1
  110. package/flow-diagram/src/manually/manually.anchor.js +1 -1
  111. package/flow-diagram/src/manually/manually.d.ts +1 -1
  112. package/flow-diagram/src/manually/manually.rect.d.ts +1 -1
  113. package/flow-diagram/src/manually/manually.rect.js +1 -1
  114. package/flow-diagram/src/parallel/parallel.anchor.d.ts +1 -1
  115. package/flow-diagram/src/parallel/parallel.anchor.js +1 -1
  116. package/flow-diagram/src/parallel/parallel.d.ts +1 -1
  117. package/flow-diagram/src/queue/queue.d.ts +1 -1
  118. package/flow-diagram/src/queue/queue.rect.d.ts +1 -1
  119. package/flow-diagram/src/queue/queue.rect.js +1 -1
  120. package/flow-diagram/src/register.js +1 -1
  121. package/flow-diagram/src/subprocess/subprocess.d.ts +1 -1
  122. package/flow-diagram/src/subprocess/subprocess.rect.d.ts +1 -1
  123. package/flow-diagram/src/subprocess/subprocess.rect.js +1 -1
  124. package/layout/src/align.d.ts +1 -1
  125. package/layout/src/align.js +1 -1
  126. package/layout/src/layout.d.ts +1 -1
  127. package/layout/src/layout.js +1 -1
  128. package/myShape-diagram/myShape.js +1 -1
  129. package/package.json +1 -1
  130. package/sequence-diagram/src/focus/focus.anchor.d.ts +1 -1
  131. package/sequence-diagram/src/focus/focus.anchor.js +1 -1
  132. package/sequence-diagram/src/focus/focus.d.ts +1 -1
  133. package/sequence-diagram/src/focus/focus.rect.d.ts +1 -1
  134. package/sequence-diagram/src/focus/focus.rect.js +1 -1
  135. package/sequence-diagram/src/lifeline/lifeline.anchor.d.ts +1 -1
  136. package/sequence-diagram/src/lifeline/lifeline.anchor.js +1 -1
  137. package/sequence-diagram/src/lifeline/lifeline.d.ts +1 -1
  138. package/sequence-diagram/src/lifeline/lifeline.rect.d.ts +1 -1
  139. package/sequence-diagram/src/lifeline/lifeline.rect.js +1 -1
  140. package/sequence-diagram/src/register.js +1 -1
  141. package/chart-diagram/src/utils/changeOptions.d.ts +0 -4
  142. package/chart-diagram/src/utils/changeOptions.js +0 -163
  143. package/chart-diagram/src/utils/conversion.d.ts +0 -17
  144. package/chart-diagram/src/utils/conversion.js +0 -179
  145. package/chart-diagram/src/utils/drawGraphic.d.ts +0 -3
  146. package/chart-diagram/src/utils/drawGraphic.js +0 -97
  147. package/chart-diagram/src/utils/index.d.ts +0 -3
  148. package/chart-diagram/src/utils/index.js +0 -3
  149. package/core/src/middles/arrows/index.d.ts +0 -4
  150. package/core/src/middles/arrows/index.js +0 -5
  151. package/core/src/middles/lines/index.d.ts +0 -4
  152. package/core/src/middles/lines/index.js +0 -5
  153. package/core/src/middles/nodes/iframe.d.ts +0 -2
  154. package/core/src/middles/nodes/iframe.js +0 -12
  155. package/core/src/middles/nodes/index.d.ts +0 -46
  156. package/core/src/middles/nodes/index.js +0 -47
  157. package/core/src/store/common.d.ts +0 -9
  158. package/core/src/store/common.js +0 -5
  159. package/core/src/store/data.d.ts +0 -129
  160. package/core/src/store/data.js +0 -86
  161. package/core/src/store/index.d.ts +0 -2
  162. package/core/src/store/index.js +0 -2
  163. package/core/src/utils/assignment.d.ts +0 -3
  164. package/core/src/utils/assignment.js +0 -69
  165. package/static/echartsDefaultData.js +0 -239
  166. package/static/echartsStore.js +0 -14
  167. package/static/index.js +0 -2
  168. package/style/index.css +0 -13
@@ -1,8 +1,8 @@
1
1
  var __extends = (this && this.__extends) || (function () {
2
2
  var extendStatics = function (d, b) {
3
3
  extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
6
  return extendStatics(d, b);
7
7
  };
8
8
  return function (d, b) {
@@ -12,16 +12,22 @@ var __extends = (this && this.__extends) || (function () {
12
12
  };
13
13
  })();
14
14
  import { Store } from 'le5le-store';
15
- import { PenType, Node, Line, Rect, Point, Lock } from './models';
15
+ import { PenType } from './models/pen';
16
+ import { Node } from './models/node';
17
+ import { Line } from './models/line';
18
+ import { Rect } from './models/rect';
19
+ import { Point } from './models/point';
20
+ import { Lock } from './models/status';
16
21
  import { drawLineFns } from './middles';
17
22
  import { getBezierPoint } from './middles/lines/curve';
18
23
  import { Layer } from './layer';
19
24
  import { flatNodes } from './utils';
20
- import { commonStore } from './store'
21
25
  var ActiveLayer = /** @class */ (function (_super) {
22
26
  __extends(ActiveLayer, _super);
23
- function ActiveLayer(TID) {
27
+ function ActiveLayer(options, TID) {
28
+ if (options === void 0) { options = {}; }
24
29
  var _this = _super.call(this, TID) || this;
30
+ _this.options = options;
25
31
  _this.rotateCPs = [];
26
32
  _this.sizeCPs = [];
27
33
  _this.pens = [];
@@ -36,11 +42,11 @@ var ActiveLayer = /** @class */ (function (_super) {
36
42
  // nodes移动时,停靠点的参考位置
37
43
  _this.dockWatchers = [];
38
44
  _this.rotating = false;
45
+ _this.data = Store.get(_this.generateStoreKey('topology-data'));
39
46
  Store.set(_this.generateStoreKey('LT:ActiveLayer'), _this);
40
47
  return _this;
41
48
  }
42
49
  ActiveLayer.prototype.calcControlPoints = function () {
43
- var globalStore = commonStore[this.TID];
44
50
  if (this.pens.length === 1 && this.pens[0] instanceof Node) {
45
51
  this.rect = this.pens[0].rect;
46
52
  this.sizeCPs = this.pens[0].rect.toPoints();
@@ -68,7 +74,7 @@ var ActiveLayer = /** @class */ (function (_super) {
68
74
  }
69
75
  }
70
76
  }
71
- if (globalStore.options.hideRotateCP || this.pens[0].hideRotateCP) {
77
+ if (this.options.hideRotateCP || this.pens[0].hideRotateCP) {
72
78
  this.rotateCPs = [new Point(-1000, -1000), new Point(-1000, -1000)];
73
79
  }
74
80
  return;
@@ -96,10 +102,9 @@ var ActiveLayer = /** @class */ (function (_super) {
96
102
  this.rect = new Rect(x1, y1, x2 - x1, y2 - y1);
97
103
  this.sizeCPs = [new Point(x1, y1), new Point(x2, y1), new Point(x2, y2), new Point(x1, y2)];
98
104
  this.rotateCPs = [new Point(x1 + (x2 - x1) / 2, y1 - 35), new Point(x1 + (x2 - x1) / 2, y1)];
99
- if (globalStore.options.hideRotateCP) {
105
+ if (this.options.hideRotateCP) {
100
106
  this.rotateCPs = [new Point(-1000, -1000), new Point(-1000, -1000)];
101
107
  }
102
- globalStore = null;
103
108
  };
104
109
  ActiveLayer.prototype.locked = function () {
105
110
  for (var _i = 0, _a = this.pens; _i < _a.length; _i++) {
@@ -187,10 +192,10 @@ var ActiveLayer = /** @class */ (function (_super) {
187
192
  }
188
193
  var offsetX = p2.x - p1.x;
189
194
  var offsetY = p2.y - p1.y;
190
- if (commonStore[this.TID].options.onlySizeX) {
195
+ if (this.options.onlySizeX) {
191
196
  offsetY = 0;
192
197
  }
193
- if (commonStore[this.TID].options.onlySizeY) {
198
+ if (this.options.onlySizeY) {
194
199
  offsetX = 0;
195
200
  }
196
201
  var lines = [];
@@ -278,7 +283,6 @@ var ActiveLayer = /** @class */ (function (_super) {
278
283
  if (this.nodeRects.length !== this.pens.length) {
279
284
  return;
280
285
  }
281
- var globalStore = commonStore[this.TID];
282
286
  var i = 0;
283
287
  for (var _i = 0, _a = this.pens; _i < _a.length; _i++) {
284
288
  var item = _a[_i];
@@ -297,7 +301,7 @@ var ActiveLayer = /** @class */ (function (_super) {
297
301
  item.calcChildrenRect();
298
302
  if (item.parentId && !item.locked) {
299
303
  var parent_1 = void 0;
300
- for (var _c = 0, _d = globalStore.data.pens; _c < _d.length; _c++) {
304
+ for (var _c = 0, _d = this.data.pens; _c < _d.length; _c++) {
301
305
  var n = _d[_c];
302
306
  if (n.id === item.parentId) {
303
307
  parent_1 = n;
@@ -317,7 +321,7 @@ var ActiveLayer = /** @class */ (function (_super) {
317
321
  var offsetX_1 = this.nodeRects[i].x + x - item.from.x;
318
322
  var offsetY_1 = this.nodeRects[i].y + y - item.from.y;
319
323
  if (item.parentId) {
320
- var items = find(item.parentId, globalStore.data.pens);
324
+ var items = find(item.parentId, this.data.pens);
321
325
  items.forEach(function (l) {
322
326
  l.translate(offsetX_1, offsetY_1);
323
327
  });
@@ -334,7 +338,7 @@ var ActiveLayer = /** @class */ (function (_super) {
334
338
  ActiveLayer.prototype.getLinesOfNode = function (node) {
335
339
  var result = [];
336
340
  var nodesLines = flatNodes([node]);
337
- for (var _i = 0, _a = commonStore[this.TID].data.pens; _i < _a.length; _i++) {
341
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
338
342
  var pen = _a[_i];
339
343
  if (!(pen instanceof Line)) {
340
344
  continue;
@@ -361,10 +365,9 @@ var ActiveLayer = /** @class */ (function (_super) {
361
365
  if (!pens) {
362
366
  pens = this.pens;
363
367
  }
364
- var globalStore = commonStore[this.TID];
365
368
  var nodesLines = flatNodes(pens);
366
369
  var lines = [];
367
- nodesLines.lines.push.apply(nodesLines.lines, globalStore.data.pens.filter(function (pen) { return pen.type; }));
370
+ nodesLines.lines.push.apply(nodesLines.lines, this.data.pens.filter(function (pen) { return pen.type; }));
368
371
  for (var _i = 0, _a = nodesLines.lines; _i < _a.length; _i++) {
369
372
  var line = _a[_i];
370
373
  for (var _b = 0, _c = nodesLines.nodes; _b < _c.length; _b++) {
@@ -380,7 +383,7 @@ var ActiveLayer = /** @class */ (function (_super) {
380
383
  line.to.y = item.rotatedAnchors[line.to.anchorIndex].y;
381
384
  ++cnt;
382
385
  }
383
- if (cnt && !globalStore.data.manualCps) {
386
+ if (cnt && !this.data.manualCps) {
384
387
  line.calcControlPoints();
385
388
  }
386
389
  line.textRect = null;
@@ -389,7 +392,6 @@ var ActiveLayer = /** @class */ (function (_super) {
389
392
  }
390
393
  }
391
394
  Store.set(this.generateStoreKey('LT:updateLines'), lines);
392
- globalStore = null;
393
395
  };
394
396
  ActiveLayer.prototype.offsetRotate = function (angle) {
395
397
  this.rotating = true;
@@ -490,9 +492,7 @@ var ActiveLayer = /** @class */ (function (_super) {
490
492
  };
491
493
  ActiveLayer.prototype.render = function (ctx) {
492
494
  var _this = this;
493
- if(!commonStore || !commonStore[_this.TID]) return;
494
- var globalStore = commonStore[_this.TID];
495
- if (globalStore.data.locked > Lock.Readonly) {
495
+ if (this.data.locked > Lock.Readonly) {
496
496
  return;
497
497
  }
498
498
 
@@ -508,7 +508,7 @@ var ActiveLayer = /** @class */ (function (_super) {
508
508
  this.calcControlPoints();
509
509
  }
510
510
  ctx.save();
511
- ctx.strokeStyle = globalStore.options.activeColor;
511
+ ctx.strokeStyle = this.options.activeColor;
512
512
  ctx.fillStyle = '#fff';
513
513
  ctx.lineWidth = 1;
514
514
  var TID = this.TID;
@@ -528,7 +528,7 @@ var ActiveLayer = /** @class */ (function (_super) {
528
528
  tmp.strokeStyle = '#ffffff';
529
529
  tmp.lineWidth += 2;
530
530
  tmp.render(ctx);
531
- tmp.strokeStyle = globalStore.options.activeColor;
531
+ tmp.strokeStyle = this.options.activeColor;
532
532
  tmp.lineWidth -= 2;
533
533
  }
534
534
  }
@@ -543,11 +543,11 @@ var ActiveLayer = /** @class */ (function (_super) {
543
543
  bk.strokeStyle = '#ffffff';
544
544
  bk.render(ctx);
545
545
  }
546
- tmp.strokeStyle = globalStore.options.activeColor;
547
- tmp.fromArrowColor = globalStore.options.activeColor;
548
- tmp.toArrowColor = globalStore.options.activeColor;
546
+ tmp.strokeStyle = this.options.activeColor;
547
+ tmp.fromArrowColor = this.options.activeColor;
548
+ tmp.toArrowColor = this.options.activeColor;
549
549
  tmp.render(ctx);
550
- if (!globalStore.data.locked && !item.locked) {
550
+ if (!this.data.locked && !item.locked) {
551
551
  drawLineFns[item.name].drawControlPointsFn(ctx, item);
552
552
  }
553
553
  }
@@ -573,7 +573,7 @@ var ActiveLayer = /** @class */ (function (_super) {
573
573
  ctx.closePath();
574
574
  ctx.stroke();
575
575
  ctx.restore();
576
- if (globalStore.data.locked || this.locked()) {
576
+ if (this.data.locked || this.locked()) {
577
577
  ctx.restore();
578
578
  return;
579
579
  }
@@ -589,7 +589,7 @@ var ActiveLayer = /** @class */ (function (_super) {
589
589
  ctx.fill();
590
590
  ctx.stroke();
591
591
  // Draw size control points.绘制拖拽框四角的点
592
- if (!globalStore.options.hideSizeCP && (this.pens.length > 1 || !this.pens[0].hideSizeCP)) {
592
+ if (!this.options.hideSizeCP && (this.pens.length > 1 || !this.pens[0].hideSizeCP)) {
593
593
  ctx.lineWidth = 1;
594
594
  for (var _b = 0, _c = this.sizeCPs; _b < _c.length; _b++) {
595
595
  var item = _c[_b];
@@ -606,7 +606,6 @@ var ActiveLayer = /** @class */ (function (_super) {
606
606
  }
607
607
  }
608
608
  ctx.restore();
609
- globalStore = null;
610
609
  };
611
610
  ActiveLayer.prototype.getDockWatchers = function () {
612
611
  if (this.pens.length === 1) {
@@ -623,7 +622,7 @@ var ActiveLayer = /** @class */ (function (_super) {
623
622
  ActiveLayer.prototype.handleArbitrayGraphSize = function (type,item, offsetX, offsetY, l, sizeX, sizeY, nodeRectsCircles) {
624
623
  if(item.name !== 'arbitraryGraph') return
625
624
 
626
- switch (type) {
625
+ switch (type) {
627
626
 
628
627
  case 0:
629
628
 
@@ -635,7 +634,7 @@ var ActiveLayer = /** @class */ (function (_super) {
635
634
 
636
635
  }
637
636
 
638
- break;
637
+ break;
639
638
 
640
639
  case 1:
641
640
 
@@ -647,19 +646,19 @@ var ActiveLayer = /** @class */ (function (_super) {
647
646
 
648
647
  }
649
648
 
650
- break;
649
+ break;
651
650
 
652
651
  case 2:
653
652
 
654
- for(let c=0, length = item.rect.circles.length; c<length; c++ ) {
655
-
656
- item.rect.circles[c].x=item.rect.circles[c].x*sizeX+item.rect.x*(1-sizeX);
653
+ for(let c=0, length = item.rect.circles.length; c<length; c++ ) {
657
654
 
658
- item.rect.circles[c].y=item.rect.circles[c].y*sizeY+item.rect.y*(1-sizeY);
655
+ item.rect.circles[c].x=item.rect.circles[c].x*sizeX+item.rect.x*(1-sizeX);
656
+
657
+ item.rect.circles[c].y=item.rect.circles[c].y*sizeY+item.rect.y*(1-sizeY);
659
658
 
660
- }
659
+ }
661
660
 
662
- break;
661
+ break;
663
662
 
664
663
  case 3:
665
664
 
@@ -671,10 +670,10 @@ var ActiveLayer = /** @class */ (function (_super) {
671
670
 
672
671
  }
673
672
 
674
- break
673
+ break
675
674
  }
676
675
  };
677
676
  return ActiveLayer;
678
677
  }(Layer));
679
678
  export { ActiveLayer };
680
- //# sourceMappingURL=activeLayer.js.map
679
+ //# sourceMappingURL=activeLayer.js.map
@@ -1,13 +1,17 @@
1
- import { Pen, Line } from './models';
1
+ import { Pen } from './models/pen';
2
+ import { Line } from './models/line';
3
+ import { TopologyData } from './models/data';
4
+ import { Options } from './options';
2
5
  import { Layer } from './layer';
3
6
  export declare class AnimateLayer extends Layer {
4
- // @ts-ignore
7
+ options: Options;
8
+ protected data: TopologyData;
5
9
  pens: Map<any, any>;
6
10
  private timer;
7
11
  private lastNow;
8
12
  private subscribeUpdate;
9
13
  private subscribePlay;
10
- constructor(TID: String);
14
+ constructor(options: Options, TID: String);
11
15
  getAnimateLine(item: Pen): Line;
12
16
  findLine(pen: Pen): Pen;
13
17
  readyPlay(tag?: string, auto?: boolean, pens?: Pen[]): void;
@@ -12,19 +12,23 @@ var __extends = (this && this.__extends) || (function () {
12
12
  };
13
13
  })();
14
14
  import { Store } from 'le5le-store';
15
- import { PenType, Node, Line } from './models';
15
+ import { PenType } from './models/pen';
16
+ import { Node } from './models/node';
17
+ import { Line } from './models/line';
16
18
  import { Layer } from './layer';
17
19
  import { s8 } from './utils';
18
- import { commonStore } from './store'
19
20
  var AnimateLayer = /** @class */ (function (_super) {
20
21
  __extends(AnimateLayer, _super);
21
- function AnimateLayer(TID) {
22
+ function AnimateLayer(options, TID) {
23
+ if (options === void 0) { options = {}; }
22
24
  var _this = _super.call(this, TID) || this;
25
+ _this.options = options;
23
26
  _this.pens = new Map();
24
27
  _this.lastNow = 0;
28
+ _this.data = Store.get(_this.generateStoreKey('topology-data'));
25
29
  Store.set(_this.generateStoreKey('LT:AnimateLayer'), _this);
26
- if (!commonStore[TID].options.animateColor) {
27
- commonStore[TID].options.animateColor = '#ff6600';
30
+ if (!_this.options.animateColor) {
31
+ _this.options.animateColor = '#ff6600';
28
32
  }
29
33
  _this.subscribeUpdate = Store.subscribe(_this.generateStoreKey('LT:updateLines'), function (lines) {
30
34
  _this.updateLines(lines);
@@ -51,7 +55,7 @@ var AnimateLayer = /** @class */ (function (_super) {
51
55
  l.animateStart = item.animateStart;
52
56
  l.lineCap = 'round';
53
57
  l.fillStyle = '#fff';
54
- l.strokeStyle = l.animateColor || commonStore[this.TID].options.animateColor;
58
+ l.strokeStyle = l.animateColor || this.options.animateColor;
55
59
  l.length = l.getLen();
56
60
  if (!l.fromArrowColor) {
57
61
  l.fromArrowColor = l.strokeStyle || '#222';
@@ -62,7 +66,7 @@ var AnimateLayer = /** @class */ (function (_super) {
62
66
  return l;
63
67
  };
64
68
  AnimateLayer.prototype.findLine = function (pen) {
65
- for (var _i = 0, _a = commonStore[this.TID].data.pens; _i < _a.length; _i++) {
69
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
66
70
  var item = _a[_i];
67
71
  if (item.id === pen.data) {
68
72
  return item;
@@ -71,13 +75,11 @@ var AnimateLayer = /** @class */ (function (_super) {
71
75
  };
72
76
  AnimateLayer.prototype.readyPlay = function (tag, auto, pens) {
73
77
  var _this = this;
74
- if(!commonStore || !commonStore[_this.TID]) return;
75
78
  var readyPens = new Map();
76
79
  if (!pens) {
77
- pens = commonStore[_this.TID].data.pens;
80
+ pens = this.data.pens;
78
81
  }
79
82
  pens.forEach(function (pen) {
80
- if(!(pen instanceof Node)) pen = new Node(pen);
81
83
  pen.setTID(_this.TID);
82
84
  if (!pen.visible || readyPens.get(pen.id)) {
83
85
  return;
@@ -2,9 +2,12 @@
2
2
  import {Options, Padding} from './options';
3
3
  import { Offscreen } from './offscreen';
4
4
  import { RenderLayer } from './renderLayer';
5
- import { Pen, Point, Rect } from './models';
5
+ import { Pen, Node, Point, TopologyData, Rect } from './models';
6
6
  export declare class Calling {
7
7
  id: String;
8
+ data: TopologyData;
9
+ options: Options;
10
+ parentElem: HTMLElement;
8
11
  canvas: RenderLayer;
9
12
  offscreen: Offscreen;
10
13
  private subcribeImage;
@@ -1,30 +1,33 @@
1
1
  import {Store} from 'le5le-store';
2
+ import {DefalutOptions} from './options';
2
3
  import {Offscreen} from './offscreen';
3
4
  import {RenderLayer} from './renderLayer';
4
- import {Node} from './models';
5
+ import {Node, Point, TopologyData, Rect} from './models';
5
6
  import {s8, getRect, formatPadding} from './utils';
6
- import { useStore, clearStore } from './store'
7
7
  var Calling = (function () {
8
8
  function Calling(parent, options) {
9
9
  var _this = this;
10
+ this.data = new TopologyData();
10
11
  this.lastTranlated = {x: 0, y: 0};
11
12
  this.rendering = false;
12
13
  this.id = s8();
13
- this.store = useStore(this.id);
14
+ Store.set(this.generateStoreKey('topology-data'), this.data);
14
15
  if (!options) {
15
16
  options = {};
16
17
  }
17
- options.type = this.store.options.isFitview ? 'titLogo' : 'bottLogo';
18
- Object.assign(this.store.options, options);
18
+ var font = Object.assign({}, DefalutOptions.font, options.font);
19
+ options.font = font;
20
+ this.options = Object.assign({}, DefalutOptions, options);
19
21
  if (typeof parent === 'string') {
20
- this.store.parentElem = document.getElementById(parent);
22
+ this.parentElem = document.getElementById(parent);
21
23
  } else {
22
- this.store.parentElem = parent;
24
+ this.parentElem = parent;
23
25
  }
24
- this.store.parentElem.style.position = 'relative';
25
- this.store.parentElem.style.overflow = 'auto';
26
- this.offscreen = new Offscreen(this.id);
27
- this.canvas = new RenderLayer(this.id);
26
+ this.parentElem.style.position = 'relative';
27
+ this.parentElem.style.overflow = 'auto';
28
+ var id = this.id;
29
+ this.offscreen = new Offscreen(this.parentElem, this.options, id);
30
+ this.canvas = new RenderLayer(this.parentElem, this.options, id);
28
31
  this.subcribeImage = Store.subscribe(this.generateStoreKey('LT:imageLoaded'), function () {
29
32
  if (_this.imageTimer) {
30
33
  clearTimeout(_this.imageTimer);
@@ -65,55 +68,52 @@ var Calling = (function () {
65
68
  data = JSON.parse(data);
66
69
  }
67
70
  this.openCount = 0
68
- this.store.data.scale = data.scale || 1;
69
- this.store.data.pens = [];
71
+ this.data.scale = data.scale || 1;
72
+ this.data.pens = [];
70
73
  // for old data.
71
74
  if (data.nodes) {
72
75
  for (var _i = 0, _a = data.nodes; _i < _a.length; _i++) {
73
76
  var item = _a[_i];
74
- item.TID = this.id;
75
77
  item.rect.x = 0;
76
78
  item.rect.y = 0;
77
- this.store.data.pens.push(new Node(item));
79
+ this.data.pens.push(new Node(item));
78
80
  }
79
81
  for (var _b = 0, _c = data.lines; _b < _c.length; _b++) {
80
82
  var item = _c[_b];
81
- item.TID = this.id;
82
- this.store.data.pens.push(new Line(item));
83
+ this.data.pens.push(new Line(item));
83
84
  }
84
85
  }
85
86
  // end.
86
87
  if (data.pens) {
87
88
  for (var _d = 0, _e = data.pens; _d < _e.length; _d++) {
88
89
  var item = _e[_d];
89
- item.TID = this.id;
90
90
  if (!item.from) {
91
- this.store.data.pens.push(new Node(item));
91
+ this.data.pens.push(new Node(item));
92
92
  } else {
93
- this.store.data.pens.push(new Line(item));
93
+ this.data.pens.push(new Line(item));
94
94
  }
95
95
  }
96
96
  }
97
- this.store.data.bkImageRect = data.bkImageRect || null;
98
- this.store.data.bkImage = data.bkImage || '';
99
- this.store.data.mqttOptions = data.mqttOptions || {clientId: s8()};
100
- this.store.data.mqttTopics = data.mqttTopics || '';
97
+ this.data.bkImageRect = data.bkImageRect || null;
98
+ this.data.bkImage = data.bkImage || '';
99
+ this.data.mqttOptions = data.mqttOptions || {clientId: s8()};
100
+ this.data.mqttTopics = data.mqttTopics || '';
101
101
  if (typeof data.data === 'object') {
102
- this.store.data.data = data.data;
102
+ this.data.data = data.data;
103
103
  } else {
104
- this.store.data.data = data.data || '';
104
+ this.data.data = data.data || '';
105
105
  }
106
- this.store.parentElem.scrollLeft = 0;
107
- this.store.parentElem.scrollTop = 0;
106
+ this.parentElem.scrollLeft = 0;
107
+ this.parentElem.scrollTop = 0;
108
108
  this.overflow();
109
109
  this.render(true);
110
110
  };
111
111
  Calling.prototype.overflow = function () {
112
- this.store.options.isFitview ? this.fitView() : this.bottomView();
112
+ this.options.isFitview ? this.fitView() : this.bottomView();
113
113
  };
114
114
  Calling.prototype.getRect = function (pens) {
115
115
  if (!pens) {
116
- pens = this.store.data.pens;
116
+ pens = this.data.pens;
117
117
  }
118
118
  return getRect(pens);
119
119
  };
@@ -124,7 +124,7 @@ var Calling = (function () {
124
124
  }
125
125
  var offsetX = x - this.lastTranlated.x;
126
126
  var offsetY = y - this.lastTranlated.y;
127
- for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
127
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
128
128
  var item = _a[_i];
129
129
  item.translate(offsetX, offsetY);
130
130
  }
@@ -135,14 +135,13 @@ var Calling = (function () {
135
135
  // > 1, expand
136
136
  // < 1, reduce
137
137
  Calling.prototype.scale = function (scale, center, w, h) {
138
- if (this.store.data.scale * scale < this.store.options.minScale ||
139
- this.store.data.scale * scale > this.store.options.maxScale) {
138
+ if (this.data.scale * scale < this.options.minScale ||
139
+ this.data.scale * scale > this.options.maxScale) {
140
140
  return;
141
141
  }
142
- this.store.data.scale *= scale;
142
+ this.data.scale *= scale;
143
143
  !center && (center = this.getRect().center);
144
- center.type = this.store.options.type;
145
- for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
144
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
146
145
  var item = _a[_i];
147
146
  item.scale(scale, center, w, h);
148
147
  }
@@ -151,7 +150,7 @@ var Calling = (function () {
151
150
  var rect = this.getRect();
152
151
  var viewCenter = this.getViewCenter(padding);
153
152
  var center = rect.center;
154
- var parentElem = this.store.parentElem;
153
+ var parentElem = this.canvas.parentElem;
155
154
  var x = (parentElem.offsetWidth - rect.width) / 2;
156
155
  var y = parentElem.scrollHeight - rect.height;
157
156
  var w = parentElem.offsetWidth / rect.width;
@@ -161,7 +160,7 @@ var Calling = (function () {
161
160
  ratio = h;
162
161
  }
163
162
  this.canvas.canvas.style.transform = `translate(${x}px, ${y}px)`;
164
- for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
163
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
165
164
  var item = _a[_i];
166
165
  if(item.rect.x > 0) {
167
166
  item.rect.ex = item.rect.ex - item.rect.x;
@@ -182,7 +181,7 @@ var Calling = (function () {
182
181
  var viewCenter = this.getViewCenter(padding);
183
182
  var center = rect.center;
184
183
  this.translate(viewCenter.x - center.x, viewCenter.y - center.y);
185
- var parentElem = this.store.parentElem;
184
+ var parentElem = this.canvas.parentElem;
186
185
  var x = (parentElem.scrollWidth - parentElem.offsetWidth) / 2;
187
186
  var y = (parentElem.scrollHeight - parentElem.offsetHeight) / 2;
188
187
  parentElem.scrollTo(x, y);
@@ -192,7 +191,7 @@ var Calling = (function () {
192
191
  if (!this.hasView())
193
192
  return;
194
193
  // 1. 重置画布尺寸为容器尺寸
195
- var parentElem = this.store.parentElem;
194
+ var parentElem = this.canvas.parentElem;
196
195
  var width = parentElem.offsetWidth, height = parentElem.offsetHeight;
197
196
  this.resize({
198
197
  width: width,
@@ -201,7 +200,7 @@ var Calling = (function () {
201
200
  // 2. 图形居中
202
201
  this.centerView(viewPadding);
203
202
  // 3. 获取设置的留白值
204
- var padding = formatPadding(viewPadding || this.store.options.viewPadding);
203
+ var padding = formatPadding(viewPadding || this.options.viewPadding);
205
204
  // 4. 获取图形尺寸
206
205
  var rect = this.getRect();
207
206
  // 6. 计算缩放比
@@ -218,7 +217,7 @@ var Calling = (function () {
218
217
  return !(rect.width === 99999 || rect.height === 99999);
219
218
  };
220
219
  Calling.prototype.getViewCenter = function (viewPadding) {
221
- var padding = formatPadding(viewPadding || this.store.options.viewPadding);
220
+ var padding = formatPadding(viewPadding || this.options.viewPadding);
222
221
  var _a = this.canvas, width = _a.width, height = _a.height;
223
222
  return {
224
223
  x: (width - padding[1] - padding[3]) / 2 + padding[3],
@@ -229,7 +228,6 @@ var Calling = (function () {
229
228
  return this.id + "-" + key;
230
229
  };
231
230
  Calling.prototype.destroy = function () {
232
- clearStore(this.store);
233
231
  this.subcribeImage.unsubscribe();
234
232
  this.canvas.destroy();
235
233
  //优化
@@ -1,10 +1,15 @@
1
+ import { TopologyData } from './models/data';
2
+ import { Options } from './options';
1
3
  import { Layer } from './layer';
2
4
  export declare class Canvas extends Layer {
5
+ parentElem: HTMLElement;
6
+ options: Options;
3
7
  static dpiRatio: number;
8
+ protected data: TopologyData;
4
9
  canvas: HTMLCanvasElement;
5
10
  width: number;
6
11
  height: number;
7
- constructor(TID: String);
12
+ constructor(parentElem: HTMLElement, options: Options, TID: String);
8
13
  resize(size?: {
9
14
  width: number;
10
15
  height: number;
@@ -13,50 +13,51 @@ var __extends = (this && this.__extends) || (function () {
13
13
  })();
14
14
  import { Store } from 'le5le-store';
15
15
  import { Layer } from './layer';
16
- import { commonStore } from './store'
17
16
  var Canvas = /** @class */ (function (_super) {
18
17
  __extends(Canvas, _super);
19
- function Canvas(TID) {
18
+ function Canvas(parentElem, options, TID) {
19
+ if (options === void 0) { options = {}; }
20
20
  var _this = _super.call(this, TID) || this;
21
+ _this.parentElem = parentElem;
22
+ _this.options = options;
21
23
  _this.canvas = document.createElement('canvas');
22
- _this.width = commonStore[TID].parentElem.clientWidth;
23
- _this.height = commonStore[TID].parentElem.clientHeight;
24
+ _this.width = parentElem.clientWidth;
25
+ _this.height = parentElem.clientHeight;
26
+ _this.data = Store.get(_this.generateStoreKey('topology-data'));
24
27
  _this.canvas.style.position = 'absolute';
25
28
  _this.canvas.style.left = '0';
26
29
  _this.canvas.style.top = '0';
27
30
  _this.canvas.style.outline = 'none';
28
31
  if (!Canvas.dpiRatio) {
29
- if (!commonStore[TID].options.extDpiRatio && commonStore[TID].options.extDpiRatio !== 0) {
32
+ if (!options.extDpiRatio && options.extDpiRatio !== 0) {
30
33
  if (window.devicePixelRatio > 1) {
31
- commonStore[TID].options.extDpiRatio = 0.25;
34
+ options.extDpiRatio = 0.25;
32
35
  }
33
36
  else {
34
- commonStore[TID].options.extDpiRatio = 0;
37
+ options.extDpiRatio = 0;
35
38
  }
36
39
  }
37
- Canvas.dpiRatio = window.devicePixelRatio + commonStore[TID].options.extDpiRatio;
40
+ Canvas.dpiRatio = window.devicePixelRatio + options.extDpiRatio;
38
41
  }
39
42
  return _this;
40
43
  }
41
44
  Canvas.prototype.resize = function (size) {
42
45
  if (size) {
43
- this.width = size.width | 0;
46
+ this.width = size.width | 0;
44
47
  this.height = size.height | 0;
45
48
  }
46
49
  else {
47
- const TID = this.TID;
48
- if(!commonStore[TID] || !commonStore[TID].options) return;
49
- if (commonStore[TID].options.width && commonStore[TID].options.width !== 'auto') {
50
- this.width = commonStore[TID].options.width;
50
+ if (this.options.width && this.options.width !== 'auto') {
51
+ this.width = this.options.width;
51
52
  }
52
53
  else {
53
- this.width = commonStore[TID].parentElem.clientWidth;
54
+ this.width = this.parentElem.clientWidth;
54
55
  }
55
- if (commonStore[TID].options.height && commonStore[TID].options.height !== 'auto') {
56
- this.height = commonStore[TID].options.height;
56
+ if (this.options.height && this.options.height !== 'auto') {
57
+ this.height = this.options.height;
57
58
  }
58
59
  else {
59
- this.height = commonStore[TID].parentElem.clientHeight;
60
+ this.height = this.parentElem.clientHeight;
60
61
  }
61
62
  }
62
63
  this.canvas.style.width = this.width + 'px';