@packtrack/layout 1.2.0 → 1.3.1

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 (87) hide show
  1. package/.built/index.d.ts +20 -20
  2. package/.built/index.js +20 -20
  3. package/.built/source/device/channel.d.ts +2 -2
  4. package/.built/source/device/channel.js +4 -8
  5. package/.built/{device → source/device}/index.d.ts +0 -1
  6. package/.built/source/device/index.js +8 -0
  7. package/.built/source/district.d.ts +3 -7
  8. package/.built/source/district.js +4 -70
  9. package/.built/source/layout.d.ts +9 -6
  10. package/.built/source/layout.js +85 -86
  11. package/.built/{monitor.d.ts → source/monitor.d.ts} +1 -2
  12. package/.built/source/monitor.js +8 -0
  13. package/.built/source/position.d.ts +3 -1
  14. package/.built/source/position.js +17 -5
  15. package/.built/{positioner → source/positioner}/point.d.ts +2 -3
  16. package/.built/{positioner → source/positioner}/point.js +1 -7
  17. package/.built/{positioner → source/positioner}/responder-type.d.ts +0 -1
  18. package/.built/{positioner → source/positioner}/responder-type.js +0 -3
  19. package/.built/{power-district → source/power-district}/index.d.ts +0 -1
  20. package/.built/{power-district → source/power-district}/index.js +0 -3
  21. package/.built/source/route.d.ts +0 -1
  22. package/.built/source/route.js +1 -8
  23. package/.built/source/router.d.ts +0 -4
  24. package/.built/source/router.js +1 -28
  25. package/.built/source/section.d.ts +1 -10
  26. package/.built/source/section.js +8 -57
  27. package/.built/{throttle.d.ts → source/throttle.d.ts} +1 -2
  28. package/.built/source/throttle.js +8 -0
  29. package/.built/source/tile.js +2 -7
  30. package/.built/source/track.d.ts +1 -2
  31. package/.built/source/track.js +3 -10
  32. package/index.ts +23 -0
  33. package/package.json +2 -2
  34. package/source/device/channel.ts +4 -4
  35. package/source/device/index.ts +2 -19
  36. package/source/district.ts +1 -80
  37. package/source/layout.ts +1 -63
  38. package/source/monitor.ts +1 -10
  39. package/source/positioner/point.ts +2 -11
  40. package/source/positioner/responder-type.ts +1 -5
  41. package/source/power-district/index.ts +0 -5
  42. package/source/route.ts +2 -6
  43. package/source/router.ts +2 -31
  44. package/source/section.ts +10 -65
  45. package/source/throttle.ts +1 -10
  46. package/source/track.ts +3 -7
  47. package/tsconfig.json +7 -8
  48. package/.built/device/channel.d.ts +0 -8
  49. package/.built/device/channel.js +0 -12
  50. package/.built/device/device.d.ts +0 -11
  51. package/.built/device/device.js +0 -20
  52. package/.built/device/index.js +0 -20
  53. package/.built/district.d.ts +0 -22
  54. package/.built/district.js +0 -83
  55. package/.built/layout.d.ts +0 -35
  56. package/.built/layout.js +0 -331
  57. package/.built/monitor.js +0 -15
  58. package/.built/position.d.ts +0 -12
  59. package/.built/position.js +0 -45
  60. package/.built/power-district.d.ts +0 -8
  61. package/.built/power-district.js +0 -14
  62. package/.built/route.d.ts +0 -10
  63. package/.built/route.js +0 -13
  64. package/.built/router.d.ts +0 -14
  65. package/.built/router.js +0 -36
  66. package/.built/section.d.ts +0 -40
  67. package/.built/section.js +0 -213
  68. package/.built/source/device/device.d.ts +0 -11
  69. package/.built/source/device/device.js +0 -24
  70. package/.built/source/power-district.d.ts +0 -8
  71. package/.built/source/power-district.js +0 -18
  72. package/.built/throttle.js +0 -15
  73. package/.built/tile.d.ts +0 -57
  74. package/.built/tile.js +0 -73
  75. package/.built/track.d.ts +0 -12
  76. package/.built/track.js +0 -25
  77. package/source/index.ts +0 -23
  78. /package/.built/{positioner → source/positioner}/index.d.ts +0 -0
  79. /package/.built/{positioner → source/positioner}/index.js +0 -0
  80. /package/.built/{power-district → source/power-district}/activator.d.ts +0 -0
  81. /package/.built/{power-district → source/power-district}/activator.js +0 -0
  82. /package/.built/{power-district → source/power-district}/monitor.d.ts +0 -0
  83. /package/.built/{power-district → source/power-district}/monitor.js +0 -0
  84. /package/.built/{power-district → source/power-district}/reverser.d.ts +0 -0
  85. /package/.built/{power-district → source/power-district}/reverser.js +0 -0
  86. /package/.built/{span.d.ts → source/span.d.ts} +0 -0
  87. /package/.built/{span.js → source/span.js} +0 -0
