@rbxts/app-forge 0.7.2-prototype.1 → 0.7.2-prototype.10
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/out/appRegistry.d.ts +7 -5
- package/out/appRegistry.luau +39 -26
- package/out/helpers/bindAppSource.d.ts +2 -0
- package/out/helpers/bindAppSource.luau +22 -0
- package/out/helpers/getAppEntry.d.ts +2 -0
- package/out/helpers/getAppEntry.luau +22 -0
- package/out/helpers/getAppSource.d.ts +2 -0
- package/out/helpers/getAppSource.luau +25 -0
- package/out/helpers/hasAppSource.d.ts +1 -0
- package/out/helpers/hasAppSource.luau +24 -0
- package/out/helpers/setAppSource.d.ts +1 -0
- package/out/helpers/setAppSource.luau +34 -0
- package/out/mount.d.ts +12 -24
- package/out/mount.luau +80 -155
- package/out/renders.d.ts +9 -0
- package/out/renders.luau +76 -0
- package/out/ruleEngine/check/exclusiveGroup.d.ts +2 -0
- package/out/ruleEngine/check/exclusiveGroup.luau +54 -0
- package/out/ruleEngine/check/parent.d.ts +2 -0
- package/out/ruleEngine/check/parent.luau +38 -0
- package/out/ruleEngine/index.d.ts +2 -2
- package/out/ruleEngine/init.luau +20 -15
- package/out/ruleEngine/render/anchor.d.ts +2 -0
- package/out/ruleEngine/render/anchor.luau +11 -0
- package/out/types.d.ts +12 -8
- package/package.json +1 -1
- package/out/renderManager.d.ts +0 -32
- package/out/renderManager.luau +0 -326
- package/out/ruleEngine/exclusiveGroup.d.ts +0 -2
- package/out/ruleEngine/exclusiveGroup.luau +0 -54
- package/out/ruleEngine/parent.d.ts +0 -2
- package/out/ruleEngine/parent.luau +0 -34
package/out/mount.luau
CHANGED
|
@@ -8,15 +8,21 @@ local Vide = _vide
|
|
|
8
8
|
local apply = _vide.apply
|
|
9
9
|
local create = _vide.create
|
|
10
10
|
local effect = _vide.effect
|
|
11
|
-
local mount = _vide.mount
|
|
12
|
-
local source = _vide.source
|
|
13
11
|
local untrack = _vide.untrack
|
|
12
|
+
-- Types
|
|
14
13
|
-- Classes
|
|
15
|
-
local Renders = TS.import(script, script.Parent, "
|
|
16
|
-
--
|
|
14
|
+
local Renders = TS.import(script, script.Parent, "renders").default
|
|
15
|
+
-- Components
|
|
17
16
|
local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
|
|
17
|
+
-- Classes
|
|
18
18
|
local Debugger = TS.import(script, script.Parent, "debugger").default
|
|
19
19
|
local Logger = TS.import(script, script.Parent, "logger").default
|
|
20
|
+
-- Helpers
|
|
21
|
+
local bindAppSource = TS.import(script, script.Parent, "helpers", "bindAppSource").default
|
|
22
|
+
local getAppSource = TS.import(script, script.Parent, "helpers", "getAppSource").default
|
|
23
|
+
local hasAppSource = TS.import(script, script.Parent, "helpers", "hasAppSource").default
|
|
24
|
+
local setAppSource = TS.import(script, script.Parent, "helpers", "setAppSource").default
|
|
25
|
+
local getAppEntry = TS.import(script, script.Parent, "helpers", "getAppEntry").default
|
|
20
26
|
local AppForge
|
|
21
27
|
do
|
|
22
28
|
local super = Renders
|
|
@@ -37,77 +43,74 @@ do
|
|
|
37
43
|
self.debug = Debugger.new(function(level, msg, data, trace)
|
|
38
44
|
return self.logger:log(level, msg, data, trace)
|
|
39
45
|
end)
|
|
40
|
-
self.sources = {}
|
|
41
|
-
self.loaded = {}
|
|
42
|
-
self.__px = false
|
|
43
46
|
-- ▼ ReadonlyMap.forEach ▼
|
|
44
|
-
local _callback = function(
|
|
45
|
-
|
|
47
|
+
local _callback = function(entryMap, name)
|
|
48
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
49
|
+
local _callback_1 = function(_, group)
|
|
50
|
+
self:createSource(name, group)
|
|
51
|
+
end
|
|
52
|
+
for _k, _v in entryMap do
|
|
53
|
+
_callback_1(_v, _k, entryMap)
|
|
54
|
+
end
|
|
55
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
46
56
|
end
|
|
47
57
|
for _k, _v in AppRegistry do
|
|
48
58
|
_callback(_v, _k, AppRegistry)
|
|
49
59
|
end
|
|
50
60
|
-- ▲ ReadonlyMap.forEach ▲
|
|
51
61
|
end
|
|
52
|
-
function AppForge:createSource(name)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
function AppForge:createSource(name, group)
|
|
63
|
+
if group == nil then
|
|
64
|
+
group = "None"
|
|
65
|
+
end
|
|
66
|
+
local entry = getAppEntry(self, name, group)
|
|
67
|
+
if not entry then
|
|
68
|
+
self.logger:log("ERROR", "App Entry not registered while creating source", {
|
|
57
69
|
name = name,
|
|
58
70
|
})
|
|
59
71
|
return nil
|
|
60
72
|
end
|
|
61
|
-
|
|
62
|
-
local _name_1 = name
|
|
63
|
-
if _sources[_name_1] ~= nil then
|
|
73
|
+
if hasAppSource(name, group) then
|
|
64
74
|
return nil
|
|
65
75
|
end
|
|
66
76
|
local _debug = self.debug
|
|
67
77
|
local _exp = name
|
|
68
78
|
local _object = {}
|
|
69
79
|
local _left = "default"
|
|
70
|
-
local _condition =
|
|
80
|
+
local _condition = entry.visible
|
|
71
81
|
if _condition == nil then
|
|
72
82
|
_condition = false
|
|
73
83
|
end
|
|
74
84
|
_object[_left] = _condition
|
|
75
85
|
_debug:logTag("state", _exp, "Creating visibility source", _object)
|
|
76
|
-
local _sources_1 = self.sources
|
|
77
86
|
local _exp_1 = name
|
|
78
|
-
local
|
|
87
|
+
local _exp_2 = group
|
|
88
|
+
local _condition_1 = entry.visible
|
|
79
89
|
if _condition_1 == nil then
|
|
80
90
|
_condition_1 = false
|
|
81
91
|
end
|
|
82
|
-
|
|
83
|
-
_sources_1[_exp_1] = _arg1
|
|
92
|
+
setAppSource(_exp_1, _exp_2, _condition_1)
|
|
84
93
|
end
|
|
85
|
-
function AppForge:getSource(name)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
function AppForge:getSource(name, group)
|
|
95
|
+
if group == nil then
|
|
96
|
+
group = "None"
|
|
97
|
+
end
|
|
98
|
+
if not hasAppSource(name, group) then
|
|
99
|
+
self:createSource(name, group)
|
|
90
100
|
end
|
|
91
|
-
local
|
|
92
|
-
local _name_1 = name
|
|
93
|
-
local src = _sources_1[_name_1]
|
|
101
|
+
local src = getAppSource(self, name, group)
|
|
94
102
|
if not src then
|
|
95
|
-
|
|
103
|
+
self.logger:log("WARN", `Failed to get source for name {name} group {group}`)
|
|
96
104
|
end
|
|
97
105
|
return src
|
|
98
106
|
end
|
|
99
|
-
function AppForge:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
end
|
|
104
|
-
function AppForge:bind(name, value)
|
|
107
|
+
function AppForge:bind(name, group, value)
|
|
108
|
+
if group == nil then
|
|
109
|
+
group = "None"
|
|
110
|
+
end
|
|
105
111
|
if not RunService:IsRunning() then
|
|
106
112
|
self.debug:logTag("state", name, "Binding external visibility source")
|
|
107
|
-
|
|
108
|
-
local _name = name
|
|
109
|
-
local _value = value
|
|
110
|
-
_sources[_name] = _value
|
|
113
|
+
bindAppSource(name, group, value)
|
|
111
114
|
local prev
|
|
112
115
|
local log = function()
|
|
113
116
|
return self.debug:logTag("state", name, "Visibility changed", {
|
|
@@ -120,7 +123,7 @@ do
|
|
|
120
123
|
count += 1
|
|
121
124
|
prev = value()
|
|
122
125
|
untrack(function()
|
|
123
|
-
return self:checkRules(self, name)
|
|
126
|
+
return self:checkRules(self, name, group)
|
|
124
127
|
end)
|
|
125
128
|
if Vide.strict and count == 2 then
|
|
126
129
|
log()
|
|
@@ -136,98 +139,15 @@ do
|
|
|
136
139
|
})
|
|
137
140
|
end
|
|
138
141
|
end
|
|
139
|
-
function AppForge:
|
|
140
|
-
if
|
|
141
|
-
|
|
142
|
-
name = name,
|
|
143
|
-
})
|
|
144
|
-
return nil
|
|
145
|
-
end
|
|
146
|
-
local _anchorName = anchorName
|
|
147
|
-
local anchorApp = AppRegistry[_anchorName]
|
|
148
|
-
if not anchorApp then
|
|
149
|
-
self.logger:log("ERROR", "Anchor parent not registered", {
|
|
150
|
-
child = name,
|
|
151
|
-
parent = anchorName,
|
|
152
|
-
})
|
|
153
|
-
return nil
|
|
154
|
-
end
|
|
155
|
-
local _loaded = self.loaded
|
|
156
|
-
local _name = name
|
|
157
|
-
local _render = _loaded[_name]
|
|
158
|
-
if _render ~= nil then
|
|
159
|
-
_render = _render.render
|
|
160
|
-
end
|
|
161
|
-
local render = _render
|
|
162
|
-
if not render then
|
|
163
|
-
self.debug:logTag("rules", name, "Anchor skipped (child not rendered yet)", {
|
|
164
|
-
parent = anchorName,
|
|
165
|
-
})
|
|
166
|
-
return nil
|
|
167
|
-
end
|
|
168
|
-
self.debug:logTag("rules", name, "Anchoring to parent", {
|
|
169
|
-
parent = anchorName,
|
|
170
|
-
})
|
|
171
|
-
local anchor = anchorApp.constructor.new(props, anchorName):render()
|
|
172
|
-
for _, child in anchor:GetDescendants() do
|
|
173
|
-
child:Destroy()
|
|
174
|
-
end
|
|
175
|
-
apply(anchor)({
|
|
176
|
-
Name = "Anchor",
|
|
177
|
-
BackgroundTransparency = 1,
|
|
178
|
-
[0] = render,
|
|
179
|
-
})
|
|
180
|
-
local _loaded_1 = self.loaded
|
|
181
|
-
local _name_1 = name
|
|
182
|
-
local prev = _loaded_1[_name_1]
|
|
183
|
-
if not prev then
|
|
184
|
-
error(`AppForge invariant broken: missing loaded app for {name}`, 2)
|
|
185
|
-
end
|
|
186
|
-
apply(prev.container)({
|
|
187
|
-
[0] = anchor,
|
|
188
|
-
})
|
|
189
|
-
local _loaded_2 = self.loaded
|
|
190
|
-
local _exp = name
|
|
191
|
-
local _object = table.clone(prev)
|
|
192
|
-
setmetatable(_object, nil)
|
|
193
|
-
_object.anchor = anchor
|
|
194
|
-
_loaded_2[_exp] = _object
|
|
195
|
-
end
|
|
196
|
-
function AppForge:index(name, index)
|
|
197
|
-
local _loaded = self.loaded
|
|
198
|
-
local _name = name
|
|
199
|
-
local loaded = _loaded[_name]
|
|
200
|
-
if not loaded then
|
|
201
|
-
self.logger:log("WARN", "ZIndex skipped (app not loaded)", {
|
|
202
|
-
name = name,
|
|
203
|
-
index = index,
|
|
204
|
-
})
|
|
205
|
-
return nil
|
|
142
|
+
function AppForge:set(name, group, value, rules)
|
|
143
|
+
if group == nil then
|
|
144
|
+
group = "None"
|
|
206
145
|
end
|
|
207
|
-
self.debug:logTag("rules", name, "Applying ZIndex", {
|
|
208
|
-
index = index,
|
|
209
|
-
})
|
|
210
|
-
apply(loaded.container)({
|
|
211
|
-
ZIndex = index,
|
|
212
|
-
})
|
|
213
|
-
end
|
|
214
|
-
function AppForge:set(name, value, rules)
|
|
215
146
|
if rules == nil then
|
|
216
147
|
rules = true
|
|
217
148
|
end
|
|
218
|
-
local
|
|
219
|
-
local _name = name
|
|
220
|
-
local src = _sources[_name]
|
|
149
|
+
local src = getAppSource(self, name, group)
|
|
221
150
|
if not src then
|
|
222
|
-
self:createSource(name)
|
|
223
|
-
local _sources_1 = self.sources
|
|
224
|
-
local _name_1 = name
|
|
225
|
-
src = _sources_1[_name_1]
|
|
226
|
-
end
|
|
227
|
-
if not src then
|
|
228
|
-
self.logger:log("ERROR", "Failed to set visibility (missing source)", {
|
|
229
|
-
name = name,
|
|
230
|
-
})
|
|
231
151
|
return nil
|
|
232
152
|
end
|
|
233
153
|
local prev = src()
|
|
@@ -240,28 +160,41 @@ do
|
|
|
240
160
|
to = value,
|
|
241
161
|
})
|
|
242
162
|
if rules then
|
|
243
|
-
self:checkRules(self, name)
|
|
163
|
+
self:checkRules(self, name, group)
|
|
244
164
|
end
|
|
245
165
|
end
|
|
246
|
-
function AppForge:open(name, rules)
|
|
166
|
+
function AppForge:open(name, group, rules)
|
|
167
|
+
if group == nil then
|
|
168
|
+
group = "None"
|
|
169
|
+
end
|
|
247
170
|
if rules == nil then
|
|
248
171
|
rules = true
|
|
249
172
|
end
|
|
250
|
-
self:set(name, true, rules)
|
|
173
|
+
self:set(name, group, true, rules)
|
|
251
174
|
end
|
|
252
|
-
function AppForge:close(name, rules)
|
|
175
|
+
function AppForge:close(name, group, rules)
|
|
176
|
+
if group == nil then
|
|
177
|
+
group = "None"
|
|
178
|
+
end
|
|
253
179
|
if rules == nil then
|
|
254
180
|
rules = true
|
|
255
181
|
end
|
|
256
|
-
self:set(name, false, rules)
|
|
182
|
+
self:set(name, group, false, rules)
|
|
257
183
|
end
|
|
258
|
-
function AppForge:toggle(name, rules)
|
|
184
|
+
function AppForge:toggle(name, group, rules)
|
|
185
|
+
if group == nil then
|
|
186
|
+
group = "None"
|
|
187
|
+
end
|
|
259
188
|
if rules == nil then
|
|
260
189
|
rules = true
|
|
261
190
|
end
|
|
262
|
-
|
|
191
|
+
local src = self:getSource(name, group)
|
|
192
|
+
if not src then
|
|
193
|
+
return self.logger:log("ERROR", `Failed to get Source for name {name} group {group}`)
|
|
194
|
+
end
|
|
195
|
+
self:set(name, group, not src(), rules)
|
|
263
196
|
end
|
|
264
|
-
function AppForge:story(props, target,
|
|
197
|
+
function AppForge:story(props, target, config)
|
|
265
198
|
self.debug:logTag("lifecycle", "story", "Creating story mount")
|
|
266
199
|
local Container = create("Frame")({
|
|
267
200
|
Name = "Story Container",
|
|
@@ -278,8 +211,8 @@ do
|
|
|
278
211
|
props = props,
|
|
279
212
|
forge = self,
|
|
280
213
|
}
|
|
281
|
-
local _left_1 = "
|
|
282
|
-
local _result =
|
|
214
|
+
local _left_1 = "renders"
|
|
215
|
+
local _result = config
|
|
283
216
|
if _result ~= nil then
|
|
284
217
|
_result = _result.render
|
|
285
218
|
end
|
|
@@ -291,34 +224,26 @@ do
|
|
|
291
224
|
target = target,
|
|
292
225
|
}
|
|
293
226
|
local _left_4 = "minScale"
|
|
294
|
-
local _result_1 =
|
|
227
|
+
local _result_1 = config
|
|
295
228
|
if _result_1 ~= nil then
|
|
296
229
|
_result_1 = _result_1.minScale
|
|
297
230
|
end
|
|
298
231
|
_object_3[_left_4] = _result_1
|
|
299
232
|
_object_2[_left_3] = _object_3
|
|
300
233
|
_object_1[_left_2] = _object_2
|
|
301
|
-
_object[_left] = _self:
|
|
234
|
+
_object[_left] = _self:initalize(_object_1)
|
|
302
235
|
_fn(_object)
|
|
303
236
|
return Container
|
|
304
237
|
end
|
|
305
|
-
function AppForge:mount(
|
|
238
|
+
function AppForge:mount(props, target, root)
|
|
306
239
|
self.debug:logTag("lifecycle", "mount", "Mounting AppForge")
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
end, target)
|
|
240
|
+
local _self = self
|
|
241
|
+
local _object = table.clone(props)
|
|
242
|
+
setmetatable(_object, nil)
|
|
243
|
+
_object.forge = self
|
|
244
|
+
_self:initalize(_object, target, root)
|
|
313
245
|
return self.innerMount
|
|
314
246
|
end
|
|
315
|
-
function AppForge:unMount()
|
|
316
|
-
self.debug:logTag("lifecycle", "unmount", "Unmounting AppForge")
|
|
317
|
-
local _result = self.innerMount
|
|
318
|
-
if _result ~= nil then
|
|
319
|
-
_result()
|
|
320
|
-
end
|
|
321
|
-
end
|
|
322
247
|
end
|
|
323
248
|
return {
|
|
324
249
|
default = AppForge,
|
package/out/renders.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Vide from "@rbxts/vide";
|
|
2
|
+
import type Types from "./types";
|
|
3
|
+
import Rules from "./ruleEngine";
|
|
4
|
+
export default class Renders extends Rules {
|
|
5
|
+
private __px;
|
|
6
|
+
constructor();
|
|
7
|
+
private Render;
|
|
8
|
+
protected initalize(props: Types.Props.Main, target?: GuiObject | Instance, root?: GuiObject | Instance): Vide.Node;
|
|
9
|
+
}
|
package/out/renders.luau
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Packages
|
|
4
|
+
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
5
|
+
local Vide = _vide
|
|
6
|
+
local mount = _vide.mount
|
|
7
|
+
-- Types
|
|
8
|
+
-- Components
|
|
9
|
+
local _appRegistry = TS.import(script, script.Parent, "appRegistry")
|
|
10
|
+
local AppRegistry = _appRegistry.AppRegistry
|
|
11
|
+
local AppSources = _appRegistry.AppSources
|
|
12
|
+
-- Hooks
|
|
13
|
+
local usePx = TS.import(script, script.Parent, "hooks", "usePx").usePx
|
|
14
|
+
-- Classes
|
|
15
|
+
local Rules = TS.import(script, script.Parent, "ruleEngine").default
|
|
16
|
+
local Renders
|
|
17
|
+
do
|
|
18
|
+
local super = Rules
|
|
19
|
+
Renders = setmetatable({}, {
|
|
20
|
+
__tostring = function()
|
|
21
|
+
return "Renders"
|
|
22
|
+
end,
|
|
23
|
+
__index = super,
|
|
24
|
+
})
|
|
25
|
+
Renders.__index = Renders
|
|
26
|
+
function Renders.new(...)
|
|
27
|
+
local self = setmetatable({}, Renders)
|
|
28
|
+
return self:constructor(...) or self
|
|
29
|
+
end
|
|
30
|
+
function Renders:constructor()
|
|
31
|
+
super.constructor(self)
|
|
32
|
+
self.__px = false
|
|
33
|
+
end
|
|
34
|
+
function Renders:Render(_param)
|
|
35
|
+
local props = _param.props
|
|
36
|
+
print(props)
|
|
37
|
+
print(AppRegistry)
|
|
38
|
+
print(AppSources)
|
|
39
|
+
end
|
|
40
|
+
function Renders:initalize(props, target, root)
|
|
41
|
+
if not self.__px then
|
|
42
|
+
local _result = props.config
|
|
43
|
+
if _result ~= nil then
|
|
44
|
+
_result = _result.px.target
|
|
45
|
+
end
|
|
46
|
+
local _result_1 = props.config
|
|
47
|
+
if _result_1 ~= nil then
|
|
48
|
+
_result_1 = _result_1.px.resolution
|
|
49
|
+
end
|
|
50
|
+
local _result_2 = props.config
|
|
51
|
+
if _result_2 ~= nil then
|
|
52
|
+
_result_2 = _result_2.px.minScale
|
|
53
|
+
end
|
|
54
|
+
usePx(_result, _result_1, _result_2)
|
|
55
|
+
self.__px = true
|
|
56
|
+
end
|
|
57
|
+
if target then
|
|
58
|
+
mount(function()
|
|
59
|
+
return if root then root else (Vide.jsx("screengui", {
|
|
60
|
+
Name = "App Tree",
|
|
61
|
+
ZIndexBehavior = "Sibling",
|
|
62
|
+
ResetOnSpawn = false,
|
|
63
|
+
}, Vide.jsx(self.Render, {
|
|
64
|
+
props = props,
|
|
65
|
+
})))
|
|
66
|
+
end)
|
|
67
|
+
else
|
|
68
|
+
return Vide.jsx(self.Render, {
|
|
69
|
+
props = props,
|
|
70
|
+
})
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
return {
|
|
75
|
+
default = Renders,
|
|
76
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Types
|
|
4
|
+
-- Components
|
|
5
|
+
local AppRegistry = TS.import(script, script.Parent.Parent.Parent, "appRegistry").AppRegistry
|
|
6
|
+
-- Helpers
|
|
7
|
+
local getAppEntry = TS.import(script, script.Parent.Parent.Parent, "helpers", "getAppEntry").default
|
|
8
|
+
local function ExclusiveGroupRule(forge, name, group)
|
|
9
|
+
local entry = getAppEntry(forge, name, group)
|
|
10
|
+
if not entry then
|
|
11
|
+
forge.logger:log("ERROR", `Failed to find app entry for "ExclusiveGroupRule" name {name} group {group} `)
|
|
12
|
+
end
|
|
13
|
+
local entryVisible = forge:getSource(name)()
|
|
14
|
+
if not entryVisible then
|
|
15
|
+
return nil
|
|
16
|
+
end
|
|
17
|
+
forge.debug:logTag("rules", name, "Exclusive group activated", group)
|
|
18
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
19
|
+
local _callback = function(entryMap, entryGroup)
|
|
20
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
21
|
+
local _callback_1 = function(entry, entryName)
|
|
22
|
+
if name == entryName then
|
|
23
|
+
return nil
|
|
24
|
+
end
|
|
25
|
+
local _result = entry.rules
|
|
26
|
+
if _result ~= nil then
|
|
27
|
+
_result = _result.exclusiveGroup
|
|
28
|
+
end
|
|
29
|
+
if _result ~= entryGroup then
|
|
30
|
+
return nil
|
|
31
|
+
end
|
|
32
|
+
local visible = forge:getSource(entryName)()
|
|
33
|
+
if not visible then
|
|
34
|
+
return nil
|
|
35
|
+
end
|
|
36
|
+
forge.debug:logTag("rules", entryName, "Closing app due to exclusive group", {
|
|
37
|
+
closed = entryName,
|
|
38
|
+
entryGroup = entryGroup,
|
|
39
|
+
})
|
|
40
|
+
forge:close(entryName, entryGroup, false)
|
|
41
|
+
end
|
|
42
|
+
for _k, _v in entryMap do
|
|
43
|
+
_callback_1(_v, _k, entryMap)
|
|
44
|
+
end
|
|
45
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
46
|
+
end
|
|
47
|
+
for _k, _v in AppRegistry do
|
|
48
|
+
_callback(_v, _k, AppRegistry)
|
|
49
|
+
end
|
|
50
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
51
|
+
end
|
|
52
|
+
return {
|
|
53
|
+
default = ExclusiveGroupRule,
|
|
54
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Types
|
|
4
|
+
-- Helpers
|
|
5
|
+
local getAppSource = TS.import(script, script.Parent.Parent.Parent, "helpers", "getAppSource").default
|
|
6
|
+
local getAppEntry = TS.import(script, script.Parent.Parent.Parent, "helpers", "getAppEntry").default
|
|
7
|
+
local function ParentRule(forge, name, group)
|
|
8
|
+
local entry = getAppEntry(forge, name, group)
|
|
9
|
+
local _result = entry
|
|
10
|
+
if _result ~= nil then
|
|
11
|
+
_result = _result.rules
|
|
12
|
+
if _result ~= nil then
|
|
13
|
+
_result = _result.parent
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
if not (_result ~= "" and _result) then
|
|
17
|
+
return nil
|
|
18
|
+
end
|
|
19
|
+
local _exp = forge
|
|
20
|
+
local _exp_1 = entry.rules.parent
|
|
21
|
+
local _condition = entry.rules.parentGroup
|
|
22
|
+
if _condition == nil then
|
|
23
|
+
_condition = "None"
|
|
24
|
+
end
|
|
25
|
+
local parentSource = getAppSource(_exp, _exp_1, _condition)
|
|
26
|
+
if parentSource and parentSource() == false then
|
|
27
|
+
local source = forge:getSource(name, group)
|
|
28
|
+
if not source then
|
|
29
|
+
return forge.logger:log("ERROR", `Failed to get Source for name {name} group {group}`)
|
|
30
|
+
end
|
|
31
|
+
if source() then
|
|
32
|
+
source(false)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
return {
|
|
37
|
+
default = ParentRule,
|
|
38
|
+
}
|
|
@@ -2,6 +2,6 @@ import type AppForge from "../mount";
|
|
|
2
2
|
import type Types from "../types";
|
|
3
3
|
export default class Rules {
|
|
4
4
|
protected processing: Set<string>;
|
|
5
|
-
protected renderRules(forge: AppForge, name: AppNames, props: Types.Props.Main): void;
|
|
6
|
-
protected checkRules(forge: AppForge, name: AppNames): void;
|
|
5
|
+
protected renderRules(forge: AppForge, name: AppNames, group: AppGroups | undefined, props: Types.Props.Main): void;
|
|
6
|
+
protected checkRules(forge: AppForge, name: AppNames, group: AppGroups): void;
|
|
7
7
|
}
|
package/out/ruleEngine/init.luau
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Types
|
|
4
4
|
-- Components
|
|
5
|
-
local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
|
|
6
5
|
-- Rules
|
|
7
|
-
local ExclusiveGroupRule = TS.import(script, script, "exclusiveGroup").default
|
|
8
|
-
local
|
|
6
|
+
local ExclusiveGroupRule = TS.import(script, script, "check", "exclusiveGroup").default
|
|
7
|
+
local AnchorRule = TS.import(script, script, "render", "anchor").default
|
|
8
|
+
local ParentRule = TS.import(script, script, "check", "parent").default
|
|
9
|
+
-- Helpers
|
|
10
|
+
local getAppEntry = TS.import(script, script.Parent, "helpers", "getAppEntry").default
|
|
9
11
|
local Rules
|
|
10
12
|
do
|
|
11
13
|
Rules = setmetatable({}, {
|
|
@@ -21,34 +23,37 @@ do
|
|
|
21
23
|
function Rules:constructor()
|
|
22
24
|
self.processing = {}
|
|
23
25
|
end
|
|
24
|
-
function Rules:renderRules(forge, name, props)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
function Rules:renderRules(forge, name, group, props)
|
|
27
|
+
if group == nil then
|
|
28
|
+
group = "None"
|
|
29
|
+
end
|
|
30
|
+
local entry = getAppEntry(forge, name, group)
|
|
31
|
+
if not entry then
|
|
32
|
+
error(`renderRules: App Entry name "{name}" group "{group}" not registered`, 2)
|
|
29
33
|
end
|
|
30
|
-
local rules =
|
|
34
|
+
local rules = entry.rules
|
|
31
35
|
if not rules then
|
|
32
36
|
return nil
|
|
33
37
|
end
|
|
34
38
|
-- Parent Anchor
|
|
35
39
|
local _condition = rules.parent
|
|
36
40
|
if _condition ~= "" and _condition then
|
|
37
|
-
_condition = not rules.
|
|
41
|
+
_condition = not rules.anchor
|
|
38
42
|
end
|
|
39
43
|
if _condition ~= "" and _condition then
|
|
40
44
|
forge.debug:logTag("rules", name, "Applying parent anchor", {
|
|
41
45
|
parent = rules.parent,
|
|
42
46
|
})
|
|
43
|
-
|
|
47
|
+
AnchorRule(name, group, props)
|
|
44
48
|
end
|
|
45
49
|
-- Index
|
|
46
50
|
if rules.zIndex ~= nil then
|
|
47
51
|
forge.debug:logTag("rules", name, "Applying ZIndex", rules.zIndex)
|
|
48
|
-
|
|
52
|
+
-- TODO: will be a separate file under ruleEngine
|
|
53
|
+
-- forge.index(name, rules.zIndex);
|
|
49
54
|
end
|
|
50
55
|
end
|
|
51
|
-
function Rules:checkRules(forge, name)
|
|
56
|
+
function Rules:checkRules(forge, name, group)
|
|
52
57
|
local _processing = self.processing
|
|
53
58
|
local _name = name
|
|
54
59
|
if _processing[_name] ~= nil then
|
|
@@ -60,8 +65,8 @@ do
|
|
|
60
65
|
_processing_1[_name_1] = true
|
|
61
66
|
forge.debug:logTag("rules", name, "Evaluating rules")
|
|
62
67
|
TS.try(function()
|
|
63
|
-
ParentRule(name,
|
|
64
|
-
ExclusiveGroupRule(name,
|
|
68
|
+
ParentRule(forge, name, group)
|
|
69
|
+
ExclusiveGroupRule(forge, name, group)
|
|
65
70
|
end, nil, function()
|
|
66
71
|
local _processing_2 = self.processing
|
|
67
72
|
local _name_2 = name
|