@quenty/playerinputmode 9.19.0 → 9.19.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [9.19.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerinputmode@9.19.0...@quenty/playerinputmode@9.19.1) (2025-04-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
12
+
13
+
14
+
15
+
16
+
6
17
  # [9.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerinputmode@9.18.2...@quenty/playerinputmode@9.19.0) (2025-04-02)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/playerinputmode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/playerinputmode",
3
- "version": "9.19.0",
3
+ "version": "9.19.1",
4
4
  "description": "Service that takes active input modes from the player and exposes it to every other player via the server.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,20 +26,20 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/attributeutils": "^14.17.0",
30
- "@quenty/brio": "^14.17.0",
31
- "@quenty/inputmode": "^13.18.0",
32
- "@quenty/loader": "^10.8.0",
33
- "@quenty/maid": "^3.4.0",
34
- "@quenty/playerutils": "^8.17.0",
35
- "@quenty/promise": "^10.10.1",
36
- "@quenty/remoting": "^12.18.0",
37
- "@quenty/rx": "^13.17.0",
38
- "@quenty/servicebag": "^11.11.1",
39
- "@quenty/table": "^3.7.1"
29
+ "@quenty/attributeutils": "^14.17.1",
30
+ "@quenty/brio": "^14.17.1",
31
+ "@quenty/inputmode": "^13.18.1",
32
+ "@quenty/loader": "^10.8.1",
33
+ "@quenty/maid": "^3.4.1",
34
+ "@quenty/playerutils": "^8.17.1",
35
+ "@quenty/promise": "^10.10.2",
36
+ "@quenty/remoting": "^12.18.1",
37
+ "@quenty/rx": "^13.17.1",
38
+ "@quenty/servicebag": "^11.11.2",
39
+ "@quenty/table": "^3.7.2"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "e8ea56930e65322fcffc05a1556d5df988068f0b"
44
+ "gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
45
45
  }
@@ -18,11 +18,12 @@ local PlayerInputModeUtils = require("PlayerInputModeUtils")
18
18
  local PlayerInputModeTypes = require("PlayerInputModeTypes")
19
19
  local RxPlayerUtils = require("RxPlayerUtils")
20
20
  local RxBrioUtils = require("RxBrioUtils")
21
+ local _ServiceBag = require("ServiceBag")
21
22
 
22
23
  local PlayerInputModeServiceClient = {}
23
24
  PlayerInputModeServiceClient.ServiceName = "PlayerInputModeServiceClient"
24
25
 
25
- function PlayerInputModeServiceClient:Init(serviceBag)
26
+ function PlayerInputModeServiceClient:Init(serviceBag: _ServiceBag.ServiceBag)
26
27
  assert(not self._serviceBag, "Already initialized")
27
28
  self._serviceBag = assert(serviceBag, "No serviceBag")
28
29
 
@@ -70,7 +71,7 @@ end
70
71
  @param player Player
71
72
  @return Observable<PlayerInputModeType>
72
73
  ]=]
73
- function PlayerInputModeServiceClient:ObservePlayerInputType(player)
74
+ function PlayerInputModeServiceClient:ObservePlayerInputType(player: Player)
74
75
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
75
76
 
76
77
  return PlayerInputModeUtils.observePlayerInputModeType(player)
@@ -82,7 +83,7 @@ end
82
83
  @param player Player
83
84
  @return PlayerInputModeType
84
85
  ]=]
85
- function PlayerInputModeServiceClient:GetPlayerInputModeType(player)
86
+ function PlayerInputModeServiceClient:GetPlayerInputModeType(player: Player)
86
87
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
87
88
 
88
89
  return PlayerInputModeUtils.getPlayerInputModeType(player)
@@ -12,11 +12,12 @@ local GetRemoteEvent = require("GetRemoteEvent")
12
12
  local Maid = require("Maid")
13
13
  local PlayerInputModeServiceConstants = require("PlayerInputModeServiceConstants")
14
14
  local PlayerInputModeUtils = require("PlayerInputModeUtils")
