ui is not an object with methods. It is a chain of Proxy objects that remember the path you typed. Only the final call does anything: it posts one message to the main thread and hands the script a Promise keyed by the call id.
←/→ step · Space play/pause · R replay · Home/End jumpStep 7 of 7
Each get trap returns a new proxy with one more segment. The apply trap joins the segments into the operation name, stores a resolver under a fresh callId, and calls postMessage. When the main thread answers with the same id, the resolver runs and the await continues. This is why the worker needs no DOM, no network, and no imports.