@rbxts/app-forge 0.6.0 → 0.7.0
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/README.md +334 -149
- package/out/global.d.ts +2 -3
- package/out/index.d.ts +11 -19
- package/out/init.luau +16 -115
- package/out/react/container.d.ts +10 -0
- package/out/{container.luau → react/container.luau} +13 -34
- package/out/react/context.d.ts +7 -0
- package/out/react/context.luau +12 -0
- package/out/{decorator.d.ts → react/decorator.d.ts} +5 -4
- package/out/{decorator.luau → react/decorator.luau} +6 -3
- package/out/react/helpers.d.ts +6 -0
- package/out/react/helpers.luau +74 -0
- package/out/react/hooks/useAppContext.d.ts +5 -0
- package/out/react/hooks/useAppContext.luau +16 -0
- package/out/react/index.d.ts +44 -0
- package/out/react/init.luau +123 -0
- package/out/react/rules/index.d.ts +6 -0
- package/out/react/rules/init.luau +27 -0
- package/out/react/rules/parent.d.ts +2 -0
- package/out/react/rules/parent.luau +42 -0
- package/out/react/types.d.ts +44 -0
- package/out/vide/classes/renders.d.ts +21 -0
- package/out/vide/classes/renders.luau +251 -0
- package/out/vide/classes/rules/exclusiveGroup.d.ts +2 -0
- package/out/vide/classes/rules/exclusiveGroup.luau +47 -0
- package/out/vide/classes/rules/index.d.ts +7 -0
- package/out/vide/classes/rules/init.luau +70 -0
- package/out/vide/classes/rules/parent.d.ts +2 -0
- package/out/vide/classes/rules/parent.luau +29 -0
- package/out/vide/context.d.ts +7 -0
- package/out/vide/context.luau +12 -0
- package/out/vide/decorator.d.ts +13 -0
- package/out/vide/decorator.luau +44 -0
- package/out/vide/hooks/useAppContext.d.ts +5 -0
- package/out/vide/hooks/useAppContext.luau +14 -0
- package/out/vide/index.d.ts +30 -0
- package/out/vide/init.luau +223 -0
- package/out/vide/types.d.ts +85 -0
- package/package.json +15 -16
- package/out/container.d.ts +0 -4
- package/out/helpers.d.ts +0 -2
- package/out/helpers.luau +0 -40
- package/out/rules.d.ts +0 -12
- package/out/rules.luau +0 -198
- package/out/types.d.ts +0 -59
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
-- Services
|
|
4
|
+
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
5
|
+
-- Packages
|
|
6
|
+
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
7
|
+
local apply = _vide.apply
|
|
8
|
+
local create = _vide.create
|
|
9
|
+
local effect = _vide.effect
|
|
10
|
+
local mount = _vide.mount
|
|
11
|
+
local source = _vide.source
|
|
12
|
+
local untrack = _vide.untrack
|
|
13
|
+
-- Classes
|
|
14
|
+
local Renders = TS.import(script, script, "classes", "renders").default
|
|
15
|
+
-- Helpers
|
|
16
|
+
local AppRegistry = TS.import(script, script, "decorator").AppRegistry
|
|
17
|
+
local AppForge
|
|
18
|
+
do
|
|
19
|
+
local super = Renders
|
|
20
|
+
AppForge = setmetatable({}, {
|
|
21
|
+
__tostring = function()
|
|
22
|
+
return "AppForge"
|
|
23
|
+
end,
|
|
24
|
+
__index = super,
|
|
25
|
+
})
|
|
26
|
+
AppForge.__index = AppForge
|
|
27
|
+
function AppForge.new(...)
|
|
28
|
+
local self = setmetatable({}, AppForge)
|
|
29
|
+
return self:constructor(...) or self
|
|
30
|
+
end
|
|
31
|
+
function AppForge:constructor()
|
|
32
|
+
super.constructor(self)
|
|
33
|
+
self.sources = {}
|
|
34
|
+
self.loaded = {}
|
|
35
|
+
self.__px = false
|
|
36
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
37
|
+
local _callback = function(_, name)
|
|
38
|
+
return self:createSource(name)
|
|
39
|
+
end
|
|
40
|
+
for _k, _v in AppRegistry do
|
|
41
|
+
_callback(_v, _k, AppRegistry)
|
|
42
|
+
end
|
|
43
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
44
|
+
end
|
|
45
|
+
function AppForge:createSource(name)
|
|
46
|
+
local _name = name
|
|
47
|
+
local app = AppRegistry[_name]
|
|
48
|
+
if not app then
|
|
49
|
+
error(`App "{name}" not registered`)
|
|
50
|
+
end
|
|
51
|
+
local _sources = self.sources
|
|
52
|
+
local _name_1 = name
|
|
53
|
+
if _sources[_name_1] ~= nil then
|
|
54
|
+
return nil
|
|
55
|
+
end
|
|
56
|
+
local _sources_1 = self.sources
|
|
57
|
+
local _exp = name
|
|
58
|
+
local _condition = app.visible
|
|
59
|
+
if _condition == nil then
|
|
60
|
+
_condition = false
|
|
61
|
+
end
|
|
62
|
+
local _arg1 = source(_condition)
|
|
63
|
+
_sources_1[_exp] = _arg1
|
|
64
|
+
return source
|
|
65
|
+
end
|
|
66
|
+
function AppForge:isLoaded(name)
|
|
67
|
+
local _loaded = self.loaded
|
|
68
|
+
local _name = name
|
|
69
|
+
return _loaded[_name] ~= nil
|
|
70
|
+
end
|
|
71
|
+
function AppForge:bind(name, value)
|
|
72
|
+
if not RunService:IsRunning() then
|
|
73
|
+
local _sources = self.sources
|
|
74
|
+
local _name = name
|
|
75
|
+
local _value = value
|
|
76
|
+
_sources[_name] = _value
|
|
77
|
+
effect(function()
|
|
78
|
+
value()
|
|
79
|
+
untrack(function()
|
|
80
|
+
return self:checkRules(name)
|
|
81
|
+
end)
|
|
82
|
+
end)
|
|
83
|
+
else
|
|
84
|
+
warn("forge.bind is used for studio when game isnt running")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
function AppForge:anchor(name, anchorName, props)
|
|
88
|
+
if name == anchorName then
|
|
89
|
+
error(`Tried to anchor an App to itself`)
|
|
90
|
+
end
|
|
91
|
+
local _anchorName = anchorName
|
|
92
|
+
local anchorApp = AppRegistry[_anchorName]
|
|
93
|
+
if not anchorApp then
|
|
94
|
+
error(`Failed to get class for {anchorName} from AppRegistry for anchor`)
|
|
95
|
+
end
|
|
96
|
+
local _loaded = self.loaded
|
|
97
|
+
local _name = name
|
|
98
|
+
local _render = _loaded[_name]
|
|
99
|
+
if _render ~= nil then
|
|
100
|
+
_render = _render.render
|
|
101
|
+
end
|
|
102
|
+
local render = _render
|
|
103
|
+
if not render then
|
|
104
|
+
error(`Failed to get {name} from this.loaded for anchor to {anchorName}`)
|
|
105
|
+
end
|
|
106
|
+
local anchor = anchorApp.constructor.new(props, anchorName):render()
|
|
107
|
+
for _, children in anchor:GetDescendants() do
|
|
108
|
+
children:Destroy()
|
|
109
|
+
end
|
|
110
|
+
apply(anchor)({
|
|
111
|
+
Name = "Anchor",
|
|
112
|
+
BackgroundTransparency = 1,
|
|
113
|
+
[0] = render,
|
|
114
|
+
})
|
|
115
|
+
local _loaded_1 = self.loaded
|
|
116
|
+
local _name_1 = name
|
|
117
|
+
local prev = _loaded_1[_name_1]
|
|
118
|
+
if not prev then
|
|
119
|
+
error(`Failed to retreive prev loaded data for {name}`)
|
|
120
|
+
end
|
|
121
|
+
apply(prev.container)({
|
|
122
|
+
[0] = anchor,
|
|
123
|
+
})
|
|
124
|
+
local _loaded_2 = self.loaded
|
|
125
|
+
local _exp = name
|
|
126
|
+
local _object = table.clone(prev)
|
|
127
|
+
setmetatable(_object, nil)
|
|
128
|
+
_object.anchor = anchor
|
|
129
|
+
_loaded_2[_exp] = _object
|
|
130
|
+
end
|
|
131
|
+
function AppForge:index(name, index)
|
|
132
|
+
local _loaded = self.loaded
|
|
133
|
+
local _name = name
|
|
134
|
+
local loaded = _loaded[_name]
|
|
135
|
+
if not loaded then
|
|
136
|
+
error(`Failed to retreive loaded data for app: {name}`)
|
|
137
|
+
end
|
|
138
|
+
apply(loaded.container)({
|
|
139
|
+
ZIndex = index,
|
|
140
|
+
})
|
|
141
|
+
end
|
|
142
|
+
function AppForge:getSource(name)
|
|
143
|
+
local _sources = self.sources
|
|
144
|
+
local _name = name
|
|
145
|
+
if not (_sources[_name] ~= nil) then
|
|
146
|
+
self:createSource(name)
|
|
147
|
+
end
|
|
148
|
+
local _sources_1 = self.sources
|
|
149
|
+
local _name_1 = name
|
|
150
|
+
return _sources_1[_name_1]
|
|
151
|
+
end
|
|
152
|
+
function AppForge:set(name, value, rules)
|
|
153
|
+
if rules == nil then
|
|
154
|
+
rules = true
|
|
155
|
+
end
|
|
156
|
+
local _sources = self.sources
|
|
157
|
+
local _name = name
|
|
158
|
+
local src = _sources[_name]
|
|
159
|
+
if not src then
|
|
160
|
+
self:createSource(name)
|
|
161
|
+
local _sources_1 = self.sources
|
|
162
|
+
local _name_1 = name
|
|
163
|
+
src = _sources_1[_name_1]
|
|
164
|
+
end
|
|
165
|
+
if src() == value then
|
|
166
|
+
return nil
|
|
167
|
+
end
|
|
168
|
+
src(value)
|
|
169
|
+
if rules then
|
|
170
|
+
self:checkRules(name)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
function AppForge:open(name, rules)
|
|
174
|
+
if rules == nil then
|
|
175
|
+
rules = true
|
|
176
|
+
end
|
|
177
|
+
self:set(name, true, rules)
|
|
178
|
+
end
|
|
179
|
+
function AppForge:close(name, rules)
|
|
180
|
+
if rules == nil then
|
|
181
|
+
rules = true
|
|
182
|
+
end
|
|
183
|
+
self:set(name, false, rules)
|
|
184
|
+
end
|
|
185
|
+
function AppForge:toggle(name, rules)
|
|
186
|
+
if rules == nil then
|
|
187
|
+
rules = true
|
|
188
|
+
end
|
|
189
|
+
self:set(name, not self:getSource(name)(), rules)
|
|
190
|
+
end
|
|
191
|
+
function AppForge:story(props)
|
|
192
|
+
local Container = create("Frame")({
|
|
193
|
+
Name = "Story Container",
|
|
194
|
+
BackgroundTransparency = 1,
|
|
195
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
196
|
+
Position = UDim2.fromScale(0.5, 0.5),
|
|
197
|
+
Size = UDim2.fromScale(1, 1),
|
|
198
|
+
})
|
|
199
|
+
apply(Container)({
|
|
200
|
+
[0] = self:renderMount(props),
|
|
201
|
+
})
|
|
202
|
+
return Container
|
|
203
|
+
end
|
|
204
|
+
function AppForge:mount(callback, props, target)
|
|
205
|
+
local Container = callback()
|
|
206
|
+
self.innerMount = mount(function()
|
|
207
|
+
apply(Container)({
|
|
208
|
+
[0] = self:renderMount(props),
|
|
209
|
+
})
|
|
210
|
+
return Container
|
|
211
|
+
end, target)
|
|
212
|
+
return self.innerMount
|
|
213
|
+
end
|
|
214
|
+
function AppForge:unMount()
|
|
215
|
+
local _result = self.innerMount
|
|
216
|
+
if _result ~= nil then
|
|
217
|
+
_result()
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
return {
|
|
222
|
+
default = AppForge,
|
|
223
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
import type { Args } from "./decorator";
|
|
3
|
+
import type AppForge from ".";
|
|
4
|
+
|
|
5
|
+
declare namespace Types {
|
|
6
|
+
namespace Props {
|
|
7
|
+
type Render =
|
|
8
|
+
| { name?: AppNames; names?: never; group?: never }
|
|
9
|
+
| { names?: AppNames[]; name?: never; group?: never }
|
|
10
|
+
| { group?: GroupNames[] | GroupNames; names?: AppNames[]; name?: never }
|
|
11
|
+
| { group?: GroupNames[] | GroupNames; name?: AppNames; names?: never }
|
|
12
|
+
| { group?: GroupNames[] | GroupNames; names?: never; name?: never };
|
|
13
|
+
|
|
14
|
+
type Main = {
|
|
15
|
+
props: AppProps;
|
|
16
|
+
forge: AppForge;
|
|
17
|
+
config?: {
|
|
18
|
+
px: {
|
|
19
|
+
target?: GuiObject | Camera;
|
|
20
|
+
resolution?: Vector2;
|
|
21
|
+
minScale?: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
render?: Render;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
type Class = AppProps & {
|
|
28
|
+
forge: AppForge;
|
|
29
|
+
px: typeof import("@rbxts/loners-pretty-vide-utils").px;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
namespace AppRegistry {
|
|
34
|
+
type Props<N extends AppNames> = {
|
|
35
|
+
name: N;
|
|
36
|
+
visible?: boolean;
|
|
37
|
+
renderGroup?: GroupNames;
|
|
38
|
+
rules?: Rules.Generic<N>;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type Static = {
|
|
42
|
+
constructor: new (props: Types.Props.Main, name: AppNames) => Args;
|
|
43
|
+
|
|
44
|
+
visible?: boolean;
|
|
45
|
+
renderGroup?: GroupNames;
|
|
46
|
+
rules?: Rules.Static;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type Generic<N extends AppNames = AppNames> = {
|
|
50
|
+
constructor: new (props: Types.Props.Main, name: AppNames) => Args;
|
|
51
|
+
|
|
52
|
+
visible?: boolean;
|
|
53
|
+
renderGroup?: GroupNames;
|
|
54
|
+
rules?: Rules.Generic<N>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
namespace Rules {
|
|
59
|
+
type WithParent<P> = {
|
|
60
|
+
parent: P;
|
|
61
|
+
detach?: boolean;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
type WithoutParent = {
|
|
65
|
+
parent?: never;
|
|
66
|
+
detach?: never;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type Static = {
|
|
70
|
+
exclusiveGroup?: string;
|
|
71
|
+
index?: number;
|
|
72
|
+
} & (WithParent<string> | WithoutParent);
|
|
73
|
+
|
|
74
|
+
export type Generic<N extends AppNames = AppNames> = {
|
|
75
|
+
exclusiveGroup?: GroupNames;
|
|
76
|
+
index?: number;
|
|
77
|
+
} & (WithParent<Exclude<AppNames, N>> | WithoutParent);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type MainProps = Types.Props.Main;
|
|
82
|
+
export type ClassProps = Types.Props.Class;
|
|
83
|
+
export type RenderProps = Types.Props.Render;
|
|
84
|
+
|
|
85
|
+
export default Types;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/app-forge",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "An App Manager for
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "An App Manager for Vide",
|
|
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",
|
|
@@ -11,7 +12,8 @@
|
|
|
11
12
|
},
|
|
12
13
|
"keywords": [
|
|
13
14
|
"roblox-ts",
|
|
14
|
-
"react"
|
|
15
|
+
"react",
|
|
16
|
+
"vide"
|
|
15
17
|
],
|
|
16
18
|
"author": "loner1536",
|
|
17
19
|
"license": "MIT",
|
|
@@ -22,7 +24,6 @@
|
|
|
22
24
|
"bugs": {
|
|
23
25
|
"url": "https://github.com/Loner1536/AppForge/issues"
|
|
24
26
|
},
|
|
25
|
-
"types": "out/index.d.ts",
|
|
26
27
|
"files": [
|
|
27
28
|
"out",
|
|
28
29
|
"!**/*.tsbuildinfo",
|
|
@@ -32,23 +33,21 @@
|
|
|
32
33
|
"publishConfig": {
|
|
33
34
|
"access": "public"
|
|
34
35
|
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@rbxts/services": "^1.6.0",
|
|
38
|
+
"@rbxts/set-timeout": "^1.1.2"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@rbxts/loners-pretty-react-hooks": "^0.2.9",
|
|
42
|
+
"@rbxts/loners-pretty-vide-utils": "^0.1.7",
|
|
43
|
+
"@rbxts/react": "^17.3.7-ts.1",
|
|
44
|
+
"@rbxts/vide": "^0.5.7"
|
|
45
|
+
},
|
|
35
46
|
"devDependencies": {
|
|
36
47
|
"@biomejs/biome": "^2.3.7",
|
|
37
48
|
"@rbxts/compiler-types": "3.0.0-types.0",
|
|
38
49
|
"@rbxts/types": "^1.0.891",
|
|
39
50
|
"roblox-ts": "3.0.0",
|
|
40
51
|
"typescript": "^5.9.3"
|
|
41
|
-
},
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"@rbxts/vide": "^0.5.7",
|
|
44
|
-
"@rbxts/ripple": "^0.9.3",
|
|
45
|
-
"@rbxts/services": "^1.6.0",
|
|
46
|
-
"@rbxts/set-timeout": "^1.1.2",
|
|
47
|
-
"@rbxts/loners-pretty-vide-utils": "^0.1.4"
|
|
48
|
-
},
|
|
49
|
-
"peerDependencies": {
|
|
50
|
-
"@rbxts/loners-pretty-vide-utils": "*",
|
|
51
|
-
"@rbxts/object-utils": "*",
|
|
52
|
-
"@rbxts/vide": "*"
|
|
53
52
|
}
|
|
54
53
|
}
|
package/out/container.d.ts
DELETED
package/out/helpers.d.ts
DELETED
package/out/helpers.luau
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
-- Packages
|
|
4
|
-
local usePx = TS.import(script, TS.getModule(script, "@rbxts", "loners-pretty-vide-utils").out).usePx
|
|
5
|
-
-- Types
|
|
6
|
-
local __px = false
|
|
7
|
-
local function Render(props)
|
|
8
|
-
local _binding = props
|
|
9
|
-
local config = _binding.config
|
|
10
|
-
local name = _binding.name
|
|
11
|
-
local names = _binding.names
|
|
12
|
-
local forge = _binding.forge
|
|
13
|
-
if not __px then
|
|
14
|
-
local _result = config
|
|
15
|
-
if _result ~= nil then
|
|
16
|
-
_result = _result.px.target
|
|
17
|
-
end
|
|
18
|
-
local _result_1 = config
|
|
19
|
-
if _result_1 ~= nil then
|
|
20
|
-
_result_1 = _result_1.px.resolution
|
|
21
|
-
end
|
|
22
|
-
local _result_2 = config
|
|
23
|
-
if _result_2 ~= nil then
|
|
24
|
-
_result_2 = _result_2.px.minScale
|
|
25
|
-
end
|
|
26
|
-
usePx(_result, _result_1, _result_2)
|
|
27
|
-
__px = true
|
|
28
|
-
else
|
|
29
|
-
warn("Rendering twice making a second px")
|
|
30
|
-
end
|
|
31
|
-
if name ~= "" and name then
|
|
32
|
-
return forge:renderApp(props)
|
|
33
|
-
elseif names then
|
|
34
|
-
return forge:renderApps(props)
|
|
35
|
-
end
|
|
36
|
-
return forge:renderAll(props)
|
|
37
|
-
end
|
|
38
|
-
return {
|
|
39
|
-
Render = Render,
|
|
40
|
-
}
|
package/out/rules.d.ts
DELETED
|
@@ -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
|
-
}
|
package/out/rules.luau
DELETED
|
@@ -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
|
-
}
|
package/out/types.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Types
|
|
2
|
-
import type { Args } from "./decorator";
|
|
3
|
-
import type AppForge from ".";
|
|
4
|
-
|
|
5
|
-
declare namespace Types {
|
|
6
|
-
type AppRegistryProps = {
|
|
7
|
-
name: AppNames[number];
|
|
8
|
-
visible?: boolean;
|
|
9
|
-
rules?: Rules.All;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type NameProps =
|
|
13
|
-
| { name?: AppNames[number]; names?: undefined }
|
|
14
|
-
| { names?: AppNames[number][]; name?: undefined };
|
|
15
|
-
|
|
16
|
-
type MainProps = {
|
|
17
|
-
props: AppProps;
|
|
18
|
-
forge: AppForge;
|
|
19
|
-
config?: {
|
|
20
|
-
px: {
|
|
21
|
-
target?: GuiObject | Camera;
|
|
22
|
-
resolution?: Vector2;
|
|
23
|
-
minScale?: number;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type ClassProps = AppProps & {
|
|
29
|
-
px: typeof import("@rbxts/loners-pretty-vide-utils").px;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type AppRegistry = {
|
|
33
|
-
constructor: new (props: MainProps) => Args;
|
|
34
|
-
visible?: boolean;
|
|
35
|
-
rules?: Rules.All;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
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][];
|
|
42
|
-
type Exclusive = boolean;
|
|
43
|
-
type Layer = number;
|
|
44
|
-
|
|
45
|
-
type All = {
|
|
46
|
-
blockedBy?: BlockedBy;
|
|
47
|
-
exclusive?: Exclusive;
|
|
48
|
-
groups?: Groups;
|
|
49
|
-
blocks?: Blocks;
|
|
50
|
-
layer?: Layer;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type NameProps = Types.NameProps;
|
|
56
|
-
export type MainProps = Types.MainProps;
|
|
57
|
-
export type ClassProps = Types.ClassProps;
|
|
58
|
-
|
|
59
|
-
export default Types;
|