@antha/input 0.18.0 → 0.19.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.
@@ -1,13 +1,13 @@
1
1
  import { type AnthaReadRawInputModState } from '../raw-inputs/antha-read-raw-input.mod.js';
2
2
  import { type MenuNavModState } from './antha-menu-nav.mod.js';
3
3
  /**
4
- * Menu navigation state with an optional parent destination for back navigation.
4
+ * Menu navigation state whose return path lists parent menus from the outermost to the nearest.
5
5
  *
6
6
  * @category Internal
7
7
  */
8
8
  export type AnthaMenuState<MenuKey extends string = string> = {
9
9
  activeMenu: MenuKey | undefined;
10
- returnTo: MenuKey | undefined;
10
+ returnTo: MenuKey[];
11
11
  };
12
12
  /**
13
13
  * State consumed or updated by {@link createAnthaMenuStateMod}.
@@ -18,14 +18,12 @@ export type AnthaMenuStateModState<MenuKey extends string = string> = MenuNavMod
18
18
  menuState: AnthaMenuState<MenuKey> | undefined;
19
19
  };
20
20
  /**
21
- * Returns the parent menu, or closes menu mode when there is no parent.
21
+ * Returns to the nearest parent menu and removes it from the path, or closes menu mode when the
22
+ * path is empty.
22
23
  *
23
24
  * @category Internal
24
25
  */
25
- export declare function getAnthaMenuReturnState<MenuKey extends string>(returnTo: MenuKey | undefined): {
26
- activeMenu: MenuKey | undefined;
27
- returnTo: undefined;
28
- };
26
+ export declare function getAnthaMenuReturnState<MenuKey extends string>(currentState: Readonly<AnthaMenuState<MenuKey>> | undefined): AnthaMenuState<MenuKey>;
29
27
  /**
30
28
  * Resolves pause and back inputs into a menu-state transition.
31
29
  *
@@ -36,10 +34,7 @@ export declare function getAnthaMenuStateForNavigation<MenuKey extends string>({
36
34
  menuState: Readonly<AnthaMenuState<MenuKey>> | undefined;
37
35
  openPauseMenuWasTriggered: boolean;
38
36
  pauseMenu: MenuKey;
39
- }>): {
40
- activeMenu: MenuKey | undefined;
41
- returnTo: undefined;
42
- } | undefined;
37
+ }>): AnthaMenuState<MenuKey> | undefined;
43
38
  /**
44
39
  * Switches the raw-input consumer and menu-navigation state on pause/back inputs. Add this before
45
40
  * `createAnthaMenuNavMod` so navigation sees the updated `isInMenu` value.
@@ -3,14 +3,15 @@ import { check } from '@augment-vir/assert';
3
3
  import { getObjectTypedEntries } from '@augment-vir/common';
4
4
  import { isPlayerMenuNavigationAllowed, MenuNavBinding, } from './antha-menu-nav.mod.js';
5
5
  /**
6
- * Returns the parent menu, or closes menu mode when there is no parent.
6
+ * Returns to the nearest parent menu and removes it from the path, or closes menu mode when the
7
+ * path is empty.
7
8
  *
8
9
  * @category Internal
9
10
  */
10
- export function getAnthaMenuReturnState(returnTo) {
11
+ export function getAnthaMenuReturnState(currentState) {
11
12
  return {
12
- activeMenu: returnTo,
13
- returnTo: undefined,
13
+ activeMenu: currentState?.returnTo.at(-1),
14
+ returnTo: currentState?.returnTo.slice(0, -1) || [],
14
15
  };
15
16
  }
16
17
  /**
@@ -24,12 +25,12 @@ export function getAnthaMenuStateForNavigation({ menuExitWasTriggered, menuState
24
25
  return openPauseMenuWasTriggered
25
26
  ? {
26
27
  activeMenu: pauseMenu,
27
- returnTo: undefined,
28
+ returnTo: [],
28
29
  }
29
30
  : undefined;
30
31
  }
31
32
  return openPauseMenuWasTriggered || menuExitWasTriggered
32
- ? getAnthaMenuReturnState(menuState?.returnTo)
33
+ ? getAnthaMenuReturnState(menuState)
33
34
  : undefined;
34
35
  }
35
36
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/input",
3
- "version": "0.18.0",
3
+ "version": "0.19.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.18.0",
46
- "@antha/gamepad-type": "^0.18.0",
45
+ "@antha/engine": "^0.19.0",
46
+ "@antha/gamepad-type": "^0.19.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.18.0",
58
- "@antha/gamepad-type": "^0.18.0",
57
+ "@antha/engine": "^0.19.0",
58
+ "@antha/gamepad-type": "^0.19.0",
59
59
  "element-vir": "^27"
60
60
  },
61
61
  "engines": {