dcim-topology2d 1.1.3 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) 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/src/echarts/index.d.ts +1 -1
  17. package/chart-diagram/src/echarts/index.js +7 -10
  18. package/chart-diagram/src/register.js +1 -1
  19. package/class-diagram/src/class/class.d.ts +1 -1
  20. package/class-diagram/src/class/class.rect.d.ts +1 -1
  21. package/class-diagram/src/class/class.rect.js +1 -1
  22. package/class-diagram/src/register.js +1 -1
  23. package/core/index.d.ts +0 -1
  24. package/core/index.js +0 -1
  25. package/core/src/activeLayer.d.ts +10 -2
  26. package/core/src/activeLayer.js +41 -42
  27. package/core/src/animateLayer.d.ts +7 -3
  28. package/core/src/animateLayer.js +12 -10
  29. package/core/src/calling.d.ts +4 -1
  30. package/core/src/calling.js +41 -40
  31. package/core/src/canvas.d.ts +6 -1
  32. package/core/src/canvas.js +18 -17
  33. package/core/src/common.d.ts +5 -5
  34. package/core/src/common.js +115 -161
  35. package/core/src/core.d.ts +4 -3
  36. package/core/src/core.js +253 -228
  37. package/core/src/divLayer.d.ts +7 -2
  38. package/core/src/divLayer.js +25 -25
  39. package/core/src/healps/changeData.d.ts +1 -1
  40. package/core/src/healps/changeData.js +42 -77
  41. package/core/src/hoverLayer.d.ts +9 -2
  42. package/core/src/hoverLayer.js +34 -31
  43. package/core/src/models/data.d.ts +26 -0
  44. package/core/src/models/data.js +77 -0
  45. package/core/src/models/data.js.map +1 -0
  46. package/core/src/models/index.d.ts +1 -0
  47. package/core/src/models/index.js +1 -0
  48. package/core/src/models/node.js +12 -14
  49. package/core/src/models/pen.js +1 -10
  50. package/core/src/mqtt.d.ts +14 -0
  51. package/core/src/mqtt.js +82 -0
  52. package/core/src/mqtt.js.map +1 -0
  53. package/core/src/offscreen.d.ts +4 -1
  54. package/core/src/offscreen.js +8 -10
  55. package/core/src/options.js +0 -1
  56. package/core/src/poll.js +2 -0
  57. package/core/src/preview.d.ts +13 -1
  58. package/core/src/preview.js +34 -42
  59. package/core/src/renderLayer.d.ts +3 -1
  60. package/core/src/renderLayer.js +31 -26
  61. package/core/src/socket.d.ts +10 -0
  62. package/core/src/socket.js +51 -0
  63. package/core/src/socket.js.map +1 -0
  64. package/core/src/utils/canvas.js +1 -1
  65. package/core/src/utils/conversion.d.ts +0 -7
  66. package/core/src/utils/conversion.js +0 -54
  67. package/core/src/utils/dom.d.ts +5 -4
  68. package/core/src/utils/dom.js +1 -3
  69. package/core/src/utils/onmousevent.js +3 -12
  70. package/flow-diagram/src/comment/comment.anchor.d.ts +1 -1
  71. package/flow-diagram/src/comment/comment.anchor.js +1 -1
  72. package/flow-diagram/src/comment/comment.d.ts +1 -1
  73. package/flow-diagram/src/data/data.anchor.d.ts +1 -1
  74. package/flow-diagram/src/data/data.anchor.js +1 -1
  75. package/flow-diagram/src/data/data.d.ts +1 -1
  76. package/flow-diagram/src/data/data.rect.d.ts +1 -1
  77. package/flow-diagram/src/data/data.rect.js +1 -1
  78. package/flow-diagram/src/db/db.d.ts +1 -1
  79. package/flow-diagram/src/db/db.rect.d.ts +1 -1
  80. package/flow-diagram/src/db/db.rect.js +1 -1
  81. package/flow-diagram/src/display/display.anchor.d.ts +1 -1
  82. package/flow-diagram/src/display/display.anchor.js +1 -1
  83. package/flow-diagram/src/display/display.d.ts +1 -1
  84. package/flow-diagram/src/display/display.rect.d.ts +1 -1
  85. package/flow-diagram/src/display/display.rect.js +1 -1
  86. package/flow-diagram/src/document/document.anchor.d.ts +1 -1
  87. package/flow-diagram/src/document/document.anchor.js +1 -1
  88. package/flow-diagram/src/document/document.d.ts +1 -1
  89. package/flow-diagram/src/document/document.rect.d.ts +1 -1
  90. package/flow-diagram/src/document/document.rect.js +1 -1
  91. package/flow-diagram/src/externStorage/externStorage.anchor.d.ts +1 -1
  92. package/flow-diagram/src/externStorage/externStorage.anchor.js +1 -1
  93. package/flow-diagram/src/externStorage/externStorage.d.ts +1 -1
  94. package/flow-diagram/src/externStorage/externStorage.rect.d.ts +1 -1
  95. package/flow-diagram/src/externStorage/externStorage.rect.js +1 -1
  96. package/flow-diagram/src/internalStorage/internalStorage.d.ts +1 -1
  97. package/flow-diagram/src/internalStorage/internalStorage.rect.d.ts +1 -1
  98. package/flow-diagram/src/internalStorage/internalStorage.rect.js +1 -1
  99. package/flow-diagram/src/manually/manually.anchor.d.ts +1 -1
  100. package/flow-diagram/src/manually/manually.anchor.js +1 -1
  101. package/flow-diagram/src/manually/manually.d.ts +1 -1
  102. package/flow-diagram/src/manually/manually.rect.d.ts +1 -1
  103. package/flow-diagram/src/manually/manually.rect.js +1 -1
  104. package/flow-diagram/src/parallel/parallel.anchor.d.ts +1 -1
  105. package/flow-diagram/src/parallel/parallel.anchor.js +1 -1
  106. package/flow-diagram/src/parallel/parallel.d.ts +1 -1
  107. package/flow-diagram/src/queue/queue.d.ts +1 -1
  108. package/flow-diagram/src/queue/queue.rect.d.ts +1 -1
  109. package/flow-diagram/src/queue/queue.rect.js +1 -1
  110. package/flow-diagram/src/register.js +1 -1
  111. package/flow-diagram/src/subprocess/subprocess.d.ts +1 -1
  112. package/flow-diagram/src/subprocess/subprocess.rect.d.ts +1 -1
  113. package/flow-diagram/src/subprocess/subprocess.rect.js +1 -1
  114. package/layout/src/align.d.ts +1 -1
  115. package/layout/src/align.js +1 -1
  116. package/layout/src/layout.d.ts +1 -1
  117. package/layout/src/layout.js +1 -1
  118. package/myShape-diagram/myShape.js +1 -1
  119. package/package.json +1 -1
  120. package/sequence-diagram/src/focus/focus.anchor.d.ts +1 -1
  121. package/sequence-diagram/src/focus/focus.anchor.js +1 -1
  122. package/sequence-diagram/src/focus/focus.d.ts +1 -1
  123. package/sequence-diagram/src/focus/focus.rect.d.ts +1 -1
  124. package/sequence-diagram/src/focus/focus.rect.js +1 -1
  125. package/sequence-diagram/src/lifeline/lifeline.anchor.d.ts +1 -1
  126. package/sequence-diagram/src/lifeline/lifeline.anchor.js +1 -1
  127. package/sequence-diagram/src/lifeline/lifeline.d.ts +1 -1
  128. package/sequence-diagram/src/lifeline/lifeline.rect.d.ts +1 -1
  129. package/sequence-diagram/src/lifeline/lifeline.rect.js +1 -1
  130. package/sequence-diagram/src/register.js +1 -1
  131. package/core/src/store/common.d.ts +0 -9
  132. package/core/src/store/common.js +0 -5
  133. package/core/src/store/data.d.ts +0 -126
  134. package/core/src/store/data.js +0 -80
  135. package/core/src/store/index.d.ts +0 -2
  136. package/core/src/store/index.js +0 -2
  137. package/static/echartsDefaultData.js +0 -95
  138. package/static/index.js +0 -1
  139. package/style/index.css +0 -10
