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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import Vide from "@rbxts/vide";
2
2
  import type Types from "./types";
3
3
  import type AppForge from "./mount";
4
4
  export declare const AppRegistry: Map<string, Types.AppRegistry.Static>;
5
+ export declare const AppsLoaded: Map<`${string}-${string}`, boolean>;
5
6
  /**
6
7
  * Registers a Vide App with AppForge.
7
8
  *
@@ -8,6 +8,7 @@ local px = TS.import(script, script.Parent, "hooks", "usePx").px
8
8
  local Logger = TS.import(script, script.Parent, "logger").default
9
9
  local logger = Logger.new("AppRegistry")
10
10
  local AppRegistry = {}
11
+ local AppsLoaded = {}
11
12
  --[[
12
13
  *
13
14
  * Registers a Vide App with AppForge.
@@ -17,8 +18,12 @@ local AppRegistry = {}
17
18
  ]]
18
19
  local function App(props)
19
20
  return function(constructor)
20
- local _name = props.name
21
- if AppRegistry[_name] ~= nil then
21
+ local _condition = props.renderGroup
22
+ if _condition == nil then
23
+ _condition = "None"
24
+ end
25
+ local _arg0 = `{_condition}-{props.name}`
26
+ if AppRegistry[_arg0] ~= nil then
22
27
  logger:log("ERROR", "Duplicate App name detected", {
23
28
  name = props.name,
24
29
  })
@@ -29,14 +34,18 @@ local function App(props)
29
34
  logger:log("ERROR", "Attempted to register App without a name", props)
30
35
  error("App registration failed: missing app name", 2)
31
36
  end
32
- local _name_1 = props.name
37
+ local _condition_1 = props.renderGroup
38
+ if _condition_1 == nil then
39
+ _condition_1 = "None"
40
+ end
41
+ local _arg0_1 = `{_condition_1}-{props.name}`
33
42
  local _arg1 = {
34
43
  constructor = constructor,
35
44
  renderGroup = props.renderGroup,
36
45
  visible = props.visible,
37
46
  rules = props.rules,
38
47
  }
39
- AppRegistry[_name_1] = _arg1
48
+ AppRegistry[_arg0_1] = _arg1
40
49
  return constructor
41
50
  end
42
51
  end
@@ -71,5 +80,6 @@ end
71
80
  return {
72
81
  App = App,
73
82
  AppRegistry = AppRegistry,
83
+ AppsLoaded = AppsLoaded,
74
84
  Args = Args,
75
85
  }
package/out/mount.d.ts CHANGED
@@ -1,24 +1,17 @@
1
1
  import Vide from "@rbxts/vide";
2
- import Renders from "./renderManager";
2
+ import Renders from "./renders";
3
3
  import Debugger from "./debugger";
4
4
  import Logger from "./logger";
5
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 sources;
11
+ private innerMount?;
18
12
  constructor();
19
- protected createSource(name: AppNames): void;
13
+ private createSource;
20
14
  getSource(name: AppNames): Vide.Source<boolean>;
21
- isLoaded(name: AppNames): boolean;
22
15
  bind(name: AppNames, value: Vide.Source<boolean>): void;
23
16
  set(name: AppNames, value: boolean, rules?: boolean): void;
24
17
  open(name: AppNames, rules?: boolean): void;
@@ -28,6 +21,6 @@ export default class AppForge extends Renders {
28
21
  render?: Types.Props.Render;
29
22
  minScale?: number;
30
23
  }): Frame;
31
- mount(node: Vide.Node, props: Types.Props.Main, target: Instance): Destructor;
24
+ mount(node: Vide.Node, props: Exclude<Types.Props.Main, "forge">, target: Instance): Destructor;
32
25
  }
33
26
  export {};
package/out/mount.luau CHANGED
@@ -12,7 +12,7 @@ local mount = _vide.mount
12
12
  local source = _vide.source
13
13
  local untrack = _vide.untrack
14
14
  -- Classes
15
- local Renders = TS.import(script, script.Parent, "renderManager").default
15
+ local Renders = TS.import(script, script.Parent, "renders").default
16
16
  -- Helpers
17
17
  local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
18
18
  local Debugger = TS.import(script, script.Parent, "debugger").default
@@ -38,7 +38,6 @@ do
38
38
  return self.logger:log(level, msg, data, trace)
39
39
  end)
40
40
  self.sources = {}
41
- self.loaded = {}
42
41
  -- ▼ ReadonlyMap.forEach ▼
43
42
  local _callback = function(_, name)
44
43
  return self:createSource(name)
@@ -49,8 +48,8 @@ do
49
48
  -- ▲ ReadonlyMap.forEach ▲
50
49
  end
51
50
  function AppForge:createSource(name)
52
- local _name = name
53
- local app = AppRegistry[_name]
51
+ local _arg0 = `-{name}`
52
+ local app = AppRegistry[_arg0]
54
53
  if not app then
55
54
  self.logger:log("ERROR", "App not registered while creating source", {
56
55
  name = name,
@@ -58,8 +57,8 @@ do
58
57
  return nil
59
58
  end
60
59
  local _sources = self.sources
61
- local _name_1 = name
62
- if _sources[_name_1] ~= nil then
60
+ local _name = name
61
+ if _sources[_name] ~= nil then
63
62
  return nil
64
63
  end
65
64
  local _debug = self.debug
@@ -95,11 +94,6 @@ do
95
94
  end
96
95
  return src
97
96
  end
98
- function AppForge:isLoaded(name)
99
- local _loaded = self.loaded
100
- local _name = name
101
- return _loaded[_name] ~= nil
102
- end
103
97
  function AppForge:bind(name, value)
104
98
  if not RunService:IsRunning() then
105
99
  self.debug:logTag("state", name, "Binding external visibility source")
@@ -229,9 +223,15 @@ do
229
223
  function AppForge:mount(node, props, target)
230
224
  self.debug:logTag("lifecycle", "mount", "Mounting AppForge")
231
225
  self.innerMount = mount(function()
232
- apply(node)({
233
- [0] = self:initalize(props),
234
- })
226
+ local _fn = apply(node)
227
+ local _object = {}
228
+ local _left = 0
229
+ local _self = self
230
+ local _object_1 = table.clone(props)
231
+ setmetatable(_object_1, nil)
232
+ _object_1.forge = self
233
+ _object[_left] = _self:initalize(_object_1)
234
+ _fn(_object)
235
235
  return node
236
236
  end, target)
237
237
  return self.innerMount
@@ -3,5 +3,6 @@ import Rules from "./ruleEngine";
3
3
  export default class Renders extends Rules {
4
4
  private __px;
5
5
  constructor();
6
+ private render;
6
7
  protected initalize(props: Types.Props.Main): void;
7
8
  }
@@ -0,0 +1,66 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Packages
4
+ -- Types
5
+ -- Components
6
+ -- Hooks
7
+ local usePx = TS.import(script, script.Parent, "hooks", "usePx").usePx
8
+ -- Classes
9
+ local Rules = TS.import(script, script.Parent, "ruleEngine").default
10
+ local Renders
11
+ do
12
+ local super = Rules
13
+ Renders = setmetatable({}, {
14
+ __tostring = function()
15
+ return "Renders"
16
+ end,
17
+ __index = super,
18
+ })
19
+ Renders.__index = Renders
20
+ function Renders.new(...)
21
+ local self = setmetatable({}, Renders)
22
+ return self:constructor(...) or self
23
+ end
24
+ function Renders:constructor()
25
+ super.constructor(self)
26
+ self.__px = false
27
+ end
28
+ function Renders:render(name, names, group)
29
+ print(name, names, group)
30
+ end
31
+ function Renders:initalize(props)
32
+ if not self.__px then
33
+ local _result = props.config
34
+ if _result ~= nil then
35
+ _result = _result.px.target
36
+ end
37
+ local _result_1 = props.config
38
+ if _result_1 ~= nil then
39
+ _result_1 = _result_1.px.resolution
40
+ end
41
+ local _result_2 = props.config
42
+ if _result_2 ~= nil then
43
+ _result_2 = _result_2.px.minScale
44
+ end
45
+ usePx(_result, _result_1, _result_2)
46
+ self.__px = true
47
+ end
48
+ local _self = self
49
+ local _result = props.renders
50
+ if _result ~= nil then
51
+ _result = _result.name
52
+ end
53
+ local _result_1 = props.renders
54
+ if _result_1 ~= nil then
55
+ _result_1 = _result_1.names
56
+ end
57
+ local _result_2 = props.renders
58
+ if _result_2 ~= nil then
59
+ _result_2 = _result_2.group
60
+ end
61
+ _self:render(_result, _result_1, _result_2)
62
+ end
63
+ end
64
+ return {
65
+ default = Renders,
66
+ }
@@ -0,0 +1,2 @@
1
+ import type AppForge from "../../mount";
2
+ export default function ExclusiveGroupRule(name: AppNames, forge: AppForge): void;
@@ -2,10 +2,10 @@
2
2
  local TS = _G[script]
3
3
  -- Types
4
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]
5
+ local AppRegistry = TS.import(script, script.Parent.Parent.Parent, "appRegistry").AppRegistry
6
+ local function ExclusiveGroupRule(name, forge)
7
+ local _name = name
8
+ local entryApp = AppRegistry[_name]
9
9
  local _group = entryApp
10
10
  if _group ~= nil then
11
11
  _group = _group.rules
@@ -17,14 +17,14 @@ local function ExclusiveGroupRule(entry, forge)
17
17
  if not (group ~= "" and group) then
18
18
  return nil
19
19
  end
20
- local entryVisible = forge:getSource(entry)()
20
+ local entryVisible = forge:getSource(name)()
21
21
  if not entryVisible then
22
22
  return nil
23
23
  end
24
- forge.debug:logTag("rules", entry, "Exclusive group activated", group)
24
+ forge.debug:logTag("rules", name, "Exclusive group activated", group)
25
25
  -- ▼ ReadonlyMap.forEach ▼
26
26
  local _callback = function(app, name)
27
- if name == entry then
27
+ if name == name then
28
28
  return nil
29
29
  end
30
30
  local _result = app.rules
@@ -38,7 +38,7 @@ local function ExclusiveGroupRule(entry, forge)
38
38
  if not visible then
39
39
  return nil
40
40
  end
41
- forge.debug:logTag("rules", entry, "Closing app due to exclusive group", {
41
+ forge.debug:logTag("rules", name, "Closing app due to exclusive group", {
42
42
  closed = name,
43
43
  group = group,
44
44
  })
@@ -0,0 +1,2 @@
1
+ import type AppForge from "../../mount";
2
+ export default function ParentRule(name: AppNames, forge: AppForge): void;
@@ -0,0 +1,37 @@
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
+ local function ParentRule(name, forge)
7
+ local _name = name
8
+ local entry = AppRegistry[_name]
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 _forge = forge
20
+ local _result_1 = entry
21
+ if _result_1 ~= nil then
22
+ _result_1 = _result_1.rules
23
+ if _result_1 ~= nil then
24
+ _result_1 = _result_1.parent
25
+ end
26
+ end
27
+ local parentSource = _forge:getSource(_result_1)
28
+ if not parentSource() then
29
+ local source = forge:getSource(name)
30
+ if source() then
31
+ source(false)
32
+ end
33
+ end
34
+ end
35
+ return {
36
+ default = ParentRule,
37
+ }
@@ -4,8 +4,9 @@ local TS = _G[script]
4
4
  -- Components
5
5
  local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
6
6
  -- Rules
7
- local ExclusiveGroupRule = TS.import(script, script, "exclusiveGroup").default
8
- local ParentRule = TS.import(script, script, "parent").default
7
+ local ExclusiveGroupRule = TS.import(script, script, "check", "exclusiveGroup").default
8
+ local ParentRule = TS.import(script, script, "check", "parent").default
9
+ local AnchorRule = TS.import(script, script, "render", "anchor").default
9
10
  local Rules
10
11
  do
11
12
  Rules = setmetatable({}, {
@@ -34,14 +35,13 @@ do
34
35
  -- Parent Anchor
35
36
  local _condition = rules.parent
36
37
  if _condition ~= "" and _condition then
37
- _condition = not rules.detach
38
+ _condition = not rules.anchor
38
39
  end
39
40
  if _condition ~= "" and _condition then
40
41
  forge.debug:logTag("rules", name, "Applying parent anchor", {
41
42
  parent = rules.parent,
42
43
  })
43
- -- TODO: will be a separate file under ruleEngine
44
- -- forge.anchor(name, rules.parent, props);
44
+ AnchorRule(name, props)
45
45
  end
46
46
  -- Index
47
47
  if rules.zIndex ~= nil then
@@ -0,0 +1,2 @@
1
+ import type Types from "../../types";
2
+ export default function anchor(name: AppNames, props: Types.Props.Main): 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.Parent, "appRegistry")
6
+ local AppRegistry = _appRegistry.AppRegistry
7
+ local AppsLoaded = _appRegistry.AppsLoaded
8
+ local function anchor(name, props)
9
+ local _binding = props
10
+ local forge = _binding.forge
11
+ local _name = name
12
+ local app = AppRegistry[_name]
13
+ local _result = app
14
+ if _result ~= nil then
15
+ _result = _result.renderGroup
16
+ end
17
+ local _condition = _result
18
+ if _condition == nil then
19
+ _condition = "None"
20
+ end
21
+ local _arg0 = `{_condition}-{name}`
22
+ local loaded = AppsLoaded[_arg0]
23
+ local _result_1 = app
24
+ if _result_1 ~= nil then
25
+ _result_1 = _result_1.rules
26
+ if _result_1 ~= nil then
27
+ _result_1 = _result_1.parent
28
+ end
29
+ end
30
+ local parentApp = AppRegistry[_result_1]
31
+ if not parentApp then
32
+ forge.debug:logTag("rules", name, `Has no Parent to Anchor to, Remove the Anchor For {name}`)
33
+ end
34
+ print(`App: {app} \n Loaded: {loaded} \n parentApp: {parentApp}`)
35
+ end
36
+ return {
37
+ default = anchor,
38
+ }
package/out/types.d.ts CHANGED
@@ -58,12 +58,12 @@ declare namespace Types {
58
58
  namespace Rules {
59
59
  type WithParent<P> = {
60
60
  parent: P;
61
- detach?: boolean;
61
+ anchor?: boolean;
62
62
  };
63
63
 
64
64
  type WithoutParent = {
65
65
  parent?: never;
66
- detach?: never;
66
+ anchor?: never;
67
67
  };
68
68
 
69
69
  export type Static = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/app-forge",
3
- "version": "0.7.2-prototype.2",
3
+ "version": "0.7.2-prototype.3",
4
4
  "description": "An App Manager for Vide",
5
5
  "main": "out/init.lua",
6
6
  "types": "out/index.d.ts",
@@ -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,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
- }