add sandbox support to desktop designer, fix mouse coordinates and UI issues

- Add DesktopSandbox class that integrates timer, JSON, crypto, and VirtualFS APIs
- Fix mouse coordinate handling: GLFW reports window coordinates, not physical pixels
- Fix font path resolution to search multiple locations for test apps
- Fix screenshot capture timing (capture before buffer swap)
- Fix test app CSS: use border-width instead of border:none, add display:block
- Fix test app Lua: add document nil checks, use HTML entities for symbols
- Update hot_reload to reset sandbox state on reload

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-19 10:22:32 +01:00
parent d40ea1e537
commit 8432bbb986
8 changed files with 372 additions and 53 deletions

View File

@@ -7,9 +7,12 @@ local logCounter = 0
local function log(msg)
logCounter = logCounter + 1
table.insert(results, string.format("[%03d] %s", logCounter, msg))
local el = document:GetElementById("results")
if el then
el.inner_rml = table.concat(results, "\n")
-- document may not be available during initial script load
if document then
local el = document:GetElementById("results")
if el then
el.inner_rml = table.concat(results, "\n")
end
end
end
@@ -23,12 +26,14 @@ function goBack()
end
local function setStatus(id, status, success)
-- document may not be available during initial script load
if not document then return end
local el = document:GetElementById(id)
if el then
if success then
el.inner_rml = " " .. status
el.inner_rml = "&#x2713; " .. status
else
el.inner_rml = " " .. status
el.inner_rml = "&#x2717; " .. status
end
end
end
@@ -151,8 +156,8 @@ function testStorage()
local success = true
local msg = ""
-- Test write
local writeOk = fs.write("test.txt", "Hello from sandbox!")
-- Test write (VirtualFS requires /data/, /cache/, /temp/, or /shared/ prefix)
local writeOk = fs.write("/data/test.txt", "Hello from sandbox!")
if writeOk then
log("Write successful")
else
@@ -162,7 +167,7 @@ function testStorage()
-- Test read
if success then
local content = fs.read("test.txt")
local content = fs.read("/data/test.txt")
if content == "Hello from sandbox!" then
log("Read successful: " .. content)
else
@@ -173,9 +178,9 @@ function testStorage()
-- Test list
if success then
local files = fs.list("/")
local files = fs.list("/data")
if files then
log("Files in root: " .. #files)
log("Files in /data: " .. #files)
for _, f in ipairs(files) do
log(" - " .. f)
end
@@ -184,7 +189,7 @@ function testStorage()
-- Test delete
if success then
local deleteOk = fs.delete("test.txt")
local deleteOk = fs.delete("/data/test.txt")
if deleteOk then
log("Delete successful")
else

View File

@@ -3,6 +3,8 @@ body {
font-size: 16dp;
background-color: #121212;
color: #ffffff;
width: 100%;
height: 100%;
}
.app-bar {
@@ -38,10 +40,14 @@ body {
}
.content {
display: block;
padding: 16dp;
width: auto;
box-sizing: border-box;
}
.card {
display: block;
background-color: #1e1e1e;
border-radius: 12dp;
padding: 16dp;
@@ -49,16 +55,22 @@ body {
}
.card-title {
display: block;
font-size: 18dp;
font-weight: bold;
margin-bottom: 8dp;
color: #bb86fc;
}
.card div {
display: block;
}
button {
display: block;
background-color: #bb86fc;
color: #000000;
border: none;
border-width: 0;
border-radius: 8dp;
padding: 12dp 24dp;
font-size: 14dp;
@@ -75,7 +87,7 @@ button:active {
}
#results {
font-family: monospace;
font-family: LatoLatin;
font-size: 12dp;
background-color: #0d0d0d;
padding: 12dp;