@lottiefiles/dotlottie-web 0.4.1 → 0.6.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 +43 -29
- package/dist/{chunk-VRCJABVO.js → chunk-2ELNS7EO.js} +2 -2
- package/dist/chunk-2ELNS7EO.js.map +1 -0
- package/dist/chunk-NIBIKWSN.js +10 -0
- package/dist/chunk-NIBIKWSN.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 +3 -3
- package/dist/event-manager.d.ts +1 -0
- package/dist/event-manager.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- 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-IPGUQKUM.js +0 -11
- package/dist/chunk-IPGUQKUM.js.map +0 -1
- package/dist/chunk-VRCJABVO.js.map +0 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* [Via CDN](#via-cdn)
|
|
22
22
|
* [Live Example](#live-example)
|
|
23
23
|
* [APIs](#apis)
|
|
24
|
-
* [
|
|
24
|
+
* [Config](#config)
|
|
25
25
|
* [Properties](#properties)
|
|
26
26
|
* [Methods](#methods)
|
|
27
27
|
* [Static Methods](#static-methods)
|
|
@@ -107,50 +107,64 @@ const dotLottie = new DotLottie({
|
|
|
107
107
|
|
|
108
108
|
## APIs
|
|
109
109
|
|
|
110
|
-
###
|
|
110
|
+
### Config
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
112
|
+
The `DotLottie` constructor accepts a config object with the following properties:
|
|
113
|
+
|
|
114
|
+
| Property name | Type | Required | Default | Description |
|
|
115
|
+
| ------------- | --------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------- |
|
|
116
|
+
| `autoplay` | boolean | | false | Auto-starts the animation on load. |
|
|
117
|
+
| `loop` | boolean | | false | Determines if the animation should loop. |
|
|
118
|
+
| `canvas` | HTMLCanvasElement | ✔️ | undefined | Canvas element for animation rendering. |
|
|
119
|
+
| `src` | string | | undefined | URL to the animation data (`.json` or `.lottie`). |
|
|
120
|
+
| `speed` | number | | 1 | Animation playback speed. 1 is regular speed. |
|
|
121
|
+
| `data` | string \| ArrayBuffer | | undefined | Animation data provided either as a Lottie JSON string or as an ArrayBuffer for .lottie animations. |
|
|
122
|
+
| `mode` | string | | "normal" | Animation play mode. Accepts "normal", "reverse", "bounce", "bounce-reverse". |
|
|
120
123
|
|
|
121
124
|
### Properties
|
|
122
125
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
| `
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
126
|
+
`DotLottie` instances expose the following properties:
|
|
127
|
+
|
|
128
|
+
| Property | Type | Description |
|
|
129
|
+
| -------------- | ------- | ------------------------------------------------------------------------------------------- |
|
|
130
|
+
| `currentFrame` | number | Represents the animation's currently displayed frame number. |
|
|
131
|
+
| `duration` | number | Specifies the animation's total playback time in milliseconds. |
|
|
132
|
+
| `totalFrames` | number | Denotes the total count of individual frames within the animation. |
|
|
133
|
+
| `loop` | boolean | Indicates if the animation is set to play in a continuous loop. |
|
|
134
|
+
| `speed` | number | Represents the playback speed factor; e.g., 2 would mean double speed. |
|
|
135
|
+
| `loopCount` | number | Tracks how many times the animation has completed its loop. |
|
|
136
|
+
| `playing` | boolean | Reflects whether the animation is in active playback or not |
|
|
137
|
+
| `direction` | string | Reflects the current playback direction; e.g., 1 would mean forward, -1 would mean reverse. |
|
|
132
138
|
|
|
133
139
|
### Methods
|
|
134
140
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
| `
|
|
140
|
-
| `
|
|
141
|
-
| `
|
|
142
|
-
| `
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
141
|
+
`DotLottie` instances expose the following methods that can be used to control the animation:
|
|
142
|
+
|
|
143
|
+
| Method | Description |
|
|
144
|
+
| --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
145
|
+
| `play()` | Begins playback from the current animation position. |
|
|
146
|
+
| `pause()` | Pauses the animation without resetting its position. |
|
|
147
|
+
| `stop()` | Halts playback and returns the animation to its initial frame. |
|
|
148
|
+
| `setSpeed(speed: number)` | Sets the playback speed with the given multiplier. |
|
|
149
|
+
| `setLoop(loop: boolean)` | Configures whether the animation should loop continuously. |
|
|
150
|
+
| `setFrame(frame: number)` | Directly navigates the animation to a specified frame. |
|
|
151
|
+
| `addEventListener(event: string, listener: Function)` | Registers a function to respond to a specific animation event. |
|
|
152
|
+
| `removeEventListener(event: string, listener?: Function)` | Removes a previously registered function from responding to a specific animation event. |
|
|
153
|
+
| `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. |
|
|
154
|
+
| `load(config: Config)` | Loads a new configuration or a new animation. |
|
|
145
155
|
|
|
146
156
|
### Static Methods
|
|
147
157
|
|
|
158
|
+
The `DotLottie` class exposes the following static methods:
|
|
159
|
+
|
|
148
160
|
| Method | Description |
|
|
149
161
|
| ------------------------- | ----------------------------------------- |
|
|
150
162
|
| `setWasmUrl(url: string)` | Sets the URL to the renderer.wasm binary. |
|
|
151
163
|
|
|
152
164
|
### Events
|
|
153
165
|
|
|
166
|
+
The `DotLottie` instance emits the following events that can be listened to via the `addEventListener` method:
|
|
167
|
+
|
|
154
168
|
| Event | Description |
|
|
155
169
|
| ----------- | ---------------------------------------------------- |
|
|
156
170
|
| `load` | Emitted when the animation is loaded. |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a } from './chunk-7Q3PPTBP.js';
|
|
2
2
|
|
|
3
|
-
var s=class{constructor(){a(this,"_eventListeners",new Map);}addEventListener(t,n){let e=this._eventListeners.get(t);e||(e=new Set,this._eventListeners.set(t,e)),e.add(n);}removeEventListener(t,n){let e=this._eventListeners.get(t);e&&(n?(e.delete(n),e.size===0&&this._eventListeners.delete(t)):this._eventListeners.delete(t));}dispatch(t){this._eventListeners.get(t.type)?.forEach(e=>e(t));}};
|
|
3
|
+
var s=class{constructor(){a(this,"_eventListeners",new Map);}addEventListener(t,n){let e=this._eventListeners.get(t);e||(e=new Set,this._eventListeners.set(t,e)),e.add(n);}removeEventListener(t,n){let e=this._eventListeners.get(t);e&&(n?(e.delete(n),e.size===0&&this._eventListeners.delete(t)):this._eventListeners.delete(t));}dispatch(t){this._eventListeners.get(t.type)?.forEach(e=>e(t));}removeAllEventListeners(){this._eventListeners.clear();}};
|
|
4
4
|
|
|
5
5
|
export { s as a };
|
|
6
6
|
//# sourceMappingURL=out.js.map
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
//# sourceMappingURL=chunk-2ELNS7EO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/event-manager.ts"],"names":["EventManager","__publicField","type","listener","listeners","event"],"mappings":"wCAuHO,IAAMA,EAAN,KAAmB,CAAnB,cACLC,EAAA,KAAiB,kBAAiE,IAAI,KAE/E,iBAAsCC,EAASC,EAAkC,CACtF,IAAIC,EAAY,KAAK,gBAAgB,IAAIF,CAAI,EAExCE,IACHA,EAAY,IAAI,IAChB,KAAK,gBAAgB,IAAIF,EAAME,CAAS,GAG1CA,EAAU,IAAID,CAAQ,CACxB,CAEO,oBAAyCD,EAASC,EAAmC,CAC1F,IAAMC,EAAY,KAAK,gBAAgB,IAAIF,CAAI,EAE1CE,IAEDD,GACFC,EAAU,OAAOD,CAAQ,EAErBC,EAAU,OAAS,GACrB,KAAK,gBAAgB,OAAOF,CAAI,GAGlC,KAAK,gBAAgB,OAAOA,CAAI,EAEpC,CAEO,SAA8BG,EAA6B,CAC9C,KAAK,gBAAgB,IAAIA,EAAM,IAAI,GAE1C,QAASF,GAAaA,EAASE,CAAK,CAAC,CAClD,CAEO,yBAAgC,CACrC,KAAK,gBAAgB,MAAM,CAC7B,CACF","sourcesContent":["/**\n * Copyright 2023 Design Barn Inc.\n */\n\n/**\n * Represents the different types of events that can be dispatched.\n */\nexport type EventType = 'complete' | 'frame' | 'load' | 'loadError' | 'loop' | 'pause' | 'play' | 'stop';\n\n/**\n * Maps an event type string to its respective event interface.\n */\ntype EventByType<T> = T extends 'complete'\n ? CompleteEvent\n : T extends 'frame'\n ? FrameEvent\n : T extends 'load'\n ? LoadEvent\n : T extends 'loadError'\n ? LoadErrorEvent\n : T extends 'loop'\n ? LoopEvent\n : T extends 'pause'\n ? PauseEvent\n : T extends 'play'\n ? PlayEvent\n : T extends 'stop'\n ? StopEvent\n : never;\n\n/**\n * Base interface for all events.\n */\nexport interface BaseEvent {\n type: EventType;\n}\n\n/**\n * Event fired when a loop action occurs.\n */\nexport interface LoopEvent extends BaseEvent {\n loopCount: number;\n type: 'loop';\n}\n\n/**\n * Event fired during frame changes.\n */\nexport interface FrameEvent extends BaseEvent {\n currentFrame: number;\n type: 'frame';\n}\n\n/**\n * Event fired when a load action occurs.\n */\nexport interface LoadEvent extends BaseEvent {\n type: 'load';\n}\n\n/**\n * Event fired when a loading error occurs.\n */\nexport interface LoadErrorEvent extends BaseEvent {\n error: Error;\n type: 'loadError';\n}\n\n/**\n * Event fired when a completion action occurs.\n */\nexport interface CompleteEvent extends BaseEvent {\n type: 'complete';\n}\n\n/**\n * Event fired when a pause action occurs.\n */\nexport interface PauseEvent extends BaseEvent {\n type: 'pause';\n}\n\n/**\n * Event fired when a play action occurs.\n */\nexport interface PlayEvent extends BaseEvent {\n type: 'play';\n}\n\n/**\n * Event fired when a stop action occurs.\n */\nexport interface StopEvent extends BaseEvent {\n type: 'stop';\n}\n\n/**\n * Represents all possible event types.\n */\nexport type Event =\n | LoopEvent\n | FrameEvent\n | LoadEvent\n | LoadErrorEvent\n | CompleteEvent\n | PauseEvent\n | PlayEvent\n | StopEvent;\n\n/**\n * Type for event listener callbacks.\n */\nexport interface EventListener<T extends EventType> {\n (event: EventByType<T>): void;\n}\n\n/**\n * Manages registration and dispatching of event listeners.\n */\nexport class EventManager {\n private readonly _eventListeners: Map<EventType, Set<EventListener<EventType>>> = new Map();\n\n public addEventListener<T extends EventType>(type: T, listener: EventListener<T>): void {\n let listeners = this._eventListeners.get(type);\n\n if (!listeners) {\n listeners = new Set<EventListener<T>>();\n this._eventListeners.set(type, listeners);\n }\n\n listeners.add(listener);\n }\n\n public removeEventListener<T extends EventType>(type: T, listener?: EventListener<T>): void {\n const listeners = this._eventListeners.get(type);\n\n if (!listeners) return;\n\n if (listener) {\n listeners.delete(listener);\n\n if (listeners.size === 0) {\n this._eventListeners.delete(type);\n }\n } else {\n this._eventListeners.delete(type);\n }\n }\n\n public dispatch<T extends EventType>(event: EventByType<T>): void {\n const listeners = this._eventListeners.get(event.type);\n\n listeners?.forEach((listener) => listener(event));\n }\n\n public removeAllEventListeners(): void {\n this._eventListeners.clear();\n }\n}\n"]}
|
|
@@ -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.6.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 Pn=(()=>{var le=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(c={}){var i=c,C,E;i.ready=new Promise((e,r)=>{C=e,E=r;});var X=Object.assign({},i),Oe=!0,R="";function Pr(e){return i.locateFile?i.locateFile(e,R):R+e}(typeof document<"u"&&document.currentScript&&(R=document.currentScript.src),le&&(R=le),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=i.print||console.log.bind(console),z=i.printErr||console.error.bind(console);Object.assign(i,X),X=null,i.arguments&&(i.arguments),i.thisProgram&&(i.thisProgram),i.quit&&(i.quit);var K;i.wasmBinary&&(K=i.wasmBinary),typeof WebAssembly!="object"&&Z("no native wasm support detected");var ce,Ie=!1;function Er(e,r){e||Z(r);}var Pe,w,Q,de,W,$,Ue,Le;function We(){var e=ce.buffer;i.HEAP8=Pe=new Int8Array(e),i.HEAP16=Q=new Int16Array(e),i.HEAPU8=w=new Uint8Array(e),i.HEAPU16=de=new Uint16Array(e),i.HEAP32=W=new Int32Array(e),i.HEAPU32=$=new Uint32Array(e),i.HEAPF32=Ue=new Float32Array(e),i.HEAPF64=Le=new Float64Array(e);}var je=[],He=[],xe=[];function Sr(){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)Or(i.preRun.shift());Ae(je);}function kr(){Ae(He);}function Dr(){if(i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;)Ur(i.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++,i.monitorRunDependencies&&i.monitorRunDependencies(j);}function Wr(e){if(j--,i.monitorRunDependencies&&i.monitorRunDependencies(j),j==0&&(Y)){var r=Y;Y=null,r();}}function Z(e){i.onAbort&&i.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=Pr(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(a=>{var o=WebAssembly.instantiateStreaming(a,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,a){return g=n.exports,ce=g.I,We(),nr=g.O,Ir(g.J),Wr(),g}Lr();function t(n){r(n.instance);}if(i.instantiateWasm)try{return i.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()(i);};i.noExitRuntime||!0;var qe=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ge=(e,r,t)=>{for(var n=r+t,a=r;e[a]&&!(a>=n);)++a;if(a-r>16&&e.buffer&&qe)return qe.decode(e.subarray(r,a));for(var o="";r<a;){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 u=e[r++]&63;if((l&240)==224?l=(l&15)<<12|s<<6|u:l=(l&7)<<18|s<<12|u<<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(w,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,a)=>{},Jr=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Ne=e;},Ne,T=e=>{for(var r="",t=e;w[t];)r+=Ne[w[t++]];return r},q={},H={},fe={},G,v=e=>{throw new G(e)},Je,ve=e=>{throw new Je(e)},re=(e,r,t)=>{e.forEach(function(s){fe[s]=r;});function n(s){var u=t(s);u.length!==e.length&&ve("Mismatched type converter count");for(var d=0;d<e.length;++d)M(e[d],u[d]);}var a=new Array(r.length),o=[],l=0;r.forEach((s,u)=>{H.hasOwnProperty(s)?a[u]=H[s]:(o.push(s),q.hasOwnProperty(s)||(q[s]=[]),q[s].push(()=>{a[u]=H[s],++l,l===o.length&&n(a);}));}),o.length===0&&n(a);};function Xr(e,r,t={}){var n=r.name;if(e||v(`type "${n}" must have a positive integer typeid pointer`),H.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;v(`Cannot register type '${n}' twice`);}if(H[e]=r,delete fe[e],q.hasOwnProperty(e)){var a=q[e];delete q[e],a.forEach(o=>o());}}function M(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Xr(e,r,t)}var k=8,Kr=(e,r,t,n)=>{r=T(r),M(e,{name:r,fromWireType:function(a){return !!a},toWireType:function(a,o){return o?t:n},argPackAdvance:k,readValueFromPointer:function(a){return this.fromWireType(w[a])},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}v(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=()=>{i.getInheritedInstanceCount=Zr,i.getLiveInheritedInstances=et,i.flushPendingDeletes=Ee,i.setDelayFunction=rt;},ie={},nt=(e,r)=>{for(r===void 0&&v("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]),he=(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 a(){return this.isSmartPointer?he(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):he(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o=this.registeredClass.getActualType(r),l=Ye[o];if(!l)return a.call(this);var s;this.isConst?s=l.constPointerType:s=l.pointerType;var u=Qe(r,this.registeredClass,s.registeredClass);return u===null?a.call(this):this.isSmartPointer?he(s.registeredClass.instancePrototype,{ptrType:s,ptr:u,smartPtrType:this,smartPtr:e}):he(s.registeredClass.instancePrototype,{ptrType:s,ptr:u})}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 a={$$:t};Re.register(r,a,r);}return r},Xe=r=>Re.unregister(r),ae(e)),st=()=>{Object.assign(pe.prototype,{isAliasOf(e){if(!(this instanceof pe)||!(e instanceof pe))return !1;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,a=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)a=n.upcast(a),n=n.baseClass;return r===n&&t===a},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&&v("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&&v("Object already scheduled for deletion"),te.push(this),te.length===1&&ne&&ne(Ee),this.$$.deleteScheduled=!0,this}});};function pe(){}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)||v(`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)=>{i.hasOwnProperty(e)?((t===void 0||i[e].overloadTable!==void 0&&i[e].overloadTable[t]!==void 0)&&v(`Cannot register public name '${e}' twice`),rr(i,e,e),i.hasOwnProperty(t)&&v(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),i[e].overloadTable[t]=r):(i[e]=r,t!==void 0&&(i[e].numArguments=t));};function ct(e,r,t,n,a,o,l,s){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=a,this.getActualType=o,this.upcast=l,this.downcast=s,this.pureVirtualFunctions=[];}var Me=(e,r,t)=>{for(;r!==t;)r.upcast||v(`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&&v(`null is not a valid ${this.name}`),0;r.$$||v(`Cannot pass "${ke(r)}" as a ${this.name}`),r.$$.ptr||v(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Me(r.$$.ptr,t,this.registeredClass);return n}function ft(e,r){var t;if(r===null)return this.isReference&&v(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;r.$$||v(`Cannot pass "${ke(r)}" as a ${this.name}`),r.$$.ptr||v(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&v(`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=Me(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&v("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:v(`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 a=r.clone();t=this.rawShare(t,me.toHandle(()=>a.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:v("Unsupporting sharing policy");}return t}function vt(e,r){if(r===null)return this.isReference&&v(`null is not a valid ${this.name}`),0;r.$$||v(`Cannot pass "${ke(r)}" as a ${this.name}`),r.$$.ptr||v(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&v(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=Me(r.$$.ptr,t,this.registeredClass);return n}function tr(e){return this.fromWireType($[e>>2])}var ht=()=>{Object.assign(_e.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor&&this.rawDestructor(e);},argPackAdvance:k,readValueFromPointer:tr,deleteObject(e){e!==null&&e.delete();},fromWireType:at});};function _e(e,r,t,n,a,o,l,s,u,d,f){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=a,this.pointeeType=o,this.sharingPolicy=l,this.rawGetPointee=s,this.rawConstructor=u,this.rawShare=d,this.rawDestructor=f,!a&&r.baseClass===void 0?n?(this.toWireType=dt,this.destructorFunction=null):(this.toWireType=vt,this.destructorFunction=null):this.toWireType=ft;}var pt=(e,r,t)=>{i.hasOwnProperty(e)||ve("Replacing nonexistant public symbol"),i[e].overloadTable!==void 0&&t!==void 0?i[e].overloadTable[t]=r:(i[e]=r,i[e].argCount=t);},_t=(e,r,t)=>{var n=i["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=T(e);function t(){return e.includes("j")?gt(e,r):D(r)}var n=t();return typeof n!="function"&&v(`unknown function pointer with signature ${e}: ${r}`),n},yt=(e,r)=>{var t=er(r,function(n){this.name=r,this.message=n;var a=new Error(n).stack;a!==void 0&&(this.stack=this.toString()+`
|
|
6
|
+
`+a.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=T(r);return S(r),t},Se=(e,r)=>{var t=[],n={};function a(o){if(!n[o]&&!H[o]){if(fe[o]){fe[o].forEach(a);return}t.push(o),n[o]=!0;}}throw r.forEach(a),new ir(`${e}: `+t.map(ar).join([", "]))},bt=(e,r,t,n,a,o,l,s,u,d,f,h,m)=>{f=T(f),o=N(a,o),s&&(s=N(l,s)),d&&(d=N(u,d)),m=N(h,m);var _=Ze(f);ut(_,function(){Se(`Cannot construct ${f} due to unbound types`,[n]);}),re([e,r,t],n?[n]:[],function(y){y=y[0];var F,b;n?(F=y.registeredClass,b=F.instancePrototype):b=pe.prototype;var J=er(_,function(){if(Object.getPrototypeOf(this)!==se)throw new G("Use 'new' to construct "+f);if(P.constructor_body===void 0)throw new G(f+" has no accessible constructor");var _r=P.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(P.constructor_body).toString()}) parameters instead!`);return _r.apply(this,arguments)}),se=Object.create(b,{constructor:{value:J}});J.prototype=se;var P=new ct(f,J,se,m,F,o,s,d);P.baseClass&&(P.baseClass.__derivedClasses===void 0&&(P.baseClass.__derivedClasses=[]),P.baseClass.__derivedClasses.push(P));var L=new _e(f,P,!0,!1,!1),ye=new _e(f+"*",P,!1,!1,!1),pr=new _e(f+" const*",P,!1,!0,!1);return Ye[e]={pointerType:ye,constPointerType:pr},pt(_,J),[L,ye,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,a,o){var l=r.length;l<2&&v("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=r[1]!==null&&t!==null,u=!1,d=1;d<r.length;++d)if(r[d]!==null&&r[d].destructorFunction===void 0){u=!0;break}var f=r[0].name!=="void",h=l-2,m=new Array(h),_=[],y=[];return function(){arguments.length!==h&&v(`function ${e} called with ${arguments.length} arguments, expected ${h}`),y.length=0;var F;_.length=s?2:1,_[0]=a,s&&(F=r[1].toWireType(y,this),_[1]=F);for(var b=0;b<h;++b)m[b]=r[b+2].toWireType(y,arguments[b]),_.push(m[b]);var J=n.apply(null,_);function se(P){if(u)wt(y);else for(var L=s?1:2;L<r.length;L++){var ye=L===1?F:m[L-2];r[L].destructorFunction!==null&&r[L].destructorFunction(ye);}if(f)return r[0].fromWireType(P)}return se(J)}}var $t=(e,r,t,n,a,o)=>{var l=sr(r,t);a=N(n,a),re([],[e],function(s){s=s[0];var u=`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]=()=>{Se(`Cannot construct ${s.name} due to unbound types`,l);},re([],l,d=>(d.splice(1,0,null),s.registeredClass.constructor_body[r-1]=or(u,d,null,a,o),[])),[]});},Ct=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},Pt=(e,r,t,n,a,o,l,s,u)=>{var d=sr(t,n);r=T(r),r=Ct(r),o=N(a,o),re([],[e],function(f){f=f[0];var h=`${f.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),s&&f.registeredClass.pureVirtualFunctions.push(r);function m(){Se(`Cannot call ${h} due to unbound types`,d);}var _=f.registeredClass.instancePrototype,y=_[r];return y===void 0||y.overloadTable===void 0&&y.className!==f.name&&y.argCount===t-2?(m.argCount=t-2,m.className=f.name,_[r]=m):(rr(_,r,h),_[r].overloadTable[t-2]=m),re([],d,function(F){var b=or(h,F,f,o,l);return _[r].overloadTable===void 0?(b.argCount=t-2,_[r]=b):_[r].overloadTable[t-2]=b,[]}),[]});};function Tt(){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,i.count_emval_handles=At;},me={toValue:e=>(e||v("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=T(r),M(e,{name:r,fromWireType:t=>{var n=me.toValue(t);return ur(t),n},toWireType:(t,n)=>me.toHandle(n),argPackAdvance:k,readValueFromPointer:cr,destructorFunction:null});},ke=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}`)}},Mt=(e,r,t)=>{r=T(r),M(e,{name:r,fromWireType:n=>n,toWireType:(n,a)=>a,argPackAdvance:k,readValueFromPointer:Et(r,t),destructorFunction:null});},St=(e,r,t)=>{switch(r){case 1:return t?n=>Pe[n>>0]:n=>w[n>>0];case 2:return t?n=>Q[n>>1]:n=>de[n>>1];case 4:return t?n=>W[n>>2]:n=>$[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},kt=(e,r,t,n,a)=>{r=T(r);var o=f=>f;if(n===0){var l=32-8*t;o=f=>f<<l>>>l;}var s=r.includes("unsigned"),u=(f,h)=>{},d;s?d=function(f,h){return u(h,this.name),h>>>0}:d=function(f,h){return u(h,this.name),h},M(e,{name:r,fromWireType:o,toWireType:d,argPackAdvance:k,readValueFromPointer:St(r,t,n!==0),destructorFunction:null});},Dt=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],a=n[r];function o(l){var s=$[l>>2],u=$[l+4>>2];return new a(Pe.buffer,u,s)}t=T(t),M(e,{name:t,fromWireType:o,argPackAdvance:k,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0});},Ot=(e,r,t,n)=>{if(!(n>0))return 0;for(var a=t,o=t+n-1,l=0;l<e.length;++l){var s=e.charCodeAt(l);if(s>=55296&&s<=57343){var u=e.charCodeAt(++l);s=65536+((s&1023)<<10)|u&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-a},It=(e,r,t)=>Ot(e,w,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=T(r);var t=r==="std::string";M(e,{name:r,fromWireType(n){var a=$[n>>2],o=n+4,l;if(t)for(var s=o,u=0;u<=a;++u){var d=o+u;if(u==a||w[d]==0){var f=d-s,h=ee(s,f);l===void 0?l=h:(l+=String.fromCharCode(0),l+=h),s=d+1;}}else {for(var m=new Array(a),u=0;u<a;++u)m[u]=String.fromCharCode(w[o+u]);l=m.join("");}return S(n),l},toWireType(n,a){a instanceof ArrayBuffer&&(a=new Uint8Array(a));var o,l=typeof a=="string";l||a instanceof Uint8Array||a instanceof Uint8ClampedArray||a instanceof Int8Array||v("Cannot pass non-string to std::string"),t&&l?o=Ut(a):o=a.length;var s=De(4+o+1),u=s+4;if($[s>>2]=o,t&&l)It(a,u,o+1);else if(l)for(var d=0;d<o;++d){var f=a.charCodeAt(d);f>255&&(S(u),v("String has UTF-16 code units that do not fit in 8 bits")),w[u+d]=f;}else for(var d=0;d<o;++d)w[u+d]=a[d];return n!==null&&n.push(S,s),s},argPackAdvance:k,readValueFromPointer:tr,destructorFunction(n){S(n);}});},dr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Wt=(e,r)=>{for(var t=e,n=t>>1,a=n+r/2;!(n>=a)&&de[n];)++n;if(t=n<<1,t-e>32&&dr)return dr.decode(w.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,a=t<e.length*2?t/2:e.length,o=0;o<a;++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 a=W[e+t*4>>2];if(a==0)break;if(++t,a>=65536){var o=a-65536;n+=String.fromCharCode(55296|o>>10,56320|o&1023);}else n+=String.fromCharCode(a);}return n},zt=(e,r,t)=>{if(t===void 0&&(t=2147483647),t<4)return 0;for(var n=r,a=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>a)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=T(t);var n,a,o,l,s;r===2?(n=Wt,a=jt,l=Ht,o=()=>de,s=1):r===4&&(n=xt,a=zt,l=Vt,o=()=>$,s=2),M(e,{name:t,fromWireType:u=>{for(var d=$[u>>2],f=o(),h,m=u+4,_=0;_<=d;++_){var y=u+4+_*r;if(_==d||f[y>>s]==0){var F=y-m,b=n(m,F);h===void 0?h=b:(h+=String.fromCharCode(0),h+=b),m=y+r;}}return S(u),h},toWireType:(u,d)=>{typeof d!="string"&&v(`Cannot pass non-string to C++ string type ${t}`);var f=l(d),h=De(4+f+r);return $[h>>2]=f>>s,a(d,h+4,f+r),u!==null&&u.push(S,h),h},argPackAdvance:k,readValueFromPointer:cr,destructorFunction(u){S(u);}});},qt=(e,r)=>{r=T(r),M(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&&v(r+" has unknown type "+ar(e)),t},Xt=(e,r)=>{e=Jt(e,"_emval_take_value");var t=e.readValueFromPointer(r);return me.toHandle(t)},Kt=()=>{Z("");},Qt=(e,r,t)=>w.copyWithin(e,r,r+t),Yt=()=>2147483648,Zt=e=>{var r=ce.buffer,t=(e-r.byteLength+65535)/65536;try{return ce.grow(t),We(),1}catch{}},en=e=>{var r=w.length;e>>>=0;var t=Yt();if(e>t)return !1;for(var n=(u,d)=>u+(d-u%d)%d,a=1;a<=4;a*=2){var o=r*(1+.2/a);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,a){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 a=0,o=0;o<t;o++){var l=$[r>>2],s=$[r+4>>2];r+=8;for(var u=0;u<s;u++)on(e,w[l+u]);a+=s;}return $[n>>2]=a,0};Jr(),G=i.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Je=i.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},st(),tt(),ht(),ir=i.UnboundTypeError=yt(Error,"UnboundTypeError"),Tt(),Ft();var un={b:Vr,n:Br,D:qr,E:Gr,w:Nr,q:Kr,H:bt,G:$t,e:Pt,F:Rt,o:Mt,f:kt,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:$n},g=zr(),S=e=>(S=g.K)(e),De=e=>(De=g.L)(e),fr=e=>(fr=g.M)(e);i.__embind_initialize_bindings=()=>(i.__embind_initialize_bindings=g.N)();var O=(e,r)=>(O=g.P)(e,r),I=()=>(I=g.Q)(),U=e=>(U=g.R)(e),vr=i.dynCall_viiij=(e,r,t,n,a,o)=>(vr=i.dynCall_viiij=g.S)(e,r,t,n,a,o);i.dynCall_jiji=(e,r,t,n,a)=>(i.dynCall_jiji=g.T)(e,r,t,n,a);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(a){if(U(n),a!==a+0)throw a;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 a=I();try{return D(e)(r,t,n)}catch(o){if(U(a),o!==o+0)throw o;O(1,0);}}function bn(e,r,t,n,a,o){var l=I();try{return D(e)(r,t,n,a,o)}catch(s){if(U(l),s!==s+0)throw s;O(1,0);}}function wn(e,r,t,n,a){var o=I();try{D(e)(r,t,n,a);}catch(l){if(U(o),l!==l+0)throw l;O(1,0);}}function $n(e,r,t,n,a,o){var l=I();try{vr(e,r,t,n,a,o);}catch(s){if(U(l),s!==s+0)throw s;O(1,0);}}var ge;Y=function e(){ge||hr(),ge||(Y=e);};function hr(){if(j>0||(Sr(),j>0))return;function e(){ge||(ge=!0,i.calledRun=!0,!Ie&&(kr(),C(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),Dr()));}i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("");},1),e();},1)):e();}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return hr(),c.ready}})(),wr=Pn;var x=class{constructor(){throw new Error("WasmLoader is a static class and cannot be instantiated.")}static async _tryLoad(c){return await wr({locateFile:()=>c})}static async _loadWithBackup(){return this._ModulePromise||(this._ModulePromise=this._tryLoad(this._wasmURL).catch(async c=>{let i=`https://cdn.jsdelivr.net/npm/${oe.name}@${oe.version}/dist/renderer.wasm`;console.warn(`Trying backup URL for WASM loading: ${i}`);try{return await this._tryLoad(i)}catch(C){throw console.error(`Both primary and backup WASM URLs failed. Primary error: ${c.message}, Backup error: ${C.message}`),new Error("WASM loading failed from all sources.")}})),this._ModulePromise}static async load(){return this._loadWithBackup()}static setWasmUrl(c){this._wasmURL=c,this._ModulePromise=null;}};a(x,"_ModulePromise",null),a(x,"_wasmURL",`https://unpkg.com/${oe.name}@${oe.version}/dist/renderer.wasm`);var be=1e3,$r=class{constructor(c$1){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,"_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=c$1.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=c$1.loop??!1,this._speed=c$1.speed??1,this._autoplay=c$1.autoplay??!1,this._mode=c$1.mode??"normal",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(i=>{this._renderer=new i.Renderer,c$1.src?this._loadAnimationFromURL(c$1.src):c$1.data&&this._initializeAnimationFromData(c$1.data);}).catch(i=>{this._eventManager.dispatch({type:"loadError",error:i});});}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(c){b(c).then(i=>{this._initializeAnimationFromData(i);}).catch(i=>{this._eventManager.dispatch({type:"loadError",error:i});});}_initializeAnimationFromData(c){let i=C=>{try{this._renderer?.load(C,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 c=="string"?i(c):c instanceof ArrayBuffer?a$2(c).then(i).catch(C=>{this._eventManager.dispatch({type:"loadError",error:C});}):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 c=this._renderer.render(),i=Uint8ClampedArray.from(c);if(i.length===0)return;let C=new ImageData(i,this._canvas.width,this._canvas.height);this._context.putImageData(C,0,0);}}_update(){if(this._duration===0)return !1;let i=(performance.now()/be-this._beginTime)*this._speed/this._duration*this._totalFrames;if(this._mode==="normal"?this._currentFrame=i:this._mode==="reverse"?this._currentFrame=this._totalFrames-i-1:this._mode==="bounce"?(this._direction===-1&&(i=this._totalFrames-i-1),this._currentFrame=i):(this._direction===-1&&(i=this._totalFrames-i-1),this._currentFrame=i,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()/be,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 c=this._canvas.getClientRects();if(!c.length)return;let i=c[0],C=window.devicePixelRatio||1,E=Math.round(i.width*C),X=Math.round(i.height*C),we=this._canvas.width,$e=this._canvas.height;E===we||X===$e||(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}let c=this._currentFrame/this._totalFrames;this._direction===-1?this._beginTime=performance.now()/be-this._duration*(1-c):this._beginTime=performance.now()/be-this._duration*c,this._playing||(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(c){if(c<=0){console.error("Speed must be a positive number.");return}this._speed=c;}setLoop(c){this._loop=c;}setFrame(c){if(c<0||c>=this._totalFrames){console.error(`Invalid frame number provided: ${c}. Valid range is between 0 and ${this._totalFrames-1}.`);return}this._currentFrame=c,this._renderer?.frame(this._currentFrame),this._render(),this._eventManager.dispatch({type:"frame",currentFrame:this._currentFrame});}load(c){this._playing=!1,this._stopAnimationLoop(),this._loop=c.loop??!1,this._speed=c.speed??1,this._autoplay=c.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=c.mode??"normal",c.src?this._loadAnimationFromURL(c.src):c.data&&this._initializeAnimationFromData(c.data);}addEventListener(c,i){this._eventManager.addEventListener(c,i);}removeEventListener(c,i){this._eventManager.removeEventListener(c,i);}static setWasmUrl(c){x.setWasmUrl(c);}destroy(){this._stopAnimationLoop(),this._eventManager.removeAllEventListeners(),this._canvasResizeObserver?.disconnect(),this._context=null,this._renderer=null;}};
|
|
7
|
+
|
|
8
|
+
export { x as a, $r as b };
|
|
9
|
+
//# sourceMappingURL=out.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-NIBIKWSN.js.map
|