2024-01-05 12:14:38 +00:00
|
|
|
--!strict
|
|
|
|
local Index = {}
|
|
|
|
|
|
|
|
local RunService = game:GetService("RunService")
|
|
|
|
local IsServer = RunService:IsServer()
|
|
|
|
|
|
|
|
local Util = script.Util
|
|
|
|
local Server = script.Server
|
|
|
|
local Client = script.Client
|
|
|
|
|
|
|
|
local Type = require(script.Type)
|
|
|
|
local Assert = require(Util.Assert)
|
|
|
|
|
|
|
|
if IsServer then
|
|
|
|
require(Server.ServerProcess).start()
|
|
|
|
else
|
|
|
|
require(Client.ClientProcess).start()
|
|
|
|
end
|
|
|
|
|
2024-01-06 03:41:10 +00:00
|
|
|
function Index.Server(Identifier: string, rateLimit: Type.rateLimitArg?): Type.Server
|
2024-01-05 12:14:38 +00:00
|
|
|
Assert(IsServer, `[Warp]: Calling .Server({Identifier}) on client side (expected server side)`)
|
|
|
|
Assert(typeof(Identifier) == "string", "[Warp]: Identifier must be a string type")
|
2024-01-06 03:41:10 +00:00
|
|
|
return require(Server.Index)(Identifier, rateLimit) :: Type.Server
|
2024-01-05 12:14:38 +00:00
|
|
|
end
|
|
|
|
function Index.Client(Identifier: string): Type.Client
|
|
|
|
Assert(not IsServer, `[Warp]: Calling .Client({Identifier}) on server side (expected client side)`)
|
|
|
|
Assert(typeof(Identifier) == "string", "[Warp]: Identifier must be a string type")
|
|
|
|
return require(Client.Index)(Identifier) :: Type.Client
|
|
|
|
end
|
|
|
|
|
2024-01-30 06:36:08 +00:00
|
|
|
function Index.fromServerArray(arrays: { any }): Type.fromServerArray
|
|
|
|
Assert(IsServer, `[Warp]: Calling .fromServerArray({arrays}) on client side (expected server side)`)
|
|
|
|
Assert(typeof(arrays) == "table", "[Warp]: Array must be a table type")
|
|
|
|
local copy = {}
|
|
|
|
for param1: any, param2: any in arrays do
|
|
|
|
if typeof(param2) == "table" then
|
|
|
|
copy[param1] = Index.Server(param1, param2)
|
|
|
|
else
|
|
|
|
copy[param2] = Index.Server(param2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return table.freeze(copy) :: typeof(copy)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Index.fromClientArray(arrays: { any }): Type.fromClientArray
|
|
|
|
Assert(not IsServer, `[Warp]: Calling .fromClientArray({arrays}) on server side (expected client side)`)
|
|
|
|
Assert(typeof(arrays) == "table", "[Warp]: Array must be a table type")
|
|
|
|
local copy = {}
|
|
|
|
for idx: number, identifier: string in arrays do
|
|
|
|
copy[identifier] = Index.Client(identifier)
|
|
|
|
end
|
|
|
|
return table.freeze(copy) :: typeof(copy)
|
|
|
|
end
|
|
|
|
|
2024-01-05 12:14:38 +00:00
|
|
|
return table.freeze(Index) :: typeof(Index)
|