@rbxts/app-forge 0.5.9 → 0.6.0-alpha.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/out/index.d.ts CHANGED
@@ -1,19 +1,8 @@
1
- import Vide from "@rbxts/vide";
2
- import type Types from "./types";
3
- import { Args, App } from "./decorator";
4
- export default class AppForge {
5
- sources: Map<string, Vide.Source<boolean>>;
6
- loaded: Map<string, Vide.Node>;
7
- private rulesManager;
8
- getSource(name: AppNames[number]): Vide.Source<boolean>;
9
- set(name: AppNames[number], value: Vide.Source<boolean> | boolean): void;
10
- open(name: AppNames[number]): void;
11
- close(name: AppNames[number]): void;
12
- toggle(name: AppNames[number]): void;
13
- renderApp(props: Types.NameProps & Types.MainProps): Vide.Node;
14
- renderApps(props: Types.NameProps & Types.MainProps): Vide.Node[];
15
- renderAll(props: Types.MainProps): Vide.Node[];
16
- }
17
- export { App, Args };
18
- export { Render } from "./helpers";
19
- export type { NameProps, MainProps, ClassProps } from "./types";
1
+ export { App as ReactApp, Args as ReactArgs } from "./react/decorator";
2
+ export { App as VideApp, Args as VideArgs } from "./vide/decorator";
3
+ export { default as CreateReactForge } from "./react";
4
+ export { default as CreateVideForge } from "./vide";
5
+ export { Render as RenderReact } from "./react/helpers";
6
+ export { Render as RenderVide } from "./vide/helpers";
7
+ export type { MainProps as ReactProps, ClassProps as ReactClassProps } from "./react/types";
8
+ export type { MainProps as VideProps, ClassProps as VideClassProps } from "./vide/types";
package/out/init.luau CHANGED
@@ -1,120 +1,18 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
3
  local exports = {}
4
- -- Services
5
- -- Packages
6
- local Vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
4
+ -- Decorators
5
+ local _decorator = TS.import(script, script, "react", "decorator")
6
+ exports.ReactApp = _decorator.App
7
+ exports.ReactArgs = _decorator.Args
8
+ local _decorator_1 = TS.import(script, script, "vide", "decorator")
9
+ exports.VideApp = _decorator_1.App
10
+ exports.VideArgs = _decorator_1.Args
11
+ -- Creators
12
+ exports.CreateReactForge = TS.import(script, script, "react").default
13
+ exports.CreateVideForge = TS.import(script, script, "vide").default
14
+ -- Helpers
15
+ exports.RenderReact = TS.import(script, script, "react", "helpers").Render
16
+ exports.RenderVide = TS.import(script, script, "vide", "helpers").Render
7
17
  -- Types
