@quenty/textserviceutils 8.0.0-canary.331.7eefa75.0 → 8.0.0-canary.367.903617a.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 +93 -1
- package/LICENSE.md +1 -1
- package/package.json +6 -6
- package/src/Shared/TextServiceUtils.lua +1 -75
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,99 @@
|
|
|
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
|
-
# [8.0.0-canary.
|
|
6
|
+
# [8.0.0-canary.367.903617a.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.20.0...@quenty/textserviceutils@8.0.0-canary.367.903617a.0) (2023-06-09)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [7.20.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.19.0...@quenty/textserviceutils@7.20.0) (2023-05-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* Initial refactor of guis to use ValueObject instead of ValueObject ([723aba0](https://github.com/Quenty/NevermoreEngine/commit/723aba0208cae7e06c9d8bf2d8f0092d042d70ea))
|
|
20
|
+
* Move rich text logic to a separate package and remove queuing mechanism ([6ffee1a](https://github.com/Quenty/NevermoreEngine/commit/6ffee1a8bcfa96a6734e1bd861f922f810b9bad5))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# [7.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.18.0...@quenty/textserviceutils@7.19.0) (2023-05-08)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# [7.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.17.1...@quenty/textserviceutils@7.18.0) (2023-04-10)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## [7.17.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.17.0...@quenty/textserviceutils@7.17.1) (2023-04-07)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# [7.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.16.0...@quenty/textserviceutils@7.17.0) (2023-04-06)
|
|
51
|
+
|
|
52
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# [7.16.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.15.0...@quenty/textserviceutils@7.16.0) (2023-04-03)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# [7.15.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.14.0...@quenty/textserviceutils@7.15.0) (2023-03-31)
|
|
67
|
+
|
|
68
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# [7.14.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.13.0...@quenty/textserviceutils@7.14.0) (2023-03-31)
|
|
75
|
+
|
|
76
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# [7.13.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.12.0...@quenty/textserviceutils@7.13.0) (2023-03-06)
|
|
83
|
+
|
|
84
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# [7.12.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.11.0...@quenty/textserviceutils@7.12.0) (2023-03-05)
|
|
91
|
+
|
|
92
|
+
**Note:** Version bump only for package @quenty/textserviceutils
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# [7.11.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@7.10.0...@quenty/textserviceutils@7.11.0) (2023-02-27)
|
|
7
99
|
|
|
8
100
|
**Note:** Version bump only for package @quenty/textserviceutils
|
|
9
101
|
|
package/LICENSE.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/textserviceutils",
|
|
3
|
-
"version": "8.0.0-canary.
|
|
3
|
+
"version": "8.0.0-canary.367.903617a.0",
|
|
4
4
|
"description": "Holds utilities involving the Roblox TextService and text fitting to size.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@quenty/blend": "7.0.0-canary.
|
|
34
|
-
"@quenty/loader": "6.1
|
|
35
|
-
"@quenty/promise": "
|
|
36
|
-
"@quenty/rx": "
|
|
33
|
+
"@quenty/blend": "7.0.0-canary.367.903617a.0",
|
|
34
|
+
"@quenty/loader": "6.2.1",
|
|
35
|
+
"@quenty/promise": "6.5.0",
|
|
36
|
+
"@quenty/rx": "7.11.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "903617ace784bce6cc7e0a15093ee50566bd9b54"
|
|
39
39
|
}
|
|
@@ -34,64 +34,7 @@ function TextServiceUtils.getSizeForLabel(textLabel, text, maxWidth)
|
|
|
34
34
|
return TextService:GetTextSize(text, textLabel.TextSize, textLabel.Font, Vector2.new(maxWidth, 1e6))
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
local queue = {}
|
|
38
|
-
local queueRunning = false
|
|
39
37
|
|
|
40
|
-
local function startQueueProcess()
|
|
41
|
-
if queueRunning then
|
|
42
|
-
return
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
queueRunning = true
|
|
46
|
-
|
|
47
|
-
task.spawn(function()
|
|
48
|
-
while #queue > 0 do
|
|
49
|
-
local data = table.remove(queue)
|
|
50
|
-
local startTime = os.clock()
|
|
51
|
-
|
|
52
|
-
local result = TextServiceUtils._promiseTextBounds(data.params)
|
|
53
|
-
local promiseTimeoutOrDone = Promise.new()
|
|
54
|
-
|
|
55
|
-
result:Then(function(v2)
|
|
56
|
-
task.spawn(function()
|
|
57
|
-
data.promise:Resolve(v2)
|
|
58
|
-
end)
|
|
59
|
-
|
|
60
|
-
promiseTimeoutOrDone:Resolve()
|
|
61
|
-
end)
|
|
62
|
-
|
|
63
|
-
local pendingTask = task.delay(5, function()
|
|
64
|
-
if data.promise:IsPending() then
|
|
65
|
-
warn("[TextServiceUtils] - Timed out promise while processing queue")
|
|
66
|
-
promiseTimeoutOrDone:Reject()
|
|
67
|
-
end
|
|
68
|
-
end)
|
|
69
|
-
|
|
70
|
-
local ok = promiseTimeoutOrDone:Yield()
|
|
71
|
-
|
|
72
|
-
-- Cancel our delayed task
|
|
73
|
-
pcall(function()
|
|
74
|
-
task.cancel(pendingTask)
|
|
75
|
-
end)
|
|
76
|
-
|
|
77
|
-
if not ok then
|
|
78
|
-
warn("[TextServiceUtils] - Requeuing entry")
|
|
79
|
-
table.insert(queue, data)
|
|
80
|
-
|
|
81
|
-
local timeElapsed = os.clock() - startTime
|
|
82
|
-
local remainingTime = 0.05 - timeElapsed
|
|
83
|
-
|
|
84
|
-
-- Yield incase we requeue very quickly
|
|
85
|
-
if remainingTime > 0 then
|
|
86
|
-
task.wait(remainingTime)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
queueRunning = false
|
|
93
|
-
end)
|
|
94
|
-
end
|
|
95
38
|
|
|
96
39
|
--[=[
|
|
97
40
|
Promises the text bounds for the given parameters
|
|
@@ -102,23 +45,6 @@ end
|
|
|
102
45
|
function TextServiceUtils.promiseTextBounds(params)
|
|
103
46
|
assert(typeof(params) == "Instance" and params:IsA("GetTextBoundsParams"), "Bad params")
|
|
104
47
|
|
|
105
|
-
-- https://devforum.roblox.com/t/calling-textservicegettextboundsasync-multiple-times-leads-to-requests-never-completing-thread-leaks/2083178
|
|
106
|
-
-- This is a hack to work around a Roblox bug.
|
|
107
|
-
|
|
108
|
-
local promise = Promise.new()
|
|
109
|
-
table.insert(queue, {
|
|
110
|
-
params = params;
|
|
111
|
-
promise = promise;
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
startQueueProcess();
|
|
115
|
-
|
|
116
|
-
return promise
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
function TextServiceUtils._promiseTextBounds(params)
|
|
120
|
-
assert(typeof(params) == "Instance" and params:IsA("GetTextBoundsParams"), "Bad params")
|
|
121
|
-
|
|
122
48
|
return Promise.spawn(function(resolve, reject)
|
|
123
49
|
local size
|
|
124
50
|
local ok, err = pcall(function()
|
|
@@ -198,7 +124,7 @@ function TextServiceUtils.observeSizeForLabelProps(props)
|
|
|
198
124
|
return Rx.of(Vector2.new(size.x, state.LineHeight*size.y))
|
|
199
125
|
else
|
|
200
126
|
warn("[TextServiceUtils.observeSizeForLabelProps] - Got neither FontFace or Font")
|
|
201
|
-
return Rx.of(Vector2.
|
|
127
|
+
return Rx.of(Vector2.zero)
|
|
202
128
|
end
|
|
203
129
|
end)
|
|
204
130
|
})
|