@flamework-experimental/core 2.0.0-alpha.2 → 2.0.0-alpha.3
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 +34 -32
- package/flamework.build +1 -1
- package/out/dependency.d.ts +4 -0
- package/out/dependency.luau +4 -0
- package/out/index.d.ts +4 -2
- package/out/init.luau +10 -2
- package/out/lifecycle/lifecyclePlugin.d.ts +13 -1
- package/out/lifecycle/lifecyclePlugin.luau +67 -7
- package/out/module/module.luau +126 -24
- package/out/module/moduleBuilder.d.ts +12 -3
- package/out/module/moduleBuilder.luau +22 -0
- package/out/module/moduleDefinition.d.ts +6 -0
- package/out/module/providerRegistration.d.ts +8 -0
- package/out/module/providerRegistration.luau +29 -0
- package/out/plugin/pluginDefinition.d.ts +7 -4
- package/out/provider.d.ts +19 -0
- package/out/provider.luau +8 -0
- package/out/reflect.luau +6 -0
- package/out/utility/explainUnresolved.d.ts +9 -0
- package/out/utility/explainUnresolved.luau +43 -0
- package/out/utility/getClassesInPath.d.ts +10 -2
- package/out/utility/getClassesInPath.luau +70 -31
- package/out/utility/globs.d.ts +2 -2
- package/out/utility/globs.luau +3 -3
- package/out/utility/leftOut.d.ts +35 -0
- package/out/utility/leftOut.luau +171 -0
- package/out/utility/moduleClasses.d.ts +9 -0
- package/out/utility/moduleClasses.luau +64 -0
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
--[[
|
|
3
|
+
*
|
|
4
|
+
* The Flamework classes each module defined as it loaded, by the module's `script`, in the order
|
|
5
|
+
* they were defined: what path registration finds in a module besides what it exports.
|
|
6
|
+
*
|
|
7
|
+
* The transformer records a class with `Reflect.defineMetadata(class, "flamework:module", script)`,
|
|
8
|
+
* and only a class the module creates once per load -- declared at the top level of the file, or
|
|
9
|
+
* of a namespace in it. A class declared inside a function is created by every call and is never
|
|
10
|
+
* recorded, so nothing here grows with calls, and a later path registration never finds a class
|
|
11
|
+
* that belongs to a test case or a factory. Keyed by the ModuleScript rather than read off the
|
|
12
|
+
* class's identifier, which says nothing about where the class came from once ids are short, tiny
|
|
13
|
+
* or obfuscated.
|
|
14
|
+
*
|
|
15
|
+
* Held for good, as the module's own exports are held by the require cache: a module loads once.
|
|
16
|
+
|
|
17
|
+
]]
|
|
18
|
+
local classesByModule = {}
|
|
19
|
+
--* Records a class against the module that defined it. Called by `Reflect.defineMetadata`.
|
|
20
|
+
local function recordModuleClass(moduleScript, value)
|
|
21
|
+
if moduleScript == nil then
|
|
22
|
+
return nil
|
|
23
|
+
end
|
|
24
|
+
local _moduleScript = moduleScript
|
|
25
|
+
local classes = classesByModule[_moduleScript]
|
|
26
|
+
if classes == nil then
|
|
27
|
+
classes = {}
|
|
28
|
+
local _moduleScript_1 = moduleScript
|
|
29
|
+
local _classes = classes
|
|
30
|
+
classesByModule[_moduleScript_1] = _classes
|
|
31
|
+
end
|
|
32
|
+
local _classes = classes
|
|
33
|
+
local _value = value
|
|
34
|
+
if not (table.find(_classes, _value) ~= nil) then
|
|
35
|
+
local _classes_1 = classes
|
|
36
|
+
local _value_1 = value
|
|
37
|
+
table.insert(_classes_1, _value_1)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
--* The classes a module defined as it loaded, in definition order, or none.
|
|
41
|
+
local function getModuleClasses(moduleScript)
|
|
42
|
+
local _moduleScript = moduleScript
|
|
43
|
+
return classesByModule[_moduleScript]
|
|
44
|
+
end
|
|
45
|
+
--[[
|
|
46
|
+
*
|
|
47
|
+
* Every recorded class, with the module that defined it, until the callback answers `true`. For
|
|
48
|
+
* explaining a failed resolution, which is rare: nothing here is indexed for it.
|
|
49
|
+
|
|
50
|
+
]]
|
|
51
|
+
local function findModuleClass(predicate)
|
|
52
|
+
for moduleScript, classes in classesByModule do
|
|
53
|
+
for _, value in classes do
|
|
54
|
+
if predicate(value) then
|
|
55
|
+
return { value, moduleScript }
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
return {
|
|
61
|
+
recordModuleClass = recordModuleClass,
|
|
62
|
+
getModuleClasses = getModuleClasses,
|
|
63
|
+
findModuleClass = findModuleClass,
|
|
64
|
+
}
|