From 07896959ce67bdfd903e35f5d0819043d91273cb Mon Sep 17 00:00:00 2001 From: omigamedev Date: Tue, 20 Jan 2026 11:32:47 +0100 Subject: [PATCH] fix sandbox test API names to match actual registration - Timer: use global setTimeout() instead of mosis.timer.setTimeout() - JSON: use json.encode/decode instead of mosis.json - Crypto: use crypto.sha256 instead of mosis.crypto - Storage: use fs.read/write with /data/ prefix instead of mosis.fs Co-Authored-By: Claude Opus 4.5 --- src/main/assets/apps/shell/shell.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/assets/apps/shell/shell.lua b/src/main/assets/apps/shell/shell.lua index 8956143..0cb2bcd 100644 --- a/src/main/assets/apps/shell/shell.lua +++ b/src/main/assets/apps/shell/shell.lua @@ -540,14 +540,14 @@ function testSandboxTimer() local status = shell_document:GetElementById("timer-status") local results = shell_document:GetElementById("sandbox-results") - if not mosis or not mosis.timer then + if not setTimeout then if status then status.inner_rml = "Timer API not available" end return end if status then status.inner_rml = "Timer started..." end - mosis.timer.setTimeout(function() + setTimeout(function() if status then status.inner_rml = "Timer completed!" end if results then results.inner_rml = results.inner_rml .. "\nTimer: PASSED (1 second delay)" end showToast("Timer test passed!", "success") @@ -558,14 +558,14 @@ function testSandboxJSON() local status = shell_document:GetElementById("json-status") local results = shell_document:GetElementById("sandbox-results") - if not mosis or not mosis.json then + if not json then if status then status.inner_rml = "JSON API not available" end return end local test_data = {name = "test", value = 42, nested = {a = 1, b = 2}} - local encoded = mosis.json.encode(test_data) - local decoded = mosis.json.decode(encoded) + local encoded = json.encode(test_data) + local decoded = json.decode(encoded) if decoded and decoded.name == "test" and decoded.value == 42 then if status then status.inner_rml = "JSON encode/decode: PASSED" end @@ -581,12 +581,12 @@ function testSandboxCrypto() local status = shell_document:GetElementById("crypto-status") local results = shell_document:GetElementById("sandbox-results") - if not mosis or not mosis.crypto then + if not crypto then if status then status.inner_rml = "Crypto API not available" end return end - local hash = mosis.crypto.sha256("test") + local hash = crypto.sha256("test") if hash and #hash > 0 then if status then status.inner_rml = "SHA256: " .. hash:sub(1, 16) .. "..." end if results then results.inner_rml = results.inner_rml .. "\nCrypto: PASSED" end @@ -601,26 +601,28 @@ function testSandboxStorage() local status = shell_document:GetElementById("storage-status") local results = shell_document:GetElementById("sandbox-results") - if not mosis or not mosis.fs then + if not fs then if status then status.inner_rml = "Storage API not available" end return end local test_content = "Hello from sandbox test!" - local write_ok = mosis.fs.writeFile("test.txt", test_content) + local write_ok, write_err = fs.write("/data/test.txt", test_content) if write_ok then - local read_content = mosis.fs.readFile("test.txt") + local read_content, read_err = fs.read("/data/test.txt") if read_content == test_content then if status then status.inner_rml = "Storage read/write: PASSED" end if results then results.inner_rml = results.inner_rml .. "\nStorage: PASSED" end showToast("Storage test passed!", "success") else - if status then status.inner_rml = "Storage read: FAILED" end + local err_msg = read_err or "content mismatch" + if status then status.inner_rml = "Storage read: " .. err_msg end showToast("Storage read failed!", "error") end else - if status then status.inner_rml = "Storage write: FAILED" end + local err_msg = write_err or "unknown error" + if status then status.inner_rml = "Storage write: " .. err_msg end showToast("Storage write failed!", "error") end end