@rbxts/app-forge 0.6.0-alpha.9 → 0.7.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/README.md +334 -149
- package/out/global.d.ts +2 -3
- package/out/index.d.ts +6 -3
- package/out/init.luau +4 -1
- package/out/react/container.luau +1 -21
- package/out/react/context.d.ts +7 -0
- package/out/react/context.luau +12 -0
- package/out/react/decorator.d.ts +1 -1
- package/out/react/decorator.luau +3 -7
- package/out/react/helpers.d.ts +4 -1
- package/out/react/helpers.luau +58 -0
- package/out/react/hooks/useAppContext.d.ts +5 -0
- package/out/react/hooks/useAppContext.luau +16 -0
- package/out/react/index.d.ts +11 -7
- package/out/react/init.luau +23 -21
- package/out/react/rules/index.d.ts +6 -0
- package/out/react/rules/init.luau +27 -0
- package/out/react/rules/parent.d.ts +2 -0
- package/out/react/rules/parent.luau +42 -0
- package/out/react/types.d.ts +5 -14
- package/out/vide/classes/renders.d.ts +21 -0
- package/out/vide/classes/renders.luau +251 -0
- package/out/vide/classes/rules/exclusiveGroup.d.ts +2 -0
- package/out/vide/classes/rules/exclusiveGroup.luau +47 -0
- package/out/vide/classes/rules/index.d.ts +7 -0
- package/out/vide/classes/rules/init.luau +70 -0
- package/out/vide/classes/rules/parent.d.ts +2 -0
- package/out/vide/classes/rules/parent.luau +29 -0
- package/out/vide/context.d.ts +7 -0
- package/out/vide/context.luau +12 -0
- package/out/vide/decorator.d.ts +5 -5
- package/out/vide/decorator.luau +4 -7
- package/out/vide/hooks/useAppContext.d.ts +5 -0
- package/out/vide/hooks/useAppContext.luau +14 -0
- package/out/vide/index.d.ts +28 -13
- package/out/vide/init.luau +179 -66
- package/out/vide/types.d.ts +68 -42
- package/package.json +11 -17
- package/out/react/rules.d.ts +0 -11
- package/out/react/rules.luau +0 -196
- package/out/vide/container.d.ts +0 -2
- package/out/vide/container.luau +0 -83
- package/out/vide/helpers.d.ts +0 -3
- package/out/vide/helpers.luau +0 -40
- package/out/vide/rules.d.ts +0 -12
- package/out/vide/rules.luau +0 -198
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Packages
|
|
4
|
+
local createContext = TS.import(script, TS.getModule(script, "@rbxts", "react")).createContext
|
|
5
|
+
-- Types
|
|
6
|
+
local Contexts = {
|
|
7
|
+
App = createContext(nil),
|
|
8
|
+
}
|
|
9
|
+
local default = Contexts
|
|
10
|
+
return {
|
|
11
|
+
default = default,
|
|
12
|
+
}
|
package/out/react/decorator.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare function App(props: Types.AppRegistryProps): <T extends new (prop
|
|
|
6
6
|
export declare abstract class Args {
|
|
7
7
|
readonly forge: AppForge;
|
|
8
8
|
readonly props: Types.ClassProps;
|
|
9
|
-
readonly name: AppNames
|
|
9
|
+
readonly name: AppNames;
|
|
10
10
|
readonly bind: React.Binding<boolean>;
|
|
11
11
|
readonly state: Boolean;
|
|
12
12
|
constructor(props: Types.NameProps & Types.MainProps);
|
package/out/react/decorator.luau
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Services
|
|
4
|
-
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
5
4
|
-- Packages
|
|
6
5
|
local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-react-hooks").out).usePx
|
|
7
6
|
-- Types
|
|
@@ -33,19 +32,16 @@ do
|
|
|
33
32
|
if not (name ~= "" and name) then
|
|
34
33
|
error("App name is required in Args constructor")
|
|
35
34
|
end
|
|
36
|
-
local bind = forge:getBind(name)
|
|
37
|
-
if not bind and RunService:IsRunning() then
|
|
38
|
-
error("FAILED TO GET BIND FOR APP!")
|
|
39
|
-
end
|
|
40
35
|
local px = usePx(target)
|
|
41
36
|
self.forge = forge
|
|
42
37
|
local _object = table.clone(props.props)
|
|
43
38
|
setmetatable(_object, nil)
|
|
44
39
|
_object.px = px
|
|
40
|
+
_object.forge = forge
|
|
45
41
|
self.props = _object
|
|
46
42
|
self.name = name
|
|
47
|
-
self.bind =
|
|
48
|
-
self.state =
|
|
43
|
+
self.bind = forge:getBind(name)
|
|
44
|
+
self.state = forge:getState(name)
|
|
49
45
|
end
|
|
50
46
|
end
|
|
51
47
|
return {
|
package/out/react/helpers.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
|
-
import Types from "./types";
|
|
2
|
+
import type Types from "./types";
|
|
3
|
+
import type AppForge from ".";
|
|
4
|
+
export declare function createBinding(name: AppNames, forge: AppForge): void;
|
|
5
|
+
export declare function createState(name: AppNames, forge: AppForge): void;
|
|
3
6
|
export declare function Render(props: Types.NameProps & Types.MainProps): React.ReactNode;
|
package/out/react/helpers.luau
CHANGED
|
@@ -1,9 +1,65 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Packages
|
|
4
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
5
|
+
local useBinding = _react.useBinding
|
|
6
|
+
local useState = _react.useState
|
|
2
7
|
-- Types
|
|
8
|
+
-- Components
|
|
9
|
+
local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
|
|
10
|
+
local function createBinding(name, forge)
|
|
11
|
+
local _name = name
|
|
12
|
+
local app = AppRegistry[_name]
|
|
13
|
+
if not app then
|
|
14
|
+
error(`App "{name}" not registered`)
|
|
15
|
+
end
|
|
16
|
+
local _binds = forge.binds
|
|
17
|
+
local _name_1 = name
|
|
18
|
+
if _binds[_name_1] ~= nil then
|
|
19
|
+
return nil
|
|
20
|
+
end
|
|
21
|
+
local _condition = app.visible
|
|
22
|
+
if _condition == nil then
|
|
23
|
+
_condition = false
|
|
24
|
+
end
|
|
25
|
+
local binding = { useBinding(_condition) }
|
|
26
|
+
local _binds_1 = forge.binds
|
|
27
|
+
local _name_2 = name
|
|
28
|
+
_binds_1[_name_2] = binding
|
|
29
|
+
end
|
|
30
|
+
local function createState(name, forge)
|
|
31
|
+
local _name = name
|
|
32
|
+
local app = AppRegistry[_name]
|
|
33
|
+
if not app then
|
|
34
|
+
error(`App "{name}" not registered`)
|
|
35
|
+
end
|
|
36
|
+
local _states = forge.states
|
|
37
|
+
local _name_1 = name
|
|
38
|
+
if _states[_name_1] ~= nil then
|
|
39
|
+
return nil
|
|
40
|
+
end
|
|
41
|
+
local _condition = app.visible
|
|
42
|
+
if _condition == nil then
|
|
43
|
+
_condition = false
|
|
44
|
+
end
|
|
45
|
+
local state = { useState(_condition) }
|
|
46
|
+
local _states_1 = forge.states
|
|
47
|
+
local _name_2 = name
|
|
48
|
+
_states_1[_name_2] = state
|
|
49
|
+
end
|
|
3
50
|
local function Render(props)
|
|
4
51
|
local names = props.names
|
|
5
52
|
local name = props.name
|
|
6
53
|
local forge = props.forge
|
|
54
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
55
|
+
local _callback = function(_, name)
|
|
56
|
+
createBinding(name, forge)
|
|
57
|
+
createState(name, forge)
|
|
58
|
+
end
|
|
59
|
+
for _k, _v in AppRegistry do
|
|
60
|
+
_callback(_v, _k, AppRegistry)
|
|
61
|
+
end
|
|
62
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
7
63
|
if name ~= "" and name then
|
|
8
64
|
return forge:renderApp(props)
|
|
9
65
|
elseif names then
|
|
@@ -12,5 +68,7 @@ local function Render(props)
|
|
|
12
68
|
return forge:renderAll(props)
|
|
13
69
|
end
|
|
14
70
|
return {
|
|
71
|
+
createBinding = createBinding,
|
|
72
|
+
createState = createState,
|
|
15
73
|
Render = Render,
|
|
16
74
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Packages
|
|
4
|
+
local useContext = TS.import(script, TS.getModule(script, "@rbxts", "react")).useContext
|
|
5
|
+
-- Components
|
|
6
|
+
local Contexts = TS.import(script, script.Parent.Parent, "context").default
|
|
7
|
+
local default = function()
|
|
8
|
+
local context = useContext(Contexts.App)
|
|
9
|
+
if not context then
|
|
10
|
+
error(`Failed to retrieve App Props for React {debug.traceback()}`)
|
|
11
|
+
end
|
|
12
|
+
return context
|
|
13
|
+
end
|
|
14
|
+
return {
|
|
15
|
+
default = default,
|
|
16
|
+
}
|
package/out/react/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
2
|
import type Types from "./types";
|
|
3
|
+
type Binding = [React.Binding<boolean>, (T: boolean) => void];
|
|
4
|
+
type State = [boolean, React.Dispatch<React.SetStateAction<boolean>>];
|
|
3
5
|
export default class AppForge {
|
|
4
|
-
binds: Map<string, [React.Binding<boolean>, (T: boolean) => void]>;
|
|
5
6
|
loaded: Map<string, React.Element<any, string | React.JSXElementConstructor<any>>>;
|
|
7
|
+
binds: Map<string, Binding>;
|
|
8
|
+
states: Map<string, State>;
|
|
6
9
|
private rulesManager;
|
|
7
|
-
getBind(name: AppNames
|
|
8
|
-
getState(name: AppNames
|
|
9
|
-
set(name: AppNames
|
|
10
|
-
open(name: AppNames
|
|
11
|
-
close(name: AppNames
|
|
12
|
-
toggle(name: AppNames
|
|
10
|
+
getBind(name: AppNames): React.Binding<boolean>;
|
|
11
|
+
getState(name: AppNames): boolean;
|
|
12
|
+
set(name: AppNames, value: boolean): void;
|
|
13
|
+
open(name: AppNames): void;
|
|
14
|
+
close(name: AppNames): void;
|
|
15
|
+
toggle(name: AppNames): void;
|
|
13
16
|
renderApp(props: Types.NameProps & Types.MainProps): React.ReactElement<{
|
|
14
17
|
key: string;
|
|
15
18
|
ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
|
|
@@ -38,3 +41,4 @@ export default class AppForge {
|
|
|
38
41
|
Size: UDim2;
|
|
39
42
|
}, string | React.JSXElementConstructor<any>>)[];
|
|
40
43
|
}
|
|
44
|
+
export {};
|
package/out/react/init.luau
CHANGED
|
@@ -7,7 +7,10 @@ local AppContainer = TS.import(script, script, "container").AppContainer
|
|
|
7
7
|
local AppRegistry = TS.import(script, script, "decorator").AppRegistry
|
|
8
8
|
-- Classes
|
|
9
9
|
local RulesManager = TS.import(script, script, "rules").default
|
|
10
|
-
|
|
10
|
+
-- Helpers
|
|
11
|
+
local _helpers = TS.import(script, script, "helpers")
|
|
12
|
+
local createBinding = _helpers.createBinding
|
|
13
|
+
local createState = _helpers.createState
|
|
11
14
|
local AppForge
|
|
12
15
|
do
|
|
13
16
|
AppForge = setmetatable({}, {
|
|
@@ -21,49 +24,48 @@ do
|
|
|
21
24
|
return self:constructor(...) or self
|
|
22
25
|
end
|
|
23
26
|
function AppForge:constructor()
|
|
24
|
-
self.binds = {}
|
|
25
27
|
self.loaded = {}
|
|
28
|
+
self.binds = {}
|
|
29
|
+
self.states = {}
|
|
26
30
|
self.rulesManager = RulesManager.new(self)
|
|
27
31
|
end
|
|
28
32
|
function AppForge:getBind(name)
|
|
29
|
-
local _condition = not RunService:IsRunning()
|
|
30
|
-
if _condition then
|
|
31
|
-
local _binds = self.binds
|
|
32
|
-
local _name = name
|
|
33
|
-
_condition = not (_binds[_name] ~= nil)
|
|
34
|
-
end
|
|
35
|
-
if _condition then
|
|
36
|
-
return nil
|
|
37
|
-
end
|
|
38
33
|
local _binds = self.binds
|
|
39
34
|
local _name = name
|
|
40
35
|
if not (_binds[_name] ~= nil) then
|
|
41
|
-
|
|
36
|
+
createBinding(name, self)
|
|
42
37
|
end
|
|
43
38
|
local _binds_1 = self.binds
|
|
44
39
|
local _name_1 = name
|
|
45
40
|
return _binds_1[_name_1][1]
|
|
46
41
|
end
|
|
47
42
|
function AppForge:getState(name)
|
|
48
|
-
local
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
local _states = self.states
|
|
44
|
+
local _name = name
|
|
45
|
+
if not (_states[_name] ~= nil) then
|
|
46
|
+
createState(name, self)
|
|
51
47
|
end
|
|
52
|
-
|
|
48
|
+
local _states_1 = self.states
|
|
49
|
+
local _name_1 = name
|
|
50
|
+
return _states_1[_name_1][1]
|
|
53
51
|
end
|
|
54
52
|
function AppForge:set(name, value)
|
|
55
|
-
|
|
56
|
-
return nil
|
|
57
|
-
end
|
|
53
|
+
self.rulesManager:applyRules(name)
|
|
58
54
|
local _binds = self.binds
|
|
59
55
|
local _name = name
|
|
60
56
|
local _binding = _binds[_name]
|
|
61
|
-
local
|
|
57
|
+
local _b = _binding[1]
|
|
62
58
|
local setBinding = _binding[2]
|
|
59
|
+
local _states = self.states
|
|
60
|
+
local _name_1 = name
|
|
61
|
+
local _binding_1 = _states[_name_1]
|
|
62
|
+
local _s = _binding_1[1]
|
|
63
|
+
local setState = _binding_1[2]
|
|
63
64
|
if not setBinding then
|
|
64
|
-
|
|
65
|
+
createBinding(name, self)
|
|
65
66
|
end
|
|
66
67
|
setBinding(value)
|
|
68
|
+
setState(value)
|
|
67
69
|
end
|
|
68
70
|
function AppForge:open(name)
|
|
69
71
|
self:set(name, true)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Types
|
|
4
|
+
-- Rules
|
|
5
|
+
local ParentRule = TS.import(script, script, "parent").default
|
|
6
|
+
local RulesManager
|
|
7
|
+
do
|
|
8
|
+
RulesManager = setmetatable({}, {
|
|
9
|
+
__tostring = function()
|
|
10
|
+
return "RulesManager"
|
|
11
|
+
end,
|
|
12
|
+
})
|
|
13
|
+
RulesManager.__index = RulesManager
|
|
14
|
+
function RulesManager.new(...)
|
|
15
|
+
local self = setmetatable({}, RulesManager)
|
|
16
|
+
return self:constructor(...) or self
|
|
17
|
+
end
|
|
18
|
+
function RulesManager:constructor(forge)
|
|
19
|
+
self.forge = forge
|
|
20
|
+
end
|
|
21
|
+
function RulesManager:applyRules(name)
|
|
22
|
+
ParentRule(name, self.forge)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
return {
|
|
26
|
+
default = RulesManager,
|
|
27
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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, "decorator").AppRegistry
|
|
6
|
+
local function ParentRule(entry, forge)
|
|
7
|
+
local children = {}
|
|
8
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
9
|
+
local _callback = function(app, name)
|
|
10
|
+
local rules = app.rules
|
|
11
|
+
if not rules then
|
|
12
|
+
return nil
|
|
13
|
+
end
|
|
14
|
+
local _condition = rules.parent
|
|
15
|
+
if _condition ~= "" and _condition then
|
|
16
|
+
_condition = rules.parent == entry
|
|
17
|
+
end
|
|
18
|
+
if _condition ~= "" and _condition then
|
|
19
|
+
local _binds = forge.binds
|
|
20
|
+
local _entry = entry
|
|
21
|
+
if not _binds[_entry] then
|
|
22
|
+
local _name = name
|
|
23
|
+
table.insert(children, _name)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
for _k, _v in AppRegistry do
|
|
28
|
+
_callback(_v, _k, AppRegistry)
|
|
29
|
+
end
|
|
30
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
31
|
+
-- ▼ ReadonlyArray.forEach ▼
|
|
32
|
+
local _callback_1 = function(name)
|
|
33
|
+
return forge:close(name)
|
|
34
|
+
end
|
|
35
|
+
for _k, _v in children do
|
|
36
|
+
_callback_1(_v, _k - 1, children)
|
|
37
|
+
end
|
|
38
|
+
-- ▲ ReadonlyArray.forEach ▲
|
|
39
|
+
end
|
|
40
|
+
return {
|
|
41
|
+
default = ParentRule,
|
|
42
|
+
}
|
package/out/react/types.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ import type AppForge from ".";
|
|
|
4
4
|
|
|
5
5
|
declare namespace Types {
|
|
6
6
|
type AppRegistryProps = {
|
|
7
|
-
name: AppNames
|
|
7
|
+
name: AppNames;
|
|
8
8
|
visible?: boolean;
|
|
9
9
|
rules?: Rules.All;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
type NameProps =
|
|
13
|
-
| { name?: AppNames
|
|
14
|
-
| { names?: AppNames[
|
|
13
|
+
| { name?: AppNames; names?: undefined }
|
|
14
|
+
| { names?: AppNames[]; name?: undefined };
|
|
15
15
|
|
|
16
16
|
type MainProps = {
|
|
17
17
|
props: AppProps;
|
|
@@ -20,6 +20,7 @@ declare namespace Types {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
type ClassProps = AppProps & {
|
|
23
|
+
forge: AppForge;
|
|
23
24
|
px: ReturnType<typeof import("@rbxts/loners-pretty-react-hooks").usePx>;
|
|
24
25
|
};
|
|
25
26
|
|
|
@@ -30,18 +31,8 @@ declare namespace Types {
|
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
namespace Rules {
|
|
33
|
-
type Groups = AppGroups[number] | "Core" | "Core"[] | AppGroups[number][];
|
|
34
|
-
type BlockedBy = AppNames[number] | AppNames[number][];
|
|
35
|
-
type Blocks = AppNames[number] | AppNames[number][];
|
|
36
|
-
type Exclusive = boolean;
|
|
37
|
-
type Layer = number;
|
|
38
|
-
|
|
39
34
|
type All = {
|
|
40
|
-
|
|
41
|
-
exclusive?: Exclusive;
|
|
42
|
-
groups?: Groups;
|
|
43
|
-
blocks?: Blocks;
|
|
44
|
-
layer?: Layer;
|
|
35
|
+
parent?: AppNames;
|
|
45
36
|
};
|
|
46
37
|
}
|
|
47
38
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Vide from "@rbxts/vide";
|
|
2
|
+
import type Types from "../types";
|
|
3
|
+
import type AppForge from "..";
|
|
4
|
+
import Rules from "./rules";
|
|
5
|
+
export default class Renders extends Rules {
|
|
6
|
+
protected anchored: Map<string, {
|
|
7
|
+
id: AppNames;
|
|
8
|
+
render: Vide.Node;
|
|
9
|
+
}>;
|
|
10
|
+
constructor();
|
|
11
|
+
protected renderMount(this: AppForge, props: Types.Props.Main): Vide.Node;
|
|
12
|
+
private renderNames;
|
|
13
|
+
private collectByGroup;
|
|
14
|
+
private normalizeGroups;
|
|
15
|
+
protected renderApp(this: AppForge, props: Types.Props.Main): Vide.Node;
|
|
16
|
+
protected renderApps(this: AppForge, props: Types.Props.Main): Vide.Node[];
|
|
17
|
+
protected renderGroup(this: AppForge, props: Types.Props.Main): Vide.Node[];
|
|
18
|
+
protected renderGroupByName(this: AppForge, props: Types.Props.Main): Vide.Node[];
|
|
19
|
+
protected renderGroupByNames(this: AppForge, props: Types.Props.Main): Vide.Node[];
|
|
20
|
+
protected renderAll(this: AppForge, props: Types.Props.Main): Vide.Node[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Services
|
|
4
|
+
-- Packages
|
|
5
|
+
local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-vide-utils").out).usePx
|
|
6
|
+
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
7
|
+
local apply = _vide.apply
|
|
8
|
+
local create = _vide.create
|
|
9
|
+
-- Types
|
|
10
|
+
-- Components
|
|
11
|
+
local AppRegistry = TS.import(script, script.Parent.Parent, "decorator").AppRegistry
|
|
12
|
+
-- Classes
|
|
13
|
+
local Rules = TS.import(script, script.Parent, "rules").default
|
|
14
|
+
local Renders
|
|
15
|
+
do
|
|
16
|
+
local super = Rules
|
|
17
|
+
Renders = setmetatable({}, {
|
|
18
|
+
__tostring = function()
|
|
19
|
+
return "Renders"
|
|
20
|
+
end,
|
|
21
|
+
__index = super,
|
|
22
|
+
})
|
|
23
|
+
Renders.__index = Renders
|
|
24
|
+
function Renders.new(...)
|
|
25
|
+
local self = setmetatable({}, Renders)
|
|
26
|
+
return self:constructor(...) or self
|
|
27
|
+
end
|
|
28
|
+
function Renders:constructor()
|
|
29
|
+
super.constructor(self)
|
|
30
|
+
self.anchored = {}
|
|
31
|
+
end
|
|
32
|
+
function Renders:renderMount(props)
|
|
33
|
+
local _binding = props
|
|
34
|
+
local config = _binding.config
|
|
35
|
+
local render = _binding.render
|
|
36
|
+
local forge = _binding.forge
|
|
37
|
+
if not forge.__px then
|
|
38
|
+
local _result = config
|
|
39
|
+
if _result ~= nil then
|
|
40
|
+
_result = _result.px.target
|
|
41
|
+
end
|
|
42
|
+
local _result_1 = config
|
|
43
|
+
if _result_1 ~= nil then
|
|
44
|
+
_result_1 = _result_1.px.resolution
|
|
45
|
+
end
|
|
46
|
+
local _result_2 = config
|
|
47
|
+
if _result_2 ~= nil then
|
|
48
|
+
_result_2 = _result_2.px.minScale
|
|
49
|
+
end
|
|
50
|
+
usePx(_result, _result_1, _result_2)
|
|
51
|
+
forge.__px = true
|
|
52
|
+
else
|
|
53
|
+
warn("Rendering twice making a second px")
|
|
54
|
+
end
|
|
55
|
+
if render then
|
|
56
|
+
local _condition = render.name
|
|
57
|
+
if _condition ~= "" and _condition then
|
|
58
|
+
_condition = render.group
|
|
59
|
+
end
|
|
60
|
+
if _condition ~= "" and _condition then
|
|
61
|
+
return forge:renderGroupByName(props)
|
|
62
|
+
else
|
|
63
|
+
local _value = render.names and render.group
|
|
64
|
+
if _value ~= "" and _value then
|
|
65
|
+
return forge:renderGroupByNames(props)
|
|
66
|
+
else
|
|
67
|
+
local _result = render
|
|
68
|
+
if _result ~= nil then
|
|
69
|
+
_result = _result.name
|
|
70
|
+
end
|
|
71
|
+
if _result ~= "" and _result then
|
|
72
|
+
return forge:renderApp(props)
|
|
73
|
+
elseif render.names then
|
|
74
|
+
return forge:renderApps(props)
|
|
75
|
+
else
|
|
76
|
+
local _value_1 = render.group
|
|
77
|
+
if _value_1 ~= "" and _value_1 then
|
|
78
|
+
return forge:renderGroup(props)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
return self:renderAll(props)
|
|
85
|
+
end
|
|
86
|
+
function Renders:renderNames(props, names, forge)
|
|
87
|
+
if #names == 0 then
|
|
88
|
+
error("No app names provided to renderApps")
|
|
89
|
+
end
|
|
90
|
+
-- ▼ ReadonlyArray.map ▼
|
|
91
|
+
local _newValue = table.create(#names)
|
|
92
|
+
local _callback = function(name)
|
|
93
|
+
local _forge = forge
|
|
94
|
+
local _object = table.clone(props)
|
|
95
|
+
setmetatable(_object, nil)
|
|
96
|
+
_object.render = {
|
|
97
|
+
name = name,
|
|
98
|
+
}
|
|
99
|
+
return _forge:renderApp(_object)
|
|
100
|
+
end
|
|
101
|
+
for _k, _v in names do
|
|
102
|
+
_newValue[_k] = _callback(_v, _k - 1, names)
|
|
103
|
+
end
|
|
104
|
+
-- ▲ ReadonlyArray.map ▲
|
|
105
|
+
return _newValue
|
|
106
|
+
end
|
|
107
|
+
function Renders:collectByGroup(groups, filter)
|
|
108
|
+
local result = {}
|
|
109
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
110
|
+
local _callback = function(app, name)
|
|
111
|
+
local appGroup = app.renderGroup
|
|
112
|
+
if not (appGroup ~= "" and appGroup) then
|
|
113
|
+
return nil
|
|
114
|
+
end
|
|
115
|
+
if not (table.find(groups, appGroup) ~= nil) then
|
|
116
|
+
return nil
|
|
117
|
+
end
|
|
118
|
+
if filter and not filter(name) then
|
|
119
|
+
return nil
|
|
120
|
+
end
|
|
121
|
+
local _name = name
|
|
122
|
+
table.insert(result, _name)
|
|
123
|
+
end
|
|
124
|
+
for _k, _v in AppRegistry do
|
|
125
|
+
_callback(_v, _k, AppRegistry)
|
|
126
|
+
end
|
|
127
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
128
|
+
return result
|
|
129
|
+
end
|
|
130
|
+
function Renders:normalizeGroups(group)
|
|
131
|
+
local _group = group
|
|
132
|
+
local _result
|
|
133
|
+
if type(_group) == "table" then
|
|
134
|
+
local _array = {}
|
|
135
|
+
local _length = #_array
|
|
136
|
+
table.move(group, 1, #group, _length + 1, _array)
|
|
137
|
+
_result = _array
|
|
138
|
+
else
|
|
139
|
+
_result = { group }
|
|
140
|
+
end
|
|
141
|
+
return _result
|
|
142
|
+
end
|
|
143
|
+
function Renders:renderApp(props)
|
|
144
|
+
local _binding = props
|
|
145
|
+
local forge = _binding.forge
|
|
146
|
+
local render = _binding.render
|
|
147
|
+
local _name = render
|
|
148
|
+
if _name ~= nil then
|
|
149
|
+
_name = _name.name
|
|
150
|
+
end
|
|
151
|
+
local name = _name
|
|
152
|
+
if not (name ~= "" and name) then
|
|
153
|
+
error("App name is required to create instance")
|
|
154
|
+
end
|
|
155
|
+
local appClass = AppRegistry[name]
|
|
156
|
+
if not appClass then
|
|
157
|
+
error(`App "{name}" not registered`)
|
|
158
|
+
end
|
|
159
|
+
if not (forge.loaded[name] ~= nil) then
|
|
160
|
+
local render = appClass.constructor.new(props, name):render()
|
|
161
|
+
apply(render)({
|
|
162
|
+
Name = "Render",
|
|
163
|
+
})
|
|
164
|
+
local container = create("Frame")({
|
|
165
|
+
Name = name,
|
|
166
|
+
BackgroundTransparency = 1,
|
|
167
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
168
|
+
Position = UDim2.fromScale(0.5, 0.5),
|
|
169
|
+
Size = UDim2.fromScale(1, 1),
|
|
170
|
+
[0] = render,
|
|
171
|
+
})
|
|
172
|
+
local _loaded = forge.loaded
|
|
173
|
+
local _arg1 = {
|
|
174
|
+
container = container,
|
|
175
|
+
render = render,
|
|
176
|
+
}
|
|
177
|
+
_loaded[name] = _arg1
|
|
178
|
+
end
|
|
179
|
+
local element = forge.loaded[name]
|
|
180
|
+
if not element then
|
|
181
|
+
error(`Failed to create instance for app "{name}"`)
|
|
182
|
+
end
|
|
183
|
+
self:renderRules(name, props)
|
|
184
|
+
return element.container
|
|
185
|
+
end
|
|
186
|
+
function Renders:renderApps(props)
|
|
187
|
+
local _names = props.render
|
|
188
|
+
if _names ~= nil then
|
|
189
|
+
_names = _names.names
|
|
190
|
+
end
|
|
191
|
+
local names = _names
|
|
192
|
+
if not names then
|
|
193
|
+
error("No app names provided")
|
|
194
|
+
end
|
|
195
|
+
return self:renderNames(props, names, self)
|
|
196
|
+
end
|
|
197
|
+
function Renders:renderGroup(props)
|
|
198
|
+
local _group = props.render
|
|
199
|
+
if _group ~= nil then
|
|
200
|
+
_group = _group.group
|
|
201
|
+
end
|
|
202
|
+
local group = _group
|
|
203
|
+
if not (group ~= "" and group) then
|
|
204
|
+
error("No group provided")
|
|
205
|
+
end
|
|
206
|
+
local groups = self:normalizeGroups(group)
|
|
207
|
+
return self:renderNames(props, self:collectByGroup(groups), self)
|
|
208
|
+
end
|
|
209
|
+
function Renders:renderGroupByName(props)
|
|
210
|
+
local _binding = props.render or {}
|
|
211
|
+
local group = _binding.group
|
|
212
|
+
local name = _binding.name
|
|
213
|
+
if not (group ~= "" and group) or not (name ~= "" and name) then
|
|
214
|
+
error("Invalid renderGroupByName")
|
|
215
|
+
end
|
|
216
|
+
local groups = self:normalizeGroups(group)
|
|
217
|
+
return self:renderNames(props, self:collectByGroup(groups, function(n)
|
|
218
|
+
return n == name
|
|
219
|
+
end), self)
|
|
220
|
+
end
|
|
221
|
+
function Renders:renderGroupByNames(props)
|
|
222
|
+
local _binding = props.render or {}
|
|
223
|
+
local group = _binding.group
|
|
224
|
+
local names = _binding.names
|
|
225
|
+
if not (group ~= "" and group) or not names then
|
|
226
|
+
error("Invalid renderGroupByNames")
|
|
227
|
+
end
|
|
228
|
+
local groups = self:normalizeGroups(group)
|
|
229
|
+
return self:renderNames(props, self:collectByGroup(groups, function(n)
|
|
230
|
+
local _n = n
|
|
231
|
+
return table.find(names, _n) ~= nil
|
|
232
|
+
end), self)
|
|
233
|
+
end
|
|
234
|
+
function Renders:renderAll(props)
|
|
235
|
+
local names = {}
|
|
236
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
237
|
+
local _callback = function(_, name)
|
|
238
|
+
local _name = name
|
|
239
|
+
table.insert(names, _name)
|
|
240
|
+
return #names
|
|
241
|
+
end
|
|
242
|
+
for _k, _v in AppRegistry do
|
|
243
|
+
_callback(_v, _k, AppRegistry)
|
|
244
|
+
end
|
|
245
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
246
|
+
return self:renderNames(props, names, self)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
return {
|
|
250
|
+
default = Renders,
|
|
251
|
+
}
|