Return component ONCE slots with handler resolution

This commit is contained in:
udo
2026-07-18 11:47:28 +00:00
parent 0e0c0b6ccc
commit 418c5812dc
4 changed files with 93 additions and 36 deletions
+15 -4
View File
@@ -466,7 +466,8 @@ extern "C" int32_t uce_host_component_resolve(
const char* target, size_t target_len,
const char* handler, size_t handler_len,
const char* current_unit, size_t current_unit_len,
char* resolved_buf, size_t resolved_cap);
char* resolved_buf, size_t resolved_cap,
int32_t* once_slot_out);
// target → table slot, reset per request (workspaces die with the request,
// but a single workspace can render the same component many times)
@@ -554,16 +555,26 @@ static s32 wasm_resolve_target(String unit_target, String handler, String* resol
return(cached->second);
}
char resolved[512];
s32 once_slot = 0;
s32 slot = uce_host_component_resolve(
unit_target.data(), unit_target.size(), handler.data(), handler.size(),
current.data(), current.size(),
resolved, sizeof(resolved));
resolved, sizeof(resolved), &once_slot);
String resolved_path = slot ? String(resolved, strnlen(resolved, sizeof(resolved))) : String("");
if(resolved_out && slot)
*resolved_out = String(resolved, strnlen(resolved, sizeof(resolved)));
*resolved_out = resolved_path;
if(!is_exists)
{
wasm_component_slots[cache_key] = slot;
wasm_component_paths[cache_key] = slot ? String(resolved, strnlen(resolved, sizeof(resolved))) : String("");
wasm_component_paths[cache_key] = resolved_path;
bool runs_once = handler == "render" || handler.rfind("render:", 0) == 0 ||
handler == "component" || handler.rfind("component:", 0) == 0;
if(slot && runs_once)
{
String once_key = current + "\t" + "once" + "\t" + resolved_path;
wasm_component_slots[once_key] = once_slot;
wasm_component_paths[once_key] = once_slot ? resolved_path : String("");
}
}
return(slot);
}