@rive-app/webgl2 2.18.0 → 2.19.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.
Files changed (4) hide show
  1. package/package.json +1 -1
  2. package/rive.js +157 -110
  3. package/rive.js.map +1 -1
  4. package/rive.wasm +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/webgl2",
3
- "version": "2.18.0",
3
+ "version": "2.19.1",
4
4
  "description": "Rive's webgl2 based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.js CHANGED
@@ -415,7 +415,7 @@ function Na(a, b) {
415
415
  return Ma(c, a, b);
416
416
  }));
417
417
  }
418
- var Oa, Pa, Ta = {473124:(a, b, c, d, e) => {
418
+ var Oa, Pa, Ta = {476212:(a, b, c, d, e) => {
419
419
  if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
420
420
  return 0;
421
421
  }
@@ -478,9 +478,9 @@ var Oa, Pa, Ta = {473124:(a, b, c, d, e) => {
478
478
  }
479
479
  window.h.Da += 1;
480
480
  return 1;
481
- }, 475302:() => {
481
+ }, 478390:() => {
482
482
  "undefined" !== typeof window.h && (--window.h.Da, 0 === window.h.Da && delete window.h);
483
- }, 475466:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 475570:() => {
483
+ }, 478554:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 478658:() => {
484
484
  try {
485
485
  var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
486
486
  a.close();
@@ -488,7 +488,7 @@ var Oa, Pa, Ta = {473124:(a, b, c, d, e) => {
488
488
  } catch (c) {
489
489
  return 0;
490
490
  }
491
- }, 475741:(a, b, c, d, e, f) => {
491
+ }, 478829:(a, b, c, d, e, f) => {
492
492
  if ("undefined" === typeof window.h) {
493
493
  return -1;
494
494
  }
@@ -534,7 +534,7 @@ var Oa, Pa, Ta = {473124:(a, b, c, d, e) => {
534
534
  a == window.h.I.Ba && g.Y.connect(g.J.destination);
535
535
  g.jb = f;
536
536
  return window.h.lc(g);
537
- }, 478618:a => window.h.va(a).J.sampleRate, 478691:a => {
537
+ }, 481706:a => window.h.va(a).J.sampleRate, 481779:a => {
538
538
  a = window.h.va(a);
539
539
  void 0 !== a.Y && (a.Y.onaudioprocess = function() {
540
540
  }, a.Y.disconnect(), a.Y = void 0);
@@ -542,13 +542,13 @@ var Oa, Pa, Ta = {473124:(a, b, c, d, e) => {
542
542
  a.J.close();
543
543
  a.J = void 0;
544
544
  a.jb = void 0;
545
- }, 479091:a => {
545
+ }, 482179:a => {
546
546
  window.h.wb(a);
547
- }, 479141:a => {
547
+ }, 482229:a => {
548
548
  a = window.h.va(a);
549
549
  a.J.resume();
550
550
  a.state = window.h.ha.rb;
551
- }, 479280:a => {
551
+ }, 482368:a => {
552
552
  a = window.h.va(a);
553
553
  a.J.suspend();
554
554
  a.state = window.h.ha.stopped;
@@ -3459,8 +3459,8 @@ n.dynCall_viijii = (a, b, c, d, e, f, g) => (n.dynCall_viijii = B.dynCall_viijii
3459
3459
  n.dynCall_iiiiij = (a, b, c, d, e, f, g) => (n.dynCall_iiiiij = B.dynCall_iiiiij)(a, b, c, d, e, f, g);
3460
3460
  n.dynCall_iiiiijj = (a, b, c, d, e, f, g, m, p) => (n.dynCall_iiiiijj = B.dynCall_iiiiijj)(a, b, c, d, e, f, g, m, p);
3461
3461
  n.dynCall_iiiiiijj = (a, b, c, d, e, f, g, m, p, l) => (n.dynCall_iiiiiijj = B.dynCall_iiiiiijj)(a, b, c, d, e, f, g, m, p, l);
3462
- n.___start_em_js = 470500;
3463
- n.___stop_em_js = 473124;
3462
+ n.___start_em_js = 473588;
3463
+ n.___stop_em_js = 476212;
3464
3464
  var Wd;
3465
3465
  Ga = function Xd() {
3466
3466
  Wd || Yd();
@@ -3520,26 +3520,160 @@ Yd();
3520
3520
  /* 2 */
3521
3521
  /***/ ((module) => {
3522
3522
 
3523
- module.exports = JSON.parse('{"name":"@rive-app/webgl2","version":"2.18.0","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.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3523
+ module.exports = JSON.parse('{"name":"@rive-app/webgl2","version":"2.19.1","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.js.map","rive.d.ts","rive_advanced.mjs.d.ts"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
3524
3524
 
3525
3525
  /***/ }),
3526
3526
  /* 3 */
3527
3527
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3528
3528
 
3529
+ __webpack_require__.r(__webpack_exports__);
3530
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3531
+ /* harmony export */ Animation: () => (/* reexport safe */ _Animation__WEBPACK_IMPORTED_MODULE_0__.Animation)
3532
+ /* harmony export */ });
3533
+ /* harmony import */ var _Animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
3534
+
3535
+
3536
+
3537
+ /***/ }),
3538
+ /* 4 */
3539
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3540
+
3541
+ __webpack_require__.r(__webpack_exports__);
3542
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3543
+ /* harmony export */ Animation: () => (/* binding */ Animation)
3544
+ /* harmony export */ });
3545
+ /**
3546
+ * Represents an animation that can be played on an Artboard.
3547
+ * Wraps animations and instances from the runtime and keeps track of playback state.
3548
+ *
3549
+ * The `Animation` class manages the state and behavior of a single animation instance,
3550
+ * including its current time, loop count, and ability to scrub to a specific time.
3551
+ *
3552
+ * The class provides methods to advance the animation, apply its interpolated keyframe
3553
+ * values to the Artboard, and clean up the underlying animation instance when the
3554
+ * animation is no longer needed.
3555
+ */
3556
+ var Animation = /** @class */ (function () {
3557
+ /**
3558
+ * Constructs a new animation
3559
+ * @constructor
3560
+ * @param {any} animation: runtime animation object
3561
+ * @param {any} instance: runtime animation instance object
3562
+ */
3563
+ function Animation(animation, artboard, runtime, playing) {
3564
+ this.animation = animation;
3565
+ this.artboard = artboard;
3566
+ this.playing = playing;
3567
+ this.loopCount = 0;
3568
+ /**
3569
+ * The time to which the animation should move to on the next render.
3570
+ * If not null, the animation will scrub to this time instead of advancing by the given time.
3571
+ */
3572
+ this.scrubTo = null;
3573
+ this.instance = new runtime.LinearAnimationInstance(animation, artboard);
3574
+ }
3575
+ Object.defineProperty(Animation.prototype, "name", {
3576
+ /**
3577
+ * Returns the animation's name
3578
+ */
3579
+ get: function () {
3580
+ return this.animation.name;
3581
+ },
3582
+ enumerable: false,
3583
+ configurable: true
3584
+ });
3585
+ Object.defineProperty(Animation.prototype, "time", {
3586
+ /**
3587
+ * Returns the animation's name
3588
+ */
3589
+ get: function () {
3590
+ return this.instance.time;
3591
+ },
3592
+ /**
3593
+ * Sets the animation's current time
3594
+ */
3595
+ set: function (value) {
3596
+ this.instance.time = value;
3597
+ },
3598
+ enumerable: false,
3599
+ configurable: true
3600
+ });
3601
+ Object.defineProperty(Animation.prototype, "loopValue", {
3602
+ /**
3603
+ * Returns the animation's loop type
3604
+ */
3605
+ get: function () {
3606
+ return this.animation.loopValue;
3607
+ },
3608
+ enumerable: false,
3609
+ configurable: true
3610
+ });
3611
+ Object.defineProperty(Animation.prototype, "needsScrub", {
3612
+ /**
3613
+ * Indicates whether the animation needs to be scrubbed.
3614
+ * @returns `true` if the animation needs to be scrubbed, `false` otherwise.
3615
+ */
3616
+ get: function () {
3617
+ return this.scrubTo !== null;
3618
+ },
3619
+ enumerable: false,
3620
+ configurable: true
3621
+ });
3622
+ /**
3623
+ * Advances the animation by the give time. If the animation needs scrubbing,
3624
+ * time is ignored and the stored scrub value is used.
3625
+ * @param time the time to advance the animation by if no scrubbing required
3626
+ */
3627
+ Animation.prototype.advance = function (time) {
3628
+ if (this.scrubTo === null) {
3629
+ this.instance.advance(time);
3630
+ }
3631
+ else {
3632
+ this.instance.time = 0;
3633
+ this.instance.advance(this.scrubTo);
3634
+ this.scrubTo = null;
3635
+ }
3636
+ };
3637
+ /**
3638
+ * Apply interpolated keyframe values to the artboard. This should be called after calling
3639
+ * .advance() on an animation instance so that new values are applied to properties.
3640
+ *
3641
+ * Note: This does not advance the artboard, which updates all objects on the artboard
3642
+ * @param mix - Mix value for the animation from 0 to 1
3643
+ */
3644
+ Animation.prototype.apply = function (mix) {
3645
+ this.instance.apply(mix);
3646
+ };
3647
+ /**
3648
+ * Deletes the backing Wasm animation instance; once this is called, this
3649
+ * animation is no more.
3650
+ */
3651
+ Animation.prototype.cleanup = function () {
3652
+ this.instance.delete();
3653
+ };
3654
+ return Animation;
3655
+ }());
3656
+
3657
+
3658
+
3659
+ /***/ }),
3660
+ /* 5 */
3661
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3662
+
3529
3663
  __webpack_require__.r(__webpack_exports__);
3530
3664
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3531
3665
  /* harmony export */ BLANK_URL: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.BLANK_URL),
3532
3666
  /* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
3533
3667
  /* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.sanitizeUrl)
3534
3668
  /* harmony export */ });
3535
- /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
3536
- /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
3669
+ /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6);
3670
+ /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
3537
3671
 
3538
3672
 
3539
3673
 
3540
3674
 
3541
3675
  /***/ }),
