@remvst/game-navigation-core 1.5.0 → 1.5.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 (49) hide show
  1. package/lib/game/game-params.js +0 -1
  2. package/lib/game/game-plugin.d.ts +1 -1
  3. package/lib/game/game-plugin.js +4 -8
  4. package/lib/game/game.d.ts +5 -5
  5. package/lib/game/game.js +8 -9
  6. package/lib/index.d.ts +20 -19
  7. package/lib/index.js +4 -3
  8. package/lib/interaction/inputs.d.ts +6 -6
  9. package/lib/interaction/inputs.js +3 -4
  10. package/lib/navigation/resolver.d.ts +1 -1
  11. package/lib/navigation/screen-stack.d.ts +4 -4
  12. package/lib/navigation/screen-stack.js +1 -2
  13. package/lib/plugins/automation-game-plugin.js +7 -6
  14. package/lib/plugins/blur-pausing-game-plugin.js +3 -3
  15. package/lib/plugins/fullscreen-button-game-plugin.js +6 -6
  16. package/lib/plugins/storage-game-plugin.js +1 -1
  17. package/lib/plugins/time-keys-game-plugin.js +1 -1
  18. package/lib/plugins/version-label-game-plugin.d.ts +2 -0
  19. package/lib/plugins/version-label-game-plugin.js +28 -17
  20. package/lib/storage/get-client-storage.js +3 -3
  21. package/lib/storage/in-memory-storage.js +1 -1
  22. package/lib/storage/local-json-store.js +0 -1
  23. package/lib/ui/screen.d.ts +4 -4
  24. package/lib/ui/screen.js +3 -3
  25. package/lib/util/math.js +0 -1
  26. package/lib/util/navigation-flow.d.ts +1 -0
  27. package/lib/util/navigation-flow.js +12 -0
  28. package/package.json +1 -1
  29. package/src/game/game-params.ts +1 -1
  30. package/src/game/game-plugin.ts +5 -14
  31. package/src/game/game.ts +23 -17
  32. package/src/index.ts +20 -19
  33. package/src/interaction/inputs.ts +43 -23
  34. package/src/interaction/screen-mouse-inputs.ts +7 -3
  35. package/src/navigation/resolver.ts +3 -6
  36. package/src/navigation/screen-stack.ts +15 -12
  37. package/src/plugins/automation-game-plugin.ts +8 -8
  38. package/src/plugins/blur-pausing-game-plugin.ts +3 -4
  39. package/src/plugins/fullscreen-button-game-plugin.ts +11 -7
  40. package/src/plugins/storage-game-plugin.ts +1 -1
  41. package/src/plugins/time-keys-game-plugin.ts +7 -6
  42. package/src/plugins/version-label-game-plugin.ts +30 -18
  43. package/src/storage/get-client-storage.ts +4 -4
  44. package/src/storage/in-memory-storage.ts +1 -3
  45. package/src/storage/local-json-store.ts +10 -12
  46. package/src/ui/screen-delegate.ts +1 -1
  47. package/src/ui/screen.ts +29 -14
  48. package/src/util/math.ts +1 -1
  49. package/src/util/navigation-flow.ts +8 -0
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
@@ -1,5 +1,5 @@
1
+ import { Screen } from "../ui/screen";
1
2
  import { Game } from "./game";
