@quenty/characterutils 12.18.0 → 12.18.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
+ ## [12.18.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/characterutils@12.18.0...@quenty/characterutils@12.18.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
  # [12.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/characterutils@12.17.2...@quenty/characterutils@12.18.0) (2025-04-02)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/characterutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/characterutils",
3
- "version": "12.18.0",
3
+ "version": "12.18.1",
4
4
  "description": "CharacterUtils",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,16 +25,16 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/brio": "^14.17.0",
29
- "@quenty/deferred": "^2.2.0",
30
- "@quenty/instanceutils": "^13.17.0",
31
- "@quenty/loader": "^10.8.0",
32
- "@quenty/maid": "^3.4.0",
33
- "@quenty/promise": "^10.10.1",
34
- "@quenty/rx": "^13.17.0"
28
+ "@quenty/brio": "^14.17.1",
29
+ "@quenty/deferred": "^2.2.1",
30
+ "@quenty/instanceutils": "^13.17.1",
31
+ "@quenty/loader": "^10.8.1",
32
+ "@quenty/maid": "^3.4.1",
33
+ "@quenty/promise": "^10.10.2",
34
+ "@quenty/rx": "^13.17.1"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "e8ea56930e65322fcffc05a1556d5df988068f0b"
39
+ "gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
40
40
  }
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Utility for Roblox character objects that involve promises.
3
4
  @class CharacterPromiseUtils
@@ -16,7 +17,7 @@ local CharacterPromiseUtils = {}
16
17
  @param player Player
17
18
  @return Promise<Model>
18
19
  ]=]
19
- function CharacterPromiseUtils.promiseCharacter(player)
20
+ function CharacterPromiseUtils.promiseCharacter(player: Player): Promise.Promise<Model>
20
21
  assert(typeof(player) == "Instance", "Bad player")
21
22
 
22
23
  local promise = Promise.new()
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  General character utility code.
3
4
  @class CharacterUtils
@@ -71,7 +72,7 @@ end
71
72
  ```lua
72
73
  local Players = game:GetService("Players")
73
74
 
74
- for _, player in pairs(Players:GetPlayers()) do
75
+ for _, player in Players:GetPlayers() do
75
76
  CharacterUtils.unequipTools(player)
76
77
  end
77
78
  ```
@@ -108,7 +109,8 @@ end
108
109
  ]=]
109
110
  function CharacterUtils.getPlayerFromCharacter(descendant: Instance): Player?
110
111
  local character = descendant
111
- local player = Players:GetPlayerFromCharacter(character)
112
+ -- TODO: Only use models
113
+ local player = Players:GetPlayerFromCharacter(character :: any)
112
114
 
113
115
  while not player do
114
116
  if character.Parent then
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Utility functions involving the root part
3
4
  @class RootPartUtils
@@ -24,7 +25,7 @@ local MAX_YIELD_TIME = 60
24
25
  @param humanoid Humanoid
25
26
  @return Promise<BasePart>
26
27
  ]=]
27
- function RootPartUtils.promiseRootPart(humanoid: Humanoid)
28
+ function RootPartUtils.promiseRootPart(humanoid: Humanoid): Promise.Promise<BasePart>
28
29
  if humanoid.RootPart then
29
30
  return Promise.resolved(humanoid.RootPart)
30
31
  end
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Utilities for observing characters and their humanoids.
3
4
  @class RxCharacterUtils
@@ -22,7 +23,7 @@ local RxCharacterUtils = {}
22
23
  @param player Player
23
24
  @return Observable<Brio<Model>>
24
25
  ]=]
25
- function RxCharacterUtils.observeLastCharacterBrio(player: Player)
26
+ function RxCharacterUtils.observeLastCharacterBrio(player: Player): Observable.Observable<Brio.Brio<Model>>
26
27
  -- This assumes a player's 'Character' field is set to nil when
27
28
  -- their character is destroyed, or when they leave the game.
28
29
  return RxInstanceUtils.observePropertyBrio(player, "Character", function(character)
@@ -36,7 +37,7 @@ end
36
37
  @param player Player
37
38
  @return Observable<Model>
38
39
  ]=]
