@aarsteinmedia/dotlottie-player 6.3.6 → 6.3.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.
@@ -13,36 +13,44 @@
13
13
  "members": [
14
14
  {
15
15
  "kind": "method",
16
- "name": "loadAnimation",
16
+ "name": "addAnimation",
17
17
  "parameters": [
18
18
  {
19
- "name": "config"
19
+ "name": "params"
20
20
  }
21
21
  ]
22
22
  },
23
23
  {
24
24
  "kind": "method",
25
- "name": "setOptions",
25
+ "name": "convert",
26
26
  "parameters": [
27
27
  {
28
- "name": "{ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }"
28
+ "name": "params"
29
29
  }
30
30
  ]
31
31
  },
32
32
  {
33
- "kind": "field",
34
- "name": "addAnimation",
35
- "default": "addAnimation"
33
+ "kind": "method",
34
+ "name": "loadAnimation",
35
+ "parameters": [
36
+ {
37
+ "name": "config"
38
+ }
39
+ ]
36
40
  },
37
41
  {
38
- "kind": "field",
39
- "name": "convert",
40
- "default": "convert"
42
+ "kind": "method",
43
+ "name": "setOptions",
44
+ "parameters": [
45
+ {
46
+ "name": "{ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }"
47
+ }
48
+ ]
41
49
  }
42
50
  ],
43
51
  "superclass": {
44
52
  "name": "DotLottiePlayerBase",
45
- "module": "/dist/chunks/DotLottiePlayerBase-BBHa6yP8.js"
53
+ "module": "/dist/chunks/DotLottiePlayerBase-B4yJibwF.js"
46
54
  },
47
55
  "tagName": "tagName",
48
56
  "customElement": true
@@ -59,9 +67,9 @@
59
67
  },
60
68
  {
61
69
  "kind": "js",
62
- "name": "PlayerEvents",
70
+ "name": "PlayerEvent",
63
71
  "declaration": {
64
- "name": "PlayerEvents",
72
+ "name": "PlayerEvent",
65
73
  "package": "@aarsteinmedia/lottie-web/utils"
66
74
  }
67
75
  },
@@ -78,7 +86,7 @@
78
86
  "name": "MouseOut",
79
87
  "declaration": {
80
88
  "name": "M",
81
- "module": "./chunks/DotLottiePlayerBase-BBHa6yP8.js"
89
+ "module": "./chunks/DotLottiePlayerBase-B4yJibwF.js"
82
90
  }
83
91
  },
84
92
  {
@@ -86,7 +94,7 @@
86
94
  "name": "PlayerState",
87
95
  "declaration": {
88
96
  "name": "P",
89
- "module": "./chunks/DotLottiePlayerBase-BBHa6yP8.js"
97
+ "module": "./chunks/DotLottiePlayerBase-B4yJibwF.js"
90
98
  }
91
99
  },
