@rbxts/app-forge 0.7.2-prototype.2 → 0.7.2-prototype.20

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.
@@ -1,21 +1,23 @@
1
1
  import Vide from "@rbxts/vide";
2
2
  import type Types from "./types";
3
3
  import type AppForge from "./mount";
4
- export declare const AppRegistry: Map<string, Types.AppRegistry.Static>;
4
+ export declare const AppRegistry: Map<string, Map<string, Types.AppRegistry.Static>>;
5
+ export declare const AppSources: Map<string, Map<string, Vide.Source<boolean>>>;
5
6
  /**
6
7
  * Registers a Vide App with AppForge.
7
8
  *
8
9
  * This runs at definition time and validates static configuration.
9
10
  */
10
- export declare function App<N extends AppNames>(props: Types.AppRegistry.Props<N>): <T extends new (props: Types.Props.Main, name: AppNames) => Args>(constructor: T) => T;
11
+ export declare function App<N extends AppNames>(props: Types.AppRegistry.Props<N>): <T extends new (props: Types.Props.Main, name: AppNames, group?: AppGroups) => Args>(constructor: T) => T;
11
12
  /**
12
13
  * Base class for all AppForge Apps.
13
14
  */
14
15
  export declare abstract class Args {
15
- readonly forge: AppForge;
16
+ readonly source: Vide.Source<boolean>;
16
17
  readonly props: Types.Props.Class;
18
+ readonly forge: AppForge;
19
+ readonly group: AppGroups;
17
20
  readonly name: AppNames;
18
- readonly source: Vide.Source<boolean>;
19
- constructor(props: Types.Props.Main, name: AppNames);
21
+ constructor(props: Types.Props.Main, name: AppNames, group?: AppGroups);
20
22
  abstract render(): Vide.Node;
21
23
  }
@@ -4,10 +4,8 @@ local TS = _G[script]
4
4
  -- Types
5
5
  -- Hooks
6
6
  local px = TS.import(script, script.Parent, "hooks", "usePx").px
7
- -- Debug
8
- local Logger = TS.import(script, script.Parent, "logger").default
9
- local logger = Logger.new("AppRegistry")
10
7
  local AppRegistry = {}
