@rive-app/canvas 2.37.2 → 2.37.4
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.js +93 -56
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_fallback.wasm +0 -0
package/package.json
CHANGED
package/rive.js
CHANGED
|
@@ -1067,7 +1067,7 @@ function Za(a, b) {
|
|
|
1067
1067
|
return Ya(c, a, b);
|
|
1068
1068
|
}));
|
|
1069
1069
|
}
|
|
1070
|
-
var $a, ab, eb = {
|
|
1070
|
+
var $a, ab, eb = {480562:(a, b, c, d, e) => {
|
|
1071
1071
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
1072
1072
|
return 0;
|
|
1073
1073
|
}
|
|
@@ -1130,11 +1130,11 @@ var $a, ab, eb = {480002:(a, b, c, d, e) => {
|
|
|
1130
1130
|
}
|
|
1131
1131
|
window.h.za += 1;
|
|
1132
1132
|
return 1;
|
|
1133
|
-
},
|
|
1133
|
+
}, 482740:() => {
|
|
1134
1134
|
"undefined" !== typeof window.h && (window.h.Sa.map(function(a) {
|
|
1135
1135
|
document.removeEventListener(a, window.h.unlock, !0);
|
|
1136
1136
|
}), --window.h.za, 0 === window.h.za && delete window.h);
|
|
1137
|
-
},
|
|
1137
|
+
}, 483044:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 483148:() => {
|
|
1138
1138
|
try {
|
|
1139
1139
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
1140
1140
|
a.close();
|
|
@@ -1142,7 +1142,7 @@ var $a, ab, eb = {480002:(a, b, c, d, e) => {
|
|
|
1142
1142
|
} catch (c) {
|
|
1143
1143
|
return 0;
|
|
1144
1144
|
}
|
|
1145
|
-
},
|
|
1145
|
+
}, 483319:(a, b, c, d, e, f) => {
|
|
1146
1146
|
if ("undefined" === typeof window.h) {
|
|
1147
1147
|
return -1;
|
|
1148
1148
|
}
|
|
@@ -1188,7 +1188,7 @@ var $a, ab, eb = {480002:(a, b, c, d, e) => {
|
|
|
1188
1188
|
a == window.h.J.xa && g.Z.connect(g.L.destination);
|
|
1189
1189
|
g.pb = f;
|
|
1190
1190
|
return window.h.sc(g);
|
|
1191
|
-
},
|
|
1191
|
+
}, 486196:a => window.h.qa(a).L.sampleRate, 486269:a => {
|
|
1192
1192
|
a = window.h.qa(a);
|
|
1193
1193
|
void 0 !== a.Z && (a.Z.onaudioprocess = function() {
|
|
1194
1194
|
}, a.Z.disconnect(), a.Z = void 0);
|
|
@@ -1196,13 +1196,13 @@ var $a, ab, eb = {480002:(a, b, c, d, e) => {
|
|
|
1196
1196
|
a.L.close();
|
|
1197
1197
|
a.L = void 0;
|
|
1198
1198
|
a.pb = void 0;
|
|
1199
|
-
},
|
|
1199
|
+
}, 486669:a => {
|
|
1200
1200
|
window.h.Ab(a);
|
|
1201
|
-
},
|
|
1201
|
+
}, 486719:a => {
|
|
1202
1202
|
a = window.h.qa(a);
|
|
1203
1203
|
a.L.resume();
|
|
1204
1204
|
a.state = window.h.ga.wb;
|
|
1205
|
-
},
|
|
1205
|
+
}, 486858:a => {
|
|
1206
1206
|
a = window.h.qa(a);
|
|
1207
1207
|
a.L.suspend();
|
|
1208
1208
|
a.state = window.h.ga.stopped;
|
|
@@ -3714,7 +3714,7 @@ moduleRtn = ea;
|
|
|
3714
3714
|
/* 5 */
|
|
3715
3715
|
/***/ ((module) => {
|
|
3716
3716
|
|
|
3717
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.37.
|
|
3717
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas","version":"2.37.4","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}}');
|
|
3718
3718
|
|
|
3719
3719
|
/***/ }),
|
|
3720
3720
|
/* 6 */
|
|
@@ -3758,60 +3758,70 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
3758
3758
|
/* harmony export */ });
|
|
3759
3759
|
var _this = undefined;
|
|
3760
3760
|
/**
|
|
3761
|
-
*
|
|
3762
|
-
*
|
|
3763
|
-
*
|
|
3764
|
-
* @param event - Either a TouchEvent or a MouseEvent
|
|
3765
|
-
* @returns - Coordinates of the clientX and clientY properties from the touch/mouse event
|
|
3761
|
+
* Extracts ClientCoordinates from a TouchList, respecting multi-touch vs.
|
|
3762
|
+
* single-touch mode. In single-touch mode, only the touch matching
|
|
3763
|
+
* primaryTouchId is returned (or the first touch when primaryTouchId is null).
|
|
3766
3764
|
*/
|
|
3767
|
-
var
|
|
3768
|
-
var _a
|
|
3765
|
+
var getTouchCoordinates = function (changedTouches, enableMultiTouch, primaryTouchId) {
|
|
3766
|
+
var _a;
|
|
3769
3767
|
var coordinates = [];
|
|
3770
|
-
if (
|
|
3771
|
-
(
|
|
3772
|
-
|
|
3773
|
-
// which may prevent scrolling if a drag motion on the canvas is performed
|
|
3774
|
-
if (!isTouchScrollEnabled) {
|
|
3775
|
-
event.preventDefault();
|
|
3776
|
-
}
|
|
3777
|
-
var cnt = 0;
|
|
3778
|
-
var totalTouches = enableMultiTouch
|
|
3779
|
-
? event.changedTouches.length
|
|
3780
|
-
: 1;
|
|
3781
|
-
while (cnt < totalTouches) {
|
|
3782
|
-
var touch = event.changedTouches[cnt];
|
|
3768
|
+
if (enableMultiTouch) {
|
|
3769
|
+
for (var i = 0; i < changedTouches.length; i++) {
|
|
3770
|
+
var touch = changedTouches[i];
|
|
3783
3771
|
coordinates.push({
|
|
3784
3772
|
clientX: touch.clientX,
|
|
3785
3773
|
clientY: touch.clientY,
|
|
3786
3774
|
identifier: touch.identifier,
|
|
3787
3775
|
});
|
|
3788
|
-
cnt++;
|
|
3789
3776
|
}
|
|
3790
3777
|
}
|
|
3791
|
-
else
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
:
|
|
3797
|
-
|
|
3798
|
-
|
|
3778
|
+
else {
|
|
3779
|
+
// In "single-touch mode", only track the primary finger identified at touchstart.
|
|
3780
|
+
// Search changedTouches for the touch matching the recorded primary touch identifier, or (on initial touchstart)
|
|
3781
|
+
// take the first available touch identifier.
|
|
3782
|
+
var primaryTouch = primaryTouchId !== null
|
|
3783
|
+
? (_a = Array.from(changedTouches).find(function (t) { return t.identifier === primaryTouchId; })) !== null && _a !== void 0 ? _a : null
|
|
3784
|
+
: changedTouches[0];
|
|
3785
|
+
if (primaryTouch) {
|
|
3799
3786
|
coordinates.push({
|
|
3800
|
-
clientX:
|
|
3801
|
-
clientY:
|
|
3802
|
-
identifier:
|
|
3787
|
+
clientX: primaryTouch.clientX,
|
|
3788
|
+
clientY: primaryTouch.clientY,
|
|
3789
|
+
identifier: primaryTouch.identifier,
|
|
3803
3790
|
});
|
|
3804
|
-
cnt++;
|
|
3805
3791
|
}
|
|
3806
3792
|
}
|
|
3807
|
-
|
|
3808
|
-
|
|
3793
|
+
return coordinates;
|
|
3794
|
+
};
|
|
3795
|
+
/**
|
|
3796
|
+
* Returns the clientX and clientY properties from touch or mouse events. Also
|
|
3797
|
+
* calls preventDefault() on the event if it is a touchstart or touchmove to prevent
|
|
3798
|
+
* scrolling the page on mobile devices
|
|
3799
|
+
* @param event - Either a TouchEvent or a MouseEvent
|
|
3800
|
+
* @param isTouchScrollEnabled - Whether touch scrolling is enabled
|
|
3801
|
+
* @param enableMultiTouch - Whether to process multiple simultaneous touches
|
|
3802
|
+
* @param primaryTouchId - When working with single touches, only process the touch
|
|
3803
|
+
* with this identifier. Pass null to accept any touch (used during touchstart to
|
|
3804
|
+
* capture the first finger down).
|
|
3805
|
+
* @returns - Coordinates of the clientX and clientY properties from the touch/mouse event
|
|
3806
|
+
*/
|
|
3807
|
+
var getClientCoordinates = function (event, isTouchScrollEnabled, enableMultiTouch, primaryTouchId) {
|
|
3808
|
+
var _a;
|
|
3809
|
+
var touchEvent = event;
|
|
3810
|
+
if ((_a = touchEvent.changedTouches) === null || _a === void 0 ? void 0 : _a.length) {
|
|
3811
|
+
// This flag, if false, prevents touch events on the canvas default behavior
|
|
3812
|
+
// which may prevent scrolling if a drag motion on the canvas is performed
|
|
3813
|
+
if (!isTouchScrollEnabled && ["touchstart", "touchmove"].includes(event.type)) {
|
|
3814
|
+
event.preventDefault();
|
|
3815
|
+
}
|
|
3816
|
+
return getTouchCoordinates(touchEvent.changedTouches, enableMultiTouch, primaryTouchId);
|
|
3817
|
+
}
|
|
3818
|
+
return [
|
|
3819
|
+
{
|
|
3809
3820
|
clientX: event.clientX,
|
|
3810
3821
|
clientY: event.clientY,
|
|
3811
3822
|
identifier: 0,
|
|
3812
|
-
}
|
|
3813
|
-
|
|
3814
|
-
return coordinates;
|
|
3823
|
+
},
|
|
3824
|
+
];
|
|
3815
3825
|
};
|
|
3816
3826
|
/**
|
|
3817
3827
|
* Registers mouse move/up/down callback handlers on the canvas to send meaningful coordinates to
|
|
@@ -3843,7 +3853,15 @@ var registerTouchInteractions = function (_a) {
|
|
|
3843
3853
|
**/
|
|
3844
3854
|
var _prevEventType = null;
|
|
3845
3855
|
var _syntheticEventsActive = false;
|
|
3856
|
+
/**
|
|
3857
|
+
* When enableMultiTouch is false ("single-touch mode"), we track the identifier of the first finger that touched down.
|
|
3858
|
+
* All subsequent touch events are filtered to this identifier so that a second finger
|
|
3859
|
+
* moving cannot displace the tracked pointer position.
|
|
3860
|
+
* Reset to null when the primary finger lifts (or touchcancel is called)
|
|
3861
|
+
*/
|
|
3862
|
+
var _primaryTouchId = null;
|
|
3846
3863
|
var processEventCallback = function (event) {
|
|
3864
|
+
var _a;
|
|
3847
3865
|
// Exit early out of all synthetic mouse events
|
|
3848
3866
|
// https://stackoverflow.com/questions/9656990/how-to-prevent-simulated-mouse-events-in-mobile-browsers
|
|
3849
3867
|
// https://stackoverflow.com/questions/25572070/javascript-touchend-versus-click-dilemma
|
|
@@ -3862,7 +3880,15 @@ var registerTouchInteractions = function (_a) {
|
|
|
3862
3880
|
_prevEventType === "touchstart";
|
|
3863
3881
|
_prevEventType = event.type;
|
|
3864
3882
|
var boundingRect = event.currentTarget.getBoundingClientRect();
|
|
3865
|
-
|
|
3883
|
+
// On touchstart in single-touch mode, record the first new finger as the primary
|
|
3884
|
+
// touch if we aren't already tracking one.
|
|
3885
|
+
if (!enableMultiTouch && event.type === "touchstart" && _primaryTouchId === null) {
|
|
3886
|
+
var firstTouch = (_a = event.changedTouches) === null || _a === void 0 ? void 0 : _a[0];
|
|
3887
|
+
if (firstTouch) {
|
|
3888
|
+
_primaryTouchId = firstTouch.identifier;
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
var coordinateSets = getClientCoordinates(event, isTouchScrollEnabled, enableMultiTouch, enableMultiTouch ? null : _primaryTouchId);
|
|
3866
3892
|
var forwardMatrix = rive.computeAlignment(fit, alignment, {
|
|
3867
3893
|
minX: 0,
|
|
3868
3894
|
minY: 0,
|
|
@@ -3927,8 +3953,8 @@ var registerTouchInteractions = function (_a) {
|
|
|
3927
3953
|
stateMachine.pointerMove(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
|
|
3928
3954
|
});
|
|
3929
3955
|
};
|
|
3930
|
-
for (var
|
|
3931
|
-
var stateMachine = stateMachines_2[
|
|
3956
|
+
for (var _b = 0, stateMachines_2 = stateMachines; _b < stateMachines_2.length; _b++) {
|
|
3957
|
+
var stateMachine = stateMachines_2[_b];
|
|
3932
3958
|
_loop_2(stateMachine);
|
|
3933
3959
|
}
|
|
3934
3960
|
break;
|
|
@@ -3941,8 +3967,8 @@ var registerTouchInteractions = function (_a) {
|
|
|
3941
3967
|
stateMachine.pointerDown(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
|
|
3942
3968
|
});
|
|
3943
3969
|
};
|
|
3944
|
-
for (var
|
|
3945
|
-
var stateMachine = stateMachines_3[
|
|
3970
|
+
for (var _c = 0, stateMachines_3 = stateMachines; _c < stateMachines_3.length; _c++) {
|
|
3971
|
+
var stateMachine = stateMachines_3[_c];
|
|
3946
3972
|
_loop_3(stateMachine);
|
|
3947
3973
|
}
|
|
3948
3974
|
break;
|
|
@@ -3955,10 +3981,16 @@ var registerTouchInteractions = function (_a) {
|
|
|
3955
3981
|
stateMachine.pointerExit(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
|
|
3956
3982
|
});
|
|
3957
3983
|
};
|
|
3958
|
-
for (var
|
|
3959
|
-
var stateMachine = stateMachines_4[
|
|
3984
|
+
for (var _d = 0, stateMachines_4 = stateMachines; _d < stateMachines_4.length; _d++) {
|
|
3985
|
+
var stateMachine = stateMachines_4[_d];
|
|
3960
3986
|
_loop_4(stateMachine);
|
|
3961
3987
|
}
|
|
3988
|
+
// Release the primary touch lock once that finger lifts so the next
|
|
3989
|
+
// touchstart can claim a new primary finger.
|
|
3990
|
+
if (!enableMultiTouch &&
|
|
3991
|
+
coordinateSets.some(function (c) { return c.identifier === _primaryTouchId; })) {
|
|
3992
|
+
_primaryTouchId = null;
|
|
3993
|
+
}
|
|
3962
3994
|
break;
|
|
3963
3995
|
}
|
|
3964
3996
|
case "mouseup": {
|
|
@@ -3967,8 +3999,8 @@ var registerTouchInteractions = function (_a) {
|
|
|
3967
3999
|
stateMachine.pointerUp(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
|
|
3968
4000
|
});
|
|
3969
4001
|
};
|
|
3970
|
-
for (var
|
|
3971
|
-
var stateMachine = stateMachines_5[
|
|
4002
|
+
for (var _e = 0, stateMachines_5 = stateMachines; _e < stateMachines_5.length; _e++) {
|
|
4003
|
+
var stateMachine = stateMachines_5[_e];
|
|
3972
4004
|
_loop_5(stateMachine);
|
|
3973
4005
|
}
|
|
3974
4006
|
break;
|
|
@@ -3976,6 +4008,9 @@ var registerTouchInteractions = function (_a) {
|
|
|
3976
4008
|
default:
|
|
3977
4009
|
}
|
|
3978
4010
|
};
|
|
4011
|
+
var touchCancelCallback = function () {
|
|
4012
|
+
_primaryTouchId = null;
|
|
4013
|
+
};
|
|
3979
4014
|
var callback = processEventCallback.bind(_this);
|
|
3980
4015
|
canvas.addEventListener("mouseover", callback);
|
|
3981
4016
|
canvas.addEventListener("mouseout", callback);
|
|
@@ -3989,6 +4024,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
3989
4024
|
passive: isTouchScrollEnabled,
|
|
3990
4025
|
});
|
|
3991
4026
|
canvas.addEventListener("touchend", callback);
|
|
4027
|
+
canvas.addEventListener("touchcancel", touchCancelCallback);
|
|
3992
4028
|
return function () {
|
|
3993
4029
|
canvas.removeEventListener("mouseover", callback);
|
|
3994
4030
|
canvas.removeEventListener("mouseout", callback);
|
|
@@ -3998,6 +4034,7 @@ var registerTouchInteractions = function (_a) {
|
|
|
3998
4034
|
canvas.removeEventListener("touchmove", callback);
|
|
3999
4035
|
canvas.removeEventListener("touchstart", callback);
|
|
4000
4036
|
canvas.removeEventListener("touchend", callback);
|
|
4037
|
+
canvas.removeEventListener("touchcancel", touchCancelCallback);
|
|
4001
4038
|
};
|
|
4002
4039
|
};
|
|
4003
4040
|
|