8
- -- Components
9
- local _decorator = TS.import(script, script, "decorator")
10
- local AppRegistry = _decorator.AppRegistry
11
- local Args = _decorator.Args
12
- local App = _decorator.App
13
- local AppContainer = TS.import(script, script, "container").default
14
- -- Classes
15
- local RulesManager = TS.import(script, script, "rules").default
16
- local AppForge
17
- do
18
- AppForge = setmetatable({}, {
19
- __tostring = function()
20
- return "AppForge"
21
- end,
22
- })
23
- AppForge.__index = AppForge
24
- function AppForge.new(...)
25
- local self = setmetatable({}, AppForge)
26
- return self:constructor(...) or self
27
- end
28
- function AppForge:constructor()
29
- self.sources = {}
30
- self.loaded = {}
31
- self.rulesManager = RulesManager.new(self)
32
- end
33
- function AppForge:getSource(name)
34
- local _sources = self.sources
35
- local _name = name
36
- if not (_sources[_name] ~= nil) then
37
- error(`App "{name}" has no source`)
38
- end
39
- local _sources_1 = self.sources
40
- local _name_1 = name
41
- return _sources_1[_name_1]
42
- end
43
- function AppForge:set(name, value)
44
- if not self.rulesManager:applyRules(name, value) then
45
- return nil
46
- end
47
- local _value = value
48
- if type(_value) == "function" then
49
- local _sources = self.sources
50
- local _name = name
51
- local _value_1 = value
52
- _sources[_name] = _value_1
53
- else
54
- local _sources = self.sources
55
- local _name = name
56
- local source = _sources[_name]
57
- if not source then
58
- error(`App "{name}" has no source`)
59
- end
60
- source(value)
61
- end
62
- end
63
- function AppForge:open(name)
64
- self:set(name, true)
65
- end
66
- function AppForge:close(name)
67
- self:set(name, false)
68
- end
69
- function AppForge:toggle(name)
70
- self:set(name, not self:getSource(name)())
71
- end
72
- function AppForge:renderApp(props)
73
- local _attributes = table.clone(props)
74
- setmetatable(_attributes, nil)
75
- return Vide.jsx(AppContainer, _attributes)
76
- end
77
- function AppForge:renderApps(props)
78
- local names = props.names
79
- if names then
80
- -- ▼ ReadonlyArray.map ▼
81
- local _newValue = table.create(#names)
82
- local _callback = function(name)
83
- local _self = self
84
- local _object = table.clone(props)
85
- setmetatable(_object, nil)
86
- _object.name = name
87
- _object.names = nil
88
- return _self:renderApp(_object)
89
- end
90
- for _k, _v in names do
91
- _newValue[_k] = _callback(_v, _k - 1, names)
92
- end
93
- -- ▲ ReadonlyArray.map ▲
94
- return _newValue
95
- end
96
- error("No app names provided to renderApps")
97
- end
98
- function AppForge:renderAll(props)
99
- local names = {}
100
- -- ▼ ReadonlyMap.forEach ▼
101
- local _callback = function(_, name)
102
- local _name = name
103
- table.insert(names, _name)
104
- end
105
- for _k, _v in AppRegistry do
106
- _callback(_v, _k, AppRegistry)
107
- end
108
- -- ▲ ReadonlyMap.forEach ▲
109
- local _self = self
110
- local _object = table.clone(props)
111
- setmetatable(_object, nil)
112
- _object.names = names
113
- return _self:renderApps(_object)
114
- end
115
- end
116
- exports.Render = TS.import(script, script, "helpers").Render
117
- exports.default = AppForge
118
- exports.App = App
119
- exports.Args = Args
120
18
  return exports
@@ -0,0 +1,11 @@
1
+ import React from "@rbxts/react";
2
+ import type Types from "./types";
3
+ export declare function AppContainer(props: Types.NameProps & Types.MainProps): React.ReactElement<{
4
+ key: string;
5
+ ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
6
+ ResetOnSpawn: boolean;
7
+ }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
8
+ key: string;
9
+ BackgroundTransparency: number;
10
+ Size: UDim2;
11
+ }, string | React.JSXElementConstructor<any>>;
@@ -0,0 +1,80 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Services
4
+ local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
5
+ -- Packages
6
+ local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
7
+ local useBinding = _react.useBinding
8
+ local createElement = _react.createElement
9
+ -- Types
10
+ -- Components
11
+ local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
12
+ local function createBinding(name, manager)
13
+ local _name = name
14
+ local app = AppRegistry[_name]
15
+ if not app then
16
+ error(`App "{name}" not registered`)
17
+ end
18
+ local _condition = app.visible
19
+ if _condition == nil then
20
+ _condition = false
21
+ end
22
+ local binding = { useBinding(_condition) }
23
+ local _binds = manager.binds
24
+ local _name_1 = name
25
+ _binds[_name_1] = binding
26
+ return unpack(binding)
27
+ end
28
+ local function createInstance(props)
29
+ local _binding = props
30
+ local name = _binding.name
31
+ local forge = _binding.forge
32
+ if not (name ~= "" and name) then
33
+ error("App name is required to create instance")
34
+ end
35
+ local appClass = AppRegistry[name]
36
+ if not appClass then
37
+ error(`App "{name}" not registered`)
38
+ end
39
+ if not (forge.loaded[name] ~= nil) then
40
+ local instance = appClass.constructor.new(props)
41
+ local Render = function()
42
+ return instance:render()
43
+ end
44
+ local _loaded = forge.loaded
45
+ local _arg1 = createElement(Render, {
46
+ key = "Main",
47
+ })
48
+ _loaded[name] = _arg1
49
+ end
50
+ return forge.loaded[name]
51
+ end
52
+ local function AppContainer(props)
53
+ local _binding = props
54
+ local name = _binding.name
55
+ local forge = _binding.forge
56
+ if not (name ~= "" and name) then
57
+ error("App name is required in AppContainer")
58
+ end
59
+ createBinding(name, forge)
60
+ local element = createInstance(props)
61
+ if not element then
62
+ error(`Failed to create instance for app "{name}"`)
63
+ end
64
+ if RunService:IsRunning() then
65
+ return createElement("ScreenGui", {
66
+ key = name,
67
+ ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
68
+ ResetOnSpawn = false,
69
+ }, element)
70
+ else
71
+ return createElement("Frame", {
72
+ key = name,
73
+ BackgroundTransparency = 1,
74
+ Size = UDim2.fromScale(1, 1),
75
+ }, element)
76
+ end
77
+ end
78
+ return {
79
+ AppContainer = AppContainer,
80
+ }
@@ -0,0 +1,14 @@
1
+ import React from "@rbxts/react";
2
+ import type Types from "./types";
3
+ import type AppForge from ".";
4
+ export declare const AppRegistry: Map<string, Types.AppRegistry>;
5
+ export declare function App(props: Types.AppRegistryProps): <T extends new (props: Types.MainProps) => Args>(constructor: T) => T;
6
+ export declare abstract class Args {
7
+ readonly forge: AppForge;
8
+ readonly props: Types.ClassProps;
9
+ readonly name: AppNames[number];
10
+ readonly bind: React.Binding<boolean>;
11
+ readonly state: Boolean;
12
+ constructor(props: Types.NameProps & Types.MainProps);
13
+ abstract render(): JSX.Element;
14
+ }
@@ -0,0 +1,55 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Services
4
+ local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
5
+ -- Packages
6
+ local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-react-hooks").out).usePx
7
+ -- Types
8
+ local AppRegistry = {}
9
+ local function App(props)
10
+ return function(constructor)
11
+ local _name = props.name
12
+ if AppRegistry[_name] ~= nil then
13
+ error(`Duplicate registered App name "{props.name}"`)
14
+ end
15
+ local _name_1 = props.name
16
+ local _arg1 = {
17
+ constructor = constructor,
18
+ visible = props.visible,
19
+ rules = props.rules,
20
+ }
21
+ AppRegistry[_name_1] = _arg1
22
+ return constructor
23
+ end
24
+ end
25
+ local Args
26
+ do
27
+ Args = {}
28
+ function Args:constructor(props)
29
+ local _binding = props
30
+ local target = _binding.target
31
+ local forge = _binding.forge
32
+ local name = _binding.name
33
+ if not (name ~= "" and name) then
34
+ error("App name is required in Args constructor")
35
+ 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
+ local px = usePx(target)
41
+ self.forge = forge
42
+ local _object = table.clone(props.props)
43
+ setmetatable(_object, nil)
44
+ _object.px = px
45
+ self.props = _object
46
+ self.name = name
47
+ self.bind = bind
48
+ self.state = if self.bind then self.bind:getValue() else nil
49
+ end
50
+ end
51
+ return {
52
+ App = App,
53
+ AppRegistry = AppRegistry,
54
+ Args = Args,
55
+ }
@@ -0,0 +1,18 @@
1
+ import Types from "./types";
2
+ export declare function Render(props: Types.NameProps & Types.MainProps): import("@rbxts/react").ReactElement<{
3
+ key: string;
4
+ ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
5
+ ResetOnSpawn: boolean;
6
+ }, string | import("@rbxts/react").JSXElementConstructor<any>> | import("@rbxts/react").ReactElement<{
7
+ key: string;
8
+ BackgroundTransparency: number;
9
+ Size: UDim2;
10
+ }, string | import("@rbxts/react").JSXElementConstructor<any>> | (import("@rbxts/react").ReactElement<{
11
+ key: string;
12
+ ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
13
+ ResetOnSpawn: boolean;
14
+ }, string | import("@rbxts/react").JSXElementConstructor<any>> | import("@rbxts/react").ReactElement<{
15
+ key: string;
16
+ BackgroundTransparency: number;
17
+ Size: UDim2;
18
+ }, string | import("@rbxts/react").JSXElementConstructor<any>>)[];
@@ -0,0 +1,16 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ -- Types
3
+ local function Render(props)
4
+ local names = props.names
5
+ local name = props.name
6
+ local forge = props.forge
7
+ if name ~= "" and name then
8
+ return forge:renderApp(props)
9
+ elseif names then
10
+ return forge:renderApps(props)
11
+ end
12
+ return forge:renderAll(props)
13
+ end
14
+ return {
15
+ Render = Render,
16
+ }
@@ -0,0 +1,40 @@
1
+ import React from "@rbxts/react";
2
+ import type Types from "./types";
3
+ export default class AppForge {
4
+ binds: Map<string, [React.Binding<boolean>, (T: boolean) => void]>;
5
+ loaded: Map<string, React.Element<any, string | React.JSXElementConstructor<any>>>;
6
+ private rulesManager;
7
+ getBind(name: AppNames[number]): React.Binding<boolean> | undefined;
8
+ getState(name: AppNames[number]): boolean | undefined;
9
+ set(name: AppNames[number], value: boolean): void;
10
+ open(name: AppNames[number]): void;
11
+ close(name: AppNames[number]): void;
12
+ toggle(name: AppNames[number]): void;
13
+ renderApp(props: Types.NameProps & Types.MainProps): React.ReactElement<{
14
+ key: string;
15
+ ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
16
+ ResetOnSpawn: boolean;
17
+ }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
18
+ key: string;
19
+ BackgroundTransparency: number;
20
+ Size: UDim2;
21
+ }, string | React.JSXElementConstructor<any>>;
22
+ renderApps(props: Types.NameProps & Types.MainProps): (React.ReactElement<{
23
+ key: string;
24
+ ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
25
+ ResetOnSpawn: boolean;
26
+ }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
27
+ key: string;
28
+ BackgroundTransparency: number;
29
+ Size: UDim2;
30
+ }, string | React.JSXElementConstructor<any>>)[];
31
+ renderAll(props: Types.MainProps): (React.ReactElement<{
32
+ key: string;
33
+ ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
34
+ ResetOnSpawn: boolean;
35
+ }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
36
+ key: string;
37
+ BackgroundTransparency: number;
38
+ Size: UDim2;
39
+ }, string | React.JSXElementConstructor<any>>)[];
40
+ }
@@ -0,0 +1,121 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ -- Types
5
+ -- Components
6
+ local AppContainer = TS.import(script, script, "container").AppContainer
7
+ local AppRegistry = TS.import(script, script, "decorator").AppRegistry
8
+ -- Classes
9
+ local RulesManager = TS.import(script, script, "rules").default
10
+ local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
11
+ local AppForge
12
+ do
13
+ AppForge = setmetatable({}, {
14
+ __tostring = function()
15
+ return "AppForge"
16
+ end,
17
+ })
18
+ AppForge.__index = AppForge
19
+ function AppForge.new(...)
20
+ local self = setmetatable({}, AppForge)
21
+ return self:constructor(...) or self
22
+ end
23
+ function AppForge:constructor()
24
+ self.binds = {}
25
+ self.loaded = {}
26
+ self.rulesManager = RulesManager.new(self)
27
+ end
28
+ 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
+ local _binds = self.binds
39
+ local _name = name
40
+ if not (_binds[_name] ~= nil) then
41
+ error(`App "{name}" has no binding`)
42
+ end
43
+ local _binds_1 = self.binds
44
+ local _name_1 = name
45
+ return _binds_1[_name_1][1]
46
+ end
47
+ function AppForge:getState(name)
48
+ local _result = self:getBind(name)
49
+ if _result ~= nil then
50
+ _result = _result:getValue()
51
+ end
52
+ return _result
53
+ end
54
+ function AppForge:set(name, value)
55
+ if not self.rulesManager:applyRules(name, value) then
56
+ return nil
57
+ end
58
+ local _binds = self.binds
59
+ local _name = name
60
+ local _binding = _binds[_name]
61
+ local _ = _binding[1]
62
+ local setBinding = _binding[2]
63
+ if not setBinding then
64
+ error(`App "{name}" has no binding setter`)
65
+ end
66
+ setBinding(value)
67
+ end
68
+ function AppForge:open(name)
69
+ self:set(name, true)
70
+ end
71
+ function AppForge:close(name)
72
+ self:set(name, false)
73
+ end
74
+ function AppForge:toggle(name)
75
+ self:set(name, not self:getState(name))
76
+ end
77
+ function AppForge:renderApp(props)
78
+ return AppContainer(props)
79
+ end
80
+ function AppForge:renderApps(props)
81
+ local names = props.names
82
+ if names then
83
+ -- ▼ ReadonlyArray.map ▼
84
+ local _newValue = table.create(#names)
85
+ local _callback = function(name)
86
+ local _self = self
87
+ local _object = table.clone(props)
88
+ setmetatable(_object, nil)
89
+ _object.name = name
90
+ _object.names = nil
91
+ return _self:renderApp(_object)
92
+ end
93
+ for _k, _v in names do
94
+ _newValue[_k] = _callback(_v, _k - 1, names)
95
+ end
96
+ -- ▲ ReadonlyArray.map ▲
97
+ return _newValue
98
+ end
99
+ error("No app names provided to renderApps")
100
+ end
101
+ function AppForge:renderAll(props)
102
+ local names = {}
103
+ -- ▼ ReadonlyMap.forEach ▼
104
+ local _callback = function(_, name)
105
+ local _name = name
106
+ table.insert(names, _name)
107
+ end
108
+ for _k, _v in AppRegistry do
109
+ _callback(_v, _k, AppRegistry)
110
+ end
111
+ -- ▲ ReadonlyMap.forEach ▲
112
+ local _self = self
113
+ local _object = table.clone(props)
114
+ setmetatable(_object, nil)
115
+ _object.names = names
116
+ return _self:renderApps(_object)
117
+ end
118
+ end
119
+ return {
120
+ default = AppForge,
121
+ }
@@ -0,0 +1,11 @@
1
+ import AppManager from ".";
2
+ export default class RulesManager {
3
+ private appManager;
4
+ constructor(appManager: AppManager);
5
+ applyRules(name: AppNames[number], value: boolean): boolean;
6
+ private inSameGroup;
7
+ private blockedBy;
8
+ private blocks;
9
+ private exclusive;
10
+ private layer;
11
+ }
@@ -0,0 +1,196 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ local Object = TS.import(script, TS.getModule(script, "@rbxts", "object-utils"))
5
+ -- Components
6
+ local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
7
+ -- Types
8
+ local function asTable(value)
9
+ local _value = value
10
+ if type(_value) == "table" then
11
+ return value
12
+ else
13
+ local t = {}
14
+ t[2] = value
15
+ return t
16
+ end
17
+ end
18
+ local RulesManager
19
+ do
20
+ RulesManager = setmetatable({}, {
21
+ __tostring = function()
22
+ return "RulesManager"
23
+ end,
24
+ })
25
+ RulesManager.__index = RulesManager
26
+ function RulesManager.new(...)
27
+ local self = setmetatable({}, RulesManager)
28
+ return self:constructor(...) or self
29
+ end
30
+ function RulesManager:constructor(appManager)
31
+ self.appManager = appManager
32
+ end
33
+ function RulesManager:applyRules(name, value)
34
+ local _name = name
35
+ local appData = AppRegistry[_name]
36
+ local _rules = appData
37
+ if _rules ~= nil then
38
+ _rules = _rules.rules
39
+ end
40
+ local rules = _rules
41
+ local _result = rules
42
+ if _result ~= nil then
43
+ _result = _result.groups
44
+ end
45
+ if _result == "Core" then
46
+ return true
47
+ end
48
+ if value then
49
+ local allNames = Object.keys(AppRegistry)
50
+ -- ▼ ReadonlyArray.forEach ▼
51
+ local _callback = function(n)
52
+ if not (n ~= "" and n) or n == name then
53
+ return nil
54
+ end
55
+ print(self.appManager.loaded)
56
+ local _n = n
57
+ local otherApp = AppRegistry[_n]
58
+ local _result_1 = otherApp
59
+ if _result_1 ~= nil then
60
+ _result_1 = _result_1.rules
61
+ if _result_1 ~= nil then
62
+ _result_1 = _result_1.groups
63
+ end
64
+ end
65
+ local groups = if _result_1 ~= "" and _result_1 then asTable(otherApp.rules.groups) else {}
66
+ -- ▼ ReadonlyArray.find ▼
67
+ local _callback_1 = function(g)
68
+ return g == "Core"
69
+ end
70
+ local _result_2
71
+ for _i, _v in groups do
72
+ if _callback_1(_v, _i - 1, groups) == true then
73
+ _result_2 = _v
74
+ break
75
+ end
76
+ end
77
+ -- ▲ ReadonlyArray.find ▲
78
+ if _result_2 then
79
+ return nil
80
+ end
81
+ if self.appManager:getState(n) then
82
+ self.appManager:set(n, false)
83
+ end
84
+ end
85
+ for _k, _v in allNames do
86
+ _callback(_v, _k - 1, allNames)
87
+ end
88
+ -- ▲ ReadonlyArray.forEach ▲
89
+ end
90
+ if not rules then
91
+ return true
92
+ end
93
+ local _condition = value
94
+ if _condition then
95
+ _condition = rules.blockedBy
96
+ if _condition ~= "" and _condition then
97
+ _condition = not self:blockedBy(name, rules.blockedBy)
98
+ end
99
+ end
100
+ if _condition ~= "" and _condition then
101
+ return false
102
+ end
103
+ local _value = value and rules.blocks
104
+ if _value ~= "" and _value then
105
+ self:blocks(name, rules.blocks)
106
+ end
107
+ if value and rules.layer ~= nil then
108
+ self:layer(name, rules.layer)
109
+ end
110
+ if value and rules.exclusive then
111
+ self:exclusive(name)
112
+ end
113
+ return true
114
+ end
115
+ function RulesManager:inSameGroup(a, b)
116
+ local _a = a
117
+ local appA = AppRegistry[_a]
118
+ local _b = b
119
+ local appB = AppRegistry[_b]
120
+ if not appA or not appB then
121
+ return false
122
+ end
123
+ local _result = appA.rules
124
+ if _result ~= nil then
125
+ _result = _result.groups
126
+ end
127
+ local _condition = _result
128
+ if _condition == nil then
129
+ _condition = {}
130
+ end
131
+ local groupsA = asTable(_condition)
132
+ local _result_1 = appB.rules
133
+ if _result_1 ~= nil then
134
+ _result_1 = _result_1.groups
135
+ end
136
+ local _condition_1 = _result_1
137
+ if _condition_1 == nil then
138
+ _condition_1 = {}
139
+ end
140
+ local groupsB = asTable(_condition_1)
141
+ for i = 1, #groupsA do
142
+ for j = 1, #groupsB do
143
+ if groupsA[i + 1] == groupsB[j + 1] then
144
+ return true
145
+ end
146
+ end
147
+ end
148
+ return false
149
+ end
150
+ function RulesManager:blockedBy(name, rule)
151
+ local blockers = asTable(rule)
152
+ for i = 1, #blockers do
153
+ local blocker = blockers[i + 1]
154
+ if self:inSameGroup(name, blocker) or not (blocker ~= "" and blocker) then
155
+ continue
156
+ end
157
+ if self.appManager:getState(blocker) then
158
+ return false
159
+ end
160
+ end
161
+ return true
162
+ end
163
+ function RulesManager:blocks(name, rule)
164
+ local blocked = asTable(rule)
165
+ for i = 1, #blocked do
166
+ local b = blocked[i + 1]
167
+ if self:inSameGroup(name, b) or not (b ~= "" and b) then
168
+ continue
169
+ end
170
+ if self.appManager:getState(b) then
171
+ self.appManager:set(b, false)
172
+ end
173
+ end
174
+ end
175
+ function RulesManager:exclusive(name)
176
+ local names = Object.keys(AppRegistry)
177
+ for i = 1, #names do
178
+ local other = names[i + 1]
179
+ if other == name or not (other ~= "" and other) then
180
+ continue
181
+ end
182
+ if self:inSameGroup(name, other) then
183
+ continue
184
+ end
185
+ if self.appManager:getState(other) then
186
+ self.appManager:set(other, false)
187
+ end
188
+ end
189
+ end
190
+ function RulesManager:layer(_name, _layer)
191
+ -- TODO: implement priority / layering
192
+ end
193
+ end
194
+ return {
195
+ default = RulesManager,
196
+ }
@@ -0,0 +1,53 @@
1
+ // Types
2
+ import type { Args } from "./decorator";
3
+ import type AppForge from ".";
4
+
5
+ declare namespace Types {
6
+ type AppRegistryProps = {
7
+ name: AppNames[number];
8
+ visible?: boolean;
9
+ rules?: Rules.All;
10
+ };
11
+
12
+ type NameProps =
13
+ | { name?: AppNames[number]; names?: undefined }
14
+ | { names?: AppNames[number][]; name?: undefined };
15
+
16
+ type MainProps = {
17
+ props: AppProps;
18
+ forge: AppForge;
19
+ target?: GuiObject | Camera;
20
+ };
21
+
22
+ type ClassProps = AppProps & {
23
+ px: ReturnType<typeof import("@rbxts/loners-pretty-react-hooks").usePx>;
24
+ };
25
+
26
+ type AppRegistry = {
27
+ constructor: new (props: MainProps) => Args;
28
+ visible?: boolean;
29
+ rules?: Rules.All;
30
+ };
31
+
32
+ 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
+ type All = {
40
+ blockedBy?: BlockedBy;
41
+ exclusive?: Exclusive;
42
+ groups?: Groups;
43
+ blocks?: Blocks;
44
+ layer?: Layer;
45
+ };
46
+ }
47
+ }
48
+
49
+ export type MainProps = Types.MainProps;
50
+ export type NameProps = Types.NameProps;
51
+ export type ClassProps = Types.ClassProps;
52
+
53
+ export default Types;
@@ -0,0 +1,2 @@
1
+ import type Types from "./types";
2
+ export declare function AppContainer(props: Types.NameProps & Types.MainProps): ScreenGui | Frame;
@@ -1,29 +1,34 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
- TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
4
3
  -- Services