8
+ local AppSources = {}
11
9
  --[[
12
10
  *
13
11
  * Registers a Vide App with AppForge.
@@ -18,25 +16,51 @@ local AppRegistry = {}
18
16
  local function App(props)
19
17
  return function(constructor)
20
18
  local _name = props.name
21
- if AppRegistry[_name] ~= nil then
22
- logger:log("ERROR", "Duplicate App name detected", {
23
- name = props.name,
24
- })
25
- error(`Duplicate registered App name "{props.name}". ` .. `App names must be globally unique.`, 2)
19
+ local _result = AppRegistry[_name]
20
+ if _result ~= nil then
21
+ local _condition = props.group
22
+ if not (_condition ~= "" and _condition) then
23
+ _condition = "None"
24
+ end
25
+ _result = _result[_condition] ~= nil
26
+ end
27
+ if _result then
28
+ local _exp = props.name
29
+ local _condition = props.group
30
+ if not (_condition ~= "" and _condition) then
31
+ _condition = "None"
32
+ end
33
+ error(`Duplicate registered App name "{_exp} in same Group name {_condition}". ` .. `App names must be globally unique.`, 2)
26
34
  end
27
35
  local _value = props.name
28
36
  if not (_value ~= "" and _value) then
29
- logger:log("ERROR", "Attempted to register App without a name", props)
30
37
  error("App registration failed: missing app name", 2)
31
38
  end
32
39
  local _name_1 = props.name
33
- local _arg1 = {
34
- constructor = constructor,
35
- renderGroup = props.renderGroup,
36
- visible = props.visible,
37
- rules = props.rules,
38
- }
39
- AppRegistry[_name_1] = _arg1
40
+ if not AppRegistry[_name_1] then
41
+ local _name_2 = props.name
42
+ AppRegistry[_name_2] = {}
43
+ end
44
+ local _name_2 = props.name
45
+ local _result_1 = AppRegistry[_name_2]
46
+ if _result_1 ~= nil then
47
+ local _condition = props.group
48
+ if not (_condition ~= "" and _condition) then
49
+ _condition = "None"
50
+ end
51
+ local _object = {
52
+ constructor = constructor,
53
+ }
54
+ local _left = "renderGroup"
55
+ local _condition_1 = props.group
56
+ if not (_condition_1 ~= "" and _condition_1) then
57
+ _condition_1 = "None"
58
+ end
59
+ _object[_left] = _condition_1
60
+ _object.visible = props.visible
61
+ _object.rules = props.rules
62
+ _result_1[_condition] = _object
63
+ end
40
64
  return constructor
41
65
  end
42
66
  end
@@ -48,28 +72,27 @@ end
48
72
  local Args
49
73
  do
50
74
  Args = {}
51
- function Args:constructor(props, name)
75
+ function Args:constructor(props, name, group)
52
76
  local _binding = props
53
77
  local forge = _binding.forge
54
78
  self.forge = forge
79
+ local _condition = group
80
+ if not (_condition ~= "" and _condition) then
81
+ _condition = "None"
82
+ end
83
+ self.group = _condition
55
84
  self.name = name
56
85
  local _object = table.clone(props.props)
57
86
  setmetatable(_object, nil)
58
- _object.px = px
59
87
  _object.forge = forge
88
+ _object.px = px
60
89
  self.props = _object
61
- local src = forge:getSource(name)
62
- if not src then
63
- logger:log("ERROR", "Missing visibility source for App", {
64
- name = name,
65
- })
66
- error(`Failed to retrieve visibility source for app "{name}"`, 2)
67
- end
68
- self.source = src
90
+ self.source = forge:getSource(name, group)
69
91
  end
70
92
  end
71
93
  return {
72
94
  App = App,
73
95
  AppRegistry = AppRegistry,
96
+ AppSources = AppSources,
74
97
  Args = Args,
75
98
  }
@@ -0,0 +1,2 @@
1
+ import Vide from "@rbxts/vide";
2
+ export default function bindAppSource(name: AppNames, group: AppGroups, value: Vide.Source<boolean>): void;
@@ -0,0 +1,22 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ -- Components
5
+ local AppSources = TS.import(script, script.Parent.Parent, "appRegistry").AppSources
6
+ local function bindAppSource(name, group, value)
7
+ local _name = name
8
+ if not AppSources[_name] then
9
+ local _name_1 = name
10
+ AppSources[_name_1] = {}
11
+ end
12
+ local _name_1 = name
13
+ local _result = AppSources[_name_1]
14
+ if _result ~= nil then
15
+ local _group = group
16
+ local _value = value
17
+ _result[_group] = _value
18
+ end
19
+ end
20
+ return {
21
+ default = bindAppSource,
22
+ }
@@ -0,0 +1,2 @@
1
+ import type CreateForge from "../mount";
2
+ export default function getAppEntry(forge: CreateForge, name: AppNames, group: AppGroups): import("../types").default.AppRegistry.Static | undefined;
@@ -0,0 +1,22 @@
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, "appRegistry").AppRegistry
6
+ local function getAppEntry(forge, name, group)
7
+ local _name = name
8
+ local entryMap = AppRegistry[_name]
9
+ local _entry = entryMap
10
+ if _entry ~= nil then
11
+ local _group = group
12
+ _entry = _entry[_group]
13
+ end
14
+ local entry = _entry
15
+ if not entry then
16
+ forge.logger:log("WARN", `Failed to get entry for name {name} and group {group}`)
17
+ end
18
+ return entry
19
+ end
20
+ return {
21
+ default = getAppEntry,
22
+ }
@@ -0,0 +1,2 @@
1
+ import type CreateForge from "../mount";
2
+ export default function getAppSource(forge: CreateForge, name: AppNames, group: AppGroups): import("@rbxts/vide").Source<boolean> | undefined;
@@ -0,0 +1,25 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Types
4
+ -- Components
5
+ local AppSources = TS.import(script, script.Parent.Parent, "appRegistry").AppSources
6
+ local function getAppSource(forge, name, group)
7
+ local _name = name
8
+ local sourceMap = AppSources[_name]
9
+ if not sourceMap then
10
+ forge.logger:log("WARN", `Failed to get source map for name {name} and group {group}`)
11
+ end
12
+ local _source = sourceMap
13
+ if _source ~= nil then
14
+ local _group = group
15
+ _source = _source[_group]
16
+ end
17
+ local source = _source
18
+ if not source then
19
+ forge.logger:log("WARN", `Failed to get source for name {name} and group {group}`)
20
+ end
21
+ return source
22
+ end
23
+ return {
24
+ default = getAppSource,
25
+ }
@@ -0,0 +1 @@
1
+ export default function hasAppSource(name: AppNames, group: AppGroups): boolean;
@@ -0,0 +1,24 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Components
4
+ local AppSources = TS.import(script, script.Parent.Parent, "appRegistry").AppSources
5
+ local function hasAppSource(name, group)
6
+ local _name = name
7
+ local sourceMap = AppSources[_name]
8
+ if not sourceMap then
9
+ local _ = false
10
+ end
11
+ local _source = sourceMap
12
+ if _source ~= nil then
13
+ local _group = group
14
+ _source = _source[_group]
15
+ end
16
+ local source = _source
17
+ if not source then
18
+ local _ = false
19
+ end
20
+ return true
21
+ end
22
+ return {
23
+ default = hasAppSource,
24
+ }
@@ -0,0 +1 @@
1
+ export default function setAppSource(name: AppNames, group: AppGroups, value: boolean): void;
@@ -0,0 +1,34 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ local source = TS.import(script, TS.getModule(script, "@rbxts", "vide").src).source
5
+ -- Components
6
+ local AppSources = TS.import(script, script.Parent.Parent, "appRegistry").AppSources
7
+ local function setAppSource(name, group, value)
8
+ local _name = name
9
+ if not AppSources[_name] then
10
+ local _name_1 = name
11
+ AppSources[_name_1] = {}
12
+ end
13
+ local _name_1 = name
14
+ local _src = AppSources[_name_1]
15
+ if _src ~= nil then
16
+ local _group = group
17
+ _src = _src[_group]
18
+ end
19
+ local src = _src
20
+ if not src then
21
+ local newSource = source(value)
22
+ local _name_2 = name
23
+ local _result = AppSources[_name_2]
24
+ if _result ~= nil then
25
+ local _group = group
26
+ _result[_group] = newSource
27
+ end
28
+ else
29
+ src(false)
30
+ end
31
+ end
32
+ return {
33
+ default = setAppSource,
34
+ }
package/out/mount.d.ts CHANGED
@@ -1,33 +1,25 @@
1
1
  import Vide from "@rbxts/vide";
2
- import Renders from "./renderManager";
2
+ import type Types from "./types";
3
+ import Renders from "./renders";
3
4
  import Debugger from "./debugger";
4
5
  import Logger from "./logger";
5
- import Types from "./types";
6
6
  type Destructor = () => void;
7
- type Loaded = {
8
- container: Vide.Node;
9
- render: Vide.Node;
10
- anchor?: Vide.Node;
11
- };
12
7
  export default class AppForge extends Renders {
13
8
  readonly logger: Logger;
14
9
  readonly debug: Debugger;
15
- protected sources: Map<string, Vide.Source<boolean>>;
16
- protected loaded: Map<string, Loaded>;
17
- protected innerMount?: Destructor;
10
+ private innerMount?;
18
11
  constructor();
19
- protected createSource(name: AppNames): void;
20
- getSource(name: AppNames): Vide.Source<boolean>;
21
- isLoaded(name: AppNames): boolean;
22
- bind(name: AppNames, value: Vide.Source<boolean>): void;
23
- set(name: AppNames, value: boolean, rules?: boolean): void;
24
- open(name: AppNames, rules?: boolean): void;
25
- close(name: AppNames, rules?: boolean): void;
26
- toggle(name: AppNames, rules?: boolean): void;
12
+ private createSource;
13
+ getSource(name: AppNames, group?: AppGroups): Vide.Source<boolean>;
14
+ bind(name: AppNames, group: AppGroups | undefined, value: Vide.Source<boolean>): void;
15
+ set(name: AppNames, group: AppGroups | undefined, value: boolean, rules?: boolean): void;
16
+ open(name: AppNames, group?: AppGroups, rules?: boolean): void;
17
+ close(name: AppNames, group?: AppGroups, rules?: boolean): void;
18
+ toggle(name: AppNames, group?: AppGroups, rules?: boolean): void;
27
19
  story(props: AppProps, target: GuiObject, config?: {
28
20
  render?: Types.Props.Render;
29
21
  minScale?: number;
30
22
  }): Frame;
31
- mount(node: Vide.Node, props: Types.Props.Main, target: Instance): Destructor;
23
+ mount(props: Omit<Types.Props.Main, "forge">, target: Instance, root?: GuiObject | Instance): Destructor | undefined;
32
24
  }
33
25
  export {};
package/out/mount.luau CHANGED
@@ -8,15 +8,21 @@ local Vide = _vide
8
8
  local apply = _vide.apply
9
9
  local create = _vide.create
10
10
  local effect = _vide.effect
11
- local mount = _vide.mount
12
- local source = _vide.source
13
11
  local untrack = _vide.untrack
12
+ -- Types
14
13
  -- Classes
15
- local Renders = TS.import(script, script.Parent, "renderManager").default
16
- -- Helpers
14
+ local Renders = TS.import(script, script.Parent, "renders").default
15
+ -- Components
17
16
  local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
17
+ -- Classes
18
18
  local Debugger = TS.import(script, script.Parent, "debugger").default
19
19
  local Logger = TS.import(script, script.Parent, "logger").default
20
+ -- Helpers
21
+ local bindAppSource = TS.import(script, script.Parent, "helpers", "bindAppSource").default
22
+ local getAppSource = TS.import(script, script.Parent, "helpers", "getAppSource").default
23
+ local hasAppSource = TS.import(script, script.Parent, "helpers", "hasAppSource").default
24
+ local setAppSource = TS.import(script, script.Parent, "helpers", "setAppSource").default
25
+ local getAppEntry = TS.import(script, script.Parent, "helpers", "getAppEntry").default
20
26
  local AppForge
21
27
  do
22
28
  local super = Renders
@@ -37,76 +43,74 @@ do
37
43
  self.debug = Debugger.new(function(level, msg, data, trace)
38
44
  return self.logger:log(level, msg, data, trace)
39
45
  end)
40
- self.sources = {}
41
- self.loaded = {}
42
46
  -- ▼ ReadonlyMap.forEach ▼
43
- local _callback = function(_, name)
44
- return self:createSource(name)
47
+ local _callback = function(entryMap, name)
48
+ -- ▼ ReadonlyMap.forEach ▼
49
+ local _callback_1 = function(_, group)
50
+ self:createSource(name, group)
51
+ end
52
+ for _k, _v in entryMap do
53
+ _callback_1(_v, _k, entryMap)
54
+ end
55
+ -- ▲ ReadonlyMap.forEach ▲
45
56
  end
46
57
  for _k, _v in AppRegistry do
47
58
  _callback(_v, _k, AppRegistry)
48
59
  end
49
60
  -- ▲ ReadonlyMap.forEach ▲
50
61
  end
51
- function AppForge:createSource(name)
52
- local _name = name
53
- local app = AppRegistry[_name]
54
- if not app then
55
- self.logger:log("ERROR", "App not registered while creating source", {
62
+ function AppForge:createSource(name, group)
63
+ if group == nil then
64
+ group = "None"
65
+ end
66
+ local entry = getAppEntry(self, name, group)
67
+ if not entry then
68
+ self.logger:log("ERROR", "App Entry not registered while creating source", {
56
69
  name = name,
57
70
  })
58
71
  return nil
59
72
  end
60
- local _sources = self.sources
61
- local _name_1 = name
62
- if _sources[_name_1] ~= nil then
73
+ if hasAppSource(name, group) then
63
74
  return nil
64
75
  end
65
76
  local _debug = self.debug
66
77
  local _exp = name
67
78
  local _object = {}
68
79
  local _left = "default"
69
- local _condition = app.visible
80
+ local _condition = entry.visible
70
81
  if _condition == nil then
71
82
  _condition = false
72
83
  end
73
84
  _object[_left] = _condition
74
85
  _debug:logTag("state", _exp, "Creating visibility source", _object)
75
- local _sources_1 = self.sources
76
86
  local _exp_1 = name
77
- local _condition_1 = app.visible
87
+ local _exp_2 = group
88
+ local _condition_1 = entry.visible
78
89
  if _condition_1 == nil then
79
90
  _condition_1 = false
80
91
  end
81
- local _arg1 = source(_condition_1)
82
- _sources_1[_exp_1] = _arg1
92
+ setAppSource(_exp_1, _exp_2, _condition_1)
83
93
  end
84
- function AppForge:getSource(name)
85
- local _sources = self.sources
86
- local _name = name
87
- if not (_sources[_name] ~= nil) then
88
- self:createSource(name)
89
- end
90
- local _sources_1 = self.sources
91
- local _name_1 = name
92
- local src = _sources_1[_name_1]
94
+ function AppForge:getSource(name, group)
95
+ if group == nil then
96
+ group = "None"
97
+ end
98
+ if not hasAppSource(name, group) then
99
+ self:createSource(name, group)
100
+ end
101
+ local src = getAppSource(self, name, group)
93
102
  if not src then
94
- error(`AppForge invariant broken: missing visibility source for {name}`, 2)
103
+ self.logger:log("WARN", `Failed to get source for name {name} group {group}`)
95
104
  end
96
105
  return src
97
106
  end
98
- function AppForge:isLoaded(name)
99
- local _loaded = self.loaded
100
- local _name = name
101
- return _loaded[_name] ~= nil
102
- end
103
- function AppForge:bind(name, value)
107
+ function AppForge:bind(name, group, value)
108
+ if group == nil then
109
+ group = "None"
110
+ end
104
111
  if not RunService:IsRunning() then
105
112
  self.debug:logTag("state", name, "Binding external visibility source")
106
- local _sources = self.sources
107
- local _name = name
108
- local _value = value
109
- _sources[_name] = _value
113
+ bindAppSource(name, group, value)
110
114
  local prev
111
115
  local log = function()
112
116
  return self.debug:logTag("state", name, "Visibility changed", {
@@ -119,7 +123,7 @@ do
119
123
  count += 1
120
124
  prev = value()
121
125
  untrack(function()
122
- return self:checkRules(self, name)
126
+ return self:checkRules(self, name, group)
123
127
  end)
124
128
  if Vide.strict and count == 2 then
125
129
  log()
@@ -135,23 +139,15 @@ do
135
139
  })
136
140
  end
137
141
  end
138
- function AppForge:set(name, value, rules)
142
+ function AppForge:set(name, group, value, rules)
143
+ if group == nil then
144
+ group = "None"
145
+ end
139
146
  if rules == nil then
140
147
  rules = true
141
148
  end
142
- local _sources = self.sources
143
- local _name = name
144
- local src = _sources[_name]
149
+ local src = getAppSource(self, name, group)
145
150
  if not src then
146
- self:createSource(name)
147
- local _sources_1 = self.sources
148
- local _name_1 = name
149
- src = _sources_1[_name_1]
150
- end
151
- if not src then
152
- self.logger:log("ERROR", "Failed to set visibility (missing source)", {
153
- name = name,
154
- })
155
151
  return nil
156
152
  end
157
153
  local prev = src()
@@ -164,26 +160,39 @@ do
164
160
  to = value,
165
161
  })
166
162
  if rules then
167
- self:checkRules(self, name)
163
+ self:checkRules(self, name, group)
168
164
  end
169
165
  end
170
- function AppForge:open(name, rules)
166
+ function AppForge:open(name, group, rules)
167
+ if group == nil then
168
+ group = "None"
169
+ end
171
170
  if rules == nil then
172
171
  rules = true
173
172
  end
174
- self:set(name, true, rules)
173
+ self:set(name, group, true, rules)
175
174
  end
176
- function AppForge:close(name, rules)
175
+ function AppForge:close(name, group, rules)
176
+ if group == nil then
177
+ group = "None"
178
+ end
177
179
  if rules == nil then
178
180
  rules = true
179
181
  end
180
- self:set(name, false, rules)
182
+ self:set(name, group, false, rules)
181
183
  end
182
- function AppForge:toggle(name, rules)
184
+ function AppForge:toggle(name, group, rules)
185
+ if group == nil then
186
+ group = "None"
187
+ end
183
188
  if rules == nil then
184
189
  rules = true
185
190
  end
186
- self:set(name, not self:getSource(name)(), rules)
191
+ local src = self:getSource(name, group)
192
+ if not src then
193
+ return self.logger:log("ERROR", `Failed to get Source for name {name} group {group}`)
194
+ end
195
+ self:set(name, group, not src(), rules)
187
196
  end
188
197
  function AppForge:story(props, target, config)
189
198
  self.debug:logTag("lifecycle", "story", "Creating story mount")
@@ -226,14 +235,13 @@ do
226
235
  _fn(_object)
227
236
  return Container
228
237
  end
229
- function AppForge:mount(node, props, target)
238
+ function AppForge:mount(props, target, root)
230
239
  self.debug:logTag("lifecycle", "mount", "Mounting AppForge")
231
- self.innerMount = mount(function()
232
- apply(node)({
233
- [0] = self:initalize(props),
234
- })
235
- return node
236
- end, target)
240
+ local _self = self
241
+ local _object = table.clone(props)
242
+ setmetatable(_object, nil)
243
+ _object.forge = self
244
+ _self:initalize(_object, target, root)
237
245
  return self.innerMount
238
246
  end
239
247
  end
@@ -0,0 +1,18 @@
1
+ import Vide from "@rbxts/vide";
2
+ import type Types from "./types";
3
+ import Rules from "./ruleEngine";
4
+ type Render = {
5
+ instance: Instance;
6
+ container: Instance;
7
+ };
8
+ export default class Renders extends Rules {
9
+ private __px;
10
+ protected Rendered: Map<string, Map<string, Render>>;
11
+ constructor();
12
+ Render: (props: Types.Props.Main) => Instance[];
13
+ private getGroupEntries;
14
+ private createRender;
15
+ private getChildren;
16
+ protected initalize(props: Types.Props.Main, target?: GuiObject | Instance, root?: GuiObject | Instance): Vide.Node;
17
+ }
18
+ export {};
@@ -0,0 +1,240 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
5
+ local Vide = _vide
6
+ local mount = _vide.mount
7
+ -- Types
8
+ -- Components
9
+ local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
10
+ -- Hooks
11
+ local usePx = TS.import(script, script.Parent, "hooks", "usePx").usePx
12
+ -- Classes
13
+ local Rules = TS.import(script, script.Parent, "ruleEngine").default
14
+ -- Helpers
15
+ local getAppEntry = TS.import(script, script.Parent, "helpers", "getAppEntry").default
16
+ local Renders
17
+ do
18
+ local super = Rules
19
+ Renders = setmetatable({}, {
20
+ __tostring = function()
21
+ return "Renders"
22
+ end,
23
+ __index = super,
24
+ })
25
+ Renders.__index = Renders
26
+ function Renders.new(...)
27
+ local self = setmetatable({}, Renders)
28
+ return self:constructor(...) or self
29
+ end
30
+ function Renders:constructor()
31
+ super.constructor(self)
32
+ self.__px = false
33
+ self.Rendered = {}
34
+ self.Render = function(props)
35
+ local _binding = props
36
+ local forge = _binding.forge
37
+ local _result = props.renders
38
+ if _result ~= nil then
39
+ _result = _result.groups
40
+ end
41
+ if _result then
42
+ local _exp = props.renders.groups
43
+ -- ▼ ReadonlyArray.forEach ▼
44
+ local _callback = function(group)
45
+ local groupEntries = self:getGroupEntries(group)
46
+ local _result_1 = props.renders
47
+ if _result_1 ~= nil then
48
+ _result_1 = _result_1.name
49
+ end
50
+ if _result_1 ~= "" and _result_1 then
51
+ local _name = props.renders.name
52
+ local _test = groupEntries[_name]
53
+ if _test ~= nil then
54
+ local _group = group
55
+ _test = _test[_group]
56
+ end
57
+ local test = _test
58
+ print("props.renders.name", test)
59
+ end
60
+ local _result_2 = props.renders
61
+ if _result_2 ~= nil then
62
+ _result_2 = _result_2.names
63
+ end
64
+ if _result_2 then
65
+ local test = {}
66
+ local _exp_1 = props.renders.names
67
+ -- ▼ ReadonlyArray.forEach ▼
68
+ local _callback_1 = function(name)
69
+ local _name = name
70
+ local _entry = groupEntries[_name]
71
+ if _entry ~= nil then
72
+ local _group = group
73
+ _entry = _entry[_group]
74
+ end
75
+ local entry = _entry
76
+ if not entry then
77
+ return forge.logger:log("INFO", `Failed to find a Name of {name} searching through group {group}`)
78
+ end
79
+ table.insert(test, entry)
80
+ end
81
+ for _k, _v in _exp_1 do
82
+ _callback_1(_v, _k - 1, _exp_1)
83
+ end
84
+ -- ▲ ReadonlyArray.forEach ▲
85
+ print("props.renders.names", test)
86
+ end
87
+ end
88
+ for _k, _v in _exp do
89
+ _callback(_v, _k - 1, _exp)
90
+ end
91
+ -- ▲ ReadonlyArray.forEach ▲
92
+ end
93
+ local _result_1 = props.renders
94
+ if _result_1 ~= nil then
95
+ _result_1 = _result_1.group
96
+ end
97
+ if _result_1 ~= "" and _result_1 then
98
+ local _group = props.renders
99
+ if _group ~= nil then
100
+ _group = _group.group
101
+ end
102
+ local group = _group
103
+ local groupEntries = self:getGroupEntries(group)
104
+ local _result_2 = props.renders
105
+ if _result_2 ~= nil then
106
+ _result_2 = _result_2.name
107
+ end
108
+ if _result_2 ~= "" and _result_2 then
109
+ local _name = props.renders.name
110
+ local _test = groupEntries[_name]
111
+ if _test ~= nil then
112
+ _test = _test[group]
113
+ end
114
+ local test = _test
115
+ print("props.renders.name", test)
116
+ end
117
+ local _result_3 = props.renders
118
+ if _result_3 ~= nil then
119
+ _result_3 = _result_3.names
120
+ end
121
+ if _result_3 then
122
+ local test = {}
123
+ local _exp = props.renders.names
124
+ -- ▼ ReadonlyArray.forEach ▼
125
+ local _callback = function(name)
126
+ local _name = name
127
+ local _entry = groupEntries[_name]
128
+ if _entry ~= nil then
129
+ _entry = _entry[group]
130
+ end
131
+ local entry = _entry
132
+ if not entry then
133
+ return forge.logger:log("INFO", `Failed to find a Name of {name} searching through group {group}`)
134
+ end
135
+ table.insert(test, entry)
136
+ end
137
+ for _k, _v in _exp do
138
+ _callback(_v, _k - 1, _exp)
139
+ end
140
+ -- ▲ ReadonlyArray.forEach ▲
141
+ print("props.renders.names", test)
142
+ end
143
+ end
144
+ local rendered = {}
145
+ local _exp = self.Rendered
146
+ -- ▼ ReadonlyMap.forEach ▼
147
+ local _callback = function(entries)
148
+ -- ▼ ReadonlyMap.forEach ▼
149
+ local _callback_1 = function(entry)
150
+ print("Rendering Entry", entry)
151
+ local _container = entry.container
152
+ table.insert(rendered, _container)
153
+ end
154
+ for _k, _v in entries do
155
+ _callback_1(_v, _k, entries)
156
+ end
157
+ -- ▲ ReadonlyMap.forEach ▲
158
+ end
159
+ for _k, _v in _exp do
160
+ _callback(_v, _k, _exp)
161
+ end
162
+ -- ▲ ReadonlyMap.forEach ▲
163
+ return rendered
164
+ end
165
+ end
166
+ function Renders:getGroupEntries(group)
167
+ local entries = {}
168
+ -- ▼ ReadonlyMap.forEach ▼
169
+ local _callback = function(regGroupEntries, name)
170
+ -- ▼ ReadonlyMap.forEach ▼
171
+ local _callback_1 = function(_, regGroup)
172
+ if group ~= regGroup then
173
+ return nil
174
+ end
175
+ local _entries = entries
176
+ local _name = name
177
+ local _regGroupEntries = regGroupEntries
178
+ _entries[_name] = _regGroupEntries
179
+ end
180
+ for _k, _v in regGroupEntries do
181
+ _callback_1(_v, _k, regGroupEntries)
182
+ end
183
+ -- ▲ ReadonlyMap.forEach ▲
184
+ end
185
+ for _k, _v in AppRegistry do
186
+ _callback(_v, _k, AppRegistry)
187
+ end
188
+ -- ▲ ReadonlyMap.forEach ▲
189
+ return entries
190
+ end
191
+ function Renders:createRender(forge, name, group)
192
+ local entry = getAppEntry(forge, name, group)
193
+ print(entry)
194
+ return nil
195
+ end
196
+ function Renders:getChildren()
197
+ end
198
+ function Renders:initalize(props, target, root)
199
+ if not self.__px then
200
+ local _result = props.config
201
+ if _result ~= nil then
202
+ _result = _result.px.target
203
+ end
204
+ local _result_1 = props.config
205
+ if _result_1 ~= nil then
206
+ _result_1 = _result_1.px.resolution
207
+ end
208
+ local _result_2 = props.config
209
+ if _result_2 ~= nil then
210
+ _result_2 = _result_2.px.minScale
211
+ end
212
+ usePx(_result, _result_1, _result_2)
213
+ self.__px = true
214
+ end
215
+ if target then
216
+ mount(function()
217
+ local _result
218
+ if root then
219
+ _result = root
220
+ else
221
+ local _attributes = table.clone(props)
222
+ setmetatable(_attributes, nil)
223
+ _result = (Vide.jsx("screengui", {
224
+ Name = "App Tree",
225
+ ZIndexBehavior = "Sibling",
226
+ ResetOnSpawn = false,
227
+ }, Vide.jsx(self.Render, _attributes)))
228
+ end
229
+ return _result
230
+ end)
231
+ else
232
+ local _attributes = table.clone(props)
233
+ setmetatable(_attributes, nil)
234
+ return Vide.jsx(self.Render, _attributes)
235
+ end
236
+ end
237
+ end
238
+ return {
239
+ default = Renders,
240
+ }
@@ -0,0 +1,2 @@
1
+ import type AppForge from "../../mount";
2
+ export default function ExclusiveGroupRule(forge: AppForge, name: AppNames, group: AppGroups): void;
@@ -0,0 +1,54 @@
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.Parent, "appRegistry").AppRegistry
6
+ -- Helpers
7
+ local getAppEntry = TS.import(script, script.Parent.Parent.Parent, "helpers", "getAppEntry").default
8
+ local function ExclusiveGroupRule(forge, name, group)
9
+ local entry = getAppEntry(forge, name, group)
10
+ if not entry then
11
+ forge.logger:log("ERROR", `Failed to find app entry for "ExclusiveGroupRule" name {name} group {group} `)
12
+ end
13
+ local entryVisible = forge:getSource(name, group)()
14
+ if not entryVisible then
15
+ return nil
16
+ end
17
+ forge.debug:logTag("rules", name, "Exclusive group activated", group)
18
+ -- ▼ ReadonlyMap.forEach ▼
19
+ local _callback = function(entryMap, entryGroup)
20
+ -- ▼ ReadonlyMap.forEach ▼
21
+ local _callback_1 = function(entry, entryName)
22
+ if name == entryName then
23
+ return nil
24
+ end
25
+ local _result = entry.rules
26
+ if _result ~= nil then
27
+ _result = _result.exclusiveGroup
28
+ end
29
+ if _result ~= entryGroup then
30
+ return nil
31
+ end
32
+ local visible = forge:getSource(entryName)()
33
+ if not visible then
34
+ return nil
35
+ end
36
+ forge.debug:logTag("rules", entryName, "Closing app due to exclusive group", {
37
+ closed = entryName,
38
+ entryGroup = entryGroup,
39
+ })
40
+ forge:close(entryName, entryGroup, false)
41
+ end
42
+ for _k, _v in entryMap do
43
+ _callback_1(_v, _k, entryMap)
44
+ end
45
+ -- ▲ ReadonlyMap.forEach ▲
46
+ end
47
+ for _k, _v in AppRegistry do
48
+ _callback(_v, _k, AppRegistry)
49
+ end
50
+ -- ▲ ReadonlyMap.forEach ▲
51
+ end
52
+ return {
53
+ default = ExclusiveGroupRule,
54
+ }
@@ -0,0 +1,2 @@
1
+ import type AppForge from "../../mount";
2
+ export default function ParentRule(forge: AppForge, name: AppNames, group: AppGroups): void;
@@ -0,0 +1,38 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Types
4
+ -- Helpers
5
+ local getAppSource = TS.import(script, script.Parent.Parent.Parent, "helpers", "getAppSource").default
6
+ local getAppEntry = TS.import(script, script.Parent.Parent.Parent, "helpers", "getAppEntry").default
7
+ local function ParentRule(forge, name, group)
8
+ local entry = getAppEntry(forge, name, group)
9
+ local _result = entry
10
+ if _result ~= nil then
11
+ _result = _result.rules
12
+ if _result ~= nil then
13
+ _result = _result.parent
14
+ end
15
+ end
16
+ if not (_result ~= "" and _result) then
17
+ return nil
18
+ end
19
+ local _exp = forge
20
+ local _exp_1 = entry.rules.parent
21
+ local _condition = entry.rules.parentGroup
22
+ if _condition == nil then
23
+ _condition = "None"
24
+ end
25
+ local parentSource = getAppSource(_exp, _exp_1, _condition)
26
+ if parentSource and parentSource() == false then
27
+ local source = forge:getSource(name, group)
28
+ if not source then
29
+ return forge.logger:log("ERROR", `Failed to get Source for name {name} group {group}`)
30
+ end
31
+ if source() then
32
+ source(false)
33
+ end
34
+ end
35
+ end
36
+ return {
37
+ default = ParentRule,
38
+ }
@@ -2,6 +2,6 @@ import type AppForge from "../mount";
2
2
  import type Types from "../types";
