This commit is contained in:
lx
2026-07-06 14:01:11 -04:00
commit c4f97d729d
16468 changed files with 935321 additions and 0 deletions
@@ -0,0 +1,223 @@
local CoreGui = game:GetService("CoreGui")
local Modules = CoreGui.RobloxGui.Modules
local Common = Modules.Common
local LuaChat = Modules.LuaChat
local Create = require(LuaChat.Create)
local Signal = require(Common.Signal)
local COLOR_BUTTON_ENABLED = Color3.new(0.85, 0.85, 0.85)
local ActionDebug = {
Updated = Signal.new(),
log = {},
enabled = false,
updateQueued = false
}
function ActionDebug:SetEnabled(value)
self.enabled = value
end
function ActionDebug:QueueUpdate()
if not self.updateQueued then
spawn(function()
self.Updated:fire()
end)
end
end
function ActionDebug:AddAction(data)
if not self.enabled then
return "DEBUG DISABLED"
end
local action = {
data = data,
status = "pending",
startTime = tick()
}
table.insert(self.log, action)
local actionId = #self.log
self:QueueUpdate()
return actionId
end
function ActionDebug:SetActionMutated(actionId)
if not self.enabled then
return
end
local action = self.log[actionId]
if not action then
warn("Couldn't find action with ID " .. tostring(actionId))
return
end
action.status = "mutated"
action.mutatedTime = tick()
self:QueueUpdate()
end
function ActionDebug:FinishAction(actionId)
if not self.enabled then
return
end
local action = self.log[actionId]
if not action then
warn("Couldn't find action with ID " .. tostring(actionId))
return
end
action.status = "done"
action.endTime = tick()
self:QueueUpdate()
end
function ActionDebug:Render()
self.updateQueued = false
local children = {}
for key, action in ipairs(self.log) do
local actionType
local actionBody
if type(action.data) == "function" then
actionType = "thunk"
actionBody = "<function>"
elseif type(action.data) == "table" then
actionType = action.data.type
actionBody = game:GetService("HttpService"):JSONEncode(action.data)
else
actionType = type(action.data)
actionBody = tostring(action.data)
end
local mutationDuration = 0
if action.mutatedTime then
mutationDuration = (action.mutatedTime - action.startTime) * 1000
end
local duration = 0
if action.endTime then
duration = (action.endTime - action.startTime) * 1000
end
local object = Create "Frame" {
Name = "log-" .. key,
LayoutOrder = key,
Size = UDim2.new(1, 0, 0, 34),
BackgroundColor3 = Color3.new(0.7, 0.7, 0.7),
Create "Frame" {
Name = "Inner",
Size = UDim2.new(1, -16, 1, -2),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
BackgroundTransparency = 1,
Create "UIListLayout" {
SortOrder = Enum.SortOrder.LayoutOrder,
FillDirection = Enum.FillDirection.Horizontal,
VerticalAlignment = Enum.VerticalAlignment.Center,
Padding = UDim.new(0, 8)
},
Create "TextLabel" {
Name = "LogNumber",
LayoutOrder = 0,
BackgroundTransparency = 1,
Size = UDim2.new(0, 30, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = tostring(key)
},
Create "TextLabel" {
Name = "MutationTime",
LayoutOrder = 1,
BackgroundTransparency = 1,
Size = UDim2.new(0, 60, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = ("%.2f ms"):format(mutationDuration)
},
Create "TextLabel" {
Name = "ElapsedTime",
LayoutOrder = 2,
BackgroundTransparency = 1,
Size = UDim2.new(0, 60, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = ("%.2f ms"):format(duration)
},
Create "TextLabel" {
Name = "Status",
LayoutOrder = 3,
BackgroundTransparency = 1,
Size = UDim2.new(0, 60, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = action.status
},
Create "TextLabel" {
Name = "ActionType",
LayoutOrder = 4,
BackgroundTransparency = 1,
Size = UDim2.new(0, 150, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = actionType
},
Create "TextButton" {
Name = "Details",
LayoutOrder = 5,
Size = UDim2.new(0, 90, 1, -10),
Text = "Details",
BackgroundColor3 = COLOR_BUTTON_ENABLED,
[Create.events] = {
MouseButton1Click = function()
print(("Action %d:\n"):format(key))
print(actionBody)
print("\n")
end
}
}
}
}
table.insert(children, object)
end
local container = Create "ScrollingFrame"({
Size = UDim2.new(0, 520, 1, 0),
Name = "ActionDebug",
Active = true,
Create "UIListLayout" {
SortOrder = Enum.SortOrder.LayoutOrder
}
}, children)
local height = 0
for _, child in ipairs(children) do
height = height + child.AbsoluteSize.Y
end
container.CanvasSize = UDim2.new(0, 350, 0, height)
return container
end
return ActionDebug
@@ -0,0 +1,204 @@
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local LuaChat = script.Parent.Parent
local Create = require(LuaChat.Create)
local HttpDebug = require(script.Parent.HttpDebug)
local ActionDebug = require(script.Parent.ActionDebug)
local FFlagLuaChatToSplitRbxConnections = settings():GetFFlag("LuaChatToSplitRbxConnections")
local DebugManager = {
connections = {},
rbx_connections = {},
screenGui = nil,
container = nil,
root = nil,
http = nil,
action = nil,
running = false,
open = false
}
function DebugManager:Initialize(root)
self.root = root
HttpDebug:SetEnabled(true)
ActionDebug:SetEnabled(true)
end
function DebugManager:Start()
if self.running then
warn("DebugManager is already running!")
return
end
self.running = true
self.httpDirty = false
self.actionDirty = false
self.screenGui = Instance.new("ScreenGui")
self.screenGui.Name = "ChatDebugScreen"
self.screenGui.DisplayOrder = 1e6
self.screenGui.Parent = self.root
self.container = Create "Frame" {
Name = "DebugContainer",
Size = UDim2.new(1, 0, 1, 0),
BackgroundTransparency = 1,
Create "UIListLayout" {
SortOrder = Enum.SortOrder.LayoutOrder,
FillDirection = Enum.FillDirection.Horizontal,
VerticalAlignment = Enum.VerticalAlignment.Top
}
}
self.container.Parent = self.screenGui
do
local connection = UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.H and UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
self:ToggleOpen()
end
end
end)
if FFlagLuaChatToSplitRbxConnections then
table.insert(self.rbx_connections, connection)
else
table.insert(self.connections, connection)
end
end
do
local connection = HttpDebug.Updated:connect(function()
if not self.open then
return
end
self.httpDirty = true
end)
table.insert(self.connections, connection)
end
do
local connection = ActionDebug.Updated:connect(function()
if not self.open then
return
end
self.actionDirty = true
end)
table.insert(self.connections, connection)
end
do
local connection = RunService.Heartbeat:Connect(function()
if not self.open then
return
end
if self.httpDirty then
self.httpDirty = false
if self.http then
self.http:Destroy()
end
self.http = HttpDebug:Render()
self.http.LayoutOrder = 2
self.http.Parent = self.container
end
if self.actionDirty then
self.actionDirty = false
if self.action then
self.action:Destroy()
end
self.action = ActionDebug:Render()
self.action.LayoutOrder = 1
self.action.Parent = self.container
end
end)
if FFlagLuaChatToSplitRbxConnections then
table.insert(self.rbx_connections, connection)
else
table.insert(self.connections, connection)
end
end
end
function DebugManager:Stop()
if not self.running then
warn("DebugManager is already stopped!")
return
end
self.running = false
self:Close()
for _, connection in ipairs(self.connections) do
connection:disconnect()
end
self.connections = {}
for _, connection in ipairs(self.rbx_connections) do
connection:Disconnect()
end
self.rbx_connections = {}
self.screenGui:Destroy()
self.screenGui = nil
self.container = nil
end
function DebugManager:Open()
if self.open then
return
end
self.open = true
if self.action then
self.action:Destroy()
end
self.action = ActionDebug:Render()
self.action.LayoutOrder = 1
self.action.Parent = self.container
if self.http then
self.http:Destroy()
end
self.http = HttpDebug:Render()
self.http.LayoutOrder = 2
self.http.Parent = self.container
self.container.Visible = true
end
function DebugManager:Close()
if not self.open then
return
end
self.open = false
self.container.Visible = false
end
function DebugManager:ToggleOpen()
if self.open then
self:Close()
else
self:Open()
end
end
return DebugManager
@@ -0,0 +1,210 @@
local CoreGui = game:GetService("CoreGui")
local Modules = CoreGui.RobloxGui.Modules
local Common = Modules.Common
local LuaChat = Modules.LuaChat
local Create = require(LuaChat.Create)
local Signal = require(Common.Signal)
local COLOR_BUTTON_DISABLED = Color3.new(0.6, 0.6, 0.6)
local COLOR_BUTTON_ENABLED = Color3.new(0.85, 0.85, 0.85)
local function reportButton(order, displayName, value)
local enabled = (value ~= nil)
return Create "TextButton" {
Name = displayName,
LayoutOrder = 4,
Size = UDim2.new(0, 90, 1, -10),
Text = displayName,
AutoButtonColor = enabled,
BackgroundColor3 = enabled and COLOR_BUTTON_ENABLED or COLOR_BUTTON_DISABLED,
BorderSizePixel = enabled and 1 or 0,
[Create.events] = {
MouseButton1Click = function()
if value == nil then
return
end
print("\n")
print(value)
print("\n")
end
}
}
end
local function getColor(status)
if status == "pending" then
return Color3.fromRGB(255, 255, 0)
elseif type(status) == "number" then
if status < 100 or status >= 400 then
return Color3.fromRGB(200, 0, 0)
else
return Color3.fromRGB(0, 200, 0)
end
else
return Color3.fromRGB(128, 128, 128)
end
end
local HttpDebug = {
Updated = Signal.new(),
log = {},
enabled = false
}
function HttpDebug:SetEnabled(value)
self.enabled = value
end
function HttpDebug:AddRequest(method, url, requestBody)
if not self.enabled then
return
end
local request = {
method = method,
url = url,
status = "pending",
startTime = tick(),
requestBody = requestBody,
stackTrace = debug.traceback()
}
table.insert(self.log, request)
local requestId = #self.log
self.Updated:fire()
return requestId
end
function HttpDebug:FinishRequest(requestId, status, response)
if not self.enabled then
return
end
local request = self.log[requestId]
if not request then
warn("Couldn't find request with ID " .. tostring(requestId))
return
end
request.status = status
request.response = response
request.endTime = tick()
self.Updated:fire()
end
function HttpDebug:Render()
local children = {}
for key, request in ipairs(self.log) do
local color = getColor(request.status)
local duration = 0
if request.endTime then
duration = (request.endTime - request.startTime) * 1000
end
local object = Create "Frame" {
Name = "log-" .. key,
LayoutOrder = key,
Size = UDim2.new(1, 0, 0, 40),
BackgroundColor3 = color,
Create "Frame" {
Name = "Inner",
Size = UDim2.new(1, -16, 1, -8),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),
BackgroundTransparency = 1,
Create "UIListLayout" {
SortOrder = Enum.SortOrder.LayoutOrder,
FillDirection = Enum.FillDirection.Horizontal,
VerticalAlignment = Enum.VerticalAlignment.Center,
Padding = UDim.new(0, 8)
},
Create "TextLabel" {
Name = "Method",
LayoutOrder = 0,
BackgroundTransparency = 1,
Size = UDim2.new(0, 60, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = request.method
},
Create "TextLabel" {
Name = "Status",
LayoutOrder = 1,
BackgroundTransparency = 1,
Size = UDim2.new(0, 60, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = request.status
},
Create "TextLabel" {
Name = "Duration",
LayoutOrder = 2,
BackgroundTransparency = 1,
Size = UDim2.new(0, 80, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = ("%.2f ms"):format(duration)
},
Create "TextButton" {
Name = "URL",
LayoutOrder = 3,
BackgroundTransparency = 1,
Size = UDim2.new(0, 375, 1, 0),
TextXAlignment = Enum.TextXAlignment.Left,
Text = request.url,
ClipsDescendants = true,
[Create.events] = {
MouseButton1Click = function()
print("\n")
print(request.url)
print("\n")
end
}
},
reportButton(4, "Stack Trace", request.stackTrace),
reportButton(5, "Request", request.requestBody),
reportButton(6, "Response", request.response)
}
}
table.insert(children, object)
end
local container = Create "ScrollingFrame"({
Size = UDim2.new(0, 940, 1, 0),
Name = "HttpDebug",
Active = true,
Create "UIListLayout" {
SortOrder = Enum.SortOrder.LayoutOrder
}
}, children)
local height = 0
for _, child in ipairs(children) do
height = height + child.AbsoluteSize.Y
end
container.CanvasSize = UDim2.new(0, 350, 0, height)
return container
end
return HttpDebug