15
+ local _ServiceBag = require("ServiceBag")
15
16
 
16
17
  local PlayerInputModeService = {}
17
18
  PlayerInputModeService.ServiceName = "PlayerInputModeService"
18
19
 
19
- function PlayerInputModeService:Init(serviceBag)
20
+ function PlayerInputModeService:Init(serviceBag: _ServiceBag.ServiceBag)
20
21
  assert(not self._serviceBag, "Already initialized")
21
22
  self._serviceBag = assert(serviceBag, "No serviceBag")
22
23
 
@@ -37,7 +38,7 @@ end
37
38
  @param player Player
38
39
  @return PlayerInputModeType
39
40
  ]=]
40
- function PlayerInputModeService:GetPlayerInputModeType(player)
41
+ function PlayerInputModeService:GetPlayerInputModeType(player: Player)
41
42
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
42
43
 
43
44
  return PlayerInputModeUtils.getPlayerInputModeType(player)
@@ -50,7 +51,7 @@ end
50
51
  @param cancelToken CancelToken
51
52
  @return Promise<PlayerInputModeType>
52
53
  ]=]
53
- function PlayerInputModeService:PromisePlayerInputMode(player, cancelToken)
54
+ function PlayerInputModeService:PromisePlayerInputMode(player: Player, cancelToken)
54
55
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
55
56
 
56
57
  return PlayerInputModeUtils.promisePlayerInputMode(player, cancelToken)
@@ -62,13 +63,13 @@ end
62
63
  @param player Player
63
64
  @return Observable<PlayerInputModeType>
64
65
  ]=]
65
- function PlayerInputModeService:ObservePlayerInputType(player)
66
+ function PlayerInputModeService:ObservePlayerInputType(player: Player)
66
67
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
67
68
 
68
69
  return PlayerInputModeUtils.observePlayerInputModeType(player)
69
70
  end
70
71
 
71
- function PlayerInputModeService:_handleServerEvent(player, request, ...)
72
+ function PlayerInputModeService:_handleServerEvent(player: Player, request, ...)
72
73
  if request == PlayerInputModeServiceConstants.REQUEST_SET_INPUT_MODE then
73
74
  self:_setPlayerInputModeType(player, ...)
74
75
  else
@@ -76,7 +77,7 @@ function PlayerInputModeService:_handleServerEvent(player, request, ...)
76
77
  end
77
78
  end
78
79
 
79
- function PlayerInputModeService:_setPlayerInputModeType(player, inputModeType)
80
+ function PlayerInputModeService:_setPlayerInputModeType(player: Player, inputModeType)
80
81
  assert(PlayerInputModeUtils.isInputModeType(inputModeType), "Bad inputModeType")
81
82
 
82
83
  PlayerInputModeUtils.setPlayerInputModeType(player, inputModeType)
@@ -1,42 +1,98 @@
1
1
  --[=[
2
+ Utility methods to track public player input mode
3
+
2
4
  @class PlayerInputModeUtils
3
5
  ]=]
4
6
 
5
7
  local require = require(script.Parent.loader).load(script)
6
8
 
9
+ local AttributeUtils = require("AttributeUtils")
7
10
  local PlayerInputModeServiceConstants = require("PlayerInputModeServiceConstants")
8
- local RxAttributeUtils = require("RxAttributeUtils")
9
11
  local PlayerInputModeTypes = require("PlayerInputModeTypes")
10
- local AttributeUtils = require("AttributeUtils")
12
+ local Rx = require("Rx")
13
+ local RxAttributeUtils = require("RxAttributeUtils")
11
14
 
12
15
  local PlayerInputModeUtils = {}
13
16
 
14
- function PlayerInputModeUtils.getPlayerInputModeType(player)
17
+ export type PlayerInputModeType = "Gamepad" | "Keyboard" | "Touch"
18
+
19
+ --[=[
20
+ Returns the player input mode type for a player.
21
+
22
+ @param player Player
23
+ @return PlayerInputModeType?
24
+ ]=]
25
+ function PlayerInputModeUtils.getPlayerInputModeType(player: Player): PlayerInputModeType?
15
26
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
16
27
 
