@rive-app/canvas-lite 2.43.0 → 2.44.0

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/rive.js CHANGED
@@ -367,12 +367,12 @@ c?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR),a.g
367
367
  q.sort((E,ba)=>ba.Na-E.Na);u=w.push(L);g!=u&&(a.bufferData(a.ARRAY_BUFFER,8*u,a.DYNAMIC_DRAW),g=u);u=0;for(var K of q)a.bufferSubData(a.ARRAY_BUFFER,u,K.ta),u+=4*K.ta.length;console.assert(u==4*L);for(var R of q)a.bufferSubData(a.ARRAY_BUFFER,u,R.Qa),u+=4*R.Qa.length;console.assert(u==8*L);u=z.push(I);f!=u&&(a.bufferData(a.ELEMENT_ARRAY_BUFFER,2*u,a.DYNAMIC_DRAW),f=u);K=0;for(var X of q)a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,K,X.indices),K+=2*X.indices.length;console.assert(K==2*I);X=0;R=!0;u=K=0;
368
368
  for(const E of q){E.image.na!=X&&(a.bindTexture(a.TEXTURE_2D,E.image.la||null),X=E.image.na);E.ub?(a.scissor(E.Aa,J-E.Ba-E.Ha,E.Bb,E.Ha),R=!0):R&&(a.scissor(0,J-x,v,x),R=!1);q=2/v;const ba=-2/x;a.uniform4f(e,E.O[0]*q*E.da,E.O[1]*ba*E.ea,E.O[2]*q*E.da,E.O[3]*ba*E.ea);a.uniform2f(k,E.O[4]*q*E.da+q*(E.Aa-E.sb*E.da)-1,E.O[5]*ba*E.ea+ba*(E.Ba-E.tb*E.ea)+1);a.vertexAttribPointer(0,2,a.FLOAT,!1,0,u);a.vertexAttribPointer(1,2,a.FLOAT,!1,0,u+4*L);a.drawElements(a.TRIANGLES,E.indices.length,a.UNSIGNED_SHORT,
369
369
  K);u+=4*E.ta.length;K+=2*E.indices.length}console.assert(u==4*L);console.assert(K==2*I)}}};this.canvas=function(){return b()&&a.canvas}},ma=h.onRuntimeInitialized;
370
- h.onRuntimeInitialized=function(){function b(l){switch(l){case n.srcOver:return"source-over";case n.screen:return"screen";case n.overlay:return"overlay";case n.darken:return"darken";case n.lighten:return"lighten";case n.colorDodge:return"color-dodge";case n.colorBurn:return"color-burn";case n.hardLight:return"hard-light";case n.softLight:return"soft-light";case n.difference:return"difference";case n.exclusion:return"exclusion";case n.multiply:return"multiply";case n.hue:return"hue";case n.saturation:return"saturation";
371
- case n.color:return"color";case n.luminosity:return"luminosity"}}function a(l){return"rgba("+((16711680&l)>>>16)+","+((65280&l)>>>8)+","+((255&l)>>>0)+","+((4278190080&l)>>>24)/255+")"}function c(){0<R.length&&(la.fb(K.drawWidth(),K.drawHeight(),R,X,E),R=[],E=X=0,K.reset(512,512));for(const l of u){for(const p of l.D)p();l.D=[]}u.clear()}ma&&ma();var d=h.RenderPaintStyle;const e=h.RenderPath,k=h.RenderPaint,g=h.Renderer,f=h.StrokeCap,m=h.StrokeJoin,n=h.BlendMode,r=d.fill,w=d.stroke,z=h.FillRule.evenOdd;
372
- let v=1;var x=h.RenderImage.extend("CanvasRenderImage",{__construct:function({U:l,ca:p}={}){this.__parent.__construct.call(this);this.na=v;v=v+1&2147483647||1;this.U=l;this.ca=p},__destruct:function(){this.la&&(la.bb(this.la),URL.revokeObjectURL(this.ya));this.__parent.__destruct.call(this)},decode:function(l){var p=this;p.ca&&p.ca(p);var A=new Image;p.ya=URL.createObjectURL(new Blob([l],{type:"image/png"}));A.onload=function(){p.Wa=A;p.la=la.ab(A);p.size(A.width,A.height);p.U&&p.U(p)};A.src=p.ya}});
373
- class q{constructor(){this.Z=this.$=0;this.K=new Path2D}clear(){this.Z=this.$=0;this.K=new Path2D}Za(l){for(0<this.$&&this.Z<l.length&&this.clear();this.Z<l.length;)l[this.Z++](this.K);this.$++;return this.K}release(l){l===this.K&&this.$--}}var L=e.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this);this.ja=[];this.K=new q;this.ia=!1;this.S=null},rewind:function(){this.ja.length=0;this.K.clear();this.ia=!1;this.S=null},addPath:function(l,p,A,t,G,B,C){const y=l.Sa();
374
- this.R(F=>{const H=new DOMMatrix;H.a=p;H.b=A;H.c=t;H.d=G;H.e=B;H.f=C;F.addPath(y,H)})},fillRule:function(l){this.xa=l},moveTo:function(l,p){this.ia=!0;const A={Ca:!0};this.S=A;this.R(t=>{t.moveTo(l,p);A.Ca&&t.lineTo(l,p)})},lineTo:function(l,p){this.wa();this.ga();this.R(A=>{A.lineTo(l,p)})},cubicTo:function(l,p,A,t,G,B){this.wa();this.ga();this.R(C=>{C.bezierCurveTo(l,p,A,t,G,B)})},close:function(){this.ga();this.R(l=>{l.closePath()})},wa:function(){this.ia||this.moveTo(0,0)},ga:function(){null!==
375
- this.S&&(this.S.Ca=!1,this.S=null)},R:function(l){this.ja.push(l)},fa:function(){return this.K.Za(this.ja)},za:function(l){this.K.release(l)},Sa:function(){const l=this.fa();this.K.clear();return l}}),I=k.extend("CanvasRenderPaint",{__construct:function(){this.__parent.__construct.call(this);this.B=[];this.ha=0;this.ka=r;this.oa=a(4278190080);this.ma=1;this.Y="miter";this.X="butt";this.ua=b(n.srcOver);this.N=null},color:function(l){this.B.push(()=>{this.oa=a(l)})},thickness:function(l){this.B.push(()=>
370
+ h.onRuntimeInitialized=function(){function b(l){switch(l){case n.srcOver:return"source-over";case n.Cb:return"plus-lighter";case n.screen:return"screen";case n.overlay:return"overlay";case n.darken:return"darken";case n.lighten:return"lighten";case n.colorDodge:return"color-dodge";case n.colorBurn:return"color-burn";case n.hardLight:return"hard-light";case n.softLight:return"soft-light";case n.difference:return"difference";case n.exclusion:return"exclusion";case n.multiply:return"multiply";case n.hue:return"hue";
371
+ case n.saturation:return"saturation";case n.color:return"color";case n.luminosity:return"luminosity"}}function a(l){return"rgba("+((16711680&l)>>>16)+","+((65280&l)>>>8)+","+((255&l)>>>0)+","+((4278190080&l)>>>24)/255+")"}function c(){0<R.length&&(la.fb(K.drawWidth(),K.drawHeight(),R,X,E),R=[],E=X=0,K.reset(512,512));for(const l of u){for(const p of l.D)p();l.D=[]}u.clear()}ma&&ma();var d=h.RenderPaintStyle;const e=h.RenderPath,k=h.RenderPaint,g=h.Renderer,f=h.StrokeCap,m=h.StrokeJoin,n=h.BlendMode,
372
+ r=d.fill,w=d.stroke,z=h.FillRule.evenOdd;let v=1;var x=h.RenderImage.extend("CanvasRenderImage",{__construct:function({U:l,ca:p}={}){this.__parent.__construct.call(this);this.na=v;v=v+1&2147483647||1;this.U=l;this.ca=p},__destruct:function(){this.la&&(la.bb(this.la),URL.revokeObjectURL(this.ya));this.__parent.__destruct.call(this)},decode:function(l){var p=this;p.ca&&p.ca(p);var A=new Image;p.ya=URL.createObjectURL(new Blob([l],{type:"image/png"}));A.onload=function(){p.Wa=A;p.la=la.ab(A);p.size(A.width,
373
+ A.height);p.U&&p.U(p)};A.src=p.ya}});class q{constructor(){this.Z=this.$=0;this.K=new Path2D}clear(){this.Z=this.$=0;this.K=new Path2D}Za(l){for(0<this.$&&this.Z<l.length&&this.clear();this.Z<l.length;)l[this.Z++](this.K);this.$++;return this.K}release(l){l===this.K&&this.$--}}var L=e.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this);this.ja=[];this.K=new q;this.ia=!1;this.S=null},rewind:function(){this.ja.length=0;this.K.clear();this.ia=!1;this.S=null},addPath:function(l,
374
+ p,A,t,G,B,C){const y=l.Sa();this.R(F=>{const H=new DOMMatrix;H.a=p;H.b=A;H.c=t;H.d=G;H.e=B;H.f=C;F.addPath(y,H)})},fillRule:function(l){this.xa=l},moveTo:function(l,p){this.ia=!0;const A={Ca:!0};this.S=A;this.R(t=>{t.moveTo(l,p);A.Ca&&t.lineTo(l,p)})},lineTo:function(l,p){this.wa();this.ga();this.R(A=>{A.lineTo(l,p)})},cubicTo:function(l,p,A,t,G,B){this.wa();this.ga();this.R(C=>{C.bezierCurveTo(l,p,A,t,G,B)})},close:function(){this.ga();this.R(l=>{l.closePath()})},wa:function(){this.ia||this.moveTo(0,
375
+ 0)},ga:function(){null!==this.S&&(this.S.Ca=!1,this.S=null)},R:function(l){this.ja.push(l)},fa:function(){return this.K.Za(this.ja)},za:function(l){this.K.release(l)},Sa:function(){const l=this.fa();this.K.clear();return l}}),I=k.extend("CanvasRenderPaint",{__construct:function(){this.__parent.__construct.call(this);this.B=[];this.ha=0;this.ka=r;this.oa=a(4278190080);this.ma=1;this.Y="miter";this.X="butt";this.ua=b(n.srcOver);this.N=null},color:function(l){this.B.push(()=>{this.oa=a(l)})},thickness:function(l){this.B.push(()=>
376
376
  {this.ma=Math.abs(l)})},join:function(l){this.B.push(()=>{switch(l){case m.miter:this.Y="miter";break;case m.round:this.Y="round";break;case m.bevel:this.Y="bevel"}})},cap:function(l){this.B.push(()=>{switch(l){case f.butt:this.X="butt";break;case f.round:this.X="round";break;case f.square:this.X="square"}})},style:function(l){this.B.push(()=>{this.ka=l})},blendMode:function(l){this.B.push(()=>{this.ua=b(l)})},clearGradient:function(){this.B.push(()=>{this.N=null})},linearGradient:function(l,p,A,
377
377
  t){this.B.push(()=>{this.N={Oa:l,Pa:p,Ea:A,Fa:t,sa:[]}})},radialGradient:function(l,p,A,t){this.B.push(()=>{this.N={Oa:l,Pa:p,Ea:A,Fa:t,sa:[],pb:!0}})},addStop:function(l,p){this.B.push(()=>{this.N.sa.push({color:l,stop:p})})},completeGradient:function(){},Ta:function(l,p,A,t){if(this.ka!==w||0<this.ma){var G=this.ka,B=this.oa,C=this.N,y=l.globalCompositeOperation,F=l.globalAlpha;l.globalCompositeOperation=this.ua;l.globalAlpha=t;if(null!=C){B=C.Oa;const O=C.Pa,Q=C.Ea;var H=C.Fa;t=C.sa;C.pb?(C=Q-
378
378
  B,H-=O,B=l.createRadialGradient(B,O,0,B,O,Math.sqrt(C*C+H*H))):B=l.createLinearGradient(B,O,Q,H);for(let S=0,Ca=t.length;S<Ca;S++)C=t[S],B.addColorStop(C.stop,a(C.color));this.oa=B;this.N=null}switch(G){case w:l.strokeStyle=B;l.lineWidth=this.ma;l.lineCap=this.X;l.lineJoin=this.Y;l.stroke(p);break;case r:l.fillStyle=B,l.fill(p,A)}l.globalCompositeOperation=y;l.globalAlpha=F}},Va:function(){return this.ha+this.B.length},Ua:function(l){const p=l-this.ha;for(let A=0;A<p;A++)this.B[A]();this.B.splice(0,
@@ -440,7 +440,7 @@ a,c,d,e)=>{a=U(a);let k=f=>f;if(0===d){var g=32-8*c;k=f=>f<<g>>>g;e=k(e)}V(b,{na
440
440
  (d=new Uint8Array(d));var e="string"==typeof d;if(!(e||ArrayBuffer.isView(d)&&1==d.BYTES_PER_ELEMENT))throw new N("Cannot pass non-string to std::string");var k=e?kc(d):d.length;var g=Jc(4+k+1),f=g+4;M[g>>2]=k;e?jc(d,f,k+1):D.set(d,f);null!==c&&c.push(hb,g);return g},F:pb,C(c){hb(c)}})},_embind_register_std_wstring:(b,a,c)=>{c=U(c);if(2===a){var d=pc;var e=qc;var k=rc}else d=sc,e=tc,k=uc;V(b,{name:c,i:g=>{var f=d(g+4,M[g>>2]*a,!0);hb(g);return f},o:(g,f)=>{if("string"!=typeof f)throw new N(`Cannot pass non-string to C++ string type ${c}`);
441
441
  var m=k(f),n=Jc(4+m+a);M[n>>2]=m/a;e(f,n+4,m+a);null!==g&&g.push(hb,n);return n},F:pb,C(g){hb(g)}})},_embind_register_value_object:(b,a,c,d,e,k)=>{nb[b]={name:U(a),ra:Z(c,d),I:Z(e,k),Ga:[]}},_embind_register_value_object_field:(b,a,c,d,e,k,g,f,m,n)=>{nb[b].Ga.push({hb:U(a),nb:c,lb:Z(d,e),mb:k,yb:g,xb:Z(f,m),zb:n})},_embind_register_void:(b,a)=>{a=U(a);V(b,{qb:!0,name:a,i:()=>{},o:()=>{}})},_emscripten_runtime_keepalive_clear:()=>{Za=!1;vc=0},_emval_create_invoker:(b,a,c)=>{var [d,...e]=yc(b,a),k=
442
442
  d.o.bind(d),g=e.map(m=>m.F.bind(m));b--;var f=Array(b);a=`methodCaller<(${e.map(m=>m.name)}) => ${d.name}>`;return xc($a(a,(m,n,r,w)=>{for(var z=0,v=0;v<b;++v)f[v]=g[v](w+z),z+=8;switch(c){case 0:var x=P(m).apply(null,f);break;case 2:x=Reflect.construct(P(m),f);break;case 3:x=f[0];break;case 1:x=P(m)[Ac(n)](...f)}m=[];x=k(m,x);m.length&&(M[r>>2]=T(m));return x}))},_emval_decref:$b,_emval_get_module_property:b=>{b=Ac(b);return T(h[b])},_emval_get_property:(b,a)=>{b=P(b);a=P(a);return T(b[a])},_emval_incref:b=>
443
- {9<b&&(bb[b+1]+=1)},_emval_invoke:(b,a,c,d,e)=>wc[b](a,c,d,e),_emval_new_array:()=>T([]),_emval_new_cstring:b=>T(Ac(b)),_emval_new_object:()=>T({}),_emval_run_destructors:b=>{var a=P(b);ob(a);$b(b)},_emval_set_property:(b,a,c)=>{b=P(b);a=P(a);c=P(c);b[a]=c},_setitimer_js:(b,a)=>{Bc[b]&&(clearTimeout(Bc[b].id),delete Bc[b]);if(!a)return 0;var c=setTimeout(()=>{delete Bc[b];Ec(()=>Kc(b,performance.now()))},a);Bc[b]={id:c,Cb:a};return 0},_tzset_js:(b,a,c,d)=>{var e=(new Date).getFullYear(),k=(new Date(e,
443
+ {9<b&&(bb[b+1]+=1)},_emval_invoke:(b,a,c,d,e)=>wc[b](a,c,d,e),_emval_new_array:()=>T([]),_emval_new_cstring:b=>T(Ac(b)),_emval_new_object:()=>T({}),_emval_run_destructors:b=>{var a=P(b);ob(a);$b(b)},_emval_set_property:(b,a,c)=>{b=P(b);a=P(a);c=P(c);b[a]=c},_setitimer_js:(b,a)=>{Bc[b]&&(clearTimeout(Bc[b].id),delete Bc[b]);if(!a)return 0;var c=setTimeout(()=>{delete Bc[b];Ec(()=>Kc(b,performance.now()))},a);Bc[b]={id:c,Db:a};return 0},_tzset_js:(b,a,c,d)=>{var e=(new Date).getFullYear(),k=(new Date(e,
444
444
  0,1)).getTimezoneOffset();e=(new Date(e,6,1)).getTimezoneOffset();M[b>>2]=60*Math.max(k,e);Fa[a>>2]=Number(k!=e);a=g=>{var f=Math.abs(g);return`UTC${0<=g?"-":"+"}${String(Math.floor(f/60)).padStart(2,"0")}${String(f%60).padStart(2,"0")}`};b=a(k);a=a(e);e<k?(jc(b,c,17),jc(a,d,17)):(jc(b,d,17),jc(a,c,17))},clock_time_get:function(b,a,c,d){if(!(0<=b&&3>=b))return 28;b=Math.round(1E6*(0===b?Date.now():performance.now()));Ra=[b>>>0,(Qa=b,1<=+Math.abs(Qa)?0<Qa?+Math.floor(Qa/4294967296)>>>0:~~+Math.ceil((Qa-
445
445
  +(~~Qa>>>0))/4294967296)>>>0:0)];Fa[d>>2]=Ra[0];Fa[d+4>>2]=Ra[1];return 0},emscripten_resize_heap:b=>{var a=D.length;b>>>=0;if(2147483648<b)return!1;for(var c=1;4>=c;c*=2){var d=a*(1+.2/c);d=Math.min(d,b+100663296);a:{d=(Math.min(2147483648,65536*Math.ceil(Math.max(b,d)/65536))-Ka.buffer.byteLength+65535)/65536|0;try{Ka.grow(d);Ja();var e=1;break a}catch(k){}e=void 0}if(e)return!0}return!1},environ_get:(b,a)=>{var c=0,d=0,e;for(e of Hc()){var k=a+c;M[b+d>>2]=k;c+=jc(e,k,Infinity)+1;d+=4}return 0},
446
446
  environ_sizes_get:(b,a)=>{var c=Hc();M[b>>2]=c.length;b=0;for(var d of c)b+=kc(d)+1;M[a>>2]=b;return 0},fd_close:()=>52,fd_seek:function(){return 70},fd_write:(b,a,c,d)=>{for(var e=0,k=0;k<c;k++){var g=M[a>>2],f=M[a+4>>2];a+=8;for(var m=0;m<f;m++){var n=b,r=D[g+m],w=Ic[n];0===r||10===r?((1===n?ua:va)(nc(w)),w.length=0):w.push(r)}e+=f}M[d>>2]=e;return 0},proc_exit:Dc},Mc;
@@ -455,7 +455,7 @@ Ma??=h.locateFile?h.locateFile("canvas_advanced.wasm",oa):oa+"canvas_advanced.wa
455
455
  /* 5 */
456
456
  /***/ ((module) => {
457
457
 
458
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.43.0","description":"A lite version of 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}}');
458
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.44.0","description":"A lite version of 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}}');
459
459
 
460
460
  /***/ }),
461
461
  /* 6 */
@@ -581,6 +581,17 @@ var SemanticTreeModel = /** @class */ (function () {
581
581
  SemanticTreeModel.prototype.nodeById = function (id) {
582
582
  return this._nodesById.get(id);
583
583
  };
584
+ /** The node with SemanticState.Focused, or undefined. */
585
+ SemanticTreeModel.prototype.focusedNode = function () {
586
+ // Manual iteration: runs every frame and must stop at the first hit (the
587
+ // TS target forbids for-of over Map iterators).
588
+ var it = this._nodesById.values();
589
+ for (var r = it.next(); !r.done; r = it.next()) {
590
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(r.value.stateFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Focused))
591
+ return r.value;
592
+ }
593
+ return;
594
+ };
584
595
  /** Current index of a node among its siblings (or roots), or -1 if absent. */
585
596
  SemanticTreeModel.prototype.siblingIndexOf = function (id) {
586
597
  var node = this._nodesById.get(id);
@@ -1128,8 +1139,42 @@ __webpack_require__.r(__webpack_exports__);
1128
1139
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1129
1140
  /* harmony export */ AccessibilityOverlay: () => (/* binding */ AccessibilityOverlay)
1130
1141
  /* harmony export */ });
1131
- /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
1142
+ /* harmony import */ var _claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
1143
+ /* harmony import */ var _utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11);
1144
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
1132
1145
 
