@rive-app/canvas 2.40.0 → 2.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas",
3
- "version": "2.40.0",
3
+ "version": "2.40.1",
4
4
  "description": "Rive's canvas based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.js CHANGED
@@ -444,14 +444,14 @@ c.va.count.value+=1;c.va.mb=!1;return c},["delete"](){this.va.Ba||zc(this);if(th
444
444
  const b=Symbol.dispose;b&&(a[b]=a["delete"])})();
445
445
  Object.assign(Pc.prototype,{Qc(a){this.pc&&(a=this.pc(a));return a},ac(a){this.Va?.(a)},Ma:tc,Aa:function(a){function b(){return this.vb?Oc(this.wa.Sa,{Da:this.gd,Ba:c,Pa:this,Ja:a}):Oc(this.wa.Sa,{Da:this,Ba:a})}var c=this.Qc(a);if(!c)return this.ac(a),null;var d=Nc(this.wa,c);if(void 0!==d){if(0===d.va.count.value)return d.va.Ba=c,d.va.Ja=a,d.clone();d=d.clone();this.ac(a);return d}d=this.wa.Pc(c);d=Cc[d];if(!d)return b.call(this);d=this.ub?d.Gc:d.pointerType;var e=Mc(c,this.wa,d.wa);return null===
446
446
  e?b.call(this):this.vb?Oc(d.wa.Sa,{Da:d,Ba:e,Pa:this,Ja:a}):Oc(d.wa.Sa,{Da:d,Ba:e})}});k.noExitRuntime&&(Xa=k.noExitRuntime);k.print&&(ta=k.print);k.printErr&&(wa=k.printErr);k.wasmBinary&&(xa=k.wasmBinary);k.thisProgram&&(la=k.thisProgram);if(k.preInit)for("function"==typeof k.preInit&&(k.preInit=[k.preInit]);0<k.preInit.length;)k.preInit.shift()();
