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PWBS2IPQI5VEALMFLCMN4HLGC5DQC
P6MGPZQVKLKELXN5SKFHTEWSUMFUCQGRGHZQZEL2GH5IXUOJ4T7AC
TGAAKKGGQZ6V6V25DGVHDXUXR74OYGG7RGRXVWKASDCONXZ63LYAC
-- the communication channel with the app
-- commands are processed on the other end, in the app
function live.send_definition_to_app(State)
local current_buffer = live.definition_to_string(State)
State.saved = true
local definition_name = live.get_cmd_from_buffer(current_buffer)
live.send_to_app(current_buffer)
end
function live.send_to_app(msg)
Load_time_error = nil
Run_time_error = nil
-- first clear the response buffer from any previous commands
local clear = io.open(love.filesystem.getAppdataDirectory()..'/_love_akkartik_app_driver', 'w')
clear:close()
-- send a fresh command
local f = io.open(love.filesystem.getAppdataDirectory()..'/_love_akkartik_driver_app', 'w')
if f == nil then return end
f:write(msg)
f:close()
print('$'..color(--[[bold]]1, --[[blue]]4))
print(msg)
print(reset_terminal())
end
-- look for a message from outside, and return nil if there's nothing
-- if there's an error, save it and return ''
function live.receive_from_app()
local f = io.open(love.filesystem.getAppdataDirectory()..'/_love_akkartik_app_driver')
if f == nil then return nil end
local result = f:read('*a')
f:close()
if result == '' then return nil end -- empty file == no message
print('=>'..color(0, --[[green]]2))
print(result)
print(reset_terminal())
if result:match('^ERROR ') then
Load_time_error = result:sub(#('ERROR '))
end
return result
end
function live.receive_run_time_error_from_app()
local f = io.open(love.filesystem.getAppdataDirectory()..'/_love_akkartik_app_driver_run_time_error')
if f == nil then return nil end
local result = f:read('*a')
f:close()
if result == '' then return nil end -- empty file == no message
print('=>'..color(0, --[[red]]1))
print(result)
print(reset_terminal())
Run_time_error = result
return result
end
function live.definition_to_string(State)
return table.concat(map(State.lines, function(line) return line.data end), '\n')
end
function map(arr, f)
local result = {}
for _, x in ipairs(arr) do
table.insert(result, f(x))
end
return result
end
os.remove(love.filesystem.getAppdataDirectory()..'/_love_akkartik_app_driver_run_time_error')
os.remove(love.filesystem.getAppdataDirectory()..'/_love_akkartik_app_driver')
result = '{}'
* `live.receive_from_app()` -- receives a message from the client app,
returning it or `nil` if no message was received. If the message is an
error, it's saved to `Load_time_error` and the call returns an empty
response `''`.
* `live.send_to_driver(msg)` -- sends a message to the driver.
* `live.receive_run_time_error_from_app()` -- checks for any run-time errors
in the client app, and populates them in `Run_time_error`. Automatically
invoked, so you shouldn't need to call this.
* `live.send_run_time_error_to_driver(msg)` -- sends an error to the driver.
Automatically invoked by the LÖVE error handler, so you shouldn't need to
call this.
* `live.receive_from_driver()` -- looks for a message from the meta-driver,
and returns nil if there's nothing.
* `live.send_to_driver(msg)` -- sends a message to the meta-driver.
* `live.send_run_time_error_to_driver(msg)` -- sends an error to the
meta-driver. Automatically invoked by the LÖVE error handler, so you
shouldn't need to call this.
-- repl
if chord == 'f4' then
State.load_time_error = nil
live.send_definition_to_app(State)
while true do
local response_string = live.receive_from_app()
if response_string then
Client_app_test_failures = json.decode(response_string)
break
end
if live.receive_run_time_error_from_app() then
break
end
love.timer.sleep(0.001)
end
if Load_time_error then
State.load_time_error = Load_time_error
Load_time_error = nil
end
if on.code_submit then on.code_submit(State) end