39
- function RxCharacterUtils.observeCharacter(player: Player)
40
+ function RxCharacterUtils.observeCharacter(player: Player): Observable.Observable<Model>
40
41
  return RxInstanceUtils.observeProperty(player, "Character")
41
42
  end
42
43
 
@@ -46,7 +47,7 @@ end
46
47
  @param player Player
47
48
  @return Observable<Brio<Model>>
48
49
  ]=]
49
- function RxCharacterUtils.observeCharacterBrio(player: Player)
50
+ function RxCharacterUtils.observeCharacterBrio(player: Player): Observable.Observable<Brio.Brio<Model>>
50
51
  return RxInstanceUtils.observePropertyBrio(player, "Character", function(character)
51
52
  return character ~= nil
52
53
  end)
@@ -58,28 +59,28 @@ end
58
59
  @param instance Instance
59
60
  @return Observable<boolean>
60
61
  ]=]
61
- function RxCharacterUtils.observeIsOfLocalCharacter(instance: Instance)
62
+ function RxCharacterUtils.observeIsOfLocalCharacter(instance: Instance): Observable.Observable<boolean>
62
63
  assert(typeof(instance) == "Instance", "Bad instance")
63
64
 
64
65
  local localPlayer = Players.LocalPlayer
65
66
  if not localPlayer then
66
67
  warn("[RxCharacterUtils] - No localPlayer")
67
- return Rx.EMPTY
68
+ return Rx.EMPTY :: any
68
69
  end
69
70
 
70
71
  return Rx.combineLatest({
71
72
  character = RxCharacterUtils.observeLocalPlayerCharacter(),
72
73
  _ancestry = RxInstanceUtils.observeAncestry(instance),
73
74
  }):Pipe({
74
- Rx.map(function(state)
75
+ Rx.map(function(state: any)
75
76
  if state.character then
76
77
  return instance == state.character or instance:IsDescendantOf(state.character)
77
78
  else
78
79
  return false
79
80
  end
80
- end),
81
- Rx.distinct(),
82
- })
81
+ end) :: any,
82
+ Rx.distinct() :: any,
83
+ }) :: any
83
84
  end
84
85
 
85
86
  --[=[
@@ -88,12 +89,12 @@ end
88
89
  @param instance Instance
89
90
  @return Observable<Brio<boolean>>
90
91
  ]=]
91
- function RxCharacterUtils.observeIsOfLocalCharacterBrio(instance: Instance)
92
+ function RxCharacterUtils.observeIsOfLocalCharacterBrio(instance: Instance): Observable.Observable<Brio.Brio<boolean>>
92
93
  return RxCharacterUtils.observeIsOfLocalCharacter(instance):Pipe({
93
94
  RxBrioUtils.switchToBrio(function(value)
94
95
  return value
95
96
  end),
96
- })
97
+ }) :: any
97
98
  end
98
99
 
99
100
  --[=[
@@ -101,17 +102,17 @@ end
101
102
 
102
103
  @return Observable<Model>
103
104
  ]=]
104
- function RxCharacterUtils.observeLocalPlayerCharacter()
105
+ function RxCharacterUtils.observeLocalPlayerCharacter(): Observable.Observable<Model>
105
106
  return RxInstanceUtils.observeProperty(Players, "LocalPlayer"):Pipe({
106
- Rx.switchMap(function(player)
107
+ Rx.switchMap(function(player: Player?): any
107
108
  if player then
108
109
  return RxCharacterUtils.observeCharacter(player)
109
110
  else
110
111
  return Rx.of(nil)
111
112
  end
112
- end),
113
- Rx.distinct(),
114
- })
113
+ end) :: any,
114
+ Rx.distinct() :: any,
115
+ }) :: any
115
116
  end
116
117
 
117
118
  --[=[
@@ -119,12 +120,12 @@ end
119
120
  @param player Player
120
121
  @return Observable<Brio<Humanoid>>
121
122
  ]=]
122
- function RxCharacterUtils.observeLastHumanoidBrio(player: Player)
123
+ function RxCharacterUtils.observeLastHumanoidBrio(player: Player): Observable.Observable<Brio.Brio<Humanoid>>
123
124
  return RxCharacterUtils.observeLastCharacterBrio(player):Pipe({
124
- RxBrioUtils.switchMapBrio(function(character)
125
+ RxBrioUtils.switchMapBrio(function(character: Model)
125
126
  return RxInstanceUtils.observeLastNamedChildBrio(character, "Humanoid", "Humanoid")
126
- end),
127
- })
127
+ end) :: any,
128
+ }) :: any
128
129
  end