3542
- /* 4 */
3676
+ /* 6 */
3543
3677
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3544
3678
 
3545
3679
  __webpack_require__.r(__webpack_exports__);
@@ -3693,7 +3827,7 @@ var registerTouchInteractions = function (_a) {
3693
3827
 
3694
3828
 
3695
3829
  /***/ }),
3696
- /* 5 */
3830
+ /* 7 */
3697
3831
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3698
3832
 
3699
3833
  __webpack_require__.r(__webpack_exports__);
@@ -3825,7 +3959,8 @@ __webpack_require__.r(__webpack_exports__);
3825
3959
  /* harmony export */ });
3826
3960
  /* harmony import */ var _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
3827
3961
  /* harmony import */ var package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
3828
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
3962
+ /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
3963
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
3829
3964
  var __extends = (undefined && undefined.__extends) || (function () {
3830
3965
  var extendStatics = function (d, b) {
3831
3966
  extendStatics = Object.setPrototypeOf ||
@@ -3880,6 +4015,7 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
3880
4015
 
3881
4016
 
3882
4017
 
4018
+
3883
4019
  // #region layout
3884
4020
  // Fit options for the canvas
3885
4021
  var Fit;
@@ -4058,95 +4194,6 @@ var RuntimeLoader = /** @class */ (function () {
4058
4194
  return RuntimeLoader;
4059
4195
  }());
4060
4196
 
4061
- // #endregion
4062
- // #region animations
4063
- // Wraps animations and instances from the runtime and keeps track of playback
4064
- // state
4065
- var Animation = /** @class */ (function () {
4066
- /**
4067
- * Constructs a new animation
4068
- * @constructor
4069
- * @param {any} animation: runtime animation object
4070
- * @param {any} instance: runtime animation instance object
4071
- */
4072
- function Animation(animation, artboard, runtime, playing) {
4073
- this.animation = animation;
4074
- this.artboard = artboard;
4075
- this.playing = playing;
4076
- this.loopCount = 0;
4077
- // Time to which the animation should move to on the next render
4078
- this.scrubTo = null;
4079
- this.instance = new runtime.LinearAnimationInstance(animation, artboard);
4080
- }
4081
- Object.defineProperty(Animation.prototype, "name", {
4082
- // Returns the animation's name
4083
- get: function () {
4084
- return this.animation.name;
4085
- },
4086
- enumerable: false,
4087
- configurable: true
4088
- });
4089
- Object.defineProperty(Animation.prototype, "time", {
4090
- // Returns the animation's current time
4091
- get: function () {
4092
- return this.instance.time;
4093
- },
4094
- // Sets the animation's current time
4095
- set: function (value) {
4096
- this.instance.time = value;
4097
- },
4098
- enumerable: false,
4099
- configurable: true
4100
- });
4101
- Object.defineProperty(Animation.prototype, "loopValue", {
4102
- // Returns the animation's loop type
4103
- get: function () {
4104
- return this.animation.loopValue;
4105
- },
4106
- enumerable: false,
4107
- configurable: true
4108
- });
4109
- /**
4110
- * Advances the animation by the give time. If the animation needs scrubbing,
4111
- * time is ignored and the stored scrub value is used.
4112
- * @param time the time to advance the animation by if no scrubbing required
4113
- */
4114
- Animation.prototype.advance = function (time) {
4115
- if (this.scrubTo === null) {
4116
- this.instance.advance(time);
4117
- }
4118
- else {
4119
- this.instance.time = 0;
4120
- this.instance.advance(this.scrubTo);
4121
- this.scrubTo = null;
4122
- }
4123
- };
4124
- /**
4125
- * Apply interpolated keyframe values to the artboard. This should be called after calling
4126
- * .advance() on an animation instance so that new values are applied to properties.
4127
- *
4128
- * Note: This does not advance the artboard, which updates all objects on the artboard
4129
- * @param mix - Mix value for the animation from 0 to 1
4130
- */
4131
- Animation.prototype.apply = function (mix) {
4132
- this.instance.apply(mix);
4133
- };
4134
- Object.defineProperty(Animation.prototype, "needsScrub", {
4135
- get: function () {
4136
- return this.scrubTo !== null;
4137
- },
4138
- enumerable: false,
4139
- configurable: true
4140
- });
4141
- /**
4142
- * Deletes the backing Wasm animation instance; once this is called, this
4143
- * animation is no more.
4144
- */
4145
- Animation.prototype.cleanup = function () {
4146
- this.instance.delete();
4147
- };
4148
- return Animation;
4149
- }());
4150
4197
  // #endregion
4151
4198
  // #region state machines
4152
4199
  var StateMachineInputType;
@@ -4361,7 +4408,7 @@ var Animator = /** @class */ (function () {
4361
4408
  // Try to create a new animation instance
4362
4409
  var anim = this.artboard.animationByName(animatables[i]);
4363
4410
  if (anim) {
4364
- var newAnimation = new Animation(anim, this.artboard, this.runtime, playing);
4411
+ var newAnimation = new _animation__WEBPACK_IMPORTED_MODULE_2__.Animation(anim, this.artboard, this.runtime, playing);
4365
4412
  // Display the first frame of the specified animation
4366
4413
  newAnimation.advance(0);
4367
4414
  newAnimation.apply(1.0);
@@ -4415,7 +4462,7 @@ var Animator = /** @class */ (function () {
4415
4462
  // Try to create a new animation instance
4416
4463
  var anim = this.artboard.animationByName(animatables[i]);
4417
4464
  if (anim) {
4418
- var newAnimation = new Animation(anim, this.artboard, this.runtime, playing);
4465
+ var newAnimation = new _animation__WEBPACK_IMPORTED_MODULE_2__.Animation(anim, this.artboard, this.runtime, playing);
4419
4466
  // Display the first frame of the specified animation
4420
4467
  newAnimation.advance(0);
4421
4468
  newAnimation.apply(1.0);
@@ -5312,7 +5359,7 @@ var Rive = /** @class */ (function () {
5312
5359
  "isTouchScrollEnabled" in riveListenerOptions) {
5313
5360
  touchScrollEnabledOption = riveListenerOptions.isTouchScrollEnabled;
5314
5361
  }
5315
- this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
5362
+ this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.registerTouchInteractions)({
5316
5363
  canvas: this.canvas,
5317
5364
  artboard: this.artboard,
5318
5365
  stateMachines: activeStateMachines,
@@ -5507,10 +5554,10 @@ var Rive = /** @class */ (function () {
5507
5554
  if (this.automaticallyHandleEvents) {
5508
5555
  var newAnchorTag = document.createElement("a");
5509
5556
  var _b = event_1, url = _b.url, target = _b.target;
5510
- var sanitizedUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)(url);
5557
+ var sanitizedUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.sanitizeUrl)(url);
5511
5558
  url && newAnchorTag.setAttribute("href", sanitizedUrl);
5512
5559
  target && newAnchorTag.setAttribute("target", target);
5513
- if (sanitizedUrl && sanitizedUrl !== _utils__WEBPACK_IMPORTED_MODULE_2__.BLANK_URL) {
5560
+ if (sanitizedUrl && sanitizedUrl !== _utils__WEBPACK_IMPORTED_MODULE_3__.BLANK_URL) {
5514
5561
  newAnchorTag.click();
5515
5562
  }
5516
5563
  }