1146
+
1147
+
1148
+ var warnedUnpositionedWrapper = false;
1149
+ /**
1150
+ * Warns once per page when no positioned element sits at or inside the canvas's
1151
+ * nearest scroll container: the overlay then can't scroll with the canvas. Reads only.
1152
+ */
1153
+ function warnIfWrapperUnpositioned(canvas) {
1154
+ if (warnedUnpositionedWrapper)
1155
+ return;
1156
+ // Null when detached (or display:none / fixed); nothing to judge yet.
1157
+ var offsetParent = canvas.offsetParent;
1158
+ if (!offsetParent)
1159
+ return;
1160
+ var scrolls = function (v) { return v === "auto" || v === "scroll" || v === "overlay"; };
1161
+ var scroller = null;
1162
+ var el = canvas.parentElement;
1163
+ // Bounds pathological nesting.
1164
+ var MAX_ANCESTOR_WALK = 32;
1165
+ for (var i = 0; el && el !== document.documentElement && i < MAX_ANCESTOR_WALK; i++, el = el.parentElement) {
1166
+ var style = getComputedStyle(el);
1167
+ if (scrolls(style.overflowX) || scrolls(style.overflowY)) {
1168
+ scroller = el;
1169
+ break;
1170
+ }
1171
+ }
1172
+ // Only the viewport scrolls: any offsetParent scrolls with the page.
1173
+ if (!scroller || scroller.contains(offsetParent))
1174
+ return;
1175
+ warnedUnpositionedWrapper = true;
1176
+ console.warn('[Rive] Semantics: give the element wrapping the <canvas> "position: relative" (or another positioned value) so the semantic overlay scrolls with the canvas. Without it, screen readers may scroll to stale positions when the canvas is inside a scrolling container.');
1177
+ }
1133
1178
  /**
1134
1179
  * Creates and manages an invisible DOM tree overlaying a Rive canvas. This is for
1135
1180
  * screen readers to discover and interact with the Rive content.
@@ -1147,7 +1192,7 @@ __webpack_require__.r(__webpack_exports__);
1147
1192
  var AccessibilityOverlay = /** @class */ (function () {
1148
1193
  function AccessibilityOverlay(options) {
1149
1194
  var _this = this;
1150
- var _a;
1195
+ var _a, _b;
1151
1196
  this.elements = new Map();
1152
1197
  /** Visually-hidden description spans keyed by node ID, referenced by aria-describedby. */
1153
1198
  this.descElements = new Map();
@@ -1157,6 +1202,8 @@ var AccessibilityOverlay = /** @class */ (function () {
1157
1202
  this.pendingTextGeometry = [];
1158
1203
  /** Last measured box-size|text key per text element, to skip redundant re-measures. */
1159
1204
  this.textGeometryKeys = new WeakMap();
1205
+ /** Node data last passed to applyAttributes per element; see {@link setEditingHostNode}. */
1206
+ this.appliedNodes = new WeakMap();
1160
1207
  this.lastCanvasPositioning = {
1161
1208
  width: -1, height: -1, offsetTop: -1, offsetLeft: -1,
1162
1209
  };
@@ -1169,6 +1216,10 @@ var AccessibilityOverlay = /** @class */ (function () {
1169
1216
  this._geometryDirty = true;
1170
1217
  /** True while reconciling the DOM (reserved for future focus-sync guards). */
1171
1218
  this.isUpdating = false;
1219
+ /** Node whose element the editing host stands in for, or null. */
1220
+ this.editingHostNodeId = null;
1221
+ /** Semantic version last folded into the editing host's decoration. */
1222
+ this.editingHostSemanticVersion = -1;
1172
1223
  /**
1173
1224
  * Single child div of the overlay container that carries the artboard→CSS
1174
1225
  * transform. All semantic node elements are children of this div and express
@@ -1193,9 +1244,116 @@ var AccessibilityOverlay = /** @class */ (function () {
1193
1244
  this.canvas = options.canvas;
1194
1245
  this.semanticsOptions = options.semanticsOptions;
1195
1246
  this.allowFocusInterrupt = (_a = options.allowFocusInterrupt) !== null && _a !== void 0 ? _a : false;
1247
+ this.isEditingHostFocused = (_b = options.isEditingHostFocused) !== null && _b !== void 0 ? _b : (function () { return false; });
1196
1248
  this.container = this.createContainer(options.canvas);
1197
1249
  this.attachPositionObservers();
1250
+ warnIfWrapperUnpositioned(options.canvas);
1198
1251
  }
1252
+ /**
1253
+ * Hide the stood-in node's element (no duplicate textbox for AT); re-derive the previous
1254
+ * one's aria-hidden.
1255
+ */
1256
+ AccessibilityOverlay.prototype.setEditingHostNode = function (nodeId) {
1257
+ if (this.editingHostNodeId === nodeId)
1258
+ return;
1259
+ var previous = this.editingHostNodeId;
1260
+ this.editingHostNodeId = nodeId;
1261
+ if (previous !== null) {
1262
+ var previousEl = this.elements.get(previous);
1263
+ // Re-derive rather than un-hide: the node may have become Hidden mid-session.
1264
+ if (previousEl) {
1265
+ var previousNode = this.appliedNodes.get(previousEl);
1266
+ if (previousNode && this.isAriaHidden(previousNode)) {
1267
+ setAttr(previousEl, "aria-hidden", "true");
1268
+ }
1269
+ else {
1270
+ removeAttr(previousEl, "aria-hidden");
1271
+ }
1272
+ }
1273
+ }
1274
+ if (nodeId !== null) {
1275
+ var el = this.elements.get(nodeId);
1276
+ if (el)
1277
+ setAttr(el, "aria-hidden", "true");
1278
+ }
1279
+ };
1280
+ /**
1281
+ * Describe the focused text field on the host and hide its element; no-op unless
1282
+ * semantics changed.
1283
+ * @param force - apply even if semantics are unchanged (session start).
1284
+ */
1285
+ AccessibilityOverlay.prototype.syncEditingHost = function (tree, host, force) {
1286
+ var _a;
1287
+ if (!force && tree.semanticVersion === this.editingHostSemanticVersion)
1288
+ return;
1289
+ this.editingHostSemanticVersion = tree.semanticVersion;
1290
+ var node = tree.focusedNode();
1291
+ if (node === undefined || node.role !== _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) {
1292
+ // Nothing to describe; drop the stale description rather than misname the host.
1293
+ if (this.editingHostNodeId !== null) {
1294
+ host.resetDecoration();
1295
+ this.setEditingHostNode(null);
1296
+ }
1297
+ return;
1298
+ }
1299
+ // Every key is passed on every call, nulls included, so nothing survives from
1300
+ // the previously described field.
1301
+ host.setSecure((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Obscured));
1302
+ host.decorate({
1303
+ "aria-label": node.label || null,
1304
+ "aria-readonly": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly) ? "true" : null,
1305
+ "aria-multiline": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Multiline) ? "true" : null,
1306
+ // Trait-gated to match applyAttributes.
1307
+ "aria-required": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Requirable) &&
1308
+ (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Required)
1309
+ ? "true"
1310
+ : null,
1311
+ // The hint span applyAttributes maintains (update() runs earlier in the frame).
1312
+ "aria-describedby": (node.hint && ((_a = this.descElements.get(node.id)) === null || _a === void 0 ? void 0 : _a.id)) || null,
1313
+ });
1314
+ this.setEditingHostNode(node.id);
1315
+ };
1316
+ /** True while the editing host stands in for a node's element. */
1317
+ AccessibilityOverlay.prototype.hasEditingHost = function () {
1318
+ return this.editingHostNodeId !== null;
1319
+ };
1320
+ /**
1321
+ * Undo the stand-in; if the host still has DOM focus, move it to the focused node's
1322
+ * element so AT announces it.
1323
+ */
1324
+ AccessibilityOverlay.prototype.releaseEditingHost = function (tree, host) {
1325
+ var _a;
1326
+ host === null || host === void 0 ? void 0 : host.resetDecoration();
1327
+ this.setEditingHostNode(null);
1328
+ this.editingHostSemanticVersion = -1;
1329
+ if (!(host === null || host === void 0 ? void 0 : host.hasDomFocus()))
1330
+ return;
1331
+ var focusedNodeId = (_a = tree === null || tree === void 0 ? void 0 : tree.focusedNode()) === null || _a === void 0 ? void 0 : _a.id;
1332
+ if (focusedNodeId !== undefined)
1333
+ this.focusNodeElement(focusedNodeId);
1334
+ };
1335
+ /** Move DOM focus onto a node's element. No-op for a node with no element. */
1336
+ AccessibilityOverlay.prototype.focusNodeElement = function (nodeId) {
1337
+ var el = this.elements.get(nodeId);
1338
+ if (!el)
1339
+ return;
1340
+ this.focusElementInPlace(el);
1341
+ };
1342
+ // The overlay is positioned outside the canvas's scroll chain, so a plain focus()
1343
+ // would scroll the root instead; scroll the canvas into view through its real ancestors.
1344
+ AccessibilityOverlay.prototype.focusElementInPlace = function (el) {
1345
+ var _a, _b;
1346
+ this.syncContainerBeforeFocus();
1347
+ el.focus({ preventScroll: true });
1348
+ (_b = (_a = this.canvas).scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, {
1349
+ block: "nearest",
1350
+ inline: "nearest",
1351
+ behavior: "instant",
1352
+ });
1353
+ // The scroll moved the canvas; re-align now rather than after the observer throttle.
1354
+ this.syncContainerGeometry();
1355
+ this.observePosition();
1356
+ };
1199
1357
  AccessibilityOverlay.prototype.getSemanticOverlayContainer = function () {
1200
1358
  return this.container;
1201
1359
  };
@@ -1273,15 +1431,16 @@ var AccessibilityOverlay = /** @class */ (function () {
1273
1431
  _this.observePosition();
1274
1432
  }, 500); // Throttle to avoid rapid style recalculations
1275
1433
  };
1434
+ /** Returns true when the container's size changed (node transforms need recomputing). */
1276
1435
  AccessibilityOverlay.prototype.syncContainerGeometry = function () {
1277
1436
  var rect = this.canvas.getBoundingClientRect();
1278
- var top = this.canvas.offsetTop;
1279
- var left = this.canvas.offsetLeft;
1280
- if (rect.width === this.lastCanvasPositioning.width &&
1281
- rect.height === this.lastCanvasPositioning.height &&
1437
+ var _a = (0,_utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__.canvasOffset)(this.canvas), top = _a.top, left = _a.left;
1438
+ var sizeChanged = rect.width !== this.lastCanvasPositioning.width ||
1439
+ rect.height !== this.lastCanvasPositioning.height;
1440
+ if (!sizeChanged &&
1282
1441
  top === this.lastCanvasPositioning.offsetTop &&
1283
1442
  left === this.lastCanvasPositioning.offsetLeft)
1284
- return;
1443
+ return false;
1285
1444
  this.container.style.top = top + "px";
1286
1445
  this.container.style.left = left + "px";
1287
1446
  this.container.style.width = rect.width + "px";
@@ -1291,6 +1450,16 @@ var AccessibilityOverlay = /** @class */ (function () {
1291
1450
  this.lastCanvasPositioning.height = rect.height;
1292
1451
  this.lastCanvasPositioning.offsetTop = top;
1293
1452
  this.lastCanvasPositioning.offsetLeft = left;
1453
+ return sizeChanged;
1454
+ };
1455
+ /**
1456
+ * Re-align the container right before focusing one of its elements. The position
1457
+ * observer re-syncs after scrolling on a throttle; focusing an element while the
1458
+ * container is stale would make the browser scroll the page to where it sits.
1459
+ */
1460
+ AccessibilityOverlay.prototype.syncContainerBeforeFocus = function () {
1461
+ if (this.syncContainerGeometry())
1462
+ this._geometryDirty = true;
1294
1463
  };
1295
1464
  AccessibilityOverlay.prototype.createContainer = function (canvas) {
1296
1465
  var _a, _b;
@@ -1300,10 +1469,13 @@ var AccessibilityOverlay = /** @class */ (function () {
1300
1469
  container.setAttribute("aria-label", (_b = (_a = this.semanticsOptions) === null || _a === void 0 ? void 0 : _a.riveCanvasLabel) !== null && _b !== void 0 ? _b : "Rive animation");
1301
1470
  // Size to the canvas's CSS layout box, not the parent container.
1302
1471
  var rect = canvas.getBoundingClientRect();
1472
+ var _c = (0,_utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__.canvasOffset)(this.canvas), top = _c.top, left = _c.left;
1303
1473
  container.style.cssText = [
1304
1474
  "position:absolute",
1305
- "top:".concat(canvas.offsetTop, "px"),
1306
- "left:".concat(canvas.offsetLeft, "px"),
1475
+ "top:".concat(top, "px"),
1476
+ "left:".concat(left, "px"),
1477
+ "line-height:normal",
1478
+ "font-size:16px",
1307
1479
  "width:".concat(rect.width, "px"),
1308
1480
  "height:".concat(rect.height, "px"),
1309
1481
  "overflow:hidden",
@@ -1480,8 +1652,8 @@ var AccessibilityOverlay = /** @class */ (function () {
1480
1652
  // The cheap trait/state flag checks gate the (per-node) DOM queries below,
1481
1653
  // so the activeElement/closest/contains walks only run for a node that is
1482
1654
  // actually focusable + focused — not for every node on every frame.
1483
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(nodeData.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable) &&
1484
- (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(nodeData.stateFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Focused)) {
1655
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(nodeData.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable) &&
1656
+ (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(nodeData.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Focused)) {
1485
1657
  var active = document.activeElement;
1486
1658
  // While focus is inside one of our modal dialogs, don't pull it back
1487
1659
  // out to a background node.
@@ -1489,8 +1661,16 @@ var AccessibilityOverlay = /** @class */ (function () {
1489
1661
  var trappedByModal = !!focusedModal &&
1490
1662
  this.container.contains(focusedModal) &&
1491
1663
  !focusedModal.contains(el);
1492
- if (active !== el && !trappedByModal && this.canMoveFocus()) {
1493
- el.focus();
1664
+ // Not while the proxy has focus (would steal the caret, drop the keyboard) nor onto
1665
+ // its aria-hidden stand-in.
1666
+ if (nodeId !== this.editingHostNodeId &&
1667
+ active !== el &&
1668
+ !trappedByModal &&
1669
+ !this.isEditingHostFocused() &&
1670
+ this.canMoveFocus()) {
1671
+ // No scrollIntoView: this runs on semantic diffs and must not drag the page.
1672
+ this.syncContainerBeforeFocus();
1673
+ el.focus({ preventScroll: true });
1494
1674
  }
1495
1675
  }
1496
1676
  // Recurse into children with this node's absolute artboard position.
@@ -1629,7 +1809,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1629
1809
  var el = document.createElement(tag);
1630
1810
  el.id = "".concat(this.nodeIdPrefix).concat(node.id);
1631
1811
  el.style.cssText = BASE_NODE_STYLE;
1632
- if (node.role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
1812
+ if (node.role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
1633
1813
  // The positioned outer div is the AX element
1634
1814
  // VoiceOver uses for its highlight box; an inner <span> carries the text
1635
1815
  // without position:absolute (which would strip the span from VoiceOver's
@@ -1661,7 +1841,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1661
1841
  target = "last";
1662
1842
  if (!target)
1663
1843
  return;
1664
- e.preventDefault();
1844
+ (0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
1665
1845
  var members = opts.members();
1666
1846
  var idx = members.indexOf(el);
1667
1847
  if (idx < 0)
@@ -1672,10 +1852,10 @@ var AccessibilityOverlay = /** @class */ (function () {
1672
1852
  : target === "first" ? members[0]
1673
1853
  : members[n - 1];
1674
1854
  if (next && next !== el) {
1675
- next.focus();
1855
+ _this.focusElementInPlace(next);
1676
1856
  var nextId = _this.nodeIdFromElement(next);
1677
1857
  if (nextId !== null)
1678
- _this.fireAction(nextId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
1858
+ _this.fireAction(nextId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
1679
1859
  }
1680
1860
  });
1681
1861
  };
@@ -1685,31 +1865,31 @@ var AccessibilityOverlay = /** @class */ (function () {
1685
1865
  var nodeId = node.id;
1686
1866
  if (isClickableRole(role)) {
1687
1867
  el.addEventListener("click", function () {
1688
- _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
1868
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
1689
1869
  });
1690
1870
  // Links activate on Enter only (Space scrolls the page per browser
1691
1871
  // convention). All other clickable roles accept both Enter and Space.
1692
- var activationKeys_1 = role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link ? ["Enter"] : ["Enter", " "];
1872
+ var activationKeys_1 = role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link ? ["Enter"] : ["Enter", " "];
1693
1873
  el.addEventListener("keydown", function (e) {
1694
1874
  if (activationKeys_1.includes(e.key)) {
1695
- e.preventDefault();
1696
- _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
1875
+ (0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
1876
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
1697
1877
  }
1698
1878
  });
1699
1879
  }
1700
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider) {
1880
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider) {
1701
1881
  el.addEventListener("keydown", function (e) {
1702
1882
  if (e.key === "ArrowRight" || e.key === "ArrowUp") {
1703
- e.preventDefault();
1704
- _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.increase);
1883
+ (0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
1884
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.increase);
1705
1885
  }
1706
1886
  else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
1707
- e.preventDefault();
1708
- _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.decrease);
1887
+ (0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
1888
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.decrease);
1709
1889
  }
1710
1890
  });
1711
1891
  }
1712
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab) {
1892
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab) {
1713
1893
  this.attachRovingNav(el, {
1714
1894
  includeHomeEnd: true,
1715
1895
  members: function () {
@@ -1722,7 +1902,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1722
1902
  },
1723
1903
  });
1724
1904
  }
1725
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton) {
1905
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton) {
1726
1906
  this.attachRovingNav(el, {
1727
1907
  includeHomeEnd: false,
1728
1908
  members: function () {
@@ -1737,15 +1917,31 @@ var AccessibilityOverlay = /** @class */ (function () {
1737
1917
  // Focus handler for nodes with the Focusable trait. When AT focuses an
1738
1918
  // element, notify the C++ runtime so it can update internal focus state
1739
1919
  // (visual focus rings, etc.). Gated on Focusable trait
1740
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable)) {
1920
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable)) {
1741
1921
  el.addEventListener("focus", function () {
1742
1922
  _this.requestFocus(nodeId);
1743
1923
  });
1744
1924
  }
1745
1925
  };
1746
1926
  // ---- Attribute application ----
1927
+ AccessibilityOverlay.prototype.isAriaHidden = function (node) {
1928
+ var role = node.role;
1929
+ var flags = node.stateFlags;
1930
+ // Hide from AT when explicitly hidden, or when an image has no accessible
1931
+ // name — a nameless role="img" is a WCAG 1.1.1 violation; treat it as
1932
+ // decorative instead.
1933
+ var isDecorativeImage = role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.image && !node.label;
1934
+ // The <input> proxy is the accessible element for the node it stands in for.
1935
+ var isEditingHostStandIn = node.id === this.editingHostNodeId;
1936
+ return ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Hidden) ||
1937
+ // Obscured text fields stay reachable (value withheld, like a native password input).
1938
+ ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Obscured) && role !== _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) ||
1939
+ isDecorativeImage ||
1940
+ isEditingHostStandIn);
1941
+ };
1747
1942
  AccessibilityOverlay.prototype.applyAttributes = function (el, node) {
1748
1943
  var _a, _b, _c;
1944
+ this.appliedNodes.set(el, node);
1749
1945
  var role = node.role;
1750
1946
  var flags = node.stateFlags;
1751
1947
  var traits = node.traitFlags;
@@ -1759,7 +1955,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1759
1955
  }
1760
1956
  // Links: a bare <a> with no href has no link semantics, so set the role
1761
1957
  // explicitly (ariaRoleForSemantic returns null for link → native <a>).
1762
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link) {
1958
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link) {
1763
1959
  setAttr(el, "role", "link");
1764
1960
  }
1765
1961
  // Tabindex — keep the screen-reader overlay out of the browser's sequential
@@ -1767,8 +1963,8 @@ var AccessibilityOverlay = /** @class */ (function () {
1767
1963
  // so AT/runtime focus sync can still target them when needed. List items are
1768
1964
  // included because Mobile Safari won't iterate them otherwise.
1769
1965
  if (isInteractiveRole(role) ||
1770
- (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable) ||
1771
- role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.listItem) {
1966
+ (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable) ||
1967
+ role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.listItem) {
1772
1968
  setAttr(el, "tabindex", "-1");
1773
1969
  }
1774
1970
  else {
@@ -1781,7 +1977,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1781
1977
  else {
1782
1978
  removeAttr(el, "aria-label");
1783
1979
  }
1784
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider) {
1980
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider) {
1785
1981
  if (node.value) {
1786
1982
  // aria-valuenow must be numeric; keep the display string (e.g. "75%")
1787
1983
  // in aria-valuetext only.
@@ -1801,7 +1997,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1801
1997
  // TODO: aria-valuemin / aria-valuemax are required by ARIA.
1802
1998
  // Defaulting to horizontal; vertical sliders need orientation data from C++.
1803
1999
  setAttr(el, "aria-orientation", "horizontal");
1804
- setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.ReadOnly));
2000
+ setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly));
1805
2001
  }
1806
2002
  else {
1807
2003
  removeAttr(el, "aria-valuenow");
@@ -1835,7 +2031,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1835
2031
  // Text nodes: use textContent rather than aria-label so screen readers
1836
2032
  // announce the text in virtual/browse mode (aria-label on a bare <span>
1837
2033
  // with no widget role is ignored by some AT in document browse mode).
1838
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
2034
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
1839
2035
  var textSpan = (_a = el.querySelector(":scope > span")) !== null && _a !== void 0 ? _a : el;
1840
2036
  var text = (_b = node.label) !== null && _b !== void 0 ? _b : "";
1841
2037
  if (textSpan.textContent !== text)
@@ -1855,77 +2051,73 @@ var AccessibilityOverlay = /** @class */ (function () {
1855
2051
  // Only set the ARIA property when the trait is present. When the trait
1856
2052
  // is absent, remove the attribute so AT sees "not applicable" rather
1857
2053
  // than "false".
1858
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Expandable) && ARIA_EXPANDED_ROLES.has(role)) {
1859
- setBoolAttr(el, "aria-expanded", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Expanded));
2054
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Expandable) && ARIA_EXPANDED_ROLES.has(role)) {
2055
+ setBoolAttr(el, "aria-expanded", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Expanded));
1860
2056
  }
1861
2057
  else {
1862
2058
  removeAttr(el, "aria-expanded");
1863
2059
  }
1864
2060
  // aria-selected is required on ALL tabs per ARIA spec regardless of trait;
1865
2061
  // for other roles it is trait-gated and guarded to ARIA_SELECTED_ROLES.
1866
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab) {
1867
- setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Selected));
2062
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab) {
2063
+ setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Selected));
1868
2064
  }
1869
- else if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Selectable) && ARIA_SELECTED_ROLES.has(role)) {
1870
- setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Selected));
2065
+ else if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Selectable) && ARIA_SELECTED_ROLES.has(role)) {
2066
+ setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Selected));
1871
2067
  }
