@packtrack/layout 1.3.3 → 1.5.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.
@@ -241,7 +241,6 @@ export class Layout {
241
241
  }
242
242
  linkRouter(source, router) {
243
243
  let child = source.firstChild;
244
- let active;
245
244
  while (child) {
246
245
  if (child.tagName == 'route') {
247
246
  const route = new Route(child.getAttribute('name'), router);
@@ -249,17 +248,18 @@ export class Layout {
249
248
  route.in.out = router;
250
249
  route.out = this.findSection(child.getAttribute('out'), router.district);
251
250
  route.out.in = router;
252
- if (child.hasAttribute('active')) {
253
- if (active) {
254
- throw new Error(`Router '${router.domainName}' has multiple active routes (${active.name}, ${route.name}).`);
255
- }
256
- active = route;
257
- }
258
251
  router.routes.push(route);
259
252
  }
260
253
  child = child.nextSibling;
261
254
  }
262
- router.activeRoute = active;
255
+ const active = source.getAttribute('active');
256
+ if (active) {
257
+ const route = router.routes.find(route => route.name == active);
258
+ if (!route) {
259
+ throw new Error(`Router '${router.domainName}' cannot have active route '${active}': Router has no such route (available: ${router.routes.map(route => route.name).join(', ')})`);
260
+ }
261
+ router.activeRoute = route;
262
+ }
263
263
  }
264
264
  loadPowerDistrict(source, district) {
265
265
  const powerDistrict = new PowerDistrict(source.getAttribute('name'), district);
@@ -31,6 +31,7 @@ export declare class TilePattern {
31
31
  'tc-bc': TilePattern;
32
32
  'tc-br': TilePattern;
33
33
  'tc-bl': TilePattern;
34
+ 'tc-cr': TilePattern;
34
35
  'tr-cl': TilePattern;
35
36
  'tr-bc': TilePattern;
36
37
  'bl-tr': TilePattern;
@@ -31,6 +31,7 @@ export class TilePattern {
31
31
  'tc-bc': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 1}`),
32
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
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
+ 'tc-cr': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 1} ${y + 0.5}`),
34
35
  '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
36
  '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
37
  '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}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@packtrack/layout",
3
- "version": "1.3.3",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "main": ".built/index.js",
6
6
  "typings": ".built/index.d.ts",
package/source/layout.ts CHANGED
@@ -343,7 +343,6 @@ export class Layout {
343
343
 
344
344
  linkRouter(source, router: Router) {
345
345
  let child = source.firstChild;
346
- let active: Route;
347
346
 
348
347
  while (child) {
349
348
  if (child.tagName == 'route') {
@@ -355,21 +354,23 @@ export class Layout {
355
354
  route.out = this.findSection(child.getAttribute('out'), router.district);
356
355
  route.out.in = router;
357
356
 
358
- if (child.hasAttribute('active')) {
359
- if (active) {
360
- throw new Error(`Router '${router.domainName}' has multiple active routes (${active.name}, ${route.name}).`);
361
- }
362
-
363
- active = route;
364
- }
365
-
366
357
  router.routes.push(route);
367
358
  }
368
359
 
369
360
  child = child.nextSibling;
370
361
  }
371
362
 
372
- router.activeRoute = active;
363
+ const active = source.getAttribute('active');
364
+
365
+ if (active) {
366
+ const route = router.routes.find(route => route.name == active);
367
+
368
+ if (!route) {
369
+ throw new Error(`Router '${router.domainName}' cannot have active route '${active}': Router has no such route (available: ${router.routes.map(route => route.name).join(', ')})`);
370
+ }
371
+
372
+ router.activeRoute = route;
373
+ }
373
374
  }
374
375
 
375
376
  loadPowerDistrict(source, district: District) {
package/source/tile.ts CHANGED
@@ -24,11 +24,11 @@ export class TilePattern {
24
24
  'cr-cl': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 1} ${y + 0.5}, L ${x + 0} ${y + 0.5}`),
25
25
  '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}`),
26
26
  '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}`),
27
-
27
+
28
28
  'cl-cr': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0} ${y + 0.5}, L ${x + 1} ${y + 0.5}`),
29
29
  '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}`),
30
30
  '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}`),
31
-
31
+
32
32
  '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}`),
33
33
  '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}`),
34
34
  '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}`),
@@ -36,10 +36,11 @@ export class TilePattern {
36
36
  'tc-bc': new TilePattern(1, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 0.5} ${y + 1}`),
37
37
  '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}`),
38
38
  '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}`),
39
+ 'tc-cr': new TilePattern(0.7, (continuous, x, y) => `${continuous ? 'L' : 'M'} ${x + 0.5} ${y + 0}, L ${x + 1} ${y + 0.5}`),
39
40
 
40
41
  '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}`),
41
42
  '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}`),
42
-
43
+
43
44
  '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}`),
44
45
  '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}`),
45
46
  '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}`),
@@ -50,7 +51,7 @@ export class TilePattern {
50
51
 
51
52
  '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}`),
52
53
  '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}`),
53
-
54
+
54
55
  '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}`),
55
56
 
56
57
  // oddities
@@ -83,4 +84,4 @@ export class Tile {
83
84
  ${this.section.tiles[0] == this ? `<text x="${this.x}" y="${this.y}" font-size="0.2">${this.section.name}</text>` : ''}
84
85
  `;
85
86
  }
86
- }
87
+ }