@rbxts/app-forge 0.6.0-alpha.3 → 0.6.0-alpha.31

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.
Files changed (39) hide show
  1. package/out/global.d.ts +2 -2
  2. package/out/index.d.ts +5 -1
  3. package/out/init.luau +4 -0
  4. package/out/react/container.d.ts +5 -6
  5. package/out/react/container.luau +3 -23
  6. package/out/react/context.d.ts +7 -0
  7. package/out/react/context.luau +12 -0
  8. package/out/react/decorator.d.ts +2 -2
  9. package/out/react/decorator.luau +4 -8
  10. package/out/react/helpers.d.ts +4 -1
  11. package/out/react/helpers.luau +59 -1
  12. package/out/react/hooks/useAppContext.d.ts +5 -0
  13. package/out/react/hooks/useAppContext.luau +16 -0
  14. package/out/react/index.d.ts +17 -13
  15. package/out/react/init.luau +22 -18
  16. package/out/react/rules.d.ts +1 -1
  17. package/out/react/rules.luau +7 -8
  18. package/out/react/types.d.ts +1 -0
  19. package/out/vide/container.luau +1 -26
  20. package/out/vide/context.d.ts +7 -0
  21. package/out/vide/context.luau +12 -0
  22. package/out/vide/decorator.d.ts +1 -1
  23. package/out/vide/decorator.luau +1 -0
  24. package/out/vide/helpers.d.ts +3 -1
  25. package/out/vide/helpers.luau +33 -0
  26. package/out/vide/hooks/useAppContext.d.ts +5 -0
  27. package/out/vide/hooks/useAppContext.luau +14 -0
  28. package/out/vide/index.d.ts +5 -5
  29. package/out/vide/init.luau +8 -5
  30. package/out/vide/rules/index.d.ts +6 -0
  31. package/out/vide/rules/init.luau +44 -0
  32. package/out/vide/rules/parent.d.ts +2 -0
  33. package/out/vide/rules/parent.luau +38 -0
  34. package/out/vide/rules/parents.d.ts +1 -0
  35. package/out/vide/rules/parents.luau +2 -0
  36. package/out/vide/types.d.ts +20 -8
  37. package/package.json +9 -9
  38. package/out/vide/rules.d.ts +0 -12
  39. package/out/vide/rules.luau +0 -198
package/out/global.d.ts CHANGED
@@ -2,8 +2,8 @@ declare global {
2
2
  // These will be overridden by the user
3
3
  // They are only placeholders for your build
4
4
 
5
- type AppGroups = readonly string[];
6
- type AppNames = readonly string[];
5
+ type AppGroups = string;
6
+ type AppNames = string;
7
7
  type AppProps = {};
8
8
  }
9
9
  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 ReactProps, ClassProps as ReactClassProps } from "./react/types";
8
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 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
@@ -1,11 +1,10 @@
1
- import React from "@rbxts/react";
2
1
  import type Types from "./types";
3
- export declare function AppContainer(props: Types.NameProps & Types.MainProps): React.ReactElement<{
4
- key: string;
2
+ export declare function AppContainer(props: Types.NameProps & Types.MainProps): import("@rbxts/react").ReactElement<{
3
+ key: any;
5
4
  ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
6
5
  ResetOnSpawn: boolean;
7
- }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
8
- key: string;
6
+ }, string | import("@rbxts/react").JSXElementConstructor<any>> | import("@rbxts/react").ReactElement<{
7
+ key: any;
9
8
  BackgroundTransparency: number;
10
9
  Size: UDim2;
11
- }, string | React.JSXElementConstructor<any>>;
10
+ }, string | import("@rbxts/react").JSXElementConstructor<any>>;
@@ -3,33 +3,15 @@ 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 _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
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
31
13
  local forge = _binding.forge
32
- if not (name ~= "" and name) then
14
+ if not (name ~= 0 and name == name and name ~= "" and name) then
33
15
  error("App name is required to create instance")
34
16
  end