1872
2068
  else {
1873
2069
  removeAttr(el, "aria-selected");
1874
2070
  }
1875
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Checkable) && ARIA_CHECKED_ROLES.has(role)) {
2071
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Checkable) && ARIA_CHECKED_ROLES.has(role)) {
1876
2072
  // Check state is a tri-state field, but not every checkable role
1877
2073
  // accepts all three values — see ARIA_MIXED_ROLES.
1878
- var checkState = (0,_types__WEBPACK_IMPORTED_MODULE_0__.checkStateOf)(flags);
1879
- if (checkState === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticCheckState.Mixed &&
2074
+ var checkState = (0,_types__WEBPACK_IMPORTED_MODULE_2__.checkStateOf)(flags);
2075
+ if (checkState === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticCheckState.Mixed &&
1880
2076
  ARIA_MIXED_ROLES.has(role)) {
1881
2077
  setAttr(el, "aria-checked", "mixed");
1882
2078
  }
1883
2079
  else {
1884
- setBoolAttr(el, "aria-checked", checkState === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticCheckState.Checked);
2080
+ setBoolAttr(el, "aria-checked", checkState === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticCheckState.Checked);
1885
2081
  }
1886
2082
  }
1887
2083
  else {
1888
2084
  removeAttr(el, "aria-checked");
1889
2085
  }
1890
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Toggleable)) {
2086
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Toggleable)) {
1891
2087
  if (ARIA_PRESSED_ROLES.has(role)) {
1892
- setBoolAttr(el, "aria-pressed", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Toggled));
2088
+ setBoolAttr(el, "aria-pressed", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Toggled));
1893
2089
  }
1894
2090
  else {
1895
2091
  removeAttr(el, "aria-pressed");
1896
2092
  }
1897
2093
  // switch uses aria-checked (not aria-pressed) for its on/off state.
1898
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl) {
1899
- setBoolAttr(el, "aria-checked", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Toggled));
2094
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl) {
2095
+ setBoolAttr(el, "aria-checked", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Toggled));
1900
2096
  }
1901
2097
  }
1902
2098
  else {
1903
2099
  removeAttr(el, "aria-pressed");
1904
2100
  }
1905
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Requirable) && ARIA_REQUIRED_ROLES.has(role)) {
1906
- setBoolAttr(el, "aria-required", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Required));
2101
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Requirable) && ARIA_REQUIRED_ROLES.has(role)) {
2102
+ setBoolAttr(el, "aria-required", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Required));
1907
2103
  }
1908
2104
  else {
1909
2105
  removeAttr(el, "aria-required");
1910
2106
  }
1911
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Enablable)) {
1912
- setBoolAttr(el, "aria-disabled", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Disabled));
2107
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Enablable)) {
2108
+ setBoolAttr(el, "aria-disabled", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Disabled));
1913
2109
  }
1914
2110
  else {
1915
2111
  removeAttr(el, "aria-disabled");
1916
2112
  }
1917
2113
  // ---- Non-trait states ----
1918
- // Hide from AT when explicitly hidden, or when an image has no accessible
1919
- // name — a nameless role="img" is a WCAG 1.1.1 violation; treat it as
1920
- // decorative instead.
1921
- var isDecorativeImage = role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.image && !node.label;
1922
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Hidden) || (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Obscured) || isDecorativeImage) {
2114
+ if (this.isAriaHidden(node)) {
1923
2115
  setAttr(el, "aria-hidden", "true");
1924
2116
  }
1925
2117
  else {
1926
2118
  removeAttr(el, "aria-hidden");
1927
2119
  }
1928
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.LiveRegion)) {
2120
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.LiveRegion)) {
1929
2121
  setAttr(el, "aria-live", "polite");
1930
2122
  }
1931
2123
  else {
@@ -1933,17 +2125,26 @@ var AccessibilityOverlay = /** @class */ (function () {
1933
2125
  }
1934
2126
  // textField-specific
1935
2127
  // TODO: Details here may change once we implement text inputs
1936
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField) {
1937
- setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.ReadOnly));
1938
- setBoolAttr(el, "aria-multiline", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Multiline));
2128
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) {
2129
+ setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly));
2130
+ setBoolAttr(el, "aria-multiline", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Multiline));
1939
2131
  // Surface the current field value as DOM text so screen readers can
1940
2132
  // announce it. Only safe when the node has no semantic children —
1941
2133
  // setting textContent would remove any child elements from the DOM.
1942
2134
  if (node.children.length === 0) {
1943
- var value = (_c = node.value) !== null && _c !== void 0 ? _c : "";
2135
+ var value = (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Obscured) ? "" : ((_c = node.value) !== null && _c !== void 0 ? _c : "");
1944
2136
  if (el.textContent !== value)
1945
2137
  el.textContent = value;
1946
2138
  }
