@rbxts/app-forge 0.6.0-alpha.37 → 0.6.0-alpha.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/global.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  declare global {
2
2
  // These will be overridden by the user
3
3
  // They are only placeholders for your build
4
-
5
- type AppGroups = string;
6
4
  type AppNames = string;
7
5
  type AppProps = {};
8
6
  }
@@ -1,10 +1,10 @@
1
1
  import type Types from "./types";
2
2
  export declare function AppContainer(props: Types.NameProps & Types.MainProps): import("@rbxts/react").ReactElement<{
3
- key: any;
3
+ key: string;
4
4
  ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
5
5
  ResetOnSpawn: boolean;
6
6
  }, string | import("@rbxts/react").JSXElementConstructor<any>> | import("@rbxts/react").ReactElement<{
7
- key: any;
7
+ key: string;
8
8
  BackgroundTransparency: number;
9
9
  Size: UDim2;
10
10
  }, string | import("@rbxts/react").JSXElementConstructor<any>>;
@@ -11,7 +11,7 @@ local function createInstance(props)
11
11
  local _binding = props
12
12
  local name = _binding.name
13
13
  local forge = _binding.forge
14
- if not (name ~= 0 and name == name and name ~= "" and name) then
14
+ if not (name ~= "" and name) then
15
15
  error("App name is required to create instance")
16
16
  end
17
17
  local appClass = AppRegistry[name]
@@ -34,7 +34,7 @@ end
34
34
  local function AppContainer(props)
35
35
  local _binding = props
36
36
  local name = _binding.name
37
- if not (name ~= 0 and name == name and name ~= "" and name) then
37
+ if not (name ~= "" and name) then
38
38
  error("App name is required in AppContainer")
39
39
  end
40
40
  local element = createInstance(props)
@@ -29,7 +29,7 @@ do
29
29
  local target = _binding.target
30
30
  local forge = _binding.forge
31
31
  local name = _binding.name
32
- if not (name ~= 0 and name == name and name ~= "" and name) then
32
+ if not (name ~= "" and name) then
33
33
  error("App name is required in Args constructor")
34
34
  end
35
35
  local px = usePx(target)
@@ -60,7 +60,7 @@ local function Render(props)
60
60
  _callback(_v, _k, AppRegistry)
61
61
  end
62
62
  -- ▲ ReadonlyMap.forEach ▲
63
- if name ~= 0 and name == name and name ~= "" and name then
63
+ if name ~= "" and name then
64
64
  return forge:renderApp(props)
65
65
  elseif names then
66
66
  return forge:renderApps(props)
@@ -14,29 +14,29 @@ export default class AppForge {
14
14
  close(name: AppNames): void;
15
15
  toggle(name: AppNames): void;
16
16
  renderApp(props: Types.NameProps & Types.MainProps): React.ReactElement<{
17
- key: any;
17
+ key: string;
18
18
  ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
19
19
  ResetOnSpawn: boolean;
20
20
  }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
21
- key: any;
21
+ key: string;
22
22
  BackgroundTransparency: number;
23
23
  Size: UDim2;
24
24
  }, string | React.JSXElementConstructor<any>>;
25
25
  renderApps(props: Types.NameProps & Types.MainProps): (React.ReactElement<{
26
- key: any;
26
+ key: string;
27
27
  ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
28
28
  ResetOnSpawn: boolean;
29
29
  }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
30
- key: any;
30
+ key: string;
31
31
  BackgroundTransparency: number;
32
32
  Size: UDim2;
33
33
  }, string | React.JSXElementConstructor<any>>)[];
34
34
  renderAll(props: Types.MainProps): (React.ReactElement<{
35
- key: any;
35
+ key: string;
36
36
  ZIndexBehavior: Enum.ZIndexBehavior.Sibling;
37
37
  ResetOnSpawn: boolean;
38
38
  }, string | React.JSXElementConstructor<any>> | React.ReactElement<{
39
- key: any;
39
+ key: string;
40
40
  BackgroundTransparency: number;
41
41
  Size: UDim2;
42
42
  }, string | React.JSXElementConstructor<any>>)[];
@@ -50,9 +50,7 @@ do
50
50
  return _states_1[_name_1][1]
51
51
  end
52
52
  function AppForge:set(name, value)
53
- if not self.rulesManager:applyRules(name, value) then
54
- return nil
55
- end
53
+ self.rulesManager:applyRules(name)
56
54
  local _binds = self.binds
57
55
  local _name = name
58
56
  local _binding = _binds[_name]
