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

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(props: Exclude<Types.Props.Main, "forge">, target: Instance, root?: () => GuiObject | Instance): Destructor | undefined;
32
25
  }
33
26
  export {};
package/out/mount.luau CHANGED
@@ -8,11 +8,10 @@ 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
11
  local source = _vide.source
13
12
  local untrack = _vide.untrack
14
13
  -- Classes
15
- local Renders = TS.import(script, script.Parent, "renderManager").default
14
+ local Renders = TS.import(script, script.Parent, "renders").default
16
15
  -- Helpers
17
16
  local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
18
17
  local Debugger = TS.import(script, script.Parent, "debugger").default
@@ -38,7 +37,6 @@ do
38
37
  return self.logger:log(level, msg, data, trace)
39
38
  end)
40
39
  self.sources = {}
41
- self.loaded = {}
42
40
  -- ▼ ReadonlyMap.forEach ▼
43
41
  local _callback = function(_, name)
44
42
  return self:createSource(name)
@@ -49,8 +47,8 @@ do
49
47
  -- ▲ ReadonlyMap.forEach ▲
50
48
  end
51
49
  function AppForge:createSource(name)
52
- local _name = name
53
- local app = AppRegistry[_name]
50
+ local _arg0 = `-{name}`
51
+ local app = AppRegistry[_arg0]
54
52
  if not app then
55
53
  self.logger:log("ERROR", "App not registered while creating source", {
56
54
  name = name,
@@ -58,8 +56,8 @@ do
58
56
  return nil
59
57
  end
60
58
  local _sources = self.sources
61
- local _name_1 = name
62
- if _sources[_name_1] ~= nil then
59
+ local _name = name
60
+ if _sources[_name] ~= nil then
63
61
  return nil
64
62
  end
65
63
  local _debug = self.debug
@@ -95,11 +93,6 @@ do
95
93
  end
96
94
  return src
97
95
  end
98
- function AppForge:isLoaded(name)
99
- local _loaded = self.loaded
100
- local _name = name
101
- return _loaded[_name] ~= nil
102
- end
103
96
  function AppForge:bind(name, value)
104
97
  if not RunService:IsRunning() then
105
98
  self.debug:logTag("state", name, "Binding external visibility source")
@@ -226,14 +219,13 @@ do
226
219
  _fn(_object)
227
220
  return Container
228
221
  end
229
- function AppForge:mount(node, props, target)
222
+ function AppForge:mount(props, target, root)
230
223
  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)
224
+ local _self = self
225
+ local _object = table.clone(props)
226
+ setmetatable(_object, nil)
227
+ _object.forge = self
228
+ _self:initalize(_object, target, root)
237
229
  return self.innerMount
238
230
  end
239
231
  end
@@ -0,0 +1,9 @@
1
+ import Vide from "@rbxts/vide";
2
+ import type Types from "./types";
3
+ import Rules from "./ruleEngine";
4
+ export default class Renders extends Rules {
5
+ private __px;
6
+ constructor();
7
+ private Render;
8
+ protected initalize(props: Types.Props.Main, target?: GuiObject | Instance, root?: () => GuiObject | Instance): Vide.Node;
9
+ }
@@ -0,0 +1,70 @@
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
+ -- Hooks
10
+ local usePx = TS.import(script, script.Parent, "hooks", "usePx").usePx
11
+ -- Classes
12
+ local Rules = TS.import(script, script.Parent, "ruleEngine").default
13
+ local Renders
14
+ do
15
+ local super = Rules
16
+ Renders = setmetatable({}, {
17
+ __tostring = function()
18
+ return "Renders"
19
+ end,
20
+ __index = super,
21
+ })
22
+ Renders.__index = Renders
23
+ function Renders.new(...)
24
+ local self = setmetatable({}, Renders)
25
+ return self:constructor(...) or self
26
+ end
27
+ function Renders:constructor()
28
+ super.constructor(self)
29
+ self.__px = false
30
+ end
31
+ function Renders:Render(props)
32
+ print(props)
33
+ end
34
+ function Renders:initalize(props, target, root)
35
+ if not self.__px then
36
+ local _result = props.config
37
+ if _result ~= nil then
38
+ _result = _result.px.target
39
+ end
40
+ local _result_1 = props.config
41
+ if _result_1 ~= nil then
42
+ _result_1 = _result_1.px.resolution
43
+ end
44
+ local _result_2 = props.config
45
+ if _result_2 ~= nil then
46
+ _result_2 = _result_2.px.minScale
47
+ end
48
+ usePx(_result, _result_1, _result_2)
49
+ self.__px = true
50
+ end
51
+ if target then
52
+ mount(if root then root else function()
53
+ local _attributes = table.clone(props)
54
+ setmetatable(_attributes, nil)
55
+ return Vide.jsx("screengui", {
56
+ Name = "App Tree",
57
+ ZIndexBehavior = "Sibling",
58
+ ResetOnSpawn = false,
59
+ }, Vide.jsx(self.Render, _attributes))
60
+ end, target)
61
+ else
62
+ local _attributes = table.clone(props)
63
+ setmetatable(_attributes, nil)
64
+ return Vide.jsx(self.Render, _attributes)
65
+ end
66
+ end
67
+ end
68
+ return {
69
+ default = Renders,
70
+ }
@@ -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.4",
4
4
  "description": "An App Manager for Vide",
5
5
  "main": "out/init.lua",
6
6
  "types": "out/index.d.ts",
@@ -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,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
- }