92
100
  {
package/dist/canvas.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { RendererType, PreserveAspectRatio } from '@aarsteinmedia/lottie-web/utils';
2
- export { PlayMode, PlayerEvents, RendererType } from '@aarsteinmedia/lottie-web/utils';
2
+ export { PlayMode, PlayerEvent, RendererType } from '@aarsteinmedia/lottie-web/utils';
3
3
  import * as _aarsteinmedia_lottie_web from '@aarsteinmedia/lottie-web';
4
4
  import { AnimationConfiguration, Vector2 } from '@aarsteinmedia/lottie-web';
5
- import { D as DotLottiePlayerBase } from './chunks/DotLottiePlayerBase.d-BSagzEPB.js';
6
- export { M as MouseOut, P as PlayerState, t as tagName } from './chunks/DotLottiePlayerBase.d-BSagzEPB.js';
5
+ import { D as DotLottiePlayerBase } from './chunks/DotLottiePlayerBase.d-DaXI0b6M.js';
6
+ export { M as MouseOut, P as PlayerState, t as tagName } from './chunks/DotLottiePlayerBase.d-DaXI0b6M.js';
7
7
 
8
8
  declare class DotLottiePlayerCanvas extends DotLottiePlayerBase {
9
9
  get renderer(): RendererType;
package/dist/canvas.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { RendererType, isServer } from '@aarsteinmedia/lottie-web/utils';
2
- export { PlayMode, PlayerEvents, RendererType } from '@aarsteinmedia/lottie-web/utils';
2
+ export { PlayMode, PlayerEvent, RendererType } from '@aarsteinmedia/lottie-web/utils';
3
3
  import Lottie from '@aarsteinmedia/lottie-web/canvas';
4
- import { D as DotLottiePlayerBase, t as tagName } from './chunks/DotLottiePlayerBase-BBHa6yP8.js';
5
- export { M as MouseOut, P as PlayerState } from './chunks/DotLottiePlayerBase-BBHa6yP8.js';
4
+ import { D as DotLottiePlayerBase, t as tagName } from './chunks/DotLottiePlayerBase-B4yJibwF.js';
5
+ export { M as MouseOut, P as PlayerState } from './chunks/DotLottiePlayerBase-B4yJibwF.js';
6
6
  import '@aarsteinmedia/lottie-web/dotlottie';
7
7
 
8
8
  /**
@@ -1,5 +1,11 @@
1
- import { convert, getAnimationData } from '@aarsteinmedia/lottie-web/dotlottie';
2
- import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename, clamp } from '@aarsteinmedia/lottie-web/utils';
1
+ import { getAnimationData } from '@aarsteinmedia/lottie-web/dotlottie';
2
+ import { isServer, PlayMode, PreserveAspectRatio, RendererType, createElementID, PlayerEvent, download, getFilename, clamp } from '@aarsteinmedia/lottie-web/utils';
3
+
4
+ let modulePromise$1;
5
+ function loadControlsModule() {
6
+ modulePromise$1 = modulePromise$1 ?? Promise.resolve().then(function () { return controls; });
7
+ return modulePromise$1;
8
+ }
3
9
 
4
10
  /**
5
11
  * Credit to: Leonardo Favre https://github.com/leofavre/observed-properties.
@@ -61,6 +67,25 @@ if (isServer) {
61
67
 
62
68
  var css_248z = "* {\n box-sizing: border-box;\n}\n\n:host {\n --lottie-player-toolbar-height: 35px;\n --lottie-player-toolbar-background-color: #fff;\n --lottie-player-toolbar-icon-color: #000;\n --lottie-player-toolbar-icon-hover-color: #000;\n --lottie-player-toolbar-icon-active-color: #4285f4;\n --lottie-player-seeker-track-color: rgb(0 0 0 / 20%);\n --lottie-player-seeker-thumb-color: #4285f4;\n --lottie-player-seeker-display: block;\n\n width: 100%;\n height: 100%;\n\n &:not([hidden]) {\n display: block;\n }\n\n .main {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n margin: 0;\n padding: 0;\n }\n\n .animation {\n width: 100%;\n height: 100%;\n display: flex;\n margin: 0;\n padding: 0;\n }\n\n [data-controls='true'] .animation {\n height: calc(100% - 35px);\n }\n\n .animation-container {\n position: relative;\n }\n\n .popover {\n position: absolute;\n right: 5px;\n bottom: 40px;\n background-color: var(--lottie-player-toolbar-background-color);\n border-radius: 5px;\n padding: 10px 15px;\n border: solid 2px var(--lottie-player-toolbar-icon-color);\n animation: fade-in 0.2s ease-in-out;\n\n &::before {\n content: '';\n right: 10px;\n border: 7px solid transparent;\n margin-right: -7px;\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n top: 100%;\n border-top-color: var(--lottie-player-toolbar-icon-color);\n }\n }\n\n .error {\n display: flex;\n margin: auto;\n justify-content: center;\n height: 100%;\n align-items: center;\n\n & svg {\n width: 100%;\n height: auto;\n }\n }\n\n .toolbar {\n display: flex;\n place-items: center center;\n background: var(--lottie-player-toolbar-background-color);\n margin: 0;\n height: 35px;\n padding: 5px;\n border-radius: 5px;\n gap: 5px;\n\n &.has-error {\n pointer-events: none;\n opacity: 0.5;\n }\n\n & button {\n cursor: pointer;\n fill: var(--lottie-player-toolbar-icon-color);\n color: var(--lottie-player-toolbar-icon-color);\n background: none;\n border: 0;\n padding: 0;\n outline: 0;\n height: 100%;\n margin: 0;\n align-items: center;\n gap: 5px;\n opacity: 0.9;\n\n &:not([hidden]) {\n display: flex;\n }\n\n &:hover {\n opacity: 1;\n }\n\n &[data-active='true'] {\n opacity: 1;\n fill: var(--lottie-player-toolbar-icon-active-color);\n }\n\n &:disabled {\n opacity: 0.5;\n }\n\n &:focus {\n outline: 0;\n }\n\n & svg {\n pointer-events: none;\n\n & > * {\n fill: inherit;\n }\n }\n\n &.disabled svg {\n display: none;\n }\n }\n }\n\n .progress-container {\n position: relative;\n width: 100%;\n\n &.simple {\n margin-right: 12px;\n }\n }\n\n & progress {\n appearance: none;\n outline: none;\n position: absolute;\n width: 100%;\n height: 5px;\n border-radius: 3px;\n border: 0;\n top: 0;\n left: 0;\n margin: 7.5px 0;\n background-color: var(--lottie-player-seeker-track-color);\n pointer-events: none;\n\n &::-webkit-progress-inner-element {\n border-radius: 3px;\n overflow: hidden;\n }\n\n &::-webkit-slider-runnable-track {\n background-color: transparent;\n }\n\n &::-webkit-progress-value {\n background-color: var(--lottie-player-seeker-thumb-color);\n }\n }\n\n .seeker {\n appearance: none;\n outline: none;\n width: 100%;\n height: 20px;\n border-radius: 3px;\n border: 0;\n cursor: pointer;\n background-color: transparent;\n\n display: var(--lottie-player-seeker-display);\n color: var(--lottie-player-seeker-thumb-color);\n margin: 0;\n padding: 7.5px 0;\n position: relative;\n z-index: 1;\n\n &::-webkit-slider-runnable-track,\n &::-webkit-slider-thumb {\n appearance: none;\n outline: none;\n }\n\n &::-webkit-slider-thumb {\n height: 15px;\n width: 15px;\n border-radius: 50%;\n border: 0;\n background-color: var(--lottie-player-seeker-thumb-color);\n cursor: pointer;\n -webkit-transition: transform 0.2s ease-in-out;\n transition: transform 0.2s ease-in-out;\n transform: scale(0);\n }\n\n &:hover::-webkit-slider-thumb,\n &:focus::-webkit-slider-thumb {\n transform: scale(1);\n }\n\n &::-moz-range-progress {\n background-color: var(--lottie-player-seeker-thumb-color);\n height: 5px;\n border-radius: 3px;\n }\n\n &::-moz-range-thumb {\n height: 15px;\n width: 15px;\n border-radius: 50%;\n background-color: var(--lottie-player-seeker-thumb-color);\n border: 0;\n cursor: pointer;\n -moz-transition: transform 0.2s ease-in-out;\n transition: transform 0.2s ease-in-out;\n transform: scale(0);\n }\n\n &:hover::-moz-range-thumb,\n &:focus::-moz-range-thumb {\n transform: scale(1);\n }\n\n &::-ms-track {\n width: 100%;\n height: 5px;\n cursor: pointer;\n background: transparent;\n border-color: transparent;\n color: transparent;\n }\n\n &::-ms-fill-upper {\n background: var(--lottie-player-seeker-track-color);\n border-radius: 3px;\n }\n\n &::-ms-fill-lower {\n background-color: var(--lottie-player-seeker-thumb-color);\n border-radius: 3px;\n }\n\n &::-ms-thumb {\n border: 0;\n height: 15px;\n width: 15px;\n border-radius: 50%;\n background: var(--lottie-player-seeker-thumb-color);\n cursor: pointer;\n -ms-transition: transform 0.2s ease-in-out;\n transition: transform 0.2s ease-in-out;\n transform: scale(0);\n }\n\n &:hover::-ms-thumb {\n transform: scale(1);\n }\n\n &:focus {\n &::-ms-thumb {\n transform: scale(1);\n }\n\n &::-ms-fill-lower,\n &::-ms-fill-upper {\n background: var(--lottie-player-seeker-track-color);\n }\n }\n }\n\n & *::-moz-progress-bar {\n background-color: var(--lottie-player-seeker-thumb-color);\n }\n}\n\n@keyframes fade-in {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n@media (prefers-color-scheme: dark) {\n :host {\n --lottie-player-toolbar-background-color: #000;\n --lottie-player-toolbar-icon-color: #fff;\n --lottie-player-toolbar-icon-hover-color: #fff;\n --lottie-player-seeker-track-color: rgb(255 255 255 / 60%);\n }\n}\n";
63
69
 
70
+ let dotlottieTools = null, loadPromise = null;
71
+ function loadDotLottieTools() {
72
+ if (dotlottieTools) {
73
+ return Promise.resolve(dotlottieTools);
74
+ }
75
+ loadPromise = loadPromise ?? (async ()=>{
76
+ const { addAnimation, convert } = await import('@aarsteinmedia/lottie-web/dotlottie');
77
+ dotlottieTools = {
78
+ addAnimation,
79
+ convert
80
+ };
81
+ return {
82
+ addAnimation,
83
+ convert
84
+ };
85
+ })();
86
+ return loadPromise;
87
+ }
88
+
64
89
  const boomerangIcon = /* HTML */ `
65
90
  <svg width="24" height="24" aria-hidden="true" focusable="false">
66
91
  <path
@@ -109,6 +134,14 @@ const nextIcon = /* HTML */ `
109
134
  </svg>
110
135
  `;
111
136
 
137
+ const pauseIcon = /* HTML */ `
138
+ <svg width="24" height="24" aria-hidden="true" focusable="false">
139
+ <path
140
+ d="M14.016 5.016H18v13.969h-3.984V5.016zM6 18.984V5.015h3.984v13.969H6z"
141
+ />
142
+ </svg>
143
+ `;
144
+
112
145
  const playIcon = /* HTML */ `
113
146
  <svg width="24" height="24" aria-hidden="true" focusable="false">
114
147
  <path d="M8.016 5.016L18.985 12 8.016 18.984V5.015z" />
@@ -216,12 +249,18 @@ const tagName = 'dotlottie-player';
216
249
  }
217
250
  const convertButton = this.shadow.querySelector('.convert');
218
251
  if (convertButton instanceof HTMLButtonElement) {
219
- convertButton.onclick = ()=>{
220
- void convert({
221
- isDotLottie: this.isDotLottie,
222
- manifest: this.getManifest(),
223
- src: this.src || this.source
224
- });
252
+ convertButton.onclick = async ()=>{
253
+ convertButton.disabled = true;
254
+ try {
255
+ const { convert } = await loadDotLottieTools();
256
+ await convert({
257
+ isDotLottie: this.isDotLottie,
258
+ manifest: this.getManifest(),
259
+ src: this.src || this.source
260
+ });
261
+ } finally{
262
+ convertButton.disabled = false;
263
+ }
225
264
  };
226
265
  }
227
266
  const snapshot = this.shadow.querySelector('.snapshot');
@@ -235,14 +274,17 @@ const tagName = 'dotlottie-player';
235
274
  }
236
275
  }
