@rive-app/canvas-lite 2.38.5 → 2.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/rive.js CHANGED
@@ -2546,12 +2546,1823 @@ moduleRtn = da;
2546
2546
  /* 5 */
2547
2547
  /***/ ((module) => {
2548
2548
 
2549
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.38.5","description":"A lite version of Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2549
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.39.1","description":"A lite version of Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2550
2550
 
2551
2551
  /***/ }),
2552
2552
  /* 6 */
2553
2553
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2554
2554
 
2555
+ __webpack_require__.r(__webpack_exports__);
2556
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2557
+ /* harmony export */ AccessibilityOverlay: () => (/* reexport safe */ _accessibilityOverlay__WEBPACK_IMPORTED_MODULE_1__.AccessibilityOverlay),
2558
+ /* harmony export */ SemanticActionType: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType),
2559
+ /* harmony export */ SemanticMode: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticMode),
2560
+ /* harmony export */ SemanticRole: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole),
2561
+ /* harmony export */ SemanticState: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState),
2562
+ /* harmony export */ SemanticTrait: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait),
2563
+ /* harmony export */ SemanticTreeModel: () => (/* reexport safe */ _semanticTreeModel__WEBPACK_IMPORTED_MODULE_0__.SemanticTreeModel),
2564
+ /* harmony export */ hasState: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.hasState),
2565
+ /* harmony export */ hasTrait: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.hasTrait),
2566
+ /* harmony export */ roleName: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.roleName),
2567
+ /* harmony export */ stateNames: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.stateNames),
2568
+ /* harmony export */ traitNames: () => (/* reexport safe */ _types__WEBPACK_IMPORTED_MODULE_2__.traitNames)
2569
+ /* harmony export */ });
2570
+ /* harmony import */ var _semanticTreeModel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
2571
+ /* harmony import */ var _accessibilityOverlay__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
2572
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
2573
+
2574
+
2575
+
2576
+
2577
+
2578
+ /***/ }),
2579
+ /* 7 */
2580
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2581
+
2582
+ __webpack_require__.r(__webpack_exports__);
2583
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2584
+ /* harmony export */ SemanticTreeModel: () => (/* binding */ SemanticTreeModel)
2585
+ /* harmony export */ });
2586
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
2587
+ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
2588
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
2589
+ if (ar || !(i in from)) {
2590
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
2591
+ ar[i] = from[i];
2592
+ }
2593
+ }
2594
+ return to.concat(ar || Array.prototype.slice.call(from));
2595
+ };
2596
+
2597
+ /**
2598
+ * Maintains an in-memory semantic tree built from incremental
2599
+ * {@link SemanticsDiff} updates received each frame from the WASM runtime.
2600
+ *
2601
+ * Processing order within {@link applyDiff} follows the contract defined in
2602
+ * `semantic_snapshot.hpp`: removed → added → moved → childrenUpdated →
2603
+ * updatedSemantic → updatedGeometry.
2604
+ */
2605
+ var SemanticTreeModel = /** @class */ (function () {
2606
+ function SemanticTreeModel() {
2607
+ this._nodesById = new Map();
2608
+ this._roots = [];
2609
+ this._semanticVersion = 0;
2610
+ this._geometryVersion = 0;
2611
+ this._geometryChangedIds = new Set();
2612
+ this._semanticChangedIds = new Set();
2613
+ this._debug = false;
2614
+ }
2615
+ Object.defineProperty(SemanticTreeModel.prototype, "nodeCount", {
2616
+ get: function () {
2617
+ return this._nodesById.size;
2618
+ },
2619
+ enumerable: false,
2620
+ configurable: true
2621
+ });
2622
+ Object.defineProperty(SemanticTreeModel.prototype, "semanticVersion", {
2623
+ /** Bumped when semantic content or tree structure changes. */
2624
+ get: function () {
2625
+ return this._semanticVersion;
2626
+ },
2627
+ enumerable: false,
2628
+ configurable: true
2629
+ });
2630
+ Object.defineProperty(SemanticTreeModel.prototype, "geometryVersion", {
2631
+ /** Bumped when node bounds change without a semantic/structural change. */
2632
+ get: function () {
2633
+ return this._geometryVersion;
2634
+ },
2635
+ enumerable: false,
2636
+ configurable: true
2637
+ });
2638
+ Object.defineProperty(SemanticTreeModel.prototype, "geometryChangedIds", {
2639
+ /** Node IDs whose bounds changed in the most recent {@link applyDiff}. */
2640
+ get: function () {
2641
+ return this._geometryChangedIds;
2642
+ },
2643
+ enumerable: false,
2644
+ configurable: true
2645
+ });
2646
+ Object.defineProperty(SemanticTreeModel.prototype, "semanticChangedIds", {
2647
+ /**
2648
+ * Node IDs whose semantic fields (role/label/value/hint/flags/headingLevel)
2649
+ * changed in the most recent {@link applyDiff}. Structural changes (moves,
2650
+ * child reorders, removals) bump {@link semanticVersion} but don't mark
2651
+ * nodes here — element attributes don't depend on tree position.
2652
+ */
2653
+ get: function () {
2654
+ return this._semanticChangedIds;
2655
+ },
2656
+ enumerable: false,
2657
+ configurable: true
2658
+ });
2659
+ Object.defineProperty(SemanticTreeModel.prototype, "roots", {
2660
+ /** Root node IDs in sibling order. */
2661
+ get: function () {
2662
+ return this._roots;
2663
+ },
2664
+ enumerable: false,
2665
+ configurable: true
2666
+ });
2667
+ /** Look up a node by its ID, or undefined if not in the tree. */
2668
+ SemanticTreeModel.prototype.nodeById = function (id) {
2669
+ return this._nodesById.get(id);
2670
+ };
2671
+ /** Current index of a node among its siblings (or roots), or -1 if absent. */
2672
+ SemanticTreeModel.prototype.siblingIndexOf = function (id) {
2673
+ var node = this._nodesById.get(id);
2674
+ if (!node)
2675
+ return -1;
2676
+ if (node.parentId < 0)
2677
+ return this._roots.indexOf(id);
2678
+ var parent = this._nodesById.get(node.parentId);
2679
+ return parent ? parent.children.indexOf(id) : -1;
2680
+ };
2681
+ /** Detach a node from its current parent (or from roots). */
2682
+ SemanticTreeModel.prototype.detach = function (id) {
2683
+ var node = this._nodesById.get(id);
2684
+ if (!node)
2685
+ return;
2686
+ if (node.parentId < 0) {
2687
+ var idx = this._roots.indexOf(id);
2688
+ if (idx !== -1)
2689
+ this._roots.splice(idx, 1);
2690
+ }
2691
+ else {
2692
+ var parent_1 = this._nodesById.get(node.parentId);
2693
+ if (parent_1) {
2694
+ var idx = parent_1.children.indexOf(id);
2695
+ if (idx !== -1)
2696
+ parent_1.children.splice(idx, 1);
2697
+ }
2698
+ }
2699
+ };
2700
+ /** Attach a node under a parent at a given sibling index (or as root). */
2701
+ SemanticTreeModel.prototype.attach = function (id, parentId, siblingIndex) {
2702
+ var node = this._nodesById.get(id);
2703
+ if (!node)
2704
+ return;
2705
+ if (parentId < 0) {
2706
+ node.parentId = -1;
2707
+ var idx = clamp(siblingIndex, 0, this._roots.length);
2708
+ this._roots.splice(idx, 0, id);
2709
+ }
2710
+ else {
2711
+ var parent_2 = this._nodesById.get(parentId);
2712
+ if (!parent_2) {
2713
+ node.parentId = -1;
2714
+ this._roots.push(id);
2715
+ }
2716
+ else {
2717
+ node.parentId = parentId;
2718
+ var idx = clamp(siblingIndex, 0, parent_2.children.length);
2719
+ parent_2.children.splice(idx, 0, id);
2720
+ }
2721
+ }
2722
+ };
2723
+ /** Recursively remove a node and all descendants. */
2724
+ SemanticTreeModel.prototype.removeSubtree = function (id) {
2725
+ var node = this._nodesById.get(id);
2726
+ if (!node)
2727
+ return;
2728
+ // Copy children array — we're mutating during traversal
2729
+ var kids = __spreadArray([], node.children, true);
2730
+ for (var _i = 0, kids_1 = kids; _i < kids_1.length; _i++) {
2731
+ var child = kids_1[_i];
2732
+ this.removeSubtree(child);
2733
+ }
2734
+ this.detach(id);
2735
+ this._nodesById.delete(id);
2736
+ };
2737
+ /**
2738
+ * Apply an incremental diff to the tree. Bumps version counters and notifies
2739
+ * listeners only when the tree actually changed.
2740
+ *
2741
+ * No-op diffs (field values identical to current model) do not bump
2742
+ * versions — the native side guards against emitting these, but applyDiff
2743
+ * defends its subscribers regardless.
2744
+ */
2745
+ SemanticTreeModel.prototype.applyDiff = function (diff) {
2746
+ var _a, _b;
2747
+ var _this = this;
2748
+ this._geometryChangedIds.clear();
2749
+ this._semanticChangedIds.clear();
2750
+ var semanticChanged = false;
2751
+ var geometryChanged = false;
2752
+ var markSemantic = function () {
2753
+ semanticChanged = true;
2754
+ };
2755
+ var markSemanticNode = function (id) {
2756
+ semanticChanged = true;
2757
+ _this._semanticChangedIds.add(id);
2758
+ };
2759
+ var markGeometry = function (id) {
2760
+ geometryChanged = true;
2761
+ _this._geometryChangedIds.add(id);
2762
+ };
2763
+ // 1. removed
2764
+ for (var _i = 0, _c = diff.removed; _i < _c.length; _i++) {
2765
+ var id = _c[_i];
2766
+ if (this._nodesById.has(id)) {
2767
+ this.removeSubtree(id);
2768
+ markSemantic();
2769
+ }
2770
+ }
2771
+ // 2. added
2772
+ for (var _d = 0, _e = diff.added; _d < _e.length; _d++) {
2773
+ var n = _e[_d];
2774
+ var existing = this._nodesById.get(n.id);
2775
+ if (existing) {
2776
+ if (semanticFieldsDiffer(existing, n)) {
2777
+ applySemantic(existing, n);
2778
+ markSemanticNode(n.id);
2779
+ }
2780
+ if (geometryFieldsDiffer(existing, n)) {
2781
+ applyGeometry(existing, n);
2782
+ markGeometry(n.id);
2783
+ }
2784
+ }
2785
+ else {
2786
+ this._nodesById.set(n.id, nodeFromDiff(n));
2787
+ markSemanticNode(n.id);
2788
+ markGeometry(n.id);
2789
+ }
2790
+ this.detach(n.id);
2791
+ this.attach(n.id, n.parentId, n.siblingIndex);
2792
+ }
2793
+ // 3. moved
2794
+ // The runtime emits a node as "moved" when its parentId OR siblingIndex
2795
+ // changes, so a reorder-only move (same parent, new index) is still a
2796
+ // structural/semantic change. Compare the actual position before and after
2797
+ // re-attaching so that geometry-only or no-op moves don't bump the semantic
2798
+ // version (which would defeat the semantic/geometry version split).
2799
+ for (var _f = 0, _g = diff.moved; _f < _g.length; _f++) {
2800
+ var n = _g[_f];
2801
+ var existing = this._nodesById.get(n.id);
2802
+ if (!existing)
2803
+ continue;
2804
+ var parentChanged = existing.parentId !== n.parentId;
2805
+ var oldIndex = this.siblingIndexOf(n.id);
2806
+ var geomChanged = geometryFieldsDiffer(existing, n);
2807
+ if (geomChanged) {
2808
+ applyGeometry(existing, n);
2809
+ markGeometry(n.id);
2810
+ }
2811
+ this.detach(n.id);
2812
+ this.attach(n.id, n.parentId, n.siblingIndex);
2813
+ if (parentChanged || this.siblingIndexOf(n.id) !== oldIndex) {
2814
+ markSemantic();
2815
+ }
2816
+ }
2817
+ // 4. childrenUpdated
2818
+ for (var _h = 0, _j = diff.childrenUpdated; _h < _j.length; _h++) {
2819
+ var update = _j[_h];
2820
+ if (update.parentId < 0) {
2821
+ var next = update.childIds.filter(function (id) { return _this._nodesById.has(id); });
2822
+ if (!arraysEqual(this._roots, next)) {
2823
+ this._roots.length = 0;
2824
+ (_a = this._roots).push.apply(_a, next);
2825
+ for (var _k = 0, _l = this._roots; _k < _l.length; _k++) {
2826
+ var id = _l[_k];
2827
+ var node = this._nodesById.get(id);
2828
+ if (node)
2829
+ node.parentId = -1;
2830
+ }
2831
+ markSemantic();
2832
+ }
2833
+ }
2834
+ else {
2835
+ var parent_3 = this._nodesById.get(update.parentId);
2836
+ if (!parent_3)
2837
+ continue;
2838
+ var next = update.childIds.filter(function (id) { return _this._nodesById.has(id); });
2839
+ if (!arraysEqual(parent_3.children, next)) {
2840
+ parent_3.children.length = 0;
2841
+ (_b = parent_3.children).push.apply(_b, next);
2842
+ for (var _m = 0, _o = parent_3.children; _m < _o.length; _m++) {
2843
+ var id = _o[_m];
2844
+ var node = this._nodesById.get(id);
2845
+ if (node)
2846
+ node.parentId = update.parentId;
2847
+ }
2848
+ markSemantic();
2849
+ }
2850
+ }
2851
+ }
2852
+ // 5. updatedSemantic — semantic fields updated
2853
+ for (var _p = 0, _q = diff.updatedSemantic; _p < _q.length; _p++) {
2854
+ var n = _q[_p];
2855
+ var existing = this._nodesById.get(n.id);
2856
+ if (!existing)
2857
+ continue;
2858
+ if (!semanticFieldsDiffer(existing, n))
2859
+ continue;
2860
+ applySemantic(existing, n);
2861
+ markSemanticNode(n.id);
2862
+ }
2863
+ // 6. updatedGeometry — bounds of a semantic node updated
2864
+ for (var _r = 0, _s = diff.updatedGeometry; _r < _s.length; _r++) {
2865
+ var n = _s[_r];
2866
+ var existing = this._nodesById.get(n.id);
2867
+ if (!existing)
2868
+ continue;
2869
+ if (!geometryFieldsDiffer(existing, n))
2870
+ continue;
2871
+ applyGeometry(existing, n);
2872
+ markGeometry(n.id);
2873
+ }
2874
+ if (!semanticChanged && !geometryChanged)
2875
+ return;
2876
+ if (semanticChanged)
2877
+ this._semanticVersion++;
2878
+ if (geometryChanged)
2879
+ this._geometryVersion++;
2880
+ if (this._debug) {
2881
+ this.logDiff(diff, semanticChanged, geometryChanged);
2882
+ }
2883
+ };
2884
+ Object.defineProperty(SemanticTreeModel.prototype, "debug", {
2885
+ /** Enable/disable debug logging of diffs to the console. */
2886
+ set: function (enabled) {
2887
+ this._debug = enabled;
2888
+ },
2889
+ enumerable: false,
2890
+ configurable: true
2891
+ });
2892
+ SemanticTreeModel.prototype.logDiff = function (diff, semanticChanged, geometryChanged) {
2893
+ var lines = [
2894
+ "[rive:semantics] semantic v".concat(this._semanticVersion) +
2895
+ (geometryChanged ? " geometry v".concat(this._geometryVersion) : "") +
2896
+ (semanticChanged ? "" : " (geometry-only)"),
2897
+ ];
2898
+ for (var _i = 0, _a = diff.removed; _i < _a.length; _i++) {
2899
+ var id = _a[_i];
2900
+ lines.push(" - removed #".concat(id));
2901
+ }
2902
+ for (var _b = 0, _c = diff.added; _b < _c.length; _b++) {
2903
+ var n = _c[_b];
2904
+ lines.push(" + added #".concat(n.id, " ").concat((0,_types__WEBPACK_IMPORTED_MODULE_0__.roleName)(n.role)) +
2905
+ (n.label ? " \"".concat(n.label, "\"") : "") +
2906
+ " bounds:(".concat(n.minX.toFixed(1), ",").concat(n.minY.toFixed(1), ")-(").concat(n.maxX.toFixed(1), ",").concat(n.maxY.toFixed(1), ")") +
2907
+ " states=[".concat((0,_types__WEBPACK_IMPORTED_MODULE_0__.stateNames)(n.stateFlags), "]") +
2908
+ " traits=[".concat((0,_types__WEBPACK_IMPORTED_MODULE_0__.traitNames)(n.traitFlags), "]"));
2909
+ }
2910
+ for (var _d = 0, _e = diff.moved; _d < _e.length; _d++) {
2911
+ var n = _e[_d];
2912
+ lines.push(" ~ moved #".concat(n.id, " \u2192 parent=").concat(n.parentId, " idx=").concat(n.siblingIndex) +
2913
+ " bounds:(".concat(n.minX.toFixed(1), ",").concat(n.minY.toFixed(1), ")-(").concat(n.maxX.toFixed(1), ",").concat(n.maxY.toFixed(1), ")"));
2914
+ }
2915
+ for (var _f = 0, _g = diff.childrenUpdated; _f < _g.length; _f++) {
2916
+ var u = _g[_f];
2917
+ lines.push(" \u2195 children of ".concat(u.parentId < 0 ? "root" : "#" + u.parentId, ": [").concat(u.childIds.join(", "), "]"));
2918
+ }
2919
+ for (var _h = 0, _j = diff.updatedSemantic; _h < _j.length; _h++) {
2920
+ var n = _j[_h];
2921
+ lines.push(" \u270E semantic #".concat(n.id, " ").concat((0,_types__WEBPACK_IMPORTED_MODULE_0__.roleName)(n.role)) +
2922
+ (n.label ? " \"".concat(n.label, "\"") : "") +
2923
+ " states=[".concat((0,_types__WEBPACK_IMPORTED_MODULE_0__.stateNames)(n.stateFlags), "]") +
2924
+ " traits=[".concat((0,_types__WEBPACK_IMPORTED_MODULE_0__.traitNames)(n.traitFlags), "]"));
2925
+ }
2926
+ for (var _k = 0, _l = diff.updatedGeometry; _k < _l.length; _k++) {
2927
+ var n = _l[_k];
2928
+ lines.push(" \u229E geometry #".concat(n.id, " (").concat(n.minX.toFixed(1), ",").concat(n.minY.toFixed(1), ")-(").concat(n.maxX.toFixed(1), ",").concat(n.maxY.toFixed(1), ")"));
2929
+ }
2930
+ console.log(lines.join("\n"));
2931
+ };
2932
+ /**
2933
+ * Returns every node in depth-first order, paired with its depth level.
2934
+ * Useful for debug logging / rendering a flat list.
2935
+ */
2936
+ SemanticTreeModel.prototype.flattened = function () {
2937
+ var _this = this;
2938
+ var out = [];
2939
+ var walk = function (id, depth) {
2940
+ var node = _this._nodesById.get(id);
2941
+ if (!node)
2942
+ return;
2943
+ out.push({ depth: depth, node: node });
2944
+ for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
2945
+ var child = _a[_i];
2946
+ walk(child, depth + 1);
2947
+ }
2948
+ };
2949
+ for (var _i = 0, _a = this._roots; _i < _a.length; _i++) {
2950
+ var root = _a[_i];
2951
+ walk(root, 0);
2952
+ }
2953
+ return out;
2954
+ };
2955
+ return SemanticTreeModel;
2956
+ }());
2957
+
2958
+ function clamp(v, min, max) {
2959
+ return v < min ? min : v > max ? max : v;
2960
+ }
2961
+ function arraysEqual(a, b) {
2962
+ if (a.length !== b.length)
2963
+ return false;
2964
+ for (var i = 0; i < a.length; i++) {
2965
+ if (a[i] !== b[i])
2966
+ return false;
2967
+ }
2968
+ return true;
2969
+ }
2970
+ function nodeFromDiff(n) {
2971
+ return {
2972
+ id: n.id,
2973
+ parentId: -1,
2974
+ role: n.role,
2975
+ label: n.label,
2976
+ value: n.value,
2977
+ hint: n.hint,
2978
+ stateFlags: n.stateFlags,
2979
+ traitFlags: n.traitFlags,
2980
+ headingLevel: n.headingLevel,
2981
+ minX: n.minX,
2982
+ minY: n.minY,
2983
+ maxX: n.maxX,
2984
+ maxY: n.maxY,
2985
+ children: [],
2986
+ };
2987
+ }
2988
+ /** Compare role/label/value/hint/stateFlags/traitFlags/headingLevel. */
2989
+ function semanticFieldsDiffer(a, b) {
2990
+ return (a.role !== b.role ||
2991
+ a.label !== b.label ||
2992
+ a.value !== b.value ||
2993
+ a.hint !== b.hint ||
2994
+ a.stateFlags !== b.stateFlags ||
2995
+ a.traitFlags !== b.traitFlags ||
2996
+ a.headingLevel !== b.headingLevel);
2997
+ }
2998
+ /** Compare only bounds (minX/minY/maxX/maxY). */
2999
+ function geometryFieldsDiffer(a, b) {
3000
+ return (a.minX !== b.minX ||
3001
+ a.minY !== b.minY ||
3002
+ a.maxX !== b.maxX ||
3003
+ a.maxY !== b.maxY);
3004
+ }
3005
+ function applySemantic(target, src) {
3006
+ target.role = src.role;
3007
+ target.label = src.label;
3008
+ target.value = src.value;
3009
+ target.hint = src.hint;
3010
+ target.stateFlags = src.stateFlags;
3011
+ target.traitFlags = src.traitFlags;
3012
+ target.headingLevel = src.headingLevel;
3013
+ }
3014
+ function applyGeometry(target, src) {
3015
+ target.minX = src.minX;
3016
+ target.minY = src.minY;
3017
+ target.maxX = src.maxX;
3018
+ target.maxY = src.maxY;
3019
+ }
3020
+
3021
+
3022
+ /***/ }),
3023
+ /* 8 */
3024
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3025
+
3026
+ __webpack_require__.r(__webpack_exports__);
3027
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3028
+ /* harmony export */ SemanticActionType: () => (/* binding */ SemanticActionType),
3029
+ /* harmony export */ SemanticMode: () => (/* binding */ SemanticMode),
3030
+ /* harmony export */ SemanticRole: () => (/* binding */ SemanticRole),
3031
+ /* harmony export */ SemanticState: () => (/* binding */ SemanticState),
3032
+ /* harmony export */ SemanticTrait: () => (/* binding */ SemanticTrait),
3033
+ /* harmony export */ hasState: () => (/* binding */ hasState),
3034
+ /* harmony export */ hasTrait: () => (/* binding */ hasTrait),
3035
+ /* harmony export */ roleName: () => (/* binding */ roleName),
3036
+ /* harmony export */ stateNames: () => (/* binding */ stateNames),
3037
+ /* harmony export */ traitNames: () => (/* binding */ traitNames)
3038
+ /* harmony export */ });
3039
+ // ---------------------------------------------------------------------------
3040
+ // SemanticRole — mirrors rive::SemanticRole
3041
+ // ---------------------------------------------------------------------------
3042
+ var SemanticRole = {
3043
+ none: 0,
3044
+ button: 1,
3045
+ link: 2,
3046
+ checkbox: 3,
3047
+ switchControl: 4,
3048
+ slider: 5,
3049
+ textField: 6,
3050
+ text: 7,
3051
+ image: 8,
3052
+ group: 9,
3053
+ list: 10,
3054
+ listItem: 11,
3055
+ tab: 12,
3056
+ tabList: 13,
3057
+ dialog: 14,
3058
+ alertDialog: 15,
3059
+ radioGroup: 16,
3060
+ radioButton: 17,
3061
+ };
3062
+ // ---------------------------------------------------------------------------
3063
+ // SemanticState — mirrors rive::SemanticState bitmask
3064
+ //
3065
+ // Bits 0-7 are trait-gated (only meaningful when the corresponding
3066
+ // SemanticTrait is set). Bits 8-13 are non-trait states.
3067
+ // ---------------------------------------------------------------------------
3068
+ var SemanticState = {
3069
+ None: 0,
3070
+ // Trait-gated
3071
+ Expanded: 1 << 0, // requires Expandable
3072
+ Selected: 1 << 1, // requires Selectable
3073
+ Checked: 1 << 2, // requires Checkable
3074
+ Mixed: 1 << 3, // requires Checkable; wins over Checked
3075
+ Toggled: 1 << 4, // requires Toggleable
3076
+ Required: 1 << 5, // requires Requirable
3077
+ Disabled: 1 << 6, // requires Enablable
3078
+ Focused: 1 << 7, // requires Focusable
3079
+ // Non-trait
3080
+ Hidden: 1 << 8,
3081
+ LiveRegion: 1 << 9,
3082
+ ReadOnly: 1 << 10,
3083
+ Modal: 1 << 11,
3084
+ Obscured: 1 << 12,
3085
+ Multiline: 1 << 13,
3086
+ };
3087
+ function hasState(flags, state) {
3088
+ return (flags & state) !== 0;
3089
+ }
3090
+ /**
3091
+ * Controls when the instance builds semantic trees and accessibility overlays.
3092
+ *
3093
+ * - `disabled`: no semantics work.
3094
+ * - `enabled`: semantics and overlay are active immediately after load.
3095
+ */
3096
+ var SemanticMode = {
3097
+ Disabled: "disabled",
3098
+ Enabled: "enabled",
3099
+ };
3100
+ // ---------------------------------------------------------------------------
3101
+ // SemanticTrait — mirrors rive::SemanticTrait bitmask
3102
+ //
3103
+ // Traits declare what *capabilities* a node has. A state flag is only
3104
+ // meaningful when its corresponding trait is set.
3105
+ // ---------------------------------------------------------------------------
3106
+ var SemanticTrait = {
3107
+ None: 0,
3108
+ Expandable: 1 << 0,
3109
+ Selectable: 1 << 1,
3110
+ Checkable: 1 << 2,
3111
+ Toggleable: 1 << 3,
3112
+ Requirable: 1 << 4,
3113
+ Enablable: 1 << 5,
3114
+ Focusable: 1 << 6,
3115
+ };
3116
+ function hasTrait(flags, trait) {
3117
+ return (flags & trait) !== 0;
3118
+ }
3119
+ // ---------------------------------------------------------------------------
3120
+ // SemanticActionType — mirrors rive::SemanticActionType
3121
+ // ---------------------------------------------------------------------------
3122
+ var SemanticActionType = {
3123
+ tap: 0,
3124
+ increase: 1,
3125
+ decrease: 2,
3126
+ };
3127
+ // ---------------------------------------------------------------------------
3128
+ // Helpers — readable names for bitmask flags
3129
+ // ---------------------------------------------------------------------------
3130
+ var _roleNames = {};
3131
+ for (var _i = 0, _a = Object.entries(SemanticRole); _i < _a.length; _i++) {
3132
+ var _b = _a[_i], name_1 = _b[0], val = _b[1];
3133
+ _roleNames[val] = name_1;
3134
+ }
3135
+ var _stateEntries = Object.entries(SemanticState).filter(function (_a) {
3136
+ var v = _a[1];
3137
+ return v !== 0;
3138
+ });
3139
+ var _traitEntries = Object.entries(SemanticTrait).filter(function (_a) {
3140
+ var v = _a[1];
3141
+ return v !== 0;
3142
+ });
3143
+ function roleName(role) {
3144
+ var _a;
3145
+ return (_a = _roleNames[role]) !== null && _a !== void 0 ? _a : "unknown(".concat(role, ")");
3146
+ }
3147
+ function stateNames(flags) {
3148
+ if (flags === 0)
3149
+ return "none";
3150
+ var active = [];
3151
+ for (var _i = 0, _stateEntries_1 = _stateEntries; _i < _stateEntries_1.length; _i++) {
3152
+ var _a = _stateEntries_1[_i], name_2 = _a[0], bit = _a[1];
3153
+ if (flags & bit)
3154
+ active.push(name_2);
3155
+ }
3156
+ return active.join(", ") || "none";
3157
+ }
3158
+ function traitNames(flags) {
3159
+ if (flags === 0)
3160
+ return "none";
3161
+ var active = [];
3162
+ for (var _i = 0, _traitEntries_1 = _traitEntries; _i < _traitEntries_1.length; _i++) {
3163
+ var _a = _traitEntries_1[_i], name_3 = _a[0], bit = _a[1];
3164
+ if (flags & bit)
3165
+ active.push(name_3);
3166
+ }
3167
+ return active.join(", ") || "none";
3168
+ }
3169
+
3170
+
3171
+ /***/ }),
3172
+ /* 9 */
3173
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3174
+
3175
+ __webpack_require__.r(__webpack_exports__);
3176
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3177
+ /* harmony export */ AccessibilityOverlay: () => (/* binding */ AccessibilityOverlay)
3178
+ /* harmony export */ });
3179
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
3180
+
3181
+ /**
3182
+ * Creates and manages an invisible DOM tree overlaying a Rive canvas. This is for
3183
+ * screen readers to discover and interact with the Rive content.
3184
+ *
3185
+ * Each semantic node in the {@link SemanticTreeModel} gets a corresponding
3186
+ * DOM element with appropriate ARIA role, states, and action handlers so
3187
+ * assistive technologies (i.e. screen readers) can discover
3188
+ * and interact with the Rive content.
3189
+ *
3190
+ * Each node receives a prefixed ID (`id=rive-{instanceId}-sem-{nodeId}`) to avoid host-page ID collisions.
3191
+ * The nodeID is Rive's semantic node ID from core runtime.
3192
+ * Each node is styled with `pointer-events: none`. Interactive nodes can receive
3193
+ * programmatic focus and keydown events without entering the browser Tab order.
3194
+ */
3195
+ var AccessibilityOverlay = /** @class */ (function () {
3196
+ function AccessibilityOverlay(options) {
3197
+ var _this = this;
3198
+ var _a;
3199
+ this.elements = new Map();
3200
+ /** Visually-hidden description spans keyed by node ID, referenced by aria-describedby. */
3201
+ this.descElements = new Map();
3202
+ this.lastSemanticVersion = -1;
3203
+ this.lastGeometryVersion = -1;
3204
+ /** Text elements whose fit-scale needs recomputing, batched per update (see flushTextGeometry). */
3205
+ this.pendingTextGeometry = [];
3206
+ /** Last measured box-size|text key per text element, to skip redundant re-measures. */
3207
+ this.textGeometryKeys = new WeakMap();
3208
+ this.lastCanvasPositioning = {
3209
+ width: -1, height: -1, offsetTop: -1, offsetLeft: -1,
3210
+ };
3211
+ /**
3212
+ * Set when a ResizeObserver/window-resize signals the canvas geometry may have
3213
+ * changed, cleared once the transform is re-synced. Lets {@link needsUpdate}
3214
+ * report geometry changes without a per-frame `getBoundingClientRect()` reflow.
3215
+ * Starts true so the first update computes the transform.
3216
+ */
3217
+ this._geometryDirty = true;
3218
+ /** True while reconciling the DOM (reserved for future focus-sync guards). */
3219
+ this.isUpdating = false;
3220
+ /**
3221
+ * Single child div of the overlay container that carries the artboard→CSS
3222
+ * transform. All semantic node elements are children of this div and express
3223
+ * their positions in raw artboard-space coordinates. The CSS transform on
3224
+ * this container maps artboard units to CSS pixels in one GPU pass — no
3225
+ * per-node matrix multiplication required.
3226
+ */
3227
+ this.transformContainer = null;
3228
+ this._artboardBounds = { minX: 0, minY: 0, maxX: 0, maxY: 0 };
3229
+ this.repositionTimer = null;
3230
+ this.canvasResizeObserver = null;
3231
+ this.parentResizeObserver = null;
3232
+ /**
3233
+ * Detects canvas *position* drift. See {@link observePosition}.
3234
+ */
3235
+ this.positionObserver = null;
3236
+ this._onWindowResize = function () { return _this.scheduleReposition(); };
3237
+ this.instanceId = options.instanceId;
3238
+ this.fireAction = options.fireAction;
3239
+ this.requestFocus = options.requestFocus;
3240
+ this.clearFocus = options.clearFocus;
3241
+ this.canvas = options.canvas;
3242
+ this.semanticsOptions = options.semanticsOptions;
3243
+ this.allowFocusInterrupt = (_a = options.allowFocusInterrupt) !== null && _a !== void 0 ? _a : false;
3244
+ this.container = this.createContainer(options.canvas);
3245
+ this.attachPositionObservers();
3246
+ }
3247
+ AccessibilityOverlay.prototype.getSemanticOverlayContainer = function () {
3248
+ return this.container;
3249
+ };
3250
+ // ---- Container lifecycle ----
3251
+ // Keep the a11y tree overlay matched to the canvas's position and size:
3252
+ // 1. The canvas resized — ResizeObserver
3253
+ // 2. The canvas's parent resized — ResizeObserver
3254
+ // 3. The window resized — resize event
3255
+ // 4. The canvas moved/drifted — IntersectionObserver (see observePosition)
3256
+ AccessibilityOverlay.prototype.attachPositionObservers = function () {
3257
+ var _this = this;
3258
+ this.canvasResizeObserver = new ResizeObserver(function () { return _this.scheduleReposition(); });
3259
+ this.canvasResizeObserver.observe(this.canvas);
3260
+ var parent = this.canvas.parentElement;
3261
+ if (parent) {
3262
+ this.parentResizeObserver = new ResizeObserver(function () { return _this.scheduleReposition(); });
3263
+ this.parentResizeObserver.observe(parent);
3264
+ }
3265
+ window.addEventListener("resize", this._onWindowResize);
3266
+ this.observePosition();
3267
+ };
3268
+ /**
3269
+ * Arms an IntersectionObserver whose root box is bounded to the canvas, so it
3270
+ * fires when the canvas moves relative to the viewport — position drift that
3271
+ * no ResizeObserver reports. Lets us re-sync the overlay container on a move
3272
+ * instead of recalculating the canvas bounding box every frame.
3273
+ */
3274
+ AccessibilityOverlay.prototype.observePosition = function () {
3275
+ var _this = this;
3276
+ var _a;
3277
+ if (typeof IntersectionObserver === "undefined")
3278
+ return;
3279
+ (_a = this.positionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
3280
+ this.positionObserver = null;
3281
+ var rect = this.canvas.getBoundingClientRect();
3282
+ // Can't frame a zero-area element; it will re-arm on the next reposition.
3283
+ if (!rect.width || !rect.height)
3284
+ return;
3285
+ // Shrink the viewport root box down to exactly the canvas: a negative inset
3286
+ // from each viewport edge to the matching canvas edge, in CSS shorthand
3287
+ // order (top, right, bottom, left). Rounded so sub-pixel jitter doesn't trip
3288
+ // the 1.0 threshold.
3289
+ var insetToPx = function (v) { return "".concat(-Math.round(v), "px"); };
3290
+ var rootMargin = [
3291
+ rect.top, // top: viewport top → canvas top
3292
+ window.innerWidth - rect.right, // right: viewport right → canvas right
3293
+ window.innerHeight - rect.bottom, // bottom: viewport bottom → canvas bottom
3294
+ rect.left, // left: viewport left → canvas left
3295
+ ]
3296
+ .map(insetToPx)
3297
+ .join(" ");
3298
+ // The observer emits an initial notification for the current (contained)
3299
+ // state; ignore that and only react to a subsequent move.
3300
+ var armed = false;
3301
+ this.positionObserver = new IntersectionObserver(function () {
3302
+ if (!armed) {
3303
+ armed = true;
3304
+ return;
3305
+ }
3306
+ _this.scheduleReposition();
3307
+ }, { threshold: 1.0, rootMargin: rootMargin });
3308
+ this.positionObserver.observe(this.canvas);
3309
+ };
3310
+ AccessibilityOverlay.prototype.scheduleReposition = function () {
3311
+ var _this = this;
3312
+ // A resize/move may have changed canvas size/scale/position; force a
3313
+ // transform recompute on the next frame's update.
3314
+ this._geometryDirty = true;
3315
+ if (this.repositionTimer !== null)
3316
+ return;
3317
+ this.repositionTimer = setTimeout(function () {
3318
+ _this.repositionTimer = null;
3319
+ _this.syncContainerGeometry();
3320
+ // Re-arm the position observer at the canvas's new location.
3321
+ _this.observePosition();
3322
+ }, 500); // Throttle to avoid rapid style recalculations
3323
+ };
3324
+ AccessibilityOverlay.prototype.syncContainerGeometry = function () {
3325
+ var rect = this.canvas.getBoundingClientRect();
3326
+ var top = this.canvas.offsetTop;
3327
+ var left = this.canvas.offsetLeft;
3328
+ if (rect.width === this.lastCanvasPositioning.width &&
3329
+ rect.height === this.lastCanvasPositioning.height &&
3330
+ top === this.lastCanvasPositioning.offsetTop &&
3331
+ left === this.lastCanvasPositioning.offsetLeft)
3332
+ return;
3333
+ this.container.style.top = top + "px";
3334
+ this.container.style.left = left + "px";
3335
+ this.container.style.width = rect.width + "px";
3336
+ this.container.style.height = rect.height + "px";
3337
+ this.container.tabIndex = -1;
3338
+ this.lastCanvasPositioning.width = rect.width;
3339
+ this.lastCanvasPositioning.height = rect.height;
3340
+ this.lastCanvasPositioning.offsetTop = top;
3341
+ this.lastCanvasPositioning.offsetLeft = left;
3342
+ };
3343
+ AccessibilityOverlay.prototype.createContainer = function (canvas) {
3344
+ var _a, _b;
3345
+ var container = document.createElement("div");
3346
+ container.id = "rive-a11y-".concat(this.instanceId);
3347
+ container.setAttribute("role", "region");
3348
+ container.setAttribute("aria-label", (_b = (_a = this.semanticsOptions) === null || _a === void 0 ? void 0 : _a.riveCanvasLabel) !== null && _b !== void 0 ? _b : "Rive animation");
3349
+ // Size to the canvas's CSS layout box, not the parent container.
3350
+ var rect = canvas.getBoundingClientRect();
3351
+ container.style.cssText = [
3352
+ "position:absolute",
3353
+ "top:".concat(canvas.offsetTop, "px"),
3354
+ "left:".concat(canvas.offsetLeft, "px"),
3355
+ "width:".concat(rect.width, "px"),
3356
+ "height:".concat(rect.height, "px"),
3357
+ "overflow:hidden",
3358
+ "pointer-events:none",
3359
+ // Visually hidden but still in the accessibility tree.
3360
+ // `display:none` and `visibility:hidden` would hide from AT.
3361
+ "opacity:0",
3362
+ ].join(";");
3363
+ canvas.insertAdjacentElement("afterend", container);
3364
+ return container;
3365
+ };
3366
+ /**
3367
+ * Returns what changed since the last update, or null if nothing changed.
3368
+ *
3369
+ * Callers use this to avoid recomputing the (relatively expensive)
3370
+ * artboard→canvas transform on frames where only node bounds changed in the
3371
+ * tree: the transform only needs recomputing when `layoutChanged` is true.
3372
+ */
3373
+ AccessibilityOverlay.prototype.needsUpdate = function (tree) {
3374
+ var semanticChanged = tree.semanticVersion !== this.lastSemanticVersion;
3375
+ var nodeGeometryChanged = tree.geometryVersion !== this.lastGeometryVersion;
3376
+ var layoutChanged = this._geometryDirty || !this.transformContainer;
3377
+ if (!semanticChanged && !nodeGeometryChanged && !layoutChanged)
3378
+ return null;
3379
+ return { semanticChanged: semanticChanged, nodeGeometryChanged: nodeGeometryChanged, layoutChanged: layoutChanged };
3380
+ };
3381
+ /**
3382
+ * Update the overlay DOM to reflect the current state of the semantic tree.
3383
+ * Call once per frame after `applyDiff` when {@link needsUpdate} reports a
3384
+ * change, when layout/transform inputs are dirty, or when a fresh
3385
+ * `forwardMat` is supplied (even if the tree versions are unchanged).
3386
+ *
3387
+ * @param tree The in-memory semantic tree model
3388
+ * @param forwardMat Artboard→canvas-pixel transform from `computeAlignment`,
3389
+ * or null to reuse the existing CSS transform on the
3390
+ * transform container
3391
+ * @param dpr Device pixel ratio used for the canvas backing store
3392
+ * @param artboardBounds The artboard's own bounding rectangle
3393
+ */
3394
+ AccessibilityOverlay.prototype.update = function (tree, forwardMat, dpr, artboardBounds, change) {
3395
+ var overlayChange = change !== null && change !== void 0 ? change : this.needsUpdate(tree);
3396
+ if (!overlayChange && forwardMat) {
3397
+ overlayChange = {
3398
+ semanticChanged: false,
3399
+ nodeGeometryChanged: false,
3400
+ layoutChanged: true,
3401
+ };
3402
+ }
3403
+ if (!overlayChange)
3404
+ return;
3405
+ this.performUpdate(tree, forwardMat, dpr, artboardBounds, overlayChange);
3406
+ };
3407
+ AccessibilityOverlay.prototype.performUpdate = function (tree, forwardMat, dpr, artboardBounds, change) {
3408
+ var _a;
3409
+ var semanticChanged = change.semanticChanged, nodeGeometryChanged = change.nodeGeometryChanged;
3410
+ // Per-node change sets only describe the most recent applyDiff. If more
3411
+ // than one semantic version elapsed since our last update (first build,
3412
+ // or a diff we never consumed), fall back to re-applying attributes on
3413
+ // every node rather than trusting an incomplete set.
3414
+ var reapplyAllAttributes = tree.semanticVersion - this.lastSemanticVersion > 1;
3415
+ this.lastSemanticVersion = tree.semanticVersion;
3416
+ this.lastGeometryVersion = tree.geometryVersion;
3417
+ this.isUpdating = true;
3418
+ this._artboardBounds = artboardBounds;
3419
+ // Container box + artboard transform only run when a fresh forwardMat was
3420
+ // supplied (layout/transform dirty). Node-only bounds updates reuse the
3421
+ // existing CSS transform and go through updateGeometryForChangedNodes.
3422
+ // Skipping syncContainerGeometry here on semantic-only frames avoids a
3423
+ // getBoundingClientRect() reflow on every animation frame. The throttled
3424
+ // scheduleReposition() path still keeps the container aligned when the page
3425
+ // layout shifts.
3426
+ if (forwardMat) {
3427
+ this.syncContainerGeometry();
3428
+ this.syncTransformContainer(forwardMat, dpr, artboardBounds);
3429
+ // Transform is now in sync with the latest layout.
3430
+ this._geometryDirty = false;
3431
+ }
3432
+ if (semanticChanged) {
3433
+ var rootEl = (_a = this.transformContainer) !== null && _a !== void 0 ? _a : this.container;
3434
+ var activeIds_1 = new Set();
3435
+ this.rebuildChildren(rootEl, tree.roots, tree, 0, // parentLeft in artboard space (transform container origin)
3436
+ 0, // parentTop in artboard space
3437
+ activeIds_1, reapplyAllAttributes);
3438
+ var staleIds_2 = [];
3439
+ this.elements.forEach(function (_el, id) {
3440
+ if (!activeIds_1.has(id))
3441
+ staleIds_2.push(id);
3442
+ });
3443
+ for (var _i = 0, staleIds_1 = staleIds_2; _i < staleIds_1.length; _i++) {
3444
+ var id = staleIds_1[_i];
3445
+ var el = this.elements.get(id);
3446
+ if (el && el.parentNode)
3447
+ el.parentNode.removeChild(el);
3448
+ this.elements.delete(id);
3449
+ var desc = this.descElements.get(id);
3450
+ if (desc && desc.parentNode)
3451
+ desc.parentNode.removeChild(desc);
3452
+ this.descElements.delete(id);
3453
+ }
3454
+ }
3455
+ else if (nodeGeometryChanged) {
3456
+ this.updateGeometryForChangedNodes(tree);
3457
+ }
3458
+ // Text scaling needs layout reads; batch them into one pass after all
3459
+ // position/attribute writes so each frame forces at most one reflow.
3460
+ this.flushTextGeometry();
3461
+ this.isUpdating = false;
3462
+ };
3463
+ /** Remove the overlay from the DOM entirely. */
3464
+ AccessibilityOverlay.prototype.destroy = function () {
3465
+ var _a, _b, _c;
3466
+ if (this.repositionTimer !== null) {
3467
+ clearTimeout(this.repositionTimer);
3468
+ this.repositionTimer = null;
3469
+ }
3470
+ window.removeEventListener("resize", this._onWindowResize);
3471
+ (_a = this.canvasResizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
3472
+ (_b = this.parentResizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
3473
+ (_c = this.positionObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
3474
+ if (this.container.parentNode) {
3475
+ this.container.parentNode.removeChild(this.container);
3476
+ }
3477
+ this.elements.clear();
3478
+ this.descElements.clear();
3479
+ this.pendingTextGeometry.length = 0;
3480
+ };
3481
+ // ---- Tree → DOM reconciliation ----
3482
+ /**
3483
+ * Reconcile a parent DOM element's children with an ordered list of
3484
+ * semantic node IDs. Creates, updates, and reorders elements as needed.
3485
+ *
3486
+ * Node positions are expressed in artboard-space coordinates. The CSS
3487
+ * transform on the transform container maps artboard units to CSS pixels,
3488
+ * so no per-node matrix multiplication is required here.
3489
+ *
3490
+ * @param parentArtboardLeft Absolute artboard minX of the parent node (0 for roots)
3491
+ * @param parentArtboardTop Absolute artboard minY of the parent node (0 for roots)
3492
+ */
3493
+ AccessibilityOverlay.prototype.rebuildChildren = function (parentEl, childIds, tree, parentArtboardLeft, parentArtboardTop, activeIds, applyAllAttributes) {
3494
+ for (var i = 0; i < childIds.length; i++) {
3495
+ var nodeId = childIds[i];
3496
+ var nodeData = tree.nodeById(nodeId);
3497
+ if (!nodeData)
3498
+ continue;
3499
+ activeIds.add(nodeId);
3500
+ var el = this.elements.get(nodeId);
3501
+ var isNew = !el;
3502
+ if (!el) {
3503
+ el = this.createElement(nodeData);
3504
+ this.elements.set(nodeId, el);
3505
+ }
3506
+ // Attributes are only applied to new elements and nodes whose semantic
3507
+ // fields changed in the latest diff. Skipping redundant setAttribute
3508
+ // calls eliminates WebKit AX notifications that knock VoiceOver off its
3509
+ // current element.
3510
+ if (isNew || applyAllAttributes || tree.semanticChangedIds.has(nodeId)) {
3511
+ this.applyAttributes(el, nodeData);
3512
+ }
3513
+ this.applyPosition(el, nodeData, parentArtboardLeft, parentArtboardTop);
3514
+ // Only touch the DOM tree if the element isn't already in the correct
3515
+ // position. Moving a focused element can blur it and knock AT off the
3516
+ // current node.
3517
+ var currentChild = parentEl.children[i];
3518
+ if (currentChild !== el) {
3519
+ if (currentChild) {
3520
+ parentEl.insertBefore(el, currentChild);
3521
+ }
3522
+ else {
3523
+ parentEl.appendChild(el);
3524
+ }
3525
+ }
3526
+ // Reflect the runtime Focused state into DOM focus. Runs after insertion
3527
+ // so the element is attached, and skips elements that already hold focus.
3528
+ // The cheap trait/state flag checks gate the (per-node) DOM queries below,
3529
+ // so the activeElement/closest/contains walks only run for a node that is
3530
+ // actually focusable + focused — not for every node on every frame.
3531
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(nodeData.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable) &&
3532
+ (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(nodeData.stateFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Focused)) {
3533
+ var active = document.activeElement;
3534
+ // While focus is inside one of our modal dialogs, don't pull it back
3535
+ // out to a background node.
3536
+ var focusedModal = active === null || active === void 0 ? void 0 : active.closest('[aria-modal="true"]');
3537
+ var trappedByModal = !!focusedModal &&
3538
+ this.container.contains(focusedModal) &&
3539
+ !focusedModal.contains(el);
3540
+ if (active !== el && !trappedByModal && this.canMoveFocus()) {
3541
+ el.focus();
3542
+ }
3543
+ }
3544
+ // Recurse into children with this node's absolute artboard position.
3545
+ if (nodeData.children.length > 0) {
3546
+ this.rebuildChildren(el, nodeData.children, tree, nodeData.minX, nodeData.minY, activeIds, applyAllAttributes);
3547
+ }
3548
+ // Focus a modal/alert dialog when it first appears (after children are
3549
+ // built so the focus target can be resolved from the subtree).
3550
+ if (isNew)
3551
+ this.autoFocusDialogOnAppear(el, nodeData, tree);
3552
+ }
3553
+ };
3554
+ /**
3555
+ * Reposition only the subtrees whose bounds changed in the latest diff.
3556
+ * Descendants are included because node CSS positions are parent-relative.
3557
+ */
3558
+ AccessibilityOverlay.prototype.updateGeometryForChangedNodes = function (tree) {
3559
+ var _a, _b;
3560
+ for (var _i = 0, _c = Array.from(tree.geometryChangedIds); _i < _c.length; _i++) {
3561
+ var nodeId = _c[_i];
3562
+ var nodeData = tree.nodeById(nodeId);
3563
+ if (!nodeData)
3564
+ continue;
3565
+ var parentLeft = 0;
3566
+ var parentTop = 0;
3567
+ var parentEl = (_a = this.transformContainer) !== null && _a !== void 0 ? _a : this.container;
3568
+ if (nodeData.parentId >= 0) {
3569
+ var parent_1 = tree.nodeById(nodeData.parentId);
3570
+ if (parent_1) {
3571
+ parentLeft = parent_1.minX;
3572
+ parentTop = parent_1.minY;
3573
+ parentEl = (_b = this.elements.get(nodeData.parentId)) !== null && _b !== void 0 ? _b : parentEl;
3574
+ }
3575
+ }
3576
+ this.updateNodeGeometrySubtree(tree, nodeId, parentLeft, parentTop, parentEl);
3577
+ }
3578
+ };
3579
+ AccessibilityOverlay.prototype.updateNodeGeometrySubtree = function (tree, nodeId, parentArtboardLeft, parentArtboardTop, _parentEl) {
3580
+ var nodeData = tree.nodeById(nodeId);
3581
+ if (!nodeData)
3582
+ return;
3583
+ var el = this.elements.get(nodeId);
3584
+ if (!el)
3585
+ return;
3586
+ this.applyPosition(el, nodeData, parentArtboardLeft, parentArtboardTop);
3587
+ for (var _i = 0, _a = nodeData.children; _i < _a.length; _i++) {
3588
+ var childId = _a[_i];
3589
+ this.updateNodeGeometrySubtree(tree, childId, nodeData.minX, nodeData.minY, el);
3590
+ }
3591
+ };
3592
+ /**
3593
+ * Whether the overlay may move focus now. Following focus already inside this
3594
+ * instance is always allowed; pulling it in from the host page is gated behind
3595
+ * allowFocusInterrupt (from the Rive class).
3596
+ */
3597
+ AccessibilityOverlay.prototype.canMoveFocus = function () {
3598
+ var active = document.activeElement;
3599
+ var focusAlreadyInScope = active === this.canvas || this.container.contains(active);
3600
+ return focusAlreadyInScope || this.allowFocusInterrupt;
3601
+ };
3602
+ /**
3603
+ * Move focus into a newly appeared modal/alert dialog so screen readers
3604
+ * announce and read its content (web ATs don't auto-enter a freshly mounted
3605
+ * dialog). Skips when focus can't move (see canMoveFocus) or a descendant
3606
+ * already holds it. The dialog's aria-modal keeps focus trapped inside.
3607
+ */
3608
+ AccessibilityOverlay.prototype.autoFocusDialogOnAppear = function (el, node, tree) {
3609
+ var _a;
3610
+ if (!isModalDialogRole(node.role, node.stateFlags))
3611
+ return;
3612
+ if (!this.canMoveFocus())
3613
+ return;
3614
+ // A descendant already holds focus — don't override it.
3615
+ var active = document.activeElement;
3616
+ if (active && active !== el && el.contains(active))
3617
+ return;
3618
+ var target = (_a = this.routeDefaultFocusTarget(node, tree)) !== null && _a !== void 0 ? _a : el;
3619
+ if (!target.hasAttribute("tabindex"))
3620
+ target.setAttribute("tabindex", "-1");
3621
+ if (document.activeElement !== target)
3622
+ target.focus({ preventScroll: true });
3623
+ };
3624
+ /**
3625
+ * Resolve the element assistive technologies (AT) should focus on appearance. Walks the subtree
3626
+ * depth-first and returns the first focusable node's host element, else the
3627
+ * inner <span> of the first labeled leaf. Container and unlabeled nodes are
3628
+ * descended into but never focused. Returns null if nothing qualifies.
3629
+ */
3630
+ AccessibilityOverlay.prototype.routeDefaultFocusTarget = function (node, tree) {
3631
+ var _a;
3632
+ for (var _i = 0, _b = node.children; _i < _b.length; _i++) {
3633
+ var childId = _b[_i];
3634
+ var child = tree.nodeById(childId);
3635
+ if (!child)
3636
+ continue;
3637
+ var childEl = this.elements.get(childId);
3638
+ // Focusable node → its host element (even if it has children).
3639
+ if (childEl && isFocusableNode(child))
3640
+ return childEl;
3641
+ // Container or unlabeled node → descend without focusing it.
3642
+ if (child.children.length > 0 || !child.label) {
3643
+ var nested = this.routeDefaultFocusTarget(child, tree);
3644
+ if (nested)
3645
+ return nested;
3646
+ continue;
3647
+ }
3648
+ // Labeled leaf → its inner label span.
3649
+ if (childEl) {
3650
+ return (_a = childEl.querySelector(":scope > span")) !== null && _a !== void 0 ? _a : childEl;
3651
+ }
3652
+ }
3653
+ return null;
3654
+ };
3655
+ Object.defineProperty(AccessibilityOverlay.prototype, "nodeIdPrefix", {
3656
+ // ---- Element creation ----
3657
+ /** Shared `id` prefix for all semantic node elements of this instance. */
3658
+ get: function () {
3659
+ return "rive-".concat(this.instanceId, "-sem-");
3660
+ },
3661
+ enumerable: false,
3662
+ configurable: true
3663
+ });
3664
+ /** Recover the semantic node ID from an overlay element, or null. */
3665
+ AccessibilityOverlay.prototype.nodeIdFromElement = function (el) {
3666
+ if (!el.id.startsWith(this.nodeIdPrefix))
3667
+ return null;
3668
+ var raw = el.id.slice(this.nodeIdPrefix.length);
3669
+ // Guard the empty string explicitly: Number("") is 0, not NaN.
3670
+ if (!raw)
3671
+ return null;
3672
+ var id = Number(raw);
3673
+ return Number.isNaN(id) ? null : id;
3674
+ };
3675
+ AccessibilityOverlay.prototype.createElement = function (node) {
3676
+ var tag = tagForRole(node.role);
3677
+ var el = document.createElement(tag);
3678
+ el.id = "".concat(this.nodeIdPrefix).concat(node.id);
3679
+ el.style.cssText = BASE_NODE_STYLE;
3680
+ if (node.role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
3681
+ // The positioned outer div is the AX element
3682
+ // VoiceOver uses for its highlight box; an inner <span> carries the text
3683
+ // without position:absolute (which would strip the span from VoiceOver's
3684
+ // bounds calculation).
3685
+ var textSpan = document.createElement("span");
3686
+ textSpan.style.cssText = SPAN_EXP;
3687
+ el.appendChild(textSpan);
3688
+ }
3689
+ this.attachActionHandlers(el, node);
3690
+ return el;
3691
+ };
3692
+ // ---- Action handlers ----
3693
+ /**
3694
+ * Wire arrow-key roving focus for a group member (tab, radio). Arrow keys
3695
+ * move focus to the next/previous member (wrapping), optionally Home/End jump
3696
+ * to first/last, and the newly focused member receives a tap action.
3697
+ */
3698
+ AccessibilityOverlay.prototype.attachRovingNav = function (el, opts) {
3699
+ var _this = this;
3700
+ el.addEventListener("keydown", function (e) {
3701
+ var target = null;
3702
+ if (e.key === "ArrowRight" || e.key === "ArrowDown")
3703
+ target = "next";
3704
+ else if (e.key === "ArrowLeft" || e.key === "ArrowUp")
3705
+ target = "prev";
3706
+ else if (opts.includeHomeEnd && e.key === "Home")
3707
+ target = "first";
3708
+ else if (opts.includeHomeEnd && e.key === "End")
3709
+ target = "last";
3710
+ if (!target)
3711
+ return;
3712
+ e.preventDefault();
3713
+ var members = opts.members();
3714
+ var idx = members.indexOf(el);
3715
+ if (idx < 0)
3716
+ return;
3717
+ var n = members.length;
3718
+ var next = target === "next" ? members[(idx + 1) % n]
3719
+ : target === "prev" ? members[(idx - 1 + n) % n]
3720
+ : target === "first" ? members[0]
3721
+ : members[n - 1];
3722
+ if (next && next !== el) {
3723
+ next.focus();
3724
+ var nextId = _this.nodeIdFromElement(next);
3725
+ if (nextId !== null)
3726
+ _this.fireAction(nextId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
3727
+ }
3728
+ });
3729
+ };
3730
+ AccessibilityOverlay.prototype.attachActionHandlers = function (el, node) {
3731
+ var _this = this;
3732
+ var role = node.role;
3733
+ var nodeId = node.id;
3734
+ if (isClickableRole(role)) {
3735
+ el.addEventListener("click", function () {
3736
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
3737
+ });
3738
+ // Links activate on Enter only (Space scrolls the page per browser
3739
+ // convention). All other clickable roles accept both Enter and Space.
3740
+ var activationKeys_1 = role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link ? ["Enter"] : ["Enter", " "];
3741
+ el.addEventListener("keydown", function (e) {
3742
+ if (activationKeys_1.includes(e.key)) {
3743
+ e.preventDefault();
3744
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
3745
+ }
3746
+ });
3747
+ }
3748
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider) {
3749
+ el.addEventListener("keydown", function (e) {
3750
+ if (e.key === "ArrowRight" || e.key === "ArrowUp") {
3751
+ e.preventDefault();
3752
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.increase);
3753
+ }
3754
+ else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
3755
+ e.preventDefault();
3756
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.decrease);
3757
+ }
3758
+ });
3759
+ }
3760
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab) {
3761
+ this.attachRovingNav(el, {
3762
+ includeHomeEnd: true,
3763
+ members: function () {
3764
+ var parent = el.parentElement;
3765
+ if (!parent)
3766
+ return [];
3767
+ return Array.from(parent.children).filter(function (c) {
3768
+ return c instanceof HTMLElement && c.getAttribute("role") === "tab";
3769
+ });
3770
+ },
3771
+ });
3772
+ }
3773
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton) {
3774
+ this.attachRovingNav(el, {
3775
+ includeHomeEnd: false,
3776
+ members: function () {
3777
+ var _a;
3778
+ var group = (_a = el.closest('[role="radiogroup"]')) !== null && _a !== void 0 ? _a : el.parentElement;
3779
+ if (!group)
3780
+ return [];
3781
+ return Array.from(group.querySelectorAll('[role="radio"]'));
3782
+ },
3783
+ });
3784
+ }
3785
+ // Focus handler for nodes with the Focusable trait. When AT focuses an
3786
+ // element, notify the C++ runtime so it can update internal focus state
3787
+ // (visual focus rings, etc.). Gated on Focusable trait
3788
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable)) {
3789
+ el.addEventListener("focus", function () {
3790
+ _this.requestFocus(nodeId);
3791
+ });
3792
+ }
3793
+ };
3794
+ // ---- Attribute application ----
3795
+ AccessibilityOverlay.prototype.applyAttributes = function (el, node) {
3796
+ var _a, _b, _c;
3797
+ var role = node.role;
3798
+ var flags = node.stateFlags;
3799
+ var traits = node.traitFlags;
3800
+ // Role
3801
+ var ariaRole = ariaRoleForSemantic(role);
3802
+ if (ariaRole) {
3803
+ setAttr(el, "role", ariaRole);
3804
+ }
3805
+ else {
3806
+ removeAttr(el, "role");
3807
+ }
3808
+ // Links: a bare <a> with no href has no link semantics, so set the role
3809
+ // explicitly (ariaRoleForSemantic returns null for link → native <a>).
3810
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link) {
3811
+ setAttr(el, "role", "link");
3812
+ }
3813
+ // Tabindex — keep the screen-reader overlay out of the browser's sequential
3814
+ // Tab order. Interactive/focusable nodes remain programmatically focusable
3815
+ // so AT/runtime focus sync can still target them when needed. List items are
3816
+ // included because Mobile Safari won't iterate them otherwise.
3817
+ if (isInteractiveRole(role) ||
3818
+ (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable) ||
3819
+ role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.listItem) {
3820
+ setAttr(el, "tabindex", "-1");
3821
+ }
3822
+ else {
3823
+ removeAttr(el, "tabindex");
3824
+ }
3825
+ // Label / value / hint
3826
+ if (node.label) {
3827
+ setAttr(el, "aria-label", node.label);
3828
+ }
3829
+ else {
3830
+ removeAttr(el, "aria-label");
3831
+ }
3832
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider) {
3833
+ if (node.value) {
3834
+ // aria-valuenow must be numeric; keep the display string (e.g. "75%")
3835
+ // in aria-valuetext only.
3836
+ var numericValue = parseFloat(node.value);
3837
+ if (Number.isFinite(numericValue)) {
3838
+ setAttr(el, "aria-valuenow", String(numericValue));
3839
+ }
3840
+ else {
3841
+ removeAttr(el, "aria-valuenow");
3842
+ }
3843
+ setAttr(el, "aria-valuetext", node.value);
3844
+ }
3845
+ else {
3846
+ removeAttr(el, "aria-valuenow");
3847
+ removeAttr(el, "aria-valuetext");
3848
+ }
3849
+ // TODO: aria-valuemin / aria-valuemax are required by ARIA.
3850
+ // Defaulting to horizontal; vertical sliders need orientation data from C++.
3851
+ setAttr(el, "aria-orientation", "horizontal");
3852
+ setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.ReadOnly));
3853
+ }
3854
+ else {
3855
+ removeAttr(el, "aria-valuenow");
3856
+ removeAttr(el, "aria-valuetext");
3857
+ removeAttr(el, "aria-orientation");
3858
+ removeAttr(el, "aria-readonly");
3859
+ }
3860
+ if (node.hint) {
3861
+ var descId = "rive-".concat(this.instanceId, "-desc-").concat(node.id);
3862
+ var descEl = this.descElements.get(node.id);
3863
+ if (!descEl) {
3864
+ descEl = document.createElement("span");
3865
+ descEl.id = descId;
3866
+ descEl.style.cssText = DESC_SPAN_STYLE;
3867
+ this.container.appendChild(descEl);
3868
+ this.descElements.set(node.id, descEl);
3869
+ }
3870
+ if (descEl.textContent !== node.hint)
3871
+ descEl.textContent = node.hint;
3872
+ setAttr(el, "aria-describedby", descId);
3873
+ }
3874
+ else {
3875
+ removeAttr(el, "aria-describedby");
3876
+ var staleDesc = this.descElements.get(node.id);
3877
+ if (staleDesc) {
3878
+ if (staleDesc.parentNode)
3879
+ staleDesc.parentNode.removeChild(staleDesc);
3880
+ this.descElements.delete(node.id);
3881
+ }
3882
+ }
3883
+ // Text nodes: use textContent rather than aria-label so screen readers
3884
+ // announce the text in virtual/browse mode (aria-label on a bare <span>
3885
+ // with no widget role is ignored by some AT in document browse mode).
3886
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
3887
+ var textSpan = (_a = el.querySelector(":scope > span")) !== null && _a !== void 0 ? _a : el;
3888
+ var text = (_b = node.label) !== null && _b !== void 0 ? _b : "";
3889
+ if (textSpan.textContent !== text)
3890
+ textSpan.textContent = text;
3891
+ removeAttr(el, "aria-label");
3892
+ if (node.headingLevel > 0) {
3893
+ setAttr(el, "role", "heading");
3894
+ setAttr(el, "aria-level", String(node.headingLevel));
3895
+ }
3896
+ else {
3897
+ // The generic role branch above already cleared role="heading";
3898
+ // aria-level must go with it when a heading reverts to plain text.
3899
+ removeAttr(el, "aria-level");
3900
+ }
3901
+ }
3902
+ // ---- Trait-gated states ----
3903
+ // Only set the ARIA property when the trait is present. When the trait
3904
+ // is absent, remove the attribute so AT sees "not applicable" rather
3905
+ // than "false".
3906
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Expandable) && ARIA_EXPANDED_ROLES.has(role)) {
3907
+ setBoolAttr(el, "aria-expanded", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Expanded));
3908
+ }
3909
+ else {
3910
+ removeAttr(el, "aria-expanded");
3911
+ }
3912
+ // aria-selected is required on ALL tabs per ARIA spec regardless of trait;
3913
+ // for other roles it is trait-gated and guarded to ARIA_SELECTED_ROLES.
3914
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab) {
3915
+ setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Selected));
3916
+ }
3917
+ else if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Selectable) && ARIA_SELECTED_ROLES.has(role)) {
3918
+ setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Selected));
3919
+ }
3920
+ else {
3921
+ removeAttr(el, "aria-selected");
3922
+ }
3923
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Checkable) && ARIA_CHECKED_ROLES.has(role)) {
3924
+ // Mixed wins over Checked per the C++ precedence contract, but
3925
+ // role="switch" only accepts true/false — "mixed" is invalid per ARIA.
3926
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Mixed) && role !== _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl) {
3927
+ setAttr(el, "aria-checked", "mixed");
3928
+ }
3929
+ else {
3930
+ setBoolAttr(el, "aria-checked", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Checked));
3931
+ }
3932
+ }
3933
+ else {
3934
+ removeAttr(el, "aria-checked");
3935
+ }
3936
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Toggleable)) {
3937
+ if (ARIA_PRESSED_ROLES.has(role)) {
3938
+ setBoolAttr(el, "aria-pressed", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Toggled));
3939
+ }
3940
+ else {
3941
+ removeAttr(el, "aria-pressed");
3942
+ }
3943
+ // switch uses aria-checked (not aria-pressed) for its on/off state.
3944
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl) {
3945
+ setBoolAttr(el, "aria-checked", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Toggled));
3946
+ }
3947
+ }
3948
+ else {
3949
+ removeAttr(el, "aria-pressed");
3950
+ }
3951
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Requirable) && ARIA_REQUIRED_ROLES.has(role)) {
3952
+ setBoolAttr(el, "aria-required", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Required));
3953
+ }
3954
+ else {
3955
+ removeAttr(el, "aria-required");
3956
+ }
3957
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Enablable)) {
3958
+ setBoolAttr(el, "aria-disabled", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Disabled));
3959
+ }
3960
+ else {
3961
+ removeAttr(el, "aria-disabled");
3962
+ }
3963
+ // ---- Non-trait states ----
3964
+ // Hide from AT when explicitly hidden, or when an image has no accessible
3965
+ // name — a nameless role="img" is a WCAG 1.1.1 violation; treat it as
3966
+ // decorative instead.
3967
+ var isDecorativeImage = role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.image && !node.label;
3968
+ 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) {
3969
+ setAttr(el, "aria-hidden", "true");
3970
+ }
3971
+ else {
3972
+ removeAttr(el, "aria-hidden");
3973
+ }
3974
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.LiveRegion)) {
3975
+ setAttr(el, "aria-live", "polite");
3976
+ }
3977
+ else {
3978
+ removeAttr(el, "aria-live");
3979
+ }
3980
+ // textField-specific
3981
+ // TODO: Details here may change once we implement text inputs
3982
+ if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField) {
3983
+ setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.ReadOnly));
3984
+ setBoolAttr(el, "aria-multiline", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Multiline));
3985
+ // Surface the current field value as DOM text so screen readers can
3986
+ // announce it. Only safe when the node has no semantic children —
3987
+ // setting textContent would remove any child elements from the DOM.
3988
+ if (node.children.length === 0) {
3989
+ var value = (_c = node.value) !== null && _c !== void 0 ? _c : "";
3990
+ if (el.textContent !== value)
3991
+ el.textContent = value;
3992
+ }
3993
+ }
3994
+ else {
3995
+ removeAttr(el, "aria-multiline");
3996
+ }
3997
+ // alertDialog is always modal per WAI-ARIA; a plain dialog only when the Modal state flag is set.
3998
+ if (isModalDialogRole(role, flags)) {
3999
+ setAttr(el, "aria-modal", "true");
4000
+ }
4001
+ else {
4002
+ removeAttr(el, "aria-modal");
4003
+ }
4004
+ };
4005
+ // ---- Positioning ----
4006
+ /**
4007
+ * Positions an element in artboard-space coordinates relative to its parent.
4008
+ *
4009
+ * Node bounds stay in raw artboard units — the CSS `transform: matrix(...)`
4010
+ * on the transform container maps artboard units to CSS pixels in one GPU
4011
+ * pass. No per-node forwardMat multiplication or DPR division needed here.
4012
+ *
4013
+ * Round to whole artboard units before comparing to avoid triggering AX
4014
+ * layout notifications from sub-unit floating-point animation jitter.
4015
+ */
4016
+ AccessibilityOverlay.prototype.applyPosition = function (el, node, parentArtboardLeft, parentArtboardTop) {
4017
+ // Clamp each node's rect to the artboard viewport before computing CSS.
4018
+ // Without this, nodes whose artboard bounds exceed the artboard (e.g. a
4019
+ // scroll list container whose height is the full content, not the viewport)
4020
+ // produce CSS heights that overflow the transform container. WebKit then
4021
+ // unions all descendant AX rects and extends the container's AX origin
4022
+ // above the canvas regardless of overflow:hidden on ancestors.
4023
+ var ab = this._artboardBounds;
4024
+ var clampedMinX = Math.max(node.minX, ab.minX);
4025
+ var clampedMinY = Math.max(node.minY, ab.minY);
4026
+ var clampedMaxX = Math.min(node.maxX, ab.maxX);
4027
+ var clampedMaxY = Math.min(node.maxY, ab.maxY);
4028
+ var elLeft = clampedMinX - parentArtboardLeft;
4029
+ var elTop = clampedMinY - parentArtboardTop;
4030
+ var elWidth = Math.max(0, clampedMaxX - clampedMinX);
4031
+ var elHeight = Math.max(0, clampedMaxY - clampedMinY);
4032
+ var tx = Math.round(elLeft);
4033
+ var ty = Math.round(elTop);
4034
+ var pxWidth = Math.round(elWidth) + "px";
4035
+ var pxHeight = Math.round(elHeight) + "px";
4036
+ // Use left/top layout properties for positioning. VoiceOver reliably
4037
+ // handles layout position + a single ancestor CSS transform (the transform
4038
+ // container). Chaining CSS transforms across multiple stacking contexts
4039
+ // (transform container → node identity → item translate) caused VoiceOver
4040
+ // to compute the correct SIZE but wrong POSITION. Artboard clamping above
4041
+ // guarantees tx/ty are always ≥ 0, so the negative-top overflow problem
4042
+ // that originally prompted the switch to CSS transforms no longer applies.
4043
+ var pxLeft = tx + "px";
4044
+ var pxTop = ty + "px";
4045
+ if (el.style.left !== pxLeft)
4046
+ el.style.left = pxLeft;
4047
+ if (el.style.top !== pxTop)
4048
+ el.style.top = pxTop;
4049
+ if (el.style.width !== pxWidth)
4050
+ el.style.width = pxWidth;
4051
+ if (el.style.height !== pxHeight)
4052
+ el.style.height = pxHeight;
4053
+ // Clear any CSS transform from a previous render pass.
4054
+ if (el.style.transform)
4055
+ el.style.transform = "";
4056
+ if (node.role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
4057
+ this.pendingTextGeometry.push(el);
4058
+ }
4059
+ };
4060
+ /**
4061
+ * Scale each queued text span to fit its layout box, batched so a frame
4062
+ * pays at most one synchronous layout: all measurement-reset writes first,
4063
+ * then all rect reads, then all transform writes. Interleaving
4064
+ * write→read→write per node would force a reflow per text node instead.
4065
+ *
4066
+ * Nodes whose box size and text are unchanged since the last pass are
4067
+ * skipped entirely (their existing transform is still correct — the scale
4068
+ * is a ratio of two rects, so ancestor transform changes cancel out).
4069
+ */
4070
+ AccessibilityOverlay.prototype.flushTextGeometry = function () {
4071
+ var _a;
4072
+ if (this.pendingTextGeometry.length === 0)
4073
+ return;
4074
+ // Phase 1 — writes: reset spans to their natural size for measurement.
4075
+ // The previous pass's scale must be cleared, or the rect reads below
4076
+ // would measure the scaled span and compound the correction.
4077
+ var toMeasure = [];
4078
+ for (var _i = 0, _b = this.pendingTextGeometry; _i < _b.length; _i++) {
4079
+ var host = _b[_i];
4080
+ var span = (_a = host.querySelector(":scope > span")) !== null && _a !== void 0 ? _a : host;
4081
+ var key = "".concat(host.style.width, "|").concat(host.style.height, "|").concat(span.textContent);
4082
+ if (this.textGeometryKeys.get(host) === key)
4083
+ continue;
4084
+ span.style.width = "auto";
4085
+ span.style.height = "auto";
4086
+ span.style.transformOrigin = "0 0";
4087
+ span.style.transform = "";
4088
+ toMeasure.push({ host: host, span: span, key: key });
4089
+ }
4090
+ this.pendingTextGeometry.length = 0;
4091
+ // Phase 2 — reads: one layout pass covers every rect measurement.
4092
+ var transforms = toMeasure.map(function (_a) {
4093
+ var host = _a.host, span = _a.span;
4094
+ var parentRect = host.getBoundingClientRect();
4095
+ var natural = span.getBoundingClientRect();
4096
+ if (natural.width > 0 && natural.height > 0) {
4097
+ var scaleX = parentRect.width / natural.width;
4098
+ var scaleY = parentRect.height / natural.height;
4099
+ return "scale(".concat(scaleX, ", ").concat(scaleY, ")");
4100
+ }
4101
+ return "none";
4102
+ });
4103
+ // Phase 3 — writes: apply all transforms.
4104
+ for (var i = 0; i < toMeasure.length; i++) {
4105
+ var _c = toMeasure[i], host = _c.host, span = _c.span, key = _c.key;
4106
+ span.style.transform = transforms[i];
4107
+ this.textGeometryKeys.set(host, key);
4108
+ }
4109
+ };
4110
+ // ---- Transform container ----
4111
+ /**
4112
+ * Creates (on first call) and updates the artboard-space transform container.
4113
+ *
4114
+ * The container is sized to the artboard dimensions and carries a CSS
4115
+ * `transform: matrix(...)` equivalent to `forwardMat / dpr`. All semantic
4116
+ * node elements are children of this container and use raw artboard
4117
+ * coordinates as their CSS `left/top/width/height`, so the CSS compositor
4118
+ * applies the artboard→screen mapping in one pass.
4119
+ */
4120
+ AccessibilityOverlay.prototype.syncTransformContainer = function (forwardMat, dpr, artboardBounds) {
4121
+ if (!this.transformContainer) {
4122
+ var tc = document.createElement("div");
4123
+ tc.style.cssText = [
4124
+ "position:absolute",
4125
+ "top:0",
4126
+ "left:0",
4127
+ // overflow:visible — artboard viewport clamping is done per-node in
4128
+ // applyPosition
4129
+ "overflow:visible",
4130
+ "pointer-events:none",
4131
+ "transform-origin:0 0",
4132
+ ].join(";");
4133
+ this.container.appendChild(tc);
4134
+ this.transformContainer = tc;
4135
+ }
4136
+ var w = artboardBounds.maxX - artboardBounds.minX;
4137
+ var h = artboardBounds.maxY - artboardBounds.minY;
4138
+ this.transformContainer.style.width = Math.round(w) + "px";
4139
+ this.transformContainer.style.height = Math.round(h) + "px";
4140
+ var s = 1 / (dpr || 1);
4141
+ var a = forwardMat.xx * s;
4142
+ var b = forwardMat.xy * s;
4143
+ var c = forwardMat.yx * s;
4144
+ var d = forwardMat.yy * s;
4145
+ var tx = forwardMat.tx * s;
4146
+ var ty = forwardMat.ty * s;
4147
+ this.transformContainer.style.transform =
4148
+ "matrix(".concat(a, ",").concat(b, ",").concat(c, ",").concat(d, ",").concat(tx, ",").concat(ty, ")");
4149
+ };
4150
+ return AccessibilityOverlay;
4151
+ }());
4152
+
4153
+ // ---------------------------------------------------------------------------
4154
+ // Static helpers (module-private)
4155
+ // ---------------------------------------------------------------------------
4156
+ // ---------------------------------------------------------------------------
4157
+ // ARIA attribute eligibility — role sets
4158
+ //
4159
+ // Each set lists the Rive roles for which a given ARIA attribute is valid per
4160
+ // WAI-ARIA 1.2 ("Used in roles" + "Inherits into roles"). The trait-gated
4161
+ // blocks in applyAttributes check these before setting an attribute so that
4162
+ // C++ nodes with unexpected trait combinations never produce invalid markup.
4163
+ //
4164
+ // To add a new role: append it to the relevant set(s) here — no other changes
4165
+ // needed in applyAttributes.
4166
+ // ---------------------------------------------------------------------------
4167
+ /** aria-expanded: button, link, checkbox, switch (inherits button), tab. */
4168
+ var ARIA_EXPANDED_ROLES = new Set([
4169
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button,
4170
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link,
4171
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
4172
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl,
4173
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab,
4174
+ ]);
4175
+ /**
4176
+ * aria-selected: tab is the only role in our current set that natively
4177
+ * supports it. Tab is also handled by an explicit unconditional branch in
4178
+ * applyAttributes (ARIA requires it there regardless of Selectable trait), but
4179
+ * the set still lists it so the constraint is visible in one place.
4180
+ */
4181
+ var ARIA_SELECTED_ROLES = new Set([
4182
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab,
4183
+ ]);
4184
+ /** aria-checked: checkbox, radio, switch. */
4185
+ var ARIA_CHECKED_ROLES = new Set([
4186
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
4187
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton,
4188
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl,
4189
+ ]);
4190
+ /**
4191
+ * aria-pressed: button only. switch is a button subclass in ARIA but uses
4192
+ * aria-checked (not aria-pressed) for its on/off state — it is intentionally
4193
+ * excluded here and handled separately in the Toggleable block.
4194
+ */
4195
+ var ARIA_PRESSED_ROLES = new Set([
4196
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button,
4197
+ ]);
4198
+ /** aria-required: checkbox, textbox, radiogroup. */
4199
+ var ARIA_REQUIRED_ROLES = new Set([
4200
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
4201
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField,
4202
+ _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioGroup,
4203
+ ]);
4204
+ // ---------------------------------------------------------------------------
4205
+ /** Style for visually-hidden description spans used with aria-describedby. */
4206
+ var DESC_SPAN_STYLE = [
4207
+ "position:absolute",
4208
+ "width:1px",
4209
+ "height:1px",
4210
+ "overflow:hidden",
4211
+ "pointer-events:none",
4212
+ "left:-9999px",
4213
+ ].join(";");
4214
+ var BASE_NODE_STYLE = [
4215
+ "position:absolute",
4216
+ "pointer-events:none",
4217
+ "box-sizing:border-box",
4218
+ "overflow:visible",
4219
+ "margin:0",
4220
+ "padding:0",
4221
+ "transform-origin: 0px 0px 0px",
4222
+ "border:none",
4223
+ "background:transparent",
4224
+ "color:transparent",
4225
+ // "list-style:none",
4226
+ ].join(";");
4227
+ var SPAN_EXP = [
4228
+ "display:inline-block",
4229
+ "white-space:nowrap",
4230
+ "pointer-events:none",
4231
+ ].join(";");
4232
+ /**
4233
+ * Attribute writers that skip same-value mutations. Even a no-op setAttribute
4234
+ * fires a mutation record, and whether AX layers dedupe those is
4235
+ * browser-specific — skipping the write is the only browser-proof guard.
4236
+ */
4237
+ function setAttr(el, attr, value) {
4238
+ if (el.getAttribute(attr) !== value)
4239
+ el.setAttribute(attr, value);
4240
+ }
4241
+ function removeAttr(el, attr) {
4242
+ if (el.hasAttribute(attr))
4243
+ el.removeAttribute(attr);
4244
+ }
4245
+ function setBoolAttr(el, attr, value) {
4246
+ setAttr(el, attr, value ? "true" : "false");
4247
+ }
4248
+ /** Roles that receive click/Enter/Space action handlers. */
4249
+ function isClickableRole(role) {
4250
+ switch (role) {
4251
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
4252
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
4253
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
4254
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
4255
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
4256
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
4257
+ return true;
4258
+ default:
4259
+ return false;
4260
+ }
4261
+ }
4262
+ /** Roles that receive tabindex="-1" for programmatic/AT focus (not Tab order). */
4263
+ function isInteractiveRole(role) {
4264
+ switch (role) {
4265
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
4266
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
4267
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
4268
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
4269
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider:
4270
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
4271
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
4272
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField:
4273
+ return true;
4274
+ default:
4275
+ return false;
4276
+ }
4277
+ }
4278
+ /**
4279
+ * A modal/alert dialog: alertDialog is always modal per WAI-ARIA, a plain
4280
+ * dialog only when the Modal state flag is set.
4281
+ */
4282
+ function isModalDialogRole(role, flags) {
4283
+ return (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.alertDialog ||
4284
+ (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.dialog && (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Modal)));
4285
+ }
4286
+ /** Whether a node can receive focus: an interactive role or the Focusable trait. */
4287
+ function isFocusableNode(node) {
4288
+ return (isInteractiveRole(node.role) ||
4289
+ (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable));
4290
+ }
4291
+ /**
4292
+ * Choose an HTML tag for a given role. Prefer native semantic elements
4293
+ * where they exist — screen readers treat them more reliably than
4294
+ * generic elements with ARIA role overrides.
4295
+ */
4296
+ function tagForRole(role) {
4297
+ switch (role) {
4298
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
4299
+ return "a";
4300
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text:
4301
+ // The outer div is the positioned AX element VoiceOver measures for its
4302
+ // highlight box. The text itself lives in a child <span> (see createElement).
4303
+ return "div";
4304
+ default:
4305
+ return "div";
4306
+ }
4307
+ }
4308
+ /**
4309
+ * Maps a Rive SemanticRole to an ARIA `role` attribute value.
4310
+ * Returns null for roles that don't need an explicit role attribute here
4311
+ * (e.g. text nodes use an outer div + inner span with textContent; heading
4312
+ * role is applied separately when headingLevel > 0).
4313
+ */
4314
+ function ariaRoleForSemantic(role) {
4315
+ switch (role) {
4316
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.none:
4317
+ // TODO: Role "none" removes the node from the accessibility tree. For now, setting to Group, but maybe we want to switch to "none"
4318
+ // or "presentation".
4319
+ return "group";
4320
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
4321
+ return "button";
4322
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
4323
+ return null; // native <a>
4324
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
4325
+ return "checkbox";
4326
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
4327
+ return "switch";
4328
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider:
4329
+ return "slider";
4330
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField:
4331
+ return "textbox";
4332
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.image:
4333
+ return "img";
4334
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.group:
4335
+ return "group";
4336
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.list:
4337
+ return "list";
4338
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.listItem:
4339
+ return "listitem";
4340
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
4341
+ return "tab";
4342
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tabList:
4343
+ return "tablist";
4344
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.dialog:
4345
+ return "dialog";
4346
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.alertDialog:
4347
+ return "alertdialog";
4348
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioGroup:
4349
+ return "radiogroup";
4350
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
4351
+ return "radio";
4352
+ case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text:
4353
+ // Text nodes use <span>; heading role is applied separately
4354
+ // when headingLevel > 0.
4355
+ return null;
4356
+ default:
4357
+ return null;
4358
+ }
4359
+ }
4360
+
4361
+
4362
+ /***/ }),
4363
+ /* 10 */
4364
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4365
+
2555
4366
  __webpack_require__.r(__webpack_exports__);