35
17
  local appClass = AppRegistry[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
- if not (name ~= "" and name) then
37
+ if not (name ~= 0 and name == name and 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,7 @@
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;
@@ -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
+ }
@@ -6,9 +6,9 @@ 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[number];
9
+ readonly name: AppNames;
10
10
  readonly bind: React.Binding<boolean>;
11
11
  readonly state: Boolean;
12
12
  constructor(props: Types.NameProps & Types.MainProps);
13
- abstract render(): JSX.Element;
13
+ abstract render(): React.ReactNode;
14
14
  }
@@ -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
@@ -30,22 +29,19 @@ do
30
29
  local target = _binding.target
31
30
  local forge = _binding.forge
32
31
  local name = _binding.name
33
- if not (name ~= "" and name) then
32
+ if not (name ~= 0 and name == name and 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 = bind
48
- self.state = if self.bind then self.bind:getValue() else nil
43
+ self.bind = forge:getBind(name)
44
+ self.state = forge:getState(name)
49
45
  end
50
46
  end
51
47
  return {
@@ -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;
@@ -1,10 +1,66 @@
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
7
- if name ~= "" and name then
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 ~= 0 and name == name and name ~= "" and name then
8
64
  return forge:renderApp(props)
9
65
  elseif names then
10
66
  return forge:renderApps(props)
@@ -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,5 @@
1
+ declare const _default: () => {
2
+ forge: import("..").default;
3
+ px: ReturnType<typeof import("@rbxts/loners-pretty-react-hooks").usePx>;
4
+ };
5
+ export default _default;
@@ -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
+ }
@@ -1,40 +1,44 @@
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[number]): React.Binding<boolean> | undefined;
8
- getState(name: AppNames[number]): boolean | undefined;
9
- set(name: AppNames[number], value: boolean): void;
10
- open(name: AppNames[number]): void;
11
- close(name: AppNames[number]): void;
12
- toggle(name: AppNames[number]): void;
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
- key: string;
17
+ key: any;
15
18
  ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
16
19
  ResetOnSpawn: boolean;
17
20
  }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
18
- key: string;
21
+ key: any;
19
22
  BackgroundTransparency: number;
20
23
  Size: UDim2;
21
24
  }, string | React.JSXElementConstructor<any>>;
22
25
  renderApps(props: Types.NameProps & Types.MainProps): (React.ReactElement<{
23
- key: string;
26
+ key: any;
24
27
  ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
25
28
  ResetOnSpawn: boolean;
26
29
  }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
27
- key: string;
30
+ key: any;
28
31
  BackgroundTransparency: number;
29
32
  Size: UDim2;
30
33
  }, string | React.JSXElementConstructor<any>>)[];
31
34
  renderAll(props: Types.MainProps): (React.ReactElement<{
32
- key: string;
35
+ key: any;
33
36
  ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
34
37
  ResetOnSpawn: boolean;
35
38
  }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
36
- key: string;
39
+ key: any;
37
40
  BackgroundTransparency: number;
38
41
  Size: UDim2;
39
42
  }, string | React.JSXElementConstructor<any>>)[];
40
43
  }
44
+ export {};
@@ -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
- local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
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,35 +24,30 @@ 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
- error(`App "{name}" has no binding`)
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 _result = self:getBind(name)
49
- if _result ~= nil then
50
- _result = _result:getValue()
43
+ local _states = self.states
44
+ local _name = name
45
+ if not (_states[_name] ~= nil) then
46
+ createState(name, self)
51
47
  end
52
- return _result
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
53
  if not self.rulesManager:applyRules(name, value) then
@@ -58,12 +56,18 @@ do
58
56
  local _binds = self.binds
59
57
  local _name = name
60
58
  local _binding = _binds[_name]
61
- local _ = _binding[1]
59
+ local _b = _binding[1]
62
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]
63
66
  if not setBinding then
64
- error(`App "{name}" has no binding setter`)
67
+ createBinding(name, self)
65
68
  end
66
69
  setBinding(value)
70
+ setState(value)
67
71
  end
68
72
  function AppForge:open(name)
69
73
  self:set(name, true)
