/** * MT-side worklet invocation — shared by the `sigxRunOnMT` bridge global * (entry-main.ts) and the `INVOKE_WORKLET` op handler (ops-apply.ts, #688). * * Dispatches ride the ordered `sigxPatchUpdate` ops stream (see * `runOnMainThread` in lynx-runtime/threading.ts): a dispatch enqueued after * a mount's SET_MT_REF / INIT_MT_REF / registration ops applies after them * by construction. The legacy `sigxRunOnMT` callLepusMethod channel is kept * for direct-from-test callers; both funnel here. */ /** * Deep-clone a value into a fresh tree whose every object has * `Object.prototype`. * * Why: PrimJS's `JSON.parse` produces null-prototype objects (a prototype- * pollution safety measure that V8 / SpiderMonkey don't apply). Upstream's * worklet runtime (`@lynx-js/react@0.121+`'s `workletRuntime.js`) walks * the captured `_c`, identifies worklet placeholders by `'_wkltId' in * subObj`, and then calls `new WeakRef(subObj)`. PrimJS's `WeakRef` rejects * null-prototype objects with `TypeError: WeakRef: target must be an * object`, so the worklet body never runs. * * `Object.setPrototypeOf` is a silent no-op on PrimJS's JSON.parse output * (the proto slot is locked even with `isExtensible: true`), so the only * way to get an `Object.prototype`-prototyped object is to rebuild it via * `{}` literal. A fresh object literal always has `Object.prototype` by * spec, so deep-cloning the captured tree produces a fully WeakRef-able * shape that's semantically identical for the worklet body. * * JSON.parse output is acyclic by construction, so no cycle detection * needed. Arrays handled separately to keep `Array.isArray` true downstream. */ export declare function rebuildWithObjectPrototype(value: T): T; /** * Invoke the registered `'main thread'` worklet `wkltId`. When `captured` * is supplied, route through upstream's `runWorklet({_wkltId, _c}, args)` * so its `I()` walker hydrates the placeholders inside `_c` (resolves * nested `{_wkltId}` worklet refs to callable functions and `{_wvid}` ref * placeholders to live MainThreadRefs from `_workletRefMap`). This matches * the path SET_WORKLET_EVENT uses for JSX-attached MT handlers. * * `invokeWorklet` is the fallback for the `captured === undefined` case * (no captures to hydrate) and for direct-from-MT callers that already * hand over a hydrated ctx. */ export declare function invokeMtWorklet(wkltId: string, args: unknown[] | undefined, captured: Record | undefined): unknown;