@aarsteinmedia/dotlottie-player 2.2.7 → 2.2.9
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 +4 -2
- package/dist/cjs/index.js +29 -30
- package/dist/esm/index.js +29 -30
- package/dist/index.js +4 -4
- package/package.json +7 -7
- package/dist/custom-elements.json +0 -1278
package/README.md
CHANGED
|
@@ -286,13 +286,15 @@ The following events are exposed and can be listened to via `addEventListener` c
|
|
|
286
286
|
| `ready` | Animation is loaded and player is ready |
|
|
287
287
|
| `stop` | Animation has stopped |
|
|
288
288
|
|
|
289
|
-
## WordPress
|
|
289
|
+
## WordPress Plugins
|
|
290
290
|
<img align="left" width="110" height="110" src="/.github/wpIcon.svg" />
|
|
291
291
|
|
|
292
|
-
We've made a free WordPress plugin that works with Gutenberg Blocks, Elementor, Divi Builder and Flatsome UX Builder: [AM LottiePlayer](https://
|
|
292
|
+
We've made a free WordPress plugin that works with Gutenberg Blocks, Elementor, Divi Builder and Flatsome UX Builder: [AM LottiePlayer](https://www.aarstein.media/en/am-lottieplayer). It has all the functionality of this package, with a helpful user interface.
|
|
293
293
|
|
|
294
294
|
It's super lightweight – and only loads on pages where animations are used.
|
|
295
295
|
|
|
296
|
+
We've also made a premium WordPress plugin for purchase: [AM LottiePlayerPRO](https://www.aarstein.media/en/am-lottieplayer/pro). It has an easy-to-use GUI for combining and controlling multiple Lottie animations in a single file, converting JSON to dotLottie with drag-and-drop, and many more exclusive features.
|
|
297
|
+
|
|
296
298
|
## License
|
|
297
299
|
|
|
298
300
|
GPL-2.0-or-later
|
package/dist/cjs/index.js
CHANGED
|
@@ -138,9 +138,7 @@ const addExt = (ext, str)=>{
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
return res;
|
|
141
|
-
}, frameOutput = (frame)=>{
|
|
142
|
-
return ((frame ?? 0) + 1).toString().padStart(3, '0');
|
|
143
|
-
}, getAnimationData = async (input)=>{
|
|
141
|
+
}, frameOutput = (frame)=>((frame ?? 0) + 1).toString().padStart(3, '0'), getAnimationData = async (input)=>{
|
|
144
142
|
try {
|
|
145
143
|
if (!input || typeof input !== 'string' && typeof input !== 'object') {
|
|
146
144
|
throw new Error('Broken file or invalid file format');
|
|
@@ -255,15 +253,11 @@ const addExt = (ext, str)=>{
|
|
|
255
253
|
}, hasExt = (path)=>{
|
|
256
254
|
const lastDotIndex = path?.split('/').pop()?.lastIndexOf('.');
|
|
257
255
|
return (lastDotIndex ?? 0) > 1 && path && path.length - 1 > (lastDotIndex ?? 0);
|
|
258
|
-
}, isAudio = (asset)=>{
|
|
259
|
-
return !('h' in asset) && !('w' in asset) && 'p' in asset && 'e' in asset && 'u' in asset && 'id' in asset;
|
|
260
|
-
}, isImage = (asset)=>{
|
|
261
|
-
return 'w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset;
|
|
262
|
-
}, isServer = ()=>{
|
|
263
|
-
return !(typeof window !== 'undefined' && window.document);
|
|
264
|
-
}, strToU8 = (str)=>{
|
|
256
|
+
}, isAudio = (asset)=>!('h' in asset) && !('w' in asset) && 'p' in asset && 'e' in asset && 'u' in asset && 'id' in asset, isImage = (asset)=>'w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset, isServer = ()=>!(typeof window !== 'undefined' && window.document), strToU8 = (str)=>{
|
|
265
257
|
const u8 = new Uint8Array(str.length);
|
|
266
|
-
for(
|
|
258
|
+
for (const [i] of [
|
|
259
|
+
...Array(str.length)
|
|
260
|
+
].entries()){
|
|
267
261
|
u8[i] = str.charCodeAt(i);
|
|
268
262
|
}
|
|
269
263
|
return u8;
|
|
@@ -301,7 +295,7 @@ const addExt = (ext, str)=>{
|
|
|
301
295
|
};
|
|
302
296
|
|
|
303
297
|
var name = "@aarsteinmedia/dotlottie-player";
|
|
304
|
-
var version = "2.2.
|
|
298
|
+
var version = "2.2.9";
|
|
305
299
|
var description = "Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player";
|
|
306
300
|
var exports$1 = {
|
|
307
301
|
".": {
|
|
@@ -351,15 +345,15 @@ var peerDependencies = {
|
|
|
351
345
|
var devDependencies = {
|
|
352
346
|
"@custom-elements-manifest/analyzer": "^0.6.9",
|
|
353
347
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
354
|
-
"@rollup/plugin-json": "^6.0
|
|
348
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
355
349
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
356
350
|
"@rollup/plugin-replace": "^5.0.5",
|
|
357
|
-
"@swc/core": "^1.3.
|
|
358
|
-
"@types/node": "^20.10.
|
|
351
|
+
"@swc/core": "^1.3.101",
|
|
352
|
+
"@types/node": "^20.10.5",
|
|
359
353
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
360
354
|
"@typescript-eslint/parser": "^5.62.0",
|
|
361
|
-
eslint: "^8.
|
|
362
|
-
"eslint-plugin-lit": "^1.
|
|
355
|
+
eslint: "^8.56.0",
|
|
356
|
+
"eslint-plugin-lit": "^1.11.0",
|
|
363
357
|
rollup: "^3.29.4",
|
|
364
358
|
"rollup-plugin-dts": "^6.1.0",
|
|
365
359
|
"rollup-plugin-html-literals": "^1.1.8",
|
|
@@ -367,7 +361,7 @@ var devDependencies = {
|
|
|
367
361
|
"rollup-plugin-swc3": "^0.9.1",
|
|
368
362
|
shx: "^0.3.4",
|
|
369
363
|
"ts-lit-plugin": "^1.2.1",
|
|
370
|
-
typescript: "^5.3.
|
|
364
|
+
typescript: "^5.3.3"
|
|
371
365
|
};
|
|
372
366
|
var customElements = "dist/custom-elements.json";
|
|
373
367
|
var files = [
|
|
@@ -577,16 +571,18 @@ class DotLottiePlayer extends lit.LitElement {
|
|
|
577
571
|
this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Error));
|
|
578
572
|
});
|
|
579
573
|
if (this.container) {
|
|
580
|
-
this.container.addEventListener('mouseenter',
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
574
|
+
this.container.addEventListener('mouseenter', this._mouseEnter);
|
|
575
|
+
this.container.addEventListener('mouseleave', this._mouseLeave);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
_mouseEnter() {
|
|
579
|
+
if (this.hover && this.currentState !== exports.PlayerState.Playing) {
|
|
580
|
+
this.play();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
_mouseLeave() {
|
|
584
|
+
if (this.hover && this.currentState === exports.PlayerState.Playing) {
|
|
585
|
+
this.stop();
|
|
590
586
|
}
|
|
591
587
|
}
|
|
592
588
|
_onVisibilityChange() {
|
|
@@ -894,8 +890,8 @@ class DotLottiePlayer extends lit.LitElement {
|
|
|
894
890
|
render() {
|
|
895
891
|
return lit.html`<figure class="${'animation-container main'}" data-controls="${this.controls ?? lit.nothing}" lang="${this.description ? document?.documentElement?.lang : 'en'}" role="img" aria-label="${this.description ?? 'Lottie animation'}" data-loaded="${this._playerState.loaded}"><div class="animation" style="background:${this.background}">${this.currentState === exports.PlayerState.Error ? lit.html`<div class="error"><svg preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="1920" height="1080" viewBox="0 0 1920 1080"><path fill="#fff" d="M0 0h1920v1080H0z"/><path fill="#3a6d8b" d="M1190.2 531 1007 212.4c-22-38.2-77.2-38-98.8.5L729.5 531.3c-21.3 37.9 6.1 84.6 49.5 84.6l361.9.3c43.7 0 71.1-47.3 49.3-85.2zM937.3 288.7c.2-7.5 3.3-23.9 23.2-23.9 16.3 0 23 16.1 23 23.5 0 55.3-10.7 197.2-12.2 214.5-.1 1-.9 1.7-1.9 1.7h-18.3c-1 0-1.8-.7-1.9-1.7-1.4-17.5-13.4-162.9-11.9-214.1zm24.2 283.8c-13.1 0-23.7-10.6-23.7-23.7s10.6-23.7 23.7-23.7 23.7 10.6 23.7 23.7-10.6 23.7-23.7 23.7zM722.1 644h112.6v34.4h-70.4V698h58.8v31.7h-58.8v22.6h72.4v36.2H722.1V644zm162 57.1h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6zm78.9 0h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5H963v15.6zm39.5 36.2c0-31.3 22.2-54.8 56.6-54.8 34.4 0 56.2 23.5 56.2 54.8s-21.8 54.6-56.2 54.6c-34.4-.1-56.6-23.3-56.6-54.6zm74 0c0-17.4-6.1-29.1-17.8-29.1-11.7 0-17.4 11.7-17.4 29.1 0 17.4 5.7 29.1 17.4 29.1s17.8-11.8 17.8-29.1zm83.1-36.2h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6z"/><path fill="none" d="M718.9 807.7h645v285.4h-645z"/><text fill="#3a6d8b" style="text-align:center;position:absolute;left:100%;font-size:47px;font-family:system-ui,-apple-system,BlinkMacSystemFont,'.SFNSText-Regular',sans-serif" x="50%" y="848.017" text-anchor="middle">${this._errorMessage}</text></svg></div>` : lit.nothing}</div>${this.controls ? this.renderControls() : lit.nothing}</figure>`;
|
|
896
892
|
}
|
|
897
|
-
constructor(
|
|
898
|
-
super(
|
|
893
|
+
constructor(){
|
|
894
|
+
super();
|
|
899
895
|
this.background = 'transparent';
|
|
900
896
|
this.controls = false;
|
|
901
897
|
this.currentState = exports.PlayerState.Loading;
|
|
@@ -928,6 +924,9 @@ class DotLottiePlayer extends lit.LitElement {
|
|
|
928
924
|
target.focus();
|
|
929
925
|
}
|
|
930
926
|
};
|
|
927
|
+
this._onVisibilityChange = this._onVisibilityChange.bind(this);
|
|
928
|
+
this._mouseEnter = this._mouseEnter.bind(this);
|
|
929
|
+
this._mouseLeave = this._mouseLeave.bind(this);
|
|
931
930
|
}
|
|
932
931
|
}
|
|
933
932
|
_ts_decorate([
|
package/dist/esm/index.js
CHANGED
|
@@ -136,9 +136,7 @@ const addExt = (ext, str)=>{
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
return res;
|
|
139
|
-
}, frameOutput = (frame)=>{
|
|
140
|
-
return ((frame ?? 0) + 1).toString().padStart(3, '0');
|
|
141
|
-
}, getAnimationData = async (input)=>{
|
|
139
|
+
}, frameOutput = (frame)=>((frame ?? 0) + 1).toString().padStart(3, '0'), getAnimationData = async (input)=>{
|
|
142
140
|
try {
|
|
143
141
|
if (!input || typeof input !== 'string' && typeof input !== 'object') {
|
|
144
142
|
throw new Error('Broken file or invalid file format');
|
|
@@ -253,15 +251,11 @@ const addExt = (ext, str)=>{
|
|
|
253
251
|
}, hasExt = (path)=>{
|
|
254
252
|
const lastDotIndex = path?.split('/').pop()?.lastIndexOf('.');
|
|
255
253
|
return (lastDotIndex ?? 0) > 1 && path && path.length - 1 > (lastDotIndex ?? 0);
|
|
256
|
-
}, isAudio = (asset)=>{
|
|
257
|
-
return !('h' in asset) && !('w' in asset) && 'p' in asset && 'e' in asset && 'u' in asset && 'id' in asset;
|
|
258
|
-
}, isImage = (asset)=>{
|
|
259
|
-
return 'w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset;
|
|
260
|
-
}, isServer = ()=>{
|
|
261
|
-
return !(typeof window !== 'undefined' && window.document);
|
|
262
|
-
}, strToU8 = (str)=>{
|
|
254
|
+
}, isAudio = (asset)=>!('h' in asset) && !('w' in asset) && 'p' in asset && 'e' in asset && 'u' in asset && 'id' in asset, isImage = (asset)=>'w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset, isServer = ()=>!(typeof window !== 'undefined' && window.document), strToU8 = (str)=>{
|
|
263
255
|
const u8 = new Uint8Array(str.length);
|
|
264
|
-
for(
|
|
256
|
+
for (const [i] of [
|
|
257
|
+
...Array(str.length)
|
|
258
|
+
].entries()){
|
|
265
259
|
u8[i] = str.charCodeAt(i);
|
|
266
260
|
}
|
|
267
261
|
return u8;
|
|
@@ -299,7 +293,7 @@ const addExt = (ext, str)=>{
|
|
|
299
293
|
};
|
|
300
294
|
|
|
301
295
|
var name = "@aarsteinmedia/dotlottie-player";
|
|
302
|
-
var version = "2.2.
|
|
296
|
+
var version = "2.2.9";
|
|
303
297
|
var description = "Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player";
|
|
304
298
|
var exports = {
|
|
305
299
|
".": {
|
|
@@ -349,15 +343,15 @@ var peerDependencies = {
|
|
|
349
343
|
var devDependencies = {
|
|
350
344
|
"@custom-elements-manifest/analyzer": "^0.6.9",
|
|
351
345
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
352
|
-
"@rollup/plugin-json": "^6.0
|
|
346
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
353
347
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
354
348
|
"@rollup/plugin-replace": "^5.0.5",
|
|
355
|
-
"@swc/core": "^1.3.
|
|
356
|
-
"@types/node": "^20.10.
|
|
349
|
+
"@swc/core": "^1.3.101",
|
|
350
|
+
"@types/node": "^20.10.5",
|
|
357
351
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
358
352
|
"@typescript-eslint/parser": "^5.62.0",
|
|
359
|
-
eslint: "^8.
|
|
360
|
-
"eslint-plugin-lit": "^1.
|
|
353
|
+
eslint: "^8.56.0",
|
|
354
|
+
"eslint-plugin-lit": "^1.11.0",
|
|
361
355
|
rollup: "^3.29.4",
|
|
362
356
|
"rollup-plugin-dts": "^6.1.0",
|
|
363
357
|
"rollup-plugin-html-literals": "^1.1.8",
|
|
@@ -365,7 +359,7 @@ var devDependencies = {
|
|
|
365
359
|
"rollup-plugin-swc3": "^0.9.1",
|
|
366
360
|
shx: "^0.3.4",
|
|
367
361
|
"ts-lit-plugin": "^1.2.1",
|
|
368
|
-
typescript: "^5.3.
|
|
362
|
+
typescript: "^5.3.3"
|
|
369
363
|
};
|
|
370
364
|
var customElements = "dist/custom-elements.json";
|
|
371
365
|
var files = [
|
|
@@ -575,16 +569,18 @@ class DotLottiePlayer extends LitElement {
|
|
|
575
569
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
|
|
576
570
|
});
|
|
577
571
|
if (this.container) {
|
|
578
|
-
this.container.addEventListener('mouseenter',
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
572
|
+
this.container.addEventListener('mouseenter', this._mouseEnter);
|
|
573
|
+
this.container.addEventListener('mouseleave', this._mouseLeave);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
_mouseEnter() {
|
|
577
|
+
if (this.hover && this.currentState !== PlayerState.Playing) {
|
|
578
|
+
this.play();
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
_mouseLeave() {
|
|
582
|
+
if (this.hover && this.currentState === PlayerState.Playing) {
|
|
583
|
+
this.stop();
|
|
588
584
|
}
|
|
589
585
|
}
|
|
590
586
|
_onVisibilityChange() {
|
|
@@ -892,8 +888,8 @@ class DotLottiePlayer extends LitElement {
|
|
|
892
888
|
render() {
|
|
893
889
|
return html`<figure class="${'animation-container main'}" data-controls="${this.controls ?? nothing}" lang="${this.description ? document?.documentElement?.lang : 'en'}" role="img" aria-label="${this.description ?? 'Lottie animation'}" data-loaded="${this._playerState.loaded}"><div class="animation" style="background:${this.background}">${this.currentState === PlayerState.Error ? html`<div class="error"><svg preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="1920" height="1080" viewBox="0 0 1920 1080"><path fill="#fff" d="M0 0h1920v1080H0z"/><path fill="#3a6d8b" d="M1190.2 531 1007 212.4c-22-38.2-77.2-38-98.8.5L729.5 531.3c-21.3 37.9 6.1 84.6 49.5 84.6l361.9.3c43.7 0 71.1-47.3 49.3-85.2zM937.3 288.7c.2-7.5 3.3-23.9 23.2-23.9 16.3 0 23 16.1 23 23.5 0 55.3-10.7 197.2-12.2 214.5-.1 1-.9 1.7-1.9 1.7h-18.3c-1 0-1.8-.7-1.9-1.7-1.4-17.5-13.4-162.9-11.9-214.1zm24.2 283.8c-13.1 0-23.7-10.6-23.7-23.7s10.6-23.7 23.7-23.7 23.7 10.6 23.7 23.7-10.6 23.7-23.7 23.7zM722.1 644h112.6v34.4h-70.4V698h58.8v31.7h-58.8v22.6h72.4v36.2H722.1V644zm162 57.1h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6zm78.9 0h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5H963v15.6zm39.5 36.2c0-31.3 22.2-54.8 56.6-54.8 34.4 0 56.2 23.5 56.2 54.8s-21.8 54.6-56.2 54.6c-34.4-.1-56.6-23.3-56.6-54.6zm74 0c0-17.4-6.1-29.1-17.8-29.1-11.7 0-17.4 11.7-17.4 29.1 0 17.4 5.7 29.1 17.4 29.1s17.8-11.8 17.8-29.1zm83.1-36.2h.6c8.3-12.9 18.2-17.8 31.3-17.8 3 0 5.1.4 6.3 1v32.6h-.8c-22.4-3.8-35.6 6.3-35.6 29.5v42.3h-38.2V685.5h36.4v15.6z"/><path fill="none" d="M718.9 807.7h645v285.4h-645z"/><text fill="#3a6d8b" style="text-align:center;position:absolute;left:100%;font-size:47px;font-family:system-ui,-apple-system,BlinkMacSystemFont,'.SFNSText-Regular',sans-serif" x="50%" y="848.017" text-anchor="middle">${this._errorMessage}</text></svg></div>` : nothing}</div>${this.controls ? this.renderControls() : nothing}</figure>`;
|
|
894
890
|
}
|
|
895
|
-
constructor(
|
|
896
|
-
super(
|
|
891
|
+
constructor(){
|
|
892
|
+
super();
|
|
897
893
|
this.background = 'transparent';
|
|
898
894
|
this.controls = false;
|
|
899
895
|
this.currentState = PlayerState.Loading;
|
|
@@ -926,6 +922,9 @@ class DotLottiePlayer extends LitElement {
|
|
|
926
922
|
target.focus();
|
|
927
923
|
}
|
|
928
924
|
};
|
|
925
|
+
this._onVisibilityChange = this._onVisibilityChange.bind(this);
|
|
926
|
+
this._mouseEnter = this._mouseEnter.bind(this);
|
|
927
|
+
this._mouseLeave = this._mouseLeave.bind(this);
|
|
929
928
|
}
|
|
930
929
|
}
|
|
931
930
|
_ts_decorate([
|