@packtrack/layout 1.0.13 → 1.2.0

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 (41) hide show
  1. package/.built/device/channel.d.ts +1 -1
  2. package/.built/device/index.d.ts +11 -0
  3. package/.built/device/index.js +20 -0
  4. package/.built/district.d.ts +2 -0
  5. package/.built/district.js +4 -3
  6. package/.built/index.d.ts +8 -2
  7. package/.built/index.js +8 -2
  8. package/.built/layout.d.ts +7 -1
  9. package/.built/layout.js +61 -12
  10. package/.built/monitor.d.ts +9 -0
  11. package/.built/monitor.js +15 -0
  12. package/.built/position.d.ts +3 -1
  13. package/.built/position.js +16 -0
  14. package/.built/positioner/point.d.ts +1 -1
  15. package/.built/power-district/activator.d.ts +7 -0
  16. package/.built/power-district/activator.js +8 -0
  17. package/.built/power-district/index.d.ts +14 -0
  18. package/.built/power-district/index.js +17 -0
  19. package/.built/power-district/monitor.d.ts +7 -0
  20. package/.built/power-district/monitor.js +8 -0
  21. package/.built/power-district/reverser.d.ts +7 -0
  22. package/.built/power-district/reverser.js +8 -0
  23. package/.built/span.d.ts +12 -0
  24. package/.built/span.js +77 -0
  25. package/.built/throttle.d.ts +9 -0
  26. package/.built/throttle.js +15 -0
  27. package/package.json +1 -1
  28. package/source/device/channel.ts +2 -2
  29. package/source/district.ts +21 -18
  30. package/source/index.ts +9 -2
  31. package/source/layout.ts +148 -82
  32. package/source/monitor.ts +19 -0
  33. package/source/position.ts +52 -32
  34. package/source/power-district/activator.ts +9 -0
  35. package/source/power-district/index.ts +24 -0
  36. package/source/power-district/monitor.ts +9 -0
  37. package/source/power-district/reverser.ts +9 -0
  38. package/source/span.ts +88 -0
  39. package/source/throttle.ts +19 -0
  40. package/source/power-district.ts +0 -16
  41. /package/source/device/{device.ts → index.ts} +0 -0
@@ -0,0 +1,24 @@
1
+ import { PowerDistrictActivator } from "./activator";
2
+ import { Device } from "../device/index";
3
+ import { District } from "../district";
4
+ import { PowerDistrictMonitor } from "./monitor";
5
+ import { PowerDistrictReverser } from "./reverser";
6
+
7
+ export class PowerDistrict {
8
+ activator?: PowerDistrictActivator;
9
+ reverser?: PowerDistrictReverser;
10
+ monitor?: PowerDistrictMonitor;
11
+
12
+ constructor(
13
+ public name: string,
14
+ public district: District
15
+ ) {}
16
+
17
+ get domainName() {
18
+ return `${this.name}.${this.district.domainName}`;
19
+ }
20
+
21
+ dump() {
22
+ console.log(this.name);
23
+ }
24
+ }
@@ -0,0 +1,9 @@
1
+ import { Channel } from "../device/channel";
2
+ import { Device } from "../device/index";
3
+
4
+ export class PowerDistrictMonitor {
5
+ constructor(
6
+ public device: Device,
7
+ public channel: Channel
8
+ ) {}
9
+ }
@@ -0,0 +1,9 @@
1
+ import { Channel } from "../device/channel";
2
+ import { Device } from "../device/index";
3
+
4
+ export class PowerDistrictReverser {
5
+ constructor(
6
+ public device: Device,
7
+ public channel: Channel
8
+ ) {}
9
+ }
package/source/span.ts ADDED
@@ -0,0 +1,88 @@
1
+ import { SectionPosition } from "./position";
2
+ import { Section } from "./section";
3
+
4
+ export class Span {
5
+ constructor(
6
+ public head: SectionPosition,
7
+ public inside: Section[],
8
+ public tail: SectionPosition
9
+ ) { }
10
+
11
+ // TODO verify reverse
12
+ contains(position: SectionPosition) {
13
+ if (this.inside.includes(position.section)) {
14
+ return true;
15
+ }
16
+
17
+ if (position.section == this.head.section) {
18
+ if (this.head.reversed) {
19
+ if (this.head.absolutePosition > position.absolutePosition) {
20
+ return true;
21
+ }
22
+ } else {
23
+ if (this.head.offset < position.absolutePosition) {
24
+ return true;
25
+ }
26
+ }
27
+ }
28
+
29
+ if (position.section == this.tail.section) {
30
+ if (this.tail.reversed) {
31
+ if (this.tail.absolutePosition < position.absolutePosition) {
32
+ return true;
33
+ }
34
+ } else {
35
+ if (this.tail.offset > position.absolutePosition) {
36
+ return true;
37
+ }
38
+ }
39
+ }
40
+
41
+ return false;
42
+ }
43
+
44
+ overlap(peer: Span) {
45
+ return this.contains(peer.head) || this.contains(peer.tail);
46
+ }
47
+
48
+ get length() {
49
+ let length = 0;
50
+
51
+ if (this.head.reversed) {
52
+ length += this.head.section.length - this.head.offset;
53
+ } else {
54
+ length += this.head.offset;
55
+ }
56
+
57
+ for (let section of this.inside) {
58
+ length += section.length;
59
+ }
60
+
61
+ if (this.tail.reversed) {
62
+ length += this.tail.section.length - this.tail.offset;
63
+ } else {
64
+ length += this.tail.offset;
65
+ }
66
+
67
+ return length;
68
+ }
69
+
70
+ // TODO verify reverse
71
+ // TODO add efficient algo
72
+ static trail(start: SectionPosition, end: SectionPosition) {
73
+ let head = start;
74
+
75
+ const sections = [];
76
+ const increment = 1;
77
+
78
+ while (head.section != end.section) {
79
+ head = head.advance(increment);
80
+
81
+ if (head.section != start.section && head.section != end.section && !sections.includes(head.section)) {
82
+ sections.push(head.section);
83
+ }
84
+ }
85
+
86
+ return new Span(start, sections, end);
87
+ }
88
+ }
@@ -0,0 +1,19 @@
1
+ import { Device } from "./device";
2
+ import { District } from "./district";
3
+ import { Layout } from "./layout";
4
+
5
+ export class Throttle {
6
+ constructor(
7
+ public device: Device,
8
+ public scope: District | Layout
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
+ }
@@ -1,16 +0,0 @@
1
- import { District } from "./district";
2
-
3
- export class PowerDistrict {
4
- constructor(
5
- public name: string,
6
- public district: District
7
- ) {}
8
-
9
- get domainName() {
10
- return `${this.name}.${this.district.domainName}`;
11
- }
12
-
13
- dump() {
14
- console.log(this.name);
15
- }
16
- }
File without changes