5
4
  local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
6
5
  -- Packages
7
6
  local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
8
- local Vide = _vide
7
+ local vide = _vide
9
8
  local source = _vide.source
10
9
  -- Types
11
10
  -- Components
12
11
  local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
13
- local function createSource(name, manager)
12
+ local create = vide.create
13
+ local function createSource(name, forge)
14
14
  local _name = name
15
15
  local app = AppRegistry[_name]
16
16
  if not app then
17
17
  error(`App "{name}" not registered`)
18
18
  end
19
+ local _sources = forge.sources
20
+ local _name_1 = name
21
+ if _sources[_name_1] ~= nil then
22
+ return nil
23
+ end
24
+ local _sources_1 = forge.sources
25
+ local _exp = name
19
26
  local _condition = app.visible
20
27
  if _condition == nil then
21
28
  _condition = false
22
29
  end
23
- local appSource = source(_condition)
24
- local _sources = manager.sources
25
- local _name_1 = name
26
- _sources[_name_1] = appSource
30
+ local _arg1 = source(_condition)
31
+ _sources_1[_exp] = _arg1
27
32
  return source
28
33
  end
29
34
  local function createInstance(props)
@@ -58,19 +63,21 @@ local function AppContainer(props)
58
63
  error(`Failed to create instance for app "{name}"`)
