@@ -16,24 +16,14 @@ declare const __TEXTJS_YOGA__: string
1616
1717export async function start ( options : { away ?: ( ) => boolean ; onExit ?: ( ) => void } = { } ) {
1818 await initYoga ( { wasm : new URL ( __TEXTJS_YOGA__ , import . meta. url ) } )
19- // Text.js 1.6 counts a press as the click back from DevTools only within 300 ms of the window's
20- // focus event, so it misses a visitor who came back while Lite loaded: their clicks on the page,
21- // which already has focus, never reached Lite. Replay that focus for their next press, until
22- // Text.js ships createHostInput({ away }), which does this itself. Registered first, so it runs
23- // before createHostInput's own listener.
24- const replay = ( e : MouseEvent ) => {
25- if ( e . button !== 0 || e . ctrlKey ) return
26- document . removeEventListener ( "mousedown" , replay , true )
27- window . dispatchEvent ( new FocusEvent ( "focus" ) )
28- }
29- if ( options . away ?.( ) && document . hasFocus ( ) ) document . addEventListener ( "mousedown" , replay , true )
3019 // Keys reach the app only once the visitor clicks the page to come back from DevTools, and never
3120 // while they type in one of its fields, so the site's own shortcuts keep working until then.
32- const input = createHostInput ( )
21+ // `away` covers the visitor who came back while Lite downloaded: they left the page before it
22+ // started listening, so its next press is the click back from DevTools.
23+ const input = createHostInput ( { away : options . away ?.( ) } )
3324 const stop = ( ) => {
3425 root . unmount ( )
3526 input . dispose ( )
36- document . removeEventListener ( "mousedown" , replay , true )
3727 }
3828 const exit = ( ) => {
3929 stop ( )
0 commit comments