@rbxts/app-forge 0.4.4 → 0.4.5
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/container.luau +7 -6
- package/out/decorator.d.ts +3 -2
- package/out/decorator.luau +5 -7
- package/out/index.d.ts +3 -4
- package/out/init.luau +21 -14
- package/package.json +1 -1
package/out/container.luau
CHANGED
|
@@ -3,8 +3,9 @@ local TS = _G[script]
|
|
|
3
3
|
-- Services
|
|
4
4
|
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
5
5
|
-- Packages
|
|
6
|
-
local
|
|
7
|
-
local React =
|
|
6
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
7
|
+
local React = _react
|
|
8
|
+
local useBinding = _react.useBinding
|
|
8
9
|
-- Types
|
|
9
10
|
-- Components
|
|
10
11
|
local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
|
|
@@ -18,11 +19,11 @@ local function createBinding(name, manager)
|
|
|
18
19
|
if _condition == nil then
|
|
19
20
|
_condition = false
|
|
20
21
|
end
|
|
21
|
-
local binding =
|
|
22
|
-
local
|
|
22
|
+
local binding = { useBinding(_condition) }
|
|
23
|
+
local _binds = manager.binds
|
|
23
24
|
local _name_1 = name
|
|
24
|
-
|
|
25
|
-
return binding
|
|
25
|
+
_binds[_name_1] = binding
|
|
26
|
+
return unpack(binding)
|
|
26
27
|
end
|
|
27
28
|
local function createInstance(props)
|
|
28
29
|
local _binding = props
|
package/out/decorator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
2
|
import type Types from "./types";
|
|
3
3
|
import type AppForge from ".";
|
|
4
4
|
export declare const AppRegistry: Map<string, Types.AppRegistry>;
|
|
@@ -7,7 +7,8 @@ export declare abstract class Args {
|
|
|
7
7
|
readonly forge: AppForge;
|
|
8
8
|
readonly props: Types.ClassProps;
|
|
9
9
|
readonly name: AppNames[number];
|
|
10
|
-
readonly
|
|
10
|
+
readonly bind: React.Binding<boolean>;
|
|
11
|
+
readonly state: Boolean;
|
|
11
12
|
constructor(props: Types.NameProps & Types.MainProps);
|
|
12
13
|
abstract render(): JSX.Element;
|
|
13
14
|
}
|
package/out/decorator.luau
CHANGED
|
@@ -4,7 +4,6 @@ local TS = _G[script]
|
|
|
4
4
|
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
5
5
|
-- Packages
|
|
6
6
|
local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-react-hooks").out).usePx
|
|
7
|
-
local useAtom = TS.import(script, TS.getModule(script, "@rbxts", "react-charm")).useAtom
|
|
8
7
|
-- Types
|
|
9
8
|
local AppRegistry = {}
|
|
10
9
|
local function App(props)
|
|
@@ -34,9 +33,9 @@ do
|
|
|
34
33
|
if not (name ~= "" and name) then
|
|
35
34
|
error("App name is required in Args constructor")
|
|
36
35
|
end
|
|
37
|
-
local
|
|
38
|
-
if not
|
|
39
|
-
error("FAILED TO GET
|
|
36
|
+
local bind = forge:getBind(name)
|
|
37
|
+
if not bind and RunService:IsRunning() then
|
|
38
|
+
error("FAILED TO GET BIND FOR APP!")
|
|
40
39
|
end
|
|
41
40
|
local px = usePx(target)
|
|
42
41
|
self.forge = forge
|
|
@@ -45,9 +44,8 @@ do
|
|
|
45
44
|
_object.px = px
|
|
46
45
|
self.props = _object
|
|
47
46
|
self.name = name
|
|
48
|
-
self.
|
|
49
|
-
|
|
50
|
-
end)
|
|
47
|
+
self.bind = bind
|
|
48
|
+
self.state = if self.bind then self.bind:getValue() else nil
|
|
51
49
|
end
|
|
52
50
|
end
|
|
53
51
|
return {
|
package/out/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
|
-
import type { Atom } from "@rbxts/charm";
|
|
3
2
|
import type Types from "./types";
|
|
4
3
|
import { Args, App } from "./decorator";
|
|
5
4
|
export default class AppForge {
|
|
6
|
-
|
|
5
|
+
binds: Map<string, [React.Binding<boolean>, (T: boolean) => void]>;
|
|
7
6
|
loaded: Map<string, React.Element<any, string | React.JSXElementConstructor<any>>>;
|
|
8
7
|
private rulesManager;
|
|
9
|
-
|
|
10
|
-
getState(name: AppNames[number]):
|
|
8
|
+
getBind(name: AppNames[number]): React.Binding<boolean> | undefined;
|
|
9
|
+
getState(name: AppNames[number]): boolean | undefined;
|
|
11
10
|
set(name: AppNames[number], value: boolean): void;
|
|
12
11
|
open(name: AppNames[number]): void;
|
|
13
12
|
close(name: AppNames[number]): void;
|
package/out/init.luau
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local exports = {}
|
|
4
|
+
-- Services
|
|
5
|
+
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
4
6
|
-- Packages
|
|
5
7
|
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
6
8
|
-- Types
|
|
@@ -12,7 +14,6 @@ local App = _decorator.App
|
|
|
12
14
|
local AppContainer = TS.import(script, script, "container").AppContainer
|
|
13
15
|
-- Classes
|
|
14
16
|
local RulesManager = TS.import(script, script, "rules").default
|
|
15
|
-
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
16
17
|
local AppForge
|
|
17
18
|
do
|
|
18
19
|
AppForge = setmetatable({}, {
|
|
@@ -26,43 +27,49 @@ do
|
|
|
26
27
|
return self:constructor(...) or self
|
|
27
28
|
end
|
|
28
29
|
function AppForge:constructor()
|
|
29
|
-
self.
|
|
30
|
+
self.binds = {}
|
|
30
31
|
self.loaded = {}
|
|
31
32
|
self.rulesManager = RulesManager.new(self)
|
|
32
33
|
end
|
|
33
|
-
function AppForge:
|
|
34
|
+
function AppForge:getBind(name)
|
|
34
35
|
local _condition = not RunService:IsRunning()
|
|
35
36
|
if _condition then
|
|
36
|
-
local
|
|
37
|
+
local _binds = self.binds
|
|
37
38
|
local _name = name
|
|
38
|
-
_condition = not (
|
|
39
|
+
_condition = not (_binds[_name] ~= nil)
|
|
39
40
|
end
|
|
40
41
|
if _condition then
|
|
41
42
|
return nil
|
|
42
43
|
end
|
|
43
|
-
local
|
|
44
|
+
local _binds = self.binds
|
|
44
45
|
local _name = name
|
|
45
|
-
if not (
|
|
46
|
+
if not (_binds[_name] ~= nil) then
|
|
46
47
|
error(`App "{name}" has no binding`)
|
|
47
48
|
end
|
|
48
|
-
local
|
|
49
|
+
local _binds_1 = self.binds
|
|
49
50
|
local _name_1 = name
|
|
50
|
-
return
|
|
51
|
+
return _binds_1[_name_1][1]
|
|
51
52
|
end
|
|
52
53
|
function AppForge:getState(name)
|
|
53
|
-
|
|
54
|
+
local _result = self:getBind(name)
|
|
55
|
+
if _result ~= nil then
|
|
56
|
+
_result = _result:getValue()
|
|
57
|
+
end
|
|
58
|
+
return _result
|
|
54
59
|
end
|
|
55
60
|
function AppForge:set(name, value)
|
|
56
61
|
if not self.rulesManager:applyRules(name, value) then
|
|
57
62
|
return nil
|
|
58
63
|
end
|
|
59
|
-
local
|
|
64
|
+
local _binds = self.binds
|
|
60
65
|
local _name = name
|
|
61
|
-
local
|
|
62
|
-
|
|
66
|
+
local _binding = _binds[_name]
|
|
67
|
+
local _ = _binding[1]
|
|
68
|
+
local setBinding = _binding[2]
|
|
69
|
+
if not setBinding then
|
|
63
70
|
error(`App "{name}" has no binding setter`)
|
|
64
71
|
end
|
|
65
|
-
|
|
72
|
+
setBinding(value)
|
|
66
73
|
end
|
|
67
74
|
function AppForge:open(name)
|
|
68
75
|
self:set(name, true)
|