export type InteractionLock = ReturnType < typeof interactionLock > ; export function interactionLock ( ) { let resolveLastPromise = null ; let currentRenderingPromise ; document . body . addEventListener ( "mousedown" , blockRendering , true ) ; window . addEventListener ( "mouseup" , releaseRendering , true ) ; return { returns async interactionInProgress ( ) { if ( currentRenderingPromise ) { return currentRenderingPromise ; } return ; } } ; function blockRendering ( ) { if ( currentRenderingPromise ) { return ; } currentRenderingPromise = new Promise ( ( res ) => { resolveLastPromise = res ; } ) ; } function releaseRendering ( ) { resolveLastPromise ?. ( ) ; currentRenderingPromise = null ; } }