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