2
- import { Screen } from '../ui/screen';
3
3
  export declare abstract class GamePlugin {
4
4
  abstract get key(): string;
5
5
  protected game: Game;
@@ -8,13 +8,9 @@ class GamePlugin {
8
8
  bind(game) {
9
9
  this.game = game;
10
10
  }
11
- setup() {
12
- }
13
- setupScreen(screen) {
14
- }
15
- cycle(elapsed) {
16
- }
17
- render() {
18
- }
11
+ setup() { }
12
+ setupScreen(screen) { }
13
+ cycle(elapsed) { }
14
+ render() { }
19
15
  }
20
16
  exports.GamePlugin = GamePlugin;
@@ -1,8 +1,8 @@
1
- import { GameInputs } from '../interaction/inputs';
2
- import { GameParams } from './game-params';
3
- import { GamePlugin } from './game-plugin';
4
- import { ScreenStack } from '../navigation/screen-stack';
5
- import { PerformanceRecorder } from '@remvst/client-performance';
1
+ import { PerformanceRecorder } from "@remvst/client-performance";
2
+ import { GameInputs } from "../interaction/inputs";
3
+ import { ScreenStack } from "../navigation/screen-stack";
4
+ import { GameParams } from "./game-params";
5
+ import { GamePlugin } from "./game-plugin";
6
6
  export declare abstract class Game<ParamsType extends GameParams = GameParams> {
7
7
  readonly params: ParamsType;
8
8
  private readonly pluginMap;
package/lib/game/game.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Game = void 0;
4
+ const client_performance_1 = require("@remvst/client-performance");
4
5
  const inputs_1 = require("../interaction/inputs");
5
6
  const screen_stack_1 = require("../navigation/screen-stack");
6
- const client_performance_1 = require("@remvst/client-performance");
7
7
  class Game {
8
8
  constructor(params) {
9
9
  this.params = params;
@@ -13,7 +13,7 @@ class Game {
13
13
  this.runningLoop = false;
14
14
  // Performance
15
15
  this.performanceRecorder = new client_performance_1.PerformanceRecorder({
16
- 'recordCount': Math.floor(window.innerWidth / 3),
16
+ recordCount: Math.floor(window.innerWidth / 3),
17
17
  });
18
18
  this.parseURL();
19
19
  }
@@ -55,18 +55,18 @@ class Game {
55
55
  }
56
56
  frame() {
57
57
  this.performanceRecorder.roll();
58
- this.performanceRecorder.onStart('FRAME');
58
+ this.performanceRecorder.onStart("FRAME");
59
59
  const now = window.performance.now();
60
60
  const elapsedMs = now - this.lastFrame;
61
61
  const elapsed = Math.min(this.params.maxFrameInterval || 1, elapsedMs / 1000);
62
62
  this.lastFrame = now;
63
63
  this.cycle(elapsed);
64
- this.performanceRecorder.onStart('RENDER');
64
+ this.performanceRecorder.onStart("RENDER");
65
65
  for (const plugin of this.plugins) {
66
66
  plugin.render();
67
67
  }
68
- this.performanceRecorder.onEnd('RENDER');
69
- this.performanceRecorder.onEnd('FRAME');
68
+ this.performanceRecorder.onEnd("RENDER");
69
+ this.performanceRecorder.onEnd("FRAME");
70
70
  if (this.runningLoop) {
71
71
  this.scheduleFrame();
72
72
  }
@@ -99,10 +99,10 @@ class Game {
99
99
  this.screenStack.current()?.addDebugValues(out);
100
100
  }
101
101
  parseURL() {
102
- const params = new URLSearchParams((document.location.search || '?').substr(1));
102
+ const params = new URLSearchParams((document.location.search || "?").substr(1));
103
103
  for (const [param, originalValue] of params.entries()) {
104
104
  let value = originalValue;
105
- if (value === 'true' || value === 'false') {
105
+ if (value === "true" || value === "false") {
106
106
  value = JSON.parse(value);
107
107
  }
108
108
  else if (!Number.isNaN(value)) {
@@ -117,4 +117,3 @@ class Game {
117
117
  }
118
118
  }
119
119
  exports.Game = Game;
120
- ;
package/lib/index.d.ts CHANGED
@@ -1,19 +1,20 @@
1
- export * from './game/game-params';
2
- export * from './game/game-plugin';
3
- export * from './game/game';
4
- export * from './interaction/inputs';
5
- export * from './interaction/screen-mouse-inputs';
6
- export * from './navigation/resolver';
7
- export * from './navigation/screen-stack';
8
- export * from './ui/screen-delegate';
9
- export * from './ui/screen';
10
- export * from './plugins/automation-game-plugin';
11
- export * from './plugins/blur-pausing-game-plugin';
12
- export * from './plugins/fullscreen-button-game-plugin';
13
- export * from './plugins/time-keys-game-plugin';
14
- export * from './plugins/version-label-game-plugin';
15
- export * from './plugins/storage-game-plugin';
16
- export * from './storage/get-client-storage';
17
- export * from './storage/in-memory-storage';
18
- export * from './storage/local-json-store';
19
- export * from './util/math';
1
+ export * from "./game/game";
2
+ export * from "./game/game-params";
3
+ export * from "./game/game-plugin";
4
+ export * from "./interaction/inputs";
5
+ export * from "./interaction/screen-mouse-inputs";
6
+ export * from "./navigation/resolver";
7
+ export * from "./navigation/screen-stack";
8
+ export * from "./ui/screen";
9
+ export * from "./ui/screen-delegate";
10
+ export * from "./plugins/automation-game-plugin";
11
+ export * from "./plugins/blur-pausing-game-plugin";
12
+ export * from "./plugins/fullscreen-button-game-plugin";
13
+ export * from "./plugins/storage-game-plugin";
14
+ export * from "./plugins/time-keys-game-plugin";
15
+ export * from "./plugins/version-label-game-plugin";
16
+ export * from "./storage/get-client-storage";
17
+ export * from "./storage/in-memory-storage";
18
+ export * from "./storage/local-json-store";
19
+ export * from "./util/math";
20
+ export * from "./util/navigation-flow";
package/lib/index.js CHANGED
@@ -14,22 +14,23 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./game/game"), exports);
17
18
  __exportStar(require("./game/game-params"), exports);
18
19
  __exportStar(require("./game/game-plugin"), exports);
19
- __exportStar(require("./game/game"), exports);
20
20
  __exportStar(require("./interaction/inputs"), exports);
21
21
  __exportStar(require("./interaction/screen-mouse-inputs"), exports);
22
22
  __exportStar(require("./navigation/resolver"), exports);
23
23
  __exportStar(require("./navigation/screen-stack"), exports);
24
- __exportStar(require("./ui/screen-delegate"), exports);
25
24
  __exportStar(require("./ui/screen"), exports);
25
+ __exportStar(require("./ui/screen-delegate"), exports);
26
26
  __exportStar(require("./plugins/automation-game-plugin"), exports);
27
27
  __exportStar(require("./plugins/blur-pausing-game-plugin"), exports);
28
28
  __exportStar(require("./plugins/fullscreen-button-game-plugin"), exports);
29
+ __exportStar(require("./plugins/storage-game-plugin"), exports);
29
30
  __exportStar(require("./plugins/time-keys-game-plugin"), exports);
30
31
  __exportStar(require("./plugins/version-label-game-plugin"), exports);
31
- __exportStar(require("./plugins/storage-game-plugin"), exports);
32
32
  __exportStar(require("./storage/get-client-storage"), exports);
33
33
  __exportStar(require("./storage/in-memory-storage"), exports);
34
34
  __exportStar(require("./storage/local-json-store"), exports);
35
35
  __exportStar(require("./util/math"), exports);
36
+ __exportStar(require("./util/navigation-flow"), exports);
@@ -1,9 +1,9 @@
1
- import { ScreenMouseInputs } from './screen-mouse-inputs';
2
- import { DOMGamepadInputs, DOMKeyboardInputs, DOMMouseInputs, Inputs } from '@remvst/client-inputs';
3
- import GamepadInputs from '@remvst/client-inputs/lib/gamepad/gamepad-inputs';
4
- import KeyboardInputs from '@remvst/client-inputs/lib/keyboard/keyboard-inputs';
5
- import { Screen } from '../ui/screen';
6
- import { Game } from '../game/game';
1
+ import { DOMGamepadInputs, DOMKeyboardInputs, DOMMouseInputs, Inputs } from "@remvst/client-inputs";
2
+ import GamepadInputs from "@remvst/client-inputs/lib/gamepad/gamepad-inputs";
3
+ import KeyboardInputs from "@remvst/client-inputs/lib/keyboard/keyboard-inputs";
4
+ import { Game } from "../game/game";
5
+ import { Screen } from "../ui/screen";
6
+ import { ScreenMouseInputs } from "./screen-mouse-inputs";
7
7
  export declare class ScreenInputs implements Inputs {
8
8
  readonly screen: Screen;
9
9
  readonly keyboard: KeyboardInputs;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GameInputs = exports.ScreenInputs = void 0;
4
- const math_1 = require("../util/math");
5
- const screen_mouse_inputs_1 = require("./screen-mouse-inputs");
6
4
  const client_inputs_1 = require("@remvst/client-inputs");
7
5
  const gamepad_inputs_1 = require("@remvst/client-inputs/lib/gamepad/gamepad-inputs");
8
6
  const keyboard_inputs_1 = require("@remvst/client-inputs/lib/keyboard/keyboard-inputs");
7
+ const math_1 = require("../util/math");
8
+ const screen_mouse_inputs_1 = require("./screen-mouse-inputs");
9
9
  class ScreenInputs {
10
10
  constructor(screen) {
11
11
  this.screen = screen;
@@ -70,7 +70,7 @@ class GameInputs {
70
70
  this.keyboard.setup();
71
71
  this.mouse.setup();
72
72
  this.gamepad.setup();
73
- window.addEventListener('blur', () => this.reset(), false);
73
+ window.addEventListener("blur", () => this.reset(), false);
74
74
  }
75
75
  reset() {
76
76
  this.keyboard.reset();
@@ -100,4 +100,3 @@ class GameInputs {
100
100
  }
101
101
  }
102
102
  exports.GameInputs = GameInputs;
103
- ;
@@ -1,4 +1,4 @@
1
- import { Screen } from '../ui/screen';
1
+ import { Screen } from "../ui/screen";
2
2
  export declare class UserCancelledError extends Error {
3
3
  }
4
4
  export declare class Resolver<T> {
@@ -1,6 +1,6 @@
1
- import { ResolverHolder } from './resolver';
2
- import { Game } from '../game/game';
3
- import { Screen } from '../ui/screen';
1
+ import { Game } from "../game/game";
2
+ import { Screen } from "../ui/screen";
3
+ import { ResolverHolder } from "./resolver";
4
4
  export declare enum NavigationType {
5
5
  RESET = 0,
6
6
  PUSH = 1,
@@ -12,7 +12,7 @@ export declare class ScreenStack {
12
12
  private readonly queue;
13
13
  prepareScreen: (screen: Screen) => void;
14
14
  constructor(game: Game);
15
- findByType<T extends Screen>(screenType: (new (...params: any) => T)): T | null;
15
+ findByType<T extends Screen>(screenType: new (...params: any) => T): T | null;
16
16
  current(): Screen;
17
17
  popTo(screen: Screen, inclusive?: boolean): void;
18
18
  push(screen: Screen): void;
@@ -17,7 +17,7 @@ class ScreenStack {
17
17
  this.prepareScreen = () => { };
18
18
  }
19
19
  findByType(screenType) {
20
- return this.screens.find((scr) => scr instanceof screenType) || null;
20
+ return (this.screens.find((scr) => scr instanceof screenType) || null);
21
21
  }
22
22
  current() {
23
23
  return this.screens[this.screens.length - 1] || null;
@@ -90,4 +90,3 @@ class ScreenStack {
90
90
  }
91
91
  }
92
92
  exports.ScreenStack = ScreenStack;
93
- ;
@@ -13,8 +13,8 @@ class AutomationGamePlugin extends game_plugin_1.GamePlugin {
13
13
  }
14
14
  setup() {
15
15
  super.setup();
16
- this.automationLabel = document.createElement('div');
17
- this.automationLabel.id = 'automation-label';
16
+ this.automationLabel = document.createElement("div");
17
+ this.automationLabel.id = "automation-label";
18
18
  document.body.appendChild(this.automationLabel);
19
19
  }
20
20
  render() {
@@ -23,9 +23,10 @@ class AutomationGamePlugin extends game_plugin_1.GamePlugin {
23
23
  this.getAutomationValues(automation);
24
24
  this.automationLabel.innerText = JSON.stringify(automation);
25
25
  // Disable all CSS animations for automation
26
- const styleElement = document.createElement('style');
27
- styleElement.setAttribute('id', 'style-tag');
28
- styleElement.innerHTML = '*,:after,:before,.animate-in{transition:none!important;animation:none!important;}';
26
+ const styleElement = document.createElement("style");
27
+ styleElement.setAttribute("id", "style-tag");
28
+ styleElement.innerHTML =
29
+ "*,:after,:before,.animate-in{transition:none!important;animation:none!important;}";
29
30
  document.head.appendChild(styleElement);
30
31
  }
31
32
  getAutomationValues(out) {
@@ -33,4 +34,4 @@ class AutomationGamePlugin extends game_plugin_1.GamePlugin {
33
34
  }
34
35
  }
35
36
  exports.AutomationGamePlugin = AutomationGamePlugin;
36
- AutomationGamePlugin.key = 'automation';
37
+ AutomationGamePlugin.key = "automation";
@@ -17,8 +17,8 @@ class BlurPausingGamePlugin extends game_plugin_1.GamePlugin {
17
17
  }
18
18
  setup() {
19
19
  super.setup();
20
- window.addEventListener('blur', () => this.updateLoop(), false);
21
- window.addEventListener('focus', () => this.updateLoop(), false);
20
+ window.addEventListener("blur", () => this.updateLoop(), false);
21
+ window.addEventListener("focus", () => this.updateLoop(), false);
22
22
  }
23
23
  updateLoop() {
24
24
  if (document.hasFocus() || !this._enabled) {
@@ -30,4 +30,4 @@ class BlurPausingGamePlugin extends game_plugin_1.GamePlugin {
30
30
  }
31
31
  }
32
32
  exports.BlurPausingGamePlugin = BlurPausingGamePlugin;
33
- BlurPausingGamePlugin.key = 'blur-pausing-game';
33
+ BlurPausingGamePlugin.key = "blur-pausing-game";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FullscreenButtonGamePlugin = void 0;
4
4
  const game_plugin_1 = require("../game/game-plugin");
5
- const ICON_DATA = 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9bpSIVQYuIOASsulgQFXHUKhShQqgVWnUwufQLmjQkKS6OgmvBwY/FqoOLs64OroIg+AHi6OSk6CIl/i8ptIjx4Lgf7+497t4B/lqJqWbbOKBqlpGMx4R0ZlUIviKEHvRhFEMSM/U5UUzAc3zdw8fXuyjP8j735+hSsiYDfALxLNMNi3iDeHrT0jnvE4dZQVKIz4nHDLog8SPXZZffOOcd9vPMsJFKzhOHiYV8C8stzAqGSjxFHFFUjfL9aZcVzluc1VKFNe7JXxjKaivLXKc5iDgWsQQRAmRUUEQJFqK0aqSYSNJ+zMM/4PhFcsnkKoKRYwFlqJAcP/gf/O7WzE1OuEmhGND+Ytsfw0BwF6hXbfv72LbrJ0DgGbjSmv5yDZj5JL3a1CJHQPc2cHHd1OQ94HIH6H/SJUNypABNfy4HvJ/RN2WA3lugc83trbGP0wcgRV0lboCDQ2AkT9nrHu/uaO3t3zON/n4AqiVyvXIak4gAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnAgQQGhZq6KlXAAAAK0lEQVQY02P8////fwYoYGRkZGRAAshyqBwc4P////+ZGIYToLqvGYkNcAAblh/vxNHP4AAAAABJRU5ErkJggg==';
5
+ const ICON_DATA = "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAABhWlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9bpSIVQYuIOASsulgQFXHUKhShQqgVWnUwufQLmjQkKS6OgmvBwY/FqoOLs64OroIg+AHi6OSk6CIl/i8ptIjx4Lgf7+497t4B/lqJqWbbOKBqlpGMx4R0ZlUIviKEHvRhFEMSM/U5UUzAc3zdw8fXuyjP8j735+hSsiYDfALxLNMNi3iDeHrT0jnvE4dZQVKIz4nHDLog8SPXZZffOOcd9vPMsJFKzhOHiYV8C8stzAqGSjxFHFFUjfL9aZcVzluc1VKFNe7JXxjKaivLXKc5iDgWsQQRAmRUUEQJFqK0aqSYSNJ+zMM/4PhFcsnkKoKRYwFlqJAcP/gf/O7WzE1OuEmhGND+Ytsfw0BwF6hXbfv72LbrJ0DgGbjSmv5yDZj5JL3a1CJHQPc2cHHd1OQ94HIH6H/SJUNypABNfy4HvJ/RN2WA3lugc83trbGP0wcgRV0lboCDQ2AkT9nrHu/uaO3t3zON/n4AqiVyvXIak4gAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAALiMAAC4jAXilP3YAAAAHdElNRQfnAgQQGhZq6KlXAAAAK0lEQVQY02P8////fwYoYGRkZGRAAshyqBwc4P////+ZGIYToLqvGYkNcAAblh/vxNHP4AAAAABJRU5ErkJggg==";
6
6
  class FullscreenButtonGamePlugin extends game_plugin_1.GamePlugin {
7
7
  constructor(container) {
8
8
  super();
@@ -11,7 +11,7 @@ class FullscreenButtonGamePlugin extends game_plugin_1.GamePlugin {
11
11
  }
12
12
  setup() {
13
13
  super.setup();
14
- const styleElt = document.createElement('style');
14
+ const styleElt = document.createElement("style");
15
15
  styleElt.innerHTML = `
16
16
  .fullscreen-button {
17
17
  position: absolute;
@@ -34,11 +34,11 @@ class FullscreenButtonGamePlugin extends game_plugin_1.GamePlugin {
34
34
  }
35
35
  `;
36
36
  document.head.appendChild(styleElt);
37
- const button = document.createElement('div');
38
- button.className = 'fullscreen-button';
39
- button.addEventListener('click', () => document.body.requestFullscreen(), false);
37
+ const button = document.createElement("div");
38
+ button.className = "fullscreen-button";
39
+ button.addEventListener("click", () => document.body.requestFullscreen(), false);
40
40
  this.container.appendChild(button);
41
41
  }
42
42
  }
43
43
  exports.FullscreenButtonGamePlugin = FullscreenButtonGamePlugin;
44
- FullscreenButtonGamePlugin.key = 'fullscreen-button';
44
+ FullscreenButtonGamePlugin.key = "fullscreen-button";
@@ -12,4 +12,4 @@ class StorageGamePlugin extends game_plugin_1.GamePlugin {
12
12
  }
13
13
  }
14
14
  exports.StorageGamePlugin = StorageGamePlugin;
15
- StorageGamePlugin.key = 'storage';
15
+ StorageGamePlugin.key = "storage";
@@ -21,4 +21,4 @@ class TimeKeysGamePlugin extends game_plugin_1.GamePlugin {
21
21
  }
22
22
  }
23
23
  exports.TimeKeysGamePlugin = TimeKeysGamePlugin;
24
- TimeKeysGamePlugin.key = 'time-keys';
24
+ TimeKeysGamePlugin.key = "time-keys";
@@ -5,6 +5,8 @@ export declare class VersionLabelGamePlugin extends GamePlugin {
5
5
  private readonly extraStyle;
6
6
  static readonly key = "version-label";
7
7
  readonly key = "version-label";
8
+ readonly labelElement: any;
9
+ readonly styleElement: HTMLStyleElement;
8
10
  constructor(container: HTMLElement, label: string, extraStyle?: string);
9
11
  setup(): void;
10
12
  }
@@ -3,31 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VersionLabelGamePlugin = void 0;
4
4
  const game_plugin_1 = require("../game/game-plugin");
5
5
  class VersionLabelGamePlugin extends game_plugin_1.GamePlugin {
6
- constructor(container, label, extraStyle = '') {
6
+ constructor(container, label, extraStyle = "") {
7
7
  super();
8
8
  this.container = container;
9
9
  this.label = label;
10
10
  this.extraStyle = extraStyle;
11
11
  this.key = VersionLabelGamePlugin.key;
12
+ this.labelElement = (() => {
13
+ const label = document.createElement("div");
14
+ label.className = "version-label";
15
+ label.innerText = this.label;
16
+ return this.labelElement;
17
+ })();
18
+ this.styleElement = (() => {
19
+ const styleElt = document.createElement("style");
20
+ styleElt.innerHTML = `
21
+ .version-label {
22
+ position: absolute;
23
+ z-index: 2;
24
+ margin: 10px;
25
+ color: #fff;
26
+ bottom: 0;
27
+ right: 0;
28
+ text-transform: uppercase;
29
+ text-shadow: 0px 2px 0px #000;
30
+ font-family: Courier;
31
+ font-size: 10px;
32
+ ${this.extraStyle}
33
+ }
34
+ `;
35
+ return styleElt;
36
+ })();
12
37
  }
13
38
  setup() {
14
39
  super.setup();
15
- const button = document.createElement('div');
16
- button.innerText = this.label;
17
- button.style.cssText = `
18
- position: absolute;
19
- z-index: 2;
20
- margin: 10px;
21
- color: #fff;
22
- bottom: 0;
23
- right: 0;
24
- text-transform: uppercase;
25
- text-shadow: 0px 2px 0px #000;
26
- font-family: Courier;
27
- font-size: 10px;
28
- ${this.extraStyle}
29
- `;
30
- this.container.appendChild(button);
40
+ document.head.appendChild(this.styleElement);
41
+ this.container.appendChild(this.labelElement);
31
42
  }
32
43
  }
33
44
  exports.VersionLabelGamePlugin = VersionLabelGamePlugin;
@@ -4,9 +4,9 @@ exports.getClientStorage = void 0;
4
4
  const in_memory_storage_1 = require("./in-memory-storage");
5
5
  function getClientStorage() {
6
6
  const options = [
7
- ['localStorage', () => window.localStorage],
8
- ['sessionStorage', () => window.sessionStorage],
9
- ['InMemoryStorage', () => new in_memory_storage_1.InMemoryStorage()],
7
+ ["localStorage", () => window.localStorage],
8
+ ["sessionStorage", () => window.sessionStorage],
9
+ ["InMemoryStorage", () => new in_memory_storage_1.InMemoryStorage()],
10
10
  ];
11
11
  for (const [label, getter] of options) {
12
12
  try {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InMemoryStorage = void 0;
4
4
  class InMemoryStorage {
5
5
  constructor() {
6
- this.items = new Map;
6
+ this.items = new Map();
7
7
  }
8
8
  get length() {
9
9
  return this.items.size;
@@ -56,4 +56,3 @@ class LocalJsonStore {
56
56
  }
57
57
  }
58
58
  exports.LocalJsonStore = LocalJsonStore;
59
- ;
@@ -1,7 +1,7 @@
1
- import { InterpolationPool } from '@remvst/animate.js';
2
- import { Game } from '../game/game';
3
- import { ScreenDelegate } from './screen-delegate';
4
- import { ScreenInputs } from '../interaction/inputs';
1
+ import { InterpolationPool } from "@remvst/animate.js";
2
+ import { Game } from "../game/game";
3
+ import { ScreenInputs } from "../interaction/inputs";
4
+ import { ScreenDelegate } from "./screen-delegate";
5
5
  export declare abstract class Screen {
6
6
  game: Game;
7
7
  cursorType: string;
package/lib/ui/screen.js CHANGED
@@ -5,7 +5,7 @@ const animate_js_1 = require("@remvst/animate.js");
5
5
  const inputs_1 = require("../interaction/inputs");
6
6
  class Screen {
7
7
  constructor() {
8
- this.cursorType = 'default';
8
+ this.cursorType = "default";
9
9
  this.age = 0;
10
10
  this.frameCount = 0;
11
11
  this.delegate = null;
@@ -111,8 +111,8 @@ class Screen {
111
111
  }
112
112
  }
113
113
  addDebugValues(values) {
114
- values['screen.id'] = this.id;
115
- values['screen.interpolations'] = this.interpolationPool.size;
114
+ values["screen.id"] = this.id;
115
+ values["screen.interpolations"] = this.interpolationPool.size;
116
116
  }
117
117
  get isForeground() {
118
118
  return this.game && this.game.screenStack.current() === this;
package/lib/util/math.js CHANGED
@@ -9,4 +9,3 @@ function between(a, b, c) {
9
9
  return b;
10
10
  }
11
11
  exports.between = between;
12
- ;
@@ -0,0 +1 @@
1
+ export declare function navigationFlow<T>(flow: Promise<T>): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.navigationFlow = void 0;
4
+ const resolver_1 = require("../navigation/resolver");
5
+ function navigationFlow(flow) {
6
+ flow.catch((err) => {
7
+ if (err instanceof resolver_1.UserCancelledError)
8
+ return;
9
+ console.error(err);
10
+ });
11
+ }
12
+ exports.navigationFlow = navigationFlow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remvst/game-navigation-core",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -3,4 +3,4 @@ export interface GameParams {
3
3
  height: number;
4
4
  maxFrameInterval?: number;
5
5
  fps?: number;
6
- };
6
+ }
@@ -1,8 +1,7 @@
1
+ import { Screen } from "../ui/screen";
1
2
  import { Game } from "./game";
2
- import { Screen } from '../ui/screen';
3
3
 
4
4
  export abstract class GamePlugin {
5
-
6
5
  abstract get key(): string;
7
6
 
8
7
  protected game: Game;
@@ -15,19 +14,11 @@ export abstract class GamePlugin {
15
14
  this.game = game;
16
15
  }
17
16
 
18
- setup(): void {
19
-
20
- }
17
+ setup(): void {}
21
18
 
22
- setupScreen(screen: Screen): void {
23
-
24
- }
19
+ setupScreen(screen: Screen): void {}
25
20
 
26
- cycle(elapsed: number) {
21
+ cycle(elapsed: number) {}
27
22
 
28
- }
29
-
30
- render() {
31
-
32
- }
23
+ render() {}
33
24
  }