@rbxts/app-forge 0.6.0-alpha.21 → 0.6.0-alpha.22
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/react/helpers.luau +20 -3
- package/out/react/index.d.ts +7 -3
- package/out/react/init.luau +16 -16
- package/package.json +1 -1
package/out/react/helpers.luau
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Packages
|
|
4
|
-
local
|
|
4
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
5
|
+
local useBinding = _react.useBinding
|
|
6
|
+
local useState = _react.useState
|
|
5
7
|
-- Types
|
|
6
8
|
-- Components
|
|
7
9
|
local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
|
|
@@ -19,7 +21,21 @@ local function createBinding(name, manager)
|
|
|
19
21
|
local _binds = manager.binds
|
|
20
22
|
local _name_1 = name
|
|
21
23
|
_binds[_name_1] = binding
|
|
22
|
-
|
|
24
|
+
end
|
|
25
|
+
local function createState(name, manager)
|
|
26
|
+
local _name = name
|
|
27
|
+
local app = AppRegistry[_name]
|
|
28
|
+
if not app then
|
|
29
|
+
error(`App "{name}" not registered`)
|
|
30
|
+
end
|
|
31
|
+
local _condition = app.visible
|
|
32
|
+
if _condition == nil then
|
|
33
|
+
_condition = false
|
|
34
|
+
end
|
|
35
|
+
local state = { useState(_condition) }
|
|
36
|
+
local _states = manager.states
|
|
37
|
+
local _name_1 = name
|
|
38
|
+
_states[_name_1] = state
|
|
23
39
|
end
|
|
24
40
|
local function Render(props)
|
|
25
41
|
local names = props.names
|
|
@@ -27,7 +43,8 @@ local function Render(props)
|
|
|
27
43
|
local forge = props.forge
|
|
28
44
|
-- ▼ ReadonlyMap.forEach ▼
|
|
29
45
|
local _callback = function(_, name)
|
|
30
|
-
|
|
46
|
+
createBinding(name, forge)
|
|
47
|
+
createState(name, forge)
|
|
31
48
|
end
|
|
32
49
|
for _k, _v in AppRegistry do
|
|
33
50
|
_callback(_v, _k, AppRegistry)
|
package/out/react/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
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[number]): React.Binding<boolean
|
|
8
|
-
getState(name: AppNames[number]): boolean
|
|
10
|
+
getBind(name: AppNames[number]): React.Binding<boolean>;
|
|
11
|
+
getState(name: AppNames[number]): boolean;
|
|
9
12
|
set(name: AppNames[number], value: boolean): void;
|
|
10
13
|
open(name: AppNames[number]): void;
|
|
11
14
|
close(name: AppNames[number]): void;
|
|
@@ -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,6 @@ 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
|
-
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
11
10
|
local AppForge
|
|
12
11
|
do
|
|
13
12
|
AppForge = setmetatable({}, {
|
|
@@ -21,20 +20,12 @@ do
|
|
|
21
20
|
return self:constructor(...) or self
|
|
22
21
|
end
|
|
23
22
|
function AppForge:constructor()
|
|
24
|
-
self.binds = {}
|
|
25
23
|
self.loaded = {}
|
|
24
|
+
self.binds = {}
|
|
25
|
+
self.states = {}
|
|
26
26
|
self.rulesManager = RulesManager.new(self)
|
|
27
27
|
end
|
|
28
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
29
|
local _binds = self.binds
|
|
39
30
|
local _name = name
|
|
40
31
|
if not (_binds[_name] ~= nil) then
|
|
@@ -45,11 +36,14 @@ do
|
|
|
45
36
|
return _binds_1[_name_1][1]
|
|
46
37
|
end
|
|
47
38
|
function AppForge:getState(name)
|
|
48
|
-
local
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
local _states = self.states
|
|
40
|
+
local _name = name
|
|
41
|
+
if not (_states[_name] ~= nil) then
|
|
42
|
+
error(`App "{name}" has no state`)
|
|
51
43
|
end
|
|
52
|
-
|
|
44
|
+
local _states_1 = self.states
|
|
45
|
+
local _name_1 = name
|
|
46
|
+
return _states_1[_name_1][1]
|
|
53
47
|
end
|
|
54
48
|
function AppForge:set(name, value)
|
|
55
49
|
if not self.rulesManager:applyRules(name, value) then
|
|
@@ -58,12 +52,18 @@ do
|
|
|
58
52
|
local _binds = self.binds
|
|
59
53
|
local _name = name
|
|
60
54
|
local _binding = _binds[_name]
|
|
61
|
-
local
|
|
55
|
+
local _b = _binding[1]
|
|
62
56
|
local setBinding = _binding[2]
|
|
57
|
+
local _states = self.states
|
|
58
|
+
local _name_1 = name
|
|
59
|
+
local _binding_1 = _states[_name_1]
|
|
60
|
+
local _s = _binding_1[1]
|
|
61
|
+
local setState = _binding_1[2]
|
|
63
62
|
if not setBinding then
|
|
64
63
|
error(`App "{name}" has no binding setter`)
|
|
65
64
|
end
|
|
66
65
|
setBinding(value)
|
|
66
|
+
setState(value)
|
|
67
67
|
end
|
|
68
68
|
function AppForge:open(name)
|
|
69
69
|
self:set(name, true)
|