@rive-app/webgl 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +6 -2
  2. package/rive.js +0 -1766
package/rive.js DELETED
@@ -1,1766 +0,0 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory();
4
- else if(typeof define === 'function' && define.amd)
5
- define([], factory);
6
- else if(typeof exports === 'object')
7
- exports["rive"] = factory();
8
- else
9
- root["rive"] = factory();
10
- })(this, function() {
11
- return /******/ (() => { // webpackBootstrap
12
- /******/ "use strict";
13
- /******/ var __webpack_modules__ = ([
14
- /* 0 */,
15
- /* 1 */
16
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
17
-
18
- __webpack_require__.r(__webpack_exports__);
19
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
20
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
21
- /* harmony export */ });
22
-
23
- var Rive = (function() {
24
- var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
25
- if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
26
- return (
27
- function(Rive) {
28
- Rive = Rive || {};
29
-
30
-
31
- null;var g;g||(g=typeof Rive !== 'undefined' ? Rive : {});var aa,ba;g.ready=new Promise(function(a,b){aa=a;ba=b});
32
- g.onRuntimeInitialized=function(){const a=g.makeRenderer;g.makeRenderer=function(c){var d=ca(c);h=da[d];g.de=r=h&&h.Jd;const e=a(c.width,c.height);e.be=d;e.ae=c;e.Rd=c.width;e.Qd=c.height;return e};const b=g.WebGLRenderer.prototype.clear;g.WebGLRenderer.prototype.clear=function(){h=da[this.be];g.de=r=h&&h.Jd;const c=this.ae;if(this.Rd!=c.width||this.Qd!=c.height)this.resize(c.width,c.height),this.Rd=c.width,this.Qd=c.height;b.call(this)}};var ea={},v;for(v in g)g.hasOwnProperty(v)&&(ea[v]=g[v]);
33
- var fa="./this.program",ha="object"===typeof window,ia="function"===typeof importScripts,ja="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node,y="",ka,la,ma,na,oa;
34
- if(ja)y=ia?require("path").dirname(y)+"/":__dirname+"/",ka=function(a,b){na||(na=require("fs"));oa||(oa=require("path"));a=oa.normalize(a);return na.readFileSync(a,b?null:"utf8")},ma=function(a){a=ka(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||pa("Assertion failed: undefined");return a},la=function(a,b,c){na||(na=require("fs"));oa||(oa=require("path"));a=oa.normalize(a);na.readFile(a,function(d,e){d?c(d):b(e.buffer)})},1<process.argv.length&&(fa=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),
35
- process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",function(a){throw a;}),g.inspect=function(){return"[Emscripten Module object]"};else if(ha||ia)ia?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="",ka=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},ia&&
36
- (ma=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),la=function(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=function(){200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)};var qa=g.print||console.log.bind(console),z=g.printErr||console.warn.bind(console);for(v in ea)ea.hasOwnProperty(v)&&(g[v]=ea[v]);ea=null;g.thisProgram&&(fa=g.thisProgram);
37
- var ra=0,sa;g.wasmBinary&&(sa=g.wasmBinary);var noExitRuntime=g.noExitRuntime||!0;"object"!==typeof WebAssembly&&pa("no native wasm support detected");var ta,ua=!1,va="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
38
- function wa(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&va)return va.decode(a.subarray(b,c));for(d="";b<c;){var e=a[b++];if(e&128){var f=a[b++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|f);else{var l=a[b++]&63;e=224==(e&240)?(e&15)<<12|f<<6|l:(e&7)<<18|f<<12|l<<6|a[b++]&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}function xa(a,b){return a?wa(A,a,b):""}
39
- function ya(a,b,c,d){if(!(0<d))return 0;var e=c;d=c+d-1;for(var f=0;f<a.length;++f){var l=a.charCodeAt(f);if(55296<=l&&57343>=l){var k=a.charCodeAt(++f);l=65536+((l&1023)<<10)|k&1023}if(127>=l){if(c>=d)break;b[c++]=l}else{if(2047>=l){if(c+1>=d)break;b[c++]=192|l>>6}else{if(65535>=l){if(c+2>=d)break;b[c++]=224|l>>12}else{if(c+3>=d)break;b[c++]=240|l>>18;b[c++]=128|l>>12&63}b[c++]=128|l>>6&63}b[c++]=128|l&63}}b[c]=0;return c-e}
40
- function za(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}var Aa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function Ba(a,b){var c=a>>1;for(var d=c+b/2;!(c>=d)&&Ca[c];)++c;c<<=1;if(32<c-a&&Aa)return Aa.decode(A.subarray(a,c));c="";for(d=0;!(d>=b/2);++d){var e=B[a+2*d>>1];if(0==e)break;c+=String.fromCharCode(e)}return c}
41
- function Da(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var e=0;e<c;++e)B[b>>1]=a.charCodeAt(e),b+=2;B[b>>1]=0;return b-d}function Ea(a){return 2*a.length}function Fa(a,b){for(var c=0,d="";!(c>=b/4);){var e=C[a+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}
42
- function Ga(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var e=0;e<a.length;++e){var f=a.charCodeAt(e);if(55296<=f&&57343>=f){var l=a.charCodeAt(++e);f=65536+((f&1023)<<10)|l&1023}C[b>>2]=f;b+=4;if(b+4>c)break}C[b>>2]=0;return b-d}function Ha(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&++c;b+=4}return b}var Ja,E,A,B,Ca,C,F,G,Ka;
43
- function La(){var a=ta.buffer;Ja=a;g.HEAP8=E=new Int8Array(a);g.HEAP16=B=new Int16Array(a);g.HEAP32=C=new Int32Array(a);g.HEAPU8=A=new Uint8Array(a);g.HEAPU16=Ca=new Uint16Array(a);g.HEAPU32=F=new Uint32Array(a);g.HEAPF32=G=new Float32Array(a);g.HEAPF64=Ka=new Float64Array(a)}var Ma,Na=[],Oa=[],Pa=[];function Qa(){var a=g.preRun.shift();Na.unshift(a)}var Ra=0,Sa=null,Ta=null;g.preloadedImages={};g.preloadedAudios={};
44
- function pa(a){if(g.onAbort)g.onAbort(a);a="Aborted("+a+")";z(a);ua=!0;a=new WebAssembly.RuntimeError(a+". Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Ua(){return H.startsWith("data:application/octet-stream;base64,")}var H;H="webgl_advanced.wasm";if(!Ua()){var Va=H;H=g.locateFile?g.locateFile(Va,y):y+Va}function Wa(){var a=H;try{if(a==H&&sa)return new Uint8Array(sa);if(ma)return ma(a);throw"both async and sync fetching of the wasm failed";}catch(b){pa(b)}}
45
- function Xa(){if(!sa&&(ha||ia)){if("function"===typeof fetch&&!H.startsWith("file://"))return fetch(H,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+H+"'";return a.arrayBuffer()}).catch(function(){return Wa()});if(la)return new Promise(function(a,b){la(H,function(c){a(new Uint8Array(c))},b)})}return Promise.resolve().then(function(){return Wa()})}
46
- function Ya(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(g);else{var c=b.Ce;"number"===typeof c?void 0===b.Kd?I(c)():I(c)(b.Kd):c(void 0===b.Kd?null:b.Kd)}}}function I(a){return Ma.get(a)}var Za={};function $a(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function ab(a){return this.fromWireType(F[a>>2])}var bb={},cb={},db={};function eb(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
47
- function fb(a,b){a=eb(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function gb(a){var b=Error,c=fb(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
48
- var hb=void 0;function ib(a){throw new hb(a);}function J(a,b,c){function d(k){k=c(k);k.length!==a.length&&ib("Mismatched type converter count");for(var n=0;n<a.length;++n)K(a[n],k[n])}a.forEach(function(k){db[k]=b});var e=Array(b.length),f=[],l=0;b.forEach(function(k,n){cb.hasOwnProperty(k)?e[n]=cb[k]:(f.push(k),bb.hasOwnProperty(k)||(bb[k]=[]),bb[k].push(function(){e[n]=cb[k];++l;l===f.length&&d(e)}))});0===f.length&&d(e)}
49
- function jb(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var kb=void 0;function L(a){for(var b="";A[a];)b+=kb[A[a++]];return b}var lb=void 0;function M(a){throw new lb(a);}
50
- function K(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||M('type "'+d+'" must have a positive integer typeid pointer');if(cb.hasOwnProperty(a)){if(c.ne)return;M("Cannot register type '"+d+"' twice")}cb[a]=b;delete db[a];bb.hasOwnProperty(a)&&(b=bb[a],delete bb[a],b.forEach(function(e){e()}))}function mb(a){M(a.ed.jd.gd.name+" instance already deleted")}var nb=!1;function ob(){}
51
- function pb(a){--a.count.value;0===a.count.value&&(a.md?a.od.qd(a.md):a.jd.gd.qd(a.hd))}function qb(a){if("undefined"===typeof FinalizationGroup)return qb=function(b){return b},a;nb=new FinalizationGroup(function(b){for(var c=b.next();!c.done;c=b.next())c=c.value,c.hd?pb(c):console.warn("object already deleted: "+c.hd)});qb=function(b){nb.register(b,b.ed,b.ed);return b};ob=function(b){nb.unregister(b.ed)};return qb(a)}var rb=void 0,sb=[];
52
- function tb(){for(;sb.length;){var a=sb.pop();a.ed.ud=!1;a["delete"]()}}function ub(){}var vb={};function wb(a,b,c){if(void 0===a[b].kd){var d=a[b];a[b]=function(){a[b].kd.hasOwnProperty(arguments.length)||M("Function '"+c+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+a[b].kd+")!");return a[b].kd[arguments.length].apply(this,arguments)};a[b].kd=[];a[b].kd[d.Ad]=d}}
53
- function xb(a,b,c){g.hasOwnProperty(a)?((void 0===c||void 0!==g[a].kd&&void 0!==g[a].kd[c])&&M("Cannot register public name '"+a+"' twice"),wb(g,a,a),g.hasOwnProperty(c)&&M("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),g[a].kd[c]=b):(g[a]=b,void 0!==c&&(g[a].Ge=c))}function yb(a,b,c,d,e,f,l,k){this.name=a;this.constructor=b;this.rd=c;this.qd=d;this.pd=e;this.ie=f;this.zd=l;this.fe=k;this.re=[]}
54
- function zb(a,b,c){for(;b!==c;)b.zd||M("Expected null or instance of "+c.name+", got an instance of "+b.name),a=b.zd(a),b=b.pd;return a}function Ab(a,b){if(null===b)return this.Md&&M("null is not a valid "+this.name),0;b.ed||M('Cannot pass "'+Bb(b)+'" as a '+this.name);b.ed.hd||M("Cannot pass deleted object as a pointer of type "+this.name);return zb(b.ed.hd,b.ed.jd.gd,this.gd)}
55
- function Cb(a,b){if(null===b){this.Md&&M("null is not a valid "+this.name);if(this.Cd){var c=this.Nd();null!==a&&a.push(this.qd,c);return c}return 0}b.ed||M('Cannot pass "'+Bb(b)+'" as a '+this.name);b.ed.hd||M("Cannot pass deleted object as a pointer of type "+this.name);!this.Bd&&b.ed.jd.Bd&&M("Cannot convert argument of type "+(b.ed.od?b.ed.od.name:b.ed.jd.name)+" to parameter type "+this.name);c=zb(b.ed.hd,b.ed.jd.gd,this.gd);if(this.Cd)switch(void 0===b.ed.md&&M("Passing raw pointer to smart pointer is illegal"),
56
- this.we){case 0:b.ed.od===this?c=b.ed.md:M("Cannot convert argument of type "+(b.ed.od?b.ed.od.name:b.ed.jd.name)+" to parameter type "+this.name);break;case 1:c=b.ed.md;break;case 2:if(b.ed.od===this)c=b.ed.md;else{var d=b.clone();c=this.se(c,Db(function(){d["delete"]()}));null!==a&&a.push(this.qd,c)}break;default:M("Unsupporting sharing policy")}return c}
57
- function Eb(a,b){if(null===b)return this.Md&&M("null is not a valid "+this.name),0;b.ed||M('Cannot pass "'+Bb(b)+'" as a '+this.name);b.ed.hd||M("Cannot pass deleted object as a pointer of type "+this.name);b.ed.jd.Bd&&M("Cannot convert argument of type "+b.ed.jd.name+" to parameter type "+this.name);return zb(b.ed.hd,b.ed.jd.gd,this.gd)}function Fb(a,b,c){if(b===c)return a;if(void 0===c.pd)return null;a=Fb(a,b,c.pd);return null===a?null:c.fe(a)}var Gb={};
58
- function Hb(a,b){for(void 0===b&&M("ptr should not be undefined");a.pd;)b=a.zd(b),a=a.pd;return Gb[b]}function Ib(a,b){b.jd&&b.hd||ib("makeClassHandle requires ptr and ptrType");!!b.od!==!!b.md&&ib("Both smartPtrType and smartPtr must be specified");b.count={value:1};return qb(Object.create(a,{ed:{value:b}}))}
59
- function O(a,b,c,d){this.name=a;this.gd=b;this.Md=c;this.Bd=d;this.Cd=!1;this.qd=this.se=this.Nd=this.Yd=this.we=this.qe=void 0;void 0!==b.pd?this.toWireType=Cb:(this.toWireType=d?Ab:Eb,this.nd=null)}function Jb(a,b,c){g.hasOwnProperty(a)||ib("Replacing nonexistant public symbol");void 0!==g[a].kd&&void 0!==c?g[a].kd[c]=b:(g[a]=b,g[a].Ad=c)}
60
- function Kb(a,b){var c=[];return function(){c.length=arguments.length;for(var d=0;d<arguments.length;d++)c[d]=arguments[d];a.includes("j")?(d=g["dynCall_"+a],d=c&&c.length?d.apply(null,[b].concat(c)):d.call(null,b)):d=I(b).apply(null,c);return d}}function P(a,b){a=L(a);var c=a.includes("j")?Kb(a,b):I(b);"function"!==typeof c&&M("unknown function pointer with signature "+a+": "+b);return c}var Lb=void 0;function Mb(a){a=Nb(a);var b=L(a);Q(a);return b}
61
- function Ob(a,b){function c(f){e[f]||cb[f]||(db[f]?db[f].forEach(c):(d.push(f),e[f]=!0))}var d=[],e={};b.forEach(c);throw new Lb(a+": "+d.map(Mb).join([", "]));}function Pb(a,b,c){a instanceof Object||M(c+' with invalid "this": '+a);a instanceof b.gd.constructor||M(c+' incompatible with "this" of type '+a.constructor.name);a.ed.hd||M("cannot call emscripten binding method "+c+" on deleted object");return zb(a.ed.hd,a.ed.jd.gd,b.gd)}
62
- function Qb(a,b){for(var c=[],d=0;d<a;d++)c.push(C[(b>>2)+d]);return c}function Rb(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=fb(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
63
- function Sb(a,b,c,d,e){var f=b.length;2>f&&M("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=null!==b[1]&&null!==c,k=!1;for(c=1;c<b.length;++c)if(null!==b[c]&&void 0===b[c].nd){k=!0;break}var n="void"!==b[0].name,p="",q="";for(c=0;c<f-2;++c)p+=(0!==c?", ":"")+"arg"+c,q+=(0!==c?", ":"")+"arg"+c+"Wired";a="return function "+eb(a)+"("+p+") {\nif (arguments.length !== "+(f-2)+") {\nthrowBindingError('function "+a+" called with ' + arguments.length + ' arguments, expected "+
64
- (f-2)+" args!');\n}\n";k&&(a+="var destructors = [];\n");var u=k?"destructors":"null";p="throwBindingError invoker fn runDestructors retType classParam".split(" ");d=[M,d,e,$a,b[0],b[1]];l&&(a+="var thisWired = classParam.toWireType("+u+", this);\n");for(c=0;c<f-2;++c)a+="var arg"+c+"Wired = argType"+c+".toWireType("+u+", arg"+c+"); // "+b[c+2].name+"\n",p.push("argType"+c),d.push(b[c+2]);l&&(q="thisWired"+(0<q.length?", ":"")+q);a+=(n?"var rv = ":"")+"invoker(fn"+(0<q.length?", ":"")+q+");\n";if(k)a+=
65
- "runDestructors(destructors);\n";else for(c=l?1:2;c<b.length;++c)f=1===c?"thisWired":"arg"+(c-2)+"Wired",null!==b[c].nd&&(a+=f+"_dtor("+f+"); // "+b[c].name+"\n",p.push(f+"_dtor"),d.push(b[c].nd));n&&(a+="var ret = retType.fromWireType(rv);\nreturn ret;\n");p.push(a+"}\n");return Rb(p).apply(null,d)}var Tb=[],S=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Ub(a){4<a&&0===--S[a].Od&&(S[a]=void 0,Tb.push(a))}
66
- function Vb(a){a||M("Cannot use deleted val. handle = "+a);return S[a].value}function Db(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Tb.length?Tb.pop():S.length;S[b]={Od:1,value:a};return b}}
67
- function Wb(a,b,c){switch(b){case 0:return function(d){return this.fromWireType((c?E:A)[d])};case 1:return function(d){return this.fromWireType((c?B:Ca)[d>>1])};case 2:return function(d){return this.fromWireType((c?C:F)[d>>2])};default:throw new TypeError("Unknown integer type: "+a);}}function Xb(a,b){var c=cb[a];void 0===c&&M(b+" has unknown type "+Mb(a));return c}function Bb(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
68
- function Yb(a,b){switch(b){case 2:return function(c){return this.fromWireType(G[c>>2])};case 3:return function(c){return this.fromWireType(Ka[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}
69
- function Zb(a,b,c){switch(b){case 0:return c?function(d){return E[d]}:function(d){return A[d]};case 1:return c?function(d){return B[d>>1]}:function(d){return Ca[d>>1]};case 2:return c?function(d){return C[d>>2]}:function(d){return F[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var $b={};function ac(a){var b=$b[a];return void 0===b?L(a):b}var bc=[];function cc(a){var b=bc.length;bc.push(a);return b}
70
- function dc(a,b){for(var c=Array(a),d=0;d<a;++d)c[d]=Xb(C[(b>>2)+d],"parameter "+d);return c}var ec=[],fc;fc=ja?function(){var a=process.hrtime();return 1E3*a[0]+a[1]/1E6}:function(){return performance.now()};var gc=1,hc=[],T=[],ic=[],jc=[],kc=[],U=[],lc=[],da=[],mc=[],nc=[],oc={},pc={};function V(a){rc||(rc=a)}function sc(a){for(var b=gc++,c=a.length;c<b;c++)a[c]=null;return b}
71
- function ca(a){var b={alpha:1,depth:1,stencil:8,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,preferLowPowerToHighPerformance:0,failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:0,renderViaOffscreenBackBuffer:0};a.Wd||(a.Wd=a.getContext,a.getContext=function(d,e){e=a.Wd(d,e);return"webgl"==d==e instanceof WebGLRenderingContext?e:null});var c=a.getContext("webgl2",b);return c?tc(c,b):0}
72
- function tc(a,b){var c=sc(da),d={De:c,attributes:b,version:b.Ee,Jd:a};a.canvas&&(a.canvas.Be=d);da[c]=d;("undefined"===typeof b.ge||b.ge)&&uc(d);return c}
73
- function uc(a){a||(a=h);if(!a.oe){a.oe=!0;var b=a.Jd;b.Td=b.getExtension("WEBGL_draw_instanced_base_vertex_base_instance");b.Xd=b.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance");2<=a.version&&(b.Ud=b.getExtension("EXT_disjoint_timer_query_webgl2"));if(2>a.version||!b.Ud)b.Ud=b.getExtension("EXT_disjoint_timer_query");b.Fe=b.getExtension("WEBGL_multi_draw");(b.getSupportedExtensions()||[]).forEach(function(c){c.includes("lose_context")||c.includes("debug")||b.getExtension(c)})}}
74
- var rc,h,vc=[];function wc(a,b,c,d){for(var e=0;e<a;e++){var f=r[c](),l=f&&sc(d);f?(f.name=l,d[l]=f):V(1282);C[b+4*e>>2]=l}}
75
- function xc(a,b){if(b){var c=void 0;switch(a){case 36346:c=1;break;case 36344:return;case 34814:case 36345:c=0;break;case 34466:var d=r.getParameter(34467);c=d?d.length:0;break;case 33309:if(2>h.version){V(1282);return}c=2*(r.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>h.version){V(1280);return}c=33307==a?3:0}if(void 0===c)switch(d=r.getParameter(a),typeof d){case "number":c=d;break;case "boolean":c=d?1:0;break;case "string":V(1280);return;case "object":if(null===d)switch(a){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:c=
76
- 0;break;default:V(1280);return}else{if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(a=0;a<d.length;++a)C[b+4*a>>2]=d[a];return}try{c=d.name|0}catch(e){V(1280);z("GL_INVALID_ENUM in glGet0v: Unknown object returned from WebGL getParameter("+a+")! (error: "+e+")");return}}break;default:V(1280);z("GL_INVALID_ENUM in glGet0v: Native code calling glGet0v("+a+") and it returns "+d+" of type "+typeof d+"!");return}C[b>>2]=c}else V(1281)}
77
- function yc(a){var b=za(a)+1,c=zc(b);ya(a,A,c,b);return c}function Ac(a){return"]"==a.slice(-1)&&a.lastIndexOf("[")}function Bc(a){a-=5120;return 0==a?E:1==a?A:2==a?B:4==a?C:6==a?G:5==a||28922==a||28520==a||30779==a||30782==a?F:Ca}function W(a){var b=r.ee;if(b){var c=b.yd[a];"number"===typeof c&&(b.yd[a]=c=r.getUniformLocation(b,b.Zd[a]+(0<c?"["+c+"]":"")));return c}V(1282)}var Cc={};
78
- function Dc(){if(!Ec){var a={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",_:fa||"./this.program"},b;for(b in Cc)void 0===Cc[b]?delete a[b]:a[b]=Cc[b];var c=[];for(b in a)c.push(b+"="+a[b]);Ec=c}return Ec}var Ec,Fc=[null,[],[]];function Gc(a){return 0===a%4&&(0!==a%100||0===a%400)}function Hc(a,b){for(var c=0,d=0;d<=b;c+=a[d++]);return c}
79
- var Ic=[31,29,31,30,31,30,31,31,30,31,30,31],Jc=[31,28,31,30,31,30,31,31,30,31,30,31];function Kc(a,b){for(a=new Date(a.getTime());0<b;){var c=a.getMonth(),d=(Gc(a.getFullYear())?Ic:Jc)[c];if(b>d-a.getDate())b-=d-a.getDate()+1,a.setDate(1),11>c?a.setMonth(c+1):(a.setMonth(0),a.setFullYear(a.getFullYear()+1));else{a.setDate(a.getDate()+b);break}}return a}
80
- function Lc(a,b,c,d){function e(m,t,w){for(m="number"===typeof m?m.toString():m||"";m.length<t;)m=w[0]+m;return m}function f(m,t){return e(m,t,"0")}function l(m,t){function w(N){return 0>N?-1:0<N?1:0}var D;0===(D=w(m.getFullYear()-t.getFullYear()))&&0===(D=w(m.getMonth()-t.getMonth()))&&(D=w(m.getDate()-t.getDate()));return D}function k(m){switch(m.getDay()){case 0:return new Date(m.getFullYear()-1,11,29);case 1:return m;case 2:return new Date(m.getFullYear(),0,3);case 3:return new Date(m.getFullYear(),
81
- 0,2);case 4:return new Date(m.getFullYear(),0,1);case 5:return new Date(m.getFullYear()-1,11,31);case 6:return new Date(m.getFullYear()-1,11,30)}}function n(m){m=Kc(new Date(m.ld+1900,0,1),m.Id);var t=new Date(m.getFullYear()+1,0,4),w=k(new Date(m.getFullYear(),0,4));t=k(t);return 0>=l(w,m)?0>=l(t,m)?m.getFullYear()+1:m.getFullYear():m.getFullYear()-1}var p=C[d+40>>2];d={ze:C[d>>2],ye:C[d+4>>2],Gd:C[d+8>>2],xd:C[d+12>>2],vd:C[d+16>>2],ld:C[d+20>>2],Hd:C[d+24>>2],Id:C[d+28>>2],He:C[d+32>>2],xe:C[d+
82
- 36>>2],Ae:p?xa(p):""};c=xa(c);p={"%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","%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 q in p)c=c.replace(new RegExp(q,"g"),p[q]);var u="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),
83
- x="January February March April May June July August September October November December".split(" ");p={"%a":function(m){return u[m.Hd].substring(0,3)},"%A":function(m){return u[m.Hd]},"%b":function(m){return x[m.vd].substring(0,3)},"%B":function(m){return x[m.vd]},"%C":function(m){return f((m.ld+1900)/100|0,2)},"%d":function(m){return f(m.xd,2)},"%e":function(m){return e(m.xd,2," ")},"%g":function(m){return n(m).toString().substring(2)},"%G":function(m){return n(m)},"%H":function(m){return f(m.Gd,
84
- 2)},"%I":function(m){m=m.Gd;0==m?m=12:12<m&&(m-=12);return f(m,2)},"%j":function(m){return f(m.xd+Hc(Gc(m.ld+1900)?Ic:Jc,m.vd-1),3)},"%m":function(m){return f(m.vd+1,2)},"%M":function(m){return f(m.ye,2)},"%n":function(){return"\n"},"%p":function(m){return 0<=m.Gd&&12>m.Gd?"AM":"PM"},"%S":function(m){return f(m.ze,2)},"%t":function(){return"\t"},"%u":function(m){return m.Hd||7},"%U":function(m){var t=new Date(m.ld+1900,0,1),w=0===t.getDay()?t:Kc(t,7-t.getDay());m=new Date(m.ld+1900,m.vd,m.xd);return 0>
85
- l(w,m)?f(Math.ceil((31-w.getDate()+(Hc(Gc(m.getFullYear())?Ic:Jc,m.getMonth()-1)-31)+m.getDate())/7),2):0===l(w,t)?"01":"00"},"%V":function(m){var t=new Date(m.ld+1901,0,4),w=k(new Date(m.ld+1900,0,4));t=k(t);var D=Kc(new Date(m.ld+1900,0,1),m.Id);return 0>l(D,w)?"53":0>=l(t,D)?"01":f(Math.ceil((w.getFullYear()<m.ld+1900?m.Id+32-w.getDate():m.Id+1-w.getDate())/7),2)},"%w":function(m){return m.Hd},"%W":function(m){var t=new Date(m.ld,0,1),w=1===t.getDay()?t:Kc(t,0===t.getDay()?1:7-t.getDay()+1);m=
86
- new Date(m.ld+1900,m.vd,m.xd);return 0>l(w,m)?f(Math.ceil((31-w.getDate()+(Hc(Gc(m.getFullYear())?Ic:Jc,m.getMonth()-1)-31)+m.getDate())/7),2):0===l(w,t)?"01":"00"},"%y":function(m){return(m.ld+1900).toString().substring(2)},"%Y":function(m){return m.ld+1900},"%z":function(m){m=m.xe;var t=0<=m;m=Math.abs(m)/60;return(t?"+":"-")+String("0000"+(m/60*100+m%60)).slice(-4)},"%Z":function(m){return m.Ae},"%%":function(){return"%"}};for(q in p)c.includes(q)&&(c=c.replace(new RegExp(q,"g"),p[q](d)));q=Mc(c);
87
- if(q.length>b)return 0;E.set(q,a);return q.length-1}hb=g.InternalError=gb("InternalError");for(var Nc=Array(256),Oc=0;256>Oc;++Oc)Nc[Oc]=String.fromCharCode(Oc);kb=Nc;lb=g.BindingError=gb("BindingError");ub.prototype.isAliasOf=function(a){if(!(this instanceof ub&&a instanceof ub))return!1;var b=this.ed.jd.gd,c=this.ed.hd,d=a.ed.jd.gd;for(a=a.ed.hd;b.pd;)c=b.zd(c),b=b.pd;for(;d.pd;)a=d.zd(a),d=d.pd;return b===d&&c===a};
88
- ub.prototype.clone=function(){this.ed.hd||mb(this);if(this.ed.wd)return this.ed.count.value+=1,this;var a=qb,b=Object,c=b.create,d=Object.getPrototypeOf(this),e=this.ed;a=a(c.call(b,d,{ed:{value:{count:e.count,ud:e.ud,wd:e.wd,hd:e.hd,jd:e.jd,md:e.md,od:e.od}}}));a.ed.count.value+=1;a.ed.ud=!1;return a};ub.prototype["delete"]=function(){this.ed.hd||mb(this);this.ed.ud&&!this.ed.wd&&M("Object already scheduled for deletion");ob(this);pb(this.ed);this.ed.wd||(this.ed.md=void 0,this.ed.hd=void 0)};
89
- ub.prototype.isDeleted=function(){return!this.ed.hd};ub.prototype.deleteLater=function(){this.ed.hd||mb(this);this.ed.ud&&!this.ed.wd&&M("Object already scheduled for deletion");sb.push(this);1===sb.length&&rb&&rb(tb);this.ed.ud=!0;return this};O.prototype.je=function(a){this.Yd&&(a=this.Yd(a));return a};O.prototype.Sd=function(a){this.qd&&this.qd(a)};O.prototype.argPackAdvance=8;O.prototype.readValueFromPointer=ab;O.prototype.deleteObject=function(a){if(null!==a)a["delete"]()};
90
- O.prototype.fromWireType=function(a){function b(){return this.Cd?Ib(this.gd.rd,{jd:this.qe,hd:c,od:this,md:a}):Ib(this.gd.rd,{jd:this,hd:a})}var c=this.je(a);if(!c)return this.Sd(a),null;var d=Hb(this.gd,c);if(void 0!==d){if(0===d.ed.count.value)return d.ed.hd=c,d.ed.md=a,d.clone();d=d.clone();this.Sd(a);return d}d=this.gd.ie(c);d=vb[d];if(!d)return b.call(this);d=this.Bd?d.ce:d.pointerType;var e=Fb(c,this.gd,d.gd);return null===e?b.call(this):this.Cd?Ib(d.gd.rd,{jd:d,hd:e,od:this,md:a}):Ib(d.gd.rd,
91
- {jd:d,hd:e})};g.getInheritedInstanceCount=function(){return Object.keys(Gb).length};g.getLiveInheritedInstances=function(){var a=[],b;for(b in Gb)Gb.hasOwnProperty(b)&&a.push(Gb[b]);return a};g.flushPendingDeletes=tb;g.setDelayFunction=function(a){rb=a;sb.length&&rb&&rb(tb)};Lb=g.UnboundTypeError=gb("UnboundTypeError");g.count_emval_handles=function(){for(var a=0,b=5;b<S.length;++b)void 0!==S[b]&&++a;return a};g.get_first_emval=function(){for(var a=5;a<S.length;++a)if(void 0!==S[a])return S[a];return null};
92
- for(var r,Pc=0;32>Pc;++Pc)vc.push(Array(Pc));function Mc(a){var b=Array(za(a)+1);ya(a,b,0,b.length);return b}
93
- var ed={cb:function(a){var b=Za[a];delete Za[a];var c=b.Nd,d=b.qd,e=b.Vd,f=e.map(function(l){return l.me}).concat(e.map(function(l){return l.ue}));J([a],f,function(l){var k={};e.forEach(function(n,p){var q=l[p],u=n.ke,x=n.le,m=l[p+e.length],t=n.te,w=n.ve;k[n.he]={read:function(D){return q.fromWireType(u(x,D))},write:function(D,N){var R=[];t(w,D,m.toWireType(R,N));$a(R)}}});return[{name:b.name,fromWireType:function(n){var p={},q;for(q in k)p[q]=k[q].read(n);d(n);return p},toWireType:function(n,p){for(var q in k)if(!(q in
94
- p))throw new TypeError('Missing field: "'+q+'"');var u=c();for(q in k)k[q].write(u,p[q]);null!==n&&n.push(d,u);return u},argPackAdvance:8,readValueFromPointer:ab,nd:d}]})},fb:function(){},wb:function(a,b,c,d,e){var f=jb(c);b=L(b);K(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,k){return k?d:e},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var k=E;else if(2===c)k=B;else if(4===c)k=C;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[l>>
95
- f])},nd:null})},g:function(a,b,c,d,e,f,l,k,n,p,q,u,x){q=L(q);f=P(e,f);k&&(k=P(l,k));p&&(p=P(n,p));x=P(u,x);var m=eb(q);xb(m,function(){Ob("Cannot construct "+q+" due to unbound types",[d])});J([a,b,c],d?[d]:[],function(t){t=t[0];if(d){var w=t.gd;var D=w.rd}else D=ub.prototype;t=fb(m,function(){if(Object.getPrototypeOf(this)!==N)throw new lb("Use 'new' to construct "+q);if(void 0===R.sd)throw new lb(q+" has no accessible constructor");var qc=R.sd[arguments.length];if(void 0===qc)throw new lb("Tried to invoke ctor of "+
96
- q+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(R.sd).toString()+") parameters instead!");return qc.apply(this,arguments)});var N=Object.create(D,{constructor:{value:t}});t.prototype=N;var R=new yb(q,t,N,x,w,f,k,p);w=new O(q,R,!0,!1);D=new O(q+"*",R,!1,!1);var Ia=new O(q+" const*",R,!1,!0);vb[a]={pointerType:D,ce:Ia};Jb(m,t);return[w,D,Ia]})},k:function(a,b,c,d,e,f,l,k){b=L(b);f=P(e,f);J([],[a],function(n){n=n[0];var p=n.name+"."+b,q={get:function(){Ob("Cannot access "+
97
- p+" due to unbound types",[c])},enumerable:!0,configurable:!0};q.set=k?function(){Ob("Cannot access "+p+" due to unbound types",[c])}:function(){M(p+" is a read-only property")};Object.defineProperty(n.gd.constructor,b,q);J([],[c],function(u){u=u[0];var x={get:function(){return u.fromWireType(f(d))},enumerable:!0};k&&(k=P(l,k),x.set=function(m){var t=[];k(d,u.toWireType(t,m));$a(t)});Object.defineProperty(n.gd.constructor,b,x);return[]});return[]})},v:function(a,b,c,d,e,f){0<b||pa("Assertion failed: undefined");
98
- var l=Qb(b,c);e=P(d,e);J([],[a],function(k){k=k[0];var n="constructor "+k.name;void 0===k.gd.sd&&(k.gd.sd=[]);if(void 0!==k.gd.sd[b-1])throw new lb("Cannot register multiple constructors with identical number of parameters ("+(b-1)+") for class '"+k.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");k.gd.sd[b-1]=function(){Ob("Cannot construct "+k.name+" due to unbound types",l)};J([],l,function(p){p.splice(1,0,null);k.gd.sd[b-1]=Sb(n,p,null,
99
- e,f);return[]});return[]})},e:function(a,b,c,d,e,f,l,k){var n=Qb(c,d);b=L(b);f=P(e,f);J([],[a],function(p){function q(){Ob("Cannot call "+u+" due to unbound types",n)}p=p[0];var u=p.name+"."+b;b.startsWith("@@")&&(b=Symbol[b.substring(2)]);k&&p.gd.re.push(b);var x=p.gd.rd,m=x[b];void 0===m||void 0===m.kd&&m.className!==p.name&&m.Ad===c-2?(q.Ad=c-2,q.className=p.name,x[b]=q):(wb(x,b,u),x[b].kd[c-2]=q);J([],n,function(t){t=Sb(u,t,p,f,l);void 0===x[b].kd?(t.Ad=c-2,x[b]=t):x[b].kd[c-2]=t;return[]});return[]})},
100
- f:function(a,b,c,d,e,f,l,k,n,p){b=L(b);e=P(d,e);J([],[a],function(q){q=q[0];var u=q.name+"."+b,x={get:function(){Ob("Cannot access "+u+" due to unbound types",[c,l])},enumerable:!0,configurable:!0};x.set=n?function(){Ob("Cannot access "+u+" due to unbound types",[c,l])}:function(){M(u+" is a read-only property")};Object.defineProperty(q.gd.rd,b,x);J([],n?[c,l]:[c],function(m){var t=m[0],w={get:function(){var N=Pb(this,q,u+" getter");return t.fromWireType(e(f,N))},enumerable:!0};if(n){n=P(k,n);var D=
101
- m[1];w.set=function(N){var R=Pb(this,q,u+" setter"),Ia=[];n(p,R,D.toWireType(Ia,N));$a(Ia)}}Object.defineProperty(q.gd.rd,b,w);return[]});return[]})},vb:function(a,b){b=L(b);K(a,{name:b,fromWireType:function(c){var d=Vb(c);Ub(c);return d},toWireType:function(c,d){return Db(d)},argPackAdvance:8,readValueFromPointer:ab,nd:null})},sb:function(a,b,c,d){function e(){}c=jb(c);b=L(b);e.values={};K(a,{name:b,constructor:e,fromWireType:function(f){return this.constructor.values[f]},toWireType:function(f,l){return l.value},
102
- argPackAdvance:8,readValueFromPointer:Wb(b,c,d),nd:null});xb(b,e)},mb:function(a,b,c){var d=Xb(a,"enum");b=L(b);a=d.constructor;d=Object.create(d.constructor.prototype,{value:{value:c},constructor:{value:fb(d.name+"_"+b,function(){})}});a.values[c]=d;a[b]=d},w:function(a,b,c){c=jb(c);b=L(b);K(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,e){return e},argPackAdvance:8,readValueFromPointer:Yb(b,c),nd:null})},y:function(a,b,c,d,e,f){var l=Qb(b,c);a=L(a);e=P(d,e);xb(a,function(){Ob("Cannot call "+
103
- a+" due to unbound types",l)},b-1);J([],l,function(k){k=[k[0],null].concat(k.slice(1));Jb(a,Sb(a,k,null,e,f),b-1);return[]})},m:function(a,b,c,d,e){function f(p){return p}b=L(b);-1===e&&(e=4294967295);var l=jb(c);if(0===d){var k=32-8*c;f=function(p){return p<<k>>>k}}var n=b.includes("unsigned");K(a,{name:b,fromWireType:f,toWireType:function(p,q){if("number"!==typeof q&&"boolean"!==typeof q)throw new TypeError('Cannot convert "'+Bb(q)+'" to '+this.name);if(q<d||q>e)throw new TypeError('Passing a number "'+
104
- Bb(q)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+e+"]!");return n?q>>>0:q|0},argPackAdvance:8,readValueFromPointer:Zb(b,l,0!==d),nd:null})},l:function(a,b,c){function d(f){f>>=2;var l=F;return new e(Ja,l[f+1],l[f])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=L(c);K(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{ne:!0})},x:function(a,b){b=L(b);var c="std::string"===
105
- b;K(a,{name:b,fromWireType:function(d){var e=F[d>>2];if(c)for(var f=d+4,l=0;l<=e;++l){var k=d+4+l;if(l==e||0==A[k]){f=xa(f,k-f);if(void 0===n)var n=f;else n+=String.fromCharCode(0),n+=f;f=k+1}}else{n=Array(e);for(l=0;l<e;++l)n[l]=String.fromCharCode(A[d+4+l]);n=n.join("")}Q(d);return n},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 Int8Array||M("Cannot pass non-string to std::string");
106
- var l=(c&&f?function(){return za(e)}:function(){return e.length})(),k=zc(4+l+1);F[k>>2]=l;if(c&&f)ya(e,A,k+4,l+1);else if(f)for(f=0;f<l;++f){var n=e.charCodeAt(f);255<n&&(Q(k),M("String has UTF-16 code units that do not fit in 8 bits"));A[k+4+f]=n}else for(f=0;f<l;++f)A[k+4+f]=e[f];null!==d&&d.push(Q,k);return k},argPackAdvance:8,readValueFromPointer:ab,nd:function(d){Q(d)}})},u:function(a,b,c){c=L(c);if(2===b){var d=Ba;var e=Da;var f=Ea;var l=function(){return Ca};var k=1}else 4===b&&(d=Fa,e=Ga,
107
- f=Ha,l=function(){return F},k=2);K(a,{name:c,fromWireType:function(n){for(var p=F[n>>2],q=l(),u,x=n+4,m=0;m<=p;++m){var t=n+4+m*b;if(m==p||0==q[t>>k])x=d(x,t-x),void 0===u?u=x:(u+=String.fromCharCode(0),u+=x),x=t+b}Q(n);return u},toWireType:function(n,p){"string"!==typeof p&&M("Cannot pass non-string to C++ string type "+c);var q=f(p),u=zc(4+q+b);F[u>>2]=q>>k;e(p,u+4,q+b);null!==n&&n.push(Q,u);return u},argPackAdvance:8,readValueFromPointer:ab,nd:function(n){Q(n)}})},ib:function(a,b,c,d,e,f){Za[a]=
108
- {name:L(b),Nd:P(c,d),qd:P(e,f),Vd:[]}},bb:function(a,b,c,d,e,f,l,k,n,p){Za[a].Vd.push({he:L(b),me:c,ke:P(d,e),le:f,ue:l,te:P(k,n),ve:p})},xb:function(a,b){b=L(b);K(a,{pe:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},nb:function(){throw"longjmp";},oa:function(a,b,c){a=Vb(a);b=Xb(b,"emval::as");var d=[],e=Db(d);C[c>>2]=e;return b.toWireType(d,a)},U:function(a,b,c,d){a=bc[a];b=Vb(b);c=ac(c);a(b,c,null,d)},Fc:Ub,J:function(a,b){var c=dc(a,b),d=c[0];b=d.name+"_$"+c.slice(1).map(function(q){return q.name}).join("_")+
109
- "$";var e=ec[b];if(void 0!==e)return e;e=["retType"];for(var f=[d],l="",k=0;k<a-1;++k)l+=(0!==k?", ":"")+"arg"+k,e.push("argType"+k),f.push(c[1+k]);var n="return function "+eb("methodCaller_"+b)+"(handle, name, destructors, args) {\n",p=0;for(k=0;k<a-1;++k)n+=" var arg"+k+" = argType"+k+".readValueFromPointer(args"+(p?"+"+p:"")+");\n",p+=c[k+1].argPackAdvance;n+=" var rv = handle[name]("+l+");\n";for(k=0;k<a-1;++k)c[k+1].deleteObject&&(n+=" argType"+k+".deleteObject(arg"+k+");\n");d.pe||
110
- (n+=" return retType.toWireType(destructors, rv);\n");e.push(n+"};\n");a=Rb(e).apply(null,f);e=cc(a);return ec[b]=e},Ka:function(a,b){a=Vb(a);b=Vb(b);return Db(a[b])},Ec:function(a){4<a&&(S[a].Od+=1)},za:function(a){return Db(ac(a))},da:function(a){var b=Vb(a);$a(b);Ub(a)},Va:function(a,b){a=Xb(a,"_emval_take_value");a=a.readValueFromPointer(b);return Db(a)},a:function(){pa("")},ob:function(a,b){if(0===a)a=Date.now();else if(1===a||4===a)a=fc();else return C[Qc()>>2]=28,-1;C[b>>2]=a/1E3|0;C[b+
111
- 4>>2]=a%1E3*1E6|0;return 0},Ya:function(a){r.activeTexture(a)},Xa:function(a,b){r.attachShader(T[a],U[b])},Wa:function(a,b,c){r.bindAttribLocation(T[a],b,xa(c))},Ua:function(a,b){35051==a?r.Ld=b:35052==a&&(r.td=b);r.bindBuffer(a,hc[b])},Xb:function(a,b){r.bindFramebuffer(a,ic[b])},Wb:function(a,b){r.bindRenderbuffer(a,jc[b])},Fb:function(a,b){r.bindSampler(a,mc[b])},Ta:function(a,b){r.bindTexture(a,kc[b])},nc:function(a){r.bindVertexArray(lc[a])},kc:function(a){r.bindVertexArray(lc[a])},Sa:function(a,
112
- b,c,d){r.blendColor(a,b,c,d)},Ra:function(a){r.blendEquation(a)},Qa:function(a,b){r.blendFunc(a,b)},Kb:function(a,b,c,d,e,f,l,k,n,p){r.blitFramebuffer(a,b,c,d,e,f,l,k,n,p)},Pa:function(a,b,c,d){c?r.bufferData(a,A,d,c,b):r.bufferData(a,b,d)},Oa:function(a,b,c,d){r.bufferSubData(a,b,A,d,c)},Vb:function(a){return r.checkFramebufferStatus(a)},Na:function(a){r.clear(a)},Ma:function(a,b,c,d){r.clearColor(a,b,c,d)},La:function(a){r.clearStencil(a)},$a:function(a,b,c,d){return r.clientWaitSync(nc[a],b,(c>>>
113
- 0)+4294967296*d)},Ja:function(a,b,c,d){r.colorMask(!!a,!!b,!!c,!!d)},Ia:function(a){r.compileShader(U[a])},Ha:function(a,b,c,d,e,f,l,k){r.td?r.compressedTexImage2D(a,b,c,d,e,f,l,k):r.compressedTexImage2D(a,b,c,d,e,f,A,k,l)},Ga:function(a,b,c,d,e,f,l,k,n){r.td?r.compressedTexSubImage2D(a,b,c,d,e,f,l,k,n):r.compressedTexSubImage2D(a,b,c,d,e,f,l,A,n,k)},Fa:function(a,b,c,d,e,f,l,k){r.copyTexSubImage2D(a,b,c,d,e,f,l,k)},Ea:function(){var a=sc(T),b=r.createProgram();b.name=a;b.Fd=b.Dd=b.Ed=0;b.Pd=1;T[a]=
114
- b;return a},Da:function(a){var b=sc(U);U[b]=r.createShader(a);return b},Ca:function(a){r.cullFace(a)},Ba:function(a,b){for(var c=0;c<a;c++){var d=C[b+4*c>>2],e=hc[d];e&&(r.deleteBuffer(e),e.name=0,hc[d]=null,d==r.Ld&&(r.Ld=0),d==r.td&&(r.td=0))}},Ub:function(a,b){for(var c=0;c<a;++c){var d=C[b+4*c>>2],e=ic[d];e&&(r.deleteFramebuffer(e),e.name=0,ic[d]=null)}},Aa:function(a){if(a){var b=T[a];b?(r.deleteProgram(b),b.name=0,T[a]=null):V(1281)}},Tb:function(a,b){for(var c=0;c<a;c++){var d=C[b+4*c>>2],
115
- e=jc[d];e&&(r.deleteRenderbuffer(e),e.name=0,jc[d]=null)}},Eb:function(a,b){for(var c=0;c<a;c++){var d=C[b+4*c>>2],e=mc[d];e&&(r.deleteSampler(e),e.name=0,mc[d]=null)}},ya:function(a){if(a){var b=U[a];b?(r.deleteShader(b),U[a]=null):V(1281)}},Ib:function(a){if(a){var b=nc[a];b?(r.deleteSync(b),b.name=0,nc[a]=null):V(1281)}},xa:function(a,b){for(var c=0;c<a;c++){var d=C[b+4*c>>2],e=kc[d];e&&(r.deleteTexture(e),e.name=0,kc[d]=null)}},mc:function(a,b){for(var c=0;c<a;c++){var d=C[b+4*c>>2];r.deleteVertexArray(lc[d]);
116
- lc[d]=null}},jc:function(a,b){for(var c=0;c<a;c++){var d=C[b+4*c>>2];r.deleteVertexArray(lc[d]);lc[d]=null}},wa:function(a){r.depthMask(!!a)},va:function(a){r.disable(a)},ua:function(a){r.disableVertexAttribArray(a)},ta:function(a,b,c){r.drawArrays(a,b,c)},hc:function(a,b,c,d){r.drawArraysInstanced(a,b,c,d)},fc:function(a,b,c,d,e){r.Td.drawArraysInstancedBaseInstanceWEBGL(a,b,c,d,e)},dc:function(a,b){for(var c=vc[a],d=0;d<a;d++)c[d]=C[b+4*d>>2];r.drawBuffers(c)},sa:function(a,b,c,d){r.drawElements(a,
117
- b,c,d)},gc:function(a,b,c,d,e){r.drawElementsInstanced(a,b,c,d,e)},ec:function(a,b,c,d,e,f,l){r.Td.drawElementsInstancedBaseVertexBaseInstanceWEBGL(a,b,c,d,e,f,l)},$b:function(a,b,c,d,e,f){r.drawElements(a,d,e,f)},ra:function(a){r.enable(a)},qa:function(a){r.enableVertexAttribArray(a)},Hb:function(a,b){return(a=r.fenceSync(a,b))?(b=sc(nc),a.name=b,nc[b]=a,b):0},pa:function(){r.finish()},na:function(){r.flush()},Sb:function(a,b,c,d){r.framebufferRenderbuffer(a,b,c,jc[d])},Rb:function(a,b,c,d,e){r.framebufferTexture2D(a,
118
- b,c,kc[d],e)},ma:function(a){r.frontFace(a)},la:function(a,b){wc(a,b,"createBuffer",hc)},Qb:function(a,b){wc(a,b,"createFramebuffer",ic)},Pb:function(a,b){wc(a,b,"createRenderbuffer",jc)},Db:function(a,b){wc(a,b,"createSampler",mc)},ka:function(a,b){wc(a,b,"createTexture",kc)},lc:function(a,b){wc(a,b,"createVertexArray",lc)},ic:function(a,b){wc(a,b,"createVertexArray",lc)},Ob:function(a){r.generateMipmap(a)},ja:function(a,b,c){c?C[c>>2]=r.getBufferParameter(a,b):V(1281)},ia:function(){var a=r.getError()||
119
- rc;rc=0;return a},Nb:function(a,b,c,d){a=r.getFramebufferAttachmentParameter(a,b,c);if(a instanceof WebGLRenderbuffer||a instanceof WebGLTexture)a=a.name|0;C[d>>2]=a},Za:function(a,b){xc(a,b)},ha:function(a,b,c,d){a=r.getProgramInfoLog(T[a]);null===a&&(a="(unknown error)");b=0<b&&d?ya(a,A,d,b):0;c&&(C[c>>2]=b)},ga:function(a,b,c){if(c)if(a>=gc)V(1281);else if(a=T[a],35716==b)a=r.getProgramInfoLog(a),null===a&&(a="(unknown error)"),C[c>>2]=a.length+1;else if(35719==b){if(!a.Fd)for(b=0;b<r.getProgramParameter(a,
120
- 35718);++b)a.Fd=Math.max(a.Fd,r.getActiveUniform(a,b).name.length+1);C[c>>2]=a.Fd}else if(35722==b){if(!a.Dd)for(b=0;b<r.getProgramParameter(a,35721);++b)a.Dd=Math.max(a.Dd,r.getActiveAttrib(a,b).name.length+1);C[c>>2]=a.Dd}else if(35381==b){if(!a.Ed)for(b=0;b<r.getProgramParameter(a,35382);++b)a.Ed=Math.max(a.Ed,r.getActiveUniformBlockName(a,b).length+1);C[c>>2]=a.Ed}else C[c>>2]=r.getProgramParameter(a,b);else V(1281)},Mb:function(a,b,c){c?C[c>>2]=r.getRenderbufferParameter(a,b):V(1281)},fa:function(a,
121
- b,c,d){a=r.getShaderInfoLog(U[a]);null===a&&(a="(unknown error)");b=0<b&&d?ya(a,A,d,b):0;c&&(C[c>>2]=b)},yb:function(a,b,c,d){a=r.getShaderPrecisionFormat(a,b);C[c>>2]=a.rangeMin;C[c+4>>2]=a.rangeMax;C[d>>2]=a.precision},ea:function(a,b,c){c?35716==b?(a=r.getShaderInfoLog(U[a]),null===a&&(a="(unknown error)"),C[c>>2]=a?a.length+1:0):35720==b?(a=r.getShaderSource(U[a]),C[c>>2]=a?a.length+1:0):C[c>>2]=r.getShaderParameter(U[a],b):V(1281)},s:function(a){var b=oc[a];if(!b){switch(a){case 7939:b=r.getSupportedExtensions()||
122
- [];b=b.concat(b.map(function(d){return"GL_"+d}));b=yc(b.join(" "));break;case 7936:case 7937:case 37445:case 37446:(b=r.getParameter(a))||V(1280);b=b&&yc(b);break;case 7938:b=yc("OpenGL ES 3.0 ("+r.getParameter(7938)+")");break;case 35724:b=r.getParameter(35724);var c=b.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==c&&(3==c[1].length&&(c[1]+="0"),b="OpenGL ES GLSL ES "+c[1]+" ("+b+")");b=yc(b);break;default:V(1280)}oc[a]=b}return b},_a:function(a,b){if(2>h.version)return V(1282),0;
123
- var c=pc[a];if(c)return 0>b||b>=c.length?(V(1281),0):c[b];switch(a){case 7939:return c=r.getSupportedExtensions()||[],c=c.concat(c.map(function(d){return"GL_"+d})),c=c.map(function(d){return yc(d)}),c=pc[a]=c,0>b||b>=c.length?(V(1281),0):c[b];default:return V(1280),0}},ca:function(a,b){b=xa(b);if(a=T[a]){var c=a,d=c.yd,e=c.$d,f;if(!d)for(c.yd=d={},c.Zd={},f=0;f<r.getProgramParameter(c,35718);++f){var l=r.getActiveUniform(c,f);var k=l.name;l=l.size;var n=Ac(k);n=0<n?k.slice(0,n):k;var p=c.Pd;c.Pd+=
124
- l;e[n]=[l,p];for(k=0;k<l;++k)d[p]=k,c.Zd[p++]=n}c=a.yd;d=0;e=b;f=Ac(b);0<f&&(d=parseInt(b.slice(f+1))>>>0,e=b.slice(0,f));if((e=a.$d[e])&&d<e[0]&&(d+=e[1],c[d]=c[d]||r.getUniformLocation(a,b)))return d}else V(1281);return-1},Ab:function(a,b,c){for(var d=vc[b],e=0;e<b;e++)d[e]=C[c+4*e>>2];r.invalidateFramebuffer(a,d)},zb:function(a,b,c,d,e,f,l){for(var k=vc[b],n=0;n<b;n++)k[n]=C[c+4*n>>2];r.invalidateSubFramebuffer(a,k,d,e,f,l)},Gb:function(a){return r.isSync(nc[a])},ba:function(a){return(a=kc[a])?
125
- r.isTexture(a):0},aa:function(a){r.lineWidth(a)},$:function(a){a=T[a];r.linkProgram(a);a.yd=0;a.$d={}},bc:function(a,b,c,d,e,f){r.Xd.multiDrawArraysInstancedBaseInstanceWEBGL(a,C,b>>2,C,c>>2,C,d>>2,F,e>>2,f)},ac:function(a,b,c,d,e,f,l,k){r.Xd.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(a,C,b>>2,c,C,d>>2,C,e>>2,C,f>>2,F,l>>2,k)},_:function(a,b){r.pixelStorei(a,b)},cc:function(a){r.readBuffer(a)},Z:function(a,b,c,d,e,f,l){if(r.Ld)r.readPixels(a,b,c,d,e,f,l);else{var k=Bc(f);r.readPixels(a,
126
- b,c,d,e,f,k,l>>31-Math.clz32(k.BYTES_PER_ELEMENT))}},Lb:function(a,b,c,d){r.renderbufferStorage(a,b,c,d)},Jb:function(a,b,c,d,e){r.renderbufferStorageMultisample(a,b,c,d,e)},Cb:function(a,b,c){r.samplerParameteri(mc[a],b,c)},Bb:function(a,b,c){r.samplerParameteri(mc[a],b,C[c>>2])},Y:function(a,b,c,d){r.scissor(a,b,c,d)},X:function(a,b,c,d){for(var e="",f=0;f<b;++f){var l=d?C[d+4*f>>2]:-1;e+=xa(C[c+4*f>>2],0>l?void 0:l)}r.shaderSource(U[a],e)},W:function(a,b,c){r.stencilFunc(a,b,c)},V:function(a,b,
127
- c,d){r.stencilFuncSeparate(a,b,c,d)},T:function(a){r.stencilMask(a)},S:function(a,b){r.stencilMaskSeparate(a,b)},R:function(a,b,c){r.stencilOp(a,b,c)},Q:function(a,b,c,d){r.stencilOpSeparate(a,b,c,d)},P:function(a,b,c,d,e,f,l,k,n){if(r.td)r.texImage2D(a,b,c,d,e,f,l,k,n);else if(n){var p=Bc(k);r.texImage2D(a,b,c,d,e,f,l,k,p,n>>31-Math.clz32(p.BYTES_PER_ELEMENT))}else r.texImage2D(a,b,c,d,e,f,l,k,null)},O:function(a,b,c){r.texParameterf(a,b,c)},N:function(a,b,c){r.texParameterf(a,b,G[c>>2])},M:function(a,
128
- b,c){r.texParameteri(a,b,c)},L:function(a,b,c){r.texParameteri(a,b,C[c>>2])},_b:function(a,b,c,d,e){r.texStorage2D(a,b,c,d,e)},K:function(a,b,c,d,e,f,l,k,n){if(r.td)r.texSubImage2D(a,b,c,d,e,f,l,k,n);else if(n){var p=Bc(k);r.texSubImage2D(a,b,c,d,e,f,l,k,p,n>>31-Math.clz32(p.BYTES_PER_ELEMENT))}else r.texSubImage2D(a,b,c,d,e,f,l,k,null)},I:function(a,b){r.uniform1f(W(a),b)},H:function(a,b,c){r.uniform1fv(W(a),G,c>>2,b)},G:function(a,b){r.uniform1i(W(a),b)},F:function(a,b,c){r.uniform1iv(W(a),C,c>>
129
- 2,b)},E:function(a,b,c){r.uniform2f(W(a),b,c)},D:function(a,b,c){r.uniform2fv(W(a),G,c>>2,2*b)},C:function(a,b,c){r.uniform2i(W(a),b,c)},B:function(a,b,c){r.uniform2iv(W(a),C,c>>2,2*b)},A:function(a,b,c,d){r.uniform3f(W(a),b,c,d)},z:function(a,b,c){r.uniform3fv(W(a),G,c>>2,3*b)},Dc:function(a,b,c,d){r.uniform3i(W(a),b,c,d)},Cc:function(a,b,c){r.uniform3iv(W(a),C,c>>2,3*b)},Bc:function(a,b,c,d,e){r.uniform4f(W(a),b,c,d,e)},Ac:function(a,b,c){r.uniform4fv(W(a),G,c>>2,4*b)},zc:function(a,b,c,d,e){r.uniform4i(W(a),
130
- b,c,d,e)},yc:function(a,b,c){r.uniform4iv(W(a),C,c>>2,4*b)},xc:function(a,b,c,d){r.uniformMatrix2fv(W(a),!!c,G,d>>2,4*b)},wc:function(a,b,c,d){r.uniformMatrix3fv(W(a),!!c,G,d>>2,9*b)},vc:function(a,b,c,d){r.uniformMatrix4fv(W(a),!!c,G,d>>2,16*b)},uc:function(a){a=T[a];r.useProgram(a);r.ee=a},tc:function(a,b){r.vertexAttrib1f(a,b)},sc:function(a,b){r.vertexAttrib2f(a,G[b>>2],G[b+4>>2])},rc:function(a,b){r.vertexAttrib3f(a,G[b>>2],G[b+4>>2],G[b+8>>2])},qc:function(a,b){r.vertexAttrib4f(a,G[b>>2],G[b+
131
- 4>>2],G[b+8>>2],G[b+12>>2])},Zb:function(a,b){r.vertexAttribDivisor(a,b)},Yb:function(a,b,c,d,e){r.vertexAttribIPointer(a,b,c,d,e)},pc:function(a,b,c,d,e,f){r.vertexAttribPointer(a,b,c,!!d,e,f)},oc:function(a,b,c,d){r.viewport(a,b,c,d)},ab:function(a,b,c,d){r.waitSync(nc[a],b,(c>>>0)+4294967296*d)},t:function(a){var b=A.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(a,d);0<d%65536&&(d+=65536-d%65536);a:{try{ta.grow(Math.min(2147483648,
132
- d)-Ja.byteLength+65535>>>16);La();var e=1;break a}catch(f){}e=void 0}if(e)return!0}return!1},qb:function(a,b){var c=0;Dc().forEach(function(d,e){var f=b+c;e=C[a+4*e>>2]=f;for(f=0;f<d.length;++f)E[e++>>0]=d.charCodeAt(f);E[e>>0]=0;c+=d.length+1});return 0},rb:function(a,b){var c=Dc();C[a>>2]=c.length;var d=0;c.forEach(function(e){d+=e.length+1});C[b>>2]=d;return 0},ub:function(){return 0},eb:function(){},tb:function(a,b,c,d){for(var e=0,f=0;f<c;f++){var l=C[b>>2],k=C[b+4>>2];b+=8;for(var n=0;n<k;n++){var p=
133
- A[l+n],q=Fc[a];0===p||10===p?((1===a?qa:z)(wa(q,0)),q.length=0):q.push(p)}e+=k}C[d>>2]=e;return 0},b:function(){return ra},db:function(a,b){xc(a,b)},n:Rc,h:Sc,o:Tc,r:Uc,hb:Vc,jb:Wc,q:Xc,j:Yc,d:Zc,p:$c,i:ad,kb:bd,gb:cd,lb:dd,c:function(a){ra=a},pb:function(a,b,c,d){return Lc(a,b,c,d)}};
134
- (function(){function a(e){g.asm=e.exports;ta=g.asm.Gc;La();Ma=g.asm.Qc;Oa.unshift(g.asm.Hc);Ra--;g.monitorRunDependencies&&g.monitorRunDependencies(Ra);0==Ra&&(null!==Sa&&(clearInterval(Sa),Sa=null),Ta&&(e=Ta,Ta=null,e()))}function b(e){a(e.instance)}function c(e){return Xa().then(function(f){return WebAssembly.instantiate(f,d)}).then(function(f){return f}).then(e,function(f){z("failed to asynchronously prepare wasm: "+f);pa(f)})}var d={a:ed};Ra++;g.monitorRunDependencies&&g.monitorRunDependencies(Ra);
135
- if(g.instantiateWasm)try{return g.instantiateWasm(d,a)}catch(e){return z("Module.instantiateWasm callback failed with error: "+e),!1}(function(){return sa||"function"!==typeof WebAssembly.instantiateStreaming||Ua()||H.startsWith("file://")||"function"!==typeof fetch?c(b):fetch(H,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,d).then(b,function(f){z("wasm streaming compile failed: "+f);z("falling back to ArrayBuffer instantiation");return c(b)})})})().catch(ba);
136
- return{}})();g.___wasm_call_ctors=function(){return(g.___wasm_call_ctors=g.asm.Hc).apply(null,arguments)};var zc=g._malloc=function(){return(zc=g._malloc=g.asm.Ic).apply(null,arguments)},Qc=g.___errno_location=function(){return(Qc=g.___errno_location=g.asm.Jc).apply(null,arguments)},Q=g._free=function(){return(Q=g._free=g.asm.Kc).apply(null,arguments)},Nb=g.___getTypeName=function(){return(Nb=g.___getTypeName=g.asm.Lc).apply(null,arguments)};
137
- g.___embind_register_native_and_builtin_types=function(){return(g.___embind_register_native_and_builtin_types=g.asm.Mc).apply(null,arguments)};var X=g.stackSave=function(){return(X=g.stackSave=g.asm.Nc).apply(null,arguments)},Y=g.stackRestore=function(){return(Y=g.stackRestore=g.asm.Oc).apply(null,arguments)},Z=g._setThrew=function(){return(Z=g._setThrew=g.asm.Pc).apply(null,arguments)};g.dynCall_iiiij=function(){return(g.dynCall_iiiij=g.asm.Rc).apply(null,arguments)};
138
- g.dynCall_viiij=function(){return(g.dynCall_viiij=g.asm.Sc).apply(null,arguments)};g.dynCall_iiij=function(){return(g.dynCall_iiij=g.asm.Tc).apply(null,arguments)};g.dynCall_viij=function(){return(g.dynCall_viij=g.asm.Uc).apply(null,arguments)};g.dynCall_viiiiij=function(){return(g.dynCall_viiiiij=g.asm.Vc).apply(null,arguments)};g.dynCall_jii=function(){return(g.dynCall_jii=g.asm.Wc).apply(null,arguments)};g.dynCall_viji=function(){return(g.dynCall_viji=g.asm.Xc).apply(null,arguments)};
139
- g.dynCall_ji=function(){return(g.dynCall_ji=g.asm.Yc).apply(null,arguments)};g.dynCall_iij=function(){return(g.dynCall_iij=g.asm.Zc).apply(null,arguments)};g.dynCall_vij=function(){return(g.dynCall_vij=g.asm._c).apply(null,arguments)};g.dynCall_jiji=function(){return(g.dynCall_jiji=g.asm.$c).apply(null,arguments)};g.dynCall_iiiiij=function(){return(g.dynCall_iiiiij=g.asm.ad).apply(null,arguments)};g.dynCall_iiiiijj=function(){return(g.dynCall_iiiiijj=g.asm.bd).apply(null,arguments)};
140
- g.dynCall_iiiiiijj=function(){return(g.dynCall_iiiiiijj=g.asm.cd).apply(null,arguments)};g.dynCall_viijii=function(){return(g.dynCall_viijii=g.asm.dd).apply(null,arguments)};function Zc(a,b,c){var d=X();try{I(a)(b,c)}catch(e){Y(d);if(e!==e+0&&"longjmp"!==e)throw e;Z(1,0)}}function Tc(a,b,c,d){var e=X();try{return I(a)(b,c,d)}catch(f){Y(e);if(f!==f+0&&"longjmp"!==f)throw f;Z(1,0)}}function ad(a,b,c,d,e){var f=X();try{I(a)(b,c,d,e)}catch(l){Y(f);if(l!==l+0&&"longjmp"!==l)throw l;Z(1,0)}}
141
- function Yc(a,b){var c=X();try{I(a)(b)}catch(d){Y(c);if(d!==d+0&&"longjmp"!==d)throw d;Z(1,0)}}function Sc(a,b,c){var d=X();try{return I(a)(b,c)}catch(e){Y(d);if(e!==e+0&&"longjmp"!==e)throw e;Z(1,0)}}function Uc(a,b,c,d,e){var f=X();try{return I(a)(b,c,d,e)}catch(l){Y(f);if(l!==l+0&&"longjmp"!==l)throw l;Z(1,0)}}function Rc(a,b){var c=X();try{return I(a)(b)}catch(d){Y(c);if(d!==d+0&&"longjmp"!==d)throw d;Z(1,0)}}
142
- function Xc(a){var b=X();try{I(a)()}catch(c){Y(b);if(c!==c+0&&"longjmp"!==c)throw c;Z(1,0)}}function dd(a,b,c,d,e,f,l,k,n){var p=X();try{I(a)(b,c,d,e,f,l,k,n)}catch(q){Y(p);if(q!==q+0&&"longjmp"!==q)throw q;Z(1,0)}}function $c(a,b,c,d){var e=X();try{I(a)(b,c,d)}catch(f){Y(e);if(f!==f+0&&"longjmp"!==f)throw f;Z(1,0)}}function bd(a,b,c,d,e,f){var l=X();try{I(a)(b,c,d,e,f)}catch(k){Y(l);if(k!==k+0&&"longjmp"!==k)throw k;Z(1,0)}}
143
- function Wc(a,b,c,d,e,f,l){var k=X();try{return I(a)(b,c,d,e,f,l)}catch(n){Y(k);if(n!==n+0&&"longjmp"!==n)throw n;Z(1,0)}}function Vc(a,b,c,d,e,f){var l=X();try{return I(a)(b,c,d,e,f)}catch(k){Y(l);if(k!==k+0&&"longjmp"!==k)throw k;Z(1,0)}}function cd(a,b,c,d,e,f,l){var k=X();try{I(a)(b,c,d,e,f,l)}catch(n){Y(k);if(n!==n+0&&"longjmp"!==n)throw n;Z(1,0)}}var fd;Ta=function gd(){fd||hd();fd||(Ta=gd)};
144
- function hd(){function a(){if(!fd&&(fd=!0,g.calledRun=!0,!ua)){Ya(Oa);aa(g);if(g.onRuntimeInitialized)g.onRuntimeInitialized();if(g.postRun)for("function"==typeof g.postRun&&(g.postRun=[g.postRun]);g.postRun.length;){var b=g.postRun.shift();Pa.unshift(b)}Ya(Pa)}}if(!(0<Ra)){if(g.preRun)for("function"==typeof g.preRun&&(g.preRun=[g.preRun]);g.preRun.length;)Qa();Ya(Na);0<Ra||(g.setStatus?(g.setStatus("Running..."),setTimeout(function(){setTimeout(function(){g.setStatus("")},1);a()},1)):a())}}
145
- g.run=hd;if(g.preInit)for("function"==typeof g.preInit&&(g.preInit=[g.preInit]);0<g.preInit.length;)g.preInit.pop()();hd();
146
-
147
-
148
- return Rive.ready
149
- }
150
- );
151
- })();
152
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Rive);
153
-
154
- /***/ }),
155
- /* 2 */
156
- /***/ ((module) => {
157
-
158
- module.exports = JSON.parse('{"name":"@rive-app/webgl","version":"1.0.3","description":"Rive\'s webgl 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.wasm"],"typings":"rive.d.ts","dependencies":{}}');
159
-
160
- /***/ })
161
- /******/ ]);
162
- /************************************************************************/
163
- /******/ // The module cache
164
- /******/ var __webpack_module_cache__ = {};
165
- /******/
166
- /******/ // The require function
167
- /******/ function __webpack_require__(moduleId) {
168
- /******/ // Check if module is in cache
169
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
170
- /******/ if (cachedModule !== undefined) {
171
- /******/ return cachedModule.exports;
172
- /******/ }
173
- /******/ // Create a new module (and put it into the cache)
174
- /******/ var module = __webpack_module_cache__[moduleId] = {
175
- /******/ // no module.id needed
176
- /******/ // no module.loaded needed
177
- /******/ exports: {}
178
- /******/ };
179
- /******/
180
- /******/ // Execute the module function
181
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
182
- /******/
183
- /******/ // Return the exports of the module
184
- /******/ return module.exports;
185
- /******/ }
186
- /******/
187
- /************************************************************************/
188
- /******/ /* webpack/runtime/define property getters */
189
- /******/ (() => {
190
- /******/ // define getter functions for harmony exports
191
- /******/ __webpack_require__.d = (exports, definition) => {
192
- /******/ for(var key in definition) {
193
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
194
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
195
- /******/ }
196
- /******/ }
197
- /******/ };
198
- /******/ })();
199
- /******/
200
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
201
- /******/ (() => {
202
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
203
- /******/ })();
204
- /******/
205
- /******/ /* webpack/runtime/make namespace object */
206
- /******/ (() => {
207
- /******/ // define __esModule on exports
208
- /******/ __webpack_require__.r = (exports) => {
209
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
210
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
211
- /******/ }
212
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
213
- /******/ };
214
- /******/ })();
215
- /******/
216
- /************************************************************************/
217
- var __webpack_exports__ = {};
218
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
219
- (() => {
220
- __webpack_require__.r(__webpack_exports__);
221
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
222
- /* harmony export */ "Fit": () => (/* binding */ Fit),
223
- /* harmony export */ "Alignment": () => (/* binding */ Alignment),
224
- /* harmony export */ "Layout": () => (/* binding */ Layout),
225
- /* harmony export */ "RuntimeLoader": () => (/* binding */ RuntimeLoader),
226
- /* harmony export */ "StateMachineInputType": () => (/* binding */ StateMachineInputType),
227
- /* harmony export */ "StateMachineInput": () => (/* binding */ StateMachineInput),
228
- /* harmony export */ "EventType": () => (/* binding */ EventType),
229
- /* harmony export */ "LoopType": () => (/* binding */ LoopType),
230
- /* harmony export */ "Rive": () => (/* binding */ Rive),
231
- /* harmony export */ "Testing": () => (/* binding */ Testing)
232
- /* harmony export */ });
233
- /* harmony import */ var _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
234
- /* harmony import */ var package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
235
- var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
236
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
237
- return new (P || (P = Promise))(function (resolve, reject) {
238
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
239
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
240
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
241
- step((generator = generator.apply(thisArg, _arguments || [])).next());
242
- });
243
- };
244
- var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
245
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
246
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
247
- function verb(n) { return function (v) { return step([n, v]); }; }
248
- function step(op) {
249
- if (f) throw new TypeError("Generator is already executing.");
250
- while (_) try {
251
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
252
- if (y = 0, t) op = [op[0] & 2, t.value];
253
- switch (op[0]) {
254
- case 0: case 1: t = op; break;
255
- case 4: _.label++; return { value: op[1], done: false };
256
- case 5: _.label++; y = op[1]; op = [0]; continue;
257
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
258
- default:
259
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
260
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
261
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
262
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
263
- if (t[2]) _.ops.pop();
264
- _.trys.pop(); continue;
265
- }
266
- op = body.call(thisArg, _);
267
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
268
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
269
- }
270
- };
271
-
272
-
273
- // Tracks playback states; numbers map to the runtime's numerical values
274
- // i.e. play: 0, pause: 1, stop: 2
275
- var PlaybackState;
276
- (function (PlaybackState) {
277
- PlaybackState[PlaybackState["Play"] = 0] = "Play";
278
- PlaybackState[PlaybackState["Pause"] = 1] = "Pause";
279
- PlaybackState[PlaybackState["Stop"] = 2] = "Stop";
280
- })(PlaybackState || (PlaybackState = {}));
281
- // #region layout
282
- // Fit options for the canvas
283
- var Fit;
284
- (function (Fit) {
285
- Fit["Cover"] = "cover";
286
- Fit["Contain"] = "contain";
287
- Fit["Fill"] = "fill";
288
- Fit["FitWidth"] = "fitWidth";
289
- Fit["FitHeight"] = "fitHeight";
290
- Fit["None"] = "none";
291
- Fit["ScaleDown"] = "scaleDown";
292
- })(Fit || (Fit = {}));
293
- // Alignment options for the canvas
294
- var Alignment;
295
- (function (Alignment) {
296
- Alignment["Center"] = "center";
297
- Alignment["TopLeft"] = "topLeft";
298
- Alignment["TopCenter"] = "topCenter";
299
- Alignment["TopRight"] = "topRight";
300
- Alignment["CenterLeft"] = "centerLeft";
301
- Alignment["CenterRight"] = "centerRight";
302
- Alignment["BottomLeft"] = "bottomLeft";
303
- Alignment["BottomCenter"] = "bottomCenter";
304
- Alignment["BottomRight"] = "bottomRight";
305
- })(Alignment || (Alignment = {}));
306
- // Alignment options for Rive animations in a HTML canvas
307
- var Layout = /** @class */ (function () {
308
- function Layout(params) {
309
- var _a, _b, _c, _d, _e, _f;
310
- this.fit = (_a = params === null || params === void 0 ? void 0 : params.fit) !== null && _a !== void 0 ? _a : Fit.Contain;
311
- this.alignment = (_b = params === null || params === void 0 ? void 0 : params.alignment) !== null && _b !== void 0 ? _b : Alignment.Center;
312
- this.minX = (_c = params === null || params === void 0 ? void 0 : params.minX) !== null && _c !== void 0 ? _c : 0;
313
- this.minY = (_d = params === null || params === void 0 ? void 0 : params.minY) !== null && _d !== void 0 ? _d : 0;
314
- this.maxX = (_e = params === null || params === void 0 ? void 0 : params.maxX) !== null && _e !== void 0 ? _e : 0;
315
- this.maxY = (_f = params === null || params === void 0 ? void 0 : params.maxY) !== null && _f !== void 0 ? _f : 0;
316
- }
317
- // Alternative constructor to build a Layout from an interface/object
318
- Layout.new = function (_a) {
319
- var fit = _a.fit, alignment = _a.alignment, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
320
- console.warn('This function is deprecated: please use `new Layout({})` instead');
321
- return new Layout({ fit: fit, alignment: alignment, minX: minX, minY: minY, maxX: maxX, maxY: maxY });
322
- };
323
- /**
324
- * Makes a copy of the layout, replacing any specified parameters
325
- */
326
- Layout.prototype.copyWith = function (_a) {
327
- var fit = _a.fit, alignment = _a.alignment, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
328
- return new Layout({
329
- fit: fit !== null && fit !== void 0 ? fit : this.fit,
330
- alignment: alignment !== null && alignment !== void 0 ? alignment : this.alignment,
331
- minX: minX !== null && minX !== void 0 ? minX : this.minX,
332
- minY: minY !== null && minY !== void 0 ? minY : this.minY,
333
- maxX: maxX !== null && maxX !== void 0 ? maxX : this.maxX,
334
- maxY: maxY !== null && maxY !== void 0 ? maxY : this.maxY
335
- });
336
- };
337
- // Returns fit for the Wasm runtime format
338
- Layout.prototype.runtimeFit = function (rive) {
339
- if (this.cachedRuntimeFit)
340
- return this.cachedRuntimeFit;
341
- var fit;
342
- if (this.fit === Fit.Cover)
343
- fit = rive.Fit.cover;
344
- else if (this.fit === Fit.Contain)
345
- fit = rive.Fit.contain;
346
- else if (this.fit === Fit.Fill)
347
- fit = rive.Fit.fill;
348
- else if (this.fit === Fit.FitWidth)
349
- fit = rive.Fit.fitWidth;
350
- else if (this.fit === Fit.FitHeight)
351
- fit = rive.Fit.fitHeight;
352
- else if (this.fit === Fit.ScaleDown)
353
- fit = rive.Fit.scaleDown;
354
- else
355
- fit = rive.Fit.none;
356
- this.cachedRuntimeFit = fit;
357
- return fit;
358
- };
359
- // Returns alignment for the Wasm runtime format
360
- Layout.prototype.runtimeAlignment = function (rive) {
361
- if (this.cachedRuntimeAlignment)
362
- return this.cachedRuntimeAlignment;
363
- var alignment;
364
- if (this.alignment === Alignment.TopLeft)
365
- alignment = rive.Alignment.topLeft;
366
- else if (this.alignment === Alignment.TopCenter)
367
- alignment = rive.Alignment.topCenter;
368
- else if (this.alignment === Alignment.TopRight)
369
- alignment = rive.Alignment.topRight;
370
- else if (this.alignment === Alignment.CenterLeft)
371
- alignment = rive.Alignment.centerLeft;
372
- else if (this.alignment === Alignment.CenterRight)
373
- alignment = rive.Alignment.centerRight;
374
- else if (this.alignment === Alignment.BottomLeft)
375
- alignment = rive.Alignment.bottomLeft;
376
- else if (this.alignment === Alignment.BottomCenter)
377
- alignment = rive.Alignment.bottomCenter;
378
- else if (this.alignment === Alignment.BottomRight)
379
- alignment = rive.Alignment.bottomRight;
380
- else
381
- alignment = rive.Alignment.center;
382
- this.cachedRuntimeAlignment = alignment;
383
- return alignment;
384
- };
385
- return Layout;
386
- }());
387
-
388
- // Runtime singleton; use getInstance to provide a callback that returns the
389
- // Rive runtime
390
- var RuntimeLoader = /** @class */ (function () {
391
- // Class is never instantiated
392
- function RuntimeLoader() {
393
- }
394
- // Loads the runtime
395
- RuntimeLoader.loadRuntime = function () {
396
- _rive_advanced_mjs__WEBPACK_IMPORTED_MODULE_0__.default({
397
- // Loads Wasm bundle
398
- locateFile: function (_) { return RuntimeLoader.wasmURL; }
399
- }).then(function (rive) {
400
- var _a;
401
- RuntimeLoader.runtime = rive;
402
- // Fire all the callbacks
403
- while (RuntimeLoader.callBackQueue.length > 0) {
404
- (_a = RuntimeLoader.callBackQueue.shift()) === null || _a === void 0 ? void 0 : _a(RuntimeLoader.runtime);
405
- }
406
- });
407
- };
408
- // Provides a runtime instance via a callback
409
- RuntimeLoader.getInstance = function (callback) {
410
- // If it's not loading, start loading runtime
411
- if (!RuntimeLoader.isLoading) {
412
- RuntimeLoader.isLoading = true;
413
- RuntimeLoader.loadRuntime();
414
- }
415
- if (!RuntimeLoader.runtime) {
416
- RuntimeLoader.callBackQueue.push(callback);
417
- }
418
- else {
419
- callback(RuntimeLoader.runtime);
420
- }
421
- };
422
- // Provides a runtime instance via a promise
423
- RuntimeLoader.awaitInstance = function () {
424
- return new Promise(function (resolve, reject) {
425
- return RuntimeLoader.getInstance(function (rive) { return resolve(rive); });
426
- });
427
- };
428
- // Manually sets the wasm url
429
- RuntimeLoader.setWasmUrl = function (url) {
430
- RuntimeLoader.wasmURL = url;
431
- };
432
- // Flag to indicate that loading has started/completed
433
- RuntimeLoader.isLoading = false;
434
- // List of callbacks for the runtime that come in while loading
435
- RuntimeLoader.callBackQueue = [];
436
- // Path to the Wasm file; default path works for testing only;
437
- // if embedded wasm is used then this is never used.
438
- RuntimeLoader.wasmURL = "https://unpkg.com/" + package_json__WEBPACK_IMPORTED_MODULE_1__.name + "@" + package_json__WEBPACK_IMPORTED_MODULE_1__.version + "/rive.wasm";
439
- return RuntimeLoader;
440
- }());
441
-
442
- // #endregion
443
- // #region animations
444
- // Wraps animations and instances from the runtime and keeps track of playback
445
- // state
446
- var Animation = /** @class */ (function () {
447
- /**
448
- * Constructs a new animation
449
- * @constructor
450
- * @param {any} animation: runtime animation object
451
- * @param {any} instance: runtime animation instance object
452
- */
453
- function Animation(animation, runtime, playing) {
454
- this.animation = animation;
455
- this.playing = playing;
456
- this.loopCount = 0;
457
- // Time to which the animation should move to on the next render
458
- this.scrubTo = null;
459
- this.instance = new runtime.LinearAnimationInstance(animation);
460
- }
461
- Object.defineProperty(Animation.prototype, "name", {
462
- // Returns the animation's name
463
- get: function () {
464
- return this.animation.name;
465
- },
466
- enumerable: false,
467
- configurable: true
468
- });
469
- Object.defineProperty(Animation.prototype, "time", {
470
- // Returns the animation's current time
471
- get: function () {
472
- return this.instance.time;
473
- },
474
- // Sets the animation's current time
475
- set: function (value) {
476
- this.instance.time = value;
477
- },
478
- enumerable: false,
479
- configurable: true
480
- });
481
- Object.defineProperty(Animation.prototype, "loopValue", {
482
- // Returns the animation's loop type
483
- get: function () {
484
- return this.animation.loopValue;
485
- },
486
- enumerable: false,
487
- configurable: true
488
- });
489
- /**
490
- * Advances the animation by the give time. If the animation needs scrubbing,
491
- * time is ignored and the stored scrub value is used.
492
- * @param time the time to advance the animation by if no scrubbing required
493
- */
494
- Animation.prototype.advance = function (time) {
495
- if (this.scrubTo === null) {
496
- this.instance.advance(time);
497
- }
498
- else {
499
- this.instance.time = 0;
500
- this.instance.advance(this.scrubTo);
501
- this.scrubTo = null;
502
- }
503
- };
504
- Object.defineProperty(Animation.prototype, "needsScrub", {
505
- get: function () {
506
- return this.scrubTo !== null;
507
- },
508
- enumerable: false,
509
- configurable: true
510
- });
511
- /**
512
- * Deletes the backing Wasm animation instance; once this is called, this
513
- * animation is no more.
514
- */
515
- Animation.prototype.cleanup = function () {
516
- this.instance.delete();
517
- };
518
- return Animation;
519
- }());
520
- // #endregion
521
- // #region state machines
522
- var StateMachineInputType;
523
- (function (StateMachineInputType) {
524
- StateMachineInputType[StateMachineInputType["Number"] = 56] = "Number";
525
- StateMachineInputType[StateMachineInputType["Trigger"] = 58] = "Trigger";
526
- StateMachineInputType[StateMachineInputType["Boolean"] = 59] = "Boolean";
527
- })(StateMachineInputType || (StateMachineInputType = {}));
528
- /**
529
- * An input for a state machine
530
- */
531
- var StateMachineInput = /** @class */ (function () {
532
- function StateMachineInput(type, runtimeInput) {
533
- this.type = type;
534
- this.runtimeInput = runtimeInput;
535
- }
536
- Object.defineProperty(StateMachineInput.prototype, "name", {
537
- /**
538
- * Returns the name of the input
539
- */
540
- get: function () {
541
- return this.runtimeInput.name;
542
- },
543
- enumerable: false,
544
- configurable: true
545
- });
546
- Object.defineProperty(StateMachineInput.prototype, "value", {
547
- /**
548
- * Returns the current value of the input
549
- */
550
- get: function () {
551
- return this.runtimeInput.value;
552
- },
553
- /**
554
- * Sets the value of the input
555
- */
556
- set: function (value) {
557
- this.runtimeInput.value = value;
558
- },
559
- enumerable: false,
560
- configurable: true
561
- });
562
- /**
563
- * Fires a trigger; does nothing on Number or Boolean input types
564
- */
565
- StateMachineInput.prototype.fire = function () {
566
- if (this.type === StateMachineInputType.Trigger) {
567
- this.runtimeInput.fire();
568
- }
569
- };
570
- return StateMachineInput;
571
- }());
572
-
573
- var StateMachine = /** @class */ (function () {
574
- /**
575
- * @constructor
576
- * @param stateMachine runtime state machine object
577
- * @param instance runtime state machine instance object
578
- */
579
- function StateMachine(stateMachine, runtime, playing) {
580
- this.stateMachine = stateMachine;
581
- this.playing = playing;
582
- /**
583
- * Caches the inputs from the runtime
584
- */
585
- this.inputs = [];
586
- this.instance = new runtime.StateMachineInstance(stateMachine);
587
- this.initInputs(runtime);
588
- }
589
- Object.defineProperty(StateMachine.prototype, "name", {
590
- get: function () {
591
- return this.stateMachine.name;
592
- },
593
- enumerable: false,
594
- configurable: true
595
- });
596
- Object.defineProperty(StateMachine.prototype, "statesChanged", {
597
- /**
598
- * Returns a list of state names that have changed on this frame
599
- */
600
- get: function () {
601
- var names = [];
602
- for (var i = 0; i < this.instance.stateChangedCount(); i++) {
603
- names.push(this.instance.stateChangedNameByIndex(i));
604
- }
605
- return names;
606
- },
607
- enumerable: false,
608
- configurable: true
609
- });
610
- /**
611
- * Fetches references to the state machine's inputs and caches them
612
- * @param runtime an instance of the runtime; needed for the SMIInput types
613
- */
614
- StateMachine.prototype.initInputs = function (runtime) {
615
- // Fetch the inputs from the runtime if we don't have them
616
- for (var i = 0; i < this.instance.inputCount(); i++) {
617
- var input = this.instance.input(i);
618
- this.inputs.push(this.mapRuntimeInput(input, runtime));
619
- }
620
- };
621
- /**
622
- * Maps a runtime input to it's appropriate type
623
- * @param input
624
- */
625
- StateMachine.prototype.mapRuntimeInput = function (input, runtime) {
626
- if (input.type === runtime.SMIInput.bool) {
627
- return new StateMachineInput(StateMachineInputType.Boolean, input.asBool());
628
- }
629
- else if (input.type === runtime.SMIInput.number) {
630
- return new StateMachineInput(StateMachineInputType.Number, input.asNumber());
631
- }
632
- else if (input.type === runtime.SMIInput.trigger) {
633
- return new StateMachineInput(StateMachineInputType.Trigger, input.asTrigger());
634
- }
635
- };
636
- /**
637
- * Deletes the backing Wasm state machine instance; once this is called, this
638
- * state machine is no more.
639
- */
640
- StateMachine.prototype.cleanup = function () {
641
- this.instance.delete();
642
- };
643
- return StateMachine;
644
- }());
645
- // #endregion
646
- // #region animator
647
- /**
648
- * Manages animation
649
- */
650
- var Animator = /** @class */ (function () {
651
- /**
652
- * Constructs a new animator
653
- * @constructor
654
- * @param runtime Rive runtime; needed to instance animations & state machines
655
- * @param artboard the artboard that holds all animations and state machines
656
- * @param animations optional list of animations
657
- * @param stateMachines optional list of state machines
658
- */
659
- function Animator(runtime, artboard, eventManager, animations, stateMachines) {
660
- if (animations === void 0) { animations = []; }
661
- if (stateMachines === void 0) { stateMachines = []; }
662
- this.runtime = runtime;
663
- this.artboard = artboard;
664
- this.eventManager = eventManager;
665
- this.animations = animations;
666
- this.stateMachines = stateMachines;
667
- }
668
- /**
669
- * Adds animations and state machines by their names. If names are shared
670
- * between animations & state machines, then the first one found will be
671
- * created. Best not to use the same names for these in your Rive file.
672
- * @param animatable the name(s) of animations and state machines to add
673
- * @returns a list of names of the playing animations and state machines
674
- */
675
- Animator.prototype.add = function (animatables, playing, fireEvent) {
676
- if (fireEvent === void 0) { fireEvent = true; }
677
- animatables = mapToStringArray(animatables);
678
- // If animatables is empty, play or pause everything
679
- if (animatables.length === 0) {
680
- this.animations.forEach(function (a) { return a.playing = playing; });
681
- this.stateMachines.forEach(function (m) { return m.playing = playing; });
682
- }
683
- else {
684
- // Play/pause already instanced items, or create new instances
685
- var instancedAnimationNames = this.animations.map(function (a) { return a.name; });
686
- var instancedMachineNames = this.stateMachines.map(function (m) { return m.name; });
687
- for (var i in animatables) {
688
- var aIndex = instancedAnimationNames.indexOf(animatables[i]);
689
- var mIndex = instancedMachineNames.indexOf(animatables[i]);
690
- if (aIndex >= 0 || mIndex >= 0) {
691
- if (aIndex >= 0) {
692
- // Animation is instanced, play/pause it
693
- this.animations[aIndex].playing = playing;
694
- }
695
- else {
696
- // State machine is instanced, play/pause it
697
- this.stateMachines[mIndex].playing = playing;
698
- }
699
- }
700
- else {
701
- // Try to create a new animation instance
702
- var anim = this.artboard.animationByName(animatables[i]);
703
- if (anim) {
704
- this.animations.push(new Animation(anim, this.runtime, playing));
705
- }
706
- else {
707
- // Try to create a new state machine instance
708
- var sm = this.artboard.stateMachineByName(animatables[i]);
709
- if (sm) {
710
- this.stateMachines.push(new StateMachine(sm, this.runtime, playing));
711
- }
712
- }
713
- }
714
- }
715
- }
716
- // Fire play/paused events for animations
717
- if (fireEvent) {
718
- if (playing) {
719
- this.eventManager.fire({
720
- type: EventType.Play,
721
- data: this.playing,
722
- });
723
- }
724
- else {
725
- this.eventManager.fire({
726
- type: EventType.Pause,
727
- data: this.paused,
728
- });
729
- }
730
- }
731
- return playing ? this.playing : this.paused;
732
- };
733
- /**
734
- * Play the named animations/state machines
735
- * @param animatables the names of the animations/machines to play; plays all if empty
736
- * @returns a list of the playing items
737
- */
738
- Animator.prototype.play = function (animatables) {
739
- return this.add(animatables, true);
740
- };
741
- /**
742
- * Pauses named animations and state machines, or everything if nothing is
743
- * specified
744
- * @param animatables names of the animations and state machines to pause
745
- * @returns a list of names of the animations and state machines paused
746
- */
747
- Animator.prototype.pause = function (animatables) {
748
- return this.add(animatables, false);
749
- };
750
- /**
751
- * Set time of named animations
752
- * @param animations names of the animations to scrub
753
- * @param value time scrub value, a floating point number to which the playhead is jumped
754
- * @returns a list of names of the animations that were scrubbed
755
- */
756
- Animator.prototype.scrub = function (animatables, value) {
757
- var forScrubbing = this.animations.filter(function (a) { return animatables.includes(a.name); });
758
- forScrubbing.forEach(function (a) { return a.scrubTo = value; });
759
- return forScrubbing.map(function (a) { return a.name; });
760
- };
761
- Object.defineProperty(Animator.prototype, "playing", {
762
- /**
763
- * Returns a list of names of all animations and state machines currently
764
- * playing
765
- */
766
- get: function () {
767
- return this.animations.filter(function (a) { return a.playing; }).map(function (a) { return a.name; }).concat(this.stateMachines.filter(function (m) { return m.playing; }).map(function (m) { return m.name; }));
768
- },
769
- enumerable: false,
770
- configurable: true
771
- });
772
- Object.defineProperty(Animator.prototype, "paused", {
773
- /**
774
- * Returns a list of names of all animations and state machines currently
775
- * paused
776
- */
777
- get: function () {
778
- return this.animations.filter(function (a) { return !a.playing; }).map(function (a) { return a.name; }).concat(this.stateMachines.filter(function (m) { return !m.playing; }).map(function (m) { return m.name; }));
779
- },
780
- enumerable: false,
781
- configurable: true
782
- });
783
- /**
784
- * Stops and removes all named animations and state machines
785
- * @param animatables animations and state machines to remove
786
- * @returns a list of names of removed items
787
- */
788
- Animator.prototype.stop = function (animatables) {
789
- var _this = this;
790
- animatables = mapToStringArray(animatables);
791
- // If nothing's specified, wipe them out, all of them
792
- var removedNames = [];
793
- // Stop everything
794
- if (animatables.length === 0) {
795
- removedNames = this.animations.map(function (a) { return a.name; }).concat(this.stateMachines.map(function (m) { return m.name; }));
796
- // Clean up before emptying the arrays
797
- this.animations.forEach(function (a) { return a.cleanup(); });
798
- this.stateMachines.forEach(function (m) { return m.cleanup(); });
799
- // Empty out the arrays
800
- this.animations.splice(0, this.animations.length);
801
- this.stateMachines.splice(0, this.stateMachines.length);
802
- }
803
- else {
804
- // Remove only the named animations/state machines
805
- var animationsToRemove = this.animations.filter(function (a) { return animatables.includes(a.name); });
806
- animationsToRemove.forEach(function (a) {
807
- a.cleanup();
808
- _this.animations.splice(_this.animations.indexOf(a), 1);
809
- });
810
- var machinesToRemove = this.stateMachines.filter(function (m) { return animatables.includes(m.name); });
811
- machinesToRemove.forEach(function (m) {
812
- m.cleanup();
813
- _this.stateMachines.splice(_this.stateMachines.indexOf(m), 1);
814
- });
815
- removedNames = animationsToRemove.map(function (a) { return a.name; }).concat(machinesToRemove.map(function (m) { return m.name; }));
816
- }
817
- this.eventManager.fire({
818
- type: EventType.Stop,
819
- data: removedNames,
820
- });
821
- // Return the list of animations removed
822
- return removedNames;
823
- };
824
- Object.defineProperty(Animator.prototype, "isPlaying", {
825
- /**
826
- * Returns true if at least one animation is active
827
- */
828
- get: function () {
829
- return this.animations.reduce(function (acc, curr) { return acc || curr.playing; }, false)
830
- || this.stateMachines.reduce(function (acc, curr) { return acc || curr.playing; }, false);
831
- },
832
- enumerable: false,
833
- configurable: true
834
- });
835
- Object.defineProperty(Animator.prototype, "isPaused", {
836
- /**
837
- * Returns true if all animations are paused and there's at least one animation
838
- */
839
- get: function () {
840
- return !this.isPlaying &&
841
- (this.animations.length > 0 || this.stateMachines.length > 0);
842
- },
843
- enumerable: false,
844
- configurable: true
845
- });
846
- Object.defineProperty(Animator.prototype, "isStopped", {
847
- /**
848
- * Returns true if there are no playing or paused animations/state machines
849
- */
850
- get: function () {
851
- return this.animations.length === 0 && this.stateMachines.length === 0;
852
- },
853
- enumerable: false,
854
- configurable: true
855
- });
856
- /**
857
- * If there are no animations or state machines, add the first one found
858
- * @returns the name of the animation or state machine instanced
859
- */
860
- Animator.prototype.atLeastOne = function (playing, fireEvent) {
861
- if (fireEvent === void 0) { fireEvent = true; }
862
- var instancedName;
863
- if (this.animations.length === 0 && this.stateMachines.length === 0) {
864
- if (this.artboard.animationCount() > 0) {
865
- // Add the first animation
866
- this.add([instancedName = this.artboard.animationByIndex(0).name], playing, fireEvent);
867
- }
868
- else if (this.artboard.stateMachineCount() > 0) {
869
- // Add the first state machine
870
- this.add([instancedName = this.artboard.stateMachineByIndex(0).name], playing, fireEvent);
871
- }
872
- }
873
- return instancedName;
874
- };
875
- /**
876
- * Checks if any animations have looped and if so, fire the appropriate event
877
- */
878
- Animator.prototype.handleLooping = function () {
879
- for (var _i = 0, _a = this.animations.filter(function (a) { return a.playing; }); _i < _a.length; _i++) {
880
- var animation = _a[_i];
881
- // Emit if the animation looped
882
- if (animation.loopValue === 0 && animation.loopCount) {
883
- animation.loopCount = 0;
884
- // This is a one-shot; if it has ended, delete the instance
885
- this.stop(animation.name);
886
- }
887
- else if (animation.loopValue === 1 && animation.loopCount) {
888
- this.eventManager.fire({
889
- type: EventType.Loop,
890
- data: { animation: animation.name, type: LoopType.Loop }
891
- });
892
- animation.loopCount = 0;
893
- }
894
- // Wasm indicates a loop at each time the animation
895
- // changes direction, so a full loop/lap occurs every
896
- // two loop counts
897
- else if (animation.loopValue === 2 && animation.loopCount > 1) {
898
- this.eventManager.fire({
899
- type: EventType.Loop,
900
- data: { animation: animation.name, type: LoopType.PingPong }
901
- });
902
- animation.loopCount = 0;
903
- }
904
- }
905
- };
906
- /**
907
- * Checks if states have changed in state machines and fires a statechange
908
- * event
909
- */
910
- Animator.prototype.handleStateChanges = function () {
911
- var statesChanged = [];
912
- for (var _i = 0, _a = this.stateMachines.filter(function (sm) { return sm.playing; }); _i < _a.length; _i++) {
913
- var stateMachine = _a[_i];
914
- statesChanged.push.apply(statesChanged, stateMachine.statesChanged);
915
- }
916
- if (statesChanged.length > 0) {
917
- this.eventManager.fire({
918
- type: EventType.StateChange,
919
- data: statesChanged,
920
- });
921
- }
922
- };
923
- return Animator;
924
- }());
925
- // #endregion
926
- // #region events
927
- /**
928
- * Supported event types triggered in Rive
929
- */
930
- var EventType;
931
- (function (EventType) {
932
- EventType["Load"] = "load";
933
- EventType["LoadError"] = "loaderror";
934
- EventType["Play"] = "play";
935
- EventType["Pause"] = "pause";
936
- EventType["Stop"] = "stop";
937
- EventType["Loop"] = "loop";
938
- EventType["Draw"] = "draw";
939
- EventType["StateChange"] = "statechange";
940
- })(EventType || (EventType = {}));
941
- /**
942
- * Looping types: one-shot, loop, and ping-pong
943
- */
944
- var LoopType;
945
- (function (LoopType) {
946
- LoopType["OneShot"] = "oneshot";
947
- LoopType["Loop"] = "loop";
948
- LoopType["PingPong"] = "pingpong"; // has value 2 in runtime
949
- })(LoopType || (LoopType = {}));
950
- // Manages Rive events and listeners
951
- var EventManager = /** @class */ (function () {
952
- function EventManager(listeners) {
953
- if (listeners === void 0) { listeners = []; }
954
- this.listeners = listeners;
955
- }
956
- // Gets listeners of specified type
957
- EventManager.prototype.getListeners = function (type) {
958
- return this.listeners.filter(function (e) { return e.type === type; });
959
- };
960
- // Adds a listener
961
- EventManager.prototype.add = function (listener) {
962
- if (!this.listeners.includes(listener)) {
963
- this.listeners.push(listener);
964
- }
965
- };
966
- /**
967
- * Removes a listener
968
- * @param listener the listener with the callback to be removed
969
- */
970
- EventManager.prototype.remove = function (listener) {
971
- // We can't simply look for the listener as it'll be a different instance to
972
- // one originally subscribed. Find all the listeners of the right type and
973
- // then check their callbacks which should match.
974
- for (var i = 0; i < this.listeners.length; i++) {
975
- var currentListener = this.listeners[i];
976
- if (currentListener.type === listener.type) {
977
- if (currentListener.callback === listener.callback) {
978
- this.listeners.splice(i, 1);
979
- break;
980
- }
981
- }
982
- }
983
- };
984
- /**
985
- * Clears all listeners of specified type, or every listener if no type is
986
- * specified
987
- * @param type the type of listeners to clear, or all listeners if not
988
- * specified
989
- */
990
- EventManager.prototype.removeAll = function (type) {
991
- var _this = this;
992
- if (!type) {
993
- this.listeners.splice(0, this.listeners.length);
994
- }
995
- else {
996
- this.listeners
997
- .filter(function (l) { return l.type === type; })
998
- .forEach(function (l) { return _this.remove(l); });
999
- }
1000
- };
1001
- // Fires an event
1002
- EventManager.prototype.fire = function (event) {
1003
- var eventListeners = this.getListeners(event.type);
1004
- eventListeners.forEach(function (listener) { return listener.callback(event); });
1005
- };
1006
- return EventManager;
1007
- }());
1008
- // Manages a queue of tasks
1009
- var TaskQueueManager = /** @class */ (function () {
1010
- function TaskQueueManager(eventManager) {
1011
- this.eventManager = eventManager;
1012
- this.queue = [];
1013
- }
1014
- // Adds a task top the queue
1015
- TaskQueueManager.prototype.add = function (task) {
1016
- this.queue.push(task);
1017
- };
1018
- // Processes all tasks in the queue
1019
- TaskQueueManager.prototype.process = function () {
1020
- while (this.queue.length > 0) {
1021
- var task = this.queue.shift();
1022
- task === null || task === void 0 ? void 0 : task.action();
1023
- if (task === null || task === void 0 ? void 0 : task.event) {
1024
- this.eventManager.fire(task.event);
1025
- }
1026
- }
1027
- };
1028
- return TaskQueueManager;
1029
- }());
1030
- var Rive = /** @class */ (function () {
1031
- function Rive(params) {
1032
- var _a;
1033
- // Flag to indicate if the layout has changed; used by the renderer to know
1034
- // when to align
1035
- this._updateLayout = true;
1036
- /**
1037
- * Flag to active/deactivate renderer
1038
- */
1039
- this.isRendererActive = true;
1040
- // Tracks if a Rive file is loaded
1041
- this.loaded = false;
1042
- /**
1043
- * Tracks if a Rive file is loaded; we need this in addition to loaded as some
1044
- * commands (e.g. contents) can be called as soon as the file is loaded.
1045
- * However, playback commands need to be queued and run in order once initial
1046
- * animations and autoplay has been sorted out. This applies to play, pause,
1047
- * and start.
1048
- */
1049
- this.readyForPlaying = false;
1050
- // Runtime artboard
1051
- this.artboard = null;
1052
- /**
1053
- * Used be draw to track when a second of active rendering time has passed. Used for debugging purposes
1054
- */
1055
- this.renderSecondTimer = 0;
1056
- this.canvas = params.canvas;
1057
- this.src = params.src;
1058
- this.buffer = params.buffer;
1059
- this.layout = (_a = params.layout) !== null && _a !== void 0 ? _a : new Layout();
1060
- // New event management system
1061
- this.eventManager = new EventManager();
1062
- if (params.onLoad)
1063
- this.on(EventType.Load, params.onLoad);
1064
- if (params.onLoadError)
1065
- this.on(EventType.LoadError, params.onLoadError);
1066
- if (params.onPlay)
1067
- this.on(EventType.Play, params.onPlay);
1068
- if (params.onPause)
1069
- this.on(EventType.Pause, params.onPause);
1070
- if (params.onStop)
1071
- this.on(EventType.Stop, params.onStop);
1072
- if (params.onLoop)
1073
- this.on(EventType.Loop, params.onLoop);
1074
- if (params.onStateChange)
1075
- this.on(EventType.StateChange, params.onStateChange);
1076
- /**
1077
- * @deprecated Use camelCase'd versions instead.
1078
- */
1079
- if (params.onload && !params.onLoad)
1080
- this.on(EventType.Load, params.onload);
1081
- if (params.onloaderror && !params.onLoadError)
1082
- this.on(EventType.LoadError, params.onloaderror);
1083
- if (params.onplay && !params.onPlay)
1084
- this.on(EventType.Play, params.onplay);
1085
- if (params.onpause && !params.onPause)
1086
- this.on(EventType.Pause, params.onpause);
1087
- if (params.onstop && !params.onStop)
1088
- this.on(EventType.Stop, params.onstop);
1089
- if (params.onloop && !params.onLoop)
1090
- this.on(EventType.Loop, params.onloop);
1091
- if (params.onstatechange && !params.onStateChange)
1092
- this.on(EventType.StateChange, params.onstatechange);
1093
- // Hook up the task queue
1094
- this.taskQueue = new TaskQueueManager(this.eventManager);
1095
- this.init({
1096
- src: this.src,
1097
- buffer: this.buffer,
1098
- autoplay: params.autoplay,
1099
- animations: params.animations,
1100
- stateMachines: params.stateMachines,
1101
- artboard: params.artboard
1102
- });
1103
- }
1104
- // Alternative constructor to build a Rive instance from an interface/object
1105
- Rive.new = function (params) {
1106
- console.warn('This function is deprecated: please use `new Rive({})` instead');
1107
- return new Rive(params);
1108
- };
1109
- // Initializes the Rive object either from constructor or load()
1110
- Rive.prototype.init = function (_a) {
1111
- var _this = this;
1112
- var src = _a.src, buffer = _a.buffer, animations = _a.animations, stateMachines = _a.stateMachines, artboard = _a.artboard, _b = _a.autoplay, autoplay = _b === void 0 ? false : _b;
1113
- this.src = src;
1114
- this.buffer = buffer;
1115
- // If no source file url specified, it's a bust
1116
- if (!this.src && !this.buffer) {
1117
- throw new Error(Rive.missingErrorMessage);
1118
- }
1119
- // List of animations that should be initialized.
1120
- var startingAnimationNames = mapToStringArray(animations);
1121
- // List of state machines that should be initialized
1122
- var startingStateMachineNames = mapToStringArray(stateMachines);
1123
- // Ensure loaded is marked as false if loading new file
1124
- this.loaded = false;
1125
- this.readyForPlaying = false;
1126
- // Ensure the runtime is loaded
1127
- RuntimeLoader.awaitInstance().then(function (runtime) {
1128
- _this.runtime = runtime;
1129
- // Get the canvas where you want to render the animation and create a renderer
1130
- _this.renderer = _this.runtime.makeRenderer(_this.canvas);
1131
- // Load Rive data from a source uri or a data buffer
1132
- _this.initData(artboard, startingAnimationNames, startingStateMachineNames, autoplay).catch(function (e) {
1133
- console.error(e);
1134
- });
1135
- }).catch(function (e) {
1136
- console.error(e);
1137
- });
1138
- };
1139
- // Initializes runtime with Rive data and preps for playing
1140
- Rive.prototype.initData = function (artboardName, animationNames, stateMachineNames, autoplay) {
1141
- var _a;
1142
- return __awaiter(this, void 0, void 0, function () {
1143
- var _b, _c, msg;
1144
- return __generator(this, function (_d) {
1145
- switch (_d.label) {
1146
- case 0:
1147
- if (!this.src) return [3 /*break*/, 2];
1148
- _b = this;
1149
- return [4 /*yield*/, loadRiveFile(this.src)];
1150
- case 1:
1151
- _b.buffer = _d.sent();
1152
- _d.label = 2;
1153
- case 2:
1154
- // Load the Rive file
1155
- _c = this;
1156
- return [4 /*yield*/, this.runtime.load(new Uint8Array(this.buffer))];
1157
- case 3:
1158
- // Load the Rive file
1159
- _c.file = _d.sent();
1160
- if (this.file) {
1161
- // Initialize and draw frame
1162
- this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay);
1163
- // Everything's set up, emit a load event
1164
- this.loaded = true;
1165
- this.eventManager.fire({
1166
- type: EventType.Load,
1167
- data: (_a = this.src) !== null && _a !== void 0 ? _a : 'buffer'
1168
- });
1169
- // Flag ready for playback commands and clear the task queue; this order
1170
- // is important or it may infinitely recurse
1171
- this.readyForPlaying = true;
1172
- this.taskQueue.process();
1173
- this.drawFrame();
1174
- return [2 /*return*/, Promise.resolve()];
1175
- }
1176
- else {
1177
- msg = 'Problem loading file; may be corrupt!';
1178
- console.warn(msg);
1179
- this.eventManager.fire({ type: EventType.LoadError, data: msg });
1180
- return [2 /*return*/, Promise.reject(msg)];
1181
- }
1182
- return [2 /*return*/];
1183
- }
1184
- });
1185
- });
1186
- };
1187
- // Initialize for playback
1188
- Rive.prototype.initArtboard = function (artboardName, animationNames, stateMachineNames, autoplay) {
1189
- // Fetch the artboard
1190
- var rootArtboard = artboardName ?
1191
- this.file.artboardByName(artboardName) :
1192
- this.file.defaultArtboard();
1193
- // Check we have a working artboard
1194
- if (!rootArtboard) {
1195
- var msg = 'Invalid artboard name or no default artboard';
1196
- console.warn(msg);
1197
- this.eventManager.fire({ type: EventType.LoadError, data: msg });
1198
- return;
1199
- }
1200
- // Instance the artboard
1201
- this.artboard = rootArtboard.instance();
1202
- // Check that the artboard has at least 1 animation
1203
- if (this.artboard.animationCount() < 1) {
1204
- var msg = 'Artboard has no animations';
1205
- this.eventManager.fire({ type: EventType.LoadError, data: msg });
1206
- throw msg;
1207
- }
1208
- // Initialize the animator
1209
- this.animator = new Animator(this.runtime, this.artboard, this.eventManager);
1210
- // Initialize the animations; as loaded hasn't happened yet, we need to
1211
- // suppress firing the play/pause events until the load event has fired. To
1212
- // do this we tell the animator to suppress firing events, and add event
1213
- // firing to the task queue.
1214
- var instanceNames;
1215
- if (animationNames.length > 0 || stateMachineNames.length > 0) {
1216
- instanceNames = animationNames.concat(stateMachineNames);
1217
- this.animator.add(instanceNames, autoplay, false);
1218
- }
1219
- else {
1220
- instanceNames = [this.animator.atLeastOne(autoplay, false)];
1221
- }
1222
- // Queue up firing the playback events
1223
- this.taskQueue.add({
1224
- action: function () { },
1225
- event: {
1226
- type: autoplay ? EventType.Play : EventType.Pause,
1227
- data: instanceNames,
1228
- }
1229
- });
1230
- };
1231
- // Draws the current artboard frame
1232
- Rive.prototype.drawFrame = function () {
1233
- this.startRendering();
1234
- };
1235
- /**
1236
- * Draw rendering loop; renders animation frames at the correct time interval.
1237
- * @param time the time at which to render a frame
1238
- */
1239
- Rive.prototype.draw = function (time, onSecond) {
1240
- // Clear the frameRequestId, as we're now rendering a fresh frame
1241
- this.frameRequestId = null;
1242
- // On the first pass, make sure lastTime has a valid value
1243
- if (!this.lastRenderTime) {
1244
- this.lastRenderTime = time;
1245
- }
1246
- // Handle the onSecond callback
1247
- this.renderSecondTimer += (time - this.lastRenderTime);
1248
- if (this.renderSecondTimer > 5000) {
1249
- this.renderSecondTimer = 0;
1250
- onSecond === null || onSecond === void 0 ? void 0 : onSecond();
1251
- }
1252
- // Calculate the elapsed time between frames in seconds
1253
- var elapsedTime = (time - this.lastRenderTime) / 1000;
1254
- this.lastRenderTime = time;
1255
- // Advance non-paused animations by the elapsed number of seconds
1256
- // Also advance any animations that require scrubbing
1257
- var activeAnimations = this.animator.animations.filter(function (a) { return a.playing || a.needsScrub; })
1258
- // The scrubbed animations must be applied first to prevent weird artifacts
1259
- // if the playing animations conflict with the scrubbed animating attribuates.
1260
- .sort(function (first, second) { return first.needsScrub ? -1 : 1; });
1261
- for (var _i = 0, activeAnimations_1 = activeAnimations; _i < activeAnimations_1.length; _i++) {
1262
- var animation = activeAnimations_1[_i];
1263
- animation.advance(elapsedTime);
1264
- if (animation.instance.didLoop) {
1265
- animation.loopCount += 1;
1266
- }
1267
- animation.instance.apply(this.artboard, 1.0);
1268
- }
1269
- // Advance non-paused state machines by the elapsed number of seconds
1270
- var activeStateMachines = this.animator.stateMachines.filter(function (a) { return a.playing; });
1271
- for (var _a = 0, activeStateMachines_1 = activeStateMachines; _a < activeStateMachines_1.length; _a++) {
1272
- var stateMachine = activeStateMachines_1[_a];
1273
- stateMachine.instance.advance(this.artboard, elapsedTime);
1274
- // stateMachine.instance.apply(this.artboard);
1275
- }
1276
- // Once the animations have been applied to the artboard, advance it
1277
- // by the elapsed time.
1278
- this.artboard.advance(elapsedTime);
1279
- var renderer = this.renderer;
1280
- renderer.save();
1281
- // Update the renderer alignment if necessary
1282
- this.alignRenderer();
1283
- this.artboard.draw(renderer);
1284
- renderer.restore();
1285
- renderer.flush();
1286
- // Check for any animations that looped
1287
- this.animator.handleLooping();
1288
- // Check for any state machines that had a state change
1289
- this.animator.handleStateChanges();
1290
- // Calling requestAnimationFrame will rerun draw() at the correct rate:
1291
- // https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations
1292
- if (this.animator.isPlaying) {
1293
- // Request a new rendering frame
1294
- this.startRendering();
1295
- }
1296
- else if (this.animator.isPaused) {
1297
- // Reset the end time so on playback it starts at the correct frame
1298
- this.lastRenderTime = 0;
1299
- }
1300
- else if (this.animator.isStopped) {
1301
- // Reset animation instances, artboard and time
1302
- // TODO: implement this properly when we have instancing
1303
- // this.initArtboard();
1304
- // this.drawFrame();
1305
- this.lastRenderTime = 0;
1306
- }
1307
- };
1308
- /**
1309
- * Align the renderer
1310
- */
1311
- Rive.prototype.alignRenderer = function () {
1312
- var _a = this, renderer = _a.renderer, runtime = _a.runtime, _layout = _a._layout, artboard = _a.artboard;
1313
- // Canvas must be wiped to prevent artifacts
1314
- renderer.clear();
1315
- // Now save so that future changes to align can restore
1316
- renderer.save();
1317
- // Align things up safe in the knowledge we can restore if changed
1318
- renderer.align(_layout.runtimeFit(runtime), _layout.runtimeAlignment(runtime), {
1319
- minX: _layout.minX,
1320
- minY: _layout.minY,
1321
- maxX: _layout.maxX,
1322
- maxY: _layout.maxY
1323
- }, artboard.bounds);
1324
- };
1325
- /**
1326
- * Cleans up any Wasm-generated objects that need to be manually destroyed:
1327
- * artboard instances, animation instances, state machine instances.
1328
- *
1329
- * Once this is called, things will need to be reinitialized or bad things
1330
- * might happen.
1331
- */
1332
- Rive.prototype.cleanup = function () {
1333
- this.artboard.delete();
1334
- // TODO: delete animation and state machine instances
1335
- };
1336
- // Plays specified animations; if none specified, it unpauses everything.
1337
- Rive.prototype.play = function (animationNames, autoplay) {
1338
- var _this = this;
1339
- animationNames = mapToStringArray(animationNames);
1340
- // If the file's not loaded, queue up the play
1341
- if (!this.readyForPlaying) {
1342
- this.taskQueue.add({
1343
- action: function () { return _this.play(animationNames, autoplay); },
1344
- });
1345
- return;
1346
- }
1347
- this.animator.play(animationNames);
1348
- this.startRendering();
1349
- };
1350
- // Pauses specified animations; if none specified, pauses all.
1351
- Rive.prototype.pause = function (animationNames) {
1352
- var _this = this;
1353
- animationNames = mapToStringArray(animationNames);
1354
- // If the file's not loaded, early out, nothing to pause
1355
- if (!this.readyForPlaying) {
1356
- this.taskQueue.add({
1357
- action: function () { return _this.pause(animationNames); },
1358
- });
1359
- return;
1360
- }
1361
- this.animator.pause(animationNames);
1362
- };
1363
- Rive.prototype.scrub = function (animationNames, value) {
1364
- var _this = this;
1365
- animationNames = mapToStringArray(animationNames);
1366
- // If the file's not loaded, early out, nothing to pause
1367
- if (!this.readyForPlaying) {
1368
- this.taskQueue.add({
1369
- action: function () { return _this.scrub(animationNames, value); },
1370
- });
1371
- return;
1372
- }
1373
- // Scrub the animation time; we draw a single frame here so that if
1374
- // nothing's currently playing, the scrubbed animation is still rendered/
1375
- this.animator.scrub(animationNames, value || 0);
1376
- this.drawFrame();
1377
- };
1378
- // Stops specified animations; if none specifies, stops them all.
1379
- Rive.prototype.stop = function (animationNames) {
1380
- var _this = this;
1381
- animationNames = mapToStringArray(animationNames);
1382
- // If the file's not loaded, early out, nothing to pause
1383
- if (!this.readyForPlaying) {
1384
- this.taskQueue.add({
1385
- action: function () { return _this.stop(animationNames); },
1386
- });
1387
- return;
1388
- }
1389
- this.animator.stop(animationNames);
1390
- };
1391
- /**
1392
- * Resets the animation
1393
- * @param artboard the name of the artboard, or default if none given
1394
- * @param animations the names of animations for playback
1395
- * @param stateMachines the names of state machines for playback
1396
- * @param autoplay whether to autoplay when reset, defaults to false
1397
- *
1398
- */
1399
- Rive.prototype.reset = function (params) {
1400
- var _a;
1401
- // Get the current artboard, animations, state machines, and playback states
1402
- var artBoardName = params === null || params === void 0 ? void 0 : params.artboard;
1403
- var animationNames = mapToStringArray(params === null || params === void 0 ? void 0 : params.animations);
1404
- var stateMachineNames = mapToStringArray(params === null || params === void 0 ? void 0 : params.stateMachines);
1405
- var autoplay = (_a = params === null || params === void 0 ? void 0 : params.autoplay) !== null && _a !== void 0 ? _a : false;
1406
- // Stop everything and clean up
1407
- this.stop();
1408
- this.cleanup();
1409
- // Reinitialize an artboard instance with the state
1410
- this.initArtboard(artBoardName, animationNames, stateMachineNames, autoplay);
1411
- };
1412
- // Loads a new Rive file, keeping listeners in place
1413
- Rive.prototype.load = function (params) {
1414
- // Stop all animations
1415
- this.stop();
1416
- // Reinitialize
1417
- this.init(params);
1418
- };
1419
- Object.defineProperty(Rive.prototype, "layout", {
1420
- /**
1421
- * Returns the current layout. Note that layout should be treated as
1422
- * immutable. If you want to change the layout, create a new one use the
1423
- * layout setter
1424
- */
1425
- get: function () {
1426
- return this._layout;
1427
- },
1428
- // Sets a new layout
1429
- set: function (layout) {
1430
- this._layout = layout;
1431
- // If the maxX or maxY are 0, then set them to the canvas width and height
1432
- if (!layout.maxX || !layout.maxY) {
1433
- this.resizeToCanvas();
1434
- }
1435
- if (this.loaded && !this.animator.isPlaying) {
1436
- this.drawFrame();
1437
- }
1438
- },
1439
- enumerable: false,
1440
- configurable: true
1441
- });
1442
- /**
1443
- * Sets the layout bounds to the current canvas size; this is typically called
1444
- * when the canvas is resized
1445
- */
1446
- Rive.prototype.resizeToCanvas = function () {
1447
- this._layout = this.layout.copyWith({
1448
- minX: 0,
1449
- minY: 0,
1450
- maxX: this.canvas.width,
1451
- maxY: this.canvas.height
1452
- });
1453
- };
1454
- Object.defineProperty(Rive.prototype, "source", {
1455
- // Returns the animation source, which may be undefined
1456
- get: function () {
1457
- return this.src;
1458
- },
1459
- enumerable: false,
1460
- configurable: true
1461
- });
1462
- Object.defineProperty(Rive.prototype, "activeArtboard", {
1463
- /**
1464
- * Returns the name of the active artboard
1465
- */
1466
- get: function () {
1467
- return this.artboard.name;
1468
- },
1469
- enumerable: false,
1470
- configurable: true
1471
- });
1472
- Object.defineProperty(Rive.prototype, "animationNames", {
1473
- // Returns a list of animation names on the chosen artboard
1474
- get: function () {
1475
- // If the file's not loaded, we got nothing to return
1476
- if (!this.loaded) {
1477
- return [];
1478
- }
1479
- var animationNames = [];
1480
- for (var i = 0; i < this.artboard.animationCount(); i++) {
1481
- animationNames.push(this.artboard.animationByIndex(i).name);
1482
- }
1483
- return animationNames;
1484
- },
1485
- enumerable: false,
1486
- configurable: true
1487
- });
1488
- Object.defineProperty(Rive.prototype, "stateMachineNames", {
1489
- /**
1490
- * Returns a list of state machine names from the current artboard
1491
- */
1492
- get: function () {
1493
- // If the file's not loaded, we got nothing to return
1494
- if (!this.loaded) {
1495
- return [];
1496
- }
1497
- var stateMachineNames = [];
1498
- for (var i = 0; i < this.artboard.stateMachineCount(); i++) {
1499
- stateMachineNames.push(this.artboard.stateMachineByIndex(i).name);
1500
- }
1501
- return stateMachineNames;
1502
- },
1503
- enumerable: false,
1504
- configurable: true
1505
- });
1506
- /**
1507
- * Returns the inputs for the specified instanced state machine, or an empty
1508
- * list if the name is invalid or the state machine is not instanced
1509
- * @param name the state machine name
1510
- * @returns the inputs for the named state machine
1511
- */
1512
- Rive.prototype.stateMachineInputs = function (name) {
1513
- // If the file's not loaded, early out, nothing to pause
1514
- if (!this.loaded) {
1515
- return;
1516
- }
1517
- var stateMachine = this.animator.stateMachines.find(function (m) { return m.name === name; });
1518
- return stateMachine === null || stateMachine === void 0 ? void 0 : stateMachine.inputs;
1519
- };
1520
- Object.defineProperty(Rive.prototype, "playingStateMachineNames", {
1521
- // Returns a list of playing machine names
1522
- get: function () {
1523
- // If the file's not loaded, we got nothing to return
1524
- if (!this.loaded) {
1525
- return [];
1526
- }
1527
- return this.animator.stateMachines
1528
- .filter(function (m) { return m.playing; })
1529
- .map(function (m) { return m.name; });
1530
- },
1531
- enumerable: false,
1532
- configurable: true
1533
- });
1534
- Object.defineProperty(Rive.prototype, "playingAnimationNames", {
1535
- // Returns a list of playing animation names
1536
- get: function () {
1537
- // If the file's not loaded, we got nothing to return
1538
- if (!this.loaded) {
1539
- return [];
1540
- }
1541
- return this.animator.animations
1542
- .filter(function (a) { return a.playing; })
1543
- .map(function (a) { return a.name; });
1544
- },
1545
- enumerable: false,
1546
- configurable: true
1547
- });
1548
- Object.defineProperty(Rive.prototype, "pausedAnimationNames", {
1549
- // Returns a list of paused animation names
1550
- get: function () {
1551
- // If the file's not loaded, we got nothing to return
1552
- if (!this.loaded) {
1553
- return [];
1554
- }
1555
- return this.animator.animations
1556
- .filter(function (a) { return !a.playing; })
1557
- .map(function (a) { return a.name; });
1558
- },
1559
- enumerable: false,
1560
- configurable: true
1561
- });
1562
- Object.defineProperty(Rive.prototype, "pausedStateMachineNames", {
1563
- /**
1564
- * Returns a list of paused machine names
1565
- * @returns a list of state machine names that are paused
1566
- */
1567
- get: function () {
1568
- // If the file's not loaded, we got nothing to return
1569
- if (!this.loaded) {
1570
- return [];
1571
- }
1572
- return this.animator.stateMachines
1573
- .filter(function (m) { return !m.playing; })
1574
- .map(function (m) { return m.name; });
1575
- },
1576
- enumerable: false,
1577
- configurable: true
1578
- });
1579
- Object.defineProperty(Rive.prototype, "isPlaying", {
1580
- /**
1581
- * @returns true if any animation is playing
1582
- */
1583
- get: function () {
1584
- return this.animator.isPlaying;
1585
- },
1586
- enumerable: false,
1587
- configurable: true
1588
- });
1589
- Object.defineProperty(Rive.prototype, "isPaused", {
1590
- /**
1591
- * @returns true if all instanced animations are paused
1592
- */
1593
- get: function () {
1594
- return this.animator.isPaused;
1595
- },
1596
- enumerable: false,
1597
- configurable: true
1598
- });
1599
- Object.defineProperty(Rive.prototype, "isStopped", {
1600
- /**
1601
- * @returns true if no animations are playing or paused
1602
- */
1603
- get: function () {
1604
- return this.animator.isStopped;
1605
- },
1606
- enumerable: false,
1607
- configurable: true
1608
- });
1609
- Object.defineProperty(Rive.prototype, "bounds", {
1610
- /**
1611
- * @returns the bounds of the current artboard, or undefined if the artboard
1612
- * isn't loaded yet.
1613
- */
1614
- get: function () {
1615
- return this.artboard ? this.artboard.bounds : undefined;
1616
- },
1617
- enumerable: false,
1618
- configurable: true
1619
- });
1620
- /**
1621
- * Subscribe to Rive-generated events
1622
- * @param type the type of event to subscribe to
1623
- * @param callback callback to fire when the event occurs
1624
- */
1625
- Rive.prototype.on = function (type, callback) {
1626
- this.eventManager.add({
1627
- type: type,
1628
- callback: callback,
1629
- });
1630
- };
1631
- /**
1632
- * Unsubscribes from a Rive-generated event
1633
- * @param callback the callback to unsubscribe from
1634
- */
1635
- Rive.prototype.unsubscribe = function (type, callback) {
1636
- this.eventManager.remove({
1637
- type: type,
1638
- callback: callback,
1639
- });
1640
- };
1641
- /**
1642
- * Unsubscribes all listeners from an event type, or everything if no type is
1643
- * given
1644
- * @param type the type of event to unsubscribe from, or all types if
1645
- * undefined
1646
- */
1647
- Rive.prototype.unsubscribeAll = function (type) {
1648
- this.eventManager.removeAll(type);
1649
- };
1650
- /**
1651
- * Stops the rendering loop; this is different from pausing in that it doesn't
1652
- * change the state of any animation. It stops rendering from occurring. This
1653
- * is designed for situations such as when Rive isn't visible.
1654
- *
1655
- * The only way to start rendering again is to call `startRendering`.
1656
- * Animations that are marked as playing will start from the position that
1657
- * they would have been at if rendering had not been stopped.
1658
- */
1659
- Rive.prototype.stopRendering = function () {
1660
- if (this.loaded && this.frameRequestId) {
1661
- cancelAnimationFrame(this.frameRequestId);
1662
- this.frameRequestId = null;
1663
- }
1664
- };
1665
- /**
1666
- * Starts the rendering loop if it has been previously stopped. If the
1667
- * renderer is already active, then this will have zero effect.
1668
- */
1669
- Rive.prototype.startRendering = function () {
1670
- if (this.loaded && !this.frameRequestId) {
1671
- this.frameRequestId = requestAnimationFrame(this.draw.bind(this));
1672
- }
1673
- };
1674
- Object.defineProperty(Rive.prototype, "contents", {
1675
- /**
1676
- * Returns the contents of a Rive file: the artboards, animations, and state machines
1677
- */
1678
- get: function () {
1679
- if (!this.loaded) {
1680
- return undefined;
1681
- }
1682
- var riveContents = {
1683
- artboards: [],
1684
- };
1685
- for (var i = 0; i < this.file.artboardCount(); i++) {
1686
- var artboard = this.file.artboardByIndex(i);
1687
- var artboardContents = {
1688
- name: artboard.name,
1689
- animations: [],
1690
- stateMachines: [],
1691
- };
1692
- for (var j = 0; j < artboard.animationCount(); j++) {
1693
- var animation = artboard.animationByIndex(j);
1694
- artboardContents.animations.push(animation.name);
1695
- }
1696
- for (var k = 0; k < artboard.stateMachineCount(); k++) {
1697
- var stateMachine = artboard.stateMachineByIndex(k);
1698
- var name_1 = stateMachine.name;
1699
- var instance = new this.runtime.StateMachineInstance(stateMachine);
1700
- var inputContents = [];
1701
- for (var l = 0; l < instance.inputCount(); l++) {
1702
- var input = instance.input(l);
1703
- inputContents.push({ name: input.name, type: input.type });
1704
- }
1705
- artboardContents.stateMachines.push({ name: name_1, inputs: inputContents });
1706
- }
1707
- riveContents.artboards.push(artboardContents);
1708
- }
1709
- return riveContents;
1710
- },
1711
- enumerable: false,
1712
- configurable: true
1713
- });
1714
- // Error message for missing source or buffer
1715
- Rive.missingErrorMessage = 'Rive source file or data buffer required';
1716
- return Rive;
1717
- }());
1718
-
1719
- // Loads Rive data from a URI via fetch.
1720
- var loadRiveFile = function (src) { return __awaiter(void 0, void 0, void 0, function () {
1721
- var req, res, buffer;
1722
- return __generator(this, function (_a) {
1723
- switch (_a.label) {
1724
- case 0:
1725
- req = new Request(src);
1726
- return [4 /*yield*/, fetch(req)];
1727
- case 1:
1728
- res = _a.sent();
1729
- return [4 /*yield*/, res.arrayBuffer()];
1730
- case 2:
1731
- buffer = _a.sent();
1732
- return [2 /*return*/, buffer];
1733
- }
1734
- });
1735
- }); };
1736
- // #endregion
1737
- // #region utility functions
1738
- /*
1739
- * Utility function to ensure an object is a string array
1740
- */
1741
- var mapToStringArray = function (obj) {
1742
- if (typeof obj === 'string') {
1743
- return [obj];
1744
- }
1745
- else if (obj instanceof Array) {
1746
- return obj;
1747
- }
1748
- // If obj is undefined, return empty array
1749
- return [];
1750
- };
1751
- // #endregion
1752
- // #region testing utilities
1753
- // Exports to only be used for tests
1754
- var Testing = {
1755
- EventManager: EventManager,
1756
- TaskQueueManager: TaskQueueManager,
1757
- };
1758
- // #endregion
1759
-
1760
- })();
1761
-
1762
- /******/ return __webpack_exports__;
1763
- /******/ })()
1764
- ;
1765
- });
1766
- //# sourceMappingURL=rive.js.map