@rive-app/canvas 2.19.3 → 2.19.5
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 +83 -44
- 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
|
@@ -349,10 +349,10 @@ m.onRuntimeInitialized = function() {
|
|
|
349
349
|
function c() {
|
|
350
350
|
0 < M.length && (ka.Qb(w.drawWidth(), w.drawHeight(), M, T, ca), M = [], ca = T = 0, w.reset(512, 512));
|
|
351
351
|
for (const q of D) {
|
|
352
|
-
for (const z of q.
|
|
352
|
+
for (const z of q.H) {
|
|
353
353
|
z();
|
|
354
354
|
}
|
|
355
|
-
q.
|
|
355
|
+
q.H = [];
|
|
356
356
|
}
|
|
357
357
|
D.clear();
|
|
358
358
|
}
|
|
@@ -482,32 +482,32 @@ m.onRuntimeInitialized = function() {
|
|
|
482
482
|
this.S = [1, 0, 0, 1, 0, 0];
|
|
483
483
|
this.C = q.getContext("2d");
|
|
484
484
|
this.Ua = q;
|
|
485
|
-
this.
|
|
485
|
+
this.H = [];
|
|
486
486
|
}, save:function() {
|
|
487
487
|
this.S.push(...this.S.slice(this.S.length - 6));
|
|
488
|
-
this.
|
|
488
|
+
this.H.push(this.C.save.bind(this.C));
|
|
489
489
|
}, restore:function() {
|
|
490
490
|
const q = this.S.length - 6;
|
|
491
491
|
if (6 > q) {
|
|
492
492
|
throw "restore() called without matching save().";
|
|
493
493
|
}
|
|
494
494
|
this.S.splice(q);
|
|
495
|
-
this.
|
|
495
|
+
this.H.push(this.C.restore.bind(this.C));
|
|
496
496
|
}, transform:function(q, z, G, H, C, I) {
|
|
497
497
|
const J = this.S, K = J.length - 6;
|
|
498
498
|
J.splice(K, 6, J[K] * q + J[K + 2] * z, J[K + 1] * q + J[K + 3] * z, J[K] * G + J[K + 2] * H, J[K + 1] * G + J[K + 3] * H, J[K] * C + J[K + 2] * I + J[K + 4], J[K + 1] * C + J[K + 3] * I + J[K + 5]);
|
|
499
|
-
this.
|
|
499
|
+
this.H.push(this.C.transform.bind(this.C, q, z, G, H, C, I));
|
|
500
500
|
}, rotate:function(q) {
|
|
501
501
|
const z = Math.sin(q);
|
|
502
502
|
q = Math.cos(q);
|
|
503
503
|
this.transform(q, z, -z, q, 0, 0);
|
|
504
504
|
}, _drawPath:function(q, z) {
|
|
505
|
-
this.
|
|
505
|
+
this.H.push(z.draw.bind(z, this.C, q.T, q.Va === x ? "evenodd" : "nonzero"));
|
|
506
506
|
}, _drawRiveImage:function(q, z, G) {
|
|
507
507
|
var H = q.Fb;
|
|
508
508
|
if (H) {
|
|
509
509
|
var C = this.C, I = a(z);
|
|
510
|
-
this.
|
|
510
|
+
this.H.push(function() {
|
|
511
511
|
C.globalCompositeOperation = I;
|
|
512
512
|
C.globalAlpha = G;
|
|
513
513
|
C.drawImage(H, 0, 0);
|
|
@@ -544,7 +544,7 @@ m.onRuntimeInitialized = function() {
|
|
|
544
544
|
T += H.length;
|
|
545
545
|
ca += I.length;
|
|
546
546
|
var za = this.C, qd = a(z);
|
|
547
|
-
this.
|
|
547
|
+
this.H.push(function() {
|
|
548
548
|
za.save();
|
|
549
549
|
za.resetTransform();
|
|
550
550
|
za.globalCompositeOperation = qd;
|
|
@@ -555,10 +555,10 @@ m.onRuntimeInitialized = function() {
|
|
|
555
555
|
});
|
|
556
556
|
}
|
|
557
557
|
}, _clipPath:function(q) {
|
|
558
|
-
this.
|
|
558
|
+
this.H.push(this.C.clip.bind(this.C, q.T, q.Va === x ? "evenodd" : "nonzero"));
|
|
559
559
|
}, clear:function() {
|
|
560
560
|
D.add(this);
|
|
561
|
-
this.
|
|
561
|
+
this.H.push(this.C.clearRect.bind(this.C, 0, 0, this.Ua.width, this.Ua.height));
|
|
562
562
|
}, flush:function() {
|
|
563
563
|
}, translate:function(q, z) {
|
|
564
564
|
this.transform(1, 0, 0, 1, q, z);
|
|
@@ -576,13 +576,15 @@ m.onRuntimeInitialized = function() {
|
|
|
576
576
|
throw Error("RiveException: Method call to '" + C + "()' is not allowed, as the renderer cannot immediately pass through the return values of any canvas 2d context methods.");
|
|
577
577
|
}
|
|
578
578
|
return function(...I) {
|
|
579
|
-
z.
|
|
579
|
+
z.H.push(G[C].bind(G, ...I));
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
582
|
return H[C];
|
|
583
583
|
}, set(H, C, I) {
|
|
584
584
|
if (C in G) {
|
|
585
|
-
return
|
|
585
|
+
return z.H.push(() => {
|
|
586
|
+
G[C] = I;
|
|
587
|
+
}), !0;
|
|
586
588
|
}
|
|
587
589
|
},});
|
|
588
590
|
};
|
|
@@ -736,16 +738,16 @@ function Ya(a, b) {
|
|
|
736
738
|
return Xa(c, a, b);
|
|
737
739
|
}));
|
|
738
740
|
}
|
|
739
|
-
var Za, $a, db = {
|
|
741
|
+
var Za, $a, db = {434540:(a, b, c, d, e) => {
|
|
740
742
|
if ("undefined" === typeof window || void 0 === (window.AudioContext || window.webkitAudioContext)) {
|
|
741
743
|
return 0;
|
|
742
744
|
}
|
|
743
745
|
if ("undefined" === typeof window.h) {
|
|
744
746
|
window.h = {Aa:0};
|
|
745
|
-
window.h.
|
|
746
|
-
window.h.
|
|
747
|
-
window.h.
|
|
748
|
-
window.h.
|
|
747
|
+
window.h.I = {};
|
|
748
|
+
window.h.I.ya = a;
|
|
749
|
+
window.h.I.capture = b;
|
|
750
|
+
window.h.I.La = c;
|
|
749
751
|
window.h.ga = {};
|
|
750
752
|
window.h.ga.stopped = d;
|
|
751
753
|
window.h.ga.xb = e;
|
|
@@ -783,7 +785,7 @@ var Za, $a, db = {433516:(a, b, c, d, e) => {
|
|
|
783
785
|
f.unlock = function() {
|
|
784
786
|
for (var g = 0; g < f.D.length; ++g) {
|
|
785
787
|
var n = f.D[g];
|
|
786
|
-
null != n && null != n.
|
|
788
|
+
null != n && null != n.J && n.state === f.ga.xb && n.J.resume().then(() => {
|
|
787
789
|
ab(n.pb);
|
|
788
790
|
}, p => {
|
|
789
791
|
console.error("Failed to resume audiocontext", p);
|
|
@@ -799,9 +801,9 @@ var Za, $a, db = {433516:(a, b, c, d, e) => {
|
|
|
799
801
|
}
|
|
800
802
|
window.h.Aa += 1;
|
|
801
803
|
return 1;
|
|
802
|
-
},
|
|
804
|
+
}, 436718:() => {
|
|
803
805
|
"undefined" !== typeof window.h && (--window.h.Aa, 0 === window.h.Aa && delete window.h);
|
|
804
|
-
},
|
|
806
|
+
}, 436882:() => void 0 !== navigator.mediaDevices && void 0 !== navigator.mediaDevices.getUserMedia, 436986:() => {
|
|
805
807
|
try {
|
|
806
808
|
var a = new (window.AudioContext || window.webkitAudioContext)(), b = a.sampleRate;
|
|
807
809
|
a.close();
|
|
@@ -809,23 +811,23 @@ var Za, $a, db = {433516:(a, b, c, d, e) => {
|
|
|
809
811
|
} catch (c) {
|
|
810
812
|
return 0;
|
|
811
813
|
}
|
|
812
|
-
},
|
|
814
|
+
}, 437157:(a, b, c, d, e, f) => {
|
|
813
815
|
if ("undefined" === typeof window.h) {
|
|
814
816
|
return -1;
|
|
815
817
|
}
|
|
816
818
|
var g = {}, n = {};
|
|
817
|
-
a == window.h.
|
|
818
|
-
g.
|
|
819
|
-
g.
|
|
819
|
+
a == window.h.I.ya && 0 != c && (n.sampleRate = c);
|
|
820
|
+
g.J = new (window.AudioContext || window.webkitAudioContext)(n);
|
|
821
|
+
g.J.suspend();
|
|
820
822
|
g.state = window.h.ga.stopped;
|
|
821
823
|
c = 0;
|
|
822
|
-
a != window.h.
|
|
823
|
-
g.Z = g.
|
|
824
|
+
a != window.h.I.ya && (c = b);
|
|
825
|
+
g.Z = g.J.createScriptProcessor(d, c, b);
|
|
824
826
|
g.Z.onaudioprocess = function(p) {
|
|
825
827
|
if (null == g.sa || 0 == g.sa.length) {
|
|
826
828
|
g.sa = new Float32Array(Fa.buffer, e, d * b);
|
|
827
829
|
}
|
|
828
|
-
if (a == window.h.
|
|
830
|
+
if (a == window.h.I.capture || a == window.h.I.La) {
|
|
829
831
|
for (var l = 0; l < b; l += 1) {
|
|
830
832
|
for (var u = p.inputBuffer.getChannelData(l), v = g.sa, x = 0; x < d; x += 1) {
|
|
831
833
|
v[x * b + l] = u[x];
|
|
@@ -833,7 +835,7 @@ var Za, $a, db = {433516:(a, b, c, d, e) => {
|
|
|
833
835
|
}
|
|
834
836
|
bb(f, d, e);
|
|
835
837
|
}
|
|
836
|
-
if (a == window.h.
|
|
838
|
+
if (a == window.h.I.ya || a == window.h.I.La) {
|
|
837
839
|
for (cb(f, d, e), l = 0; l < p.outputBuffer.numberOfChannels; ++l) {
|
|
838
840
|
for (u = p.outputBuffer.getChannelData(l), v = g.sa, x = 0; x < d; x += 1) {
|
|
839
841
|
u[x] = v[x * b + l];
|
|
@@ -845,33 +847,33 @@ var Za, $a, db = {433516:(a, b, c, d, e) => {
|
|
|
845
847
|
}
|
|
846
848
|
}
|
|
847
849
|
};
|
|
848
|
-
a != window.h.
|
|
849
|
-
g.Da = g.
|
|
850
|
+
a != window.h.I.capture && a != window.h.I.La || navigator.mediaDevices.getUserMedia({audio:!0, video:!1}).then(function(p) {
|
|
851
|
+
g.Da = g.J.createMediaStreamSource(p);
|
|
850
852
|
g.Da.connect(g.Z);
|
|
851
|
-
g.Z.connect(g.
|
|
853
|
+
g.Z.connect(g.J.destination);
|
|
852
854
|
}).catch(function(p) {
|
|
853
855
|
console.log("Failed to get user media: " + p);
|
|
854
856
|
});
|
|
855
|
-
a == window.h.
|
|
857
|
+
a == window.h.I.ya && g.Z.connect(g.J.destination);
|
|
856
858
|
g.pb = f;
|
|
857
859
|
return window.h.yc(g);
|
|
858
|
-
},
|
|
860
|
+
}, 440034:a => window.h.ra(a).J.sampleRate, 440107:a => {
|
|
859
861
|
a = window.h.ra(a);
|
|
860
862
|
void 0 !== a.Z && (a.Z.onaudioprocess = function() {
|
|
861
863
|
}, a.Z.disconnect(), a.Z = void 0);
|
|
862
864
|
void 0 !== a.Da && (a.Da.disconnect(), a.Da = void 0);
|
|
863
|
-
a.
|
|
864
|
-
a.
|
|
865
|
+
a.J.close();
|
|
866
|
+
a.J = void 0;
|
|
865
867
|
a.pb = void 0;
|
|
866
|
-
},
|
|
868
|
+
}, 440507:a => {
|
|
867
869
|
window.h.Cb(a);
|
|
868
|
-
},
|
|
870
|
+
}, 440557:a => {
|
|
869
871
|
a = window.h.ra(a);
|
|
870
|
-
a.
|
|
872
|
+
a.J.resume();
|
|
871
873
|
a.state = window.h.ga.xb;
|
|
872
|
-
},
|
|
874
|
+
}, 440696:a => {
|
|
873
875
|
a = window.h.ra(a);
|
|
874
|
-
a.
|
|
876
|
+
a.J.suspend();
|
|
875
877
|
a.state = window.h.ga.stopped;
|
|
876
878
|
}}, eb = a => {
|
|
877
879
|
for (; 0 < a.length;) {
|
|
@@ -3355,7 +3357,7 @@ Zd();
|
|
|
3355
3357
|
/* 2 */
|
|
3356
3358
|
/***/ ((module) => {
|
|
3357
3359
|
|
|
3358
|
-
module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.19.
|
|
3360
|
+
module.exports = JSON.parse('{"name":"@rive-app/canvas","version":"2.19.5","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"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
3359
3361
|
|
|
3360
3362
|
/***/ }),
|
|
3361
3363
|
/* 3 */
|
|
@@ -3565,7 +3567,40 @@ var registerTouchInteractions = function (_a) {
|
|
|
3565
3567
|
typeof window === "undefined") {
|
|
3566
3568
|
return null;
|
|
3567
3569
|
}
|
|
3570
|
+
/**
|
|
3571
|
+
* After a touchend event, some browsers may fire synthetic mouse events
|
|
3572
|
+
* (mouseover, mousedown, mousemove, mouseup) if the touch interaction did not cause
|
|
3573
|
+
* any default action (such as scrolling).
|
|
3574
|
+
*
|
|
3575
|
+
* This is done to simulate the behavior of a mouse for applications that do not support
|
|
3576
|
+
* touch events.
|
|
3577
|
+
*
|
|
3578
|
+
* We're keeping track of the previous event to not send the synthetic mouse events if the
|
|
3579
|
+
* touch event was a click (touchstart -> touchend).
|
|
3580
|
+
*
|
|
3581
|
+
* This is only needed when `isTouchScrollEnabled` is false
|
|
3582
|
+
* When true, `preventDefault()` is called which prevents this behaviour.
|
|
3583
|
+
**/
|
|
3584
|
+
var _prevEventType = null;
|
|
3585
|
+
var _syntheticEventsActive = false;
|
|
3568
3586
|
var processEventCallback = function (event) {
|
|
3587
|
+
// Exit early out of all synthetic mouse events
|
|
3588
|
+
// https://stackoverflow.com/questions/9656990/how-to-prevent-simulated-mouse-events-in-mobile-browsers
|
|
3589
|
+
// https://stackoverflow.com/questions/25572070/javascript-touchend-versus-click-dilemma
|
|
3590
|
+
if (_syntheticEventsActive && event instanceof MouseEvent) {
|
|
3591
|
+
// Synthetic event finished
|
|
3592
|
+
if (event.type == "mouseup") {
|
|
3593
|
+
_syntheticEventsActive = false;
|
|
3594
|
+
}
|
|
3595
|
+
return;
|
|
3596
|
+
}
|
|
3597
|
+
// Test if it's a "touch click". This could cause the browser to send
|
|
3598
|
+
// synthetic mouse events.
|
|
3599
|
+
_syntheticEventsActive =
|
|
3600
|
+
isTouchScrollEnabled &&
|
|
3601
|
+
event.type === "touchend" &&
|
|
3602
|
+
_prevEventType === "touchstart";
|
|
3603
|
+
_prevEventType = event.type;
|
|
3569
3604
|
var boundingRect = event.currentTarget.getBoundingClientRect();
|
|
3570
3605
|
var _a = getClientCoordinates(event, isTouchScrollEnabled), clientX = _a.clientX, clientY = _a.clientY;
|
|
3571
3606
|
if (!clientX && !clientY) {
|
|
@@ -3645,8 +3680,12 @@ var registerTouchInteractions = function (_a) {
|
|
|
3645
3680
|
canvas.addEventListener("mousemove", callback);
|
|
3646
3681
|
canvas.addEventListener("mousedown", callback);
|
|
3647
3682
|
canvas.addEventListener("mouseup", callback);
|
|
3648
|
-
canvas.addEventListener("touchmove", callback
|
|
3649
|
-
|
|
3683
|
+
canvas.addEventListener("touchmove", callback, {
|
|
3684
|
+
passive: isTouchScrollEnabled,
|
|
3685
|
+
});
|
|
3686
|
+
canvas.addEventListener("touchstart", callback, {
|
|
3687
|
+
passive: isTouchScrollEnabled,
|
|
3688
|
+
});
|
|
3650
3689
|
canvas.addEventListener("touchend", callback);
|
|
3651
3690
|
return function () {
|
|
3652
3691
|
canvas.removeEventListener("mouseover", callback);
|