package/source/router.ts CHANGED
@@ -5,7 +5,7 @@ export class Router {
5
5
  activeRoute?: Route;
6
6
 
7
7
  routes: Route[] = [];
8
-
8
+
9
9
  constructor(
10
10
  public name: string,
11
11
  public district: District
@@ -14,33 +14,4 @@ export class Router {
14
14
  get domainName() {
15
15
  return `${this.name}.${this.district.domainName}`;
16
16
  }
17
-
18
- dump() {
19
- console.group(`Router ${this.domainName}`);
20
-
21
- for (let route of this.routes) {
22
- route.dump();
23
- }
24
-
25
- console.groupEnd();
26
- }
27
-
28
- toDotReference() {
29
- return `router_${this.name.replace(/-/g, '_')}_${this.district.toDotReference()}`;
30
- }
31
-
32
- toDotDefinition() {
33
- return `
34
- ${this.toDotReference()} [ label = ${JSON.stringify(this.name)}, shape = diamond ]
35
- `;
36
- }
37
-
38
- toDotConnection() {
39
- return `
40
- ${this.routes.map(route => `
41
- ${route.in.toDotReference()} -> ${this.toDotReference()} [ headlabel = ${JSON.stringify(route.name)} ]
42
- ${this.toDotReference()} -> ${route.out.toDotReference()} [ taillabel = ${JSON.stringify(route.name)} ]
43
- `).join('')}
44
- `;
45
- }
46
- }
17
+ }
package/source/section.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { District } from "./district";
2
2
  import { SectionPosition } from "./position";
3
- import { PowerDistrict } from "./power-district";
3
+ import { PowerDistrict } from "./power-district/index";
4
4
  import { Router } from "./router";
5
5
  import { Tile } from "./tile";
6
6
  import { Track } from "./track";
7
7
 
8
8
  export class Section {
9
9
  powerDistrict: PowerDistrict;
10
-
10
+
11
11
  tracks: Track[] = [];
12
12
  tiles: Tile[] = [];
13
-
13
+
14
14
  in?: Router | Section;
15
15
  out?: Router | Section;
16
-
16
+
17
17
  constructor(
18
18
  public name: string,
19
19
  public district: District
@@ -87,14 +87,14 @@ export class Section {
87
87
  start: 0,
88
88
  end: this.tiles[this.tiles.length - 1].pattern.length
89
89
  },
90
-
90
+
91
91
  tiles: [...this.tiles]
92
92
  };
93
93
  }
94
94
 
95
95
  let start = 0;
96
96
  let end = this.length;
97
-
97
+
98
98
  // only use the position limit if it is within our section
99
99
  if (startPosition.section == this) {
100
100
  end = startPosition.absolutePosition;
@@ -131,7 +131,7 @@ export class Section {
131
131
  if (start <= passed) {
132
132
  offset.start = (start + length - passed) * tile.pattern.length / length;
133
133
  }
134
-
134
+
135
135
  if (end >= passed) {
136
136
  offset.end = 0.5; // (start + length - passed) * tile.pattern.length / length;
137
137
  }
@@ -139,29 +139,13 @@ export class Section {
139
139
 
140
140
  passed += length;
141
141
  }
142
-
142
+
143
143
  return {
144
144
  offset,
145
145
  tiles
146
146
  };
147
147
  }
148
-
149
- dump() {
150
- console.group(`Section ${this.domainName}`);
151
-
152
- console.log('in', this.in?.name ?? 'buffer');
153
- console.log('out', this.out?.name ?? 'buffer');
154
-
155
- console.group(`tracks`);
156
-
157
- for (let track of this.tracks) {
158
- track.dump();
159
- }
160
-
161
- console.groupEnd();
162
- console.groupEnd();
163
- }
164
-
148
+
165
149
  get length() {
166
150
  return this.tracks.reduce((accumulator, track) => accumulator + track.length, 0);
167
151
  }
@@ -227,43 +211,4 @@ export class Section {
227
211
  tip: new SectionPosition(tip, reversed ? -length : tip.length + length, false)
228
212
  };
229
213
  }
230
-
231
- toDotReference() {
232
- return `section_${this.name.replace(/-/g, '_')}_${this.district.toDotReference()}`;
233
- }
234
-
235
- toDotDefinition() {
236
- return `
237
- ${this.toDotReference()} [ label = ${JSON.stringify(`${this.name}\n${this.length}`)}, shape = box ]
238
- `;
239
- }
240
-
241
- toDotConnection() {
242
- return `
243
- ${this.out instanceof Section ? `${this.toDotReference()} -> ${this.out.toDotReference()}` : ''}
244
- `;
245
- }
246
-
247
- toSVG() {
248
- return `
249
- <g id=${JSON.stringify(this.domainName).split('.').join('_')}>
250
- <style>
251
-
252
- g#${this.domainName.split('.').join('_')} path {
253
- stroke: hsl(${(this.length / this.tileLength)}deg, 100%, 50%);
254
- }
255
-
256
- </style>
257
-
258
- ${this.tiles.map(tile => tile.toSVG()).join('')}
259
- </g>
260
- `;
261
- }
262
-
263
- findSVGPositions() {
264
- return this.tiles.map(tile => ({
265
- x: tile.x,
266
- y: tile.y
267
- }));
268
- }
269
- }
214
+ }
@@ -1,4 +1,4 @@
1
- import { Device } from "./device";
1
+ import { Device } from "./device/index";
2
2
  import { District } from "./district";
