@quenty/textserviceutils 13.18.0 → 13.18.1-canary.545.2374fb2.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
+ ## [13.18.1-canary.545.2374fb2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@13.18.0...@quenty/textserviceutils@13.18.1-canary.545.2374fb2.0) (2025-04-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
12
+
13
+
14
+
15
+
16
+
6
17
  # [13.18.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/textserviceutils@13.17.2...@quenty/textserviceutils@13.18.0) (2025-04-02)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/textserviceutils
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/textserviceutils",
3
- "version": "13.18.0",
3
+ "version": "13.18.1-canary.545.2374fb2.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": "^12.18.0",
34
- "@quenty/loader": "^10.8.0",
35
- "@quenty/promise": "^10.10.1",
36
- "@quenty/rx": "^13.17.0"
33
+ "@quenty/blend": "12.18.1-canary.545.2374fb2.0",
34
+ "@quenty/loader": "10.8.1-canary.545.2374fb2.0",
35
+ "@quenty/promise": "10.10.2-canary.545.2374fb2.0",
36
+ "@quenty/rx": "13.17.1-canary.545.2374fb2.0"
37
37
  },
38
- "gitHead": "e8ea56930e65322fcffc05a1556d5df988068f0b"
38
+ "gitHead": "2374fb2b043cfbe0e9b507b3316eec46a4e353a0"
39
39
  }
@@ -1,14 +1,16 @@
1
+ --!strict
1
2
  --[=[
2
3
  @class TextServiceUtils
3
4
  ]=]
4
5
 
5
- local TextService = game:GetService("TextService")
6
-
7
6
  local require = require(script.Parent.loader).load(script)
8
7
 
8
+ local TextService = game:GetService("TextService")
9
+
9
10
  local Blend = require("Blend")
10
11
  local Promise = require("Promise")
11
12
  local Rx = require("Rx")
13
+ local _Observable = require("Observable")
12
14
 
13
15
  local TextServiceUtils = {}
14
16
 
@@ -22,9 +24,9 @@ local TextServiceUtils = {}
22
24
  @param textLabel TextLabel
23
25
  @param text string
24
26
  @param maxWidth number
25
- @return Promise<Vector2>
27
+ @return Vector2
26
28
  ]=]
27
- function TextServiceUtils.getSizeForLabel(textLabel, text, maxWidth)
29
+ function TextServiceUtils.getSizeForLabel(textLabel: TextLabel, text: string, maxWidth: number?): Vector2
28
30
  assert(typeof(textLabel) == "Instance", "Bad textLabel")
29
31
  assert(type(text) == "string", "Bad text")
30
32
 
@@ -34,15 +36,13 @@ function TextServiceUtils.getSizeForLabel(textLabel, text, maxWidth)
34
36
  return TextService:GetTextSize(text, textLabel.TextSize, textLabel.Font, Vector2.new(maxWidth, 1e6))
35
37
  end
36
38
 
37
-
38
-
39
39
  --[=[
40
40
  Promises the text bounds for the given parameters
41
41
 
42
42
  @param params GetTextBoundsParams
43
43
  @return Promise<Vector2>
44
44
  ]=]
45
- function TextServiceUtils.promiseTextBounds(params)
45
+ function TextServiceUtils.promiseTextBounds(params: GetTextBoundsParams): Promise.Promise<Vector2>
46
46
  assert(typeof(params) == "Instance" and params:IsA("GetTextBoundsParams"), "Bad params")
47
47
 
48
48
  return Promise.spawn(function(resolve, reject)
@@ -59,6 +59,15 @@ function TextServiceUtils.promiseTextBounds(params)
59
59
  end)
60
60
  end
61
61
 
62
+ export type Props = {
63
+ Text: string | Instance,
64
+ TextSize: number,
65
+ Font: Enum.Font?,
66
+ FontFace: Font?,
67
+ MaxSize: Vector2?,
68
+ LineHeight: number?,
69
+ }
70
+
62
71
  --[=[
63
72
  Observes the current size for the current props. The properties
64
73
  can be anything [Blend] would accept as an input. If FontFace is defined,
@@ -92,7 +101,7 @@ end
92
101
  @param props table
93
102
  @return Observable<Vector2> -- The text bounds reported
94
103
  ]=]
95
- function TextServiceUtils.observeSizeForLabelProps(props)
104
+ function TextServiceUtils.observeSizeForLabelProps(props: Props): _Observable.Observable<Vector2>
96
105
  assert(props.Text, "Bad props.Text")
97
106
  assert(props.TextSize, "Bad props.TextSize")
98
107
 
@@ -108,7 +117,7 @@ function TextServiceUtils.observeSizeForLabelProps(props)
108
117
  MaxSize = Blend.toPropertyObservable(props.MaxSize) or props.MaxSize or Vector2.new(1e6, 1e6),
109
118
  LineHeight = Blend.toPropertyObservable(props.LineHeight) or 1,
110
119
  }):Pipe({
111
- Rx.switchMap(function(state)
120
+ Rx.switchMap(function(state: any): any
112
121
  if typeof(state.FontFace) == "Font" then
113
122
  -- Yes, our font may have to stream in
114
123
  local params = Instance.new("GetTextBoundsParams")
@@ -119,15 +128,15 @@ function TextServiceUtils.observeSizeForLabelProps(props)
119
128
 
120
129
  return Rx.fromPromise(TextServiceUtils.promiseTextBounds(params))
121
130
  elseif typeof(state.Font) == "EnumItem" then
122
- local size = TextService:GetTextSize(state.Text, state.TextSize, state.Font, state.MaxSize)
131
+ local size: Vector2 = TextService:GetTextSize(state.Text, state.TextSize, state.Font, state.MaxSize)
123
132
 
124
- return Rx.of(Vector2.new(size.x, state.LineHeight*size.y))
133
+ return Rx.of(Vector2.new(size.X, state.LineHeight * size.Y))
125
134
  else
126
135
  warn("[TextServiceUtils.observeSizeForLabelProps] - Got neither FontFace or Font")
127
136
  return Rx.of(Vector2.zero)
128
137
  end
129
- end)
130
- })
138
+ end) :: any,
139
+ }) :: any
131
140
  end
132
141
 
133
142
  return TextServiceUtils