Recursive menu-item builder shared by ContextMenuManager and
MainMenuManager.
Walks items depth-first, allocating a new id from
state.nextId++ for each leaf command.
Maps each allocated id to the identifier state.family can actually
dispatch, inside state.idMap, so callers can later dispatch via
ExecuteByID. Items offering no such identifier stay unmapped.
Recursive menu-item builder shared by
ContextMenuManagerandMainMenuManager.itemsdepth-first, allocating a newidfromstate.nextId++for each leaf command.idto the identifierstate.familycan actually dispatch, insidestate.idMap, so callers can later dispatch viaExecuteByID. Items offering no such identifier stay unmapped.state.limitis hit (when set).Pure function: never mutates the input
items.