@antha/input 0.10.0 → 0.11.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.
|
@@ -85,6 +85,15 @@ export type BindingAssignments<BindingNames extends string = string> = Partial<R
|
|
|
85
85
|
* @category Internal
|
|
86
86
|
*/
|
|
87
87
|
export type PlayersBindingAssignments<BindingNames extends string = string> = Record<PlayerPosition, BindingAssignments<BindingNames>>;
|
|
88
|
+
/**
|
|
89
|
+
* Returns assignments limited to the binding names supported by the consuming game.
|
|
90
|
+
*
|
|
91
|
+
* @category Internal
|
|
92
|
+
*/
|
|
93
|
+
export declare function filterToAllowedActions<BindingNames extends string>({ allowedBindingNames, bindingAssignments, }: Readonly<{
|
|
94
|
+
allowedBindingNames: ReadonlyArray<BindingNames>;
|
|
95
|
+
bindingAssignments: Readonly<Partial<Record<PlayerPosition, Readonly<BindingAssignments>>>>;
|
|
96
|
+
}>): PlayersBindingAssignments<BindingNames>;
|
|
88
97
|
/**
|
|
89
98
|
* An individual active binding. Used in `createAnthaReadBindingsMod` and {@link ActiveBindings}.
|
|
90
99
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getObjectTypedEntries, pickObjectKeys } from '@augment-vir/common';
|
|
1
2
|
import { InputDeviceKey } from 'input-device-handler';
|
|
2
3
|
import { defineShape, enumShape, nonEmptyStringShape, optionalShape, recordShape, typedStringShape, } from 'object-shape-tester';
|
|
3
4
|
import { InputDirection } from '../raw-inputs/raw-input.js';
|
|
@@ -35,3 +36,16 @@ export const playersBindingAssignmentsShape = recordShape({
|
|
|
35
36
|
values: [bindingAssignmentShape],
|
|
36
37
|
}),
|
|
37
38
|
});
|
|
39
|
+
/**
|
|
40
|
+
* Returns assignments limited to the binding names supported by the consuming game.
|
|
41
|
+
*
|
|
42
|
+
* @category Internal
|
|
43
|
+
*/
|
|
44
|
+
export function filterToAllowedActions({ allowedBindingNames, bindingAssignments, }) {
|
|
45
|
+
return getObjectTypedEntries(bindingAssignments).reduce((filteredBindingAssignments, [playerPosition, playerBindingAssignments,]) => {
|
|
46
|
+
return {
|
|
47
|
+
...filteredBindingAssignments,
|
|
48
|
+
[playerPosition]: pickObjectKeys(playerBindingAssignments, allowedBindingNames),
|
|
49
|
+
};
|
|
50
|
+
}, {});
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antha/input",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "An Antha mod for handling inputs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vir",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test:docs": "virmator docs check"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@antha/gamepad-type": "^0.
|
|
36
|
+
"@antha/gamepad-type": "^0.11.0",
|
|
37
37
|
"@augment-vir/assert": "^32.2.3",
|
|
38
38
|
"@augment-vir/common": "^32.2.3",
|
|
39
39
|
"date-vir": "^9.1.1",
|
|
@@ -48,10 +48,12 @@
|
|
|
48
48
|
"@web/test-runner": "^1.0.0",
|
|
49
49
|
"@web/test-runner-playwright": "^1.0.0",
|
|
50
50
|
"element-vir": "^26.17.3",
|
|
51
|
-
"istanbul-smart-text-reporter": "^1.1.5"
|
|
51
|
+
"istanbul-smart-text-reporter": "^1.1.5",
|
|
52
|
+
"markdown-code-example-inserter": "^3.0.6",
|
|
53
|
+
"typedoc": "^0.28.20"
|
|
52
54
|
},
|
|
53
55
|
"peerDependencies": {
|
|
54
|
-
"@antha/engine": "^0.
|
|
56
|
+
"@antha/engine": "^0.11.0",
|
|
55
57
|
"element-vir": ">=26"
|
|
56
58
|
},
|
|
57
59
|
"engines": {
|