@rbxts/app-forge 0.7.2-alpha.3 → 0.7.2-alpha.30
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 +86 -372
- package/out/{vide/decorator.d.ts → appRegistry.d.ts} +1 -1
- package/out/{vide/decorator.luau → appRegistry.luau} +1 -7
- package/out/{vide/context.d.ts → context.d.ts} +1 -1
- package/out/global.d.ts +1 -1
- package/out/{vide/hooks → hooks}/useAppContext.d.ts +1 -1
- package/out/{vide/hooks → hooks}/useAppContext.luau +1 -1
- package/out/{vide/hooks → hooks}/useEventListener.luau +1 -1
- package/out/{vide/hooks → hooks}/usePx.luau +2 -2
- package/out/index.d.ts +5 -11
- package/out/init.luau +6 -14
- package/out/{vide/index.d.ts → mount.d.ts} +8 -4
- package/out/{vide/init.luau → mount.luau} +63 -19
- package/out/renderManager.d.ts +32 -0
- package/out/{vide/classes/renders.luau → renderManager.luau} +107 -39
- package/out/{vide/classes/rules → ruleEngine}/exclusiveGroup.d.ts +1 -1
- package/out/{vide/classes/rules → ruleEngine}/exclusiveGroup.luau +1 -1
- package/out/ruleEngine/index.d.ts +7 -0
- package/out/{vide/classes/rules → ruleEngine}/init.luau +12 -12
- package/out/{react/rules → ruleEngine}/parent.d.ts +1 -1
- package/out/{vide/classes/rules → ruleEngine}/parent.luau +2 -1
- package/out/{vide/types.d.ts → types.d.ts} +12 -12
- package/package.json +4 -10
- package/out/react/container.d.ts +0 -10
- package/out/react/container.luau +0 -60
- package/out/react/context.d.ts +0 -7
- package/out/react/context.luau +0 -12
- package/out/react/decorator.d.ts +0 -14
- package/out/react/decorator.luau +0 -51
- package/out/react/helpers.d.ts +0 -6
- package/out/react/helpers.luau +0 -74
- package/out/react/hooks/useAppContext.d.ts +0 -5
- package/out/react/hooks/useAppContext.luau +0 -16
- package/out/react/hooks/usePx.d.ts +0 -15
- package/out/react/hooks/usePx.luau +0 -117
- package/out/react/index.d.ts +0 -44
- package/out/react/init.luau +0 -123
- package/out/react/rules/index.d.ts +0 -6
- package/out/react/rules/init.luau +0 -27
- package/out/react/rules/parent.luau +0 -42
- package/out/react/types.d.ts +0 -44
- package/out/vide/classes/renders.d.ts +0 -25
- package/out/vide/classes/rules/index.d.ts +0 -7
- package/out/vide/classes/rules/parent.d.ts +0 -2
- package/out/vide/debug/index.d.ts +0 -3
- package/out/vide/debug/init.luau +0 -8
- /package/out/{vide/context.luau → context.luau} +0 -0
- /package/out/{vide/debug/debugger.d.ts → debugger.d.ts} +0 -0
- /package/out/{vide/debug/debugger.luau → debugger.luau} +0 -0
- /package/out/{vide/hooks → hooks}/useEventListener.d.ts +0 -0
- /package/out/{vide/hooks → hooks}/usePx.d.ts +0 -0
- /package/out/{vide/debug/logger.d.ts → logger.d.ts} +0 -0
- /package/out/{vide/debug/logger.luau → logger.luau} +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Vide from "@rbxts/vide";
|
|
2
|
-
import Renders from "./
|
|
2
|
+
import Renders from "./renderManager";
|
|
3
|
+
import Debugger from "./debugger";
|
|
4
|
+
import Logger from "./logger";
|
|
3
5
|
import Types from "./types";
|
|
4
|
-
import { Logger, Debugger } from "./debug";
|
|
5
6
|
type Destructor = () => void;
|
|
6
7
|
type Loaded = {
|
|
7
8
|
container: Vide.Node;
|
|
@@ -26,8 +27,11 @@ export default class AppForge extends Renders {
|
|
|
26
27
|
open(name: AppNames, rules?: boolean): void;
|
|
27
28
|
close(name: AppNames, rules?: boolean): void;
|
|
28
29
|
toggle(name: AppNames, rules?: boolean): void;
|
|
29
|
-
story(props:
|
|
30
|
-
|
|
30
|
+
story(props: AppProps, target: GuiObject, conf?: {
|
|
31
|
+
render?: Types.Props.Render;
|
|
32
|
+
minScale?: number;
|
|
33
|
+
}): Frame;
|
|
34
|
+
mount(node: Vide.Node, props: Types.Props.Main, target: Instance): Destructor;
|
|
31
35
|
unMount(): void;
|
|
32
36
|
}
|
|
33
37
|
export {};
|
|
@@ -4,6 +4,7 @@ local TS = _G[script]
|
|
|
4
4
|
local RunService = TS.import(script, TS.getModule(script, "@rbxts", "services")).RunService
|
|
5
5
|
-- Packages
|
|
6
6
|
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
7
|
+
local Vide = _vide
|
|
7
8
|
local apply = _vide.apply
|
|
8
9
|
local create = _vide.create
|
|
9
10
|
local effect = _vide.effect
|
|
@@ -11,13 +12,11 @@ local mount = _vide.mount
|
|
|
11
12
|
local source = _vide.source
|
|
12
13
|
local untrack = _vide.untrack
|
|
13
14
|
-- Classes
|
|
14
|
-
local Renders = TS.import(script, script, "
|
|
15
|
+
local Renders = TS.import(script, script.Parent, "renderManager").default
|
|
15
16
|
-- Helpers
|
|
16
|
-
local AppRegistry = TS.import(script, script, "
|
|
17
|
-
|
|
18
|
-
local
|
|
19
|
-
local Logger = _debug.Logger
|
|
20
|
-
local Debugger = _debug.Debugger
|
|
17
|
+
local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
|
|
18
|
+
local Debugger = TS.import(script, script.Parent, "debugger").default
|
|
19
|
+
local Logger = TS.import(script, script.Parent, "logger").default
|
|
21
20
|
local AppForge
|
|
22
21
|
do
|
|
23
22
|
local super = Renders
|
|
@@ -64,7 +63,7 @@ do
|
|
|
64
63
|
if _sources[_name_1] ~= nil then
|
|
65
64
|
return nil
|
|
66
65
|
end
|
|
67
|
-
local
|
|
66
|
+
local _debug = self.debug
|
|
68
67
|
local _exp = name
|
|
69
68
|
local _object = {}
|
|
70
69
|
local _left = "default"
|
|
@@ -73,7 +72,7 @@ do
|
|
|
73
72
|
_condition = false
|
|
74
73
|
end
|
|
75
74
|
_object[_left] = _condition
|
|
76
|
-
|
|
75
|
+
_debug:logTag("state", _exp, "Creating visibility source", _object)
|
|
77
76
|
local _sources_1 = self.sources
|
|
78
77
|
local _exp_1 = name
|
|
79
78
|
local _condition_1 = app.visible
|
|
@@ -109,11 +108,27 @@ do
|
|
|
109
108
|
local _name = name
|
|
110
109
|
local _value = value
|
|
111
110
|
_sources[_name] = _value
|
|
111
|
+
local prev
|
|
112
|
+
local log = function()
|
|
113
|
+
return self.debug:logTag("state", name, "Visibility changed", {
|
|
114
|
+
from = prev,
|
|
115
|
+
to = value,
|
|
116
|
+
})
|
|
117
|
+
end
|
|
118
|
+
local count = 0
|
|
112
119
|
effect(function()
|
|
113
|
-
|
|
120
|
+
count += 1
|
|
121
|
+
prev = value()
|
|
114
122
|
untrack(function()
|
|
115
|
-
return self:checkRules(name)
|
|
123
|
+
return self:checkRules(self, name)
|
|
116
124
|
end)
|
|
125
|
+
if Vide.strict and count == 2 then
|
|
126
|
+
log()
|
|
127
|
+
count = 0
|
|
128
|
+
elseif not Vide.strict and count == 1 then
|
|
129
|
+
log()
|
|
130
|
+
count = 0
|
|
131
|
+
end
|
|
117
132
|
end)
|
|
118
133
|
else
|
|
119
134
|
self.logger:log("WARN", "forge.bind called while game is running", {
|
|
@@ -195,6 +210,9 @@ do
|
|
|
195
210
|
apply(loaded.container)({
|
|
196
211
|
ZIndex = index,
|
|
197
212
|
})
|
|
213
|
+
apply(loaded.render)({
|
|
214
|
+
ZIndex = index,
|
|
215
|
+
})
|
|
198
216
|
end
|
|
199
217
|
function AppForge:set(name, value, rules)
|
|
200
218
|
if rules == nil then
|
|
@@ -225,7 +243,7 @@ do
|
|
|
225
243
|
to = value,
|
|
226
244
|
})
|
|
227
245
|
if rules then
|
|
228
|
-
self:checkRules(name)
|
|
246
|
+
self:checkRules(self, name)
|
|
229
247
|
end
|
|
230
248
|
end
|
|
231
249
|
function AppForge:open(name, rules)
|
|
@@ -246,7 +264,7 @@ do
|
|
|
246
264
|
end
|
|
247
265
|
self:set(name, not self:getSource(name)(), rules)
|
|
248
266
|
end
|
|
249
|
-
function AppForge:story(props)
|
|
267
|
+
function AppForge:story(props, target, conf)
|
|
250
268
|
self.debug:logTag("lifecycle", "story", "Creating story mount")
|
|
251
269
|
local Container = create("Frame")({
|
|
252
270
|
Name = "Story Container",
|
|
@@ -255,19 +273,45 @@ do
|
|
|
255
273
|
Position = UDim2.fromScale(0.5, 0.5),
|
|
256
274
|
Size = UDim2.fromScale(1, 1),
|
|
257
275
|
})
|
|
258
|
-
apply(Container)
|
|
259
|
-
|
|
260
|
-
|
|
276
|
+
local _fn = apply(Container)
|
|
277
|
+
local _object = {}
|
|
278
|
+
local _left = 0
|
|
279
|
+
local _self = self
|
|
280
|
+
local _object_1 = {
|
|
281
|
+
props = props,
|
|
282
|
+
forge = self,
|
|
283
|
+
}
|
|
284
|
+
local _left_1 = "render"
|
|
285
|
+
local _result = conf
|
|
286
|
+
if _result ~= nil then
|
|
287
|
+
_result = _result.render
|
|
288
|
+
end
|
|
289
|
+
_object_1[_left_1] = _result
|
|
290
|
+
local _left_2 = "config"
|
|
291
|
+
local _object_2 = {}
|
|
292
|
+
local _left_3 = "px"
|
|
293
|
+
local _object_3 = {
|
|
294
|
+
target = target,
|
|
295
|
+
}
|
|
296
|
+
local _left_4 = "minScale"
|
|
297
|
+
local _result_1 = conf
|
|
298
|
+
if _result_1 ~= nil then
|
|
299
|
+
_result_1 = _result_1.minScale
|
|
300
|
+
end
|
|
301
|
+
_object_3[_left_4] = _result_1
|
|
302
|
+
_object_2[_left_3] = _object_3
|
|
303
|
+
_object_1[_left_2] = _object_2
|
|
304
|
+
_object[_left] = _self:renderMount(_object_1)
|
|
305
|
+
_fn(_object)
|
|
261
306
|
return Container
|
|
262
307
|
end
|
|
263
|
-
function AppForge:mount(
|
|
308
|
+
function AppForge:mount(node, props, target)
|
|
264
309
|
self.debug:logTag("lifecycle", "mount", "Mounting AppForge")
|
|
265
|
-
local Container = callback()
|
|
266
310
|
self.innerMount = mount(function()
|
|
267
|
-
apply(
|
|
311
|
+
apply(node)({
|
|
268
312
|
[0] = self:renderMount(props),
|
|
269
313
|
})
|
|
270
|
-
return
|
|
314
|
+
return node
|
|
271
315
|
end, target)
|
|
272
316
|
return self.innerMount
|
|
273
317
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Vide from "@rbxts/vide";
|
|
2
|
+
import type Types from "./types";
|
|
3
|
+
import type AppForge from "./mount";
|
|
4
|
+
import Rules from "./ruleEngine";
|
|
5
|
+
export default class Renders extends Rules {
|
|
6
|
+
protected anchored: Map<string, {
|
|
7
|
+
id: AppNames;
|
|
8
|
+
render: Vide.Node;
|
|
9
|
+
}>;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Entry point for mounting renders.
|
|
13
|
+
* Decides render strategy based on props.
|
|
14
|
+
*/
|
|
15
|
+
protected renderMount(this: AppForge, props: Types.Props.Main): Vide.Node;
|
|
16
|
+
/**
|
|
17
|
+
* Render multiple apps by name, avoiding duplicates.
|
|
18
|
+
*/
|
|
19
|
+
private renderNames;
|
|
20
|
+
/**
|
|
21
|
+
* Render children of a parent app recursively inside parent container
|
|
22
|
+
*/
|
|
23
|
+
private renderChildren;
|
|
24
|
+
private collectByGroup;
|
|
25
|
+
private normalizeGroups;
|
|
26
|
+
protected renderApp(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>, parentContainer?: Instance): Vide.Node;
|
|
27
|
+
protected renderApps(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
28
|
+
protected renderGroup(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
29
|
+
protected renderGroupByName(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
30
|
+
protected renderGroupByNames(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
31
|
+
protected renderAll(this: AppForge, props: Types.Props.Main, renderedSet?: Set<AppNames>): Instance[];
|
|
32
|
+
}
|
|
@@ -6,11 +6,11 @@ local apply = _vide.apply
|
|
|
6
6
|
local create = _vide.create
|
|
7
7
|
-- Types
|
|
8
8
|
-- Components
|
|
9
|
-
local AppRegistry = TS.import(script, script.Parent
|
|
9
|
+
local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
|
|
10
10
|
-- Hooks
|
|
11
|
-
local usePx = TS.import(script, script.Parent
|
|
11
|
+
local usePx = TS.import(script, script.Parent, "hooks", "usePx").usePx
|
|
12
12
|
-- Classes
|
|
13
|
-
local Rules = TS.import(script, script.Parent, "
|
|
13
|
+
local Rules = TS.import(script, script.Parent, "ruleEngine").default
|
|
14
14
|
local Renders
|
|
15
15
|
do
|
|
16
16
|
local super = Rules
|
|
@@ -58,58 +58,96 @@ do
|
|
|
58
58
|
else
|
|
59
59
|
forge.debug:logTag("px", "global", "Skipped duplicate px initialization")
|
|
60
60
|
end
|
|
61
|
+
local renderedSet = {}
|
|
61
62
|
if render then
|
|
62
63
|
local _condition = render.name
|
|
63
64
|
if _condition ~= "" and _condition then
|
|
64
65
|
_condition = render.group
|
|
65
66
|
end
|
|
66
67
|
if _condition ~= "" and _condition then
|
|
67
|
-
|
|
68
|
-
return forge:renderGroupByName(props)
|
|
68
|
+
return self:renderGroupByName(props, renderedSet)
|
|
69
69
|
end
|
|
70
70
|
local _value = render.names and render.group
|
|
71
71
|
if _value ~= "" and _value then
|
|
72
|
-
|
|
73
|
-
return forge:renderGroupByNames(props)
|
|
72
|
+
return self:renderGroupByNames(props, renderedSet)
|
|
74
73
|
end
|
|
75
74
|
local _value_1 = render.name
|
|
76
75
|
if _value_1 ~= "" and _value_1 then
|
|
77
|
-
|
|
78
|
-
return forge:renderApp(props)
|
|
76
|
+
return self:renderApp(props, renderedSet)
|
|
79
77
|
end
|
|
80
78
|
if render.names then
|
|
81
|
-
|
|
82
|
-
return forge:renderApps(props)
|
|
79
|
+
return self:renderApps(props, renderedSet)
|
|
83
80
|
end
|
|
84
81
|
local _value_2 = render.group
|
|
85
82
|
if _value_2 ~= "" and _value_2 then
|
|
86
|
-
|
|
87
|
-
return forge:renderGroup(props)
|
|
83
|
+
return self:renderGroup(props, renderedSet)
|
|
88
84
|
end
|
|
89
85
|
end
|
|
90
|
-
|
|
91
|
-
return self:renderAll(props)
|
|
86
|
+
return self:renderAll(props, renderedSet)
|
|
92
87
|
end
|
|
93
|
-
function Renders:renderNames(props, names, forge)
|
|
94
|
-
if
|
|
95
|
-
|
|
88
|
+
function Renders:renderNames(props, names, forge, context, renderedSet, details, parentContainer)
|
|
89
|
+
if not names then
|
|
90
|
+
local _logger = forge.logger
|
|
91
|
+
local _exp = `Renderer resolved 0 apps ({context})`
|
|
92
|
+
local _condition = details
|
|
93
|
+
if _condition == nil then
|
|
94
|
+
_condition = props.render
|
|
95
|
+
end
|
|
96
|
+
_logger:log("WARN", _exp, _condition)
|
|
97
|
+
return {}
|
|
96
98
|
end
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
local rendered = {}
|
|
100
|
+
for _, name in names do
|
|
101
|
+
if renderedSet[name] ~= nil then
|
|
102
|
+
continue
|
|
103
|
+
end
|
|
104
|
+
renderedSet[name] = true
|
|
100
105
|
local _forge = forge
|
|
101
106
|
local _object = table.clone(props)
|
|
102
107
|
setmetatable(_object, nil)
|
|
103
108
|
_object.render = {
|
|
104
109
|
name = name,
|
|
105
110
|
}
|
|
106
|
-
|
|
111
|
+
local appRender = _forge:renderApp(_object, renderedSet, parentContainer)
|
|
112
|
+
table.insert(rendered, appRender)
|
|
113
|
+
self:renderChildren(props, name, forge, renderedSet, rendered, appRender)
|
|
107
114
|
end
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
return rendered
|
|
116
|
+
end
|
|
117
|
+
function Renders:renderChildren(props, parentName, forge, renderedSet, accumulated, parentContainer)
|
|
118
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
119
|
+
local _callback = function(app, childName)
|
|
120
|
+
local _result = app.rules
|
|
121
|
+
if _result ~= nil then
|
|
122
|
+
_result = _result.parent
|
|
123
|
+
end
|
|
124
|
+
local _condition = _result == parentName
|
|
125
|
+
if _condition then
|
|
126
|
+
local _renderedSet = renderedSet
|
|
127
|
+
local _childName = childName
|
|
128
|
+
_condition = not (_renderedSet[_childName] ~= nil)
|
|
129
|
+
end
|
|
130
|
+
if _condition then
|
|
131
|
+
local _renderedSet = renderedSet
|
|
132
|
+
local _childName = childName
|
|
133
|
+
_renderedSet[_childName] = true
|
|
134
|
+
local _forge = forge
|
|
135
|
+
local _object = table.clone(props)
|
|
136
|
+
setmetatable(_object, nil)
|
|
137
|
+
_object.render = {
|
|
138
|
+
name = childName,
|
|
139
|
+
}
|
|
140
|
+
local childRender = _forge:renderApp(_object, renderedSet, parentContainer)
|
|
141
|
+
table.insert(accumulated, childRender)
|
|
142
|
+
childRender.Parent = parentContainer
|
|
143
|
+
forge:index(parentName, 10)
|
|
144
|
+
self:renderChildren(props, childName, forge, renderedSet, accumulated, childRender)
|
|
145
|
+
end
|
|
110
146
|
end
|
|
111
|
-
|
|
112
|
-
|
|
147
|
+
for _k, _v in AppRegistry do
|
|
148
|
+
_callback(_v, _k, AppRegistry)
|
|
149
|
+
end
|
|
150
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
113
151
|
end
|
|
114
152
|
function Renders:collectByGroup(groups, filter)
|
|
115
153
|
local result = {}
|
|
@@ -147,7 +185,7 @@ do
|
|
|
147
185
|
end
|
|
148
186
|
return _result
|
|
149
187
|
end
|
|
150
|
-
function Renders:renderApp(props)
|
|
188
|
+
function Renders:renderApp(props, renderedSet, parentContainer)
|
|
151
189
|
local _name = props.render
|
|
152
190
|
if _name ~= nil then
|
|
153
191
|
_name = _name.name
|
|
@@ -162,8 +200,10 @@ do
|
|
|
162
200
|
end
|
|
163
201
|
self.debug:time("render", name)
|
|
164
202
|
if not (self.loaded[name] ~= nil) then
|
|
165
|
-
self.debug:logTag("render", name, "Creating render instance")
|
|
166
203
|
local render = appClass.constructor.new(props, name):render()
|
|
204
|
+
if not render then
|
|
205
|
+
error(`App "{name}" returned undefined from render()`, 2)
|
|
206
|
+
end
|
|
167
207
|
apply(render)({
|
|
168
208
|
Name = "Render",
|
|
169
209
|
})
|
|
@@ -175,6 +215,9 @@ do
|
|
|
175
215
|
Size = UDim2.fromScale(1, 1),
|
|
176
216
|
[0] = render,
|
|
177
217
|
})
|
|
218
|
+
if parentContainer then
|
|
219
|
+
container.Parent = parentContainer
|
|
220
|
+
end
|
|
178
221
|
local _loaded = self.loaded
|
|
179
222
|
local _arg1 = {
|
|
180
223
|
container = container,
|
|
@@ -184,11 +227,18 @@ do
|
|
|
184
227
|
else
|
|
185
228
|
self.debug:logTag("render", name, "Reusing existing render instance")
|
|
186
229
|
end
|
|
187
|
-
|
|
230
|
+
local _result = renderedSet
|
|
231
|
+
if _result ~= nil then
|
|
232
|
+
_result[name] = true
|
|
233
|
+
end
|
|
234
|
+
self:renderRules(self, name, props)
|
|
188
235
|
self.debug:timeEnd("render", name)
|
|
189
236
|
return self.loaded[name].container
|
|
190
237
|
end
|
|
191
|
-
function Renders:renderApps(props)
|
|
238
|
+
function Renders:renderApps(props, renderedSet)
|
|
239
|
+
if renderedSet == nil then
|
|
240
|
+
renderedSet = {}
|
|
241
|
+
end
|
|
192
242
|
local _names = props.render
|
|
193
243
|
if _names ~= nil then
|
|
194
244
|
_names = _names.names
|
|
@@ -197,9 +247,12 @@ do
|
|
|
197
247
|
if not names then
|
|
198
248
|
error("renderApps requires app names", 2)
|
|
199
249
|
end
|
|
200
|
-
return self:renderNames(props, names, self)
|
|
250
|
+
return self:renderNames(props, names, self, "renderApps", renderedSet, names)
|
|
201
251
|
end
|
|
202
|
-
function Renders:renderGroup(props)
|
|
252
|
+
function Renders:renderGroup(props, renderedSet)
|
|
253
|
+
if renderedSet == nil then
|
|
254
|
+
renderedSet = {}
|
|
255
|
+
end
|
|
203
256
|
local _group = props.render
|
|
204
257
|
if _group ~= nil then
|
|
205
258
|
_group = _group.group
|
|
@@ -209,9 +262,12 @@ do
|
|
|
209
262
|
error("renderGroup requires a group", 2)
|
|
210
263
|
end
|
|
211
264
|
local groups = self:normalizeGroups(group)
|
|
212
|
-
return self:renderNames(props, self:collectByGroup(groups), self)
|
|
265
|
+
return self:renderNames(props, self:collectByGroup(groups), self, "renderGroup", renderedSet, group)
|
|
213
266
|
end
|
|
214
|
-
function Renders:renderGroupByName(props)
|
|
267
|
+
function Renders:renderGroupByName(props, renderedSet)
|
|
268
|
+
if renderedSet == nil then
|
|
269
|
+
renderedSet = {}
|
|
270
|
+
end
|
|
215
271
|
local _binding = props.render or {}
|
|
216
272
|
local group = _binding.group
|
|
217
273
|
local name = _binding.name
|
|
@@ -221,9 +277,15 @@ do
|
|
|
221
277
|
local groups = self:normalizeGroups(group)
|
|
222
278
|
return self:renderNames(props, self:collectByGroup(groups, function(n)
|
|
223
279
|
return n == name
|
|
224
|
-
end), self
|
|
280
|
+
end), self, "renderGroupByName", renderedSet, {
|
|
281
|
+
group = group,
|
|
282
|
+
name = name,
|
|
283
|
+
})
|
|
225
284
|
end
|
|
226
|
-
function Renders:renderGroupByNames(props)
|
|
285
|
+
function Renders:renderGroupByNames(props, renderedSet)
|
|
286
|
+
if renderedSet == nil then
|
|
287
|
+
renderedSet = {}
|
|
288
|
+
end
|
|
227
289
|
local _binding = props.render or {}
|
|
228
290
|
local group = _binding.group
|
|
229
291
|
local names = _binding.names
|
|
@@ -234,9 +296,15 @@ do
|
|
|
234
296
|
return self:renderNames(props, self:collectByGroup(groups, function(n)
|
|
235
297
|
local _n = n
|
|
236
298
|
return table.find(names, _n) ~= nil
|
|
237
|
-
end), self
|
|
299
|
+
end), self, "renderGroupByNames", renderedSet, {
|
|
300
|
+
group = group,
|
|
301
|
+
names = names,
|
|
302
|
+
})
|
|
238
303
|
end
|
|
239
|
-
function Renders:renderAll(props)
|
|
304
|
+
function Renders:renderAll(props, renderedSet)
|
|
305
|
+
if renderedSet == nil then
|
|
306
|
+
renderedSet = {}
|
|
307
|
+
end
|
|
240
308
|
local names = {}
|
|
241
309
|
-- ▼ ReadonlyMap.forEach ▼
|
|
242
310
|
local _callback = function(_, name)
|
|
@@ -248,7 +316,7 @@ do
|
|
|
248
316
|
_callback(_v, _k, AppRegistry)
|
|
249
317
|
end
|
|
250
318
|
-- ▲ ReadonlyMap.forEach ▲
|
|
251
|
-
return self:renderNames(props, names, self)
|
|
319
|
+
return self:renderNames(props, names, self, "renderAll", renderedSet)
|
|
252
320
|
end
|
|
253
321
|
end
|
|
254
322
|
return {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type AppForge from "
|
|
1
|
+
import type AppForge from "../mount";
|
|
2
2
|
export default function ExclusiveGroupRule(entry: AppNames, forge: AppForge): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Types
|
|
4
4
|
-- Components
|
|
5
|
-
local AppRegistry = TS.import(script, script.Parent.Parent
|
|
5
|
+
local AppRegistry = TS.import(script, script.Parent.Parent, "appRegistry").AppRegistry
|
|
6
6
|
local function ExclusiveGroupRule(entry, forge)
|
|
7
7
|
local _entry = entry
|
|
8
8
|
local entryApp = AppRegistry[_entry]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type AppForge from "../mount";
|
|
2
|
+
import type Types from "../types";
|
|
3
|
+
export default class Rules {
|
|
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;
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Types
|
|
4
4
|
-- Components
|
|
5
|
-
local AppRegistry = TS.import(script, script.Parent
|
|
5
|
+
local AppRegistry = TS.import(script, script.Parent, "appRegistry").AppRegistry
|
|
6
6
|
-- Rules
|
|
7
7
|
local ExclusiveGroupRule = TS.import(script, script, "exclusiveGroup").default
|
|
8
8
|
local ParentRule = TS.import(script, script, "parent").default
|
|
@@ -21,7 +21,7 @@ do
|
|
|
21
21
|
function Rules:constructor()
|
|
22
22
|
self.processing = {}
|
|
23
23
|
end
|
|
24
|
-
function Rules:renderRules(name, props)
|
|
24
|
+
function Rules:renderRules(forge, name, props)
|
|
25
25
|
local _name = name
|
|
26
26
|
local appClass = AppRegistry[_name]
|
|
27
27
|
if not appClass then
|
|
@@ -37,31 +37,31 @@ do
|
|
|
37
37
|
_condition = not rules.detach
|
|
38
38
|
end
|
|
39
39
|
if _condition ~= "" and _condition then
|
|
40
|
-
|
|
40
|
+
forge.debug:logTag("rules", name, "Applying parent anchor", {
|
|
41
41
|
parent = rules.parent,
|
|
42
42
|
})
|
|
43
|
-
|
|
43
|
+
forge:anchor(name, rules.parent, props)
|
|
44
44
|
end
|
|
45
45
|
-- Index
|
|
46
|
-
if rules.
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
if rules.zIndex ~= nil then
|
|
47
|
+
forge.debug:logTag("rules", name, "Applying ZIndex", rules.zIndex)
|
|
48
|
+
forge:index(name, rules.zIndex)
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
function Rules:checkRules(name)
|
|
51
|
+
function Rules:checkRules(forge, name)
|
|
52
52
|
local _processing = self.processing
|
|
53
53
|
local _name = name
|
|
54
54
|
if _processing[_name] ~= nil then
|
|
55
|
-
|
|
55
|
+
forge.debug:logTag("rules", name, "Skipped rule processing (cycle detected)")
|
|
56
56
|
return nil
|
|
57
57
|
end
|
|
58
58
|
local _processing_1 = self.processing
|
|
59
59
|
local _name_1 = name
|
|
60
60
|
_processing_1[_name_1] = true
|
|
61
|
-
|
|
61
|
+
forge.debug:logTag("rules", name, "Evaluating rules")
|
|
62
62
|
TS.try(function()
|
|
63
|
-
ParentRule(name,
|
|
64
|
-
ExclusiveGroupRule(name,
|
|
63
|
+
ParentRule(name, forge)
|
|
64
|
+
ExclusiveGroupRule(name, forge)
|
|
65
65
|
end, nil, function()
|
|
66
66
|
local _processing_2 = self.processing
|
|
67
67
|
local _name_2 = name
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type AppForge from "
|
|
1
|
+
import type AppForge from "../mount";
|
|
2
2
|
export default function ParentRule(entry: AppNames, forge: AppForge): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
-- Types
|
|
4
4
|
-- Components
|
|
5
|
-
local AppRegistry = TS.import(script, script.Parent.Parent
|
|
5
|
+
local AppRegistry = TS.import(script, script.Parent.Parent, "appRegistry").AppRegistry
|
|
6
6
|
local function ParentRule(entry, forge)
|
|
7
7
|
local entryVisible = forge:getSource(entry)()
|
|
8
8
|
-- ▼ ReadonlyMap.forEach ▼
|
|
@@ -19,6 +19,7 @@ local function ParentRule(entry, forge)
|
|
|
19
19
|
return nil
|
|
20
20
|
end
|
|
21
21
|
forge.debug:logTag("rules", entry, "Closing child app (parent closed)", {
|
|
22
|
+
parent = entry,
|
|
22
23
|
child = name,
|
|
23
24
|
})
|
|
24
25
|
forge:close(name, false)
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Types
|
|
2
|
-
import type { Args } from "./
|
|
3
|
-
import type AppForge from "
|
|
2
|
+
import type { Args } from "./appRegistry";
|
|
3
|
+
import type AppForge from "./mount";
|
|
4
4
|
|
|
5
5
|
declare namespace Types {
|
|
6
6
|
namespace Props {
|
|
7
7
|
type Render =
|
|
8
8
|
| { name?: AppNames; names?: never; group?: never }
|
|
9
9
|
| { names?: AppNames[]; name?: never; group?: never }
|
|
10
|
-
| { group?:
|
|
11
|
-
| { group?:
|
|
12
|
-
| { group?:
|
|
10
|
+
| { group?: AppGroups[] | AppGroups; names?: AppNames[]; name?: never }
|
|
11
|
+
| { group?: AppGroups[] | AppGroups; name?: AppNames; names?: never }
|
|
12
|
+
| { group?: AppGroups[] | AppGroups; names?: never; name?: never };
|
|
13
13
|
|
|
14
14
|
type Main = {
|
|
15
15
|
props: AppProps;
|
|
@@ -34,7 +34,7 @@ declare namespace Types {
|
|
|
34
34
|
type Props<N extends AppNames> = {
|
|
35
35
|
name: N;
|
|
36
36
|
visible?: boolean;
|
|
37
|
-
renderGroup?:
|
|
37
|
+
renderGroup?: AppGroups;
|
|
38
38
|
rules?: Rules.Generic<N>;
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ declare namespace Types {
|
|
|
42
42
|
constructor: new (props: Types.Props.Main, name: AppNames) => Args;
|
|
43
43
|
|
|
44
44
|
visible?: boolean;
|
|
45
|
-
renderGroup?:
|
|
45
|
+
renderGroup?: AppGroups;
|
|
46
46
|
rules?: Rules.Static;
|
|
47
47
|
};
|
|
48
48
|
|
|
@@ -50,7 +50,7 @@ declare namespace Types {
|
|
|
50
50
|
constructor: new (props: Types.Props.Main, name: AppNames) => Args;
|
|
51
51
|
|
|
52
52
|
visible?: boolean;
|
|
53
|
-
renderGroup?:
|
|
53
|
+
renderGroup?: AppGroups;
|
|
54
54
|
rules?: Rules.Generic<N>;
|
|
55
55
|
};
|
|
56
56
|
}
|
|
@@ -68,17 +68,17 @@ declare namespace Types {
|
|
|
68
68
|
|
|
69
69
|
export type Static = {
|
|
70
70
|
exclusiveGroup?: string;
|
|
71
|
-
|
|
71
|
+
zIndex?: number;
|
|
72
72
|
} & (WithParent<string> | WithoutParent);
|
|
73
73
|
|
|
74
74
|
export type Generic<N extends AppNames = AppNames> = {
|
|
75
|
-
exclusiveGroup?:
|
|
76
|
-
|
|
75
|
+
exclusiveGroup?: AppGroups;
|
|
76
|
+
zIndex?: number;
|
|
77
77
|
} & (WithParent<Exclude<AppNames, N>> | WithoutParent);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export type
|
|
81
|
+
export type ForgeProps = Types.Props.Main;
|
|
82
82
|
export type ClassProps = Types.Props.Class;
|
|
83
83
|
export type RenderProps = Types.Props.Render;
|
|
84
84
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/app-forge",
|
|
3
|
-
"version": "0.7.2-alpha.
|
|
3
|
+
"version": "0.7.2-alpha.30",
|
|
4
4
|
"description": "An App Manager for Vide",
|
|
5
5
|
"main": "out/init.lua",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -34,24 +34,18 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@rbxts/set-timeout": "^1.1.2",
|
|
37
38
|
"@rbxts/services": "^1.6.0",
|
|
38
|
-
"@rbxts/
|
|
39
|
-
},
|
|
40
|
-
"peerDependencies": {
|
|
41
|
-
"@rbxts/react": "^17.3.7-ts.1",
|
|
42
|
-
"@rbxts/vide": "^0.5.7"
|
|
39
|
+
"@rbxts/vide": "^0.6.0"
|
|
43
40
|
},
|
|
44
41
|
"peerDependenciesMeta": {
|
|
45
|
-
"@rbxts/react": {
|
|
46
|
-
"optional": true
|
|
47
|
-
},
|
|
48
42
|
"@rbxts/vide": {
|
|
49
43
|
"optional": true
|
|
50
44
|
}
|
|
51
45
|
},
|
|
52
46
|
"devDependencies": {
|
|
53
|
-
"@biomejs/biome": "^2.3.7",
|
|
54
47
|
"@rbxts/compiler-types": "3.0.0-types.0",
|
|
48
|
+
"@biomejs/biome": "^2.3.7",
|
|
55
49
|
"@rbxts/types": "^1.0.891",
|
|
56
50
|
"roblox-ts": "3.0.0",
|
|
57
51
|
"typescript": "^5.9.3"
|