3
3
  export default class Rules {
4
4
  protected processing: Set<string>;
5
- protected renderRules(forge: AppForge, name: AppNames, props: Types.Props.Main): void;
6
- protected checkRules(forge: AppForge, name: AppNames): void;
5
+ protected renderRules(forge: AppForge, name: AppNames, group: AppGroups | undefined, props: Types.Props.Main): void;
6
+ protected checkRules(forge: AppForge, name: AppNames, group: AppGroups): void;
7
7
  }
@@ -2,10 +2,12 @@
2
2
  local TS = _G[script]
3
3
  -- Types
4
4
  -- Components
5
- local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
6
5
  -- Rules
7
- local ExclusiveGroupRule = TS.import(script, script, "exclusiveGroup").default
8
- local ParentRule = TS.import(script, script, "parent").default
6
+ local ExclusiveGroupRule = TS.import(script, script, "check", "exclusiveGroup").default
7
+ local AnchorRule = TS.import(script, script, "render", "anchor").default
8
+ local ParentRule = TS.import(script, script, "check", "parent").default
9
+ -- Helpers
10
+ local getAppEntry = TS.import(script, script.Parent, "helpers", "getAppEntry").default
9
11
  local Rules
10
12
  do
11
13
  Rules = setmetatable({}, {
@@ -21,27 +23,28 @@ do
21
23
  function Rules:constructor()
22
24
  self.processing = {}
23
25
  end
24
- function Rules:renderRules(forge, name, props)
25
- local _name = name
26
- local appClass = AppRegistry[_name]
27
- if not appClass then
28
- error(`renderRules: App "{name}" not registered`, 2)
26
+ function Rules:renderRules(forge, name, group, props)
27
+ if group == nil then
28
+ group = "None"
29
+ end
30
+ local entry = getAppEntry(forge, name, group)
31
+ if not entry then
32
+ error(`renderRules: App Entry name "{name}" group "{group}" not registered`, 2)
29
33
  end
30
- local rules = appClass.rules
34
+ local rules = entry.rules
31
35
  if not rules then
32
36
  return nil
33
37
  end
34
38
  -- Parent Anchor
35
39
  local _condition = rules.parent
36
40
  if _condition ~= "" and _condition then
37
- _condition = not rules.detach
41
+ _condition = not rules.anchor
38
42
  end
39
43
  if _condition ~= "" and _condition then
40
44
  forge.debug:logTag("rules", name, "Applying parent anchor", {
41
45
  parent = rules.parent,
42
46
  })
43
- -- TODO: will be a separate file under ruleEngine
44
- -- forge.anchor(name, rules.parent, props);
47
+ AnchorRule(name, group, props)
45
48
  end
46
49
  -- Index
47
50
  if rules.zIndex ~= nil then
@@ -50,7 +53,7 @@ do
50
53
  -- forge.index(name, rules.zIndex);
51
54
  end
52
55
  end
53
- function Rules:checkRules(forge, name)
56
+ function Rules:checkRules(forge, name, group)
54
57
  local _processing = self.processing
55
58
  local _name = name
56
59
  if _processing[_name] ~= nil then
@@ -62,8 +65,8 @@ do
62
65
  _processing_1[_name_1] = true
63
66
  forge.debug:logTag("rules", name, "Evaluating rules")
64
67
  TS.try(function()
65
- ParentRule(name, forge)
66
- ExclusiveGroupRule(name, forge)
68
+ ParentRule(forge, name, group)
69
+ ExclusiveGroupRule(forge, name, group)
67
70
  end, nil, function()
68
71
  local _processing_2 = self.processing
69
72
  local _name_2 = name
@@ -0,0 +1,2 @@
1
+ import type Types from "../../types";
2
+ export default function anchor(name: AppNames, group: AppGroups | undefined, props: Types.Props.Main): void;
@@ -0,0 +1,11 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ -- Types
3
+ local function anchor(name, group, props)
4
+ if group == nil then
5
+ group = "None"
6
+ end
7
+ -- TODO: FIX THIS TO ANCHOR APP TO PARENT IF HAS ONE WARN IF DOESN'T
8
+ end
9
+ return {
10
+ default = anchor,
11
+ }
package/out/types.d.ts CHANGED
@@ -4,12 +4,7 @@ import type AppForge from "./mount";
4
4
 
5
5
  declare namespace Types {
6
6
  namespace Props {
7
- type Render =
8
- | { name?: AppNames; names?: never; group?: never }
9
- | { names?: AppNames[]; name?: never; group?: never }
10
- | { group?: AppGroups[] | AppGroups; names?: AppNames[]; name?: never }
11
- | { group?: AppGroups[] | AppGroups; name?: AppNames; names?: never }
12
- | { group?: AppGroups[] | AppGroups; names?: never; name?: never };
7
+ type Render = { name?: AppNames; names?: AppNames[]; group?: AppGroups; groups?: AppGroups[] };
13
8
 
14
9
  type Main = {
15
10
  props: AppProps;
@@ -34,23 +29,23 @@ declare namespace Types {
34
29
  type Props<N extends AppNames> = {
35
30
  name: N;
36
31
  visible?: boolean;
37
- renderGroup?: AppGroups;
32
+ group?: AppGroups;
38
33
  rules?: Rules.Generic<N>;
39
34
  };
40
35
 
41
36
  type Static = {
42
- constructor: new (props: Types.Props.Main, name: AppNames) => Args;
37
+ constructor: new (props: Types.Props.Main, name: AppNames, group?: AppGroups) => Args;
43
38
 
44
39
  visible?: boolean;
45
- renderGroup?: AppGroups;
40
+ group?: AppGroups;
46
41
  rules?: Rules.Static;
47
42
  };
48
43
 
49
44
  type Generic<N extends AppNames = AppNames> = {
50
- constructor: new (props: Types.Props.Main, name: AppNames) => Args;
45
+ constructor: new (props: Types.Props.Main, name: AppNames, group?: AppGroups) => Args;
51
46
 
52
47
  visible?: boolean;
53
- renderGroup?: AppGroups;
48
+ group?: AppGroups;
54
49
  rules?: Rules.Generic<N>;
55
50
  };
56
51
  }
@@ -58,12 +53,16 @@ declare namespace Types {
58
53
  namespace Rules {
59
54
  type WithParent<P> = {
60
55
  parent: P;
61
- detach?: boolean;
56
+
57
+ parentGroup?: AppGroups;
58
+ anchor?: boolean;
62
59
  };
63
60
 
64
61
  type WithoutParent = {
65
62
  parent?: never;
66
- detach?: never;
63
+
64
+ parentGroup?: never;
65
+ anchor?: never;
67
66
  };
68
67
 
69
68
  export type Static = {
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@rbxts/app-forge",
3
- "version": "0.7.2-prototype.2",
3
+ "version": "0.7.2-prototype.20",
4
4
  "description": "An App Manager for Vide",
5
5
  "main": "out/init.lua",
6
6
  "types": "out/index.d.ts",
7
7
  "packageManager": "bun@1.3.1",
8
+
8
9
  "scripts": {
9
10
  "build": "rbxtsc",
10
11
  "dev": "rbxtsc -w --type game --rojo test.project.json",
11
12
  "login": "bunx npm login --auth-type=legacy"
12
13
  },
14
+
13
15
  "keywords": [
14
16
  "roblox-ts",
15
17
  "react",
@@ -17,6 +19,7 @@
17
19
  ],
18
20
  "author": "loner1536",
19
21
  "license": "MIT",
22
+
20
23
  "repository": {
21
24
  "type": "git",
22
25
  "url": "https://github.com/Loner1536/AppForge"
@@ -24,15 +27,18 @@
24
27
  "bugs": {
25
28
  "url": "https://github.com/Loner1536/AppForge/issues"
26
29
  },
30
+
27
31
  "files": [
28
32
  "out",
29
33
  "!**/*.tsbuildinfo",
30
34
  "!**/*.spec.lua",
31
35
  "!**/*.spec.d.ts"
32
36
  ],
37
+
33
38
  "publishConfig": {
34
39
  "access": "public"
35
40
  },
41
+
36
42
  "dependencies": {
37
43
  "@rbxts/set-timeout": "^1.1.2",
38
44
  "@rbxts/services": "^1.6.0",
@@ -43,6 +49,7 @@
43
49
  "optional": true
44
50
  }
45
51
  },
52
+
46
53
  "devDependencies": {
47
54
  "@rbxts/compiler-types": "3.0.0-types.0",
48
55
  "@biomejs/biome": "^2.3.7",
@@ -1,7 +0,0 @@
1
- import type Types from "./types";
2
- import Rules from "./ruleEngine";
3
- export default class Renders extends Rules {
4
- private __px;
5
- constructor();
6
- protected initalize(props: Types.Props.Main): void;
7
- }
@@ -1,36 +0,0 @@
1
- -- Compiled with roblox-ts v3.0.0
2
- local TS = _G[script]
3
- -- Packages
4
- -- Types
5
- -- Components
6
- -- Hooks
7
- -- Classes
8
- local Rules = TS.import(script, script.Parent, "ruleEngine").default
9
- local Renders
10
- do
11
- local super = Rules
12
- Renders = setmetatable({}, {
13
- __tostring = function()
14
- return "Renders"
15
- end,
16
- __index = super,
17
- })
18
- Renders.__index = Renders
19
- function Renders.new(...)
20
- local self = setmetatable({}, Renders)
21
- return self:constructor(...) or self
22
- end
23
- function Renders:constructor()
24
- super.constructor(self)
25
- self.__px = false
26
- end
27
- function Renders:initalize(props)
28
- if not self.__px then
29
- self.__px = true
30
- end
31
- props.forge.logger:log("INFO", "Initalized Renders", props.renders)
32
- end
33
- end
34
- return {
35
- default = Renders,
36
- }
@@ -1,2 +0,0 @@
1
- import type AppForge from "../mount";
2
- export default function ExclusiveGroupRule(entry: AppNames, forge: AppForge): void;
@@ -1,54 +0,0 @@
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, "appRegistry").AppRegistry
6
- local function ExclusiveGroupRule(entry, forge)
7
- local _entry = entry
8
- local entryApp = AppRegistry[_entry]
9
- local _group = entryApp
10
- if _group ~= nil then
11
- _group = _group.rules
12
- if _group ~= nil then
13
- _group = _group.exclusiveGroup
14
- end
15
- end
16
- local group = _group
17
- if not (group ~= "" and group) then
18
- return nil
19
- end
20
- local entryVisible = forge:getSource(entry)()
21
- if not entryVisible then
22
- return nil
23
- end
24
- forge.debug:logTag("rules", entry, "Exclusive group activated", group)
25
- -- ▼ ReadonlyMap.forEach ▼
26
- local _callback = function(app, name)
27
- if name == entry then
28
- return nil
29
- end
30
- local _result = app.rules
31
- if _result ~= nil then
32
- _result = _result.exclusiveGroup
33
- end
34
- if _result ~= group then
35
- return nil
36
- end
37
- local visible = forge:getSource(name)()
38
- if not visible then
39
- return nil
40
- end
41
- forge.debug:logTag("rules", entry, "Closing app due to exclusive group", {
42
- closed = name,
43
- group = group,
44
- })
45
- forge:close(name, false)
46
- end
47
- for _k, _v in AppRegistry do
48
- _callback(_v, _k, AppRegistry)
49
- end
50
- -- ▲ ReadonlyMap.forEach ▲
51
- end
52
- return {
53
- default = ExclusiveGroupRule,
54
- }
@@ -1,2 +0,0 @@
1
- import type AppForge from "../mount";
2
- export default function ParentRule(entry: AppNames, forge: AppForge): void;
@@ -1,34 +0,0 @@
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, "appRegistry").AppRegistry
6
- local function ParentRule(entry, forge)
7
- local entryVisible = forge:getSource(entry)()
8
- -- ▼ ReadonlyMap.forEach ▼
9
- local _callback = function(app, name)
10
- local rules = app.rules
11
- if not rules or rules.parent ~= entry then
12
- return nil
13
- end
14
- if name == entry then
15
- return nil
16
- end
17
- local childVisible = forge:getSource(name)()
18
- if entryVisible or not childVisible then
19
- return nil
20
- end
21
- forge.debug:logTag("rules", entry, "Closing child app (parent closed)", {
22
- parent = entry,
23
- child = name,
24
- })
25
- forge:close(name, false)
26
- end
27
- for _k, _v in AppRegistry do
28
- _callback(_v, _k, AppRegistry)
29
- end
30
- -- ▲ ReadonlyMap.forEach ▲
31
- end
32
- return {
33
- default = ParentRule,
34
- }