dcim-topology2d 2.0.7 → 3.0.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 (204) 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 +1 -3
  17. package/chart-diagram/index.js +1 -2
  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 -2
  26. package/core/index.js +0 -2
  27. package/core/src/activeLayer.d.ts +10 -2
  28. package/core/src/activeLayer.js +47 -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 -18
  35. package/core/src/common.d.ts +7 -6
  36. package/core/src/common.js +672 -333
  37. package/core/src/core.d.ts +4 -3
  38. package/core/src/core.js +367 -466
  39. package/core/src/divLayer.d.ts +36 -2
  40. package/core/src/divLayer.js +305 -33
  41. package/core/src/healps/changeData.d.ts +2 -1
  42. package/core/src/healps/changeData.js +66 -32
  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 -53
  47. package/core/src/middles/index.js +2 -3
  48. package/core/src/middles/nodes/arbitrarygraph.js +9 -11
  49. package/core/src/middles/nodes/pentagon.rect.js +1 -1
  50. package/core/src/middles/nodes/rectangle.rect.js +1 -1
  51. package/core/src/models/data.d.ts +26 -0
  52. package/core/src/models/data.js +77 -0
  53. package/core/src/models/data.js.map +1 -0
  54. package/core/src/models/index.d.ts +1 -0
  55. package/core/src/models/index.js +1 -0
  56. package/core/src/models/node.d.ts +0 -10
  57. package/core/src/models/node.js +32 -54
  58. package/core/src/models/pen.js +59 -19
  59. package/core/src/models/rect.js +2 -2
  60. package/core/src/mqtt.d.ts +14 -0
  61. package/core/src/mqtt.js +82 -0
  62. package/core/src/mqtt.js.map +1 -0
  63. package/core/src/offscreen.d.ts +4 -1
  64. package/core/src/offscreen.js +8 -10
  65. package/core/src/options.d.ts +1 -3
  66. package/core/src/options.js +0 -2
  67. package/core/src/poll.js +39 -0
  68. package/core/src/preview.d.ts +13 -1
  69. package/core/src/preview.js +43 -111
  70. package/core/src/renderLayer.d.ts +9 -11
  71. package/core/src/renderLayer.js +60 -48
  72. package/core/src/socket.d.ts +10 -0
  73. package/core/src/socket.js +51 -0
  74. package/core/src/socket.js.map +1 -0
  75. package/core/src/utils/canvas.js +1 -1
  76. package/core/src/utils/construction.d.ts +3 -12
  77. package/core/src/utils/construction.js +1 -8
  78. package/core/src/utils/conversion.d.ts +0 -11
  79. package/core/src/utils/conversion.js +0 -167
  80. package/core/src/utils/dom.d.ts +8 -0
  81. package/core/src/utils/dom.js +67 -0
  82. package/core/src/utils/dom.js.map +1 -0
  83. package/core/src/utils/index.d.ts +1 -2
  84. package/core/src/utils/index.js +1 -2
  85. package/core/src/utils/math.d.ts +0 -1
  86. package/core/src/utils/math.js +0 -3
  87. package/core/src/utils/onmousevent.d.ts +0 -3
  88. package/core/src/utils/onmousevent.js +8 -37
  89. package/flow-diagram/src/comment/comment.anchor.d.ts +1 -1
  90. package/flow-diagram/src/comment/comment.anchor.js +1 -1
  91. package/flow-diagram/src/comment/comment.d.ts +1 -1
  92. package/flow-diagram/src/data/data.anchor.d.ts +1 -1
  93. package/flow-diagram/src/data/data.anchor.js +1 -1
  94. package/flow-diagram/src/data/data.d.ts +1 -1
  95. package/flow-diagram/src/data/data.rect.d.ts +1 -1
  96. package/flow-diagram/src/data/data.rect.js +1 -1
  97. package/flow-diagram/src/db/db.d.ts +1 -1
  98. package/flow-diagram/src/db/db.rect.d.ts +1 -1
  99. package/flow-diagram/src/db/db.rect.js +1 -1
  100. package/flow-diagram/src/display/display.anchor.d.ts +1 -1
  101. package/flow-diagram/src/display/display.anchor.js +1 -1
  102. package/flow-diagram/src/display/display.d.ts +1 -1
  103. package/flow-diagram/src/display/display.rect.d.ts +1 -1
  104. package/flow-diagram/src/display/display.rect.js +1 -1
  105. package/flow-diagram/src/document/document.anchor.d.ts +1 -1
  106. package/flow-diagram/src/document/document.anchor.js +1 -1
  107. package/flow-diagram/src/document/document.d.ts +1 -1
  108. package/flow-diagram/src/document/document.rect.d.ts +1 -1
  109. package/flow-diagram/src/document/document.rect.js +1 -1
  110. package/flow-diagram/src/externStorage/externStorage.anchor.d.ts +1 -1
  111. package/flow-diagram/src/externStorage/externStorage.anchor.js +1 -1
  112. package/flow-diagram/src/externStorage/externStorage.d.ts +1 -1
  113. package/flow-diagram/src/externStorage/externStorage.rect.d.ts +1 -1
  114. package/flow-diagram/src/externStorage/externStorage.rect.js +1 -1
  115. package/flow-diagram/src/internalStorage/internalStorage.d.ts +1 -1
  116. package/flow-diagram/src/internalStorage/internalStorage.rect.d.ts +1 -1
  117. package/flow-diagram/src/internalStorage/internalStorage.rect.js +1 -1
  118. package/flow-diagram/src/manually/manually.anchor.d.ts +1 -1
  119. package/flow-diagram/src/manually/manually.anchor.js +1 -1
  120. package/flow-diagram/src/manually/manually.d.ts +1 -1
  121. package/flow-diagram/src/manually/manually.rect.d.ts +1 -1
  122. package/flow-diagram/src/manually/manually.rect.js +1 -1
  123. package/flow-diagram/src/parallel/parallel.anchor.d.ts +1 -1
  124. package/flow-diagram/src/parallel/parallel.anchor.js +1 -1
  125. package/flow-diagram/src/parallel/parallel.d.ts +1 -1
  126. package/flow-diagram/src/queue/queue.d.ts +1 -1
  127. package/flow-diagram/src/queue/queue.rect.d.ts +1 -1
  128. package/flow-diagram/src/queue/queue.rect.js +1 -1
  129. package/flow-diagram/src/register.js +1 -1
  130. package/flow-diagram/src/subprocess/subprocess.d.ts +1 -1
  131. package/flow-diagram/src/subprocess/subprocess.rect.d.ts +1 -1
  132. package/flow-diagram/src/subprocess/subprocess.rect.js +1 -1
  133. package/layout/src/align.d.ts +1 -1
  134. package/layout/src/align.js +1 -1
  135. package/layout/src/layout.d.ts +1 -1
  136. package/layout/src/layout.js +1 -1
  137. package/myShape-diagram/{index.js → myShape.js} +1 -4
  138. package/package.json +1 -1
  139. package/sequence-diagram/src/focus/focus.anchor.d.ts +1 -1
  140. package/sequence-diagram/src/focus/focus.anchor.js +1 -1
  141. package/sequence-diagram/src/focus/focus.d.ts +1 -1
  142. package/sequence-diagram/src/focus/focus.rect.d.ts +1 -1
  143. package/sequence-diagram/src/focus/focus.rect.js +1 -1
  144. package/sequence-diagram/src/lifeline/lifeline.anchor.d.ts +1 -1
  145. package/sequence-diagram/src/lifeline/lifeline.anchor.js +1 -1
  146. package/sequence-diagram/src/lifeline/lifeline.d.ts +1 -1
  147. package/sequence-diagram/src/lifeline/lifeline.rect.d.ts +1 -1
  148. package/sequence-diagram/src/lifeline/lifeline.rect.js +1 -1
  149. package/sequence-diagram/src/register.js +1 -1
  150. package/chart-diagram/src/utils/changeOptions.d.ts +0 -7
  151. package/chart-diagram/src/utils/changeOptions.js +0 -253
  152. package/chart-diagram/src/utils/conversion.d.ts +0 -18
  153. package/chart-diagram/src/utils/conversion.js +0 -399
  154. package/chart-diagram/src/utils/drawGraphic.d.ts +0 -3
  155. package/chart-diagram/src/utils/drawGraphic.js +0 -97
  156. package/chart-diagram/src/utils/formatter.d.ts +0 -1
  157. package/chart-diagram/src/utils/formatter.js +0 -129
  158. package/chart-diagram/src/utils/index.d.ts +0 -4
  159. package/chart-diagram/src/utils/index.js +0 -4
  160. package/chart-diagram/src/utils/render.d.ts +0 -8
  161. package/chart-diagram/src/utils/render.js +0 -199
  162. package/core/src/element/common.d.ts +0 -5
  163. package/core/src/element/common.js +0 -54
  164. package/core/src/element/iframe.d.ts +0 -3
  165. package/core/src/element/iframe.js +0 -12
  166. package/core/src/element/index.d.ts +0 -4
  167. package/core/src/element/index.js +0 -4
  168. package/core/src/element/select.d.ts +0 -11
  169. package/core/src/element/select.js +0 -263
  170. package/core/src/element/tab.d.ts +0 -1
  171. package/core/src/element/tab.js +0 -23
  172. package/core/src/middles/arrows/index.d.ts +0 -4
  173. package/core/src/middles/arrows/index.js +0 -5
  174. package/core/src/middles/lines/index.d.ts +0 -4
  175. package/core/src/middles/lines/index.js +0 -5
  176. package/core/src/middles/nodes/formoverflow.js +0 -61
  177. package/core/src/middles/nodes/formselect.d.ts +0 -2
  178. package/core/src/middles/nodes/formselect.js +0 -95
  179. package/core/src/middles/nodes/iframe.d.ts +0 -2
  180. package/core/src/middles/nodes/iframe.js +0 -29
  181. package/core/src/middles/nodes/index.d.ts +0 -48
  182. package/core/src/middles/nodes/index.js +0 -49
  183. package/core/src/store/common.d.ts +0 -9
  184. package/core/src/store/common.js +0 -5
  185. package/core/src/store/data.d.ts +0 -186
  186. package/core/src/store/data.js +0 -178
  187. package/core/src/store/index.d.ts +0 -2
  188. package/core/src/store/index.js +0 -2
  189. package/core/src/utils/assignment.d.ts +0 -6
  190. package/core/src/utils/assignment.js +0 -168
  191. package/core/src/utils/params.d.ts +0 -2
  192. package/core/src/utils/params.js +0 -60
  193. package/static/echartsDefaultData.js +0 -167
  194. package/static/element.js +0 -14
  195. package/static/form.js +0 -11
  196. package/static/index.js +0 -3
  197. package/store/actions.js +0 -1
  198. package/store/clear.js +0 -10
  199. package/store/index.js +0 -2
  200. package/style/common.css +0 -18
  201. package/style/editor.css +0 -13
  202. package/style/index.css +0 -4
  203. package/style/select.css +0 -143
  204. /package/myShape-diagram/{index.ts → myShape.ts} +0 -0