3
3
  import { Layout } from "./layout";
4
4
 
@@ -7,13 +7,4 @@ export class Throttle {
7
7
  public device: Device,
8
8
  public scope: District | Layout
9
9
  ) { }
10
-
11
- dump() {
12
- console.group('Throttle');
13
- console.log('scope:', this.scope instanceof Layout ? '*' : this.scope.domainName);
14
-
15
- this.device.dump();
16
-
17
- console.groupEnd();
18
- }
19
10
  }
package/source/track.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Positioner } from "./positioner";
1
+ import { Positioner } from "./positioner/index";
2
2
  import { Section } from "./section";
3
3
  import { SectionPosition } from "./position";
4
4
 
@@ -19,12 +19,8 @@ export class Track {
19
19
  if (track == this) {
20
20
  return new SectionPosition(this.section, offset, false);
21
21
  }
22
-
22
+
23
23
  offset += track.length;
24
24
  }
25
25
  }
26
-
27
- dump() {
28
- console.log(this.length);
29
- }
30
- }
26
+ }
package/tsconfig.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "outDir": ".built",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
3
  "target": "esnext",
7
- "declaration": true
8
- },
9
- "include": [
10
- "source"
11
- ]
4
+ "module": "esnext",
5
+ "outDir": ".built",
6
+ "declaration": true,
7
+ "lib": [
8
+ "esnext"
9
+ ]
10
+ }
12
11
  }