2139
+ else {
2140
+ // A value rendered earlier (before the node had children) must not linger,
2141
+ // least of all once the field turns Obscured.
2142
+ for (var _i = 0, _d = Array.from(el.childNodes); _i < _d.length; _i++) {
2143
+ var child = _d[_i];
2144
+ if (child.nodeType === Node.TEXT_NODE)
2145
+ child.remove();
2146
+ }
2147
+ }
1947
2148
  }
1948
2149
  else {
1949
2150
  removeAttr(el, "aria-multiline");
@@ -2007,7 +2208,7 @@ var AccessibilityOverlay = /** @class */ (function () {
2007
2208
  // Clear any CSS transform from a previous render pass.
2008
2209
  if (el.style.transform)
2009
2210
  el.style.transform = "";
2010
- if (node.role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
2211
+ if (node.role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
2011
2212
  this.pendingTextGeometry.push(el);
2012
2213
  }
2013
2214
  };
@@ -2066,7 +2267,8 @@ var AccessibilityOverlay = /** @class */ (function () {
2066
2267
  * Creates (on first call) and updates the artboard-space transform container.
2067
2268
  *
2068
2269
  * The container is sized to the artboard dimensions and carries a CSS
2069
- * `transform: matrix(...)` equivalent to `forwardMat / dpr`. All semantic
2270
+ * `transform: matrix(...)` that maps artboard coordinates to the canvas's CSS box
2271
+ * (forwardMat in backing-store pixels, scaled by CSS size / backing-store size). All semantic
2070
2272
  * node elements are children of this container and use raw artboard
2071
2273
  * coordinates as their CSS `left/top/width/height`, so the CSS compositor
2072
2274
  * applies the artboard→screen mapping in one pass.
@@ -2091,13 +2293,20 @@ var AccessibilityOverlay = /** @class */ (function () {
2091
2293
  var h = artboardBounds.maxY - artboardBounds.minY;
2092
2294
  this.transformContainer.style.width = Math.round(w) + "px";
2093
2295
  this.transformContainer.style.height = Math.round(h) + "px";
2094
- var s = 1 / (dpr || 1);
2095
- var a = forwardMat.xx * s;
2096
- var b = forwardMat.xy * s;
2097
- var c = forwardMat.yx * s;
2098
- var d = forwardMat.yy * s;
2099
- var tx = forwardMat.tx * s;
2100
- var ty = forwardMat.ty * s;
2296
+ // Backing-store pixels → CSS pixels. Measured rather than 1/dpr: a canvas can be
2297
+ // stretched by CSS, or have a stale backing store after a resize, and the drawn
2298
+ // content follows the CSS box either way. Equal to 1/dpr when they match.
2299
+ var cssWidth = this.lastCanvasPositioning.width;
2300
+ var cssHeight = this.lastCanvasPositioning.height;
2301
+ var fallback = 1 / (dpr || 1);
2302
+ var sx = this.canvas.width > 0 && cssWidth > 0 ? cssWidth / this.canvas.width : fallback;
2303
+ var sy = this.canvas.height > 0 && cssHeight > 0 ? cssHeight / this.canvas.height : fallback;
2304
+ var a = forwardMat.xx * sx;
2305
+ var b = forwardMat.xy * sy;
2306
+ var c = forwardMat.yx * sx;
2307
+ var d = forwardMat.yy * sy;
2308
+ var tx = forwardMat.tx * sx;
2309
+ var ty = forwardMat.ty * sy;
2101
2310
  this.transformContainer.style.transform =
2102
2311
  "matrix(".concat(a, ",").concat(b, ",").concat(c, ",").concat(d, ",").concat(tx, ",").concat(ty, ")");
2103
2312
  };
@@ -2120,11 +2329,11 @@ var AccessibilityOverlay = /** @class */ (function () {
2120
2329
  // ---------------------------------------------------------------------------
2121
2330
  /** aria-expanded: button, link, checkbox, switch (inherits button), tab. */
2122
2331
  var ARIA_EXPANDED_ROLES = new Set([
2123
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button,
2124
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link,
2125
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2126
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl,
2127
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab,
2332
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button,
2333
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link,
2334
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
2335
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl,
2336
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab,
2128
2337
  ]);
2129
2338
  /**
2130
2339
  * aria-selected: tab is the only role in our current set that natively
@@ -2133,13 +2342,13 @@ var ARIA_EXPANDED_ROLES = new Set([
2133
2342
  * the set still lists it so the constraint is visible in one place.
2134
2343
  */
2135
2344
  var ARIA_SELECTED_ROLES = new Set([
2136
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab,
2345
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab,
2137
2346
  ]);
2138
2347
  /** aria-checked: checkbox, radio, switch. */
2139
2348
  var ARIA_CHECKED_ROLES = new Set([
2140
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2141
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton,
2142
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl,
2349
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
2350
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton,
2351
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl,
2143
2352
  ]);
2144
2353
  /**
2145
2354
  * aria-checked="mixed": checkbox only. ARIA defines checkbox as three-valued
@@ -2148,7 +2357,7 @@ var ARIA_CHECKED_ROLES = new Set([
2148
2357
  * emitting a value they do not support.
2149
2358
  */
2150
2359
  var ARIA_MIXED_ROLES = new Set([
2151
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2360
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
2152
2361
  ]);
2153
2362
  /**
2154
2363
  * aria-pressed: button only. switch is a button subclass in ARIA but uses
@@ -2156,13 +2365,13 @@ var ARIA_MIXED_ROLES = new Set([
2156
2365
  * excluded here and handled separately in the Toggleable block.
2157
2366
  */
2158
2367
  var ARIA_PRESSED_ROLES = new Set([
2159
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button,
2368
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button,
2160
2369
  ]);
2161
2370
  /** aria-required: checkbox, textbox, radiogroup. */
2162
2371
  var ARIA_REQUIRED_ROLES = new Set([
2163
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2164
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField,
2165
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioGroup,
2372
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
2373
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField,
2374
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioGroup,
2166
2375
  ]);
2167
2376
  // ---------------------------------------------------------------------------
2168
2377
  /** Style for visually-hidden description spans used with aria-describedby. */
@@ -2211,12 +2420,12 @@ function setBoolAttr(el, attr, value) {
2211
2420
  /** Roles that receive click/Enter/Space action handlers. */
2212
2421
  function isClickableRole(role) {
2213
2422
  switch (role) {
2214
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
2215
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
2216
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
2217
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
2218
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
2219
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
2423
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
2424
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
2425
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
2426
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
2427
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
2428
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
2220
2429
  return true;
2221
2430
  default:
2222
2431
  return false;
@@ -2225,14 +2434,14 @@ function isClickableRole(role) {
2225
2434
  /** Roles that receive tabindex="-1" for programmatic/AT focus (not Tab order). */
2226
2435
  function isInteractiveRole(role) {
2227
2436
  switch (role) {
2228
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
2229
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
2230
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
2231
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
2232
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider:
2233
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
2234
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
2235
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField:
2437
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
2438
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
2439
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
2440
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
2441
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider:
2442
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
2443
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
2444
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField:
2236
2445
  return true;
2237
2446
  default:
2238
2447
  return false;
@@ -2243,13 +2452,13 @@ function isInteractiveRole(role) {
2243
2452
  * dialog only when the Modal state flag is set.
2244
2453
  */
2245
2454
  function isModalDialogRole(role, flags) {
2246
- return (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.alertDialog ||
2247
- (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.dialog && (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Modal)));
2455
+ return (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.alertDialog ||
2456
+ (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.dialog && (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Modal)));
2248
2457
  }
2249
2458
  /** Whether a node can receive focus: an interactive role or the Focusable trait. */
2250
2459
  function isFocusableNode(node) {
2251
2460
  return (isInteractiveRole(node.role) ||
2252
- (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable));
2461
+ (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable));
2253
2462
  }
2254
2463
  /**
2255
2464
  * Choose an HTML tag for a given role. Prefer native semantic elements
@@ -2258,9 +2467,9 @@ function isFocusableNode(node) {
2258
2467
  */
2259
2468
  function tagForRole(role) {
2260
2469
  switch (role) {
2261
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
2470
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
2262
2471
  return "a";
2263
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text:
2472
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text:
2264
2473
  // The outer div is the positioned AX element VoiceOver measures for its
2265
2474
  // highlight box. The text itself lives in a child <span> (see createElement).
2266
2475
  return "div";
@@ -2276,43 +2485,43 @@ function tagForRole(role) {
2276
2485
  */
2277
2486
  function ariaRoleForSemantic(role) {
2278
2487
  switch (role) {
2279
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.none:
2488
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.none:
2280
2489
  // TODO: Role "none" removes the node from the accessibility tree. For now, setting to Group, but maybe we want to switch to "none"
2281
2490
  // or "presentation".
2282
2491
  return "group";
2283
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
2492
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
2284
2493
  return "button";
2285
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
2494
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
2286
2495
  return null; // native <a>
2287
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
2496
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
2288
2497
  return "checkbox";
2289
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
2498
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
2290
2499
  return "switch";
2291
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider:
2500
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider:
2292
2501
  return "slider";
2293
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField:
2502
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField:
2294
2503
  return "textbox";
2295
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.image:
2504
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.image:
2296
2505
  return "img";
2297
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.group:
2506
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.group:
2298
2507
  return "group";
2299
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.list:
2508
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.list:
2300
2509
  return "list";
2301
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.listItem:
2510
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.listItem:
2302
2511
  return "listitem";
2303
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
2512
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
2304
2513
  return "tab";
2305
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tabList:
2514
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tabList:
2306
2515
  return "tablist";
2307
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.dialog:
2516
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.dialog:
2308
2517
  return "dialog";
2309
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.alertDialog:
2518
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.alertDialog:
2310
2519
  return "alertdialog";
2311
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioGroup:
2520
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioGroup:
2312
2521
  return "radiogroup";
2313
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
2522
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
2314
2523
  return "radio";
2315
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text:
2524
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text:
2316
2525
  // Text nodes use <span>; heading role is applied separately
2317
2526
  // when headingLevel > 0.
2318
2527
  return null;
@@ -2326,6 +2535,56 @@ function ariaRoleForSemantic(role) {
2326
2535
  /* 10 */
2327
2536
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2328
2537
 
2538
+ __webpack_require__.r(__webpack_exports__);
2539
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2540
+ /* harmony export */ claimKeyEvent: () => (/* binding */ claimKeyEvent),
2541
+ /* harmony export */ isKeyEventClaimed: () => (/* binding */ isKeyEventClaimed)
2542
+ /* harmony export */ });
2543
+ var claimed = new WeakSet();
2544
+ /**
2545
+ * Marks a key event as handled by a semantic overlay widget (and prevents its
2546
+ * default), so the Rive keyboard handler leaves it alone. A plain
2547
+ * `defaultPrevented` check can't tell these apart from host-page handlers.
2548
+ */
2549
+ function claimKeyEvent(event) {
2550
+ event.preventDefault();
2551
+ claimed.add(event);
2552
+ }
2553
+ function isKeyEventClaimed(event) {
2554
+ return claimed.has(event);
2555
+ }
2556
+
2557
+
2558
+ /***/ }),
2559
+ /* 11 */
2560
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2561
+
2562
+ __webpack_require__.r(__webpack_exports__);
2563
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2564
+ /* harmony export */ canvasOffset: () => (/* binding */ canvasOffset)
2565
+ /* harmony export */ });
2566
+ /**
2567
+ * Canvas offset within its offsetParent, minus the scroll of ancestors in between (they
2568
+ * move the canvas, not absolutely positioned siblings).
2569
+ */
2570
+ function canvasOffset(canvas) {
2571
+ var top = canvas.offsetTop;
2572
+ var left = canvas.offsetLeft;
2573
+ var offsetParent = canvas.offsetParent;
2574
+ if (!offsetParent)
2575
+ return { top: top, left: left };
2576
+ for (var el = canvas.parentElement; el && el !== offsetParent; el = el.parentElement) {
2577
+ top -= el.scrollTop;
2578
+ left -= el.scrollLeft;
2579
+ }
2580
+ return { top: top, left: left };
2581
+ }
2582
+
2583
+
2584
+ /***/ }),
2585
+ /* 12 */
2586
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2587
+
2329
2588
  __webpack_require__.r(__webpack_exports__);
2330
2589
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2331
2590
  /* harmony export */ AudioAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.AudioAssetWrapper),
@@ -2346,11 +2605,11 @@ __webpack_require__.r(__webpack_exports__);
2346
2605
  /* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
2347
2606
  /* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)
2348
2607
  /* harmony export */ });
2349
- /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
2350
- /* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
2351
- /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(13);
2352
- /* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
2353
- /* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(15);
2608
+ /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
2609
+ /* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
2610
+ /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
2611
+ /* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(18);
2612
+ /* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(19);
2354
2613
 
2355
2614
 
2356
2615
 
@@ -2359,7 +2618,7 @@ __webpack_require__.r(__webpack_exports__);
2359
2618
 
2360
2619
 
2361
2620
  /***/ }),
2362
- /* 11 */
2621
+ /* 13 */
2363
2622
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2364
2623
 
2365
2624
  __webpack_require__.r(__webpack_exports__);
@@ -2438,7 +2697,7 @@ var getClientCoordinates = function (event, isTouchScrollEnabled, enableMultiTou
2438
2697
  * the state machine pointer move/up/down functions based on cursor interaction
2439
2698
  */
2440
2699
  var registerTouchInteractions = function (_a) {
2441
- var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c, _d = _a.dispatchPointerExit, dispatchPointerExit = _d === void 0 ? true : _d, _e = _a.enableMultiTouch, enableMultiTouch = _e === void 0 ? false : _e, _f = _a.layoutScaleFactor, layoutScaleFactor = _f === void 0 ? 1.0 : _f, advanceAndDrain = _a.advanceAndDrain;
2700
+ var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c, _d = _a.dispatchPointerExit, dispatchPointerExit = _d === void 0 ? true : _d, _e = _a.enableMultiTouch, enableMultiTouch = _e === void 0 ? false : _e, _f = _a.layoutScaleFactor, layoutScaleFactor = _f === void 0 ? 1.0 : _f, advanceAndDrain = _a.advanceAndDrain, summonKeyboard = _a.summonKeyboard, isTextProxyFocused = _a.isTextProxyFocused;
2442
2701
  if (!canvas ||
2443
2702
  !stateMachines.length ||
2444
2703
  !renderer ||
@@ -2458,8 +2717,10 @@ var registerTouchInteractions = function (_a) {
2458
2717
  * We're keeping track of the previous event to not send the synthetic mouse events if the
2459
2718
  * touch event was a click (touchstart -> touchend).
2460
2719
  *
2461
- * This is only needed when `isTouchScrollEnabled` is false
2462
- * When true, `preventDefault()` is called which prevents this behaviour.
2720
+ * Emulated events only occur when `isTouchScrollEnabled` is true; when false,
2721
+ * touchstart is default-prevented, which suppresses them.
2722
+ * Emulated mousedown is prevented while the proxy is focused, or it would blur it and
2723
+ * drop the keyboard.
2463
2724
  **/
2464
2725
  var _prevEventType = null;
2465
2726
  var _syntheticEventsActive = false;
@@ -2476,6 +2737,9 @@ var registerTouchInteractions = function (_a) {
2476
2737
  // https://stackoverflow.com/questions/9656990/how-to-prevent-simulated-mouse-events-in-mobile-browsers
2477
2738
  // https://stackoverflow.com/questions/25572070/javascript-touchend-versus-click-dilemma
2478
2739
  if (_syntheticEventsActive && event instanceof MouseEvent) {
2740
+ if (event.type === "mousedown" && (isTextProxyFocused === null || isTextProxyFocused === void 0 ? void 0 : isTextProxyFocused())) {
2741
+ event.preventDefault();
2742
+ }
2479
2743
  // Synthetic event finished
2480
2744
  if (event.type == "mouseup") {
2481
2745
  _syntheticEventsActive = false;
@@ -2582,7 +2846,7 @@ var registerTouchInteractions = function (_a) {
2582
2846
  _loop_3(stateMachine);
2583
2847
  }
2584
2848
  // Advance the state machine immediately so pointer down(s) takes effect synchronously
2585
- advanceAndDrain(0);
2849
+ advanceAndDrain(0, { pointerDown: true });
2586
2850
  break;
2587
2851
  }
2588
2852
  // Pointer click released on the canvas
@@ -2599,6 +2863,9 @@ var registerTouchInteractions = function (_a) {
2599
2863
  }
2600
2864
  // Advance the state machine immediately so pointer up(s) takes effect synchronously
2601
2865
  advanceAndDrain(0);
2866
+ // Still inside the touch gesture — summon the keyboard if the tap focused a
2867
+ // text input
2868
+ summonKeyboard === null || summonKeyboard === void 0 ? void 0 : summonKeyboard();
2602
2869
  // Release the primary touch lock once that finger lifts so the next
2603
2870
  // touchstart can claim a new primary finger.
2604
2871
  if (!enableMultiTouch &&
@@ -2619,6 +2886,7 @@ var registerTouchInteractions = function (_a) {
2619
2886
  }
2620
2887
  // Advance the state machine immediately so pointer up(s) takes effect synchronously
2621
2888
  advanceAndDrain(0);
2889
+ summonKeyboard === null || summonKeyboard === void 0 ? void 0 : summonKeyboard();
2622
2890
  break;
2623
2891
  }
2624
2892
  default:
@@ -2656,7 +2924,7 @@ var registerTouchInteractions = function (_a) {
2656
2924
 
2657
2925
 
2658
2926
  /***/ }),
2659
- /* 12 */
2927
+ /* 14 */
2660
2928
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2661
2929
 
2662
2930
  __webpack_require__.r(__webpack_exports__);
@@ -2664,6 +2932,43 @@ __webpack_require__.r(__webpack_exports__);
2664
2932
  /* harmony export */ FocusSessionState: () => (/* binding */ FocusSessionState),
2665
2933
  /* harmony export */ KeyboardInteractions: () => (/* binding */ KeyboardInteractions)
2666
2934
  /* harmony export */ });
2935
+ /* harmony import */ var _keyMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
2936
+ /* harmony import */ var _semantics_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
2937
+ /* harmony import */ var _textInputProxy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
2938
+
2939
+
2940
+
2941
+ /**
2942
+ * Defaults suppressed while typing (scroll/navigate/submit). Tab is traversal's; proxy
2943
+ * Space returns earlier as a printable.
2944
+ */
2945
+ var EDITING_NAV_CODES = new Set([
2946
+ "Space",
2947
+ "ArrowLeft",
2948
+ "ArrowRight",
2949
+ "ArrowUp",
2950
+ "ArrowDown",
2951
+ "Backspace",
2952
+ "Delete",
2953
+ "Home",
2954
+ "End",
2955
+ "Enter",
2956
+ "NumpadEnter",
2957
+ ]);
2958
+ /** A keystroke that types a character (not a Ctrl/Cmd shortcut). */
2959
+ function isPrintable(event) {
2960
+ return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
2961
+ }
2962
+ function isArrowKey(key) {
2963
+ return (key === _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.left || key === _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.right || key === _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.up || key === _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.down);
2964
+ }
2965
+ /**
2966
+ * Alt/Ctrl/Meta arrows are browser/OS shortcuts (Alt+Left = back, Cmd+Arrow, etc.).
2967
+ * Shift is allowed: it is the spatial-navigation chord in Vivaldi/Opera.
2968
+ */
2969
+ function hasShortcutModifier(event) {
2970
+ return event.altKey || event.ctrlKey || event.metaKey;
2971
+ }
2667
2972
  /**
2668
2973
  * Tracks the relationship between DOM focus inside this Rive focus domain (canvas or semantic overlay)
2669
2974
  * and Rive's internal focus for the current focus session.
@@ -2689,7 +2994,8 @@ var FocusSessionState;
2689
2994
  FocusSessionState["RiveFocused"] = "riveFocused";
2690
2995
  })(FocusSessionState || (FocusSessionState = {}));
2691
2996
  /**
2692
- * Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas> or semantic overlay).
2997
+ * Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas>, semantic
2998
+ * overlay, text input proxy). Owns the proxy and the text input session state.
2693
2999
  * Because keyboard events can apply on either part of the domain, we need to track what events we should
2694
3000
  * handle/intercept, and when to release focus back to the page outside of the domain.
2695
3001
  *
@@ -2701,7 +3007,7 @@ var KeyboardInteractions = /** @class */ (function () {
2701
3007
  function KeyboardInteractions(_a) {
2702
3008
  var canvas = _a.canvas, stateMachine = _a.stateMachine, hasFocusNodes = _a.hasFocusNodes, getOverlayElement = _a.getOverlayElement;
2703
3009
  var _this = this;
2704
- var _b;
3010
+ var _b, _c;
2705
3011
  this.focusSessionState = FocusSessionState.NotFocused;
2706
3012
  /** Whether the canvas currently has browser DOM focus. */
2707
3013
  this.canvasHasFocus = false;
@@ -2709,6 +3015,19 @@ var KeyboardInteractions = /** @class */ (function () {
2709
3015
  this.focusDomainReleased = false;
2710
3016
  /** Overlay element currently wired with focusin/keydown listeners, if any. */
2711
3017
  this.currentOverlayElement = null;
3018
+ /** Codes whose keydown an overlay widget took, so their keyup is skipped too. */
3019
+ this.claimedKeyCodes = new Set();
3020
+ this.textInputSessionActive = false;
3021
+ /**
3022
+ * The proxy is always empty: copy Rive's selection; always preventDefault.
3023
+ */
3024
+ this.onCopy = function (event) {
3025
+ var _a;
3026
+ event.preventDefault();
3027
+ var selected = _this.mainSm.selectedText();
3028
+ if (selected)
3029
+ (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.setData("text/plain", selected);
3030
+ };
2712
3031
  /**
2713
3032
  * Handles the canvas gaining browser focus. The behavior differs based on how focus was gained -
2714
3033
  *
@@ -2724,10 +3043,11 @@ var KeyboardInteractions = /** @class */ (function () {
2724
3043
  _this.syncOverlayListener();
2725
3044
  _this.canvasHasFocus = true;
2726
3045
  _this.focusDomainReleased = false;
2727
- if (!_this.hasFocusNodes)
2728
- return;
2729
- if (_this.mainSm.focusState().hasFocus)
3046
+ if (_this.isInFocusDomain(event.relatedTarget) ||
3047
+ !_this.hasFocusNodes ||
3048
+ _this.mainSm.focusState().hasFocus) {
2730
3049
  return;
3050
+ }
2731
3051
  _this.focusSessionState = FocusSessionState.EntryPending;
2732
3052
  // Pointer focus waits for the user's next Tab (handled in onKeyDown). Keyboard focus enters now.
2733
3053
  if (!_this.isKeyboardDrivenFocus())
@@ -2746,11 +3066,13 @@ var KeyboardInteractions = /** @class */ (function () {
2746
3066
  * When we're not in either of those buckets, it's safe to call `clearFocus()` on the SMI.
2747
3067
  */
2748
3068
  this.onCanvasBlur = function (event) {
3069
+ // Must stay before the state reset because beginTextInputSession sets the session state and
3070
+ // then focuses the proxy, which synchronously blurs the canvas.
3071
+ if (_this.inputProxy.owns(event.relatedTarget))
3072
+ return;
2749
3073
  _this.focusSessionState = FocusSessionState.NotFocused;
2750
3074
  _this.canvasHasFocus = false;
2751
- var movedWithinFocusDomain = _this.isInFocusDomain(event.relatedTarget);
2752
- var documentLostFocus = event.relatedTarget === null && !document.hasFocus();
2753
- if (movedWithinFocusDomain || documentLostFocus)
3075
+ if (_this.blurStaysWithRive(event.relatedTarget))
2754
3076
  return;
2755
3077
  _this.mainSm.clearFocus();
2756
3078
  };
@@ -2776,15 +3098,44 @@ var KeyboardInteractions = /** @class */ (function () {
2776
3098
  this.onFocusDomainHostFocusIn = function (event) {
2777
3099
  _this.syncOverlayListener();
2778
3100
  _this.onOverlayFocusIn(event);
3101
+ // Focus entering the proxy re-enters the focus domain, so clear any earlier Tab-out
3102
+ // release, or onKeyDown would drop the session's keystrokes.
3103
+ if (_this.inputProxy.owns(event.target)) {
3104
+ _this.focusDomainReleased = false;
3105
+ }
2779
3106
  };
3107
+ /**
3108
+ * Handles keydown events in the Rive focus domain. We route certain keys to different functions, with the following
3109
+ * fallback behavior:
3110
+ * 1. Tab/Shift+Tab - check if keyInput() takes this key, if not, call focusNext/Previous traversal if there are focus nodes
3111
+ * 2. Check - if a semantic overlay element's key handler claimed the event, don't intercept the key event further
3112
+ * 3. Send key to `keyInput()` on Rive state machine if applicable.
3113
+ * 4. If the keyInput returned false, and the key is directional arrow keys, call directional focus methods on state machine
3114
+ * 5. Printables: in a session the proxy's input event supplies text; otherwise textInput().
3115
+ * A printable fires both keyInput and textInput even if a listener claims it.
3116
+ * @param event KeyboardEvent
3117
+ * @returns void
3118
+ */
2780
3119
  this.onKeyDown = function (event) {
2781
3120
  _this.syncOverlayListener();
3121
+ // Keys that are part of an IME composition belong to the IME (candidate
3122
+ // navigation, commit). Safari reports the first one as keyCode 229 with
3123
+ // isComposing still false.
3124
+ if (event.isComposing || event.keyCode === 229)
3125
+ return;
2782
3126
  // After Tab exits the last Rive node, ignore keys until focus re-enters the focus domain.
2783
3127
  if (_this.focusDomainReleased)
2784
3128
  return;
2785
3129
  if (!_this.shouldRiveHandleKeyEvent(event))
2786
3130
  return;
2787
- if (event.code === "Tab" && _this.hasFocusNodes) {
3131
+ if (event.key === "Tab" && _this.hasFocusNodes) {
3132
+ // Tab listeners are matched per phase (down/repeat/up), as in the editor, so
3133
+ // each event is offered on its own; one that isn't claimed traverses.
3134
+ if (_this.mainSm.focusState().hasFocus &&
3135
+ _this.mainSm.keyInput(_keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.tab, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), true, event.repeat)) {
3136
+ event.preventDefault();
3137
+ return;
3138
+ }
2788
3139
  var forward = !event.shiftKey;
2789
3140
  var focusMoved = forward ? _this.mainSm.focusNext() : _this.mainSm.focusPrevious();
2790
3141
  var focusState = _this.mainSm.focusState();
@@ -2797,13 +3148,74 @@ var KeyboardInteractions = /** @class */ (function () {
2797
3148
  }
2798
3149
  else {
2799
3150
  // No more traversable nodes — release Tab to the page.
3151
+ if (document.activeElement !== _this.canvas &&
3152
+ _this.isInFocusDomain(document.activeElement)) {
3153
+ // The browser's default Tab starts from the focused element; from an overlay element,
3154
+ // the nearest stop backward is the canvas itself. Start it from the
3155
+ // canvas instead, so a Shift+Tab goes to the proper element before Rive.
3156
+ _this.canvas.focus({ preventScroll: true });
3157
+ }
2800
3158
  _this.focusSessionState = FocusSessionState.NotFocused;
2801
3159
  _this.focusDomainReleased = true;
2802
3160
  _this.canvasHasFocus = false;
2803
3161
  }
2804
3162
  _this.syncOverlayListener();
3163
+ return;
3164
+ }
3165
+ // A semantic overlay widget (roving radio/tab group, slider, Enter/Space activation)
3166
+ // already acted on this key at its target, so don't act on it twice.
3167
+ if ((0,_semantics_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_1__.isKeyEventClaimed)(event)) {
3168
+ _this.claimedKeyCodes.add(event.code);
3169
+ return;
3170
+ }
3171
+ // A new unclaimed press: drop any claim whose keyup never arrived.
3172
+ _this.claimedKeyCodes.delete(event.code);
3173
+ var fromProxy = _this.textInputSessionActive && _this.inputProxy.owns(event.target);
3174
+ var expectsKeyboardInput = _this.mainSm.focusState().expectsKeyboardInput;
3175
+ // The focused node gets first refusal (a TextInput's caret, or a keyboard listener
3176
+ // on that key). Keys with no Rive equivalent map to null and aren't dispatched.
3177
+ var key = (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.keyboardEventToRiveKey)(event);
3178
+ var consumed = key !== null &&
3179
+ _this.mainSm.keyInput(key, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), true, event.repeat);
3180
+ // An arrow key with no consumed key input moves focus spatially. While a Rive node holds focus,
3181
+ // arrows never scroll the page
3182
+ if (!consumed && key !== null && isArrowKey(key) && !hasShortcutModifier(event)) {
3183
+ consumed =
3184
+ _this.focusInDirection(key) || _this.mainSm.focusState().hasFocus;
3185
+ }
3186
+ if (isPrintable(event)) {
3187
+ // During a session the printable must reach the proxy: its input event is the
3188
+ // (IME- and dead-key-correct) text source, and C++ inserts nothing from keyInput.
3189
+ if (fromProxy)
3190
+ return;
3191
+ // Session live but focus elsewhere in Rive: refocus the proxy so the default inserts there.
3192
+ if (_this.textInputSessionActive && _this.isInFocusDomain(event.target)) {
3193
+ _this.inputProxy.focus();
3194
+ return;
3195
+ }
3196
+ if (!_this.textInputSessionActive && expectsKeyboardInput) {
3197
+ _this.mainSm.textInput(event.key);
3198
+ }
3199
+ }
3200
+ // Rive consumed it, or an unmodified editing key while typing (would scroll/submit).
3201
+ var typing = fromProxy || expectsKeyboardInput;
3202
+ if (consumed ||
3203
+ (typing && !hasShortcutModifier(event) && EDITING_NAV_CODES.has(event.code))) {
3204
+ event.preventDefault();
2805
3205
  }
2806
3206
  };
3207
+ this.onKeyUp = function (event) {
3208
+ if (event.isComposing || event.keyCode === 229)
3209
+ return;
3210
+ if (_this.claimedKeyCodes.delete(event.code))
3211
+ return;
3212
+ if (_this.focusSessionState === FocusSessionState.NotFocused)
3213
+ return;
3214
+ var key = (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.keyboardEventToRiveKey)(event);
3215
+ if (key === null)
3216
+ return;
3217
+ _this.mainSm.keyInput(key, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), false, false);
3218
+ };
2807
3219
  this.canvas = canvas;
2808
3220
  this.mainSm = stateMachine;
2809
3221
  this.hasFocusNodes = hasFocusNodes;
@@ -2812,9 +3224,74 @@ var KeyboardInteractions = /** @class */ (function () {
2812
3224
  canvas.addEventListener("focus", this.onCanvasFocus);
2813
3225
  canvas.addEventListener("blur", this.onCanvasBlur);
2814
3226
  canvas.addEventListener("keydown", this.onKeyDown);
3227
+ canvas.addEventListener("keyup", this.onKeyUp);
2815
3228
  this.focusDomainHost.addEventListener("focusin", this.onFocusDomainHostFocusIn);
2816
3229
  this.syncOverlayListener();
3230
+ this.inputProxy = new _textInputProxy__WEBPACK_IMPORTED_MODULE_2__.TextInputProxy({
3231
+ container: (_c = canvas.parentElement) !== null && _c !== void 0 ? _c : document.body,
3232
+ canvas: canvas,
3233
+ textInput: function (text) { return _this.mainSm.textInput(text); },
3234
+ // Proxy keystrokes go through the same handlers as the canvas.
3235
+ onKeyDown: this.onKeyDown,
3236
+ onKeyUp: this.onKeyUp,
3237
+ onCopy: this.onCopy,
3238
+ onBlur: function (relatedTarget) { return _this.handleProxyBlur(relatedTarget); },
3239
+ });
2817
3240
  }
3241
+ KeyboardInteractions.prototype.isTextInputSessionActive = function () {
3242
+ return this.textInputSessionActive;
3243
+ };
3244
+ /** Session active and the proxy holds DOM focus. */
3245
+ KeyboardInteractions.prototype.isEditingHostFocused = function () {
3246
+ return this.textInputSessionActive && this.inputProxy.hasDomFocus();
3247
+ };
3248
+ /** @param focusProxy move DOM focus to the proxy; false leaves it where it is. */
3249
+ KeyboardInteractions.prototype.beginTextInputSession = function (focusProxy) {
3250
+ this.textInputSessionActive = true;
3251
+ this.focusSessionState = FocusSessionState.RiveFocused;
3252
+ if (focusProxy)
3253
+ this.inputProxy.focus();
3254
+ };
3255
+ /** @param fromBlur focus is already leaving; don't park it on the canvas. */
3256
+ KeyboardInteractions.prototype.endTextInputSession = function (fromBlur) {
3257
+ if (fromBlur === void 0) { fromBlur = false; }
3258
+ if (!this.textInputSessionActive)
3259
+ return;
3260
+ this.textInputSessionActive = false;
3261
+ this.inputProxy.endSession();
3262
+ if (fromBlur || !this.inputProxy.hasDomFocus())
3263
+ return;
3264
+ // Nothing took DOM focus from the proxy (e.g. semantics is off). Park it on the
3265
+ // canvas so keys keep reaching Rive; onCanvasFocus ignores focus from the input proxy.
3266
+ this.canvas.focus({ preventScroll: true });
3267
+ };
3268
+ /** Must run synchronously in the pointer gesture or mobile keyboards won't open. */
3269
+ KeyboardInteractions.prototype.summonForPointer = function () {
3270
+ if (this.textInputSessionActive)
3271
+ this.inputProxy.focus();
3272
+ else
3273
+ this.beginTextInputSession(true);
3274
+ };
3275
+ Object.defineProperty(KeyboardInteractions.prototype, "editingHost", {
3276
+ /** The text-input proxy, for the semantics layer to decorate while editing. */
3277
+ get: function () {
3278
+ return this.inputProxy;
3279
+ },
3280
+ enumerable: false,
3281
+ configurable: true
3282
+ });
3283
+ KeyboardInteractions.prototype.handleProxyBlur = function (relatedTarget) {
3284
+ // Teardown already in progress (endTextInputSession blurred the proxy).
3285
+ if (!this.textInputSessionActive)
3286
+ return;
3287
+ // Still in Rive or the document blurred: keep the session (pollFocusState tears down).
3288
+ if (this.blurStaysWithRive(relatedTarget))
3289
+ return;
3290
+ // Blurred out of Rive entirely: release C++ focus and end the session.
3291
+ this.mainSm.clearFocus();
3292
+ this.endTextInputSession(true);
3293
+ this.focusSessionState = FocusSessionState.NotFocused;
3294
+ };
2818
3295
  /**
2819
3296
  * Set the FocusSessionState. Useful for invoking a Rive "blur" without actually blurring from the <canvas>. This
2820
3297
  * helps put the DOM focus state on the canvas rather than the <body>, so the user doesn't lose the spot in page navigation
@@ -2833,6 +3310,26 @@ var KeyboardInteractions = /** @class */ (function () {
2833
3310
  KeyboardInteractions.prototype.notifyRiveFocused = function () {
2834
3311
  this.focusSessionState = FocusSessionState.RiveFocused;
2835
3312
  };
3313
+ /** Blur into the focus domain, or the whole document losing focus (tab/window switch). */
3314
+ KeyboardInteractions.prototype.blurStaysWithRive = function (relatedTarget) {
3315
+ return (this.isInFocusDomain(relatedTarget) ||
3316
+ (relatedTarget === null && !document.hasFocus()));
3317
+ };
3318
+ /** Arrow keys map to directional focus; anything else is not a focus move. */
3319
+ KeyboardInteractions.prototype.focusInDirection = function (key) {
3320
+ switch (key) {
3321
+ case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.left:
3322
+ return this.mainSm.focusLeft();
3323
+ case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.right:
3324
+ return this.mainSm.focusRight();
3325
+ case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.up:
3326
+ return this.mainSm.focusUp();
3327
+ case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.down:
3328
+ return this.mainSm.focusDown();
3329
+ default:
3330
+ return false;
3331
+ }
3332
+ };
2836
3333
  /**
2837
3334
  * Determine if Rive should handle keyboard input. If session state is `NotFocused` - no.
2838
3335
  * DOM focus stays parked on the canvas after Rive releases focus internally, and that Tab
@@ -2850,14 +3347,12 @@ var KeyboardInteractions = /** @class */ (function () {
2850
3347
  var eventOnCanvas = event.target === this.canvas;
2851
3348
  return inFocusDomain || this.canvasHasFocus || eventOnCanvas;
2852
3349
  };
2853
- /**
2854
- * The Rive focus domain: the DOM that counts as "inside" Rive for focus purposes — today the
2855
- * canvas itself OR the accessibility overlay subtree. Anything added later belongs here, so
2856
- * session bookkeeping and keydown routing pick it up for free.
2857
- */
3350
+ /** DOM that counts as inside Rive for focus: canvas, overlay subtree, text-input proxy. */
2858
3351
  KeyboardInteractions.prototype.isInFocusDomain = function (target) {
2859
3352
  if (target === this.canvas)
2860
3353
  return true;
3354
+ if (this.inputProxy.owns(target))
3355
+ return true;
2861
3356
  return this.isInOverlay(target);
2862
3357
  };
2863
3358
  /** Overlay only (excludes the canvas) — the accessibility overlay subtree. */
@@ -2868,15 +3363,19 @@ var KeyboardInteractions = /** @class */ (function () {
2868
3363
  return (_c = (_b = (_a = this.getOverlayElement) === null || _a === void 0 ? void 0 : _a.call(this)) === null || _b === void 0 ? void 0 : _b.contains(target)) !== null && _c !== void 0 ? _c : false;
2869
3364
  };
2870
3365
  KeyboardInteractions.prototype.syncOverlayListener = function () {
2871
- var _a, _b, _c, _d, _e, _f;
3366
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2872
3367
  var nextOverlayElement = (_b = (_a = this.getOverlayElement) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : null;
2873
3368
  if (nextOverlayElement === this.currentOverlayElement)
2874
3369
  return;
2875
3370
  (_c = this.currentOverlayElement) === null || _c === void 0 ? void 0 : _c.removeEventListener("focusin", this.onOverlayFocusIn);
2876
- (_d = this.currentOverlayElement) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", this.onKeyDown, true);
3371
+ (_d = this.currentOverlayElement) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", this.onKeyDown);
3372
+ (_e = this.currentOverlayElement) === null || _e === void 0 ? void 0 : _e.removeEventListener("keyup", this.onKeyUp);
2877
3373
  this.currentOverlayElement = nextOverlayElement;
2878
- (_e = this.currentOverlayElement) === null || _e === void 0 ? void 0 : _e.addEventListener("focusin", this.onOverlayFocusIn);
2879
- (_f = this.currentOverlayElement) === null || _f === void 0 ? void 0 : _f.addEventListener("keydown", this.onKeyDown, true);
3374
+ (_f = this.currentOverlayElement) === null || _f === void 0 ? void 0 : _f.addEventListener("focusin", this.onOverlayFocusIn);
3375
+ // Bubble phase, so a semantic widget's own key handler runs first and can claim
3376
+ // the key via claimKeyEvent (see onKeyDown).
3377
+ (_g = this.currentOverlayElement) === null || _g === void 0 ? void 0 : _g.addEventListener("keydown", this.onKeyDown);
3378
+ (_h = this.currentOverlayElement) === null || _h === void 0 ? void 0 : _h.addEventListener("keyup", this.onKeyUp);
2880
3379
  };
2881
3380
  /**
2882
3381
  * Whether the canvas currently matches :focus-visible — the browser's heuristic for keyboard-
@@ -2902,13 +3401,22 @@ var KeyboardInteractions = /** @class */ (function () {
2902
3401
  return true;
2903
3402
  };
2904
3403
  KeyboardInteractions.prototype.cleanup = function () {
2905
- var _a, _b;
3404
+ var _a, _b, _c;
2906
3405
  this.canvas.removeEventListener("focus", this.onCanvasFocus);
2907
3406
  this.canvas.removeEventListener("blur", this.onCanvasBlur);
2908
3407
  this.canvas.removeEventListener("keydown", this.onKeyDown);
3408
+ this.canvas.removeEventListener("keyup", this.onKeyUp);
3409
+ this.claimedKeyCodes.clear();
2909
3410
  this.focusDomainHost.removeEventListener("focusin", this.onFocusDomainHostFocusIn);
2910
3411
  (_a = this.currentOverlayElement) === null || _a === void 0 ? void 0 : _a.removeEventListener("focusin", this.onOverlayFocusIn);
2911
- (_b = this.currentOverlayElement) === null || _b === void 0 ? void 0 : _b.removeEventListener("keydown", this.onKeyDown, true);
3412
+ (_b = this.currentOverlayElement) === null || _b === void 0 ? void 0 : _b.removeEventListener("keydown", this.onKeyDown);
3413
+ (_c = this.currentOverlayElement) === null || _c === void 0 ? void 0 : _c.removeEventListener("keyup", this.onKeyUp);
3414
+ // Removing a focused element drops focus to <body> with no blur; park on the canvas.
3415
+ if (this.inputProxy.hasDomFocus()) {
3416
+ this.canvas.focus({ preventScroll: true });
3417
+ }
3418
+ this.inputProxy.cleanup();
3419
+ this.textInputSessionActive = false;
2912
3420
  };
2913
3421
  return KeyboardInteractions;
2914
3422
  }());
@@ -2916,7 +3424,592 @@ var KeyboardInteractions = /** @class */ (function () {
2916
3424
 
2917
3425
 
2918
3426
  /***/ }),
2919
- /* 13 */
3427
+ /* 15 */
3428
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3429
+
3430
+ __webpack_require__.r(__webpack_exports__);
3431
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3432
+ /* harmony export */ Key: () => (/* binding */ Key),
3433
+ /* harmony export */ KeyModifiers: () => (/* binding */ KeyModifiers),
3434
+ /* harmony export */ keyboardEventToRiveKey: () => (/* binding */ keyboardEventToRiveKey),
3435
+ /* harmony export */ modifiersFromEvent: () => (/* binding */ modifiersFromEvent)
3436
+ /* harmony export */ });
3437
+ /*
3438
+ * Maps DOM keyboard events to the GLFW-style key codes and modifier bitmask
3439
+ * that StateMachineInstance.keyInput() expects. Values mirror `enum class Key`
3440
+ * and `enum class KeyModifiers` in rive-runtime focusable.hpp;
3441
+ * they are stable GLFW codes, so they live here as constants instead of an
3442
+ * embind enum.
3443
+ */
3444
+ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
3445
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3446
+ if (ar || !(i in from)) {
3447
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3448
+ ar[i] = from[i];
3449
+ }
3450
+ }
3451
+ return to.concat(ar || Array.prototype.slice.call(from));
3452
+ };
3453
+ var Key = {
3454
+ space: 32,
3455
+ apostrophe: 39, // '
3456
+ comma: 44, // ,
3457
+ minus: 45, // -
3458
+ period: 46, // .
3459
+ slash: 47, // /
3460
+ key0: 48,
3461
+ key1: 49,
3462
+ key2: 50,
3463
+ key3: 51,
3464
+ key4: 52,
3465
+ key5: 53,
3466
+ key6: 54,
3467
+ key7: 55,
3468
+ key8: 56,
3469
+ key9: 57,
3470
+ semicolon: 59, // ;
3471
+ equal: 61, // =
3472
+ a: 65,
3473
+ b: 66,
3474
+ c: 67,
3475
+ d: 68,
3476
+ e: 69,
3477
+ f: 70,
3478
+ g: 71,
3479
+ h: 72,
3480
+ i: 73,
3481
+ j: 74,
3482
+ k: 75,
3483
+ l: 76,
3484
+ m: 77,
3485
+ n: 78,
3486
+ o: 79,
3487
+ p: 80,
3488
+ q: 81,
3489
+ r: 82,
3490
+ s: 83,
3491
+ t: 84,
3492
+ u: 85,
3493
+ v: 86,
3494
+ w: 87,
3495
+ x: 88,
3496
+ y: 89,
3497
+ z: 90,
3498
+ leftBracket: 91, // [
3499
+ backslash: 92, // \
3500
+ rightBracket: 93, // ]
3501
+ graveAccent: 96, // `
3502
+ world1: 161, // non-US #1
3503
+ world2: 162, // non-US #2
3504
+ escape: 256,
3505
+ enter: 257,
3506
+ tab: 258,
3507
+ backspace: 259,
3508
+ insert: 260,
3509
+ deleteKey: 261,
3510
+ right: 262,
3511
+ left: 263,
3512
+ down: 264,
3513
+ up: 265,
3514
+ pageUp: 266,
3515
+ pageDown: 267,
3516
+ home: 268,
3517
+ end: 269,
3518
+ capsLock: 280,
3519
+ scrollLock: 281,
3520
+ numLock: 282,
3521
+ printScreen: 283,
3522
+ pause: 284,
3523
+ f1: 290,
3524
+ f2: 291,
3525
+ f3: 292,
3526
+ f4: 293,
3527
+ f5: 294,
3528
+ f6: 295,
3529
+ f7: 296,
3530
+ f8: 297,
3531
+ f9: 298,
3532
+ f10: 299,
3533
+ f11: 300,
3534
+ f12: 301,
3535
+ f13: 302,
3536
+ f14: 303,
3537
+ f15: 304,
3538
+ f16: 305,
3539
+ f17: 306,
3540
+ f18: 307,
3541
+ f19: 308,
3542
+ f20: 309,
3543
+ f21: 310,
3544
+ f22: 311,
3545
+ f23: 312,
3546
+ f24: 313,
3547
+ f25: 314,
3548
+ kp0: 320,
3549
+ kp1: 321,
3550
+ kp2: 322,
3551
+ kp3: 323,
3552
+ kp4: 324,
3553
+ kp5: 325,
3554
+ kp6: 326,
3555
+ kp7: 327,
3556
+ kp8: 328,
3557
+ kp9: 329,
3558
+ kpDecimal: 330,
3559
+ kpDivide: 331,
3560
+ kpMultiply: 332,
3561
+ kpSubtract: 333,
3562
+ kpAdd: 334,
3563
+ kpEnter: 335,
3564
+ kpEqual: 336,
3565
+ leftShift: 340,
3566
+ leftControl: 341,
3567
+ leftAlt: 342,
3568
+ leftSuper: 343,
3569
+ rightShift: 344,
3570
+ rightControl: 345,
3571
+ rightAlt: 346,
3572
+ rightSuper: 347,
3573
+ menu: 348,
3574
+ };
3575
+ var KeyModifiers = {
3576
+ none: 0,
3577
+ shift: 1 << 0,
3578
+ ctrl: 1 << 1,
3579
+ alt: 1 << 2,
3580
+ meta: 1 << 3,
3581
+ };
3582
+ // Physical key (KeyboardEvent.code) to Rive key, by US-QWERTY position.
3583
+ var CODE_TO_KEY = {
3584
+ // Modifiers are keys too (the editor sends them), and are also in the bitmask.
3585
+ ShiftLeft: Key.leftShift,
3586
+ ShiftRight: Key.rightShift,
3587
+ ControlLeft: Key.leftControl,
3588
+ ControlRight: Key.rightControl,
3589
+ AltLeft: Key.leftAlt,
3590
+ AltRight: Key.rightAlt,
3591
+ MetaLeft: Key.leftSuper,
3592
+ MetaRight: Key.rightSuper,
3593
+ KeyA: Key.a,
3594
+ KeyB: Key.b,
3595
+ KeyC: Key.c,
3596
+ KeyD: Key.d,
3597
+ KeyE: Key.e,
3598
+ KeyF: Key.f,
3599
+ KeyG: Key.g,
3600
+ KeyH: Key.h,
3601
+ KeyI: Key.i,
3602
+ KeyJ: Key.j,
3603
+ KeyK: Key.k,
3604
+ KeyL: Key.l,
3605
+ KeyM: Key.m,
3606
+ KeyN: Key.n,
3607
+ KeyO: Key.o,
3608
+ KeyP: Key.p,
3609
+ KeyQ: Key.q,
3610
+ KeyR: Key.r,
3611
+ KeyS: Key.s,
3612
+ KeyT: Key.t,
3613
+ KeyU: Key.u,
3614
+ KeyV: Key.v,
3615
+ KeyW: Key.w,
3616
+ KeyX: Key.x,
3617
+ KeyY: Key.y,
3618
+ KeyZ: Key.z,
3619
+ Digit0: Key.key0,
3620
+ Digit1: Key.key1,
3621
+ Digit2: Key.key2,
3622
+ Digit3: Key.key3,
3623
+ Digit4: Key.key4,
3624
+ Digit5: Key.key5,
3625
+ Digit6: Key.key6,
3626
+ Digit7: Key.key7,
3627
+ Digit8: Key.key8,
3628
+ Digit9: Key.key9,
3629
+ Numpad0: Key.kp0,
3630
+ Numpad1: Key.kp1,
3631
+ Numpad2: Key.kp2,
3632
+ Numpad3: Key.kp3,
3633
+ Numpad4: Key.kp4,
3634
+ Numpad5: Key.kp5,
3635
+ Numpad6: Key.kp6,
3636
+ Numpad7: Key.kp7,
3637
+ Numpad8: Key.kp8,
3638
+ Numpad9: Key.kp9,
3639
+ NumpadDecimal: Key.kpDecimal,
3640
+ NumpadDivide: Key.kpDivide,
3641
+ NumpadMultiply: Key.kpMultiply,
3642
+ NumpadSubtract: Key.kpSubtract,
3643
+ NumpadAdd: Key.kpAdd,
3644
+ NumpadEnter: Key.kpEnter,
3645
+ NumpadEqual: Key.kpEqual,
3646
+ Minus: Key.minus,
3647
+ Equal: Key.equal,
3648
+ BracketLeft: Key.leftBracket,
3649
+ BracketRight: Key.rightBracket,
3650
+ Backslash: Key.backslash,
3651
+ Semicolon: Key.semicolon,
3652
+ Quote: Key.apostrophe,
3653
+ Backquote: Key.graveAccent,
3654
+ Comma: Key.comma,
3655
+ Period: Key.period,
3656
+ Slash: Key.slash,
3657
+ IntlBackslash: Key.world1,
3658
+ IntlRo: Key.world2,
3659
+ Space: Key.space,
3660
+ Enter: Key.enter,
3661
+ Tab: Key.tab,
3662
+ Backspace: Key.backspace,
3663
+ Insert: Key.insert,
3664
+ Delete: Key.deleteKey,
3665
+ Escape: Key.escape,
3666
+ ArrowRight: Key.right,
3667
+ ArrowLeft: Key.left,
3668
+ ArrowDown: Key.down,
3669
+ ArrowUp: Key.up,
3670
+ PageUp: Key.pageUp,
3671
+ PageDown: Key.pageDown,
3672
+ Home: Key.home,
3673
+ End: Key.end,
3674
+ CapsLock: Key.capsLock,
3675
+ ScrollLock: Key.scrollLock,
3676
+ NumLock: Key.numLock,
3677
+ PrintScreen: Key.printScreen,
3678
+ Pause: Key.pause,
3679
+ ContextMenu: Key.menu,
3680
+ F1: Key.f1,
3681
+ F2: Key.f2,
3682
+ F3: Key.f3,
3683
+ F4: Key.f4,
3684
+ F5: Key.f5,
3685
+ F6: Key.f6,
3686
+ F7: Key.f7,
3687
+ F8: Key.f8,
3688
+ F9: Key.f9,
3689
+ F10: Key.f10,
3690
+ F11: Key.f11,
3691
+ F12: Key.f12,
3692
+ F13: Key.f13,
3693
+ F14: Key.f14,
3694
+ F15: Key.f15,
3695
+ F16: Key.f16,
3696
+ F17: Key.f17,
3697
+ F18: Key.f18,
3698
+ F19: Key.f19,
3699
+ F20: Key.f20,
3700
+ F21: Key.f21,
3701
+ F22: Key.f22,
3702
+ F23: Key.f23,
3703
+ F24: Key.f24,
3704
+ F25: Key.f25,
3705
+ };
3706
+ // Unshifted characters (event.key, lowercased) that name a Rive key.
3707
+ var CHAR_TO_KEY = (function () {
3708
+ var map = {
3709
+ " ": Key.space,
3710
+ "'": Key.apostrophe,
3711
+ ",": Key.comma,
3712
+ "-": Key.minus,
3713
+ ".": Key.period,
3714
+ "/": Key.slash,
3715
+ ";": Key.semicolon,
3716
+ "=": Key.equal,
3717
+ "[": Key.leftBracket,
3718
+ "\\": Key.backslash,
3719
+ "]": Key.rightBracket,
3720
+ "`": Key.graveAccent,
3721
+ };
3722
+ for (var c = 0; c < 26; c++)
3723
+ map[String.fromCharCode(97 + c)] = Key.a + c;
3724
+ for (var d = 0; d <= 9; d++)
3725
+ map[String(d)] = Key.key0 + d;
3726
+ return map;
3727
+ })();
3728
+ // Non-printable event.key values; each shares its name with its code.
3729
+ var NAMED_KEYS = new Set(__spreadArray([
3730
+ "Enter",
3731
+ "Tab",
3732
+ "Backspace",
3733
+ "Insert",
3734
+ "Delete",
3735
+ "Escape",
3736
+ "ArrowRight",
3737
+ "ArrowLeft",
3738
+ "ArrowDown",
3739
+ "ArrowUp",
3740
+ "PageUp",
3741
+ "PageDown",
3742
+ "Home",
3743
+ "End",
3744
+ "CapsLock",
3745
+ "ScrollLock",
3746
+ "NumLock",
3747
+ "PrintScreen",
3748
+ "Pause",
3749
+ "ContextMenu"
3750
+ ], Array.from({ length: 25 }, function (_, i) { return "F".concat(i + 1); }), true));
3751
+ /**
3752
+ * Maps a KeyboardEvent to a Rive key, or null if Rive has no equivalent.
3753
+ *
3754
+ * Resolves the logical key: what the user's layout labels the key, ignoring
3755
+ * Shift, so a listener on "A" fires on AZERTY's A too. `event.key` is preferred;
3756
+ * `event.code` is the fallback when `key` isn't a plain unshifted character
3757
+ * (shifted symbols, Option/AltGr output, non-Latin letters, dead keys).
3758
+ * Digit-row and numpad keys skip the character lookup so AZERTY's digit row
3759
+ * still reports digits and numpad digits stay distinct from the digit row.
3760
+ */
3761
+ function keyboardEventToRiveKey(event) {
3762
+ var _a, _b;
3763
+ var code = event.code, key = event.key;
3764
+ if (NAMED_KEYS.has(key)) {
3765
+ // NumpadEnter reports key "Enter"; keep it distinct.
3766
+ return code === "NumpadEnter" ? Key.kpEnter : (_a = CODE_TO_KEY[key]) !== null && _a !== void 0 ? _a : null;
3767
+ }
3768
+ if (!code.startsWith("Digit") && !code.startsWith("Numpad") && key) {
3769
+ var fromChar = CHAR_TO_KEY[key.toLowerCase()];
3770
+ if (fromChar !== undefined)
3771
+ return fromChar;
3772
+ }
3773
+ return (_b = CODE_TO_KEY[code]) !== null && _b !== void 0 ? _b : null;
3774
+ }
3775
+ function modifiersFromEvent(event) {
3776
+ var modifiers = KeyModifiers.none;
3777
+ if (event.shiftKey)
3778
+ modifiers |= KeyModifiers.shift;
3779
+ if (event.ctrlKey)
3780
+ modifiers |= KeyModifiers.ctrl;
3781
+ if (event.altKey)
3782
+ modifiers |= KeyModifiers.alt;
3783
+ if (event.metaKey)
3784
+ modifiers |= KeyModifiers.meta;
3785
+ return modifiers;
3786
+ }
3787
+
3788
+
3789
+ /***/ }),
3790
+ /* 16 */
3791
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3792
+
3793
+ __webpack_require__.r(__webpack_exports__);
3794
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3795
+ /* harmony export */ TextInputProxy: () => (/* binding */ TextInputProxy)
3796
+ /* harmony export */ });
3797
+ /* harmony import */ var _canvasOffset__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
3798
+
3799
+ // 16px: the smallest font size at which iOS Safari doesn't zoom on focus
3800
+ var FONT_SIZE_PX = 16;
3801
+ /** Capture-critical attributes decorate() must not touch. */
3802
+ var PROTECTED_ATTRS = new Set([
3803
+ "type",
3804
+ "value",
3805
+ "style",
3806
+ "tabindex",
3807
+ "autocapitalize",
3808
+ "autocomplete",
3809
+ "autocorrect",
3810
+ "spellcheck",
3811
+ ]);
3812
+ /**
3813
+ * Invisible per-instance <input> capturing IME/dead-key/paste text; focusable inside a
3814
+ * gesture to raise mobile keyboards. Always empty: C++ owns value and caret. Decorated
3815
+ * for AT only while it holds DOM focus.
3816
+ */
3817
+ var TextInputProxy = /** @class */ (function () {
3818
+ function TextInputProxy(params) {
3819
+ var _this = this;
3820
+ // True between compositionstart/compositionend; we never commit mid-composition.
3821
+ this.composing = false;
3822
+ // Names set by decorate(), removed by resetDecoration().
3823
+ this.decoratedKeys = new Set();
3824
+ // Last written left/top, to skip no-op style writes.
3825
+ this.lastLeft = NaN;
3826
+ this.lastTop = NaN;
3827
+ /** Re-sync before input: the canvas may have scrolled since the session began. */
3828
+ this.reposition = function () { return _this.positionOverCanvas(); };
3829
+ this.onCompositionStart = function () {
3830
+ _this.composing = true;
3831
+ };
3832
+ this.onCompositionEnd = function () {
3833
+ _this.composing = false;
3834
+ // The composed text is now committed in element.value; forward it here. A
3835
+ // trailing `input` event (order varies by browser) then sees an empty field.
3836
+ _this.commit();
3837
+ };
3838
+ this.onInput = function () {
3839
+ if (_this.composing)
3840
+ return;
3841
+ _this.commit();
3842
+ };
3843
+ // An <input type=text> strips line breaks from its value, so forward the clipboard
3844
+ // text directly. Core's single-line fields strip them themselves.
3845
+ this.onPaste = function (event) {
3846
+ var _a;
3847
+ var text = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData("text/plain");
3848
+ if (!text)
3849
+ return;
3850
+ event.preventDefault();
3851
+ _this.params.textInput(text.replace(/\r\n?/g, "\n"));
3852
+ };
3853
+ this.onBlur = function (event) {
3854
+ _this.params.onBlur(event.relatedTarget);
3855
+ };
3856
+ this.params = params;
3857
+ this.element = this.createElement();
3858
+ this.positionOverCanvas();
3859
+ // Order vs. the overlay is unspecified; fine, Tab release starts from the canvas.
3860
+ this.params.container.appendChild(this.element);
3861
+ }
3862
+ // Registered first so it runs before the key handler inserts or moves the caret.
3863
+ TextInputProxy.prototype.listeners = function () {
3864
+ return [
3865
+ ["keydown", this.reposition],
3866
+ ["beforeinput", this.reposition],
3867
+ ["keydown", this.params.onKeyDown],
3868
+ ["keyup", this.params.onKeyUp],
3869
+ ["input", this.onInput],
3870
+ ["compositionstart", this.onCompositionStart],
3871
+ ["compositionend", this.onCompositionEnd],
3872
+ ["paste", this.onPaste],
3873
+ ["copy", this.params.onCopy],
3874
+ ["blur", this.onBlur],
3875
+ ];
3876
+ };
3877
+ TextInputProxy.prototype.createElement = function () {
3878
+ var el = document.createElement("input");
3879
+ el.type = "text";
3880
+ // Focusable but never in native tab order (Rive drives traversal synthetically),
3881
+ // and invisible without display:none (which would forbid focus).
3882
+ el.tabIndex = -1;
3883
+ el.setAttribute("aria-hidden", "true");
3884
+ // Always empty, so autocapitalize/autocorrect would misfire.
3885
+ el.setAttribute("autocapitalize", "off");
3886
+ el.setAttribute("autocomplete", "off");
3887
+ el.setAttribute("autocorrect", "off");
3888
+ el.spellcheck = false;
3889
+ // Over the canvas (not display:none) so iOS doesn't scroll-jump on keyboard open.
3890
+ // font-size must stay 16px or iOS Safari zooms on focus.
3891
+ el.style.cssText =
3892
+ "position:absolute;width:1px;height:1px;padding:0;margin:0;border:0;" +
3893
+ "outline:none;opacity:0;background:transparent;color:transparent;" +
3894
+ "caret-color:transparent;overflow:hidden;resize:none;z-index:0;" +
3895
+ // Focused programmatically only; must not swallow clicks
3896
+ "pointer-events:none;" +
3897
+ "font-size:".concat(FONT_SIZE_PX, "px;line-height:1;");
3898
+ for (var _i = 0, _a = this.listeners(); _i < _a.length; _i++) {
3899
+ var _b = _a[_i], type = _b[0], listener = _b[1];
3900
+ el.addEventListener(type, listener);
3901
+ }
3902
+ return el;
3903
+ };
3904
+ TextInputProxy.prototype.positionOverCanvas = function () {
3905
+ // Track the canvas (browsers scroll to the caret); clamp on-screen, one caret line box
3906
+ // (FONT_SIZE_PX) from the far edges, or the root scrolls to reveal it.
3907
+ var _a = (0,_canvasOffset__WEBPACK_IMPORTED_MODULE_0__.canvasOffset)(this.params.canvas), top = _a.top, left = _a.left;
3908
+ if (window.innerHeight > 0) {
3909
+ var r = this.params.canvas.getBoundingClientRect();
3910
+ top += clamp(r.top, 0, window.innerHeight - FONT_SIZE_PX) - r.top;
3911
+ left += clamp(r.left, 0, window.innerWidth - FONT_SIZE_PX) - r.left;
3912
+ }
3913
+ if (left !== this.lastLeft) {
3914
+ this.element.style.left = "".concat(left, "px");
3915
+ this.lastLeft = left;
3916
+ }
3917
+ if (top !== this.lastTop) {
3918
+ this.element.style.top = "".concat(top, "px");
3919
+ this.lastTop = top;
3920
+ }
3921
+ };
3922
+ /**
3923
+ * Forward the field's text to Rive and clear it.
3924
+ *
3925
+ * TODO: iOS won't autorepeat Backspace in an empty field (needs a text mirror).
3926
+ * */
3927
+ TextInputProxy.prototype.commit = function () {
3928
+ var text = this.element.value;
3929
+ if (!text)
3930
+ return;
3931
+ this.element.value = "";
3932
+ this.params.textInput(text);
3933
+ };
3934
+ /** Clear any transient value and decoration. Does not blur the element. */
3935
+ TextInputProxy.prototype.endSession = function () {
3936
+ this.element.value = "";
3937
+ // Browsers fire compositionend on blur, but a stuck flag would drop every
3938
+ // keystroke of the next session.
3939
+ this.composing = false;
3940
+ // Also covers blur-out, which bypasses the overlay.
3941
+ this.resetDecoration();
3942
+ };
3943
+ /** Must be called synchronously inside a gesture on iOS to raise the keyboard. */
3944
+ TextInputProxy.prototype.focus = function () {
3945
+ // Reposition first: iOS scrolls the focused input into view when the keyboard opens.
3946
+ this.positionOverCanvas();
3947
+ this.element.focus({ preventScroll: true });
3948
+ };
3949
+ TextInputProxy.prototype.hasDomFocus = function () {
3950
+ return document.activeElement === this.element;
3951
+ };
3952
+ TextInputProxy.prototype.owns = function (target) {
3953
+ return target === this.element;
3954
+ };
3955
+ /** See EditingHost.decorate. */
3956
+ TextInputProxy.prototype.decorate = function (attrs) {
3957
+ // aria-hidden outranks every attribute set below, so it must come off before this
3958
+ // element can stand in as the accessible element for the focused node.
3959
+ this.element.removeAttribute("aria-hidden");
3960
+ for (var _i = 0, _a = Object.entries(attrs); _i < _a.length; _i++) {
3961
+ var _b = _a[_i], name_1 = _b[0], value = _b[1];
3962
+ // Never override capture attrs.
3963
+ if (PROTECTED_ATTRS.has(name_1.toLowerCase()))
3964
+ continue;
3965
+ if (value === null) {
3966
+ this.element.removeAttribute(name_1);
3967
+ this.decoratedKeys.delete(name_1);
3968
+ }
3969
+ else {
3970
+ // Skip no-op writes: setting an attribute to the value it already has still
3971
+ // emits a mutation, and assistive tech is focused on this element mid-edit.
3972
+ if (this.element.getAttribute(name_1) !== value) {
3973
+ this.element.setAttribute(name_1, value);
3974
+ }
3975
+ this.decoratedKeys.add(name_1);
3976
+ }
3977
+ }
3978
+ };
3979
+ /**
3980
+ * type=password for obscured fields so AT doesn't echo keys.
3981
+ * TODO: source "type" from Core, not semantics.
3982
+ */
3983
+ TextInputProxy.prototype.setSecure = function (secure) {
3984
+ var type = secure ? "password" : "text";
3985
+ if (this.element.type !== type)
3986
+ this.element.type = type;
3987
+ };
3988
+ /** Drop all decoration and return to the AT-invisible baseline. */
3989
+ TextInputProxy.prototype.resetDecoration = function () {
3990
+ var _this = this;
3991
+ this.setSecure(false);
3992
+ this.decoratedKeys.forEach(function (name) { return _this.element.removeAttribute(name); });
3993
+ this.decoratedKeys.clear();
3994
+ this.element.setAttribute("aria-hidden", "true");
3995
+ };
3996
+ TextInputProxy.prototype.cleanup = function () {
3997
+ for (var _i = 0, _a = this.listeners(); _i < _a.length; _i++) {
3998
+ var _b = _a[_i], type = _b[0], listener = _b[1];
3999
+ this.element.removeEventListener(type, listener);
4000
+ }
4001
+ this.element.remove();
4002
+ };
4003
+ return TextInputProxy;
4004
+ }());
4005
+
4006
+ function clamp(v, min, max) {
4007
+ return Math.min(Math.max(v, min), Math.max(min, max));
4008
+ }
4009
+
4010
+
4011
+ /***/ }),
4012
+ /* 17 */
2920
4013
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2921
4014
 
2922
4015
  __webpack_require__.r(__webpack_exports__);
@@ -2969,7 +4062,7 @@ function sanitizeUrl(url) {
2969
4062
 
2970
4063
 
2971
4064
  /***/ }),
2972
- /* 14 */
4065
+ /* 18 */
2973
4066
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2974
4067
 
2975
4068
  __webpack_require__.r(__webpack_exports__);
@@ -3269,7 +4362,7 @@ var createFinalization = function (target, finalizable) {
3269
4362
 
3270
4363
 
3271
4364
  /***/ }),
3272
- /* 15 */
4365
+ /* 19 */
3273
4366
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3274
4367
 
3275
4368
  __webpack_require__.r(__webpack_exports__);
@@ -3441,7 +4534,7 @@ __webpack_require__.r(__webpack_exports__);
3441
4534
  /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
3442
4535
  /* harmony import */ var _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
3443
4536
  /* harmony import */ var _semantics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
3444
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
4537
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);
3445
4538
  var __extends = (undefined && undefined.__extends) || (function () {
3446
4539
  var extendStatics = function (d, b) {
3447
4540
  extendStatics = Object.setPrototypeOf ||
@@ -5329,6 +6422,10 @@ var Rive = /** @class */ (function () {
5329
6422
  this._dataEnums = null;
5330
6423
  this._tabIndex = null;
5331
6424
  this._prevHasFocus = false;
6425
+ this._prevWantsTextInputSession = false;
6426
+ // Pointer-down defers the proxy focus: mousedown's default would refocus the canvas and
6427
+ // touchstart isn't user activation; pointer-up focuses it.
6428
+ this._inPointerDownDrain = false;
5332
6429
  this._focusOptions = {
5333
6430
  allowFocusInterrupt: false,
5334
6431
  };
@@ -5364,6 +6461,7 @@ var Rive = /** @class */ (function () {
5364
6461
  _this.resizeToCanvas();
5365
6462
  }
5366
6463
  };
6464
+ this.isEditingHostFocused = function () { var _a, _b; return (_b = (_a = _this._keyboardInteractions) === null || _a === void 0 ? void 0 : _a.isEditingHostFocused()) !== null && _b !== void 0 ? _b : false; };
5367
6465
  // Tracks the current animation frame request
5368
6466
  this.frameRequestId = null;
5369
6467
  /**
@@ -5684,11 +6782,21 @@ var Rive = /** @class */ (function () {
5684
6782
  dispatchPointerExit: dispatchPointerExit,
5685
6783
  enableMultiTouch: enableMultiTouch,
5686
6784
  layoutScaleFactor: this._layout.layoutScaleFactor,
5687
- advanceAndDrain: this.advanceAndReportChanges.bind(this)
6785
+ advanceAndDrain: this.advanceAndDrainForPointer.bind(this),
6786
+ summonKeyboard: this.summonKeyboardForGesture.bind(this),
6787
+ isTextProxyFocused: this.isEditingHostFocused,
5688
6788
  });
5689
6789
  this.ensureKeyboardInteractions();
5690
6790
  }
5691
6791
  };
6792
+ Object.defineProperty(Rive.prototype, "focusStateMachine", {
6793
+ // Assumes a single state machine drives focus.
6794
+ get: function () {
6795
+ return this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; });
6796
+ },
6797
+ enumerable: false,
6798
+ configurable: true
6799
+ });
5692
6800
  /**
5693
6801
  * Wire keyboard interactions when a playing state machine has focus nodes.
5694
6802
  * Called at listener setup and lazily each frame so late-bound bindable artboards work.
@@ -5701,7 +6809,7 @@ var Rive = /** @class */ (function () {
5701
6809
  !(this.canvas instanceof HTMLCanvasElement)) {
5702
6810
  return;
5703
6811
  }
5704
- var smWithFocusNodes = this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; });
6812
+ var smWithFocusNodes = this.focusStateMachine;
5705
6813
  if (!smWithFocusNodes) {
5706
6814
  return;
5707
6815
  }
@@ -5711,16 +6819,51 @@ var Rive = /** @class */ (function () {
5711
6819
  }
5712
6820
  this._keyboardInteractions = new _utils__WEBPACK_IMPORTED_MODULE_3__.KeyboardInteractions({
5713
6821
  canvas: this.canvas,
5714
- stateMachine: smWithFocusNodes.instance, // work off assumption of single state machine
6822
+ stateMachine: smWithFocusNodes.instance,
5715
6823
  hasFocusNodes: true,
5716
6824
  getOverlayElement: function () { var _a, _b; return (_b = (_a = _this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.getSemanticOverlayContainer()) !== null && _b !== void 0 ? _b : null; },
5717
6825
  });
5718
6826
  };
6827
+ /** Runs inside touchend/mouseup so focusing the proxy raises the mobile keyboard. */
6828
+ Rive.prototype.summonKeyboardForGesture = function () {
6829
+ if (!this._keyboardInteractions)
6830
+ return;
6831
+ var activeSm = this.focusStateMachine;
6832
+ if (!activeSm)
6833
+ return;
6834
+ if (this.wantsTextInputSession(activeSm.focusState().expectsKeyboardInput)) {
6835
+ this._keyboardInteractions.summonForPointer();
6836
+ }
6837
+ };
6838
+ /** expectsKeyboardInput, and (with semantics on) the focused node is a textField. */
6839
+ Rive.prototype.wantsTextInputSession = function (expectsKeyboardInput) {
6840
+ var _a;
6841
+ if (!expectsKeyboardInput)
6842
+ return false;
6843
+ var node = (_a = this._semanticTree) === null || _a === void 0 ? void 0 : _a.focusedNode();
6844
+ return node === undefined || node.role === _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField;
6845
+ };
6846
+ Rive.prototype.advanceAndDrainForPointer = function (elapsedTime, options) {
6847
+ if (!(options === null || options === void 0 ? void 0 : options.pointerDown)) {
6848
+ this.advanceAndReportChanges(elapsedTime);
6849
+ return;
6850
+ }
6851
+ this._inPointerDownDrain = true;
6852
+ try {
6853
+ this.advanceAndReportChanges(elapsedTime);
6854
+ }
6855
+ finally {
6856
+ this._inPointerDownDrain = false;
6857
+ }
6858
+ };
5719
6859
  Rive.prototype.cleanupKeyboardInteractions = function () {
6860
+ var _a;
5720
6861
  if (this._keyboardInteractions) {
5721
6862
  this._keyboardInteractions.cleanup();
5722
6863
  this._keyboardInteractions = null;
5723
6864
  }
6865
+ this._prevWantsTextInputSession = false;
6866
+ (_a = this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.releaseEditingHost(null, null);
5724
6867
  };
5725
6868
  /**
5726
6869
  * Remove Rive Listeners setup on the canvas
@@ -6056,56 +7199,69 @@ var Rive = /** @class */ (function () {
6056
7199
  var _a, _b, _c;
6057
7200
  return (_c = (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.deferredSession) === null || _b === void 0 ? void 0 : _b.recordedThisFrame()) !== null && _c !== void 0 ? _c : false;
6058
7201
  };
6059
- /**
6060
- * Poll focus state each frame to see if we should focus/blur the canvas in case
6061
- * Rive internally updated focus outside of user interaction (e.g., via listener action)
6062
- */
7202
+ /** Rive can move focus on its own, so reconcile the text session and DOM focus each frame. */
6063
7203
  Rive.prototype.pollFocusState = function () {
6064
- var _a, _b;
6065
7204
  this.ensureKeyboardInteractions();
6066
- if (!this._keyboardInteractions) {
7205
+ var ki = this._keyboardInteractions;
7206
+ var activeSm = ki ? this.focusStateMachine : undefined;
7207
+ if (!ki || !activeSm || !(this.canvas instanceof HTMLCanvasElement)) {
6067
7208
  this._prevHasFocus = false;
7209
+ this._prevWantsTextInputSession = false;
6068
7210
  return;
6069
7211
  }
6070
- var activeSm = this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; }); // work off assumption of single state machine
6071
- if (!activeSm) {
6072
- this._prevHasFocus = false;
6073
- return;
7212
+ var _a = activeSm.focusState(), hasFocus = _a.hasFocus, expectsKeyboardInput = _a.expectsKeyboardInput;
7213
+ this.syncTextInputSession(ki, this.wantsTextInputSession(expectsKeyboardInput));
7214
+ this.syncRiveFocus(ki, this.canvas, hasFocus);
7215
+ };
7216
+ /** Begin/end the text session on wantsSession edges; decorate the proxy while it has DOM focus. */
7217
+ Rive.prototype.syncTextInputSession = function (ki, wantsSession) {
7218
+ var host = ki.editingHost;
7219
+ var overlay = this._accessibilityOverlay;
7220
+ if (wantsSession) {
7221
+ var began = !this._prevWantsTextInputSession;
7222
+ if (began) {
7223
+ // In-domain or opted-in only; during pointer-down, pointer-up focuses instead.
7224
+ var focusProxy = !this._inPointerDownDrain &&
7225
+ (ki.isInFocusDomain(document.activeElement) ||
7226
+ !!this._focusOptions.allowFocusInterrupt);
7227
+ ki.beginTextInputSession(focusProxy);
7228
+ }
7229
+ // The <input> proxy stands in for the semantic DOM field only while it holds DOM focus.
7230
+ if (overlay && this._semanticTree) {
7231
+ if (host.hasDomFocus()) {
7232
+ overlay.syncEditingHost(this._semanticTree, host, began || !overlay.hasEditingHost());
7233
+ }
7234
+ else if (overlay.hasEditingHost()) {
7235
+ overlay.releaseEditingHost(this._semanticTree, host);
7236
+ }
7237
+ }
6074
7238
  }
6075
- if (this.canvas instanceof HTMLCanvasElement) {
6076
- var hasFocus = activeSm.focusState().hasFocus;
6077
- if (hasFocus) {
6078
- // Rive has an active focus node. Mark the session RiveFocused so Tab stays
6079
- // trapped and a later internal release (hasFocus true → false) is detected.
6080
- this._keyboardInteractions.notifyRiveFocused();
6081
- // Only steal DOM focus on the false→true transition. Rive can hold focus across
6082
- // frames while DOM focus sits elsewhere — a window switch preserves runtime focus
6083
- // by design — and that must not re-focus the canvas again.
6084
- if (!this._prevHasFocus) {
6085
- // Steal DOM focus to the canvas only when focus isn't already held
6086
- // somewhere inside this instance's focus scope. When the accessibility
6087
- // overlay has driven focus onto a specific semantic node element (e.g.
6088
- // an appearing alert dialog), focus is already in-scope. The steal
6089
- // stays a fallback for runtime focus nodes that have no overlay element
6090
- // to hold DOM focus.
6091
- var scope = (_a = this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.getSemanticOverlayContainer();
6092
- var focusAlreadyInScope = document.activeElement === this.canvas ||
6093
- ((_b = scope === null || scope === void 0 ? void 0 : scope.contains(document.activeElement)) !== null && _b !== void 0 ? _b : false);
6094
- if (!focusAlreadyInScope && this._focusOptions.allowFocusInterrupt) {
6095
- this.canvas.focus();
6096
- }
6097
- this._prevHasFocus = true;
7239
+ else if (this._prevWantsTextInputSession) {
7240
+ // Overlay hand-off first, ahead of endTextInputSession's park-on-canvas fallback.
7241
+ overlay === null || overlay === void 0 ? void 0 : overlay.releaseEditingHost(this._semanticTree, host);
7242
+ ki.endTextInputSession();
7243
+ }
7244
+ this._prevWantsTextInputSession = wantsSession;
7245
+ };
7246
+ /** Mirror Rive's hasFocus into the keyboard session state and, on opt-in, canvas focus. */
7247
+ Rive.prototype.syncRiveFocus = function (ki, canvas, hasFocus) {
7248
+ if (hasFocus) {
7249
+ ki.notifyRiveFocused();
7250
+ // Pull focus from outside Rive only with allowFocusInterrupt.
7251
+ if (!this._prevHasFocus) {
7252
+ if (!ki.isInFocusDomain(document.activeElement) &&
7253
+ this._focusOptions.allowFocusInterrupt) {
7254
+ canvas.focus();
6098
7255
  }
6099
- return;
7256
+ this._prevHasFocus = true;
6100
7257
  }
7258
+ }
7259
+ else {
6101
7260
  this._prevHasFocus = false;
6102
- // hasFocus is false — only act when Rive previously held focus and released it internally
6103
- // (state change clears focus). Release the DOM Tab trap so the next Tab moves to the next
6104
- // page element. A DOM blur reaches here too now that onCanvasBlur clears Rive focus, but it
6105
- // has already set NotFocused, so this is a no-op. EntryPending and NotFocused are likewise
6106
- // intentional no-ops — EntryPending must stay put (a click awaiting its first Tab).
6107
- if (this._keyboardInteractions.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.RiveFocused) {
6108
- this._keyboardInteractions.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.NotFocused);
7261
+ // Rive released focus internally (e.g. a state change): drop the Tab trap so the next
7262
+ // Tab leaves the canvas.
7263
+ if (ki.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.RiveFocused) {
7264
+ ki.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.NotFocused);
6109
7265
  }
6110
7266
  }
6111
7267
  };
@@ -6203,6 +7359,7 @@ var Rive = /** @class */ (function () {
6203
7359
  instanceId: this._instanceId,
6204
7360
  semanticsOptions: this.semanticsOptions,
6205
7361
  allowFocusInterrupt: this._focusOptions.allowFocusInterrupt,
7362
+ isEditingHostFocused: this.isEditingHostFocused,
6206
7363
  fireAction: function (nodeId, actionType) {
6207
7364
  mainSm_1.fireSemanticAction(nodeId, actionType);
6208
7365
  },
@@ -6787,7 +7944,7 @@ var Rive = /** @class */ (function () {
6787
7944
  this.canvas.height = dpr * height;
6788
7945
  this._needsRedraw = true;
6789
7946
  this.resizeToCanvas();
6790
- if (this.layout.fit === Fit.Layout) {
7947
+ if (this.layout.fit === Fit.Layout && this.artboard) {
6791
7948
  var scaleFactor = this._layout.layoutScaleFactor;
6792
7949
  this.artboard.width = width / scaleFactor;
6793
7950
  this.artboard.height = height / scaleFactor;