@rive-app/webgl2 2.37.7 → 2.37.8
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 +16 -0
- package/rive.js +192 -32
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +17 -0
- package/rive_fallback.wasm +0 -0
- package/utils/index.d.ts +2 -0
- package/utils/registerKeyboardInteractions.d.ts +22 -0
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -215,6 +215,10 @@ export interface RiveParameters {
|
|
|
215
215
|
layout?: Layout;
|
|
216
216
|
autoplay?: boolean;
|
|
217
217
|
useOffscreenRenderer?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Optional tab index to set for the canvas element if there are any Focus nodes within the graphic
|
|
220
|
+
*/
|
|
221
|
+
tabIndex?: number;
|
|
218
222
|
/**
|
|
219
223
|
* Allow the runtime to automatically load assets hosted in Rive's CDN.
|
|
220
224
|
* enabled by default.
|
|
@@ -316,6 +320,7 @@ export interface RiveLoadParameters {
|
|
|
316
320
|
stateMachines?: string | string[];
|
|
317
321
|
useOffscreenRenderer?: boolean;
|
|
318
322
|
shouldDisableRiveListeners?: boolean;
|
|
323
|
+
tabIndex?: number;
|
|
319
324
|
}
|
|
320
325
|
export interface RiveResetParameters {
|
|
321
326
|
artboard?: string;
|
|
@@ -415,6 +420,7 @@ export declare class Rive {
|
|
|
415
420
|
private runtime;
|
|
416
421
|
private artboard;
|
|
417
422
|
private eventCleanup;
|
|
423
|
+
private keyboardEventCleanup;
|
|
418
424
|
private file;
|
|
419
425
|
private riveFile;
|
|
420
426
|
private eventManager;
|
|
@@ -438,8 +444,11 @@ export declare class Rive {
|
|
|
438
444
|
private _currentCanvasHeight;
|
|
439
445
|
private _audioEventListener;
|
|
440
446
|
private _boundDraw;
|
|
447
|
+
private _pageVisibilityHandler;
|
|
448
|
+
private _explicitlyStoppedRendering;
|
|
441
449
|
private _viewModelInstance;
|
|
442
450
|
private _dataEnums;
|
|
451
|
+
private _tabIndex;
|
|
443
452
|
private drawOptimization;
|
|
444
453
|
private enablePerfMarks;
|
|
445
454
|
durations: number[];
|
|
@@ -723,6 +732,13 @@ export declare class Rive {
|
|
|
723
732
|
*/
|
|
724
733
|
startRendering(): void;
|
|
725
734
|
private scheduleRendering;
|
|
735
|
+
/**
|
|
736
|
+
* Called when document.visibilitychange fires (tab change, window minimize, etc.).
|
|
737
|
+
* Cancels the rAF loop on hide and resets the time reference so that no accumulated time is
|
|
738
|
+
* applied to state machines when the tab becomes visible again. This prevents state machine
|
|
739
|
+
* advances with large time deltas when rAF starts up again.
|
|
740
|
+
*/
|
|
741
|
+
private _onPageVisibilityChange;
|
|
726
742
|
/**
|
|
727
743
|
* Enables frames-per-second (FPS) reporting for the runtime
|
|
728
744
|
* If no callback is provided, Rive will append a fixed-position div at the top-right corner of
|
package/rive.js
CHANGED
|
@@ -769,7 +769,7 @@ function Na(a, b) {
|
|
|
769
769
|
return Ma(c, a, b);
|
|
770
770
|
}));
|
|
771
771
|
}
|
|
772
|
-
var Oa, Pa, Ta = {
|
|
772
|
+
var Oa, Pa, Ta = {569016:(a, b, c, d, e) => {
|
|
773
773
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
774
774
|
return 0;
|
|
775
775
|
}
|
|
@@ -832,11 +832,11 @@ var Oa, Pa, Ta = {569208:(a, b, c, d, e) => {
|
|
|
832
832
|
}
|
|
833
833
|
window.h.Ea += 1;
|
|
834
834
|
return 1;
|
|
835
|
-
},
|
|
835
|
+
}, 571194:() => {
|
|
836
836
|
"undefined" !== typeof window.h && (window.h.Xa.map(function(a) {
|
|
837
837
|
document.removeEventListener(a, window.h.unlock, !0);
|
|
838
838
|
}), --window.h.Ea, 0 === window.h.Ea && delete window.h);
|
|
839
|
-
},
|
|
839
|
+
}, 571498:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 571602:() => {
|
|
840
840
|
try {
|
|
841
841
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
842
842
|
a.close();
|
|
@@ -844,7 +844,7 @@ var Oa, Pa, Ta = {569208:(a, b, c, d, e) => {
|
|
|
844
844
|
} catch (c) {
|
|
845
845
|
return 0;
|
|
846
846
|
}
|
|
847
|
-
},
|
|
847
|
+
}, 571773:(a, b, c, d, e, f) => {
|
|
848
848
|
if ("undefined" === typeof window.h) {
|
|
849
849
|
return -1;
|
|
850
850
|
}
|
|
@@ -890,7 +890,7 @@ var Oa, Pa, Ta = {569208:(a, b, c, d, e) => {
|
|
|
890
890
|
a == window.h.I.Ba && g.Y.connect(g.K.destination);
|
|
891
891
|
g.nb = f;
|
|
892
892
|
return window.h.mc(g);
|
|
893
|
-
},
|
|
893
|
+
}, 574650:a => window.h.sa(a).K.sampleRate, 574723:a => {
|
|
894
894
|
a = window.h.sa(a);
|
|
895
895
|
void 0 !== a.Y && (a.Y.onaudioprocess = function() {
|
|
896
896
|
}, a.Y.disconnect(), a.Y = void 0);
|
|
@@ -898,13 +898,13 @@ var Oa, Pa, Ta = {569208:(a, b, c, d, e) => {
|
|
|
898
898
|
a.K.close();
|
|
899
899
|
a.K = void 0;
|
|
900
900
|
a.nb = void 0;
|
|
901
|
-
},
|
|
901
|
+
}, 575123:a => {
|
|
902
902
|
window.h.yb(a);
|
|
903
|
-
},
|
|
903
|
+
}, 575173:a => {
|
|
904
904
|
a = window.h.sa(a);
|
|
905
905
|
a.K.resume();
|
|
906
906
|
a.state = window.h.ha.ub;
|
|
907
|
-
},
|
|
907
|
+
}, 575312:a => {
|
|
908
908
|
a = window.h.sa(a);
|
|
909
909
|
a.K.suspend();
|
|
910
910
|
a.state = window.h.ha.stopped;
|
|
@@ -3907,7 +3907,7 @@ moduleRtn = ca;
|
|
|
3907
3907
|
/* 5 */
|
|
3908
3908
|
/***/ ((module) => {
|
|
3909
3909
|
|
|
3910
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.37.
|
|
3910
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"2.37.8","description":"Rive\'s webgl2 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)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive_fallback.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3911
3911
|
|
|
3912
3912
|
/***/ }),
|
|
3913
3913
|
/* 6 */
|
|
@@ -3915,26 +3915,29 @@ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/webgl2","version":"
|
|
|
3915
3915
|
|
|
3916
3916
|
__webpack_require__.r(__webpack_exports__);
|
|
3917
3917
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3918
|
-
/* harmony export */ AudioAssetWrapper: () => (/* reexport safe */
|
|
3919
|
-
/* harmony export */ AudioWrapper: () => (/* reexport safe */
|
|
3920
|
-
/* harmony export */ BLANK_URL: () => (/* reexport safe */
|
|
3921
|
-
/* harmony export */ CustomFileAssetLoaderWrapper: () => (/* reexport safe */
|
|
3922
|
-
/* harmony export */ FileAssetWrapper: () => (/* reexport safe */
|
|
3923
|
-
/* harmony export */ FileFinalizer: () => (/* reexport safe */
|
|
3924
|
-
/* harmony export */ FontAssetWrapper: () => (/* reexport safe */
|
|
3925
|
-
/* harmony export */ FontWrapper: () => (/* reexport safe */
|
|
3926
|
-
/* harmony export */ ImageAssetWrapper: () => (/* reexport safe */
|
|
3927
|
-
/* harmony export */ ImageWrapper: () => (/* reexport safe */
|
|
3928
|
-
/* harmony export */ RiveFont: () => (/* reexport safe */
|
|
3929
|
-
/* harmony export */ createFinalization: () => (/* reexport safe */
|
|
3930
|
-
/* harmony export */ finalizationRegistry: () => (/* reexport safe */
|
|
3918
|
+
/* harmony export */ AudioAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.AudioAssetWrapper),
|
|
3919
|
+
/* harmony export */ AudioWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.AudioWrapper),
|
|
3920
|
+
/* harmony export */ BLANK_URL: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__.BLANK_URL),
|
|
3921
|
+
/* harmony export */ CustomFileAssetLoaderWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.CustomFileAssetLoaderWrapper),
|
|
3922
|
+
/* harmony export */ FileAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.FileAssetWrapper),
|
|
3923
|
+
/* harmony export */ FileFinalizer: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.FileFinalizer),
|
|
3924
|
+
/* harmony export */ FontAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.FontAssetWrapper),
|
|
3925
|
+
/* harmony export */ FontWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.FontWrapper),
|
|
3926
|
+
/* harmony export */ ImageAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.ImageAssetWrapper),
|
|
3927
|
+
/* harmony export */ ImageWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.ImageWrapper),
|
|
3928
|
+
/* harmony export */ RiveFont: () => (/* reexport safe */ _riveFont__WEBPACK_IMPORTED_MODULE_4__.RiveFont),
|
|
3929
|
+
/* harmony export */ createFinalization: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.createFinalization),
|
|
3930
|
+
/* harmony export */ finalizationRegistry: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.finalizationRegistry),
|
|
3931
|
+
/* harmony export */ registerKeyboardInteractions: () => (/* reexport safe */ _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__.registerKeyboardInteractions),
|
|
3931
3932
|
/* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
|
|
3932
|
-
/* harmony export */ sanitizeUrl: () => (/* reexport safe */
|
|
3933
|
+
/* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)
|
|
3933
3934
|
/* harmony export */ });
|
|
3934
3935
|
/* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
|
|
3935
|
-
/* harmony import */ var
|
|
3936
|
-
/* harmony import */ var
|
|
3937
|
-
/* harmony import */ var
|
|
3936
|
+
/* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
|
|
3937
|
+
/* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
|
|
3938
|
+
/* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
|
|
3939
|
+
/* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(11);
|
|
3940
|
+
|
|
3938
3941
|
|
|
3939
3942
|
|
|
3940
3943
|
|
|
@@ -4236,6 +4239,68 @@ var registerTouchInteractions = function (_a) {
|
|
|
4236
4239
|
/* 8 */
|
|
4237
4240
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4238
4241
|
|
|
4242
|
+
__webpack_require__.r(__webpack_exports__);
|
|
4243
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4244
|
+
/* harmony export */ registerKeyboardInteractions: () => (/* binding */ registerKeyboardInteractions)
|
|
4245
|
+
/* harmony export */ });
|
|
4246
|
+
/**
|
|
4247
|
+
* Registers focus and tab-traversal event handlers on the canvas to route
|
|
4248
|
+
* Tab/Shift+Tab to the active Rive state machine's focus manager.
|
|
4249
|
+
*
|
|
4250
|
+
* Mirrors registerTouchInteractions for pointer events.
|
|
4251
|
+
*
|
|
4252
|
+
* Returns a cleanup function that removes all registered event listeners,
|
|
4253
|
+
* or null if the setup conditions are not met.
|
|
4254
|
+
*/
|
|
4255
|
+
var registerKeyboardInteractions = function (_a) {
|
|
4256
|
+
var canvas = _a.canvas, stateMachine = _a.stateMachine, rive = _a.rive, hasFocusNodes = _a.hasFocusNodes;
|
|
4257
|
+
if (!canvas ||
|
|
4258
|
+
!stateMachine ||
|
|
4259
|
+
!rive ||
|
|
4260
|
+
typeof window === "undefined") {
|
|
4261
|
+
return null;
|
|
4262
|
+
}
|
|
4263
|
+
// Work off an assumption of a single state machine
|
|
4264
|
+
var mainSm = stateMachine;
|
|
4265
|
+
var canvasHasFocus = false;
|
|
4266
|
+
var onCanvasFocus = function (_event) {
|
|
4267
|
+
canvasHasFocus = true;
|
|
4268
|
+
};
|
|
4269
|
+
var onCanvasBlur = function (_event) {
|
|
4270
|
+
canvasHasFocus = false;
|
|
4271
|
+
};
|
|
4272
|
+
var onKeyDown = function (event) {
|
|
4273
|
+
if (!canvasHasFocus)
|
|
4274
|
+
return;
|
|
4275
|
+
if (event.code === "Tab" && hasFocusNodes) {
|
|
4276
|
+
var forward = !event.shiftKey;
|
|
4277
|
+
var focusMoved = forward ? mainSm.focusNext() : mainSm.focusPrevious();
|
|
4278
|
+
if (focusMoved) {
|
|
4279
|
+
// Keep Tab inside the canvas — a Rive node received focus.
|
|
4280
|
+
event.preventDefault();
|
|
4281
|
+
}
|
|
4282
|
+
else {
|
|
4283
|
+
// No more traversable nodes — release Tab to the page.
|
|
4284
|
+
// Since we're not preventing default, blur event will fire on the canvas
|
|
4285
|
+
canvasHasFocus = false;
|
|
4286
|
+
}
|
|
4287
|
+
}
|
|
4288
|
+
};
|
|
4289
|
+
canvas.addEventListener("focus", onCanvasFocus);
|
|
4290
|
+
canvas.addEventListener("blur", onCanvasBlur);
|
|
4291
|
+
canvas.addEventListener("keydown", onKeyDown);
|
|
4292
|
+
return function () {
|
|
4293
|
+
canvas.removeEventListener("focus", onCanvasFocus);
|
|
4294
|
+
canvas.removeEventListener("blur", onCanvasBlur);
|
|
4295
|
+
canvas.removeEventListener("keydown", onKeyDown);
|
|
4296
|
+
};
|
|
4297
|
+
};
|
|
4298
|
+
|
|
4299
|
+
|
|
4300
|
+
/***/ }),
|
|
4301
|
+
/* 9 */
|
|
4302
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4303
|
+
|
|
4239
4304
|
__webpack_require__.r(__webpack_exports__);
|
|
4240
4305
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4241
4306
|
/* harmony export */ BLANK_URL: () => (/* binding */ BLANK_URL),
|
|
@@ -4286,7 +4351,7 @@ function sanitizeUrl(url) {
|
|
|
4286
4351
|
|
|
4287
4352
|
|
|
4288
4353
|
/***/ }),
|
|
4289
|
-
/*
|
|
4354
|
+
/* 10 */
|
|
4290
4355
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4291
4356
|
|
|
4292
4357
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -4565,7 +4630,7 @@ var createFinalization = function (target, finalizable) {
|
|
|
4565
4630
|
|
|
4566
4631
|
|
|
4567
4632
|
/***/ }),
|
|
4568
|
-
/*
|
|
4633
|
+
/* 11 */
|
|
4569
4634
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
4570
4635
|
|
|
4571
4636
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -6184,8 +6249,10 @@ var Rive = /** @class */ (function () {
|
|
|
6184
6249
|
this.readyForPlaying = false;
|
|
6185
6250
|
// Runtime artboard
|
|
6186
6251
|
this.artboard = null;
|
|
6187
|
-
// place to clear up event listeners
|
|
6252
|
+
// place to clear up pointer/touch event listeners
|
|
6188
6253
|
this.eventCleanup = null;
|
|
6254
|
+
// place to clear up focus/keyboard event listeners
|
|
6255
|
+
this.keyboardEventCleanup = null;
|
|
6189
6256
|
this.shouldDisableRiveListeners = false;
|
|
6190
6257
|
this.automaticallyHandleEvents = false;
|
|
6191
6258
|
this.dispatchPointerExit = true;
|
|
@@ -6213,8 +6280,16 @@ var Rive = /** @class */ (function () {
|
|
|
6213
6280
|
this._audioEventListener = null;
|
|
6214
6281
|
// draw method bound to the class
|
|
6215
6282
|
this._boundDraw = null;
|
|
6283
|
+
// Page visibility handler — prevents state machine advancing / rAF from being invoked with large time delta
|
|
6284
|
+
// when the browser tab is switched back to after being hidden.
|
|
6285
|
+
this._pageVisibilityHandler = null;
|
|
6286
|
+
// True only when the page visibility handler itself cancelled an active frame.
|
|
6287
|
+
// Set by stopRendering(), cleared by startRendering(). Prevents the
|
|
6288
|
+
// visibilitychange handler from restarting a rendering loop the caller intentionally stopped.
|
|
6289
|
+
this._explicitlyStoppedRendering = false;
|
|
6216
6290
|
this._viewModelInstance = null;
|
|
6217
6291
|
this._dataEnums = null;
|
|
6292
|
+
this._tabIndex = null;
|
|
6218
6293
|
this.drawOptimization = DrawOptimizationOptions.DrawOnChanged;
|
|
6219
6294
|
// When true, emits performance.mark/measure entries for load and render.
|
|
6220
6295
|
this.enablePerfMarks = false;
|
|
@@ -6235,12 +6310,18 @@ var Rive = /** @class */ (function () {
|
|
|
6235
6310
|
_this.resizeToCanvas();
|
|
6236
6311
|
}
|
|
6237
6312
|
};
|
|
6313
|
+
// Tracks the current animation frame request
|
|
6314
|
+
this.frameRequestId = null;
|
|
6238
6315
|
/**
|
|
6239
6316
|
* Used be draw to track when a second of active rendering time has passed.
|
|
6240
6317
|
* Used for debugging purposes
|
|
6241
6318
|
*/
|
|
6242
6319
|
this.renderSecondTimer = 0;
|
|
6243
6320
|
this._boundDraw = this.draw.bind(this);
|
|
6321
|
+
if (typeof document !== 'undefined') {
|
|
6322
|
+
this._pageVisibilityHandler = this._onPageVisibilityChange.bind(this);
|
|
6323
|
+
document.addEventListener('visibilitychange', this._pageVisibilityHandler);
|
|
6324
|
+
}
|
|
6244
6325
|
this.canvas = params.canvas;
|
|
6245
6326
|
if (params.canvas.constructor === HTMLCanvasElement) {
|
|
6246
6327
|
this._observed = observers.add(this.canvas, this.onCanvasResize);
|
|
@@ -6319,6 +6400,7 @@ var Rive = /** @class */ (function () {
|
|
|
6319
6400
|
stateMachines: params.stateMachines,
|
|
6320
6401
|
artboard: params.artboard,
|
|
6321
6402
|
useOffscreenRenderer: params.useOffscreenRenderer,
|
|
6403
|
+
tabIndex: params.tabIndex,
|
|
6322
6404
|
});
|
|
6323
6405
|
}
|
|
6324
6406
|
Object.defineProperty(Rive.prototype, "viewModelCount", {
|
|
@@ -6340,13 +6422,14 @@ var Rive = /** @class */ (function () {
|
|
|
6340
6422
|
// Initializes the Rive object either from constructor or load()
|
|
6341
6423
|
Rive.prototype.init = function (_a) {
|
|
6342
6424
|
var _this = this;
|
|
6343
|
-
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;
|
|
6425
|
+
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;
|
|
6344
6426
|
if (this.destroyed) {
|
|
6345
6427
|
return;
|
|
6346
6428
|
}
|
|
6347
6429
|
this.src = src;
|
|
6348
6430
|
this.buffer = buffer;
|
|
6349
6431
|
this.riveFile = riveFile;
|
|
6432
|
+
this._tabIndex = tabIndex !== null && tabIndex !== void 0 ? tabIndex : null;
|
|
6350
6433
|
// If no source file url specified, it's a bust
|
|
6351
6434
|
if (!this.src && !this.buffer && !this.riveFile) {
|
|
6352
6435
|
throw new RiveError(Rive.missingErrorMessage);
|
|
@@ -6417,9 +6500,14 @@ var Rive = /** @class */ (function () {
|
|
|
6417
6500
|
if (this.eventCleanup) {
|
|
6418
6501
|
this.eventCleanup();
|
|
6419
6502
|
}
|
|
6503
|
+
if (this.keyboardEventCleanup) {
|
|
6504
|
+
this.keyboardEventCleanup();
|
|
6505
|
+
this.keyboardEventCleanup = null;
|
|
6506
|
+
}
|
|
6420
6507
|
if (!this.shouldDisableRiveListeners) {
|
|
6421
|
-
var
|
|
6422
|
-
|
|
6508
|
+
var playingStateMachines = this.animator.stateMachines.filter(function (sm) { return sm.playing; });
|
|
6509
|
+
var activeStateMachines = playingStateMachines
|
|
6510
|
+
.filter(function (sm) { return _this.runtime.hasListeners(sm.instance); })
|
|
6423
6511
|
.map(function (sm) { return sm.instance; });
|
|
6424
6512
|
var touchScrollEnabledOption = this.isTouchScrollEnabled;
|
|
6425
6513
|
var dispatchPointerExit = this.dispatchPointerExit;
|
|
@@ -6441,6 +6529,27 @@ var Rive = /** @class */ (function () {
|
|
|
6441
6529
|
enableMultiTouch: enableMultiTouch,
|
|
6442
6530
|
layoutScaleFactor: this._layout.layoutScaleFactor,
|
|
6443
6531
|
});
|
|
6532
|
+
// Wire up keyboard interactions for state machines that have focus nodes.
|
|
6533
|
+
// hasFocusNodes — unified focus tree check, gates tab traversal
|
|
6534
|
+
var smWithFocusNodes = playingStateMachines
|
|
6535
|
+
.filter(function (sm) { return sm.instance.hasFocusNodes(); })
|
|
6536
|
+
.map(function (sm) { return sm.instance; });
|
|
6537
|
+
if (smWithFocusNodes.length) {
|
|
6538
|
+
// Set the canvas as a tabbable element if there are any focus nodes.
|
|
6539
|
+
// Prefer the tabIndex param set by the user, otherwise use 0.
|
|
6540
|
+
// But do not override any explicit tabIndex already set on the canvas, if any.
|
|
6541
|
+
var currentCanvasTabIndex = this.canvas.tabIndex;
|
|
6542
|
+
// By default, canvas elements have a tabIndex of -1
|
|
6543
|
+
if (currentCanvasTabIndex === -1 || isNaN(currentCanvasTabIndex)) {
|
|
6544
|
+
this.canvas.tabIndex = (this._tabIndex !== null ? this._tabIndex : 0);
|
|
6545
|
+
}
|
|
6546
|
+
this.keyboardEventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerKeyboardInteractions)({
|
|
6547
|
+
canvas: this.canvas,
|
|
6548
|
+
stateMachine: smWithFocusNodes[0], // work off assumption of single state machine
|
|
6549
|
+
rive: this.runtime,
|
|
6550
|
+
hasFocusNodes: smWithFocusNodes.length > 0,
|
|
6551
|
+
});
|
|
6552
|
+
}
|
|
6444
6553
|
}
|
|
6445
6554
|
};
|
|
6446
6555
|
/**
|
|
@@ -6451,6 +6560,10 @@ var Rive = /** @class */ (function () {
|
|
|
6451
6560
|
this.eventCleanup();
|
|
6452
6561
|
this.eventCleanup = null;
|
|
6453
6562
|
}
|
|
6563
|
+
if (this.keyboardEventCleanup) {
|
|
6564
|
+
this.keyboardEventCleanup();
|
|
6565
|
+
this.keyboardEventCleanup = null;
|
|
6566
|
+
}
|
|
6454
6567
|
};
|
|
6455
6568
|
/**
|
|
6456
6569
|
* If the instance has audio and the system audio is not ready
|
|
@@ -6850,6 +6963,10 @@ var Rive = /** @class */ (function () {
|
|
|
6850
6963
|
audioManager.remove(this._audioEventListener);
|
|
6851
6964
|
this._audioEventListener = null;
|
|
6852
6965
|
}
|
|
6966
|
+
if (this._pageVisibilityHandler) {
|
|
6967
|
+
document.removeEventListener('visibilitychange', this._pageVisibilityHandler);
|
|
6968
|
+
this._pageVisibilityHandler = null;
|
|
6969
|
+
}
|
|
6853
6970
|
(_b = this._viewModelInstance) === null || _b === void 0 ? void 0 : _b.cleanup();
|
|
6854
6971
|
this._viewModelInstance = null;
|
|
6855
6972
|
this._dataEnums = null;
|
|
@@ -6874,6 +6991,10 @@ var Rive = /** @class */ (function () {
|
|
|
6874
6991
|
if (this.eventCleanup !== null) {
|
|
6875
6992
|
this.eventCleanup();
|
|
6876
6993
|
}
|
|
6994
|
+
if (this.keyboardEventCleanup) {
|
|
6995
|
+
this.keyboardEventCleanup();
|
|
6996
|
+
this.keyboardEventCleanup = null;
|
|
6997
|
+
}
|
|
6877
6998
|
// Delete all animation and state machine instances
|
|
6878
6999
|
this.stop();
|
|
6879
7000
|
if (this.artboard) {
|
|
@@ -6942,6 +7063,10 @@ var Rive = /** @class */ (function () {
|
|
|
6942
7063
|
if (this.eventCleanup) {
|
|
6943
7064
|
this.eventCleanup();
|
|
6944
7065
|
}
|
|
7066
|
+
if (this.keyboardEventCleanup) {
|
|
7067
|
+
this.keyboardEventCleanup();
|
|
7068
|
+
this.keyboardEventCleanup = null;
|
|
7069
|
+
}
|
|
6945
7070
|
this.setupRiveListeners();
|
|
6946
7071
|
this.startRendering();
|
|
6947
7072
|
};
|
|
@@ -6959,6 +7084,10 @@ var Rive = /** @class */ (function () {
|
|
|
6959
7084
|
if (this.eventCleanup) {
|
|
6960
7085
|
this.eventCleanup();
|
|
6961
7086
|
}
|
|
7087
|
+
if (this.keyboardEventCleanup) {
|
|
7088
|
+
this.keyboardEventCleanup();
|
|
7089
|
+
this.keyboardEventCleanup = null;
|
|
7090
|
+
}
|
|
6962
7091
|
this.animator.pause(animationNames);
|
|
6963
7092
|
};
|
|
6964
7093
|
Rive.prototype.scrub = function (animationNames, value) {
|
|
@@ -6994,6 +7123,10 @@ var Rive = /** @class */ (function () {
|
|
|
6994
7123
|
if (this.eventCleanup) {
|
|
6995
7124
|
this.eventCleanup();
|
|
6996
7125
|
}
|
|
7126
|
+
if (this.keyboardEventCleanup) {
|
|
7127
|
+
this.keyboardEventCleanup();
|
|
7128
|
+
this.keyboardEventCleanup = null;
|
|
7129
|
+
}
|
|
6997
7130
|
};
|
|
6998
7131
|
/**
|
|
6999
7132
|
* Resets the animation
|
|
@@ -7453,6 +7586,7 @@ var Rive = /** @class */ (function () {
|
|
|
7453
7586
|
* they would have been at if rendering had not been stopped.
|
|
7454
7587
|
*/
|
|
7455
7588
|
Rive.prototype.stopRendering = function () {
|
|
7589
|
+
this._explicitlyStoppedRendering = true;
|
|
7456
7590
|
if (this.loaded && this.frameRequestId) {
|
|
7457
7591
|
if (this.runtime.cancelAnimationFrame) {
|
|
7458
7592
|
this.runtime.cancelAnimationFrame(this.frameRequestId);
|
|
@@ -7468,6 +7602,7 @@ var Rive = /** @class */ (function () {
|
|
|
7468
7602
|
* renderer is already active, then this will have zero effect.
|
|
7469
7603
|
*/
|
|
7470
7604
|
Rive.prototype.startRendering = function () {
|
|
7605
|
+
this._explicitlyStoppedRendering = false;
|
|
7471
7606
|
this.drawFrame();
|
|
7472
7607
|
};
|
|
7473
7608
|
Rive.prototype.scheduleRendering = function () {
|
|
@@ -7480,6 +7615,31 @@ var Rive = /** @class */ (function () {
|
|
|
7480
7615
|
}
|
|
7481
7616
|
}
|
|
7482
7617
|
};
|
|
7618
|
+
/**
|
|
7619
|
+
* Called when document.visibilitychange fires (tab change, window minimize, etc.).
|
|
7620
|
+
* Cancels the rAF loop on hide and resets the time reference so that no accumulated time is
|
|
7621
|
+
* applied to state machines when the tab becomes visible again. This prevents state machine
|
|
7622
|
+
* advances with large time deltas when rAF starts up again.
|
|
7623
|
+
*/
|
|
7624
|
+
Rive.prototype._onPageVisibilityChange = function () {
|
|
7625
|
+
var _a, _b;
|
|
7626
|
+
if (document.hidden) {
|
|
7627
|
+
if (this.frameRequestId !== null) {
|
|
7628
|
+
if ((_a = this.runtime) === null || _a === void 0 ? void 0 : _a.cancelAnimationFrame) {
|
|
7629
|
+
this.runtime.cancelAnimationFrame(this.frameRequestId);
|
|
7630
|
+
}
|
|
7631
|
+
else {
|
|
7632
|
+
cancelAnimationFrame(this.frameRequestId);
|
|
7633
|
+
}
|
|
7634
|
+
this.frameRequestId = null;
|
|
7635
|
+
}
|
|
7636
|
+
// Reset so the first resumed frame starts with elapsedTime === 0.
|
|
7637
|
+
this.lastRenderTime = 0;
|
|
7638
|
+
}
|
|
7639
|
+
else if (((_b = this.animator) === null || _b === void 0 ? void 0 : _b.isPlaying) && !this._explicitlyStoppedRendering) {
|
|
7640
|
+
this.scheduleRendering();
|
|
7641
|
+
}
|
|
7642
|
+
};
|
|
7483
7643
|
/**
|
|
7484
7644
|
* Enables frames-per-second (FPS) reporting for the runtime
|
|
7485
7645
|
* If no callback is provided, Rive will append a fixed-position div at the top-right corner of
|