@@ -1,8 +0,0 @@
1
- import { Device } from "./index";
2
- export declare class Channel {
3
- device: Device;
4
- name: string;
5
- constructor(device: Device, name: string);
6
- dump(): void;
7
- publish(data: any): void;
8
- }
@@ -1,12 +0,0 @@
1
- export class Channel {
2
- device;
3
- name;
4
- constructor(device, name) {
5
- this.device = device;
6
- this.name = name;
7
- }
8
- dump() {
9
- console.log(`Channel '${this.name}' on ${this.device.identifier}`);
10
- }
11
- publish(data) { }
12
- }
@@ -1,11 +0,0 @@
1
- import { Channel } from "./channel";
2
- export declare class Device {
3
- identifier: string;
4
- channels: Channel[];
5
- lastDiscovery: {
6
- date: Date;
7
- address: string;
8
- };
9
- constructor(identifier: string);
10
- dump(): void;
11
- }
@@ -1,20 +0,0 @@
1
- export class Device {
2
- identifier;
3
- channels = [];
4
- lastDiscovery;
5
- constructor(identifier) {
6
- this.identifier = identifier;
7
- }
8
- dump() {
9
- console.group(`Device ${this.identifier}`);
10
- if (this.lastDiscovery) {
11
- console.log(`last discovery: ${this.lastDiscovery.date.toISOString()} ${this.lastDiscovery.address}`);
12
- }
13
- console.group('channels');
14
- for (let channel of this.channels) {
15
- channel.dump();
16
- }
17
- console.groupEnd();
18
- console.groupEnd();
19
- }
20
- }
@@ -1,20 +0,0 @@
1
- export class Device {
2
- identifier;
3
- channels = [];
4
- lastDiscovery;
5
- constructor(identifier) {
6
- this.identifier = identifier;
7
- }
8
- dump() {
9
- console.group(`Device ${this.identifier}`);
10
- if (this.lastDiscovery) {
11
- console.log(`last discovery: ${this.lastDiscovery.date.toISOString()} ${this.lastDiscovery.address}`);
12
- }
13
- console.group('channels');
14
- for (let channel of this.channels) {
15
- channel.dump();
16
- }
17
- console.groupEnd();
18
- console.groupEnd();
19
- }
20
- }
@@ -1,22 +0,0 @@
1
- import { Layout } from "./layout";
2
- import { Monitor } from "./monitor";
3
- import { PowerDistrict } from "./power-district";
4
- import { Router } from "./router";
5
- import { Section } from "./section";
6
- export declare class District {
7
- name: string;
8
- parent: District | Layout;
9
- children: District[];
10
- powerDistricts: PowerDistrict[];
11
- sections: Section[];
12
- routers: Router[];
13
- monitors: Monitor[];
14
- constructor(name: string, parent: District | Layout);
15
- get domainName(): string;
16
- dump(): void;
17
- toDotReference(): any;
18
- toDotDefinition(): any;
19
- toDotConnection(): any;
20
- toSVG(): any;
21
- findSVGPositions(): any;
22
- }
@@ -1,83 +0,0 @@
1
- import { Layout } from "./layout";
2
- export class District {
3
- name;
4
- parent;
5
- children = [];
6
- powerDistricts = [];
7
- sections = [];
8
- routers = [];
9
- monitors = [];
10
- constructor(name, parent) {
11
- this.name = name;
12
- this.parent = parent;
13
- }
14
- get domainName() {
15
- if (this.parent instanceof Layout) {
16
- return `${this.name}.${this.parent.name}`;
17
- }
18
- return `${this.name}.${this.parent.domainName}`;
19
- }
20
- dump() {
21
- console.group(`District ${this.domainName}`);
22
- if (this.powerDistricts.length) {
23
- console.group('power districts');
24
- for (let district of this.powerDistricts) {
25
- district.dump();
26
- }
27
- console.groupEnd();
28
- }
29
- if (this.sections.length) {
30
- console.group('sections');
31
- for (let section of this.sections) {
32
- section.dump();
33
- }
34
- console.groupEnd();
35
- }
36
- if (this.children.length) {
37
- console.group('children');
38
- for (let district of this.children) {
39
- district.dump();
40
- }
41
- console.groupEnd();
42
- }
43
- console.groupEnd();
44
- }
45
- toDotReference() {
46
- return `cluster_${this.name.replace(/-/g, '_')}${this.parent instanceof District ? this.parent.toDotReference() : ''}`;
47
- }
48
- toDotDefinition() {
49
- return `
50
- subgraph ${this.toDotReference()} {
51
- label = ${JSON.stringify(this.name)}
52
-
53
- ${this.sections.map(section => section.toDotDefinition()).join('')}
54
- ${this.routers.map(router => router.toDotDefinition()).join('')}
55
-
56
- ${this.children.map(child => child.toDotDefinition()).join('')}
57
- }
58
- `;
59
- }
60
- toDotConnection() {
61
- return `
62
- ${this.sections.map(section => section.toDotConnection()).join('')}
63
- ${this.routers.map(router => router.toDotConnection()).join('')}
64
-
65
- ${this.children.map(child => child.toDotConnection()).join('')}
66
- `;
67
- }
68
- toSVG() {
69
- return `
70
- <g id=${JSON.stringify(this.domainName)}>
71
- ${this.sections.map(section => section.toSVG()).join('')}
72
-
73
- ${this.children.map(child => child.toSVG()).join('')}
74
- </g>
75
- `;
76
- }
77
- findSVGPositions() {
78
- return [
79
- ...this.sections.map(section => section.findSVGPositions()),
80
- ...this.children.map(child => child.findSVGPositions())
81
- ];
82
- }
83
- }
@@ -1,35 +0,0 @@
1
- import { District } from "./district";
2
- import { PowerDistrict } from "./power-district";
3
- import { Router } from "./router";
4
- import { Section } from "./section";
5
- import { Device } from "./device/index";
6
- import { ResponderType } from "./positioner/responder-type";
7
- import { Channel } from "./device/channel";
8
- import { Monitor } from "./monitor";
9
- import { Throttle } from "./throttle";
10
- export declare class Layout {
11
- name: string;
12
- districts: District[];
13
- devices: Device[];
14
- responderType: ResponderType[];
15
- monitors: Monitor[];
16
- throttles: Throttle[];
17
- get allDistricts(): District[];
18
- static from(document: any): Layout;
19
- loadMonitor(source: any, parent: District | Layout): Monitor;
20
- loadThrottle(source: any, parent: District | Layout): Throttle;
21
- loadDistrict(source: any, parent: District | Layout): District;
22
- linkDistrict(source: any, district: District): void;
23
- loadSection(source: any, district: District): void;
24
- findDevice(identifier: string): Device;
25
- findChannel(device: Device, name: string): Channel;
26
- findResponderType(name: string): ResponderType;
27
- linkSection(source: any, section: Section): void;
28
- findSection(path: string, base: District, source?: District): any;
29
- loadRouter(source: any, district: District): Router;
30
- linkRouter(source: any, router: Router): void;
31
- loadPowerDistrict(source: any, district: District): PowerDistrict;
32
- toDot(): string;
33
- toSVG(inject?: string): string;
34
- dump(): void;
35
- }