@packtrack/layout 1.6.6 → 1.6.8

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.
@@ -15,7 +15,7 @@ export declare class Layout {
15
15
  monitors: Monitor[];
16
16
  throttles: Throttle[];
17
17
  get allDistricts(): District[];
18
- static from(document: any): Layout;
18
+ static from(railway: any): Layout;
19
19
  loadMonitor(source: any, parent: District | Layout): Monitor;
20
20
  loadThrottle(source: any, parent: District | Layout): Throttle;
21
21
  loadDistrict(source: any, parent: District | Layout): District;
@@ -35,9 +35,8 @@ export class Layout {
35
35
  }
36
36
  return districts;
37
37
  }
38
- static from(document) {
38
+ static from(railway) {
39
39
  const layout = new Layout();
40
- const railway = document.firstChild;
41
40
  layout.name = railway.getAttribute('name');
42
41
  const version = railway.getAttribute('version');
43
42
  if (version == '1') {
@@ -128,6 +127,9 @@ export class Layout {
128
127
  loadSection(source, district) {
129
128
  const section = new Section(source.getAttribute('name'), district);
130
129
  district.sections.push(section);
130
+ if (source.hasAttribute('power-district')) {
131
+ section.powerDistrict = district.powerDistricts.find(district => district.name == source.hasAttribute('power-district'));
132
+ }
131
133
  let child = source.firstChild;
132
134
  while (child) {
133
135
  if (child.tagName == 'tracks') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@packtrack/layout",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "type": "module",
5
5
  "main": ".built/index.js",
6
6
  "typings": ".built/index.d.ts",
package/source/layout.ts CHANGED
@@ -45,10 +45,8 @@ export class Layout {
45
45
  return districts;
46
46
  }
47
47
 
48
- static from(document: any) {
48
+ static from(railway: any) {
49
49
  const layout = new Layout();
50
-
51
- const railway = document.firstChild!;
52
50
  layout.name = railway.getAttribute('name');
53
51
 
54
52
  const version = railway.getAttribute('version');
@@ -174,6 +172,10 @@ export class Layout {
174
172
  const section = new Section(source.getAttribute('name'), district);
175
173
  district.sections.push(section);
176
174
 
175
+ if (source.hasAttribute('power-district')) {
176
+ section.powerDistrict = district.powerDistricts.find(district => district.name == source.hasAttribute('power-district'));
177
+ }
178
+
177
179
  let child = source.firstChild;
178
180
 
179
181
  while (child) {
package/source/section.ts CHANGED
@@ -86,7 +86,6 @@ export class Section {
86
86
  const span = Span.trail(startPosition, endPosition);
87
87
 
88
88
  const tiles: Tile[] = [];
89
-
90
89
  let sectionLength = 0;
91
90
 
92
91
  if (startPosition.section == endPosition.section) {