129
130
 
130
131
  --[[
@@ -134,7 +135,7 @@ end
134
135
  @param humanoid Humanoid
135
136
  @return Observable<Brio<Humanoid>>
136
137
  ]]
137
- local function observeHumanoidLifetimeAsBrio(humanoid: Humanoid)
138
+ local function observeHumanoidLifetimeAsBrio(humanoid: Humanoid): Observable.Observable<Brio.Brio<Humanoid>>
138
139
  return Observable.new(function(sub)
139
140
  local function onDeath()
140
141
  sub:Complete()
@@ -154,7 +155,7 @@ local function observeHumanoidLifetimeAsBrio(humanoid: Humanoid)
154
155
  onDeath()
155
156
  return nil
156
157
  end
157
- end)
158
+ end) :: any
158
159
  end
159
160
 
160
161
  --[=[
@@ -181,12 +182,12 @@ end
181
182
  @param player Player
182
183
  @return Observable<Brio<Humanoid>>
183
184
  ]=]
184
- function RxCharacterUtils.observeLastAliveHumanoidBrio(player: Player)
185
+ function RxCharacterUtils.observeLastAliveHumanoidBrio(player: Player): Observable.Observable<Brio.Brio<Humanoid>>
185
186
  return RxCharacterUtils.observeLastHumanoidBrio(player):Pipe({
186
187
  RxBrioUtils.switchMapBrio(function(humanoid)
187
188
  return observeHumanoidLifetimeAsBrio(humanoid)
188
- end),
189
- })
189
+ end) :: any,
190
+ }) :: any
190
191
  end
191
192
 
192
193
  return RxCharacterUtils
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  @class RxRootPartUtils
3
4
  ]=]
@@ -6,6 +7,8 @@ local require = require(script.Parent.loader).load(script)
6
7
 
7
8
  local RxInstanceUtils = require("RxInstanceUtils")
8
9
  local RxBrioUtils = require("RxBrioUtils")
10
+ local _Observable = require("Observable")
11
+ local _Brio = require("Brio")
9
12
 
10
13
  local RxRootPartUtils = {}
11
14
 
@@ -13,27 +16,27 @@ local RxRootPartUtils = {}
13
16
  Observes the last humanoid root part of a character
14
17
 
15
18
  @param character Model
16
- @return Brio<BasePart>
19
+ @return Observable<Brio<BasePart>>
17
20
  ]=]
18
- function RxRootPartUtils.observeHumanoidRootPartBrio(character: Model)
21
+ function RxRootPartUtils.observeHumanoidRootPartBrio(character: Model): _Observable.Observable<_Brio.Brio<BasePart>>
19
22
  -- let's make a reasonable assumption here about name not changing
20
23
  return RxInstanceUtils.observeChildrenBrio(character, function(part)
21
24
  return part:IsA("BasePart") and part.Name == "HumanoidRootPart"
22
- end)
25
+ end) :: any
23
26
  end
24
27
 
25
28
  --[=[
26
29
  Observes the last humanoid root part of a character
27
30
 
28
31
  @param humanoid Humanoid
29
- @return Brio<BasePart>
32
+ @return Observvable<Brio<BasePart>>
30
33
  ]=]
31
- function RxRootPartUtils.observeHumanoidRootPartBrioFromHumanoid(humanoid: Humanoid)
34
+ function RxRootPartUtils.observeHumanoidRootPartBrioFromHumanoid(humanoid: Humanoid): _Observable.Observable<_Brio.Brio<BasePart>>
32
35
  return RxInstanceUtils.observeParentBrio(humanoid):Pipe({
33
- RxBrioUtils.switchMapBrio(function(character)
36
+ RxBrioUtils.switchMapBrio(function(character: Model)
34
37
  return RxRootPartUtils.observeHumanoidRootPartBrio(character)
35
- end),
36
- })
38
+ end) :: any,
39
+ }) :: any
37
40
  end
38
41
 
39
42
  return RxRootPartUtils