@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/.built/section.js DELETED
@@ -1,213 +0,0 @@
1
- import { SectionPosition } from "./position";
2
- import { Router } from "./router";
3
- export class Section {
4
- name;
5
- district;
6
- powerDistrict;
7
- tracks = [];
8
- tiles = [];
9
- in;
10
- out;
11
- constructor(name, district) {
12
- this.name = name;
13
- this.district = district;
14
- }
15
- get domainName() {
16
- return `${this.name}.${this.district.domainName}`;
17
- }
18
- // returns the next currently set section
19
- next(reverse) {
20
- if (reverse) {
21
- if (!this.in) {
22
- return null;
23
- }
24
- if (this.in instanceof Section) {
25
- return this.in;
26
- }
27
- if (this.in instanceof Router) {
28
- const activeRoute = this.in.activeRoute;
29
- if (!activeRoute) {
30
- throw new Error(`Router '${this.in.domainName}' has no active route`);
31
- }
32
- if (activeRoute.in == this) {
33
- return activeRoute.out;
34
- }
35
- if (activeRoute.out == this) {
36
- return activeRoute.in;
37
- }
38
- throw new Error(`Router '${this.in.domainName}' is not routing from '${this.domainName}'`);
39
- }
40
- }
41
- else {
42
- if (!this.out) {
43
- return null;
44
- }
45
- if (this.out instanceof Section) {
46
- return this.out;
47
- }
48
- if (this.out instanceof Router) {
49
- const activeRoute = this.out.activeRoute;
50
- if (!activeRoute) {
51
- throw new Error(`Router '${this.out.domainName}' has no active route`);
52
- }
53
- if (activeRoute.in == this) {
54
- return activeRoute.out;
55
- }
56
- if (activeRoute.out == this) {
57
- return activeRoute.in;
58
- }
59
- throw new Error(`Router '${this.in?.domainName}' is not routing from '${this.domainName}'`);
60
- }
61
- }
62
- }
63
- getTilesInRange(startPosition, endPosition) {
64
- if (startPosition.section != this && endPosition.section != this) {
65
- return {
66
- offset: {
67
- start: 0,
68
- end: this.tiles[this.tiles.length - 1].pattern.length
69
- },
70
- tiles: [...this.tiles]
71
- };
72
- }
73
- let start = 0;
74
- let end = this.length;
75
- // only use the position limit if it is within our section
76
- if (startPosition.section == this) {
77
- end = startPosition.absolutePosition;
78
- }
79
- if (endPosition.section == this) {
80
- start = endPosition.absolutePosition;
81
- }
82
- // flip if the range was reversed
83
- if (end < start) {
84
- const small = end;
85
- end = start;
86
- start = small;
87
- }
88
- let passed = 0;
89
- const tiles = [];
90
- const tileUnitLength = this.length / this.tileLength;
91
- const offset = {
92
- start: 0,
93
- end: 0
94
- };
95
- for (let tile of this.tiles) {
96
- const length = tile.pattern.length * tileUnitLength;
97
- if (start - length <= passed && end + length >= passed) {
98
- tiles.push(tile);
99
- if (start <= passed) {
100
- offset.start = (start + length - passed) * tile.pattern.length / length;
101
- }
102
- if (end >= passed) {
103
- offset.end = 0.5; // (start + length - passed) * tile.pattern.length / length;
104
- }
105
- }
106
- passed += length;
107
- }
108
- return {
109
- offset,
110
- tiles
111
- };
112
- }
113
- dump() {
114
- console.group(`Section ${this.domainName}`);
115
- console.log('in', this.in?.name ?? 'buffer');
116
- console.log('out', this.out?.name ?? 'buffer');
117
- console.group(`tracks`);
118
- for (let track of this.tracks) {
119
- track.dump();
120
- }
121
- console.groupEnd();
122
- console.groupEnd();
123
- }
124
- get length() {
125
- return this.tracks.reduce((accumulator, track) => accumulator + track.length, 0);
126
- }
127
- get tileLength() {
128
- return this.tiles.reduce((accumulator, tile) => accumulator + tile.pattern.length, 0);
129
- }
130
- // follow the active path ahead (reverse = true = back)
131
- // uses the currently set routes
132
- // returns all touched sections
133
- trail(offset, reversed, length) {
134
- let tip = this;
135
- const sections = [this];
136
- if (reversed) {
137
- length -= offset;
138
- }
139
- else {
140
- length -= this.length - offset;
141
- }
142
- while (length > 0) {
143
- let next;
144
- if (reversed) {
145
- next = tip.in;
146
- }
147
- else {
148
- next = tip.out;
149
- }
150
- if (!next) {
151
- return {
152
- sections,
153
- tip: new SectionPosition(tip, tip.length, false)
154
- };
155
- }
156
- if (next instanceof Section) {
157
- tip = next;
158
- }
159
- if (next instanceof Router) {
160
- if (!next.activeRoute) {
161
- throw new Error(`Router '${next.domainName}' has no active route (routes: ${next.routes.map(route => `'${route.name}'`).join(', ')})`);
162
- }
163
- // TODO: handle flipped cases
164
- if (reversed) {
165
- tip = next.activeRoute.in;
166
- }
167
- else {
168
- tip = next.activeRoute.out;
169
- }
170
- }
171
- sections.push(tip);
172
- length -= tip.length;
173
- }
174
- return {
175
- sections,
176
- tip: new SectionPosition(tip, reversed ? -length : tip.length + length, false)
177
- };
178
- }
179
- toDotReference() {
180
- return `section_${this.name.replace(/-/g, '_')}_${this.district.toDotReference()}`;
181
- }
182
- toDotDefinition() {
183
- return `
184
- ${this.toDotReference()} [ label = ${JSON.stringify(`${this.name}\n${this.length}`)}, shape = box ]
185
- `;
186
- }
187
- toDotConnection() {
188
- return `
189
- ${this.out instanceof Section ? `${this.toDotReference()} -> ${this.out.toDotReference()}` : ''}
190
- `;
191
- }
192
- toSVG() {
193
- return `
194
- <g id=${JSON.stringify(this.domainName).split('.').join('_')}>
195
- <style>
196
-
197
- g#${this.domainName.split('.').join('_')} path {
198
- stroke: hsl(${(this.length / this.tileLength)}deg, 100%, 50%);
199
- }
200
-
201
- </style>
202
-
203
- ${this.tiles.map(tile => tile.toSVG()).join('')}
204
- </g>
205
- `;
206
- }
207
- findSVGPositions() {
208
- return this.tiles.map(tile => ({
209
- x: tile.x,
210
- y: tile.y
211
- }));
212
- }
213
- }
@@ -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,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Device = void 0;
4
- class Device {
5
- identifier;
6
- channels = [];
7
- lastDiscovery;
8
- constructor(identifier) {
9
- this.identifier = identifier;
10
- }
11
- dump() {
12
- console.group(`Device ${this.identifier}`);
13
- if (this.lastDiscovery) {
14
- console.log(`last discovery: ${this.lastDiscovery.date.toISOString()} ${this.lastDiscovery.address}`);
15
- }
16
- console.group('channels');
17
- for (let channel of this.channels) {
18
- channel.dump();
19
- }
20
- console.groupEnd();
21
- console.groupEnd();
22
- }
23
- }
24
- exports.Device = Device;
@@ -1,8 +0,0 @@
1
- import { District } from "./district";
2
- export declare class PowerDistrict {
3
- name: string;
4
- district: District;
5
- constructor(name: string, district: District);
6
- get domainName(): string;
7
- dump(): void;
8
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PowerDistrict = void 0;
4
- class PowerDistrict {
5
- name;
6
- district;
7
- constructor(name, district) {
8
- this.name = name;
9
- this.district = district;
10
- }
11
- get domainName() {
12
- return `${this.name}.${this.district.domainName}`;
13
- }
14
- dump() {
15
- console.log(this.name);
16
- }
17
- }
18
- exports.PowerDistrict = PowerDistrict;
@@ -1,15 +0,0 @@
1
- import { Layout } from "./layout";
2
- export class Throttle {
3
- device;
4
- scope;
5
- constructor(device, scope) {
6
- this.device = device;
7
- this.scope = scope;
8
- }
9
- dump() {
10
- console.group('Throttle');
11
- console.log('scope:', this.scope instanceof Layout ? '*' : this.scope.domainName);
12
- this.device.dump();
13
- console.groupEnd();
14
- }
15
- }
package/.built/tile.d.ts DELETED
@@ -1,57 +0,0 @@
1
- import { Section } from './section.js';
2
- export declare class TilePattern {
3
- length: number;
4
- path: (continuous: boolean, x: number, y: number) => string;
5
- static patterns: {
6
- 'tl-cc': TilePattern;
7
- 'tc-cc': TilePattern;
8
- 'tr-cc': TilePattern;
9
- 'cl-cc': TilePattern;
10
- 'cr-cc': TilePattern;
11
- 'bl-cc': TilePattern;
12
- 'bc-cc': TilePattern;
13
- 'br-cc': TilePattern;
14
- 'cc-tl': TilePattern;
15
- 'cc-tc': TilePattern;
16
- 'cc-tr': TilePattern;
17
- 'cc-cl': TilePattern;
18
- 'cc-cr': TilePattern;
19
- 'cc-bl': TilePattern;
20
- 'cc-bc': TilePattern;
21
- 'cc-br': TilePattern;
22
- 'cr-cl': TilePattern;
23
- 'cr-tl': TilePattern;
24
- 'cr-bl': TilePattern;
25
- 'cl-cr': TilePattern;
26
- 'cl-tr': TilePattern;
27
- 'cl-bl': TilePattern;
28
- 'tl-bc': TilePattern;
29
- 'tl-br': TilePattern;
30
- 'tl-cr': TilePattern;
31
- 'tc-bc': TilePattern;
32
- 'tc-br': TilePattern;
33
- 'tc-bl': TilePattern;
34
- 'tr-cl': TilePattern;
35
- 'tr-bc': TilePattern;
36
- 'bl-tr': TilePattern;
37
- 'bl-tc': TilePattern;
38
- 'bl-cr': TilePattern;
39
- 'bc-tc': TilePattern;
40
- 'bc-tr': TilePattern;
41
- 'bc-tl': TilePattern;
42
- 'br-cl': TilePattern;
43
- 'br-tc': TilePattern;
44
- 'br-tl': TilePattern;
45
- 'cl-bc': TilePattern;
46
- };
47
- constructor(length: number, path: (continuous: boolean, x: number, y: number) => string);
48
- }
49
- export declare class Tile {
50
- section: Section;
51
- x: number;
52
- y: number;
53
- pattern: TilePattern;
54
- constructor(section: Section, x: number, y: number, pattern: TilePattern);
55
- toSVGPath(continuous?: boolean): string;
56
- toSVG(): string;
57
- }
package/.built/tile.js DELETED
@@ -1,73 +0,0 @@
1
- export class TilePattern {
2
- length;
3
- path;
4
- // TODO: replace simple paths with rounded versions
5
- static patterns = {
6
- 'tl-cc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0}, L ${x + 0.5} ${y + 0.5}`),
7
- 'tc-cc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 0.5}`),
8
- 'tr-cc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0}, L ${x + 0.5} ${y + 0.5}`),
9
- 'cl-cc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}`),
10
- 'cr-cc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}`),
11
- 'bl-cc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 1}, L ${x + 0.5} ${y + 0.5}`),
12
- 'bc-cc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 1}, L ${x + 0.5} ${y + 0.5}`),
13
- 'br-cc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 1}, L ${x + 0.5} ${y + 0.5}`),
14
- 'cc-tl': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0}`),
15
- 'cc-tc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 0}`),
16
- 'cc-tr': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0}`),
17
- 'cc-cl': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
18
- 'cc-cr': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
19
- 'cc-bl': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 1}`),
20
- 'cc-bc': new TilePattern(0.5, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 1}`),
21
- 'cc-br': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 1}`),
22
- 'cr-cl': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
23
- 'cr-tl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0}`),
24
- 'cr-bl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 1}`),
25
- 'cl-cr': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
26
- 'cl-tr': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0}`),
27
- 'cl-bl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 1}`),
28
- 'tl-bc': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 1}`),
29
- 'tl-br': new TilePattern(1.4, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 1}`),
30
- 'tl-cr': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
31
- 'tc-bc': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 1}`),
32
- 'tc-br': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 1}`),
33
- 'tc-bl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 1}`),
34
- 'tr-cl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
35
- 'tr-bc': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 1}`),
36
- 'bl-tr': new TilePattern(1.4, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0}`),
37
- 'bl-tc': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 0}`),
38
- 'bl-cr': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
39
- 'bc-tc': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 0}`),
40
- 'bc-tr': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 1} ${y + 0}`),
41
- 'bc-tl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0}`),
42
- 'br-cl': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
43
- 'br-tc': new TilePattern(1.2, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0.5} ${y + 0}`),
44
- 'br-tl': new TilePattern(1.4, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 1}, L ${x + 0.5} ${y + 0.5}, L ${x + 0} ${y + 0}`),
45
- // oddities
46
- 'cl-bc': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 0.5} ${y + 1}`)
47
- };
48
- constructor(length, path) {
49
- this.length = length;
50
- this.path = path;
51
- }
52
- }
53
- export class Tile {
54
- section;
55
- x;
56
- y;
57
- pattern;
58
- constructor(section, x, y, pattern) {
59
- this.section = section;
60
- this.x = x;
61
- this.y = y;
62
- this.pattern = pattern;
63
- }
64
- toSVGPath(continuous = false) {
65
- return this.pattern.path(continuous, this.x, this.y);
66
- }
67
- toSVG() {
68
- return `
69
- <path d="${this.toSVGPath()}" />
70
- ${this.section.tiles[0] == this ? `<text x="${this.x}" y="${this.y}" font-size="0.2">${this.section.name}</text>` : ''}
71
- `;
72
- }
73
- }
package/.built/track.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { Positioner } from "./positioner";
2
- import { Section } from "./section";
3
- import { SectionPosition } from "./position";
4
- export declare class Track {
5
- section: Section;
6
- length: number;
7
- path: string;
8
- positioners: Positioner[];
9
- constructor(section: Section, length: number, path: string);
10
- get head(): SectionPosition;
11
- dump(): void;
12
- }
package/.built/track.js DELETED
@@ -1,25 +0,0 @@
1
- import { SectionPosition } from "./position";
2
- export class Track {
3
- section;
4
- length;
5
- path;
6
- positioners = [];
7
- constructor(section, length, path) {
8
- this.section = section;
9
- this.length = length;
10
- this.path = path;
11
- }
12
- // the start of the track within the section
13
- get head() {
14
- let offset = 0;
15
- for (let track of this.section.tracks) {
16
- if (track == this) {
17
- return new SectionPosition(this.section, offset, false);
18
- }
19
- offset += track.length;
20
- }
21
- }
22
- dump() {
23
- console.log(this.length);
24
- }
25
- }
package/source/index.ts DELETED
@@ -1,23 +0,0 @@
1
- export * from './district';
2
- export * from './layout';
3
- export * from './position';
4
- export * from './route';
5
- export * from './router';
6
- export * from './section';
7
- export * from './span';
8
- export * from './tile';
9
- export * from './track';
10
- export * from './monitor';
11
- export * from './throttle';
12
-
13
- export * from './power-district/index';
14
- export * from './power-district/activator';
15
- export * from './power-district/monitor';
16
- export * from './power-district/reverser';
17
-
18
- export * from './positioner/index';
19
- export * from './positioner/point';
20
- export * from './positioner/responder-type';
21
-
22
- export * from './device/index';
23
- export * from './device/channel';
File without changes
File without changes