@lottiefiles/dotlottie-web 0.41.0-pre.1 → 0.41.0-pre.2
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/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/webgl/index.cjs +1 -1
- package/dist/webgl/index.cjs.map +1 -1
- package/dist/webgl/index.js +1 -1
- package/dist/webgl/index.js.map +1 -1
- package/dist/webgpu/index.cjs +2 -2
- package/dist/webgpu/index.cjs.map +1 -1
- package/dist/webgpu/index.js +2 -2
- package/dist/webgpu/index.js.map +1 -1
- package/package.json +1 -1
package/dist/webgl/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var lo=Object.defineProperty,uo=Object.defineProperties;var co=Object.getOwnPropertyDescriptors;var Ke=Object.getOwnPropertySymbols;var _n=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable;var Lt=(m,o,d)=>o in m?lo(m,o,{enumerable:true,configurable:true,writable:true,value:d}):m[o]=d,W=(m,o)=>{for(var d in o||(o={}))_n.call(o,d)&&Lt(m,d,o[d]);if(Ke)for(var d of Ke(o))yn.call(o,d)&&Lt(m,d,o[d]);return m},G=(m,o)=>uo(m,co(o));var gn=(m,o)=>{var d={};for(var c in m)_n.call(m,c)&&o.indexOf(c)<0&&(d[c]=m[c]);if(m!=null&&Ke)for(var c of Ke(m))o.indexOf(c)<0&&yn.call(m,c)&&(d[c]=m[c]);return d};var b=(m,o,d)=>Lt(m,typeof o!="symbol"?o+"":o,d);var fe=(m,o,d)=>new Promise((c,s)=>{var L=j=>{try{M(d.next(j));}catch(z){s(z);}},F=j=>{try{M(d.throw(j));}catch(z){s(z);}},M=j=>j.done?c(j.value):Promise.resolve(j.value).then(L,F);M((d=d.apply(m,o)).next());});var xt=class{requestAnimationFrame(o){return requestAnimationFrame(o)}cancelAnimationFrame(o){cancelAnimationFrame(o);}},Mt=class{constructor(){b(this,"_lastHandleId",0);b(this,"_lastImmediate",null);}requestAnimationFrame(o){return this._lastHandleId>=Number.MAX_SAFE_INTEGER&&(this._lastHandleId=0),this._lastHandleId+=1,this._lastImmediate=setImmediate(()=>{o(Date.now());}),this._lastHandleId}cancelAnimationFrame(o){this._lastImmediate&&clearImmediate(this._lastImmediate);}},Ye=class{constructor(){b(this,"_strategy");this._strategy=typeof requestAnimationFrame=="function"?new xt:new Mt;}requestAnimationFrame(o){return this._strategy.requestAnimationFrame(o)}cancelAnimationFrame(o){this._strategy.cancelAnimationFrame(o);}};var V=typeof window!="undefined"&&typeof window.document!="undefined";var Ze=new Uint8Array([80,75,3,4]),Cn=["v","ip","op","layers","fr","w","h"],Tt="0.41.0-pre.
|
|
1
|
+
var lo=Object.defineProperty,uo=Object.defineProperties;var co=Object.getOwnPropertyDescriptors;var Ke=Object.getOwnPropertySymbols;var _n=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable;var Lt=(m,o,d)=>o in m?lo(m,o,{enumerable:true,configurable:true,writable:true,value:d}):m[o]=d,W=(m,o)=>{for(var d in o||(o={}))_n.call(o,d)&&Lt(m,d,o[d]);if(Ke)for(var d of Ke(o))yn.call(o,d)&&Lt(m,d,o[d]);return m},G=(m,o)=>uo(m,co(o));var gn=(m,o)=>{var d={};for(var c in m)_n.call(m,c)&&o.indexOf(c)<0&&(d[c]=m[c]);if(m!=null&&Ke)for(var c of Ke(m))o.indexOf(c)<0&&yn.call(m,c)&&(d[c]=m[c]);return d};var b=(m,o,d)=>Lt(m,typeof o!="symbol"?o+"":o,d);var fe=(m,o,d)=>new Promise((c,s)=>{var L=j=>{try{M(d.next(j));}catch(z){s(z);}},F=j=>{try{M(d.throw(j));}catch(z){s(z);}},M=j=>j.done?c(j.value):Promise.resolve(j.value).then(L,F);M((d=d.apply(m,o)).next());});var xt=class{requestAnimationFrame(o){return requestAnimationFrame(o)}cancelAnimationFrame(o){cancelAnimationFrame(o);}},Mt=class{constructor(){b(this,"_lastHandleId",0);b(this,"_lastImmediate",null);}requestAnimationFrame(o){return this._lastHandleId>=Number.MAX_SAFE_INTEGER&&(this._lastHandleId=0),this._lastHandleId+=1,this._lastImmediate=setImmediate(()=>{o(Date.now());}),this._lastHandleId}cancelAnimationFrame(o){this._lastImmediate&&clearImmediate(this._lastImmediate);}},Ye=class{constructor(){b(this,"_strategy");this._strategy=typeof requestAnimationFrame=="function"?new xt:new Mt;}requestAnimationFrame(o){return this._strategy.requestAnimationFrame(o)}cancelAnimationFrame(o){this._strategy.cancelAnimationFrame(o);}};var V=typeof window!="undefined"&&typeof window.document!="undefined";var Ze=new Uint8Array([80,75,3,4]),Cn=["v","ip","op","layers","fr","w","h"],Tt="0.41.0-pre.2",At="@lottiefiles/dotlottie-web",wn=.75;var Qe=class{constructor(){b(this,"_eventListeners",new Map);}addEventListener(o,d){let c=this._eventListeners.get(o);c||(c=new Set,this._eventListeners.set(o,c)),c.add(d);}removeEventListener(o,d){let c=this._eventListeners.get(o);c&&(d?(c.delete(d),c.size===0&&this._eventListeners.delete(o)):this._eventListeners.delete(o));}dispatch(o){let d=this._eventListeners.get(o.type);d==null||d.forEach(c=>c(o));}removeAllEventListeners(){this._eventListeners.clear();}};var te=class{static _initializeObserver(){if(this._observer)return;let o=d=>{d.forEach(c=>{let s=this._observedCanvases.get(c.target);s&&(c.isIntersecting?s.unfreeze():s.freeze());});};this._observer=new IntersectionObserver(o,{threshold:0});}static observe(o,d){var c;this._initializeObserver(),!this._observedCanvases.has(o)&&(this._observedCanvases.set(o,d),(c=this._observer)==null||c.observe(o));}static unobserve(o){var d,c;(d=this._observer)==null||d.unobserve(o),this._observedCanvases.delete(o),this._observedCanvases.size===0&&((c=this._observer)==null||c.disconnect(),this._observer=null);}};b(te,"_observer",null),b(te,"_observedCanvases",new Map);var re=class{static _initializeObserver(){if(this._observer)return;let o=d=>{d.forEach(c=>{let s=this._observedCanvases.get(c.target);if(!s)return;let[L,F]=s;clearTimeout(F);let M=setTimeout(()=>{L.resize();},100);this._observedCanvases.set(c.target,[L,M]);});};this._observer=new ResizeObserver(o);}static observe(o,d){var c;this._initializeObserver(),!this._observedCanvases.has(o)&&(this._observedCanvases.set(o,[d,0]),(c=this._observer)==null||c.observe(o));}static unobserve(o){var d,c;(d=this._observer)==null||d.unobserve(o),this._observedCanvases.delete(o),this._observedCanvases.size===0&&((c=this._observer)==null||c.disconnect(),this._observer=null);}};b(re,"_observer",null),b(re,"_observedCanvases",new Map);function fo(m){return /^#([\da-f]{6}|[\da-f]{8})$/iu.test(m)}function bn(m){if(!fo(m))return 0;let o=m.replace("#","");return o=o.length===6?`${o}ff`:o,parseInt(o,16)}function Pt(m){if(m.byteLength<4)return false;let o=new Uint8Array(m.slice(0,Ze.byteLength));for(let d=0;d<Ze.length;d+=1)if(Ze[d]!==o[d])return false;return true}function En(m){return Cn.every(o=>Object.prototype.hasOwnProperty.call(m,o))}function Ft(m){if(typeof m=="string")try{return En(JSON.parse(m))}catch(o){return false}else return En(m)}function jt(){return 1+((V?window.devicePixelRatio:1)-1)*wn}function Ln(m){let o=m.getBoundingClientRect();return o.top>=0&&o.left>=0&&o.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&o.right<=(window.innerWidth||document.documentElement.clientWidth)}var St=(m,o)=>m==="reverse"?o.Mode.Reverse:m==="bounce"?o.Mode.Bounce:m==="reverse-bounce"?o.Mode.ReverseBounce:o.Mode.Forward,It=(m,o)=>m==="contain"?o.Fit.Contain:m==="cover"?o.Fit.Cover:m==="fill"?o.Fit.Fill:m==="fit-height"?o.Fit.FitHeight:m==="fit-width"?o.Fit.FitWidth:o.Fit.None,Rt=(m,o)=>{let d=new o.VectorFloat;return d.push_back(m[0]),d.push_back(m[1]),d},Ot=(m,o)=>{let d=new o.VectorFloat;return m.length!==2||(d.push_back(m[0]),d.push_back(m[1])),d},ye=m=>typeof HTMLCanvasElement!="undefined"&&m instanceof HTMLCanvasElement,xn=0,qe=class{constructor(o,d,c="sw"){b(this,"_canvas");b(this,"_context",null);b(this,"_eventManager");b(this,"_animationFrameId",null);b(this,"_frameManager");b(this,"_dotLottieCore",null);b(this,"_wasmModule",null);b(this,"_renderConfig",{});b(this,"_isFrozen",false);b(this,"_backgroundColor",null);b(this,"_pointerUpMethod");b(this,"_pointerDownMethod");b(this,"_pointerMoveMethod");b(this,"_pointerEnterMethod");b(this,"_pointerExitMethod");b(this,"_wasmLoader");b(this,"_renderer");var s,L,F;this._canvas=o.canvas,this._wasmLoader=d,this._renderer=c,this._eventManager=new Qe,this._frameManager=new Ye,this._renderConfig=G(W({},o.renderConfig),{devicePixelRatio:((s=o.renderConfig)==null?void 0:s.devicePixelRatio)||jt(),freezeOnOffscreen:(F=(L=o.renderConfig)==null?void 0:L.freezeOnOffscreen)!=null?F:true}),this._wasmLoader.load().then(M=>{var k,ge,Oe,X,ae,se,ne,ve;this._wasmModule=M;let j=null;this._renderer==="wg"?j=M.TvgEngine.TvgEngineWg:this._renderer==="gl"?j=M.TvgEngine.TvgEngineGl:j=M.TvgEngine.TvgEngineSw;let z="";ye(this._canvas)&&(this._canvas.id?z=`#${this._canvas.id}`:this._renderer!=="sw"&&(this._canvas.getAttribute("data-dl-id")||(this._canvas.setAttribute("data-dl-id",`${xn}`),xn+=1),z=`[data-dl-id="${this._canvas.getAttribute("data-dl-id")}"]`)),this._dotLottieCore=new M.DotLottiePlayer(G(W({},M.createDefaultConfig()),{themeId:(k=o.themeId)!=null?k:"",autoplay:(ge=o.autoplay)!=null?ge:false,loopAnimation:(Oe=o.loop)!=null?Oe:false,mode:St((X=o.mode)!=null?X:"forward",M),segment:Ot((ae=o.segment)!=null?ae:[],M),speed:(se=o.speed)!=null?se:1,useFrameInterpolation:(ne=o.useFrameInterpolation)!=null?ne:true,marker:(ve=o.marker)!=null?ve:"",layout:o.layout?{align:Rt(o.layout.align,M),fit:It(o.layout.fit,M)}:M.createDefaultLayout()}),j,0,z),this._eventManager.dispatch({type:"ready"}),o.data?this._loadFromData(o.data):o.src&&this._loadFromSrc(o.src),o.backgroundColor&&this.setBackgroundColor(o.backgroundColor);}).catch(M=>{console.error("error",M),this._eventManager.dispatch({type:"loadError",error:new Error(`Failed to load wasm module: ${M}`)});}),this._pointerUpMethod=this._onPointerUp.bind(this),this._pointerDownMethod=this._onPointerDown.bind(this),this._pointerMoveMethod=this._onPointerMove.bind(this),this._pointerEnterMethod=this._onPointerEnter.bind(this),this._pointerExitMethod=this._onPointerLeave.bind(this);}_dispatchError(o){console.error(o),this._eventManager.dispatch({type:"loadError",error:new Error(o)});}_fetchData(o){return fe(this,null,function*(){let d=yield fetch(o);if(!d.ok)throw new Error(`Failed to fetch animation data from URL: ${o}. ${d.status}: ${d.statusText}`);let c=yield d.arrayBuffer();return Pt(c)?c:new TextDecoder().decode(c)})}_loadFromData(o){if(this._dotLottieCore===null)return;let d=this._canvas.width,c=this._canvas.height,s=false;if(typeof o=="string"){if(!Ft(o)){this._dispatchError("Invalid Lottie JSON string: The provided string does not conform to the Lottie JSON format.");return}s=this._dotLottieCore.loadAnimationData(o,d,c);}else if(o instanceof ArrayBuffer){if(!Pt(o)){this._dispatchError("Invalid dotLottie ArrayBuffer: The provided ArrayBuffer does not conform to the dotLottie format.");return}s=this._dotLottieCore.loadDotLottieData(o,d,c);}else if(typeof o=="object"){if(!Ft(o)){this._dispatchError("Invalid Lottie JSON object: The provided object does not conform to the Lottie JSON format.");return}s=this._dotLottieCore.loadAnimationData(JSON.stringify(o),d,c);}else {this._dispatchError(`Unsupported data type for animation data. Expected:
|
|
2
2
|
- string (Lottie JSON),
|
|
3
3
|
- ArrayBuffer (dotLottie),
|
|
4
4
|
- object (Lottie JSON).
|