2556
4367
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2557
4368
  /* harmony export */ AudioAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.AudioAssetWrapper),
@@ -2572,11 +4383,11 @@ __webpack_require__.r(__webpack_exports__);
2572
4383
  /* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
2573
4384
  /* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)
2574
4385
  /* harmony export */ });
2575
- /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
2576
- /* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
2577
- /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
2578
- /* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
2579
- /* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(11);
4386
+ /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
4387
+ /* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
4388
+ /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(13);
4389
+ /* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
4390
+ /* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(15);
2580
4391
 
2581
4392
 
2582
4393
 
@@ -2585,7 +4396,7 @@ __webpack_require__.r(__webpack_exports__);
2585
4396
 
2586
4397
 
2587
4398
  /***/ }),
2588
- /* 7 */
4399
+ /* 11 */
2589
4400
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2590
4401
 
2591
4402
  __webpack_require__.r(__webpack_exports__);
@@ -2882,7 +4693,7 @@ var registerTouchInteractions = function (_a) {
2882
4693
 
2883
4694
 
2884
4695
  /***/ }),
2885
- /* 8 */
4696
+ /* 12 */
2886
4697
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2887
4698
 
2888
4699
  __webpack_require__.r(__webpack_exports__);
@@ -2922,9 +4733,16 @@ var FocusSessionState;
2922
4733
  */