@@ -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,27 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ -- Types
4
+ -- Rules
5
+ local ParentRule = TS.import(script, script, "parent").default
6
+ local RulesManager
7
+ do
8
+ RulesManager = setmetatable({}, {
9
+ __tostring = function()
10
+ return "RulesManager"
11
+ end,
12
+ })
13
+ RulesManager.__index = RulesManager
14
+ function RulesManager.new(...)
15
+ local self = setmetatable({}, RulesManager)
16
+ return self:constructor(...) or self
17
+ end
18
+ function RulesManager:constructor(forge)
19
+ self.forge = forge
20
+ end
21
+ function RulesManager:applyRules(name)
22
+ ParentRule(name, self.forge)
23
+ end
24
+ end
25
+ return {
26
+ default = RulesManager,
27
+ }
@@ -0,0 +1,2 @@
1
+ import type AppForge from "..";
2
+ export default function ParentRule(entry: AppNames, forge: AppForge): void;
@@ -0,0 +1,42 @@
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 _binds = forge.binds
20
+ local _entry = entry
21
+ if not _binds[_entry] then
22
+ local _name = name
23
+ table.insert(children, _name)
24
+ end
25
+ end
26
+ end
27
+ for _k, _v in AppRegistry do
28
+ _callback(_v, _k, AppRegistry)
29
+ end
30
+ -- ▲ ReadonlyMap.forEach ▲
31
+ -- ▼ ReadonlyArray.forEach ▼
32
+ local _callback_1 = function(name)
33
+ return forge:close(name)
34
+ end
35
+ for _k, _v in children do
36
+ _callback_1(_v, _k - 1, children)
37
+ end
38
+ -- ▲ ReadonlyArray.forEach ▲
39
+ end
40
+ return {
41
+ default = ParentRule,
42
+ }
@@ -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;
@@ -31,18 +31,8 @@ declare namespace Types {
31
31
  };
32
32
 
33
33
  namespace Rules {
34
- type Groups = AppGroups[number] | "Core" | "Core"[] | AppGroups[number][];
35
- type BlockedBy = AppNames[number] | AppNames[number][];
36
- type Blocks = AppNames[number] | AppNames[number][];
37
- type Exclusive = boolean;
38
- type Layer = number;
39
-
40
34
  type All = {
41
- blockedBy?: BlockedBy;
42
- exclusive?: Exclusive;
43
- groups?: Groups;
44
- blocks?: Blocks;
45
- layer?: Layer;
35
+ parent?: AppNames;
46
36
  };
47
37
  }
48
38
  }
@@ -40,6 +40,10 @@ do
40
40
  end
41
41
  function AppForge:bind(name, value)
42
42
  if not RunService:IsRunning() then
43
+ local _sources = self.sources
44
+ local _name = name
45
+ local _value = value
46
+ _sources[_name] = _value
43
47
  effect(function()
44
48
  return self.rulesManager:applyRules(name)
45
49
  end)
@@ -16,8 +16,12 @@ local function ParentRule(entry, forge)
16
16
  _condition = rules.parent == entry
17
17
  end
18
18
  if _condition ~= "" and _condition then
19
- local _name = name
20
- table.insert(children, _name)
19
+ local _sources = forge.sources
20
+ local _entry = entry
21
+ if not _sources[_entry]() then
22
+ local _name = name
23
+ table.insert(children, _name)
24
+ end
21
25
  end
22
26
  end
23
27
  for _k, _v in AppRegistry do
@@ -37,30 +37,9 @@ declare namespace Types {
37
37
  };
38
38
 
39
39
  namespace Rules {
40
- type BlockedBy = AppNames | AppNames[];
41
- type Blocks = AppNames | AppNames[];
42
- type Exclusive = boolean;
43
- type Layer = number;
44
-
45
- type GroupUnion =
46
- | {
47
- groups?: AppGroups[];
48
- group?: never;
49
- }
50
- | {
51
- groups?: never;
52
- group?: AppGroups | "Core";
53
- };
54
-
55
40
  type All = {
56
- blockedBy?: BlockedBy;
57
- exclusive?: Exclusive;
58
- blocks?: Blocks;
59
- layer?: Layer;
60
-
61
41
  parent?: AppNames;
62
- parents?: AppNames[];
63
- } & GroupUnion;
42
+ };
64
43
  }
65
44
  }
66
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/app-forge",
3
- "version": "0.6.0-alpha.37",
3
+ "version": "0.6.0-alpha.39",
4
4
  "description": "An App Manager for react",
5
5
  "main": "out/init.lua",
6
6
  "types": "out/index.d.ts",
