@quenty/rbxthumb 1.1.0 → 1.2.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 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
+ # [1.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/rbxthumb@1.1.0...@quenty/rbxthumb@1.2.0) (2023-02-27)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add RbxThumbUtils.avatarItemTypeToThumbnailType(avatarItemType) ([496f505](https://github.com/Quenty/NevermoreEngine/commit/496f5057b35e653ff5ef47e48330490644f8d6e4))
12
+
13
+
14
+
15
+
16
+
6
17
  # 1.1.0 (2022-10-30)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/rbxthumb",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Wraps the rbxthumb URL api surface.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -28,5 +28,9 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "14f4c0bcf449d395411ef413c38fd09669e5d6c0"
31
+ "dependencies": {
32
+ "@quenty/loader": "^6.1.0",
33
+ "@quenty/table": "^3.2.0"
34
+ },
35
+ "gitHead": "67ba3f581ff4eb7272de9607e578969ce9ae5a8e"
32
36
  }
@@ -6,6 +6,10 @@
6
6
  @class RbxThumbUtils
7
7
  ]=]
8
8
 
9
+ local require = require(script.Parent.loader).load(script)
10
+
11
+ local RbxThumbnailTypes = require("RbxThumbnailTypes")
12
+
9
13
  local RbxThumbUtils = {}
10
14
 
11
15
  --[=[
@@ -25,7 +29,7 @@ local RbxThumbUtils = {}
25
29
  "GroupIcon" 150x150, 420x420
26
30
  "Outfit" 150x150, 420x420
27
31
 
28
- @param thumbnailType ThumbnailType
32
+ @param thumbnailType RbxThumbnailTypes
29
33
  @param targetId number
30
34
  @param width number
31
35
  @param height number
@@ -40,6 +44,21 @@ function RbxThumbUtils.getThumbnailUrl(thumbnailType, targetId, width, height)
40
44
  return string.format("rbxthumb://type=%s&id=%d&w=%d&h=%d", thumbnailType, targetId, width, height)
41
45
  end
42
46
 
47
+ --[=[
48
+ Converts an AvatarItemType to a string thumbnailType for thumbnail generation
49
+ @param avatarItemType AvatarItemType
50
+ @return string
51
+ ]=]
52
+ function RbxThumbUtils.avatarItemTypeToThumbnailType(avatarItemType)
53
+ if avatarItemType == Enum.AvatarItemType.Asset then
54
+ return RbxThumbnailTypes.ASSET
55
+ elseif avatarItemType == Enum.AvatarItemType.Bundle then
56
+ return RbxThumbnailTypes.BUNDLE
57
+ else
58
+ error("Unknown avatarItemType")
59
+ end
60
+ end
61
+
43
62
  --[=[
44
63
  Gets a Asset URL for use in an image label or other rendering application.
45
64
 
@@ -56,7 +75,7 @@ function RbxThumbUtils.getAssetThumbnailUrl(targetId, width, height)
56
75
  width = width or 150
57
76
  height = height or 150
58
77
 
59
- return RbxThumbUtils.getThumbnailUrl("Asset", targetId, width, height)
78
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.ASSET, targetId, width, height)
60
79
  end
61
80
 
62
81
  --[=[
@@ -75,7 +94,7 @@ function RbxThumbUtils.getAvatarThumbnailUrl(targetId, width, height)
75
94
  width = width or 150
76
95
  height = height or 150
77
96
 
78
- return RbxThumbUtils.getThumbnailUrl("Avatar", targetId, width, height)
97
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.AVATAR, targetId, width, height)
79
98
  end
80
99
 
81
100
  --[=[
@@ -94,7 +113,7 @@ function RbxThumbUtils.getAvatarHeadShotThumbnailUrl(targetId, width, height)
94
113
  width = width or 150
95
114
  height = height or 150
96
115
 
97
- return RbxThumbUtils.getThumbnailUrl("AvatarHeadShot", targetId, width, height)
116
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.AVATAR_HEAD_SHOT, targetId, width, height)
98
117
  end
99
118
 
100
119
  --[=[
@@ -113,7 +132,7 @@ function RbxThumbUtils.getBadgeIconThumbnailUrl(targetId, width, height)
113
132
  width = width or 150
114
133
  height = height or 150
115
134
 
116
- return RbxThumbUtils.getThumbnailUrl("BadgeIcon", targetId, width, height)
135
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.BADGE, targetId, width, height)
117
136
  end
118
137
 
119
138
  --[=[
@@ -132,7 +151,7 @@ function RbxThumbUtils.getBundleThumbnailThumbnailUrl(targetId, width, height)
132
151
  width = width or 150
133
152
  height = height or 150
134
153
 
135
- return RbxThumbUtils.getThumbnailUrl("BundleThumbnail", targetId, width, height)
154
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.BUNDLE, targetId, width, height)
136
155
  end
137
156
 
138
157
  --[=[
@@ -151,7 +170,7 @@ function RbxThumbUtils.getGameIconThumbnailUrl(targetId, width, height)
151
170
  width = width or 150
152
171
  height = height or 150
153
172
 
154
- return RbxThumbUtils.getThumbnailUrl("GameIcon", targetId, width, height)
173
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.GAME_ICON, targetId, width, height)
155
174
  end
156
175
 
157
176
  --[=[
@@ -170,7 +189,7 @@ function RbxThumbUtils.getGamePassThumbnailUrl(targetId, width, height)
170
189
  width = width or 150
171
190
  height = height or 150
172
191
 
173
- return RbxThumbUtils.getThumbnailUrl("GamePass", targetId, width, height)
192
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.GAME_PASS, targetId, width, height)
174
193
  end
175
194
 
176
195
  --[=[
@@ -189,7 +208,7 @@ function RbxThumbUtils.getGroupIconThumbnailUrl(targetId, width, height)
189
208
  width = width or 150
190
209
  height = height or 150
191
210
 
192
- return RbxThumbUtils.getThumbnailUrl("GroupIcon", targetId, width, height)
211
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.GROUP_ICON, targetId, width, height)
193
212
  end
194
213
 
195
214
  --[=[
@@ -208,7 +227,7 @@ function RbxThumbUtils.getOutfitThumbnailUrl(targetId, width, height)
208
227
  width = width or 150
209
228
  height = height or 150
210
229
 
211
- return RbxThumbUtils.getThumbnailUrl("Outfit", targetId, width, height)
230
+ return RbxThumbUtils.getThumbnailUrl(RbxThumbnailTypes.OUTFIT, targetId, width, height)
212
231
  end
213
232
 
214
233
 
@@ -0,0 +1,20 @@
1
+ --[=[
2
+ Canonical RbxThumbnailTypes
3
+ @class RbxThumbnailTypes
4
+ ]=]
5
+
6
+ local require = require(script.Parent.loader).load(script)
7
+
8
+ local Table = require("Table")
9
+
10
+ return Table.readonly({
11
+ ASSET = "Asset";
12
+ AVATAR = "Avatar";
13
+ AVATAR_HEAD_SHOT = "AvatarHeadShot";
14
+ BADGE = "BadgeIcon";
15
+ BUNDLE = "BundleThumbnail";
16
+ GAME_ICON = "GameIcon";
17
+ GAME_PASS = "GamePass";
18
+ GROUP_ICON = "GroupIcon";
19
+ OUTFIT = "Outfit";
20
+ })