@rbxts/app-forge 0.4.2 → 0.4.4
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 +6 -7
- package/out/decorator.d.ts +2 -3
- package/out/decorator.luau +7 -5
- package/out/index.d.ts +4 -3
- package/out/init.luau +18 -18
- package/package.json +3 -2
package/out/container.luau
CHANGED
|
@@ -3,9 +3,8 @@ 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 =
|
|
8
|
-
local useBinding = _react.useBinding
|
|
6
|
+
local atom = TS.import(script, TS.getModule(script, "@rbxts", "charm")).atom
|
|
7
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
9
8
|
-- Types
|
|
10
9
|
-- Components
|
|
11
10
|
local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
|
|
@@ -19,11 +18,11 @@ local function createBinding(name, manager)
|
|
|
19
18
|
if _condition == nil then
|
|
20
19
|
_condition = false
|
|
21
20
|
end
|
|
22
|
-
local binding =
|
|
23
|
-
local
|
|
21
|
+
local binding = atom(_condition)
|
|
22
|
+
local _atoms = manager.atoms
|
|
24
23
|
local _name_1 = name
|
|
25
|
-
|
|
26
|
-
return
|
|
24
|
+
_atoms[_name_1] = binding
|
|
25
|
+
return binding
|
|
27
26
|
end
|
|
28
27
|
local function createInstance(props)
|
|
29
28
|
local _binding = props
|
package/out/decorator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Atom } from "@rbxts/charm";
|
|
2
2
|
import type Types from "./types";
|
|
3
3
|
import type AppForge from ".";
|
|
4
4
|
export declare const AppRegistry: Map<string, Types.AppRegistry>;
|
|
@@ -7,8 +7,7 @@ export declare abstract class Args {
|
|
|
7
7
|
readonly forge: AppForge;
|
|
8
8
|
readonly props: Types.ClassProps;
|
|
9
9
|
readonly name: AppNames[number];
|
|
10
|
-
readonly
|
|
11
|
-
readonly state: Boolean;
|
|
10
|
+
readonly atom: Atom<boolean>;
|
|
12
11
|
constructor(props: Types.NameProps & Types.MainProps);
|
|
13
12
|
abstract render(): JSX.Element;
|
|
14
13
|
}
|
package/out/decorator.luau
CHANGED
|
@@ -4,6 +4,7 @@ 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
|
|
7
8
|
-- Types
|
|
8
9
|
local AppRegistry = {}
|
|
9
10
|
local function App(props)
|
|
@@ -33,9 +34,9 @@ do
|
|
|
33
34
|
if not (name ~= "" and name) then
|
|
34
35
|
error("App name is required in Args constructor")
|
|
35
36
|
end
|
|
36
|
-
local
|
|
37
|
-
if not
|
|
38
|
-
error("FAILED TO GET
|
|
37
|
+
local atom = forge:getAtom(name)
|
|
38
|
+
if not atom and RunService:IsRunning() then
|
|
39
|
+
error("FAILED TO GET ATOM FOR APP!")
|
|
39
40
|
end
|
|
40
41
|
local px = usePx(target)
|
|
41
42
|
self.forge = forge
|
|
@@ -44,8 +45,9 @@ do
|
|
|
44
45
|
_object.px = px
|
|
45
46
|
self.props = _object
|
|
46
47
|
self.name = name
|
|
47
|
-
self.
|
|
48
|
-
|
|
48
|
+
self.atom = useAtom(function()
|
|
49
|
+
return atom
|
|
50
|
+
end)
|
|
49
51
|
end
|
|
50
52
|
end
|
|
51
53
|
return {
|
package/out/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
|
+
import type { Atom } from "@rbxts/charm";
|
|
2
3
|
import type Types from "./types";
|
|
3
4
|
import { Args, App } from "./decorator";
|
|
4
5
|
export default class AppForge {
|
|
5
|
-
|
|
6
|
+
atoms: Map<string, Atom<boolean>>;
|
|
6
7
|
loaded: Map<string, React.Element<any, string | React.JSXElementConstructor<any>>>;
|
|
7
8
|
private rulesManager;
|
|
8
|
-
|
|
9
|
-
getState(name: AppNames[number]): boolean
|
|
9
|
+
getAtom(name: AppNames[number]): Atom<boolean> | undefined;
|
|
10
|
+
getState(name: AppNames[number]): Atom<boolean>;
|
|
10
11
|
set(name: AppNames[number], value: boolean): void;
|
|
11
12
|
open(name: AppNames[number]): void;
|
|
12
13
|
close(name: AppNames[number]): void;
|
package/out/init.luau
CHANGED
|
@@ -26,43 +26,43 @@ do
|
|
|
26
26
|
return self:constructor(...) or self
|
|
27
27
|
end
|
|
28
28
|
function AppForge:constructor()
|
|
29
|
-
self.
|
|
29
|
+
self.atoms = {}
|
|
30
30
|
self.loaded = {}
|
|
31
31
|
self.rulesManager = RulesManager.new(self)
|
|
32
32
|
end
|
|
33
|
-
function AppForge:
|
|
34
|
-
|
|
33
|
+
function AppForge:getAtom(name)
|
|
34
|
+
local _condition = not RunService:IsRunning()
|
|
35
|
+
if _condition then
|
|
36
|
+
local _atoms = self.atoms
|
|
37
|
+
local _name = name
|
|
38
|
+
_condition = not (_atoms[_name] ~= nil)
|
|
39
|
+
end
|
|
40
|
+
if _condition then
|
|
35
41
|
return nil
|
|
36
42
|
end
|
|
37
|
-
local
|
|
43
|
+
local _atoms = self.atoms
|
|
38
44
|
local _name = name
|
|
39
|
-
if not (
|
|
45
|
+
if not (_atoms[_name] ~= nil) then
|
|
40
46
|
error(`App "{name}" has no binding`)
|
|
41
47
|
end
|
|
42
|
-
local
|
|
48
|
+
local _atoms_1 = self.atoms
|
|
43
49
|
local _name_1 = name
|
|
44
|
-
return
|
|
50
|
+
return _atoms_1[_name_1]
|
|
45
51
|
end
|
|
46
52
|
function AppForge:getState(name)
|
|
47
|
-
|
|
48
|
-
if _result ~= nil then
|
|
49
|
-
_result = _result:getValue()
|
|
50
|
-
end
|
|
51
|
-
return _result
|
|
53
|
+
return self:getAtom(name)
|
|
52
54
|
end
|
|
53
55
|
function AppForge:set(name, value)
|
|
54
56
|
if not self.rulesManager:applyRules(name, value) then
|
|
55
57
|
return nil
|
|
56
58
|
end
|
|
57
|
-
local
|
|
59
|
+
local _atoms = self.atoms
|
|
58
60
|
local _name = name
|
|
59
|
-
local
|
|
60
|
-
|
|
61
|
-
local setBinding = _binding[2]
|
|
62
|
-
if not setBinding then
|
|
61
|
+
local atom = _atoms[_name]
|
|
62
|
+
if not atom then
|
|
63
63
|
error(`App "{name}" has no binding setter`)
|
|
64
64
|
end
|
|
65
|
-
|
|
65
|
+
atom(value)
|
|
66
66
|
end
|
|
67
67
|
function AppForge:open(name)
|
|
68
68
|
self:set(name, true)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/app-forge",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "An App Manager for react",
|
|
5
5
|
"main": "out/init.lua",
|
|
6
6
|
"packageManager": "bun@1.3.1",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@rbxts/loners-pretty-react-hooks": "*",
|
|
56
56
|
"@rbxts/react-roblox": "*",
|
|
57
|
-
"@rbxts/react": "*"
|
|
57
|
+
"@rbxts/react": "*",
|
|
58
|
+
"@rbxts/charm": "*"
|
|
58
59
|
}
|
|
59
60
|
}
|