@quenty/linkutils 13.17.0 → 13.17.1
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 +11 -0
- package/package.json +8 -8
- package/src/Shared/LinkUtils.lua +20 -16
- package/src/Shared/RxLinkUtils.lua +22 -27
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.17.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/linkutils@13.17.0...@quenty/linkutils@13.17.1) (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.17.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/linkutils@13.16.2...@quenty/linkutils@13.17.0) (2025-04-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/linkutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/linkutils",
|
|
3
|
-
"version": "13.17.
|
|
3
|
+
"version": "13.17.1",
|
|
4
4
|
"description": "Utility functions for links. Links are object values pointing to other values!",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/brio": "^14.17.
|
|
29
|
-
"@quenty/instanceutils": "^13.17.
|
|
30
|
-
"@quenty/loader": "^10.8.
|
|
31
|
-
"@quenty/maid": "^3.4.
|
|
32
|
-
"@quenty/promise": "^10.10.
|
|
33
|
-
"@quenty/rx": "^13.17.
|
|
28
|
+
"@quenty/brio": "^14.17.1",
|
|
29
|
+
"@quenty/instanceutils": "^13.17.1",
|
|
30
|
+
"@quenty/loader": "^10.8.1",
|
|
31
|
+
"@quenty/maid": "^3.4.1",
|
|
32
|
+
"@quenty/promise": "^10.10.2",
|
|
33
|
+
"@quenty/rx": "^13.17.1"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
|
|
39
39
|
}
|
package/src/Shared/LinkUtils.lua
CHANGED
|
@@ -17,7 +17,7 @@ local LinkUtils = {}
|
|
|
17
17
|
@param to Instance
|
|
18
18
|
@return ObjectValue
|
|
19
19
|
]=]
|
|
20
|
-
function LinkUtils.createLink(linkName, from, to)
|
|
20
|
+
function LinkUtils.createLink(linkName: string, from: Instance, to: Instance): ObjectValue
|
|
21
21
|
assert(type(linkName) == "string", "Bad linkName")
|
|
22
22
|
assert(typeof(from) == "Instance", "Bad from")
|
|
23
23
|
assert(typeof(to) == "Instance", "Bad to")
|
|
@@ -37,13 +37,13 @@ end
|
|
|
37
37
|
@param from Instance
|
|
38
38
|
@return { Instance }
|
|
39
39
|
]=]
|
|
40
|
-
function LinkUtils.getAllLinkValues(linkName, from)
|
|
40
|
+
function LinkUtils.getAllLinkValues(linkName: string, from: Instance): { ObjectValue }
|
|
41
41
|
assert(type(linkName) == "string", "Bad linkName")
|
|
42
42
|
assert(typeof(from) == "Instance", "Bad from")
|
|
43
43
|
|
|
44
44
|
local linkValues = {}
|
|
45
45
|
|
|
46
|
-
for _, item in
|
|
46
|
+
for _, item in from:GetChildren() do
|
|
47
47
|
if item:IsA("ObjectValue") and item.Name == linkName then
|
|
48
48
|
local value = item.Value
|
|
49
49
|
if value then
|
|
@@ -55,7 +55,6 @@ function LinkUtils.getAllLinkValues(linkName, from)
|
|
|
55
55
|
return linkValues
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
|
|
59
58
|
--[=[
|
|
60
59
|
Ensures after operation a single link is pointed to the value, unless the value is "nil"
|
|
61
60
|
in which case no link will be set
|
|
@@ -63,16 +62,16 @@ end
|
|
|
63
62
|
@param linkName string
|
|
64
63
|
@param from Instance
|
|
65
64
|
@param to Instance
|
|
66
|
-
@return Instance
|
|
65
|
+
@return Instance?
|
|
67
66
|
]=]
|
|
68
|
-
function LinkUtils.setSingleLinkValue(linkName, from, to)
|
|
67
|
+
function LinkUtils.setSingleLinkValue(linkName: string, from: Instance, to: Instance): ObjectValue?
|
|
69
68
|
assert(type(linkName) == "string", "Bad linkName")
|
|
70
69
|
assert(typeof(from) == "Instance", "Bad from")
|
|
71
70
|
assert(typeof(to) == "Instance" or to == nil, "Bad to")
|
|
72
71
|
|
|
73
72
|
if to then
|
|
74
73
|
local existingLink = nil
|
|
75
|
-
for _, link in
|
|
74
|
+
for _, link in from:GetChildren() do
|
|
76
75
|
if link:IsA("ObjectValue") and link.Name == linkName then
|
|
77
76
|
if existingLink then
|
|
78
77
|
link:Destroy()
|
|
@@ -89,7 +88,7 @@ function LinkUtils.setSingleLinkValue(linkName, from, to)
|
|
|
89
88
|
|
|
90
89
|
return LinkUtils.createLink(linkName, from, to)
|
|
91
90
|
else
|
|
92
|
-
for _, link in
|
|
91
|
+
for _, link in from:GetChildren() do
|
|
93
92
|
if link:IsA("ObjectValue") and link.Name == linkName then
|
|
94
93
|
link:Destroy()
|
|
95
94
|
end
|
|
@@ -99,19 +98,18 @@ function LinkUtils.setSingleLinkValue(linkName, from, to)
|
|
|
99
98
|
end
|
|
100
99
|
end
|
|
101
100
|
|
|
102
|
-
|
|
103
101
|
--[=[
|
|
104
102
|
Gets all links underneath an instance.
|
|
105
103
|
@param linkName string
|
|
106
104
|
@param from Instance
|
|
107
105
|
@return { ObjectValue }
|
|
108
106
|
]=]
|
|
109
|
-
function LinkUtils.getAllLinks(linkName, from)
|
|
107
|
+
function LinkUtils.getAllLinks(linkName: string, from: Instance): { ObjectValue }
|
|
110
108
|
assert(type(linkName) == "string", "Bad linkName")
|
|
111
109
|
assert(typeof(from) == "Instance", "Bad from")
|
|
112
110
|
|
|
113
111
|
local links = {}
|
|
114
|
-
for _, item in
|
|
112
|
+
for _, item in from:GetChildren() do
|
|
115
113
|
if item:IsA("ObjectValue") and item.Name == linkName then
|
|
116
114
|
table.insert(links, item)
|
|
117
115
|
end
|
|
@@ -124,9 +122,9 @@ end
|
|
|
124
122
|
Gets the first links value
|
|
125
123
|
@param linkName string
|
|
126
124
|
@param from Instance
|
|
127
|
-
@return
|
|
125
|
+
@return Instance
|
|
128
126
|
]=]
|
|
129
|
-
function LinkUtils.getLinkValue(linkName, from)
|
|
127
|
+
function LinkUtils.getLinkValue(linkName: string, from: Instance): Instance?
|
|
130
128
|
assert(type(linkName) == "string", "Bad linkName")
|
|
131
129
|
assert(typeof(from) == "Instance", "Bad from")
|
|
132
130
|
|
|
@@ -136,7 +134,13 @@ function LinkUtils.getLinkValue(linkName, from)
|
|
|
136
134
|
end
|
|
137
135
|
|
|
138
136
|
if not objectValue:IsA("ObjectValue") then
|
|
139
|
-
warn(
|
|
137
|
+
warn(
|
|
138
|
+
string.format(
|
|
139
|
+
"[LinkUtils.getLinkValue] - Bad link %q not an object value, from %q",
|
|
140
|
+
objectValue:GetFullName(),
|
|
141
|
+
from:GetFullName()
|
|
142
|
+
)
|
|
143
|
+
)
|
|
140
144
|
return nil
|
|
141
145
|
end
|
|
142
146
|
|
|
@@ -150,7 +154,7 @@ end
|
|
|
150
154
|
@param from Instance
|
|
151
155
|
@return Promise<Instance>
|
|
152
156
|
]=]
|
|
153
|
-
function LinkUtils.promiseLinkValue(maid, linkName, from)
|
|
157
|
+
function LinkUtils.promiseLinkValue(maid, linkName: string, from: Instance)
|
|
154
158
|
assert(maid, "Bad maid")
|
|
155
159
|
assert(type(linkName) == "string", "Bad linkName")
|
|
156
160
|
assert(typeof(from) == "Instance", "Bad from")
|
|
@@ -158,7 +162,7 @@ function LinkUtils.promiseLinkValue(maid, linkName, from)
|
|
|
158
162
|
local childPromise = promiseChild(from, linkName)
|
|
159
163
|
maid:GiveTask(childPromise)
|
|
160
164
|
|
|
161
|
-
return childPromise:Then(function(objectValue)
|
|
165
|
+
return childPromise:Then(function(objectValue: ObjectValue)
|
|
162
166
|
local promise = promisePropertyValue(objectValue, "Value")
|
|
163
167
|
maid:GiveTask(promise)
|
|
164
168
|
|
|
@@ -14,21 +14,20 @@ local RxInstanceUtils = require("RxInstanceUtils")
|
|
|
14
14
|
local RxLinkUtils = {}
|
|
15
15
|
|
|
16
16
|
-- Emits valid links in format Brio.new(link, linkValue)
|
|
17
|
-
function RxLinkUtils.observeValidLinksBrio(linkName, parent)
|
|
17
|
+
function RxLinkUtils.observeValidLinksBrio(linkName: string, parent: Instance)
|
|
18
18
|
assert(type(linkName) == "string", "linkName should be 'string'")
|
|
19
19
|
assert(typeof(parent) == "Instance", "parent should be 'Instance'")
|
|
20
20
|
|
|
21
|
-
return RxInstanceUtils.observeChildrenBrio(parent)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
21
|
+
return RxInstanceUtils.observeChildrenBrio(parent):Pipe({
|
|
22
|
+
Rx.flatMap(function(brio)
|
|
23
|
+
local instance: Instance = brio:GetValue()
|
|
24
|
+
if not instance:IsA("ObjectValue") then
|
|
25
|
+
return Rx.EMPTY
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
return RxBrioUtils.completeOnDeath(brio, RxLinkUtils.observeValidityBrio(linkName, instance))
|
|
29
|
+
end),
|
|
30
|
+
})
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
--[=[
|
|
@@ -38,23 +37,22 @@ end
|
|
|
38
37
|
@param parent Instance
|
|
39
38
|
@return Brio<Instance>
|
|
40
39
|
]=]
|
|
41
|
-
function RxLinkUtils.observeLinkValueBrio(linkName, parent)
|
|
40
|
+
function RxLinkUtils.observeLinkValueBrio(linkName: string, parent: Instance)
|
|
42
41
|
assert(type(linkName) == "string", "linkName should be 'string'")
|
|
43
42
|
assert(typeof(parent) == "Instance", "parent should be 'Instance'")
|
|
44
43
|
|
|
45
|
-
return RxInstanceUtils.observeChildrenOfNameBrio(parent, "ObjectValue", linkName)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
return value ~= nil
|
|
50
|
-
end)
|
|
44
|
+
return RxInstanceUtils.observeChildrenOfNameBrio(parent, "ObjectValue", linkName):Pipe({
|
|
45
|
+
RxBrioUtils.flatMapBrio(function(instance)
|
|
46
|
+
return RxInstanceUtils.observePropertyBrio(instance, "Value", function(value: Instance?)
|
|
47
|
+
return value ~= nil
|
|
51
48
|
end)
|
|
52
|
-
|
|
49
|
+
end),
|
|
50
|
+
})
|
|
53
51
|
end
|
|
54
52
|
|
|
55
53
|
-- Fires off everytime the link is reconfigured into a valid link
|
|
56
54
|
-- Fires with link, linkValue
|
|
57
|
-
function RxLinkUtils.observeValidityBrio(linkName, link)
|
|
55
|
+
function RxLinkUtils.observeValidityBrio(linkName: string, link: Instance)
|
|
58
56
|
assert(typeof(link) == "Instance" and link:IsA("ObjectValue"), "Bad link")
|
|
59
57
|
assert(type(linkName) == "string", "Bad linkName")
|
|
60
58
|
|
|
@@ -72,15 +70,12 @@ function RxLinkUtils.observeValidityBrio(linkName, link)
|
|
|
72
70
|
sub:Fire(newValid)
|
|
73
71
|
end
|
|
74
72
|
|
|
75
|
-
maid:GiveTask(link:GetPropertyChangedSignal("Value")
|
|
76
|
-
|
|
77
|
-
maid:GiveTask(link:GetPropertyChangedSignal("Name")
|
|
78
|
-
:Connect(updateValidity))
|
|
73
|
+
maid:GiveTask(link:GetPropertyChangedSignal("Value"):Connect(updateValidity))
|
|
74
|
+
maid:GiveTask(link:GetPropertyChangedSignal("Name"):Connect(updateValidity))
|
|
79
75
|
updateValidity()
|
|
80
76
|
|
|
81
77
|
return maid
|
|
82
78
|
end)
|
|
83
79
|
end
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
return RxLinkUtils
|
|
81
|
+
return RxLinkUtils
|