@rive-app/canvas-lite 2.17.3 → 2.19.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rive-app/canvas-lite",
3
- "version": "2.17.3",
3
+ "version": "2.19.0",
4
4
  "description": "A lite version of Rive's canvas based web api.",
5
5
  "main": "rive.js",
6
6
  "homepage": "https://rive.app",
package/rive.js CHANGED
@@ -2259,26 +2259,160 @@ Pc();
2259
2259
  /* 2 */
2260
2260
  /***/ ((module) => {
2261
2261
 
2262
- module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.17.3","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"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2262
+ module.exports = JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.19.0","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"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
2263
2263
 
2264
2264
  /***/ }),
2265
2265
  /* 3 */
2266
2266
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2267
2267
 
2268
+ __webpack_require__.r(__webpack_exports__);
2269
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2270
+ /* harmony export */ Animation: () => (/* reexport safe */ _Animation__WEBPACK_IMPORTED_MODULE_0__.Animation)
2271
+ /* harmony export */ });
2272
+ /* harmony import */ var _Animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
2273
+
2274
+
2275
+
2276
+ /***/ }),
2277
+ /* 4 */
2278
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2279
+
2280
+ __webpack_require__.r(__webpack_exports__);
2281
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2282
+ /* harmony export */ Animation: () => (/* binding */ Animation)
2283
+ /* harmony export */ });
2284
+ /**
2285
+ * Represents an animation that can be played on an Artboard.
2286
+ * Wraps animations and instances from the runtime and keeps track of playback state.
2287
+ *
2288
+ * The `Animation` class manages the state and behavior of a single animation instance,
2289
+ * including its current time, loop count, and ability to scrub to a specific time.
2290
+ *
2291
+ * The class provides methods to advance the animation, apply its interpolated keyframe
2292
+ * values to the Artboard, and clean up the underlying animation instance when the
2293
+ * animation is no longer needed.
2294
+ */
2295
+ var Animation = /** @class */ (function () {
2296
+ /**
2297
+ * Constructs a new animation
2298
+ * @constructor
2299
+ * @param {any} animation: runtime animation object
2300
+ * @param {any} instance: runtime animation instance object
2301
+ */
2302
+ function Animation(animation, artboard, runtime, playing) {
2303
+ this.animation = animation;
2304
+ this.artboard = artboard;
2305
+ this.playing = playing;
2306
+ this.loopCount = 0;
2307
+ /**
2308
+ * The time to which the animation should move to on the next render.
2309
+ * If not null, the animation will scrub to this time instead of advancing by the given time.
2310
+ */
2311
+ this.scrubTo = null;
2312
+ this.instance = new runtime.LinearAnimationInstance(animation, artboard);
2313
+ }
2314
+ Object.defineProperty(Animation.prototype, "name", {
2315
+ /**
2316
+ * Returns the animation's name
2317
+ */
2318
+ get: function () {
2319
+ return this.animation.name;
2320
+ },
2321
+ enumerable: false,
2322
+ configurable: true
2323
+ });
2324
+ Object.defineProperty(Animation.prototype, "time", {
2325
+ /**
2326
+ * Returns the animation's name
2327
+ */
2328
+ get: function () {
2329
+ return this.instance.time;
2330
+ },
2331
+ /**
2332
+ * Sets the animation's current time
2333
+ */
2334
+ set: function (value) {
2335
+ this.instance.time = value;
2336
+ },
2337
+ enumerable: false,
2338
+ configurable: true
2339
+ });
2340
+ Object.defineProperty(Animation.prototype, "loopValue", {
2341
+ /**
2342
+ * Returns the animation's loop type
2343
+ */
2344
+ get: function () {
2345
+ return this.animation.loopValue;
2346
+ },
2347
+ enumerable: false,
2348
+ configurable: true
2349
+ });
2350
+ Object.defineProperty(Animation.prototype, "needsScrub", {
2351
+ /**
2352
+ * Indicates whether the animation needs to be scrubbed.
2353
+ * @returns `true` if the animation needs to be scrubbed, `false` otherwise.
2354
+ */
2355
+ get: function () {
2356
+ return this.scrubTo !== null;
2357
+ },
2358
+ enumerable: false,
2359
+ configurable: true
2360
+ });
2361
+ /**
2362
+ * Advances the animation by the give time. If the animation needs scrubbing,
2363
+ * time is ignored and the stored scrub value is used.
2364
+ * @param time the time to advance the animation by if no scrubbing required
2365
+ */
2366
+ Animation.prototype.advance = function (time) {
2367
+ if (this.scrubTo === null) {
2368
+ this.instance.advance(time);
2369
+ }
2370
+ else {
2371
+ this.instance.time = 0;
2372
+ this.instance.advance(this.scrubTo);
2373
+ this.scrubTo = null;
2374
+ }
2375
+ };
2376
+ /**
2377
+ * Apply interpolated keyframe values to the artboard. This should be called after calling
2378
+ * .advance() on an animation instance so that new values are applied to properties.
2379
+ *
2380
+ * Note: This does not advance the artboard, which updates all objects on the artboard
2381
+ * @param mix - Mix value for the animation from 0 to 1
2382
+ */
2383
+ Animation.prototype.apply = function (mix) {
2384
+ this.instance.apply(mix);
2385
+ };
2386
+ /**
2387
+ * Deletes the backing Wasm animation instance; once this is called, this
2388
+ * animation is no more.
2389
+ */
2390
+ Animation.prototype.cleanup = function () {
2391
+ this.instance.delete();
2392
+ };
2393
+ return Animation;
2394
+ }());
2395
+
2396
+
2397
+
2398
+ /***/ }),
2399
+ /* 5 */
2400
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2401
+
2268
2402
  __webpack_require__.r(__webpack_exports__);
