@quenty/contentproviderutils 7.0.0-canary.331.7eefa75.0 → 7.0.0-canary.367.e9fdcbc.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 +92 -1
- package/LICENSE.md +1 -1
- package/package.json +10 -4
- package/src/Client/ImageLabelLoaded.lua +143 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,98 @@
|
|
|
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.0.0-canary.
|
|
6
|
+
# [7.0.0-canary.367.e9fdcbc.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.10.0...@quenty/contentproviderutils@7.0.0-canary.367.e9fdcbc.0) (2023-06-05)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [6.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.9.0...@quenty/contentproviderutils@6.10.0) (2023-05-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* Fix dependencies ([67791a2](https://github.com/Quenty/NevermoreEngine/commit/67791a289c0956bf4947ac81bf792ee56496b3e8))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* Initial refactor of guis to use ValueObject instead of ValueObject ([723aba0](https://github.com/Quenty/NevermoreEngine/commit/723aba0208cae7e06c9d8bf2d8f0092d042d70ea))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [6.9.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.8.0...@quenty/contentproviderutils@6.9.0) (2023-05-08)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# [6.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.7.1...@quenty/contentproviderutils@6.8.0) (2023-04-10)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [6.7.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.7.0...@quenty/contentproviderutils@6.7.1) (2023-04-07)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# [6.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.6.0...@quenty/contentproviderutils@6.7.0) (2023-04-06)
|
|
55
|
+
|
|
56
|
+
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# [6.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.5.0...@quenty/contentproviderutils@6.6.0) (2023-04-03)
|
|
63
|
+
|
|
64
|
+
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# [6.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.4.0...@quenty/contentproviderutils@6.5.0) (2023-03-31)
|
|
71
|
+
|
|
72
|
+
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# [6.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.3.0...@quenty/contentproviderutils@6.4.0) (2023-03-06)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Features
|
|
82
|
+
|
|
83
|
+
* Add ImageLabelLoaded ([b24af97](https://github.com/Quenty/NevermoreEngine/commit/b24af97b56fb11edd8577598a44bbcacdb31e98e))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# [6.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.2.0...@quenty/contentproviderutils@6.3.0) (2023-03-05)
|
|
90
|
+
|
|
91
|
+
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
# [6.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/contentproviderutils@6.1.0...@quenty/contentproviderutils@6.2.0) (2023-02-27)
|
|
7
98
|
|
|
8
99
|
**Note:** Version bump only for package @quenty/contentproviderutils
|
|
9
100
|
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/contentproviderutils",
|
|
3
|
-
"version": "7.0.0-canary.
|
|
3
|
+
"version": "7.0.0-canary.367.e9fdcbc.0",
|
|
4
4
|
"description": "Utility functions to ensure that content is preloaded (wrapping calls in promises)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -27,11 +27,17 @@
|
|
|
27
27
|
"Quenty"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@quenty/
|
|
31
|
-
"@quenty/
|
|
30
|
+
"@quenty/baseobject": "6.2.1",
|
|
31
|
+
"@quenty/instanceutils": "7.14.0",
|
|
32
|
+
"@quenty/loader": "6.2.1",
|
|
33
|
+
"@quenty/maid": "2.5.0",
|
|
34
|
+
"@quenty/promise": "6.5.0",
|
|
35
|
+
"@quenty/rx": "7.11.0",
|
|
36
|
+
"@quenty/signal": "2.4.0",
|
|
37
|
+
"@quenty/valueobject": "8.0.0-canary.367.e9fdcbc.0"
|
|
32
38
|
},
|
|
33
39
|
"publishConfig": {
|
|
34
40
|
"access": "public"
|
|
35
41
|
},
|
|
36
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "e9fdcbc6ea1d46e068bf42a08b833099e9005259"
|
|
37
43
|
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class ImageLabelLoaded
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local BaseObject = require("BaseObject")
|
|
8
|
+
local Promise = require("Promise")
|
|
9
|
+
local Signal = require("Signal")
|
|
10
|
+
local Maid = require("Maid")
|
|
11
|
+
local ContentProviderUtils = require("ContentProviderUtils")
|
|
12
|
+
local RxInstanceUtils = require("RxInstanceUtils")
|
|
13
|
+
local Rx = require("Rx")
|
|
14
|
+
local ValueObject = require("ValueObject")
|
|
15
|
+
|
|
16
|
+
local ImageLabelLoaded = setmetatable({}, BaseObject)
|
|
17
|
+
ImageLabelLoaded.ClassName = "ImageLabelLoaded"
|
|
18
|
+
ImageLabelLoaded.__index = ImageLabelLoaded
|
|
19
|
+
|
|
20
|
+
function ImageLabelLoaded.new()
|
|
21
|
+
local self = setmetatable(BaseObject.new(), ImageLabelLoaded)
|
|
22
|
+
|
|
23
|
+
self._isLoaded = ValueObject.new(false, "boolean")
|
|
24
|
+
self._maid:GiveTask(self._isLoaded)
|
|
25
|
+
|
|
26
|
+
self._defaultTimeout = 1
|
|
27
|
+
|
|
28
|
+
self._preloadImage = ValueObject.new(true, "boolean")
|
|
29
|
+
self._maid:GiveTask(self._preloadImage)
|
|
30
|
+
|
|
31
|
+
self.ImageChanged = Signal.new()
|
|
32
|
+
self._maid:GiveTask(self.ImageChanged)
|
|
33
|
+
|
|
34
|
+
return self
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
function ImageLabelLoaded:SetDefaultTimeout(defaultTimeout)
|
|
38
|
+
assert(type(defaultTimeout) == "number" or defaultTimeout == nil, "Bad defaultTimeout")
|
|
39
|
+
|
|
40
|
+
self._defaultTimeout = defaultTimeout
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
function ImageLabelLoaded:IsLoaded()
|
|
44
|
+
return self._isLoaded.Value
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
function ImageLabelLoaded:SetPreloadImage(preloadImage)
|
|
48
|
+
assert(type(preloadImage) == "boolean", "Bad preloadImage")
|
|
49
|
+
|
|
50
|
+
self._preloadImage.Value = preloadImage
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
function ImageLabelLoaded:PromiseLoaded(timeout)
|
|
54
|
+
assert(type(timeout) == "number" or timeout == nil, "Bad timeout")
|
|
55
|
+
|
|
56
|
+
local originalTimeout = timeout
|
|
57
|
+
timeout = timeout or self._defaultTimeout
|
|
58
|
+
|
|
59
|
+
if self._isLoaded.Value then
|
|
60
|
+
return Promise.resolved()
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
local promise = Promise.new()
|
|
64
|
+
|
|
65
|
+
local maid = Maid.new()
|
|
66
|
+
self._maid[promise] = maid
|
|
67
|
+
|
|
68
|
+
maid:GiveTask(self._isLoaded.Changed:Connect(function()
|
|
69
|
+
if self._isLoaded.Value then
|
|
70
|
+
promise:Resolve()
|
|
71
|
+
end
|
|
72
|
+
end))
|
|
73
|
+
|
|
74
|
+
maid:GiveTask(self.ImageChanged:Connect(function(isVisible)
|
|
75
|
+
if not isVisible then
|
|
76
|
+
promise:Reject()
|
|
77
|
+
end
|
|
78
|
+
end))
|
|
79
|
+
|
|
80
|
+
if timeout then
|
|
81
|
+
maid:GiveTask(task.delay(timeout, function()
|
|
82
|
+
if originalTimeout then
|
|
83
|
+
promise:Reject("[ImageLabelLoaded] - Failed to load image after default timeout time")
|
|
84
|
+
else
|
|
85
|
+
promise:Reject()
|
|
86
|
+
end
|
|
87
|
+
end))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
promise:Finally(function()
|
|
91
|
+
self._maid[promise] = nil
|
|
92
|
+
end)
|
|
93
|
+
|
|
94
|
+
return promise
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
function ImageLabelLoaded:SetImageLabel(imageLabel)
|
|
98
|
+
assert(typeof(imageLabel) == "Instance" and imageLabel:IsA("ImageLabel") or imageLabel == nil, "Bad imageLabel")
|
|
99
|
+
if self._imageLabel == imageLabel then
|
|
100
|
+
return
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
local maid = Maid.new()
|
|
104
|
+
|
|
105
|
+
self._imageLabel = imageLabel
|
|
106
|
+
|
|
107
|
+
if self._imageLabel then
|
|
108
|
+
self._isLoaded.Value = self._imageLabel.IsLoaded
|
|
109
|
+
|
|
110
|
+
maid:GiveTask(self._imageLabel:GetPropertyChangedSignal("IsLoaded"):Connect(function()
|
|
111
|
+
self._isLoaded.Value = self._imageLabel.IsLoaded
|
|
112
|
+
end))
|
|
113
|
+
|
|
114
|
+
-- Setup preloading as necessary
|
|
115
|
+
maid:GiveTask(self._preloadImage:Observe():Pipe({
|
|
116
|
+
Rx.switchMap(function(preload)
|
|
117
|
+
if preload then
|
|
118
|
+
return Rx.combineLatest({
|
|
119
|
+
isLoaded = self._isLoaded;
|
|
120
|
+
image = RxInstanceUtils.observeProperty(self._imageLabel, "Image");
|
|
121
|
+
})
|
|
122
|
+
else
|
|
123
|
+
return Rx.EMPTY
|
|
124
|
+
end
|
|
125
|
+
end);
|
|
126
|
+
}):Subscribe(function(state)
|
|
127
|
+
if not state.isLoaded and state.image ~= "" then
|
|
128
|
+
maid:GivePromise(ContentProviderUtils.promisePreload({self._imageLabel}))
|
|
129
|
+
:Then(function()
|
|
130
|
+
self._isLoaded.Value = true
|
|
131
|
+
end)
|
|
132
|
+
end
|
|
133
|
+
end))
|
|
134
|
+
else
|
|
135
|
+
self._isLoaded.Value = false
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
self.ImageChanged:Fire()
|
|
139
|
+
|
|
140
|
+
self._maid._imageLabelMaid = maid
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
return ImageLabelLoaded
|