@sigx/lynx-runtime-main
v0.2.7
Published
Main Thread (Lepus) entry and ops applier for SignalX Lynx renderer
Readme
@sigx/lynx-runtime-main
Main-thread (Lepus) runtime for SignalX on Lynx. Receives the op stream from @sigx/lynx-runtime, mutates the native render tree via Lynx PAPI, and runs 'main thread'-marked worklets at the host's display refresh rate.
Application code rarely imports from this package directly. The build pipeline (
@sigx/lynx-plugin) wires it into the main-thread bundle automatically.
Responsibilities
entry-main.ts— installsglobalThis.processData,renderPage,updatePage,sigxPatchUpdate,sigxRunOnMT, andrunOnBackground. This is the file the build plugin lists as the first import in the MT bundle so the Lynx runtime finds the global hooks it expects.ops-apply.ts— theapplyOpsloop that consumes the BG → MT op stream (CREATE,INSERT,SET_STYLE,SET_WORKLET_EVENT,INIT_MT_REF,REGISTER_AV_BRIDGE, ...) and translates them into PAPI calls (__CreatePage,__SetInlineStyles,__AddEvent, etc.).MTElementWrapper— high-level wrapper your worklets drive viamainThreadRef.current.method(...)(setStyleProperties,getComputedStyleProperty,animate,invoke, query selectors).- Hybrid worklet dispatch — the slot machine in
event-slots.tsplus the hybrid context inhybrid-worklet.tslets a single MT slot carry both a worklet handler and a BG-side handler for the same event, dispatching to both. - AnimatedValue bridge —
animated-bridge-mt.tsdiffs registered AVs against last-published snapshots and dispatches batchedLynx.Sigx.AvPublishevents to BG once per__FlushElementTreeboundary. The matching BG sink lives in@sigx/lynx-runtime. useAnimatedStylemapper registry —animated-style-mappers.tsships built-in mappers (translateX,scale,opacity, ...) and exposesregisterMapper(name, fn)so MT-side code can add custom ones.
Bootstrap order
Three modules must evaluate in this order on the MT thread:
entry-main— setsglobalThis.SystemInfoand the renderer hooks.@lynx-js/react/worklet-runtime— installslynxWorkletImpl,registerWorkletInternal,runWorklet.install-hybrid-worklet— registers the hybrid dispatcher into the now-populated worklet map.
@sigx/lynx-plugin prepends side-effect imports for these three at the top of every file in the MT bundle, so the order is enforced regardless of which user file the Lynx runtime evaluates first.
License
MIT