2269
2403
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2270
2404
  /* harmony export */ BLANK_URL: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.BLANK_URL),
2271
2405
  /* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
2272
2406
  /* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__.sanitizeUrl)
2273
2407
  /* harmony export */ });
2274
- /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
2275
- /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
2408
+ /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6);
2409
+ /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
2276
2410
 
2277
2411
 
2278
2412
 
2279
2413
 
2280
2414
  /***/ }),
2281
- /* 4 */
2415
+ /* 6 */
2282
2416
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2283
2417
 
2284
2418
  __webpack_require__.r(__webpack_exports__);
@@ -2432,7 +2566,7 @@ var registerTouchInteractions = function (_a) {
2432
2566
 
2433
2567
 
2434
2568
  /***/ }),
2435
- /* 5 */
2569
+ /* 7 */
2436
2570
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2437
2571
 
2438
2572
  __webpack_require__.r(__webpack_exports__);
@@ -2564,7 +2698,8 @@ __webpack_require__.r(__webpack_exports__);
2564
2698
  /* harmony export */ });
2565
2699
  /* harmony import */ var _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
2566
2700
  /* harmony import */ var package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
2567
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
2701
+ /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
2702
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
2568
2703
  var __extends = (undefined && undefined.__extends) || (function () {
2569
2704
  var extendStatics = function (d, b) {
2570
2705
  extendStatics = Object.setPrototypeOf ||
@@ -2619,6 +2754,7 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
2619
2754
 
2620
2755
 
2621
2756
 
2757
+
2622
2758
  // #region layout
2623
2759
  // Fit options for the canvas
2624
2760
  var Fit;
@@ -2797,95 +2933,6 @@ var RuntimeLoader = /** @class */ (function () {
2797
2933
  return RuntimeLoader;
2798
2934
  }());
2799
2935
 
2800
- // #endregion
2801
- // #region animations
2802
- // Wraps animations and instances from the runtime and keeps track of playback
2803
- // state
2804
- var Animation = /** @class */ (function () {
2805
- /**
2806
- * Constructs a new animation
2807
- * @constructor
2808
- * @param {any} animation: runtime animation object
2809
- * @param {any} instance: runtime animation instance object
2810
- */
2811
- function Animation(animation, artboard, runtime, playing) {
2812
- this.animation = animation;
2813
- this.artboard = artboard;
2814
- this.playing = playing;
2815
- this.loopCount = 0;
2816
- // Time to which the animation should move to on the next render
2817
- this.scrubTo = null;
2818
- this.instance = new runtime.LinearAnimationInstance(animation, artboard);
2819
- }
2820
- Object.defineProperty(Animation.prototype, "name", {
2821
- // Returns the animation's name
2822
- get: function () {
2823
- return this.animation.name;
2824
- },
2825
- enumerable: false,
2826
- configurable: true
2827
- });
2828
- Object.defineProperty(Animation.prototype, "time", {
2829
- // Returns the animation's current time
2830
- get: function () {
2831
- return this.instance.time;
2832
- },
2833
- // Sets the animation's current time
2834
- set: function (value) {
2835
- this.instance.time = value;
2836
- },
2837
- enumerable: false,
2838
- configurable: true
2839
- });
2840
- Object.defineProperty(Animation.prototype, "loopValue", {
2841
- // Returns the animation's loop type
2842
- get: function () {
2843
- return this.animation.loopValue;
2844
- },
2845
- enumerable: false,
2846
- configurable: true
2847
- });
2848
- /**
2849
- * Advances the animation by the give time. If the animation needs scrubbing,
2850
- * time is ignored and the stored scrub value is used.
2851
- * @param time the time to advance the animation by if no scrubbing required
2852
- */
2853
- Animation.prototype.advance = function (time) {
2854
- if (this.scrubTo === null) {
2855
- this.instance.advance(time);
2856
- }
2857
- else {
2858
- this.instance.time = 0;
2859
- this.instance.advance(this.scrubTo);
2860
- this.scrubTo = null;
2861
- }
2862
- };
2863
- /**
2864
- * Apply interpolated keyframe values to the artboard. This should be called after calling
2865
- * .advance() on an animation instance so that new values are applied to properties.
2866
- *
2867
- * Note: This does not advance the artboard, which updates all objects on the artboard
2868
- * @param mix - Mix value for the animation from 0 to 1
2869
- */
2870
- Animation.prototype.apply = function (mix) {
2871
- this.instance.apply(mix);
2872
- };
2873
- Object.defineProperty(Animation.prototype, "needsScrub", {
2874
- get: function () {
2875
- return this.scrubTo !== null;
2876
- },
2877
- enumerable: false,
2878
- configurable: true
2879
- });
2880
- /**
2881
- * Deletes the backing Wasm animation instance; once this is called, this
2882
- * animation is no more.
2883
- */
2884
- Animation.prototype.cleanup = function () {
2885
- this.instance.delete();
2886
- };
2887
- return Animation;
2888
- }());
2889
2936
  // #endregion
2890
2937
  // #region state machines
2891
2938
  var StateMachineInputType;
@@ -3100,7 +3147,7 @@ var Animator = /** @class */ (function () {
3100
3147
  // Try to create a new animation instance
3101
3148
  var anim = this.artboard.animationByName(animatables[i]);
3102
3149
  if (anim) {
3103
- var newAnimation = new Animation(anim, this.artboard, this.runtime, playing);
3150
+ var newAnimation = new _animation__WEBPACK_IMPORTED_MODULE_2__.Animation(anim, this.artboard, this.runtime, playing);
3104
3151
  // Display the first frame of the specified animation
3105
3152
  newAnimation.advance(0);
3106
3153
  newAnimation.apply(1.0);
@@ -3154,7 +3201,7 @@ var Animator = /** @class */ (function () {
3154
3201
  // Try to create a new animation instance
3155
3202
  var anim = this.artboard.animationByName(animatables[i]);
3156
3203
  if (anim) {
3157
- var newAnimation = new Animation(anim, this.artboard, this.runtime, playing);
3204
+ var newAnimation = new _animation__WEBPACK_IMPORTED_MODULE_2__.Animation(anim, this.artboard, this.runtime, playing);
3158
3205
  // Display the first frame of the specified animation
3159
3206
  newAnimation.advance(0);
3160
3207
  newAnimation.apply(1.0);
@@ -4051,7 +4098,7 @@ var Rive = /** @class */ (function () {
4051
4098
  "isTouchScrollEnabled" in riveListenerOptions) {
4052
4099
  touchScrollEnabledOption = riveListenerOptions.isTouchScrollEnabled;
4053
4100
  }
4054
- this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.registerTouchInteractions)({
4101
+ this.eventCleanup = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.registerTouchInteractions)({
4055
4102
  canvas: this.canvas,
4056
4103
  artboard: this.artboard,
4057
4104
  stateMachines: activeStateMachines,
@@ -4246,10 +4293,10 @@ var Rive = /** @class */ (function () {
4246
4293
  if (this.automaticallyHandleEvents) {
4247
4294
  var newAnchorTag = document.createElement("a");
4248
4295
  var _b = event_1, url = _b.url, target = _b.target;
4249
- var sanitizedUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)(url);
4296
+ var sanitizedUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_3__.sanitizeUrl)(url);
4250
4297
  url && newAnchorTag.setAttribute("href", sanitizedUrl);
4251
4298
  target && newAnchorTag.setAttribute("target", target);
4252
- if (sanitizedUrl && sanitizedUrl !== _utils__WEBPACK_IMPORTED_MODULE_2__.BLANK_URL) {
4299
+ if (sanitizedUrl && sanitizedUrl !== _utils__WEBPACK_IMPORTED_MODULE_3__.BLANK_URL) {
4253
4300
  newAnchorTag.click();
4254
4301
  }
4255
4302
  }