@rbxts/app-forge 0.6.0-alpha.7 → 0.6.0-alpha.71
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/README.md +123 -75
- package/out/global.d.ts +2 -3
- package/out/index.d.ts +6 -2
- package/out/init.luau +4 -0
- package/out/react/container.luau +1 -21
- package/out/react/context.d.ts +7 -0
- package/out/react/context.luau +12 -0
- package/out/react/decorator.d.ts +1 -1
- package/out/react/decorator.luau +3 -7
- package/out/react/helpers.d.ts +4 -1
- package/out/react/helpers.luau +58 -0
- package/out/react/hooks/useAppContext.d.ts +5 -0
- package/out/react/hooks/useAppContext.luau +16 -0
- package/out/react/index.d.ts +11 -7
- package/out/react/init.luau +23 -21
- package/out/react/rules/index.d.ts +6 -0
- package/out/react/rules/init.luau +27 -0
- package/out/react/rules/parent.d.ts +2 -0
- package/out/react/rules/parent.luau +42 -0
- package/out/react/types.d.ts +5 -14
- package/out/vide/container.d.ts +1 -1
- package/out/vide/container.luau +14 -29
- package/out/vide/context.d.ts +7 -0
- package/out/vide/context.luau +12 -0
- package/out/vide/decorator.d.ts +5 -5
- package/out/vide/decorator.luau +4 -7
- package/out/vide/helpers.d.ts +8 -2
- package/out/vide/helpers.luau +122 -6
- package/out/vide/hooks/useAppContext.d.ts +5 -0
- package/out/vide/hooks/useAppContext.luau +14 -0
- package/out/vide/index.d.ts +16 -8
- package/out/vide/init.luau +117 -46
- package/out/vide/rules/exclusiveGroup.d.ts +2 -0
- package/out/vide/rules/exclusiveGroup.luau +47 -0
- package/out/vide/rules/index.d.ts +7 -0
- package/out/vide/rules/init.luau +44 -0
- package/out/vide/rules/parent.d.ts +2 -0
- package/out/vide/rules/parent.luau +29 -0
- package/out/vide/types.d.ts +58 -42
- package/package.json +8 -11
- package/out/react/rules.d.ts +0 -11
- package/out/react/rules.luau +0 -196
- package/out/vide/rules.d.ts +0 -12
- package/out/vide/rules.luau +0 -198
package/README.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
# AppForge — React App & Window Manager for roblox-ts
|
|
1
|
+
# AppForge — Vide/React App & Window Manager for roblox-ts
|
|
2
2
|
|
|
3
|
-
AppForge is a UI/app orchestration system for React in Roblox, enabling:
|
|
3
|
+
AppForge is a UI/app orchestration system for Vide/React in Roblox, enabling:
|
|
4
4
|
|
|
5
|
-
✔ App registration
|
|
6
|
-
✔ Visibility & state control
|
|
7
|
-
✔ App grouping
|
|
8
|
-
✔ Exclusive UI modes
|
|
9
5
|
✔ Rule-based interactions
|
|
10
6
|
✔ Priority & layering
|
|
11
|
-
✔
|
|
7
|
+
✔ App registration
|
|
8
|
+
✔ state control
|
|
12
9
|
|
|
13
10
|
---
|
|
14
11
|
|
|
@@ -28,6 +25,8 @@ bun i @rbxts/app-forge
|
|
|
28
25
|
|
|
29
26
|
```ts
|
|
30
27
|
declare global {
|
|
28
|
+
type GroupNames = "Main" | "Popups"
|
|
29
|
+
type AppNames = "SideButtons" | "Inventory"
|
|
31
30
|
type AppProps = {
|
|
32
31
|
player: Player;
|
|
33
32
|
}
|
|
@@ -35,11 +34,38 @@ declare global {
|
|
|
35
34
|
}
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
# 🚀 Initializing AppForge -- VIDE
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { Workspace, Players } from "@rbxts/services"
|
|
43
|
+
|
|
44
|
+
import { RenderVide, CreateVideForge } from "@rbxts/app-forge";
|
|
45
|
+
import { Players, Workspace } from "@rbxts/services";
|
|
46
|
+
import Vide from "@rbxts/vide";
|
|
47
|
+
|
|
48
|
+
const forge = new CreateVideForge();
|
|
49
|
+
const target = Players.LocalPlayer.WaitForChild("PlayerGui")
|
|
50
|
+
|
|
51
|
+
const props = {
|
|
52
|
+
player: Players.LocalPlayer!,
|
|
53
|
+
} as const satisfies AppProps;
|
|
54
|
+
|
|
55
|
+
mount(() => {
|
|
56
|
+
return (
|
|
57
|
+
<screengui Name={"App"} ZIndexBehavior="Sibling" ResetOnSpawn={false}>
|
|
58
|
+
<RenderVide {...{ props, forge }} />
|
|
59
|
+
</screengui>
|
|
60
|
+
);
|
|
61
|
+
}, target);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
> `RenderVide` will contruct all decorated apps and dependencies for that decorated app.
|
|
39
65
|
|
|
40
66
|
---
|
|
41
67
|
|
|
42
|
-
# 🚀 Initializing AppForge
|
|
68
|
+
# 🚀 Initializing AppForge -- VIDE
|
|
43
69
|
|
|
44
70
|
```ts
|
|
45
71
|
import { Workspace } from "@rbxts/services"
|
|
@@ -68,30 +94,49 @@ root.render(
|
|
|
68
94
|
);
|
|
69
95
|
```
|
|
70
96
|
|
|
71
|
-
> `
|
|
97
|
+
> `RenderReact` will contruct all decorated apps and dependencies for that decorated app.
|
|
72
98
|
|
|
73
99
|
---
|
|
74
100
|
|
|
75
|
-
# 🧱 Creating an App
|
|
101
|
+
# 🧱 Creating an App -- Vide
|
|
76
102
|
|
|
77
103
|
```ts
|
|
78
|
-
import {
|
|
104
|
+
import { VideApp, VideArgs } from "@rbxts/app-forge";
|
|
105
|
+
import Vide from "@rbxts/vide";
|
|
106
|
+
|
|
107
|
+
@VideApp({
|
|
108
|
+
name: "SideButtons",
|
|
109
|
+
visible: true,
|
|
110
|
+
})
|
|
111
|
+
export default class SideButtons extends VideArgs {
|
|
112
|
+
public render() {
|
|
113
|
+
return <frame Size={UDim2.fromScale(1, 1)}></frame>;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
# 🧱 Creating an App -- React
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { ReactApp, ReactArgs } from "@rbxts/app-forge";
|
|
79
124
|
import React from "@rbxts/react";
|
|
80
125
|
|
|
81
|
-
@
|
|
126
|
+
@ReactApp({
|
|
82
127
|
name: "SideButtons",
|
|
83
128
|
visible: true,
|
|
84
129
|
})
|
|
85
|
-
export default class SideButtons extends
|
|
130
|
+
export default class SideButtons extends ReactArgs {
|
|
86
131
|
public render() {
|
|
87
|
-
return <frame Size={UDim2.fromScale(1, 1)}
|
|
132
|
+
return <frame Size={UDim2.fromScale(1, 1)}></frame>;
|
|
88
133
|
}
|
|
89
134
|
}
|
|
90
135
|
```
|
|
91
136
|
|
|
92
137
|
---
|
|
93
138
|
|
|
94
|
-
# 📦 Props & `
|
|
139
|
+
# 📦 Props & `VideArgs` Features
|
|
95
140
|
|
|
96
141
|
Inside a decorated App:
|
|
97
142
|
|
|
@@ -99,31 +144,72 @@ Inside a decorated App:
|
|
|
99
144
|
this.forge // AppForge instance
|
|
100
145
|
this.name // App Name
|
|
101
146
|
this.props // AppProps
|
|
102
|
-
this.
|
|
147
|
+
this.source // Vide Source
|
|
103
148
|
```
|
|
104
149
|
|
|
105
150
|
Example:
|
|
106
151
|
|
|
107
152
|
```ts
|
|
108
|
-
const { px } = this.props;
|
|
153
|
+
const { px, forge } = this.props;
|
|
109
154
|
const scale2px = px.map((s) => s * 2);
|
|
110
155
|
```
|
|
111
156
|
|
|
112
157
|
---
|
|
113
158
|
|
|
114
|
-
#
|
|
159
|
+
# 📦 Props & `ReactArgs` Features
|
|
160
|
+
|
|
161
|
+
Inside a decorated App:
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
this.forge // AppForge instance
|
|
165
|
+
this.name // App Name
|
|
166
|
+
this.props // AppProps
|
|
167
|
+
this.bind // React useBinding()
|
|
168
|
+
this.state // React useState()
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Example:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
const { px, forge } = this.props;
|
|
175
|
+
const scale2px = px.map((s) => s * 2);
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
# 🕹 App Manager API -- Vide
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
forge.toggle("Inventory");
|
|
184
|
+
forge.bind("Shop", Vide.source(false));
|
|
185
|
+
const bind = forge.getSource("Inventory");
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
# 🕹 App Manager API -- React
|
|
115
191
|
|
|
116
192
|
```ts
|
|
117
193
|
forge.toggle("Inventory");
|
|
118
194
|
forge.set("Shop", true);
|
|
119
195
|
forge.set("HUD", false);
|
|
120
|
-
const
|
|
121
|
-
const bind = forge.
|
|
196
|
+
const bind = forge.getBind("Pause");
|
|
197
|
+
const bind = forge.getSource("Inventory");
|
|
122
198
|
```
|
|
123
199
|
|
|
124
200
|
---
|
|
125
201
|
|
|
126
|
-
# 📐 Using `
|
|
202
|
+
# 📐 Using `getSource()` inside Vide
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
return (
|
|
206
|
+
<frame Visible={forge.getSource("Inventory")}>
|
|
207
|
+
Items…
|
|
208
|
+
</frame>
|
|
209
|
+
);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
# 📐 Using `getBind()` inside Vide
|
|
127
213
|
|
|
128
214
|
```tsx
|
|
129
215
|
return (
|
|
@@ -150,73 +236,40 @@ UserInputService.InputBegan.Connect((input) => {
|
|
|
150
236
|
|
|
151
237
|
Rules control app visibility behavior.
|
|
152
238
|
|
|
153
|
-
| Rule | Effect
|
|
154
|
-
| --------- |
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
|
158
|
-
| groups | Non-conflicting coexistence grouping |
|
|
159
|
-
| Core | Always allowed — never auto-closed |
|
|
160
|
-
| layer | (Reserved – future rendering priority) |
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## `groups`
|
|
165
|
-
|
|
166
|
-
```ts
|
|
167
|
-
@App({ name: "HUD", rules: { groups: "HUD" } })
|
|
168
|
-
@App({ name: "Crosshair", rules: { groups: "HUD" } })
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
Both may open at the same time.
|
|
239
|
+
| Rule | Effect |
|
|
240
|
+
| --------- | --------------------------------------------- |
|
|
241
|
+
| parent | if parent is closed so is this app |
|
|
242
|
+
| layer | (Reserved – future rendering priority) |
|
|
243
|
+
| exclusiveGroups | (Reserved – future rendering priority) |
|
|
172
244
|
|
|
173
245
|
---
|
|
174
246
|
|
|
175
|
-
## `
|
|
247
|
+
## `parent`
|
|
176
248
|
|
|
177
249
|
```ts
|
|
178
|
-
@App({ name: "
|
|
250
|
+
@App({ name: "ItemInfo", rules: { parent: "Inventory" } })
|
|
179
251
|
```
|
|
180
252
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
# 🧪 Modern App Example (from your snippet)
|
|
186
|
-
|
|
187
|
-
```ts
|
|
188
|
-
@App({ name: "TestApp", visible: true, rules: { groups: "Core" } })
|
|
189
|
-
export default class TestApp extends Args {
|
|
190
|
-
public render() {
|
|
191
|
-
const { px } = this.props;
|
|
192
|
-
|
|
193
|
-
return (
|
|
194
|
-
<frame AnchorPoint={new Vector2(0.5, 1)}>
|
|
195
|
-
UI Stuff…
|
|
196
|
-
</frame>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
```
|
|
253
|
+
ItemInfo can only be true if Inventory's source/state is true.
|
|
201
254
|
|
|
202
255
|
---
|
|
203
256
|
|
|
204
257
|
# 🧠 Using AppForge from Flamework
|
|
205
258
|
|
|
206
259
|
```ts
|
|
207
|
-
import
|
|
260
|
+
import { RenderVide, CreateReactForge } from "@rbxts/app-forge";
|
|
208
261
|
|
|
209
262
|
@Controller()
|
|
210
263
|
export default class AppController implements OnInit {
|
|
211
264
|
onInit() {
|
|
212
265
|
const props = this.createProps(player);
|
|
213
|
-
const forge = new
|
|
266
|
+
const forge = new CreateReactForge();
|
|
214
267
|
const root = createRoot(new Instance("Folder"));
|
|
215
268
|
|
|
216
269
|
root.render(
|
|
217
270
|
createPortal(
|
|
218
271
|
<screengui ResetOnSpawn={false}>
|
|
219
|
-
<
|
|
272
|
+
<RenderVide {...{ props, forge, root, target: props.target }} />
|
|
220
273
|
</screengui>,
|
|
221
274
|
player.WaitForChild("PlayerGui"),
|
|
222
275
|
),
|
|
@@ -241,16 +294,11 @@ or:
|
|
|
241
294
|
<Render {...{ props, forge, target, names: ["HUD", "Shop"] }} />
|
|
242
295
|
```
|
|
243
296
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
# ❗ Best Practices
|
|
297
|
+
or:
|
|
247
298
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
✔ Use `exclusive` for fullscreen control
|
|
252
|
-
✔ Use `"Core"` for never-hidden persistent UI
|
|
253
|
-
✔ Avoid manually instantiating apps
|
|
299
|
+
```tsx
|
|
300
|
+
<Render {...{ props, forge, target }} /> // Renders All
|
|
301
|
+
```
|
|
254
302
|
|
|
255
303
|
---
|
|
256
304
|
|
package/out/global.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
declare global {
|
|
2
2
|
// These will be overridden by the user
|
|
3
3
|
// They are only placeholders for your build
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
type AppNames = readonly string[];
|
|
4
|
+
type GroupNames = string;
|
|
5
|
+
type AppNames = string;
|
|
7
6
|
type AppProps = {};
|
|
8
7
|
}
|
|
9
8
|
export {};
|
package/out/index.d.ts
CHANGED
|
@@ -4,5 +4,9 @@ export { default as CreateReactForge } from "./react";
|
|
|
4
4
|
export { default as CreateVideForge } from "./vide";
|
|
5
5
|
export { Render as RenderReact } from "./react/helpers";
|
|
6
6
|
export { Render as RenderVide } from "./vide/helpers";
|
|
7
|
-
export type { MainProps as VideProps, ClassProps as VideClassProps } from "./vide/types";
|
|
8
|
-
export type { MainProps as ReactProps, ClassProps as ReactClassProps,
|
|
7
|
+
export type { MainProps as VideProps, ClassProps as VideClassProps, RenderProps as VideRenderProps, } from "./vide/types";
|
|
8
|
+
export type { MainProps as ReactProps, ClassProps as ReactClassProps, } from "./react/types";
|
|
9
|
+
export { default as useReactAppContext } from "./react/hooks/useAppContext";
|
|
10
|
+
export { default as ReactContexts } from "./react/context";
|
|
11
|
+
export { default as useVideAppContext } from "./vide/hooks/useAppContext";
|
|
12
|
+
export { default as VideContexts } from "./vide/context";
|
package/out/init.luau
CHANGED
|
@@ -15,4 +15,8 @@ exports.CreateVideForge = TS.import(script, script, "vide").default
|
|
|
15
15
|
exports.RenderReact = TS.import(script, script, "react", "helpers").Render
|
|
16
16
|
exports.RenderVide = TS.import(script, script, "vide", "helpers").Render
|
|
17
17
|
-- Types
|
|
18
|
+
exports.useReactAppContext = TS.import(script, script, "react", "hooks", "useAppContext").default
|
|
19
|
+
exports.ReactContexts = TS.import(script, script, "react", "context").default
|
|
20
|
+
exports.useVideAppContext = TS.import(script, script, "vide", "hooks", "useAppContext").default
|
|
21
|
+
exports.VideContexts = TS.import(script, script, "vide", "context").default
|
|
18
22
|
return exports
|
package/out/react/container.luau
CHANGED
|
@@ -3,28 +3,10 @@ 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 useBinding = _react.useBinding
|
|
8
|
-
local createElement = _react.createElement
|
|
6
|
+
local createElement = TS.import(script, TS.getModule(script, "@rbxts", "react")).createElement
|
|
9
7
|
-- Types
|
|
10
8
|
-- Components
|
|
11
9
|
local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
|
|
12
|
-
local function createBinding(name, manager)
|
|
13
|
-
local _name = name
|
|
14
|
-
local app = AppRegistry[_name]
|
|
15
|
-
if not app then
|
|
16
|
-
error(`App "{name}" not registered`)
|
|
17
|
-
end
|
|
18
|
-
local _condition = app.visible
|
|
19
|
-
if _condition == nil then
|
|
20
|
-
_condition = false
|
|
21
|
-
end
|
|
22
|
-
local binding = { useBinding(_condition) }
|
|
23
|
-
local _binds = manager.binds
|
|
24
|
-
local _name_1 = name
|
|
25
|
-
_binds[_name_1] = binding
|
|
26
|
-
return unpack(binding)
|
|
27
|
-
end
|
|
28
10
|
local function createInstance(props)
|
|
29
11
|
local _binding = props
|
|
30
12
|
local name = _binding.name
|
|
@@ -52,11 +34,9 @@ end
|
|
|
52
34
|
local function AppContainer(props)
|
|
53
35
|
local _binding = props
|
|
54
36
|
local name = _binding.name
|
|
55
|
-
local forge = _binding.forge
|
|
56
37
|
if not (name ~= "" and name) then
|
|
57
38
|
error("App name is required in AppContainer")
|
|
58
39
|
end
|
|
59
|
-
createBinding(name, forge)
|
|
60
40
|
local element = createInstance(props)
|
|
61
41
|
if not element then
|
|
62
42
|
error(`Failed to create instance for app "{name}"`)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Packages
|
|
4
|
+
local createContext = TS.import(script, TS.getModule(script, "@rbxts", "react")).createContext
|
|
5
|
+
-- Types
|
|
6
|
+
local Contexts = {
|
|
7
|
+
App = createContext(nil),
|
|
8
|
+
}
|
|
9
|
+
local default = Contexts
|
|
10
|
+
return {
|
|
11
|
+
default = default,
|
|
12
|
+
}
|
package/out/react/decorator.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare function App(props: Types.AppRegistryProps): <T extends new (prop
|
|
|
6
6
|
export declare abstract class Args {
|
|
7
7
|
readonly forge: AppForge;
|
|
8
8
|
readonly props: Types.ClassProps;
|
|
9
|
-
readonly name: AppNames
|
|
9
|
+
readonly name: AppNames;
|
|
10
10
|
readonly bind: React.Binding<boolean>;
|
|
11
11
|
readonly state: Boolean;
|
|
12
12
|
constructor(props: Types.NameProps & Types.MainProps);
|
package/out/react/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 RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
5
4
|
-- Packages
|
|
6
5
|
local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-react-hooks").out).usePx
|
|
7
6
|
-- Types
|
|
@@ -33,19 +32,16 @@ do
|
|
|
33
32
|
if not (name ~= "" and name) then
|
|
34
33
|
error("App name is required in Args constructor")
|
|
35
34
|
end
|
|
36
|
-
local bind = forge:getBind(name)
|
|
37
|
-
if not bind and RunService:IsRunning() then
|
|
38
|
-
error("FAILED TO GET BIND FOR APP!")
|
|
39
|
-
end
|
|
40
35
|
local px = usePx(target)
|
|
41
36
|
self.forge = forge
|
|
42
37
|
local _object = table.clone(props.props)
|
|
43
38
|
setmetatable(_object, nil)
|
|
44
39
|
_object.px = px
|
|
40
|
+
_object.forge = forge
|
|
45
41
|
self.props = _object
|
|
46
42
|
self.name = name
|
|
47
|
-
self.bind =
|
|
48
|
-
self.state =
|
|
43
|
+
self.bind = forge:getBind(name)
|
|
44
|
+
self.state = forge:getState(name)
|
|
49
45
|
end
|
|
50
46
|
end
|
|
51
47
|
return {
|
package/out/react/helpers.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
|
-
import Types from "./types";
|
|
2
|
+
import type Types from "./types";
|
|
3
|
+
import type AppForge from ".";
|
|
4
|
+
export declare function createBinding(name: AppNames, forge: AppForge): void;
|
|
5
|
+
export declare function createState(name: AppNames, forge: AppForge): void;
|
|
3
6
|
export declare function Render(props: Types.NameProps & Types.MainProps): React.ReactNode;
|
package/out/react/helpers.luau
CHANGED
|
@@ -1,9 +1,65 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Packages
|
|
4
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
5
|
+
local useBinding = _react.useBinding
|
|
6
|
+
local useState = _react.useState
|
|
2
7
|
-- Types
|
|
8
|
+
-- Components
|
|
9
|
+
local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
|
|
10
|
+
local function createBinding(name, forge)
|
|
11
|
+
local _name = name
|
|
12
|
+
local app = AppRegistry[_name]
|
|
13
|
+
if not app then
|
|
14
|
+
error(`App "{name}" not registered`)
|
|
15
|
+
end
|
|
16
|
+
local _binds = forge.binds
|
|
17
|
+
local _name_1 = name
|
|
18
|
+
if _binds[_name_1] ~= nil then
|
|
19
|
+
return nil
|
|
20
|
+
end
|
|
21
|
+
local _condition = app.visible
|
|
22
|
+
if _condition == nil then
|
|
23
|
+
_condition = false
|
|
24
|
+
end
|
|
25
|
+
local binding = { useBinding(_condition) }
|
|
26
|
+
local _binds_1 = forge.binds
|
|
27
|
+
local _name_2 = name
|
|
28
|
+
_binds_1[_name_2] = binding
|
|
29
|
+
end
|
|
30
|
+
local function createState(name, forge)
|
|
31
|
+
local _name = name
|
|
32
|
+
local app = AppRegistry[_name]
|
|
33
|
+
if not app then
|
|
34
|
+
error(`App "{name}" not registered`)
|
|
35
|
+
end
|
|
36
|
+
local _states = forge.states
|
|
37
|
+
local _name_1 = name
|
|
38
|
+
if _states[_name_1] ~= nil then
|
|
39
|
+
return nil
|
|
40
|
+
end
|
|
41
|
+
local _condition = app.visible
|
|
42
|
+
if _condition == nil then
|
|
43
|
+
_condition = false
|
|
44
|
+
end
|
|
45
|
+
local state = { useState(_condition) }
|
|
46
|
+
local _states_1 = forge.states
|
|
47
|
+
local _name_2 = name
|
|
48
|
+
_states_1[_name_2] = state
|
|
49
|
+
end
|
|
3
50
|
local function Render(props)
|
|
4
51
|
local names = props.names
|
|
5
52
|
local name = props.name
|
|
6
53
|
local forge = props.forge
|
|
54
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
55
|
+
local _callback = function(_, name)
|
|
56
|
+
createBinding(name, forge)
|
|
57
|
+
createState(name, forge)
|
|
58
|
+
end
|
|
59
|
+
for _k, _v in AppRegistry do
|
|
60
|
+
_callback(_v, _k, AppRegistry)
|
|
61
|
+
end
|
|
62
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
7
63
|
if name ~= "" and name then
|
|
8
64
|
return forge:renderApp(props)
|
|
9
65
|
elseif names then
|
|
@@ -12,5 +68,7 @@ local function Render(props)
|
|
|
12
68
|
return forge:renderAll(props)
|
|
13
69
|
end
|
|
14
70
|
return {
|
|
71
|
+
createBinding = createBinding,
|
|
72
|
+
createState = createState,
|
|
15
73
|
Render = Render,
|
|
16
74
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Packages
|
|
4
|
+
local useContext = TS.import(script, TS.getModule(script, "@rbxts", "react")).useContext
|
|
5
|
+
-- Components
|
|
6
|
+
local Contexts = TS.import(script, script.Parent.Parent, "context").default
|
|
7
|
+
local default = function()
|
|
8
|
+
local context = useContext(Contexts.App)
|
|
9
|
+
if not context then
|
|
10
|
+
error(`Failed to retrieve App Props for React {debug.traceback()}`)
|
|
11
|
+
end
|
|
12
|
+
return context
|
|
13
|
+
end
|
|
14
|
+
return {
|
|
15
|
+
default = default,
|
|
16
|
+
}
|
package/out/react/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
2
|
import type Types from "./types";
|
|
3
|
+
type Binding = [React.Binding<boolean>, (T: boolean) => void];
|
|
4
|
+
type State = [boolean, React.Dispatch<React.SetStateAction<boolean>>];
|
|
3
5
|
export default class AppForge {
|
|
4
|
-
binds: Map<string, [React.Binding<boolean>, (T: boolean) => void]>;
|
|
5
6
|
loaded: Map<string, React.Element<any, string | React.JSXElementConstructor<any>>>;
|
|
7
|
+
binds: Map<string, Binding>;
|
|
8
|
+
states: Map<string, State>;
|
|
6
9
|
private rulesManager;
|
|
7
|
-
getBind(name: AppNames
|
|
8
|
-
getState(name: AppNames
|
|
9
|
-
set(name: AppNames
|
|
10
|
-
open(name: AppNames
|
|
11
|
-
close(name: AppNames
|
|
12
|
-
toggle(name: AppNames
|
|
10
|
+
getBind(name: AppNames): React.Binding<boolean>;
|
|
11
|
+
getState(name: AppNames): boolean;
|
|
12
|
+
set(name: AppNames, value: boolean): void;
|
|
13
|
+
open(name: AppNames): void;
|
|
14
|
+
close(name: AppNames): void;
|
|
15
|
+
toggle(name: AppNames): void;
|
|
13
16
|
renderApp(props: Types.NameProps & Types.MainProps): React.ReactElement<{
|
|
14
17
|
key: string;
|
|
15
18
|
ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
|
|
@@ -38,3 +41,4 @@ export default class AppForge {
|
|
|
38
41
|
Size: UDim2;
|
|
39
42
|
}, string | React.JSXElementConstructor<any>>)[];
|
|
40
43
|
}
|
|
44
|
+
export {};
|
package/out/react/init.luau
CHANGED
|
@@ -7,7 +7,10 @@ local AppContainer = TS.import(script, script, "container").AppContainer
|
|
|
7
7
|
local AppRegistry = TS.import(script, script, "decorator").AppRegistry
|
|
8
8
|
-- Classes
|
|
9
9
|
local RulesManager = TS.import(script, script, "rules").default
|
|
10
|
-
|
|
10
|
+
-- Helpers
|
|
11
|
+
local _helpers = TS.import(script, script, "helpers")
|
|
12
|
+
local createBinding = _helpers.createBinding
|
|
13
|
+
local createState = _helpers.createState
|
|
11
14
|
local AppForge
|
|
12
15
|
do
|
|
13
16
|
AppForge = setmetatable({}, {
|
|
@@ -21,49 +24,48 @@ do
|
|
|
21
24
|
return self:constructor(...) or self
|
|
22
25
|
end
|
|
23
26
|
function AppForge:constructor()
|
|
24
|
-
self.binds = {}
|
|
25
27
|
self.loaded = {}
|
|
28
|
+
self.binds = {}
|
|
29
|
+
self.states = {}
|
|
26
30
|
self.rulesManager = RulesManager.new(self)
|
|
27
31
|
end
|
|
28
32
|
function AppForge:getBind(name)
|
|
29
|
-
local _condition = not RunService:IsRunning()
|
|
30
|
-
if _condition then
|
|
31
|
-
local _binds = self.binds
|
|
32
|
-
local _name = name
|
|
33
|
-
_condition = not (_binds[_name] ~= nil)
|
|
34
|
-
end
|
|
35
|
-
if _condition then
|
|
36
|
-
return nil
|
|
37
|
-
end
|
|
38
33
|
local _binds = self.binds
|
|
39
34
|
local _name = name
|
|
40
35
|
if not (_binds[_name] ~= nil) then
|
|
41
|
-
|
|
36
|
+
createBinding(name, self)
|
|
42
37
|
end
|
|
43
38
|
local _binds_1 = self.binds
|
|
44
39
|
local _name_1 = name
|
|
45
40
|
return _binds_1[_name_1][1]
|
|
46
41
|
end
|
|
47
42
|
function AppForge:getState(name)
|
|
48
|
-
local
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
local _states = self.states
|
|
44
|
+
local _name = name
|
|
45
|
+
if not (_states[_name] ~= nil) then
|
|
46
|
+
createState(name, self)
|
|
51
47
|
end
|
|
52
|
-
|
|
48
|
+
local _states_1 = self.states
|
|
49
|
+
local _name_1 = name
|
|
50
|
+
return _states_1[_name_1][1]
|
|
53
51
|
end
|
|
54
52
|
function AppForge:set(name, value)
|
|
55
|
-
|
|
56
|
-
return nil
|
|
57
|
-
end
|
|
53
|
+
self.rulesManager:applyRules(name)
|
|
58
54
|
local _binds = self.binds
|
|
59
55
|
local _name = name
|
|
60
56
|
local _binding = _binds[_name]
|
|
61
|
-
local
|
|
57
|
+
local _b = _binding[1]
|
|
62
58
|
local setBinding = _binding[2]
|
|
59
|
+
local _states = self.states
|
|
60
|
+
local _name_1 = name
|
|
61
|
+
local _binding_1 = _states[_name_1]
|
|
62
|
+
local _s = _binding_1[1]
|
|
63
|
+
local setState = _binding_1[2]
|
|
63
64
|
if not setBinding then
|
|
64
|
-
|
|
65
|
+
createBinding(name, self)
|
|
65
66
|
end
|
|
66
67
|
setBinding(value)
|
|
68
|
+
setState(value)
|
|
67
69
|
end
|
|
68
70
|
function AppForge:open(name)
|
|
69
71
|
self:set(name, true)
|