447
- var Gd={236669:(a,b,c,d,e)=>{if("undefined"===typeof window||void 0===(window.AudioContext||window.webkitAudioContext))return 0;if("undefined"===typeof window.miniaudio){window.miniaudio={referenceCount:0};window.miniaudio.device_type={};window.miniaudio.device_type.playback=a;window.miniaudio.device_type.capture=b;window.miniaudio.device_type.duplex=c;window.miniaudio.device_state={};window.miniaudio.device_state.stopped=d;window.miniaudio.device_state.started=e;let f=window.miniaudio;f.devices=
447
+ var Gd={236911:(a,b,c,d,e)=>{if("undefined"===typeof window||void 0===(window.AudioContext||window.webkitAudioContext))return 0;if("undefined"===typeof window.miniaudio){window.miniaudio={referenceCount:0};window.miniaudio.device_type={};window.miniaudio.device_type.playback=a;window.miniaudio.device_type.capture=b;window.miniaudio.device_type.duplex=c;window.miniaudio.device_state={};window.miniaudio.device_state.stopped=d;window.miniaudio.device_state.started=e;let f=window.miniaudio;f.devices=
448
448
  [];f.track_device=function(g){for(var h=0;h<f.devices.length;++h)if(null==f.devices[h])return f.devices[h]=g,h;f.devices.push(g);return f.devices.length-1};f.untrack_device_by_index=function(g){for(f.devices[g]=null;0<f.devices.length;)if(null==f.devices[f.devices.length-1])f.devices.pop();else break};f.untrack_device=function(g){for(var h=0;h<f.devices.length;++h)if(f.devices[h]==g)return f.untrack_device_by_index(h)};f.get_device_by_index=function(g){return f.devices[g]};f.unlock_event_types=["touchend",
449
- "click"];f.unlock=function(){for(var g=0;g<f.devices.length;++g){var h=f.devices[g];null!=h&&null!=h.Qa&&h.state===f.device_state.started&&h.Qa.resume().then(()=>{Dd(h.nc)},m=>{console.error("Failed to resume audiocontext",m)})}f.unlock_event_types.map(function(m){document.removeEventListener(m,f.unlock,!0)})};f.unlock_event_types.map(function(g){document.addEventListener(g,f.unlock,!0)})}window.miniaudio.referenceCount+=1;return 1},238847:()=>{"undefined"!==typeof window.miniaudio&&(window.miniaudio.unlock_event_types.map(function(a){document.removeEventListener(a,
450
- window.miniaudio.unlock,!0)}),--window.miniaudio.referenceCount,0===window.miniaudio.referenceCount&&delete window.miniaudio)},239151:()=>void 0!==navigator.mediaDevices&&void 0!==navigator.mediaDevices.getUserMedia,239255:()=>{try{var a=new (window.AudioContext||window.webkitAudioContext),b=a.sampleRate;a.close();return b}catch(c){return 0}},239426:(a,b,c,d,e,f)=>{if("undefined"===typeof window.miniaudio)return-1;var g={},h={};a==window.miniaudio.device_type.playback&&0!=c&&(h.sampleRate=c);g.Qa=
449
+ "click"];f.unlock=function(){for(var g=0;g<f.devices.length;++g){var h=f.devices[g];null!=h&&null!=h.Qa&&h.state===f.device_state.started&&h.Qa.resume().then(()=>{Dd(h.nc)},m=>{console.error("Failed to resume audiocontext",m)})}f.unlock_event_types.map(function(m){document.removeEventListener(m,f.unlock,!0)})};f.unlock_event_types.map(function(g){document.addEventListener(g,f.unlock,!0)})}window.miniaudio.referenceCount+=1;return 1},239089:()=>{"undefined"!==typeof window.miniaudio&&(window.miniaudio.unlock_event_types.map(function(a){document.removeEventListener(a,
450
+ window.miniaudio.unlock,!0)}),--window.miniaudio.referenceCount,0===window.miniaudio.referenceCount&&delete window.miniaudio)},239393:()=>void 0!==navigator.mediaDevices&&void 0!==navigator.mediaDevices.getUserMedia,239497:()=>{try{var a=new (window.AudioContext||window.webkitAudioContext),b=a.sampleRate;a.close();return b}catch(c){return 0}},239668:(a,b,c,d,e,f)=>{if("undefined"===typeof window.miniaudio)return-1;var g={},h={};a==window.miniaudio.device_type.playback&&0!=c&&(h.sampleRate=c);g.Qa=
451
451
  new (window.AudioContext||window.webkitAudioContext)(h);g.Qa.suspend();g.state=window.miniaudio.device_state.stopped;c=0;a!=window.miniaudio.device_type.playback&&(c=b);g.fb=g.Qa.createScriptProcessor(d,c,b);g.fb.onaudioprocess=function(m){if(null==g.tb||0==g.tb.length)g.tb=new Float32Array(Ga.buffer,e,d*b);if(a==window.miniaudio.device_type.capture||a==window.miniaudio.device_type.duplex){for(var l=0;l<b;l+=1)for(var u=m.inputBuffer.getChannelData(l),y=g.tb,t=0;t<d;t+=1)y[t*b+l]=u[t];Ed(f,d,e)}if(a==
452
452
  window.miniaudio.device_type.playback||a==window.miniaudio.device_type.duplex)for(Fd(f,d,e),l=0;l<m.outputBuffer.numberOfChannels;++l)for(u=m.outputBuffer.getChannelData(l),y=g.tb,t=0;t<d;t+=1)u[t]=y[t*b+l];else for(l=0;l<m.outputBuffer.numberOfChannels;++l)m.outputBuffer.getChannelData(l).fill(0)};a!=window.miniaudio.device_type.capture&&a!=window.miniaudio.device_type.duplex||navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then(function(m){g.Cb=g.Qa.createMediaStreamSource(m);g.Cb.connect(g.fb);
453
- g.fb.connect(g.Qa.destination)}).catch(function(m){console.log("Failed to get user media: "+m)});a==window.miniaudio.device_type.playback&&g.fb.connect(g.Qa.destination);g.nc=f;return window.miniaudio.track_device(g)},242303:a=>window.miniaudio.get_device_by_index(a).Qa.sampleRate,242376:a=>{a=window.miniaudio.get_device_by_index(a);void 0!==a.fb&&(a.fb.onaudioprocess=function(){},a.fb.disconnect(),a.fb=void 0);void 0!==a.Cb&&(a.Cb.disconnect(),a.Cb=void 0);a.Qa.close();a.Qa=void 0;a.nc=void 0},242776:a=>
454
- {window.miniaudio.untrack_device_by_index(a)},242826:a=>{a=window.miniaudio.get_device_by_index(a);a.Qa.resume();a.state=window.miniaudio.device_state.started},242965:a=>{a=window.miniaudio.get_device_by_index(a);a.Qa.suspend();a.state=window.miniaudio.device_state.stopped}},lc,Hd,kc,Dd,Ed,Fd,Id,Jd,Kd,Ld,Ma,Rc,Nd={s:function(a,b,c){Ya=c;try{var d=Lb(a);switch(b){case 0:var e=Za();if(0>e)break;for(;Ab[e];)e++;return Nb(d,e).cb;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=Za(),d.flags|=
453
+ g.fb.connect(g.Qa.destination)}).catch(function(m){console.log("Failed to get user media: "+m)});a==window.miniaudio.device_type.playback&&g.fb.connect(g.Qa.destination);g.nc=f;return window.miniaudio.track_device(g)},242545:a=>window.miniaudio.get_device_by_index(a).Qa.sampleRate,242618:a=>{a=window.miniaudio.get_device_by_index(a);void 0!==a.fb&&(a.fb.onaudioprocess=function(){},a.fb.disconnect(),a.fb=void 0);void 0!==a.Cb&&(a.Cb.disconnect(),a.Cb=void 0);a.Qa.close();a.Qa=void 0;a.nc=void 0},243018:a=>
454
+ {window.miniaudio.untrack_device_by_index(a)},243068:a=>{a=window.miniaudio.get_device_by_index(a);a.Qa.resume();a.state=window.miniaudio.device_state.started},243207:a=>{a=window.miniaudio.get_device_by_index(a);a.Qa.suspend();a.state=window.miniaudio.device_state.stopped}},lc,Hd,kc,Dd,Ed,Fd,Id,Jd,Kd,Ld,Ma,Rc,Nd={s:function(a,b,c){Ya=c;try{var d=Lb(a);switch(b){case 0:var e=Za();if(0>e)break;for(;Ab[e];)e++;return Nb(d,e).cb;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=Za(),d.flags|=
455
455
  e,0;case 12:return e=Za(),Ca[e+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(f){if("undefined"==typeof bc||"ErrnoError"!==f.name)throw f;return-f.bb}},L:function(a,b,c){Ya=c;try{var d=Lb(a);switch(b){case 21509:return d.Ca?0:-59;case 21505:if(!d.Ca)return-59;if(d.Ca.ab.Wc){a=[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];var e=Za();B[e>>2]=25856;B[e+4>>2]=5;B[e+8>>2]=191;B[e+12>>2]=35387;for(var f=0;32>f;f++)v[e+f+17]=a[f]||0}return 0;case 21510:case 21511:case 21512:return d.Ca?
456
456
  0:-59;case 21506:case 21507:case 21508:if(!d.Ca)return-59;if(d.Ca.ab.Xc)for(e=Za(),a=[],f=0;32>f;f++)a.push(v[e+f+17]);return 0;case 21519:if(!d.Ca)return-59;e=Za();return B[e>>2]=0;case 21520:return d.Ca?-28:-59;case 21537:case 21531:e=Za();if(!d.xa.Vc)throw new M(59);return d.xa.Vc(d,b,e);case 21523:if(!d.Ca)return-59;d.Ca.ab.Yc&&(f=[24,80],e=Za(),Ca[e>>1]=f[0],Ca[e+2>>1]=f[1]);return 0;case 21524:return d.Ca?0:-59;case 21515:return d.Ca?0:-59;default:return-28}}catch(g){if("undefined"==typeof bc||
457
457
  "ErrnoError"!==g.name)throw g;return-g.bb}},M:function(a,b,c,d){Ya=d;try{b=b?ib(A,b):"";var e=b;if("/"===e.charAt(0))b=e;else{var f=-100===a?"/":Lb(a).path;if(0==e.length)throw new M(44);b=f+"/"+e}var g=d?Za():0;return Zb(b,c,g).cb}catch(h){if("undefined"==typeof bc||"ErrnoError"!==h.name)throw h;return-h.bb}},P:()=>Na(""),o:(a,b,c)=>{a=T(a);b=nc(b,"wrapper");c=Q(c);var d=b.wa,e=d.Sa,f=d.Ia.Sa,g=d.Ia.constructor;a=cc(a,function(...h){for(var m of d.Ia.oc)if(this[m]===f[m])throw new gc(`Pure virtual function ${m} must be implemented in JavaScript`);
@@ -479,8 +479,8 @@ for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);a:{d=(Math.min
479
479
  null);try{b.xa.close&&b.xa.close(b)}catch(c){throw c;}finally{Ab[b.cb]=null}b.cb=null;return 0}catch(c){if("undefined"==typeof bc||"ErrnoError"!==c.name)throw c;return c.bb}},K:function(a,b,c,d){try{a:{var e=Lb(a);a=b;for(var f,g=b=0;g<c;g++){var h=J[a>>2],m=J[a+4>>2];a+=8;var l=e,u=h,y=m,t=f,w=v;if(0>y||0>t)throw new M(28);if(null===l.cb)throw new M(8);if(1===(l.flags&2097155))throw new M(8);if(16384===(l.node.mode&61440))throw new M(31);if(!l.xa.read)throw new M(28);var x="undefined"!=typeof t;
480
480
  if(!x)t=l.position;else if(!l.seekable)throw new M(70);var p=l.xa.read(l,w,u,y,t);x||(l.position+=p);var H=p;if(0>H){var F=-1;break a}b+=H;if(H<m)break;"undefined"!=typeof f&&(f+=H)}F=b}J[d>>2]=F;return 0}catch(q){if("undefined"==typeof bc||"ErrnoError"!==q.name)throw q;return q.bb}},I:function(a,b,c,d){b=-9007199254740992>b||9007199254740992<b?NaN:Number(b);try{if(isNaN(b))return 61;var e=Lb(a);$b(e,b,c);Ia[d>>3]=BigInt(e.position);e.Mb&&0===b&&0===c&&(e.Mb=null);return 0}catch(f){if("undefined"==
481
481
  typeof bc||"ErrnoError"!==f.name)throw f;return f.bb}},J:function(a,b,c,d){try{a:{var e=Lb(a);a=b;for(var f,g=b=0;g<c;g++){var h=J[a>>2],m=J[a+4>>2];a+=8;var l=e,u=h,y=m,t=f,w=v;if(0>y||0>t)throw new M(28);if(null===l.cb)throw new M(8);if(0===(l.flags&2097155))throw new M(8);if(16384===(l.node.mode&61440))throw new M(31);if(!l.xa.write)throw new M(28);l.seekable&&l.flags&1024&&$b(l,0,2);var x="undefined"!=typeof t;if(!x)t=l.position;else if(!l.seekable)throw new M(70);var p=l.xa.write(l,w,u,y,t,void 0);
482
- x||(l.position+=p);var H=p;if(0>H){var F=-1;break a}b+=H;if(H<m)break;"undefined"!=typeof f&&(f+=H)}F=b}J[d>>2]=F;return 0}catch(q){if("undefined"==typeof bc||"ErrnoError"!==q.name)throw q;return q.bb}},x:Md,R:function(){return-1<navigator.platform.indexOf("Win")},z:xd,S:function(a,b,c){b=k.HEAP8.subarray(b,b+c);c=new Uint8Array(c);c.set(b);createImageBitmap(new Blob([c])).then(function(d){var e=(new OffscreenCanvas(d.width,d.height)).getContext("2d");e.drawImage(d,0,0);e=e.getImageData(0,0,d.width,
483
- d.height);var f=e.data.length,g=k.Cc(f);k.pd.set(e.data,g);k.rd(a,d.width,d.height,g,f)}).catch(function(d){d=d.message||"decode failed";var e=k.Gd(d)+1,f=k.Cc(e);k.Jd(d,f,e);k.sd(a,f);k.qd(f)})}};function Md(a,b,c){var d=Ld();try{Rc.get(a)(b,c)}catch(e){Kd(d);if(e!==e+0)throw e;Jd(1,0)}}var Od;
482
+ x||(l.position+=p);var H=p;if(0>H){var F=-1;break a}b+=H;if(H<m)break;"undefined"!=typeof f&&(f+=H)}F=b}J[d>>2]=F;return 0}catch(q){if("undefined"==typeof bc||"ErrnoError"!==q.name)throw q;return q.bb}},x:Md,R:function(){return-1<navigator.platform.indexOf("Win")},z:xd,S:function(a,b,c){b=new Uint8Array(Ma.buffer,b,c);c=new Uint8Array(c);c.set(b);createImageBitmap(new Blob([c])).then(function(d){var e=(new OffscreenCanvas(d.width,d.height)).getContext("2d");e.drawImage(d,0,0);e=e.getImageData(0,0,
483
+ d.width,d.height);var f=e.data.length,g=k.Cc(f);k.pd.set(e.data,g);k.rd(a,d.width,d.height,g,f)}).catch(function(d){d=d.message||"decode failed";var e=k.Gd(d)+1,f=k.Cc(e);k.Jd(d,f,e);k.sd(a,f);k.qd(f)})}};function Md(a,b,c){var d=Ld();try{Rc.get(a)(b,c)}catch(e){Kd(d);if(e!==e+0)throw e;Jd(1,0)}}var Od;
484
484
  Od=await (async function(){function a(c){c=Od=c.exports;lc=c.ga;Hd=c.ha;kc=c.ia;k._wasm_image_decode_complete=c.ja;k._wasm_image_decode_error=c.ka;Dd=k._ma_device__on_notification_unlocked=c.la;k._ma_malloc_emscripten=c.ma;k._ma_free_emscripten=c.na;Ed=k._ma_device_process_pcm_frames_capture__webaudio=c.oa;Fd=k._ma_device_process_pcm_frames_playback__webaudio=c.pa;Id=c.ra;Jd=c.sa;Kd=c.ta;Ld=c.ua;Ma=c.ea;Rc=c.qa;La();return Od}var b={a:Nd};if(k.instantiateWasm)return new Promise(c=>{k.instantiateWasm(b,
485
485
  (d,e)=>{c(a(d,e))})});Oa??=k.locateFile?k.locateFile("canvas_advanced.wasm",ma):ma+"canvas_advanced.wasm";return a((await Ra(b)).instance)}());
