mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Update more code to new formatting machinery
This commit is contained in:
parent
af866f0665
commit
0c7a94c062
5 changed files with 22 additions and 18 deletions
|
|
@ -133,7 +133,7 @@ function App:startSession(address, port)
|
|||
-- Details being present indicates that this
|
||||
-- disconnection was from an error.
|
||||
if details ~= nil then
|
||||
Log.warn(tostring(details))
|
||||
Log.warn("Disconnected from an error: {}", details)
|
||||
|
||||
self:setState({
|
||||
appStatus = AppStatus.Error,
|
||||
|
|
@ -207,7 +207,7 @@ function App:render()
|
|||
end
|
||||
|
||||
function App:didMount()
|
||||
Log.trace("Rojo %s initializing", self.displayedVersion)
|
||||
Log.trace("Rojo {} initializing", self.displayedVersion)
|
||||
|
||||
checkUpgrade(self.props.plugin)
|
||||
preloadAssets()
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@ function InstanceMap.new(onInstanceChanged)
|
|||
return setmetatable(self, InstanceMap)
|
||||
end
|
||||
|
||||
function InstanceMap:debugState()
|
||||
local buffer = {}
|
||||
function InstanceMap:__fmtDebug(output)
|
||||
output:writeLine("InstanceMap {{")
|
||||
output:indent()
|
||||
|
||||
for id, instance in pairs(self.fromIds) do
|
||||
table.insert(buffer, string.format("- %s: %s", id, instance:GetFullName()))
|
||||
output:writeLine("- {}: {}", id, instance:GetFullName())
|
||||
end
|
||||
|
||||
return table.concat(buffer, "\n")
|
||||
output:unindent()
|
||||
output:writeLine("}")
|
||||
end
|
||||
|
||||
function InstanceMap:insert(id, instance)
|
||||
|
|
@ -44,7 +46,7 @@ function InstanceMap:removeId(id)
|
|||
self.fromIds[id] = nil
|
||||
self.fromInstances[instance] = nil
|
||||
else
|
||||
Log.warn("Attempted to remove nonexistant ID %s", tostring(id))
|
||||
Log.warn("Attempted to remove nonexistant ID {}", id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -56,7 +58,7 @@ function InstanceMap:removeInstance(instance)
|
|||
self.fromInstances[instance] = nil
|
||||
self.fromIds[id] = nil
|
||||
else
|
||||
Log.warn("Attempted to remove nonexistant instance %s", tostring(instance))
|
||||
Log.warn("Attempted to remove nonexistant instance {}", instance)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -66,7 +68,7 @@ function InstanceMap:destroyInstance(instance)
|
|||
if id ~= nil then
|
||||
self:destroyId(id)
|
||||
else
|
||||
Log.warn("Attempted to destroy untracked instance %s", tostring(instance))
|
||||
Log.warn("Attempted to destroy untracked instance {}", instance)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -89,7 +91,7 @@ function InstanceMap:destroyId(id)
|
|||
|
||||
instance:Destroy()
|
||||
else
|
||||
Log.warn("Attempted to destroy nonexistant ID %s", tostring(id))
|
||||
Log.warn("Attempted to destroy nonexistant ID {}", id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -134,10 +134,10 @@ function Reconciler:applyPatch(patch)
|
|||
|
||||
if parentInstance == nil then
|
||||
invariant(
|
||||
"Cannot add an instance from a patch that has no parent.\nInstance %s with parent %s.\nInstanceMap state:\n%s",
|
||||
"Cannot add an instance from a patch that has no parent.\nInstance {} with parent {}.\nState: {:#?}",
|
||||
id,
|
||||
tostring(apiInstance.Parent),
|
||||
self.__instanceMap:debugState()
|
||||
apiInstance.Parent,
|
||||
self.__instanceMap
|
||||
)
|
||||
end
|
||||
|
||||
|
|
@ -150,9 +150,9 @@ function Reconciler:applyPatch(patch)
|
|||
|
||||
if instance == nil then
|
||||
invariant(
|
||||
"Cannot update an instance that does not exist in the reconciler's state.\nInstance ID %s\nInstanceMap state:\n%s",
|
||||
"Cannot update an instance that does not exist in the reconciler's state.\nInstance {}\nState: {:#?}",
|
||||
update.id,
|
||||
self.__instanceMap:debugState()
|
||||
self.__instanceMap
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
local Fmt = require(script.Parent.Parent.Fmt)
|
||||
|
||||
local Config = require(script.Parent.Config)
|
||||
|
||||
local invariant
|
||||
|
||||
if Config.isDevBuild then
|
||||
function invariant(message, ...)
|
||||
message = string.format(message, ...)
|
||||
message = Fmt.fmt(message, ...)
|
||||
|
||||
error("Invariant violation: " .. message, 2)
|
||||
end
|
||||
else
|
||||
function invariant(message, ...)
|
||||
message = string.format(message, ...)
|
||||
message = Fmt.fmt(message, ...)
|
||||
|
||||
local fullMessage = string.format(
|
||||
"Rojo detected an invariant violation within itself:\n" ..
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ local function preloadAssets()
|
|||
table.insert(contentUrls, url)
|
||||
end
|
||||
|
||||
Log.trace("Preloading assets: %s", table.concat(contentUrls, ", "))
|
||||
Log.trace("Preloading assets: {:?}", contentUrls)
|
||||
|
||||
coroutine.wrap(function()
|
||||
ContentProvider:PreloadAsync(contentUrls)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue