@lottiefiles/dotlottie-web 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -19
- package/dist/chunk-4GVX2PO3.js +10 -0
- package/dist/chunk-4GVX2PO3.js.map +1 -0
- package/dist/{chunk-6PRCY2FC.js → chunk-SMXCTWPA.js} +3 -3
- package/dist/chunk-SMXCTWPA.js.map +1 -0
- package/dist/dotlottie.d.ts +44 -3
- package/dist/dotlottie.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/renderer.wasm +0 -0
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -5
- package/dist/chunk-6PRCY2FC.js.map +0 -1
- package/dist/chunk-LVR6J6SH.js +0 -11
- package/dist/chunk-LVR6J6SH.js.map +0 -1
package/README.md
CHANGED
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
* [Usage](#usage)
|
|
20
20
|
* [Via npm](#via-npm)
|
|
21
21
|
* [Via CDN](#via-cdn)
|
|
22
|
+
* [Responsive Canvas](#responsive-canvas)
|
|
22
23
|
* [Live Example](#live-example)
|
|
23
24
|
* [APIs](#apis)
|
|
24
|
-
* [
|
|
25
|
+
* [Config](#config)
|
|
25
26
|
* [Properties](#properties)
|
|
26
27
|
* [Methods](#methods)
|
|
27
28
|
* [Static Methods](#static-methods)
|
|
@@ -101,37 +102,56 @@ const dotLottie = new DotLottie({
|
|
|
101
102
|
</html>
|
|
102
103
|
```
|
|
103
104
|
|
|
105
|
+
### Responsive Canvas
|
|
106
|
+
|
|
107
|
+
`DotLottie` offers an automatic canvas resizing behavior to ensure optimal animation quality, especially when the canvas size changes dynamically, such as during browser window resizing or layout adjustments. This behavior is particularly useful when the canvas does not have fixed width and height attributes set, as it maintains the quality of the animation by adjusting the canvas's internal drawing buffer to match its display size.
|
|
108
|
+
|
|
109
|
+
For this behavior to work correctly, the canvas element must be styled using CSS to take up 100% of the width of its parent container. Additionally, you can use the `aspect-ratio` property to maintain a specific aspect ratio for the canvas. Adjust this property as needed for your design requirements. For example:
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<canvas id="canvas" style="width: 100%; aspect-ratio: 1"></canvas>
|
|
113
|
+
```
|
|
114
|
+
|
|
104
115
|
## Live Example
|
|
105
116
|
|
|
106
117
|
[](https://codesandbox.io/s/lottiefiles-dotlottie-web-basic-example-tcy3rv?autoresize=1\&fontsize=14\&hidenavigation=1\&theme=dark)
|
|
107
118
|
|
|
108
119
|
## APIs
|
|
109
120
|
|
|
110
|
-
###
|
|
121
|
+
### Config
|
|
111
122
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
123
|
+
The `DotLottie` constructor accepts a config object with the following properties:
|
|
124
|
+
|
|
125
|
+
| Property name | Type | Required | Default | Description |
|
|
126
|
+
| ----------------- | --------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------- |
|
|
127
|
+
| `autoplay` | boolean | | false | Auto-starts the animation on load. |
|
|
128
|
+
| `loop` | boolean | | false | Determines if the animation should loop. |
|
|
129
|
+
| `canvas` | HTMLCanvasElement | ✔️ | undefined | Canvas element for animation rendering. |
|
|
130
|
+
| `src` | string | | undefined | URL to the animation data (`.json` or `.lottie`). |
|
|
131
|
+
| `speed` | number | | 1 | Animation playback speed. 1 is regular speed. |
|
|
132
|
+
| `data` | string \| ArrayBuffer | | undefined | Animation data provided either as a Lottie JSON string or as an ArrayBuffer for .lottie animations. |
|
|
133
|
+
| `mode` | string | | "normal" | Animation play mode. Accepts "normal", "reverse", "bounce", "bounce-reverse". |
|
|
134
|
+
| `backgroundColor` | string | | undefined | Background color of the canvas. e.g., "#000000", "rgba(0, 0, 0, 0.5)" or "transparent". |
|
|
120
135
|
|
|
121
136
|
### Properties
|
|
122
137
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
138
|
+
`DotLottie` instances expose the following properties:
|
|
139
|
+
|
|
140
|
+
| Property | Type | Description |
|
|
141
|
+
| -------------- | ------- | ------------------------------------------------------------------------------------------- |
|
|
142
|
+
| `currentFrame` | number | Represents the animation's currently displayed frame number. |
|
|
143
|
+
| `duration` | number | Specifies the animation's total playback time in milliseconds. |
|
|
144
|
+
| `totalFrames` | number | Denotes the total count of individual frames within the animation. |
|
|
145
|
+
| `loop` | boolean | Indicates if the animation is set to play in a continuous loop. |
|
|
146
|
+
| `speed` | number | Represents the playback speed factor; e.g., 2 would mean double speed. |
|
|
147
|
+
| `loopCount` | number | Tracks how many times the animation has completed its loop. |
|
|
148
|
+
| `playing` | boolean | Reflects whether the animation is in active playback or not |
|
|
149
|
+
| `direction` | string | Reflects the current playback direction; e.g., 1 would mean forward, -1 would mean reverse. |
|
|
132
150
|
|
|
133
151
|
### Methods
|
|
134
152
|
|
|
153
|
+
`DotLottie` instances expose the following methods that can be used to control the animation:
|
|
154
|
+
|
|
135
155
|
| Method | Description |
|
|
136
156
|
| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
137
157
|
| `play()` | Begins playback from the current animation position. |
|
|
@@ -143,15 +163,20 @@ const dotLottie = new DotLottie({
|
|
|
143
163
|
| `addEventListener(event: string, listener: Function)` | Registers a function to respond to a specific animation event. |
|
|
144
164
|
| `removeEventListener(event: string, listener?: Function)` | Removes a previously registered function from responding to a specific animation event. |
|
|
145
165
|
| `destroy()` | Destroys the renderer instance and unregisters all event listeners. This method should be called when the canvas is removed from the DOM to prevent memory leaks. |
|
|
166
|
+
| `load(config: Config)` | Loads a new configuration or a new animation. |
|
|
146
167
|
|
|
147
168
|
### Static Methods
|
|
148
169
|
|
|
170
|
+
The `DotLottie` class exposes the following static methods:
|
|
171
|
+
|
|
149
172
|
| Method | Description |
|
|
150
173
|
| ------------------------- | ----------------------------------------- |
|
|
151
174
|
| `setWasmUrl(url: string)` | Sets the URL to the renderer.wasm binary. |
|
|
152
175
|
|
|
153
176
|
### Events
|
|
154
177
|
|
|
178
|
+
The `DotLottie` instance emits the following events that can be listened to via the `addEventListener` method:
|
|
179
|
+
|
|
155
180
|
| Event | Description |
|
|
156
181
|
| ----------- | ---------------------------------------------------- |
|
|
157
182
|
| `load` | Emitted when the animation is loaded. |
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { a as a$1 } from './chunk-2ELNS7EO.js';
|
|
2
|
+
import { c, b, a as a$2 } from './chunk-SMXCTWPA.js';
|
|
3
|
+
import { a } from './chunk-7Q3PPTBP.js';
|
|
4
|
+
|
|
5
|
+
var oe={name:"@lottiefiles/dotlottie-web",version:"0.7.0",type:"module",description:"Lottie and DotLottie player for the web",repository:{type:"git",url:"git+https://github.com/LottieFiles/dotlottie-web.git",directory:"packages/web"},homepage:"https://github.com/LottieFiles/dotlottie-web#readme",bugs:"https://github.com/LottieFiles/dotlottie-web/issues",author:"LottieFiles",contributors:["Abdelrahman Ashraf <a.theashraf@gmail.com>"],license:"MIT",engines:{node:">=18"},main:"dist/index.js",module:"dist/index.js",types:"dist/index.d.ts",files:["dist"],keywords:["dotlottie","lottie","player","animation","web","canvas","javascript"],scripts:{build:"tsup","build:wasm":"./build_wasm.sh","build:wasm:docker":"./docker_build_wasm.sh",dev:"tsup --watch",lint:"eslint --fix .","size:why":"size-limit --why --clean-dir --save-bundle ./tmp","stats:eslint":"cross-env TIMING=1 eslint .","stats:ts":"tsc -p tsconfig.build.json --extendedDiagnostics","type-check":"tsc --noEmit"},dependencies:{"@dotlottie/dotlottie-js":"^0.6.0"},devDependencies:{"cross-env":"7.0.3",tsup:"7.2.0",typescript:"5.0.4"},publishConfig:{access:"public"}};var Tn=(()=>{var ue=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(u={}){var a=u,y,E;a.ready=new Promise((e,r)=>{y=e,E=r;});var X=Object.assign({},a),Oe=!0,R="";function Tr(e){return a.locateFile?a.locateFile(e,R):R+e}(typeof document<"u"&&document.currentScript&&(R=document.currentScript.src),ue&&(R=ue),R.indexOf("blob:")!==0?R=R.substr(0,R.replace(/[?#].*/,"").lastIndexOf("/")+1):R="",(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t();},n.onerror=t,n.send(null);});var Fr=a.print||console.log.bind(console),z=a.printErr||console.error.bind(console);Object.assign(a,X),X=null,a.arguments&&(a.arguments),a.thisProgram&&(a.thisProgram),a.quit&&(a.quit);var K;a.wasmBinary&&(K=a.wasmBinary),typeof WebAssembly!="object"&&Z("no native wasm support detected");var de,Ie=!1;function Er(e,r){e||Z(r);}var Te,C,Q,fe,W,$,Ue,Le;function We(){var e=de.buffer;a.HEAP8=Te=new Int8Array(e),a.HEAP16=Q=new Int16Array(e),a.HEAPU8=C=new Uint8Array(e),a.HEAPU16=fe=new Uint16Array(e),a.HEAP32=W=new Int32Array(e),a.HEAPU32=$=new Uint32Array(e),a.HEAPF32=Ue=new Float32Array(e),a.HEAPF64=Le=new Float64Array(e);}var je=[],He=[],xe=[];function Mr(){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)Or(a.preRun.shift());Ae(je);}function Sr(){Ae(He);}function Dr(){if(a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;)Ur(a.postRun.shift());Ae(xe);}function Or(e){je.unshift(e);}function Ir(e){He.unshift(e);}function Ur(e){xe.unshift(e);}var j=0,Y=null;function Lr(e){j++,a.monitorRunDependencies&&a.monitorRunDependencies(j);}function Wr(e){if(j--,a.monitorRunDependencies&&a.monitorRunDependencies(j),j==0&&(Y)){var r=Y;Y=null,r();}}function Z(e){a.onAbort&&a.onAbort(e),e="Aborted("+e+")",z(e),Ie=!0,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw E(r),r}var jr="data:application/octet-stream;base64,",ze=e=>e.startsWith(jr),V;V="renderer.wasm",ze(V)||(V=Tr(V));function Ve(e){if(e==V&&K)return new Uint8Array(K);throw "both async and sync fetching of the wasm failed"}function Hr(e){return !K&&(Oe)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw "failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>Ve(e)):Promise.resolve().then(()=>Ve(e))}function Be(e,r,t){return Hr(e).then(n=>WebAssembly.instantiate(n,r)).then(n=>n).then(t,n=>{z(`failed to asynchronously prepare wasm: ${n}`),Z(n);})}function xr(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!ze(r)&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(i=>{var o=WebAssembly.instantiateStreaming(i,t);return o.then(n,function(l){return z(`wasm streaming compile failed: ${l}`),z("falling back to ArrayBuffer instantiation"),Be(r,t,n)})}):Be(r,t,n)}function zr(){var e={a:un};function r(n,i){return g=n.exports,de=g.I,We(),nr=g.O,Ir(g.J),Wr(),g}Lr();function t(n){r(n.instance);}if(a.instantiateWasm)try{return a.instantiateWasm(e,r)}catch(n){z(`Module.instantiateWasm callback failed with error: ${n}`),E(n);}return xr(K,V,e,t).catch(E),{}}var Ae=e=>{for(;e.length>0;)e.shift()(a);};a.noExitRuntime||!0;var qe=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ge=(e,r,t)=>{for(var n=r+t,i=r;e[i]&&!(i>=n);)++i;if(i-r>16&&e.buffer&&qe)return qe.decode(e.subarray(r,i));for(var o="";r<i;){var l=e[r++];if(!(l&128)){o+=String.fromCharCode(l);continue}var s=e[r++]&63;if((l&224)==192){o+=String.fromCharCode((l&31)<<6|s);continue}var c=e[r++]&63;if((l&240)==224?l=(l&15)<<12|s<<6|c:l=(l&7)<<18|s<<12|c<<6|e[r++]&63,l<65536)o+=String.fromCharCode(l);else {var d=l-65536;o+=String.fromCharCode(55296|d>>10,56320|d&1023);}}return o},ee=(e,r)=>e?Ge(C,e,r):"",Vr=(e,r,t,n)=>{Z(`Assertion failed: ${ee(e)}, at: `+[r?ee(r):"unknown filename",t,n?ee(n):"unknown function"]);};function Br(e,r,t){return 0}function qr(e,r,t){return 0}function Gr(e,r,t,n){}var Nr=(e,r,t,n,i)=>{},Jr=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Ne=e;},Ne,P=e=>{for(var r="",t=e;C[t];)r+=Ne[C[t++]];return r},q={},H={},he={},G,h=e=>{throw new G(e)},Je,ve=e=>{throw new Je(e)},re=(e,r,t)=>{e.forEach(function(s){he[s]=r;});function n(s){var c=t(s);c.length!==e.length&&ve("Mismatched type converter count");for(var d=0;d<e.length;++d)k(e[d],c[d]);}var i=new Array(r.length),o=[],l=0;r.forEach((s,c)=>{H.hasOwnProperty(s)?i[c]=H[s]:(o.push(s),q.hasOwnProperty(s)||(q[s]=[]),q[s].push(()=>{i[c]=H[s],++l,l===o.length&&n(i);}));}),o.length===0&&n(i);};function Xr(e,r,t={}){var n=r.name;if(e||h(`type "${n}" must have a positive integer typeid pointer`),H.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;h(`Cannot register type '${n}' twice`);}if(H[e]=r,delete he[e],q.hasOwnProperty(e)){var i=q[e];delete q[e],i.forEach(o=>o());}}function k(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Xr(e,r,t)}var S=8,Kr=(e,r,t,n)=>{r=P(r),k(e,{name:r,fromWireType:function(i){return !!i},toWireType:function(i,o){return o?t:n},argPackAdvance:S,readValueFromPointer:function(i){return this.fromWireType(C[i])},destructorFunction:null});},Qr=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Fe=e=>{function r(t){return t.$$.ptrType.registeredClass.name}h(r(e)+" instance already deleted");},Re=!1,Xe=e=>{},Yr=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr);},Ke=e=>{e.count.value-=1;var r=e.count.value===0;r&&Yr(e);},Qe=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=Qe(e,r,t.baseClass);return n===null?null:t.downcast(n)},Ye={},Zr=()=>Object.keys(ie).length,et=()=>{var e=[];for(var r in ie)ie.hasOwnProperty(r)&&e.push(ie[r]);return e},te=[],Ee=()=>{for(;te.length;){var e=te.pop();e.$$.deleteScheduled=!1,e.delete();}},ne,rt=e=>{ne=e,te.length&&ne&&ne(Ee);},tt=()=>{a.getInheritedInstanceCount=Zr,a.getLiveInheritedInstances=et,a.flushPendingDeletes=Ee,a.setDelayFunction=rt;},ie={},nt=(e,r)=>{for(r===void 0&&h("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},it=(e,r)=>(r=nt(e,r),ie[r]),pe=(e,r)=>{(!r.ptrType||!r.ptr)&&ve("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&ve("Both smartPtrType and smartPtr must be specified"),r.count={value:1},ae(Object.create(e,{$$:{value:r}}))};function at(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=it(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?pe(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):pe(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o=this.registeredClass.getActualType(r),l=Ye[o];if(!l)return i.call(this);var s;this.isConst?s=l.constPointerType:s=l.pointerType;var c=Qe(r,this.registeredClass,s.registeredClass);return c===null?i.call(this):this.isSmartPointer?pe(s.registeredClass.instancePrototype,{ptrType:s,ptr:c,smartPtrType:this,smartPtr:e}):pe(s.registeredClass.instancePrototype,{ptrType:s,ptr:c})}var ae=e=>typeof FinalizationRegistry>"u"?(ae=r=>r,e):(Re=new FinalizationRegistry(r=>{Ke(r.$$);}),ae=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t};Re.register(r,i,r);}return r},Xe=r=>Re.unregister(r),ae(e)),st=()=>{Object.assign(_e.prototype,{isAliasOf(e){if(!(this instanceof _e)||!(e instanceof _e))return !1;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,i=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)i=n.upcast(i),n=n.baseClass;return r===n&&t===i},clone(){if(this.$$.ptr||Fe(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=ae(Object.create(Object.getPrototypeOf(this),{$$:{value:Qr(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=!1,e},delete(){this.$$.ptr||Fe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&h("Object already scheduled for deletion"),Xe(this),Ke(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0);},isDeleted(){return !this.$$.ptr},deleteLater(){return this.$$.ptr||Fe(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&h("Object already scheduled for deletion"),te.push(this),te.length===1&&ne&&ne(Ee),this.$$.deleteScheduled=!0,this}});};function _e(){}var ot=48,lt=57,Ze=e=>{if(e===void 0)return "_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=ot&&r<=lt?`_${e}`:e};function er(e,r){return e=Ze(e),{[e]:function(){return r.apply(this,arguments)}}[e]}var rr=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(){return e[r].overloadTable.hasOwnProperty(arguments.length)||h(`Function '${t}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[arguments.length].apply(this,arguments)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n;}},ut=(e,r,t)=>{a.hasOwnProperty(e)?((t===void 0||a[e].overloadTable!==void 0&&a[e].overloadTable[t]!==void 0)&&h(`Cannot register public name '${e}' twice`),rr(a,e,e),a.hasOwnProperty(t)&&h(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),a[e].overloadTable[t]=r):(a[e]=r,t!==void 0&&(a[e].numArguments=t));};function ct(e,r,t,n,i,o,l,s){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=o,this.upcast=l,this.downcast=s,this.pureVirtualFunctions=[];}var ke=(e,r,t)=>{for(;r!==t;)r.upcast||h(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function dt(e,r){if(r===null)return this.isReference&&h(`null is not a valid ${this.name}`),0;r.$$||h(`Cannot pass "${Se(r)}" as a ${this.name}`),r.$$.ptr||h(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=ke(r.$$.ptr,t,this.registeredClass);return n}function ft(e,r){var t;if(r===null)return this.isReference&&h(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||h(`Cannot pass "${Se(r)}" as a ${this.name}`),r.$$.ptr||h(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&h(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=ke(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&h("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:h(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else {var i=r.clone();t=this.rawShare(t,ge.toHandle(()=>i.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:h("Unsupporting sharing policy");}return t}function ht(e,r){if(r===null)return this.isReference&&h(`null is not a valid ${this.name}`),0;r.$$||h(`Cannot pass "${Se(r)}" as a ${this.name}`),r.$$.ptr||h(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&h(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=ke(r.$$.ptr,t,this.registeredClass);return n}function tr(e){return this.fromWireType($[e>>2])}var vt=()=>{Object.assign(me.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor&&this.rawDestructor(e);},argPackAdvance:S,readValueFromPointer:tr,deleteObject(e){e!==null&&e.delete();},fromWireType:at});};function me(e,r,t,n,i,o,l,s,c,d,f){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=o,this.sharingPolicy=l,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=d,this.rawDestructor=f,!i&&r.baseClass===void 0?n?(this.toWireType=dt,this.destructorFunction=null):(this.toWireType=ht,this.destructorFunction=null):this.toWireType=ft;}var pt=(e,r,t)=>{a.hasOwnProperty(e)||ve("Replacing nonexistant public symbol"),a[e].overloadTable!==void 0&&t!==void 0?a[e].overloadTable[t]=r:(a[e]=r,a[e].argCount=t);},_t=(e,r,t)=>{var n=a["dynCall_"+e];return t&&t.length?n.apply(null,[r].concat(t)):n.call(null,r)},nr,D=e=>nr.get(e),mt=(e,r,t)=>{if(e.includes("j"))return _t(e,r,t);var n=D(r).apply(null,t);return n},gt=(e,r)=>{var t=[];return function(){return t.length=0,Object.assign(t,arguments),mt(e,r,t)}},N=(e,r)=>{e=P(e);function t(){return e.includes("j")?gt(e,r):D(r)}var n=t();return typeof n!="function"&&h(`unknown function pointer with signature ${e}: ${r}`),n},yt=(e,r)=>{var t=er(r,function(n){this.name=r,this.message=n;var i=new Error(n).stack;i!==void 0&&(this.stack=this.toString()+`
|
|
6
|
+
`+i.replace(/^Error(:[^\n]*)?\n/,""));});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},ir,ar=e=>{var r=fr(e),t=P(r);return M(r),t},Me=(e,r)=>{var t=[],n={};function i(o){if(!n[o]&&!H[o]){if(he[o]){he[o].forEach(i);return}t.push(o),n[o]=!0;}}throw r.forEach(i),new ir(`${e}: `+t.map(ar).join([", "]))},bt=(e,r,t,n,i,o,l,s,c,d,f,v,m)=>{f=P(f),o=N(i,o),s&&(s=N(l,s)),d&&(d=N(c,d)),m=N(v,m);var _=Ze(f);ut(_,function(){Me(`Cannot construct ${f} due to unbound types`,[n]);}),re([e,r,t],n?[n]:[],function(b){b=b[0];var F,w;n?(F=b.registeredClass,w=F.instancePrototype):w=_e.prototype;var J=er(_,function(){if(Object.getPrototypeOf(this)!==se)throw new G("Use 'new' to construct "+f);if(T.constructor_body===void 0)throw new G(f+" has no accessible constructor");var _r=T.constructor_body[arguments.length];if(_r===void 0)throw new G(`Tried to invoke ctor of ${f} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(T.constructor_body).toString()}) parameters instead!`);return _r.apply(this,arguments)}),se=Object.create(w,{constructor:{value:J}});J.prototype=se;var T=new ct(f,J,se,m,F,o,s,d);T.baseClass&&(T.baseClass.__derivedClasses===void 0&&(T.baseClass.__derivedClasses=[]),T.baseClass.__derivedClasses.push(T));var L=new me(f,T,!0,!1,!1),be=new me(f+"*",T,!1,!1,!1),pr=new me(f+" const*",T,!1,!0,!1);return Ye[e]={pointerType:be,constPointerType:pr},pt(_,J),[L,be,pr]});},sr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push($[r+n*4>>2]);return t},wt=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r);}};function or(e,r,t,n,i,o){var l=r.length;l<2&&h("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=r[1]!==null&&t!==null,c=!1,d=1;d<r.length;++d)if(r[d]!==null&&r[d].destructorFunction===void 0){c=!0;break}var f=r[0].name!=="void",v=l-2,m=new Array(v),_=[],b=[];return function(){arguments.length!==v&&h(`function ${e} called with ${arguments.length} arguments, expected ${v}`),b.length=0;var F;_.length=s?2:1,_[0]=i,s&&(F=r[1].toWireType(b,this),_[1]=F);for(var w=0;w<v;++w)m[w]=r[w+2].toWireType(b,arguments[w]),_.push(m[w]);var J=n.apply(null,_);function se(T){if(c)wt(b);else for(var L=s?1:2;L<r.length;L++){var be=L===1?F:m[L-2];r[L].destructorFunction!==null&&r[L].destructorFunction(be);}if(f)return r[0].fromWireType(T)}return se(J)}}var Ct=(e,r,t,n,i,o)=>{var l=sr(r,t);i=N(n,i),re([],[e],function(s){s=s[0];var c=`constructor ${s.name}`;if(s.registeredClass.constructor_body===void 0&&(s.registeredClass.constructor_body=[]),s.registeredClass.constructor_body[r-1]!==void 0)throw new G(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${s.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return s.registeredClass.constructor_body[r-1]=()=>{Me(`Cannot construct ${s.name} due to unbound types`,l);},re([],l,d=>(d.splice(1,0,null),s.registeredClass.constructor_body[r-1]=or(c,d,null,i,o),[])),[]});},$t=e=>{e=e.trim();let r=e.indexOf("(");return r!==-1?(Er(e[e.length-1]==")","Parentheses for argument names should match."),e.substr(0,r)):e},Tt=(e,r,t,n,i,o,l,s,c)=>{var d=sr(t,n);r=P(r),r=$t(r),o=N(i,o),re([],[e],function(f){f=f[0];var v=`${f.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),s&&f.registeredClass.pureVirtualFunctions.push(r);function m(){Me(`Cannot call ${v} due to unbound types`,d);}var _=f.registeredClass.instancePrototype,b=_[r];return b===void 0||b.overloadTable===void 0&&b.className!==f.name&&b.argCount===t-2?(m.argCount=t-2,m.className=f.name,_[r]=m):(rr(_,r,v),_[r].overloadTable[t-2]=m),re([],d,function(F){var w=or(v,F,f,o,l);return _[r].overloadTable===void 0?(w.argCount=t-2,_[r]=w):_[r].overloadTable[t-2]=w,[]}),[]});};function Pt(){Object.assign(lr.prototype,{get(e){return this.allocated[e]},has(e){return this.allocated[e]!==void 0},allocate(e){var r=this.freelist.pop()||this.allocated.length;return this.allocated[r]=e,r},free(e){this.allocated[e]=void 0,this.freelist.push(e);}});}function lr(){this.allocated=[void 0],this.freelist=[];}var A=new lr,ur=e=>{e>=A.reserved&&--A.get(e).refcount===0&&A.free(e);},At=()=>{for(var e=0,r=A.reserved;r<A.allocated.length;++r)A.allocated[r]!==void 0&&++e;return e},Ft=()=>{A.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),A.reserved=A.allocated.length,a.count_emval_handles=At;},ge={toValue:e=>(e||h("Cannot use deleted val. handle = "+e),A.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return A.allocate({refcount:1,value:e})}}};function cr(e){return this.fromWireType(W[e>>2])}var Rt=(e,r)=>{r=P(r),k(e,{name:r,fromWireType:t=>{var n=ge.toValue(t);return ur(t),n},toWireType:(t,n)=>ge.toHandle(n),argPackAdvance:S,readValueFromPointer:cr,destructorFunction:null});},Se=e=>{if(e===null)return "null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},Et=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(Ue[t>>2])};case 8:return function(t){return this.fromWireType(Le[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},kt=(e,r,t)=>{r=P(r),k(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>i,argPackAdvance:S,readValueFromPointer:Et(r,t),destructorFunction:null});},Mt=(e,r,t)=>{switch(r){case 1:return t?n=>Te[n>>0]:n=>C[n>>0];case 2:return t?n=>Q[n>>1]:n=>fe[n>>1];case 4:return t?n=>W[n>>2]:n=>$[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},St=(e,r,t,n,i)=>{r=P(r);var o=f=>f;if(n===0){var l=32-8*t;o=f=>f<<l>>>l;}var s=r.includes("unsigned"),c=(f,v)=>{},d;s?d=function(f,v){return c(v,this.name),v>>>0}:d=function(f,v){return c(v,this.name),v},k(e,{name:r,fromWireType:o,toWireType:d,argPackAdvance:S,readValueFromPointer:Mt(r,t,n!==0),destructorFunction:null});},Dt=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],i=n[r];function o(l){var s=$[l>>2],c=$[l+4>>2];return new i(Te.buffer,c,s)}t=P(t),k(e,{name:t,fromWireType:o,argPackAdvance:S,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0});},Ot=(e,r,t,n)=>{if(!(n>0))return 0;for(var i=t,o=t+n-1,l=0;l<e.length;++l){var s=e.charCodeAt(l);if(s>=55296&&s<=57343){var c=e.charCodeAt(++l);s=65536+((s&1023)<<10)|c&1023;}if(s<=127){if(t>=o)break;r[t++]=s;}else if(s<=2047){if(t+1>=o)break;r[t++]=192|s>>6,r[t++]=128|s&63;}else if(s<=65535){if(t+2>=o)break;r[t++]=224|s>>12,r[t++]=128|s>>6&63,r[t++]=128|s&63;}else {if(t+3>=o)break;r[t++]=240|s>>18,r[t++]=128|s>>12&63,r[t++]=128|s>>6&63,r[t++]=128|s&63;}}return r[t]=0,t-i},It=(e,r,t)=>Ot(e,C,r,t),Ut=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3;}return r},Lt=(e,r)=>{r=P(r);var t=r==="std::string";k(e,{name:r,fromWireType(n){var i=$[n>>2],o=n+4,l;if(t)for(var s=o,c=0;c<=i;++c){var d=o+c;if(c==i||C[d]==0){var f=d-s,v=ee(s,f);l===void 0?l=v:(l+=String.fromCharCode(0),l+=v),s=d+1;}}else {for(var m=new Array(i),c=0;c<i;++c)m[c]=String.fromCharCode(C[o+c]);l=m.join("");}return M(n),l},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var o,l=typeof i=="string";l||i instanceof Uint8Array||i instanceof Uint8ClampedArray||i instanceof Int8Array||h("Cannot pass non-string to std::string"),t&&l?o=Ut(i):o=i.length;var s=De(4+o+1),c=s+4;if($[s>>2]=o,t&&l)It(i,c,o+1);else if(l)for(var d=0;d<o;++d){var f=i.charCodeAt(d);f>255&&(M(c),h("String has UTF-16 code units that do not fit in 8 bits")),C[c+d]=f;}else for(var d=0;d<o;++d)C[c+d]=i[d];return n!==null&&n.push(M,s),s},argPackAdvance:S,readValueFromPointer:tr,destructorFunction(n){M(n);}});},dr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Wt=(e,r)=>{for(var t=e,n=t>>1,i=n+r/2;!(n>=i)&&fe[n];)++n;if(t=n<<1,t-e>32&&dr)return dr.decode(C.subarray(e,t));for(var o="",l=0;!(l>=r/2);++l){var s=Q[e+l*2>>1];if(s==0)break;o+=String.fromCharCode(s);}return o},jt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,o=0;o<i;++o){var l=e.charCodeAt(o);Q[r>>1]=l,r+=2;}return Q[r>>1]=0,r-n},Ht=e=>e.length*2,xt=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var i=W[e+t*4>>2];if(i==0)break;if(++t,i>=65536){var o=i-65536;n+=String.fromCharCode(55296|o>>10,56320|o&1023);}else n+=String.fromCharCode(i);}return n},zt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,i=n+t-4,o=0;o<e.length;++o){var l=e.charCodeAt(o);if(l>=55296&&l<=57343){var s=e.charCodeAt(++o);l=65536+((l&1023)<<10)|s&1023;}if(W[r>>2]=l,r+=4,r+4>i)break}return W[r>>2]=0,r-n},Vt=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4;}return r},Bt=(e,r,t)=>{t=P(t);var n,i,o,l,s;r===2?(n=Wt,i=jt,l=Ht,o=()=>fe,s=1):r===4&&(n=xt,i=zt,l=Vt,o=()=>$,s=2),k(e,{name:t,fromWireType:c=>{for(var d=$[c>>2],f=o(),v,m=c+4,_=0;_<=d;++_){var b=c+4+_*r;if(_==d||f[b>>s]==0){var F=b-m,w=n(m,F);v===void 0?v=w:(v+=String.fromCharCode(0),v+=w),m=b+r;}}return M(c),v},toWireType:(c,d)=>{typeof d!="string"&&h(`Cannot pass non-string to C++ string type ${t}`);var f=l(d),v=De(4+f+r);return $[v>>2]=f>>s,i(d,v+4,f+r),c!==null&&c.push(M,v),v},argPackAdvance:S,readValueFromPointer:cr,destructorFunction(c){M(c);}});},qt=(e,r)=>{r=P(r),k(e,{isVoid:!0,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}});},Gt=()=>{throw 1/0},Nt=e=>{e>4&&(A.get(e).refcount+=1);},Jt=(e,r)=>{var t=H[e];return t===void 0&&h(r+" has unknown type "+ar(e)),t},Xt=(e,r)=>{e=Jt(e,"_emval_take_value");var t=e.readValueFromPointer(r);return ge.toHandle(t)},Kt=()=>{Z("");},Qt=(e,r,t)=>C.copyWithin(e,r,r+t),Yt=()=>2147483648,Zt=e=>{var r=de.buffer,t=(e-r.byteLength+65535)/65536;try{return de.grow(t),We(),1}catch{}},en=e=>{var r=C.length;e>>>=0;var t=Yt();if(e>t)return !1;for(var n=(c,d)=>c+(d-c%d)%d,i=1;i<=4;i*=2){var o=r*(1+.2/i);o=Math.min(o,e+100663296);var l=Math.min(t,n(Math.max(e,o),65536)),s=Zt(l);if(s)return !0}return !1},rn=e=>52,tn=(e,r,t,n)=>52;function an(e,r,t,n,i){return 70}var sn=[null,[],[]],on=(e,r)=>{var t=sn[e];r===0||r===10?((e===1?Fr:z)(Ge(t,0)),t.length=0):t.push(r);},ln=(e,r,t,n)=>{for(var i=0,o=0;o<t;o++){var l=$[r>>2],s=$[r+4>>2];r+=8;for(var c=0;c<s;c++)on(e,C[l+c]);i+=s;}return $[n>>2]=i,0};Jr(),G=a.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Je=a.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},st(),tt(),vt(),ir=a.UnboundTypeError=yt(Error,"UnboundTypeError"),Pt(),Ft();var un={b:Vr,n:Br,D:qr,E:Gr,w:Nr,q:Kr,H:bt,G:Ct,e:Tt,F:Rt,o:kt,f:St,d:Dt,p:Lt,k:Bt,r:qt,y:Gt,s:ur,t:Nt,g:Xt,h:Kt,A:Qt,z:en,m:rn,C:tn,v:an,B:ln,j:gn,i:yn,l:bn,a:_n,c:mn,x:wn,u:Cn},g=zr(),M=e=>(M=g.K)(e),De=e=>(De=g.L)(e),fr=e=>(fr=g.M)(e);a.__embind_initialize_bindings=()=>(a.__embind_initialize_bindings=g.N)();var O=(e,r)=>(O=g.P)(e,r),I=()=>(I=g.Q)(),U=e=>(U=g.R)(e),hr=a.dynCall_viiij=(e,r,t,n,i,o)=>(hr=a.dynCall_viiij=g.S)(e,r,t,n,i,o);a.dynCall_jiji=(e,r,t,n,i)=>(a.dynCall_jiji=g.T)(e,r,t,n,i);function _n(e,r){var t=I();try{D(e)(r);}catch(n){if(U(t),n!==n+0)throw n;O(1,0);}}function mn(e,r,t){var n=I();try{D(e)(r,t);}catch(i){if(U(n),i!==i+0)throw i;O(1,0);}}function gn(e,r){var t=I();try{return D(e)(r)}catch(n){if(U(t),n!==n+0)throw n;O(1,0);}}function yn(e,r,t,n){var i=I();try{return D(e)(r,t,n)}catch(o){if(U(i),o!==o+0)throw o;O(1,0);}}function bn(e,r,t,n,i,o){var l=I();try{return D(e)(r,t,n,i,o)}catch(s){if(U(l),s!==s+0)throw s;O(1,0);}}function wn(e,r,t,n,i){var o=I();try{D(e)(r,t,n,i);}catch(l){if(U(o),l!==l+0)throw l;O(1,0);}}function Cn(e,r,t,n,i,o){var l=I();try{hr(e,r,t,n,i,o);}catch(s){if(U(l),s!==s+0)throw s;O(1,0);}}var ye;Y=function e(){ye||vr(),ye||(Y=e);};function vr(){if(j>0||(Mr(),j>0))return;function e(){ye||(ye=!0,a.calledRun=!0,!Ie&&(Sr(),y(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),Dr()));}a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("");},1),e();},1)):e();}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return vr(),u.ready}})(),wr=Tn;var x=class{constructor(){throw new Error("WasmLoader is a static class and cannot be instantiated.")}static async _tryLoad(u){return await wr({locateFile:()=>u})}static async _loadWithBackup(){return this._ModulePromise||(this._ModulePromise=this._tryLoad(this._wasmURL).catch(async u=>{let a=`https://cdn.jsdelivr.net/npm/${oe.name}@${oe.version}/dist/renderer.wasm`;console.warn(`Trying backup URL for WASM loading: ${a}`);try{return await this._tryLoad(a)}catch(y){throw console.error(`Both primary and backup WASM URLs failed. Primary error: ${u.message}, Backup error: ${y.message}`),new Error("WASM loading failed from all sources.")}})),this._ModulePromise}static async load(){return this._loadWithBackup()}static setWasmUrl(u){this._wasmURL=u,this._ModulePromise=null;}};a(x,"_ModulePromise",null),a(x,"_wasmURL",`https://unpkg.com/${oe.name}@${oe.version}/dist/renderer.wasm`);var le=1e3,Cr=class{constructor(u){a(this,"_canvas");a(this,"_context");a(this,"_eventManager",new a$1);a(this,"_renderer",null);a(this,"_playing",!1);a(this,"_beginTime",0);a(this,"_elapsedTime",0);a(this,"_totalFrames",0);a(this,"_loop",!1);a(this,"_speed",1);a(this,"_currentFrame",0);a(this,"_duration",0);a(this,"_loopCount",0);a(this,"_autoplay",!1);a(this,"_mode","normal");a(this,"_direction",1);a(this,"_bounceCount",0);a(this,"_animationFrameId");a(this,"_shouldAutoResizeCanvas",!1);a(this,"_canvasResizeObserver",null);if(this._animationLoop=this._animationLoop.bind(this),this._canvas=u.canvas,this._context=this._canvas.getContext("2d"),!this._context)throw new Error("2D context not supported or canvas already initialized with another context type.");this._loop=u.loop??!1,this._speed=u.speed??1,this._autoplay=u.autoplay??!1,this._mode=u.mode??"normal",u.backgroundColor&&(this._canvas.style.backgroundColor=u.backgroundColor),this._canvas.hasAttribute("width")||this._canvas.hasAttribute("height")||(this._shouldAutoResizeCanvas=!0,this._canvasResizeObserver=new ResizeObserver(c(()=>{this._resizeAnimationToCanvas(),this._playing||this._render();},100)),this._canvasResizeObserver.observe(this._canvas)),x.load().then(a=>{this._renderer=new a.Renderer,u.src?this._loadAnimationFromURL(u.src):u.data&&this._initializeAnimationFromData(u.data);}).catch(a=>{this._eventManager.dispatch({type:"loadError",error:a});});}get direction(){return this._direction}get currentFrame(){return this._currentFrame}get duration(){return this._duration}get totalFrames(){return this._totalFrames}get loop(){return this._loop}get speed(){return this._speed}get loopCount(){return this._loopCount}get playing(){return this._playing}_loadAnimationFromURL(u){b(u).then(a=>{this._initializeAnimationFromData(a);}).catch(a=>{this._eventManager.dispatch({type:"loadError",error:a});});}_initializeAnimationFromData(u){let a=y=>{try{this._renderer?.load(y,this._canvas.width,this._canvas.height)?(this._setupAnimationDetails(),this._eventManager.dispatch({type:"load"}),this._resizeAnimationToCanvas(),this._autoplay?this.play():this._render()):this._eventManager.dispatch({type:"loadError",error:new Error("Error encountered while initializing animation from data.")});}catch(E){this._eventManager.dispatch({type:"loadError",error:E});}};typeof u=="string"?a(u):u instanceof ArrayBuffer?a$2(u).then(a).catch(y=>{this._eventManager.dispatch({type:"loadError",error:y});}):console.error("Unsupported data type for animation data. Expected a string or ArrayBuffer.");}_setupAnimationDetails(){this._renderer&&(this._totalFrames=this._renderer.totalFrames(),this._duration=this._renderer.duration());}_render(){if(this._context&&(this._renderer?.resize(this._canvas.width,this._canvas.height),this._renderer?.update())){let u=this._renderer.render(),a=Uint8ClampedArray.from(u);if(a.length===0)return;let y=new ImageData(a,this._canvas.width,this._canvas.height);this._context.putImageData(y,0,0);}}_update(){if(this._duration===0)return !1;this._elapsedTime=(performance.now()/le-this._beginTime)*this._speed;let u=this._elapsedTime/this._duration*this._totalFrames;if(this._mode==="normal"?this._currentFrame=u:this._mode==="reverse"?this._currentFrame=this._totalFrames-u-1:this._mode==="bounce"?(this._direction===-1&&(u=this._totalFrames-u-1),this._currentFrame=u):(this._direction===-1&&(u=this._totalFrames-u-1),this._currentFrame=u,this._bounceCount===0&&(this._direction=-1)),this._currentFrame=Math.max(0,Math.min(this._currentFrame,this._totalFrames-1)),this._currentFrame>=this._totalFrames-1||this._currentFrame<=0)if(this._loop||this._mode==="bounce"||this._mode==="bounce-reverse")if(this._beginTime=performance.now()/le,this._elapsedTime=0,this._mode==="bounce"||this._mode==="bounce-reverse"){if(this._direction*=-1,this._bounceCount+=1,this._bounceCount>=2){if(this._bounceCount=0,!this._loop)return this._playing=!1,this._bounceCount=0,this._direction=1,this._eventManager.dispatch({type:"complete"}),!1;this._loopCount+=1,this._eventManager.dispatch({type:"loop",loopCount:this._loopCount});}}else this._loopCount+=1,this._eventManager.dispatch({type:"loop",loopCount:this._loopCount});else return this._playing=!1,this._eventManager.dispatch({type:"complete"}),!1;return this._renderer?.frame(this._currentFrame)?(this._eventManager.dispatch({type:"frame",currentFrame:this._currentFrame}),!0):!1}_animationLoop(){this._playing&&this._update()&&(this._render(),this._startAnimationLoop());}_resizeAnimationToCanvas(){if(!this._shouldAutoResizeCanvas)return;let u=this._canvas.getClientRects();if(!u.length)return;let a=u[0],y=window.devicePixelRatio||1,E=Math.round(a.width*y),X=Math.round(a.height*y),we=this._canvas.width,Ce=this._canvas.height;E===we||X===Ce||(this._canvas.width=E,this._canvas.height=X);}_stopAnimationLoop(){this._animationFrameId&&window.cancelAnimationFrame(this._animationFrameId);}_startAnimationLoop(){this._animationFrameId&&window.cancelAnimationFrame(this._animationFrameId),this._animationFrameId=window.requestAnimationFrame(this._animationLoop);}play(){if(this._totalFrames===0){this._eventManager.dispatch({type:"loadError",error:new Error("Unable to play animation.")});return}if(!this._playing){let u=this._duration/this._totalFrames,a=this._currentFrame*u;this._direction===-1&&(a=this._duration-a),this._beginTime=performance.now()/le-a/this._speed,this._playing=!0,this._eventManager.dispatch({type:"play"}),this._startAnimationLoop();}}stop(){this._stopAnimationLoop(),this._playing=!1,this._loopCount=0,this._direction=1,this._currentFrame=0,this._bounceCount=0,this._beginTime=0,this.setFrame(0),this._eventManager.dispatch({type:"stop"});}pause(){this._playing&&(this._playing=!1,this._eventManager.dispatch({type:"pause"}));}setSpeed(u){if(u<=0){console.error("Speed must be a positive number.");return}if(this._playing){let a=performance.now()/le;this._beginTime=a-this._elapsedTime/u;}this._speed=u;}setLoop(u){this._loop=u;}setFrame(u){if(u<0||u>=this._totalFrames){console.error(`Invalid frame number provided: ${u}. Valid range is between 0 and ${this._totalFrames-1}.`);return}if(this._currentFrame=u,this._playing){let a=this._duration/this._totalFrames,y=u*a;this._direction===-1&&(y=this._duration-y),this._beginTime=performance.now()/le-y/this._speed;}this._renderer?.frame(this._currentFrame),this._render(),this._eventManager.dispatch({type:"frame",currentFrame:this._currentFrame});}load(u){this._playing=!1,this._stopAnimationLoop(),this._loop=u.loop??!1,this._speed=u.speed??1,this._autoplay=u.autoplay??!1,this._loopCount=0,this._currentFrame=0,this._beginTime=0,this._totalFrames=0,this._duration=0,this._bounceCount=0,this._direction=1,this._mode=u.mode??"normal",this._canvas.style.backgroundColor="",u.backgroundColor&&(this._canvas.style.backgroundColor=u.backgroundColor),u.src?this._loadAnimationFromURL(u.src):u.data&&this._initializeAnimationFromData(u.data);}addEventListener(u,a){this._eventManager.addEventListener(u,a);}removeEventListener(u,a){this._eventManager.removeEventListener(u,a);}static setWasmUrl(u){x.setWasmUrl(u);}destroy(){this._stopAnimationLoop(),this._eventManager.removeAllEventListeners(),this._canvasResizeObserver?.disconnect(),this._context=null,this._renderer=null;}};
|
|
7
|
+
|
|
8
|
+
export { x as a, Cr as b };
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-4GVX2PO3.js.map
|