@rbxts/app-forge 0.1.2 → 0.1.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.d.ts +2 -5
- package/out/container.luau +18 -16
- package/out/decorator.d.ts +6 -2
- package/out/decorator.luau +14 -1
- package/out/global.d.ts +5 -5
- package/out/helpers.d.ts +3 -5
- package/out/helpers.luau +7 -8
- package/out/index.d.ts +4 -3
- package/out/init.luau +37 -22
- package/out/types.d.ts +11 -1
- package/package.json +3 -2
package/out/container.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare function AppContainer(props:
|
|
3
|
-
name: AppNames[number];
|
|
4
|
-
manager: AppForge;
|
|
5
|
-
}): JSX.Element;
|
|
1
|
+
import type Types from "./types";
|
|
2
|
+
export declare function AppContainer(props: Types.MainProps): JSX.Element;
|
package/out/container.luau
CHANGED
|
@@ -26,33 +26,35 @@ local function createBinding(name, manager)
|
|
|
26
26
|
_binds[_name_1] = binding
|
|
27
27
|
return unpack(binding)
|
|
28
28
|
end
|
|
29
|
-
local function createInstance(props
|
|
30
|
-
local
|
|
31
|
-
local
|
|
29
|
+
local function createInstance(props)
|
|
30
|
+
local _binding = props
|
|
31
|
+
local name = _binding.name
|
|
32
|
+
local forge = _binding.forge
|
|
33
|
+
if not (name ~= "" and name) then
|
|
34
|
+
error("App name is required to create instance")
|
|
35
|
+
end
|
|
36
|
+
local appClass = AppRegistry[name]
|
|
32
37
|
if not appClass then
|
|
33
38
|
error(`App "{name}" not registered`)
|
|
34
39
|
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if not (_loaded[_name_1] ~= nil) then
|
|
38
|
-
local instance = appClass.constructor.new(props, forge, name)
|
|
40
|
+
if not (forge.loaded[name] ~= nil) then
|
|
41
|
+
local instance = appClass.constructor.new(props)
|
|
39
42
|
local element = cloneElement(instance:render(), {
|
|
40
43
|
key = "Main",
|
|
41
44
|
})
|
|
42
|
-
|
|
43
|
-
local _name_2 = name
|
|
44
|
-
_loaded_1[_name_2] = element
|
|
45
|
+
forge.loaded[name] = element
|
|
45
46
|
end
|
|
46
|
-
|
|
47
|
-
local _name_2 = name
|
|
48
|
-
return _loaded_1[_name_2]
|
|
47
|
+
return forge.loaded[name]
|
|
49
48
|
end
|
|
50
49
|
local function AppContainer(props)
|
|
51
50
|
local _binding = props
|
|
52
51
|
local name = _binding.name
|
|
53
|
-
local
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
local forge = _binding.forge
|
|
53
|
+
if not (name ~= "" and name) then
|
|
54
|
+
error("App name is required in AppContainer")
|
|
55
|
+
end
|
|
56
|
+
createBinding(name, forge)
|
|
57
|
+
local element = createInstance(props)
|
|
56
58
|
if not element then
|
|
57
59
|
error(`Failed to create instance for app "{name}"`)
|
|
58
60
|
end
|
package/out/decorator.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { usePx } from "@rbxts/loners-pretty-react-hooks";
|
|
1
2
|
import React from "@rbxts/react";
|
|
2
3
|
import type Types from "./types";
|
|
3
4
|
import type AppForge from ".";
|
|
5
|
+
import ReactRoblox from "@rbxts/react-roblox";
|
|
4
6
|
export declare const AppRegistry: Map<string, Types.AppRegistry>;
|
|
5
|
-
export declare function App(props: Types.AppRegistryProps): <T extends new (props:
|
|
7
|
+
export declare function App(props: Types.AppRegistryProps): <T extends new (props: Types.MainProps) => Args>(constructor: T) => T;
|
|
6
8
|
export declare abstract class Args {
|
|
7
9
|
readonly Forge: AppForge;
|
|
10
|
+
readonly root: ReactRoblox.Root | undefined;
|
|
8
11
|
readonly props: AppProps;
|
|
9
12
|
readonly name: AppNames[number];
|
|
10
13
|
readonly bind: React.Binding<boolean>;
|
|
11
|
-
|
|
14
|
+
readonly px: ReturnType<typeof usePx>;
|
|
15
|
+
constructor(props: Types.MainProps);
|
|
12
16
|
abstract render(): JSX.Element;
|
|
13
17
|
}
|
package/out/decorator.luau
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Services
|
|
2
4
|
-- Packages
|
|
5
|
+
local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-react-hooks").out).usePx
|
|
3
6
|
-- Types
|
|
4
7
|
local AppRegistry = {}
|
|
5
8
|
local function App(props)
|
|
@@ -21,11 +24,21 @@ end
|
|
|
21
24
|
local Args
|
|
22
25
|
do
|
|
23
26
|
Args = {}
|
|
24
|
-
function Args:constructor(props
|
|
27
|
+
function Args:constructor(props)
|
|
28
|
+
local _binding = props
|
|
29
|
+
local root = _binding.root
|
|
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
|
|
25
36
|
self.Forge = forge
|
|
37
|
+
self.root = root
|
|
26
38
|
self.props = props
|
|
27
39
|
self.name = name
|
|
28
40
|
self.bind = forge:getBind(name)
|
|
41
|
+
self.px = usePx(target)
|
|
29
42
|
end
|
|
30
43
|
end
|
|
31
44
|
return {
|
package/out/global.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare global {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// These will be overridden by the user
|
|
3
|
+
// They are only placeholders for your build
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type AppGroups = readonly string[];
|
|
6
|
+
type AppNames = readonly string[];
|
|
7
|
+
type AppProps = {};
|
|
8
8
|
}
|
|
9
9
|
export {};
|
package/out/helpers.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function Render({ props
|
|
3
|
-
props:
|
|
4
|
-
forge: AppForge;
|
|
5
|
-
names?: AppNames[number] | AppNames[number][];
|
|
1
|
+
import Types from "./types";
|
|
2
|
+
export declare function Render({ props }: {
|
|
3
|
+
props: Types.MainProps;
|
|
6
4
|
}): JSX.Element | JSX.Element[];
|
package/out/helpers.luau
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
-- Types
|
|
3
3
|
local function Render(_param)
|
|
4
4
|
local props = _param.props
|
|
5
|
-
local
|
|
6
|
-
local
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
end
|
|
5
|
+
local names = props.names
|
|
6
|
+
local name = props.name
|
|
7
|
+
local forge = props.forge
|
|
8
|
+
if name ~= "" and name then
|
|
9
|
+
return forge:renderApp(props)
|
|
10
|
+
elseif names then
|
|
11
|
+
return forge:renderApps(props)
|
|
13
12
|
end
|
|
14
13
|
return forge:renderAll(props)
|
|
15
14
|
end
|
package/out/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
|
+
import type Types from "./types";
|
|
2
3
|
import { Args, App } from "./decorator";
|
|
3
4
|
export default class AppForge {
|
|
4
5
|
binds: Map<string, [React.Binding<boolean>, (T: boolean) => void]>;
|
|
@@ -10,9 +11,9 @@ export default class AppForge {
|
|
|
10
11
|
open(name: AppNames[number]): void;
|
|
11
12
|
close(name: AppNames[number]): void;
|
|
12
13
|
toggle(name: AppNames[number]): void;
|
|
13
|
-
renderApp(props:
|
|
14
|
-
renderApps(props:
|
|
15
|
-
renderAll(props:
|
|
14
|
+
renderApp(props: Types.MainProps): JSX.Element;
|
|
15
|
+
renderApps(props: Types.MainProps): JSX.Element | JSX.Element[];
|
|
16
|
+
renderAll(props: Types.MainProps): JSX.Element | JSX.Element[];
|
|
16
17
|
}
|
|
17
18
|
export { App, Args };
|
|
18
19
|
export { Render } from "./helpers";
|
package/out/init.luau
CHANGED
|
@@ -3,6 +3,7 @@ local TS = _G[script]
|
|
|
3
3
|
local exports = {}
|
|
4
4
|
-- Packages
|
|
5
5
|
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
6
|
+
-- Types
|
|
6
7
|
-- Components
|
|
7
8
|
local _decorator = TS.import(script, script, "decorator")
|
|
8
9
|
local AppRegistry = _decorator.AppRegistry
|
|
@@ -64,41 +65,55 @@ do
|
|
|
64
65
|
function AppForge:toggle(name)
|
|
65
66
|
self:set(name, not self:getState(name))
|
|
66
67
|
end
|
|
67
|
-
function AppForge:renderApp(props
|
|
68
|
-
local _attributes =
|
|
69
|
-
|
|
70
|
-
name = name,
|
|
71
|
-
manager = self,
|
|
72
|
-
}
|
|
73
|
-
for _k, _v in props do
|
|
74
|
-
_attributes[_k] = _v
|
|
75
|
-
end
|
|
68
|
+
function AppForge:renderApp(props)
|
|
69
|
+
local _attributes = table.clone(props)
|
|
70
|
+
setmetatable(_attributes, nil)
|
|
76
71
|
return React.createElement(AppContainer, _attributes)
|
|
77
72
|
end
|
|
78
|
-
function AppForge:renderApps(props
|
|
79
|
-
|
|
80
|
-
local
|
|
81
|
-
local
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
function AppForge:renderApps(props)
|
|
74
|
+
local _binding = props
|
|
75
|
+
local name = _binding.name
|
|
76
|
+
local names = _binding.names
|
|
77
|
+
if name ~= "" and name then
|
|
78
|
+
return self:renderApp({
|
|
79
|
+
props = props,
|
|
80
|
+
name = name,
|
|
81
|
+
forge = self,
|
|
82
|
+
})
|
|
83
|
+
elseif names then
|
|
84
|
+
-- ▼ ReadonlyArray.map ▼
|
|
85
|
+
local _newValue = table.create(#names)
|
|
86
|
+
local _callback = function(n)
|
|
87
|
+
return self:renderApp({
|
|
88
|
+
props = props,
|
|
89
|
+
name = n,
|
|
90
|
+
forge = self,
|
|
91
|
+
})
|
|
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
|
|
86
98
|
end
|
|
87
|
-
|
|
88
|
-
return _newValue
|
|
99
|
+
error("Invalid props: must provide name or names")
|
|
89
100
|
end
|
|
90
101
|
function AppForge:renderAll(props)
|
|
91
|
-
local
|
|
102
|
+
local names = {}
|
|
92
103
|
-- ▼ ReadonlyMap.forEach ▼
|
|
93
104
|
local _callback = function(_, name)
|
|
94
105
|
local _name = name
|
|
95
|
-
table.insert(
|
|
106
|
+
table.insert(names, _name)
|
|
96
107
|
end
|
|
97
108
|
for _k, _v in AppRegistry do
|
|
98
109
|
_callback(_v, _k, AppRegistry)
|
|
99
110
|
end
|
|
100
111
|
-- ▲ ReadonlyMap.forEach ▲
|
|
101
|
-
return self:renderApps(
|
|
112
|
+
return self:renderApps({
|
|
113
|
+
props = props,
|
|
114
|
+
names = names,
|
|
115
|
+
forge = self,
|
|
116
|
+
})
|
|
102
117
|
end
|
|
103
118
|
end
|
|
104
119
|
exports.Render = TS.import(script, script, "helpers").Render
|
package/out/types.d.ts
CHANGED
|
@@ -9,8 +9,18 @@ declare namespace Types {
|
|
|
9
9
|
rules?: Rules.All;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
type MainProps = {
|
|
13
|
+
props: AppProps;
|
|
14
|
+
} & ExtraProps;
|
|
15
|
+
|
|
16
|
+
type ExtraProps = {
|
|
17
|
+
target?: GuiObject | Camera;
|
|
18
|
+
root?: ReactRoblox.Root;
|
|
19
|
+
forge: AppForge;
|
|
20
|
+
} & ({ name: AppNames[number]; names?: never } | { names: AppNames[number][]; name?: never });
|
|
21
|
+
|
|
12
22
|
type AppRegistry = {
|
|
13
|
-
constructor: new (props:
|
|
23
|
+
constructor: new (props: MainProps) => Args;
|
|
14
24
|
visible?: boolean;
|
|
15
25
|
rules?: Rules.All;
|
|
16
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/app-forge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "An App Manager for react",
|
|
5
5
|
"main": "out/init.lua",
|
|
6
6
|
"packageManager": "bun@1.3.1",
|
|
@@ -45,13 +45,14 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@rbxts/charm": "^0.10.0",
|
|
48
|
-
"@rbxts/loners-pretty-react-hooks": "^0.
|
|
48
|
+
"@rbxts/loners-pretty-react-hooks": "^0.2.9",
|
|
49
49
|
"@rbxts/react-charm": "^0.3.0",
|
|
50
50
|
"@rbxts/ripple": "^0.9.3",
|
|
51
51
|
"@rbxts/services": "^1.6.0",
|
|
52
52
|
"@rbxts/set-timeout": "^1.1.2"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
+
"@rbxts/loners-pretty-react-hooks": "*",
|
|
55
56
|
"@rbxts/react-roblox": "*",
|
|
56
57
|
"@rbxts/react": "*"
|
|
57
58
|
}
|