237
276
  }
277
+ function updatePlayPauseButton(togglePlay, state) {
278
+ const isActive = state === PlayerState.Playing || state === PlayerState.Paused;
279
+ togglePlay.dataset.active = isActive.toString();
280
+ togglePlay.innerHTML = state === PlayerState.Playing ? pauseIcon : playIcon;
281
+ }
238
282
 
239
- const pauseIcon = /* HTML */ `
240
- <svg width="24" height="24" aria-hidden="true" focusable="false">
241
- <path
242
- d="M14.016 5.016H18v13.969h-3.984V5.016zM6 18.984V5.015h3.984v13.969H6z"
243
- />
244
- </svg>
245
- `;
283
+ var controls = /*#__PURE__*/Object.freeze({
284
+ __proto__: null,
285
+ default: renderControls,
286
+ updatePlayPauseButton: updatePlayPauseButton
287
+ });
246
288
 
247
289
  /**
248
290
  * Render Player.
@@ -252,7 +294,7 @@ const pauseIcon = /* HTML */ `
252
294
  }
253
295
  this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}" data-loaded="${this._playerState.loaded}"><figure class="animation" style="background:${this.background}" ${this.description ? /* HTML */ `
254
296
  aria-label="${this.description}"
255
- ` : ''}>${this.playerState === PlayerState.Error ? /* HTML */ `<div class="error"><svg preserveAspectRatio="${PreserveAspectRatio.Cover}" xmlns="${namespaceSVG}" width="1920" height="1080" viewBox="0 0 1920 1080" style="white-space:preserve"><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>` : ''}</figure><slot name="controls"></slot></div>`;
297
+ ` : ''}></figure><slot name="controls"></slot></div>`;
256
298
  this.shadow.adoptedStyleSheets = [
257
299
  await DotLottiePlayerBase.styles()
258
300
  ];