59
64
  end
60
65
  if RunService:IsRunning() then
61
- return Vide.jsx("screengui", {
66
+ return create("ScreenGui")({
62
67
  Name = name,
63
68
  ZIndexBehavior = "Sibling",
64
69
  ResetOnSpawn = false,
65
- }, element)
70
+ [0] = element,
71
+ })
66
72
  else
67
- return Vide.jsx("frame", {
73
+ return create("Frame")({
68
74
  Name = name,
69
75
  BackgroundTransparency = 1,
70
76
  Size = UDim2.fromScale(1, 1),
71
- }, element)
77
+ [0] = element,
78
+ })
72
79
  end
73
80
  end
74
81
  return {
75
- default = AppContainer,
82
+ AppContainer = AppContainer,
76
83
  }
@@ -1,6 +1,5 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
- -- Services
4
3
  -- Packages
5
4
  local pxScale = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-vide-utils").out).px
6
5
  -- Types
@@ -1,2 +1,2 @@
1
1
  import Types from "./types";
2
- export declare function Render(props: Types.NameProps & Types.MainProps): import("@rbxts/vide").Node;
2
+ export declare function Render(props: Types.NameProps & Types.MainProps): ScreenGui | Frame | (ScreenGui | Frame)[];
@@ -0,0 +1,15 @@
1
+ import Vide from "@rbxts/vide";
2
+ import type Types from "./types";
3
+ export default class AppForge {
4
+ sources: Map<string, Vide.Source<boolean>>;
5
+ loaded: Map<string, Vide.Node>;
6
+ private rulesManager;
7
+ getSource(name: AppNames[number]): Vide.Source<boolean>;
8
+ set(name: AppNames[number], value: Vide.Source<boolean> | boolean): void;
9
+ open(name: AppNames[number]): void;
10
+ close(name: AppNames[number]): void;
11
+ toggle(name: AppNames[number]): void;
12
+ renderApp(props: Types.NameProps & Types.MainProps): ScreenGui | Frame;
13
+ renderApps(props: Types.NameProps & Types.MainProps): (ScreenGui | Frame)[];
14
+ renderAll(props: Types.MainProps): (ScreenGui | Frame)[];
15
+ }
@@ -0,0 +1,110 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ -- Types
5
+ -- Components
6
+ local AppContainer = TS.import(script, script, "container").AppContainer
7
+ local AppRegistry = TS.import(script, script, "decorator").AppRegistry
8
+ -- Classes
9
+ local RulesManager = TS.import(script, script, "rules").default
10
+ local AppForge
11
+ do
12
+ AppForge = setmetatable({}, {
13
+ __tostring = function()
14
+ return "AppForge"
15
+ end,
16
+ })
17
+ AppForge.__index = AppForge
18
+ function AppForge.new(...)
19
+ local self = setmetatable({}, AppForge)
20
+ return self:constructor(...) or self
21
+ end
22
+ function AppForge:constructor()
23
+ self.sources = {}
24
+ self.loaded = {}
25
+ self.rulesManager = RulesManager.new(self)
26
+ end
27
+ function AppForge:getSource(name)
28
+ local _sources = self.sources
29
+ local _name = name
30
+ if not (_sources[_name] ~= nil) then
31
+ error(`App "{name}" has no source`)
32
+ end
33
+ local _sources_1 = self.sources
34
+ local _name_1 = name
35
+ return _sources_1[_name_1]
36
+ end
37
+ function AppForge:set(name, value)
38
+ if not self.rulesManager:applyRules(name, value) then
39
+ return nil
40
+ end
41
+ local _value = value
42
+ if type(_value) == "function" then
43
+ local _sources = self.sources
44
+ local _name = name
45
+ local _value_1 = value
46
+ _sources[_name] = _value_1
47
+ else
48
+ local _sources = self.sources
49
+ local _name = name
50
+ local source = _sources[_name]
51
+ if not source then
52
+ error(`App "{name}" has no source`)
53
+ end
54
+ source(value)
55
+ end
56
+ end
57
+ function AppForge:open(name)
58
+ self:set(name, true)
59
+ end
60
+ function AppForge:close(name)
61
+ self:set(name, false)
62
+ end
63
+ function AppForge:toggle(name)
64
+ self:set(name, not self:getSource(name)())
65
+ end
66
+ function AppForge:renderApp(props)
67
+ return AppContainer(props)
68
+ end
69
+ function AppForge:renderApps(props)
70
+ local names = props.names
71
+ if names then
72
+ -- ▼ ReadonlyArray.map ▼
73
+ local _newValue = table.create(#names)
74
+ local _callback = function(name)
75
+ local _self = self
76
+ local _object = table.clone(props)
77
+ setmetatable(_object, nil)
78
+ _object.name = name
79
+ _object.names = nil
80
+ return _self:renderApp(_object)
81
+ end
82
+ for _k, _v in names do
83
+ _newValue[_k] = _callback(_v, _k - 1, names)
84
+ end
85
+ -- ▲ ReadonlyArray.map ▲
86
+ return _newValue
87
+ end
88
+ error("No app names provided to renderApps")
89
+ end
90
+ function AppForge:renderAll(props)
91
+ local names = {}
92
+ -- ▼ ReadonlyMap.forEach ▼
93
+ local _callback = function(_, name)
94
+ local _name = name
95
+ table.insert(names, _name)
96
+ end
97
+ for _k, _v in AppRegistry do
98
+ _callback(_v, _k, AppRegistry)
99
+ end
100
+ -- ▲ ReadonlyMap.forEach ▲
101
+ local _self = self
102
+ local _object = table.clone(props)
103
+ setmetatable(_object, nil)
104
+ _object.names = names
105
+ return _self:renderApps(_object)
106
+ end
107
+ end
108
+ return {
109
+ default = AppForge,
110
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/app-forge",
3
- "version": "0.5.9",
3
+ "version": "0.6.0-alpha.1",
4
4
  "description": "An App Manager for react",
5
5
  "main": "out/init.lua",
6
6
  "packageManager": "bun@1.3.1",
@@ -11,7 +11,8 @@
11
11
  },
12
12
  "keywords": [
13
13
  "roblox-ts",
14
- "react"
14
+ "react",
15
+ "vide"
15
16
  ],
16
17
  "author": "loner1536",
17
18
  "license": "MIT",
@@ -40,15 +41,14 @@
40
41
  "typescript": "^5.9.3"
41
42
  },
42
43
  "dependencies": {
43
- "@rbxts/vide": "^0.5.7",
44
- "@rbxts/ripple": "^0.9.3",
45
- "@rbxts/services": "^1.6.0",
46
44
  "@rbxts/set-timeout": "^1.1.2",
47
- "@rbxts/loners-pretty-vide-utils": "^0.1.4"
45
+ "@rbxts/services": "^1.6.0"
48
46
  },
49
47
  "peerDependencies": {
48
+ "@rbxts/loners-pretty-react-hooks": "*",
50
49
  "@rbxts/loners-pretty-vide-utils": "*",
51
50
  "@rbxts/object-utils": "*",
51
+ "@rbxts/react": "*",
52
52
  "@rbxts/vide": "*"
53
53
  }
54
54
  }
@@ -1,4 +0,0 @@
1
- import "@rbxts/vide";
2
- import Vide from "@rbxts/vide";
3
- import type Types from "./types";
4
- export default function AppContainer(props: Types.NameProps & Types.MainProps): Vide.Node;
File without changes
File without changes
File without changes
File without changes
File without changes