fix: retain resolved component paths
This commit is contained in:
@@ -458,6 +458,7 @@ extern "C" int32_t uce_host_component_resolve(
|
||||
// target → table slot, reset per request (workspaces die with the request,
|
||||
// but a single workspace can render the same component many times)
|
||||
static std::map<String, s32> wasm_component_slots;
|
||||
static std::map<String, String> wasm_component_paths;
|
||||
|
||||
// These mirror small page-runtime pieces that cannot include compiler.cpp in
|
||||
// the wasm core (compiler.cpp owns parser/clang/cache bookkeeping for the host
|
||||
@@ -521,7 +522,11 @@ static s32 wasm_resolve_target(String unit_target, String handler, String* resol
|
||||
bool is_exists = (handler == "exists");
|
||||
auto cached = wasm_component_slots.find(cache_key);
|
||||
if(cached != wasm_component_slots.end() && !is_exists)
|
||||
{
|
||||
if(resolved_out)
|
||||
*resolved_out = wasm_component_paths[cache_key];
|
||||
return(cached->second);
|
||||
}
|
||||
char resolved[512];
|
||||
String current = context ? context->resources.current_unit_file : "";
|
||||
s32 slot = uce_host_component_resolve(
|
||||
@@ -531,7 +536,10 @@ static s32 wasm_resolve_target(String unit_target, String handler, String* resol
|
||||
if(resolved_out && slot)
|
||||
*resolved_out = String(resolved, strnlen(resolved, sizeof(resolved)));
|
||||
if(!is_exists)
|
||||
{
|
||||
wasm_component_slots[cache_key] = slot;
|
||||
wasm_component_paths[cache_key] = slot ? String(resolved, strnlen(resolved, sizeof(resolved))) : String("");
|
||||
}
|
||||
return(slot);
|
||||
}
|
||||
|
||||
@@ -768,6 +776,7 @@ void uce_wasm_core_reset_request()
|
||||
wasm_request.out = "";
|
||||
wasm_request.resources.current_unit_file = "";
|
||||
wasm_component_slots.clear();
|
||||
wasm_component_paths.clear();
|
||||
}
|
||||
|
||||
// Host pushes the UCEB2-encoded request context into a guest buffer
|
||||
|
||||
Reference in New Issue
Block a user