@rive-app/canvas 2.43.1 → 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/package.json +1 -1
- package/rive.d.ts +14 -4
- package/rive.js +1365 -208
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +10 -3
- package/rive_fallback.wasm +0 -0
- package/semantics/accessibilityOverlay.d.ts +56 -1
- package/semantics/claimedKeyEvents.d.ts +7 -0
- package/semantics/semanticTreeModel.d.ts +2 -0
- package/utils/canvasOffset.d.ts +8 -0
- package/utils/keyMap.d.ts +141 -0
- package/utils/registerKeyboardInteractions.d.ts +42 -7
- package/utils/registerTouchInteractions.d.ts +6 -2
- package/utils/textInputProxy.d.ts +61 -0
package/rive.js
CHANGED
|
@@ -448,14 +448,14 @@ c=0;c<a.length;++c)65535<a.codePointAt(c)&&c++,b+=4;return b},sd=0,td=[],ud=a=>{
|
|
|
448
448
|
!1;return c},["delete"](){this.g.m||yc(this);if(this.g.ma&&!this.g.ja)throw new S("Object already scheduled for deletion");oc(this);var c=this.g;--c.count.value;0===c.count.value&&(c.F?c.M.T(c.F):c.u.h.T(c.m));this.g.ja||(this.g.F=void 0,this.g.m=void 0)},isDeleted:function(){return!this.g.m},deleteLater:function(){this.g.m||yc(this);if(this.g.ma&&!this.g.ja)throw new S("Object already scheduled for deletion");zc.push(this);this.g.ma=!0;return this}});const b=Symbol.dispose;b&&(a[b]=a["delete"])})();
|
|
449
449
|
Object.assign(Oc.prototype,{dc(a){this.Ab&&(a=this.Ab(a));return a},mb(a){this.T?.(a)},L:tc,o:function(a){function b(){return this.ya?Nc(this.h.P,{u:this.vc,m:c,M:this,F:a}):Nc(this.h.P,{u:this,m:a})}var c=this.dc(a);if(!c)return this.mb(a),null;var d=Mc(this.h,c);if(void 0!==d){if(0===d.g.count.value)return d.g.m=c,d.g.F=a,d.clone();d=d.clone();this.mb(a);return d}d=this.h.cc(c);d=Bc[d];if(!d)return b.call(this);d=this.xa?d.Ub:d.pointerType;var e=Lc(c,this.h,d.h);return null===e?b.call(this):this.ya?
|
|
450
450
|
Nc(d.h.P,{u:d,m:e,M:this,F:a}):Nc(d.h.P,{u:d,m:e})}});k.noExitRuntime&&(Wa=k.noExitRuntime);k.print&&(sa=k.print);k.printErr&&(ta=k.printErr);k.wasmBinary&&(ua=k.wasmBinary);k.thisProgram&&(la=k.thisProgram);if(k.preInit)for("function"==typeof k.preInit&&(k.preInit=[k.preInit]);0<k.preInit.length;)k.preInit.shift()();
|
|
451
|
-
var Ld={
|
|
451
|
+
var Ld={262254:(a,b,c,d,e)=>{if("undefined"===typeof window||void 0===(window.AudioContext||window.webkitAudioContext))return 0;if("undefined"===typeof window.miniaudio){window.miniaudio={referenceCount:0};window.miniaudio.device_type={};window.miniaudio.device_type.playback=a;window.miniaudio.device_type.capture=b;window.miniaudio.device_type.duplex=c;window.miniaudio.device_state={};window.miniaudio.device_state.stopped=d;window.miniaudio.device_state.started=e;let f=window.miniaudio;f.devices=
|
|
452
452
|
[];f.track_device=function(g){for(var h=0;h<f.devices.length;++h)if(null==f.devices[h])return f.devices[h]=g,h;f.devices.push(g);return f.devices.length-1};f.untrack_device_by_index=function(g){for(f.devices[g]=null;0<f.devices.length;)if(null==f.devices[f.devices.length-1])f.devices.pop();else break};f.untrack_device=function(g){for(var h=0;h<f.devices.length;++h)if(f.devices[h]==g)return f.untrack_device_by_index(h)};f.get_device_by_index=function(g){return f.devices[g]};f.unlock_event_types=["touchend",
|
|
453
|
-
"click"];f.unlock=function(){for(var g=0;g<f.devices.length;++g){var h=f.devices[g];null!=h&&null!=h.N&&h.state===f.device_state.started&&h.N.resume().then(()=>{Id(h.yb)},l=>{console.error("Failed to resume audiocontext",l)})}f.unlock_event_types.map(function(l){document.removeEventListener(l,f.unlock,!0)})};f.unlock_event_types.map(function(g){document.addEventListener(g,f.unlock,!0)})}window.miniaudio.referenceCount+=1;return 1},
|
|
454
|
-
window.miniaudio.unlock,!0)}),--window.miniaudio.referenceCount,0===window.miniaudio.referenceCount&&delete window.miniaudio)},
|
|
453
|
+
"click"];f.unlock=function(){for(var g=0;g<f.devices.length;++g){var h=f.devices[g];null!=h&&null!=h.N&&h.state===f.device_state.started&&h.N.resume().then(()=>{Id(h.yb)},l=>{console.error("Failed to resume audiocontext",l)})}f.unlock_event_types.map(function(l){document.removeEventListener(l,f.unlock,!0)})};f.unlock_event_types.map(function(g){document.addEventListener(g,f.unlock,!0)})}window.miniaudio.referenceCount+=1;return 1},264432:()=>{"undefined"!==typeof window.miniaudio&&(window.miniaudio.unlock_event_types.map(function(a){document.removeEventListener(a,
|
|
454
|
+
window.miniaudio.unlock,!0)}),--window.miniaudio.referenceCount,0===window.miniaudio.referenceCount&&delete window.miniaudio)},264736:()=>void 0!==navigator.mediaDevices&&void 0!==navigator.mediaDevices.getUserMedia,264840:()=>{try{var a=new (window.AudioContext||window.webkitAudioContext),b=a.sampleRate;a.close();return b}catch(c){return 0}},265011:(a,b,c,d,e,f)=>{if("undefined"===typeof window.miniaudio)return-1;var g={},h={};a==window.miniaudio.device_type.playback&&0!=c&&(h.sampleRate=c);g.N=
|
|
455
455
|
new (window.AudioContext||window.webkitAudioContext)(h);g.N.suspend();g.state=window.miniaudio.device_state.stopped;c=0;a!=window.miniaudio.device_type.playback&&(c=b);g.da=g.N.createScriptProcessor(d,c,b);g.da.onaudioprocess=function(l){if(null==g.wa||0==g.wa.length)g.wa=new Float32Array(Da.buffer,e,d*b);if(a==window.miniaudio.device_type.capture||a==window.miniaudio.device_type.duplex){for(var n=0;n<b;n+=1)for(var t=l.inputBuffer.getChannelData(n),u=g.wa,r=0;r<d;r+=1)u[r*b+n]=t[r];Jd(f,d,e)}if(a==
|
|
456
456
|
window.miniaudio.device_type.playback||a==window.miniaudio.device_type.duplex)for(Kd(f,d,e),n=0;n<l.outputBuffer.numberOfChannels;++n)for(t=l.outputBuffer.getChannelData(n),u=g.wa,r=0;r<d;r+=1)t[r]=u[r*b+n];else for(n=0;n<l.outputBuffer.numberOfChannels;++n)l.outputBuffer.getChannelData(n).fill(0)};a!=window.miniaudio.device_type.capture&&a!=window.miniaudio.device_type.duplex||navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then(function(l){g.Fa=g.N.createMediaStreamSource(l);g.Fa.connect(g.da);
|
|
457
|
-
g.da.connect(g.N.destination)}).catch(function(l){console.log("Failed to get user media: "+l)});a==window.miniaudio.device_type.playback&&g.da.connect(g.N.destination);g.yb=f;return window.miniaudio.track_device(g)},
|
|
458
|
-
{window.miniaudio.untrack_device_by_index(a)},
|
|
457
|
+
g.da.connect(g.N.destination)}).catch(function(l){console.log("Failed to get user media: "+l)});a==window.miniaudio.device_type.playback&&g.da.connect(g.N.destination);g.yb=f;return window.miniaudio.track_device(g)},267888:a=>window.miniaudio.get_device_by_index(a).N.sampleRate,267961:a=>{a=window.miniaudio.get_device_by_index(a);void 0!==a.da&&(a.da.onaudioprocess=function(){},a.da.disconnect(),a.da=void 0);void 0!==a.Fa&&(a.Fa.disconnect(),a.Fa=void 0);a.N.close();a.N=void 0;a.yb=void 0},268361:a=>
|
|
458
|
+
{window.miniaudio.untrack_device_by_index(a)},268411:a=>{a=window.miniaudio.get_device_by_index(a);a.N.resume();a.state=window.miniaudio.device_state.started},268550:a=>{a=window.miniaudio.get_device_by_index(a);a.N.suspend();a.state=window.miniaudio.device_state.stopped}},lc,Md,kc,Id,Jd,Kd,Nd,Od,Pd,Qd,Ja,Rc,Sd={__syscall_fcntl64:function(a,b,c){Xa=c;try{var d=Lb(a);switch(b){case 0:var e=Ya();if(0>e)break;for(;Ab[e];)e++;return Nb(d,e).ba;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=
|
|
459
459
|
Ya(),d.flags|=e,0;case 12:return e=Ya(),Ba[e+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(f){if("undefined"==typeof ac||"ErrnoError"!==f.name)throw f;return-f.aa}},__syscall_ioctl:function(a,b,c){Xa=c;try{var d=Lb(a);switch(b){case 21509:return d.s?0:-59;case 21505:if(!d.s)return-59;if(d.s.$.kc){a=[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];var e=Ya();E[e>>2]=25856;E[e+4>>2]=5;E[e+8>>2]=191;E[e+12>>2]=35387;for(var f=0;32>f;f++)Aa[e+f+17]=a[f]||0}return 0;case 21510:case 21511:case 21512:return d.s?
|
|
460
460
|
0:-59;case 21506:case 21507:case 21508:if(!d.s)return-59;if(d.s.$.lc)for(e=Ya(),a=[],f=0;32>f;f++)a.push(Aa[e+f+17]);return 0;case 21519:if(!d.s)return-59;e=Ya();return E[e>>2]=0;case 21520:return d.s?-28:-59;case 21537:case 21531:e=Ya();if(!d.i.jc)throw new P(59);return d.i.jc(d,b,e);case 21523:if(!d.s)return-59;d.s.$.mc&&(f=[24,80],e=Ya(),Ba[e>>1]=f[0],Ba[e+2>>1]=f[1]);return 0;case 21524:return d.s?0:-59;case 21515:return d.s?0:-59;default:return-28}}catch(g){if("undefined"==typeof ac||"ErrnoError"!==
|
|
461
461
|
g.name)throw g;return-g.aa}},__syscall_openat:function(a,b,c,d){Xa=d;try{b=b?gb(w,b):"";var e=b;if("/"===e.charAt(0))b=e;else{var f=-100===a?"/":Lb(a).path;if(0==e.length)throw new P(44);b=f+"/"+e}var g=d?Ya():0;return Yb(b,c,g).ba}catch(h){if("undefined"==typeof ac||"ErrnoError"!==h.name)throw h;return-h.aa}},_abort_js:()=>Ka(""),_embind_create_inheriting_constructor:(a,b,c)=>{a=T(a);b=nc(b,"wrapper");c=ec(c);var d=b.h,e=d.P,f=d.C.P,g=d.C.constructor;a=bc(a,function(...h){for(var l of d.C.zb)if(this[l]===
|
|
@@ -500,7 +500,7 @@ Ta.push(d)}Sa(Ta)}}if(k.preRun)for("function"==typeof k.preRun&&(k.preRun=[k.pre
|
|
|
500
500
|
/* 5 */
|
|
501
501
|
/***/ ((module) => {
|
|
502
502
|
|
|
503
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.
|
|
503
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.44.0","description":"Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
504
504
|
|
|
505
505
|
/***/ }),
|
|
506
506
|
/* 6 */
|
|
@@ -626,6 +626,17 @@ var SemanticTreeModel = /** @class */ (function () {
|
|
|
626
626
|
SemanticTreeModel.prototype.nodeById = function (id) {
|
|
627
627
|
return this._nodesById.get(id);
|
|
628
628
|
};
|
|
629
|
+
/** The node with SemanticState.Focused, or undefined. */
|
|
630
|
+
SemanticTreeModel.prototype.focusedNode = function () {
|
|
631
|
+
// Manual iteration: runs every frame and must stop at the first hit (the
|
|
632
|
+
// TS target forbids for-of over Map iterators).
|
|
633
|
+
var it = this._nodesById.values();
|
|
634
|
+
for (var r = it.next(); !r.done; r = it.next()) {
|
|
635
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(r.value.stateFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Focused))
|
|
636
|
+
return r.value;
|
|
637
|
+
}
|
|
638
|
+
return;
|
|
639
|
+
};
|
|
629
640
|
/** Current index of a node among its siblings (or roots), or -1 if absent. */
|
|
630
641
|
SemanticTreeModel.prototype.siblingIndexOf = function (id) {
|
|
631
642
|
var node = this._nodesById.get(id);
|
|
@@ -1173,8 +1184,42 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1173
1184
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1174
1185
|
/* harmony export */ AccessibilityOverlay: () => (/* binding */ AccessibilityOverlay)
|
|
1175
1186
|
/* harmony export */ });
|
|
1176
|
-
/* harmony import */ var
|
|
1187
|
+
/* harmony import */ var _claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
|
|
1188
|
+
/* harmony import */ var _utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11);
|
|
1189
|
+
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
|
|
1177
1190
|
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
var warnedUnpositionedWrapper = false;
|
|
1194
|
+
/**
|
|
1195
|
+
* Warns once per page when no positioned element sits at or inside the canvas's
|
|
1196
|
+
* nearest scroll container: the overlay then can't scroll with the canvas. Reads only.
|
|
1197
|
+
*/
|
|
1198
|
+
function warnIfWrapperUnpositioned(canvas) {
|
|
1199
|
+
if (warnedUnpositionedWrapper)
|
|
1200
|
+
return;
|
|
1201
|
+
// Null when detached (or display:none / fixed); nothing to judge yet.
|
|
1202
|
+
var offsetParent = canvas.offsetParent;
|
|
1203
|
+
if (!offsetParent)
|
|
1204
|
+
return;
|
|
1205
|
+
var scrolls = function (v) { return v === "auto" || v === "scroll" || v === "overlay"; };
|
|
1206
|
+
var scroller = null;
|
|
1207
|
+
var el = canvas.parentElement;
|
|
1208
|
+
// Bounds pathological nesting.
|
|
1209
|
+
var MAX_ANCESTOR_WALK = 32;
|
|
1210
|
+
for (var i = 0; el && el !== document.documentElement && i < MAX_ANCESTOR_WALK; i++, el = el.parentElement) {
|
|
1211
|
+
var style = getComputedStyle(el);
|
|
1212
|
+
if (scrolls(style.overflowX) || scrolls(style.overflowY)) {
|
|
1213
|
+
scroller = el;
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
// Only the viewport scrolls: any offsetParent scrolls with the page.
|
|
1218
|
+
if (!scroller || scroller.contains(offsetParent))
|
|
1219
|
+
return;
|
|
1220
|
+
warnedUnpositionedWrapper = true;
|
|
1221
|
+
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.');
|
|
1222
|
+
}
|
|
1178
1223
|
/**
|
|
1179
1224
|
* Creates and manages an invisible DOM tree overlaying a Rive canvas. This is for
|
|
1180
1225
|
* screen readers to discover and interact with the Rive content.
|
|
@@ -1192,7 +1237,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1192
1237
|
var AccessibilityOverlay = /** @class */ (function () {
|
|
1193
1238
|
function AccessibilityOverlay(options) {
|
|
1194
1239
|
var _this = this;
|
|
1195
|
-
var _a;
|
|
1240
|
+
var _a, _b;
|
|
1196
1241
|
this.elements = new Map();
|
|
1197
1242
|
/** Visually-hidden description spans keyed by node ID, referenced by aria-describedby. */
|
|
1198
1243
|
this.descElements = new Map();
|
|
@@ -1202,6 +1247,8 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1202
1247
|
this.pendingTextGeometry = [];
|
|
1203
1248
|
/** Last measured box-size|text key per text element, to skip redundant re-measures. */
|
|
1204
1249
|
this.textGeometryKeys = new WeakMap();
|
|
1250
|
+
/** Node data last passed to applyAttributes per element; see {@link setEditingHostNode}. */
|
|
1251
|
+
this.appliedNodes = new WeakMap();
|
|
1205
1252
|
this.lastCanvasPositioning = {
|
|
1206
1253
|
width: -1, height: -1, offsetTop: -1, offsetLeft: -1,
|
|
1207
1254
|
};
|
|
@@ -1214,6 +1261,10 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1214
1261
|
this._geometryDirty = true;
|
|
1215
1262
|
/** True while reconciling the DOM (reserved for future focus-sync guards). */
|
|
1216
1263
|
this.isUpdating = false;
|
|
1264
|
+
/** Node whose element the editing host stands in for, or null. */
|
|
1265
|
+
this.editingHostNodeId = null;
|
|
1266
|
+
/** Semantic version last folded into the editing host's decoration. */
|
|
1267
|
+
this.editingHostSemanticVersion = -1;
|
|
1217
1268
|
/**
|
|
1218
1269
|
* Single child div of the overlay container that carries the artboard→CSS
|
|
1219
1270
|
* transform. All semantic node elements are children of this div and express
|
|
@@ -1238,9 +1289,116 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1238
1289
|
this.canvas = options.canvas;
|
|
1239
1290
|
this.semanticsOptions = options.semanticsOptions;
|
|
1240
1291
|
this.allowFocusInterrupt = (_a = options.allowFocusInterrupt) !== null && _a !== void 0 ? _a : false;
|
|
1292
|
+
this.isEditingHostFocused = (_b = options.isEditingHostFocused) !== null && _b !== void 0 ? _b : (function () { return false; });
|
|
1241
1293
|
this.container = this.createContainer(options.canvas);
|
|
1242
1294
|
this.attachPositionObservers();
|
|
1295
|
+
warnIfWrapperUnpositioned(options.canvas);
|
|
1243
1296
|
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Hide the stood-in node's element (no duplicate textbox for AT); re-derive the previous
|
|
1299
|
+
* one's aria-hidden.
|
|
1300
|
+
*/
|
|
1301
|
+
AccessibilityOverlay.prototype.setEditingHostNode = function (nodeId) {
|
|
1302
|
+
if (this.editingHostNodeId === nodeId)
|
|
1303
|
+
return;
|
|
1304
|
+
var previous = this.editingHostNodeId;
|
|
1305
|
+
this.editingHostNodeId = nodeId;
|
|
1306
|
+
if (previous !== null) {
|
|
1307
|
+
var previousEl = this.elements.get(previous);
|
|
1308
|
+
// Re-derive rather than un-hide: the node may have become Hidden mid-session.
|
|
1309
|
+
if (previousEl) {
|
|
1310
|
+
var previousNode = this.appliedNodes.get(previousEl);
|
|
1311
|
+
if (previousNode && this.isAriaHidden(previousNode)) {
|
|
1312
|
+
setAttr(previousEl, "aria-hidden", "true");
|
|
1313
|
+
}
|
|
1314
|
+
else {
|
|
1315
|
+
removeAttr(previousEl, "aria-hidden");
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
if (nodeId !== null) {
|
|
1320
|
+
var el = this.elements.get(nodeId);
|
|
1321
|
+
if (el)
|
|
1322
|
+
setAttr(el, "aria-hidden", "true");
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
/**
|
|
1326
|
+
* Describe the focused text field on the host and hide its element; no-op unless
|
|
1327
|
+
* semantics changed.
|
|
1328
|
+
* @param force - apply even if semantics are unchanged (session start).
|
|
1329
|
+
*/
|
|
1330
|
+
AccessibilityOverlay.prototype.syncEditingHost = function (tree, host, force) {
|
|
1331
|
+
var _a;
|
|
1332
|
+
if (!force && tree.semanticVersion === this.editingHostSemanticVersion)
|
|
1333
|
+
return;
|
|
1334
|
+
this.editingHostSemanticVersion = tree.semanticVersion;
|
|
1335
|
+
var node = tree.focusedNode();
|
|
1336
|
+
if (node === undefined || node.role !== _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) {
|
|
1337
|
+
// Nothing to describe; drop the stale description rather than misname the host.
|
|
1338
|
+
if (this.editingHostNodeId !== null) {
|
|
1339
|
+
host.resetDecoration();
|
|
1340
|
+
this.setEditingHostNode(null);
|
|
1341
|
+
}
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
// Every key is passed on every call, nulls included, so nothing survives from
|
|
1345
|
+
// the previously described field.
|
|
1346
|
+
host.setSecure((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Obscured));
|
|
1347
|
+
host.decorate({
|
|
1348
|
+
"aria-label": node.label || null,
|
|
1349
|
+
"aria-readonly": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly) ? "true" : null,
|
|
1350
|
+
"aria-multiline": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Multiline) ? "true" : null,
|
|
1351
|
+
// Trait-gated to match applyAttributes.
|
|
1352
|
+
"aria-required": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Requirable) &&
|
|
1353
|
+
(0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Required)
|
|
1354
|
+
? "true"
|
|
1355
|
+
: null,
|
|
1356
|
+
// The hint span applyAttributes maintains (update() runs earlier in the frame).
|
|
1357
|
+
"aria-describedby": (node.hint && ((_a = this.descElements.get(node.id)) === null || _a === void 0 ? void 0 : _a.id)) || null,
|
|
1358
|
+
});
|
|
1359
|
+
this.setEditingHostNode(node.id);
|
|
1360
|
+
};
|
|
1361
|
+
/** True while the editing host stands in for a node's element. */
|
|
1362
|
+
AccessibilityOverlay.prototype.hasEditingHost = function () {
|
|
1363
|
+
return this.editingHostNodeId !== null;
|
|
1364
|
+
};
|
|
1365
|
+
/**
|
|
1366
|
+
* Undo the stand-in; if the host still has DOM focus, move it to the focused node's
|
|
1367
|
+
* element so AT announces it.
|
|
1368
|
+
*/
|
|
1369
|
+
AccessibilityOverlay.prototype.releaseEditingHost = function (tree, host) {
|
|
1370
|
+
var _a;
|
|
1371
|
+
host === null || host === void 0 ? void 0 : host.resetDecoration();
|
|
1372
|
+
this.setEditingHostNode(null);
|
|
1373
|
+
this.editingHostSemanticVersion = -1;
|
|
1374
|
+
if (!(host === null || host === void 0 ? void 0 : host.hasDomFocus()))
|
|
1375
|
+
return;
|
|
1376
|
+
var focusedNodeId = (_a = tree === null || tree === void 0 ? void 0 : tree.focusedNode()) === null || _a === void 0 ? void 0 : _a.id;
|
|
1377
|
+
if (focusedNodeId !== undefined)
|
|
1378
|
+
this.focusNodeElement(focusedNodeId);
|
|
1379
|
+
};
|
|
1380
|
+
/** Move DOM focus onto a node's element. No-op for a node with no element. */
|
|
1381
|
+
AccessibilityOverlay.prototype.focusNodeElement = function (nodeId) {
|
|
1382
|
+
var el = this.elements.get(nodeId);
|
|
1383
|
+
if (!el)
|
|
1384
|
+
return;
|
|
1385
|
+
this.focusElementInPlace(el);
|
|
1386
|
+
};
|
|
1387
|
+
// The overlay is positioned outside the canvas's scroll chain, so a plain focus()
|
|
1388
|
+
// would scroll the root instead; scroll the canvas into view through its real ancestors.
|
|
1389
|
+
AccessibilityOverlay.prototype.focusElementInPlace = function (el) {
|
|
1390
|
+
var _a, _b;
|
|
1391
|
+
this.syncContainerBeforeFocus();
|
|
1392
|
+
el.focus({ preventScroll: true });
|
|
1393
|
+
(_b = (_a = this.canvas).scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, {
|
|
1394
|
+
block: "nearest",
|
|
1395
|
+
inline: "nearest",
|
|
1396
|
+
behavior: "instant",
|
|
1397
|
+
});
|
|
1398
|
+
// The scroll moved the canvas; re-align now rather than after the observer throttle.
|
|
1399
|
+
this.syncContainerGeometry();
|
|
1400
|
+
this.observePosition();
|
|
1401
|
+
};
|
|
1244
1402
|
AccessibilityOverlay.prototype.getSemanticOverlayContainer = function () {
|
|
1245
1403
|
return this.container;
|
|
1246
1404
|
};
|
|
@@ -1318,15 +1476,16 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1318
1476
|
_this.observePosition();
|
|
1319
1477
|
}, 500); // Throttle to avoid rapid style recalculations
|
|
1320
1478
|
};
|
|
1479
|
+
/** Returns true when the container's size changed (node transforms need recomputing). */
|
|
1321
1480
|
AccessibilityOverlay.prototype.syncContainerGeometry = function () {
|
|
1322
1481
|
var rect = this.canvas.getBoundingClientRect();
|
|
1323
|
-
var
|
|
1324
|
-
var
|
|
1325
|
-
|
|
1326
|
-
|
|
1482
|
+
var _a = (0,_utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__.canvasOffset)(this.canvas), top = _a.top, left = _a.left;
|
|
1483
|
+
var sizeChanged = rect.width !== this.lastCanvasPositioning.width ||
|
|
1484
|
+
rect.height !== this.lastCanvasPositioning.height;
|
|
1485
|
+
if (!sizeChanged &&
|
|
1327
1486
|
top === this.lastCanvasPositioning.offsetTop &&
|
|
1328
1487
|
left === this.lastCanvasPositioning.offsetLeft)
|
|
1329
|
-
return;
|
|
1488
|
+
return false;
|
|
1330
1489
|
this.container.style.top = top + "px";
|
|
1331
1490
|
this.container.style.left = left + "px";
|
|
1332
1491
|
this.container.style.width = rect.width + "px";
|
|
@@ -1336,6 +1495,16 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1336
1495
|
this.lastCanvasPositioning.height = rect.height;
|
|
1337
1496
|
this.lastCanvasPositioning.offsetTop = top;
|
|
1338
1497
|
this.lastCanvasPositioning.offsetLeft = left;
|
|
1498
|
+
return sizeChanged;
|
|
1499
|
+
};
|
|
1500
|
+
/**
|
|
1501
|
+
* Re-align the container right before focusing one of its elements. The position
|
|
1502
|
+
* observer re-syncs after scrolling on a throttle; focusing an element while the
|
|
1503
|
+
* container is stale would make the browser scroll the page to where it sits.
|
|
1504
|
+
*/
|
|
1505
|
+
AccessibilityOverlay.prototype.syncContainerBeforeFocus = function () {
|
|
1506
|
+
if (this.syncContainerGeometry())
|
|
1507
|
+
this._geometryDirty = true;
|
|
1339
1508
|
};
|
|
1340
1509
|
AccessibilityOverlay.prototype.createContainer = function (canvas) {
|
|
1341
1510
|
var _a, _b;
|
|
@@ -1345,10 +1514,13 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1345
1514
|
container.setAttribute("aria-label", (_b = (_a = this.semanticsOptions) === null || _a === void 0 ? void 0 : _a.riveCanvasLabel) !== null && _b !== void 0 ? _b : "Rive animation");
|
|
1346
1515
|
// Size to the canvas's CSS layout box, not the parent container.
|
|
1347
1516
|
var rect = canvas.getBoundingClientRect();
|
|
1517
|
+
var _c = (0,_utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__.canvasOffset)(this.canvas), top = _c.top, left = _c.left;
|
|
1348
1518
|
container.style.cssText = [
|
|
1349
1519
|
"position:absolute",
|
|
1350
|
-
"top:".concat(
|
|
1351
|
-
"left:".concat(
|
|
1520
|
+
"top:".concat(top, "px"),
|
|
1521
|
+
"left:".concat(left, "px"),
|
|
1522
|
+
"line-height:normal",
|
|
1523
|
+
"font-size:16px",
|
|
1352
1524
|
"width:".concat(rect.width, "px"),
|
|
1353
1525
|
"height:".concat(rect.height, "px"),
|
|
1354
1526
|
"overflow:hidden",
|
|
@@ -1525,8 +1697,8 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1525
1697
|
// The cheap trait/state flag checks gate the (per-node) DOM queries below,
|
|
1526
1698
|
// so the activeElement/closest/contains walks only run for a node that is
|
|
1527
1699
|
// actually focusable + focused — not for every node on every frame.
|
|
1528
|
-
if ((0,
|
|
1529
|
-
(0,
|
|
1700
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(nodeData.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable) &&
|
|
1701
|
+
(0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(nodeData.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Focused)) {
|
|
1530
1702
|
var active = document.activeElement;
|
|
1531
1703
|
// While focus is inside one of our modal dialogs, don't pull it back
|
|
1532
1704
|
// out to a background node.
|
|
@@ -1534,8 +1706,16 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1534
1706
|
var trappedByModal = !!focusedModal &&
|
|
1535
1707
|
this.container.contains(focusedModal) &&
|
|
1536
1708
|
!focusedModal.contains(el);
|
|
1537
|
-
|
|
1538
|
-
|
|
1709
|
+
// Not while the proxy has focus (would steal the caret, drop the keyboard) nor onto
|
|
1710
|
+
// its aria-hidden stand-in.
|
|
1711
|
+
if (nodeId !== this.editingHostNodeId &&
|
|
1712
|
+
active !== el &&
|
|
1713
|
+
!trappedByModal &&
|
|
1714
|
+
!this.isEditingHostFocused() &&
|
|
1715
|
+
this.canMoveFocus()) {
|
|
1716
|
+
// No scrollIntoView: this runs on semantic diffs and must not drag the page.
|
|
1717
|
+
this.syncContainerBeforeFocus();
|
|
1718
|
+
el.focus({ preventScroll: true });
|
|
1539
1719
|
}
|
|
1540
1720
|
}
|
|
1541
1721
|
// Recurse into children with this node's absolute artboard position.
|
|
@@ -1674,7 +1854,7 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1674
1854
|
var el = document.createElement(tag);
|
|
1675
1855
|
el.id = "".concat(this.nodeIdPrefix).concat(node.id);
|
|
1676
1856
|
el.style.cssText = BASE_NODE_STYLE;
|
|
1677
|
-
if (node.role ===
|
|
1857
|
+
if (node.role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
|
|
1678
1858
|
// The positioned outer div is the AX element
|
|
1679
1859
|
// VoiceOver uses for its highlight box; an inner <span> carries the text
|
|
1680
1860
|
// without position:absolute (which would strip the span from VoiceOver's
|
|
@@ -1706,7 +1886,7 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1706
1886
|
target = "last";
|
|
1707
1887
|
if (!target)
|
|
1708
1888
|
return;
|
|
1709
|
-
|
|
1889
|
+
(0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
|
|
1710
1890
|
var members = opts.members();
|
|
1711
1891
|
var idx = members.indexOf(el);
|
|
1712
1892
|
if (idx < 0)
|
|
@@ -1717,10 +1897,10 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1717
1897
|
: target === "first" ? members[0]
|
|
1718
1898
|
: members[n - 1];
|
|
1719
1899
|
if (next && next !== el) {
|
|
1720
|
-
|
|
1900
|
+
_this.focusElementInPlace(next);
|
|
1721
1901
|
var nextId = _this.nodeIdFromElement(next);
|
|
1722
1902
|
if (nextId !== null)
|
|
1723
|
-
_this.fireAction(nextId,
|
|
1903
|
+
_this.fireAction(nextId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
|
|
1724
1904
|
}
|
|
1725
1905
|
});
|
|
1726
1906
|
};
|
|
@@ -1730,31 +1910,31 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1730
1910
|
var nodeId = node.id;
|
|
1731
1911
|
if (isClickableRole(role)) {
|
|
1732
1912
|
el.addEventListener("click", function () {
|
|
1733
|
-
_this.fireAction(nodeId,
|
|
1913
|
+
_this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
|
|
1734
1914
|
});
|
|
1735
1915
|
// Links activate on Enter only (Space scrolls the page per browser
|
|
1736
1916
|
// convention). All other clickable roles accept both Enter and Space.
|
|
1737
|
-
var activationKeys_1 = role ===
|
|
1917
|
+
var activationKeys_1 = role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link ? ["Enter"] : ["Enter", " "];
|
|
1738
1918
|
el.addEventListener("keydown", function (e) {
|
|
1739
1919
|
if (activationKeys_1.includes(e.key)) {
|
|
1740
|
-
|
|
1741
|
-
_this.fireAction(nodeId,
|
|
1920
|
+
(0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
|
|
1921
|
+
_this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
|
|
1742
1922
|
}
|
|
1743
1923
|
});
|
|
1744
1924
|
}
|
|
1745
|
-
if (role ===
|
|
1925
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider) {
|
|
1746
1926
|
el.addEventListener("keydown", function (e) {
|
|
1747
1927
|
if (e.key === "ArrowRight" || e.key === "ArrowUp") {
|
|
1748
|
-
|
|
1749
|
-
_this.fireAction(nodeId,
|
|
1928
|
+
(0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
|
|
1929
|
+
_this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.increase);
|
|
1750
1930
|
}
|
|
1751
1931
|
else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
|
|
1752
|
-
|
|
1753
|
-
_this.fireAction(nodeId,
|
|
1932
|
+
(0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
|
|
1933
|
+
_this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.decrease);
|
|
1754
1934
|
}
|
|
1755
1935
|
});
|
|
1756
1936
|
}
|
|
1757
|
-
if (role ===
|
|
1937
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab) {
|
|
1758
1938
|
this.attachRovingNav(el, {
|
|
1759
1939
|
includeHomeEnd: true,
|
|
1760
1940
|
members: function () {
|
|
@@ -1767,7 +1947,7 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1767
1947
|
},
|
|
1768
1948
|
});
|
|
1769
1949
|
}
|
|
1770
|
-
if (role ===
|
|
1950
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton) {
|
|
1771
1951
|
this.attachRovingNav(el, {
|
|
1772
1952
|
includeHomeEnd: false,
|
|
1773
1953
|
members: function () {
|
|
@@ -1782,15 +1962,31 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1782
1962
|
// Focus handler for nodes with the Focusable trait. When AT focuses an
|
|
1783
1963
|
// element, notify the C++ runtime so it can update internal focus state
|
|
1784
1964
|
// (visual focus rings, etc.). Gated on Focusable trait
|
|
1785
|
-
if ((0,
|
|
1965
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable)) {
|
|
1786
1966
|
el.addEventListener("focus", function () {
|
|
1787
1967
|
_this.requestFocus(nodeId);
|
|
1788
1968
|
});
|
|
1789
1969
|
}
|
|
1790
1970
|
};
|
|
1791
1971
|
// ---- Attribute application ----
|
|
1972
|
+
AccessibilityOverlay.prototype.isAriaHidden = function (node) {
|
|
1973
|
+
var role = node.role;
|
|
1974
|
+
var flags = node.stateFlags;
|
|
1975
|
+
// Hide from AT when explicitly hidden, or when an image has no accessible
|
|
1976
|
+
// name — a nameless role="img" is a WCAG 1.1.1 violation; treat it as
|
|
1977
|
+
// decorative instead.
|
|
1978
|
+
var isDecorativeImage = role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.image && !node.label;
|
|
1979
|
+
// The <input> proxy is the accessible element for the node it stands in for.
|
|
1980
|
+
var isEditingHostStandIn = node.id === this.editingHostNodeId;
|
|
1981
|
+
return ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Hidden) ||
|
|
1982
|
+
// Obscured text fields stay reachable (value withheld, like a native password input).
|
|
1983
|
+
((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Obscured) && role !== _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) ||
|
|
1984
|
+
isDecorativeImage ||
|
|
1985
|
+
isEditingHostStandIn);
|
|
1986
|
+
};
|
|
1792
1987
|
AccessibilityOverlay.prototype.applyAttributes = function (el, node) {
|
|
1793
1988
|
var _a, _b, _c;
|
|
1989
|
+
this.appliedNodes.set(el, node);
|
|
1794
1990
|
var role = node.role;
|
|
1795
1991
|
var flags = node.stateFlags;
|
|
1796
1992
|
var traits = node.traitFlags;
|
|
@@ -1804,7 +2000,7 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1804
2000
|
}
|
|
1805
2001
|
// Links: a bare <a> with no href has no link semantics, so set the role
|
|
1806
2002
|
// explicitly (ariaRoleForSemantic returns null for link → native <a>).
|
|
1807
|
-
if (role ===
|
|
2003
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link) {
|
|
1808
2004
|
setAttr(el, "role", "link");
|
|
1809
2005
|
}
|
|
1810
2006
|
// Tabindex — keep the screen-reader overlay out of the browser's sequential
|
|
@@ -1812,8 +2008,8 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1812
2008
|
// so AT/runtime focus sync can still target them when needed. List items are
|
|
1813
2009
|
// included because Mobile Safari won't iterate them otherwise.
|
|
1814
2010
|
if (isInteractiveRole(role) ||
|
|
1815
|
-
(0,
|
|
1816
|
-
role ===
|
|
2011
|
+
(0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable) ||
|
|
2012
|
+
role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.listItem) {
|
|
1817
2013
|
setAttr(el, "tabindex", "-1");
|
|
1818
2014
|
}
|
|
1819
2015
|
else {
|
|
@@ -1826,7 +2022,7 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1826
2022
|
else {
|
|
1827
2023
|
removeAttr(el, "aria-label");
|
|
1828
2024
|
}
|
|
1829
|
-
if (role ===
|
|
2025
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider) {
|
|
1830
2026
|
if (node.value) {
|
|
1831
2027
|
// aria-valuenow must be numeric; keep the display string (e.g. "75%")
|
|
1832
2028
|
// in aria-valuetext only.
|
|
@@ -1846,7 +2042,7 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1846
2042
|
// TODO: aria-valuemin / aria-valuemax are required by ARIA.
|
|
1847
2043
|
// Defaulting to horizontal; vertical sliders need orientation data from C++.
|
|
1848
2044
|
setAttr(el, "aria-orientation", "horizontal");
|
|
1849
|
-
setBoolAttr(el, "aria-readonly", (0,
|
|
2045
|
+
setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly));
|
|
1850
2046
|
}
|
|
1851
2047
|
else {
|
|
1852
2048
|
removeAttr(el, "aria-valuenow");
|
|
@@ -1880,7 +2076,7 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1880
2076
|
// Text nodes: use textContent rather than aria-label so screen readers
|
|
1881
2077
|
// announce the text in virtual/browse mode (aria-label on a bare <span>
|
|
1882
2078
|
// with no widget role is ignored by some AT in document browse mode).
|
|
1883
|
-
if (role ===
|
|
2079
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
|
|
1884
2080
|
var textSpan = (_a = el.querySelector(":scope > span")) !== null && _a !== void 0 ? _a : el;
|
|
1885
2081
|
var text = (_b = node.label) !== null && _b !== void 0 ? _b : "";
|
|
1886
2082
|
if (textSpan.textContent !== text)
|
|
@@ -1900,77 +2096,73 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1900
2096
|
// Only set the ARIA property when the trait is present. When the trait
|
|
1901
2097
|
// is absent, remove the attribute so AT sees "not applicable" rather
|
|
1902
2098
|
// than "false".
|
|
1903
|
-
if ((0,
|
|
1904
|
-
setBoolAttr(el, "aria-expanded", (0,
|
|
2099
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Expandable) && ARIA_EXPANDED_ROLES.has(role)) {
|
|
2100
|
+
setBoolAttr(el, "aria-expanded", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Expanded));
|
|
1905
2101
|
}
|
|
1906
2102
|
else {
|
|
1907
2103
|
removeAttr(el, "aria-expanded");
|
|
1908
2104
|
}
|
|
1909
2105
|
// aria-selected is required on ALL tabs per ARIA spec regardless of trait;
|
|
1910
2106
|
// for other roles it is trait-gated and guarded to ARIA_SELECTED_ROLES.
|
|
1911
|
-
if (role ===
|
|
1912
|
-
setBoolAttr(el, "aria-selected", (0,
|
|
2107
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab) {
|
|
2108
|
+
setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Selected));
|
|
1913
2109
|
}
|
|
1914
|
-
else if ((0,
|
|
1915
|
-
setBoolAttr(el, "aria-selected", (0,
|
|
2110
|
+
else if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Selectable) && ARIA_SELECTED_ROLES.has(role)) {
|
|
2111
|
+
setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Selected));
|
|
1916
2112
|
}
|
|
1917
2113
|
else {
|
|
1918
2114
|
removeAttr(el, "aria-selected");
|
|
1919
2115
|
}
|
|
1920
|
-
if ((0,
|
|
2116
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Checkable) && ARIA_CHECKED_ROLES.has(role)) {
|
|
1921
2117
|
// Check state is a tri-state field, but not every checkable role
|
|
1922
2118
|
// accepts all three values — see ARIA_MIXED_ROLES.
|
|
1923
|
-
var checkState = (0,
|
|
1924
|
-
if (checkState ===
|
|
2119
|
+
var checkState = (0,_types__WEBPACK_IMPORTED_MODULE_2__.checkStateOf)(flags);
|
|
2120
|
+
if (checkState === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticCheckState.Mixed &&
|
|
1925
2121
|
ARIA_MIXED_ROLES.has(role)) {
|
|
1926
2122
|
setAttr(el, "aria-checked", "mixed");
|
|
1927
2123
|
}
|
|
1928
2124
|
else {
|
|
1929
|
-
setBoolAttr(el, "aria-checked", checkState ===
|
|
2125
|
+
setBoolAttr(el, "aria-checked", checkState === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticCheckState.Checked);
|
|
1930
2126
|
}
|
|
1931
2127
|
}
|
|
1932
2128
|
else {
|
|
1933
2129
|
removeAttr(el, "aria-checked");
|
|
1934
2130
|
}
|
|
1935
|
-
if ((0,
|
|
2131
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Toggleable)) {
|
|
1936
2132
|
if (ARIA_PRESSED_ROLES.has(role)) {
|
|
1937
|
-
setBoolAttr(el, "aria-pressed", (0,
|
|
2133
|
+
setBoolAttr(el, "aria-pressed", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Toggled));
|
|
1938
2134
|
}
|
|
1939
2135
|
else {
|
|
1940
2136
|
removeAttr(el, "aria-pressed");
|
|
1941
2137
|
}
|
|
1942
2138
|
// switch uses aria-checked (not aria-pressed) for its on/off state.
|
|
1943
|
-
if (role ===
|
|
1944
|
-
setBoolAttr(el, "aria-checked", (0,
|
|
2139
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl) {
|
|
2140
|
+
setBoolAttr(el, "aria-checked", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Toggled));
|
|
1945
2141
|
}
|
|
1946
2142
|
}
|
|
1947
2143
|
else {
|
|
1948
2144
|
removeAttr(el, "aria-pressed");
|
|
1949
2145
|
}
|
|
1950
|
-
if ((0,
|
|
1951
|
-
setBoolAttr(el, "aria-required", (0,
|
|
2146
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Requirable) && ARIA_REQUIRED_ROLES.has(role)) {
|
|
2147
|
+
setBoolAttr(el, "aria-required", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Required));
|
|
1952
2148
|
}
|
|
1953
2149
|
else {
|
|
1954
2150
|
removeAttr(el, "aria-required");
|
|
1955
2151
|
}
|
|
1956
|
-
if ((0,
|
|
1957
|
-
setBoolAttr(el, "aria-disabled", (0,
|
|
2152
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Enablable)) {
|
|
2153
|
+
setBoolAttr(el, "aria-disabled", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Disabled));
|
|
1958
2154
|
}
|
|
1959
2155
|
else {
|
|
1960
2156
|
removeAttr(el, "aria-disabled");
|
|
1961
2157
|
}
|
|
1962
2158
|
// ---- Non-trait states ----
|
|
1963
|
-
|
|
1964
|
-
// name — a nameless role="img" is a WCAG 1.1.1 violation; treat it as
|
|
1965
|
-
// decorative instead.
|
|
1966
|
-
var isDecorativeImage = role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.image && !node.label;
|
|
1967
|
-
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) {
|
|
2159
|
+
if (this.isAriaHidden(node)) {
|
|
1968
2160
|
setAttr(el, "aria-hidden", "true");
|
|
1969
2161
|
}
|
|
1970
2162
|
else {
|
|
1971
2163
|
removeAttr(el, "aria-hidden");
|
|
1972
2164
|
}
|
|
1973
|
-
if ((0,
|
|
2165
|
+
if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.LiveRegion)) {
|
|
1974
2166
|
setAttr(el, "aria-live", "polite");
|
|
1975
2167
|
}
|
|
1976
2168
|
else {
|
|
@@ -1978,17 +2170,26 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
1978
2170
|
}
|
|
1979
2171
|
// textField-specific
|
|
1980
2172
|
// TODO: Details here may change once we implement text inputs
|
|
1981
|
-
if (role ===
|
|
1982
|
-
setBoolAttr(el, "aria-readonly", (0,
|
|
1983
|
-
setBoolAttr(el, "aria-multiline", (0,
|
|
2173
|
+
if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) {
|
|
2174
|
+
setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly));
|
|
2175
|
+
setBoolAttr(el, "aria-multiline", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Multiline));
|
|
1984
2176
|
// Surface the current field value as DOM text so screen readers can
|
|
1985
2177
|
// announce it. Only safe when the node has no semantic children —
|
|
1986
2178
|
// setting textContent would remove any child elements from the DOM.
|
|
1987
2179
|
if (node.children.length === 0) {
|
|
1988
|
-
var value = (_c = node.value) !== null && _c !== void 0 ? _c : "";
|
|
2180
|
+
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 : "");
|
|
1989
2181
|
if (el.textContent !== value)
|
|
1990
2182
|
el.textContent = value;
|
|
1991
2183
|
}
|
|
2184
|
+
else {
|
|
2185
|
+
// A value rendered earlier (before the node had children) must not linger,
|
|
2186
|
+
// least of all once the field turns Obscured.
|
|
2187
|
+
for (var _i = 0, _d = Array.from(el.childNodes); _i < _d.length; _i++) {
|
|
2188
|
+
var child = _d[_i];
|
|
2189
|
+
if (child.nodeType === Node.TEXT_NODE)
|
|
2190
|
+
child.remove();
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
1992
2193
|
}
|
|
1993
2194
|
else {
|
|
1994
2195
|
removeAttr(el, "aria-multiline");
|
|
@@ -2052,7 +2253,7 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
2052
2253
|
// Clear any CSS transform from a previous render pass.
|
|
2053
2254
|
if (el.style.transform)
|
|
2054
2255
|
el.style.transform = "";
|
|
2055
|
-
if (node.role ===
|
|
2256
|
+
if (node.role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
|
|
2056
2257
|
this.pendingTextGeometry.push(el);
|
|
2057
2258
|
}
|
|
2058
2259
|
};
|
|
@@ -2111,7 +2312,8 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
2111
2312
|
* Creates (on first call) and updates the artboard-space transform container.
|
|
2112
2313
|
*
|
|
2113
2314
|
* The container is sized to the artboard dimensions and carries a CSS
|
|
2114
|
-
* `transform: matrix(...)`
|
|
2315
|
+
* `transform: matrix(...)` that maps artboard coordinates to the canvas's CSS box
|
|
2316
|
+
* (forwardMat in backing-store pixels, scaled by CSS size / backing-store size). All semantic
|
|
2115
2317
|
* node elements are children of this container and use raw artboard
|
|
2116
2318
|
* coordinates as their CSS `left/top/width/height`, so the CSS compositor
|
|
2117
2319
|
* applies the artboard→screen mapping in one pass.
|
|
@@ -2136,13 +2338,20 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
2136
2338
|
var h = artboardBounds.maxY - artboardBounds.minY;
|
|
2137
2339
|
this.transformContainer.style.width = Math.round(w) + "px";
|
|
2138
2340
|
this.transformContainer.style.height = Math.round(h) + "px";
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
var
|
|
2143
|
-
var
|
|
2144
|
-
var
|
|
2145
|
-
var
|
|
2341
|
+
// Backing-store pixels → CSS pixels. Measured rather than 1/dpr: a canvas can be
|
|
2342
|
+
// stretched by CSS, or have a stale backing store after a resize, and the drawn
|
|
2343
|
+
// content follows the CSS box either way. Equal to 1/dpr when they match.
|
|
2344
|
+
var cssWidth = this.lastCanvasPositioning.width;
|
|
2345
|
+
var cssHeight = this.lastCanvasPositioning.height;
|
|
2346
|
+
var fallback = 1 / (dpr || 1);
|
|
2347
|
+
var sx = this.canvas.width > 0 && cssWidth > 0 ? cssWidth / this.canvas.width : fallback;
|
|
2348
|
+
var sy = this.canvas.height > 0 && cssHeight > 0 ? cssHeight / this.canvas.height : fallback;
|
|
2349
|
+
var a = forwardMat.xx * sx;
|
|
2350
|
+
var b = forwardMat.xy * sy;
|
|
2351
|
+
var c = forwardMat.yx * sx;
|
|
2352
|
+
var d = forwardMat.yy * sy;
|
|
2353
|
+
var tx = forwardMat.tx * sx;
|
|
2354
|
+
var ty = forwardMat.ty * sy;
|
|
2146
2355
|
this.transformContainer.style.transform =
|
|
2147
2356
|
"matrix(".concat(a, ",").concat(b, ",").concat(c, ",").concat(d, ",").concat(tx, ",").concat(ty, ")");
|
|
2148
2357
|
};
|
|
@@ -2165,11 +2374,11 @@ var AccessibilityOverlay = /** @class */ (function () {
|
|
|
2165
2374
|
// ---------------------------------------------------------------------------
|
|
2166
2375
|
/** aria-expanded: button, link, checkbox, switch (inherits button), tab. */
|
|
2167
2376
|
var ARIA_EXPANDED_ROLES = new Set([
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2377
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button,
|
|
2378
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link,
|
|
2379
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
|
|
2380
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl,
|
|
2381
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab,
|
|
2173
2382
|
]);
|
|
2174
2383
|
/**
|
|
2175
2384
|
* aria-selected: tab is the only role in our current set that natively
|
|
@@ -2178,13 +2387,13 @@ var ARIA_EXPANDED_ROLES = new Set([
|
|
|
2178
2387
|
* the set still lists it so the constraint is visible in one place.
|
|
2179
2388
|
*/
|
|
2180
2389
|
var ARIA_SELECTED_ROLES = new Set([
|
|
2181
|
-
|
|
2390
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab,
|
|
2182
2391
|
]);
|
|
2183
2392
|
/** aria-checked: checkbox, radio, switch. */
|
|
2184
2393
|
var ARIA_CHECKED_ROLES = new Set([
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2394
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
|
|
2395
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton,
|
|
2396
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl,
|
|
2188
2397
|
]);
|
|
2189
2398
|
/**
|
|
2190
2399
|
* aria-checked="mixed": checkbox only. ARIA defines checkbox as three-valued
|
|
@@ -2193,7 +2402,7 @@ var ARIA_CHECKED_ROLES = new Set([
|
|
|
2193
2402
|
* emitting a value they do not support.
|
|
2194
2403
|
*/
|
|
2195
2404
|
var ARIA_MIXED_ROLES = new Set([
|
|
2196
|
-
|
|
2405
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
|
|
2197
2406
|
]);
|
|
2198
2407
|
/**
|
|
2199
2408
|
* aria-pressed: button only. switch is a button subclass in ARIA but uses
|
|
@@ -2201,13 +2410,13 @@ var ARIA_MIXED_ROLES = new Set([
|
|
|
2201
2410
|
* excluded here and handled separately in the Toggleable block.
|
|
2202
2411
|
*/
|
|
2203
2412
|
var ARIA_PRESSED_ROLES = new Set([
|
|
2204
|
-
|
|
2413
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button,
|
|
2205
2414
|
]);
|
|
2206
2415
|
/** aria-required: checkbox, textbox, radiogroup. */
|
|
2207
2416
|
var ARIA_REQUIRED_ROLES = new Set([
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2417
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
|
|
2418
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField,
|
|
2419
|
+
_types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioGroup,
|
|
2211
2420
|
]);
|
|
2212
2421
|
// ---------------------------------------------------------------------------
|
|
2213
2422
|
/** Style for visually-hidden description spans used with aria-describedby. */
|
|
@@ -2256,12 +2465,12 @@ function setBoolAttr(el, attr, value) {
|
|
|
2256
2465
|
/** Roles that receive click/Enter/Space action handlers. */
|
|
2257
2466
|
function isClickableRole(role) {
|
|
2258
2467
|
switch (role) {
|
|
2259
|
-
case
|
|
2260
|
-
case
|
|
2261
|
-
case
|
|
2262
|
-
case
|
|
2263
|
-
case
|
|
2264
|
-
case
|
|
2468
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
|
|
2469
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
|
|
2470
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
|
|
2471
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
|
|
2472
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
|
|
2473
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
|
|
2265
2474
|
return true;
|
|
2266
2475
|
default:
|
|
2267
2476
|
return false;
|
|
@@ -2270,14 +2479,14 @@ function isClickableRole(role) {
|
|
|
2270
2479
|
/** Roles that receive tabindex="-1" for programmatic/AT focus (not Tab order). */
|
|
2271
2480
|
function isInteractiveRole(role) {
|
|
2272
2481
|
switch (role) {
|
|
2273
|
-
case
|
|
2274
|
-
case
|
|
2275
|
-
case
|
|
2276
|
-
case
|
|
2277
|
-
case
|
|
2278
|
-
case
|
|
2279
|
-
case
|
|
2280
|
-
case
|
|
2482
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
|
|
2483
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
|
|
2484
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
|
|
2485
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
|
|
2486
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider:
|
|
2487
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
|
|
2488
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
|
|
2489
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField:
|
|
2281
2490
|
return true;
|
|
2282
2491
|
default:
|
|
2283
2492
|
return false;
|
|
@@ -2288,13 +2497,13 @@ function isInteractiveRole(role) {
|
|
|
2288
2497
|
* dialog only when the Modal state flag is set.
|
|
2289
2498
|
*/
|
|
2290
2499
|
function isModalDialogRole(role, flags) {
|
|
2291
|
-
return (role ===
|
|
2292
|
-
(role ===
|
|
2500
|
+
return (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.alertDialog ||
|
|
2501
|
+
(role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.dialog && (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Modal)));
|
|
2293
2502
|
}
|
|
2294
2503
|
/** Whether a node can receive focus: an interactive role or the Focusable trait. */
|
|
2295
2504
|
function isFocusableNode(node) {
|
|
2296
2505
|
return (isInteractiveRole(node.role) ||
|
|
2297
|
-
(0,
|
|
2506
|
+
(0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable));
|
|
2298
2507
|
}
|
|
2299
2508
|
/**
|
|
2300
2509
|
* Choose an HTML tag for a given role. Prefer native semantic elements
|
|
@@ -2303,9 +2512,9 @@ function isFocusableNode(node) {
|
|
|
2303
2512
|
*/
|
|
2304
2513
|
function tagForRole(role) {
|
|
2305
2514
|
switch (role) {
|
|
2306
|
-
case
|
|
2515
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
|
|
2307
2516
|
return "a";
|
|
2308
|
-
case
|
|
2517
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text:
|
|
2309
2518
|
// The outer div is the positioned AX element VoiceOver measures for its
|
|
2310
2519
|
// highlight box. The text itself lives in a child <span> (see createElement).
|
|
2311
2520
|
return "div";
|
|
@@ -2321,43 +2530,43 @@ function tagForRole(role) {
|
|
|
2321
2530
|
*/
|
|
2322
2531
|
function ariaRoleForSemantic(role) {
|
|
2323
2532
|
switch (role) {
|
|
2324
|
-
case
|
|
2533
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.none:
|
|
2325
2534
|
// TODO: Role "none" removes the node from the accessibility tree. For now, setting to Group, but maybe we want to switch to "none"
|
|
2326
2535
|
// or "presentation".
|
|
2327
2536
|
return "group";
|
|
2328
|
-
case
|
|
2537
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
|
|
2329
2538
|
return "button";
|
|
2330
|
-
case
|
|
2539
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
|
|
2331
2540
|
return null; // native <a>
|
|
2332
|
-
case
|
|
2541
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
|
|
2333
2542
|
return "checkbox";
|
|
2334
|
-
case
|
|
2543
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
|
|
2335
2544
|
return "switch";
|
|
2336
|
-
case
|
|
2545
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider:
|
|
2337
2546
|
return "slider";
|
|
2338
|
-
case
|
|
2547
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField:
|
|
2339
2548
|
return "textbox";
|
|
2340
|
-
case
|
|
2549
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.image:
|
|
2341
2550
|
return "img";
|
|
2342
|
-
case
|
|
2551
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.group:
|
|
2343
2552
|
return "group";
|
|
2344
|
-
case
|
|
2553
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.list:
|
|
2345
2554
|
return "list";
|
|
2346
|
-
case
|
|
2555
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.listItem:
|
|
2347
2556
|
return "listitem";
|
|
2348
|
-
case
|
|
2557
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
|
|
2349
2558
|
return "tab";
|
|
2350
|
-
case
|
|
2559
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tabList:
|
|
2351
2560
|
return "tablist";
|
|
2352
|
-
case
|
|
2561
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.dialog:
|
|
2353
2562
|
return "dialog";
|
|
2354
|
-
case
|
|
2563
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.alertDialog:
|
|
2355
2564
|
return "alertdialog";
|
|
2356
|
-
case
|
|
2565
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioGroup:
|
|
2357
2566
|
return "radiogroup";
|
|
2358
|
-
case
|
|
2567
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
|
|
2359
2568
|
return "radio";
|
|
2360
|
-
case
|
|
2569
|
+
case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text:
|
|
2361
2570
|
// Text nodes use <span>; heading role is applied separately
|
|
2362
2571
|
// when headingLevel > 0.
|
|
2363
2572
|
return null;
|
|
@@ -2371,6 +2580,56 @@ function ariaRoleForSemantic(role) {
|
|
|
2371
2580
|
/* 10 */
|
|
2372
2581
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2373
2582
|
|
|
2583
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2584
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2585
|
+
/* harmony export */ claimKeyEvent: () => (/* binding */ claimKeyEvent),
|
|
2586
|
+
/* harmony export */ isKeyEventClaimed: () => (/* binding */ isKeyEventClaimed)
|
|
2587
|
+
/* harmony export */ });
|
|
2588
|
+
var claimed = new WeakSet();
|
|
2589
|
+
/**
|
|
2590
|
+
* Marks a key event as handled by a semantic overlay widget (and prevents its
|
|
2591
|
+
* default), so the Rive keyboard handler leaves it alone. A plain
|
|
2592
|
+
* `defaultPrevented` check can't tell these apart from host-page handlers.
|
|
2593
|
+
*/
|
|
2594
|
+
function claimKeyEvent(event) {
|
|
2595
|
+
event.preventDefault();
|
|
2596
|
+
claimed.add(event);
|
|
2597
|
+
}
|
|
2598
|
+
function isKeyEventClaimed(event) {
|
|
2599
|
+
return claimed.has(event);
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
|
|
2603
|
+
/***/ }),
|
|
2604
|
+
/* 11 */
|
|
2605
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2606
|
+
|
|
2607
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2608
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2609
|
+
/* harmony export */ canvasOffset: () => (/* binding */ canvasOffset)
|
|
2610
|
+
/* harmony export */ });
|
|
2611
|
+
/**
|
|
2612
|
+
* Canvas offset within its offsetParent, minus the scroll of ancestors in between (they
|
|
2613
|
+
* move the canvas, not absolutely positioned siblings).
|
|
2614
|
+
*/
|
|
2615
|
+
function canvasOffset(canvas) {
|
|
2616
|
+
var top = canvas.offsetTop;
|
|
2617
|
+
var left = canvas.offsetLeft;
|
|
2618
|
+
var offsetParent = canvas.offsetParent;
|
|
2619
|
+
if (!offsetParent)
|
|
2620
|
+
return { top: top, left: left };
|
|
2621
|
+
for (var el = canvas.parentElement; el && el !== offsetParent; el = el.parentElement) {
|
|
2622
|
+
top -= el.scrollTop;
|
|
2623
|
+
left -= el.scrollLeft;
|
|
2624
|
+
}
|
|
2625
|
+
return { top: top, left: left };
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
|
|
2629
|
+
/***/ }),
|
|
2630
|
+
/* 12 */
|
|
2631
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2632
|
+
|
|
2374
2633
|
__webpack_require__.r(__webpack_exports__);
|
|
2375
2634
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2376
2635
|
/* harmony export */ AudioAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.AudioAssetWrapper),
|
|
@@ -2391,11 +2650,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2391
2650
|
/* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
|
|
2392
2651
|
/* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)
|
|
2393
2652
|
/* harmony export */ });
|
|
2394
|
-
/* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
2395
|
-
/* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
2396
|
-
/* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
2397
|
-
/* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
2398
|
-
/* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
2653
|
+
/* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
|
|
2654
|
+
/* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
|
|
2655
|
+
/* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
|
|
2656
|
+
/* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(18);
|
|
2657
|
+
/* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(19);
|
|
2399
2658
|
|
|
2400
2659
|
|
|
2401
2660
|
|
|
@@ -2404,7 +2663,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2404
2663
|
|
|
2405
2664
|
|
|
2406
2665
|
/***/ }),
|
|
2407
|
-
/*
|
|
2666
|
+
/* 13 */
|
|
2408
2667
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2409
2668
|
|
|
2410
2669
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -2483,7 +2742,7 @@ var getClientCoordinates = function (event, isTouchScrollEnabled, enableMultiTou
|
|
|
2483
2742
|
* the state machine pointer move/up/down functions based on cursor interaction
|
|
2484
2743
|
*/
|
|
2485
2744
|
var registerTouchInteractions = function (_a) {
|
|
2486
|
-
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;
|
|
2745
|
+
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;
|
|
2487
2746
|
if (!canvas ||
|
|
2488
2747
|
!stateMachines.length ||
|
|
2489
2748
|
!renderer ||
|
|
@@ -2503,8 +2762,10 @@ var registerTouchInteractions = function (_a) {
|
|
|
2503
2762
|
* We're keeping track of the previous event to not send the synthetic mouse events if the
|
|
2504
2763
|
* touch event was a click (touchstart -> touchend).
|
|
2505
2764
|
*
|
|
2506
|
-
*
|
|
2507
|
-
*
|
|
2765
|
+
* Emulated events only occur when `isTouchScrollEnabled` is true; when false,
|
|
2766
|
+
* touchstart is default-prevented, which suppresses them.
|
|
2767
|
+
* Emulated mousedown is prevented while the proxy is focused, or it would blur it and
|
|
2768
|
+
* drop the keyboard.
|
|
2508
2769
|
**/
|
|
2509
2770
|
var _prevEventType = null;
|
|
2510
2771
|
var _syntheticEventsActive = false;
|
|
@@ -2521,6 +2782,9 @@ var registerTouchInteractions = function (_a) {
|
|
|
2521
2782
|
// https://stackoverflow.com/questions/9656990/how-to-prevent-simulated-mouse-events-in-mobile-browsers
|
|
2522
2783
|
// https://stackoverflow.com/questions/25572070/javascript-touchend-versus-click-dilemma
|
|
2523
2784
|
if (_syntheticEventsActive && event instanceof MouseEvent) {
|
|
2785
|
+
if (event.type === "mousedown" && (isTextProxyFocused === null || isTextProxyFocused === void 0 ? void 0 : isTextProxyFocused())) {
|
|
2786
|
+
event.preventDefault();
|
|
2787
|
+
}
|
|
2524
2788
|
// Synthetic event finished
|
|
2525
2789
|
if (event.type == "mouseup") {
|
|
2526
2790
|
_syntheticEventsActive = false;
|
|
@@ -2627,7 +2891,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
2627
2891
|
_loop_3(stateMachine);
|
|
2628
2892
|
}
|
|
2629
2893
|
// Advance the state machine immediately so pointer down(s) takes effect synchronously
|
|
2630
|
-
advanceAndDrain(0);
|
|
2894
|
+
advanceAndDrain(0, { pointerDown: true });
|
|
2631
2895
|
break;
|
|
2632
2896
|
}
|
|
2633
2897
|
// Pointer click released on the canvas
|
|
@@ -2644,6 +2908,9 @@ var registerTouchInteractions = function (_a) {
|
|
|
2644
2908
|
}
|
|
2645
2909
|
// Advance the state machine immediately so pointer up(s) takes effect synchronously
|
|
2646
2910
|
advanceAndDrain(0);
|
|
2911
|
+
// Still inside the touch gesture — summon the keyboard if the tap focused a
|
|
2912
|
+
// text input
|
|
2913
|
+
summonKeyboard === null || summonKeyboard === void 0 ? void 0 : summonKeyboard();
|
|
2647
2914
|
// Release the primary touch lock once that finger lifts so the next
|
|
2648
2915
|
// touchstart can claim a new primary finger.
|
|
2649
2916
|
if (!enableMultiTouch &&
|
|
@@ -2664,6 +2931,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
2664
2931
|
}
|
|
2665
2932
|
// Advance the state machine immediately so pointer up(s) takes effect synchronously
|
|
2666
2933
|
advanceAndDrain(0);
|
|
2934
|
+
summonKeyboard === null || summonKeyboard === void 0 ? void 0 : summonKeyboard();
|
|
2667
2935
|
break;
|
|
2668
2936
|
}
|
|
2669
2937
|
default:
|
|
@@ -2701,7 +2969,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
2701
2969
|
|
|
2702
2970
|
|
|
2703
2971
|
/***/ }),
|
|
2704
|
-
/*
|
|
2972
|
+
/* 14 */
|
|
2705
2973
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2706
2974
|
|
|
2707
2975
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -2709,6 +2977,43 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2709
2977
|
/* harmony export */ FocusSessionState: () => (/* binding */ FocusSessionState),
|
|
2710
2978
|
/* harmony export */ KeyboardInteractions: () => (/* binding */ KeyboardInteractions)
|
|
2711
2979
|
/* harmony export */ });
|
|
2980
|
+
/* harmony import */ var _keyMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
|
|
2981
|
+
/* harmony import */ var _semantics_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
|
|
2982
|
+
/* harmony import */ var _textInputProxy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
|
|
2983
|
+
|
|
2984
|
+
|
|
2985
|
+
|
|
2986
|
+
/**
|
|
2987
|
+
* Defaults suppressed while typing (scroll/navigate/submit). Tab is traversal's; proxy
|
|
2988
|
+
* Space returns earlier as a printable.
|
|
2989
|
+
*/
|
|
2990
|
+
var EDITING_NAV_CODES = new Set([
|
|
2991
|
+
"Space",
|
|
2992
|
+
"ArrowLeft",
|
|
2993
|
+
"ArrowRight",
|
|
2994
|
+
"ArrowUp",
|
|
2995
|
+
"ArrowDown",
|
|
2996
|
+
"Backspace",
|
|
2997
|
+
"Delete",
|
|
2998
|
+
"Home",
|
|
2999
|
+
"End",
|
|
3000
|
+
"Enter",
|
|
3001
|
+
"NumpadEnter",
|
|
3002
|
+
]);
|
|
3003
|
+
/** A keystroke that types a character (not a Ctrl/Cmd shortcut). */
|
|
3004
|
+
function isPrintable(event) {
|
|
3005
|
+
return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
|
|
3006
|
+
}
|
|
3007
|
+
function isArrowKey(key) {
|
|
3008
|
+
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);
|
|
3009
|
+
}
|
|
3010
|
+
/**
|
|
3011
|
+
* Alt/Ctrl/Meta arrows are browser/OS shortcuts (Alt+Left = back, Cmd+Arrow, etc.).
|
|
3012
|
+
* Shift is allowed: it is the spatial-navigation chord in Vivaldi/Opera.
|
|
3013
|
+
*/
|
|
3014
|
+
function hasShortcutModifier(event) {
|
|
3015
|
+
return event.altKey || event.ctrlKey || event.metaKey;
|
|
3016
|
+
}
|
|
2712
3017
|
/**
|
|
2713
3018
|
* Tracks the relationship between DOM focus inside this Rive focus domain (canvas or semantic overlay)
|
|
2714
3019
|
* and Rive's internal focus for the current focus session.
|
|
@@ -2734,7 +3039,8 @@ var FocusSessionState;
|
|
|
2734
3039
|
FocusSessionState["RiveFocused"] = "riveFocused";
|
|
2735
3040
|
})(FocusSessionState || (FocusSessionState = {}));
|
|
2736
3041
|
/**
|
|
2737
|
-
* Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas
|
|
3042
|
+
* Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas>, semantic
|
|
3043
|
+
* overlay, text input proxy). Owns the proxy and the text input session state.
|
|
2738
3044
|
* Because keyboard events can apply on either part of the domain, we need to track what events we should
|
|
2739
3045
|
* handle/intercept, and when to release focus back to the page outside of the domain.
|
|
2740
3046
|
*
|
|
@@ -2746,7 +3052,7 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2746
3052
|
function KeyboardInteractions(_a) {
|
|
2747
3053
|
var canvas = _a.canvas, stateMachine = _a.stateMachine, hasFocusNodes = _a.hasFocusNodes, getOverlayElement = _a.getOverlayElement;
|
|
2748
3054
|
var _this = this;
|
|
2749
|
-
var _b;
|
|
3055
|
+
var _b, _c;
|
|
2750
3056
|
this.focusSessionState = FocusSessionState.NotFocused;
|
|
2751
3057
|
/** Whether the canvas currently has browser DOM focus. */
|
|
2752
3058
|
this.canvasHasFocus = false;
|
|
@@ -2754,6 +3060,19 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2754
3060
|
this.focusDomainReleased = false;
|
|
2755
3061
|
/** Overlay element currently wired with focusin/keydown listeners, if any. */
|
|
2756
3062
|
this.currentOverlayElement = null;
|
|
3063
|
+
/** Codes whose keydown an overlay widget took, so their keyup is skipped too. */
|
|
3064
|
+
this.claimedKeyCodes = new Set();
|
|
3065
|
+
this.textInputSessionActive = false;
|
|
3066
|
+
/**
|
|
3067
|
+
* The proxy is always empty: copy Rive's selection; always preventDefault.
|
|
3068
|
+
*/
|
|
3069
|
+
this.onCopy = function (event) {
|
|
3070
|
+
var _a;
|
|
3071
|
+
event.preventDefault();
|
|
3072
|
+
var selected = _this.mainSm.selectedText();
|
|
3073
|
+
if (selected)
|
|
3074
|
+
(_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.setData("text/plain", selected);
|
|
3075
|
+
};
|
|
2757
3076
|
/**
|
|
2758
3077
|
* Handles the canvas gaining browser focus. The behavior differs based on how focus was gained -
|
|
2759
3078
|
*
|
|
@@ -2769,10 +3088,11 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2769
3088
|
_this.syncOverlayListener();
|
|
2770
3089
|
_this.canvasHasFocus = true;
|
|
2771
3090
|
_this.focusDomainReleased = false;
|
|
2772
|
-
if (
|
|
2773
|
-
|
|
2774
|
-
|
|
3091
|
+
if (_this.isInFocusDomain(event.relatedTarget) ||
|
|
3092
|
+
!_this.hasFocusNodes ||
|
|
3093
|
+
_this.mainSm.focusState().hasFocus) {
|
|
2775
3094
|
return;
|
|
3095
|
+
}
|
|
2776
3096
|
_this.focusSessionState = FocusSessionState.EntryPending;
|
|
2777
3097
|
// Pointer focus waits for the user's next Tab (handled in onKeyDown). Keyboard focus enters now.
|
|
2778
3098
|
if (!_this.isKeyboardDrivenFocus())
|
|
@@ -2791,11 +3111,13 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2791
3111
|
* When we're not in either of those buckets, it's safe to call `clearFocus()` on the SMI.
|
|
2792
3112
|
*/
|
|
2793
3113
|
this.onCanvasBlur = function (event) {
|
|
3114
|
+
// Must stay before the state reset because beginTextInputSession sets the session state and
|
|
3115
|
+
// then focuses the proxy, which synchronously blurs the canvas.
|
|
3116
|
+
if (_this.inputProxy.owns(event.relatedTarget))
|
|
3117
|
+
return;
|
|
2794
3118
|
_this.focusSessionState = FocusSessionState.NotFocused;
|
|
2795
3119
|
_this.canvasHasFocus = false;
|
|
2796
|
-
|
|
2797
|
-
var documentLostFocus = event.relatedTarget === null && !document.hasFocus();
|
|
2798
|
-
if (movedWithinFocusDomain || documentLostFocus)
|
|
3120
|
+
if (_this.blurStaysWithRive(event.relatedTarget))
|
|
2799
3121
|
return;
|
|
2800
3122
|
_this.mainSm.clearFocus();
|
|
2801
3123
|
};
|
|
@@ -2821,15 +3143,44 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2821
3143
|
this.onFocusDomainHostFocusIn = function (event) {
|
|
2822
3144
|
_this.syncOverlayListener();
|
|
2823
3145
|
_this.onOverlayFocusIn(event);
|
|
3146
|
+
// Focus entering the proxy re-enters the focus domain, so clear any earlier Tab-out
|
|
3147
|
+
// release, or onKeyDown would drop the session's keystrokes.
|
|
3148
|
+
if (_this.inputProxy.owns(event.target)) {
|
|
3149
|
+
_this.focusDomainReleased = false;
|
|
3150
|
+
}
|
|
2824
3151
|
};
|
|
3152
|
+
/**
|
|
3153
|
+
* Handles keydown events in the Rive focus domain. We route certain keys to different functions, with the following
|
|
3154
|
+
* fallback behavior:
|
|
3155
|
+
* 1. Tab/Shift+Tab - check if keyInput() takes this key, if not, call focusNext/Previous traversal if there are focus nodes
|
|
3156
|
+
* 2. Check - if a semantic overlay element's key handler claimed the event, don't intercept the key event further
|
|
3157
|
+
* 3. Send key to `keyInput()` on Rive state machine if applicable.
|
|
3158
|
+
* 4. If the keyInput returned false, and the key is directional arrow keys, call directional focus methods on state machine
|
|
3159
|
+
* 5. Printables: in a session the proxy's input event supplies text; otherwise textInput().
|
|
3160
|
+
* A printable fires both keyInput and textInput even if a listener claims it.
|
|
3161
|
+
* @param event KeyboardEvent
|
|
3162
|
+
* @returns void
|
|
3163
|
+
*/
|
|
2825
3164
|
this.onKeyDown = function (event) {
|
|
2826
3165
|
_this.syncOverlayListener();
|
|
3166
|
+
// Keys that are part of an IME composition belong to the IME (candidate
|
|
3167
|
+
// navigation, commit). Safari reports the first one as keyCode 229 with
|
|
3168
|
+
// isComposing still false.
|
|
3169
|
+
if (event.isComposing || event.keyCode === 229)
|
|
3170
|
+
return;
|
|
2827
3171
|
// After Tab exits the last Rive node, ignore keys until focus re-enters the focus domain.
|
|
2828
3172
|
if (_this.focusDomainReleased)
|
|
2829
3173
|
return;
|
|
2830
3174
|
if (!_this.shouldRiveHandleKeyEvent(event))
|
|
2831
3175
|
return;
|
|
2832
|
-
if (event.
|
|
3176
|
+
if (event.key === "Tab" && _this.hasFocusNodes) {
|
|
3177
|
+
// Tab listeners are matched per phase (down/repeat/up), as in the editor, so
|
|
3178
|
+
// each event is offered on its own; one that isn't claimed traverses.
|
|
3179
|
+
if (_this.mainSm.focusState().hasFocus &&
|
|
3180
|
+
_this.mainSm.keyInput(_keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.tab, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), true, event.repeat)) {
|
|
3181
|
+
event.preventDefault();
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
2833
3184
|
var forward = !event.shiftKey;
|
|
2834
3185
|
var focusMoved = forward ? _this.mainSm.focusNext() : _this.mainSm.focusPrevious();
|
|
2835
3186
|
var focusState = _this.mainSm.focusState();
|
|
@@ -2842,13 +3193,74 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2842
3193
|
}
|
|
2843
3194
|
else {
|
|
2844
3195
|
// No more traversable nodes — release Tab to the page.
|
|
3196
|
+
if (document.activeElement !== _this.canvas &&
|
|
3197
|
+
_this.isInFocusDomain(document.activeElement)) {
|
|
3198
|
+
// The browser's default Tab starts from the focused element; from an overlay element,
|
|
3199
|
+
// the nearest stop backward is the canvas itself. Start it from the
|
|
3200
|
+
// canvas instead, so a Shift+Tab goes to the proper element before Rive.
|
|
3201
|
+
_this.canvas.focus({ preventScroll: true });
|
|
3202
|
+
}
|
|
2845
3203
|
_this.focusSessionState = FocusSessionState.NotFocused;
|
|
2846
3204
|
_this.focusDomainReleased = true;
|
|
2847
3205
|
_this.canvasHasFocus = false;
|
|
2848
3206
|
}
|
|
2849
3207
|
_this.syncOverlayListener();
|
|
3208
|
+
return;
|
|
3209
|
+
}
|
|
3210
|
+
// A semantic overlay widget (roving radio/tab group, slider, Enter/Space activation)
|
|
3211
|
+
// already acted on this key at its target, so don't act on it twice.
|
|
3212
|
+
if ((0,_semantics_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_1__.isKeyEventClaimed)(event)) {
|
|
3213
|
+
_this.claimedKeyCodes.add(event.code);
|
|
3214
|
+
return;
|
|
3215
|
+
}
|
|
3216
|
+
// A new unclaimed press: drop any claim whose keyup never arrived.
|
|
3217
|
+
_this.claimedKeyCodes.delete(event.code);
|
|
3218
|
+
var fromProxy = _this.textInputSessionActive && _this.inputProxy.owns(event.target);
|
|
3219
|
+
var expectsKeyboardInput = _this.mainSm.focusState().expectsKeyboardInput;
|
|
3220
|
+
// The focused node gets first refusal (a TextInput's caret, or a keyboard listener
|
|
3221
|
+
// on that key). Keys with no Rive equivalent map to null and aren't dispatched.
|
|
3222
|
+
var key = (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.keyboardEventToRiveKey)(event);
|
|
3223
|
+
var consumed = key !== null &&
|
|
3224
|
+
_this.mainSm.keyInput(key, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), true, event.repeat);
|
|
3225
|
+
// An arrow key with no consumed key input moves focus spatially. While a Rive node holds focus,
|
|
3226
|
+
// arrows never scroll the page
|
|
3227
|
+
if (!consumed && key !== null && isArrowKey(key) && !hasShortcutModifier(event)) {
|
|
3228
|
+
consumed =
|
|
3229
|
+
_this.focusInDirection(key) || _this.mainSm.focusState().hasFocus;
|
|
3230
|
+
}
|
|
3231
|
+
if (isPrintable(event)) {
|
|
3232
|
+
// During a session the printable must reach the proxy: its input event is the
|
|
3233
|
+
// (IME- and dead-key-correct) text source, and C++ inserts nothing from keyInput.
|
|
3234
|
+
if (fromProxy)
|
|
3235
|
+
return;
|
|
3236
|
+
// Session live but focus elsewhere in Rive: refocus the proxy so the default inserts there.
|
|
3237
|
+
if (_this.textInputSessionActive && _this.isInFocusDomain(event.target)) {
|
|
3238
|
+
_this.inputProxy.focus();
|
|
3239
|
+
return;
|
|
3240
|
+
}
|
|
3241
|
+
if (!_this.textInputSessionActive && expectsKeyboardInput) {
|
|
3242
|
+
_this.mainSm.textInput(event.key);
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
// Rive consumed it, or an unmodified editing key while typing (would scroll/submit).
|
|
3246
|
+
var typing = fromProxy || expectsKeyboardInput;
|
|
3247
|
+
if (consumed ||
|
|
3248
|
+
(typing && !hasShortcutModifier(event) && EDITING_NAV_CODES.has(event.code))) {
|
|
3249
|
+
event.preventDefault();
|
|
2850
3250
|
}
|
|
2851
3251
|
};
|
|
3252
|
+
this.onKeyUp = function (event) {
|
|
3253
|
+
if (event.isComposing || event.keyCode === 229)
|
|
3254
|
+
return;
|
|
3255
|
+
if (_this.claimedKeyCodes.delete(event.code))
|
|
3256
|
+
return;
|
|
3257
|
+
if (_this.focusSessionState === FocusSessionState.NotFocused)
|
|
3258
|
+
return;
|
|
3259
|
+
var key = (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.keyboardEventToRiveKey)(event);
|
|
3260
|
+
if (key === null)
|
|
3261
|
+
return;
|
|
3262
|
+
_this.mainSm.keyInput(key, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), false, false);
|
|
3263
|
+
};
|
|
2852
3264
|
this.canvas = canvas;
|
|
2853
3265
|
this.mainSm = stateMachine;
|
|
2854
3266
|
this.hasFocusNodes = hasFocusNodes;
|
|
@@ -2857,9 +3269,74 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2857
3269
|
canvas.addEventListener("focus", this.onCanvasFocus);
|
|
2858
3270
|
canvas.addEventListener("blur", this.onCanvasBlur);
|
|
2859
3271
|
canvas.addEventListener("keydown", this.onKeyDown);
|
|
3272
|
+
canvas.addEventListener("keyup", this.onKeyUp);
|
|
2860
3273
|
this.focusDomainHost.addEventListener("focusin", this.onFocusDomainHostFocusIn);
|
|
2861
3274
|
this.syncOverlayListener();
|
|
3275
|
+
this.inputProxy = new _textInputProxy__WEBPACK_IMPORTED_MODULE_2__.TextInputProxy({
|
|
3276
|
+
container: (_c = canvas.parentElement) !== null && _c !== void 0 ? _c : document.body,
|
|
3277
|
+
canvas: canvas,
|
|
3278
|
+
textInput: function (text) { return _this.mainSm.textInput(text); },
|
|
3279
|
+
// Proxy keystrokes go through the same handlers as the canvas.
|
|
3280
|
+
onKeyDown: this.onKeyDown,
|
|
3281
|
+
onKeyUp: this.onKeyUp,
|
|
3282
|
+
onCopy: this.onCopy,
|
|
3283
|
+
onBlur: function (relatedTarget) { return _this.handleProxyBlur(relatedTarget); },
|
|
3284
|
+
});
|
|
2862
3285
|
}
|
|
3286
|
+
KeyboardInteractions.prototype.isTextInputSessionActive = function () {
|
|
3287
|
+
return this.textInputSessionActive;
|
|
3288
|
+
};
|
|
3289
|
+
/** Session active and the proxy holds DOM focus. */
|
|
3290
|
+
KeyboardInteractions.prototype.isEditingHostFocused = function () {
|
|
3291
|
+
return this.textInputSessionActive && this.inputProxy.hasDomFocus();
|
|
3292
|
+
};
|
|
3293
|
+
/** @param focusProxy move DOM focus to the proxy; false leaves it where it is. */
|
|
3294
|
+
KeyboardInteractions.prototype.beginTextInputSession = function (focusProxy) {
|
|
3295
|
+
this.textInputSessionActive = true;
|
|
3296
|
+
this.focusSessionState = FocusSessionState.RiveFocused;
|
|
3297
|
+
if (focusProxy)
|
|
3298
|
+
this.inputProxy.focus();
|
|
3299
|
+
};
|
|
3300
|
+
/** @param fromBlur focus is already leaving; don't park it on the canvas. */
|
|
3301
|
+
KeyboardInteractions.prototype.endTextInputSession = function (fromBlur) {
|
|
3302
|
+
if (fromBlur === void 0) { fromBlur = false; }
|
|
3303
|
+
if (!this.textInputSessionActive)
|
|
3304
|
+
return;
|
|
3305
|
+
this.textInputSessionActive = false;
|
|
3306
|
+
this.inputProxy.endSession();
|
|
3307
|
+
if (fromBlur || !this.inputProxy.hasDomFocus())
|
|
3308
|
+
return;
|
|
3309
|
+
// Nothing took DOM focus from the proxy (e.g. semantics is off). Park it on the
|
|
3310
|
+
// canvas so keys keep reaching Rive; onCanvasFocus ignores focus from the input proxy.
|
|
3311
|
+
this.canvas.focus({ preventScroll: true });
|
|
3312
|
+
};
|
|
3313
|
+
/** Must run synchronously in the pointer gesture or mobile keyboards won't open. */
|
|
3314
|
+
KeyboardInteractions.prototype.summonForPointer = function () {
|
|
3315
|
+
if (this.textInputSessionActive)
|
|
3316
|
+
this.inputProxy.focus();
|
|
3317
|
+
else
|
|
3318
|
+
this.beginTextInputSession(true);
|
|
3319
|
+
};
|
|
3320
|
+
Object.defineProperty(KeyboardInteractions.prototype, "editingHost", {
|
|
3321
|
+
/** The text-input proxy, for the semantics layer to decorate while editing. */
|
|
3322
|
+
get: function () {
|
|
3323
|
+
return this.inputProxy;
|
|
3324
|
+
},
|
|
3325
|
+
enumerable: false,
|
|
3326
|
+
configurable: true
|
|
3327
|
+
});
|
|
3328
|
+
KeyboardInteractions.prototype.handleProxyBlur = function (relatedTarget) {
|
|
3329
|
+
// Teardown already in progress (endTextInputSession blurred the proxy).
|
|
3330
|
+
if (!this.textInputSessionActive)
|
|
3331
|
+
return;
|
|
3332
|
+
// Still in Rive or the document blurred: keep the session (pollFocusState tears down).
|
|
3333
|
+
if (this.blurStaysWithRive(relatedTarget))
|
|
3334
|
+
return;
|
|
3335
|
+
// Blurred out of Rive entirely: release C++ focus and end the session.
|
|
3336
|
+
this.mainSm.clearFocus();
|
|
3337
|
+
this.endTextInputSession(true);
|
|
3338
|
+
this.focusSessionState = FocusSessionState.NotFocused;
|
|
3339
|
+
};
|
|
2863
3340
|
/**
|
|
2864
3341
|
* Set the FocusSessionState. Useful for invoking a Rive "blur" without actually blurring from the <canvas>. This
|
|
2865
3342
|
* helps put the DOM focus state on the canvas rather than the <body>, so the user doesn't lose the spot in page navigation
|
|
@@ -2878,6 +3355,26 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2878
3355
|
KeyboardInteractions.prototype.notifyRiveFocused = function () {
|
|
2879
3356
|
this.focusSessionState = FocusSessionState.RiveFocused;
|
|
2880
3357
|
};
|
|
3358
|
+
/** Blur into the focus domain, or the whole document losing focus (tab/window switch). */
|
|
3359
|
+
KeyboardInteractions.prototype.blurStaysWithRive = function (relatedTarget) {
|
|
3360
|
+
return (this.isInFocusDomain(relatedTarget) ||
|
|
3361
|
+
(relatedTarget === null && !document.hasFocus()));
|
|
3362
|
+
};
|
|
3363
|
+
/** Arrow keys map to directional focus; anything else is not a focus move. */
|
|
3364
|
+
KeyboardInteractions.prototype.focusInDirection = function (key) {
|
|
3365
|
+
switch (key) {
|
|
3366
|
+
case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.left:
|
|
3367
|
+
return this.mainSm.focusLeft();
|
|
3368
|
+
case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.right:
|
|
3369
|
+
return this.mainSm.focusRight();
|
|
3370
|
+
case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.up:
|
|
3371
|
+
return this.mainSm.focusUp();
|
|
3372
|
+
case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.down:
|
|
3373
|
+
return this.mainSm.focusDown();
|
|
3374
|
+
default:
|
|
3375
|
+
return false;
|
|
3376
|
+
}
|
|
3377
|
+
};
|
|
2881
3378
|
/**
|
|
2882
3379
|
* Determine if Rive should handle keyboard input. If session state is `NotFocused` - no.
|
|
2883
3380
|
* DOM focus stays parked on the canvas after Rive releases focus internally, and that Tab
|
|
@@ -2895,14 +3392,12 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2895
3392
|
var eventOnCanvas = event.target === this.canvas;
|
|
2896
3393
|
return inFocusDomain || this.canvasHasFocus || eventOnCanvas;
|
|
2897
3394
|
};
|
|
2898
|
-
/**
|
|
2899
|
-
* The Rive focus domain: the DOM that counts as "inside" Rive for focus purposes — today the
|
|
2900
|
-
* canvas itself OR the accessibility overlay subtree. Anything added later belongs here, so
|
|
2901
|
-
* session bookkeeping and keydown routing pick it up for free.
|
|
2902
|
-
*/
|
|
3395
|
+
/** DOM that counts as inside Rive for focus: canvas, overlay subtree, text-input proxy. */
|
|
2903
3396
|
KeyboardInteractions.prototype.isInFocusDomain = function (target) {
|
|
2904
3397
|
if (target === this.canvas)
|
|
2905
3398
|
return true;
|
|
3399
|
+
if (this.inputProxy.owns(target))
|
|
3400
|
+
return true;
|
|
2906
3401
|
return this.isInOverlay(target);
|
|
2907
3402
|
};
|
|
2908
3403
|
/** Overlay only (excludes the canvas) — the accessibility overlay subtree. */
|
|
@@ -2913,15 +3408,19 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2913
3408
|
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;
|
|
2914
3409
|
};
|
|
2915
3410
|
KeyboardInteractions.prototype.syncOverlayListener = function () {
|
|
2916
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3411
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2917
3412
|
var nextOverlayElement = (_b = (_a = this.getOverlayElement) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : null;
|
|
2918
3413
|
if (nextOverlayElement === this.currentOverlayElement)
|
|
2919
3414
|
return;
|
|
2920
3415
|
(_c = this.currentOverlayElement) === null || _c === void 0 ? void 0 : _c.removeEventListener("focusin", this.onOverlayFocusIn);
|
|
2921
|
-
(_d = this.currentOverlayElement) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", this.onKeyDown
|
|
3416
|
+
(_d = this.currentOverlayElement) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", this.onKeyDown);
|
|
3417
|
+
(_e = this.currentOverlayElement) === null || _e === void 0 ? void 0 : _e.removeEventListener("keyup", this.onKeyUp);
|
|
2922
3418
|
this.currentOverlayElement = nextOverlayElement;
|
|
2923
|
-
(
|
|
2924
|
-
|
|
3419
|
+
(_f = this.currentOverlayElement) === null || _f === void 0 ? void 0 : _f.addEventListener("focusin", this.onOverlayFocusIn);
|
|
3420
|
+
// Bubble phase, so a semantic widget's own key handler runs first and can claim
|
|
3421
|
+
// the key via claimKeyEvent (see onKeyDown).
|
|
3422
|
+
(_g = this.currentOverlayElement) === null || _g === void 0 ? void 0 : _g.addEventListener("keydown", this.onKeyDown);
|
|
3423
|
+
(_h = this.currentOverlayElement) === null || _h === void 0 ? void 0 : _h.addEventListener("keyup", this.onKeyUp);
|
|
2925
3424
|
};
|
|
2926
3425
|
/**
|
|
2927
3426
|
* Whether the canvas currently matches :focus-visible — the browser's heuristic for keyboard-
|
|
@@ -2947,13 +3446,22 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2947
3446
|
return true;
|
|
2948
3447
|
};
|
|
2949
3448
|
KeyboardInteractions.prototype.cleanup = function () {
|
|
2950
|
-
var _a, _b;
|
|
3449
|
+
var _a, _b, _c;
|
|
2951
3450
|
this.canvas.removeEventListener("focus", this.onCanvasFocus);
|
|
2952
3451
|
this.canvas.removeEventListener("blur", this.onCanvasBlur);
|
|
2953
3452
|
this.canvas.removeEventListener("keydown", this.onKeyDown);
|
|
3453
|
+
this.canvas.removeEventListener("keyup", this.onKeyUp);
|
|
3454
|
+
this.claimedKeyCodes.clear();
|
|
2954
3455
|
this.focusDomainHost.removeEventListener("focusin", this.onFocusDomainHostFocusIn);
|
|
2955
3456
|
(_a = this.currentOverlayElement) === null || _a === void 0 ? void 0 : _a.removeEventListener("focusin", this.onOverlayFocusIn);
|
|
2956
|
-
(_b = this.currentOverlayElement) === null || _b === void 0 ? void 0 : _b.removeEventListener("keydown", this.onKeyDown
|
|
3457
|
+
(_b = this.currentOverlayElement) === null || _b === void 0 ? void 0 : _b.removeEventListener("keydown", this.onKeyDown);
|
|
3458
|
+
(_c = this.currentOverlayElement) === null || _c === void 0 ? void 0 : _c.removeEventListener("keyup", this.onKeyUp);
|
|
3459
|
+
// Removing a focused element drops focus to <body> with no blur; park on the canvas.
|
|
3460
|
+
if (this.inputProxy.hasDomFocus()) {
|
|
3461
|
+
this.canvas.focus({ preventScroll: true });
|
|
3462
|
+
}
|
|
3463
|
+
this.inputProxy.cleanup();
|
|
3464
|
+
this.textInputSessionActive = false;
|
|
2957
3465
|
};
|
|
2958
3466
|
return KeyboardInteractions;
|
|
2959
3467
|
}());
|
|
@@ -2961,7 +3469,592 @@ var KeyboardInteractions = /** @class */ (function () {
|
|
|
2961
3469
|
|
|
2962
3470
|
|
|
2963
3471
|
/***/ }),
|
|
2964
|
-
/*
|
|
3472
|
+
/* 15 */
|
|
3473
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
3474
|
+
|
|
3475
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3476
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3477
|
+
/* harmony export */ Key: () => (/* binding */ Key),
|
|
3478
|
+
/* harmony export */ KeyModifiers: () => (/* binding */ KeyModifiers),
|
|
3479
|
+
/* harmony export */ keyboardEventToRiveKey: () => (/* binding */ keyboardEventToRiveKey),
|
|
3480
|
+
/* harmony export */ modifiersFromEvent: () => (/* binding */ modifiersFromEvent)
|
|
3481
|
+
/* harmony export */ });
|
|
3482
|
+
/*
|
|
3483
|
+
* Maps DOM keyboard events to the GLFW-style key codes and modifier bitmask
|
|
3484
|
+
* that StateMachineInstance.keyInput() expects. Values mirror `enum class Key`
|
|
3485
|
+
* and `enum class KeyModifiers` in rive-runtime focusable.hpp;
|
|
3486
|
+
* they are stable GLFW codes, so they live here as constants instead of an
|
|
3487
|
+
* embind enum.
|
|
3488
|
+
*/
|
|
3489
|
+
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
|
|
3490
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3491
|
+
if (ar || !(i in from)) {
|
|
3492
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
3493
|
+
ar[i] = from[i];
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
3497
|
+
};
|
|
3498
|
+
var Key = {
|
|
3499
|
+
space: 32,
|
|
3500
|
+
apostrophe: 39, // '
|
|
3501
|
+
comma: 44, // ,
|
|
3502
|
+
minus: 45, // -
|
|
3503
|
+
period: 46, // .
|
|
3504
|
+
slash: 47, // /
|
|
3505
|
+
key0: 48,
|
|
3506
|
+
key1: 49,
|
|
3507
|
+
key2: 50,
|
|
3508
|
+
key3: 51,
|
|
3509
|
+
key4: 52,
|
|
3510
|
+
key5: 53,
|
|
3511
|
+
key6: 54,
|
|
3512
|
+
key7: 55,
|
|
3513
|
+
key8: 56,
|
|
3514
|
+
key9: 57,
|
|
3515
|
+
semicolon: 59, // ;
|
|
3516
|
+
equal: 61, // =
|
|
3517
|
+
a: 65,
|
|
3518
|
+
b: 66,
|
|
3519
|
+
c: 67,
|
|
3520
|
+
d: 68,
|
|
3521
|
+
e: 69,
|
|
3522
|
+
f: 70,
|
|
3523
|
+
g: 71,
|
|
3524
|
+
h: 72,
|
|
3525
|
+
i: 73,
|
|
3526
|
+
j: 74,
|
|
3527
|
+
k: 75,
|
|
3528
|
+
l: 76,
|
|
3529
|
+
m: 77,
|
|
3530
|
+
n: 78,
|
|
3531
|
+
o: 79,
|
|
3532
|
+
p: 80,
|
|
3533
|
+
q: 81,
|
|
3534
|
+
r: 82,
|
|
3535
|
+
s: 83,
|
|
3536
|
+
t: 84,
|
|
3537
|
+
u: 85,
|
|
3538
|
+
v: 86,
|
|
3539
|
+
w: 87,
|
|
3540
|
+
x: 88,
|
|
3541
|
+
y: 89,
|
|
3542
|
+
z: 90,
|
|
3543
|
+
leftBracket: 91, // [
|
|
3544
|
+
backslash: 92, // \
|
|
3545
|
+
rightBracket: 93, // ]
|
|
3546
|
+
graveAccent: 96, // `
|
|
3547
|
+
world1: 161, // non-US #1
|
|
3548
|
+
world2: 162, // non-US #2
|
|
3549
|
+
escape: 256,
|
|
3550
|
+
enter: 257,
|
|
3551
|
+
tab: 258,
|
|
3552
|
+
backspace: 259,
|
|
3553
|
+
insert: 260,
|
|
3554
|
+
deleteKey: 261,
|
|
3555
|
+
right: 262,
|
|
3556
|
+
left: 263,
|
|
3557
|
+
down: 264,
|
|
3558
|
+
up: 265,
|
|
3559
|
+
pageUp: 266,
|
|
3560
|
+
pageDown: 267,
|
|
3561
|
+
home: 268,
|
|
3562
|
+
end: 269,
|
|
3563
|
+
capsLock: 280,
|
|
3564
|
+
scrollLock: 281,
|
|
3565
|
+
numLock: 282,
|
|
3566
|
+
printScreen: 283,
|
|
3567
|
+
pause: 284,
|
|
3568
|
+
f1: 290,
|
|
3569
|
+
f2: 291,
|
|
3570
|
+
f3: 292,
|
|
3571
|
+
f4: 293,
|
|
3572
|
+
f5: 294,
|
|
3573
|
+
f6: 295,
|
|
3574
|
+
f7: 296,
|
|
3575
|
+
f8: 297,
|
|
3576
|
+
f9: 298,
|
|
3577
|
+
f10: 299,
|
|
3578
|
+
f11: 300,
|
|
3579
|
+
f12: 301,
|
|
3580
|
+
f13: 302,
|
|
3581
|
+
f14: 303,
|
|
3582
|
+
f15: 304,
|
|
3583
|
+
f16: 305,
|
|
3584
|
+
f17: 306,
|
|
3585
|
+
f18: 307,
|
|
3586
|
+
f19: 308,
|
|
3587
|
+
f20: 309,
|
|
3588
|
+
f21: 310,
|
|
3589
|
+
f22: 311,
|
|
3590
|
+
f23: 312,
|
|
3591
|
+
f24: 313,
|
|
3592
|
+
f25: 314,
|
|
3593
|
+
kp0: 320,
|
|
3594
|
+
kp1: 321,
|
|
3595
|
+
kp2: 322,
|
|
3596
|
+
kp3: 323,
|
|
3597
|
+
kp4: 324,
|
|
3598
|
+
kp5: 325,
|
|
3599
|
+
kp6: 326,
|
|
3600
|
+
kp7: 327,
|
|
3601
|
+
kp8: 328,
|
|
3602
|
+
kp9: 329,
|
|
3603
|
+
kpDecimal: 330,
|
|
3604
|
+
kpDivide: 331,
|
|
3605
|
+
kpMultiply: 332,
|
|
3606
|
+
kpSubtract: 333,
|
|
3607
|
+
kpAdd: 334,
|
|
3608
|
+
kpEnter: 335,
|
|
3609
|
+
kpEqual: 336,
|
|
3610
|
+
leftShift: 340,
|
|
3611
|
+
leftControl: 341,
|
|
3612
|
+
leftAlt: 342,
|
|
3613
|
+
leftSuper: 343,
|
|
3614
|
+
rightShift: 344,
|
|
3615
|
+
rightControl: 345,
|
|
3616
|
+
rightAlt: 346,
|
|
3617
|
+
rightSuper: 347,
|
|
3618
|
+
menu: 348,
|
|
3619
|
+
};
|
|
3620
|
+
var KeyModifiers = {
|
|
3621
|
+
none: 0,
|
|
3622
|
+
shift: 1 << 0,
|
|
3623
|
+
ctrl: 1 << 1,
|
|
3624
|
+
alt: 1 << 2,
|
|
3625
|
+
meta: 1 << 3,
|
|
3626
|
+
};
|
|
3627
|
+
// Physical key (KeyboardEvent.code) to Rive key, by US-QWERTY position.
|
|
3628
|
+
var CODE_TO_KEY = {
|
|
3629
|
+
// Modifiers are keys too (the editor sends them), and are also in the bitmask.
|
|
3630
|
+
ShiftLeft: Key.leftShift,
|
|
3631
|
+
ShiftRight: Key.rightShift,
|
|
3632
|
+
ControlLeft: Key.leftControl,
|
|
3633
|
+
ControlRight: Key.rightControl,
|
|
3634
|
+
AltLeft: Key.leftAlt,
|
|
3635
|
+
AltRight: Key.rightAlt,
|
|
3636
|
+
MetaLeft: Key.leftSuper,
|
|
3637
|
+
MetaRight: Key.rightSuper,
|
|
3638
|
+
KeyA: Key.a,
|
|
3639
|
+
KeyB: Key.b,
|
|
3640
|
+
KeyC: Key.c,
|
|
3641
|
+
KeyD: Key.d,
|
|
3642
|
+
KeyE: Key.e,
|
|
3643
|
+
KeyF: Key.f,
|
|
3644
|
+
KeyG: Key.g,
|
|
3645
|
+
KeyH: Key.h,
|
|
3646
|
+
KeyI: Key.i,
|
|
3647
|
+
KeyJ: Key.j,
|
|
3648
|
+
KeyK: Key.k,
|
|
3649
|
+
KeyL: Key.l,
|
|
3650
|
+
KeyM: Key.m,
|
|
3651
|
+
KeyN: Key.n,
|
|
3652
|
+
KeyO: Key.o,
|
|
3653
|
+
KeyP: Key.p,
|
|
3654
|
+
KeyQ: Key.q,
|
|
3655
|
+
KeyR: Key.r,
|
|
3656
|
+
KeyS: Key.s,
|
|
3657
|
+
KeyT: Key.t,
|
|
3658
|
+
KeyU: Key.u,
|
|
3659
|
+
KeyV: Key.v,
|
|
3660
|
+
KeyW: Key.w,
|
|
3661
|
+
KeyX: Key.x,
|
|
3662
|
+
KeyY: Key.y,
|
|
3663
|
+
KeyZ: Key.z,
|
|
3664
|
+
Digit0: Key.key0,
|
|
3665
|
+
Digit1: Key.key1,
|
|
3666
|
+
Digit2: Key.key2,
|
|
3667
|
+
Digit3: Key.key3,
|
|
3668
|
+
Digit4: Key.key4,
|
|
3669
|
+
Digit5: Key.key5,
|
|
3670
|
+
Digit6: Key.key6,
|
|
3671
|
+
Digit7: Key.key7,
|
|
3672
|
+
Digit8: Key.key8,
|
|
3673
|
+
Digit9: Key.key9,
|
|
3674
|
+
Numpad0: Key.kp0,
|
|
3675
|
+
Numpad1: Key.kp1,
|
|
3676
|
+
Numpad2: Key.kp2,
|
|
3677
|
+
Numpad3: Key.kp3,
|
|
3678
|
+
Numpad4: Key.kp4,
|
|
3679
|
+
Numpad5: Key.kp5,
|
|
3680
|
+
Numpad6: Key.kp6,
|
|
3681
|
+
Numpad7: Key.kp7,
|
|
3682
|
+
Numpad8: Key.kp8,
|
|
3683
|
+
Numpad9: Key.kp9,
|
|
3684
|
+
NumpadDecimal: Key.kpDecimal,
|
|
3685
|
+
NumpadDivide: Key.kpDivide,
|
|
3686
|
+
NumpadMultiply: Key.kpMultiply,
|
|
3687
|
+
NumpadSubtract: Key.kpSubtract,
|
|
3688
|
+
NumpadAdd: Key.kpAdd,
|
|
3689
|
+
NumpadEnter: Key.kpEnter,
|
|
3690
|
+
NumpadEqual: Key.kpEqual,
|
|
3691
|
+
Minus: Key.minus,
|
|
3692
|
+
Equal: Key.equal,
|
|
3693
|
+
BracketLeft: Key.leftBracket,
|
|
3694
|
+
BracketRight: Key.rightBracket,
|
|
3695
|
+
Backslash: Key.backslash,
|
|
3696
|
+
Semicolon: Key.semicolon,
|
|
3697
|
+
Quote: Key.apostrophe,
|
|
3698
|
+
Backquote: Key.graveAccent,
|
|
3699
|
+
Comma: Key.comma,
|
|
3700
|
+
Period: Key.period,
|
|
3701
|
+
Slash: Key.slash,
|
|
3702
|
+
IntlBackslash: Key.world1,
|
|
3703
|
+
IntlRo: Key.world2,
|
|
3704
|
+
Space: Key.space,
|
|
3705
|
+
Enter: Key.enter,
|
|
3706
|
+
Tab: Key.tab,
|
|
3707
|
+
Backspace: Key.backspace,
|
|
3708
|
+
Insert: Key.insert,
|
|
3709
|
+
Delete: Key.deleteKey,
|
|
3710
|
+
Escape: Key.escape,
|
|
3711
|
+
ArrowRight: Key.right,
|
|
3712
|
+
ArrowLeft: Key.left,
|
|
3713
|
+
ArrowDown: Key.down,
|
|
3714
|
+
ArrowUp: Key.up,
|
|
3715
|
+
PageUp: Key.pageUp,
|
|
3716
|
+
PageDown: Key.pageDown,
|
|
3717
|
+
Home: Key.home,
|
|
3718
|
+
End: Key.end,
|
|
3719
|
+
CapsLock: Key.capsLock,
|
|
3720
|
+
ScrollLock: Key.scrollLock,
|
|
3721
|
+
NumLock: Key.numLock,
|
|
3722
|
+
PrintScreen: Key.printScreen,
|
|
3723
|
+
Pause: Key.pause,
|
|
3724
|
+
ContextMenu: Key.menu,
|
|
3725
|
+
F1: Key.f1,
|
|
3726
|
+
F2: Key.f2,
|
|
3727
|
+
F3: Key.f3,
|
|
3728
|
+
F4: Key.f4,
|
|
3729
|
+
F5: Key.f5,
|
|
3730
|
+
F6: Key.f6,
|
|
3731
|
+
F7: Key.f7,
|
|
3732
|
+
F8: Key.f8,
|
|
3733
|
+
F9: Key.f9,
|
|
3734
|
+
F10: Key.f10,
|
|
3735
|
+
F11: Key.f11,
|
|
3736
|
+
F12: Key.f12,
|
|
3737
|
+
F13: Key.f13,
|
|
3738
|
+
F14: Key.f14,
|
|
3739
|
+
F15: Key.f15,
|
|
3740
|
+
F16: Key.f16,
|
|
3741
|
+
F17: Key.f17,
|
|
3742
|
+
F18: Key.f18,
|
|
3743
|
+
F19: Key.f19,
|
|
3744
|
+
F20: Key.f20,
|
|
3745
|
+
F21: Key.f21,
|
|
3746
|
+
F22: Key.f22,
|
|
3747
|
+
F23: Key.f23,
|
|
3748
|
+
F24: Key.f24,
|
|
3749
|
+
F25: Key.f25,
|
|
3750
|
+
};
|
|
3751
|
+
// Unshifted characters (event.key, lowercased) that name a Rive key.
|
|
3752
|
+
var CHAR_TO_KEY = (function () {
|
|
3753
|
+
var map = {
|
|
3754
|
+
" ": Key.space,
|
|
3755
|
+
"'": Key.apostrophe,
|
|
3756
|
+
",": Key.comma,
|
|
3757
|
+
"-": Key.minus,
|
|
3758
|
+
".": Key.period,
|
|
3759
|
+
"/": Key.slash,
|
|
3760
|
+
";": Key.semicolon,
|
|
3761
|
+
"=": Key.equal,
|
|
3762
|
+
"[": Key.leftBracket,
|
|
3763
|
+
"\\": Key.backslash,
|
|
3764
|
+
"]": Key.rightBracket,
|
|
3765
|
+
"`": Key.graveAccent,
|
|
3766
|
+
};
|
|
3767
|
+
for (var c = 0; c < 26; c++)
|
|
3768
|
+
map[String.fromCharCode(97 + c)] = Key.a + c;
|
|
3769
|
+
for (var d = 0; d <= 9; d++)
|
|
3770
|
+
map[String(d)] = Key.key0 + d;
|
|
3771
|
+
return map;
|
|
3772
|
+
})();
|
|
3773
|
+
// Non-printable event.key values; each shares its name with its code.
|
|
3774
|
+
var NAMED_KEYS = new Set(__spreadArray([
|
|
3775
|
+
"Enter",
|
|
3776
|
+
"Tab",
|
|
3777
|
+
"Backspace",
|
|
3778
|
+
"Insert",
|
|
3779
|
+
"Delete",
|
|
3780
|
+
"Escape",
|
|
3781
|
+
"ArrowRight",
|
|
3782
|
+
"ArrowLeft",
|
|
3783
|
+
"ArrowDown",
|
|
3784
|
+
"ArrowUp",
|
|
3785
|
+
"PageUp",
|
|
3786
|
+
"PageDown",
|
|
3787
|
+
"Home",
|
|
3788
|
+
"End",
|
|
3789
|
+
"CapsLock",
|
|
3790
|
+
"ScrollLock",
|
|
3791
|
+
"NumLock",
|
|
3792
|
+
"PrintScreen",
|
|
3793
|
+
"Pause",
|
|
3794
|
+
"ContextMenu"
|
|
3795
|
+
], Array.from({ length: 25 }, function (_, i) { return "F".concat(i + 1); }), true));
|
|
3796
|
+
/**
|
|
3797
|
+
* Maps a KeyboardEvent to a Rive key, or null if Rive has no equivalent.
|
|
3798
|
+
*
|
|
3799
|
+
* Resolves the logical key: what the user's layout labels the key, ignoring
|
|
3800
|
+
* Shift, so a listener on "A" fires on AZERTY's A too. `event.key` is preferred;
|
|
3801
|
+
* `event.code` is the fallback when `key` isn't a plain unshifted character
|
|
3802
|
+
* (shifted symbols, Option/AltGr output, non-Latin letters, dead keys).
|
|
3803
|
+
* Digit-row and numpad keys skip the character lookup so AZERTY's digit row
|
|
3804
|
+
* still reports digits and numpad digits stay distinct from the digit row.
|
|
3805
|
+
*/
|
|
3806
|
+
function keyboardEventToRiveKey(event) {
|
|
3807
|
+
var _a, _b;
|
|
3808
|
+
var code = event.code, key = event.key;
|
|
3809
|
+
if (NAMED_KEYS.has(key)) {
|
|
3810
|
+
// NumpadEnter reports key "Enter"; keep it distinct.
|
|
3811
|
+
return code === "NumpadEnter" ? Key.kpEnter : (_a = CODE_TO_KEY[key]) !== null && _a !== void 0 ? _a : null;
|
|
3812
|
+
}
|
|
3813
|
+
if (!code.startsWith("Digit") && !code.startsWith("Numpad") && key) {
|
|
3814
|
+
var fromChar = CHAR_TO_KEY[key.toLowerCase()];
|
|
3815
|
+
if (fromChar !== undefined)
|
|
3816
|
+
return fromChar;
|
|
3817
|
+
}
|
|
3818
|
+
return (_b = CODE_TO_KEY[code]) !== null && _b !== void 0 ? _b : null;
|
|
3819
|
+
}
|
|
3820
|
+
function modifiersFromEvent(event) {
|
|
3821
|
+
var modifiers = KeyModifiers.none;
|
|
3822
|
+
if (event.shiftKey)
|
|
3823
|
+
modifiers |= KeyModifiers.shift;
|
|
3824
|
+
if (event.ctrlKey)
|
|
3825
|
+
modifiers |= KeyModifiers.ctrl;
|
|
3826
|
+
if (event.altKey)
|
|
3827
|
+
modifiers |= KeyModifiers.alt;
|
|
3828
|
+
if (event.metaKey)
|
|
3829
|
+
modifiers |= KeyModifiers.meta;
|
|
3830
|
+
return modifiers;
|
|
3831
|
+
}
|
|
3832
|
+
|
|
3833
|
+
|
|
3834
|
+
/***/ }),
|
|
3835
|
+
/* 16 */
|
|
3836
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
3837
|
+
|
|
3838
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3839
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3840
|
+
/* harmony export */ TextInputProxy: () => (/* binding */ TextInputProxy)
|
|
3841
|
+
/* harmony export */ });
|
|
3842
|
+
/* harmony import */ var _canvasOffset__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
|
|
3843
|
+
|
|
3844
|
+
// 16px: the smallest font size at which iOS Safari doesn't zoom on focus
|
|
3845
|
+
var FONT_SIZE_PX = 16;
|
|
3846
|
+
/** Capture-critical attributes decorate() must not touch. */
|
|
3847
|
+
var PROTECTED_ATTRS = new Set([
|
|
3848
|
+
"type",
|
|
3849
|
+
"value",
|
|
3850
|
+
"style",
|
|
3851
|
+
"tabindex",
|
|
3852
|
+
"autocapitalize",
|
|
3853
|
+
"autocomplete",
|
|
3854
|
+
"autocorrect",
|
|
3855
|
+
"spellcheck",
|
|
3856
|
+
]);
|
|
3857
|
+
/**
|
|
3858
|
+
* Invisible per-instance <input> capturing IME/dead-key/paste text; focusable inside a
|
|
3859
|
+
* gesture to raise mobile keyboards. Always empty: C++ owns value and caret. Decorated
|
|
3860
|
+
* for AT only while it holds DOM focus.
|
|
3861
|
+
*/
|
|
3862
|
+
var TextInputProxy = /** @class */ (function () {
|
|
3863
|
+
function TextInputProxy(params) {
|
|
3864
|
+
var _this = this;
|
|
3865
|
+
// True between compositionstart/compositionend; we never commit mid-composition.
|
|
3866
|
+
this.composing = false;
|
|
3867
|
+
// Names set by decorate(), removed by resetDecoration().
|
|
3868
|
+
this.decoratedKeys = new Set();
|
|
3869
|
+
// Last written left/top, to skip no-op style writes.
|
|
3870
|
+
this.lastLeft = NaN;
|
|
3871
|
+
this.lastTop = NaN;
|
|
3872
|
+
/** Re-sync before input: the canvas may have scrolled since the session began. */
|
|
3873
|
+
this.reposition = function () { return _this.positionOverCanvas(); };
|
|
3874
|
+
this.onCompositionStart = function () {
|
|
3875
|
+
_this.composing = true;
|
|
3876
|
+
};
|
|
3877
|
+
this.onCompositionEnd = function () {
|
|
3878
|
+
_this.composing = false;
|
|
3879
|
+
// The composed text is now committed in element.value; forward it here. A
|
|
3880
|
+
// trailing `input` event (order varies by browser) then sees an empty field.
|
|
3881
|
+
_this.commit();
|
|
3882
|
+
};
|
|
3883
|
+
this.onInput = function () {
|
|
3884
|
+
if (_this.composing)
|
|
3885
|
+
return;
|
|
3886
|
+
_this.commit();
|
|
3887
|
+
};
|
|
3888
|
+
// An <input type=text> strips line breaks from its value, so forward the clipboard
|
|
3889
|
+
// text directly. Core's single-line fields strip them themselves.
|
|
3890
|
+
this.onPaste = function (event) {
|
|
3891
|
+
var _a;
|
|
3892
|
+
var text = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData("text/plain");
|
|
3893
|
+
if (!text)
|
|
3894
|
+
return;
|
|
3895
|
+
event.preventDefault();
|
|
3896
|
+
_this.params.textInput(text.replace(/\r\n?/g, "\n"));
|
|
3897
|
+
};
|
|
3898
|
+
this.onBlur = function (event) {
|
|
3899
|
+
_this.params.onBlur(event.relatedTarget);
|
|
3900
|
+
};
|
|
3901
|
+
this.params = params;
|
|
3902
|
+
this.element = this.createElement();
|
|
3903
|
+
this.positionOverCanvas();
|
|
3904
|
+
// Order vs. the overlay is unspecified; fine, Tab release starts from the canvas.
|
|
3905
|
+
this.params.container.appendChild(this.element);
|
|
3906
|
+
}
|
|
3907
|
+
// Registered first so it runs before the key handler inserts or moves the caret.
|
|
3908
|
+
TextInputProxy.prototype.listeners = function () {
|
|
3909
|
+
return [
|
|
3910
|
+
["keydown", this.reposition],
|
|
3911
|
+
["beforeinput", this.reposition],
|
|
3912
|
+
["keydown", this.params.onKeyDown],
|
|
3913
|
+
["keyup", this.params.onKeyUp],
|
|
3914
|
+
["input", this.onInput],
|
|
3915
|
+
["compositionstart", this.onCompositionStart],
|
|
3916
|
+
["compositionend", this.onCompositionEnd],
|
|
3917
|
+
["paste", this.onPaste],
|
|
3918
|
+
["copy", this.params.onCopy],
|
|
3919
|
+
["blur", this.onBlur],
|
|
3920
|
+
];
|
|
3921
|
+
};
|
|
3922
|
+
TextInputProxy.prototype.createElement = function () {
|
|
3923
|
+
var el = document.createElement("input");
|
|
3924
|
+
el.type = "text";
|
|
3925
|
+
// Focusable but never in native tab order (Rive drives traversal synthetically),
|
|
3926
|
+
// and invisible without display:none (which would forbid focus).
|
|
3927
|
+
el.tabIndex = -1;
|
|
3928
|
+
el.setAttribute("aria-hidden", "true");
|
|
3929
|
+
// Always empty, so autocapitalize/autocorrect would misfire.
|
|
3930
|
+
el.setAttribute("autocapitalize", "off");
|
|
3931
|
+
el.setAttribute("autocomplete", "off");
|
|
3932
|
+
el.setAttribute("autocorrect", "off");
|
|
3933
|
+
el.spellcheck = false;
|
|
3934
|
+
// Over the canvas (not display:none) so iOS doesn't scroll-jump on keyboard open.
|
|
3935
|
+
// font-size must stay 16px or iOS Safari zooms on focus.
|
|
3936
|
+
el.style.cssText =
|
|
3937
|
+
"position:absolute;width:1px;height:1px;padding:0;margin:0;border:0;" +
|
|
3938
|
+
"outline:none;opacity:0;background:transparent;color:transparent;" +
|
|
3939
|
+
"caret-color:transparent;overflow:hidden;resize:none;z-index:0;" +
|
|
3940
|
+
// Focused programmatically only; must not swallow clicks
|
|
3941
|
+
"pointer-events:none;" +
|
|
3942
|
+
"font-size:".concat(FONT_SIZE_PX, "px;line-height:1;");
|
|
3943
|
+
for (var _i = 0, _a = this.listeners(); _i < _a.length; _i++) {
|
|
3944
|
+
var _b = _a[_i], type = _b[0], listener = _b[1];
|
|
3945
|
+
el.addEventListener(type, listener);
|
|
3946
|
+
}
|
|
3947
|
+
return el;
|
|
3948
|
+
};
|
|
3949
|
+
TextInputProxy.prototype.positionOverCanvas = function () {
|
|
3950
|
+
// Track the canvas (browsers scroll to the caret); clamp on-screen, one caret line box
|
|
3951
|
+
// (FONT_SIZE_PX) from the far edges, or the root scrolls to reveal it.
|
|
3952
|
+
var _a = (0,_canvasOffset__WEBPACK_IMPORTED_MODULE_0__.canvasOffset)(this.params.canvas), top = _a.top, left = _a.left;
|
|
3953
|
+
if (window.innerHeight > 0) {
|
|
3954
|
+
var r = this.params.canvas.getBoundingClientRect();
|
|
3955
|
+
top += clamp(r.top, 0, window.innerHeight - FONT_SIZE_PX) - r.top;
|
|
3956
|
+
left += clamp(r.left, 0, window.innerWidth - FONT_SIZE_PX) - r.left;
|
|
3957
|
+
}
|
|
3958
|
+
if (left !== this.lastLeft) {
|
|
3959
|
+
this.element.style.left = "".concat(left, "px");
|
|
3960
|
+
this.lastLeft = left;
|
|
3961
|
+
}
|
|
3962
|
+
if (top !== this.lastTop) {
|
|
3963
|
+
this.element.style.top = "".concat(top, "px");
|
|
3964
|
+
this.lastTop = top;
|
|
3965
|
+
}
|
|
3966
|
+
};
|
|
3967
|
+
/**
|
|
3968
|
+
* Forward the field's text to Rive and clear it.
|
|
3969
|
+
*
|
|
3970
|
+
* TODO: iOS won't autorepeat Backspace in an empty field (needs a text mirror).
|
|
3971
|
+
* */
|
|
3972
|
+
TextInputProxy.prototype.commit = function () {
|
|
3973
|
+
var text = this.element.value;
|
|
3974
|
+
if (!text)
|
|
3975
|
+
return;
|
|
3976
|
+
this.element.value = "";
|
|
3977
|
+
this.params.textInput(text);
|
|
3978
|
+
};
|
|
3979
|
+
/** Clear any transient value and decoration. Does not blur the element. */
|
|
3980
|
+
TextInputProxy.prototype.endSession = function () {
|
|
3981
|
+
this.element.value = "";
|
|
3982
|
+
// Browsers fire compositionend on blur, but a stuck flag would drop every
|
|
3983
|
+
// keystroke of the next session.
|
|
3984
|
+
this.composing = false;
|
|
3985
|
+
// Also covers blur-out, which bypasses the overlay.
|
|
3986
|
+
this.resetDecoration();
|
|
3987
|
+
};
|
|
3988
|
+
/** Must be called synchronously inside a gesture on iOS to raise the keyboard. */
|
|
3989
|
+
TextInputProxy.prototype.focus = function () {
|
|
3990
|
+
// Reposition first: iOS scrolls the focused input into view when the keyboard opens.
|
|
3991
|
+
this.positionOverCanvas();
|
|
3992
|
+
this.element.focus({ preventScroll: true });
|
|
3993
|
+
};
|
|
3994
|
+
TextInputProxy.prototype.hasDomFocus = function () {
|
|
3995
|
+
return document.activeElement === this.element;
|
|
3996
|
+
};
|
|
3997
|
+
TextInputProxy.prototype.owns = function (target) {
|
|
3998
|
+
return target === this.element;
|
|
3999
|
+
};
|
|
4000
|
+
/** See EditingHost.decorate. */
|
|
4001
|
+
TextInputProxy.prototype.decorate = function (attrs) {
|
|
4002
|
+
// aria-hidden outranks every attribute set below, so it must come off before this
|
|
4003
|
+
// element can stand in as the accessible element for the focused node.
|
|
4004
|
+
this.element.removeAttribute("aria-hidden");
|
|
4005
|
+
for (var _i = 0, _a = Object.entries(attrs); _i < _a.length; _i++) {
|
|
4006
|
+
var _b = _a[_i], name_1 = _b[0], value = _b[1];
|
|
4007
|
+
// Never override capture attrs.
|
|
4008
|
+
if (PROTECTED_ATTRS.has(name_1.toLowerCase()))
|
|
4009
|
+
continue;
|
|
4010
|
+
if (value === null) {
|
|
4011
|
+
this.element.removeAttribute(name_1);
|
|
4012
|
+
this.decoratedKeys.delete(name_1);
|
|
4013
|
+
}
|
|
4014
|
+
else {
|
|
4015
|
+
// Skip no-op writes: setting an attribute to the value it already has still
|
|
4016
|
+
// emits a mutation, and assistive tech is focused on this element mid-edit.
|
|
4017
|
+
if (this.element.getAttribute(name_1) !== value) {
|
|
4018
|
+
this.element.setAttribute(name_1, value);
|
|
4019
|
+
}
|
|
4020
|
+
this.decoratedKeys.add(name_1);
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
};
|
|
4024
|
+
/**
|
|
4025
|
+
* type=password for obscured fields so AT doesn't echo keys.
|
|
4026
|
+
* TODO: source "type" from Core, not semantics.
|
|
4027
|
+
*/
|
|
4028
|
+
TextInputProxy.prototype.setSecure = function (secure) {
|
|
4029
|
+
var type = secure ? "password" : "text";
|
|
4030
|
+
if (this.element.type !== type)
|
|
4031
|
+
this.element.type = type;
|
|
4032
|
+
};
|
|
4033
|
+
/** Drop all decoration and return to the AT-invisible baseline. */
|
|
4034
|
+
TextInputProxy.prototype.resetDecoration = function () {
|
|
4035
|
+
var _this = this;
|
|
4036
|
+
this.setSecure(false);
|
|
4037
|
+
this.decoratedKeys.forEach(function (name) { return _this.element.removeAttribute(name); });
|
|
4038
|
+
this.decoratedKeys.clear();
|
|
4039
|
+
this.element.setAttribute("aria-hidden", "true");
|
|
4040
|
+
};
|
|
4041
|
+
TextInputProxy.prototype.cleanup = function () {
|
|
4042
|
+
for (var _i = 0, _a = this.listeners(); _i < _a.length; _i++) {
|
|
4043
|
+
var _b = _a[_i], type = _b[0], listener = _b[1];
|
|
4044
|
+
this.element.removeEventListener(type, listener);
|
|
4045
|
+
}
|
|
4046
|
+
this.element.remove();
|
|
4047
|
+
};
|
|
4048
|
+
return TextInputProxy;
|
|
4049
|
+
}());
|
|
4050
|
+
|
|
4051
|
+
function clamp(v, min, max) {
|
|
4052
|
+
return Math.min(Math.max(v, min), Math.max(min, max));
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
|
|
4056
|
+
/***/ }),
|
|
4057
|
+
/* 17 */
|
|
2965
4058
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2966
4059
|
|
|
2967
4060
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -3014,7 +4107,7 @@ function sanitizeUrl(url) {
|
|
|
3014
4107
|
|
|
3015
4108
|
|
|
3016
4109
|
/***/ }),
|
|
3017
|
-
/*
|
|
4110
|
+
/* 18 */
|
|
3018
4111
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
3019
4112
|
|
|
3020
4113
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -3314,7 +4407,7 @@ var createFinalization = function (target, finalizable) {
|
|
|
3314
4407
|
|
|
3315
4408
|
|
|
3316
4409
|
/***/ }),
|
|
3317
|
-
/*
|
|
4410
|
+
/* 19 */
|
|
3318
4411
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
3319
4412
|
|
|
3320
4413
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -3486,7 +4579,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3486
4579
|
/* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
|
|
3487
4580
|
/* harmony import */ var _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
|
|
3488
4581
|
/* harmony import */ var _semantics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
|
|
3489
|
-
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(
|
|
4582
|
+
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);
|
|
3490
4583
|
var __extends = (undefined && undefined.__extends) || (function () {
|
|
3491
4584
|
var extendStatics = function (d, b) {
|
|
3492
4585
|
extendStatics = Object.setPrototypeOf ||
|
|
@@ -5374,6 +6467,10 @@ var Rive = /** @class */ (function () {
|
|
|
5374
6467
|
this._dataEnums = null;
|
|
5375
6468
|
this._tabIndex = null;
|
|
5376
6469
|
this._prevHasFocus = false;
|
|
6470
|
+
this._prevWantsTextInputSession = false;
|
|
6471
|
+
// Pointer-down defers the proxy focus: mousedown's default would refocus the canvas and
|
|
6472
|
+
// touchstart isn't user activation; pointer-up focuses it.
|
|
6473
|
+
this._inPointerDownDrain = false;
|
|
5377
6474
|
this._focusOptions = {
|
|
5378
6475
|
allowFocusInterrupt: false,
|
|
5379
6476
|
};
|
|
@@ -5409,6 +6506,7 @@ var Rive = /** @class */ (function () {
|
|
|
5409
6506
|
_this.resizeToCanvas();
|
|
5410
6507
|
}
|
|
5411
6508
|
};
|
|
6509
|
+
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; };
|
|
5412
6510
|
// Tracks the current animation frame request
|
|
5413
6511
|
this.frameRequestId = null;
|
|
5414
6512
|
/**
|
|
@@ -5729,11 +6827,21 @@ var Rive = /** @class */ (function () {
|
|
|
5729
6827
|
dispatchPointerExit: dispatchPointerExit,
|
|
5730
6828
|
enableMultiTouch: enableMultiTouch,
|
|
5731
6829
|
layoutScaleFactor: this._layout.layoutScaleFactor,
|
|
5732
|
-
advanceAndDrain: this.
|
|
6830
|
+
advanceAndDrain: this.advanceAndDrainForPointer.bind(this),
|
|
6831
|
+
summonKeyboard: this.summonKeyboardForGesture.bind(this),
|
|
6832
|
+
isTextProxyFocused: this.isEditingHostFocused,
|
|
5733
6833
|
});
|
|
5734
6834
|
this.ensureKeyboardInteractions();
|
|
5735
6835
|
}
|
|
5736
6836
|
};
|
|
6837
|
+
Object.defineProperty(Rive.prototype, "focusStateMachine", {
|
|
6838
|
+
// Assumes a single state machine drives focus.
|
|
6839
|
+
get: function () {
|
|
6840
|
+
return this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; });
|
|
6841
|
+
},
|
|
6842
|
+
enumerable: false,
|
|
6843
|
+
configurable: true
|
|
6844
|
+
});
|
|
5737
6845
|
/**
|
|
5738
6846
|
* Wire keyboard interactions when a playing state machine has focus nodes.
|
|
5739
6847
|
* Called at listener setup and lazily each frame so late-bound bindable artboards work.
|
|
@@ -5746,7 +6854,7 @@ var Rive = /** @class */ (function () {
|
|
|
5746
6854
|
!(this.canvas instanceof HTMLCanvasElement)) {
|
|
5747
6855
|
return;
|
|
5748
6856
|
}
|
|
5749
|
-
var smWithFocusNodes = this.
|
|
6857
|
+
var smWithFocusNodes = this.focusStateMachine;
|
|
5750
6858
|
if (!smWithFocusNodes) {
|
|
5751
6859
|
return;
|
|
5752
6860
|
}
|
|
@@ -5756,16 +6864,51 @@ var Rive = /** @class */ (function () {
|
|
|
5756
6864
|
}
|
|
5757
6865
|
this._keyboardInteractions = new _utils__WEBPACK_IMPORTED_MODULE_3__.KeyboardInteractions({
|
|
5758
6866
|
canvas: this.canvas,
|
|
5759
|
-
stateMachine: smWithFocusNodes.instance,
|
|
6867
|
+
stateMachine: smWithFocusNodes.instance,
|
|
5760
6868
|
hasFocusNodes: true,
|
|
5761
6869
|
getOverlayElement: function () { var _a, _b; return (_b = (_a = _this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.getSemanticOverlayContainer()) !== null && _b !== void 0 ? _b : null; },
|
|
5762
6870
|
});
|
|
5763
6871
|
};
|
|
6872
|
+
/** Runs inside touchend/mouseup so focusing the proxy raises the mobile keyboard. */
|
|
6873
|
+
Rive.prototype.summonKeyboardForGesture = function () {
|
|
6874
|
+
if (!this._keyboardInteractions)
|
|
6875
|
+
return;
|
|
6876
|
+
var activeSm = this.focusStateMachine;
|
|
6877
|
+
if (!activeSm)
|
|
6878
|
+
return;
|
|
6879
|
+
if (this.wantsTextInputSession(activeSm.focusState().expectsKeyboardInput)) {
|
|
6880
|
+
this._keyboardInteractions.summonForPointer();
|
|
6881
|
+
}
|
|
6882
|
+
};
|
|
6883
|
+
/** expectsKeyboardInput, and (with semantics on) the focused node is a textField. */
|
|
6884
|
+
Rive.prototype.wantsTextInputSession = function (expectsKeyboardInput) {
|
|
6885
|
+
var _a;
|
|
6886
|
+
if (!expectsKeyboardInput)
|
|
6887
|
+
return false;
|
|
6888
|
+
var node = (_a = this._semanticTree) === null || _a === void 0 ? void 0 : _a.focusedNode();
|
|
6889
|
+
return node === undefined || node.role === _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField;
|
|
6890
|
+
};
|
|
6891
|
+
Rive.prototype.advanceAndDrainForPointer = function (elapsedTime, options) {
|
|
6892
|
+
if (!(options === null || options === void 0 ? void 0 : options.pointerDown)) {
|
|
6893
|
+
this.advanceAndReportChanges(elapsedTime);
|
|
6894
|
+
return;
|
|
6895
|
+
}
|
|
6896
|
+
this._inPointerDownDrain = true;
|
|
6897
|
+
try {
|
|
6898
|
+
this.advanceAndReportChanges(elapsedTime);
|
|
6899
|
+
}
|
|
6900
|
+
finally {
|
|
6901
|
+
this._inPointerDownDrain = false;
|
|
6902
|
+
}
|
|
6903
|
+
};
|
|
5764
6904
|
Rive.prototype.cleanupKeyboardInteractions = function () {
|
|
6905
|
+
var _a;
|
|
5765
6906
|
if (this._keyboardInteractions) {
|
|
5766
6907
|
this._keyboardInteractions.cleanup();
|
|
5767
6908
|
this._keyboardInteractions = null;
|
|
5768
6909
|
}
|
|
6910
|
+
this._prevWantsTextInputSession = false;
|
|
6911
|
+
(_a = this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.releaseEditingHost(null, null);
|
|
5769
6912
|
};
|
|
5770
6913
|
/**
|
|
5771
6914
|
* Remove Rive Listeners setup on the canvas
|
|
@@ -6101,56 +7244,69 @@ var Rive = /** @class */ (function () {
|
|
|
6101
7244
|
var _a, _b, _c;
|
|
6102
7245
|
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;
|
|
6103
7246
|
};
|
|
6104
|
-
/**
|
|
6105
|
-
* Poll focus state each frame to see if we should focus/blur the canvas in case
|
|
6106
|
-
* Rive internally updated focus outside of user interaction (e.g., via listener action)
|
|
6107
|
-
*/
|
|
7247
|
+
/** Rive can move focus on its own, so reconcile the text session and DOM focus each frame. */
|
|
6108
7248
|
Rive.prototype.pollFocusState = function () {
|
|
6109
|
-
var _a, _b;
|
|
6110
7249
|
this.ensureKeyboardInteractions();
|
|
6111
|
-
|
|
7250
|
+
var ki = this._keyboardInteractions;
|
|
7251
|
+
var activeSm = ki ? this.focusStateMachine : undefined;
|
|
7252
|
+
if (!ki || !activeSm || !(this.canvas instanceof HTMLCanvasElement)) {
|
|
6112
7253
|
this._prevHasFocus = false;
|
|
7254
|
+
this._prevWantsTextInputSession = false;
|
|
6113
7255
|
return;
|
|
6114
7256
|
}
|
|
6115
|
-
var
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
7257
|
+
var _a = activeSm.focusState(), hasFocus = _a.hasFocus, expectsKeyboardInput = _a.expectsKeyboardInput;
|
|
7258
|
+
this.syncTextInputSession(ki, this.wantsTextInputSession(expectsKeyboardInput));
|
|
7259
|
+
this.syncRiveFocus(ki, this.canvas, hasFocus);
|
|
7260
|
+
};
|
|
7261
|
+
/** Begin/end the text session on wantsSession edges; decorate the proxy while it has DOM focus. */
|
|
7262
|
+
Rive.prototype.syncTextInputSession = function (ki, wantsSession) {
|
|
7263
|
+
var host = ki.editingHost;
|
|
7264
|
+
var overlay = this._accessibilityOverlay;
|
|
7265
|
+
if (wantsSession) {
|
|
7266
|
+
var began = !this._prevWantsTextInputSession;
|
|
7267
|
+
if (began) {
|
|
7268
|
+
// In-domain or opted-in only; during pointer-down, pointer-up focuses instead.
|
|
7269
|
+
var focusProxy = !this._inPointerDownDrain &&
|
|
7270
|
+
(ki.isInFocusDomain(document.activeElement) ||
|
|
7271
|
+
!!this._focusOptions.allowFocusInterrupt);
|
|
7272
|
+
ki.beginTextInputSession(focusProxy);
|
|
7273
|
+
}
|
|
7274
|
+
// The <input> proxy stands in for the semantic DOM field only while it holds DOM focus.
|
|
7275
|
+
if (overlay && this._semanticTree) {
|
|
7276
|
+
if (host.hasDomFocus()) {
|
|
7277
|
+
overlay.syncEditingHost(this._semanticTree, host, began || !overlay.hasEditingHost());
|
|
7278
|
+
}
|
|
7279
|
+
else if (overlay.hasEditingHost()) {
|
|
7280
|
+
overlay.releaseEditingHost(this._semanticTree, host);
|
|
7281
|
+
}
|
|
7282
|
+
}
|
|
6119
7283
|
}
|
|
6120
|
-
if (this.
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
var scope = (_a = this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.getSemanticOverlayContainer();
|
|
6137
|
-
var focusAlreadyInScope = document.activeElement === this.canvas ||
|
|
6138
|
-
((_b = scope === null || scope === void 0 ? void 0 : scope.contains(document.activeElement)) !== null && _b !== void 0 ? _b : false);
|
|
6139
|
-
if (!focusAlreadyInScope && this._focusOptions.allowFocusInterrupt) {
|
|
6140
|
-
this.canvas.focus();
|
|
6141
|
-
}
|
|
6142
|
-
this._prevHasFocus = true;
|
|
7284
|
+
else if (this._prevWantsTextInputSession) {
|
|
7285
|
+
// Overlay hand-off first, ahead of endTextInputSession's park-on-canvas fallback.
|
|
7286
|
+
overlay === null || overlay === void 0 ? void 0 : overlay.releaseEditingHost(this._semanticTree, host);
|
|
7287
|
+
ki.endTextInputSession();
|
|
7288
|
+
}
|
|
7289
|
+
this._prevWantsTextInputSession = wantsSession;
|
|
7290
|
+
};
|
|
7291
|
+
/** Mirror Rive's hasFocus into the keyboard session state and, on opt-in, canvas focus. */
|
|
7292
|
+
Rive.prototype.syncRiveFocus = function (ki, canvas, hasFocus) {
|
|
7293
|
+
if (hasFocus) {
|
|
7294
|
+
ki.notifyRiveFocused();
|
|
7295
|
+
// Pull focus from outside Rive only with allowFocusInterrupt.
|
|
7296
|
+
if (!this._prevHasFocus) {
|
|
7297
|
+
if (!ki.isInFocusDomain(document.activeElement) &&
|
|
7298
|
+
this._focusOptions.allowFocusInterrupt) {
|
|
7299
|
+
canvas.focus();
|
|
6143
7300
|
}
|
|
6144
|
-
|
|
7301
|
+
this._prevHasFocus = true;
|
|
6145
7302
|
}
|
|
7303
|
+
}
|
|
7304
|
+
else {
|
|
6146
7305
|
this._prevHasFocus = false;
|
|
6147
|
-
//
|
|
6148
|
-
//
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
// intentional no-ops — EntryPending must stay put (a click awaiting its first Tab).
|
|
6152
|
-
if (this._keyboardInteractions.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.RiveFocused) {
|
|
6153
|
-
this._keyboardInteractions.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.NotFocused);
|
|
7306
|
+
// Rive released focus internally (e.g. a state change): drop the Tab trap so the next
|
|
7307
|
+
// Tab leaves the canvas.
|
|
7308
|
+
if (ki.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.RiveFocused) {
|
|
7309
|
+
ki.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.NotFocused);
|
|
6154
7310
|
}
|
|
6155
7311
|
}
|
|
6156
7312
|
};
|
|
@@ -6248,6 +7404,7 @@ var Rive = /** @class */ (function () {
|
|
|
6248
7404
|
instanceId: this._instanceId,
|
|
6249
7405
|
semanticsOptions: this.semanticsOptions,
|
|
6250
7406
|
allowFocusInterrupt: this._focusOptions.allowFocusInterrupt,
|
|
7407
|
+
isEditingHostFocused: this.isEditingHostFocused,
|
|
6251
7408
|
fireAction: function (nodeId, actionType) {
|
|
6252
7409
|
mainSm_1.fireSemanticAction(nodeId, actionType);
|
|
6253
7410
|
},
|