dcim-topology2d 1.1.6 → 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 (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
@@ -7,12 +7,6 @@ export declare const images: {
7
7
  cnt: number;
8
8
  };
9
9
  };
10
- export declare const defaultImages: {
11
- [key: string]: {
12
- img: string;
13
- status: number;
14
- };
15
- };
16
10
  export declare class Node extends Pen {
17
11
  is3D: boolean;
18
12
  z: number;
@@ -21,8 +21,7 @@ import { defaultIconRect, defaultTextRect } from '../middles/default.rect';
21
21
  import { text, tableText, defaultText, iconfont } from '../middles/nodes/text';
22
22
  import { Store } from 'le5le-store';
23
23
  import { abs, s8, animateType, createChildrenDivByElementId } from '../utils';
24
- export const images = {};
25
- export const defaultImages = {};
24
+ export var images = {};
26
25
  var Node = /** @class */ (function (_super) {
27
26
  __extends(Node, _super);
28
27
  function Node(json, noChild) {
@@ -36,7 +35,6 @@ var Node = /** @class */ (function (_super) {
36
35
  _this.animateDuration = 0;
37
36
  _this.animateFrames = [];
38
37
  _this.type = PenType.Node;
39
- _this.TID = json.TID;
40
38
  _this.is3D = json.is3D;
41
39
  _this.z = json.z;
42
40
  _this.zRotate = json.zRotate || 0;
@@ -82,7 +80,7 @@ var Node = /** @class */ (function (_super) {
82
80
  _this.leakageFillStyle = json.leakageFillStyle || '#ff0000';
83
81
  _this.bindStaticId = json.bindStaticId || '';
84
82
  _this.buttonCheckSlide = json.buttonCheckSlide || '';
85
- _this.visitStrokeStyle = json.visitStrokeStyle || '';
83
+ _this.activeImgeIndex = json.activeImgeIndex || false;
86
84
  _this.thBottomStrokeStyle = json.thBottomStrokeStyle || '#fff';
87
85
  _this.thBottomLineWidth = json.thBottomLineWidth || 1;
88
86
  // 兼容老数据
@@ -129,7 +127,6 @@ var Node = /** @class */ (function (_super) {
129
127
  : '';
130
128
  _this.animateAlone = json.animateAlone;
131
129
  _this.iframe = json.iframe;
132
- _this.iframePageAuto = json.iframePageAuto || false;
133
130
  _this.elementId = json.elementId;
134
131
  _this.audio = json.audio;
135
132
  _this.video = json.video;
@@ -236,16 +233,17 @@ var Node = /** @class */ (function (_super) {
236
233
  })
237
234
  };
238
235
  Node.prototype.addToDiv = function (type) {
239
- if (this.iframe ||
236
+ if (this.audio ||
237
+ this.video ||
238
+ this.iframe ||
240
239
  this.elementId ||
241
240
  this.hasGif()) {
241
+ if(type) {
242
+ // 复合Echarts初始化
243
+ createChildrenDivByElementId(this);
244
+ }else {
242
245
  Store.set(this.generateStoreKey('LT:addDiv'), this);
243
- // if(type || this.iframe) {
244
- // // 复合Echarts初始化
245
- // createChildrenDivByElementId(this);
246
- // }else {
247
- // Store.set(this.generateStoreKey('LT:addDiv'), this);
248
- // }
246
+ }
249
247
  }
250
248
  };
251
249
  Node.prototype.hasGif = function () {
@@ -407,10 +405,9 @@ var Node = /** @class */ (function (_super) {
407
405
  //this.drawImg(ctx);
408
406
  return;
409
407
  }
410
- const defaultImageNode = defaultImages[this.id];
411
408
  var img = new Image();
412
409
  img.crossOrigin = 'anonymous';
413
- img.src = defaultImageNode && defaultImageNode.status === 404 ? '' : this.image;
410
+ img.src = this.image;
414
411
  img.onload = function (e) {
415
412
  _this.lastImage = _this.image;
416
413
  _this.imgNaturalWidth = img.naturalWidth;
@@ -420,20 +417,12 @@ var Node = /** @class */ (function (_super) {
420
417
  img: img,
421
418
  cnt: 1,
422
419
  };
423
- if(defaultImageNode) delete defaultImages[_this.id];
424
420
  Store.set(_this.generateStoreKey('LT:imageLoaded'), true);
425
421
  if (!_this.gif && gif) {
426
422
  _this.gif = true;
427
423
  Store.set(_this.generateStoreKey('LT:addDiv'), _this);
428
424
  }
429
425
  };
430
- img.onerror = function(e){
431
- // 图片加载失败时预留默认图为空
432
- defaultImages[_this.id] = {
433
- img: '',
434
- status: 404
435
- };
436
- };
437
426
  };
438
427
  Node.prototype.initDrawImg = function (ctx){
439
428
  var _this = this;
@@ -760,13 +749,11 @@ var Node = /** @class */ (function (_super) {
760
749
  this.rect.height *= h;
761
750
  this.rect.ex = this.rect.x + this.rect.width;
762
751
  this.rect.ey = this.rect.y + this.rect.height;
763
- if(!(center.type && center.type === 'bottLogo')) {
764
- if (this.imageWidth) {
765
- this.imageWidth *= w;
766
- }
767
- if (this.imageHeight) {
768
- this.imageHeight *= h;
769
- }
752
+ if (this.imageWidth) {
753
+ this.imageWidth *= w;
754
+ }
755
+ if (this.imageHeight) {
756
+ this.imageHeight *= h;
770
757
  }
771
758
  this.lastImage = null;
772
759
  this.font.fontSize *= scale;
@@ -19,8 +19,10 @@ var Pen = /** @class */ (function () {
19
19
  this.globalAlpha = 1;
20
20
  this.dash = 0;
21
21
  this.strokeStyle = '';
22
- this.visitStrokeStyle = '';
23
22
  this.fillStyle = '';
23
+ this.defaultFillStyle = '';
24
+ this.defaultFontColor = '#fff';
25
+ this.defaultStrokeStyle = '';
24
26
  this.font = {
25
27
  color: '',
26
28
  fontFamily: '"Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial',
@@ -45,9 +47,6 @@ var Pen = /** @class */ (function () {
45
47
  this.events = [];
46
48
  this.eventFns = ['link', 'doAnimate', 'doFn', 'doWindowFn'];
47
49
  this.floorImageIndex = false;
48
- this.defaultFillStyle = '';
49
- this.defaultFontColor = '';
50
- this.defaultStrokeStyle = '';
51
50
  if (json) {
52
51
  this.id = json.id || s8();
53
52
  this.name = json.name || '';
@@ -72,10 +71,11 @@ var Pen = /** @class */ (function () {
72
71
  if (json.lineWidth || json.lineWidth === 0) {
73
72
  this.lineWidth = json.lineWidth;
74
73
  }
75
- this.activeImgeIndex = json.activeImgeIndex || false;
76
- this.visitStrokeStyle = json.visitStrokeStyle || '';
77
74
  this.strokeStyle = json.strokeStyle || '';
78
75
  this.fillStyle = json.fillStyle || '';
76
+ this.defaultFillStyle = json.defaultFillStyle || '';
77
+ this.defaultFontColor = json.defaultFontColor || '#fff';
78
+ this.defaultStrokeStyle = json.defaultStrokeStyle || '';
79
79
  this.lineCap = json.lineCap;
80
80
  this.globalAlpha = (json.globalAlpha || json.globalAlpha === 0) ? json.globalAlpha : 1
81
81
  this.rotate = json.rotate || 0;
@@ -108,9 +108,6 @@ var Pen = /** @class */ (function () {
108
108
  this.tipId = json.tipId;
109
109
  this.title = json.title;
110
110
  this.visible = json.visible !== false;
111
- this.defaultFillStyle = json.defaultFillStyle || '';
112
- this.defaultFontColor = json.defaultFontColor || '';
113
- this.defaultStrokeStyle = json.defaultStrokeStyle || '';
114
111
  if (json.rectInParent) {
115
112
  this.rectInParent = json.rectInParent;
116
113
  }
@@ -150,13 +147,7 @@ var Pen = /** @class */ (function () {
150
147
  if (this.lineWidth > 1) {
151
148
  ctx.lineWidth = this.lineWidth;
152
149
  }
153
- if(this.dash === 4) {
154
- ctx.strokeStyle = 'transparent';
155
- }else {
156
- const staticStrokeStyle = this.strokeStyle || '#222';
157
- ctx.strokeStyle = !this.activeImgeIndex ? this.visitStrokeStyle || staticStrokeStyle : this.defaultStrokeStyle || staticStrokeStyle;
158
- }
159
- //ctx.strokeStyle = this.dash === 4 ? 'transparent' : this.strokeStyle || '#222';
150
+ ctx.strokeStyle = this.dash === 4 ? 'transparent' : this.strokeStyle || '#222';
160
151
  this.fillStyle && (ctx.fillStyle = this.fillStyle);
161
152
  if (this.lineCap) {
162
153
  ctx.lineCap = this.lineCap;
@@ -0,0 +1,14 @@
1
+ import { TopologyData } from './models';
2
+ export declare class MQTT {
3
+ url: string;
4
+ options: any;
5
+ topics: string;
6
+ data: TopologyData;
7
+ client: any;
8
+ constructor(url: string, options: any, topics: string, data: TopologyData);
9
+ init(): void;
10
+ onmessage: (topic: string, message: any) => void;
11
+ publish(topic: string, message: string): void;
12
+ close(): void;
13
+ isEnd: boolean;
14
+ }
@@ -0,0 +1,82 @@
1
+ import * as mqtt from './mqtt.min.js';
2
+ import { EventType } from './models';
3
+ import { Store } from 'le5le-store';
4
+ var MQTT = /** @class */ (function () {
5
+ function MQTT(url, options, topics, data) {
6
+ var _this = this;
7
+ this.url = url;
8
+ this.options = options;
9
+ this.topics = topics;
10
+ this.data = data;
11
+ this.isEnd = false;
12
+ this.num = 0; // 记录推送的次数,用于判单丢失情况
13
+ this.onmessage = function (topic, message) {
14
+ if (!_this.data.pens.length || !topic || topic != _this.data.mqttTopics) {
15
+ return;
16
+ }
17
+ console.log((new Date()).toString().substring(16,24))
18
+ // 判单推送是否有失丢
19
+ var theNum = JSON.parse(message.toString()).pushNumber
20
+ if((theNum - this.num) > 1) {
21
+ console.log('发生丢失!')
22
+ console.log('上次的计数===',this.num)
23
+ console.log('当前的计数===',theNum)
24
+ // 再次主动请求
25
+ Store.set('mqttLostMessage', true);
26
+ }else{
27
+ Store.set('mqttLostMessage', false);
28
+ }
29
+ this.num = JSON.parse(message.toString()).pushNumber
30
+ console.log('已执行的计数===',this.num)
31
+ console.log('\n')
32
+
33
+ if(!_this.isEnd){
34
+ _this.getPen(_this.data.pens, topics, message)
35
+ }
36
+ };
37
+ //服务器连接异常的回调
38
+ this.onerror= function (error) {
39
+ console.log('服务器连接异常',error)
40
+
41
+ };
42
+ this.init();
43
+ }
44
+ MQTT.prototype.init = function () {
45
+ this.client = mqtt.connect(this.url, this.options);
46
+ console.log('connect===',this.options)
47
+ this.client.on('message', this.onmessage);
48
+ if (this.topics) {
49
+ this.client.subscribe(this.topics.split(','));
50
+ }
51
+ };
52
+ MQTT.prototype.publish = function (topic, message) {
53
+ this.client.publish(topic, message);
54
+ };
55
+ MQTT.prototype.close = function () {
56
+ this.isEnd = true
57
+ this.client.end();
58
+ };
59
+ MQTT.prototype.getPen = function (pens, topics, message) {
60
+ const _this = this;
61
+ pens.forEach((pen)=>{
62
+ if(pen.children != undefined){
63
+ _this.getPen(pen.children, topics, message)
64
+ }else{
65
+ var item = pen;
66
+ for (var _b = 0, _c = item.events; _b < _c.length; _b++) {
67
+ var event_1 = _c[_b];
68
+ if (event_1.type === EventType.Mqtt) {
69
+ event_1.name = topics;
70
+ if(message){
71
+ item.doSocketMqtt(event_1, message.toString(), _this.client);
72
+ }
73
+ }
74
+ }
75
+ }
76
+ })
77
+ };
78
+ return MQTT;
79
+ }());
80
+
81
+ export { MQTT };
82
+ //# sourceMappingURL=mqtt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqtt.js","sourceRoot":"","sources":["../../../packages/core/src/mqtt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAgB,MAAM,UAAU,CAAC;AAEnD;IAEE,cAAmB,GAAW,EAAS,OAAY,EAAS,MAAc,EAAS,IAAkB;QAArG,iBAEC;QAFkB,QAAG,GAAH,GAAG,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAK;QAAS,WAAM,GAAN,MAAM,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAc;QAarG,cAAS,GAAG,UAAC,KAAa,EAAE,OAAY;YACtC,IAAI,CAAC,KAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;gBACpC,OAAO;aACR;YAED,KAAmB,UAAc,EAAd,KAAA,KAAI,CAAC,IAAI,CAAC,IAAI,EAAd,cAAc,EAAd,IAAc,EAAE;gBAA9B,IAAM,IAAI,SAAA;gBACb,KAAoB,UAAW,EAAX,KAAA,IAAI,CAAC,MAAM,EAAX,cAAW,EAAX,IAAW,EAAE;oBAA5B,IAAM,OAAK,SAAA;oBACd,IAAI,OAAK,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE;wBACjC,IAAI,OAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,OAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;4BAChD,IAAI,CAAC,YAAY,CAAC,OAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAI,CAAC,MAAM,CAAC,CAAC;yBAC3D;qBACF;iBACF;aACF;QACH,CAAC,CAAC;QA1BA,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAED,mBAAI,GAAJ;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAE1C,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;SAC/C;IACH,CAAC;IAkBD,sBAAO,GAAP,UAAQ,KAAa,EAAE,OAAe;QACpC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,oBAAK,GAAL;QACE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;IACH,WAAC;AAAD,CAAC,AAtCD,IAsCC"}
@@ -1,12 +1,15 @@
1
+ import { Options } from './options';
1
2
  import { Canvas } from './canvas';
2
3
  import { ActiveLayer } from './activeLayer';
3
4
  import { HoverLayer } from './hoverLayer';
4
5
  import { AnimateLayer } from './animateLayer';
5
6
  export declare class Offscreen extends Canvas {
7
+ parentElem: HTMLElement;
8
+ options: Options;
6
9
  activeLayer: ActiveLayer;
7
10
  hoverLayer: HoverLayer;
8
11
  animateLayer: AnimateLayer;
9
- constructor(TID: String);
12
+ constructor(parentElem: HTMLElement, options: Options, TID: String);
10
13
  getRoutineLayer(auto?:[]): void;
11
14
  render(): void;
12
15
  destroy(): void;
@@ -13,12 +13,13 @@ var __extends = (this && this.__extends) || (function () {
13
13
  })();
14
14
  import { Store } from 'le5le-store';
15
15
  import { Canvas } from './canvas';
16
- import { Node } from './models'
17
- import { commonStore } from './store'
18
16
  var Offscreen = /** @class */ (function (_super) {
19
17
  __extends(Offscreen, _super);
20
- function Offscreen(TID) {
21
- var _this = _super.call(this, TID) || this;
18
+ function Offscreen(parentElem, options, TID) {
19
+ if (options === void 0) { options = {}; }
20
+ var _this = _super.call(this, parentElem, options, TID) || this;
21
+ _this.parentElem = parentElem;
22
+ _this.options = options;
22
23
  _this.activeLayer = null;
23
24
  _this.hoverLayer = null;
24
25
  _this.animateLayer = null;
@@ -39,12 +40,9 @@ var Offscreen = /** @class */ (function (_super) {
39
40
  Offscreen.prototype.render = function () {
40
41
  _super.prototype.render.call(this);
41
42
  var ctx = this.canvas.getContext('2d');
42
- if(!commonStore || !commonStore[this.TID]) return;
43
- let store = commonStore[this.TID];
44
- ctx.strokeStyle = store.options.color;
45
- for (var _i = 0, _a = store.data.pens; _i < _a.length; _i++) {
43
+ ctx.strokeStyle = this.options.color;
44
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
46
45
  var item = _a[_i];
47
- if(!(item instanceof Node)) item = new Node(item);
48
46
  if (!item.getTID()) {
49
47
  item.setTID(this.TID);
50
48
  }
@@ -59,9 +57,9 @@ var Offscreen = /** @class */ (function (_super) {
59
57
  if(this.animateLayer) {
60
58
  this.animateLayer.render(ctx);
61
59
  }
62
- store = null;
63
60
  };
64
61
  Offscreen.prototype.destroy = function () {
62
+ this.options = null;
65
63
  this.activeLayer = null;
66
64
  this.hoverLayer = null;
67
65
  this.animateLayer = null;
@@ -38,6 +38,5 @@ export var DefalutOptions = {
38
38
  autoExpandDistance: 200,
39
39
  keydown: KeydownType.Document,
40
40
  viewPadding: 0,
41
- interval: 50
42
41
  };
43
42
  //# sourceMappingURL=options.js.map
package/core/src/poll.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { EventType } from 'dcim-topology/core/src/models';
2
+
1
3
  // 轮询
2
4
  var POLL = /** @class */ (function () {
3
5
  function POLL(data, message, val) {
@@ -1,6 +1,18 @@
1
1
  // @ts-ignore
2
- import {Padding, Options} from './options';
2
+ import {Options, Padding} from './options';
3
+ import { Pen } from './models';
4
+ import { Node } from './models';
3
5
  import { Point } from './models';
6
+ import { Line } from './models';
7
+ import { TopologyData } from './models';
8
+ import { Lock } from './models';
9
+ import { Offscreen } from './offscreen';
10
+ import { RenderLayer } from './renderLayer';
11
+ import { AnimateLayer } from './animateLayer';
12
+ import { DivLayer } from './divLayer';
13
+ import { Rect } from './models';
14
+ import { Socket } from './socket';
15
+ import { MQTT } from './mqtt';
4
16
  import {Common} from './common';
5
17
  export declare class Preview extends Common{
6
18
  constructor(parent: string | HTMLElement, options?: Options);
@@ -23,14 +23,13 @@ var Preview = (function (_super) {
23
23
  _this.offscreen.getRoutineLayer(['AnimateLayer']);
24
24
  _this.scheduledAnimationFrame = false;
25
25
  _this.onMouseMove = function (e) {
26
- _this.store.data.dataResize = 0;
27
26
  // https://caniuse.com/#feat=mdn-api_mouseevent_buttons
28
27
  if (_this.mouseDown && !_this.mouseDown.restore && e.buttons !== 1) {
29
28
  // 防止异常情况导致mouseup事件没有触发
30
29
  _this.onmouseup(e);
31
30
  return;
32
31
  }
33
- if (_this.store.data.locked && _this.mouseDown) {
32
+ if (_this.data.locked && _this.mouseDown) {
34
33
  return;
35
34
  }
36
35
  _this.scheduledAnimationFrame = true;
@@ -46,13 +45,13 @@ var Preview = (function (_super) {
46
45
  hoverNode,
47
46
  moveType,
48
47
  eventNode
49
- } = mousMoveFun(_this.store.options.type, pos, _this.store.data.pens);
48
+ } = mousMoveFun(_this.options.type, pos, _this.data.pens);
50
49
  _this.moveIn.type = _this.moveInType.None;
51
50
  _this.scheduledAnimationFrame = false;
52
51
  _this.hideTip();
53
- _this.setAttributeForCanvasPoint('default');
52
+ _this.divLayer.canvas.style.cursor = 'default';
54
53
  if (hoverNode) {
55
- if(eventNode) _this.setAttributeForCanvasPoint('pointer');
54
+ if(eventNode) _this.divLayer.canvas.style.cursor = 'pointer';
56
55
  if(hoverNode.visible) _this.showTip(hoverNode, pos);
57
56
  _this.moveIn.type = moveType;
58
57
  }
@@ -69,14 +68,14 @@ var Preview = (function (_super) {
69
68
  var canvasPos = _this.divLayer.canvas.getBoundingClientRect();
70
69
  _this.mouseDown = {x: e.x - canvasPos.x, y: e.y - canvasPos.y};
71
70
  if (e.altKey) {
72
- _this.setAttributeForCanvasPoint('pointer');
71
+ _this.divLayer.canvas.style.cursor = 'pointer';
73
72
  }
74
73
  if (_this.inputObj) {
75
74
  _this.setNodeText();
76
75
  }
77
- const {eventType, value} = mousDownFun(_this.store.options.type, _this.moveIn.eventNode);
76
+ const {eventType, value} = mousDownFun(_this.options.type, _this.moveIn.eventNode);
78
77
  if (_this.moveIn.type == _this.moveInType.Nodes) {
79
- _this.setAttributeForCanvasPoint('pointer');
78
+ _this.divLayer.canvas.style.cursor = 'pointer';
80
79
  switch (eventType) {
81
80
  case downDataType.Window:
82
81
  omouseEventPrototDoWindowFn(_this.moveIn.eventNode, _this.moveIn.hoverNode);
@@ -85,7 +84,7 @@ var Preview = (function (_super) {
85
84
  _this.dispatch('node', _this.moveIn.hoverNode);
86
85
  break;
87
86
  case downDataType.Showhide:
88
- _this.hidePenByTag(_this.store.data.pens, value);
87
+ _this.hidePenByTag(_this.data.pens, value);
89
88
  const obj = value ? JSON.parse(value) : {}
90
89
  const visibleRange = obj.visibleRange
91
90
  if (visibleRange == '1') {
@@ -104,20 +103,16 @@ var Preview = (function (_super) {
104
103
  _this.mouseDown = null;
105
104
  _this.lastTranlated.x = 0;
106
105
  _this.lastTranlated.y = 0;
107
- if(_this.moveIn.eventNode) {
108
- _this.setAttributeForCanvasPoint('pointer');
109
- }else {
110
- _this.setAttributeForCanvasPoint('default');
111
- }
106
+ _this.divLayer.canvas.style.cursor = _this.moveIn.eventNode ? 'pointer' : 'default';
112
107
  };
113
108
  _this.divLayer.canvas.onmousemove = this.onMouseMove;
114
109
  _this.divLayer.canvas.onmousedown = this.onmousedown;
115
110
  _this.divLayer.canvas.onmouseup = this.onmouseup;
116
111
  _this.divLayer.canvas.onwheel = function (event) {
117
- if (_this.store.options.disableScale) {
112
+ if (_this.options.disableScale) {
118
113
  return;
119
114
  }
120
- switch (_this.store.options.scaleKey) {
115
+ switch (_this.options.scaleKey) {
121
116
  case KeyType.None:
122
117
  break;
123
118
  case KeyType.Ctrl:
@@ -163,71 +158,54 @@ var Preview = (function (_super) {
163
158
  return false;
164
159
  };
165
160
  return _this;
166
- }
167
- Preview.prototype.setAttributeForCanvasPoint = function (type){
168
-
169
- this.divLayer.canvas.setAttribute('class', `canvas-point ${type}`);
170
-
171
161
  };
172
162
  Preview.prototype.fitViewPreview = function (restore){
173
163
  this.fitView(null, restore);
174
164
  this.render();
175
165
  };
176
166
  // open - redraw by the data
177
- Preview.prototype.open = function (topoJSon, type) {
178
- this.conversionData(topoJSon, type);
179
- this.setBKImageRect();
167
+ Preview.prototype.open = function (topoJSon) {
168
+ this.conversionData(topoJSon);
169
+ this.parentElem.scrollLeft = 0;
170
+ this.parentElem.scrollTop = 0;
171
+ this.divLayer.clear();
180
172
  this.fitView();
181
173
  this.render(true);
182
174
  this.animate(true);
183
175
  };
184
- Preview.prototype.setBKImageRect = function () {
185
- if (this.store.data.bkImageRect) {
186
- this.store.data.bkImageRect.x = this.store.data.bkImageRect.x ? Number(this.store.data.bkImageRect.x) : 0;
187
- this.store.data.bkImageRect.y = this.store.data.bkImageRect.y ? Number(this.store.data.bkImageRect.y) : 0;
188
- this.store.data.bkImageRect.width = this.store.data.bkImageRect.width ? Number(this.store.data.bkImageRect.width) : this.canvas.width;
189
- this.store.data.bkImageRect.height = this.store.data.bkImageRect.height ? Number(this.store.data.bkImageRect.height) : this.canvas.height;
190
- this.store.data.bkImageRect.center = {
191
- x: this.store.data.bkImageRect.x + this.store.data.bkImageRect.width / 2,
192
- y: this.store.data.bkImageRect.y + this.store.data.bkImageRect.height / 2
193
- }
194
- }
195
- };
196
176
  Preview.prototype.scale = function (scale, center, w, h) {
197
- if (this.store.data.scale * scale < this.store.options.minScale ||
198
- this.store.data.scale * scale > this.store.options.maxScale) {
177
+ if (this.data.scale * scale < this.options.minScale ||
178
+ this.data.scale * scale > this.options.maxScale) {
199
179
  return;
200
180
  }
201
181
  const scaleX = w ? w : scale;
202
182
  const scaleY = h ? h : scale;
203
- this.store.data.scale *= scale;
183
+ this.data.scale *= scale;
204
184
  if(this.isFullScreen) {
205
- this.store.ratioCord.ratio *= scale;
206
- this.store.ratioCord.scaleX *= scaleX;
207
- this.store.ratioCord.scaleY *= scaleY;
185
+ this.ratioCord.ratio *= scale;
186
+ this.ratioCord.scaleX *= scaleX;
187
+ this.ratioCord.scaleY *= scaleY;
208
188
  }else {
209
- this.store.ratioCord = {
210
- ratio: 1,
211
- scaleX: 1,
212
- scaleY: 1
213
- }
189
+ this.ratioCord.ratio = 1;
190
+ this.ratioCord.scaleX = 1;
191
+ this.ratioCord.scaleY = 1;
214
192
  }
215
193
  !center && (center = this.getRect().center);
216
- for (var _i = 0, _a = this.store.data.pens; _i < _a.length; _i++) {
194
+ for (var _i = 0, _a = this.data.pens; _i < _a.length; _i++) {
217
195
  var item = _a[_i];
218
196
  item.scale(scale, center, w, h);
219
197
  }
220
198
  };
221
199
  Preview.prototype.scaleTo = function (scale) {
222
- this.scale(scale / this.store.data.scale);
223
- this.store.data.scale = scale;
200
+ this.scale(scale / this.data.scale);
201
+ this.data.scale = scale;
224
202
  };
225
203
  // scale for origin canvas:
226
204
  Preview.prototype.fitView = function (viewPadding, restore) {
227
205
  if (!this.hasView())
228
206
  return;
229
207
  // 1. 重置画布尺寸为容器尺寸
230
- var parentElem = this.store.parentElem;
208
+ var parentElem = this.canvas.parentElem;
231
209
  var width = parentElem.offsetWidth, height = parentElem.offsetHeight;
232
210
  this.canvasResize({
233
211
  width: width,
@@ -236,7 +214,7 @@ var Preview = (function (_super) {
236
214
  // 2. 图形居中
237
215
  this.centerView(viewPadding);
238
216
  // 3. 获取设置的留白值
239
- var padding = formatPadding(viewPadding || this.store.options.viewPadding);
217
+ var padding = formatPadding(viewPadding || this.options.viewPadding);
240
218
  // 4. 获取图形尺寸
241
219
  var rect = this.getRect();
242
220
  // 6. 计算缩放比
@@ -247,14 +225,14 @@ var Preview = (function (_super) {
247
225
  ratio = h;
248
226
  }
249
227
  if(typeof restore === 'boolean' && restore) {
250
- ratio = 1 / this.store.ratioCord.ratio;
251
- w = 1 / this.store.ratioCord.scaleX;
252
- h = 1 / this.store.ratioCord.scaleY;
228
+ ratio = 1 / this.ratioCord.ratio;
229
+ w = 1 / this.ratioCord.scaleX;
230
+ h = 1 / this.ratioCord.scaleY;
253
231
  }
254
232
  this.scale(ratio, undefined, w, h);
255
233
  this.canvas.scale(ratio, undefined, w, h);
256
234
  // 7. X抽滚动条隐藏
257
- this.store.parentElem.style.overflow = 'hidden auto';
235
+ this.parentElem.style.overflow = 'hidden auto';
258
236
  };
259
237
  Preview.prototype.destroy = function () {
260
238
  this.destroyStatic();
@@ -2,6 +2,8 @@ import { Options } from './options';
2
2
  import { Canvas } from './canvas';
3
3
  import {Point} from './models';
4
4
  export declare class RenderLayer extends Canvas {
5
+ parentElem: HTMLElement;
6
+ options: Options;
5
7
  offscreen: any;
6
8
  bkImg: HTMLImageElement;
7
9
  bkImgRect: {
@@ -20,7 +22,7 @@ export declare class RenderLayer extends Canvas {
20
22
  width: number;
21
23
  height: number;
22
24
  };
23
- constructor(TID: String);
25
+ constructor(parentElem: HTMLElement, options: Options, TID: String);
24
26
  loadBkImg(cb?: any): void;
25
27
  clearBkImg(): void;
26
28
  render: () => void;