Skip to main content

API resolution — Util/Api.lua

WGG exposes some capabilities under multiple names (e.g. FileRead vs ReadFile). These helpers resolve the first available candidate, checking WGG[name] before _G[name] for each. Both are dot-called (no self) and are public framework API consumed by remotely loaded modules — keep them additive and backward compatible.
---@param ... string   -- candidate API names, tried in order
---@return function|nil fn
function volvox.ResolveApiFunction(...)
Returns the first candidate that maps to a function. Use for callables (file I/O, JSON codecs) where a non-function value is unusable.
---@param ... string   -- candidate API names, tried in order
---@return any value
function volvox.ResolveApi(...)
Same WGG-first resolution but returns the first non-nil value of any type (also resolves tables/constants such as C_CombatLog). Callers must type-check.
local ReadFile = volvox.ResolveApiFunction("FileRead", "ReadFile")
if ReadFile then
  local contents = ReadFile(path)
end

Secret-value unwrapping — Util/Secure.lua

Retail WoW wraps some API return values in “secret value” protections. These helpers unwrap them into plain Lua values.
---@param value any
---@return any unwrapped
volvox.UnwrapSecret(value)
Recursively unwraps a secret value; non-secret tables are deep-copied with each element unwrapped. Returns nil when unwrap is unsupported or fails. Aliases: volvox.SecretUnwrap, volvox.secretunwrap, volvox.secretUnwrap.
---@param ... any
---@return any ...
volvox.UnwrapSecretValues(...)
Unwraps a vararg list preserving arity (including trailing nils). Aliases: volvox.unwrapsecretvalues, volvox.UnwrapSecrets.
---@return any ...
volvox.GetCombatLogEventInfo()
pcall-wraps the resolved combat-log event-info function (CombatLogGetCurrentEventInfo or C_CombatLog.GetCurrentEventInfo) and returns up to 30 unwrapped fields; nil on failure. This is what volvox.EventHandler uses to read the combat log.
On retail, the file also self-installs secret-unwrapping wrappers over a curated list of Unit/Spell APIs and C_Spell methods (idempotent; originals stashed internally).