@quenty/friendutils 12.17.0-canary.544.de8fcee.0 → 12.17.1-canary.545.2374fb2.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.
- package/CHANGELOG.md +20 -1
- package/package.json +7 -7
- package/src/Shared/FriendUtils.lua +31 -26
- package/src/Shared/RxFriendUtils.lua +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,26 @@
|
|
|
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
|
-
|
|
6
|
+
## [12.17.1-canary.545.2374fb2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@12.17.0...@quenty/friendutils@12.17.1-canary.545.2374fb2.0) (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
|
+
|
|
17
|
+
# [12.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@12.16.2...@quenty/friendutils@12.17.0) (2025-04-02)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @quenty/friendutils
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [12.16.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/friendutils@12.16.1...@quenty/friendutils@12.16.2) (2025-03-31)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @quenty/friendutils
|
|
9
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/friendutils",
|
|
3
|
-
"version": "12.17.
|
|
3
|
+
"version": "12.17.1-canary.545.2374fb2.0",
|
|
4
4
|
"description": "Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/brio": "14.17.
|
|
29
|
-
"@quenty/loader": "10.8.0",
|
|
30
|
-
"@quenty/maid": "3.4.0",
|
|
31
|
-
"@quenty/promise": "10.10.
|
|
32
|
-
"@quenty/rx": "13.17.
|
|
28
|
+
"@quenty/brio": "14.17.1-canary.545.2374fb2.0",
|
|
29
|
+
"@quenty/loader": "10.8.1-canary.545.2374fb2.0",
|
|
30
|
+
"@quenty/maid": "3.4.1-canary.545.2374fb2.0",
|
|
31
|
+
"@quenty/promise": "10.10.2-canary.545.2374fb2.0",
|
|
32
|
+
"@quenty/rx": "13.17.1-canary.545.2374fb2.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "2374fb2b043cfbe0e9b507b3316eec46a4e353a0"
|
|
38
38
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier.
|
|
3
4
|
@class FriendUtils
|
|
@@ -19,6 +20,12 @@ local FriendUtils = {}
|
|
|
19
20
|
.IsOnline bool -- If the friend is currently online
|
|
20
21
|
@within FriendUtils
|
|
21
22
|
]=]
|
|
23
|
+
export type FriendData = {
|
|
24
|
+
Id: number,
|
|
25
|
+
Username: string,
|
|
26
|
+
DisplayName: string,
|
|
27
|
+
IsOnline: boolean,
|
|
28
|
+
}
|
|
22
29
|
|
|
23
30
|
--[=[
|
|
24
31
|
Returns the current studio users friends
|
|
@@ -31,9 +38,8 @@ local FriendUtils = {}
|
|
|
31
38
|
```
|
|
32
39
|
@return Promise<{ FriendData }>
|
|
33
40
|
]=]
|
|
34
|
-
function FriendUtils.promiseAllStudioFriends()
|
|
35
|
-
return FriendUtils.promiseCurrentStudioUserId()
|
|
36
|
-
:Then(FriendUtils.promiseAllFriends)
|
|
41
|
+
function FriendUtils.promiseAllStudioFriends(): Promise.Promise<{ FriendData }>
|
|
42
|
+
return FriendUtils.promiseCurrentStudioUserId():Then(FriendUtils.promiseAllFriends)
|
|
37
43
|
end
|
|
38
44
|
|
|
39
45
|
--[=[
|
|
@@ -41,9 +47,9 @@ end
|
|
|
41
47
|
@param friends { FriendData }
|
|
42
48
|
@return { FriendData }
|
|
43
49
|
]=]
|
|
44
|
-
function FriendUtils.onlineFriends(friends)
|
|
50
|
+
function FriendUtils.onlineFriends(friends: { FriendData }): { FriendData }
|
|
45
51
|
local onlineFriends = {}
|
|
46
|
-
for _, friend in
|
|
52
|
+
for _, friend in friends do
|
|
47
53
|
if friend.IsOnline then
|
|
48
54
|
table.insert(onlineFriends, friend)
|
|
49
55
|
end
|
|
@@ -56,14 +62,14 @@ end
|
|
|
56
62
|
@param friends { FriendData }
|
|
57
63
|
@return { FriendData }
|
|
58
64
|
]=]
|
|
59
|
-
function FriendUtils.friendsNotInGame(friends)
|
|
65
|
+
function FriendUtils.friendsNotInGame(friends: { FriendData }): { FriendData }
|
|
60
66
|
local userIdsInGame = {}
|
|
61
|
-
for _, player in
|
|
67
|
+
for _, player in Players:GetPlayers() do
|
|
62
68
|
userIdsInGame[player.UserId] = true
|
|
63
69
|
end
|
|
64
70
|
|
|
65
71
|
local onlineFriends = {}
|
|
66
|
-
for _, friend in
|
|
72
|
+
for _, friend in friends do
|
|
67
73
|
if not userIdsInGame[friend.Id] then
|
|
68
74
|
table.insert(onlineFriends, friend)
|
|
69
75
|
end
|
|
@@ -77,26 +83,25 @@ end
|
|
|
77
83
|
@param limitMaxFriends number? -- Optional max friends
|
|
78
84
|
@return Promise<{ FriendData }>
|
|
79
85
|
]=]
|
|
80
|
-
function FriendUtils.promiseAllFriends(userId, limitMaxFriends)
|
|
86
|
+
function FriendUtils.promiseAllFriends(userId: number, limitMaxFriends: number?): Promise.Promise<{ FriendData }>
|
|
81
87
|
assert(userId, "Bad userId")
|
|
82
88
|
|
|
83
|
-
return FriendUtils.promiseFriendPages(userId)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
local users = {}
|
|
89
|
+
return FriendUtils.promiseFriendPages(userId):Then(function(pages)
|
|
90
|
+
return Promise.spawn(function(resolve, _)
|
|
91
|
+
local users = {}
|
|
87
92
|
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
for userData in FriendUtils.iterateFriendsYielding(pages) do
|
|
94
|
+
table.insert(users, userData)
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
end
|
|
96
|
+
-- Exit quickly!
|
|
97
|
+
if limitMaxFriends and #users >= limitMaxFriends then
|
|
98
|
+
return resolve(users)
|
|
95
99
|
end
|
|
100
|
+
end
|
|
96
101
|
|
|
97
|
-
|
|
98
|
-
end)
|
|
102
|
+
return resolve(users)
|
|
99
103
|
end)
|
|
104
|
+
end)
|
|
100
105
|
end
|
|
101
106
|
|
|
102
107
|
--[=[
|
|
@@ -104,7 +109,7 @@ end
|
|
|
104
109
|
@param userId number
|
|
105
110
|
@return Promise<FriendPages>
|
|
106
111
|
]=]
|
|
107
|
-
function FriendUtils.promiseFriendPages(userId)
|
|
112
|
+
function FriendUtils.promiseFriendPages(userId: number): Promise.Promise<FriendPages>
|
|
108
113
|
assert(type(userId) == "number", "Bad userId")
|
|
109
114
|
|
|
110
115
|
return Promise.spawn(function(resolve, reject)
|
|
@@ -127,12 +132,12 @@ end
|
|
|
127
132
|
@param pages FriendPages
|
|
128
133
|
@return () => FrienData? -- Iterator
|
|
129
134
|
]=]
|
|
130
|
-
function FriendUtils.iterateFriendsYielding(pages)
|
|
135
|
+
function FriendUtils.iterateFriendsYielding(pages: FriendPages): () -> FriendData?
|
|
131
136
|
assert(pages, "Bad pages")
|
|
132
137
|
|
|
133
138
|
return coroutine.wrap(function()
|
|
134
139
|
while true do
|
|
135
|
-
for _, userData in
|
|
140
|
+
for _, userData in pages:GetCurrentPage() do
|
|
136
141
|
assert(type(userData.Id) == "number", "Bad userData.Id")
|
|
137
142
|
assert(type(userData.Username) == "string", "Bad userData.Username")
|
|
138
143
|
assert(type(userData.IsOnline) == "boolean", "Bad userData.IsOnline")
|
|
@@ -157,7 +162,7 @@ end
|
|
|
157
162
|
|
|
158
163
|
@return Promise<number>
|
|
159
164
|
]=]
|
|
160
|
-
function FriendUtils.promiseStudioServiceUserId()
|
|
165
|
+
function FriendUtils.promiseStudioServiceUserId(): Promise.Promise<number>
|
|
161
166
|
return Promise.new(function(resolve, reject)
|
|
162
167
|
local userId
|
|
163
168
|
local ok, err = pcall(function()
|
|
@@ -180,7 +185,7 @@ end
|
|
|
180
185
|
Gets the current studio user's user id.
|
|
181
186
|
@return Promise<number>
|
|
182
187
|
]=]
|
|
183
|
-
function FriendUtils.promiseCurrentStudioUserId()
|
|
188
|
+
function FriendUtils.promiseCurrentStudioUserId(): Promise.Promise<number>
|
|
184
189
|
return FriendUtils.promiseStudioServiceUserId()
|
|
185
190
|
:Catch(function(...)
|
|
186
191
|
warn(...)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Utilities for observing the local player's friends.
|
|
3
4
|
|
|
@@ -24,7 +25,7 @@ local RxFriendUtils = {}
|
|
|
24
25
|
@param player Player?
|
|
25
26
|
@return Observable<Brio<Player>>
|
|
26
27
|
]=]
|
|
27
|
-
function RxFriendUtils.observeFriendsInServerAsBrios(player: Player?)
|
|
28
|
+
function RxFriendUtils.observeFriendsInServerAsBrios(player: Player?): Observable.Observable<Brio.Brio<Player>>
|
|
28
29
|
player = player or Players.LocalPlayer
|
|
29
30
|
|
|
30
31
|
assert(typeof(player) == "Instance", "Bad player")
|
|
@@ -37,7 +38,7 @@ function RxFriendUtils.observeFriendsInServerAsBrios(player: Player?)
|
|
|
37
38
|
return Observable.new(function(sub)
|
|
38
39
|
local maid = Maid.new()
|
|
39
40
|
|
|
40
|
-
local function handleFriendState(otherPlayer: Player, isFriendsWith)
|
|
41
|
+
local function handleFriendState(otherPlayer: Player, isFriendsWith: boolean)
|
|
41
42
|
if otherPlayer == Players.LocalPlayer then
|
|
42
43
|
return
|
|
43
44
|
end
|
|
@@ -105,7 +106,7 @@ function RxFriendUtils.observeFriendsInServerAsBrios(player: Player?)
|
|
|
105
106
|
end
|
|
106
107
|
|
|
107
108
|
return maid
|
|
108
|
-
end)
|
|
109
|
+
end) :: any
|
|
109
110
|
end
|
|
110
111
|
|
|
111
112
|
return RxFriendUtils
|