@quenty/avatareditorutils 7.20.3 → 7.20.4-canary.11a5dcf.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
|
+
## [7.20.4-canary.11a5dcf.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/avatareditorutils@7.20.3...@quenty/avatareditorutils@7.20.4-canary.11a5dcf.0) (2025-05-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Additional type checking updates ([05ba29a](https://github.com/Quenty/NevermoreEngine/commit/05ba29a03efc9f3feed74b34f1d9dfb237496214))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [7.20.3](https://github.com/Quenty/NevermoreEngine/compare/@quenty/avatareditorutils@7.20.2...@quenty/avatareditorutils@7.20.3) (2025-04-10)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/avatareditorutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/avatareditorutils",
|
|
3
|
-
"version": "7.20.
|
|
3
|
+
"version": "7.20.4-canary.11a5dcf.0",
|
|
4
4
|
"description": "Provides utility functions to work with the Roblox AvatarEditorService",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/aggregator": "
|
|
29
|
-
"@quenty/brio": "
|
|
30
|
-
"@quenty/enumutils": "
|
|
31
|
-
"@quenty/loader": "
|
|
32
|
-
"@quenty/maid": "
|
|
33
|
-
"@quenty/memoize": "
|
|
34
|
-
"@quenty/observablecollection": "
|
|
35
|
-
"@quenty/pagesutils": "
|
|
36
|
-
"@quenty/promise": "
|
|
37
|
-
"@quenty/rx": "
|
|
38
|
-
"@quenty/servicebag": "
|
|
39
|
-
"@quenty/symbol": "
|
|
40
|
-
"@quenty/valueobject": "
|
|
28
|
+
"@quenty/aggregator": "1.4.4-canary.11a5dcf.0",
|
|
29
|
+
"@quenty/brio": "14.17.4-canary.11a5dcf.0",
|
|
30
|
+
"@quenty/enumutils": "3.4.2",
|
|
31
|
+
"@quenty/loader": "10.8.4-canary.11a5dcf.0",
|
|
32
|
+
"@quenty/maid": "3.4.4-canary.11a5dcf.0",
|
|
33
|
+
"@quenty/memoize": "1.6.4-canary.11a5dcf.0",
|
|
34
|
+
"@quenty/observablecollection": "12.20.4-canary.11a5dcf.0",
|
|
35
|
+
"@quenty/pagesutils": "5.11.5-canary.11a5dcf.0",
|
|
36
|
+
"@quenty/promise": "10.10.5-canary.11a5dcf.0",
|
|
37
|
+
"@quenty/rx": "13.17.4-canary.11a5dcf.0",
|
|
38
|
+
"@quenty/servicebag": "11.11.5-canary.11a5dcf.0",
|
|
39
|
+
"@quenty/symbol": "3.4.3-canary.11a5dcf.0",
|
|
40
|
+
"@quenty/valueobject": "13.17.4-canary.11a5dcf.0"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "11a5dcf7d4c7a0bfbf3337e97d30e8346ea09d3f"
|
|
46
46
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
@class AvatarEditorInventory
|
|
3
4
|
]=]
|
|
@@ -5,26 +6,49 @@
|
|
|
5
6
|
local require = require(script.Parent.loader).load(script)
|
|
6
7
|
|
|
7
8
|
local BaseObject = require("BaseObject")
|
|
9
|
+
local Observable = require("Observable")
|
|
8
10
|
local ObservableMap = require("ObservableMap")
|
|
9
|
-
local Rx = require("Rx")
|
|
10
11
|
local PagesUtils = require("PagesUtils")
|
|
11
12
|
local Promise = require("Promise")
|
|
13
|
+
local Rx = require("Rx")
|
|
12
14
|
|
|
13
15
|
local AvatarEditorInventory = setmetatable({}, BaseObject)
|
|
14
16
|
AvatarEditorInventory.ClassName = "AvatarEditorInventory"
|
|
15
17
|
AvatarEditorInventory.__index = AvatarEditorInventory
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
export type AssetData = unknown
|
|
20
|
+
|
|
21
|
+
export type AvatarEditorInventory = typeof(setmetatable(
|
|
22
|
+
{} :: {
|
|
23
|
+
_assetIdToAsset: ObservableMap.ObservableMap<number, AssetData>,
|
|
24
|
+
},
|
|
25
|
+
{} :: typeof({ __index = AvatarEditorInventory })
|
|
26
|
+
)) & BaseObject.BaseObject
|
|
27
|
+
|
|
28
|
+
--[=[
|
|
29
|
+
Constructs a new AvatarEditorInventory
|
|
30
|
+
|
|
31
|
+
@return AvatarEditorInventory
|
|
32
|
+
]=]
|
|
33
|
+
function AvatarEditorInventory.new(): AvatarEditorInventory
|
|
34
|
+
local self: AvatarEditorInventory = setmetatable(BaseObject.new() :: any, AvatarEditorInventory)
|
|
19
35
|
|
|
20
36
|
self._assetIdToAsset = self._maid:Add(ObservableMap.new())
|
|
21
37
|
|
|
22
38
|
return self
|
|
23
39
|
end
|
|
24
40
|
|
|
25
|
-
|
|
41
|
+
--[=[
|
|
42
|
+
Processes the pages and stores the asset data in the inventory.
|
|
43
|
+
@param inventoryPages Pages
|
|
44
|
+
@return Promise.Promise<()>
|
|
45
|
+
]=]
|
|
46
|
+
function AvatarEditorInventory.PromiseProcessPages(
|
|
47
|
+
self: AvatarEditorInventory,
|
|
48
|
+
inventoryPages: Pages
|
|
49
|
+
): Promise.Promise<()>
|
|
26
50
|
return Promise.spawn(function(resolve, reject)
|
|
27
|
-
local pageData = inventoryPages:GetCurrentPage()
|
|
51
|
+
local pageData: any = inventoryPages:GetCurrentPage()
|
|
28
52
|
while pageData do
|
|
29
53
|
for _, data in pageData do
|
|
30
54
|
self._assetIdToAsset:Set(data.AssetId, data)
|
|
@@ -46,18 +70,31 @@ function AvatarEditorInventory:PromiseProcessPages(inventoryPages: Pages)
|
|
|
46
70
|
end)
|
|
47
71
|
end
|
|
48
72
|
|
|
49
|
-
|
|
73
|
+
--[=[
|
|
74
|
+
Returns the asset data for the given assetId.
|
|
75
|
+
@param assetId number
|
|
76
|
+
@return boolean
|
|
77
|
+
]=]
|
|
78
|
+
function AvatarEditorInventory.IsAssetIdInInventory(self: AvatarEditorInventory, assetId: number): boolean
|
|
50
79
|
return self._assetIdToAsset:Get(assetId) ~= nil
|
|
51
80
|
end
|
|
52
81
|
|
|
53
|
-
|
|
82
|
+
--[=[
|
|
83
|
+
Observes the assetId in the inventory. Returns true if it is in the inventory.
|
|
84
|
+
@param assetId number
|
|
85
|
+
@return Observable<AssetData>
|
|
86
|
+
]=]
|
|
87
|
+
function AvatarEditorInventory.ObserveAssetIdInInventory(
|
|
88
|
+
self: AvatarEditorInventory,
|
|
89
|
+
assetId: number
|
|
90
|
+
): Observable.Observable<AssetData>
|
|
54
91
|
assert(type(assetId) == "number", "Bad assetId")
|
|
55
92
|
|
|
56
93
|
return self._assetIdToAsset:ObserveAtKey(assetId):Pipe({
|
|
57
94
|
Rx.map(function(data)
|
|
58
95
|
return data ~= nil
|
|
59
|
-
end)
|
|
60
|
-
})
|
|
96
|
+
end) :: any,
|
|
97
|
+
}) :: any
|
|
61
98
|
end
|
|
62
99
|
|
|
63
|
-
return AvatarEditorInventory
|
|
100
|
+
return AvatarEditorInventory
|
|
@@ -11,15 +11,15 @@ local AvatarEditorUtils = require("AvatarEditorUtils")
|
|
|
11
11
|
local EnumUtils = require("EnumUtils")
|
|
12
12
|
local Maid = require("Maid")
|
|
13
13
|
local MemorizeUtils = require("MemorizeUtils")
|
|
14
|
+
local PagesProxy = require("PagesProxy")
|
|
14
15
|
local Promise = require("Promise")
|
|
16
|
+
local ServiceBag = require("ServiceBag")
|
|
15
17
|
local ValueObject = require("ValueObject")
|
|
16
|
-
local PagesProxy = require("PagesProxy")
|
|
17
|
-
local _ServiceBag = require("ServiceBag")
|
|
18
18
|
|
|
19
19
|
local AvatarEditorInventoryServiceClient = {}
|
|
20
20
|
AvatarEditorInventoryServiceClient.ServiceName = "AvatarEditorInventoryServiceClient"
|
|
21
21
|
|
|
22
|
-
function AvatarEditorInventoryServiceClient:Init(serviceBag:
|
|
22
|
+
function AvatarEditorInventoryServiceClient:Init(serviceBag: ServiceBag.ServiceBag)
|
|
23
23
|
assert(not self._serviceBag, "Already initialized")
|
|
24
24
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
25
25
|
self._maid = Maid.new()
|
|
@@ -34,15 +34,14 @@ function AvatarEditorInventoryServiceClient:Init(serviceBag: _ServiceBag.Service
|
|
|
34
34
|
end))
|
|
35
35
|
|
|
36
36
|
self._promiseInventoryPages = MemorizeUtils.memoize(function(avatarAssetTypes)
|
|
37
|
-
return AvatarEditorUtils.promiseInventoryPages(avatarAssetTypes)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end)
|
|
37
|
+
return AvatarEditorUtils.promiseInventoryPages(avatarAssetTypes):Then(function(catalogPages)
|
|
38
|
+
-- Allow for replay
|
|
39
|
+
return PagesProxy.new(catalogPages)
|
|
40
|
+
end)
|
|
42
41
|
end)
|
|
43
42
|
end
|
|
44
43
|
|
|
45
|
-
function AvatarEditorInventoryServiceClient:PromiseInventoryPages(avatarAssetTypes)
|
|
44
|
+
function AvatarEditorInventoryServiceClient:PromiseInventoryPages(avatarAssetTypes: Enum.AvatarAssetType)
|
|
46
45
|
return self:PromiseEnsureAccess()
|
|
47
46
|
:Then(function()
|
|
48
47
|
return self._promiseInventoryPages(avatarAssetTypes)
|
|
@@ -52,7 +51,7 @@ function AvatarEditorInventoryServiceClient:PromiseInventoryPages(avatarAssetTyp
|
|
|
52
51
|
end)
|
|
53
52
|
end
|
|
54
53
|
|
|
55
|
-
function AvatarEditorInventoryServiceClient:PromiseInventoryForAvatarAssetType(avatarAssetType)
|
|
54
|
+
function AvatarEditorInventoryServiceClient:PromiseInventoryForAvatarAssetType(avatarAssetType: Enum.AvatarAssetType)
|
|
56
55
|
assert(EnumUtils.isOfType(Enum.AvatarAssetType, avatarAssetType), "Bad avatarAssetType")
|
|
57
56
|
|
|
58
57
|
if self._assetTypeToInventoryPromises[avatarAssetType] then
|
|
@@ -62,7 +61,7 @@ function AvatarEditorInventoryServiceClient:PromiseInventoryForAvatarAssetType(a
|
|
|
62
61
|
local inventory = self._maid:Add(AvatarEditorInventory.new())
|
|
63
62
|
|
|
64
63
|
self._assetTypeToInventoryPromises[avatarAssetType] = AvatarEditorUtils.promiseInventoryPages({
|
|
65
|
-
avatarAssetType
|
|
64
|
+
avatarAssetType,
|
|
66
65
|
})
|
|
67
66
|
:Then(function(inventoryPages)
|
|
68
67
|
return inventory:PromiseProcessPages(inventoryPages)
|
|
@@ -74,7 +73,7 @@ function AvatarEditorInventoryServiceClient:PromiseInventoryForAvatarAssetType(a
|
|
|
74
73
|
return self._assetTypeToInventoryPromises[avatarAssetType]
|
|
75
74
|
end
|
|
76
75
|
|
|
77
|
-
function AvatarEditorInventoryServiceClient:IsInventoryAccessAllowed()
|
|
76
|
+
function AvatarEditorInventoryServiceClient:IsInventoryAccessAllowed(): boolean
|
|
78
77
|
return self._isAccessAllowed.Value
|
|
79
78
|
end
|
|
80
79
|
|
|
@@ -82,7 +81,7 @@ function AvatarEditorInventoryServiceClient:ObserveIsInventoryAccessAllowed()
|
|
|
82
81
|
return self._isAccessAllowed:Observe()
|
|
83
82
|
end
|
|
84
83
|
|
|
85
|
-
function AvatarEditorInventoryServiceClient:PromiseEnsureAccess()
|
|
84
|
+
function AvatarEditorInventoryServiceClient:PromiseEnsureAccess(): Promise.Promise<()>
|
|
86
85
|
if self._isAccessAllowed.Value then
|
|
87
86
|
return Promise.resolved()
|
|
88
87
|
end
|
|
@@ -108,4 +107,4 @@ function AvatarEditorInventoryServiceClient:Destroy()
|
|
|
108
107
|
self._maid:DoCleaning()
|
|
109
108
|
end
|
|
110
109
|
|
|
111
|
-
return AvatarEditorInventoryServiceClient
|
|
110
|
+
return AvatarEditorInventoryServiceClient
|
|
@@ -184,7 +184,9 @@ end
|
|
|
184
184
|
@param humanoidDescription HumanoidDescription
|
|
185
185
|
@return Promise<HumanoidDescription?>
|
|
186
186
|
]=]
|
|
187
|
-
function AvatarEditorUtils.promiseCheckApplyDefaultClothing(
|
|
187
|
+
function AvatarEditorUtils.promiseCheckApplyDefaultClothing(
|
|
188
|
+
humanoidDescription: HumanoidDescription
|
|
189
|
+
): Promise.Promise<HumanoidDescription?>
|
|
188
190
|
assert(
|
|
189
191
|
typeof(humanoidDescription) == "Instance" and humanoidDescription:IsA("HumanoidDescription"),
|
|
190
192
|
"Bad humanoidDescription"
|
|
@@ -526,7 +528,7 @@ end
|
|
|
526
528
|
|
|
527
529
|
@return Promise<AvatarPromptResult>
|
|
528
530
|
]=]
|
|
529
|
-
function AvatarEditorUtils.promptAllowInventoryReadAccess()
|
|
531
|
+
function AvatarEditorUtils.promptAllowInventoryReadAccess(): Promise.Promise<()>
|
|
530
532
|
local maid = Maid.new()
|
|
531
533
|
|
|
532
534
|
local promise = Promise.new()
|
|
@@ -763,7 +765,11 @@ end
|
|
|
763
765
|
@param rigType HumanoidRigType
|
|
764
766
|
@return Promise<AvatarPromptResult>
|
|
765
767
|
]=]
|
|
766
|
-
function AvatarEditorUtils.promptUpdateOutfit(
|
|
768
|
+
function AvatarEditorUtils.promptUpdateOutfit(
|
|
769
|
+
outfitId: number,
|
|
770
|
+
updatedOutfit: HumanoidDescription,
|
|
771
|
+
rigType: Enum.HumanoidRigType
|
|
772
|
+
)
|
|
767
773
|
assert(type(outfitId) == "number", "Bad outfitId")
|
|
768
774
|
assert(typeof(updatedOutfit) == "Instance" and updatedOutfit:IsA("HumanoidDescription"), "Bad updatedOutfit")
|
|
769
775
|
assert(EnumUtils.isOfType(Enum.HumanoidRigType, rigType), "Bad rigType")
|
|
@@ -776,13 +782,15 @@ function AvatarEditorUtils.promptUpdateOutfit(outfitId: number, updatedOutfit: H
|
|
|
776
782
|
maid:DoCleaning()
|
|
777
783
|
end)
|
|
778
784
|
|
|
779
|
-
maid:GiveTask(
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
785
|
+
maid:GiveTask(
|
|
786
|
+
AvatarEditorService.PromptUpdateOutfitCompleted:Connect(function(avatarPromptResult: Enum.AvatarPromptResult)
|
|
787
|
+
if avatarPromptResult == Enum.AvatarPromptResult.Success then
|
|
788
|
+
promise:Resolve(avatarPromptResult)
|
|
789
|
+
else
|
|
790
|
+
promise:Reject(avatarPromptResult)
|
|
791
|
+
end
|
|
792
|
+
end)
|
|
793
|
+
)
|
|
786
794
|
|
|
787
795
|
local ok, err = pcall(function()
|
|
788
796
|
AvatarEditorService:PromptUpdateOutfit(outfitId, updatedOutfit, rigType)
|
|
@@ -795,4 +803,4 @@ function AvatarEditorUtils.promptUpdateOutfit(outfitId: number, updatedOutfit: H
|
|
|
795
803
|
return promise
|
|
796
804
|
end
|
|
797
805
|
|
|
798
|
-
return AvatarEditorUtils
|
|
806
|
+
return AvatarEditorUtils
|
|
@@ -4,27 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
local require = require(script.Parent.loader).load(script)
|
|
6
6
|
|
|
7
|
-
local MemorizeUtils = require("MemorizeUtils")
|
|
8
|
-
local AvatarEditorUtils = require("AvatarEditorUtils")
|
|
9
7
|
local Aggregator = require("Aggregator")
|
|
8
|
+
local AvatarEditorUtils = require("AvatarEditorUtils")
|
|
10
9
|
local Maid = require("Maid")
|
|
10
|
+
local MemorizeUtils = require("MemorizeUtils")
|
|
11
11
|
local PagesProxy = require("PagesProxy")
|
|
12
|
-
local
|
|
12
|
+
local ServiceBag = require("ServiceBag")
|
|
13
13
|
|
|
14
14
|
local CatalogSearchServiceCache = {}
|
|
15
15
|
CatalogSearchServiceCache.ServiceName = "CatalogSearchServiceCache"
|
|
16
16
|
|
|
17
|
-
function CatalogSearchServiceCache:Init(serviceBag:
|
|
17
|
+
function CatalogSearchServiceCache:Init(serviceBag: ServiceBag.ServiceBag)
|
|
18
18
|
assert(not self._serviceBag, "Already initialized")
|
|
19
19
|
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
20
20
|
self._maid = Maid.new()
|
|
21
21
|
|
|
22
22
|
-- TODO: If you scroll down long enough this leaks memory
|
|
23
23
|
self._promiseSearchCatalog = MemorizeUtils.memoize(function(params)
|
|
24
|
-
return AvatarEditorUtils.promiseSearchCatalog(params)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end)
|
|
24
|
+
return AvatarEditorUtils.promiseSearchCatalog(params):Then(function(catalogPages)
|
|
25
|
+
return PagesProxy.new(catalogPages)
|
|
26
|
+
end)
|
|
28
27
|
end)
|
|
29
28
|
|
|
30
29
|
self._assetAggregator = self._maid:Add(Aggregator.new("AvatarEditorUtils.promiseBatchItemDetails", function(itemIds)
|
|
@@ -32,9 +31,10 @@ function CatalogSearchServiceCache:Init(serviceBag: _ServiceBag.ServiceBag)
|
|
|
32
31
|
end))
|
|
33
32
|
self._assetAggregator:SetMaxBatchSize(100)
|
|
34
33
|
|
|
35
|
-
self._bundleAggregator =
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
self._bundleAggregator =
|
|
35
|
+
self._maid:Add(Aggregator.new("AvatarEditorUtils.promiseBatchItemDetails", function(itemIds)
|
|
36
|
+
return AvatarEditorUtils.promiseBatchItemDetails(itemIds, Enum.AvatarItemType.Bundle)
|
|
37
|
+
end))
|
|
38
38
|
self._bundleAggregator:SetMaxBatchSize(100)
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -58,14 +58,13 @@ function CatalogSearchServiceCache:PromiseItemDetails(assetId, avatarItemType)
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
function CatalogSearchServiceCache:PromiseSearchCatalog(params)
|
|
61
|
-
return self._promiseSearchCatalog(params)
|
|
62
|
-
:
|
|
63
|
-
|
|
64
|
-
end)
|
|
61
|
+
return self._promiseSearchCatalog(params):Then(function(pagesProxy)
|
|
62
|
+
return pagesProxy:Clone()
|
|
63
|
+
end)
|
|
65
64
|
end
|
|
66
65
|
|
|
67
66
|
function CatalogSearchServiceCache:Destroy()
|
|
68
67
|
self._maid:DoCleaning()
|
|
69
68
|
end
|
|
70
69
|
|
|
71
|
-
return CatalogSearchServiceCache
|
|
70
|
+
return CatalogSearchServiceCache
|