@antha/input 0.19.0 → 0.20.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.
@@ -23,7 +23,17 @@ export type AnthaMenuStateModState<MenuKey extends string = string> = MenuNavMod
23
23
  *
24
24
  * @category Internal
25
25
  */
26
- export declare function getAnthaMenuReturnState<MenuKey extends string>(currentState: Readonly<AnthaMenuState<MenuKey>> | undefined): AnthaMenuState<MenuKey>;
26
+ export declare function popAnthaMenuState<MenuKey extends string>(currentState: Readonly<AnthaMenuState<MenuKey>> | undefined): AnthaMenuState<MenuKey>;
27
+ /**
28
+ * Opens `submenu` and appends the current menu to the return path so backing out of `submenu`
29
+ * returns to it. When no menu is open, `submenu` opens with an empty return path.
30
+ *
31
+ * @category Internal
32
+ */
33
+ export declare function pushAnthaMenuState<MenuKey extends string>(currentState: Readonly<AnthaMenuState<MenuKey>> | undefined, submenu: NoInfer<MenuKey>): {
34
+ activeMenu: MenuKey;
35
+ returnTo: MenuKey[];
36
+ };
27
37
  /**
28
38
  * Resolves pause and back inputs into a menu-state transition.
29
39
  *
@@ -8,12 +8,27 @@ import { isPlayerMenuNavigationAllowed, MenuNavBinding, } from './antha-menu-nav
8
8
  *
9
9
  * @category Internal
10
10
  */
11
- export function getAnthaMenuReturnState(currentState) {
11
+ export function popAnthaMenuState(currentState) {
12
12
  return {
13
13
  activeMenu: currentState?.returnTo.at(-1),
14
14
  returnTo: currentState?.returnTo.slice(0, -1) || [],
15
15
  };
16
16
  }
17
+ /**
18
+ * Opens `submenu` and appends the current menu to the return path so backing out of `submenu`
19
+ * returns to it. When no menu is open, `submenu` opens with an empty return path.
20
+ *
21
+ * @category Internal
22
+ */
23
+ export function pushAnthaMenuState(currentState, submenu) {
24
+ return {
25
+ activeMenu: submenu,
26
+ returnTo: [
27
+ ...(currentState?.returnTo || []),
28
+ ...(check.isDefined(currentState?.activeMenu) ? [currentState.activeMenu] : []),
29
+ ],
30
+ };
31
+ }
17
32
  /**
18
33
  * Resolves pause and back inputs into a menu-state transition.
19
34
  *
@@ -30,7 +45,7 @@ export function getAnthaMenuStateForNavigation({ menuExitWasTriggered, menuState
30
45
  : undefined;
31
46
  }
32
47
  return openPauseMenuWasTriggered || menuExitWasTriggered
33
- ? getAnthaMenuReturnState(menuState)
48
+ ? popAnthaMenuState(menuState)
34
49
  : undefined;
35
50
  }
36
51
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/input",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "An Antha mod for handling inputs.",
5
5
  "keywords": [
6
6
  "vir",
@@ -42,8 +42,8 @@
42
42
  "vira": "^32.0.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@antha/engine": "^0.19.0",
46
- "@antha/gamepad-type": "^0.19.0",
45
+ "@antha/engine": "^0.20.0",
46
+ "@antha/gamepad-type": "^0.20.0",
47
47
  "@augment-vir/test": "^32.3.0",
48
48
  "@web/dev-server-esbuild": "^2.0.0",
49
49
  "@web/test-runner": "^1.0.0",
@@ -54,8 +54,8 @@
54
54
  "typedoc": "^0.28.20"
55
55
  },
56
56
  "peerDependencies": {
57
- "@antha/engine": "^0.19.0",
58
- "@antha/gamepad-type": "^0.19.0",
57
+ "@antha/engine": "^0.20.0",
58
+ "@antha/gamepad-type": "^0.20.0",
59
59
  "element-vir": "^27"
60
60
  },
61
61
  "engines": {