@rive-app/canvas-lite 2.49.1 → 2.49.3
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 +1 -0
- package/rive.js +148 -7
- package/rive.js.map +1 -1
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +5 -0
- package/rive_fallback.wasm +0 -0
- package/utils/index.d.ts +1 -0
- package/utils/replayPacer.d.ts +24 -0
package/package.json
CHANGED
package/rive.d.ts
CHANGED
|
@@ -883,6 +883,7 @@ export declare class Rive {
|
|
|
883
883
|
private lastRenderTime;
|
|
884
884
|
private static batchStart;
|
|
885
885
|
private frameRequestId;
|
|
886
|
+
private replayPacer;
|
|
886
887
|
/**
|
|
887
888
|
* Used be draw to track when a second of active rendering time has passed.
|
|
888
889
|
* Used for debugging purposes
|
package/rive.js
CHANGED
|
@@ -528,7 +528,7 @@ w)a.canvas.width=q,a.canvas.height=w;a.viewport(0,0,q,w);a.disable(a.SCISSOR_TES
|
|
|
528
528
|
console.assert(E==8*C);E=A.push(G);g!=E&&(a.bufferData(a.ELEMENT_ARRAY_BUFFER,2*E,a.DYNAMIC_DRAW),g=E);H=0;for(var R of p)a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,H,R.N.indices),H+=2*R.N.indices.length;console.assert(H==2*G);R=0;L=!1;E=H=0;for(const I of p){p=I.N;p.image.Ca!=R&&(a.bindTexture(a.TEXTURE_2D,p.image.V||null),R=p.image.Ca);I.Za?(a.scissor(I.qb,w-I.rb-I.Xa,I.Vb,I.Xa),L||(a.enable(a.SCISSOR_TEST),L=!0)):L&&(a.disable(a.SCISSOR_TEST),L=!1);const S=I.pb,Y=2/q,ca=-2/w;a.uniform4f(f,S[0]*Y,S[1]*
|
|
529
529
|
ca,S[2]*Y,S[3]*ca);a.uniform2f(m,S[4]*Y-1,S[5]*ca+1);a.vertexAttribPointer(0,2,a.FLOAT,!1,0,E);a.vertexAttribPointer(1,2,a.FLOAT,!1,0,E+4*C);a.drawElements(a.TRIANGLES,p.indices.length,a.UNSIGNED_SHORT,H);E+=4*p.pa.length;H+=2*p.indices.length}console.assert(E==4*C);console.assert(H==2*G)}};this.canvas=function(){return b()&&a.canvas}};class ua{constructor(){this.eb=!1}canvas(){return oa.canvas()||null}}const va=new qa;
|
|
530
530
|
function wa(b,a,c,d,f,m){const h=new DOMMatrix;h.a=b;h.b=a;h.c=c;h.d=d;h.e=f;h.f=m;return h}const xa="createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "),ya=l.onRuntimeInitialized;
|
|
531
|
-
l.onRuntimeInitialized=function(){function b(e){switch(e){case z.srcOver:return"source-over";case z.
|
|
531
|
+
l.onRuntimeInitialized=function(){function b(e){switch(e){case z.srcOver:return"source-over";case z.additive:return"lighter";case z.screen:return"screen";case z.overlay:return"overlay";case z.darken:return"darken";case z.lighten:return"lighten";case z.colorDodge:return"color-dodge";case z.colorBurn:return"color-burn";case z.hardLight:return"hard-light";case z.softLight:return"soft-light";case z.difference:return"difference";case z.exclusion:return"exclusion";case z.multiply:return"multiply";case z.hue:return"hue";
|
|
532
532
|
case z.saturation:return"saturation";case z.color:return"color";case z.luminosity:return"luminosity"}}function a(e){return"rgba("+((16711680&e)>>>16)+","+((65280&e)>>>8)+","+((255&e)>>>0)+","+((4278190080&e)>>>24)/255+")"}function c(e,k,t,u,v){return{fb:e,gb:k,Sa:t,Ta:u,type:v,Ka:[],T:null}}function d(e,k,t,u){if(k.Y===H&&!(0<k.Z))return null;t=1===t;return{Ha:e.La(t?k.xa:null),gradientTransform:t?k.ca:null,Ub:t?k.Z*k.Ba:k.Z,fillRule:e.ha===L?"evenodd":"nonzero",opacity:u,style:k.Y,color:k.sa,Wa:k.I,
|
|
533
533
|
tb:k.ra,join:k.ya,sb:k.qa}}function f(e,k){return k.Y!==H||0<k.Z?{path:e.kb(e.ha),Ga:k.lb()}:null}function m(){if(0!==I.m.length){var e=na();if(0!==e){var k=Math.min(I.na.push(I.i.drawWidth()),e);e=Math.min(I.$.push(I.i.drawHeight()),e);oa.Ab(k,e,I.m)}}for(const t of ta){for(const u of t.G)u();t.G=[]}ta.clear();for(const t of I.m)t.Pb();I.m=[];I.i&&I.i.reset(512,512)}ya&&ya();var h=l.RenderPaintStyle,g=l.FillRule;const n=l.RenderPath,r=l.RenderPaint,A=l.Renderer,q=l.StrokeCap,w=l.StrokeJoin,p=l.StrokePosition,
|
|
534
534
|
z=l.BlendMode,C=l.ImageFilter,G=l.ImageWrap,E=h.fill,H=h.stroke,L=g.evenOdd,R=g.nonZero,I=va,S=I.M;let Y=1;var ca=l.RenderImage.extend("CanvasRenderImage",{__construct:function({ea:e,oa:k}={}){this.__parent.__construct.call(this);this.Ca=Y;Y=Y+1&2147483647||1;this.ea=e;this.oa=k;this.V=this.Pa=this.ia=this.wa=null},__destruct:function(){this.V&&(oa.xb(this.V),this.V=null);this.ia&&URL.revokeObjectURL(this.ia);this.__parent.__destruct.call(this)},decode:function(e){var k=this;k.oa&&k.oa(k);var t=new Image;
|
|
@@ -537,7 +537,7 @@ y:k}),this.path.lineTo(e.x,e.y)):this.path.lineTo(e,k)}wb(e,k,t,u,v,B){this.m=nu
|
|
|
537
537
|
this.m||this.ua||(this.M(),this.ua=!0)}dispose(){}}class sa{constructor(e){this.Lb=e;this.$=this.M=0;this.m=null;this.i=e(null)}clear(){this.na(null)}Da(e,k){for(((null===k?null!==this.m:null===this.m||this.m.a!==k.a||this.m.b!==k.b||this.m.c!==k.c||this.m.d!==k.d||this.m.e!==k.e||this.m.f!==k.f)||this.$<e.length&&(0<this.M||this.i.ua))&&this.na(k);this.$<e.length;)e[this.$++](this.i);this.i.Va();this.M++;return this.i.path}Ja(e){null!==this.i&&e===this.i.path&&this.M--}dispose(){this.i.dispose();
|
|
538
538
|
this.i=null}na(e){this.i.dispose();this.$=this.M=0;this.m=e;this.i=this.Lb(e)}}var Ea=n.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this);this.W=[];this.ja=new sa(e=>new ra(e));this.ka=new sa(e=>new ra(e));this.X=new Map;this.ha=R;this.va=!1},__destruct:function(){this.ja.dispose();this.ka.dispose();for(const e of this.X.values())e.dispose();this.X.clear();this.__parent.__destruct.call(this)},rewind:function(){this.W.length=0;this.ja.clear();this.ka.clear();for(const e of this.X.values())e.clear();
|
|
539
539
|
this.va=!1},addPath:function(e,k,t,u,v,B,D){const y=e.W.slice();this.ba(x=>x.addPath(y,k,t,u,v,B,D))},fillRule:function(e){this.ha=e},moveTo:function(e,k){this.va=!0;this.ba(t=>t.moveTo(e,k))},lineTo:function(e,k){this.Oa();this.ba(t=>t.lineTo(e,k))},cubicTo:function(e,k,t,u,v,B){this.Oa();this.ba(D=>D.wb(e,k,t,u,v,B))},close:function(){this.ba(e=>e.close())},Oa:function(){this.va||this.moveTo(0,0)},ba:function(e){this.W.push(e)},La:function(e){e=null===e?this.ja.Da(this.W,null):this.ka.Da(this.W,
|
|
540
|
-
e);e.ref&&e.ref();return e},kb:function(e){var k=this.X.get(e);void 0===k&&(k=new sa(()=>S.
|
|
540
|
+
e);e.ref&&e.ref();return e},kb:function(e){var k=this.X.get(e);void 0===k&&(k=new sa(()=>S.Yb(e)),this.X.set(e,k));k=k.Da(this.W,null);k.ref&&k.ref();return k},za:function(e){this.ja.Ja(e);this.ka.Ja(e);for(const k of this.X.values())k.Ja(e);e.unref&&e.unref()}});const bc=c(0,0,0,0,0);var dc=r.extend("CanvasRenderPaint",{__construct:function(){this.__parent.__construct.call(this);this.Y=E;this.sa=4278190080;this.Z=1;this.ya=w.miter;this.ra=q.butt;this.Aa=p.center;this.ta=0;this.qa=b(z.srcOver);this.xa=
|
|
541
541
|
this.A=this.ca=this.I=null;this.Ba=1;this.B=0;this.S=null;this.Qa=-1},__destruct:function(){null!==this.S&&(l.unrefWebGL2Paint(this.S),this.S=null);this.__parent.__destruct.call(this)},color:function(e){this.sa=e;this.I=null;this.B++},thickness:function(e){this.Z=Math.abs(e);this.B++},join:function(e){this.ya=e;this.B++},cap:function(e){this.ra=e;this.B++},strokePosition:function(e){this.Aa=e;this.B++},feather:function(e){this.ta=Math.abs(e);this.B++},style:function(e){this.Y=e;this.B++},blendMode:function(e){this.qa=
|
|
542
542
|
b(e);this.B++},clearGradient:function(){this.I=null;this.B++},linearGradient:function(e,k,t,u){this.I=c(e,k,t,u,0);this.B++},radialGradient:function(e,k,t,u){this.I=c(e,k,t,u,1);this.B++},angularGradient:function(){this.I=c(0,0,0,0,2);this.B++},addStop:function(e,k){this.I.Ka.push({color:e,stop:k});this.I.T=null;this.B++},modulatedImage:function(e,k,t,u,v,B,D,y,x,J){const K=e.wa;K?this.A={image:K,jb:e.Pa,filter:k,Wb:t,Xb:u,transform:wa(v,B,D,y,x,J)}:this.A=null},completeGradient:function(){},_setGradientTransform:function(e,
|
|
543
543
|
k,t,u,v,B,D,y,x,J,K,P,T){1===e&&0===k&&0===t&&1===u&&0===v&&0===B?this.xa=this.ca=null:(this.ca=wa(e,k,t,u,v,B),this.xa=wa(D,y,x,J,K,P));this.Ba=T;this.B++},lb:function(){if(this.Qa!==this.B){null!==this.S&&l.unrefWebGL2Paint(this.S);const k=null!==this.I?this.I:bc;let t=null,u=null;if(null!==this.I){var e=k.Ka;t=new Uint32Array(e.length);u=new Float32Array(e.length);for(let ja=0,cc=e.length;ja<cc;ja++)t[ja]=e[ja].color,u[ja]=e[ja].stop}e=null;let v=C.bilinear,B=G.clamp,D=G.clamp,y=1,x=0,J=0,K=1,
|
|
@@ -626,7 +626,7 @@ Lc=await (async function(){function b(c){c=Lc=c.exports;pb=c.free;Jc=c.malloc;ob
|
|
|
626
626
|
/***/ ((module) => {
|
|
627
627
|
|
|
628
628
|
"use strict";
|
|
629
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.49.
|
|
629
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.49.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","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
|
|
630
630
|
|
|
631
631
|
/***/ }),
|
|
632
632
|
/* 7 */
|
|
@@ -2778,6 +2778,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2778
2778
|
/* harmony export */ ImageAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_4__.ImageAssetWrapper),
|
|
2779
2779
|
/* harmony export */ ImageWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_4__.ImageWrapper),
|
|
2780
2780
|
/* harmony export */ KeyboardInteractions: () => (/* reexport safe */ _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__.KeyboardInteractions),
|
|
2781
|
+
/* harmony export */ ReplayPacer: () => (/* reexport safe */ _replayPacer__WEBPACK_IMPORTED_MODULE_6__.ReplayPacer),
|
|
2781
2782
|
/* harmony export */ RiveFont: () => (/* reexport safe */ _riveFont__WEBPACK_IMPORTED_MODULE_5__.RiveFont),
|
|
2782
2783
|
/* harmony export */ createFinalization: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_4__.createFinalization),
|
|
2783
2784
|
/* harmony export */ finalizationRegistry: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_4__.finalizationRegistry),
|
|
@@ -2790,6 +2791,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2790
2791
|
/* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(20);
|
|
2791
2792
|
/* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(21);
|
|
2792
2793
|
/* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(22);
|
|
2794
|
+
/* harmony import */ var _replayPacer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23);
|
|
2795
|
+
|
|
2793
2796
|
|
|
2794
2797
|
|
|
2795
2798
|
|
|
@@ -5224,6 +5227,138 @@ var RiveFont = /** @class */ (function () {
|
|
|
5224
5227
|
|
|
5225
5228
|
|
|
5226
5229
|
|
|
5230
|
+
/***/ }),
|
|
5231
|
+
/* 23 */
|
|
5232
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
5233
|
+
|
|
5234
|
+
"use strict";
|
|
5235
|
+
__webpack_require__.r(__webpack_exports__);
|
|
5236
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5237
|
+
/* harmony export */ ReplayPacer: () => (/* binding */ ReplayPacer)
|
|
5238
|
+
/* harmony export */ });
|
|
5239
|
+
var kRefreshSamples = 15;
|
|
5240
|
+
// The frames the worker's replay time averages over, plus the three still in
|
|
5241
|
+
// flight when the cadence changes.
|
|
5242
|
+
var kSettleFrames = 12;
|
|
5243
|
+
var kProbeAfterMs = 1000;
|
|
5244
|
+
var kMaxProbeAfterMs = 16000;
|
|
5245
|
+
// A worker only slightly slower than its cadence fills its queue now and then,
|
|
5246
|
+
// a worker that keeps up almost never.
|
|
5247
|
+
var kBackupWindow = 60;
|
|
5248
|
+
var kSaturatedBackups = 3;
|
|
5249
|
+
var median = function (values) {
|
|
5250
|
+
var sorted = values.slice().sort(function (a, b) { return a - b; });
|
|
5251
|
+
return sorted[sorted.length >> 1];
|
|
5252
|
+
};
|
|
5253
|
+
/**
|
|
5254
|
+
* Paces recording to a replay worker slower than the display. Recording as
|
|
5255
|
+
* soon as its queue frees sends frames in bursts, so instead they go out every
|
|
5256
|
+
* N refreshes, with N following the worker's recent replay time.
|
|
5257
|
+
*/
|
|
5258
|
+
var ReplayPacer = /** @class */ (function () {
|
|
5259
|
+
function ReplayPacer() {
|
|
5260
|
+
this.lastTime = 0;
|
|
5261
|
+
this.lastRecord = 0;
|
|
5262
|
+
this.intervals = [];
|
|
5263
|
+
this.divisor = 1;
|
|
5264
|
+
// Frames recorded since the divisor changed, which the replay time still
|
|
5265
|
+
// averages in.
|
|
5266
|
+
this.settle = 0;
|
|
5267
|
+
this.nextProbe = 0;
|
|
5268
|
+
this.probing = false;
|
|
5269
|
+
// Failed probes back off, since each one costs a few uneven frames.
|
|
5270
|
+
this.probeAfter = kProbeAfterMs;
|
|
5271
|
+
// Whether the worker's queue filled since the last decision.
|
|
5272
|
+
this.backedUp = false;
|
|
5273
|
+
this.recentBackups = [];
|
|
5274
|
+
}
|
|
5275
|
+
/**
|
|
5276
|
+
* Called on every animation frame. Returns whether this one should record,
|
|
5277
|
+
* given the worker's replay time and whether its queue has room.
|
|
5278
|
+
*/
|
|
5279
|
+
ReplayPacer.prototype.shouldRecord = function (time, replayMs, accepts) {
|
|
5280
|
+
if (this.lastTime && time > this.lastTime) {
|
|
5281
|
+
this.intervals.push(time - this.lastTime);
|
|
5282
|
+
if (this.intervals.length > kRefreshSamples) {
|
|
5283
|
+
this.intervals.shift();
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
this.lastTime = time;
|
|
5287
|
+
if (!accepts) {
|
|
5288
|
+
// A canvas the worker has yet to take refuses frames too.
|
|
5289
|
+
if (replayMs > 0) {
|
|
5290
|
+
this.backedUp = true;
|
|
5291
|
+
}
|
|
5292
|
+
return false;
|
|
5293
|
+
}
|
|
5294
|
+
if (replayMs > 0 && this.intervals.length > 0) {
|
|
5295
|
+
var refresh = median(this.intervals);
|
|
5296
|
+
if (this.settle === 0) {
|
|
5297
|
+
this.adapt(time, replayMs / refresh);
|
|
5298
|
+
}
|
|
5299
|
+
if (this.divisor > 1 &&
|
|
5300
|
+
time - this.lastRecord < (this.divisor - 0.5) * refresh) {
|
|
5301
|
+
return false;
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5304
|
+
this.lastRecord = time;
|
|
5305
|
+
this.settle = Math.max(0, this.settle - 1);
|
|
5306
|
+
return true;
|
|
5307
|
+
};
|
|
5308
|
+
ReplayPacer.prototype.adapt = function (time, ratio) {
|
|
5309
|
+
var divisor = this.divisor;
|
|
5310
|
+
var backedUp = this.backedUp;
|
|
5311
|
+
this.backedUp = false;
|
|
5312
|
+
this.recentBackups.push(backedUp);
|
|
5313
|
+
if (this.recentBackups.length > kBackupWindow) {
|
|
5314
|
+
this.recentBackups.shift();
|
|
5315
|
+
}
|
|
5316
|
+
var saturated = this.recentBackups.filter(Boolean).length >= kSaturatedBackups;
|
|
5317
|
+
var lagging = ratio > divisor * 1.1;
|
|
5318
|
+
// A worker that keeps up never fills its queue, however long each frame
|
|
5319
|
+
// takes to finish, so only a lag with a full queue slows the cadence. A
|
|
5320
|
+
// probe fails on either, since it settled at the new cadence.
|
|
5321
|
+
if (this.probing
|
|
5322
|
+
? lagging || backedUp
|
|
5323
|
+
: (lagging && backedUp) || (ratio > divisor && saturated)) {
|
|
5324
|
+
this.probeAfter = this.probing
|
|
5325
|
+
? Math.min(this.probeAfter * 2, kMaxProbeAfterMs)
|
|
5326
|
+
: kProbeAfterMs;
|
|
5327
|
+
this.setDivisor(time, Math.max(divisor + 1, Math.ceil(ratio)));
|
|
5328
|
+
}
|
|
5329
|
+
else if (ratio < (divisor - 1) * 0.9) {
|
|
5330
|
+
// Paced frames no longer overlap, so their replay time is a ceiling
|
|
5331
|
+
// and a faster cadence under it is safe.
|
|
5332
|
+
this.probeAfter = kProbeAfterMs;
|
|
5333
|
+
this.setDivisor(time, Math.max(1, Math.ceil(ratio / 0.9)));
|
|
5334
|
+
}
|
|
5335
|
+
else if (this.probing) {
|
|
5336
|
+
// A worker only slightly too slow takes a while to fill its queue.
|
|
5337
|
+
if (this.recentBackups.length >= kBackupWindow) {
|
|
5338
|
+
this.probing = false;
|
|
5339
|
+
this.probeAfter = kProbeAfterMs;
|
|
5340
|
+
}
|
|
5341
|
+
}
|
|
5342
|
+
else if (divisor > 1 && time >= this.nextProbe) {
|
|
5343
|
+
// Frames that overlap on the GPU can keep up with a cadence shorter
|
|
5344
|
+
// than one frame's replay, which only trying it shows.
|
|
5345
|
+
this.setDivisor(time, divisor - 1);
|
|
5346
|
+
this.probing = true;
|
|
5347
|
+
}
|
|
5348
|
+
};
|
|
5349
|
+
ReplayPacer.prototype.setDivisor = function (time, divisor) {
|
|
5350
|
+
this.divisor = divisor;
|
|
5351
|
+
this.settle = kSettleFrames;
|
|
5352
|
+
this.probing = false;
|
|
5353
|
+
this.backedUp = false;
|
|
5354
|
+
this.recentBackups = [];
|
|
5355
|
+
this.nextProbe = time + this.probeAfter;
|
|
5356
|
+
};
|
|
5357
|
+
return ReplayPacer;
|
|
5358
|
+
}());
|
|
5359
|
+
|
|
5360
|
+
|
|
5361
|
+
|
|
5227
5362
|
/***/ })
|
|
5228
5363
|
/******/ ]);
|
|
5229
5364
|
/************************************************************************/
|
|
@@ -7303,6 +7438,7 @@ var Rive = /** @class */ (function () {
|
|
|
7303
7438
|
this.lastRenderTime = 0;
|
|
7304
7439
|
// Tracks the current animation frame request
|
|
7305
7440
|
this.frameRequestId = null;
|
|
7441
|
+
this.replayPacer = new _utils__WEBPACK_IMPORTED_MODULE_3__.ReplayPacer();
|
|
7306
7442
|
/**
|
|
7307
7443
|
* Used be draw to track when a second of active rendering time has passed.
|
|
7308
7444
|
* Used for debugging purposes
|
|
@@ -8382,7 +8518,7 @@ var Rive = /** @class */ (function () {
|
|
|
8382
8518
|
* @param time the rAF timestamp, or null to draw now without advancing
|
|
8383
8519
|
*/
|
|
8384
8520
|
Rive.prototype.draw = function (time, onSecond) {
|
|
8385
|
-
var _a, _b, _c, _d;
|
|
8521
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8386
8522
|
// Clear the frameRequestId, as we're now rendering a fresh frame
|
|
8387
8523
|
this.frameRequestId = null;
|
|
8388
8524
|
// load() tears the artboard down and re-inits asynchronously; a frame
|
|
@@ -8396,10 +8532,15 @@ var Rive = /** @class */ (function () {
|
|
|
8396
8532
|
this.reloadForRestoredContext();
|
|
8397
8533
|
return;
|
|
8398
8534
|
}
|
|
8399
|
-
// The replay worker has yet to take the canvas,
|
|
8400
|
-
// frames
|
|
8535
|
+
// The replay worker has yet to take the canvas, is still on earlier
|
|
8536
|
+
// frames, or is slower than the display and this frame falls between its
|
|
8537
|
+
// paced ones. Waiting keeps its queue bounded, and the frame that follows
|
|
8401
8538
|
// advances by the whole wait, so playback keeps time.
|
|
8402
|
-
|
|
8539
|
+
var accepts = ((_d = (_c = this.renderer) === null || _c === void 0 ? void 0 : _c.acceptsFrame) === null || _d === void 0 ? void 0 : _d.call(_c)) !== false;
|
|
8540
|
+
var replayMs = (_f = (_e = this.renderer) === null || _e === void 0 ? void 0 : _e.replayMs) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
8541
|
+
if (time !== null && replayMs !== undefined
|
|
8542
|
+
? !this.replayPacer.shouldRecord(time, replayMs, accepts)
|
|
8543
|
+
: !accepts) {
|
|
8403
8544
|
this.scheduleRendering();
|
|
8404
8545
|
return;
|
|
8405
8546
|
}
|