@@ -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,19 +68,19 @@ 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
77
  item.rect.x = 0;
75
78
  item.rect.y = 0;
76
- this.store.data.pens.push(new Node(item));
79
+ this.data.pens.push(new Node(item));
77
80
  }
78
81
  for (var _b = 0, _c = data.lines; _b < _c.length; _b++) {
79
82
  var item = _c[_b];
80
- this.store.data.pens.push(new Line(item));
83
+ this.data.pens.push(new Line(item));
81
84
  }
82
85
  }
83
86
  // end.
@@ -85,32 +88,32 @@ var Calling = (function () {
85
88
  for (var _d = 0, _e = data.pens; _d < _e.length; _d++) {
86
89
  var item = _e[_d];
87
90
  if (!item.from) {
88
- this.store.data.pens.push(new Node(item));
91
+ this.data.pens.push(new Node(item));
89
92
  } else {
90
- this.store.data.pens.push(new Line(item));
93
+ this.data.pens.push(new Line(item));
91
94
  }
92
95
  }
93
96
  }
94
- this.store.data.bkImageRect = data.bkImageRect || null;
95
- this.store.data.bkImage = data.bkImage || '';
96
- this.store.data.mqttOptions = data.mqttOptions || {clientId: s8()};
97
- 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 || '';
98
101
  if (typeof data.data === 'object') {
99
- this.store.data.data = data.data;
102
+ this.data.data = data.data;
100
103
  } else {
101
- this.store.data.data = data.data || '';
104
+ this.data.data = data.data || '';
102
105
  }
103
- this.store.parentElem.scrollLeft = 0;
104
- this.store.parentElem.scrollTop = 0;
106
+ this.parentElem.scrollLeft = 0;
107
+ this.parentElem.scrollTop = 0;
105
108
  this.overflow();
106
109
  this.render(true);
107
110
  };
