@quenty/rbxthumb 1.0.1-canary.299.5bb1fa6.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 ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.1-canary.299.5bb1fa6.0 (2022-10-30)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add rbxthumb package ([19d94d3](https://github.com/Quenty/NevermoreEngine/commit/19d94d36755a560ae68081138286cffc25f134b3))
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2014-2022 Quenty
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ ## RbxThumb
2
+ <div align="center">
3
+ <a href="http://quenty.github.io/NevermoreEngine/">
4
+ <img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
5
+ </a>
6
+ <a href="https://discord.gg/mhtGUS8">
7
+ <img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
8
+ </a>
9
+ <a href="https://github.com/Quenty/NevermoreEngine/actions">
10
+ <img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
11
+ </a>
12
+ </div>
13
+
14
+ Wraps the rbxthumb URL api surface to generate a URL for a thumbnail on the cloud.
15
+
16
+ These thumbnails are automatically batched for performance.
17
+
18
+ <div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/RbxThumbUtils">View docs →</a></div>
19
+
20
+ ## Installation
21
+ ```
22
+ npm install @quenty/rbxthumb --save
23
+ ```
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "rbxthumb",
3
+ "tree": {
4
+ "$path": "src"
5
+ }
6
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@quenty/rbxthumb",
3
+ "version": "1.0.1-canary.299.5bb1fa6.0",
4
+ "description": "Wraps the rbxthumb URL api surface.",
5
+ "keywords": [
6
+ "Roblox",
7
+ "Nevermore",
8
+ "Lua",
9
+ "Thumbnail",
10
+ "rbxthumb"
11
+ ],
12
+ "bugs": {
13
+ "url": "https://github.com/Quenty/NevermoreEngine/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/Quenty/NevermoreEngine.git",
18
+ "directory": "src/rbxthumb/"
19
+ },
20
+ "funding": {
21
+ "type": "patreon",
22
+ "url": "https://www.patreon.com/quenty"
23
+ },
24
+ "license": "MIT",
25
+ "contributors": [
26
+ "Quenty"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "gitHead": "5bb1fa6256a59039e42cdc1b2433929c9b3e6adb"
32
+ }
@@ -0,0 +1,215 @@
1
+ --[=[
2
+ Wraps the rbxthumb URL api surface to generate a URL for a thumbnail on the cloud.
3
+
4
+ These thumbnails are automatically batched for performance.
5
+
6
+ @class RbxThumbUtils
7
+ ]=]
8
+
9
+ local RbxThumbUtils = {}
10
+
11
+ --[=[
12
+ Gets a thumbnail URL for a given content type and id
13
+
14
+ https://devforum.roblox.com/t/new-contentid-format-for-easy-thumbnail-loading/357335
15
+ https://create.roblox.com/docs/studio/asset-types#rbxthumb
16
+
17
+ Type: Supported Sizes:
18
+ "Asset" 150x150, 420x420
19
+ "Avatar" 100x100, 352x352, 720x720
20
+ "AvatarHeadShot" 48x48, 60x60, 150x150
21
+ "BadgeIcon" 150x150
22
+ "BundleThumbnail" 150x150, 420x420
23
+ "GameIcon" 50x50, 150x150
24
+ "GamePass" 150x150
25
+ "GroupIcon" 150x150, 420x420
26
+ "Outfit" 150x150, 420x420
27
+
28
+ @param thumbnailType ThumbnailType
29
+ @param targetId number
30
+ @param width number
31
+ @param height number
32
+ @return string
33
+ ]=]
34
+ function RbxThumbUtils.getThumbnailUrl(thumbnailType, targetId, width, height)
35
+ assert(type(thumbnailType) == "string", "Bad thumbnailType")
36
+ assert(type(targetId) == "number", "Bad targetId")
37
+ assert(type(width) == "number", "Bad width")
38
+ assert(type(height) == "number", "Bad height")
39
+
40
+ return string.format("rbxthumb://type=%s&id=%d&w=%d&h=%d", thumbnailType, targetId, width, height)
41
+ end
42
+
43
+ --[=[
44
+ Gets a Asset URL for use in an image label or other rendering application.
45
+
46
+ Supported sizes: 150x150, 420x420
47
+
48
+ @param targetId number
49
+ @param width number?
50
+ @param height number?
51
+ @return string
52
+ ]=]
53
+ function RbxThumbUtils.getAssetThumbnailUrl(targetId, width, height)
54
+ assert(type(targetId) == "number", "Bad targetId")
55
+
56
+ width = width or 150
57
+ height = height or 150
58
+
59
+ return RbxThumbUtils.getThumbnailUrl("Asset", targetId, width, height)
60
+ end
61
+
62
+ --[=[
63
+ Gets a Avatar URL for use in an image label or other rendering application.
64
+
65
+ Supported sizes: 100x100, 352x352, 720x720
66
+
67
+ @param targetId number
68
+ @param width number?
69
+ @param height number?
70
+ @return string
71
+ ]=]
72
+ function RbxThumbUtils.getAvatarThumbnailUrl(targetId, width, height)
73
+ assert(type(targetId) == "number", "Bad targetId")
74
+
75
+ width = width or 150
76
+ height = height or 150
77
+
78
+ return RbxThumbUtils.getThumbnailUrl("Avatar", targetId, width, height)
79
+ end
80
+
81
+ --[=[
82
+ Gets a AvatarHeadShot URL for use in an image label or other rendering application.
83
+
84
+ Supported sizes: 48x48, 60x60, 150x150
85
+
86
+ @param targetId number
87
+ @param width number?
88
+ @param height number?
89
+ @return string
90
+ ]=]
91
+ function RbxThumbUtils.getAvatarHeadShotThumbnailUrl(targetId, width, height)
92
+ assert(type(targetId) == "number", "Bad targetId")
93
+
94
+ width = width or 150
95
+ height = height or 150
96
+
97
+ return RbxThumbUtils.getThumbnailUrl("AvatarHeadShot", targetId, width, height)
98
+ end
99
+
100
+ --[=[
101
+ Gets a BadgeIcon URL for use in an image label or other rendering application.
102
+
103
+ Supported sizes: 150x150
104
+
105
+ @param targetId number
106
+ @param width number?
107
+ @param height number?
108
+ @return string
109
+ ]=]
110
+ function RbxThumbUtils.getBadgeIconThumbnailUrl(targetId, width, height)
111
+ assert(type(targetId) == "number", "Bad targetId")
112
+
113
+ width = width or 150
114
+ height = height or 150
115
+
116
+ return RbxThumbUtils.getThumbnailUrl("BadgeIcon", targetId, width, height)
117
+ end
118
+
119
+ --[=[
120
+ Gets a BundleThumbnail URL for use in an image label or other rendering application.
121
+
122
+ Supported sizes: 150x150, 420x420
123
+
124
+ @param targetId number
125
+ @param width number?
126
+ @param height number?
127
+ @return string
128
+ ]=]
129
+ function RbxThumbUtils.getBundleThumbnailThumbnailUrl(targetId, width, height)
130
+ assert(type(targetId) == "number", "Bad targetId")
131
+
132
+ width = width or 150
133
+ height = height or 150
134
+
135
+ return RbxThumbUtils.getThumbnailUrl("BundleThumbnail", targetId, width, height)
136
+ end
137
+
138
+ --[=[
139
+ Gets a GameIcon URL for use in an image label or other rendering application.
140
+
141
+ Supported sizes: 50x50, 150x150
142
+
143
+ @param targetId number
144
+ @param width number?
145
+ @param height number?
146
+ @return string
147
+ ]=]
148
+ function RbxThumbUtils.getGameIconThumbnailUrl(targetId, width, height)
149
+ assert(type(targetId) == "number", "Bad targetId")
150
+
151
+ width = width or 150
152
+ height = height or 150
153
+
154
+ return RbxThumbUtils.getThumbnailUrl("GameIcon", targetId, width, height)
155
+ end
156
+
157
+ --[=[
158
+ Gets a GamePass URL for use in an image label or other rendering application.
159
+
160
+ Supported sizes: 150x150
161
+
162
+ @param targetId number
163
+ @param width number?
164
+ @param height number?
165
+ @return string
166
+ ]=]
167
+ function RbxThumbUtils.getGamePassThumbnailUrl(targetId, width, height)
168
+ assert(type(targetId) == "number", "Bad targetId")
169
+
170
+ width = width or 150
171
+ height = height or 150
172
+
173
+ return RbxThumbUtils.getThumbnailUrl("GamePass", targetId, width, height)
174
+ end
175
+
176
+ --[=[
177
+ Gets a GroupIcon URL for use in an image label or other rendering application.
178
+
179
+ Supported sizes: 150x150, 420x420
180
+
181
+ @param targetId number
182
+ @param width number?
183
+ @param height number?
184
+ @return string
185
+ ]=]
186
+ function RbxThumbUtils.getGroupIconThumbnailUrl(targetId, width, height)
187
+ assert(type(targetId) == "number", "Bad targetId")
188
+
189
+ width = width or 150
190
+ height = height or 150
191
+
192
+ return RbxThumbUtils.getThumbnailUrl("GroupIcon", targetId, width, height)
193
+ end
194
+
195
+ --[=[
196
+ Gets a Outfit URL for use in an image label or other rendering application.
197
+
198
+ Supported sizes: 150x150, 420x420
199
+
200
+ @param targetId number
201
+ @param width number?
202
+ @param height number?
203
+ @return string
204
+ ]=]
205
+ function RbxThumbUtils.getOutfitThumbnailUrl(targetId, width, height)
206
+ assert(type(targetId) == "number", "Bad targetId")
207
+
208
+ width = width or 150
209
+ height = height or 150
210
+
211
+ return RbxThumbUtils.getThumbnailUrl("Outfit", targetId, width, height)
212
+ end
213
+
214
+
215
+ return RbxThumbUtils