@rbxts/app-forge 0.6.0-alpha.25 → 0.6.0-alpha.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/app-forge",
3
- "version": "0.6.0-alpha.25",
3
+ "version": "0.6.0-alpha.26",
4
4
  "description": "An App Manager for react",
5
5
  "main": "out/init.lua",
6
6
  "types": "out/index.d.ts",
package/out/global.d.ts DELETED
@@ -1,9 +0,0 @@
1
- declare global {
2
- // These will be overridden by the user
3
- // They are only placeholders for your build
4
-
5
- type AppGroups = readonly string[];
6
- type AppNames = readonly string[];
7
- type AppProps = {};
8
- }
9
- export {};
package/out/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export { App as ReactApp, Args as ReactArgs } from "./react/decorator";
2
- export { App as VideApp, Args as VideArgs } from "./vide/decorator";
3
- export { default as CreateReactForge } from "./react";
4
- export { default as CreateVideForge } from "./vide";
5
- export { Render as RenderReact } from "./react/helpers";
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, NameProps, } 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 DELETED
@@ -1,22 +0,0 @@
1
- -- Compiled with roblox-ts v3.0.0
2
- local TS = _G[script]
3
- local exports = {}
4
- -- Decorators
5
- local _decorator = TS.import(script, script, "react", "decorator")
6
- exports.ReactApp = _decorator.App
7
- exports.ReactArgs = _decorator.Args
8
- local _decorator_1 = TS.import(script, script, "vide", "decorator")
9
- exports.VideApp = _decorator_1.App
10
- exports.VideArgs = _decorator_1.Args
11
- -- Creators
12
- exports.CreateReactForge = TS.import(script, script, "react").default
13
- exports.CreateVideForge = TS.import(script, script, "vide").default
14
- -- Helpers
15
- exports.RenderReact = TS.import(script, script, "react", "helpers").Render
16
- exports.RenderVide = TS.import(script, script, "vide", "helpers").Render
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
22
- return exports
@@ -1,10 +0,0 @@
1
- import type Types from "./types";
2
- export declare function AppContainer(props: Types.NameProps & Types.MainProps): import("@rbxts/react").ReactElement<{
3
- key: string;
4
- ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
5
- ResetOnSpawn: boolean;
6
- }, string | import("@rbxts/react").JSXElementConstructor<any>> | import("@rbxts/react").ReactElement<{
7
- key: string;
8
- BackgroundTransparency: number;
9
- Size: UDim2;
10
- }, string | import("@rbxts/react").JSXElementConstructor<any>>;
@@ -1,60 +0,0 @@
1
- -- Compiled with roblox-ts v3.0.0
2
- local TS = _G[script]
3
- -- Services
4
- local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
5
- -- Packages
6
- local createElement = TS.import(script, TS.getModule(script, "@rbxts", "react")).createElement
7
- -- Types
8
- -- Components
9
- local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
10
- local function createInstance(props)
11
- local _binding = props
12
- local name = _binding.name
13
- local forge = _binding.forge
14
- if not (name ~= "" and name) then
15
- error("App name is required to create instance")
16
- end
17
- local appClass = AppRegistry[name]
18
- if not appClass then
19
- error(`App "{name}" not registered`)
20
- end
21
- if not (forge.loaded[name] ~= nil) then
22
- local instance = appClass.constructor.new(props)
23
- local Render = function()
24
- return instance:render()
25
- end
26
- local _loaded = forge.loaded
27
- local _arg1 = createElement(Render, {
28
- key = "Main",
29
- })
30
- _loaded[name] = _arg1
31
- end
32
- return forge.loaded[name]
33
- end
34
- local function AppContainer(props)
35
- local _binding = props
36
- local name = _binding.name
37
- if not (name ~= "" and name) then
38
- error("App name is required in AppContainer")
39
- end
40
- local element = createInstance(props)
41
- if not element then
42
- error(`Failed to create instance for app "{name}"`)
43
- end
44
- if RunService:IsRunning() then
45
- return createElement("ScreenGui", {
46
- key = name,
47
- ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
48
- ResetOnSpawn = false,
49
- }, element)
50
- else
51
- return createElement("Frame", {
52
- key = name,
53
- BackgroundTransparency = 1,
54
- Size = UDim2.fromScale(1, 1),
55
- }, element)
56
- end
57
- end
58
- return {
59
- AppContainer = AppContainer,
60
- }
@@ -1,7 +0,0 @@
1
- declare const Contexts: {
2
- readonly App: import("@rbxts/react").Context<{
3
- forge: import(".").default;
4
- px: ReturnType<typeof import("@rbxts/loners-pretty-react-hooks").usePx>;
5
- } | undefined>;
6
- };
7
- export default Contexts;
@@ -1,12 +0,0 @@
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
- }
@@ -1,14 +0,0 @@
1
- import React from "@rbxts/react";
2
- import type Types from "./types";
3
- import type AppForge from ".";
4
- export declare const AppRegistry: Map<string, Types.AppRegistry>;
5
- export declare function App(props: Types.AppRegistryProps): <T extends new (props: Types.MainProps) => Args>(constructor: T) => T;
6
- export declare abstract class Args {
7
- readonly forge: AppForge;
8
- readonly props: Types.ClassProps;
9
- readonly name: AppNames[number];
10
- readonly bind: React.Binding<boolean>;
11
- readonly state: Boolean;
12
- constructor(props: Types.NameProps & Types.MainProps);
13
- abstract render(): React.ReactNode;
14
- }
@@ -1,51 +0,0 @@
1
- -- Compiled with roblox-ts v3.0.0
2
- local TS = _G[script]
3
- -- Services
4
- -- Packages
5
- local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-react-hooks").out).usePx
6
- -- Types
7
- local AppRegistry = {}
8
- local function App(props)
9
- return function(constructor)
10
- local _name = props.name
11
- if AppRegistry[_name] ~= nil then
12
- error(`Duplicate registered App name "{props.name}"`)
13
- end
14
- local _name_1 = props.name
15
- local _arg1 = {
16
- constructor = constructor,
17
- visible = props.visible,
18
- rules = props.rules,
19
- }
20
- AppRegistry[_name_1] = _arg1
21
- return constructor
22
- end
23
- end
24
- local Args
25
- do
26
- Args = {}
27
- function Args:constructor(props)
28
- local _binding = props
29
- local target = _binding.target
30
- local forge = _binding.forge
31
- local name = _binding.name
32
- if not (name ~= "" and name) then
33
- error("App name is required in Args constructor")
34
- end
35
- local px = usePx(target)
36
- self.forge = forge
37
- local _object = table.clone(props.props)
38
- setmetatable(_object, nil)
39
- _object.px = px
40
- _object.forge = forge
41
- self.props = _object
42
- self.name = name
43
- self.bind = forge:getBind(name)
44
- self.state = forge:getState(name)
45
- end
46
- end
47
- return {
48
- App = App,
49
- AppRegistry = AppRegistry,
50
- Args = Args,
51
- }
@@ -1,6 +0,0 @@
1
- import React from "@rbxts/react";
2
- import type Types from "./types";
3
- import type AppForge from ".";
4
- export declare function createBinding(name: AppNames[number], forge: AppForge): void;
5
- export declare function createState(name: AppNames[number], forge: AppForge): void;
6
- export declare function Render(props: Types.NameProps & Types.MainProps): React.ReactNode;
@@ -1,74 +0,0 @@
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
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
50
- local function Render(props)
51
- local names = props.names
52
- local name = props.name
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 ▲
63
- if name ~= "" and name then
64
- return forge:renderApp(props)
65
- elseif names then
66
- return forge:renderApps(props)
67
- end
68
- return forge:renderAll(props)
69
- end
70
- return {
71
- createBinding = createBinding,
72
- createState = createState,
73
- Render = Render,
74
- }
@@ -1,5 +0,0 @@
1
- declare const _default: () => {
2
- forge: import("..").default;
3
- px: ReturnType<typeof import("@rbxts/loners-pretty-react-hooks").usePx>;
4
- };
5
- export default _default;
@@ -1,16 +0,0 @@
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
- }
@@ -1,44 +0,0 @@
1
- import React from "@rbxts/react";
2
- import type Types from "./types";
3
- type Binding = [React.Binding<boolean>, (T: boolean) => void];
4
- type State = [boolean, React.Dispatch<React.SetStateAction<boolean>>];
5
- export default class AppForge {
6
- loaded: Map<string, React.Element<any, string | React.JSXElementConstructor<any>>>;
7
- binds: Map<string, Binding>;
8
- states: Map<string, State>;
9
- private rulesManager;
10
- getBind(name: AppNames[number]): React.Binding<boolean>;
11
- getState(name: AppNames[number]): boolean;
12
- set(name: AppNames[number], value: boolean): void;
13
- open(name: AppNames[number]): void;
14
- close(name: AppNames[number]): void;
15
- toggle(name: AppNames[number]): void;
16
- renderApp(props: Types.NameProps & Types.MainProps): React.ReactElement<{
17
- key: string;
18
- ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
19
- ResetOnSpawn: boolean;
20
- }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
21
- key: string;
22
- BackgroundTransparency: number;
23
- Size: UDim2;
24
- }, string | React.JSXElementConstructor<any>>;
25
- renderApps(props: Types.NameProps & Types.MainProps): (React.ReactElement<{
26
- key: string;
27
- ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
28
- ResetOnSpawn: boolean;
29
- }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
30
- key: string;
31
- BackgroundTransparency: number;
32
- Size: UDim2;
33
- }, string | React.JSXElementConstructor<any>>)[];
34
- renderAll(props: Types.MainProps): (React.ReactElement<{
35
- key: string;
36
- ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
37
- ResetOnSpawn: boolean;
38
- }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
39
- key: string;
40
- BackgroundTransparency: number;
41
- Size: UDim2;
42
- }, string | React.JSXElementConstructor<any>>)[];
43
- }
44
- export {};
@@ -1,125 +0,0 @@
1
- -- Compiled with roblox-ts v3.0.0
2
- local TS = _G[script]
3
- -- Packages
4
- -- Types
5
- -- Components
6
- local AppContainer = TS.import(script, script, "container").AppContainer
7
- local AppRegistry = TS.import(script, script, "decorator").AppRegistry
8
- -- Classes
9
- local RulesManager = TS.import(script, script, "rules").default
10
- -- Helpers
11
- local _helpers = TS.import(script, script, "helpers")
12
- local createBinding = _helpers.createBinding
13
- local createState = _helpers.createState
14
- local AppForge
15
- do
16
- AppForge = setmetatable({}, {
17
- __tostring = function()
18
- return "AppForge"
19
- end,
20
- })
21
- AppForge.__index = AppForge
22
- function AppForge.new(...)
23
- local self = setmetatable({}, AppForge)
24
- return self:constructor(...) or self
25
- end
26
- function AppForge:constructor()
27
- self.loaded = {}
28
- self.binds = {}
29
- self.states = {}
30
- self.rulesManager = RulesManager.new(self)
31
- end
32
- function AppForge:getBind(name)
33
- local _binds = self.binds
34
- local _name = name
35
- if not (_binds[_name] ~= nil) then
36
- createBinding(name, self)
37
- end
38
- local _binds_1 = self.binds
39
- local _name_1 = name
40
- return _binds_1[_name_1][1]
41
- end
42
- function AppForge:getState(name)
43
- local _states = self.states
44
- local _name = name
45
- if not (_states[_name] ~= nil) then
46
- createState(name, self)
47
- end
48
- local _states_1 = self.states
49
- local _name_1 = name
50
- return _states_1[_name_1][1]
51
- end
52
- function AppForge:set(name, value)
53
- if not self.rulesManager:applyRules(name, value) then
54
- return nil
55
- end
56
- local _binds = self.binds
57
- local _name = name
58
- local _binding = _binds[_name]
59
- local _b = _binding[1]
60
- local setBinding = _binding[2]
61
- local _states = self.states
62
- local _name_1 = name
63
- local _binding_1 = _states[_name_1]
64
- local _s = _binding_1[1]
65
- local setState = _binding_1[2]
66
- if not setBinding then
67
- createBinding(name, self)
68
- end
69
- setBinding(value)
70
- setState(value)
71
- end
72
- function AppForge:open(name)
73
- self:set(name, true)
74
- end
75
- function AppForge:close(name)
76
- self:set(name, false)
77
- end
78
- function AppForge:toggle(name)
79
- self:set(name, not self:getState(name))
80
- end
81
- function AppForge:renderApp(props)
82
- return AppContainer(props)
83
- end
84
- function AppForge:renderApps(props)
85
- local names = props.names
86
- if names then
87
- -- ▼ ReadonlyArray.map ▼
88
- local _newValue = table.create(#names)
89
- local _callback = function(name)
90
- local _self = self
91
- local _object = table.clone(props)
92
- setmetatable(_object, nil)
93
- _object.name = name
94
- _object.names = nil
95
- return _self:renderApp(_object)
96
- end
97
- for _k, _v in names do
98
- _newValue[_k] = _callback(_v, _k - 1, names)
99
- end
100
- -- ▲ ReadonlyArray.map ▲
101
- return _newValue
102
- end
103
- error("No app names provided to renderApps")
104
- end
105
- function AppForge:renderAll(props)
106
- local names = {}
107
- -- ▼ ReadonlyMap.forEach ▼
108
- local _callback = function(_, name)
109
- local _name = name
110
- table.insert(names, _name)
111
- end
112
- for _k, _v in AppRegistry do
113
- _callback(_v, _k, AppRegistry)
114
- end
115
- -- ▲ ReadonlyMap.forEach ▲
116
- local _self = self
117
- local _object = table.clone(props)
118
- setmetatable(_object, nil)
119
- _object.names = names
120
- return _self:renderApps(_object)
121
- end
122
- end
123
- return {
124
- default = AppForge,
125
- }
@@ -1,11 +0,0 @@
1
- import AppManager from ".";
2
- export default class RulesManager {
3
- private appManager;
4
- constructor(appManager: AppManager);
5
- applyRules(name: AppNames[number], value: boolean): boolean;
6
- private inSameGroup;
7
- private blockedBy;
8
- private blocks;
9
- private exclusive;
10
- private layer;
11
- }