@rive-app/canvas-advanced-lite 0.1.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.
- package/README.md +22 -0
- package/canvas_advanced.mjs +120 -0
- package/package.json +35 -0
- package/rive.wasm +0 -0
- package/rive_advanced.mjs.d.ts +873 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# Rive
|
|
4
|
+
Low-level lite Rive API using CanvasRenderingContext2D. Please see https://help.rive.app/runtimes/overview/web-js/canvas-vs-webgl for a list of all the available web runtimes and their details.
|
|
5
|
+
|
|
6
|
+
## Canvas Advanced
|
|
7
|
+
```
|
|
8
|
+
npm install @rive-app/canvas-advanced-lite
|
|
9
|
+
```
|
|
10
|
+
A low-level Rive API using the [CanvasRenderingContext2D](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D) renderer. It has the same benefits as the regular `@rive-app/canvas` package plus:
|
|
11
|
+
- Full control over the update and render loop
|
|
12
|
+
- Allows for rendering multiple Rive artboards to a single canvas
|
|
13
|
+
- Allows deeper control and manipulation of the components in a Rive hierarchy
|
|
14
|
+
- Web Assembly (WASM) is part of the NPM bundle, but you load in the WASM manually
|
|
15
|
+
|
|
16
|
+
[Getting Started](https://help.rive.app/runtimes/overview/web-js/low-level-api-usage)
|
|
17
|
+
|
|
18
|
+
## Why Lite?
|
|
19
|
+
|
|
20
|
+
The complimentary `@rive-app/canvas-advanced` dependency supports all Rive features and contains the necessary backing dependencies to render those graphics. This `lite` version has the same API, but does not compile and build with certain dependencies in order to keep the package size as small as possible.
|
|
21
|
+
|
|
22
|
+
At this time, this lite version of `@rive-app/canvas-advanced-lite` will not render [Rive Text](https://help.rive.app/editor/text) onto the canvas. Note however, that even if your Rive file may include Rive Text components, rendering the graphic should not cause any app errors, or cease to render.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
|
|
2
|
+
var Rive = (() => {
|
|
3
|
+
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
|
4
|
+
|
|
5
|
+
return (
|
|
6
|
+
function(moduleArg = {}) {
|
|
7
|
+
|
|
8
|
+
var h=moduleArg,ba,ca;h.ready=new Promise((b,a)=>{ba=b;ca=a});
|
|
9
|
+
function da(){function b(m){const l=d;c=a=0;d=new Map;l.forEach(p=>{try{p(m)}catch(k){console.error(k)}});this.fb();e&&e.Db()}let a=0,c=0,d=new Map,e=null,f=null;this.requestAnimationFrame=function(m){a||(a=requestAnimationFrame(b.bind(this)));const l=++c;d.set(l,m);return l};this.cancelAnimationFrame=function(m){d.delete(m);a&&0==d.size&&(cancelAnimationFrame(a),a=0)};this.Bb=function(m){f&&(document.body.remove(f),f=null);m||(f=document.createElement("div"),f.style.backgroundColor="black",f.style.position=
|
|
10
|
+
"fixed",f.style.right=0,f.style.top=0,f.style.color="white",f.style.padding="4px",f.innerHTML="RIVE FPS",m=function(l){f.innerHTML="RIVE FPS "+l.toFixed(1)},document.body.appendChild(f));e=new function(){let l=0,p=0;this.Db=function(){var k=performance.now();p?(++l,k-=p,1E3<k&&(m(1E3*l/k),l=p=0)):(p=k,l=0)}}};this.yb=function(){f&&(document.body.remove(f),f=null);e=null};this.fb=function(){}}
|
|
11
|
+
function ea(b){console.assert(!0);const a=new Map;let c=-Infinity;this.push=function(d){d=d+((1<<b)-1)>>b;a.has(d)&&clearTimeout(a.get(d));a.set(d,setTimeout(function(){a.delete(d);0==a.length?c=-Infinity:d==c&&(c=Math.max(...a.keys()),console.assert(c<d))},1E3));c=Math.max(d,c);return c<<b}}
|
|
12
|
+
const ha="createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "),ka=new function(){function b(){if(!a){var t=document.createElement("canvas"),g={alpha:1,depth:0,stencil:0,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,preferLowPowerToHighPerformance:0,failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:1,
|
|
13
|
+
renderViaOffscreenBackBuffer:1};let n=t.getContext("webgl2",g);if(n)c=2;else if(n=t.getContext("webgl",g))c=1;else return console.log("No WebGL support. Image mesh will not be drawn."),!1;d=Math.min(n.getParameter(n.MAX_RENDERBUFFER_SIZE),n.getParameter(n.MAX_TEXTURE_SIZE));function w(H,x,A){x=n.createShader(x);n.shaderSource(x,A);n.compileShader(x);A=n.getShaderInfoLog(x);if(0<A.length)throw A;n.attachShader(H,x)}t=n.createProgram();w(t,n.VERTEX_SHADER,"attribute vec2 vertex;\n attribute vec2 uv;\n uniform vec4 mat;\n uniform vec2 translate;\n varying vec2 st;\n void main() {\n st = uv;\n gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);\n }");
|
|
14
|
+
w(t,n.FRAGMENT_SHADER,"precision highp float;\n uniform sampler2D image;\n varying vec2 st;\n void main() {\n gl_FragColor = texture2D(image, st);\n }");n.bindAttribLocation(t,0,"vertex");n.bindAttribLocation(t,1,"uv");n.linkProgram(t);g=n.getProgramInfoLog(t);if(0<g.trim().length)throw g;e=n.getUniformLocation(t,"mat");f=n.getUniformLocation(t,"translate");n.useProgram(t);n.bindBuffer(n.ARRAY_BUFFER,n.createBuffer());
|
|
15
|
+
n.enableVertexAttribArray(0);n.enableVertexAttribArray(1);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,n.createBuffer());n.uniform1i(n.getUniformLocation(t,"image"),0);n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);a=n}return!0}let a=null,c=0,d=0,e=null,f=null,m=0,l=0;this.Mb=function(){b();return d};this.vb=function(t){if(!b())return null;const g=a.createTexture();a.bindTexture(a.TEXTURE_2D,g);a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,t);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);
|
|
16
|
+
a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);2==c?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR),a.generateMipmap(a.TEXTURE_2D)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);return g};const p=new ea(8),k=new ea(8),r=new ea(10),u=new ea(10);this.Ab=function(t,g,n,w,H){if(b()){var x=p.push(t),A=k.push(g);if(a.canvas.width!=x||a.canvas.height!=A)a.canvas.width=x,a.canvas.height=A;
|
|
17
|
+
a.viewport(0,A-g,t,g);a.disable(a.SCISSOR_TEST);a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT);a.enable(a.SCISSOR_TEST);n.sort((B,fa)=>fa.jb-B.jb);x=r.push(w);m!=x&&(a.bufferData(a.ARRAY_BUFFER,8*x,a.DYNAMIC_DRAW),m=x);x=0;for(var J of n)a.bufferSubData(a.ARRAY_BUFFER,x,J.Ra),x+=4*J.Ra.length;console.assert(x==4*w);for(var Q of n)a.bufferSubData(a.ARRAY_BUFFER,x,Q.mb),x+=4*Q.mb.length;console.assert(x==8*w);x=u.push(H);l!=x&&(a.bufferData(a.ELEMENT_ARRAY_BUFFER,2*x,a.DYNAMIC_DRAW),l=x);J=0;for(var aa of n)a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,
|
|
18
|
+
J,aa.indices),J+=2*aa.indices.length;console.assert(J==2*H);aa=0;Q=!0;x=J=0;for(const B of n){B.image.Ma!=aa&&(a.bindTexture(a.TEXTURE_2D,B.image.rb||null),aa=B.image.Ma);B.Pb?(a.scissor(B.Va,A-B.Wa-B.cb,B.$b,B.cb),Q=!0):Q&&(a.scissor(0,A-g,t,g),Q=!1);n=2/t;const fa=-2/g;a.uniform4f(e,B.xa[0]*n*B.Ga,B.xa[1]*fa*B.Ha,B.xa[2]*n*B.Ga,B.xa[3]*fa*B.Ha);a.uniform2f(f,B.xa[4]*n*B.Ga+n*(B.Va-B.Nb*B.Ga)-1,B.xa[5]*fa*B.Ha+fa*(B.Wa-B.Ob*B.Ha)+1);a.vertexAttribPointer(0,2,a.FLOAT,!1,0,x);a.vertexAttribPointer(1,
|
|
19
|
+
2,a.FLOAT,!1,0,x+4*w);a.drawElements(a.TRIANGLES,B.indices.length,a.UNSIGNED_SHORT,J);x+=4*B.Ra.length;J+=2*B.indices.length}console.assert(x==4*w);console.assert(J==2*H)}};this.canvas=function(){return b()&&a.canvas}},la=h.onRuntimeInitialized;
|
|
20
|
+
h.onRuntimeInitialized=function(){function b(q){switch(q){case k.srcOver:return"source-over";case k.screen:return"screen";case k.overlay:return"overlay";case k.darken:return"darken";case k.lighten:return"lighten";case k.colorDodge:return"color-dodge";case k.colorBurn:return"color-burn";case k.hardLight:return"hard-light";case k.softLight:return"soft-light";case k.difference:return"difference";case k.exclusion:return"exclusion";case k.multiply:return"multiply";case k.hue:return"hue";case k.saturation:return"saturation";
|
|
21
|
+
case k.color:return"color";case k.luminosity:return"luminosity"}}function a(q){return"rgba("+((16711680&q)>>>16)+","+((65280&q)>>>8)+","+((255&q)>>>0)+","+((4278190080&q)>>>24)/255+")"}function c(){0<J.length&&(ka.Ab(A.drawWidth(),A.drawHeight(),J,Q,aa),J=[],aa=Q=0,A.reset(512,512));for(const q of x){for(const v of q.ja)v();q.ja=[]}x.clear()}la&&la();var d=h.RenderPaintStyle;const e=h.RenderPath,f=h.RenderPaint,m=h.Renderer,l=h.StrokeCap,p=h.StrokeJoin,k=h.BlendMode,r=d.fill,u=d.stroke,t=h.FillRule.evenOdd;
|
|
22
|
+
let g=1;var n=h.RenderImage.extend("CanvasRenderImage",{__construct:function({Aa:q,Fa:v}={}){this.__parent.__construct.call(this);this.Ma=g;g=g+1&2147483647||1;this.Aa=q;this.Fa=v},decode:function(q){var v=this;v.Fa&&v.Fa(v);var C=new Image;C.src=URL.createObjectURL(new Blob([q],{type:"image/png"}));C.onload=function(){v.ob=C;v.rb=ka.vb(C);v.size(C.width,C.height);v.Aa&&v.Aa(v)}}}),w=e.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this);this.pa=new Path2D},rewind:function(){this.pa=
|
|
23
|
+
new Path2D},addPath:function(q,v,C,D,z,E,F){var G=this.pa,T=G.addPath;q=q.pa;const K=new DOMMatrix;K.a=v;K.b=C;K.c=D;K.d=z;K.e=E;K.f=F;T.call(G,q,K)},fillRule:function(q){this.Ta=q},moveTo:function(q,v){this.pa.moveTo(q,v)},lineTo:function(q,v){this.pa.lineTo(q,v)},cubicTo:function(q,v,C,D,z,E){this.pa.bezierCurveTo(q,v,C,D,z,E)},close:function(){this.pa.closePath()}}),H=f.extend("CanvasRenderPaint",{color:function(q){this.Ua=a(q)},thickness:function(q){this.sb=q},join:function(q){switch(q){case p.miter:this.La=
|
|
24
|
+
"miter";break;case p.round:this.La="round";break;case p.bevel:this.La="bevel"}},cap:function(q){switch(q){case l.butt:this.Ka="butt";break;case l.round:this.Ka="round";break;case l.square:this.Ka="square"}},style:function(q){this.qb=q},blendMode:function(q){this.nb=b(q)},clearGradient:function(){this.za=null},linearGradient:function(q,v,C,D){this.za={kb:q,lb:v,Za:C,$a:D,Pa:[]}},radialGradient:function(q,v,C,D){this.za={kb:q,lb:v,Za:C,$a:D,Pa:[],Kb:!0}},addStop:function(q,v){this.za.Pa.push({color:q,
|
|
25
|
+
stop:v})},completeGradient:function(){},draw:function(q,v,C){let D=this.qb;var z=this.Ua,E=this.za;q.globalCompositeOperation=this.nb;if(null!=E){z=E.kb;var F=E.lb;const T=E.Za;var G=E.$a;const K=E.Pa;E.Kb?(E=T-z,G-=F,z=q.createRadialGradient(z,F,0,z,F,Math.sqrt(E*E+G*G))):z=q.createLinearGradient(z,F,T,G);for(let W=0,N=K.length;W<N;W++)F=K[W],z.addColorStop(F.stop,a(F.color));this.Ua=z;this.za=null}switch(D){case u:q.strokeStyle=z;q.lineWidth=this.sb;q.lineCap=this.Ka;q.lineJoin=this.La;q.stroke(v);
|
|
26
|
+
break;case r:q.fillStyle=z,q.fill(v,C)}}});const x=new Set;let A=null,J=[],Q=0,aa=0;var B=h.CanvasRenderer=m.extend("Renderer",{__construct:function(q){this.__parent.__construct.call(this);this.oa=[1,0,0,1,0,0];this.ha=q.getContext("2d");this.Sa=q;this.ja=[]},save:function(){this.oa.push(...this.oa.slice(this.oa.length-6));this.ja.push(this.ha.save.bind(this.ha))},restore:function(){const q=this.oa.length-6;if(6>q)throw"restore() called without matching save().";this.oa.splice(q);this.ja.push(this.ha.restore.bind(this.ha))},
|
|
27
|
+
transform:function(q,v,C,D,z,E){const F=this.oa,G=F.length-6;F.splice(G,6,F[G]*q+F[G+2]*v,F[G+1]*q+F[G+3]*v,F[G]*C+F[G+2]*D,F[G+1]*C+F[G+3]*D,F[G]*z+F[G+2]*E+F[G+4],F[G+1]*z+F[G+3]*E+F[G+5]);this.ja.push(this.ha.transform.bind(this.ha,q,v,C,D,z,E))},rotate:function(q){const v=Math.sin(q);q=Math.cos(q);this.transform(q,v,-v,q,0,0)},_drawPath:function(q,v){this.ja.push(v.draw.bind(v,this.ha,q.pa,q.Ta===t?"evenodd":"nonzero"))},_drawRiveImage:function(q,v,C){var D=q.ob;if(D){var z=this.ha,E=b(v);this.ja.push(function(){z.globalCompositeOperation=
|
|
28
|
+
E;z.globalAlpha=C;z.drawImage(D,0,0);z.globalAlpha=1})}},_getMatrix:function(q){const v=this.oa,C=v.length-6;for(let D=0;6>D;++D)q[D]=v[C+D]},_drawImageMesh:function(q,v,C,D,z,E,F,G,T,K){var W=this.ha.canvas.width,N=this.ha.canvas.height;const sb=T-F,tb=K-G;F=Math.max(F,0);G=Math.max(G,0);T=Math.min(T,W);K=Math.min(K,N);const ua=T-F,va=K-G;console.assert(ua<=Math.min(sb,W));console.assert(va<=Math.min(tb,N));if(!(0>=ua||0>=va)){T=ua<sb||va<tb;W=K=1;var ia=Math.ceil(ua*K),ja=Math.ceil(va*W);N=ka.Mb();
|
|
29
|
+
ia>N&&(K*=N/ia,ia=N);ja>N&&(W*=N/ja,ja=N);A||(A=new h.DynamicRectanizer(N),A.reset(512,512));N=A.addRect(ia,ja);0>N&&(c(),x.add(this),N=A.addRect(ia,ja),console.assert(0<=N));var ub=N&65535,vb=N>>16;J.push({xa:this.oa.slice(this.oa.length-6),image:q,Va:ub,Wa:vb,Nb:F,Ob:G,$b:ia,cb:ja,Ga:K,Ha:W,Ra:new Float32Array(D),mb:new Float32Array(z),indices:new Uint16Array(E),Pb:T,jb:q.Ma<<1|(T?1:0)});Q+=D.length;aa+=E.length;var oa=this.ha,kc=b(v);this.ja.push(function(){oa.save();oa.resetTransform();oa.globalCompositeOperation=
|
|
30
|
+
kc;oa.globalAlpha=C;oa.drawImage(ka.canvas(),ub,vb,ia,ja,F,G,ua,va);oa.restore()})}},_clipPath:function(q){this.ja.push(this.ha.clip.bind(this.ha,q.pa,q.Ta===t?"evenodd":"nonzero"))},clear:function(){x.add(this);this.ja.push(this.ha.clearRect.bind(this.ha,0,0,this.Sa.width,this.Sa.height))},flush:function(){},translate:function(q,v){this.transform(1,0,0,1,q,v)}});h.makeRenderer=function(q){const v=new B(q),C=v.ha;return new Proxy(v,{get(D,z){if("function"===typeof D[z])return function(...E){return D[z].apply(D,
|
|
31
|
+
E)};if("function"===typeof C[z]){if(-1<ha.indexOf(z))throw Error("RiveException: Method call to '"+z+"()' is not allowed, as the renderer cannot immediately pass through the return values of any canvas 2d context methods.");return function(...E){v.ja.push(C[z].bind(C,...E))}}return D[z]},set(D,z,E){if(z in C)return C[z]=E,!0}})};h.decodeImage=function(q,v){(new n({Aa:v})).decode(q)};h.renderFactory={makeRenderPaint:function(){return new H},makeRenderPath:function(){return new w},makeRenderImage:function(){let q=
|
|
32
|
+
Za;return new n({Fa:()=>{q.total++},Aa:()=>{q.loaded++;if(q.loaded===q.total){const v=q.ready;v&&(v(),q.ready=null)}}})}};let fa=h.load,Za=null;h.load=function(q,v,C=!0){const D=new h.FallbackFileAssetLoader;void 0!==v&&D.addLoader(v);C&&(v=new h.CDNFileAssetLoader,D.addLoader(v));return new Promise(function(z){let E=null;Za={total:0,loaded:0,ready:function(){z(E)}};E=fa(q,D);0==Za.total&&z(E)})};d=new da;h.requestAnimationFrame=d.requestAnimationFrame.bind(d);h.cancelAnimationFrame=d.cancelAnimationFrame.bind(d);
|
|
33
|
+
h.enableFPSCounter=d.Bb.bind(d);h.disableFPSCounter=d.yb;d.fb=c;h.cleanup=function(){A&&A.delete()}};const ma=h.onRuntimeInitialized;
|
|
34
|
+
h.onRuntimeInitialized=function(){ma&&ma();let b=h.decodeFont;h.decodeFont=function(c,d){c=b(c);d(c)};const a=h.FileAssetLoader;h.ptrToAsset=c=>{let d=h.ptrToFileAsset(c);return d.isImage?h.ptrToImageAsset(c):d.isFont?h.ptrToFontAsset(c):d};h.CustomFileAssetLoader=a.extend("CustomFileAssetLoader",{__construct:function({loadContents:c}){this.__parent.__construct.call(this);this.pb=c},loadContents:function(c,d){c=h.ptrToAsset(c);return this.pb(c,d)}});h.CDNFileAssetLoader=a.extend("CDNFileAssetLoader",
|
|
35
|
+
{__construct:function(){this.__parent.__construct.call(this)},loadContents:function(c){let d=h.ptrToAsset(c);c=d.cdnUuid;if(""===c)return!1;(function(e,f){var m=new XMLHttpRequest;m.responseType="arraybuffer";m.onreadystatechange=function(){4==m.readyState&&200==m.status&&f(m)};m.open("GET",e,!0);m.send(null)})(d.cdnBaseUrl+"/"+c,e=>{d.decode(new Uint8Array(e.response))});return!0}});h.FallbackFileAssetLoader=a.extend("FallbackFileAssetLoader",{__construct:function(){this.__parent.__construct.call(this);
|
|
36
|
+
this.eb=[]},addLoader:function(c){this.eb.push(c)},loadContents:function(c,d){for(let e of this.eb)if(e.loadContents(c,d))return!0;return!1}})};var na=Object.assign({},h),pa="./this.program",qa="object"==typeof window,ra="function"==typeof importScripts,y="",sa,ta;
|
|
37
|
+
if(qa||ra)ra?y=self.location.href:"undefined"!=typeof document&&document.currentScript&&(y=document.currentScript.src),_scriptDir&&(y=_scriptDir),0!==y.indexOf("blob:")?y=y.substr(0,y.replace(/[?#].*/,"").lastIndexOf("/")+1):y="",ra&&(ta=b=>{var a=new XMLHttpRequest;a.open("GET",b,!1);a.responseType="arraybuffer";a.send(null);return new Uint8Array(a.response)}),sa=(b,a,c)=>{var d=new XMLHttpRequest;d.open("GET",b,!0);d.responseType="arraybuffer";d.onload=()=>{200==d.status||0==d.status&&d.response?
|
|
38
|
+
a(d.response):c()};d.onerror=c;d.send(null)};var wa=h.print||console.log.bind(console),xa=h.printErr||console.error.bind(console);Object.assign(h,na);na=null;h.thisProgram&&(pa=h.thisProgram);var ya;h.wasmBinary&&(ya=h.wasmBinary);var noExitRuntime=h.noExitRuntime||!0;"object"!=typeof WebAssembly&&za("no native wasm support detected");var Aa,I,Ba=!1,Ca,L,Da,Ea,M,O,Fa,Ga;
|
|
39
|
+
function Ha(){var b=Aa.buffer;h.HEAP8=Ca=new Int8Array(b);h.HEAP16=Da=new Int16Array(b);h.HEAP32=M=new Int32Array(b);h.HEAPU8=L=new Uint8Array(b);h.HEAPU16=Ea=new Uint16Array(b);h.HEAPU32=O=new Uint32Array(b);h.HEAPF32=Fa=new Float32Array(b);h.HEAPF64=Ga=new Float64Array(b)}var Ia,Ja=[],Ka=[],La=[];function Ma(){var b=h.preRun.shift();Ja.unshift(b)}var Na=0,Oa=null,Pa=null;
|
|
40
|
+
function za(b){if(h.onAbort)h.onAbort(b);b="Aborted("+b+")";xa(b);Ba=!0;b=new WebAssembly.RuntimeError(b+". Build with -sASSERTIONS for more info.");ca(b);throw b;}function Qa(b){return b.startsWith("data:application/octet-stream;base64,")}var Ra;Ra="canvas_advanced.wasm";if(!Qa(Ra)){var Sa=Ra;Ra=h.locateFile?h.locateFile(Sa,y):y+Sa}function Ta(b){if(b==Ra&&ya)return new Uint8Array(ya);if(ta)return ta(b);throw"both async and sync fetching of the wasm failed";}
|
|
41
|
+
function Ua(b){if(!ya&&(qa||ra)){if("function"==typeof fetch&&!b.startsWith("file://"))return fetch(b,{credentials:"same-origin"}).then(a=>{if(!a.ok)throw"failed to load wasm binary file at '"+b+"'";return a.arrayBuffer()}).catch(()=>Ta(b));if(sa)return new Promise((a,c)=>{sa(b,d=>a(new Uint8Array(d)),c)})}return Promise.resolve().then(()=>Ta(b))}function Va(b,a,c){return Ua(b).then(d=>WebAssembly.instantiate(d,a)).then(d=>d).then(c,d=>{xa("failed to asynchronously prepare wasm: "+d);za(d)})}
|
|
42
|
+
function Wa(b,a){var c=Ra;return ya||"function"!=typeof WebAssembly.instantiateStreaming||Qa(c)||c.startsWith("file://")||"function"!=typeof fetch?Va(c,b,a):fetch(c,{credentials:"same-origin"}).then(d=>WebAssembly.instantiateStreaming(d,b).then(a,function(e){xa("wasm streaming compile failed: "+e);xa("falling back to ArrayBuffer instantiation");return Va(c,b,a)}))}var Xa=b=>{for(;0<b.length;)b.shift()(h)};
|
|
43
|
+
function Ya(b){if(void 0===b)return"_unknown";b=b.replace(/[^a-zA-Z0-9_]/g,"$");var a=b.charCodeAt(0);return 48<=a&&57>=a?`_${b}`:b}function $a(b,a){b=Ya(b);return{[b]:function(){return a.apply(this,arguments)}}[b]}function ab(){this.qa=[void 0];this.bb=[]}var P=new ab,bb=void 0;function R(b){throw new bb(b);}
|
|
44
|
+
var S=b=>{b||R("Cannot use deleted val. handle = "+b);return P.get(b).value},U=b=>{switch(b){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:return P.tb({ib:1,value:b})}};
|
|
45
|
+
function cb(b){var a=Error,c=$a(b,function(d){this.name=b;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(a.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:`${this.name}: ${this.message}`};return c}var db=void 0,eb=void 0;function V(b){for(var a="";L[b];)a+=eb[L[b++]];return a}var fb=[];
|
|
46
|
+
function gb(){for(;fb.length;){var b=fb.pop();b.ba.wa=!1;b["delete"]()}}var hb=void 0,ib={};function jb(b,a){for(void 0===a&&R("ptr should not be undefined");b.fa;)a=b.Ba(a),b=b.fa;return a}var kb={};function lb(b){b=mb(b);var a=V(b);nb(b);return a}function ob(b,a){var c=kb[b];void 0===c&&R(a+" has unknown type "+lb(b));return c}function pb(){}var qb=!1;function rb(b){--b.count.value;0===b.count.value&&(b.ia?b.la.ra(b.ia):b.ea.ca.ra(b.da))}
|
|
47
|
+
function wb(b,a,c){if(a===c)return b;if(void 0===c.fa)return null;b=wb(b,a,c.fa);return null===b?null:c.zb(b)}var xb={};function yb(b,a){a=jb(b,a);return ib[a]}var zb=void 0;function Ab(b){throw new zb(b);}function Bb(b,a){a.ea&&a.da||Ab("makeClassHandle requires ptr and ptrType");!!a.la!==!!a.ia&&Ab("Both smartPtrType and smartPtr must be specified");a.count={value:1};return Cb(Object.create(b,{ba:{value:a}}))}
|
|
48
|
+
function Cb(b){if("undefined"===typeof FinalizationRegistry)return Cb=a=>a,b;qb=new FinalizationRegistry(a=>{rb(a.ba)});Cb=a=>{var c=a.ba;c.ia&&qb.register(a,{ba:c},a);return a};pb=a=>{qb.unregister(a)};return Cb(b)}var Db={};function Eb(b){for(;b.length;){var a=b.pop();b.pop()(a)}}function Fb(b){return this.fromWireType(M[b>>2])}var Gb={},Hb={};
|
|
49
|
+
function X(b,a,c){function d(l){l=c(l);l.length!==b.length&&Ab("Mismatched type converter count");for(var p=0;p<b.length;++p)Y(b[p],l[p])}b.forEach(function(l){Hb[l]=a});var e=Array(a.length),f=[],m=0;a.forEach((l,p)=>{kb.hasOwnProperty(l)?e[p]=kb[l]:(f.push(l),Gb.hasOwnProperty(l)||(Gb[l]=[]),Gb[l].push(()=>{e[p]=kb[l];++m;m===f.length&&d(e)}))});0===f.length&&d(e)}
|
|
50
|
+
function Ib(b){switch(b){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${b}`);}}function Jb(b,a,c={}){var d=a.name;b||R(`type "${d}" must have a positive integer typeid pointer`);if(kb.hasOwnProperty(b)){if(c.Jb)return;R(`Cannot register type '${d}' twice`)}kb[b]=a;delete Hb[b];Gb.hasOwnProperty(b)&&(a=Gb[b],delete Gb[b],a.forEach(e=>e()))}
|
|
51
|
+
function Y(b,a,c={}){if(!("argPackAdvance"in a))throw new TypeError("registerType registeredInstance requires argPackAdvance");Jb(b,a,c)}function Kb(b){R(b.ba.ea.ca.name+" instance already deleted")}function Lb(){}
|
|
52
|
+
function Mb(b,a,c){if(void 0===b[a].ga){var d=b[a];b[a]=function(){b[a].ga.hasOwnProperty(arguments.length)||R(`Function '${c}' called with an invalid number of arguments (${arguments.length}) - expects one of (${b[a].ga})!`);return b[a].ga[arguments.length].apply(this,arguments)};b[a].ga=[];b[a].ga[d.va]=d}}
|
|
53
|
+
function Nb(b,a,c){h.hasOwnProperty(b)?((void 0===c||void 0!==h[b].ga&&void 0!==h[b].ga[c])&&R(`Cannot register public name '${b}' twice`),Mb(h,b,b),h.hasOwnProperty(c)&&R(`Cannot register multiple overloads of a function with the same number of arguments (${c})!`),h[b].ga[c]=a):(h[b]=a,void 0!==c&&(h[b].ac=c))}function Ob(b,a,c,d,e,f,m,l){this.name=b;this.constructor=a;this.ma=c;this.ra=d;this.fa=e;this.Eb=f;this.Ba=m;this.zb=l;this.gb=[]}
|
|
54
|
+
function Pb(b,a,c){for(;a!==c;)a.Ba||R(`Expected null or instance of ${c.name}, got an instance of ${a.name}`),b=a.Ba(b),a=a.fa;return b}function Qb(b,a){if(null===a)return this.Na&&R(`null is not a valid ${this.name}`),0;a.ba||R(`Cannot pass "${Rb(a)}" as a ${this.name}`);a.ba.da||R(`Cannot pass deleted object as a pointer of type ${this.name}`);return Pb(a.ba.da,a.ba.ea.ca,this.ca)}
|
|
55
|
+
function Sb(b,a){if(null===a){this.Na&&R(`null is not a valid ${this.name}`);if(this.Ea){var c=this.Oa();null!==b&&b.push(this.ra,c);return c}return 0}a.ba||R(`Cannot pass "${Rb(a)}" as a ${this.name}`);a.ba.da||R(`Cannot pass deleted object as a pointer of type ${this.name}`);!this.Da&&a.ba.ea.Da&&R(`Cannot convert argument of type ${a.ba.la?a.ba.la.name:a.ba.ea.name} to parameter type ${this.name}`);c=Pb(a.ba.da,a.ba.ea.ca,this.ca);if(this.Ea)switch(void 0===a.ba.ia&&R("Passing raw pointer to smart pointer is illegal"),
|
|
56
|
+
this.Vb){case 0:a.ba.la===this?c=a.ba.ia:R(`Cannot convert argument of type ${a.ba.la?a.ba.la.name:a.ba.ea.name} to parameter type ${this.name}`);break;case 1:c=a.ba.ia;break;case 2:if(a.ba.la===this)c=a.ba.ia;else{var d=a.clone();c=this.Rb(c,U(function(){d["delete"]()}));null!==b&&b.push(this.ra,c)}break;default:R("Unsupporting sharing policy")}return c}
|
|
57
|
+
function Tb(b,a){if(null===a)return this.Na&&R(`null is not a valid ${this.name}`),0;a.ba||R(`Cannot pass "${Rb(a)}" as a ${this.name}`);a.ba.da||R(`Cannot pass deleted object as a pointer of type ${this.name}`);a.ba.ea.Da&&R(`Cannot convert argument of type ${a.ba.ea.name} to parameter type ${this.name}`);return Pb(a.ba.da,a.ba.ea.ca,this.ca)}
|
|
58
|
+
function Ub(b,a,c,d){this.name=b;this.ca=a;this.Na=c;this.Da=d;this.Ea=!1;this.ra=this.Rb=this.Oa=this.hb=this.Vb=this.Qb=void 0;void 0!==a.fa?this.toWireType=Sb:(this.toWireType=d?Qb:Tb,this.ka=null)}function Vb(b,a,c){h.hasOwnProperty(b)||Ab("Replacing nonexistant public symbol");void 0!==h[b].ga&&void 0!==c?h[b].ga[c]=a:(h[b]=a,h[b].va=c)}
|
|
59
|
+
var Wb=(b,a)=>{var c=[];return function(){c.length=0;Object.assign(c,arguments);if(b.includes("j")){var d=h["dynCall_"+b];d=c&&c.length?d.apply(null,[a].concat(c)):d.call(null,a)}else d=Ia.get(a).apply(null,c);return d}};function Z(b,a){b=V(b);var c=b.includes("j")?Wb(b,a):Ia.get(a);"function"!=typeof c&&R(`unknown function pointer with signature ${b}: ${a}`);return c}var Xb=void 0;
|
|
60
|
+
function Yb(b,a){function c(f){e[f]||kb[f]||(Hb[f]?Hb[f].forEach(c):(d.push(f),e[f]=!0))}var d=[],e={};a.forEach(c);throw new Xb(`${b}: `+d.map(lb).join([", "]));}
|
|
61
|
+
function Zb(b,a,c,d,e){var f=a.length;2>f&&R("argTypes array size mismatch! Must at least get return value and 'this' types!");var m=null!==a[1]&&null!==c,l=!1;for(c=1;c<a.length;++c)if(null!==a[c]&&void 0===a[c].ka){l=!0;break}var p="void"!==a[0].name,k=f-2,r=Array(k),u=[],t=[];return function(){arguments.length!==k&&R(`function ${b} called with ${arguments.length} arguments, expected ${k} args!`);t.length=0;u.length=m?2:1;u[0]=e;if(m){var g=a[1].toWireType(t,this);u[1]=g}for(var n=0;n<k;++n)r[n]=
|
|
62
|
+
a[n+2].toWireType(t,arguments[n]),u.push(r[n]);n=d.apply(null,u);if(l)Eb(t);else for(var w=m?1:2;w<a.length;w++){var H=1===w?g:r[w-2];null!==a[w].ka&&a[w].ka(H)}g=p?a[0].fromWireType(n):void 0;return g}}function $b(b,a){for(var c=[],d=0;d<b;d++)c.push(O[a+4*d>>2]);return c}
|
|
63
|
+
function ac(b,a,c){b instanceof Object||R(`${c} with invalid "this": ${b}`);b instanceof a.ca.constructor||R(`${c} incompatible with "this" of type ${b.constructor.name}`);b.ba.da||R(`cannot call emscripten binding method ${c} on deleted object`);return Pb(b.ba.da,b.ba.ea.ca,a.ca)}function bc(b){b>=P.Xa&&0===--P.get(b).ib&&P.wb(b)}
|
|
64
|
+
function cc(b,a,c){switch(a){case 0:return function(d){return this.fromWireType((c?Ca:L)[d])};case 1:return function(d){return this.fromWireType((c?Da:Ea)[d>>1])};case 2:return function(d){return this.fromWireType((c?M:O)[d>>2])};default:throw new TypeError("Unknown integer type: "+b);}}function Rb(b){if(null===b)return"null";var a=typeof b;return"object"===a||"array"===a||"function"===a?b.toString():""+b}
|
|
65
|
+
function dc(b,a){switch(a){case 2:return function(c){return this.fromWireType(Fa[c>>2])};case 3:return function(c){return this.fromWireType(Ga[c>>3])};default:throw new TypeError("Unknown float type: "+b);}}
|
|
66
|
+
function ec(b,a,c){switch(a){case 0:return c?function(d){return Ca[d]}:function(d){return L[d]};case 1:return c?function(d){return Da[d>>1]}:function(d){return Ea[d>>1]};case 2:return c?function(d){return M[d>>2]}:function(d){return O[d>>2]};default:throw new TypeError("Unknown integer type: "+b);}}
|
|
67
|
+
var fc=(b,a,c,d)=>{if(0<d){d=c+d-1;for(var e=0;e<b.length;++e){var f=b.charCodeAt(e);if(55296<=f&&57343>=f){var m=b.charCodeAt(++e);f=65536+((f&1023)<<10)|m&1023}if(127>=f){if(c>=d)break;a[c++]=f}else{if(2047>=f){if(c+1>=d)break;a[c++]=192|f>>6}else{if(65535>=f){if(c+2>=d)break;a[c++]=224|f>>12}else{if(c+3>=d)break;a[c++]=240|f>>18;a[c++]=128|f>>12&63}a[c++]=128|f>>6&63}a[c++]=128|f&63}}a[c]=0}},gc=b=>{for(var a=0,c=0;c<b.length;++c){var d=b.charCodeAt(c);127>=d?a++:2047>=d?a+=2:55296<=d&&57343>=
|
|
68
|
+
d?(a+=4,++c):a+=3}return a},hc="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,ic=(b,a,c)=>{var d=a+c;for(c=a;b[c]&&!(c>=d);)++c;if(16<c-a&&b.buffer&&hc)return hc.decode(b.subarray(a,c));for(d="";a<c;){var e=b[a++];if(e&128){var f=b[a++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|f);else{var m=b[a++]&63;e=224==(e&240)?(e&15)<<12|f<<6|m:(e&7)<<18|f<<12|m<<6|b[a++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d},
|
|
69
|
+
jc="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,lc=(b,a)=>{var c=b>>1;for(var d=c+a/2;!(c>=d)&&Ea[c];)++c;c<<=1;if(32<c-b&&jc)return jc.decode(L.subarray(b,c));c="";for(d=0;!(d>=a/2);++d){var e=Da[b+2*d>>1];if(0==e)break;c+=String.fromCharCode(e)}return c},mc=(b,a,c)=>{void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=a;c=c<2*b.length?c/2:b.length;for(var e=0;e<c;++e)Da[a>>1]=b.charCodeAt(e),a+=2;Da[a>>1]=0;return a-d},nc=b=>2*b.length,oc=(b,a)=>{for(var c=0,d="";!(c>=a/
|
|
70
|
+
4);){var e=M[b+4*c>>2];if(0==e)break;++c;65536<=e?(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023)):d+=String.fromCharCode(e)}return d},pc=(b,a,c)=>{void 0===c&&(c=2147483647);if(4>c)return 0;var d=a;c=d+c-4;for(var e=0;e<b.length;++e){var f=b.charCodeAt(e);if(55296<=f&&57343>=f){var m=b.charCodeAt(++e);f=65536+((f&1023)<<10)|m&1023}M[a>>2]=f;a+=4;if(a+4>c)break}M[a>>2]=0;return a-d},qc=b=>{for(var a=0,c=0;c<b.length;++c){var d=b.charCodeAt(c);55296<=d&&57343>=d&&++c;a+=4}return a},rc={};
|
|
71
|
+
function sc(b){var a=rc[b];return void 0===a?V(b):a}var tc=[];function uc(b){var a=tc.length;tc.push(b);return a}function vc(b,a){for(var c=Array(b),d=0;d<b;++d)c[d]=ob(O[a+4*d>>2],"parameter "+d);return c}
|
|
72
|
+
var wc=[],xc={},zc=()=>{if(!yc){var b={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:pa||"./this.program"},a;for(a in xc)void 0===xc[a]?delete b[a]:b[a]=xc[a];var c=[];for(a in b)c.push(`${a}=${b[a]}`);yc=c}return yc},yc,Ac=[null,[],[]],Bc=b=>0===b%4&&(0!==b%100||0===b%400),Cc=[31,29,31,30,31,30,31,31,30,31,30,31],Dc=[31,28,31,30,31,30,31,31,30,31,30,31];
|
|
73
|
+
function Ec(b){var a=Array(gc(b)+1);fc(b,a,0,a.length);return a}
|
|
74
|
+
var Fc=(b,a,c,d)=>{function e(g,n,w){for(g="number"==typeof g?g.toString():g||"";g.length<n;)g=w[0]+g;return g}function f(g,n){return e(g,n,"0")}function m(g,n){function w(x){return 0>x?-1:0<x?1:0}var H;0===(H=w(g.getFullYear()-n.getFullYear()))&&0===(H=w(g.getMonth()-n.getMonth()))&&(H=w(g.getDate()-n.getDate()));return H}function l(g){switch(g.getDay()){case 0:return new Date(g.getFullYear()-1,11,29);case 1:return g;case 2:return new Date(g.getFullYear(),0,3);case 3:return new Date(g.getFullYear(),
|
|
75
|
+
0,2);case 4:return new Date(g.getFullYear(),0,1);case 5:return new Date(g.getFullYear()-1,11,31);case 6:return new Date(g.getFullYear()-1,11,30)}}function p(g){var n=g.ta;for(g=new Date((new Date(g.ua+1900,0,1)).getTime());0<n;){var w=g.getMonth(),H=(Bc(g.getFullYear())?Cc:Dc)[w];if(n>H-g.getDate())n-=H-g.getDate()+1,g.setDate(1),11>w?g.setMonth(w+1):(g.setMonth(0),g.setFullYear(g.getFullYear()+1));else{g.setDate(g.getDate()+n);break}}w=new Date(g.getFullYear()+1,0,4);n=l(new Date(g.getFullYear(),
|
|
76
|
+
0,4));w=l(w);return 0>=m(n,g)?0>=m(w,g)?g.getFullYear()+1:g.getFullYear():g.getFullYear()-1}var k=M[d+40>>2];d={Yb:M[d>>2],Xb:M[d+4>>2],Ia:M[d+8>>2],Qa:M[d+12>>2],Ja:M[d+16>>2],ua:M[d+20>>2],na:M[d+24>>2],ta:M[d+28>>2],bc:M[d+32>>2],Wb:M[d+36>>2],Zb:k?k?ic(L,k):"":""};c=c?ic(L,c):"";k={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y",
|
|
77
|
+
"%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var r in k)c=c.replace(new RegExp(r,"g"),k[r]);var u="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),t="January February March April May June July August September October November December".split(" ");k={"%a":g=>u[g.na].substring(0,3),"%A":g=>u[g.na],"%b":g=>t[g.Ja].substring(0,3),"%B":g=>t[g.Ja],"%C":g=>f((g.ua+1900)/
|
|
78
|
+
100|0,2),"%d":g=>f(g.Qa,2),"%e":g=>e(g.Qa,2," "),"%g":g=>p(g).toString().substring(2),"%G":g=>p(g),"%H":g=>f(g.Ia,2),"%I":g=>{g=g.Ia;0==g?g=12:12<g&&(g-=12);return f(g,2)},"%j":g=>{for(var n=0,w=0;w<=g.Ja-1;n+=(Bc(g.ua+1900)?Cc:Dc)[w++]);return f(g.Qa+n,3)},"%m":g=>f(g.Ja+1,2),"%M":g=>f(g.Xb,2),"%n":()=>"\n","%p":g=>0<=g.Ia&&12>g.Ia?"AM":"PM","%S":g=>f(g.Yb,2),"%t":()=>"\t","%u":g=>g.na||7,"%U":g=>f(Math.floor((g.ta+7-g.na)/7),2),"%V":g=>{var n=Math.floor((g.ta+7-(g.na+6)%7)/7);2>=(g.na+371-g.ta-
|
|
79
|
+
2)%7&&n++;if(n)53==n&&(w=(g.na+371-g.ta)%7,4==w||3==w&&Bc(g.ua)||(n=1));else{n=52;var w=(g.na+7-g.ta-1)%7;(4==w||5==w&&Bc(g.ua%400-1))&&n++}return f(n,2)},"%w":g=>g.na,"%W":g=>f(Math.floor((g.ta+7-(g.na+6)%7)/7),2),"%y":g=>(g.ua+1900).toString().substring(2),"%Y":g=>g.ua+1900,"%z":g=>{g=g.Wb;var n=0<=g;g=Math.abs(g)/60;return(n?"+":"-")+String("0000"+(g/60*100+g%60)).slice(-4)},"%Z":g=>g.Zb,"%%":()=>"%"};c=c.replace(/%%/g,"\x00\x00");for(r in k)c.includes(r)&&(c=c.replace(new RegExp(r,"g"),k[r](d)));
|
|
80
|
+
c=c.replace(/\0\0/g,"%");r=Ec(c);if(r.length>a)return 0;Ca.set(r,b);return r.length-1};Object.assign(ab.prototype,{get(b){return this.qa[b]},has(b){return void 0!==this.qa[b]},tb(b){var a=this.bb.pop()||this.qa.length;this.qa[a]=b;return a},wb(b){this.qa[b]=void 0;this.bb.push(b)}});bb=h.BindingError=class extends Error{constructor(b){super(b);this.name="BindingError"}};P.qa.push({value:void 0},{value:null},{value:!0},{value:!1});P.Xa=P.qa.length;
|
|
81
|
+
h.count_emval_handles=function(){for(var b=0,a=P.Xa;a<P.qa.length;++a)void 0!==P.qa[a]&&++b;return b};db=h.PureVirtualError=cb("PureVirtualError");for(var Gc=Array(256),Hc=0;256>Hc;++Hc)Gc[Hc]=String.fromCharCode(Hc);eb=Gc;h.getInheritedInstanceCount=function(){return Object.keys(ib).length};h.getLiveInheritedInstances=function(){var b=[],a;for(a in ib)ib.hasOwnProperty(a)&&b.push(ib[a]);return b};h.flushPendingDeletes=gb;h.setDelayFunction=function(b){hb=b;fb.length&&hb&&hb(gb)};
|
|
82
|
+
zb=h.InternalError=class extends Error{constructor(b){super(b);this.name="InternalError"}};Lb.prototype.isAliasOf=function(b){if(!(this instanceof Lb&&b instanceof Lb))return!1;var a=this.ba.ea.ca,c=this.ba.da,d=b.ba.ea.ca;for(b=b.ba.da;a.fa;)c=a.Ba(c),a=a.fa;for(;d.fa;)b=d.Ba(b),d=d.fa;return a===d&&c===b};
|
|
83
|
+
Lb.prototype.clone=function(){this.ba.da||Kb(this);if(this.ba.ya)return this.ba.count.value+=1,this;var b=Cb,a=Object,c=a.create,d=Object.getPrototypeOf(this),e=this.ba;b=b(c.call(a,d,{ba:{value:{count:e.count,wa:e.wa,ya:e.ya,da:e.da,ea:e.ea,ia:e.ia,la:e.la}}}));b.ba.count.value+=1;b.ba.wa=!1;return b};Lb.prototype["delete"]=function(){this.ba.da||Kb(this);this.ba.wa&&!this.ba.ya&&R("Object already scheduled for deletion");pb(this);rb(this.ba);this.ba.ya||(this.ba.ia=void 0,this.ba.da=void 0)};
|
|
84
|
+
Lb.prototype.isDeleted=function(){return!this.ba.da};Lb.prototype.deleteLater=function(){this.ba.da||Kb(this);this.ba.wa&&!this.ba.ya&&R("Object already scheduled for deletion");fb.push(this);1===fb.length&&hb&&hb(gb);this.ba.wa=!0;return this};Ub.prototype.Fb=function(b){this.hb&&(b=this.hb(b));return b};Ub.prototype.Ya=function(b){this.ra&&this.ra(b)};Ub.prototype.argPackAdvance=8;Ub.prototype.readValueFromPointer=Fb;Ub.prototype.deleteObject=function(b){if(null!==b)b["delete"]()};
|
|
85
|
+
Ub.prototype.fromWireType=function(b){function a(){return this.Ea?Bb(this.ca.ma,{ea:this.Qb,da:c,la:this,ia:b}):Bb(this.ca.ma,{ea:this,da:b})}var c=this.Fb(b);if(!c)return this.Ya(b),null;var d=yb(this.ca,c);if(void 0!==d){if(0===d.ba.count.value)return d.ba.da=c,d.ba.ia=b,d.clone();d=d.clone();this.Ya(b);return d}d=this.ca.Eb(c);d=xb[d];if(!d)return a.call(this);d=this.Da?d.ub:d.pointerType;var e=wb(c,this.ca,d.ca);return null===e?a.call(this):this.Ea?Bb(d.ca.ma,{ea:d,da:e,la:this,ia:b}):Bb(d.ca.ma,
|
|
86
|
+
{ea:d,da:e})};Xb=h.UnboundTypeError=cb("UnboundTypeError");
|
|
87
|
+
var Jc={N:function(b,a,c){b=V(b);a=ob(a,"wrapper");c=S(c);var d=[].slice,e=a.ca,f=e.ma,m=e.fa.ma,l=e.fa.constructor;b=$a(b,function(){e.fa.gb.forEach(function(k){if(this[k]===m[k])throw new db(`Pure virtual function ${k} must be implemented in JavaScript`);}.bind(this));Object.defineProperty(this,"__parent",{value:f});this.__construct.apply(this,d.call(arguments))});f.__construct=function(){this===f&&R("Pass correct 'this' to __construct");var k=l.implement.apply(void 0,[this].concat(d.call(arguments)));
|
|
88
|
+
pb(k);var r=k.ba;k.notifyOnDestruction();r.ya=!0;Object.defineProperties(this,{ba:{value:r}});Cb(this);k=r.da;k=jb(e,k);ib.hasOwnProperty(k)?R(`Tried to register registered instance: ${k}`):ib[k]=this};f.__destruct=function(){this===f&&R("Pass correct 'this' to __destruct");pb(this);var k=this.ba.da;k=jb(e,k);ib.hasOwnProperty(k)?delete ib[k]:R(`Tried to unregister unregistered instance: ${k}`)};b.prototype=Object.create(f);for(var p in c)b.prototype[p]=c[p];return U(b)},O:function(b){var a=Db[b];
|
|
89
|
+
delete Db[b];var c=a.Oa,d=a.ra,e=a.ab,f=e.map(m=>m.Ib).concat(e.map(m=>m.Tb));X([b],f,m=>{var l={};e.forEach((p,k)=>{var r=m[k],u=p.Gb,t=p.Hb,g=m[k+e.length],n=p.Sb,w=p.Ub;l[p.Cb]={read:H=>r.fromWireType(u(t,H)),write:(H,x)=>{var A=[];n(w,H,g.toWireType(A,x));Eb(A)}}});return[{name:a.name,fromWireType:function(p){var k={},r;for(r in l)k[r]=l[r].read(p);d(p);return k},toWireType:function(p,k){for(var r in l)if(!(r in k))throw new TypeError(`Missing field: "${r}"`);var u=c();for(r in l)l[r].write(u,
|
|
90
|
+
k[r]);null!==p&&p.push(d,u);return u},argPackAdvance:8,readValueFromPointer:Fb,ka:d}]})},C:function(){},K:function(b,a,c,d,e){var f=Ib(c);a=V(a);Y(b,{name:a,fromWireType:function(m){return!!m},toWireType:function(m,l){return l?d:e},argPackAdvance:8,readValueFromPointer:function(m){if(1===c)var l=Ca;else if(2===c)l=Da;else if(4===c)l=M;else throw new TypeError("Unknown boolean type size: "+a);return this.fromWireType(l[m>>f])},ka:null})},f:function(b,a,c,d,e,f,m,l,p,k,r,u,t){r=V(r);f=Z(e,f);l&&(l=
|
|
91
|
+
Z(m,l));k&&(k=Z(p,k));t=Z(u,t);var g=Ya(r);Nb(g,function(){Yb(`Cannot construct ${r} due to unbound types`,[d])});X([b,a,c],d?[d]:[],function(n){n=n[0];if(d){var w=n.ca;var H=w.ma}else H=Lb.prototype;n=$a(g,function(){if(Object.getPrototypeOf(this)!==x)throw new bb("Use 'new' to construct "+r);if(void 0===A.sa)throw new bb(r+" has no accessible constructor");var Q=A.sa[arguments.length];if(void 0===Q)throw new bb(`Tried to invoke ctor of ${r} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(A.sa).toString()}) parameters instead!`);
|
|
92
|
+
return Q.apply(this,arguments)});var x=Object.create(H,{constructor:{value:n}});n.prototype=x;var A=new Ob(r,n,x,t,w,f,l,k);A.fa&&(void 0===A.fa.Ca&&(A.fa.Ca=[]),A.fa.Ca.push(A));w=new Ub(r,A,!0,!1);H=new Ub(r+"*",A,!1,!1);var J=new Ub(r+" const*",A,!1,!0);xb[b]={pointerType:H,ub:J};Vb(g,n);return[w,H,J]})},j:function(b,a,c,d,e,f,m){var l=$b(c,d);a=V(a);f=Z(e,f);X([],[b],function(p){function k(){Yb(`Cannot call ${r} due to unbound types`,l)}p=p[0];var r=`${p.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);
|
|
93
|
+
var u=p.ca.constructor;void 0===u[a]?(k.va=c-1,u[a]=k):(Mb(u,a,r),u[a].ga[c-1]=k);X([],l,function(t){t=Zb(r,[t[0],null].concat(t.slice(1)),null,f,m);void 0===u[a].ga?(t.va=c-1,u[a]=t):u[a].ga[c-1]=t;if(p.ca.Ca)for(const g of p.ca.Ca)g.constructor.hasOwnProperty(a)||(g.constructor[a]=t);return[]});return[]})},x:function(b,a,c,d,e,f,m,l){a=V(a);f=Z(e,f);X([],[b],function(p){p=p[0];var k=`${p.name}.${a}`,r={get(){Yb(`Cannot access ${k} due to unbound types`,[c])},enumerable:!0,configurable:!0};r.set=
|
|
94
|
+
l?()=>{Yb(`Cannot access ${k} due to unbound types`,[c])}:()=>{R(`${k} is a read-only property`)};Object.defineProperty(p.ca.constructor,a,r);X([],[c],function(u){u=u[0];var t={get(){return u.fromWireType(f(d))},enumerable:!0};l&&(l=Z(m,l),t.set=g=>{var n=[];l(d,u.toWireType(n,g));Eb(n)});Object.defineProperty(p.ca.constructor,a,t);return[]});return[]})},s:function(b,a,c,d,e,f){var m=$b(a,c);e=Z(d,e);X([],[b],function(l){l=l[0];var p=`constructor ${l.name}`;void 0===l.ca.sa&&(l.ca.sa=[]);if(void 0!==
|
|
95
|
+
l.ca.sa[a-1])throw new bb(`Cannot register multiple constructors with identical number of parameters (${a-1}) for class '${l.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);l.ca.sa[a-1]=()=>{Yb(`Cannot construct ${l.name} due to unbound types`,m)};X([],m,function(k){k.splice(1,0,null);l.ca.sa[a-1]=Zb(p,k,null,e,f);return[]});return[]})},a:function(b,a,c,d,e,f,m,l){var p=$b(c,d);a=V(a);f=Z(e,f);X([],[b],function(k){function r(){Yb(`Cannot call ${u} due to unbound types`,
|
|
96
|
+
p)}k=k[0];var u=`${k.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);l&&k.ca.gb.push(a);var t=k.ca.ma,g=t[a];void 0===g||void 0===g.ga&&g.className!==k.name&&g.va===c-2?(r.va=c-2,r.className=k.name,t[a]=r):(Mb(t,a,u),t[a].ga[c-2]=r);X([],p,function(n){n=Zb(u,n,k,f,m);void 0===t[a].ga?(n.va=c-2,t[a]=n):t[a].ga[c-2]=n;return[]});return[]})},e:function(b,a,c,d,e,f,m,l,p,k){a=V(a);e=Z(d,e);X([],[b],function(r){r=r[0];var u=`${r.name}.${a}`,t={get(){Yb(`Cannot access ${u} due to unbound types`,
|
|
97
|
+
[c,m])},enumerable:!0,configurable:!0};t.set=p?()=>{Yb(`Cannot access ${u} due to unbound types`,[c,m])}:()=>{R(u+" is a read-only property")};Object.defineProperty(r.ca.ma,a,t);X([],p?[c,m]:[c],function(g){var n=g[0],w={get(){var x=ac(this,r,u+" getter");return n.fromWireType(e(f,x))},enumerable:!0};if(p){p=Z(l,p);var H=g[1];w.set=function(x){var A=ac(this,r,u+" setter"),J=[];p(k,A,H.toWireType(J,x));Eb(J)}}Object.defineProperty(r.ca.ma,a,w);return[]});return[]})},J:function(b,a){a=V(a);Y(b,{name:a,
|
|
98
|
+
fromWireType:function(c){var d=S(c);bc(c);return d},toWireType:function(c,d){return U(d)},argPackAdvance:8,readValueFromPointer:Fb,ka:null})},p:function(b,a,c,d){function e(){}c=Ib(c);a=V(a);e.values={};Y(b,{name:a,constructor:e,fromWireType:function(f){return this.constructor.values[f]},toWireType:function(f,m){return m.value},argPackAdvance:8,readValueFromPointer:cc(a,c,d),ka:null});Nb(a,e)},d:function(b,a,c){var d=ob(b,"enum");a=V(a);b=d.constructor;d=Object.create(d.constructor.prototype,{value:{value:c},
|
|
99
|
+
constructor:{value:$a(`${d.name}_${a}`,function(){})}});b.values[c]=d;b[a]=d},y:function(b,a,c){c=Ib(c);a=V(a);Y(b,{name:a,fromWireType:function(d){return d},toWireType:function(d,e){return e},argPackAdvance:8,readValueFromPointer:dc(a,c),ka:null})},m:function(b,a,c,d,e,f){var m=$b(a,c);b=V(b);e=Z(d,e);Nb(b,function(){Yb(`Cannot call ${b} due to unbound types`,m)},a-1);X([],m,function(l){Vb(b,Zb(b,[l[0],null].concat(l.slice(1)),null,e,f),a-1);return[]})},l:function(b,a,c,d,e){a=V(a);-1===e&&(e=4294967295);
|
|
100
|
+
e=Ib(c);var f=l=>l;if(0===d){var m=32-8*c;f=l=>l<<m>>>m}c=a.includes("unsigned")?function(l,p){return p>>>0}:function(l,p){return p};Y(b,{name:a,fromWireType:f,toWireType:c,argPackAdvance:8,readValueFromPointer:ec(a,e,0!==d),ka:null})},g:function(b,a,c){function d(f){f>>=2;var m=O;return new e(m.buffer,m[f+1],m[f])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][a];c=V(c);Y(b,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{Jb:!0})},
|
|
101
|
+
z:function(b,a){a=V(a);var c="std::string"===a;Y(b,{name:a,fromWireType:function(d){var e=O[d>>2],f=d+4;if(c)for(var m=f,l=0;l<=e;++l){var p=f+l;if(l==e||0==L[p]){m=m?ic(L,m,p-m):"";if(void 0===k)var k=m;else k+=String.fromCharCode(0),k+=m;m=p+1}}else{k=Array(e);for(l=0;l<e;++l)k[l]=String.fromCharCode(L[f+l]);k=k.join("")}nb(d);return k},toWireType:function(d,e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));var f="string"==typeof e;f||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof
|
|
102
|
+
Int8Array||R("Cannot pass non-string to std::string");var m=c&&f?gc(e):e.length;var l=Ic(4+m+1),p=l+4;O[l>>2]=m;if(c&&f)fc(e,L,p,m+1);else if(f)for(f=0;f<m;++f){var k=e.charCodeAt(f);255<k&&(nb(p),R("String has UTF-16 code units that do not fit in 8 bits"));L[p+f]=k}else for(f=0;f<m;++f)L[p+f]=e[f];null!==d&&d.push(nb,l);return l},argPackAdvance:8,readValueFromPointer:Fb,ka:function(d){nb(d)}})},u:function(b,a,c){c=V(c);if(2===a){var d=lc;var e=mc;var f=nc;var m=()=>Ea;var l=1}else 4===a&&(d=oc,e=
|
|
103
|
+
pc,f=qc,m=()=>O,l=2);Y(b,{name:c,fromWireType:function(p){for(var k=O[p>>2],r=m(),u,t=p+4,g=0;g<=k;++g){var n=p+4+g*a;if(g==k||0==r[n>>l])t=d(t,n-t),void 0===u?u=t:(u+=String.fromCharCode(0),u+=t),t=n+a}nb(p);return u},toWireType:function(p,k){"string"!=typeof k&&R(`Cannot pass non-string to C++ string type ${c}`);var r=f(k),u=Ic(4+r+a);O[u>>2]=r>>l;e(k,u+4,r+a);null!==p&&p.push(nb,u);return u},argPackAdvance:8,readValueFromPointer:Fb,ka:function(p){nb(p)}})},Q:function(b,a,c,d,e,f){Db[b]={name:V(a),
|
|
104
|
+
Oa:Z(c,d),ra:Z(e,f),ab:[]}},P:function(b,a,c,d,e,f,m,l,p,k){Db[b].ab.push({Cb:V(a),Ib:c,Gb:Z(d,e),Hb:f,Tb:m,Sb:Z(l,p),Ub:k})},L:function(b,a){a=V(a);Y(b,{Lb:!0,name:a,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},v:function(b,a,c){b=S(b);a=ob(a,"emval::as");var d=[],e=U(d);O[c>>2]=e;return a.toWireType(d,b)},w:function(b,a,c,d,e){b=tc[b];a=S(a);c=sc(c);var f=[];O[d>>2]=U(f);return b(a,c,f,e)},i:function(b,a,c,d){b=tc[b];a=S(a);c=sc(c);b(a,c,null,d)},c:bc,h:function(b,a){var c=
|
|
105
|
+
vc(b,a),d=c[0];a=d.name+"_$"+c.slice(1).map(function(m){return m.name}).join("_")+"$";var e=wc[a];if(void 0!==e)return e;var f=Array(b-1);e=uc((m,l,p,k)=>{for(var r=0,u=0;u<b-1;++u)f[u]=c[u+1].readValueFromPointer(k+r),r+=c[u+1].argPackAdvance;m=m[l].apply(m,f);for(u=0;u<b-1;++u)c[u+1].xb&&c[u+1].xb(f[u]);if(!d.Lb)return d.toWireType(p,m)});return wc[a]=e},t:function(b){b=sc(b);return U(h[b])},M:function(b,a){b=S(b);a=S(a);return U(b[a])},n:function(b){4<b&&(P.get(b).ib+=1)},o:function(b){return U(sc(b))},
|
|
106
|
+
A:function(){return U({})},q:function(b){var a=S(b);Eb(a);bc(b)},k:function(b,a,c){b=S(b);a=S(a);c=S(c);b[a]=c},r:function(b,a){b=ob(b,"_emval_take_value");b=b.readValueFromPointer(a);return U(b)},b:()=>{za("")},E:b=>{var a=L.length;b>>>=0;if(2147483648<b)return!1;for(var c=1;4>=c;c*=2){var d=a*(1+.2/c);d=Math.min(d,b+100663296);var e=Math;d=Math.max(b,d);a:{e=e.min.call(e,2147483648,d+(65536-d%65536)%65536)-Aa.buffer.byteLength+65535>>>16;try{Aa.grow(e);Ha();var f=1;break a}catch(m){}f=void 0}if(f)return!0}return!1},
|
|
107
|
+
F:(b,a)=>{var c=0;zc().forEach(function(d,e){var f=a+c;e=O[b+4*e>>2]=f;for(f=0;f<d.length;++f)Ca[e++>>0]=d.charCodeAt(f);Ca[e>>0]=0;c+=d.length+1});return 0},G:(b,a)=>{var c=zc();O[b>>2]=c.length;var d=0;c.forEach(function(e){d+=e.length+1});O[a>>2]=d;return 0},H:()=>52,B:function(){return 70},I:(b,a,c,d)=>{for(var e=0,f=0;f<c;f++){var m=O[a>>2],l=O[a+4>>2];a+=8;for(var p=0;p<l;p++){var k=L[m+p],r=Ac[b];0===k||10===k?((1===b?wa:xa)(ic(r,0)),r.length=0):r.push(k)}e+=l}O[d>>2]=e;return 0},D:(b,a,c,
|
|
108
|
+
d)=>Fc(b,a,c,d)};(function(){function b(c){I=c=c.exports;Aa=I.R;Ha();Ia=I.X;Ka.unshift(I.S);Na--;h.monitorRunDependencies&&h.monitorRunDependencies(Na);if(0==Na&&(null!==Oa&&(clearInterval(Oa),Oa=null),Pa)){var d=Pa;Pa=null;d()}return c}var a={a:Jc};Na++;h.monitorRunDependencies&&h.monitorRunDependencies(Na);if(h.instantiateWasm)try{return h.instantiateWasm(a,b)}catch(c){xa("Module.instantiateWasm callback failed with error: "+c),ca(c)}Wa(a,function(c){b(c.instance)}).catch(ca);return{}})();
|
|
109
|
+
var nb=b=>(nb=I.T)(b),Ic=b=>(Ic=I.U)(b),mb=b=>(mb=I.V)(b);h.__embind_initialize_bindings=()=>(h.__embind_initialize_bindings=I.W)();h.dynCall_jiji=(b,a,c,d,e)=>(h.dynCall_jiji=I.Y)(b,a,c,d,e);h.dynCall_viijii=(b,a,c,d,e,f,m)=>(h.dynCall_viijii=I.Z)(b,a,c,d,e,f,m);h.dynCall_iiiiij=(b,a,c,d,e,f,m)=>(h.dynCall_iiiiij=I._)(b,a,c,d,e,f,m);h.dynCall_iiiiijj=(b,a,c,d,e,f,m,l,p)=>(h.dynCall_iiiiijj=I.$)(b,a,c,d,e,f,m,l,p);
|
|
110
|
+
h.dynCall_iiiiiijj=(b,a,c,d,e,f,m,l,p,k)=>(h.dynCall_iiiiiijj=I.aa)(b,a,c,d,e,f,m,l,p,k);var Kc;Pa=function Lc(){Kc||Mc();Kc||(Pa=Lc)};
|
|
111
|
+
function Mc(){function b(){if(!Kc&&(Kc=!0,h.calledRun=!0,!Ba)){Xa(Ka);ba(h);if(h.onRuntimeInitialized)h.onRuntimeInitialized();if(h.postRun)for("function"==typeof h.postRun&&(h.postRun=[h.postRun]);h.postRun.length;){var a=h.postRun.shift();La.unshift(a)}Xa(La)}}if(!(0<Na)){if(h.preRun)for("function"==typeof h.preRun&&(h.preRun=[h.preRun]);h.preRun.length;)Ma();Xa(Ja);0<Na||(h.setStatus?(h.setStatus("Running..."),setTimeout(function(){setTimeout(function(){h.setStatus("")},1);b()},1)):b())}}
|
|
112
|
+
if(h.preInit)for("function"==typeof h.preInit&&(h.preInit=[h.preInit]);0<h.preInit.length;)h.preInit.pop()();Mc();
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
return moduleArg.ready
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
);
|
|
119
|
+
})();
|
|
120
|
+
export default Rive;
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rive-app/canvas-advanced-lite",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Rive's lite low-level canvas based web api.",
|
|
5
|
+
"main": "canvas_advanced.mjs",
|
|
6
|
+
"homepage": "https://rive.app",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/rive-app/rive-wasm/tree/master/js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"rive",
|
|
13
|
+
"animation"
|
|
14
|
+
],
|
|
15
|
+
"author": "Rive",
|
|
16
|
+
"contributors": [
|
|
17
|
+
"Luigi Rosso <luigi@rive.app> (https://rive.app)",
|
|
18
|
+
"Maxwell Talbot <max@rive.app> (https://rive.app)",
|
|
19
|
+
"Arthur Vivian <arthur@rive.app> (https://rive.app)",
|
|
20
|
+
"Umberto Sonnino <umberto@rive.app> (https://rive.app)",
|
|
21
|
+
"Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"files": [
|
|
25
|
+
"canvas_advanced.mjs",
|
|
26
|
+
"rive.wasm",
|
|
27
|
+
"rive_advanced.mjs.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"typings": "rive_advanced.d.ts",
|
|
30
|
+
"dependencies": {},
|
|
31
|
+
"browser": {
|
|
32
|
+
"fs": false,
|
|
33
|
+
"path": false
|
|
34
|
+
}
|
|
35
|
+
}
|
package/rive.wasm
ADDED
|
Binary file
|
|
@@ -0,0 +1,873 @@
|
|
|
1
|
+
interface RiveOptions {
|
|
2
|
+
locateFile(file: string): string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
declare function Rive(options?: RiveOptions): Promise<RiveCanvas>;
|
|
6
|
+
export default Rive;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* RiveCanvas is the main export object that contains references to different Rive classes to help
|
|
10
|
+
* build the Rive render loop for low-level API usage. In addition, this contains multiple methods
|
|
11
|
+
* that help aid in setup, such as loading in a Rive file, creating the renderer, and
|
|
12
|
+
* starting/finishing the render loop (requestAnimationFrame)
|
|
13
|
+
*/
|
|
14
|
+
export interface RiveCanvas {
|
|
15
|
+
Alignment: AlignmentFactory;
|
|
16
|
+
CanvasRenderer: typeof CanvasRenderer;
|
|
17
|
+
LinearAnimationInstance: typeof LinearAnimationInstance;
|
|
18
|
+
StateMachineInstance: typeof StateMachineInstance;
|
|
19
|
+
CustomFileAssetLoader: typeof CustomFileAssetLoader;
|
|
20
|
+
Mat2D: typeof Mat2D;
|
|
21
|
+
Vec2D: typeof Vec2D;
|
|
22
|
+
AABB: AABB;
|
|
23
|
+
SMIInput: typeof SMIInput;
|
|
24
|
+
renderFactory: CanvasRenderFactory;
|
|
25
|
+
|
|
26
|
+
BlendMode: typeof BlendMode;
|
|
27
|
+
FillRule: typeof FillRule;
|
|
28
|
+
Fit: typeof Fit;
|
|
29
|
+
RenderPaintStyle: typeof RenderPaintStyle;
|
|
30
|
+
StrokeCap: typeof StrokeCap;
|
|
31
|
+
StrokeJoin: typeof StrokeJoin;
|
|
32
|
+
decodeImage: Function;
|
|
33
|
+
decodeFont: Function;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Loads a Rive file for the runtime and returns a Rive-specific File class
|
|
37
|
+
*
|
|
38
|
+
* @param buffer - Array buffer of a Rive file
|
|
39
|
+
* @param assetLoader - FileAssetLoader used to optionally customize loading of font and image assets
|
|
40
|
+
* @param enableRiveAssetCDN - boolean flag to allow loading assets from the Rive CDN, enabled by default.
|
|
41
|
+
* @returns A Promise for a Rive File class
|
|
42
|
+
*/
|
|
43
|
+
load(
|
|
44
|
+
buffer: Uint8Array,
|
|
45
|
+
assetLoader?: FileAssetLoader,
|
|
46
|
+
enableRiveAssetCDN?: boolean,
|
|
47
|
+
): Promise<File>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates the renderer to draw the Rive on the provided canvas element
|
|
51
|
+
*
|
|
52
|
+
* @param canvas - Canvas to draw the Rive on
|
|
53
|
+
* @param useOffscreenRenderer - Option for those using the WebGL-variant of the Rive JS library.
|
|
54
|
+
* This uses an offscreen renderer to draw on the canvas, allowing for multiple Rives/canvases on
|
|
55
|
+
* a given screen. It is highly recommended to set this to `true` when using with the
|
|
56
|
+
* `@rive-app/webgl` package
|
|
57
|
+
* @returns A Rive CanvasRenderer (Canvas2D) or Renderer (WebGL) class
|
|
58
|
+
*/
|
|
59
|
+
makeRenderer(
|
|
60
|
+
canvas: HTMLCanvasElement | OffscreenCanvas,
|
|
61
|
+
useOffscreenRenderer?: boolean,
|
|
62
|
+
): WrappedRenderer;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Computes how the Rive is laid out onto the canvas
|
|
66
|
+
* @param {Fit} fit - Fit enum (i.e Fit.contain)
|
|
67
|
+
* @param alignment - Alignment enum (i.e Alignment.center)
|
|
68
|
+
* @param frame - AABB object representing the bounds of the canvas frame
|
|
69
|
+
* @param content - AABB object representing the bounds of what to draw the Rive onto
|
|
70
|
+
* (i.e an artboard's size)
|
|
71
|
+
* @returns Mat2D - A Mat2D view matrix
|
|
72
|
+
*/
|
|
73
|
+
computeAlignment(
|
|
74
|
+
fit: Fit,
|
|
75
|
+
alignment: Alignment,
|
|
76
|
+
frame: AABB,
|
|
77
|
+
content: AABB,
|
|
78
|
+
): Mat2D;
|
|
79
|
+
mapXY(matrix: Mat2D, canvasPoints: Vec2D): Vec2D;
|
|
80
|
+
/**
|
|
81
|
+
* A Rive-specific requestAnimationFrame function; this must be used instead of the global
|
|
82
|
+
* requestAnimationFrame function.
|
|
83
|
+
* @param cb - Callback function to call with an elapsed timestamp
|
|
84
|
+
* @returns number - An ID of the requestAnimationFrame request
|
|
85
|
+
*/
|
|
86
|
+
requestAnimationFrame(cb: (timestamp: DOMHighResTimeStamp) => void): number;
|
|
87
|
+
/**
|
|
88
|
+
* A Rive-specific cancelAnimationFrame function; this must be used instead of the global
|
|
89
|
+
* cancelAnimationFrame function.
|
|
90
|
+
* @param requestID - ID of the requestAnimationFrame request to cancel
|
|
91
|
+
*/
|
|
92
|
+
cancelAnimationFrame(requestID: number): void;
|
|
93
|
+
/**
|
|
94
|
+
* Debugging tool to showcase the FPS in the corner of the screen in a new div. If a callback
|
|
95
|
+
* function is provided, this function passes the FPS count to the callback instead of creating a
|
|
96
|
+
* new div so the client can decide what to do with that data.
|
|
97
|
+
*/
|
|
98
|
+
enableFPSCounter(cb?: (fps: number) => void): void;
|
|
99
|
+
/**
|
|
100
|
+
* Debugging tool to remove the FPS counter that displays from enableFPSCounter
|
|
101
|
+
*/
|
|
102
|
+
disableFPSCounter(): void;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Cleans up any WASM-generate objects that need to be destroyed manually.
|
|
106
|
+
* This should be called when you wish to remove a rive animation from view.
|
|
107
|
+
*/
|
|
108
|
+
cleanup(): void;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Returns whether or not there are Rive Listeners configured on a given StateMachineInstance
|
|
112
|
+
* @param stateMachine - StateMachineInstance to check for Listeners
|
|
113
|
+
* @returns bool - Boolean of if there are Listners on the state machine
|
|
114
|
+
*/
|
|
115
|
+
hasListeners(stateMachine: StateMachineInstance): boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//////////////
|
|
119
|
+
// RENDERER //
|
|
120
|
+
//////////////
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Rive wrapper around a rendering context for a canvas element, implementing a subset of the APIs
|
|
124
|
+
* from the rendering context interface
|
|
125
|
+
*/
|
|
126
|
+
export declare class RendererWrapper {
|
|
127
|
+
/**
|
|
128
|
+
* Saves the state of the canvas and pushes it onto a stack
|
|
129
|
+
*
|
|
130
|
+
* For the underlying API, check
|
|
131
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save
|
|
132
|
+
*/
|
|
133
|
+
save(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Restores the most recent state of the canvas saved on the stack
|
|
136
|
+
*
|
|
137
|
+
* For the underlying API, check
|
|
138
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/restore
|
|
139
|
+
*/
|
|
140
|
+
restore(): void;
|
|
141
|
+
transform(tranform: Mat2D): void;
|
|
142
|
+
drawPath(path: RenderPath, paint: RenderPaint): void;
|
|
143
|
+
clipPath(path: RenderPath): void;
|
|
144
|
+
/**
|
|
145
|
+
* Calls the context's clearRect() function to clear the entire canvas. Crucial to call
|
|
146
|
+
* this at the start of the render loop to clear the canvas before drawing the next frame
|
|
147
|
+
*
|
|
148
|
+
* For the underlying API, check
|
|
149
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clearRect
|
|
150
|
+
*/
|
|
151
|
+
clear(): void;
|
|
152
|
+
delete(): void;
|
|
153
|
+
flush(): void;
|
|
154
|
+
translate(x: number, y: number): void;
|
|
155
|
+
rotate(angle: number): void;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export declare class RenderPathWrapper {
|
|
159
|
+
reset(): void;
|
|
160
|
+
addPath(path: CommandPath, transform: Mat2D): void;
|
|
161
|
+
fillRule(value: FillRule): void;
|
|
162
|
+
moveTo(x: number, y: number): void;
|
|
163
|
+
lineTo(x: number, y: number): void;
|
|
164
|
+
cubicTo(
|
|
165
|
+
ox: number,
|
|
166
|
+
oy: number,
|
|
167
|
+
ix: number,
|
|
168
|
+
iy: number,
|
|
169
|
+
x: number,
|
|
170
|
+
y: number,
|
|
171
|
+
): void;
|
|
172
|
+
close(): void;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export declare class RenderPaintWrapper {
|
|
176
|
+
color(value: number): void;
|
|
177
|
+
thickness(value: number): void;
|
|
178
|
+
join(value: StrokeJoin): void;
|
|
179
|
+
cap(value: StrokeCap): void;
|
|
180
|
+
blendMode(value: BlendMode): void;
|
|
181
|
+
style(value: RenderPaintStyle): void;
|
|
182
|
+
linearGradient(sx: number, sy: number, ex: number, ey: number): void;
|
|
183
|
+
radialGradient(sx: number, sy: number, ex: number, ey: number): void;
|
|
184
|
+
addStop(color: number, stop: number): void;
|
|
185
|
+
completeGradient(): void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Renderer returned when Rive makes a renderer via `makeRenderer()`
|
|
190
|
+
*/
|
|
191
|
+
export declare class Renderer extends RendererWrapper {
|
|
192
|
+
/**
|
|
193
|
+
* Aligns the Rive content on the canvas space
|
|
194
|
+
* @param fit - Fit enum value
|
|
195
|
+
* @param alignment - Alignment enum value
|
|
196
|
+
* @param frame - Bounds of the canvas space
|
|
197
|
+
* @param content - Bounds of the Rive content
|
|
198
|
+
*/
|
|
199
|
+
align(fit: Fit, alignment: Alignment, frame: AABB, content: AABB): void;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export declare class CommandPath {}
|
|
203
|
+
|
|
204
|
+
export declare class RenderPath extends RenderPathWrapper {}
|
|
205
|
+
|
|
206
|
+
export declare class RenderPaint extends RenderPaintWrapper {}
|
|
207
|
+
|
|
208
|
+
/////////////////////
|
|
209
|
+
// CANVAS RENDERER //
|
|
210
|
+
/////////////////////
|
|
211
|
+
export declare class CanvasRenderer extends Renderer {
|
|
212
|
+
constructor(
|
|
213
|
+
ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
type OmittedCanvasRenderingContext2DMethods =
|
|
218
|
+
| "createConicGradient"
|
|
219
|
+
| "createImageData"
|
|
220
|
+
| "createLinearGradient"
|
|
221
|
+
| "createPattern"
|
|
222
|
+
| "createRadialGradient"
|
|
223
|
+
| "getContextAttributes"
|
|
224
|
+
| "getImageData"
|
|
225
|
+
| "getLineDash"
|
|
226
|
+
| "getTransform"
|
|
227
|
+
| "isContextLost"
|
|
228
|
+
| "isPointInPath"
|
|
229
|
+
| "isPointInStroke"
|
|
230
|
+
| "measureText";
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Proxy class that handles calls to a CanvasRenderer instance and handles Rive-related rendering calls such
|
|
234
|
+
* as `save`, `restore`, `transform`, and more, effectively overriding and/or wrapping Canvas2D context
|
|
235
|
+
* APIs for Rive-specific purposes. Other calls not intentionally overridden are passed through to the
|
|
236
|
+
* Canvas2D context directly.
|
|
237
|
+
*
|
|
238
|
+
* Note: Currently, any calls to the Canvas2D context that you expect to return a value (i.e. `isPointInStroke()`)
|
|
239
|
+
* will return undefined
|
|
240
|
+
*/
|
|
241
|
+
export type CanvasRendererProxy = CanvasRenderer &
|
|
242
|
+
Omit<CanvasRenderingContext2D, OmittedCanvasRenderingContext2DMethods>;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Renderer type for `makeRenderer()` that returns Renderer (webgl) or a CanvasRendererProxy (canvas2d)
|
|
246
|
+
*/
|
|
247
|
+
export type WrappedRenderer = Renderer | CanvasRendererProxy;
|
|
248
|
+
|
|
249
|
+
export declare class CanvasRenderPaint extends RenderPaint {
|
|
250
|
+
draw(
|
|
251
|
+
ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
|
|
252
|
+
path: RenderPath,
|
|
253
|
+
): void;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export declare class CanvasRenderPath extends RenderPath {}
|
|
257
|
+
|
|
258
|
+
export interface CanvasRenderFactory {
|
|
259
|
+
makeRenderPaint(): CanvasRenderPaint;
|
|
260
|
+
makeRenderPath(): CanvasRenderPath;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
//////////
|
|
264
|
+
// File //
|
|
265
|
+
//////////
|
|
266
|
+
/**
|
|
267
|
+
* Rive-specific File class that provides a number of functions to load instances of Artboards
|
|
268
|
+
*/
|
|
269
|
+
export declare class File {
|
|
270
|
+
/**
|
|
271
|
+
* Returns the first Artboard found in the Rive file as a new Artboard instance
|
|
272
|
+
* @returns An Artboard instance
|
|
273
|
+
*/
|
|
274
|
+
defaultArtboard(): Artboard; // rive::ArtboardInstance
|
|
275
|
+
/**
|
|
276
|
+
* Returns the named Artboard found in the Rive file as a new Artboard instance
|
|
277
|
+
* @param name - Name of the Artboard to create an instance for
|
|
278
|
+
*/
|
|
279
|
+
artboardByName(name: string): Artboard; // rive::ArtboardInstance
|
|
280
|
+
/**
|
|
281
|
+
* Returns a new Artboard instance for the Artboard at the given index in the Rive file
|
|
282
|
+
* @param index - Index of the Artboard in the file to create an Artboard instance for
|
|
283
|
+
*/
|
|
284
|
+
artboardByIndex(index: number): Artboard; // rive::ArtboardInstance
|
|
285
|
+
/**
|
|
286
|
+
* Returns the number of Artboards in the Rive File
|
|
287
|
+
* @returns Number of artboards in the Rive file
|
|
288
|
+
*/
|
|
289
|
+
artboardCount(): number;
|
|
290
|
+
|
|
291
|
+
delete(): void;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Rive class representing an Artboard instance. Use this class to create instances for
|
|
296
|
+
* LinearAnimations, StateMachines, Nodes, Bones, and more. This Artboard instance should also be
|
|
297
|
+
* advanced in the drawing render loop.
|
|
298
|
+
*
|
|
299
|
+
* Important: Make sure to delete this instance when it's no longer in use via the `delete()`
|
|
300
|
+
* method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
|
|
301
|
+
* be done in cases where the user navigates away from the page with this animation, the canvas is
|
|
302
|
+
* unmounted, etc.
|
|
303
|
+
*/
|
|
304
|
+
export declare class Artboard {
|
|
305
|
+
/**
|
|
306
|
+
* Get the name of this Artboard instance
|
|
307
|
+
*/
|
|
308
|
+
get name(): string;
|
|
309
|
+
/**
|
|
310
|
+
* Get the bounds of this Artboard instance
|
|
311
|
+
*/
|
|
312
|
+
get bounds(): AABB;
|
|
313
|
+
get frameOrigin(): boolean;
|
|
314
|
+
set frameOrigin(val: boolean);
|
|
315
|
+
/**
|
|
316
|
+
* Deletes the underlying instance created via the WASM. It's important to clean up this
|
|
317
|
+
* instance when no longer in use
|
|
318
|
+
*/
|
|
319
|
+
delete(): void;
|
|
320
|
+
/**
|
|
321
|
+
* Advances the Artboard instance by the set amount of seconds. This method updates each object
|
|
322
|
+
* in the Artboard with any changes that animations apply on properties of the objects. This
|
|
323
|
+
* should be called after calling `advance()` of a LinearAnimationInstance or StateMachineInstance
|
|
324
|
+
* @param sec - Scrub the Artboard instance by a number of seconds
|
|
325
|
+
*/
|
|
326
|
+
advance(sec: number): boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Draws the artboard with a given rendering context.
|
|
329
|
+
* @param renderer - Renderer context to draw with
|
|
330
|
+
*/
|
|
331
|
+
draw(renderer: CanvasRenderer | Renderer): void;
|
|
332
|
+
/**
|
|
333
|
+
* Creates a LinearAnimation for the animation with the given name
|
|
334
|
+
*
|
|
335
|
+
* Note: This does not create a LinearAnimationInstance to advance in the render loop.
|
|
336
|
+
* That needs to be created separately.
|
|
337
|
+
*
|
|
338
|
+
* @param name - Name of the animation to create a LinearAnimation reference for
|
|
339
|
+
* @returns A new LinearAnimation object
|
|
340
|
+
*/
|
|
341
|
+
animationByName(name: string): LinearAnimation;
|
|
342
|
+
/**
|
|
343
|
+
* Creates a LinearAnimation for the animation with the given index
|
|
344
|
+
*
|
|
345
|
+
* Note: This does not create a LinearAnimationInstance to advance in the render loop.
|
|
346
|
+
* That needs to be created separately.
|
|
347
|
+
*
|
|
348
|
+
* @param index - Index of the animation to create a LinearAnimation reference for
|
|
349
|
+
* @returns A new LinearAnimation object
|
|
350
|
+
*/
|
|
351
|
+
animationByIndex(index: number): LinearAnimation;
|
|
352
|
+
/**
|
|
353
|
+
* Returns the number of animations in the artboard
|
|
354
|
+
* @returns Number of animations on the Artboard
|
|
355
|
+
*/
|
|
356
|
+
animationCount(): number;
|
|
357
|
+
/**
|
|
358
|
+
* Creates a StateMachine for the state machine with the given name.
|
|
359
|
+
*
|
|
360
|
+
* Note: This does not create a StateMachineInstance to advance in the render loop.
|
|
361
|
+
* That needs to be created separately.
|
|
362
|
+
*
|
|
363
|
+
* @param name - Name of the state machine to create a StateMachine reference for
|
|
364
|
+
* @returns A new StateMachine object
|
|
365
|
+
*/
|
|
366
|
+
stateMachineByName(name: string): StateMachine;
|
|
367
|
+
/**
|
|
368
|
+
* Creates a StateMachine for the state machine with the given index
|
|
369
|
+
*
|
|
370
|
+
* Note: This does not create a StateMachineInstance to advance in the render loop.
|
|
371
|
+
* That needs to be created separately.
|
|
372
|
+
*
|
|
373
|
+
* @param index - Index of the state machine to create a StateMachine reference for
|
|
374
|
+
* @returns A new StateMachine object
|
|
375
|
+
*/
|
|
376
|
+
stateMachineByIndex(index: number): StateMachine;
|
|
377
|
+
/**
|
|
378
|
+
* Returns the number of state machines in the artboard
|
|
379
|
+
* @returns Number of state machines on the Artboard
|
|
380
|
+
*/
|
|
381
|
+
stateMachineCount(): number;
|
|
382
|
+
/**
|
|
383
|
+
* Returns a reference for a Bone object of a given name.
|
|
384
|
+
* Learn more: https://help.rive.app/editor/manipulating-shapes/bones
|
|
385
|
+
*
|
|
386
|
+
* @param name - Name of the Bone to grab a reference to
|
|
387
|
+
*/
|
|
388
|
+
bone(name: string): Bone;
|
|
389
|
+
/**
|
|
390
|
+
* Returns a reference for a Node object of a given name from the Artboard hierarchy
|
|
391
|
+
* @param name - Name of the Node from the Artboard hierarchy to grab a reference to
|
|
392
|
+
*/
|
|
393
|
+
node(name: string): Node;
|
|
394
|
+
/**
|
|
395
|
+
* Returns a reference for a root Bone object of a given name
|
|
396
|
+
* @param name - Name of the root Bone to grab a reference to
|
|
397
|
+
*/
|
|
398
|
+
rootBone(name: string): RootBone;
|
|
399
|
+
/**
|
|
400
|
+
* Returns a reference for a transform component object of a given name
|
|
401
|
+
* @param name - Name of the transform component to grab a reference to
|
|
402
|
+
*/
|
|
403
|
+
transformComponent(name: string): TransformComponent;
|
|
404
|
+
/**
|
|
405
|
+
* Returns a reference for a TextValueRun object to get/set a text value for
|
|
406
|
+
* @param name - Name of the Text Run to grab a reference to
|
|
407
|
+
*/
|
|
408
|
+
textRun(name: string): TextValueRun;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export declare class Bone extends TransformComponent {
|
|
412
|
+
/**
|
|
413
|
+
* Length of the bone
|
|
414
|
+
*/
|
|
415
|
+
length: number;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export declare class RootBone extends Bone {
|
|
419
|
+
/**
|
|
420
|
+
* X coordinate of the position on the RootBone
|
|
421
|
+
*/
|
|
422
|
+
x: number;
|
|
423
|
+
/**
|
|
424
|
+
* Y coordinate of the position on the RootBone
|
|
425
|
+
*/
|
|
426
|
+
y: number;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Representation of a node in the Artboard hierarchy (i.e group, shape, etc.)
|
|
431
|
+
*/
|
|
432
|
+
export declare class Node extends TransformComponent {
|
|
433
|
+
/**
|
|
434
|
+
* X coordinate of the position on the Node
|
|
435
|
+
*/
|
|
436
|
+
x: number;
|
|
437
|
+
/**
|
|
438
|
+
* Y coordinate of the position on the RootBone
|
|
439
|
+
*/
|
|
440
|
+
y: number;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export declare class TransformComponent {
|
|
444
|
+
rotation: number;
|
|
445
|
+
scaleX: number;
|
|
446
|
+
scaleY: number;
|
|
447
|
+
worldTransform(): Mat2D;
|
|
448
|
+
parentWorldTransform(result: Mat2D): void;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
///////////////
|
|
452
|
+
// Animation //
|
|
453
|
+
///////////////
|
|
454
|
+
/**
|
|
455
|
+
* Rive class representing a LinearAnimation instance. Use this class to advance and control a
|
|
456
|
+
* particular animation in the render loop (i.e speed, scrub, mix, etc.).
|
|
457
|
+
*
|
|
458
|
+
* Important: Make sure to delete this instance when it's no longer in use via the `delete()`
|
|
459
|
+
* method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
|
|
460
|
+
* be done in cases where the user navigates away from the page with this animation, the canvas is
|
|
461
|
+
* unmounted, etc.
|
|
462
|
+
*/
|
|
463
|
+
export declare class LinearAnimationInstance {
|
|
464
|
+
/**
|
|
465
|
+
* Create a new LinearAnimationInstance reference
|
|
466
|
+
* @param animation - A LinearAnimation reference retrieved via the Artboard
|
|
467
|
+
* (i.e `artboard.animationByName('foo')`)
|
|
468
|
+
* @param artboard - The Artboard instance for this animation
|
|
469
|
+
*/
|
|
470
|
+
constructor(animation: LinearAnimation, artboard: Artboard);
|
|
471
|
+
get name(): string;
|
|
472
|
+
get duration(): number;
|
|
473
|
+
get fps(): number;
|
|
474
|
+
get workStart(): number;
|
|
475
|
+
get workEnd(): number;
|
|
476
|
+
get loopValue(): number;
|
|
477
|
+
get speed(): number;
|
|
478
|
+
/**
|
|
479
|
+
* Number of seconds the animation has advanced by
|
|
480
|
+
*/
|
|
481
|
+
time: number;
|
|
482
|
+
/**
|
|
483
|
+
* Flag to determine if the animation looped (this is reset when the loop restarts)
|
|
484
|
+
*/
|
|
485
|
+
didLoop: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Advances/scrubs the LinearAnimationInstance by the set amount of seconds. Note that this only
|
|
488
|
+
* moves the "time" in the animation, but does not apply changes to the properties in the
|
|
489
|
+
* Artboard. This must be called before the `apply()` method of LinearAnimationInstance.
|
|
490
|
+
*
|
|
491
|
+
* @param sec - Scrub the animation instance by a number of seconds
|
|
492
|
+
*/
|
|
493
|
+
advance(sec: number): boolean;
|
|
494
|
+
/**
|
|
495
|
+
* Apply a mixing value on the animation instance. This is useful if you are looking to blend
|
|
496
|
+
* multiple animations together and want to dictate a strength for each of the animations played
|
|
497
|
+
* back. This also applies new values to properties of objects on the Artboard according to the
|
|
498
|
+
* keys of the animation.
|
|
499
|
+
* This must be called after the `advance()` method of `LinearAnimationInstance`
|
|
500
|
+
*
|
|
501
|
+
* @param mix 0-1 the strength of the animation in the animations mix.
|
|
502
|
+
*/
|
|
503
|
+
apply(mix: number): void;
|
|
504
|
+
/**
|
|
505
|
+
* Deletes the underlying instance created via the WASM. It's important to clean up this instance
|
|
506
|
+
* when no longer in use
|
|
507
|
+
*/
|
|
508
|
+
delete(): void;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export declare class TextValueRun {
|
|
512
|
+
/**
|
|
513
|
+
* Getter for the name of the Text Run
|
|
514
|
+
*/
|
|
515
|
+
get name(): string;
|
|
516
|
+
/**
|
|
517
|
+
* Getter for text value of the Text Run
|
|
518
|
+
*/
|
|
519
|
+
get text(): string;
|
|
520
|
+
/**
|
|
521
|
+
* Setter for the text value of the Text Run
|
|
522
|
+
*/
|
|
523
|
+
set text(val: string);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Rive Event interface for "General" custom events defined in the Rive editor. Each event has a
|
|
528
|
+
* name and optionally some other custom properties and a type
|
|
529
|
+
*/
|
|
530
|
+
export interface RiveEvent {
|
|
531
|
+
/**
|
|
532
|
+
* Name of the event fired
|
|
533
|
+
*/
|
|
534
|
+
name: string;
|
|
535
|
+
/**
|
|
536
|
+
* Optional type of the specific kind of event fired (i.e. General, OpenUrl)
|
|
537
|
+
*/
|
|
538
|
+
type?: number;
|
|
539
|
+
/**
|
|
540
|
+
* Optional custom properties defined on the event
|
|
541
|
+
*/
|
|
542
|
+
properties?: RiveEventCustomProperties;
|
|
543
|
+
/**
|
|
544
|
+
* Optional elapsed time since the event specifically occurred
|
|
545
|
+
*/
|
|
546
|
+
delay?: number;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* A specific Rive Event type for "OpenUrl" events. This event type has a URL and optionally a
|
|
551
|
+
* target property to dictate how to open the URL
|
|
552
|
+
*/
|
|
553
|
+
export interface OpenUrlEvent extends RiveEvent {
|
|
554
|
+
/**
|
|
555
|
+
* URL to open when the event is invoked
|
|
556
|
+
*/
|
|
557
|
+
url: string;
|
|
558
|
+
/**
|
|
559
|
+
* Where to display the linked URL
|
|
560
|
+
*/
|
|
561
|
+
target?: string;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* A Rive Event may have any number of optional custom properties defined on itself with variable names
|
|
566
|
+
* and values that are either a number, boolean, or string
|
|
567
|
+
*/
|
|
568
|
+
export interface RiveEventCustomProperties {
|
|
569
|
+
/**
|
|
570
|
+
* Custom property may be named anything in the Rive editor, and given a value of
|
|
571
|
+
* a number, boolean, or string type
|
|
572
|
+
*/
|
|
573
|
+
[key: string]: number | boolean | string;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export declare class LinearAnimation {
|
|
577
|
+
/**
|
|
578
|
+
* The animation's loop type
|
|
579
|
+
*/
|
|
580
|
+
get loopValue(): number;
|
|
581
|
+
/**
|
|
582
|
+
* Name of the LinearAnimation
|
|
583
|
+
*/
|
|
584
|
+
get name(): string;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export declare class StateMachine {
|
|
588
|
+
/**
|
|
589
|
+
* Name of the StateMachine
|
|
590
|
+
*/
|
|
591
|
+
get name(): string;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Rive class representing a StateMachine instance. Use this class to advance and control a
|
|
596
|
+
* particular state machine in the render loop (i.e scrub, grab state machine inputs, set up
|
|
597
|
+
* listener events, etc.).
|
|
598
|
+
*
|
|
599
|
+
* Important: Make sure to delete this instance when it's no longer in use via the `delete()`
|
|
600
|
+
* method. This deletes the underlying c++ reference and frees up the backing WASM object. This can
|
|
601
|
+
* be done in cases where the user navigates away from the page with this animation, the canvas is
|
|
602
|
+
* unmounted, etc.
|
|
603
|
+
*/
|
|
604
|
+
export declare class StateMachineInstance {
|
|
605
|
+
/**
|
|
606
|
+
* Create a new StateMachineInstance reference
|
|
607
|
+
* @param stateMachine - A StateMachine retrieved via the Artboard
|
|
608
|
+
* (i.e `artboard.stateMachineByName('foo')`)
|
|
609
|
+
* @param artboard - The Artboard instance for this state machine
|
|
610
|
+
*/
|
|
611
|
+
constructor(stateMachine: StateMachine, artboard: Artboard);
|
|
612
|
+
get name(): string;
|
|
613
|
+
/**
|
|
614
|
+
* Returns the number of inputs associated with this state machine
|
|
615
|
+
* @returns Number of inputs
|
|
616
|
+
*/
|
|
617
|
+
inputCount(): number;
|
|
618
|
+
/**
|
|
619
|
+
* Returns the state machine input at the given index
|
|
620
|
+
* @param i - Index to retrieve the state machine input at
|
|
621
|
+
* @returns SMIInput reference
|
|
622
|
+
*/
|
|
623
|
+
input(i: number): SMIInput;
|
|
624
|
+
/**
|
|
625
|
+
* Advances/scrubs the StateMachineInstance by the set amount of seconds. Note that this does not
|
|
626
|
+
* apply changes to the properties of objects in the Artboard yet.
|
|
627
|
+
* @param sec - Scrub the state machine instance by a number of seconds
|
|
628
|
+
*/
|
|
629
|
+
advance(sec: number): boolean;
|
|
630
|
+
/**
|
|
631
|
+
* Returns the number of states changed while the state machine played
|
|
632
|
+
* @returns Number of states changed in the duration of the state machine played
|
|
633
|
+
*/
|
|
634
|
+
stateChangedCount(): number;
|
|
635
|
+
/**
|
|
636
|
+
* Returns the name of the state/animation transitioned to, given the index in the array of state
|
|
637
|
+
* changes in total
|
|
638
|
+
* @param i
|
|
639
|
+
* @returns Name of the state/animation transitioned to
|
|
640
|
+
*/
|
|
641
|
+
stateChangedNameByIndex(i: number): string;
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Returns the number of events reported from the last advance call
|
|
645
|
+
* @returns Number of events reported
|
|
646
|
+
*/
|
|
647
|
+
reportedEventCount(): number;
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Returns a RiveEvent object emitted from the last advance call at the given index
|
|
651
|
+
* of a list of potentially multiple events. If an event at the index is not found,
|
|
652
|
+
* undefined is returned.
|
|
653
|
+
* @param i index of the event reported in a list of potentially multiple events
|
|
654
|
+
* @returns RiveEvent or extended RiveEvent object returned, or undefined
|
|
655
|
+
*/
|
|
656
|
+
reportedEventAt(i: number): OpenUrlEvent | RiveEvent | undefined;
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Notifies the state machine that the pointer has pressed down at the given coordinate in
|
|
660
|
+
* Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
|
|
661
|
+
* interest at a given moment.
|
|
662
|
+
*
|
|
663
|
+
* @param x - X coordinate
|
|
664
|
+
* @param y - Y coordinate
|
|
665
|
+
*/
|
|
666
|
+
pointerDown(x: number, y: number): void;
|
|
667
|
+
/**
|
|
668
|
+
* Notifies the state machine that the pointer has moved to the given coordinate in
|
|
669
|
+
* Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
|
|
670
|
+
* interest at a given moment.
|
|
671
|
+
*
|
|
672
|
+
* @param x - X coordinate
|
|
673
|
+
* @param y - Y coordinate
|
|
674
|
+
*/
|
|
675
|
+
pointerMove(x: number, y: number): void;
|
|
676
|
+
/**
|
|
677
|
+
* Notifies the state machine that the pointer has released at the given coordinate in
|
|
678
|
+
* Artboard space. Internally, Rive may advance a state machine if the listener coordinate is of
|
|
679
|
+
* interest at a given moment.
|
|
680
|
+
* @param x - X coordinate
|
|
681
|
+
* @param y - Y coordinate
|
|
682
|
+
*/
|
|
683
|
+
pointerUp(x: number, y: number): void;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Deletes the underlying instance created via the WASM. It's important to clean up this instance
|
|
687
|
+
* when no longer in use
|
|
688
|
+
*/
|
|
689
|
+
delete(): void;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export declare class SMIInput {
|
|
693
|
+
// TODO: Keep only the base SMIInput properties and make SMIBool, SMINumber, SMITriger extend it
|
|
694
|
+
static bool: number;
|
|
695
|
+
static number: number;
|
|
696
|
+
static trigger: number;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Getter for name of the state machine input
|
|
700
|
+
*/
|
|
701
|
+
get name(): string;
|
|
702
|
+
get type(): number;
|
|
703
|
+
/**
|
|
704
|
+
* Getter for value of the state machine input
|
|
705
|
+
*/
|
|
706
|
+
get value(): boolean | number | undefined;
|
|
707
|
+
/**
|
|
708
|
+
* Setter for value of the state machine input
|
|
709
|
+
*/
|
|
710
|
+
set value(val: boolean | number | undefined);
|
|
711
|
+
/**
|
|
712
|
+
* Fires a trigger input on a state machine
|
|
713
|
+
*/
|
|
714
|
+
fire(): void;
|
|
715
|
+
asBool(): SMIInput;
|
|
716
|
+
asNumber(): SMIInput;
|
|
717
|
+
asTrigger(): SMIInput;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
export declare class SMIBool {}
|
|
721
|
+
|
|
722
|
+
export declare class SMINumber {}
|
|
723
|
+
|
|
724
|
+
export declare class SMITrigger {}
|
|
725
|
+
|
|
726
|
+
///////////
|
|
727
|
+
// ENUMS //
|
|
728
|
+
///////////
|
|
729
|
+
|
|
730
|
+
export enum Fit {
|
|
731
|
+
fill,
|
|
732
|
+
contain,
|
|
733
|
+
cover,
|
|
734
|
+
fitWidth,
|
|
735
|
+
fitHeight,
|
|
736
|
+
none,
|
|
737
|
+
scaleDown,
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
export enum RenderPaintStyle {
|
|
741
|
+
fill,
|
|
742
|
+
stroke,
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
export enum FillRule {
|
|
746
|
+
nonZero,
|
|
747
|
+
evenOdd,
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
export enum StrokeCap {
|
|
751
|
+
butt,
|
|
752
|
+
round,
|
|
753
|
+
square,
|
|
754
|
+
}
|
|
755
|
+
export enum StrokeJoin {
|
|
756
|
+
miter,
|
|
757
|
+
round,
|
|
758
|
+
bevel,
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
export enum BlendMode {
|
|
762
|
+
srcOver = 3,
|
|
763
|
+
screen = 14,
|
|
764
|
+
overlay = 15,
|
|
765
|
+
darken = 16,
|
|
766
|
+
lighten = 17,
|
|
767
|
+
colorDodge = 18,
|
|
768
|
+
colorBurn = 19,
|
|
769
|
+
hardLight = 20,
|
|
770
|
+
softLight = 21,
|
|
771
|
+
difference = 22,
|
|
772
|
+
exclusion = 23,
|
|
773
|
+
multiply = 24,
|
|
774
|
+
hue = 25,
|
|
775
|
+
saturation = 26,
|
|
776
|
+
color = 27,
|
|
777
|
+
luminosity = 28,
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
///////////
|
|
781
|
+
// UTILS //
|
|
782
|
+
///////////
|
|
783
|
+
|
|
784
|
+
export declare class Alignment {
|
|
785
|
+
get x(): number;
|
|
786
|
+
get y(): number;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
export declare class AlignmentFactory {
|
|
790
|
+
get topLeft(): Alignment;
|
|
791
|
+
get topCenter(): Alignment;
|
|
792
|
+
get topRight(): Alignment;
|
|
793
|
+
get centerLeft(): Alignment;
|
|
794
|
+
get center(): Alignment;
|
|
795
|
+
get centerRight(): Alignment;
|
|
796
|
+
get bottomLeft(): Alignment;
|
|
797
|
+
get bottomCenter(): Alignment;
|
|
798
|
+
get bottomRight(): Alignment;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Axis-aligned bounding box
|
|
803
|
+
*/
|
|
804
|
+
export interface AABB {
|
|
805
|
+
minX: number;
|
|
806
|
+
minY: number;
|
|
807
|
+
maxX: number;
|
|
808
|
+
maxY: number;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Column-major matrix described by the following:
|
|
813
|
+
* | xx yx tx |
|
|
814
|
+
* | xy yy ty |
|
|
815
|
+
* | 0 0 1 |
|
|
816
|
+
*/
|
|
817
|
+
export declare class Mat2D {
|
|
818
|
+
xx: number;
|
|
819
|
+
xy: number;
|
|
820
|
+
yx: number;
|
|
821
|
+
yy: number;
|
|
822
|
+
tx: number;
|
|
823
|
+
ty: number;
|
|
824
|
+
/**
|
|
825
|
+
* Returns whether or not a matrix could be inverted, and if yes, sets the resulting Mat2D into
|
|
826
|
+
* the passed-in `mat` parameter
|
|
827
|
+
*
|
|
828
|
+
* @param mat - Reference Mat2D to store the newly inverted matrix into if successful
|
|
829
|
+
* @returns True if the matrix could be inverted
|
|
830
|
+
*/
|
|
831
|
+
invert(mat: Mat2D): boolean;
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Deletes the underlying CPP object created for this instance
|
|
835
|
+
*/
|
|
836
|
+
delete(): void;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Rive Vector class
|
|
841
|
+
*/
|
|
842
|
+
export declare class Vec2D {
|
|
843
|
+
constructor(x: number, y: number);
|
|
844
|
+
/**
|
|
845
|
+
* Returns the x coordinate of the vector
|
|
846
|
+
*/
|
|
847
|
+
x(): number;
|
|
848
|
+
/**
|
|
849
|
+
* Returns the y coordinate of the vector
|
|
850
|
+
*/
|
|
851
|
+
y(): number;
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Deletes the underlying CPP object created for this instance
|
|
855
|
+
*/
|
|
856
|
+
delete(): void;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
export declare class FileAsset {
|
|
860
|
+
name: string;
|
|
861
|
+
fileExtension: string;
|
|
862
|
+
isImage: boolean;
|
|
863
|
+
isFont: boolean;
|
|
864
|
+
cdnUuid: boolean;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
export declare class FileAssetLoader {
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
export declare class CustomFileAssetLoader extends FileAssetLoader {
|
|
871
|
+
constructor({loadContents}: {loadContents:Function});
|
|
872
|
+
loadContents(asset: FileAsset, bytes:any): boolean;
|
|
873
|
+
}
|