Motivation
Hosts embedding many activities want to unmount off-screen viewers to reclaim their ~180 MB (assignment-viewer windowed pagination; PreTeXt park-and-restore for long book pages). Remounting later with prior work intact already almost works — hosts receive serialized doc state via reportScoreAndStateCallback and can pass it back as initialState. The gap: state is only reported at core save events, so any student work since the last report is silently lost when the host tears the viewer down.
Proposed change
Add a host-initiated flush to the standalone viewer / doenetml-iframe protocol:
- A
flushState request message: the viewer responds (once the core is idle) with the current serialized document state in the same shape as initialState, plus the current score payload.
- A documented guarantee that after the response, unmounting loses nothing.
- Optionally an explicit
ready / stateSaved acknowledgment event stream so hosts can implement "safe to unmount" logic without polling.
The worker already has the serialization machinery (StatePersistence builds exactly this payload on every save), so this is mostly protocol plumbing through CoreWorker → standalone → iframe messages.
Enables
Related: #1436 (message-based prop updates), PR #880 rescope (initialization coordination).
🤖 Generated with Claude Code
Motivation
Hosts embedding many activities want to unmount off-screen viewers to reclaim their ~180 MB (assignment-viewer windowed pagination; PreTeXt park-and-restore for long book pages). Remounting later with prior work intact already almost works — hosts receive serialized doc state via
reportScoreAndStateCallbackand can pass it back asinitialState. The gap: state is only reported at core save events, so any student work since the last report is silently lost when the host tears the viewer down.Proposed change
Add a host-initiated flush to the standalone viewer /
doenetml-iframeprotocol:flushStaterequest message: the viewer responds (once the core is idle) with the current serialized document state in the same shape asinitialState, plus the current score payload.ready/stateSavedacknowledgment event stream so hosts can implement "safe to unmount" logic without polling.The worker already has the serialization machinery (
StatePersistencebuilds exactly this payload on every save), so this is mostly protocol plumbing throughCoreWorker→ standalone → iframe messages.Enables
Related: #1436 (message-based prop updates), PR #880 rescope (initialization coordination).
🤖 Generated with Claude Code