@rive-app/canvas 2.37.7 → 2.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/rive.d.ts +55 -0
- package/rive.js +385 -61
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +41 -0
- package/rive_fallback.wasm +0 -0
- package/utils/finalizationRegistry.d.ts +1 -1
- package/utils/index.d.ts +2 -0
- package/utils/registerKeyboardInteractions.d.ts +82 -0
- package/utils/registerTouchInteractions.d.ts +2 -1
package/rive.js
CHANGED
|
@@ -1084,7 +1084,7 @@ function Za(a, b) {
|
|
|
1084
1084
|
return Ya(c, a, b);
|
|
1085
1085
|
}));
|
|
1086
1086
|
}
|
|
1087
|
-
var $a, ab, eb = {
|
|
1087
|
+
var $a, ab, eb = {485773:(a, b, c, d, e) => {
|
|
1088
1088
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
1089
1089
|
return 0;
|
|
1090
1090
|
}
|
|
@@ -1147,11 +1147,11 @@ var $a, ab, eb = {484301:(a, b, c, d, e) => {
|
|
|
1147
1147
|
}
|
|
1148
1148
|
window.h.za += 1;
|
|
1149
1149
|
return 1;
|
|
1150
|
-
},
|
|
1150
|
+
}, 487951:() => {
|
|
1151
1151
|
"undefined" !== typeof window.h && (window.h.Sa.map(function(a) {
|
|
1152
1152
|
document.removeEventListener(a, window.h.unlock, !0);
|
|
1153
1153
|
}), --window.h.za, 0 === window.h.za && delete window.h);
|
|
1154
|
-
},
|
|
1154
|
+
}, 488255:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 488359:() => {
|
|
1155
1155
|
try {
|
|
1156
1156
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
1157
1157
|
a.close();
|
|
@@ -1159,7 +1159,7 @@ var $a, ab, eb = {484301:(a, b, c, d, e) => {
|
|
|
1159
1159
|
} catch (c) {
|
|
1160
1160
|
return 0;
|
|
1161
1161
|
}
|
|
1162
|
-
},
|
|
1162
|
+
}, 488530:(a, b, c, d, e, f) => {
|
|
1163
1163
|
if ("undefined" === typeof window.h) {
|
|
1164
1164
|
return -1;
|
|
1165
1165
|
}
|
|
@@ -1205,7 +1205,7 @@ var $a, ab, eb = {484301:(a, b, c, d, e) => {
|
|
|
1205
1205
|
a == window.h.J.xa && g.Z.connect(g.L.destination);
|
|
1206
1206
|
g.pb = f;
|
|
1207
1207
|
return window.h.tc(g);
|
|
1208
|
-
},
|
|
1208
|
+
}, 491407:a => window.h.qa(a).L.sampleRate, 491480:a => {
|
|
1209
1209
|
a = window.h.qa(a);
|
|
1210
1210
|
void 0 !== a.Z && (a.Z.onaudioprocess = function() {
|
|
1211
1211
|
}, a.Z.disconnect(), a.Z = void 0);
|
|
@@ -1213,13 +1213,13 @@ var $a, ab, eb = {484301:(a, b, c, d, e) => {
|
|
|
1213
1213
|
a.L.close();
|
|
1214
1214
|
a.L = void 0;
|
|
1215
1215
|
a.pb = void 0;
|
|
1216
|
-
},
|
|
1216
|
+
}, 491880:a => {
|
|
1217
1217
|
window.h.Ab(a);
|
|
1218
|
-
},
|
|
1218
|
+
}, 491930:a => {
|
|
1219
1219
|
a = window.h.qa(a);
|
|
1220
1220
|
a.L.resume();
|
|
1221
1221
|
a.state = window.h.ga.wb;
|
|
1222
|
-
},
|
|
1222
|
+
}, 492069:a => {
|
|
1223
1223
|
a = window.h.qa(a);
|
|
1224
1224
|
a.L.suspend();
|
|
1225
1225
|
a.state = window.h.ga.stopped;
|
|
@@ -3752,7 +3752,7 @@ moduleRtn = ea;
|
|
|
3752
3752
|
/* 5 */
|
|
3753
3753
|
/***/ ((module) => {
|
|
3754
3754
|
|
|
3755
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.
|
|
3755
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.38.0","description":"Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3756
3756
|
|
|
3757
3757
|
/***/ }),
|
|
3758
3758
|
/* 6 */
|
|
@@ -3760,26 +3760,30 @@ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"
|
|
|
3760
3760
|
|
|
3761
3761
|
__webpack_require__.r(__webpack_exports__);
|
|
3762
3762
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3763
|
-
/* harmony export */ AudioAssetWrapper: () => (/* reexport safe */
|
|
3764
|
-
/* harmony export */ AudioWrapper: () => (/* reexport safe */
|
|
3765
|
-
/* harmony export */ BLANK_URL: () => (/* reexport safe */
|
|
3766
|
-
/* harmony export */ CustomFileAssetLoaderWrapper: () => (/* reexport safe */
|
|
3767
|
-
/* harmony export */ FileAssetWrapper: () => (/* reexport safe */
|
|
3768
|
-
/* harmony export */ FileFinalizer: () => (/* reexport safe */
|
|
3769
|
-
/* harmony export */
|
|
3770
|
-
/* harmony export */
|
|
3771
|
-
/* harmony export */
|
|
3772
|
-
/* harmony export */
|
|
3773
|
-
/* harmony export */
|
|
3774
|
-
/* harmony export */
|
|
3775
|
-
/* harmony export */
|
|
3763
|
+
/* harmony export */ AudioAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.AudioAssetWrapper),
|
|
3764
|
+
/* harmony export */ AudioWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.AudioWrapper),
|
|
3765
|
+
/* harmony export */ BLANK_URL: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__.BLANK_URL),
|
|
3766
|
+
/* harmony export */ CustomFileAssetLoaderWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.CustomFileAssetLoaderWrapper),
|
|
3767
|
+
/* harmony export */ FileAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.FileAssetWrapper),
|
|
3768
|
+
/* harmony export */ FileFinalizer: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.FileFinalizer),
|
|
3769
|
+
/* harmony export */ FocusSessionState: () => (/* reexport safe */ _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__.FocusSessionState),
|
|
3770
|
+
/* harmony export */ FontAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.FontAssetWrapper),
|
|
3771
|
+
/* harmony export */ FontWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.FontWrapper),
|
|
3772
|
+
/* harmony export */ ImageAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.ImageAssetWrapper),
|
|
3773
|
+
/* harmony export */ ImageWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.ImageWrapper),
|
|
3774
|
+
/* harmony export */ KeyboardInteractions: () => (/* reexport safe */ _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__.KeyboardInteractions),
|
|
3775
|
+
/* harmony export */ RiveFont: () => (/* reexport safe */ _riveFont__WEBPACK_IMPORTED_MODULE_4__.RiveFont),
|
|
3776
|
+
/* harmony export */ createFinalization: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.createFinalization),
|
|
3777
|
+
/* harmony export */ finalizationRegistry: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry),
|
|
3776
3778
|
/* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
|
|
3777
|
-
/* harmony export */ sanitizeUrl: () => (/* reexport safe */
|
|
3779
|
+
/* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)
|
|
3778
3780
|
/* harmony export */ });
|
|
3779
3781
|
/* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
|
|
3780
|
-
/* harmony import */ var
|
|
3781
|
-
/* harmony import */ var
|
|
3782
|
-
/* harmony import */ var
|
|
3782
|
+
/* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
|
|
3783
|
+
/* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
|
|
3784
|
+
/* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
|
|
3785
|
+
/* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(11);
|
|
3786
|
+
|
|
3783
3787
|
|
|
3784
3788
|
|
|
3785
3789
|
|
|
@@ -3866,7 +3870,7 @@ var getClientCoordinates = function (event, isTouchScrollEnabled, enableMultiTou
|
|
|
3866
3870
|
* the state machine pointer move/up/down functions based on cursor interaction
|
|
3867
3871
|
*/
|
|
3868
3872
|
var registerTouchInteractions = function (_a) {
|
|
3869
|
-
var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c, _d = _a.dispatchPointerExit, dispatchPointerExit = _d === void 0 ? true : _d, _e = _a.enableMultiTouch, enableMultiTouch = _e === void 0 ? false : _e, _f = _a.layoutScaleFactor, layoutScaleFactor = _f === void 0 ? 1.0 : _f;
|
|
3873
|
+
var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c, _d = _a.dispatchPointerExit, dispatchPointerExit = _d === void 0 ? true : _d, _e = _a.enableMultiTouch, enableMultiTouch = _e === void 0 ? false : _e, _f = _a.layoutScaleFactor, layoutScaleFactor = _f === void 0 ? 1.0 : _f, advanceAndDrain = _a.advanceAndDrain;
|
|
3870
3874
|
if (!canvas ||
|
|
3871
3875
|
!stateMachines.length ||
|
|
3872
3876
|
!renderer ||
|
|
@@ -4009,6 +4013,8 @@ var registerTouchInteractions = function (_a) {
|
|
|
4009
4013
|
var stateMachine = stateMachines_3[_c];
|
|
4010
4014
|
_loop_3(stateMachine);
|
|
4011
4015
|
}
|
|
4016
|
+
// Advance the state machine immediately so pointer down(s) takes effect synchronously
|
|
4017
|
+
advanceAndDrain(0);
|
|
4012
4018
|
break;
|
|
4013
4019
|
}
|
|
4014
4020
|
// Pointer click released on the canvas
|
|
@@ -4023,6 +4029,8 @@ var registerTouchInteractions = function (_a) {
|
|
|
4023
4029
|
var stateMachine = stateMachines_4[_d];
|
|
4024
4030
|
_loop_4(stateMachine);
|
|
4025
4031
|
}
|
|
4032
|
+
// Advance the state machine immediately so pointer up(s) takes effect synchronously
|
|
4033
|
+
advanceAndDrain(0);
|
|
4026
4034
|
// Release the primary touch lock once that finger lifts so the next
|
|
4027
4035
|
// touchstart can claim a new primary finger.
|
|
4028
4036
|
if (!enableMultiTouch &&
|
|
@@ -4041,6 +4049,8 @@ var registerTouchInteractions = function (_a) {
|
|
|
4041
4049
|
var stateMachine = stateMachines_5[_e];
|
|
4042
4050
|
_loop_5(stateMachine);
|
|
4043
4051
|
}
|
|
4052
|
+
// Advance the state machine immediately so pointer up(s) takes effect synchronously
|
|
4053
|
+
advanceAndDrain(0);
|
|
4044
4054
|
break;
|
|
4045
4055
|
}
|
|
4046
4056
|
default:
|
|
@@ -4081,6 +4091,153 @@ var registerTouchInteractions = function (_a) {
|
|
|
4081
4091
|
/* 8 */
|
|
4082
4092
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4083
4093
|
|
|
4094
|
+
__webpack_require__.r(__webpack_exports__);
|
|
4095
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4096
|
+
/* harmony export */ FocusSessionState: () => (/* binding */ FocusSessionState),
|
|
4097
|
+
/* harmony export */ KeyboardInteractions: () => (/* binding */ KeyboardInteractions)
|
|
4098
|
+
/* harmony export */ });
|
|
4099
|
+
/**
|
|
4100
|
+
* Tracks the relationship between the canvas's DOM focus and Rive's internal focus for the
|
|
4101
|
+
* current focus session.
|
|
4102
|
+
*
|
|
4103
|
+
* NotFocused — the canvas is not the active DOM element, or Rive entered and then released focus
|
|
4104
|
+
* internally this session. Either way the next Tab should move on to the next page
|
|
4105
|
+
* element, so Tab events are ignored.
|
|
4106
|
+
* EntryPending — the canvas has DOM focus but Rive holds no active focus node yet, and the next Tab should enter
|
|
4107
|
+
* the focus tree. This is the resting state for pointer-driven focus (a click on the
|
|
4108
|
+
* canvas), or an edge case for keyboard focus where initial focus action did not land on a focus node.
|
|
4109
|
+
* RiveFocused — a Rive node currently holds focus. Tab/Shift+Tab are routed to the Rive focus
|
|
4110
|
+
* manager and trapped inside the canvas until Rive notifies focus has ended.
|
|
4111
|
+
*
|
|
4112
|
+
* When keyboard focus lands on the canvas, onCanvasFocus reads the direction focus came from and
|
|
4113
|
+
* moves into the focus tree immediately, going straight to RiveFocused. EntryPending is only set via pointer focus (or keyboard focus
|
|
4114
|
+
* where focusNext()/focusPrevious() return false but respects tabindex).
|
|
4115
|
+
*/
|
|
4116
|
+
var FocusSessionState;
|
|
4117
|
+
(function (FocusSessionState) {
|
|
4118
|
+
FocusSessionState["NotFocused"] = "notFocused";
|
|
4119
|
+
FocusSessionState["EntryPending"] = "entryPending";
|
|
4120
|
+
FocusSessionState["RiveFocused"] = "riveFocused";
|
|
4121
|
+
})(FocusSessionState || (FocusSessionState = {}));
|
|
4122
|
+
/**
|
|
4123
|
+
* Manages keyboard and DOM focus interactions for a Rive canvas.
|
|
4124
|
+
*
|
|
4125
|
+
* Tracks the canvas focus session state (focusSessionState) and routes
|
|
4126
|
+
* Tab/Shift+Tab to the Rive state machine's focus manager. Exposes shared
|
|
4127
|
+
* state as properties so the Rive render loop can read them directly.
|
|
4128
|
+
*/
|
|
4129
|
+
var KeyboardInteractions = /** @class */ (function () {
|
|
4130
|
+
function KeyboardInteractions(_a) {
|
|
4131
|
+
var canvas = _a.canvas, stateMachine = _a.stateMachine, hasFocusNodes = _a.hasFocusNodes;
|
|
4132
|
+
var _this = this;
|
|
4133
|
+
this.focusSessionState = FocusSessionState.NotFocused;
|
|
4134
|
+
/**
|
|
4135
|
+
* Handles the canvas gaining browser focus. The behavior differs based on how focus was gained -
|
|
4136
|
+
*
|
|
4137
|
+
* Pointer-driven focus: the canvas now has focus but Rive holds nothing yet, so we move to EntryPending — this lets the
|
|
4138
|
+
* next Tab enter the focus tree even when the focus is pointer-driven
|
|
4139
|
+
*
|
|
4140
|
+
* Keyboard-driven focus: we enter the Rive focus tree immediately once canvas gains focus.
|
|
4141
|
+
* The direction is inferred from where focus came from: an element before the canvas in DOM order
|
|
4142
|
+
* means a forward Tab (focusNext), one after means a Shift+Tab (focusPrevious). :focus-visible
|
|
4143
|
+
* gates this so a click doesn't yank Rive focus to the first node on the focus event itself.
|
|
4144
|
+
*/
|
|
4145
|
+
this.onCanvasFocus = function (event) {
|
|
4146
|
+
if (!_this.hasFocusNodes)
|
|
4147
|
+
return;
|
|
4148
|
+
if (_this.mainSm.focusState().hasFocus)
|
|
4149
|
+
return;
|
|
4150
|
+
_this.focusSessionState = FocusSessionState.EntryPending;
|
|
4151
|
+
// Pointer focus waits for the user's next Tab (handled in onKeyDown). Keyboard focus enters now.
|
|
4152
|
+
if (!_this.isKeyboardDrivenFocus())
|
|
4153
|
+
return;
|
|
4154
|
+
var forward = _this.cameFromBeforeCanvas(event.relatedTarget);
|
|
4155
|
+
if (forward ? _this.mainSm.focusNext() : _this.mainSm.focusPrevious()) {
|
|
4156
|
+
_this.focusSessionState = FocusSessionState.RiveFocused;
|
|
4157
|
+
}
|
|
4158
|
+
};
|
|
4159
|
+
this.onCanvasBlur = function (_event) {
|
|
4160
|
+
_this.focusSessionState = FocusSessionState.NotFocused;
|
|
4161
|
+
};
|
|
4162
|
+
this.onKeyDown = function (event) {
|
|
4163
|
+
if (_this.focusSessionState === FocusSessionState.NotFocused)
|
|
4164
|
+
return;
|
|
4165
|
+
if (event.code === "Tab" && _this.hasFocusNodes) {
|
|
4166
|
+
var forward = !event.shiftKey;
|
|
4167
|
+
var focusMoved = forward ? _this.mainSm.focusNext() : _this.mainSm.focusPrevious();
|
|
4168
|
+
if (focusMoved) {
|
|
4169
|
+
// A Rive node accepted focus — keep trapping Tab inside the canvas.
|
|
4170
|
+
_this.focusSessionState = FocusSessionState.RiveFocused;
|
|
4171
|
+
event.preventDefault();
|
|
4172
|
+
}
|
|
4173
|
+
else {
|
|
4174
|
+
// No more traversable nodes — release Tab to the page.
|
|
4175
|
+
// Set state immediately; onCanvasBlur will also fire naturally.
|
|
4176
|
+
_this.focusSessionState = FocusSessionState.NotFocused;
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
4179
|
+
};
|
|
4180
|
+
this.canvas = canvas;
|
|
4181
|
+
this.mainSm = stateMachine;
|
|
4182
|
+
this.hasFocusNodes = hasFocusNodes;
|
|
4183
|
+
canvas.addEventListener("focus", this.onCanvasFocus);
|
|
4184
|
+
canvas.addEventListener("blur", this.onCanvasBlur);
|
|
4185
|
+
canvas.addEventListener("keydown", this.onKeyDown);
|
|
4186
|
+
}
|
|
4187
|
+
/**
|
|
4188
|
+
* Set the FocusSessionState. Useful for invoking a Rive "blur" without actually blurring from the <canvas>. This
|
|
4189
|
+
* helps put the DOM focus state on the canvas rather than the <body>, so the user doesn't lose the spot in page navigation
|
|
4190
|
+
*
|
|
4191
|
+
* @param state FocusSessionState enum
|
|
4192
|
+
*/
|
|
4193
|
+
KeyboardInteractions.prototype.setFocusSessionState = function (state) {
|
|
4194
|
+
this.focusSessionState = state;
|
|
4195
|
+
};
|
|
4196
|
+
/**
|
|
4197
|
+
* Called by pollFocusState on the Rive instance when it observes hasFocus=true. Rive acquired
|
|
4198
|
+
* focus internally (e.g. via a listener action or state transition) without a DOM focus event,
|
|
4199
|
+
* so mark the session RiveFocused.
|
|
4200
|
+
*/
|
|
4201
|
+
KeyboardInteractions.prototype.notifyRiveFocused = function () {
|
|
4202
|
+
this.focusSessionState = FocusSessionState.RiveFocused;
|
|
4203
|
+
};
|
|
4204
|
+
/**
|
|
4205
|
+
* Whether the canvas currently matches :focus-visible — the browser's heuristic for keyboard-
|
|
4206
|
+
* (vs pointer-) driven focus. For older browser versions that don't support this selector, return false
|
|
4207
|
+
* so that we don't incorrectly assume pointer vs keyboard focus. Next tab would enter the focus tree in those edge cases.
|
|
4208
|
+
*/
|
|
4209
|
+
KeyboardInteractions.prototype.isKeyboardDrivenFocus = function () {
|
|
4210
|
+
try {
|
|
4211
|
+
return this.canvas.matches(":focus-visible");
|
|
4212
|
+
}
|
|
4213
|
+
catch (_a) {
|
|
4214
|
+
return false;
|
|
4215
|
+
}
|
|
4216
|
+
};
|
|
4217
|
+
KeyboardInteractions.prototype.cameFromBeforeCanvas = function (from) {
|
|
4218
|
+
if (!from)
|
|
4219
|
+
return true;
|
|
4220
|
+
var position = this.canvas.compareDocumentPosition(from);
|
|
4221
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING)
|
|
4222
|
+
return true;
|
|
4223
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING)
|
|
4224
|
+
return false;
|
|
4225
|
+
return true;
|
|
4226
|
+
};
|
|
4227
|
+
KeyboardInteractions.prototype.cleanup = function () {
|
|
4228
|
+
this.canvas.removeEventListener("focus", this.onCanvasFocus);
|
|
4229
|
+
this.canvas.removeEventListener("blur", this.onCanvasBlur);
|
|
4230
|
+
this.canvas.removeEventListener("keydown", this.onKeyDown);
|
|
4231
|
+
};
|
|
4232
|
+
return KeyboardInteractions;
|
|
4233
|
+
}());
|
|
4234
|
+
|
|
4235
|
+
|
|
4236
|
+
|
|
4237
|
+
/***/ }),
|
|
4238
|
+
/* 9 */
|
|
4239
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4240
|
+
|
|
4084
4241
|
__webpack_require__.r(__webpack_exports__);
|
|
4085
4242
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4086
4243
|
/* harmony export */ BLANK_URL: () => (/* binding */ BLANK_URL),
|
|
@@ -4131,7 +4288,7 @@ function sanitizeUrl(url) {
|
|
|
4131
4288
|
|
|
4132
4289
|
|
|
4133
4290
|
/***/ }),
|
|
4134
|
-
/*
|
|
4291
|
+
/* 10 */
|
|
4135
4292
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4136
4293
|
|
|
4137
4294
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -4272,6 +4429,9 @@ var CustomFileAssetLoaderWrapper = /** @class */ (function () {
|
|
|
4272
4429
|
else if (asset.isFont) {
|
|
4273
4430
|
assetWrapper = new FontAssetWrapper(asset);
|
|
4274
4431
|
}
|
|
4432
|
+
else {
|
|
4433
|
+
return false;
|
|
4434
|
+
}
|
|
4275
4435
|
return this._assetLoaderCallback(assetWrapper, bytes);
|
|
4276
4436
|
};
|
|
4277
4437
|
return CustomFileAssetLoaderWrapper;
|
|
@@ -4410,7 +4570,7 @@ var createFinalization = function (target, finalizable) {
|
|
|
4410
4570
|
|
|
4411
4571
|
|
|
4412
4572
|
/***/ }),
|
|
4413
|
-
/*
|
|
4573
|
+
/* 11 */
|
|
4414
4574
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4415
4575
|
|
|
4416
4576
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -4911,6 +5071,7 @@ var StateMachine = /** @class */ (function () {
|
|
|
4911
5071
|
this.inputs = [];
|
|
4912
5072
|
this.instance = new runtime.StateMachineInstance(stateMachine, artboard);
|
|
4913
5073
|
this.initInputs(runtime);
|
|
5074
|
+
this.hasFocusNodes = this.instance.hasFocusNodes();
|
|
4914
5075
|
}
|
|
4915
5076
|
Object.defineProperty(StateMachine.prototype, "name", {
|
|
4916
5077
|
get: function () {
|
|
@@ -5006,6 +5167,19 @@ var StateMachine = /** @class */ (function () {
|
|
|
5006
5167
|
this.instance.bindViewModelInstance(viewModelInstance.runtimeInstance);
|
|
5007
5168
|
}
|
|
5008
5169
|
};
|
|
5170
|
+
/**
|
|
5171
|
+
* Get metadata about the state of focus if applicable for this state machine.
|
|
5172
|
+
* @returns FocusState - { hasFocus: boolean, expectsKeyboardInput: boolean }
|
|
5173
|
+
*/
|
|
5174
|
+
StateMachine.prototype.focusState = function () {
|
|
5175
|
+
return this.instance.focusState();
|
|
5176
|
+
};
|
|
5177
|
+
/**
|
|
5178
|
+
* Clear focus from the Rive focus node tree.
|
|
5179
|
+
*/
|
|
5180
|
+
StateMachine.prototype.clearFocus = function () {
|
|
5181
|
+
this.instance.clearFocus();
|
|
5182
|
+
};
|
|
5009
5183
|
return StateMachine;
|
|
5010
5184
|
}());
|
|
5011
5185
|
// #endregion
|
|
@@ -6012,7 +6186,7 @@ var RiveFile = /** @class */ (function () {
|
|
|
6012
6186
|
var Rive = /** @class */ (function () {
|
|
6013
6187
|
function Rive(params) {
|
|
6014
6188
|
var _this = this;
|
|
6015
|
-
var _a, _b;
|
|
6189
|
+
var _a, _b, _c;
|
|
6016
6190
|
// Tracks if a Rive file is loaded
|
|
6017
6191
|
this.loaded = false;
|
|
6018
6192
|
// Tracks if a Rive file is destroyed
|
|
@@ -6029,8 +6203,10 @@ var Rive = /** @class */ (function () {
|
|
|
6029
6203
|
this.readyForPlaying = false;
|
|
6030
6204
|
// Runtime artboard
|
|
6031
6205
|
this.artboard = null;
|
|
6032
|
-
// place to clear up event listeners
|
|
6206
|
+
// place to clear up pointer/touch event listeners
|
|
6033
6207
|
this.eventCleanup = null;
|
|
6208
|
+
// Manages keyboard and DOM-focus interactions for the canvas.
|
|
6209
|
+
this._keyboardInteractions = null;
|
|
6034
6210
|
this.shouldDisableRiveListeners = false;
|
|
6035
6211
|
this.automaticallyHandleEvents = false;
|
|
6036
6212
|
this.dispatchPointerExit = true;
|
|
@@ -6058,8 +6234,20 @@ var Rive = /** @class */ (function () {
|
|
|
6058
6234
|
this._audioEventListener = null;
|
|
6059
6235
|
// draw method bound to the class
|
|
6060
6236
|
this._boundDraw = null;
|
|
6237
|
+
// Page visibility handler — prevents state machine advancing / rAF from being invoked with large time delta
|
|
6238
|
+
// when the browser tab is switched back to after being hidden.
|
|
6239
|
+
this._pageVisibilityHandler = null;
|
|
6240
|
+
// True only when the page visibility handler itself cancelled an active frame.
|
|
6241
|
+
// Set by stopRendering(), cleared by startRendering(). Prevents the
|
|
6242
|
+
// visibilitychange handler from restarting a rendering loop the caller intentionally stopped.
|
|
6243
|
+
this._explicitlyStoppedRendering = false;
|
|
6061
6244
|
this._viewModelInstance = null;
|
|
6062
6245
|
this._dataEnums = null;
|
|
6246
|
+
this._tabIndex = null;
|
|
6247
|
+
this._prevHasFocus = false;
|
|
6248
|
+
this._focusOptions = {
|
|
6249
|
+
allowFocusInterrupt: false,
|
|
6250
|
+
};
|
|
6063
6251
|
this.drawOptimization = DrawOptimizationOptions.DrawOnChanged;
|
|
6064
6252
|
// When true, emits performance.mark/measure entries for load and render.
|
|
6065
6253
|
this.enablePerfMarks = false;
|
|
@@ -6080,12 +6268,18 @@ var Rive = /** @class */ (function () {
|
|
|
6080
6268
|
_this.resizeToCanvas();
|
|
6081
6269
|
}
|
|
6082
6270
|
};
|
|
6271
|
+
// Tracks the current animation frame request
|
|
6272
|
+
this.frameRequestId = null;
|
|
6083
6273
|
/**
|
|
6084
6274
|
* Used be draw to track when a second of active rendering time has passed.
|
|
6085
6275
|
* Used for debugging purposes
|
|
6086
6276
|
*/
|
|
6087
6277
|
this.renderSecondTimer = 0;
|
|
6088
6278
|
this._boundDraw = this.draw.bind(this);
|
|
6279
|
+
if (typeof document !== 'undefined') {
|
|
6280
|
+
this._pageVisibilityHandler = this._onPageVisibilityChange.bind(this);
|
|
6281
|
+
document.addEventListener('visibilitychange', this._pageVisibilityHandler);
|
|
6282
|
+
}
|
|
6089
6283
|
this.canvas = params.canvas;
|
|
6090
6284
|
if (params.canvas.constructor === HTMLCanvasElement) {
|
|
6091
6285
|
this._observed = observers.add(this.canvas, this.onCanvasResize);
|
|
@@ -6112,6 +6306,7 @@ var Rive = /** @class */ (function () {
|
|
|
6112
6306
|
this.enablePerfMarks = !!params.enablePerfMarks;
|
|
6113
6307
|
if (this.enablePerfMarks)
|
|
6114
6308
|
_runtimeLoader__WEBPACK_IMPORTED_MODULE_1__.RuntimeLoader.enablePerfMarks = true;
|
|
6309
|
+
this._focusOptions = (_c = params.focusOptions) !== null && _c !== void 0 ? _c : this._focusOptions;
|
|
6115
6310
|
// New event management system
|
|
6116
6311
|
this.eventManager = new EventManager();
|
|
6117
6312
|
if (params.onLoad)
|
|
@@ -6164,6 +6359,7 @@ var Rive = /** @class */ (function () {
|
|
|
6164
6359
|
stateMachines: params.stateMachines,
|
|
6165
6360
|
artboard: params.artboard,
|
|
6166
6361
|
useOffscreenRenderer: params.useOffscreenRenderer,
|
|
6362
|
+
tabIndex: params.tabIndex,
|
|
6167
6363
|
});
|
|
6168
6364
|
}
|
|
6169
6365
|
Object.defineProperty(Rive.prototype, "viewModelCount", {
|
|
@@ -6185,13 +6381,14 @@ var Rive = /** @class */ (function () {
|
|
|
6185
6381
|
// Initializes the Rive object either from constructor or load()
|
|
6186
6382
|
Rive.prototype.init = function (_a) {
|
|
6187
6383
|
var _this = this;
|
|
6188
|
-
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;
|
|
6384
|
+
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;
|
|
6189
6385
|
if (this.destroyed) {
|
|
6190
6386
|
return;
|
|
6191
6387
|
}
|
|
6192
6388
|
this.src = src;
|
|
6193
6389
|
this.buffer = buffer;
|
|
6194
6390
|
this.riveFile = riveFile;
|
|
6391
|
+
this._tabIndex = tabIndex !== null && tabIndex !== void 0 ? tabIndex : null;
|
|
6195
6392
|
// If no source file url specified, it's a bust
|
|
6196
6393
|
if (!this.src && !this.buffer && !this.riveFile) {
|
|
6197
6394
|
throw new RiveError(Rive.missingErrorMessage);
|
|
@@ -6262,9 +6459,11 @@ var Rive = /** @class */ (function () {
|
|
|
6262
6459
|
if (this.eventCleanup) {
|
|
6263
6460
|
this.eventCleanup();
|
|
6264
6461
|
}
|
|
6462
|
+
this.cleanupKeyboardInteractions();
|
|
6265
6463
|
if (!this.shouldDisableRiveListeners) {
|
|
6266
|
-
var
|
|
6267
|
-
|
|
6464
|
+
var playingStateMachines = this.animator.stateMachines.filter(function (sm) { return sm.playing; });
|
|
6465
|
+
var activeStateMachines = playingStateMachines
|
|
6466
|
+
.filter(function (sm) { return _this.runtime.hasListeners(sm.instance); })
|
|
6268
6467
|
.map(function (sm) { return sm.instance; });
|
|
6269
6468
|
var touchScrollEnabledOption = this.isTouchScrollEnabled;
|
|
6270
6469
|
var dispatchPointerExit = this.dispatchPointerExit;
|
|
@@ -6285,7 +6484,34 @@ var Rive = /** @class */ (function () {
|
|
|
6285
6484
|
dispatchPointerExit: dispatchPointerExit,
|
|
6286
6485
|
enableMultiTouch: enableMultiTouch,
|
|
6287
6486
|
layoutScaleFactor: this._layout.layoutScaleFactor,
|
|
6487
|
+
advanceAndDrain: this.advanceAndReportChanges.bind(this)
|
|
6288
6488
|
});
|
|
6489
|
+
// Wire up keyboard interactions for state machines that have focus nodes.
|
|
6490
|
+
// hasFocusNodes — unified focus tree check, gates tab traversal
|
|
6491
|
+
var smWithFocusNodes = playingStateMachines.filter(function (sm) { return sm.hasFocusNodes; });
|
|
6492
|
+
if (smWithFocusNodes.length) {
|
|
6493
|
+
// Set the canvas as a tabbable element if there are any focus nodes.
|
|
6494
|
+
// Prefer the tabIndex param set by the user, otherwise use 0.
|
|
6495
|
+
// But do not override any explicit tabIndex already set on the canvas, if any.
|
|
6496
|
+
var currentCanvasTabIndex = this.canvas.tabIndex;
|
|
6497
|
+
// By default, canvas elements have a tabIndex of -1
|
|
6498
|
+
if (currentCanvasTabIndex === -1 || isNaN(currentCanvasTabIndex)) {
|
|
6499
|
+
this.canvas.tabIndex = (this._tabIndex !== null ? this._tabIndex : 0);
|
|
6500
|
+
}
|
|
6501
|
+
if (typeof window !== "undefined") {
|
|
6502
|
+
this._keyboardInteractions = new _utils__WEBPACK_IMPORTED_MODULE_2__.KeyboardInteractions({
|
|
6503
|
+
canvas: this.canvas,
|
|
6504
|
+
stateMachine: smWithFocusNodes[0].instance, // work off assumption of single state machine
|
|
6505
|
+
hasFocusNodes: true,
|
|
6506
|
+
});
|
|
6507
|
+
}
|
|
6508
|
+
}
|
|
6509
|
+
}
|
|
6510
|
+
};
|
|
6511
|
+
Rive.prototype.cleanupKeyboardInteractions = function () {
|
|
6512
|
+
if (this._keyboardInteractions) {
|
|
6513
|
+
this._keyboardInteractions.cleanup();
|
|
6514
|
+
this._keyboardInteractions = null;
|
|
6289
6515
|
}
|
|
6290
6516
|
};
|
|
6291
6517
|
/**
|
|
@@ -6296,6 +6522,7 @@ var Rive = /** @class */ (function () {
|
|
|
6296
6522
|
this.eventCleanup();
|
|
6297
6523
|
this.eventCleanup = null;
|
|
6298
6524
|
}
|
|
6525
|
+
this.cleanupKeyboardInteractions();
|
|
6299
6526
|
};
|
|
6300
6527
|
/**
|
|
6301
6528
|
* If the instance has audio and the system audio is not ready
|
|
@@ -6473,27 +6700,53 @@ var Rive = /** @class */ (function () {
|
|
|
6473
6700
|
return changed;
|
|
6474
6701
|
};
|
|
6475
6702
|
/**
|
|
6476
|
-
*
|
|
6477
|
-
*
|
|
6703
|
+
* Poll focus state each frame to see if we should focus/blur the canvas in case
|
|
6704
|
+
* Rive internally updated focus outside of user interaction (e.g., via listener action)
|
|
6478
6705
|
*/
|
|
6479
|
-
Rive.prototype.
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
var before = performance.now();
|
|
6484
|
-
// On the first pass, make sure lastTime has a valid value
|
|
6485
|
-
if (!this.lastRenderTime) {
|
|
6486
|
-
this.lastRenderTime = time;
|
|
6706
|
+
Rive.prototype.pollFocusState = function () {
|
|
6707
|
+
if (!this._keyboardInteractions) {
|
|
6708
|
+
this._prevHasFocus = false;
|
|
6709
|
+
return;
|
|
6487
6710
|
}
|
|
6488
|
-
//
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
onSecond === null || onSecond === void 0 ? void 0 : onSecond();
|
|
6711
|
+
var activeSm = this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; }); // work off assumption of single state machine
|
|
6712
|
+
if (!activeSm) {
|
|
6713
|
+
this._prevHasFocus = false;
|
|
6714
|
+
return;
|
|
6493
6715
|
}
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6716
|
+
if (this.canvas instanceof HTMLCanvasElement) {
|
|
6717
|
+
var hasFocus = activeSm.focusState().hasFocus;
|
|
6718
|
+
if (hasFocus) {
|
|
6719
|
+
// Rive has an active focus node. Mark the session RiveFocused so Tab stays
|
|
6720
|
+
// trapped and a later internal release (hasFocus true → false) is detected.
|
|
6721
|
+
this._keyboardInteractions.notifyRiveFocused();
|
|
6722
|
+
// Only steal DOM focus on the false→true transition. If hasFocus stays
|
|
6723
|
+
// true across frames and the user clicks away, do not re-focus the canvas again.
|
|
6724
|
+
if (!this._prevHasFocus) {
|
|
6725
|
+
if (this.canvas !== document.activeElement && this._focusOptions.allowFocusInterrupt) {
|
|
6726
|
+
this.canvas.focus();
|
|
6727
|
+
}
|
|
6728
|
+
this._prevHasFocus = true;
|
|
6729
|
+
}
|
|
6730
|
+
return;
|
|
6731
|
+
}
|
|
6732
|
+
this._prevHasFocus = false;
|
|
6733
|
+
// hasFocus is false — only act when Rive previously held focus and released it internally
|
|
6734
|
+
// (state change clears focus). Release the DOM Tab trap so the next Tab moves to the next
|
|
6735
|
+
// page element. EntryPending and NotFocused cases are intentional no-ops — EntryPending in
|
|
6736
|
+
// particular must stay in its state (a click awaiting its first Tab) rather than be reset here.
|
|
6737
|
+
if (this._keyboardInteractions.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_2__.FocusSessionState.RiveFocused) {
|
|
6738
|
+
this._keyboardInteractions.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_2__.FocusSessionState.NotFocused);
|
|
6739
|
+
}
|
|
6740
|
+
}
|
|
6741
|
+
};
|
|
6742
|
+
/**
|
|
6743
|
+
* Handles important sequence of reporting Rive events, advancing the state machine or animation, and invoking various callbacks
|
|
6744
|
+
* due to state changes, view model property changes, etc.
|
|
6745
|
+
*
|
|
6746
|
+
* @param elapsedTime time to advance the state machine by
|
|
6747
|
+
*/
|
|
6748
|
+
Rive.prototype.advanceAndReportChanges = function (elapsedTime) {
|
|
6749
|
+
var _a;
|
|
6497
6750
|
// - Advance non-paused animations by the elapsed number of seconds
|
|
6498
6751
|
// - Advance any animations that require scrubbing
|
|
6499
6752
|
// - Advance to the first frame even when autoplay is false
|
|
@@ -6557,13 +6810,48 @@ var Rive = /** @class */ (function () {
|
|
|
6557
6810
|
performance.mark("rive:sm-advance:end:f".concat(_perfFrame));
|
|
6558
6811
|
performance.measure("rive:sm-advance:f".concat(_perfFrame), "rive:sm-advance:start:f".concat(_perfFrame), "rive:sm-advance:end:f".concat(_perfFrame));
|
|
6559
6812
|
}
|
|
6560
|
-
// stateMachine.instance.apply(this.artboard);
|
|
6561
6813
|
}
|
|
6562
|
-
//
|
|
6814
|
+
// For linear animations that have been applied to the artboard, advance it
|
|
6563
6815
|
// by the elapsed time.
|
|
6564
6816
|
if (this.animator.stateMachines.length == 0) {
|
|
6565
6817
|
this.artboard.advance(elapsedTime);
|
|
6566
6818
|
}
|
|
6819
|
+
// Check for any animations that looped
|
|
6820
|
+
this.animator.handleLooping();
|
|
6821
|
+
// Check for any state machines that had a state change
|
|
6822
|
+
this.animator.handleStateChanges();
|
|
6823
|
+
// Report advanced time
|
|
6824
|
+
this.animator.handleAdvancing(elapsedTime);
|
|
6825
|
+
// Poll focus state to see whether or not to blur or pull up a virtual keyboard for any change to a text input node.
|
|
6826
|
+
this.pollFocusState();
|
|
6827
|
+
// Handle callbacks for view model property changes
|
|
6828
|
+
(_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.handleCallbacks();
|
|
6829
|
+
};
|
|
6830
|
+
/**
|
|
6831
|
+
* Draw rendering loop; renders animation frames at the correct time interval.
|
|
6832
|
+
* @param time the time at which to render a frame
|
|
6833
|
+
*/
|
|
6834
|
+
Rive.prototype.draw = function (time, onSecond) {
|
|
6835
|
+
// Clear the frameRequestId, as we're now rendering a fresh frame
|
|
6836
|
+
this.frameRequestId = null;
|
|
6837
|
+
var before = performance.now();
|
|
6838
|
+
// Instrument the first 3 frames so the Performance timeline shows precise
|
|
6839
|
+
// per-call latency for advance, draw, and flush without polluting the trace.
|
|
6840
|
+
var _perfFrame = this.enablePerfMarks && this.frameCount < 3 ? this.frameCount : -1;
|
|
6841
|
+
// On the first pass, make sure lastTime has a valid value
|
|
6842
|
+
if (!this.lastRenderTime) {
|
|
6843
|
+
this.lastRenderTime = time;
|
|
6844
|
+
}
|
|
6845
|
+
// Handle the onSecond callback
|
|
6846
|
+
this.renderSecondTimer += time - this.lastRenderTime;
|
|
6847
|
+
if (this.renderSecondTimer > 5000) {
|
|
6848
|
+
this.renderSecondTimer = 0;
|
|
6849
|
+
onSecond === null || onSecond === void 0 ? void 0 : onSecond();
|
|
6850
|
+
}
|
|
6851
|
+
// Calculate the elapsed time between frames in seconds
|
|
6852
|
+
var elapsedTime = (time - this.lastRenderTime) / 1000;
|
|
6853
|
+
this.lastRenderTime = time;
|
|
6854
|
+
this.advanceAndReportChanges(elapsedTime);
|
|
6567
6855
|
var renderer = this.renderer;
|
|
6568
6856
|
// Do not draw on 0 canvas size
|
|
6569
6857
|
if (!this._hasZeroSize) {
|
|
@@ -6601,12 +6889,6 @@ var Rive = /** @class */ (function () {
|
|
|
6601
6889
|
this._needsRedraw = false;
|
|
6602
6890
|
}
|
|
6603
6891
|
}
|
|
6604
|
-
// Check for any animations that looped
|
|
6605
|
-
this.animator.handleLooping();
|
|
6606
|
-
// Check for any state machines that had a state change
|
|
6607
|
-
this.animator.handleStateChanges();
|
|
6608
|
-
// Report advanced time
|
|
6609
|
-
this.animator.handleAdvancing(elapsedTime);
|
|
6610
6892
|
// Add duration to create frame to durations array
|
|
6611
6893
|
this.frameCount++;
|
|
6612
6894
|
var after = performance.now();
|
|
@@ -6616,7 +6898,6 @@ var Rive = /** @class */ (function () {
|
|
|
6616
6898
|
this.frameTimes.shift();
|
|
6617
6899
|
this.durations.shift();
|
|
6618
6900
|
}
|
|
6619
|
-
(_a = this._viewModelInstance) === null || _a === void 0 ? void 0 : _a.handleCallbacks();
|
|
6620
6901
|
// Calling requestAnimationFrame will rerun draw() at the correct rate:
|
|
6621
6902
|
// https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations
|
|
6622
6903
|
if (this.animator.isPlaying) {
|
|
@@ -6695,6 +6976,10 @@ var Rive = /** @class */ (function () {
|
|
|
6695
6976
|
audioManager.remove(this._audioEventListener);
|
|
6696
6977
|
this._audioEventListener = null;
|
|
6697
6978
|
}
|
|
6979
|
+
if (this._pageVisibilityHandler) {
|
|
6980
|
+
document.removeEventListener('visibilitychange', this._pageVisibilityHandler);
|
|
6981
|
+
this._pageVisibilityHandler = null;
|
|
6982
|
+
}
|
|
6698
6983
|
(_b = this._viewModelInstance) === null || _b === void 0 ? void 0 : _b.cleanup();
|
|
6699
6984
|
this._viewModelInstance = null;
|
|
6700
6985
|
this._dataEnums = null;
|
|
@@ -6719,6 +7004,7 @@ var Rive = /** @class */ (function () {
|
|
|
6719
7004
|
if (this.eventCleanup !== null) {
|
|
6720
7005
|
this.eventCleanup();
|
|
6721
7006
|
}
|
|
7007
|
+
this.cleanupKeyboardInteractions();
|
|
6722
7008
|
// Delete all animation and state machine instances
|
|
6723
7009
|
this.stop();
|
|
6724
7010
|
if (this.artboard) {
|
|
@@ -6787,6 +7073,7 @@ var Rive = /** @class */ (function () {
|
|
|
6787
7073
|
if (this.eventCleanup) {
|
|
6788
7074
|
this.eventCleanup();
|
|
6789
7075
|
}
|
|
7076
|
+
this.cleanupKeyboardInteractions();
|
|
6790
7077
|
this.setupRiveListeners();
|
|
6791
7078
|
this.startRendering();
|
|
6792
7079
|
};
|
|
@@ -6804,6 +7091,7 @@ var Rive = /** @class */ (function () {
|
|
|
6804
7091
|
if (this.eventCleanup) {
|
|
6805
7092
|
this.eventCleanup();
|
|
6806
7093
|
}
|
|
7094
|
+
this.cleanupKeyboardInteractions();
|
|
6807
7095
|
this.animator.pause(animationNames);
|
|
6808
7096
|
};
|
|
6809
7097
|
Rive.prototype.scrub = function (animationNames, value) {
|
|
@@ -6839,6 +7127,7 @@ var Rive = /** @class */ (function () {
|
|
|
6839
7127
|
if (this.eventCleanup) {
|
|
6840
7128
|
this.eventCleanup();
|
|
6841
7129
|
}
|
|
7130
|
+
this.cleanupKeyboardInteractions();
|
|
6842
7131
|
};
|
|
6843
7132
|
/**
|
|
6844
7133
|
* Resets the animation
|
|
@@ -7298,6 +7587,7 @@ var Rive = /** @class */ (function () {
|
|
|
7298
7587
|
* they would have been at if rendering had not been stopped.
|
|
7299
7588
|
*/
|
|
7300
7589
|
Rive.prototype.stopRendering = function () {
|
|
7590
|
+
this._explicitlyStoppedRendering = true;
|
|
7301
7591
|
if (this.loaded && this.frameRequestId) {
|
|
7302
7592
|
if (this.runtime.cancelAnimationFrame) {
|
|
7303
7593
|
this.runtime.cancelAnimationFrame(this.frameRequestId);
|
|
@@ -7313,6 +7603,7 @@ var Rive = /** @class */ (function () {
|
|
|
7313
7603
|
* renderer is already active, then this will have zero effect.
|
|
7314
7604
|
*/
|
|
7315
7605
|
Rive.prototype.startRendering = function () {
|
|
7606
|
+
this._explicitlyStoppedRendering = false;
|
|
7316
7607
|
this.drawFrame();
|
|
7317
7608
|
};
|
|
7318
7609
|
Rive.prototype.scheduleRendering = function () {
|
|
@@ -7325,6 +7616,31 @@ var Rive = /** @class */ (function () {
|
|
|
7325
7616
|
}
|
|
7326
7617
|
}
|
|
7327
7618
|
};
|
|
7619
|
+
/**
|
|
7620
|
+
* Called when document.visibilitychange fires (tab change, window minimize, etc.).
|
|
7621
|
+
* Cancels the rAF loop on hide and resets the time reference so that no accumulated time is
|
|
7622
|
+
* applied to state machines when the tab becomes visible again. This prevents state machine
|
|
7623
|
+
* advances with large time deltas when rAF starts up again.
|
|
7624
|
+
*/
|
|
7625
|
+
Rive.prototype._onPageVisibilityChange = function () {
|
|
7626
|
+
var _a, _b;
|
|
7627
|
+
if (document.hidden) {
|
|
7628
|
+
if (this.frameRequestId !== null) {
|
|
7629
|
+
if ((_a = this.runtime) === null || _a === void 0 ? void 0 : _a.cancelAnimationFrame) {
|
|
7630
|
+
this.runtime.cancelAnimationFrame(this.frameRequestId);
|
|
7631
|
+
}
|
|
7632
|
+
else {
|
|
7633
|
+
cancelAnimationFrame(this.frameRequestId);
|
|
7634
|
+
}
|
|
7635
|
+
this.frameRequestId = null;
|
|
7636
|
+
}
|
|
7637
|
+
// Reset so the first resumed frame starts with elapsedTime === 0.
|
|
7638
|
+
this.lastRenderTime = 0;
|
|
7639
|
+
}
|
|
7640
|
+
else if (((_b = this.animator) === null || _b === void 0 ? void 0 : _b.isPlaying) && !this._explicitlyStoppedRendering) {
|
|
7641
|
+
this.scheduleRendering();
|
|
7642
|
+
}
|
|
7643
|
+
};
|
|
7328
7644
|
/**
|
|
7329
7645
|
* Enables frames-per-second (FPS) reporting for the runtime
|
|
7330
7646
|
* If no callback is provided, Rive will append a fixed-position div at the top-right corner of
|
|
@@ -7562,6 +7878,14 @@ var Rive = /** @class */ (function () {
|
|
|
7562
7878
|
var _a, _b;
|
|
7563
7879
|
return (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.getDefaultBindableArtboard()) !== null && _b !== void 0 ? _b : null;
|
|
7564
7880
|
};
|
|
7881
|
+
/**
|
|
7882
|
+
* Clear focus applicable to active state machines with focus nodes. Useful if users want to
|
|
7883
|
+
* reset focus state and behavior within the Rive graphic at any point (i.e. blurring off the canvas)
|
|
7884
|
+
*/
|
|
7885
|
+
Rive.prototype.clearFocus = function () {
|
|
7886
|
+
var playingStateMachines = this.animator.stateMachines.filter(function (sm) { return sm.playing && sm.hasFocusNodes; });
|
|
7887
|
+
playingStateMachines.forEach(function (sm) { return sm.clearFocus(); });
|
|
7888
|
+
};
|
|
7565
7889
|
// Error message for missing source or buffer
|
|
7566
7890
|
Rive.missingErrorMessage = "Rive source file or data buffer required";
|
|
7567
7891
|
// Error message for removed rive file
|