108
111
  Calling.prototype.overflow = function () {
109
- this.store.options.isFitview ? this.fitView() : this.bottomView();
112
+ this.options.isFitview ? this.fitView() : this.bottomView();
110
113
  };
111
114
  Calling.prototype.getRect = function (pens) {
112
115
  if (!pens) {
113
- pens = this.store.data.pens;
116
+ pens = this.data.pens;
114
117
  }
115
118
  return getRect(pens);
116
119
  };
@@ -121,7 +124,7 @@ var Calling = (function () {
121
124
  }
122
125
  var offsetX = x - this.lastTranlated.x;
123
126
  var offsetY = y - this.lastTranlated.y;
124
- 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++) {
125
128
  var item = _a[_i];
126
129
  item.translate(offsetX, offsetY);
127
130
  }
@@ -132,14 +135,13 @@ var Calling = (function () {
132
135
  // > 1, expand
133
136
  // < 1, reduce
134
137
  Calling.prototype.scale = function (scale, center, w, h) {
135
- if (this.store.data.scale * scale < this.store.options.minScale ||
136
- 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) {
137
140
  return;
138
141
  }
139
- this.store.data.scale *= scale;
142
+ this.data.scale *= scale;
140
143
  !center && (center = this.getRect().center);
141
- center.type = this.store.options.type;
142
- 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++) {
143
145
  var item = _a[_i];
144
146
  item.scale(scale, center, w, h);
145
147
  }
@@ -148,7 +150,7 @@ var Calling = (function () {
148
150
  var rect = this.getRect();
149
151
  var viewCenter = this.getViewCenter(padding);
150
152
  var center = rect.center;
151
- var parentElem = this.store.parentElem;
153
+ var parentElem = this.canvas.parentElem;
152
154
  var x = (parentElem.offsetWidth - rect.width) / 2;
153
155
  var y = parentElem.scrollHeight - rect.height;
154
156
  var w = parentElem.offsetWidth / rect.width;
@@ -158,7 +160,7 @@ var Calling = (function () {
158
160
  ratio = h;
159
161
  }
160
162
  this.canvas.canvas.style.transform = `translate(${x}px, ${y}px)`;
161
- 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++) {
162
164
  var item = _a[_i];
163
165
  if(item.rect.x > 0) {
164
166
  item.rect.ex = item.rect.ex - item.rect.x;
@@ -179,7 +181,7 @@ var Calling = (function () {
179
181
  var viewCenter = this.getViewCenter(padding);
180
182
  var center = rect.center;
181
183
  this.translate(viewCenter.x - center.x, viewCenter.y - center.y);
182
- var parentElem = this.store.parentElem;
184
+ var parentElem = this.canvas.parentElem;
183
185
  var x = (parentElem.scrollWidth - parentElem.offsetWidth) / 2;
184
186
  var y = (parentElem.scrollHeight - parentElem.offsetHeight) / 2;
185
187
  parentElem.scrollTo(x, y);
@@ -189,7 +191,7 @@ var Calling = (function () {
189
191
  if (!this.hasView())
190
192
  return;
191
193
  // 1. 重置画布尺寸为容器尺寸
192
- var parentElem = this.store.parentElem;
194
+ var parentElem = this.canvas.parentElem;
193
195
  var width = parentElem.offsetWidth, height = parentElem.offsetHeight;
194
196
  this.resize({
195
197
  width: width,
@@ -198,7 +200,7 @@ var Calling = (function () {
198
200
  // 2. 图形居中
199
201
  this.centerView(viewPadding);
200
202
  // 3. 获取设置的留白值
201
- var padding = formatPadding(viewPadding || this.store.options.viewPadding);
203
+ var padding = formatPadding(viewPadding || this.options.viewPadding);
202
204
  // 4. 获取图形尺寸
203
205
  var rect = this.getRect();
204
206
  // 6. 计算缩放比
@@ -215,7 +217,7 @@ var Calling = (function () {
215
217
  return !(rect.width === 99999 || rect.height === 99999);
216
218
  };
217
219
  Calling.prototype.getViewCenter = function (viewPadding) {
218
- var padding = formatPadding(viewPadding || this.store.options.viewPadding);
220
+ var padding = formatPadding(viewPadding || this.options.viewPadding);
219
221
  var _a = this.canvas, width = _a.width, height = _a.height;
220
222
  return {
221
223
  x: (width - padding[1] - padding[3]) / 2 + padding[3],
@@ -226,7 +228,6 @@ var Calling = (function () {
226
228
  return this.id + "-" + key;
227
229
  };
228
230
  Calling.prototype.destroy = function () {
229
- clearStore(this.store);
230
231
  this.subcribeImage.unsubscribe();
231
232
  this.canvas.destroy();
232
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';
@@ -4,9 +4,9 @@ import { DivLayer } from './divLayer';
4
4
  import { AnimateLayer } from './animateLayer';
5
5
  import { RenderLayer } from './renderLayer';
6
6
  import { Offscreen } from './offscreen';
7
- import {Line, Node, Pen, Point, Rect} from './models';
7
+ import {Line, Node, Pen, Point, Rect, TopologyData} from './models';
8
8
  import {Padding, Options} from './options';
9
- import { visualization2DStore } from './store'
9
+ import { Socket } from './socket';
10
10
  declare enum MoveInType {
11
11
  None = 0,
12
12
  Line = 1,
@@ -21,7 +21,8 @@ declare enum MoveInType {
21
21
  }
22
22
  export declare class Common {
23
23
  //constructor(parent: HTMLElement, options: Options);
24
- store: visualization2DStore;
24
+ options: Options;
25
+ data: TopologyData;
25
26
  moveInType: MoveInType;
26
27
  id: String;
27
28
  parentElem: HTMLElement;
@@ -32,6 +33,7 @@ export declare class Common {
32
33
  input: HTMLTextAreaElement;
33
34
  tipMarkdown: HTMLElement;
34
35
  tipElem: HTMLElement;
36
+ socket: Socket;
35
37
  private subcribe;
36
38
  private subcribeRender;
37
39
  private subcribeImage;
@@ -56,8 +58,6 @@ export declare class Common {
56
58
  y: number;
57
59
  restore?: boolean;
58
60
  };
59
- renderTimer: number;
60
- lastRender: number;
61
61
  lastTranlated: {
62
62
  x: number;
63
63
  y: number;