simulateStructuredClone function
Deep-copies payload with the same semantics the structured clone
algorithm applies to protocol payloads: containers and typed data are
copied, SharedBuffers are passed through by reference (their memory
is shared), and unsupported values throw ArgumentError.
Used by the in-process transports (and available from
package:wasmforge/testing.dart) so off-browser code sees the same
pass-by-value behavior a real worker boundary imposes. Transfer-induced
detachment is not simulated.
Implementation
Object? simulateStructuredClone(Object? payload) => _clone(payload, r'$');