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
@@ -80,7 +80,7 @@ var Node = /** @class */ (function (_super) {
80
80
  _this.leakageFillStyle = json.leakageFillStyle || '#ff0000';
81
81
  _this.bindStaticId = json.bindStaticId || '';
82
82
  _this.buttonCheckSlide = json.buttonCheckSlide || '';
83
- _this.visitStrokeStyle = json.visitStrokeStyle || '';
83
+ _this.activeImgeIndex = json.activeImgeIndex || false;
84
84
  _this.thBottomStrokeStyle = json.thBottomStrokeStyle || '#fff';
85
85
  _this.thBottomLineWidth = json.thBottomLineWidth || 1;
86
86
  // 兼容老数据
@@ -238,12 +238,12 @@ var Node = /** @class */ (function (_super) {
238
238
  this.iframe ||
239
239
  this.elementId ||
240
240
  this.hasGif()) {
241
- if(type) {
242
- // 复合Echarts初始化
243
- createChildrenDivByElementId(this);
244
- }else {
245
- Store.set(this.generateStoreKey('LT:addDiv'), this);
246
- }
241
+ if(type) {
242
+ // 复合Echarts初始化
243
+ createChildrenDivByElementId(this);
244
+ }else {
245
+ Store.set(this.generateStoreKey('LT:addDiv'), this);
246
+ }
247
247
  }
248
248
  };
249
249
  Node.prototype.hasGif = function () {
@@ -749,13 +749,11 @@ var Node = /** @class */ (function (_super) {
749
749
  this.rect.height *= h;
750
750
  this.rect.ex = this.rect.x + this.rect.width;
751
751
  this.rect.ey = this.rect.y + this.rect.height;
752
- if(!(center.type && center.type === 'bottLogo')) {
753
- if (this.imageWidth) {
754
- this.imageWidth *= w;
755
- }
756
- if (this.imageHeight) {
757
- this.imageHeight *= h;
758
- }
752
+ if (this.imageWidth) {
753
+ this.imageWidth *= w;
754
+ }
755
+ if (this.imageHeight) {
756
+ this.imageHeight *= h;
759
757
  }
760
758
  this.lastImage = null;
761
759
  this.font.fontSize *= scale;
@@ -19,7 +19,6 @@ 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 = '';
24
23
  this.defaultFillStyle = '';
25
24
  this.defaultFontColor = '#fff';
@@ -72,8 +71,6 @@ 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 || '';
79
76
  this.defaultFillStyle = json.defaultFillStyle || '';
@@ -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);
@@ -29,7 +29,7 @@ var Preview = (function (_super) {
29
29
  _this.onmouseup(e);
30
30
  return;
31
31
  }
32
- if (_this.store.data.locked && _this.mouseDown) {
32
+ if (_this.data.locked && _this.mouseDown) {
33
33
  return;
34
34
  }
35
35
  _this.scheduledAnimationFrame = true;
@@ -45,13 +45,13 @@ var Preview = (function (_super) {
45
45
  hoverNode,
46
46
  moveType,
47
47
  eventNode
48
- } = mousMoveFun(_this.store.options.type, pos, _this.store.data.pens);
48
+ } = mousMoveFun(_this.options.type, pos, _this.data.pens);
49
49
  _this.moveIn.type = _this.moveInType.None;
50
50
  _this.scheduledAnimationFrame = false;
51
51
  _this.hideTip();
52
- _this.setAttributeForCanvasPoint('default');
52
+ _this.divLayer.canvas.style.cursor = 'default';
53
53
  if (hoverNode) {
54
- if(eventNode) _this.setAttributeForCanvasPoint('pointer');
54
+ if(eventNode) _this.divLayer.canvas.style.cursor = 'pointer';
55
55
  if(hoverNode.visible) _this.showTip(hoverNode, pos);
56
56
  _this.moveIn.type = moveType;
57
57
  }
@@ -68,14 +68,14 @@ var Preview = (function (_super) {
68
68
  var canvasPos = _this.divLayer.canvas.getBoundingClientRect();
69
69
  _this.mouseDown = {x: e.x - canvasPos.x, y: e.y - canvasPos.y};
70
70
  if (e.altKey) {
71
- _this.setAttributeForCanvasPoint('pointer');
71
+ _this.divLayer.canvas.style.cursor = 'pointer';
72
72
  }
73
73
  if (_this.inputObj) {
74
74
  _this.setNodeText();
75
75
  }
76
- const {eventType, value} = mousDownFun(_this.store.options.type, _this.moveIn.eventNode);
76
+ const {eventType, value} = mousDownFun(_this.options.type, _this.moveIn.eventNode);
77
77
  if (_this.moveIn.type == _this.moveInType.Nodes) {
78
- _this.setAttributeForCanvasPoint('pointer');
78
+ _this.divLayer.canvas.style.cursor = 'pointer';
79
79
  switch (eventType) {
80
80
  case downDataType.Window:
81
81
  omouseEventPrototDoWindowFn(_this.moveIn.eventNode, _this.moveIn.hoverNode);
@@ -84,7 +84,7 @@ var Preview = (function (_super) {
84
84
  _this.dispatch('node', _this.moveIn.hoverNode);
85
85
  break;
86
86
  case downDataType.Showhide:
87
- _this.hidePenByTag(_this.store.data.pens, value);
87
+ _this.hidePenByTag(_this.data.pens, value);
88
88
  const obj = value ? JSON.parse(value) : {}
89
89
  const visibleRange = obj.visibleRange
90
90
  if (visibleRange == '1') {
@@ -103,20 +103,16 @@ var Preview = (function (_super) {
103
103
  _this.mouseDown = null;
104
104
  _this.lastTranlated.x = 0;
105
105
  _this.lastTranlated.y = 0;
106
- if(_this.moveIn.eventNode) {
107
- _this.setAttributeForCanvasPoint('pointer');
108
- }else {
109
- _this.setAttributeForCanvasPoint('default');
110
- }
106
+ _this.divLayer.canvas.style.cursor = _this.moveIn.eventNode ? 'pointer' : 'default';
111
107
  };
112
108
  _this.divLayer.canvas.onmousemove = this.onMouseMove;
113
109
  _this.divLayer.canvas.onmousedown = this.onmousedown;
114
110
  _this.divLayer.canvas.onmouseup = this.onmouseup;
115
111
  _this.divLayer.canvas.onwheel = function (event) {
116
- if (_this.store.options.disableScale) {
112
+ if (_this.options.disableScale) {
117
113
  return;
118
114
  }
119
- switch (_this.store.options.scaleKey) {
115
+ switch (_this.options.scaleKey) {
120
116
  case KeyType.None:
121
117
  break;
122
118
  case KeyType.Ctrl:
@@ -162,58 +158,54 @@ var Preview = (function (_super) {
162
158
  return false;
163
159
  };
164
160
  return _this;
165
- }
166
- Preview.prototype.setAttributeForCanvasPoint = function (type){
167
-
168
- this.divLayer.canvas.setAttribute('class', `canvas-point ${type}`);
169
-
170
161
  };
171
162
  Preview.prototype.fitViewPreview = function (restore){
172
163
  this.fitView(null, restore);
173
164
  this.render();
174
165
  };
175
166
  // open - redraw by the data
176
- Preview.prototype.open = function (topoJSon, type) {
177
- this.conversionData(topoJSon, type);
167
+ Preview.prototype.open = function (topoJSon) {
168
+ this.conversionData(topoJSon);
169
+ this.parentElem.scrollLeft = 0;
170
+ this.parentElem.scrollTop = 0;
171
+ this.divLayer.clear();
178
172
  this.fitView();
179
173
  this.render(true);
180
174
  this.animate(true);
181
175
  };
182
176
  Preview.prototype.scale = function (scale, center, w, h) {
183
- if (this.store.data.scale * scale < this.store.options.minScale ||
184
- 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) {
185
179
  return;
186
180
  }
187
181
  const scaleX = w ? w : scale;
188
182
  const scaleY = h ? h : scale;
189
- this.store.data.scale *= scale;
183
+ this.data.scale *= scale;
190
184
  if(this.isFullScreen) {
191
- this.store.ratioCord.ratio *= scale;
192
- this.store.ratioCord.scaleX *= scaleX;
193
- this.store.ratioCord.scaleY *= scaleY;
185
+ this.ratioCord.ratio *= scale;
186
+ this.ratioCord.scaleX *= scaleX;
187
+ this.ratioCord.scaleY *= scaleY;
194
188
  }else {
195
- this.store.ratioCord = {
196
- ratio: 1,
197
- scaleX: 1,
198
- scaleY: 1
199
- }
189
+ this.ratioCord.ratio = 1;
190
+ this.ratioCord.scaleX = 1;
191
+ this.ratioCord.scaleY = 1;
200
192
  }
201
193
  !center && (center = this.getRect().center);
202
- 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++) {
203
195
  var item = _a[_i];
204
196
  item.scale(scale, center, w, h);
205
197
  }
206
198
  };
207
199
  Preview.prototype.scaleTo = function (scale) {
208
- this.scale(scale / this.store.data.scale);
209
- this.store.data.scale = scale;
200
+ this.scale(scale / this.data.scale);
201
+ this.data.scale = scale;
210
202
  };
211
203
  // scale for origin canvas:
212
204
  Preview.prototype.fitView = function (viewPadding, restore) {
213
205
  if (!this.hasView())
214
206
  return;
215
207
  // 1. 重置画布尺寸为容器尺寸
216
- var parentElem = this.store.parentElem;
208
+ var parentElem = this.canvas.parentElem;
217
209
  var width = parentElem.offsetWidth, height = parentElem.offsetHeight;
218
210
  this.canvasResize({
219
211
  width: width,
@@ -222,7 +214,7 @@ var Preview = (function (_super) {
222
214
  // 2. 图形居中
223
215
  this.centerView(viewPadding);
224
216
  // 3. 获取设置的留白值
225
- var padding = formatPadding(viewPadding || this.store.options.viewPadding);
217
+ var padding = formatPadding(viewPadding || this.options.viewPadding);
226
218
  // 4. 获取图形尺寸
227
219
  var rect = this.getRect();
228
220
  // 6. 计算缩放比
@@ -233,14 +225,14 @@ var Preview = (function (_super) {
233
225
  ratio = h;
234
226
  }
235
227
  if(typeof restore === 'boolean' && restore) {
236
- ratio = 1 / this.store.ratioCord.ratio;
237
- w = 1 / this.store.ratioCord.scaleX;
238
- h = 1 / this.store.ratioCord.scaleY;
228
+ ratio = 1 / this.ratioCord.ratio;
229
+ w = 1 / this.ratioCord.scaleX;
230
+ h = 1 / this.ratioCord.scaleY;
239
231
  }
240
232
  this.scale(ratio, undefined, w, h);
241
233
  this.canvas.scale(ratio, undefined, w, h);
242
234
  // 7. X抽滚动条隐藏
243
- this.store.parentElem.style.overflow = 'hidden auto';
235
+ this.parentElem.style.overflow = 'hidden auto';
244
236
  };
245
237
  Preview.prototype.destroy = function () {
246
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;
@@ -13,20 +13,22 @@ var __extends = (this && this.__extends) || (function () {
13
13
  })();
14
14
  import { Store } from 'le5le-store';
15
15
  import { Canvas } from './canvas';
16
- import { commonStore } from './store'
16
+ import {previewType} from './utils/construction'
17
17
  //let isQttFillStyle = false;
18
18
  var RenderLayer = /** @class */ (function (_super) {
19
19
  __extends(RenderLayer, _super);
20
- function RenderLayer(TID) {
20
+ function RenderLayer(parentElem, options, TID) {
21
21
  //isQttFillStyle = false;
22
- var _this = _super.call(this, TID) || this;
22
+ if (options === void 0) { options = {}; }
23
+ var _this = _super.call(this, parentElem, options, TID) || this;
24
+ _this.parentElem = parentElem;
25
+ _this.options = options;
23
26
  _this.bkImgRect = null;
24
27
  _this.initImage = false;
25
28
  _this.coverType = 'container';
26
29
  _this.bgRect = null;
27
30
  _this.render = function () {
28
- if(!commonStore || !commonStore[TID]) return;
29
- if (commonStore[TID].data.bkImage && !_this.initImage) {
31
+ if (_this.data.bkImage && !_this.initImage) {
30
32
  _this.loadBkImg(_this.render, 'pixi');
31
33
  return;
32
34
  }
@@ -35,8 +37,12 @@ var RenderLayer = /** @class */ (function (_super) {
35
37
  }
36
38
  var ctx = _this.canvas.getContext('2d');
37
39
  ctx.clearRect(0, 0, _this.canvas.width, _this.canvas.height);
38
- if (commonStore[TID].data.bkColor) {
39
- ctx.fillStyle = commonStore[TID].data.bkColor;
40
+ // if (_this.data.pens && _this.data.pens.length > 0 && !isQttFillStyle) {
41
+ // _this.data.pens.map((penItem) => {penItem.defaultFillStyle = penItem.fillStyle;})
42
+ // isQttFillStyle = true;
43
+ // }
44
+ if (_this.data.bkColor) {
45
+ ctx.fillStyle = _this.data.bkColor;
40
46
  ctx.fillRect(0, 0, _this.width, _this.height);
41
47
  }
42
48
  if (_this.bkImg && _this.bkImgRect) {
@@ -46,38 +52,34 @@ var RenderLayer = /** @class */ (function (_super) {
46
52
  ctx.drawImage(_this.offscreen, 0, 0, _this.width, _this.height);
47
53
  };
48
54
  _this.offscreen = Store.get(_this.generateStoreKey('LT:offscreen'));
49
- commonStore[TID].parentElem.appendChild(_this.canvas);
55
+ _this.parentElem.appendChild(_this.canvas);
50
56
  return _this;
51
57
  }
52
58
  RenderLayer.prototype.scale = function (scale, center, w, h){
53
- const TID = this.TID;
54
- if(!commonStore || !commonStore[TID]) return;
55
- const bkImage = commonStore[TID].data.bkImage;
56
- const bkImageRect = commonStore[TID].data.bkImageRect;
57
- if(!bkImage) return;
59
+ if(!this.data.bkImage) return;
58
60
  if(!center) {
59
- center = bkImageRect ? bkImageRect.center : this.bgRect.center;
61
+ center = this.data.bkImageRect ? this.data.bkImageRect.center : this.bgRect.center;
60
62
  }
61
63
  if (!w) {
62
64
  w = scale;
63
- if(bkImageRect) {
64
- bkImageRect.x = center.x - (center.x - bkImageRect.x) * w;
65
+ if(this.data.bkImageRect) {
66
+ this.data.bkImageRect.x = center.x - (center.x - this.data.bkImageRect.x) * w;
65
67
  }else {
66
68
  this.bgRect.x = center.x - (center.x - this.bgRect.x) * w;
67
69
  }
68
70
  }
69
71
  if (!h) {
70
72
  h = scale;
71
- if(bkImageRect){
72
- bkImageRect.y = center.y - (center.y - bkImageRect.y) * h;
73
+ if(this.data.bkImageRect){
74
+ this.data.bkImageRect.y = center.y - (center.y - this.data.bkImageRect.y) * h;
73
75
  }else {
74
76
  this.bgRect.y = center.y - (center.y - this.bgRect.y) * h;
75
77
  }
76
78
  }
77
- if(bkImageRect) {
78
- bkImageRect.width *= w;
79
- bkImageRect.height *= h;
80
- this.bkImgRect = bkImageRect;
79
+ if(this.data.bkImageRect) {
80
+ this.data.bkImageRect.width *= w;
81
+ this.data.bkImageRect.height *= h;
82
+ this.bkImgRect = this.data.bkImageRect;
81
83
  }else {
82
84
  if(this.initImage) {
83
85
  this.bgRect.width *= w;
@@ -88,13 +90,12 @@ var RenderLayer = /** @class */ (function (_super) {
88
90
  };
89
91
  RenderLayer.prototype.loadBkImg = function (cb, pixi) {
90
92
  var _this = this;
91
- const bkImage = commonStore[_this.TID].data.bkImage;
92
- if (!bkImage || this.initImage) {
93
+ if (!this.data.bkImage || this.initImage) {
93
94
  return;
94
95
  }
95
96
  this.bkImg = new Image();
96
97
  this.bkImg.crossOrigin = 'anonymous';
97
- this.bkImg.src = bkImage;
98
+ this.bkImg.src = this.data.bkImage;
98
99
  this.bkImg.onload = function () {
99
100
  if(pixi && !_this.bkImgRect) {
100
101
  _this.bkImgRectResize({width: _this.canvas.width, height: _this.canvas.height});
@@ -148,7 +149,7 @@ var RenderLayer = /** @class */ (function (_super) {
148
149
  };
149
150
 
150
151
  RenderLayer.prototype.bkImgRectResize = function (size) {
151
- const bkImageRect = commonStore[this.TID].data.bkImageRect;
152
+ const bkImageRect = this.data.bkImageRect;
152
153
  if(!size) return;
153
154
  if(bkImageRect) {
154
155
  let x = bkImageRect.x ? Number(bkImageRect.x) : 0;
@@ -169,12 +170,16 @@ var RenderLayer = /** @class */ (function (_super) {
169
170
 
170
171
  RenderLayer.prototype.destroy = function() {
171
172
 
173
+ this.data = null;
174
+
172
175
  this.canvas = null;
173
176
 
174
177
  this.render = null;
175
178
 
176
179
  this.offscreen = null;
177
180
 
181
+ this.options = null;
182
+
178
183
  }
179
184
  return RenderLayer;
180
185
  }(Canvas));
@@ -0,0 +1,10 @@
1
+ import { TopologyData } from './models';
2
+ export declare class Socket {
3
+ url: string;
4
+ data: TopologyData;
5
+ socket: WebSocket;
6
+ constructor(url: string, data: TopologyData);
7
+ init(): void;
8
+ onmessage: (e: MessageEvent) => void;
9
+ close(): void;
10
+ }