@rbxts/app-forge 0.1.3 → 0.1.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.d.ts +2 -6
- package/out/container.luau +18 -22
- package/out/decorator.d.ts +5 -3
- package/out/decorator.luau +9 -4
- package/out/global.d.ts +5 -5
- package/out/helpers.d.ts +2 -7
- package/out/helpers.luau +8 -10
- package/out/index.d.ts +4 -3
- package/out/init.luau +38 -24
- package/out/types.d.ts +11 -6
- package/package.json +1 -1
package/out/container.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare function AppContainer(props:
|
|
3
|
-
name: AppNames[number];
|
|
4
|
-
manager: AppForge;
|
|
5
|
-
target?: GuiObject | Camera;
|
|
6
|
-
}): JSX.Element;
|
|
1
|
+
import type Types from "./types";
|
|
2
|
+
export declare function AppContainer(props: Types.MainProps): JSX.Element;
|
package/out/container.luau
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Services
|
|
4
|
-
local
|
|
5
|
-
local RunService = _services.RunService
|
|
6
|
-
local Workspace = _services.Workspace
|
|
4
|
+
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
7
5
|
-- Packages
|
|
8
6
|
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
9
7
|
local React = _react
|
|
@@ -28,37 +26,35 @@ local function createBinding(name, manager)
|
|
|
28
26
|
_binds[_name_1] = binding
|
|
29
27
|
return unpack(binding)
|
|
30
28
|
end
|
|
31
|
-
local function createInstance(props
|
|
32
|
-
|
|
33
|
-
|
|
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")
|
|
34
35
|
end
|
|
35
|
-
local
|
|
36
|
-
local appClass = AppRegistry[_name]
|
|
36
|
+
local appClass = AppRegistry[name]
|
|
37
37
|
if not appClass then
|
|
38
38
|
error(`App "{name}" not registered`)
|
|
39
39
|
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if not (_loaded[_name_1] ~= nil) then
|
|
43
|
-
local instance = appClass.constructor.new(props, forge, name, target)
|
|
40
|
+
if not (forge.loaded[name] ~= nil) then
|
|
41
|
+
local instance = appClass.constructor.new(props)
|
|
44
42
|
local element = cloneElement(instance:render(), {
|
|
45
43
|
key = "Main",
|
|
46
44
|
})
|
|
47
|
-
|
|
48
|
-
local _name_2 = name
|
|
49
|
-
_loaded_1[_name_2] = element
|
|
45
|
+
forge.loaded[name] = element
|
|
50
46
|
end
|
|
51
|
-
|
|
52
|
-
local _name_2 = name
|
|
53
|
-
return _loaded_1[_name_2]
|
|
47
|
+
return forge.loaded[name]
|
|
54
48
|
end
|
|
55
49
|
local function AppContainer(props)
|
|
56
50
|
local _binding = props
|
|
57
51
|
local name = _binding.name
|
|
58
|
-
local
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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)
|
|
62
58
|
if not element then
|
|
63
59
|
error(`Failed to create instance for app "{name}"`)
|
|
64
60
|
end
|
package/out/decorator.d.ts
CHANGED
|
@@ -2,14 +2,16 @@ import { usePx } from "@rbxts/loners-pretty-react-hooks";
|
|
|
2
2
|
import React from "@rbxts/react";
|
|
3
3
|
import type Types from "./types";
|
|
4
4
|
import type AppForge from ".";
|
|
5
|
+
import ReactRoblox from "@rbxts/react-roblox";
|
|
5
6
|
export declare const AppRegistry: Map<string, Types.AppRegistry>;
|
|
6
|
-
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;
|
|
7
8
|
export declare abstract class Args {
|
|
8
9
|
readonly Forge: AppForge;
|
|
10
|
+
readonly root: ReactRoblox.Root | undefined;
|
|
9
11
|
readonly props: AppProps;
|
|
10
12
|
readonly name: AppNames[number];
|
|
11
|
-
readonly px: ReturnType<typeof usePx>;
|
|
12
13
|
readonly bind: React.Binding<boolean>;
|
|
13
|
-
|
|
14
|
+
readonly px: ReturnType<typeof usePx>;
|
|
15
|
+
constructor(props: Types.MainProps);
|
|
14
16
|
abstract render(): JSX.Element;
|
|
15
17
|
}
|
package/out/decorator.luau
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Services
|
|
4
|
-
local Workspace = TS.import(script, TS.getModule(script, "@rbxts", "services")).Workspace
|
|
5
4
|
-- Packages
|
|
6
5
|
local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-react-hooks").out).usePx
|
|
7
6
|
-- Types
|
|
@@ -25,11 +24,17 @@ end
|
|
|
25
24
|
local Args
|
|
26
25
|
do
|
|
27
26
|
Args = {}
|
|
28
|
-
function Args:constructor(props
|
|
29
|
-
|
|
30
|
-
|
|
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")
|
|
31
35
|
end
|
|
32
36
|
self.Forge = forge
|
|
37
|
+
self.root = root
|
|
33
38
|
self.props = props
|
|
34
39
|
self.name = name
|
|
35
40
|
self.bind = forge:getBind(name)
|
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,7 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function Render(
|
|
3
|
-
props: AppProps;
|
|
4
|
-
forge: AppForge;
|
|
5
|
-
target?: GuiObject | Camera;
|
|
6
|
-
names?: AppNames[number] | AppNames[number][];
|
|
7
|
-
}): JSX.Element | JSX.Element[];
|
|
1
|
+
import Types from "./types";
|
|
2
|
+
export declare function Render(props: Types.MainProps): JSX.Element | JSX.Element[];
|
package/out/helpers.luau
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
-- Types
|
|
3
|
-
local function Render(
|
|
4
|
-
local
|
|
5
|
-
local
|
|
6
|
-
local
|
|
7
|
-
if
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return forge:renderApp(props, names)
|
|
12
|
-
end
|
|
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)
|
|
13
11
|
end
|
|
14
12
|
return forge:renderAll(props)
|
|
15
13
|
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,42 +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
|
-
target = target,
|
|
73
|
-
}
|
|
74
|
-
for _k, _v in props do
|
|
75
|
-
_attributes[_k] = _v
|
|
76
|
-
end
|
|
68
|
+
function AppForge:renderApp(props)
|
|
69
|
+
local _attributes = table.clone(props)
|
|
70
|
+
setmetatable(_attributes, nil)
|
|
77
71
|
return React.createElement(AppContainer, _attributes)
|
|
78
72
|
end
|
|
79
|
-
function AppForge:renderApps(props
|
|
80
|
-
|
|
81
|
-
local
|
|
82
|
-
local
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
|
87
98
|
end
|
|
88
|
-
|
|
89
|
-
return _newValue
|
|
99
|
+
error("Invalid props: must provide name or names")
|
|
90
100
|
end
|
|
91
|
-
function AppForge:renderAll(props
|
|
92
|
-
local
|
|
101
|
+
function AppForge:renderAll(props)
|
|
102
|
+
local names = {}
|
|
93
103
|
-- ▼ ReadonlyMap.forEach ▼
|
|
94
104
|
local _callback = function(_, name)
|
|
95
105
|
local _name = name
|
|
96
|
-
table.insert(
|
|
106
|
+
table.insert(names, _name)
|
|
97
107
|
end
|
|
98
108
|
for _k, _v in AppRegistry do
|
|
99
109
|
_callback(_v, _k, AppRegistry)
|
|
100
110
|
end
|
|
101
111
|
-- ▲ ReadonlyMap.forEach ▲
|
|
102
|
-
return self:renderApps(
|
|
112
|
+
return self:renderApps({
|
|
113
|
+
props = props,
|
|
114
|
+
names = names,
|
|
115
|
+
forge = self,
|
|
116
|
+
})
|
|
103
117
|
end
|
|
104
118
|
end
|
|
105
119
|
exports.Render = TS.import(script, script, "helpers").Render
|
package/out/types.d.ts
CHANGED
|
@@ -9,13 +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 (
|
|
14
|
-
props: AppProps,
|
|
15
|
-
forge: AppForge,
|
|
16
|
-
name: AppNames[number],
|
|
17
|
-
target: GuiObject | Camera,
|
|
18
|
-
) => Args;
|
|
23
|
+
constructor: new (props: MainProps) => Args;
|
|
19
24
|
visible?: boolean;
|
|
20
25
|
rules?: Rules.All;
|
|
21
26
|
};
|