-- Compiled with roblox-ts v1.2.7 local TS = _G[script] -- eslint-disable roblox-ts/lua-truthiness local Roact = TS.import(script, TS.getModule(script, "@rbxts", "roact").src) local LocalizationService = game:GetService("LocalizationService") local ZirconLogLevel = TS.import(script, script.Parent.Parent, "Types").ZirconLogLevel local _ThemeContext = TS.import(script, script.Parent.Parent, "UIKit", "ThemeContext") local ThemeContext = _ThemeContext.default local getRichTextColor3 = _ThemeContext.getRichTextColor3 local getThemeRichTextColor = _ThemeContext.getThemeRichTextColor local italicize = _ThemeContext.italicize local ZrRichTextHighlighter = TS.import(script, TS.getModule(script, "@rbxts", "zirconium").out.Ast).ZrRichTextHighlighter local _Format = TS.import(script, script.Parent.Parent, "Format") local formatParse = _Format.formatParse local formatTokens = _Format.formatTokens local StructuredLogMessage = TS.import(script, script.Parent, "StructuredLogMessage").StructuredLogMessage local function sanitise(input) return (string.gsub(input, "[<>]", { [">"] = ">", ["<"] = "<", })) end local function OutputMessage(props) local output = props.Message if output.type == "slog:output" then return Roact.createElement(StructuredLogMessage, { LogEvent = output.data, Context = output.context, DetailedView = true, }) end return Roact.createElement(ThemeContext.Consumer, { render = function(theme) local messages = {} if output.type == "zr:output" then local _binding = output local message = _binding.message local _arg0 = getRichTextColor3(theme, "Grey", "[" .. (DateTime.fromUnixTimestamp(message.time):FormatLocalTime("LT", LocalizationService.SystemLocaleId) .. "]")) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0 -- ▲ Array.push ▲ local _message = message.message -- ▼ Array.push ▼ messages[#messages + 1] = _message -- ▲ Array.push ▲ elseif output.type == "zirclog:message" then local _binding = output local message = _binding.message local _arg0 = getRichTextColor3(theme, "Grey", "[" .. (DateTime.fromUnixTimestamp(message.time):FormatLocalTime("LT", LocalizationService.SystemLocaleId) .. "]")) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0 -- ▲ Array.push ▲ local _result = message.data.Variables if _result ~= nil then _result = #_result end local _condition = _result if _condition == nil then _condition = 0 end local text = _condition > 0 and formatTokens(formatParse(message.message), message.data.Variables) or message.message if message.level == ZirconLogLevel.Info then local _arg0_1 = getRichTextColor3(theme, "Cyan", "INFO ") -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ local _arg0_2 = getRichTextColor3(theme, "White", text) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_2 -- ▲ Array.push ▲ elseif message.level == ZirconLogLevel.Debug then local _arg0_1 = getRichTextColor3(theme, "Green", "DEBUG") -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ local _arg0_2 = getRichTextColor3(theme, "White", text) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_2 -- ▲ Array.push ▲ elseif message.level == ZirconLogLevel.Warning then local _arg0_1 = getRichTextColor3(theme, "Yellow", "WARN ") -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ local _arg0_2 = getRichTextColor3(theme, "White", text) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_2 -- ▲ Array.push ▲ end local _value = props.ShowTags and message.tag if _value ~= "" and _value then -- const toAppend = padEnd(message.tag ?? "", 20, " "); local _arg0_1 = "- " .. italicize(getRichTextColor3(theme, "Grey", message.tag)) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ end end return Roact.createElement("Frame", { Size = UDim2.new(1, 0, 0, 25), BackgroundTransparency = 0.5, BackgroundColor3 = theme.PrimaryBackgroundColor3, BorderSizePixel = 0, }, { Roact.createElement("Frame", { Size = UDim2.new(0, 5, 1, 0), BackgroundColor3 = props.Message.context == 0 and theme.ServerContextColor or theme.ClientContextColor, BorderSizePixel = 0, }), Roact.createElement("TextLabel", { RichText = true, Position = UDim2.new(0, 10, 0, 0), Size = UDim2.new(1, -15, 0, 25), Text = table.concat(messages, " "), BackgroundTransparency = 1, Font = theme.ConsoleFont, TextColor3 = theme.PrimaryTextColor3, TextXAlignment = "Left", TextSize = 20, }), }) end, }) end local function OutputError(props) local output = props.Message return Roact.createElement(ThemeContext.Consumer, { render = function(theme) local messages = {} if output.type == "zr:error" then local _binding = output local zrError = _binding.error local _arg0 = getRichTextColor3(theme, "Grey", "[" .. (DateTime.fromUnixTimestamp(zrError.time):FormatLocalTime("LT", LocalizationService.SystemLocaleId) .. "]")) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0 -- ▲ Array.push ▲ if zrError.script ~= nil then local inner = getRichTextColor3(theme, "Cyan", zrError.script) if zrError.source ~= nil then inner ..= ":" .. (getRichTextColor3(theme, "Yellow", tostring(zrError.source[1])) .. (":" .. getRichTextColor3(theme, "Yellow", tostring(zrError.source[2])))) end local _arg0_1 = getRichTextColor3(theme, "White", inner .. " -") -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ end local _arg0_1 = getRichTextColor3(theme, "Red", "error") -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ local _code = zrError.code local _arg0_2 = getRichTextColor3(theme, "Grey", "ZR" .. (string.format("%.4d", _code) .. ":")) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_2 -- ▲ Array.push ▲ local _arg0_3 = getRichTextColor3(theme, "White", zrError.message) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_3 -- ▲ Array.push ▲ elseif output.type == "zirclog:error" then local _binding = output local zrError = _binding.error local _arg0 = getRichTextColor3(theme, "Grey", "[" .. (DateTime.fromUnixTimestamp(zrError.time):FormatLocalTime("LT", LocalizationService.SystemLocaleId) .. "]")) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0 -- ▲ Array.push ▲ if zrError.level == ZirconLogLevel.Error then local _arg0_1 = getRichTextColor3(theme, "Red", "ERROR") -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ local _arg0_2 = getRichTextColor3(theme, "Yellow", zrError.message) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_2 -- ▲ Array.push ▲ elseif zrError.level == ZirconLogLevel.Wtf then local _arg0_1 = getRichTextColor3(theme, "Red", "FAIL ") -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ local _arg0_2 = getRichTextColor3(theme, "Yellow", zrError.message) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_2 -- ▲ Array.push ▲ end local _value = props.ShowTags and zrError.tag if _value ~= "" and _value then -- const toAppend = padEnd(zrError.tag ?? "", 20, " "); local _arg0_1 = "- " .. italicize(getRichTextColor3(theme, "Grey", zrError.tag)) -- ▼ Array.push ▼ messages[#messages + 1] = _arg0_1 -- ▲ Array.push ▲ end end return Roact.createElement("Frame", { Size = UDim2.new(1, 0, 0, 25), BackgroundTransparency = 0.5, BackgroundColor3 = theme.PrimaryBackgroundColor3, BorderSizePixel = 0, }, { Roact.createElement("Frame", { Size = UDim2.new(0, 5, 1, 0), BackgroundColor3 = props.Message.context == 0 and theme.ServerContextColor or theme.ClientContextColor, BorderSizePixel = 0, }), Roact.createElement("TextLabel", { RichText = true, Position = UDim2.new(0, 10, 0, 0), Size = UDim2.new(1, -15, 0, 25), Text = table.concat(messages, " "), BackgroundTransparency = 1, Font = theme.ConsoleFont, TextColor3 = theme.PrimaryTextColor3, TextXAlignment = "Left", TextSize = 20, }), }) end, }) end local getErrorLine local function ErrorLine(_param) local TokenInfo = _param.TokenInfo local Highlight = _param.Highlight if Highlight == nil then Highlight = true end return Roact.createElement(ThemeContext.Consumer, { render = function(theme) return Roact.createElement("Frame", { Size = UDim2.new(1, 0, 0, 30), Position = UDim2.new(0.1, 0, 0, 0), BackgroundTransparency = 1, }, { Roact.createElement("TextLabel", { Text = tostring(TokenInfo.LineAndColumn[1]), TextColor3 = theme.PrimaryBackgroundColor3, BackgroundColor3 = theme.PrimaryTextColor3, Size = UDim2.new(0, 20, 1, 0), Position = UDim2.new(0, 20, 0, 0), Font = theme.ConsoleFont, TextSize = 20, TextXAlignment = "Center", }), Roact.createElement("TextLabel", { RichText = true, BackgroundTransparency = 1, Size = UDim2.new(1, 0, 0, 30), Position = UDim2.new(0, 20 + 25, 0, 0), Text = Highlight and ZrRichTextHighlighter.new(TokenInfo.Line):parse() or TokenInfo.Line, Font = theme.ConsoleFont, TextSize = 20, TextXAlignment = "Left", TextColor3 = theme.PrimaryTextColor3, }), Roact.createElement("TextLabel", { BackgroundTransparency = 1, TextXAlignment = "Left", RichText = true, Font = theme.ConsoleFont, TextSize = 20, TextColor3 = theme.PrimaryTextColor3, Text = getErrorLine(theme, TokenInfo).ErrorLine, Size = UDim2.new(1, 0, 0, 30), Position = UDim2.new(0, 20 + 25, 0, 0), }), }) end, }) end function getErrorLine(theme, _param) local Line = _param.Line local TokenLinePosition = _param.TokenLinePosition local red = getThemeRichTextColor(theme, "Red") local resultingString = "" local errorArrows = "" do local i = 1 local _shouldIncrement = false while true do if _shouldIncrement then i += 1 else _shouldIncrement = true end if not (i <= #Line) then break end local char = " " if i == TokenLinePosition[1] and i == TokenLinePosition[2] then resultingString ..= '' .. char .. "" errorArrows ..= '^' elseif i == TokenLinePosition[1] then resultingString ..= '' .. char errorArrows ..= '^' elseif i > TokenLinePosition[1] and i < TokenLinePosition[2] then resultingString ..= " " errorArrows ..= "^" elseif i == TokenLinePosition[2] then resultingString ..= char .. "" errorArrows ..= char .. "^" else resultingString ..= char end end end return { ErrorLine = resultingString, } end local ZirconOutputMessage do ZirconOutputMessage = Roact.PureComponent:extend("ZirconOutputMessage") function ZirconOutputMessage:init() end function ZirconOutputMessage:render() local _binding = self.props local Message = _binding.Message if Message.type == "zr:error" or Message.type == "zirclog:error" then local _binding_1 = Message local zrError = _binding_1.error if zrError.type == "ZrParserError" or zrError.type == "ZrRuntimeError" then if zrError.debug ~= nil then return Roact.createFragment({ Roact.createElement(OutputError, { ShowTags = self.props.ShowTags, Message = Message, }), Roact.createElement(ErrorLine, { Highlight = true, TokenInfo = zrError.debug, }), }) end end return Roact.createElement(OutputError, { ShowTags = self.props.ShowTags, Message = Message, }) elseif Message.type == "zr:output" or (Message.type == "zirclog:message" or Message.type == "slog:output") then return Roact.createElement(OutputMessage, { ShowTags = self.props.ShowTags, Message = Message, }) end return nil end end return { default = ZirconOutputMessage, }