@@ -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;
@@ -306,12 +310,18 @@ var ActiveLayer = /** @class */ (function (_super) {
306
310
  }
307
311
  }
308
312
  }
313
+ if(item.name == 'arbitraryGraph') {
314
+ for(let i = 0, circles = item.rect.circles; i<circles.length; i++) {
315
+ circles[i].x = circles[i].x + offsetX;
316
+ circles[i].y = circles[i].y + offsetY;
317
+ }
318
+ }
309
319
  }
310
320
  if (item instanceof Line && item.from) {
311
321
  var offsetX_1 = this.nodeRects[i].x + x - item.from.x;
312
322
  var offsetY_1 = this.nodeRects[i].y + y - item.from.y;
313
323
  if (item.parentId) {
314
- var items = find(item.parentId, globalStore.data.pens);
324
+ var items = find(item.parentId, this.data.pens);
315
325
  items.forEach(function (l) {
316
326
  l.translate(offsetX_1, offsetY_1);
317
327
  });
@@ -328,7 +338,7 @@ var ActiveLayer = /** @class */ (function (_super) {
328
338
  ActiveLayer.prototype.getLinesOfNode = function (node) {
329
339
  var result = [];
330
340
  var nodesLines = flatNodes([node]);
331
- 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++) {
332
342
  var pen = _a[_i];
333
343
  if (!(pen instanceof Line)) {
334
344
  continue;
@@ -355,10 +365,9 @@ var ActiveLayer = /** @class */ (function (_super) {
355
365
  if (!pens) {
356
366
  pens = this.pens;
357
367
  }
358
- var globalStore = commonStore[this.TID];
359
368
  var nodesLines = flatNodes(pens);
360
369
  var lines = [];
361
- 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; }));
362
371
  for (var _i = 0, _a = nodesLines.lines; _i < _a.length; _i++) {
363
372
  var line = _a[_i];
364
373
  for (var _b = 0, _c = nodesLines.nodes; _b < _c.length; _b++) {
@@ -374,7 +383,7 @@ var ActiveLayer = /** @class */ (function (_super) {
374
383
  line.to.y = item.rotatedAnchors[line.to.anchorIndex].y;
375
384
  ++cnt;
376
385
  }
377
- if (cnt && !globalStore.data.manualCps) {
386
+ if (cnt && !this.data.manualCps) {
378
387
  line.calcControlPoints();
379
388
  }
380
389
  line.textRect = null;
@@ -383,7 +392,6 @@ var ActiveLayer = /** @class */ (function (_super) {
383
392
  }
384
393
  }
385
394
  Store.set(this.generateStoreKey('LT:updateLines'), lines);
386
- globalStore = null;
387
395
  };
388
396
  ActiveLayer.prototype.offsetRotate = function (angle) {
389
397
  this.rotating = true;
@@ -484,9 +492,7 @@ var ActiveLayer = /** @class */ (function (_super) {
484
492
  };
485
493
  ActiveLayer.prototype.render = function (ctx) {
486
494
  var _this = this;
487
- if(!commonStore || !commonStore[_this.TID]) return;
488
- var globalStore = commonStore[_this.TID];
489
- if (globalStore.data.locked > Lock.Readonly) {
495
+ if (this.data.locked > Lock.Readonly) {
490
496
  return;
491
497
  }
492
498
 
@@ -502,7 +508,7 @@ var ActiveLayer = /** @class */ (function (_super) {
502
508
  this.calcControlPoints();
503
509
  }
504
510
  ctx.save();
505
- ctx.strokeStyle = globalStore.options.activeColor;
511
+ ctx.strokeStyle = this.options.activeColor;
506
512
  ctx.fillStyle = '#fff';
507
513
  ctx.lineWidth = 1;
508
514
  var TID = this.TID;
@@ -522,7 +528,7 @@ var ActiveLayer = /** @class */ (function (_super) {
522
528
  tmp.strokeStyle = '#ffffff';
523
529
  tmp.lineWidth += 2;
524
530
  tmp.render(ctx);
525
- tmp.strokeStyle = globalStore.options.activeColor;
531
+ tmp.strokeStyle = this.options.activeColor;
526
532
  tmp.lineWidth -= 2;
527
533
  }
528
534
  }
@@ -537,11 +543,11 @@ var ActiveLayer = /** @class */ (function (_super) {
537
543
  bk.strokeStyle = '#ffffff';
538
544
  bk.render(ctx);
539
545
  }
540
- tmp.strokeStyle = globalStore.options.activeColor;
541
- tmp.fromArrowColor = globalStore.options.activeColor;
542
- tmp.toArrowColor = globalStore.options.activeColor;
546
+ tmp.strokeStyle = this.options.activeColor;
547
+ tmp.fromArrowColor = this.options.activeColor;
548
+ tmp.toArrowColor = this.options.activeColor;
543
549
  tmp.render(ctx);
544
- if (!globalStore.data.locked && !item.locked) {
550
+ if (!this.data.locked && !item.locked) {
545
551
  drawLineFns[item.name].drawControlPointsFn(ctx, item);
546
552
  }
547
553
  }
@@ -567,7 +573,7 @@ var ActiveLayer = /** @class */ (function (_super) {
567
573
  ctx.closePath();
568
574
  ctx.stroke();
569
575
  ctx.restore();
570
- if (globalStore.data.locked || this.locked()) {
576
+ if (this.data.locked || this.locked()) {
571
577
  ctx.restore();
572
578
  return;
573
579
  }
@@ -583,7 +589,7 @@ var ActiveLayer = /** @class */ (function (_super) {
583
589
  ctx.fill();
584
590
  ctx.stroke();
585
591
  // Draw size control points.绘制拖拽框四角的点
586
- 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)) {
587
593
  ctx.lineWidth = 1;
588
594
  for (var _b = 0, _c = this.sizeCPs; _b < _c.length; _b++) {
589
595
  var item = _c[_b];
@@ -600,7 +606,6 @@ var ActiveLayer = /** @class */ (function (_super) {
600
606
  }
601
607
  }
602
608
  ctx.restore();
603
- globalStore = null;
604
609
  };
605
610
  ActiveLayer.prototype.getDockWatchers = function () {
606
611
  if (this.pens.length === 1) {
@@ -617,7 +622,7 @@ var ActiveLayer = /** @class */ (function (_super) {
617
622
  ActiveLayer.prototype.handleArbitrayGraphSize = function (type,item, offsetX, offsetY, l, sizeX, sizeY, nodeRectsCircles) {
618
623
  if(item.name !== 'arbitraryGraph') return
619
624
 
620
- switch (type) {
625
+ switch (type) {
621
626
 
622
627
  case 0:
623
628
 
@@ -629,7 +634,7 @@ var ActiveLayer = /** @class */ (function (_super) {
629
634
 
630
635
  }
631
636
 
632
- break;
637
+ break;
633
638
 
634
639
  case 1:
635
640
 
@@ -641,19 +646,19 @@ var ActiveLayer = /** @class */ (function (_super) {
641
646
 
642
647
  }
643
648
 
644
- break;
649
+ break;
645
650
 
646
651
  case 2:
647
652
 
648
- for(let c=0, length = item.rect.circles.length; c<length; c++ ) {
649
-
650
- 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++ ) {
651
654
 
652
- 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);
653
658
 
654
- }
659
+ }
655
660
 
656
- break;
661
+ break;
657
662
 
658
663
  case 3:
659
664
 
@@ -665,10 +670,10 @@ var ActiveLayer = /** @class */ (function (_super) {
665
670
 
666
671
  }
667
672
 
668
- break
673
+ break
669
674
  }
670
675
  };
671
676
  return ActiveLayer;
672
677
  }(Layer));
673
678
  export { ActiveLayer };
674
- //# 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,51 +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.canvas.setAttribute('class', 'canvas-draw');
23
- _this.width = commonStore[TID].parentElem.clientWidth;
24
- _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'));
25
27
  _this.canvas.style.position = 'absolute';
26
28
  _this.canvas.style.left = '0';
27
29
  _this.canvas.style.top = '0';
28
30
  _this.canvas.style.outline = 'none';
29
31
  if (!Canvas.dpiRatio) {
30
- if (!commonStore[TID].options.extDpiRatio && commonStore[TID].options.extDpiRatio !== 0) {
32
+ if (!options.extDpiRatio && options.extDpiRatio !== 0) {
31
33
  if (window.devicePixelRatio > 1) {
32
- commonStore[TID].options.extDpiRatio = 0.25;
34
+ options.extDpiRatio = 0.25;
33
35
  }
34
36
  else {
35
- commonStore[TID].options.extDpiRatio = 0;
37
+ options.extDpiRatio = 0;
36
38
  }
37
39
  }
38
- Canvas.dpiRatio = window.devicePixelRatio + commonStore[TID].options.extDpiRatio;
40
+ Canvas.dpiRatio = window.devicePixelRatio + options.extDpiRatio;
39
41
  }
40
42
  return _this;
41
43
  }
42
44
  Canvas.prototype.resize = function (size) {
43
45
  if (size) {
44
- this.width = size.width | 0;
46
+ this.width = size.width | 0;
45
47
  this.height = size.height | 0;
46
48
  }
47
49
  else {
48
- const TID = this.TID;
49
- if(!commonStore[TID] || !commonStore[TID].options) return;
50
- if (commonStore[TID].options.width && commonStore[TID].options.width !== 'auto') {
51
- this.width = commonStore[TID].options.width;
50
+ if (this.options.width && this.options.width !== 'auto') {
51
+ this.width = this.options.width;
52
52
  }
53
53
  else {
54
- this.width = commonStore[TID].parentElem.clientWidth;
54
+ this.width = this.parentElem.clientWidth;
55
55
  }
56
- if (commonStore[TID].options.height && commonStore[TID].options.height !== 'auto') {
57
- this.height = commonStore[TID].options.height;
56
+ if (this.options.height && this.options.height !== 'auto') {
57
+ this.height = this.options.height;
58
58
  }
59
59
  else {
60
- this.height = commonStore[TID].parentElem.clientHeight;
60
+ this.height = this.parentElem.clientHeight;
61
61
  }
62
62
  }
63
63
  this.canvas.style.width = this.width + 'px';