I'm trying to write an "interesting" js program and it keeps being frustrating to try and manage lifetime in the C API.
The problems that I keep hitting is that JSValueProtect/Unprotect require a context argument, that means a smart pointer has to carry both the value and context references.
The other problem is weak and conditional ownership.
I think an API along the lines of
JSHandleRef JSHandleMakeWeak(JSContextRef, nullable JSWeakCallback)
// Note the lack of a context here -- I believe that is completely achievable.
// While it would be nice to just have a "get slot" style api, I think that would
// result in ABI heartbreak down the road
void JSHandleSetValue(JSHandleRef, JSValueRef)