17
- return player:GetAttribute(PlayerInputModeServiceConstants.INPUT_MODE_ATTRIBUTE)
28
+ local result = player:GetAttribute(PlayerInputModeServiceConstants.INPUT_MODE_ATTRIBUTE)
29
+ if PlayerInputModeUtils.isInputModeType(result) then
30
+ return result
31
+ else
32
+ return nil
33
+ end
18
34
  end
19
35
 
20
- function PlayerInputModeUtils.observePlayerInputModeType(player)
36
+ --[=[
37
+ Observes the player input mode type for a player.
38
+
39
+ @param player Player
40
+ @return Observable<PlayerInputModeType?>
41
+ ]=]
42
+ function PlayerInputModeUtils.observePlayerInputModeType(player: Player): PlayerInputModeType?
21
43
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
22
44
 
23
- return RxAttributeUtils.observeAttribute(player, PlayerInputModeServiceConstants.INPUT_MODE_ATTRIBUTE)
45
+ return RxAttributeUtils.observeAttribute(player, PlayerInputModeServiceConstants.INPUT_MODE_ATTRIBUTE):Pipe({
46
+ Rx.map(function(value)
47
+ if PlayerInputModeUtils.isInputModeType(value) then
48
+ return value
49
+ else
50
+ return nil
51
+ end
52
+ end),
53
+ })
24
54
  end
25
55
 
26
- function PlayerInputModeUtils.promisePlayerInputMode(player, cancelToken)
56
+ --[=[
57
+ Observes the player input mode type for a player.
58
+
59
+ @param player Player
60
+ @param cancelToken CancelToken?
61
+ @return Promise<string?>
62
+ ]=]
63
+ function PlayerInputModeUtils.promisePlayerInputMode(player: Player, cancelToken)
27
64
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
28
65
 
29
- return AttributeUtils.promiseAttribute(player, PlayerInputModeServiceConstants.INPUT_MODE_ATTRIBUTE, PlayerInputModeUtils.isInputModeType, cancelToken)
66
+ return AttributeUtils.promiseAttribute(
67
+ player,
68
+ PlayerInputModeServiceConstants.INPUT_MODE_ATTRIBUTE,
69
+ PlayerInputModeUtils.isInputModeType,
70
+ cancelToken
71
+ )
30
72
  end
31
73
 
32
- function PlayerInputModeUtils.isInputModeType(playerInputModeType)
33
- return typeof(playerInputModeType) == "string" and (
34
- playerInputModeType == PlayerInputModeTypes.GAMEPAD
35
- or playerInputModeType == PlayerInputModeTypes.KEYBOARD
36
- or playerInputModeType == PlayerInputModeTypes.TOUCH)
74
+ --[=[
75
+ Checks if the input mode type is valid.
76
+
77
+ @param playerInputModeType any
78
+ @return boolean
79
+ ]=]
80
+ function PlayerInputModeUtils.isInputModeType(playerInputModeType: any): boolean
81
+ return typeof(playerInputModeType) == "string"
82
+ and (
83
+ playerInputModeType == PlayerInputModeTypes.GAMEPAD
84
+ or playerInputModeType == PlayerInputModeTypes.KEYBOARD
85
+ or playerInputModeType == PlayerInputModeTypes.TOUCH
86
+ )
37
87
  end
38
88
 
39
- function PlayerInputModeUtils.setPlayerInputModeType(player, playerInputModeType)
89
+ --[=[
90
+ Sets the player input mode type for a player.
91
+
92
+ @param player Player
93
+ @param playerInputModeType string
94
+ ]=]
95
+ function PlayerInputModeUtils.setPlayerInputModeType(player: Player, playerInputModeType: PlayerInputModeType)
40
96
  assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
41
97
  assert(PlayerInputModeUtils.isInputModeType(playerInputModeType), "Bad playerInputModeType")
42
98