2923
4734
  var KeyboardInteractions = /** @class */ (function () {
2924
4735
  function KeyboardInteractions(_a) {
2925
- var canvas = _a.canvas, stateMachine = _a.stateMachine, hasFocusNodes = _a.hasFocusNodes;
4736
+ var canvas = _a.canvas, stateMachine = _a.stateMachine, hasFocusNodes = _a.hasFocusNodes, getOverlayElement = _a.getOverlayElement;
2926
4737
  var _this = this;
4738
+ var _b;
2927
4739
  this.focusSessionState = FocusSessionState.NotFocused;
4740
+ /** Whether the canvas currently has browser DOM focus. */
4741
+ this.canvasHasFocus = false;
4742
+ /** After Tab exits the last Rive node, ignore keydowns until focus re-enters the focus domain. */
4743
+ this.focusDomainReleased = false;
4744
+ /** Overlay element currently wired with focusin/keydown listeners, if any. */
4745
+ this.currentOverlayElement = null;
2928
4746
  /**
2929
4747
  * Handles the canvas gaining browser focus. The behavior differs based on how focus was gained -
2930
4748
  *
@@ -2937,6 +4755,9 @@ var KeyboardInteractions = /** @class */ (function () {
2937
4755
  * gates this so a click doesn't yank Rive focus to the first node on the focus event itself.
2938
4756
  */
2939
4757
  this.onCanvasFocus = function (event) {
4758
+ _this.syncOverlayListener();
4759
+ _this.canvasHasFocus = true;
4760
+ _this.focusDomainReleased = false;
2940
4761
  if (!_this.hasFocusNodes)
2941
4762
  return;
2942
4763
  if (_this.mainSm.focusState().hasFocus)
@@ -2952,9 +4773,22 @@ var KeyboardInteractions = /** @class */ (function () {
2952
4773
  };
2953
4774
  this.onCanvasBlur = function (_event) {
2954
4775
  _this.focusSessionState = FocusSessionState.NotFocused;
4776
+ _this.canvasHasFocus = false;
4777
+ };
4778
+ this.onOverlayFocusIn = function (event) {
4779
+ if (_this.isInOverlay(event.target)) {
4780
+ _this.focusDomainReleased = false;
4781
+ }
4782
+ };
4783
+ this.onFocusDomainHostFocusIn = function (_event) {
4784
+ _this.syncOverlayListener();
2955
4785
  };
2956
4786
  this.onKeyDown = function (event) {
2957
- if (_this.focusSessionState === FocusSessionState.NotFocused)
4787
+ _this.syncOverlayListener();
4788
+ // After Tab exits the last Rive node, ignore keys until focus re-enters the focus domain.
4789
+ if (_this.focusDomainReleased)
4790
+ return;
4791
+ if (!_this.shouldRiveHandleKeyEvent(event))
2958
4792
  return;
2959
4793
  if (event.code === "Tab" && _this.hasFocusNodes) {
2960
4794
  var forward = !event.shiftKey;
@@ -2966,17 +4800,23 @@ var KeyboardInteractions = /** @class */ (function () {
2966
4800
  }
2967
4801
  else {
2968
4802
  // No more traversable nodes — release Tab to the page.
2969
- // Set state immediately; onCanvasBlur will also fire naturally.
2970
4803
  _this.focusSessionState = FocusSessionState.NotFocused;
4804
+ _this.focusDomainReleased = true;
4805
+ _this.canvasHasFocus = false;
2971
4806
  }
4807
+ _this.syncOverlayListener();
2972
4808
  }
2973
4809
  };
2974
4810
  this.canvas = canvas;
2975
4811
  this.mainSm = stateMachine;
2976
4812
  this.hasFocusNodes = hasFocusNodes;
4813
+ this.getOverlayElement = getOverlayElement;
4814
+ this.focusDomainHost = (_b = canvas.parentElement) !== null && _b !== void 0 ? _b : document;
2977
4815
  canvas.addEventListener("focus", this.onCanvasFocus);
2978
4816
  canvas.addEventListener("blur", this.onCanvasBlur);
2979
4817
  canvas.addEventListener("keydown", this.onKeyDown);
4818
+ this.focusDomainHost.addEventListener("focusin", this.onFocusDomainHostFocusIn);
4819
+ this.syncOverlayListener();
2980
4820
  }
2981
4821
  /**
2982
4822
  * Set the FocusSessionState. Useful for invoking a Rive "blur" without actually blurring from the <canvas>. This
@@ -2995,6 +4835,45 @@ var KeyboardInteractions = /** @class */ (function () {
2995
4835
  KeyboardInteractions.prototype.notifyRiveFocused = function () {
2996
4836
  this.focusSessionState = FocusSessionState.RiveFocused;
2997
4837
  };
4838
+ /**
4839
+ * Whether Rive should handle this keydown — i.e. it currently owns keyboard input.
4840
+ * True when focus is anywhere in the Rive focus domain (the canvas itself or the
4841
+ * accessibility overlay), OR a focus session is active and the key landed on the
4842
+ * canvas.
4843
+ */
4844
+ KeyboardInteractions.prototype.shouldRiveHandleKeyEvent = function (event) {
4845
+ var inFocusDomain = this.isInFocusDomain(document.activeElement) ||
4846
+ this.isInOverlay(event.target);
4847
+ if (inFocusDomain)
4848
+ return true;
4849
+ var sessionActive = this.focusSessionState !== FocusSessionState.NotFocused;
4850
+ var eventOnCanvas = event.target === this.canvas;
4851
+ return sessionActive && (this.canvasHasFocus || eventOnCanvas);
4852
+ };
4853
+ /** Rive focus domain = the canvas itself OR the accessibility overlay. */
4854
+ KeyboardInteractions.prototype.isInFocusDomain = function (target) {
4855
+ if (target === this.canvas)
4856
+ return true;
4857
+ return this.isInOverlay(target);
4858
+ };
4859
+ /** Overlay only (excludes the canvas) — the accessibility overlay subtree. */
4860
+ KeyboardInteractions.prototype.isInOverlay = function (target) {
4861
+ var _a, _b, _c;
4862
+ if (!(target instanceof Node))
4863
+ return false;
4864
+ 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;
4865
+ };
4866
+ KeyboardInteractions.prototype.syncOverlayListener = function () {
4867
+ var _a, _b, _c, _d, _e, _f;
4868
+ var nextOverlayElement = (_b = (_a = this.getOverlayElement) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : null;
4869
+ if (nextOverlayElement === this.currentOverlayElement)
4870
+ return;
4871
+ (_c = this.currentOverlayElement) === null || _c === void 0 ? void 0 : _c.removeEventListener("focusin", this.onOverlayFocusIn);
4872
+ (_d = this.currentOverlayElement) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", this.onKeyDown, true);
4873
+ this.currentOverlayElement = nextOverlayElement;
4874
+ (_e = this.currentOverlayElement) === null || _e === void 0 ? void 0 : _e.addEventListener("focusin", this.onOverlayFocusIn);
4875
+ (_f = this.currentOverlayElement) === null || _f === void 0 ? void 0 : _f.addEventListener("keydown", this.onKeyDown, true);
4876
+ };
2998
4877
  /**
2999
4878
  * Whether the canvas currently matches :focus-visible — the browser's heuristic for keyboard-
3000
4879
  * (vs pointer-) driven focus. For older browser versions that don't support this selector, return false
@@ -3019,9 +4898,13 @@ var KeyboardInteractions = /** @class */ (function () {
3019
4898
  return true;
3020
4899
  };
3021
4900
  KeyboardInteractions.prototype.cleanup = function () {
4901
+ var _a, _b;
3022
4902
  this.canvas.removeEventListener("focus", this.onCanvasFocus);
3023
4903
  this.canvas.removeEventListener("blur", this.onCanvasBlur);
3024
4904
  this.canvas.removeEventListener("keydown", this.onKeyDown);
4905
+ this.focusDomainHost.removeEventListener("focusin", this.onFocusDomainHostFocusIn);
4906
+ (_a = this.currentOverlayElement) === null || _a === void 0 ? void 0 : _a.removeEventListener("focusin", this.onOverlayFocusIn);
4907
+ (_b = this.currentOverlayElement) === null || _b === void 0 ? void 0 : _b.removeEventListener("keydown", this.onKeyDown, true);
3025
4908
  };
3026
4909
  return KeyboardInteractions;
3027
4910
  }());
@@ -3029,7 +4912,7 @@ var KeyboardInteractions = /** @class */ (function () {
3029
4912
 
3030
4913
 
3031
4914
  /***/ }),
3032
- /* 9 */
4915
+ /* 13 */
3033
4916
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3034
4917
 
3035
4918
  __webpack_require__.r(__webpack_exports__);
@@ -3082,7 +4965,7 @@ function sanitizeUrl(url) {
3082
4965
 
3083
4966
 
3084
4967
  /***/ }),
3085
- /* 10 */
4968
+ /* 14 */
3086
4969
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3087
4970
 
3088
4971
  __webpack_require__.r(__webpack_exports__);
@@ -3364,7 +5247,7 @@ var createFinalization = function (target, finalizable) {
3364
5247
 
3365
5248
 
3366
5249
  /***/ }),
3367
- /* 11 */
5250
+ /* 15 */
3368
5251
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3369
5252
 
3370
5253
  __webpack_require__.r(__webpack_exports__);
@@ -3509,14 +5392,16 @@ __webpack_require__.r(__webpack_exports__);
3509
5392
  /* harmony export */ Rive: () => (/* binding */ Rive),
3510
5393
  /* harmony export */ RiveEventType: () => (/* binding */ RiveEventType),
3511
5394
  /* harmony export */ RiveFile: () => (/* binding */ RiveFile),
3512
- /* harmony export */ RiveFont: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_2__.RiveFont),
5395
+ /* harmony export */ RiveFont: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_3__.RiveFont),
3513
5396
  /* harmony export */ RuntimeLoader: () => (/* reexport safe */ _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader),
5397
+ /* harmony export */ SemanticMode: () => (/* reexport safe */ _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticMode),
3514
5398
  /* harmony export */ StateMachineInput: () => (/* binding */ StateMachineInput),
3515
5399
  /* harmony export */ StateMachineInputType: () => (/* binding */ StateMachineInputType),
3516
5400
  /* harmony export */ Testing: () => (/* binding */ Testing),
3517
5401
  /* harmony export */ ViewModel: () => (/* binding */ ViewModel),
3518
5402
  /* harmony export */ ViewModelInstance: () => (/* binding */ ViewModelInstance),
3519
5403
  /* harmony export */ ViewModelInstanceArtboard: () => (/* binding */ ViewModelInstanceArtboard),
5404
+ /* harmony export */ ViewModelInstanceAssetFont: () => (/* binding */ ViewModelInstanceAssetFont),
3520
5405
  /* harmony export */ ViewModelInstanceAssetImage: () => (/* binding */ ViewModelInstanceAssetImage),
3521
5406
  /* harmony export */ ViewModelInstanceBoolean: () => (/* binding */ ViewModelInstanceBoolean),
3522
5407
  /* harmony export */ ViewModelInstanceColor: () => (/* binding */ ViewModelInstanceColor),
@@ -3532,7 +5417,8 @@ __webpack_require__.r(__webpack_exports__);
3532
5417
  /* harmony export */ });
3533
5418
  /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
3534
5419
  /* harmony import */ var _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
3535
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
5420
+ /* harmony import */ var _semantics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
5421
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
3536
5422
  var __extends = (undefined && undefined.__extends) || (function () {
3537
5423
  var extendStatics = function (d, b) {
3538
5424
  extendStatics = Object.setPrototypeOf ||
@@ -3607,6 +5493,7 @@ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from
3607
5493
 
3608
5494
 
3609
5495
 
5496
+
3610
5497
  var RiveError = /** @class */ (function (_super) {
3611
5498
  __extends(RiveError, _super);
3612
5499
  function RiveError() {
@@ -3617,6 +5504,7 @@ var RiveError = /** @class */ (function (_super) {
3617
5504
  return RiveError;
3618
5505
  }(Error));
3619
5506
 
5507
+
3620
5508
  // #regions helpers
3621
5509
  var resolveErrorMessage = function (error) {
3622
5510
  return error && error.isHandledError
@@ -3865,8 +5753,17 @@ var StateMachine = /** @class */ (function () {
3865
5753
  this.inputs = [];
3866
5754
  this.instance = new runtime.StateMachineInstance(stateMachine, artboard);
3867
5755
  this.initInputs(runtime);
3868
- this.hasFocusNodes = this.instance.hasFocusNodes();
3869
5756
  }
5757
+ Object.defineProperty(StateMachine.prototype, "hasFocusNodes", {
5758
+ /**
5759
+ * Whether this state machine has focus nodes
5760
+ */
5761
+ get: function () {
5762
+ return this.instance.hasFocusNodes();
5763
+ },
5764
+ enumerable: false,
5765
+ configurable: true
5766
+ });
3870
5767
  Object.defineProperty(StateMachine.prototype, "name", {
3871
5768
  get: function () {
3872
5769
  return this.stateMachine.name;
@@ -3902,6 +5799,37 @@ var StateMachine = /** @class */ (function () {
3902
5799
  StateMachine.prototype.advanceAndApply = function (time) {
3903
5800
  this.instance.advanceAndApply(time);
3904
5801
  };
5802
+ /**
5803
+ * Enables semantic tree tracking for this state machine instance.
5804
+ */
5805
+ StateMachine.prototype.enableSemantics = function () {
5806
+ this.instance.enableSemantics();
5807
+ };
5808
+ /**
5809
+ * Returns the incremental semantic diff since the last call, or null
5810
+ * if semantics is not enabled or nothing changed.
5811
+ */
5812
+ StateMachine.prototype.drainSemanticsDiff = function () {
5813
+ return this.instance.drainSemanticsDiff();
5814
+ };
5815
+ /**
5816
+ * Fire a semantic action (tap, increase, decrease) on a node.
5817
+ * @param nodeId - The semantic node ID to target
5818
+ * @param actionType - 0 = tap, 1 = increase, 2 = decrease
5819
+ */
5820
+ StateMachine.prototype.fireSemanticAction = function (nodeId, actionType) {
5821
+ this.instance.fireSemanticAction(nodeId, actionType);
5822
+ };
5823
+ /**
5824
+ * When tools that enable accessible experiences traverse elements with focus,
5825
+ * we should call this method to focus the semantic node. It will also trigger
5826
+ * focus on any Focus listeners for this node
5827
+ * @param nodeId ID of the Semantic Node to focus
5828
+ * @returns boolean - True if focus was set, false otherwise
5829
+ */
5830
+ StateMachine.prototype.focusSemanticNode = function (nodeId) {
5831
+ return this.instance.focusSemanticNode(nodeId);
5832
+ };
3905
5833
  /**
3906
5834
  * Returns the number of events reported from the last advance call
3907
5835
  * @returns Number of events reported
@@ -4006,8 +5934,9 @@ var Animator = /** @class */ (function () {
4006
5934
  * @param animatable the name(s) of animations and state machines to add
4007
5935
  * @returns a list of names of the playing animations and state machines
4008
5936
  */
4009
- Animator.prototype.add = function (animatables, playing, fireEvent) {
5937
+ Animator.prototype.add = function (animatables, playing, fireEvent, semanticsActive) {
4010
5938
  if (fireEvent === void 0) { fireEvent = true; }
5939
+ if (semanticsActive === void 0) { semanticsActive = false; }
4011
5940
  animatables = mapToStringArray(animatables);
4012
5941
  // If animatables is empty, play or pause everything
4013
5942
  if (animatables.length === 0) {
@@ -4046,6 +5975,9 @@ var Animator = /** @class */ (function () {
4046
5975
  var sm = this.artboard.stateMachineByName(animatables[i]);
4047
5976
  if (sm) {
4048
5977
  var newStateMachine = new StateMachine(sm, this.runtime, playing, this.artboard);
5978
+ if (semanticsActive) {
5979
+ newStateMachine.enableSemantics();
5980
+ }
4049
5981
  this.stateMachines.push(newStateMachine);
4050
5982
  }
4051
5983
  }
@@ -4111,7 +6043,7 @@ var Animator = /** @class */ (function () {
4111
6043
  * @param animatables the name(s) of state machines to add
4112
6044
  * @param playing whether state machines should play on instantiation
4113
6045
  */
4114
- Animator.prototype.initStateMachines = function (animatables, playing) {
6046
+ Animator.prototype.initStateMachines = function (animatables, playing, semanticsActive) {
4115
6047
  // Play/pause already instanced items, or create new instances
4116
6048
  // This validation is kept to maintain compatibility with current behavior.
4117
6049
  // But given that it this is called during artboard initialization
@@ -4127,6 +6059,9 @@ var Animator = /** @class */ (function () {
4127
6059
  var sm = this.artboard.stateMachineByName(animatables[i]);
4128
6060
  if (sm) {
4129
6061
  var newStateMachine = new StateMachine(sm, this.runtime, playing, this.artboard);
6062
+ if (semanticsActive) {
6063
+ newStateMachine.enableSemantics();
6064
+ }
4130
6065
  this.stateMachines.push(newStateMachine);
4131
6066
  }
4132
6067
  else {
@@ -4292,8 +6227,9 @@ var Animator = /** @class */ (function () {
4292
6227
  * If there are no animations or state machines, add the first one found
4293
6228
  * @returns the name of the animation or state machine instanced
4294
6229
  */
4295
- Animator.prototype.atLeastOne = function (playing, fireEvent) {
6230
+ Animator.prototype.atLeastOne = function (playing, fireEvent, semanticsActive) {
4296
6231
  if (fireEvent === void 0) { fireEvent = true; }
6232
+ if (semanticsActive === void 0) { semanticsActive = false; }
4297
6233
  var instancedName;
4298
6234
  if (this.animations.length === 0 && this.stateMachines.length === 0) {
4299
6235
  if (this.artboard.animationCount() > 0) {
@@ -4302,7 +6238,7 @@ var Animator = /** @class */ (function () {
4302
6238
  }
4303
6239
  else if (this.artboard.stateMachineCount() > 0) {
4304
6240
  // Add the first state machine
4305
- this.add([(instancedName = this.artboard.stateMachineByIndex(0).name)], playing, fireEvent);
6241
+ this.add([(instancedName = this.artboard.stateMachineByIndex(0).name)], playing, fireEvent, semanticsActive);
4306
6242
  }
4307
6243
  }
4308
6244
  return instancedName;
@@ -4694,6 +6630,9 @@ var ObjectObservers = /** @class */ (function () {
4694
6630
  return ObjectObservers;
4695
6631
  }());
4696
6632
  var observers = new ObjectObservers();
6633
+ // #endregion
6634
+ // #region Rive
6635
+ var nextRiveInstanceId = 0;
4697
6636
  var RiveFile = /** @class */ (function () {
4698
6637
  function RiveFile(params) {
4699
6638
  // Allow the runtime to automatically load assets hosted in Rive's runtime.
@@ -4760,7 +6699,7 @@ var RiveFile = /** @class */ (function () {
4760
6699
  return [2 /*return*/];
4761
6700
  }
4762
6701
  if (this.assetLoader) {
4763
- loaderWrapper = new _utils__WEBPACK_IMPORTED_MODULE_2__.CustomFileAssetLoaderWrapper(this.runtime, this.assetLoader);
6702
+ loaderWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.CustomFileAssetLoaderWrapper(this.runtime, this.assetLoader);
4764
6703
  loader = loaderWrapper.assetLoader;
4765
6704
  }
4766
6705
  // Load the Rive file
@@ -4774,8 +6713,8 @@ var RiveFile = /** @class */ (function () {
4774
6713
  performance.mark('rive:file-load:end');
4775
6714
  performance.measure('rive:file-load', 'rive:file-load:start', 'rive:file-load:end');
4776
6715
  }
4777
- fileFinalizer = new _utils__WEBPACK_IMPORTED_MODULE_2__.FileFinalizer(this.file);
4778
- _utils__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry.register(this, fileFinalizer);
6716
+ fileFinalizer = new _utils__WEBPACK_IMPORTED_MODULE_3__.FileFinalizer(this.file);
6717
+ _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(this, fileFinalizer);
4779
6718
  if (this.destroyed) {
4780
6719
  this.releaseFile();
4781
6720
  return [2 /*return*/];
@@ -4933,7 +6872,7 @@ var RiveFile = /** @class */ (function () {
4933
6872
  RiveFile.prototype.createBindableArtboard = function (nativeBindableArtboard) {
4934
6873
  if (nativeBindableArtboard != null) {
4935
6874
  var bindableArtboard = new BindableArtboard(nativeBindableArtboard);
4936
- (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(bindableArtboard, bindableArtboard.nativeArtboard);
6875
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(bindableArtboard, bindableArtboard.nativeArtboard);
4937
6876
  this.bindableArtboards.push(bindableArtboard);
4938
6877
  return bindableArtboard;
4939
6878
  }
@@ -4970,6 +6909,12 @@ var RiveFile = /** @class */ (function () {
4970
6909
  }
4971
6910
  return null;
4972
6911
  };
6912
+ /**
6913
+ * @returns the names of the file's global view models, in file order.
6914
+ */
6915
+ RiveFile.prototype.globalViewModelNames = function () {
6916
+ return this.file.globalViewModelNames();
6917
+ };
4973
6918
  // Error message for missing source or buffer
4974
6919
  RiveFile.missingErrorMessage = "Rive source file or data buffer required";
4975
6920
  // Error message for file load error
@@ -4980,7 +6925,7 @@ var RiveFile = /** @class */ (function () {
4980
6925
  var Rive = /** @class */ (function () {
4981
6926
  function Rive(params) {
4982
6927
  var _this = this;
4983
- var _a, _b, _c;
6928
+ var _a, _b, _c, _d;
4984
6929
  // Tracks if a Rive file is loaded
4985
6930
  this.loaded = false;
4986
6931
  // Tracks if a Rive file is destroyed
@@ -5008,6 +6953,12 @@ var Rive = /** @class */ (function () {
5008
6953
  this.enableMultiTouch = false;
5009
6954
  // Allow the runtime to automatically load assets hosted in Rive's runtime.
5010
6955
  this.enableRiveAssetCDN = true;
6956
+ this.semanticsMode = _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticMode.Disabled;
6957
+ this.semanticsOptions = {
6958
+ riveCanvasLabel: "Rive animation",
6959
+ };
6960
+ /** True when this instance may drain semantics and render the overlay. */
6961
+ this._semanticsActive = false;
5011
6962
  // Keep a local value of the set volume to update it asynchronously
5012
6963
  this._volume = 1;
5013
6964
  // Keep a local value of the set width to update it asynchronously
@@ -5036,12 +6987,29 @@ var Rive = /** @class */ (function () {
5036
6987
  // visibilitychange handler from restarting a rendering loop the caller intentionally stopped.
5037
6988
  this._explicitlyStoppedRendering = false;
5038
6989
  this._viewModelInstance = null;
6990
+ // User-provided global view model instances, keyed by their global view
6991
+ // model's name. Globals not present here are still driven by the default
6992
+ // instances the runtime seeds; the getter only surfaces instances the user
6993
+ // has explicitly set.
6994
+ this._globalViewModelInstances = new Map();
5039
6995
  this._dataEnums = null;
5040
6996
  this._tabIndex = null;
5041
6997
  this._prevHasFocus = false;
5042
6998
  this._focusOptions = {
5043
6999
  allowFocusInterrupt: false,
5044
7000
  };
7001
+ // Tracks the semantic tree for the given graphic
7002
+ this._semanticTree = null;
7003
+ this._accessibilityOverlay = null;
7004
+ /**
7005
+ * True when an input to the accessibility overlay's artboard→canvas transform
7006
+ * (layout fit/alignment/bounds, devicePixelRatio, or layout scale) has changed
7007
+ * and the matrix must be recomputed on the next overlay update. Avoids calling
7008
+ * computeAlignment every frame when only the semantic tree changed.
7009
+ */
7010
+ this._overlayTransformDirty = true;
7011
+ // Module-level counter for unique instance IDs for semantic overlay containers
7012
+ this._instanceId = "".concat(nextRiveInstanceId++);
5045
7013
  this.drawOptimization = DrawOptimizationOptions.DrawOnChanged;
5046
7014
  // When true, emits performance.mark/measure entries for load and render.
5047
7015
  this.enablePerfMarks = false;
@@ -5101,6 +7069,7 @@ var Rive = /** @class */ (function () {
5101
7069
  if (this.enablePerfMarks)
5102
7070
  _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.enablePerfMarks = true;
5103
7071
  this._focusOptions = (_c = params.focusOptions) !== null && _c !== void 0 ? _c : this._focusOptions;
7072
+ this._tabIndex = (_d = params.tabIndex) !== null && _d !== void 0 ? _d : null;
5104
7073
  // New event management system
5105
7074
  this.eventManager = new EventManager();
5106
7075
  if (params.onLoad)
@@ -5154,6 +7123,8 @@ var Rive = /** @class */ (function () {
5154
7123
  artboard: params.artboard,
5155
7124
  useOffscreenRenderer: params.useOffscreenRenderer,
5156
7125
  tabIndex: params.tabIndex,
7126
+ semanticsMode: params.semanticsMode,
7127
+ semanticsOptions: params.semanticsOptions,
5157
7128
  });
5158
7129
  }
5159
7130
  Object.defineProperty(Rive.prototype, "viewModelCount", {
@@ -5168,6 +7139,44 @@ var Rive = /** @class */ (function () {
5168
7139
  console.warn("This function is deprecated: please use `new Rive({})` instead");
5169
7140
  return new Rive(params);
5170
7141
  };
7142
+ /**
7143
+ * @experimental Turns on semantics and the accessibility overlay for this
7144
+ * instance. Idempotent; safe to call before or after load. Use this to drive
7145
+ * a consumer-controlled accessibility toggle when constructed with the
7146
+ * default {@link SemanticMode.Disabled}.
7147
+ */
7148
+ Rive.prototype.enableSemantics = function () {
7149
+ this.semanticsMode = _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticMode.Enabled;
7150
+ this.activateSemantics();
7151
+ };
7152
+ Rive.prototype.activateSemantics = function () {
7153
+ if (this._semanticsActive || this.semanticsMode === _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticMode.Disabled) {
7154
+ return;
7155
+ }
7156
+ this._semanticsActive = true;
7157
+ this.syncSemanticsOnStateMachines();
7158
+ };
7159
+ Rive.prototype.syncSemanticsOnStateMachines = function () {
7160
+ if (!this._semanticsActive || !this.animator) {
7161
+ return;
7162
+ }
7163
+ for (var _i = 0, _a = this.animator.stateMachines; _i < _a.length; _i++) {
7164
+ var stateMachine = _a[_i];
7165
+ stateMachine.enableSemantics();
7166
+ }
7167
+ };
7168
+ /**
7169
+ * Tears down the semantic tree and accessibility overlay. The overlay captures the
7170
+ * active state machine in its action closures, so it must not outlive the
7171
+ * instances it points at (reset/load delete them)
7172
+ */
7173
+ Rive.prototype.cleanupSemantics = function () {
7174
+ this._semanticTree = null;
7175
+ if (this._accessibilityOverlay) {
7176
+ this._accessibilityOverlay.destroy();
7177
+ this._accessibilityOverlay = null;
7178
+ }
7179
+ };
5171
7180
  // Event handler for when audio context becomes available
5172
7181
  Rive.prototype.onSystemAudioChanged = function () {
5173
7182
  this.volume = this._volume;
@@ -5175,7 +7184,7 @@ var Rive = /** @class */ (function () {
5175
7184
  // Initializes the Rive object either from constructor or load()
5176
7185
  Rive.prototype.init = function (_a) {
5177
7186
  var _this = this;
5178
- var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c, _d = _a.autoBind, autoBind = _d === void 0 ? false : _d, tabIndex = _a.tabIndex;
7187
+ var src = _a.src, buffer = _a.buffer, riveFile = _a.riveFile, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b, _c = _a.useOffscreenRenderer, useOffscreenRenderer = _c === void 0 ? false : _c, _d = _a.autoBind, autoBind = _d === void 0 ? false : _d, tabIndex = _a.tabIndex, semanticsMode = _a.semanticsMode, semanticsOptions = _a.semanticsOptions;
5179
7188
  if (this.destroyed) {
5180
7189
  return;
5181
7190
  }
@@ -5183,6 +7192,8 @@ var Rive = /** @class */ (function () {
5183
7192
  this.buffer = buffer;
5184
7193
  this.riveFile = riveFile;
5185
7194
  this._tabIndex = tabIndex !== null && tabIndex !== void 0 ? tabIndex : null;
7195
+ this.semanticsMode = semanticsMode !== null && semanticsMode !== void 0 ? semanticsMode : _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticMode.Disabled;
7196
+ this.semanticsOptions = semanticsOptions !== null && semanticsOptions !== void 0 ? semanticsOptions : this.semanticsOptions;
5186
7197
  // If no source file url specified, it's a bust
5187
7198
  if (!this.src && !this.buffer && !this.riveFile) {
5188
7199
  throw new RiveError(Rive.missingErrorMessage);
@@ -5202,6 +7213,9 @@ var Rive = /** @class */ (function () {
5202
7213
  }
5203
7214
  _this.runtime = runtime;
5204
7215
  _this.removeRiveListeners();
7216
+ // load() reinitializes without cleanupInstances(); drop any stale overlay
7217
+ // bound to the previous file's state machines (no-op on first construct).
7218
+ _this.cleanupSemantics();
5205
7219
  _this.deleteRiveRenderer();
5206
7220
  // Get the canvas where you want to render the animation and create a renderer
5207
7221
  if (_this.enablePerfMarks)
@@ -5266,7 +7280,7 @@ var Rive = /** @class */ (function () {
5266
7280
  "isTouchScrollEnabled" in riveListenerOptions) {
5267
7281
  touchScrollEnabledOption = riveListenerOptions.isTouchScrollEnabled;
5268
7282
  }
5269
- this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
7283
+ this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.registerTouchInteractions)({
5270
7284
  canvas: this.canvas,
5271
7285
  artboard: this.artboard,
5272
7286
  stateMachines: activeStateMachines,
@@ -5280,28 +7294,36 @@ var Rive = /** @class */ (function () {
5280
7294
  layoutScaleFactor: this._layout.layoutScaleFactor,
5281
7295
  advanceAndDrain: this.advanceAndReportChanges.bind(this)
5282
7296
  });
5283
- // Wire up keyboard interactions for state machines that have focus nodes.
5284
- // hasFocusNodes — unified focus tree check, gates tab traversal
5285
- var smWithFocusNodes = playingStateMachines.filter(function (sm) { return sm.hasFocusNodes; });
5286
- if (smWithFocusNodes.length) {
5287
- // Set the canvas as a tabbable element if there are any focus nodes.
5288
- // Prefer the tabIndex param set by the user, otherwise use 0.
5289
- // But do not override any explicit tabIndex already set on the canvas, if any.
5290
- var currentCanvasTabIndex = this.canvas.tabIndex;
5291
- // By default, canvas elements have a tabIndex of -1
5292
- if (currentCanvasTabIndex === -1 || isNaN(currentCanvasTabIndex)) {
5293
- this.canvas.tabIndex = (this._tabIndex !== null ? this._tabIndex : 0);
5294
- }
5295
- if (typeof window !== "undefined") {
5296
- this._keyboardInteractions = new _utils__WEBPACK_IMPORTED_MODULE_2__.KeyboardInteractions({
5297
- canvas: this.canvas,
5298
- stateMachine: smWithFocusNodes[0].instance, // work off assumption of single state machine
5299
- hasFocusNodes: true,
5300
- });
5301
- }
5302
- }
7297
+ this.ensureKeyboardInteractions();
5303
7298
  }
5304
7299
  };
7300
+ /**
7301
+ * Wire keyboard interactions when a playing state machine has focus nodes.
7302
+ * Called at listener setup and lazily each frame so late-bound bindable artboards work.
7303
+ */
7304
+ Rive.prototype.ensureKeyboardInteractions = function () {
7305
+ var _this = this;
7306
+ if (this._keyboardInteractions ||
7307
+ this.shouldDisableRiveListeners ||
7308
+ typeof window === "undefined" ||
7309
+ !(this.canvas instanceof HTMLCanvasElement)) {
7310
+ return;
7311
+ }
7312
+ var smWithFocusNodes = this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; });
7313
+ if (!smWithFocusNodes) {
7314
+ return;
7315
+ }
7316
+ var currentCanvasTabIndex = this.canvas.tabIndex;
7317
+ if (currentCanvasTabIndex === -1 || isNaN(currentCanvasTabIndex)) {
7318
+ this.canvas.tabIndex = (this._tabIndex !== null ? this._tabIndex : 0);
7319
+ }
7320
+ this._keyboardInteractions = new _utils__WEBPACK_IMPORTED_MODULE_3__.KeyboardInteractions({
7321
+ canvas: this.canvas,
7322
+ stateMachine: smWithFocusNodes.instance, // work off assumption of single state machine
7323
+ hasFocusNodes: true,
7324
+ getOverlayElement: function () { var _a, _b; return (_b = (_a = _this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.getSemanticOverlayContainer()) !== null && _b !== void 0 ? _b : null; },
7325
+ });
7326
+ };
5305
7327
  Rive.prototype.cleanupKeyboardInteractions = function () {
5306
7328
  if (this._keyboardInteractions) {
5307
7329
  this._keyboardInteractions.cleanup();
@@ -5384,6 +7406,12 @@ var Rive = /** @class */ (function () {
5384
7406
  this.initArtboardSize();
5385
7407
  // Check for audio
5386
7408
  this.initializeAudio();
7409
+ if (this.semanticsMode === _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticMode.Enabled) {
7410
+ this.activateSemantics();
7411
+ }
7412
+ else if (this._semanticsActive) {
7413
+ this.syncSemanticsOnStateMachines();
7414
+ }
5387
7415
  // Everything's set up, emit a load event
5388
7416
  try {
5389
7417
  this.loaded = true;
@@ -5442,10 +7470,10 @@ var Rive = /** @class */ (function () {
5442
7470
  if (animationNames.length > 0 || stateMachineNames.length > 0) {
5443
7471
  instanceNames = animationNames.concat(stateMachineNames);
5444
7472
  this.animator.initLinearAnimations(animationNames, autoplay);
5445
- this.animator.initStateMachines(stateMachineNames, autoplay);
7473
+ this.animator.initStateMachines(stateMachineNames, autoplay, this._semanticsActive);
5446
7474
  }
5447
7475
  else {
5448
- instanceNames = [this.animator.atLeastOne(autoplay, false)];
7476
+ instanceNames = [this.animator.atLeastOne(autoplay, false, this._semanticsActive)];
5449
7477
  }
5450
7478
  // Queue up firing the playback events
5451
7479
  this.taskQueue.add({
@@ -5455,15 +7483,29 @@ var Rive = /** @class */ (function () {
5455
7483
  },
5456
7484
  });
5457
7485
  if (autoBind) {
7486
+ // Set the main view model instance (if the artboard has one)...
5458
7487
  var viewModel = this.file.defaultArtboardViewModel(rootArtboard);
5459
7488
  if (viewModel !== null) {
5460
7489
  var runtimeInstance = viewModel.defaultInstance();
5461
7490
  if (runtimeInstance !== null) {
5462
7491
  var viewModelInstance = new ViewModelInstance(runtimeInstance, null);
5463
- (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, viewModelInstance.runtimeInstance);
5464
- this.bindViewModelInstance(viewModelInstance);
7492
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(viewModelInstance, viewModelInstance.runtimeInstance);
7493
+ this.setViewModelInstance(viewModelInstance);
5465
7494
  }
5466
7495
  }
7496
+ // ...and a default instance for each global view model (no longer
7497
+ // auto-created by the runtime), then apply everything in one rebind.
7498
+ for (var _i = 0, _a = this.file.globalViewModelNames(); _i < _a.length; _i++) {
7499
+ var name_1 = _a[_i];
7500
+ var globalViewModel = this.file.viewModelByName(name_1);
7501
+ if (globalViewModel !== null) {
7502
+ var instance = new ViewModel(globalViewModel).defaultInstance();
7503
+ if (instance !== null) {
7504
+ this.setGlobalViewModelInstance(name_1, instance);
7505
+ }
7506
+ }
7507
+ }
7508
+ this.bind();
5467
7509
  }
5468
7510
  };
5469
7511
  // Draws the current artboard frame
@@ -5498,6 +7540,8 @@ var Rive = /** @class */ (function () {
5498
7540
  * Rive internally updated focus outside of user interaction (e.g., via listener action)
5499
7541
  */
5500
7542
  Rive.prototype.pollFocusState = function () {
7543
+ var _a, _b;
7544
+ this.ensureKeyboardInteractions();
5501
7545
  if (!this._keyboardInteractions) {
5502
7546
  this._prevHasFocus = false;
5503
7547
  return;
@@ -5516,7 +7560,16 @@ var Rive = /** @class */ (function () {
5516
7560
  // Only steal DOM focus on the false→true transition. If hasFocus stays
5517
7561
  // true across frames and the user clicks away, do not re-focus the canvas again.
5518
7562
  if (!this._prevHasFocus) {
5519
- if (this.canvas !== document.activeElement && this._focusOptions.allowFocusInterrupt) {
7563
+ // Steal DOM focus to the canvas only when focus isn't already held
7564
+ // somewhere inside this instance's focus scope. When the accessibility
7565
+ // overlay has driven focus onto a specific semantic node element (e.g.
7566
+ // an appearing alert dialog), focus is already in-scope. The steal
7567
+ // stays a fallback for runtime focus nodes that have no overlay element
7568
+ // to hold DOM focus.
7569
+ var scope = (_a = this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.getSemanticOverlayContainer();
7570
+ var focusAlreadyInScope = document.activeElement === this.canvas ||
7571
+ ((_b = scope === null || scope === void 0 ? void 0 : scope.contains(document.activeElement)) !== null && _b !== void 0 ? _b : false);
7572
+ if (!focusAlreadyInScope && this._focusOptions.allowFocusInterrupt) {
5520
7573
  this.canvas.focus();
5521
7574
  }
5522
7575
  this._prevHasFocus = true;
@@ -5528,8 +7581,8 @@ var Rive = /** @class */ (function () {
5528
7581
  // (state change clears focus). Release the DOM Tab trap so the next Tab moves to the next
5529
7582
  // page element. EntryPending and NotFocused cases are intentional no-ops — EntryPending in
5530
7583
  // particular must stay in its state (a click awaiting its first Tab) rather than be reset here.
5531
- if (this._keyboardInteractions.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_2__.FocusSessionState.RiveFocused) {
5532
- this._keyboardInteractions.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_2__.FocusSessionState.NotFocused);
7584
+ if (this._keyboardInteractions.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.RiveFocused) {
7585
+ this._keyboardInteractions.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.NotFocused);
5533
7586
  }
5534
7587
  }
5535
7588
  };
@@ -5540,7 +7593,7 @@ var Rive = /** @class */ (function () {
5540
7593
  * @param elapsedTime time to advance the state machine by
5541
7594
  */
5542
7595
  Rive.prototype.advanceAndReportChanges = function (elapsedTime) {
5543
- var _a;
7596
+ var _a, _b;
5544
7597
  // - Advance non-paused animations by the elapsed number of seconds
5545
7598
  // - Advance any animations that require scrubbing
5546
7599
  // - Advance to the first frame even when autoplay is false
@@ -5563,8 +7616,8 @@ var Rive = /** @class */ (function () {
5563
7616
  // Instrument the first 3 frames so the Performance timeline shows precise
5564
7617
  // per-call latency for advance, draw, and flush without polluting the trace.
5565
7618
  var _perfFrame = this.enablePerfMarks && this.frameCount < 3 ? this.frameCount : -1;
5566
- for (var _b = 0, activeStateMachines_1 = activeStateMachines; _b < activeStateMachines_1.length; _b++) {
5567
- var stateMachine = activeStateMachines_1[_b];
7619
+ for (var _c = 0, activeStateMachines_1 = activeStateMachines; _c < activeStateMachines_1.length; _c++) {
7620
+ var stateMachine = activeStateMachines_1[_c];
5568
7621
  // Check for events before the current frame's state machine advance
5569
7622
  var numEventsReported = stateMachine.reportedEventCount();
5570
7623
  if (numEventsReported) {
@@ -5579,11 +7632,11 @@ var Rive = /** @class */ (function () {
5579
7632
  // Handle the event side effect if explicitly enabled
5580
7633
  if (this.automaticallyHandleEvents) {
5581
7634
  var newAnchorTag = document.createElement("a");
5582
- var _c = event_1, url = _c.url, target = _c.target;
5583
- var sanitizedUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)(url);
7635
+ var _d = event_1, url = _d.url, target = _d.target;
7636
+ var sanitizedUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.sanitizeUrl)(url);
5584
7637
  url && newAnchorTag.setAttribute("href", sanitizedUrl);
5585
7638
  target && newAnchorTag.setAttribute("target", target);
5586
- if (sanitizedUrl && sanitizedUrl !== _utils__WEBPACK_IMPORTED_MODULE_2__.BLANK_URL) {
7639
+ if (sanitizedUrl && sanitizedUrl !== _utils__WEBPACK_IMPORTED_MODULE_3__.BLANK_URL) {
5587
7640
  newAnchorTag.click();
5588
7641
  }
5589
7642
  }
@@ -5604,6 +7657,61 @@ var Rive = /** @class */ (function () {
5604
7657
  performance.mark("rive:sm-advance:end:f".concat(_perfFrame));
5605
7658
  performance.measure("rive:sm-advance:f".concat(_perfFrame), "rive:sm-advance:start:f".concat(_perfFrame), "rive:sm-advance:end:f".concat(_perfFrame));
5606
7659
  }
7660
+ if (this._semanticsActive) {
7661
+ var diff = stateMachine.drainSemanticsDiff();
7662
+ if (diff) {
7663
+ if (!this._semanticTree) {
7664
+ this._semanticTree = new _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticTreeModel();
7665
+ }
7666
+ this._semanticTree.applyDiff(diff);
7667
+ }
7668
+ }
7669
+ }
7670
+ // Update the accessibility overlay after all state machines have
7671
+ // been advanced and their diffs applied to the tree model.
7672
+ if (this._semanticsActive &&
7673
+ this._semanticTree &&
7674
+ activeStateMachines.length > 0 &&
7675
+ this.canvas instanceof HTMLCanvasElement) {
7676
+ if (!this._accessibilityOverlay) {
7677
+ var mainSm_1 = activeStateMachines[0];
7678
+ this._accessibilityOverlay = new _semantics__WEBPACK_IMPORTED_MODULE_2__.AccessibilityOverlay({
7679
+ canvas: this.canvas,
7680
+ instanceId: this._instanceId,
7681
+ semanticsOptions: this.semanticsOptions,
7682
+ allowFocusInterrupt: this._focusOptions.allowFocusInterrupt,
7683
+ fireAction: function (nodeId, actionType) {
7684
+ mainSm_1.fireSemanticAction(nodeId, actionType);
7685
+ },
7686
+ requestFocus: function (nodeId) {
7687
+ return mainSm_1.focusSemanticNode(nodeId);
7688
+ },
7689
+ clearFocus: function () {
7690
+ return mainSm_1.instance.clearFocus();
7691
+ },
7692
+ });
7693
+ }
7694
+ var overlayChange = (_a = this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.needsUpdate(this._semanticTree);
7695
+ if (overlayChange || this._overlayTransformDirty) {
7696
+ // Only recompute the artboard→canvas transform when something that
7697
+ // affects it changed (canvas geometry or a layout/dpr input). When only
7698
+ // the semantic tree changed we pass null and reuse the existing CSS
7699
+ // transform on the overlay container.
7700
+ var forwardMat = null;
7701
+ if ((overlayChange === null || overlayChange === void 0 ? void 0 : overlayChange.layoutChanged) || this._overlayTransformDirty) {
7702
+ var fit_1 = this._layout.runtimeFit(this.runtime);
7703
+ var alignment = this._layout.runtimeAlignment(this.runtime);
7704
+ forwardMat = this.runtime.computeAlignment(fit_1, alignment, {
7705
+ minX: this._layout.minX,
7706
+ minY: this._layout.minY,
7707
+ maxX: this._layout.maxX,
7708
+ maxY: this._layout.maxY,
7709
+ }, this.artboard.bounds, this._devicePixelRatioUsed * this._layout.layoutScaleFactor);
7710
+ this._overlayTransformDirty = false;
7711
+ }
7712
+ this._accessibilityOverlay.update(this._semanticTree, forwardMat, this._devicePixelRatioUsed, this.artboard.bounds, overlayChange);
7713
+ forwardMat === null || forwardMat === void 0 ? void 0 : forwardMat.delete();
7714
+ }
5607
7715
  }
5608
7716
  // For linear animations that have been applied to the artboard, advance it
5609
7717
  // by the elapsed time.
@@ -5619,7 +7727,7 @@ var Rive = /** @class */ (function () {
5619
7727
  // Poll focus state to see whether or not to blur or pull up a virtual keyboard for any change to a text input node.
5620
7728
  this.pollFocusState();
5621
7729
  // Handle callbacks for view model property changes
5622
- (_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.handleCallbacks();
7730
+ (_b = this._viewModelInstance) === null || _b === void 0 ? void 0 : _b.handleCallbacks();
5623
7731
  };
5624
7732
  /**
5625
7733
  * Draw rendering loop; renders animation frames at the correct time interval.
@@ -5781,6 +7889,8 @@ var Rive = /** @class */ (function () {
5781
7889
  }
5782
7890
  (_d = this._viewModelInstance) === null || _d === void 0 ? void 0 : _d.cleanup();
5783
7891
  this._viewModelInstance = null;
7892
+ this._globalViewModelInstances.forEach(function (instance) { return instance.cleanup(); });
7893
+ this._globalViewModelInstances.clear();
5784
7894
  this._dataEnums = null;
5785
7895
  };
5786
7896
  /**
@@ -5804,6 +7914,9 @@ var Rive = /** @class */ (function () {
5804
7914
  this.eventCleanup();
5805
7915
  }
5806
7916
  this.cleanupKeyboardInteractions();
7917
+ // Tear down semantics before deleting state machines — the overlay's action
7918
+ // closures point at instances that stop() is about to free.
7919
+ this.cleanupSemantics();
5807
7920
  // Delete all animation and state machine instances
5808
7921
  this.stop();
5809
7922
  if (this.artboard) {
@@ -5869,6 +7982,7 @@ var Rive = /** @class */ (function () {
5869
7982
  return;
5870
7983
  }
5871
7984
  this.animator.play(animationNames);
7985
+ this.syncSemanticsOnStateMachines();
5872
7986
  if (this.eventCleanup) {
5873
7987
  this.eventCleanup();
5874
7988
  }
@@ -5927,6 +8041,7 @@ var Rive = /** @class */ (function () {
5927
8041
  this.eventCleanup();
5928
8042
  }
5929
8043
  this.cleanupKeyboardInteractions();
8044
+ this.cleanupSemantics();
5930
8045
  };
5931
8046
  /**
5932
8047
  * Resets the animation
@@ -5970,6 +8085,8 @@ var Rive = /** @class */ (function () {
5970
8085
  // Sets a new layout
5971
8086
  set: function (layout) {
5972
8087
  this._layout = layout;
8088
+ // Fit/alignment/bounds feed the overlay transform.
8089
+ this._overlayTransformDirty = true;
5973
8090
  // If the maxX or maxY are 0, then set them to the canvas width and height
5974
8091
  if (!layout.maxX || !layout.maxY) {
5975
8092
  this.resizeToCanvas();
@@ -5992,6 +8109,8 @@ var Rive = /** @class */ (function () {
5992
8109
  maxX: this.canvas.width,
5993
8110
  maxY: this.canvas.height,
5994
8111
  });
8112
+ // Layout bounds feed the overlay transform.
8113
+ this._overlayTransformDirty = true;
5995
8114
  };
5996
8115
  /**
5997
8116
  * Accounts for devicePixelRatio as a multiplier to render the size of the canvas drawing surface.
@@ -6013,12 +8132,12 @@ var Rive = /** @class */ (function () {
6013
8132
  this.canvas.height = dpr * height;
6014
8133
  this._needsRedraw = true;
6015
8134
  this.resizeToCanvas();
6016
- this.drawFrame();
6017
8135
  if (this.layout.fit === Fit.Layout) {
6018
8136
  var scaleFactor = this._layout.layoutScaleFactor;
6019
8137
  this.artboard.width = width / scaleFactor;
6020
8138
  this.artboard.height = height / scaleFactor;
6021
8139
  }
8140
+ this.drawFrame();
6022
8141
  }
6023
8142
  };
6024
8143
  Object.defineProperty(Rive.prototype, "source", {
@@ -6039,6 +8158,30 @@ var Rive = /** @class */ (function () {
6039
8158
  enumerable: false,
6040
8159
  configurable: true
6041
8160
  });
8161
+ Object.defineProperty(Rive.prototype, "semanticTree", {
8162
+ /**
8163
+ * Returns the semantic tree model when semantics are enabled, or null.
8164
+ * The overlay and external consumers use this to inspect the
8165
+ * current state of the semantic tree.
8166
+ */
8167
+ get: function () {
8168
+ return this._semanticTree;
8169
+ },
8170
+ enumerable: false,
8171
+ configurable: true
8172
+ });
8173
+ Object.defineProperty(Rive.prototype, "accessibilityOverlay", {
8174
+ /**
8175
+ * Returns the accessibility overlay when semantics are enabled, or null.
8176
+ * External consumers can use this to inspect the
8177
+ * current state of the accessibility overlay for this instance.
8178
+ */
8179
+ get: function () {
8180
+ return this._accessibilityOverlay;
8181
+ },
8182
+ enumerable: false,
8183
+ configurable: true
8184
+ });
6042
8185
  Object.defineProperty(Rive.prototype, "animationNames", {
6043
8186
  // Returns a list of animation names on the chosen artboard
6044
8187
  get: function () {
@@ -6479,7 +8622,7 @@ var Rive = /** @class */ (function () {
6479
8622
  }
6480
8623
  for (var k = 0; k < artboard.stateMachineCount(); k++) {
6481
8624
  var stateMachine = artboard.stateMachineByIndex(k);
6482
- var name_1 = stateMachine.name;
8625
+ var name_2 = stateMachine.name;
6483
8626
  var instance = new this.runtime.StateMachineInstance(stateMachine, artboard);
6484
8627
  var inputContents = [];
6485
8628
  for (var l = 0; l < instance.inputCount(); l++) {
@@ -6487,7 +8630,7 @@ var Rive = /** @class */ (function () {
6487
8630
  inputContents.push({ name: input.name, type: input.type });
6488
8631
  }
6489
8632
  artboardContents.stateMachines.push({
6490
- name: name_1,
8633
+ name: name_2,
6491
8634
  inputs: inputContents,
6492
8635
  });
6493
8636
  }
@@ -6597,30 +8740,67 @@ var Rive = /** @class */ (function () {
6597
8740
  return this._devicePixelRatioUsed;
6598
8741
  },
6599
8742
  set: function (value) {
8743
+ if (value !== this._devicePixelRatioUsed) {
8744
+ this._overlayTransformDirty = true;
8745
+ }
6600
8746
  this._devicePixelRatioUsed = value;
6601
8747
  },
6602
8748
  enumerable: false,
6603
8749
  configurable: true
6604
8750
  });
6605
8751
  /**
6606
- * Initialize the data context with the view model instance.
8752
+ * Sets the main view model instance and applies it (rebinds). Equivalent to
8753
+ * `setViewModelInstance(vmi)` followed by `bind()`.
6607
8754
  */
6608
8755
  Rive.prototype.bindViewModelInstance = function (viewModelInstance) {
8756
+ if (!viewModelInstance) {
8757
+ return;
8758
+ }
8759
+ this.setViewModelInstance(viewModelInstance);
8760
+ this.bind();
8761
+ };
8762
+ /**
8763
+ * Sets the main view model instance in the data context WITHOUT rebinding.
8764
+ * Call {@link bind} to apply. Use this with {@link setGlobalViewModelInstance}
8765
+ * to batch multiple changes into a single rebind.
8766
+ */
8767
+ Rive.prototype.setViewModelInstance = function (viewModelInstance) {
6609
8768
  var _a;
6610
- if (this.artboard && !this.destroyed) {
6611
- if (viewModelInstance && viewModelInstance.runtimeInstance) {
6612
- viewModelInstance.internalIncrementReferenceCount();
6613
- (_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.cleanup();
6614
- this._viewModelInstance = viewModelInstance;
6615
- if (this.animator.stateMachines.length > 0) {
6616
- this.animator.stateMachines.forEach(function (stateMachine) {
6617
- return stateMachine.bindViewModelInstance(viewModelInstance);
6618
- });
6619
- }
6620
- else {
6621
- this.artboard.bindViewModelInstance(viewModelInstance.runtimeInstance);
6622
- }
6623
- }
8769
+ var runtimeInstance = viewModelInstance === null || viewModelInstance === void 0 ? void 0 : viewModelInstance.runtimeInstance;
8770
+ if (!this.artboard ||
8771
+ this.destroyed ||
8772
+ !viewModelInstance ||
8773
+ !runtimeInstance) {
8774
+ return;
8775
+ }
8776
+ viewModelInstance.internalIncrementReferenceCount();
8777
+ (_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.cleanup();
8778
+ this._viewModelInstance = viewModelInstance;
8779
+ if (this.animator.stateMachines.length > 0) {
8780
+ this.animator.stateMachines.forEach(function (stateMachine) {
8781
+ return stateMachine.instance.setViewModelInstance(runtimeInstance);
8782
+ });
8783
+ }
8784
+ else {
8785
+ this.artboard.setViewModelInstance(runtimeInstance);
8786
+ }
8787
+ };
8788
+ /**
8789
+ * Applies any pending `set*` view model instance changes by rebinding the
8790
+ * data binds once.
8791
+ * Implicitly creates and binds any view models that have not been set.
8792
+ */
8793
+ Rive.prototype.bind = function () {
8794
+ if (!this.artboard || this.destroyed) {
8795
+ return;
8796
+ }
8797
+ if (this.animator.stateMachines.length > 0) {
8798
+ this.animator.stateMachines.forEach(function (stateMachine) {
8799
+ return stateMachine.instance.bind();
8800
+ });
8801
+ }
8802
+ else {
8803
+ this.artboard.bind();
6624
8804
  }
6625
8805
  };
6626
8806
  Object.defineProperty(Rive.prototype, "viewModelInstance", {
@@ -6630,6 +8810,78 @@ var Rive = /** @class */ (function () {
6630
8810
  enumerable: false,
6631
8811
  configurable: true
6632
8812
  });
8813
+ /**
8814
+ * Sets (or replaces) the global view model instance for the given global view
8815
+ * model name in the data context WITHOUT rebinding. The main instance and any
8816
+ * other globals keep their order. Call {@link bind} to apply — batch several
8817
+ * `set*` calls then a single `bind()` to avoid rebinding per set.
8818
+ * @param name - the name of the global view model
8819
+ * @param viewModelInstance - the instance to set for that global
8820
+ * @returns whether the instance was set (false if `name` does not match a
8821
+ * global view model in the file)
8822
+ */
8823
+ Rive.prototype.setGlobalViewModelInstance = function (name, viewModelInstance) {
8824
+ var _a;
8825
+ var runtimeInstance = viewModelInstance === null || viewModelInstance === void 0 ? void 0 : viewModelInstance.runtimeInstance;
8826
+ if (!this.artboard || this.destroyed || !runtimeInstance) {
8827
+ return false;
8828
+ }
8829
+ var bound = false;
8830
+ if (this.animator.stateMachines.length > 0) {
8831
+ this.animator.stateMachines.forEach(function (stateMachine) {
8832
+ if (stateMachine.instance.setGlobalViewModelInstance(name, runtimeInstance)) {
8833
+ bound = true;
8834
+ }
8835
+ });
8836
+ }
8837
+ else {
8838
+ bound = this.artboard.setGlobalViewModelInstance(name, runtimeInstance);
8839
+ }
8840
+ if (bound) {
8841
+ viewModelInstance.internalIncrementReferenceCount();
8842
+ (_a = this._globalViewModelInstances.get(name)) === null || _a === void 0 ? void 0 : _a.cleanup();
8843
+ this._globalViewModelInstances.set(name, viewModelInstance);
8844
+ }
8845
+ return bound;
8846
+ };
8847
+ /**
8848
+ * @param name - the name of the global view model
8849
+ * @returns the global view model instance bound under the given name — the
8850
+ * instance set via {@link setGlobalViewModelInstance} or one created by
8851
+ * auto-bind — or null if none has been set/created for that name (globals are
8852
+ * not auto-created; the getter never creates one).
8853
+ */
8854
+ Rive.prototype.globalViewModelInstance = function (name) {
8855
+ var cached = this._globalViewModelInstances.get(name);
8856
+ if (cached) {
8857
+ return cached;
8858
+ }
8859
+ if (!this.artboard || this.destroyed) {
8860
+ return null;
8861
+ }
8862
+ // State machines share the artboard's data context; query the first one
8863
+ // when present (mirroring how the setter routes), otherwise the artboard.
8864
+ // This is a pure read — it returns null unless an instance was set/bound.
8865
+ var runtimeInstance = this.animator.stateMachines.length > 0
8866
+ ? this.animator.stateMachines[0].instance.globalViewModelInstance(name)
8867
+ : this.artboard.globalViewModelInstance(name);
8868
+ if (runtimeInstance === null) {
8869
+ return null;
8870
+ }
8871
+ var viewModelInstance = new ViewModelInstance(runtimeInstance, null);
8872
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(viewModelInstance, runtimeInstance);
8873
+ viewModelInstance.internalIncrementReferenceCount();
8874
+ this._globalViewModelInstances.set(name, viewModelInstance);
8875
+ return viewModelInstance;
8876
+ };
8877
+ /**
8878
+ * @returns the names of the file's global view models, in file order. Use
8879
+ * these with {@link setGlobalViewModelInstance} / {@link globalViewModelInstance}.
8880
+ */
8881
+ Rive.prototype.globalViewModelNames = function () {
8882
+ var _a, _b;
8883
+ return (_b = (_a = this.file) === null || _a === void 0 ? void 0 : _a.globalViewModelNames()) !== null && _b !== void 0 ? _b : [];
8884
+ };
6633
8885
  Rive.prototype.viewModelByIndex = function (index) {
6634
8886
  var viewModel = this.file.viewModelByIndex(index);
6635
8887
  if (viewModel !== null) {
@@ -6730,7 +8982,7 @@ var ViewModel = /** @class */ (function () {
6730
8982
  var instance = this._viewModel.instanceByIndex(index);
6731
8983
  if (instance !== null) {
6732
8984
  var viewModelInstance = new ViewModelInstance(instance, null);
6733
- (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, instance);
8985
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(viewModelInstance, instance);
6734
8986
  return viewModelInstance;
6735
8987
  }
6736
8988
  return null;
@@ -6739,7 +8991,7 @@ var ViewModel = /** @class */ (function () {
6739
8991
  var instance = this._viewModel.instanceByName(name);
6740
8992
  if (instance !== null) {
6741
8993
  var viewModelInstance = new ViewModelInstance(instance, null);
6742
- (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, instance);
8994
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(viewModelInstance, instance);
6743
8995
  return viewModelInstance;
6744
8996
  }
6745
8997
  return null;
@@ -6748,7 +9000,7 @@ var ViewModel = /** @class */ (function () {
6748
9000
  var runtimeInstance = this._viewModel.defaultInstance();
6749
9001
  if (runtimeInstance !== null) {
6750
9002
  var viewModelInstance = new ViewModelInstance(runtimeInstance, null);
6751
- (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, runtimeInstance);
9003
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(viewModelInstance, runtimeInstance);
6752
9004
  return viewModelInstance;
6753
9005
  }
6754
9006
  return null;
@@ -6757,7 +9009,7 @@ var ViewModel = /** @class */ (function () {
6757
9009
  var runtimeInstance = this._viewModel.instance();
6758
9010
  if (runtimeInstance !== null) {
6759
9011
  var viewModelInstance = new ViewModelInstance(runtimeInstance, null);
6760
- (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, runtimeInstance);
9012
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(viewModelInstance, runtimeInstance);
6761
9013
  return viewModelInstance;
6762
9014
  }
6763
9015
  return null;
@@ -6810,6 +9062,7 @@ var PropertyType;
6810
9062
  PropertyType["Enum"] = "enum";
6811
9063
  PropertyType["List"] = "list";
6812
9064
  PropertyType["Image"] = "image";
9065
+ PropertyType["Font"] = "font";
6813
9066
  PropertyType["Artboard"] = "artboard";
6814
9067
  })(PropertyType || (PropertyType = {}));
6815
9068
  var ViewModelInstance = /** @class */ (function () {
@@ -6945,7 +9198,7 @@ var ViewModelInstance = /** @class */ (function () {
6945
9198
  return null;
6946
9199
  };
6947
9200
  ViewModelInstance.prototype.propertyFromPathSegments = function (pathSegments, index, type) {
6948
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
9201
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
6949
9202
  if (index < pathSegments.length - 1) {
6950
9203
  var viewModelInstance = this.internalViewModelInstance(pathSegments[index]);
6951
9204
  if (viewModelInstance !== null) {
@@ -7005,8 +9258,14 @@ var ViewModelInstance = /** @class */ (function () {
7005
9258
  return new ViewModelInstanceAssetImage(instance, this);
7006
9259
  }
7007
9260
  break;
9261
+ case PropertyType.Font:
9262
+ instance = (_t = (_s = this._runtimeInstance) === null || _s === void 0 ? void 0 : _s.font(pathSegments[index])) !== null && _t !== void 0 ? _t : null;
9263
+ if (instance !== null) {
9264
+ return new ViewModelInstanceAssetFont(instance, this);
9265
+ }
9266
+ break;
7008
9267
  case PropertyType.Artboard:
7009
- instance = (_t = (_s = this._runtimeInstance) === null || _s === void 0 ? void 0 : _s.artboard(pathSegments[index])) !== null && _t !== void 0 ? _t : null;
9268
+ instance = (_v = (_u = this._runtimeInstance) === null || _u === void 0 ? void 0 : _u.artboard(pathSegments[index])) !== null && _v !== void 0 ? _v : null;
7010
9269
  if (instance !== null) {
7011
9270
  return new ViewModelInstanceArtboard(instance, this);
7012
9271
  }
@@ -7022,7 +9281,7 @@ var ViewModelInstance = /** @class */ (function () {
7022
9281
  var viewModelRuntimeInstance = (_a = this._runtimeInstance) === null || _a === void 0 ? void 0 : _a.viewModel(name);
7023
9282
  if (viewModelRuntimeInstance !== null) {
7024
9283
  var viewModelInstance = new ViewModelInstance(viewModelRuntimeInstance, this);
7025
- (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, viewModelRuntimeInstance);
9284
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(viewModelInstance, viewModelRuntimeInstance);
7026
9285
  viewModelInstance.internalIncrementReferenceCount();
7027
9286
  this._viewModelInstances.set(name, viewModelInstance);
7028
9287
  return viewModelInstance;
@@ -7101,6 +9360,15 @@ var ViewModelInstance = /** @class */ (function () {
7101
9360
  var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Image);
7102
9361
  return viewmodelInstanceValue;
7103
9362
  };
9363
+ /**
9364
+ * method to access a view model property instance belonging
9365
+ * to the view model instance or to a nested view model instance
9366
+ * @param path - path to the font property
9367
+ */
9368
+ ViewModelInstance.prototype.font = function (path) {
9369
+ var viewmodelInstanceValue = this.propertyFromPath(path, PropertyType.Font);
9370
+ return viewmodelInstanceValue;
9371
+ };
7104
9372
  /**
7105
9373
  * method to access an artboard property instance belonging
7106
9374
  * to the view model instance or to a nested view model instance
@@ -7439,7 +9707,7 @@ var ViewModelInstanceList = /** @class */ (function (_super) {
7439
9707
  var runtimeInstance = this._viewModelInstanceValue.instanceAt(index);
7440
9708
  if (runtimeInstance != null) {
7441
9709
  var viewModelInstance = new ViewModelInstance(runtimeInstance, this._parentViewModel);
7442
- (0,_utils__WEBPACK_IMPORTED_MODULE_2__.createFinalization)(viewModelInstance, runtimeInstance);
9710
+ (0,_utils__WEBPACK_IMPORTED_MODULE_3__.createFinalization)(viewModelInstance, runtimeInstance);
7443
9711
  return viewModelInstance;
7444
9712
  }
7445
9713
  return null;
@@ -7510,6 +9778,25 @@ var ViewModelInstanceAssetImage = /** @class */ (function (_super) {
7510
9778
  return ViewModelInstanceAssetImage;
7511
9779
  }(ViewModelInstanceValue));
7512
9780
 
9781
+ var ViewModelInstanceAssetFont = /** @class */ (function (_super) {
9782
+ __extends(ViewModelInstanceAssetFont, _super);
9783
+ function ViewModelInstanceAssetFont(instance, root) {
9784
+ return _super.call(this, instance, root) || this;
9785
+ }
9786
+ Object.defineProperty(ViewModelInstanceAssetFont.prototype, "value", {
9787
+ set: function (font) {
9788
+ var _a;
9789
+ this._viewModelInstanceValue.value((_a = font === null || font === void 0 ? void 0 : font.nativeFont) !== null && _a !== void 0 ? _a : null);
9790
+ },
9791
+ enumerable: false,
9792
+ configurable: true
9793
+ });
9794
+ ViewModelInstanceAssetFont.prototype.internalHandleCallback = function (callback) {
9795
+ callback();
9796
+ };
9797
+ return ViewModelInstanceAssetFont;
9798
+ }(ViewModelInstanceValue));
9799
+
7513
9800
  var ViewModelInstanceArtboard = /** @class */ (function (_super) {
7514
9801
  __extends(ViewModelInstanceArtboard, _super);
7515
9802
  function ViewModelInstanceArtboard(instance, root) {
@@ -7602,8 +9889,8 @@ var decodeAudio = function (bytes) { return __awaiter(void 0, void 0, void 0, fu
7602
9889
  return [4 /*yield*/, decodedPromise];
7603
9890
  case 1:
7604
9891
  audio = _a.sent();
7605
- audioWrapper = new _utils__WEBPACK_IMPORTED_MODULE_2__.AudioWrapper(audio);
7606
- _utils__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry.register(audioWrapper, audio);
9892
+ audioWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.AudioWrapper(audio);
9893
+ _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(audioWrapper, audio);
7607
9894
  return [2 /*return*/, audioWrapper];
7608
9895
  }
7609
9896
  });
@@ -7627,8 +9914,8 @@ var decodeImage = function (bytes) { return __awaiter(void 0, void 0, void 0, fu
7627
9914
  return [4 /*yield*/, decodedPromise];
7628
9915
  case 1:
7629
9916
  image = _a.sent();
7630
- imageWrapper = new _utils__WEBPACK_IMPORTED_MODULE_2__.ImageWrapper(image);
7631
- _utils__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry.register(imageWrapper, image);
9917
+ imageWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.ImageWrapper(image);
9918
+ _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(imageWrapper, image);
7632
9919
  return [2 /*return*/, imageWrapper];
7633
9920
  }
7634
9921
  });
@@ -7652,8 +9939,8 @@ var decodeFont = function (bytes) { return __awaiter(void 0, void 0, void 0, fun
7652
9939
  return [4 /*yield*/, decodedPromise];
7653
9940
  case 1:
7654
9941
  font = _a.sent();
7655
- fontWrapper = new _utils__WEBPACK_IMPORTED_MODULE_2__.FontWrapper(font);
7656
- _utils__WEBPACK_IMPORTED_MODULE_2__.finalizationRegistry.register(fontWrapper, font);
9942
+ fontWrapper = new _utils__WEBPACK_IMPORTED_MODULE_3__.FontWrapper(font);
9943
+ _utils__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry.register(fontWrapper, font);
7657
9944
  return [2 /*return*/, fontWrapper];
7658
9945
  }
7659
9946
  });