@rbxts/app-forge 0.7.2-alpha.3 → 0.7.2-alpha.31
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} +60 -19
- package/out/renderManager.d.ts +32 -0
- package/out/{vide/classes/renders.luau → renderManager.luau} +109 -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", {
|
|
@@ -225,7 +240,7 @@ do
|
|
|
225
240
|
to = value,
|
|
226
241
|
})
|
|
227
242
|
if rules then
|
|
228
|
-
self:checkRules(name)
|
|
243
|
+
self:checkRules(self, name)
|
|
229
244
|
end
|
|
230
245
|
end
|
|
231
246
|
function AppForge:open(name, rules)
|
|
@@ -246,7 +261,7 @@ do
|
|
|
246
261
|
end
|
|
247
262
|
self:set(name, not self:getSource(name)(), rules)
|
|
248
263
|
end
|
|
249
|
-
function AppForge:story(props)
|
|
264
|
+
function AppForge:story(props, target, conf)
|
|
250
265
|
self.debug:logTag("lifecycle", "story", "Creating story mount")
|
|
251
266
|
local Container = create("Frame")({
|
|
252
267
|
Name = "Story Container",
|
|
@@ -255,19 +270,45 @@ do
|
|
|
255
270
|
Position = UDim2.fromScale(0.5, 0.5),
|
|
256
271
|
Size = UDim2.fromScale(1, 1),
|
|
257
272
|
})
|
|
258
|
-
apply(Container)
|
|
259
|
-
|
|
260
|
-
|
|
273
|
+
local _fn = apply(Container)
|
|
274
|
+
local _object = {}
|
|
275
|
+
local _left = 0
|
|
276
|
+
local _self = self
|
|
277
|
+
local _object_1 = {
|
|
278
|
+
props = props,
|
|
279
|
+
forge = self,
|
|
280
|
+
}
|
|
281
|
+
local _left_1 = "render"
|
|
282
|
+
local _result = conf
|
|
283
|
+
if _result ~= nil then
|
|
284
|
+
_result = _result.render
|
|
285
|
+
end
|
|
286
|
+
_object_1[_left_1] = _result
|
|
287
|
+
local _left_2 = "config"
|
|
288
|
+
local _object_2 = {}
|
|
289
|
+
local _left_3 = "px"
|
|
290
|
+
local _object_3 = {
|
|
291
|
+
target = target,
|
|
292
|
+
}
|
|
293
|
+
local _left_4 = "minScale"
|
|
294
|
+
local _result_1 = conf
|
|
295
|
+
if _result_1 ~= nil then
|
|
296
|
+
_result_1 = _result_1.minScale
|
|
297
|
+
end
|
|
298
|
+
_object_3[_left_4] = _result_1
|
|
299
|
+
_object_2[_left_3] = _object_3
|
|
300
|
+
_object_1[_left_2] = _object_2
|
|
301
|
+
_object[_left] = _self:renderMount(_object_1)
|
|
302
|
+
_fn(_object)
|
|
261
303
|
return Container
|
|
262
304
|
end
|
|
263
|
-
function AppForge:mount(
|
|
305
|
+
function AppForge:mount(node, props, target)
|
|
264
306
|
self.debug:logTag("lifecycle", "mount", "Mounting AppForge")
|
|
265
|
-
local Container = callback()
|
|
266
307
|
self.innerMount = mount(function()
|
|
267
|
-
apply(
|
|
308
|
+
apply(node)({
|
|
268
309
|
[0] = self:renderMount(props),
|
|
269
310
|
})
|
|
270
|
-
return
|
|
311
|
+
return node
|
|
271
312
|
end, target)
|
|
272
313
|
return self.innerMount
|
|
273
314
|
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,98 @@ 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
|
+
apply(childRender)({
|
|
143
|
+
Parent = parentContainer,
|
|
144
|
+
})
|
|
145
|
+
forge:index(parentName, 10)
|
|
146
|
+
self:renderChildren(props, childName, forge, renderedSet, accumulated, childRender)
|
|
147
|
+
end
|
|
110
148
|
end
|
|
111
|
-
|
|
112
|
-
|
|
149
|
+
for _k, _v in AppRegistry do
|
|
150
|
+
_callback(_v, _k, AppRegistry)
|
|
151
|
+
end
|
|
152
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
113
153
|
end
|
|
114
154
|
function Renders:collectByGroup(groups, filter)
|
|
115
155
|
local result = {}
|
|
@@ -147,7 +187,7 @@ do
|
|
|
147
187
|
end
|
|
148
188
|
return _result
|
|
149
189
|
end
|
|
150
|
-
function Renders:renderApp(props)
|
|
190
|
+
function Renders:renderApp(props, renderedSet, parentContainer)
|
|
151
191
|
local _name = props.render
|
|
152
192
|
if _name ~= nil then
|
|
153
193
|
_name = _name.name
|
|
@@ -162,8 +202,10 @@ do
|
|
|
162
202
|
end
|
|
163
203
|
self.debug:time("render", name)
|
|
164
204
|
if not (self.loaded[name] ~= nil) then
|
|
165
|
-
self.debug:logTag("render", name, "Creating render instance")
|
|
166
205
|
local render = appClass.constructor.new(props, name):render()
|
|
206
|
+
if not render then
|
|
207
|
+
error(`App "{name}" returned undefined from render()`, 2)
|
|
208
|
+
end
|
|
167
209
|
apply(render)({
|
|
168
210
|
Name = "Render",
|
|
169
211
|
})
|
|
@@ -175,6 +217,9 @@ do
|
|
|
175
217
|
Size = UDim2.fromScale(1, 1),
|
|
176
218
|
[0] = render,
|
|
177
219
|
})
|
|
220
|
+
if parentContainer then
|
|
221
|
+
container.Parent = parentContainer
|
|
222
|
+
end
|
|
178
223
|
local _loaded = self.loaded
|
|
179
224
|
local _arg1 = {
|
|
180
225
|
container = container,
|
|
@@ -184,11 +229,18 @@ do
|
|
|
184
229
|
else
|
|
185
230
|
self.debug:logTag("render", name, "Reusing existing render instance")
|
|
186
231
|
end
|
|
187
|
-
|
|
232
|
+
local _result = renderedSet
|
|
233
|
+
if _result ~= nil then
|
|
234
|
+
_result[name] = true
|
|
235
|
+
end
|
|
236
|
+
self:renderRules(self, name, props)
|
|
188
237
|
self.debug:timeEnd("render", name)
|
|
189
238
|
return self.loaded[name].container
|
|
190
239
|
end
|
|
191
|
-
function Renders:renderApps(props)
|
|
240
|
+
function Renders:renderApps(props, renderedSet)
|
|
241
|
+
if renderedSet == nil then
|
|
242
|
+
renderedSet = {}
|
|
243
|
+
end
|
|
192
244
|
local _names = props.render
|
|
193
245
|
if _names ~= nil then
|
|
194
246
|
_names = _names.names
|
|
@@ -197,9 +249,12 @@ do
|
|
|
197
249
|
if not names then
|
|
198
250
|
error("renderApps requires app names", 2)
|
|
199
251
|
end
|
|
200
|
-
return self:renderNames(props, names, self)
|
|
252
|
+
return self:renderNames(props, names, self, "renderApps", renderedSet, names)
|
|
201
253
|
end
|
|
202
|
-
function Renders:renderGroup(props)
|
|
254
|
+
function Renders:renderGroup(props, renderedSet)
|
|
255
|
+
if renderedSet == nil then
|
|
256
|
+
renderedSet = {}
|
|
257
|
+
end
|
|
203
258
|
local _group = props.render
|
|
204
259
|
if _group ~= nil then
|
|
205
260
|
_group = _group.group
|
|
@@ -209,9 +264,12 @@ do
|
|
|
209
264
|
error("renderGroup requires a group", 2)
|
|
210
265
|
end
|
|
211
266
|
local groups = self:normalizeGroups(group)
|
|
212
|
-
return self:renderNames(props, self:collectByGroup(groups), self)
|
|
267
|
+
return self:renderNames(props, self:collectByGroup(groups), self, "renderGroup", renderedSet, group)
|
|
213
268
|
end
|
|
214
|
-
function Renders:renderGroupByName(props)
|
|
269
|
+
function Renders:renderGroupByName(props, renderedSet)
|
|
270
|
+
if renderedSet == nil then
|
|
271
|
+
renderedSet = {}
|
|
272
|
+
end
|
|
215
273
|
local _binding = props.render or {}
|
|
216
274
|
local group = _binding.group
|
|
217
275
|
local name = _binding.name
|
|
@@ -221,9 +279,15 @@ do
|
|
|
221
279
|
local groups = self:normalizeGroups(group)
|
|
222
280
|
return self:renderNames(props, self:collectByGroup(groups, function(n)
|
|
223
281
|
return n == name
|
|
224
|
-
end), self
|
|
282
|
+
end), self, "renderGroupByName", renderedSet, {
|
|
283
|
+
group = group,
|
|
284
|
+
name = name,
|
|
285
|
+
})
|
|
225
286
|
end
|
|
226
|
-
function Renders:renderGroupByNames(props)
|
|
287
|
+
function Renders:renderGroupByNames(props, renderedSet)
|
|
288
|
+
if renderedSet == nil then
|
|
289
|
+
renderedSet = {}
|
|
290
|
+
end
|
|
227
291
|
local _binding = props.render or {}
|
|
228
292
|
local group = _binding.group
|
|
229
293
|
local names = _binding.names
|
|
@@ -234,9 +298,15 @@ do
|
|
|
234
298
|
return self:renderNames(props, self:collectByGroup(groups, function(n)
|
|
235
299
|
local _n = n
|
|
236
300
|
return table.find(names, _n) ~= nil
|
|
237
|
-
end), self
|
|
301
|
+
end), self, "renderGroupByNames", renderedSet, {
|
|
302
|
+
group = group,
|
|
303
|
+
names = names,
|
|
304
|
+
})
|
|
238
305
|
end
|
|
239
|
-
function Renders:renderAll(props)
|
|
306
|
+
function Renders:renderAll(props, renderedSet)
|
|
307
|
+
if renderedSet == nil then
|
|
308
|
+
renderedSet = {}
|
|
309
|
+
end
|
|
240
310
|
local names = {}
|
|
241
311
|
-- ▼ ReadonlyMap.forEach ▼
|
|
242
312
|
local _callback = function(_, name)
|
|
@@ -248,7 +318,7 @@ do
|
|
|
248
318
|
_callback(_v, _k, AppRegistry)
|
|
249
319
|
end
|
|
250
320
|
-- ▲ ReadonlyMap.forEach ▲
|
|
251
|
-
return self:renderNames(props, names, self)
|
|
321
|
+
return self:renderNames(props, names, self, "renderAll", renderedSet)
|
|
252
322
|
end
|
|
253
323
|
end
|
|
254
324
|
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.31",
|
|
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"
|