@quenty/loader 5.0.1 → 5.1.0-canary.288.30808b9.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/CHANGELOG.md +16 -0
- package/package.json +2 -2
- package/src/LoaderUtils.lua +2 -2
- package/src/PackageInfoUtils.lua +1 -1
- package/src/ScriptInfoUtils.lua +2 -2
- package/src/StaticLegacyLoader.lua +2 -2
- package/src2/Bounce/BounceTemplate.lua +17 -0
- package/src2/Bounce/BounceTemplateUtils.lua +51 -0
- package/src2/Dependencies/DependencyUtils.lua +133 -0
- package/src2/Loader/LoaderAdder.lua +181 -0
- package/src2/LoaderUtils.lua +0 -0
- package/src2/Maid.lua +222 -0
- package/src2/PathUtils.lua +15 -0
- package/src2/Replication/ReplicationType.lua +13 -0
- package/src2/Replication/ReplicationTypeUtils.lua +37 -0
- package/src2/Replication/Replicator.lua +549 -0
- package/src2/Replication/ReplicatorReferences.lua +103 -0
- package/src2/Replication/ReplicatorUtils.lua +24 -0
- package/src2/Utils.lua +114 -0
- package/src2/init.lua +68 -0
package/src2/Utils.lua
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@private
|
|
3
|
+
@class Utils
|
|
4
|
+
]=]
|
|
5
|
+
|
|
6
|
+
local Utils = {}
|
|
7
|
+
|
|
8
|
+
local function errorOnIndex(_, index)
|
|
9
|
+
error(("Bad index %q"):format(tostring(index)), 2)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
local READ_ONLY_METATABLE = {
|
|
13
|
+
__index = errorOnIndex;
|
|
14
|
+
__newindex = errorOnIndex;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function Utils.readonly(_table)
|
|
18
|
+
return setmetatable(_table, READ_ONLY_METATABLE)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
function Utils.copyTable(target)
|
|
22
|
+
local new = {}
|
|
23
|
+
for key, value in pairs(target) do
|
|
24
|
+
new[key] = value
|
|
25
|
+
end
|
|
26
|
+
return new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
function Utils.count(_table)
|
|
30
|
+
local count = 0
|
|
31
|
+
for _, _ in pairs(_table) do
|
|
32
|
+
count = count + 1
|
|
33
|
+
end
|
|
34
|
+
return count
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
function Utils.getOrCreateValue(parent, instanceType, name, defaultValue)
|
|
38
|
+
assert(typeof(parent) == "Instance", "Bad argument 'parent'")
|
|
39
|
+
assert(type(instanceType) == "string", "Bad argument 'instanceType'")
|
|
40
|
+
assert(type(name) == "string", "Bad argument 'name'")
|
|
41
|
+
|
|
42
|
+
local foundChild = parent:FindFirstChild(name)
|
|
43
|
+
if foundChild then
|
|
44
|
+
if not foundChild:IsA(instanceType) then
|
|
45
|
+
warn(("[Utils.getOrCreateValue] - Value of type %q of name %q is of type %q in %s instead")
|
|
46
|
+
:format(instanceType, name, foundChild.ClassName, foundChild:GetFullName()))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return foundChild
|
|
50
|
+
else
|
|
51
|
+
local newChild = Instance.new(instanceType)
|
|
52
|
+
newChild.Name = name
|
|
53
|
+
newChild.Value = defaultValue
|
|
54
|
+
newChild.Parent = parent
|
|
55
|
+
|
|
56
|
+
return newChild
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
function Utils.getValue(parent, instanceType, name, default)
|
|
61
|
+
assert(typeof(parent) == "Instance", "Bad argument 'parent'")
|
|
62
|
+
assert(type(instanceType) == "string", "Bad argument 'instanceType'")
|
|
63
|
+
assert(type(name) == "string", "Bad argument 'name'")
|
|
64
|
+
|
|
65
|
+
local foundChild = parent:FindFirstChild(name)
|
|
66
|
+
if foundChild then
|
|
67
|
+
if foundChild:IsA(instanceType) then
|
|
68
|
+
return foundChild.Value
|
|
69
|
+
else
|
|
70
|
+
warn(("[Utils.getValue] - Value of type %q of name %q is of type %q in %s instead")
|
|
71
|
+
:format(instanceType, name, foundChild.ClassName, foundChild:GetFullName()))
|
|
72
|
+
return nil
|
|
73
|
+
end
|
|
74
|
+
else
|
|
75
|
+
return default
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
function Utils.setValue(parent, instanceType, name, value)
|
|
80
|
+
assert(typeof(parent) == "Instance", "Bad argument 'parent'")
|
|
81
|
+
assert(type(instanceType) == "string", "Bad argument 'instanceType'")
|
|
82
|
+
assert(type(name) == "string", "Bad argument 'name'")
|
|
83
|
+
|
|
84
|
+
local foundChild = parent:FindFirstChild(name)
|
|
85
|
+
if foundChild then
|
|
86
|
+
if not foundChild:IsA(instanceType) then
|
|
87
|
+
warn(("[Utils.setValue] - Value of type %q of name %q is of type %q in %s instead")
|
|
88
|
+
:format(instanceType, name, foundChild.ClassName, foundChild:GetFullName()))
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
foundChild.Value = value
|
|
92
|
+
else
|
|
93
|
+
local newChild = Instance.new(instanceType)
|
|
94
|
+
newChild.Name = name
|
|
95
|
+
newChild.Value = value
|
|
96
|
+
newChild.Parent = parent
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function Utils.getOrCreateFolder(parent, folderName)
|
|
102
|
+
local found = parent:FindFirstChild(folderName)
|
|
103
|
+
if found then
|
|
104
|
+
return found
|
|
105
|
+
else
|
|
106
|
+
local folder = Instance.new("Folder")
|
|
107
|
+
folder.Name = folderName
|
|
108
|
+
folder.Parent = parent
|
|
109
|
+
return folder
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
return Utils
|
package/src2/init.lua
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
2
|
+
|
|
3
|
+
local DependencyUtils = require(script.Dependencies.DependencyUtils)
|
|
4
|
+
local Replicator = require(script.Replication.Replicator)
|
|
5
|
+
local ReplicatorReferences = require(script.Replication.ReplicatorReferences)
|
|
6
|
+
local Maid = require(script.Maid)
|
|
7
|
+
local LoaderAdder = require(script.Loader.LoaderAdder)
|
|
8
|
+
local ReplicationType = require(script.Replication.ReplicationType)
|
|
9
|
+
|
|
10
|
+
local function handleLoad(moduleScript)
|
|
11
|
+
assert(typeof(moduleScript) == "Instance", "Bad moduleScript")
|
|
12
|
+
|
|
13
|
+
return function(request)
|
|
14
|
+
if type(request) == "string" then
|
|
15
|
+
local module = DependencyUtils.findDependency(moduleScript, request)
|
|
16
|
+
return require(module)
|
|
17
|
+
else
|
|
18
|
+
return require(request)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
local function bootstrapGame(packages)
|
|
24
|
+
local maid = Maid.new()
|
|
25
|
+
|
|
26
|
+
local copy = Instance.new("Folder")
|
|
27
|
+
copy.Name = packages.Name
|
|
28
|
+
maid:GiveTask(copy)
|
|
29
|
+
|
|
30
|
+
local references = ReplicatorReferences.new()
|
|
31
|
+
|
|
32
|
+
local serverAdder = LoaderAdder.new(references, packages, ReplicationType.SERVER)
|
|
33
|
+
maid:GiveTask(serverAdder)
|
|
34
|
+
|
|
35
|
+
local replicator = Replicator.new(references)
|
|
36
|
+
replicator:SetTarget(copy)
|
|
37
|
+
replicator:ReplicateFrom(packages)
|
|
38
|
+
maid:GiveTask(replicator)
|
|
39
|
+
|
|
40
|
+
local clientAdder = LoaderAdder.new(references, copy, ReplicationType.CLIENT)
|
|
41
|
+
maid:GiveTask(clientAdder)
|
|
42
|
+
|
|
43
|
+
copy.Parent = ReplicatedStorage
|
|
44
|
+
|
|
45
|
+
return setmetatable({}, {__index = function(_, value)
|
|
46
|
+
-- Lookup module script
|
|
47
|
+
if type(value) == "string" then
|
|
48
|
+
local result = DependencyUtils.findDependency(packages, value)
|
|
49
|
+
if result then
|
|
50
|
+
return result
|
|
51
|
+
else
|
|
52
|
+
error(("Could not find dependency %q"):format(value))
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
error(("Bad index %q"):format(type(value)))
|
|
56
|
+
end
|
|
57
|
+
end})
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
local function bootstrapPlugin(_packages)
|
|
61
|
+
error("Not implemented")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
load = handleLoad;
|
|
66
|
+
bootstrapGame = bootstrapGame;
|
|
67
|
+
bootstrapPlugin = bootstrapPlugin;
|
|
68
|
+
}
|