486
486
  (function(){function a(){k.calledRun=!0;if(!ya){Ka=!0;if(!k.noFSInit&&!Cb){var b,c;Cb=!0;b??=k.stdin;c??=k.stdout;d??=k.stderr;b?ac("stdin",b):Yb("/dev/tty","/dev/stdin");c?ac("stdout",null,c):Yb("/dev/tty","/dev/stdout");d?ac("stderr",null,d):Yb("/dev/tty1","/dev/stderr");Zb("/dev/stdin",0);Zb("/dev/stdout",1);Zb("/dev/stderr",1)}Od.fa();Db=!1;Aa?.(k);k.onRuntimeInitialized?.();if(k.postRun)for("function"==typeof k.postRun&&(k.postRun=[k.postRun]);k.postRun.length;){var d=k.postRun.shift();Ua.push(d)}Ta(Ua)}}
@@ -493,7 +493,7 @@ if(k.preRun)for("function"==typeof k.preRun&&(k.preRun=[k.preRun]);k.preRun.leng
493
493
  /* 5 */
494
494
  /***/ ((module) => {
495
495
 
496
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.40.0","description":"Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
496
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.40.1","description":"Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
497
497
 
498
498
  /***/ }),
499
499
  /* 6 */
@@ -2649,21 +2649,21 @@ __webpack_require__.r(__webpack_exports__);
2649
2649
  /* harmony export */ KeyboardInteractions: () => (/* binding */ KeyboardInteractions)
2650
2650
  /* harmony export */ });
2651
2651
  /**
2652
- * Tracks the relationship between the canvas's DOM focus and Rive's internal focus for the
2653
- * current focus session.
2652
+ * Tracks the relationship between DOM focus inside this Rive focus domain (canvas or semantic overlay)
2653
+ * and Rive's internal focus for the current focus session.
2654
2654
  *
2655
- * NotFocused — the canvas is not the active DOM element, or Rive entered and then released focus
2656
- * internally this session. Either way the next Tab should move on to the next page
2657
- * element, so Tab events are ignored.
2658
- * EntryPending — the canvas has DOM focus but Rive holds no active focus node yet, and the next Tab should enter
2659
- * the focus tree. This is the resting state for pointer-driven focus (a click on the
2660
- * canvas), or an edge case for keyboard focus where initial focus action did not land on a focus node.
2661
- * RiveFocused — a Rive node currently holds focus. Tab/Shift+Tab are routed to the Rive focus
2662
- * manager and trapped inside the canvas until Rive notifies focus has ended.
2655
+ * NotFocused — DOM focus left the domain, Rive released focus internally, or Tab walked
2656
+ * off the end of the tree. Keyboard input isn't ours, so Tab is ignored and
2657
+ * reaches the next page element.
2658
+ * EntryPending — DOM focus is inside the domain but Rive holds no node yet, so the next Tab
2659
+ * enters the focus tree. Set by pointer focus on the canvas, by assistive technology (AT) focus landing
2660
+ * in the overlay, and by keyboard focus whose entry attempt found no eligible node.
2661
+ * RiveFocused — a Rive node holds focus. Tab/Shift+Tab route to the Rive focus manager and stay
2662
+ * inside the domain until either Rive reports focus ended (pollFocusState) or
2663
+ * focusNext()/focusPrevious() returns false at the edge of the tree.
2663
2664
  *
2664
- * When keyboard focus lands on the canvas, onCanvasFocus reads the direction focus came from and
2665
- * moves into the focus tree immediately, going straight to RiveFocused. EntryPending is only set via pointer focus (or keyboard focus
2666
- * where focusNext()/focusPrevious() return false but respects tabindex).
2665
+ * Keyboard focus on the canvas enters the tree immediately: onCanvasFocus infers direction from
2666
+ * where focus came from and goes straight to RiveFocused when a node accepts.
2667
2667
  */
2668
2668
  var FocusSessionState;
2669
2669
  (function (FocusSessionState) {
@@ -2672,7 +2672,9 @@ var FocusSessionState;
2672
2672
  FocusSessionState["RiveFocused"] = "riveFocused";
2673
2673
  })(FocusSessionState || (FocusSessionState = {}));
2674
2674
  /**
2675
- * Manages keyboard and DOM focus interactions for a Rive canvas.
2675
+ * Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas> or semantic overlay).
2676
+ * Because keyboard events can apply on either part of the domain, we need to track what events we should
2677
+ * handle/intercept, and when to release focus back to the page outside of the domain.
2676
2678
  *
2677
2679
  * Tracks the canvas focus session state (focusSessionState) and routes
2678
2680
  * Tab/Shift+Tab to the Rive state machine's focus manager. Exposes shared
@@ -2718,17 +2720,45 @@ var KeyboardInteractions = /** @class */ (function () {
2718
2720
  _this.focusSessionState = FocusSessionState.RiveFocused;
2719
2721
  }
2720
2722
  };
2721
- this.onCanvasBlur = function (_event) {
2723
+ /**
2724
+ * Marks internal state that the canvas has lost DOM focus. Do not actually clear
2725
+ * Rive focus though if:
2726
+ * 1. DOM focus is still within Rive domain (i.e., semantic overlay)
2727
+ * 2. Document just lost focus (i.e. tab switching)
2728
+ *
2729
+ * When we're not in either of those buckets, it's safe to call `clearFocus()` on the SMI.
2730
+ */
2731
+ this.onCanvasBlur = function (event) {
2722
2732
  _this.focusSessionState = FocusSessionState.NotFocused;
2723
2733
  _this.canvasHasFocus = false;
2734
+ var movedWithinFocusDomain = _this.isInFocusDomain(event.relatedTarget);
2735
+ var documentLostFocus = event.relatedTarget === null && !document.hasFocus();
2736
+ if (movedWithinFocusDomain || documentLostFocus)
2737
+ return;
2738
+ _this.mainSm.clearFocus();
2724
2739
  };
2740
+ /**
2741
+ * Assistive technology (AT) focus landing inside the overlay is DOM focus inside the Rive focus domain, so open a
2742
+ * session even when no Rive node holds focus yet. shouldRiveHandleKeyEvent treats NotFocused
2743
+ * as authoritative, so without this the overlay's Tab keydowns reach onKeyDown and get dropped
2744
+ * at that gate — the browser would move focus out of Rive instead of to the next focus node.
2745
+ */
2725
2746
  this.onOverlayFocusIn = function (event) {
2726
- if (_this.isInOverlay(event.target)) {
2727
- _this.focusDomainReleased = false;
2728
- }
2747
+ if (!_this.isInOverlay(event.target))
2748
+ return;
2749
+ _this.focusDomainReleased = false;
2750
+ if (!_this.hasFocusNodes)
2751
+ return;
2752
+ if (_this.focusSessionState !== FocusSessionState.NotFocused)
2753
+ return;
2754
+ _this.focusSessionState = _this.mainSm.focusState().hasFocus
2755
+ ? FocusSessionState.RiveFocused
2756
+ : FocusSessionState.EntryPending;
2729
2757
  };
2730
- this.onFocusDomainHostFocusIn = function (_event) {
2758
+ /** Overlay listeners attach lazily, so the first focusin only ever lands here. */
2759
+ this.onFocusDomainHostFocusIn = function (event) {
2731
2760
  _this.syncOverlayListener();
2761
+ _this.onOverlayFocusIn(event);
2732
2762
  };
2733
2763
  this.onKeyDown = function (event) {
2734
2764
  _this.syncOverlayListener();
@@ -2741,7 +2771,7 @@ var KeyboardInteractions = /** @class */ (function () {
2741
2771
  var forward = !event.shiftKey;
2742
2772
  var focusMoved = forward ? _this.mainSm.focusNext() : _this.mainSm.focusPrevious();
2743
2773
  if (focusMoved) {
2744
- // A Rive node accepted focus — keep trapping Tab inside the canvas.
2774
+ // A Rive node accepted focus — keep trapping Tab inside Rive.
2745
2775
  _this.focusSessionState = FocusSessionState.RiveFocused;
2746
2776
  event.preventDefault();
2747
2777
  }
@@ -2777,27 +2807,34 @@ var KeyboardInteractions = /** @class */ (function () {
2777
2807
  /**
2778
2808
  * Called by pollFocusState on the Rive instance when it observes hasFocus=true. Rive acquired
2779
2809
  * focus internally (e.g. via a listener action or state transition) without a DOM focus event,
2780
- * so mark the session RiveFocused.
2810
+ * so mark the session RiveFocused. This cannot resurrect a session that a DOM blur ended,
2811
+ * because onCanvasBlur clears Rive's focus alongside it.
2781
2812
  */
2782
2813
  KeyboardInteractions.prototype.notifyRiveFocused = function () {
2783
2814
  this.focusSessionState = FocusSessionState.RiveFocused;
2784
2815
  };
2785
2816
  /**
2786
- * Whether Rive should handle this keydown — i.e. it currently owns keyboard input.
2787
- * True when focus is anywhere in the Rive focus domain (the canvas itself or the
2788
- * accessibility overlay), OR a focus session is active and the key landed on the
2789
- * canvas.
2817
+ * Determine if Rive should handle keyboard input. If session state is `NotFocused` - no.
2818
+ * DOM focus stays parked on the canvas after Rive releases focus internally, and that Tab
2819
+ * has to reach the page rather than re-enter the tree.
2820
+ *
2821
+ * Otherwise, the event still has to belong to Rive:
2822
+ * 1. If the current DOM focus is in Rive domain (canvas or semantic overlay)
2823
+ * 2. If the target for the key input is for the semantic overlay, or the canvas
2790
2824
  */
2791
2825
  KeyboardInteractions.prototype.shouldRiveHandleKeyEvent = function (event) {
2826
+ if (this.focusSessionState === FocusSessionState.NotFocused)
2827
+ return false;
2792
2828
  var inFocusDomain = this.isInFocusDomain(document.activeElement) ||
2793
2829
  this.isInOverlay(event.target);
2794
- if (inFocusDomain)
2795
- return true;
2796
- var sessionActive = this.focusSessionState !== FocusSessionState.NotFocused;
2797
2830
  var eventOnCanvas = event.target === this.canvas;
2798
- return sessionActive && (this.canvasHasFocus || eventOnCanvas);
2831
+ return inFocusDomain || this.canvasHasFocus || eventOnCanvas;
2799
2832
  };
2800
- /** Rive focus domain = the canvas itself OR the accessibility overlay. */
2833
+ /**
2834
+ * The Rive focus domain: the DOM that counts as "inside" Rive for focus purposes — today the
2835
+ * canvas itself OR the accessibility overlay subtree. Anything added later belongs here, so
2836
+ * session bookkeeping and keydown routing pick it up for free.
2837
+ */
2801
2838
  KeyboardInteractions.prototype.isInFocusDomain = function (target) {
2802
2839
  if (target === this.canvas)
2803
2840
  return true;
@@ -5504,8 +5541,9 @@ var Rive = /** @class */ (function () {
5504
5541
  // Rive has an active focus node. Mark the session RiveFocused so Tab stays
5505
5542
  // trapped and a later internal release (hasFocus true → false) is detected.
5506
5543
  this._keyboardInteractions.notifyRiveFocused();
5507
- // Only steal DOM focus on the false→true transition. If hasFocus stays
5508
- // true across frames and the user clicks away, do not re-focus the canvas again.
5544
+ // Only steal DOM focus on the false→true transition. Rive can hold focus across
5545
+ // frames while DOM focus sits elsewhere — a window switch preserves runtime focus
5546
+ // by design — and that must not re-focus the canvas again.
5509
5547
  if (!this._prevHasFocus) {
5510
5548
  // Steal DOM focus to the canvas only when focus isn't already held
5511
5549
  // somewhere inside this instance's focus scope. When the accessibility
@@ -5526,8 +5564,9 @@ var Rive = /** @class */ (function () {
5526
5564
  this._prevHasFocus = false;
5527
5565
  // hasFocus is false — only act when Rive previously held focus and released it internally
5528
5566
  // (state change clears focus). Release the DOM Tab trap so the next Tab moves to the next
5529
- // page element. EntryPending and NotFocused cases are intentional no-ops — EntryPending in
5530
- // particular must stay in its state (a click awaiting its first Tab) rather than be reset here.
5567
+ // page element. A DOM blur reaches here too now that onCanvasBlur clears Rive focus, but it
5568
+ // has already set NotFocused, so this is a no-op. EntryPending and NotFocused are likewise
5569
+ // intentional no-ops — EntryPending must stay put (a click awaiting its first Tab).
5531
5570
  if (this._keyboardInteractions.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.RiveFocused) {
5532
5571
  this._keyboardInteractions.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.NotFocused);
5533
5572
  }