@rbxts/app-forge 0.7.2-prototype.1 → 0.7.2-prototype.3
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 +1 -0
- package/out/appRegistry.luau +14 -4
- package/out/mount.d.ts +6 -17
- package/out/mount.luau +19 -102
- package/out/renders.d.ts +8 -0
- package/out/renders.luau +66 -0
- package/out/ruleEngine/check/exclusiveGroup.d.ts +2 -0
- package/out/ruleEngine/{exclusiveGroup.luau → check/exclusiveGroup.luau} +8 -8
- package/out/ruleEngine/check/parent.d.ts +2 -0
- package/out/ruleEngine/check/parent.luau +37 -0
- package/out/ruleEngine/init.luau +7 -5
- package/out/ruleEngine/render/anchor.d.ts +2 -0
- package/out/ruleEngine/render/anchor.luau +38 -0
- package/out/types.d.ts +3 -3
- 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/parent.d.ts +0 -2
- package/out/ruleEngine/parent.luau +0 -34
package/out/appRegistry.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import Vide from "@rbxts/vide";
|
|
|
2
2
|
import type Types from "./types";
|
|
3
3
|
import type AppForge from "./mount";
|
|
4
4
|
export declare const AppRegistry: Map<string, Types.AppRegistry.Static>;
|
|
5
|
+
export declare const AppsLoaded: Map<`${string}-${string}`, boolean>;
|
|
5
6
|
/**
|
|
6
7
|
* Registers a Vide App with AppForge.
|
|
7
8
|
*
|
package/out/appRegistry.luau
CHANGED
|
@@ -8,6 +8,7 @@ local px = TS.import(script, script.Parent, "hooks", "usePx").px
|
|
|
8
8
|
local Logger = TS.import(script, script.Parent, "logger").default
|
|
9
9
|
local logger = Logger.new("AppRegistry")
|
|
10
10
|
local AppRegistry = {}
|
|
11
|
+
local AppsLoaded = {}
|
|
11
12
|
--[[
|
|
12
13
|
*
|
|
13
14
|
* Registers a Vide App with AppForge.
|
|
@@ -17,8 +18,12 @@ local AppRegistry = {}
|
|
|
17
18
|
]]
|
|
18
19
|
local function App(props)
|
|
19
20
|
return function(constructor)
|
|
20
|
-
local
|
|
21
|
-
if
|
|
21
|
+
local _condition = props.renderGroup
|
|
22
|
+
if _condition == nil then
|
|
23
|
+
_condition = "None"
|
|
24
|
+
end
|
|
25
|
+
local _arg0 = `{_condition}-{props.name}`
|
|
26
|
+
if AppRegistry[_arg0] ~= nil then
|
|
22
27
|
logger:log("ERROR", "Duplicate App name detected", {
|
|
23
28
|
name = props.name,
|
|
24
29
|
})
|
|
@@ -29,14 +34,18 @@ local function App(props)
|
|
|
29
34
|
logger:log("ERROR", "Attempted to register App without a name", props)
|
|
30
35
|
error("App registration failed: missing app name", 2)
|
|
31
36
|
end
|
|
32
|
-
local
|
|
37
|
+
local _condition_1 = props.renderGroup
|
|
38
|
+
if _condition_1 == nil then
|
|
39
|
+
_condition_1 = "None"
|
|
40
|
+
end
|
|
41
|
+
local _arg0_1 = `{_condition_1}-{props.name}`
|
|
33
42
|
local _arg1 = {
|
|
34
43
|
constructor = constructor,
|
|
35
44
|
renderGroup = props.renderGroup,
|
|
36
45
|
visible = props.visible,
|
|
37
46
|
rules = props.rules,
|
|
38
47
|
}
|
|
39
|
-
AppRegistry[
|
|
48
|
+
AppRegistry[_arg0_1] = _arg1
|
|
40
49
|
return constructor
|
|
41
50
|
end
|
|
42
51
|
end
|
|
@@ -71,5 +80,6 @@ end
|
|
|
71
80
|
return {
|
|
72
81
|
App = App,
|
|
73
82
|
AppRegistry = AppRegistry,
|
|
83
|
+
AppsLoaded = AppsLoaded,
|
|
74
84
|
Args = Args,
|
|
75
85
|
}
|
package/out/mount.d.ts
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
import Vide from "@rbxts/vide";
|
|
2
|
-
import Renders from "./
|
|
2
|
+
import Renders from "./renders";
|
|
3
3
|
import Debugger from "./debugger";
|
|
4
4
|
import Logger from "./logger";
|
|
5
5
|
import Types from "./types";
|
|
6
6
|
type Destructor = () => void;
|
|
7
|
-
type Loaded = {
|
|
8
|
-
container: Vide.Node;
|
|
9
|
-
render: Vide.Node;
|
|
10
|
-
anchor?: Vide.Node;
|
|
11
|
-
};
|
|
12
7
|
export default class AppForge extends Renders {
|
|
13
8
|
readonly logger: Logger;
|
|
14
9
|
readonly debug: Debugger;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
protected innerMount?: Destructor;
|
|
18
|
-
protected __px: boolean;
|
|
10
|
+
private sources;
|
|
11
|
+
private innerMount?;
|
|
19
12
|
constructor();
|
|
20
|
-
|
|
13
|
+
private createSource;
|
|
21
14
|
getSource(name: AppNames): Vide.Source<boolean>;
|
|
22
|
-
isLoaded(name: AppNames): boolean;
|
|
23
15
|
bind(name: AppNames, value: Vide.Source<boolean>): void;
|
|
24
|
-
anchor(name: AppNames, anchorName: AppNames, props: Types.Props.Main): void;
|
|
25
|
-
index(name: AppNames, index: number): void;
|
|
26
16
|
set(name: AppNames, value: boolean, rules?: boolean): void;
|
|
27
17
|
open(name: AppNames, rules?: boolean): void;
|
|
28
18
|
close(name: AppNames, rules?: boolean): void;
|
|
29
19
|
toggle(name: AppNames, rules?: boolean): void;
|
|
30
|
-
story(props: AppProps, target: GuiObject,
|
|
20
|
+
story(props: AppProps, target: GuiObject, config?: {
|
|
31
21
|
render?: Types.Props.Render;
|
|
32
22
|
minScale?: number;
|
|
33
23
|
}): Frame;
|
|
34
|
-
mount(node: Vide.Node, props: Types.Props.Main, target: Instance): Destructor;
|
|
35
|
-
unMount(): void;
|
|
24
|
+
mount(node: Vide.Node, props: Exclude<Types.Props.Main, "forge">, target: Instance): Destructor;
|
|
36
25
|
}
|
|
37
26
|
export {};
|
package/out/mount.luau
CHANGED
|
@@ -12,7 +12,7 @@ local mount = _vide.mount
|
|
|
12
12
|
local source = _vide.source
|
|
13
13
|
local untrack = _vide.untrack
|
|
14
14
|
-- Classes
|
|
15
|
-
local Renders = TS.import(script, script.Parent, "
|
|
15
|
+
local Renders = TS.import(script, script.Parent, "renders").default
|
|
16
16
|
-- Helpers
|
|
17
17
|
local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
|
|
18
18
|
local Debugger = TS.import(script, script.Parent, "debugger").default
|
|
@@ -38,8 +38,6 @@ do
|
|
|
38
38
|
return self.logger:log(level, msg, data, trace)
|
|
39
39
|
end)
|
|
40
40
|
self.sources = {}
|
|
41
|
-
self.loaded = {}
|
|
42
|
-
self.__px = false
|
|
43
41
|
-- ▼ ReadonlyMap.forEach ▼
|
|
44
42
|
local _callback = function(_, name)
|
|
45
43
|
return self:createSource(name)
|
|
@@ -50,8 +48,8 @@ do
|
|
|
50
48
|
-- ▲ ReadonlyMap.forEach ▲
|
|
51
49
|
end
|
|
52
50
|
function AppForge:createSource(name)
|
|
53
|
-
local
|
|
54
|
-
local app = AppRegistry[
|
|
51
|
+
local _arg0 = `-{name}`
|
|
52
|
+
local app = AppRegistry[_arg0]
|
|
55
53
|
if not app then
|
|
56
54
|
self.logger:log("ERROR", "App not registered while creating source", {
|
|
57
55
|
name = name,
|
|
@@ -59,8 +57,8 @@ do
|
|
|
59
57
|
return nil
|
|
60
58
|
end
|
|
61
59
|
local _sources = self.sources
|
|
62
|
-
local
|
|
63
|
-
if _sources[
|
|
60
|
+
local _name = name
|
|
61
|
+
if _sources[_name] ~= nil then
|
|
64
62
|
return nil
|
|
65
63
|
end
|
|
66
64
|
local _debug = self.debug
|
|
@@ -96,11 +94,6 @@ do
|
|
|
96
94
|
end
|
|
97
95
|
return src
|
|
98
96
|
end
|
|
99
|
-
function AppForge:isLoaded(name)
|
|
100
|
-
local _loaded = self.loaded
|
|
101
|
-
local _name = name
|
|
102
|
-
return _loaded[_name] ~= nil
|
|
103
|
-
end
|
|
104
97
|
function AppForge:bind(name, value)
|
|
105
98
|
if not RunService:IsRunning() then
|
|
106
99
|
self.debug:logTag("state", name, "Binding external visibility source")
|
|
@@ -136,81 +129,6 @@ do
|
|
|
136
129
|
})
|
|
137
130
|
end
|
|
138
131
|
end
|
|
139
|
-
function AppForge:anchor(name, anchorName, props)
|
|
140
|
-
if name == anchorName then
|
|
141
|
-
self.logger:log("ERROR", "Attempted to anchor app to itself", {
|
|
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
|
|
206
|
-
end
|
|
207
|
-
self.debug:logTag("rules", name, "Applying ZIndex", {
|
|
208
|
-
index = index,
|
|
209
|
-
})
|
|
210
|
-
apply(loaded.container)({
|
|
211
|
-
ZIndex = index,
|
|
212
|
-
})
|
|
213
|
-
end
|
|
214
132
|
function AppForge:set(name, value, rules)
|
|
215
133
|
if rules == nil then
|
|
216
134
|
rules = true
|
|
@@ -261,7 +179,7 @@ do
|
|
|
261
179
|
end
|
|
262
180
|
self:set(name, not self:getSource(name)(), rules)
|
|
263
181
|
end
|
|
264
|
-
function AppForge:story(props, target,
|
|
182
|
+
function AppForge:story(props, target, config)
|
|
265
183
|
self.debug:logTag("lifecycle", "story", "Creating story mount")
|
|
266
184
|
local Container = create("Frame")({
|
|
267
185
|
Name = "Story Container",
|
|
@@ -278,8 +196,8 @@ do
|
|
|
278
196
|
props = props,
|
|
279
197
|
forge = self,
|
|
280
198
|
}
|
|
281
|
-
local _left_1 = "
|
|
282
|
-
local _result =
|
|
199
|
+
local _left_1 = "renders"
|
|
200
|
+
local _result = config
|
|
283
201
|
if _result ~= nil then
|
|
284
202
|
_result = _result.render
|
|
285
203
|
end
|
|
@@ -291,34 +209,33 @@ do
|
|
|
291
209
|
target = target,
|
|
292
210
|
}
|
|
293
211
|
local _left_4 = "minScale"
|
|
294
|
-
local _result_1 =
|
|
212
|
+
local _result_1 = config
|
|
295
213
|
if _result_1 ~= nil then
|
|
296
214
|
_result_1 = _result_1.minScale
|
|
297
215
|
end
|
|
298
216
|
_object_3[_left_4] = _result_1
|
|
299
217
|
_object_2[_left_3] = _object_3
|
|
300
218
|
_object_1[_left_2] = _object_2
|
|
301
|
-
_object[_left] = _self:
|
|
219
|
+
_object[_left] = _self:initalize(_object_1)
|
|
302
220
|
_fn(_object)
|
|
303
221
|
return Container
|
|
304
222
|
end
|
|
305
223
|
function AppForge:mount(node, props, target)
|
|
306
224
|
self.debug:logTag("lifecycle", "mount", "Mounting AppForge")
|
|
307
225
|
self.innerMount = mount(function()
|
|
308
|
-
apply(node)
|
|
309
|
-
|
|
310
|
-
|
|
226
|
+
local _fn = apply(node)
|
|
227
|
+
local _object = {}
|
|
228
|
+
local _left = 0
|
|
229
|
+
local _self = self
|
|
230
|
+
local _object_1 = table.clone(props)
|
|
231
|
+
setmetatable(_object_1, nil)
|
|
232
|
+
_object_1.forge = self
|
|
233
|
+
_object[_left] = _self:initalize(_object_1)
|
|
234
|
+
_fn(_object)
|
|
311
235
|
return node
|
|
312
236
|
end, target)
|
|
313
237
|
return self.innerMount
|
|
314
238
|
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
239
|
end
|
|
323
240
|
return {
|
|
324
241
|
default = AppForge,
|
package/out/renders.d.ts
ADDED
package/out/renders.luau
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Packages
|
|
4
|
+
-- Types
|
|
5
|
+
-- Components
|
|
6
|
+
-- Hooks
|
|
7
|
+
local usePx = TS.import(script, script.Parent, "hooks", "usePx").usePx
|
|
8
|
+
-- Classes
|
|
9
|
+
local Rules = TS.import(script, script.Parent, "ruleEngine").default
|
|
10
|
+
local Renders
|
|
11
|
+
do
|
|
12
|
+
local super = Rules
|
|
13
|
+
Renders = setmetatable({}, {
|
|
14
|
+
__tostring = function()
|
|
15
|
+
return "Renders"
|
|
16
|
+
end,
|
|
17
|
+
__index = super,
|
|
18
|
+
})
|
|
19
|
+
Renders.__index = Renders
|
|
20
|
+
function Renders.new(...)
|
|
21
|
+
local self = setmetatable({}, Renders)
|
|
22
|
+
return self:constructor(...) or self
|
|
23
|
+
end
|
|
24
|
+
function Renders:constructor()
|
|
25
|
+
super.constructor(self)
|
|
26
|
+
self.__px = false
|
|
27
|
+
end
|
|
28
|
+
function Renders:render(name, names, group)
|
|
29
|
+
print(name, names, group)
|
|
30
|
+
end
|
|
31
|
+
function Renders:initalize(props)
|
|
32
|
+
if not self.__px then
|
|
33
|
+
local _result = props.config
|
|
34
|
+
if _result ~= nil then
|
|
35
|
+
_result = _result.px.target
|
|
36
|
+
end
|
|
37
|
+
local _result_1 = props.config
|
|
38
|
+
if _result_1 ~= nil then
|
|
39
|
+
_result_1 = _result_1.px.resolution
|
|
40
|
+
end
|
|
41
|
+
local _result_2 = props.config
|
|
42
|
+
if _result_2 ~= nil then
|
|
43
|
+
_result_2 = _result_2.px.minScale
|
|
44
|
+
end
|
|
45
|
+
usePx(_result, _result_1, _result_2)
|
|
46
|
+
self.__px = true
|
|
47
|
+
end
|
|
48
|
+
local _self = self
|
|
49
|
+
local _result = props.renders
|
|
50
|
+
if _result ~= nil then
|
|
51
|
+
_result = _result.name
|
|
52
|
+
end
|
|
53
|
+
local _result_1 = props.renders
|
|
54
|
+
if _result_1 ~= nil then
|
|
55
|
+
_result_1 = _result_1.names
|
|
56
|
+
end
|
|
57
|
+
local _result_2 = props.renders
|
|
58
|
+
if _result_2 ~= nil then
|
|
59
|
+
_result_2 = _result_2.group
|
|
60
|
+
end
|
|
61
|
+
_self:render(_result, _result_1, _result_2)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
return {
|
|
65
|
+
default = Renders,
|
|
66
|
+
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Types
|
|
4
4
|
-- Components
|
|
5
|
-
local AppRegistry = TS.import(script, script.Parent.Parent, "appRegistry").AppRegistry
|
|
6
|
-
local function ExclusiveGroupRule(
|
|
7
|
-
local
|
|
8
|
-
local entryApp = AppRegistry[
|
|
5
|
+
local AppRegistry = TS.import(script, script.Parent.Parent.Parent, "appRegistry").AppRegistry
|
|
6
|
+
local function ExclusiveGroupRule(name, forge)
|
|
7
|
+
local _name = name
|
|
8
|
+
local entryApp = AppRegistry[_name]
|
|
9
9
|
local _group = entryApp
|
|
10
10
|
if _group ~= nil then
|
|
11
11
|
_group = _group.rules
|
|
@@ -17,14 +17,14 @@ local function ExclusiveGroupRule(entry, forge)
|
|
|
17
17
|
if not (group ~= "" and group) then
|
|
18
18
|
return nil
|
|
19
19
|
end
|
|
20
|
-
local entryVisible = forge:getSource(
|
|
20
|
+
local entryVisible = forge:getSource(name)()
|
|
21
21
|
if not entryVisible then
|
|
22
22
|
return nil
|
|
23
23
|
end
|
|
24
|
-
forge.debug:logTag("rules",
|
|
24
|
+
forge.debug:logTag("rules", name, "Exclusive group activated", group)
|
|
25
25
|
-- ▼ ReadonlyMap.forEach ▼
|
|
26
26
|
local _callback = function(app, name)
|
|
27
|
-
if name ==
|
|
27
|
+
if name == name then
|
|
28
28
|
return nil
|
|
29
29
|
end
|
|
30
30
|
local _result = app.rules
|
|
@@ -38,7 +38,7 @@ local function ExclusiveGroupRule(entry, forge)
|
|
|
38
38
|
if not visible then
|
|
39
39
|
return nil
|
|
40
40
|
end
|
|
41
|
-
forge.debug:logTag("rules",
|
|
41
|
+
forge.debug:logTag("rules", name, "Closing app due to exclusive group", {
|
|
42
42
|
closed = name,
|
|
43
43
|
group = group,
|
|
44
44
|
})
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
local function ParentRule(name, forge)
|
|
7
|
+
local _name = name
|
|
8
|
+
local entry = AppRegistry[_name]
|
|
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 _forge = forge
|
|
20
|
+
local _result_1 = entry
|
|
21
|
+
if _result_1 ~= nil then
|
|
22
|
+
_result_1 = _result_1.rules
|
|
23
|
+
if _result_1 ~= nil then
|
|
24
|
+
_result_1 = _result_1.parent
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
local parentSource = _forge:getSource(_result_1)
|
|
28
|
+
if not parentSource() then
|
|
29
|
+
local source = forge:getSource(name)
|
|
30
|
+
if source() then
|
|
31
|
+
source(false)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
return {
|
|
36
|
+
default = ParentRule,
|
|
37
|
+
}
|
package/out/ruleEngine/init.luau
CHANGED
|
@@ -4,8 +4,9 @@ local TS = _G[script]
|
|
|
4
4
|
-- Components
|
|
5
5
|
local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
|
|
6
6
|
-- Rules
|
|
7
|
-
local ExclusiveGroupRule = TS.import(script, script, "exclusiveGroup").default
|
|
8
|
-
local ParentRule = TS.import(script, script, "parent").default
|
|
7
|
+
local ExclusiveGroupRule = TS.import(script, script, "check", "exclusiveGroup").default
|
|
8
|
+
local ParentRule = TS.import(script, script, "check", "parent").default
|
|
9
|
+
local AnchorRule = TS.import(script, script, "render", "anchor").default
|
|
9
10
|
local Rules
|
|
10
11
|
do
|
|
11
12
|
Rules = setmetatable({}, {
|
|
@@ -34,18 +35,19 @@ do
|
|
|
34
35
|
-- Parent Anchor
|
|
35
36
|
local _condition = rules.parent
|
|
36
37
|
if _condition ~= "" and _condition then
|
|
37
|
-
_condition = not rules.
|
|
38
|
+
_condition = not rules.anchor
|
|
38
39
|
end
|
|
39
40
|
if _condition ~= "" and _condition then
|
|
40
41
|
forge.debug:logTag("rules", name, "Applying parent anchor", {
|
|
41
42
|
parent = rules.parent,
|
|
42
43
|
})
|
|
43
|
-
|
|
44
|
+
AnchorRule(name, props)
|
|
44
45
|
end
|
|
45
46
|
-- Index
|
|
46
47
|
if rules.zIndex ~= nil then
|
|
47
48
|
forge.debug:logTag("rules", name, "Applying ZIndex", rules.zIndex)
|
|
48
|
-
|
|
49
|
+
-- TODO: will be a separate file under ruleEngine
|
|
50
|
+
-- forge.index(name, rules.zIndex);
|
|
49
51
|
end
|
|
50
52
|
end
|
|
51
53
|
function Rules:checkRules(forge, name)
|
|
@@ -0,0 +1,38 @@
|
|
|
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")
|
|
6
|
+
local AppRegistry = _appRegistry.AppRegistry
|
|
7
|
+
local AppsLoaded = _appRegistry.AppsLoaded
|
|
8
|
+
local function anchor(name, props)
|
|
9
|
+
local _binding = props
|
|
10
|
+
local forge = _binding.forge
|
|
11
|
+
local _name = name
|
|
12
|
+
local app = AppRegistry[_name]
|
|
13
|
+
local _result = app
|
|
14
|
+
if _result ~= nil then
|
|
15
|
+
_result = _result.renderGroup
|
|
16
|
+
end
|
|
17
|
+
local _condition = _result
|
|
18
|
+
if _condition == nil then
|
|
19
|
+
_condition = "None"
|
|
20
|
+
end
|
|
21
|
+
local _arg0 = `{_condition}-{name}`
|
|
22
|
+
local loaded = AppsLoaded[_arg0]
|
|
23
|
+
local _result_1 = app
|
|
24
|
+
if _result_1 ~= nil then
|
|
25
|
+
_result_1 = _result_1.rules
|
|
26
|
+
if _result_1 ~= nil then
|
|
27
|
+
_result_1 = _result_1.parent
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
local parentApp = AppRegistry[_result_1]
|
|
31
|
+
if not parentApp then
|
|
32
|
+
forge.debug:logTag("rules", name, `Has no Parent to Anchor to, Remove the Anchor For {name}`)
|
|
33
|
+
end
|
|
34
|
+
print(`App: {app} \n Loaded: {loaded} \n parentApp: {parentApp}`)
|
|
35
|
+
end
|
|
36
|
+
return {
|
|
37
|
+
default = anchor,
|
|
38
|
+
}
|
package/out/types.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare namespace Types {
|
|
|
21
21
|
minScale?: number;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
renders?: Render;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
type Class = AppProps & {
|
|
@@ -58,12 +58,12 @@ declare namespace Types {
|
|
|
58
58
|
namespace Rules {
|
|
59
59
|
type WithParent<P> = {
|
|
60
60
|
parent: P;
|
|
61
|
-
|
|
61
|
+
anchor?: boolean;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
type WithoutParent = {
|
|
65
65
|
parent?: never;
|
|
66
|
-
|
|
66
|
+
anchor?: never;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
export type Static = {
|
package/package.json
CHANGED
package/out/renderManager.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import Vide from "@rbxts/vide";
|
|
2
|
-
import type Types from "./types";
|
|
3
|
-
import type AppForge from "./mount";
|
|
4
|
-
import Rules from "./ruleEngine";
|
|
5
|
-
export default class Renders extends Rules {
|
|
6
|
-
protected anchored: Map<string, {
|
|
7
|
-
id: AppNames;
|
|
8
|
-
render: Vide.Node;
|
|
9
|
-
}>;
|
|
10
|
-
constructor();
|
|
11
|
-
/**
|
|
12
|
-
* Entry point for mounting renders.
|
|
13
|
-
* Decides render strategy based on props.
|
|
14
|
-
*/
|
|
15
|
-
protected renderMount(this: AppForge, props: Types.Props.Main): Vide.Node;
|
|
16
|
-
/**
|
|
17
|
-
* Render multiple apps by name, avoiding duplicates.
|
|
18
|
-
*/
|
|
19
|
-
private renderNames;
|
|
20
|
-
/**
|
|
21
|
-
* Render children of a parent app recursively inside parent container
|
|
22
|
-
*/
|
|
23
|
-
private renderChildren;
|
|
24
|
-
private collectByGroup;
|
|
25
|
-
private normalizeGroups;
|
|
26
|
-
protected renderApp(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>, parentContainer?: Instance): Vide.Node;
|
|
27
|
-
protected renderApps(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
28
|
-
protected renderGroup(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
29
|
-
protected renderGroupByName(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
30
|
-
protected renderGroupByNames(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
31
|
-
protected renderAll(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
32
|
-
}
|
package/out/renderManager.luau
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
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 apply = _vide.apply
|
|
6
|
-
local create = _vide.create
|
|
7
|
-
local mount = _vide.mount
|
|
8
|
-
-- Types
|
|
9
|
-
-- Components
|
|
10
|
-
local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
|
|
11
|
-
-- Hooks
|
|
12
|
-
local usePx = TS.import(script, script.Parent, "hooks", "usePx").usePx
|
|
13
|
-
-- Classes
|
|
14
|
-
local Rules = TS.import(script, script.Parent, "ruleEngine").default
|
|
15
|
-
local Renders
|
|
16
|
-
do
|
|
17
|
-
local super = Rules
|
|
18
|
-
Renders = setmetatable({}, {
|
|
19
|
-
__tostring = function()
|
|
20
|
-
return "Renders"
|
|
21
|
-
end,
|
|
22
|
-
__index = super,
|
|
23
|
-
})
|
|
24
|
-
Renders.__index = Renders
|
|
25
|
-
function Renders.new(...)
|
|
26
|
-
local self = setmetatable({}, Renders)
|
|
27
|
-
return self:constructor(...) or self
|
|
28
|
-
end
|
|
29
|
-
function Renders:constructor()
|
|
30
|
-
super.constructor(self)
|
|
31
|
-
self.anchored = {}
|
|
32
|
-
end
|
|
33
|
-
function Renders:renderMount(props)
|
|
34
|
-
local _binding = props
|
|
35
|
-
local config = _binding.config
|
|
36
|
-
local render = _binding.render
|
|
37
|
-
local forge = _binding.forge
|
|
38
|
-
if not forge.__px then
|
|
39
|
-
local _debug = forge.debug
|
|
40
|
-
local _result = config
|
|
41
|
-
if _result ~= nil then
|
|
42
|
-
_result = _result.px
|
|
43
|
-
end
|
|
44
|
-
_debug:logTag("px", "global", "Initializing px scaling", _result)
|
|
45
|
-
local _result_1 = config
|
|
46
|
-
if _result_1 ~= nil then
|
|
47
|
-
_result_1 = _result_1.px.target
|
|
48
|
-
end
|
|
49
|
-
local _result_2 = config
|
|
50
|
-
if _result_2 ~= nil then
|
|
51
|
-
_result_2 = _result_2.px.resolution
|
|
52
|
-
end
|
|
53
|
-
local _result_3 = config
|
|
54
|
-
if _result_3 ~= nil then
|
|
55
|
-
_result_3 = _result_3.px.minScale
|
|
56
|
-
end
|
|
57
|
-
usePx(_result_1, _result_2, _result_3)
|
|
58
|
-
forge.__px = true
|
|
59
|
-
else
|
|
60
|
-
forge.debug:logTag("px", "global", "Skipped duplicate px initialization")
|
|
61
|
-
end
|
|
62
|
-
local renderedSet = {}
|
|
63
|
-
if render then
|
|
64
|
-
local _condition = render.name
|
|
65
|
-
if _condition ~= "" and _condition then
|
|
66
|
-
_condition = render.group
|
|
67
|
-
end
|
|
68
|
-
if _condition ~= "" and _condition then
|
|
69
|
-
return self:renderGroupByName(props, renderedSet)
|
|
70
|
-
end
|
|
71
|
-
local _value = render.names and render.group
|
|
72
|
-
if _value ~= "" and _value then
|
|
73
|
-
return self:renderGroupByNames(props, renderedSet)
|
|
74
|
-
end
|
|
75
|
-
local _value_1 = render.name
|
|
76
|
-
if _value_1 ~= "" and _value_1 then
|
|
77
|
-
return self:renderApp(props, renderedSet)
|
|
78
|
-
end
|
|
79
|
-
if render.names then
|
|
80
|
-
return self:renderApps(props, renderedSet)
|
|
81
|
-
end
|
|
82
|
-
local _value_2 = render.group
|
|
83
|
-
if _value_2 ~= "" and _value_2 then
|
|
84
|
-
return self:renderGroup(props, renderedSet)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
return self:renderAll(props, renderedSet)
|
|
88
|
-
end
|
|
89
|
-
function Renders:renderNames(props, names, forge, context, renderedSet, details, parentContainer)
|
|
90
|
-
if not names then
|
|
91
|
-
local _logger = forge.logger
|
|
92
|
-
local _exp = `Renderer resolved 0 apps ({context})`
|
|
93
|
-
local _condition = details
|
|
94
|
-
if _condition == nil then
|
|
95
|
-
_condition = props.render
|
|
96
|
-
end
|
|
97
|
-
_logger:log("WARN", _exp, _condition)
|
|
98
|
-
return {}
|
|
99
|
-
end
|
|
100
|
-
local rendered = {}
|
|
101
|
-
for _, name in names do
|
|
102
|
-
if renderedSet[name] ~= nil then
|
|
103
|
-
continue
|
|
104
|
-
end
|
|
105
|
-
renderedSet[name] = true
|
|
106
|
-
local _forge = forge
|
|
107
|
-
local _object = table.clone(props)
|
|
108
|
-
setmetatable(_object, nil)
|
|
109
|
-
_object.render = {
|
|
110
|
-
name = name,
|
|
111
|
-
}
|
|
112
|
-
local appRender = _forge:renderApp(_object, renderedSet, parentContainer)
|
|
113
|
-
table.insert(rendered, appRender)
|
|
114
|
-
self:renderChildren(props, name, forge, renderedSet, rendered, appRender)
|
|
115
|
-
end
|
|
116
|
-
return rendered
|
|
117
|
-
end
|
|
118
|
-
function Renders:renderChildren(props, parentName, forge, renderedSet, accumulated, parentContainer)
|
|
119
|
-
-- ▼ ReadonlyMap.forEach ▼
|
|
120
|
-
local _callback = function(app, childName)
|
|
121
|
-
local _result = app.rules
|
|
122
|
-
if _result ~= nil then
|
|
123
|
-
_result = _result.parent
|
|
124
|
-
end
|
|
125
|
-
local _condition = _result == parentName
|
|
126
|
-
if _condition then
|
|
127
|
-
local _renderedSet = renderedSet
|
|
128
|
-
local _childName = childName
|
|
129
|
-
_condition = not (_renderedSet[_childName] ~= nil)
|
|
130
|
-
end
|
|
131
|
-
if _condition then
|
|
132
|
-
local _renderedSet = renderedSet
|
|
133
|
-
local _childName = childName
|
|
134
|
-
_renderedSet[_childName] = true
|
|
135
|
-
local _forge = forge
|
|
136
|
-
local _object = table.clone(props)
|
|
137
|
-
setmetatable(_object, nil)
|
|
138
|
-
_object.render = {
|
|
139
|
-
name = childName,
|
|
140
|
-
}
|
|
141
|
-
local childRender = _forge:renderApp(_object, renderedSet, parentContainer)
|
|
142
|
-
table.insert(accumulated, childRender)
|
|
143
|
-
mount(function()
|
|
144
|
-
return childRender
|
|
145
|
-
end, parentContainer)
|
|
146
|
-
self:renderChildren(props, childName, forge, renderedSet, accumulated, childRender)
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
for _k, _v in AppRegistry do
|
|
150
|
-
_callback(_v, _k, AppRegistry)
|
|
151
|
-
end
|
|
152
|
-
-- ▲ ReadonlyMap.forEach ▲
|
|
153
|
-
end
|
|
154
|
-
function Renders:collectByGroup(groups, filter)
|
|
155
|
-
local result = {}
|
|
156
|
-
-- ▼ ReadonlyMap.forEach ▼
|
|
157
|
-
local _callback = function(app, name)
|
|
158
|
-
local appGroup = app.renderGroup
|
|
159
|
-
if not (appGroup ~= "" and appGroup) then
|
|
160
|
-
return nil
|
|
161
|
-
end
|
|
162
|
-
if not (table.find(groups, appGroup) ~= nil) then
|
|
163
|
-
return nil
|
|
164
|
-
end
|
|
165
|
-
if filter and not filter(name) then
|
|
166
|
-
return nil
|
|
167
|
-
end
|
|
168
|
-
local _name = name
|
|
169
|
-
table.insert(result, _name)
|
|
170
|
-
end
|
|
171
|
-
for _k, _v in AppRegistry do
|
|
172
|
-
_callback(_v, _k, AppRegistry)
|
|
173
|
-
end
|
|
174
|
-
-- ▲ ReadonlyMap.forEach ▲
|
|
175
|
-
return result
|
|
176
|
-
end
|
|
177
|
-
function Renders:normalizeGroups(group)
|
|
178
|
-
local _group = group
|
|
179
|
-
local _result
|
|
180
|
-
if type(_group) == "table" then
|
|
181
|
-
local _array = {}
|
|
182
|
-
local _length = #_array
|
|
183
|
-
table.move(group, 1, #group, _length + 1, _array)
|
|
184
|
-
_result = _array
|
|
185
|
-
else
|
|
186
|
-
_result = { group }
|
|
187
|
-
end
|
|
188
|
-
return _result
|
|
189
|
-
end
|
|
190
|
-
function Renders:renderApp(props, renderedSet, parentContainer)
|
|
191
|
-
local _name = props.render
|
|
192
|
-
if _name ~= nil then
|
|
193
|
-
_name = _name.name
|
|
194
|
-
end
|
|
195
|
-
local name = _name
|
|
196
|
-
if not (name ~= "" and name) then
|
|
197
|
-
error("renderApp requires an app name", 2)
|
|
198
|
-
end
|
|
199
|
-
local appClass = AppRegistry[name]
|
|
200
|
-
if not appClass then
|
|
201
|
-
error(`App "{name}" not registered`, 2)
|
|
202
|
-
end
|
|
203
|
-
self.debug:time("render", name)
|
|
204
|
-
if not (self.loaded[name] ~= nil) then
|
|
205
|
-
local render = appClass.constructor.new(props, name):render()
|
|
206
|
-
if not render then
|
|
207
|
-
error(`App "{name}" returned undefined from render()`, 2)
|
|
208
|
-
end
|
|
209
|
-
apply(render)({
|
|
210
|
-
Name = "Render",
|
|
211
|
-
})
|
|
212
|
-
local container = create("Frame")({
|
|
213
|
-
Name = name,
|
|
214
|
-
BackgroundTransparency = 1,
|
|
215
|
-
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
216
|
-
Position = UDim2.fromScale(0.5, 0.5),
|
|
217
|
-
Size = UDim2.fromScale(1, 1),
|
|
218
|
-
[0] = render,
|
|
219
|
-
})
|
|
220
|
-
if parentContainer then
|
|
221
|
-
container.Parent = parentContainer
|
|
222
|
-
end
|
|
223
|
-
local _loaded = self.loaded
|
|
224
|
-
local _arg1 = {
|
|
225
|
-
container = container,
|
|
226
|
-
render = render,
|
|
227
|
-
}
|
|
228
|
-
_loaded[name] = _arg1
|
|
229
|
-
else
|
|
230
|
-
self.debug:logTag("render", name, "Reusing existing render instance")
|
|
231
|
-
end
|
|
232
|
-
local _result = renderedSet
|
|
233
|
-
if _result ~= nil then
|
|
234
|
-
_result[name] = true
|
|
235
|
-
end
|
|
236
|
-
self:renderRules(self, name, props)
|
|
237
|
-
self.debug:timeEnd("render", name)
|
|
238
|
-
return self.loaded[name].container
|
|
239
|
-
end
|
|
240
|
-
function Renders:renderApps(props, renderedSet)
|
|
241
|
-
if renderedSet == nil then
|
|
242
|
-
renderedSet = {}
|
|
243
|
-
end
|
|
244
|
-
local _names = props.render
|
|
245
|
-
if _names ~= nil then
|
|
246
|
-
_names = _names.names
|
|
247
|
-
end
|
|
248
|
-
local names = _names
|
|
249
|
-
if not names then
|
|
250
|
-
error("renderApps requires app names", 2)
|
|
251
|
-
end
|
|
252
|
-
return self:renderNames(props, names, self, "renderApps", renderedSet, names)
|
|
253
|
-
end
|
|
254
|
-
function Renders:renderGroup(props, renderedSet)
|
|
255
|
-
if renderedSet == nil then
|
|
256
|
-
renderedSet = {}
|
|
257
|
-
end
|
|
258
|
-
local _group = props.render
|
|
259
|
-
if _group ~= nil then
|
|
260
|
-
_group = _group.group
|
|
261
|
-
end
|
|
262
|
-
local group = _group
|
|
263
|
-
if not (group ~= "" and group) then
|
|
264
|
-
error("renderGroup requires a group", 2)
|
|
265
|
-
end
|
|
266
|
-
local groups = self:normalizeGroups(group)
|
|
267
|
-
return self:renderNames(props, self:collectByGroup(groups), self, "renderGroup", renderedSet, group)
|
|
268
|
-
end
|
|
269
|
-
function Renders:renderGroupByName(props, renderedSet)
|
|
270
|
-
if renderedSet == nil then
|
|
271
|
-
renderedSet = {}
|
|
272
|
-
end
|
|
273
|
-
local _binding = props.render or {}
|
|
274
|
-
local group = _binding.group
|
|
275
|
-
local name = _binding.name
|
|
276
|
-
if not (group ~= "" and group) or not (name ~= "" and name) then
|
|
277
|
-
error("Invalid renderGroupByName call", 2)
|
|
278
|
-
end
|
|
279
|
-
local groups = self:normalizeGroups(group)
|
|
280
|
-
return self:renderNames(props, self:collectByGroup(groups, function(n)
|
|
281
|
-
return n == name
|
|
282
|
-
end), self, "renderGroupByName", renderedSet, {
|
|
283
|
-
group = group,
|
|
284
|
-
name = name,
|
|
285
|
-
})
|
|
286
|
-
end
|
|
287
|
-
function Renders:renderGroupByNames(props, renderedSet)
|
|
288
|
-
if renderedSet == nil then
|
|
289
|
-
renderedSet = {}
|
|
290
|
-
end
|
|
291
|
-
local _binding = props.render or {}
|
|
292
|
-
local group = _binding.group
|
|
293
|
-
local names = _binding.names
|
|
294
|
-
if not (group ~= "" and group) or not names then
|
|
295
|
-
error("Invalid renderGroupByNames call", 2)
|
|
296
|
-
end
|
|
297
|
-
local groups = self:normalizeGroups(group)
|
|
298
|
-
return self:renderNames(props, self:collectByGroup(groups, function(n)
|
|
299
|
-
local _n = n
|
|
300
|
-
return table.find(names, _n) ~= nil
|
|
301
|
-
end), self, "renderGroupByNames", renderedSet, {
|
|
302
|
-
group = group,
|
|
303
|
-
names = names,
|
|
304
|
-
})
|
|
305
|
-
end
|
|
306
|
-
function Renders:renderAll(props, renderedSet)
|
|
307
|
-
if renderedSet == nil then
|
|
308
|
-
renderedSet = {}
|
|
309
|
-
end
|
|
310
|
-
local names = {}
|
|
311
|
-
-- ▼ ReadonlyMap.forEach ▼
|
|
312
|
-
local _callback = function(_, name)
|
|
313
|
-
local _name = name
|
|
314
|
-
table.insert(names, _name)
|
|
315
|
-
return #names
|
|
316
|
-
end
|
|
317
|
-
for _k, _v in AppRegistry do
|
|
318
|
-
_callback(_v, _k, AppRegistry)
|
|
319
|
-
end
|
|
320
|
-
-- ▲ ReadonlyMap.forEach ▲
|
|
321
|
-
return self:renderNames(props, names, self, "renderAll", renderedSet)
|
|
322
|
-
end
|
|
323
|
-
end
|
|
324
|
-
return {
|
|
325
|
-
default = Renders,
|
|
326
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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, "appRegistry").AppRegistry
|
|
6
|
-
local function ParentRule(entry, forge)
|
|
7
|
-
local entryVisible = forge:getSource(entry)()
|
|
8
|
-
-- ▼ ReadonlyMap.forEach ▼
|
|
9
|
-
local _callback = function(app, name)
|
|
10
|
-
local rules = app.rules
|
|
11
|
-
if not rules or rules.parent ~= entry then
|
|
12
|
-
return nil
|
|
13
|
-
end
|
|
14
|
-
if name == entry then
|
|
15
|
-
return nil
|
|
16
|
-
end
|
|
17
|
-
local childVisible = forge:getSource(name)()
|
|
18
|
-
if entryVisible or not childVisible then
|
|
19
|
-
return nil
|
|
20
|
-
end
|
|
21
|
-
forge.debug:logTag("rules", entry, "Closing child app (parent closed)", {
|
|
22
|
-
parent = entry,
|
|
23
|
-
child = name,
|
|
24
|
-
})
|
|
25
|
-
forge:close(name, false)
|
|
26
|
-
end
|
|
27
|
-
for _k, _v in AppRegistry do
|
|
28
|
-
_callback(_v, _k, AppRegistry)
|
|
29
|
-
end
|
|
30
|
-
-- ▲ ReadonlyMap.forEach ▲
|
|
31
|
-
end
|
|
32
|
-
return {
|
|
33
|
-
default = ParentRule,
|
|
34
|
-
}
|