#include "demo_guard.h" String unit_query(String selected_path, String compile_path = "") { String result = "?"; if(selected_path != "") result += "selected=" + uri_encode(selected_path); if(compile_path != "") { if(result.length() > 1) result += "&"; result += "compile=" + uri_encode(compile_path); } return(result); } String unit_status_class(String compile_status, String error_status) { if(trim(error_status) != "") return("status-error"); if(compile_status == "loaded" || compile_status == "compiled") return("status-ok"); if(compile_status == "stale") return("status-warn"); if(compile_status == "missing_source") return("status-error"); return("status-muted"); } String unit_flag_label(DValue value) { return(value.to_string() == "(true)" ? "✅" : "❌"); } RENDER(Request& context) { bool allow_mutation = test_demo_request_allowed(context); String compile_target = first(context.get["compile"], ""); String selected_path = first(context.get["selected"], ""); String compile_message = ""; String compile_message_class = "status-muted"; if(compile_target != "") { selected_path = compile_target; if(allow_mutation) { bool compile_ok = unit_compile(compile_target); compile_message = (compile_ok ? "Compile succeeded for " : "Compile failed for ") + compile_target; compile_message_class = compile_ok ? "status-ok" : "status-error"; } else { context.set_status(403, "Restricted"); compile_message = "Manual compile is restricted to localhost and private-network access."; compile_message_class = "status-error"; } } auto unit_paths = units_list(); if(selected_path == "" && unit_paths.size() > 0) selected_path = unit_paths.front(); DValue selected_info = unit_info(selected_path); String selected_compile_status = selected_info["compile_status"].to_string(); String selected_error_status = selected_info["error_status"].to_string(); String selected_status_class = unit_status_class(selected_compile_status, selected_error_status); String selected_export_count = std::to_string(selected_info["exports"]._map.size()); String selected_compile_link = unit_query(selected_path, selected_path); <>
No unit metadata is available for the current selection.
} else { ?>= selected_info["path"].to_string() ?>
= selected_info["wasm_name"].to_string() ?>
unit_info() payload= var_dump(selected_info) ?>