@@ -2,7 +2,7 @@ import AppManager from ".";
2
2
  export default class RulesManager {
3
3
  private appManager;
4
4
  constructor(appManager: AppManager);
5
- applyRules(name: AppNames[number], value: boolean): boolean;
5
+ applyRules(name: AppNames, value: boolean): boolean;
6
6
  private inSameGroup;
7
7
  private blockedBy;
8
8
  private blocks;
@@ -52,7 +52,6 @@ do
52
52
  if not (n ~= "" and n) or n == name then
53
53
  return nil
54
54
  end
55
- print(self.appManager.loaded)
56
55
  local _n = n
57
56
  local otherApp = AppRegistry[_n]
58
57
  local _result_1 = otherApp
@@ -62,7 +61,7 @@ do
62
61
  _result_1 = _result_1.groups
63
62
  end
64
63
  end
65
- local groups = if _result_1 ~= "" and _result_1 then asTable(otherApp.rules.groups) else {}
64
+ local groups = if _result_1 ~= 0 and _result_1 == _result_1 and _result_1 ~= "" and _result_1 then asTable(otherApp.rules.groups) else {}
66
65
  -- ▼ ReadonlyArray.find ▼
67
66
  local _callback_1 = function(g)
68
67
  return g == "Core"
@@ -75,7 +74,7 @@ do
75
74
  end
76
75
  end
77
76
  -- ▲ ReadonlyArray.find ▲
78
- if _result_2 then
77
+ if _result_2 ~= 0 and _result_2 == _result_2 and _result_2 ~= "" and _result_2 then
79
78
  return nil
80
79
  end
81
80
  if self.appManager:getState(n) then
@@ -93,15 +92,15 @@ do
93
92
  local _condition = value
94
93
  if _condition then
95
94
  _condition = rules.blockedBy
96
- if _condition ~= "" and _condition then
95
+ if _condition ~= 0 and _condition == _condition and _condition ~= "" and _condition then
97
96
  _condition = not self:blockedBy(name, rules.blockedBy)
98
97
  end
99
98
  end
100
- if _condition ~= "" and _condition then
99
+ if _condition ~= 0 and _condition == _condition and _condition ~= "" and _condition then
101
100
  return false
102
101
  end
103
102
  local _value = value and rules.blocks
104
- if _value ~= "" and _value then
103
+ if _value ~= 0 and _value == _value and _value ~= "" and _value then
105
104
  self:blocks(name, rules.blocks)
106
105
  end
107
106
  if value and rules.layer ~= nil then
@@ -151,7 +150,7 @@ do
151
150
  local blockers = asTable(rule)
152
151
  for i = 1, #blockers do
153
152
  local blocker = blockers[i + 1]
154
- if self:inSameGroup(name, blocker) or not (blocker ~= "" and blocker) then
153
+ if self:inSameGroup(name, blocker) or not (blocker ~= 0 and blocker == blocker and blocker ~= "" and blocker) then
155
154
  continue
156
155
  end
157
156
  if self.appManager:getState(blocker) then
@@ -164,7 +163,7 @@ do
164
163
  local blocked = asTable(rule)
165
164
  for i = 1, #blocked do
166
165
  local b = blocked[i + 1]
167
- if self:inSameGroup(name, b) or not (b ~= "" and b) then
166
+ if self:inSameGroup(name, b) or not (b ~= 0 and b == b and b ~= "" and b) then
168
167
  continue
169
168
  end
170
169
  if self.appManager:getState(b) then
@@ -20,6 +20,7 @@ declare namespace Types {
20
20
  };
21
21
 
22
22
  type ClassProps = AppProps & {
23
+ forge: AppForge;
23
24
  px: ReturnType<typeof import("@rbxts/loners-pretty-react-hooks").usePx>;
24
25
  };
25
26
 
@@ -3,34 +3,11 @@ 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 _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
7
- local vide = _vide
8
- local source = _vide.source
6
+ local vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
9
7
  -- Types
10
8
  -- Components
11
9
  local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
12
10
  local create = vide.create
13
- local function createSource(name, forge)
14
- local _name = name
15
- local app = AppRegistry[_name]
16
- if not app then
17
- error(`App "{name}" not registered`)
18
- end
19
- local _sources = forge.sources
20
- local _name_1 = name
21
- if _sources[_name_1] ~= nil then
22
- return nil
23
- end
24
- local _sources_1 = forge.sources
25
- local _exp = name
26
- local _condition = app.visible
27
- if _condition == nil then
28
- _condition = false
29
- end
30
- local _arg1 = source(_condition)
31
- _sources_1[_exp] = _arg1
32
- return source
33
- end
34
11
  local function createInstance(props)
35
12
  local _binding = props
36
13
  local name = _binding.name
@@ -53,11 +30,9 @@ end
53
30
  local function AppContainer(props)
54
31
  local _binding = props
55
32
  local name = _binding.name
56
- local forge = _binding.forge
57
33
  if not (name ~= "" and name) then
58
34
  error("App name is required in AppContainer")
59
35
  end
60
- createSource(name, forge)
61
36
  local element = createInstance(props)
62
37
  if not element then
63
38
  error(`Failed to create instance for app "{name}"`)
@@ -0,0 +1,7 @@
1
+ declare const Contexts: {
2
+ readonly App: import("@rbxts/vide").Context<{
3
+ forge: import(".").default;
4
+ px: typeof import("@rbxts/loners-pretty-vide-utils").px;
5
+ } | undefined>;
6
+ };
7
+ export default Contexts;
@@ -0,0 +1,12 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ local context = TS.import(script, TS.getModule(script, "@rbxts", "vide").src).context
5
+ -- Types
6
+ local Contexts = {
7
+ App = context(nil),
8
+ }
9
+ local default = Contexts
10
+ return {
11
+ default = default,
12
+ }
@@ -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[number];
9
+ readonly name: AppNames;
10
10
  readonly source: Vide.Source<boolean>;
11
11
  constructor(props: Types.NameProps & Types.MainProps);
12
12
  abstract render(): Vide.Node;
@@ -35,6 +35,7 @@ do
35
35
  local _object = table.clone(props.props)
36
36
  setmetatable(_object, nil)
37
37
  _object.px = px
38
+ _object.forge = forge
38
39
  self.props = _object
39
40
  self.name = name
40
41
  self.source = forge:getSource(name)
@@ -1,3 +1,5 @@
1
1
  import Vide from "@rbxts/vide";
2
- import Types from "./types";
2
+ import type Types from "./types";
3
+ import type AppForge from ".";
4
+ export declare function createSource(name: AppNames, forge: AppForge): typeof Vide.source | undefined;
3
5
  export declare function Render(props: Types.NameProps & Types.MainProps): Vide.Node;
@@ -2,14 +2,46 @@
2
2
  local TS = _G[script]
3
3
  -- Packages
4
4
  local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-vide-utils").out).usePx
5
+ local source = TS.import(script, TS.getModule(script, "@rbxts", "vide").src).source
5
6
  -- Types
7
+ -- Components
8
+ local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
6
9
  local __px = false
10
+ local function createSource(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 _sources = forge.sources
17
+ local _name_1 = name
18
+ if _sources[_name_1] ~= nil then
19
+ return nil
20
+ end
21
+ local _sources_1 = forge.sources
22
+ local _exp = name
23
+ local _condition = app.visible
24
+ if _condition == nil then
25
+ _condition = false
26
+ end
27
+ local _arg1 = source(_condition)
28
+ _sources_1[_exp] = _arg1
29
+ return source
30
+ end
7
31
  local function Render(props)
8
32
  local _binding = props
9
33
  local config = _binding.config
10
34
  local name = _binding.name
11
35
  local names = _binding.names
12
36
  local forge = _binding.forge
37
+ -- ▼ ReadonlyMap.forEach ▼
38
+ local _callback = function(_, name)
39
+ return createSource(name, forge)
40
+ end
41
+ for _k, _v in AppRegistry do
42
+ _callback(_v, _k, AppRegistry)
43
+ end
44
+ -- ▲ ReadonlyMap.forEach ▲
13
45
  if not __px then
14
46
  local _result = config
15
47
  if _result ~= nil then
@@ -36,5 +68,6 @@ local function Render(props)
36
68
  return forge:renderAll(props)
37
69
  end
38
70
  return {
71
+ createSource = createSource,
39
72
  Render = Render,
40
73
  }
@@ -0,0 +1,5 @@
1
+ declare const _default: () => {
2
+ forge: import("..").default;
3
+ px: typeof import("@rbxts/loners-pretty-vide-utils").px;
4
+ };
5
+ export default _default;
@@ -0,0 +1,14 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Components
4
+ local Contexts = TS.import(script, script.Parent.Parent, "context").default
5
+ local default = function()
6
+ local context = Contexts.App()
7
+ if not context then
8
+ error(`Failed to retrieve App Props for Vide {debug.traceback()}`)
9
+ end
10
+ return context
11
+ end
12
+ return {
13
+ default = default,
14
+ }
@@ -4,11 +4,11 @@ export default class AppForge {
4
4
  sources: Map<string, Vide.Source<boolean>>;
5
5
  loaded: Map<string, Vide.Node>;
6
6
  private rulesManager;
7
- getSource(name: AppNames[number]): Vide.Source<boolean>;
8
- set(name: AppNames[number], value: Vide.Source<boolean> | boolean): void;
9
- open(name: AppNames[number]): void;
10
- close(name: AppNames[number]): void;
11
- toggle(name: AppNames[number]): void;
7
+ getSource(name: AppNames): Vide.Source<boolean>;
8
+ set(name: AppNames, value: Vide.Source<boolean> | boolean): void;
9
+ open(name: AppNames): void;
10
+ close(name: AppNames): void;
11
+ toggle(name: AppNames): void;
12
12
  renderApp(props: Types.NameProps & Types.MainProps): ScreenGui | Frame;
13
13
  renderApps(props: Types.NameProps & Types.MainProps): (ScreenGui | Frame)[];
14
14
  renderAll(props: Types.MainProps): (ScreenGui | Frame)[];
@@ -7,6 +7,8 @@ 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
+ -- Helpers
11
+ local createSource = TS.import(script, script, "helpers").createSource
10
12
  local AppForge
11
13
  do
12
14
  AppForge = setmetatable({}, {
@@ -28,16 +30,14 @@ do
28
30
  local _sources = self.sources
29
31
  local _name = name
30
32
  if not (_sources[_name] ~= nil) then
31
- error(`App "{name}" has no source`)
33
+ createSource(name, self)
32
34
  end
33
35
  local _sources_1 = self.sources
34
36
  local _name_1 = name
35
37
  return _sources_1[_name_1]
36
38
  end
37
39
  function AppForge:set(name, value)
38
- if not self.rulesManager:applyRules(name, value) then
39
- return nil
40
- end
40
+ self.rulesManager:applyRules(name)
41
41
  local _value = value
42
42
  if type(_value) == "function" then
43
43
  local _sources = self.sources
@@ -48,8 +48,11 @@ do
48
48
  local _sources = self.sources
49
49
  local _name = name
50
50
  local source = _sources[_name]
51
+ if source() == value then
52
+ return nil
53
+ end
51
54
  if not source then
52
- error(`App "{name}" has no source`)
55
+ createSource(name, self)
53
56
  end
54
57
  source(value)
55
58
  end
@@ -0,0 +1,6 @@
1
+ import type AppForge from "..";
2
+ export default class RulesManager {
3
+ private forge;
4
+ constructor(forge: AppForge);
5
+ applyRules(name: AppNames): void;
6
+ }
@@ -0,0 +1,44 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ -- Components
5
+ local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
6
+ -- Types
7
+ -- Rules
8
+ local ParentRule = TS.import(script, script, "parent").default
9
+ local RulesManager
10
+ do
11
+ RulesManager = setmetatable({}, {
12
+ __tostring = function()
13
+ return "RulesManager"
14
+ end,
15
+ })
16
+ RulesManager.__index = RulesManager
17
+ function RulesManager.new(...)
18
+ local self = setmetatable({}, RulesManager)
19
+ return self:constructor(...) or self
20
+ end
21
+ function RulesManager:constructor(forge)
22
+ self.forge = forge
23
+ end
24
+ function RulesManager:applyRules(name)
25
+ local _name = name
26
+ local appData = AppRegistry[_name]
27
+ local _rules = appData
28
+ if _rules ~= nil then
29
+ _rules = _rules.rules
30
+ end
31
+ local rules = _rules
32
+ if not rules then
33
+ return nil
34
+ end
35
+ local _value = rules.parent
36
+ if _value ~= "" and _value then
37
+ ParentRule(name, self.forge)
38
+ end
39
+ return nil
40
+ end
41
+ end
42
+ return {
43
+ default = RulesManager,
44
+ }
@@ -0,0 +1,2 @@
1
+ import type AppForge from "..";
2
+ export default function ParentRule(entry: AppNames, forge: AppForge): void;
@@ -0,0 +1,38 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Types
4
+ -- Components
5
+ local AppRegistry = TS.import(script, script.Parent.Parent, "decorator").AppRegistry
6
+ local function ParentRule(entry, forge)
7
+ local children = {}
8
+ -- ▼ ReadonlyMap.forEach ▼
9
+ local _callback = function(app, name)
10
+ local rules = app.rules
11
+ if not rules then
12
+ return nil
13
+ end
14
+ local _condition = rules.parent
15
+ if _condition ~= "" and _condition then
16
+ _condition = rules.parent == entry
17
+ end
18
+ if _condition ~= "" and _condition then
19
+ local _name = name
20
+ table.insert(children, _name)
21
+ end
22
+ end
23
+ for _k, _v in AppRegistry do
24
+ _callback(_v, _k, AppRegistry)
25
+ end
26
+ -- ▲ ReadonlyMap.forEach ▲
27
+ -- ▼ ReadonlyArray.forEach ▼
28
+ local _callback_1 = function(name)
29
+ return forge:close(name)
30
+ end
31
+ for _k, _v in children do
32
+ _callback_1(_v, _k - 1, children)
33
+ end
34
+ -- ▲ ReadonlyArray.forEach ▲
35
+ end
36
+ return {
37
+ default = ParentRule,
38
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ return nil
@@ -4,14 +4,14 @@ import type AppForge from ".";
4
4
 
5
5
  declare namespace Types {
6
6
  type AppRegistryProps = {
7
- name: AppNames[number];
7
+ name: AppNames;
8
8
  visible?: boolean;
9
9
  rules?: Rules.All;
10
10
  };
11
11
 
12
12
  type NameProps =
13
- | { name?: AppNames[number]; names?: undefined }
14
- | { names?: AppNames[number][]; name?: undefined };
13
+ | { name?: AppNames; names?: undefined }
14
+ | { names?: AppNames[]; name?: undefined };
15
15
 
16
16
  type MainProps = {
17
17
  props: AppProps;
@@ -26,6 +26,7 @@ declare namespace Types {
26
26
  };
27
27
 
28
28
  type ClassProps = AppProps & {
29
+ forge: AppForge;
29
30
  px: typeof import("@rbxts/loners-pretty-vide-utils").px;
30
31
  };
31
32
 
@@ -36,19 +37,30 @@ declare namespace Types {
36
37
  };
37
38
 
38
39
  namespace Rules {
39
- type Groups = AppGroups[number] | "Core" | "Core"[] | AppGroups[number][];
40
- type BlockedBy = AppNames[number] | AppNames[number][];
41
- type Blocks = AppNames[number] | AppNames[number][];
40
+ type BlockedBy = AppNames | AppNames[];
41
+ type Blocks = AppNames | AppNames[];
42
42
  type Exclusive = boolean;
43
43
  type Layer = number;
44
44
 
45
+ type GroupUnion =
46
+ | {
47
+ groups?: AppGroups[];
48
+ group?: never;
49
+ }
50
+ | {
51
+ groups?: never;
52
+ group?: AppGroups | "Core";
53
+ };
54
+
45
55
  type All = {
46
56
  blockedBy?: BlockedBy;
47
57
  exclusive?: Exclusive;
48
- groups?: Groups;
49
58
  blocks?: Blocks;
50
59
  layer?: Layer;
51
- };
60
+
61
+ parent?: AppNames;
62
+ parents?: AppNames[];
63
+ } & GroupUnion;
52
64
  }
53
65
  }
54
66
 
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@rbxts/app-forge",
3
- "version": "0.6.0-alpha.3",
3
+ "version": "0.6.0-alpha.31",
4
4
  "description": "An App Manager for react",
5
5
  "main": "out/init.lua",
6
+ "types": "out/index.d.ts",
6
7
  "packageManager": "bun@1.3.1",
7
8
  "scripts": {
8
9
  "build": "rbxtsc",
@@ -23,7 +24,6 @@
23
24
  "bugs": {
24
25
  "url": "https://github.com/Loner1536/AppForge/issues"
25
26
  },
26
- "types": "out/index.d.ts",
27
27
  "files": [
28
28
  "out",
29
29
  "!**/*.tsbuildinfo",
@@ -41,14 +41,14 @@
41
41
  "typescript": "^5.9.3"
42
42
  },
43
43
  "dependencies": {
44
- "@rbxts/set-timeout": "^1.1.2",
45
- "@rbxts/services": "^1.6.0"
44
+ "@rbxts/loners-pretty-react-hooks": "^0.2.9",
45
+ "@rbxts/loners-pretty-vide-utils": "^0.1.4",
46
+ "@rbxts/object-utils": "^1.0.4",
47
+ "@rbxts/services": "^1.6.0",
48
+ "@rbxts/set-timeout": "^1.1.2"
46
49
  },
47
50
  "peerDependencies": {
48
- "@rbxts/loners-pretty-react-hooks": "*",
49
- "@rbxts/loners-pretty-vide-utils": "*",
50
- "@rbxts/object-utils": "*",
51
- "@rbxts/react": "*",
52
- "@rbxts/vide": "*"
51
+ "@rbxts/react": "^17.3.7-ts.1",
52
+ "@rbxts/vide": "^0.5.7"
53
53
  }
54
54
  }
@@ -1,12 +0,0 @@
1
- import Vide from "@rbxts/vide";
2
- import type AppForge from ".";
3
- export default class RulesManager {
4
- private appManager;
5
- constructor(appManager: AppForge);
6
- applyRules(name: AppNames[number], source: Vide.Source<boolean> | boolean): boolean;
7
- private inSameGroup;
8
- private blockedBy;
9
- private blocks;
10
- private exclusive;
11
- private layer;
12
- }
@@ -1,198 +0,0 @@
1
- -- Compiled with roblox-ts v3.0.0
2
- local TS = _G[script]
3
- -- Packages
4
- local Object = TS.import(script, TS.getModule(script, "@rbxts", "object-utils"))
5
- -- Components
6
- local AppRegistry = TS.import(script, script.Parent, "decorator").AppRegistry
7
- -- Types
8
- local function asTable(value)
9
- local _value = value
10
- if type(_value) == "table" then
11
- return value
12
- else
13
- local t = {}
14
- t[2] = value
15
- return t
16
- end
17
- end
18
- local RulesManager
19
- do
20
- RulesManager = setmetatable({}, {
21
- __tostring = function()
22
- return "RulesManager"
23
- end,
24
- })
25
- RulesManager.__index = RulesManager
26
- function RulesManager.new(...)
27
- local self = setmetatable({}, RulesManager)
28
- return self:constructor(...) or self
29
- end
30
- function RulesManager:constructor(appManager)
31
- self.appManager = appManager
32
- end
33
- function RulesManager:applyRules(name, source)
34
- local _name = name
35
- local appData = AppRegistry[_name]
36
- local _rules = appData
37
- if _rules ~= nil then
38
- _rules = _rules.rules
39
- end
40
- local rules = _rules
41
- local _source = source
42
- local value = if type(_source) == "function" then source() else source
43
- local _result = rules
44
- if _result ~= nil then
45
- _result = _result.groups
46
- end
47
- if _result == "Core" then
48
- return true
49
- end
50
- if value then
51
- local allNames = Object.keys(AppRegistry)
52
- -- ▼ ReadonlyArray.forEach ▼
53
- local _callback = function(n)
54
- if not (n ~= "" and n) or n == name then
55
- return nil
56
- end
57
- print(self.appManager.loaded)
58
- local _n = n
59
- local otherApp = AppRegistry[_n]
60
- local _result_1 = otherApp
61
- if _result_1 ~= nil then
62
- _result_1 = _result_1.rules
63
- if _result_1 ~= nil then
64
- _result_1 = _result_1.groups
65
- end
66
- end
67
- local groups = if _result_1 ~= "" and _result_1 then asTable(otherApp.rules.groups) else {}
68
- -- ▼ ReadonlyArray.find ▼
69
- local _callback_1 = function(g)
70
- return g == "Core"
71
- end
72
- local _result_2
73
- for _i, _v in groups do
74
- if _callback_1(_v, _i - 1, groups) == true then
75
- _result_2 = _v
76
- break
77
- end
78
- end
79
- -- ▲ ReadonlyArray.find ▲
80
- if _result_2 then
81
- return nil
82
- end
83
- if self.appManager:getSource(n)() then
84
- self.appManager:set(n, false)
85
- end
86
- end
87
- for _k, _v in allNames do
88
- _callback(_v, _k - 1, allNames)
89
- end
90
- -- ▲ ReadonlyArray.forEach ▲
91
- end
92
- if not rules then
93
- return true
94
- end
95
- local _condition = value
96
- if _condition then
97
- _condition = rules.blockedBy
98
- if _condition ~= "" and _condition then
99
- _condition = not self:blockedBy(name, rules.blockedBy)
100
- end
101
- end
102
- if _condition ~= "" and _condition then
103
- return false
104
- end
105
- local _value = value and rules.blocks
106
- if _value ~= "" and _value then
107
- self:blocks(name, rules.blocks)
108
- end
109
- if value and rules.layer ~= nil then
110
- self:layer(name, rules.layer)
111
- end
112
- if value and rules.exclusive then
113
- self:exclusive(name)
114
- end
115
- return true
116
- end
117
- function RulesManager:inSameGroup(a, b)
118
- local _a = a
119
- local appA = AppRegistry[_a]
120
- local _b = b
121
- local appB = AppRegistry[_b]
122
- if not appA or not appB then
123
- return false
124
- end
125
- local _result = appA.rules
126
- if _result ~= nil then
127
- _result = _result.groups
128
- end
129
- local _condition = _result
130
- if _condition == nil then
131
- _condition = {}
132
- end
133
- local groupsA = asTable(_condition)
134
- local _result_1 = appB.rules
135
- if _result_1 ~= nil then
136
- _result_1 = _result_1.groups
137
- end
138
- local _condition_1 = _result_1
139
- if _condition_1 == nil then
140
- _condition_1 = {}
141
- end
142
- local groupsB = asTable(_condition_1)
143
- for i = 1, #groupsA do
144
- for j = 1, #groupsB do
145
- if groupsA[i + 1] == groupsB[j + 1] then
146
- return true
147
- end
148
- end
149
- end
150
- return false
151
- end
152
- function RulesManager:blockedBy(name, rule)
153
- local blockers = asTable(rule)
154
- for i = 1, #blockers do
155
- local blocker = blockers[i + 1]
156
- if self:inSameGroup(name, blocker) or not (blocker ~= "" and blocker) then
157
- continue
158
- end
159
- if self.appManager:getSource(blocker)() then
160
- return false
161
- end
162
- end
163
- return true
164
- end
165
- function RulesManager:blocks(name, rule)
166
- local blocked = asTable(rule)
167
- for i = 1, #blocked do
168
- local b = blocked[i + 1]
169
- if self:inSameGroup(name, b) or not (b ~= "" and b) then
170
- continue
171
- end
172
- if self.appManager:getSource(b)() then
173
- self.appManager:set(b, false)
174
- end
175
- end
176
- end
177
- function RulesManager:exclusive(name)
178
- local names = Object.keys(AppRegistry)
179
- for i = 1, #names do
180
- local other = names[i + 1]
181
- if other == name or not (other ~= "" and other) then
182
- continue
183
- end
184
- if self:inSameGroup(name, other) then
185
- continue
186
- end
187
- if self.appManager:getSource(other)() then
188
- self.appManager:set(other, false)
189
- end
190
- end
191
- end
192
- function RulesManager:layer(_name, _layer)
193
- -- TODO: implement priority / layering
194
- end
195
- end
196
- return {
197
- default = RulesManager,
198
- }