Lifecycle Channel
Plugin lifecycle acknowledgement and resource reclamation notifications.
unloadDone
Notifies the runtime that the plugin has finished unloading.
- Request:
{ "type": "unloadDone" } - Return: no return value
The plugin sends this message after all __yeowUnloadCbs callbacks have finished executing. Once received, the runtime should safely shut down the plugin thread.
gc-collect
Notifies the runtime that a particular resource is no longer referenced by the JS side and can be released.
- Request:
{ "type": "gc-collect", "ids": ["a1b2c3d4e5_1", "f6a7b8c9d0_2"] } - Return: no return value
How it works:
- The JS side pushes resource identifiers that are no longer in use into
__yeowGcQueueviaFinalizationRegistry(or an equivalent mechanism) - After each message is processed (once the microtask queue is drained), the runtime checks
__yeowGcQueue - If there are ids pending reclamation, it sends a
gc-collectmessage through thelifecyclechannel - Upon receiving it, the implementation releases the corresponding resources
Conventions:
- Resource ids are opaque handles (e.g.
a1b2c3d4e5_1) and do not carry resource-kind information — the runtime should not parse the id content, but should maintain anid → release logicregistry mapping (registered when the resource is created, looked up to release at gc-collect time) - The
idsarray may be empty (meaning no resources pending reclamation; may be skipped) - The implementation may defer
gc-collectuntil the next$sendcall instead of handling it immediately after every message