@@ -317,31 +359,23 @@ const pauseIcon = /* HTML */ `
317
359
  'h'
318
360
  ];
319
361
  return mandatory.every((field)=>Object.hasOwn(json, field));
320
- }, isTouch = ()=>'ontouchstart' in window, frameOutput = (frame)=>((frame ?? 0) + 1).toString().padStart(3, '0');
362
+ }, isTouch = ()=>'ontouchstart' in window, frameOutput = (frame)=>((frame ?? 0) + 1).toString().padStart(3, '0'), parseHTMLBooleans = (val)=>val !== null && [
363
+ 'true',
364
+ '',
365
+ '1'
366
+ ].includes(val);
367
+
368
+ let modulePromise = null;
369
+ function loadErrorModule() {
370
+ modulePromise = modulePromise ?? import('./errorScreen-CN8UGB0n.js');
371
+ return modulePromise;
372
+ }
321
373
 
322
374
  const notImplemented = 'Method is not implemented', getStyles = async ()=>{
323
375
  const styleSheet = new CSSStyleSheet();
324
376
  await styleSheet.replace(css_248z);
325
377
  return styleSheet;
326
378
  };
327
- // export interface DotLottieAnimationInstance {
328
- // addEventListener: (name: string, callback: (...args: any[]) => void) => void
329
- // autoplay?: boolean
330
- // currentFrame: number
331
- // destroy: () => void
332
- // goToAndPlay: (value: number, isFrame?: boolean) => void
333
- // goToAndStop: (value: number, isFrame?: boolean) => void
334
- // pause: () => void
335
- // play: () => void
336
- // playDirection: number
337
- // removeEventListener: (name: string, callback: (...args: any[]) => void) => void
338
- // setDirection: (direction: AnimationDirection) => void
339
- // setLoop: (loop: boolean) => void
340
- // setSpeed: (speed: number) => void
341
- // setSubframe: (useSubframe: boolean) => void
342
- // stop: () => void
343
- // totalFrames: number
344
- // }
345
379
  /**
346
380
  * DotLottie Player Web Component.
347
381
  */ class DotLottiePlayerBase extends PropertyCallbackElement {
@@ -385,7 +419,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
385
419
  }
386
420
  get animateOnScroll() {
387
421
  const val = this.getAttribute('animateOnScroll');
388
- return val === 'true' || val === '' || val === '1';
422
+ return parseHTMLBooleans(val);
389
423
  }
390
424
  get animations() {
391
425
  return this._animations;
@@ -397,7 +431,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
397
431
  }
398
432
  get autoplay() {
399
433
  const val = this.getAttribute('autoplay');
400
- return val === 'true' || val === '' || val === '1';
434
+ return parseHTMLBooleans(val);
401
435
  }
402
436
  /**
403
437
  * Background color.
@@ -414,7 +448,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
414
448
  }
415
449
  get controls() {
416
450
  const val = this.getAttribute('controls');
417
- return val === 'true' || val === '' || val === '1';
451
+ return parseHTMLBooleans(val);
418
452
  }
419
453
  /**
420
454
  * Number of times to loop.
@@ -472,7 +506,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
472
506
  }
473
507
  get dontFreezeOnBlur() {
474
508
  const val = this.getAttribute('dontFreezeOnBlur');
475
- return val === 'true' || val === '' || val === '1';
509
+ return parseHTMLBooleans(val);
476
510
  }
477
511
  /**
478
512
  * Whether to play on mouseover.
@@ -481,7 +515,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
481
515
  }
482
516
  get hover() {
483
517
  const val = this.getAttribute('hover');
484
- return val === 'true' || val === '' || val === '1';
518
+ return parseHTMLBooleans(val);
485
519
  }
486
520
  /**
487
521
  * Pause between loop intrations, in miliseconds.
@@ -505,7 +539,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
505
539
  }
506
540
  get loop() {
507
541
  const val = this.getAttribute('loop');
508
- return val === 'true' || val === '' || val === '1';
542
+ return parseHTMLBooleans(val);
509
543
  }
510
544
  /**
511
545
  * Play mode.
@@ -559,7 +593,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
559
593
  }
560
594
  get once() {
561
595
  const val = this.getAttribute('once');
562
- return val === 'true' || val === '' || val === '1';
596
+ return parseHTMLBooleans(val);
563
597
  }
564
598
  /**
565
599
  * Whether to toggle play on click.
@@ -568,7 +602,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
568
602
  }
569
603
  get playOnClick() {
570
604
  const val = this.getAttribute('playOnClick');
571
- return val === 'true' || val === '' || val === '1';
605
+ return parseHTMLBooleans(val);
572
606
  }
573
607
  /**
574
608
  * Play when visible.
@@ -577,7 +611,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
577
611
  }
578
612
  get playOnVisible() {
579
613
  const val = this.getAttribute('playOnVisible');
580
- return val === 'true' || val === '' || val === '1';
614
+ return parseHTMLBooleans(val);
581
615
  }
582
616
  /**
583
617
  * Resizing to container (Deprecated).
@@ -622,7 +656,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
622
656
  }
623
657
  get simple() {
624
658
  const val = this.getAttribute('simple');
625
- return val === 'true' || val === '' || val === '1';
659
+ return parseHTMLBooleans(val);
626
660
  }
627
661
  /**
628
662
  * Speed.
@@ -651,7 +685,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
651
685
  }
652
686
  get subframe() {
653
687
  const val = this.getAttribute('subframe');
654
- return val === 'true' || val === '' || val === '1';
688
+ return parseHTMLBooleans(val);
655
689
  }
656
690
  constructor(){
657
691
  super(), this.isLight = false, /**
@@ -667,17 +701,31 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
667
701
  scrollTimeout: null,
668
702
  scrollY: 0,
669
703
  visible: false
670
- }, this._render = renderPlayer, this._renderControls = renderControls, /**
704
+ }, this._render = renderPlayer, /**
671
705
  * Seeker.
672
706
  */ this._seeker = 0, /**
673
707
  * This is included in watched properties,
674
708
  * so that next-button will show up
675
709
  * on load, if controls are visible.
676
- */ this._animations = [], /**
710
+ */ this._animations = [], this._controlsLoadId = 0, /**
677
711
  * Which animation to show, if several.
678
- */ this._currentAnimation = 0, this._isBounce = false, this._isDotLottie = false, this._lottieInstance = null, /**
712
+ */ this._currentAnimation = 0, this._errorLoadId = 0, this._isBounce = false, this._isDotLottie = false, this._lottieInstance = null, /**
679
713
  * Multi-animation settings.
680
- */ this._multiAnimationSettings = [];
714
+ */ this._multiAnimationSettings = [], this._renderControls = async ()=>{
715
+ const slot = this.shadow?.querySelector('slot[name=controls]');
716
+ if (!slot) {
717
+ return;
718
+ }
719
+ if (!this.controls) {
720
+ slot.innerHTML = '';
721
+ return;
722
+ }
723
+ const loadId = ++this._controlsLoadId, { default: renderControls } = await loadControlsModule();
724
+ if (loadId !== this._controlsLoadId) {
725
+ return;
726
+ }
727
+ renderControls.call(this);
728
+ };
681
729
  this._complete = this._complete.bind(this);
682
730
  this._dataFailed = this._dataFailed.bind(this);
683
731
  this._dataReady = this._dataReady.bind(this);
@@ -699,7 +747,6 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
699
747
  this.stop = this.stop.bind(this);
700
748
  this.prev = this.prev.bind(this);
701
749
  this.next = this.next.bind(this);
702
- this._renderControls = this._renderControls.bind(this);
703
750
  this.snapshot = this.snapshot.bind(this);
704
751
  this.toggleLoop = this.toggleLoop.bind(this);
705
752
  this.toggleBoomerang = this.toggleBoomerang.bind(this);
@@ -746,7 +793,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
746
793
  }
747
794
  case 'controls':
748
795
  {
749
- this._renderControls();
796
+ await this._renderControls();
750
797
  break;
751
798
  }
752
799
  case 'direction':
@@ -855,11 +902,11 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
855
902
  }
856
903
  // Add intersection observer for detecting component being out-of-view.
857
904
  this._addIntersectionObserver();
858
- this.dispatchEvent(new CustomEvent(PlayerEvents.Rendered));
905
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Rendered));
859
906
  })();
860
907
  } catch (error) {
861
908
  console.error(error);
862
- this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
909
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Error));
863
910
  }
864
911
  }
865
912
  convert(_params) {
@@ -874,7 +921,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
874
921
  this.playerState = PlayerState.Destroyed;
875
922
  this._lottieInstance.destroy();
876
923
  this._lottieInstance = null;
877
- this.dispatchEvent(new CustomEvent(PlayerEvents.Destroyed));
924
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Destroyed));
878
925
  this.remove();
879
926
  document.removeEventListener('visibilitychange', this._onVisibilityChange);
880
927
  }
@@ -982,26 +1029,13 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
982
1029
  // Start playing if autoplay is enabled
983
1030
  if ((this.autoplay || this.animateOnScroll || this.playOnVisible) && this.direction === -1) {
984
1031
  this.seek('99%');
985
- // if (!('IntersectionObserver' in window)) {
986
- // if (!this.animateOnScroll) {
987
- // this.play()
988
- // }
989
- // this._playerState.visible = true
990
- // }
991
- // this._addIntersectionObserver()
992
- }
993
- this._renderControls();
994
- if (this.autoplay || this.playOnVisible) {
995
- const togglePlay = this.shadow?.querySelector('.togglePlay');
996
- if (togglePlay) {
997
- togglePlay.innerHTML = pauseIcon;
998
- }
999
1032
  }
1033
+ await this._renderControls();
1000
1034
  } catch (error) {
1001
1035
  console.error(error);
1002
1036
  this._errorMessage = handleErrors(error).message;
1003
1037
  this.playerState = PlayerState.Error;
1004
- this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
1038
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Error));
1005
1039
  }
1006
1040
  }
1007
1041
  loadAnimation(_config) {
@@ -1023,7 +1057,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1023
1057
  let hasError = false;
1024
1058
  try {
1025
1059
  this._lottieInstance.pause();
1026
- this.dispatchEvent(new CustomEvent(PlayerEvents.Pause));
1060
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Pause));
1027
1061
  } catch (error) {
1028
1062
  hasError = true;
1029
1063
  console.error(error);
@@ -1041,7 +1075,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1041
1075
  let hasError = false;
1042
1076
  try {
1043
1077
  this._lottieInstance.play();
1044
- this.dispatchEvent(new CustomEvent(PlayerEvents.Play));
1078
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Play));
1045
1079
  } catch (error) {
1046
1080
  hasError = true;
1047
1081
  console.error(error);
@@ -1066,13 +1100,8 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1066
1100
  return;
1067
1101
  }
1068
1102
  if (name === 'playerState') {
1069
- togglePlay.dataset.active = (value === PlayerState.Playing || value === PlayerState.Paused).toString();
1103
+ updatePlayPauseButton(togglePlay, value);
1070
1104
  stopButton.dataset.active = (value === PlayerState.Stopped).toString();
1071
- if (value === PlayerState.Playing) {
1072
- togglePlay.innerHTML = pauseIcon;
1073
- } else {
1074
- togglePlay.innerHTML = playIcon;
1075
- }
1076
1105
  }
1077
1106
  if (name === '_seeker' && typeof value === 'number') {
1078
1107
  seeker.value = value.toString();
@@ -1219,7 +1248,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1219
1248
  this._playerState.count = 0;
1220
1249
  try {
1221
1250
  this._lottieInstance.stop();
1222
- this.dispatchEvent(new CustomEvent(PlayerEvents.Stop));
1251
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Stop));
1223
1252
  } finally{
1224
1253
  this.playerState = PlayerState.Stopped;
1225
1254
  }
@@ -1291,7 +1320,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1291
1320
  this._playerState.prev = this.playerState;
1292
1321
  try {
1293
1322
  this._lottieInstance.pause();
1294
- this.dispatchEvent(new CustomEvent(PlayerEvents.Freeze));
1323
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Freeze));
1295
1324
  } finally{
1296
1325
  this.playerState = PlayerState.Frozen;
1297
1326
  }
@@ -1328,6 +1357,20 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1328
1357
  target.focus();
1329
1358
  }
1330
1359
  }
1360
+ async _showError() {
1361
+ if (this.playerState !== PlayerState.Error) {
1362
+ return;
1363
+ }
1364
+ const figure = this.shadow?.querySelector('.animation');
1365
+ if (!(figure instanceof HTMLElement)) {
1366
+ return;
1367
+ }
1368
+ const loadId = ++this._errorLoadId, { default: errorScreen } = await loadErrorModule();
1369
+ if (loadId !== this._errorLoadId) {
1370
+ return;
1371
+ }
1372
+ figure.innerHTML = errorScreen(this._errorMessage);
1373
+ }
1331
1374
  setOptions(_options) {
1332
1375
  throw new Error('Method not implemented');
1333
1376
  }
@@ -1405,7 +1448,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1405
1448
  const { currentFrame, totalFrames } = this._lottieInstance;
1406
1449
  this._seeker = Math.round(currentFrame / totalFrames * 100);
1407
1450
  this.playerState = PlayerState.Completed;
1408
- this.dispatchEvent(new CustomEvent(PlayerEvents.Complete, {
1451
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Complete, {
1409
1452
  detail: {
1410
1453
  frame: currentFrame,
1411
1454
  seeker: this._seeker
@@ -1414,14 +1457,14 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1414
1457
  }
1415
1458
  _dataFailed() {
1416
1459
  this.playerState = PlayerState.Error;
1417
- this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
1460
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Error));
1418
1461
  }
1419
1462
  _dataReady() {
1420
- this.dispatchEvent(new CustomEvent(PlayerEvents.Load));
1463
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Load));
1421
1464
  }
1422
1465
  _DOMLoaded() {
1423
1466
  this._playerState.loaded = true;
1424
- this.dispatchEvent(new CustomEvent(PlayerEvents.Ready));
1467
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Ready));
1425
1468
  }
1426
1469
  _enterFrame() {
1427
1470
  if (!this._lottieInstance) {
@@ -1429,7 +1472,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1429
1472
  }
1430
1473
  const { currentFrame, totalFrames } = this._lottieInstance;
1431
1474
  this._seeker = Math.round(currentFrame / totalFrames * 100);
1432
- this.dispatchEvent(new CustomEvent(PlayerEvents.Frame, {
1475
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Frame, {
1433
1476
  detail: {
1434
1477
  frame: currentFrame,
1435
1478
  seeker: this._seeker
@@ -1561,11 +1604,11 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1561
1604
  if (this._playerState.count >= this.count) {
1562
1605
  this.setLoop(false);
1563
1606
  this.playerState = PlayerState.Completed;
1564
- this.dispatchEvent(new CustomEvent(PlayerEvents.Complete));
1607
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Complete));
1565
1608
  return;
1566
1609
  }
1567
1610
  }
1568
- this.dispatchEvent(new CustomEvent(PlayerEvents.Loop));
1611
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Loop));
1569
1612
  if (this._isBounce) {
1570
1613
  this._lottieInstance.goToAndStop(playDirection === -1 ? inPoint : outPoint * 0.99, true);
1571
1614
  this._lottieInstance.setDirection(playDirection * -1);
@@ -1670,7 +1713,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1670
1713
  // Remove event listeners to new Lottie instance, and add new
1671
1714
  this._removeEventListeners();
1672
1715
  this._addEventListeners();
1673
- this.dispatchEvent(new CustomEvent(isPrevious ? PlayerEvents.Previous : PlayerEvents.Next));
1716
+ this.dispatchEvent(new CustomEvent(isPrevious ? PlayerEvent.Previous : PlayerEvent.Next));
1674
1717
  if (this._multiAnimationSettings[this._currentAnimation]?.autoplay ?? this.autoplay) {
1675
1718
  if (this.animateOnScroll) {
1676
1719
  this._lottieInstance.goToAndStop(0, true);
@@ -1686,7 +1729,7 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1686
1729
  } catch (error) {
1687
1730
  this._errorMessage = handleErrors(error).message;
1688
1731
  this.playerState = PlayerState.Error;
1689
- this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
1732
+ this.dispatchEvent(new CustomEvent(PlayerEvent.Error));
1690
1733
  }
1691
1734
  }
1692
1735
  /**
@@ -1694,12 +1737,12 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1694
1737
  */ _toggleEventListeners(action) {
1695
1738
  const method = action === 'add' ? 'addEventListener' : 'removeEventListener';
1696
1739
  if (this._lottieInstance) {
1697
- this._lottieInstance[method]('enterFrame', this._enterFrame);
1698
- this._lottieInstance[method]('complete', this._complete);
1699
- this._lottieInstance[method]('loopComplete', this._loopComplete);
1700
- this._lottieInstance[method]('DOMLoaded', this._DOMLoaded);
1701
- this._lottieInstance[method]('data_ready', this._dataReady);
1702
- this._lottieInstance[method]('data_failed', this._dataFailed);
1740
+ this._lottieInstance[method](PlayerEvent.EnterFrame, this._enterFrame);
1741
+ this._lottieInstance[method](PlayerEvent.Complete, this._complete);
1742
+ this._lottieInstance[method](PlayerEvent.LoopComplete, this._loopComplete);
1743
+ this._lottieInstance[method](PlayerEvent.DOMLoaded, this._DOMLoaded);
1744
+ this._lottieInstance[method](PlayerEvent.DataReady, this._dataReady);
1745
+ this._lottieInstance[method](PlayerEvent.DataFailed, this._dataFailed);
1703
1746
  }
1704
1747
  if (this.selector) {
1705
1748
  const selector = document.getElementById(this.selector);
@@ -1749,4 +1792,4 @@ const notImplemented = 'Method is not implemented', getStyles = async ()=>{
1749
1792
  }
1750
1793
  }
1751
1794
 
1752
- export { DotLottiePlayerBase as D, MouseOut as M, PlayerState as P, tagName as t };
1795
+ export { DotLottiePlayerBase as D, MouseOut as M, PlayerState as P, loadDotLottieTools as l, tagName as t };