@@ -1,11 +0,0 @@
1
- import AppManager from ".";
2
- export default class RulesManager {
3
- private appManager;
4
- constructor(appManager: AppManager);
5
- applyRules(name: AppNames, value: boolean): boolean;
6
- private inSameGroup;
7
- private blockedBy;
8
- private blocks;
9
- private exclusive;
10
- private layer;
11
- }
@@ -1,195 +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, value)
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 _result = rules
42
- if _result ~= nil then
43
- _result = _result.groups
44
- end
45
- if _result == "Core" then
46
- return true
47
- end
48
- if value then
49
- local allNames = Object.keys(AppRegistry)
50
- -- ▼ ReadonlyArray.forEach ▼
51
- local _callback = function(n)
52
- if not (n ~= "" and n) or n == name then
53
- return nil
54
- end
55
- local _n = n
56
- local otherApp = AppRegistry[_n]
57
- local _result_1 = otherApp
58
- if _result_1 ~= nil then
59
- _result_1 = _result_1.rules
60
- if _result_1 ~= nil then
61
- _result_1 = _result_1.groups
62
- end
63
- end
64
- local groups = if _result_1 ~= 0 and _result_1 == _result_1 and _result_1 ~= "" and _result_1 then asTable(otherApp.rules.groups) else {}
65
- -- ▼ ReadonlyArray.find ▼
66
- local _callback_1 = function(g)
67
- return g == "Core"
68
- end
69
- local _result_2
70
- for _i, _v in groups do
71
- if _callback_1(_v, _i - 1, groups) == true then
72
- _result_2 = _v
73
- break
74
- end
75
- end
76
- -- ▲ ReadonlyArray.find ▲
77
- if _result_2 ~= 0 and _result_2 == _result_2 and _result_2 ~= "" and _result_2 then
78
- return nil
79
- end
80
- if self.appManager:getState(n) then
81
- self.appManager:set(n, false)
82
- end
83
- end
84
- for _k, _v in allNames do
85
- _callback(_v, _k - 1, allNames)
86
- end
87
- -- ▲ ReadonlyArray.forEach ▲
88
- end
89
- if not rules then
90
- return true
91
- end
92
- local _condition = value
93
- if _condition then
94
- _condition = rules.blockedBy
95
- if _condition ~= 0 and _condition == _condition and _condition ~= "" and _condition then
96
- _condition = not self:blockedBy(name, rules.blockedBy)
97
- end
98
- end
99
- if _condition ~= 0 and _condition == _condition and _condition ~= "" and _condition then
100
- return false
101
- end
102
- local _value = value and rules.blocks
103
- if _value ~= 0 and _value == _value and _value ~= "" and _value then
104
- self:blocks(name, rules.blocks)
105
- end
106
- if value and rules.layer ~= nil then
107
- self:layer(name, rules.layer)
108
- end
109
- if value and rules.exclusive then
110
- self:exclusive(name)
111
- end
112
- return true
113
- end
114
- function RulesManager:inSameGroup(a, b)
115
- local _a = a
116
- local appA = AppRegistry[_a]
117
- local _b = b
118
- local appB = AppRegistry[_b]
119
- if not appA or not appB then
120
- return false
121
- end
122
- local _result = appA.rules
123
- if _result ~= nil then
124
- _result = _result.groups
125
- end
126
- local _condition = _result
127
- if _condition == nil then
128
- _condition = {}
129
- end
130
- local groupsA = asTable(_condition)
131
- local _result_1 = appB.rules
132
- if _result_1 ~= nil then
133
- _result_1 = _result_1.groups
134
- end
135
- local _condition_1 = _result_1
136
- if _condition_1 == nil then
137
- _condition_1 = {}
138
- end
139
- local groupsB = asTable(_condition_1)
140
- for i = 1, #groupsA do
141
- for j = 1, #groupsB do
142
- if groupsA[i + 1] == groupsB[j + 1] then
143
- return true
144
- end
145
- end
146
- end
147
- return false
148
- end
149
- function RulesManager:blockedBy(name, rule)
150
- local blockers = asTable(rule)
151
- for i = 1, #blockers do
152
- local blocker = blockers[i + 1]
153
- if self:inSameGroup(name, blocker) or not (blocker ~= 0 and blocker == blocker and blocker ~= "" and blocker) then
154
- continue
155
- end
156
- if self.appManager:getState(blocker) then
157
- return false
158
- end
159
- end
160
- return true
161
- end
162
- function RulesManager:blocks(name, rule)
163
- local blocked = asTable(rule)
164
- for i = 1, #blocked do
165
- local b = blocked[i + 1]
166
- if self:inSameGroup(name, b) or not (b ~= 0 and b == b and b ~= "" and b) then
167
- continue
168
- end
169
- if self.appManager:getState(b) then
170
- self.appManager:set(b, false)
171
- end
172
- end
173
- end
174
- function RulesManager:exclusive(name)
175
- local names = Object.keys(AppRegistry)
176
- for i = 1, #names do
177
- local other = names[i + 1]
178
- if other == name or not (other ~= "" and other) then
179
- continue
180
- end
181
- if self:inSameGroup(name, other) then
182
- continue
183
- end
184
- if self.appManager:getState(other) then
185
- self.appManager:set(other, false)
186
- end
187
- end
188
- end
189
- function RulesManager:layer(_name, _layer)
190
- -- TODO: implement priority / layering
191
- end
192
- end
193
- return {
194
- default = RulesManager,
195
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- -- Compiled with roblox-ts v3.0.0
2
- return nil