mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +08:00
structuredClone of checked-dynamic values builds a fresh tree (shared inputs are copied per path, cycles throw), so its containers join one ScrDynRegion as they complete, exactly like JSON.parse; a BigInt or bytes leaf clears the region, because intact containers promise JSON.stringify inert leaves only. scr_message_decode (worker, MessagePort and BroadcastChannel payloads) tags its containers before dropping the decoder's references when every node is a JSON primitive, undefined, array or object, arrays carry no named properties, and every container edge leads to a higher encoder id. Ids are assigned parents first, so that proves the graph acyclic; shared subtrees reached again from a later node and cycles stay untagged. Region API for other whole-document producers: scr_dyn_region_open, scr_dyn_region_tag (on each completed container) and scr_dyn_region_close. Node layout is unchanged: arrays and objects keep the region pointer added for parse regions (arr.region / obj.region in the capsule payload space).