@aarsteinmedia/dotlottie-player 5.3.2 → 6.0.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.
@@ -1,7 +1,35 @@
1
- import { PlayMode, PreserveAspectRatio, RendererType } from '@aarsteinmedia/lottie-web/utils';
1
+ import { RendererType, PreserveAspectRatio, PlayMode } from '@aarsteinmedia/lottie-web/utils';
2
2
  export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
- import { AnimationData, AnimationDirection, AnimationItem, LottieManifest, AnimationSettings, Vector2 } from '@aarsteinmedia/lottie-web';
3
+ import * as _aarsteinmedia_lottie_web from '@aarsteinmedia/lottie-web';
4
+ import { Vector2, AnimationConfiguration, AnimationData, AnimationDirection, AddAnimationParams, Result, ConvertParams, AnimationItem, LottieManifest, AnimationSettings } from '@aarsteinmedia/lottie-web';
4
5
  import { addAnimation, convert } from '@aarsteinmedia/lottie-web/dotlottie';
6
+ import * as _aarsteinmedia_lottie_web_light from '@aarsteinmedia/lottie-web/light';
7
+
8
+ declare class DotLottiePlayerLight extends DotLottiePlayerBase {
9
+ loadAnimation: typeof _aarsteinmedia_lottie_web_light.loadAnimation;
10
+ get renderer(): RendererType;
11
+ constructor();
12
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
13
+ container?: HTMLElement;
14
+ rendererType: RendererType;
15
+ initialSegment?: Vector2;
16
+ hasAutoplay: boolean;
17
+ hasLoop: boolean;
18
+ preserveAspectRatio: PreserveAspectRatio;
19
+ }): AnimationConfiguration<RendererType.SVG>;
20
+ }
21
+
22
+ declare enum PlayerState {
23
+ Completed = "completed",
24
+ Destroyed = "destroyed",
25
+ Error = "error",
26
+ Frozen = "frozen",
27
+ Loading = "loading",
28
+ Paused = "paused",
29
+ Playing = "playing",
30
+ Stopped = "stopped"
31
+ }
32
+ declare const tagName = "dotlottie-player";
5
33
 
6
34
  type AnimateOnScroll = boolean | '' | null;
7
35
  type Autoplay = boolean | '' | 'autoplay' | null;
@@ -10,11 +38,11 @@ type Loop = boolean | '' | 'loop' | null;
10
38
  type Subframe = boolean | '' | null;
11
39
  declare global {
12
40
  interface HTMLElementTagNameMap {
13
- [tagName]: DotLottiePlayer;
41
+ [tagName]: DotLottiePlayer | DotLottiePlayerLight;
14
42
  }
15
- function dotLottiePlayer(): DotLottiePlayer;
43
+ function dotLottiePlayer(): DotLottiePlayer | DotLottiePlayerLight;
16
44
  }
17
- type JSXLottiePlayer = Omit<Partial<DotLottiePlayer>, 'style'> & {
45
+ type JSXLottiePlayer = Omit<Partial<DotLottiePlayer | DotLottiePlayerLight>, 'style'> & {
18
46
  class?: string;
19
47
  ref?: React.RefObject<unknown>;
20
48
  style?: React.CSSProperties;
@@ -48,31 +76,19 @@ declare abstract class PropertyCallbackElement extends HTMLElement {
48
76
  propertyChangedCallback(_name: string, _oldValue: unknown, _value: unknown): void;
49
77
  }
50
78
 
51
- declare function renderControls(this: DotLottiePlayer): void;
79
+ declare function renderControls(this: DotLottiePlayerBase): void;
52
80
 
53
- declare function renderPlayer(this: DotLottiePlayer): Promise<void>;
81
+ declare function renderPlayer(this: DotLottiePlayerBase): Promise<void>;
54
82
 
55
- declare enum PlayerState {
56
- Completed = "completed",
57
- Destroyed = "destroyed",
58
- Error = "error",
59
- Frozen = "frozen",
60
- Loading = "loading",
61
- Paused = "paused",
62
- Playing = "playing",
63
- Stopped = "stopped"
64
- }
65
-
66
- declare class DotLottiePlayer extends PropertyCallbackElement {
83
+ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
67
84
  static get observedAttributes(): string[];
68
85
  static get observedProperties(): string[];
69
86
  static get styles(): () => Promise<CSSStyleSheet>;
70
- addAnimation: typeof addAnimation;
71
- convert: typeof convert;
87
+ isLight: boolean;
72
88
  playerState: PlayerState;
73
89
  shadow: ShadowRoot | undefined;
74
90
  source?: string;
75
- template: HTMLTemplateElement;
91
+ template?: HTMLTemplateElement;
76
92
  set animateOnScroll(value: AnimateOnScroll);
77
93
  get animateOnScroll(): AnimateOnScroll;
78
94
  get animations(): AnimationData[];
@@ -137,8 +153,10 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
137
153
  private _multiAnimationSettings;
138
154
  private _segment?;
139
155
  constructor();
156
+ addAnimation(_params: AddAnimationParams): Promise<Result>;
140
157
  attributeChangedCallback(name: string, _oldValue: unknown, value: string): Promise<void>;
141
158
  connectedCallback(): void;
159
+ convert(_params: ConvertParams): Promise<Result>;
142
160
  destroy(): void;
143
161
  disconnectedCallback(): void;
144
162
  getLottie(): AnimationItem | null;
@@ -146,6 +164,7 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
146
164
  getMultiAnimationSettings(): AnimationSettings[];
147
165
  getSegment(): Vector2 | undefined;
148
166
  load(src: string | null): Promise<void>;
167
+ loadAnimation(_config: AnimationConfiguration): AnimationItem;
149
168
  next(): void;
150
169
  pause(): void;
151
170
  play(): void;
@@ -169,6 +188,14 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
169
188
  protected _handleBlur(): void;
170
189
  protected _handleSeekChange({ target }: Event): void;
171
190
  protected _handleSettingsClick({ target }: Event): void;
191
+ protected setOptions(_options: {
192
+ container?: HTMLElement;
193
+ rendererType: RendererType;
194
+ initialSegment?: Vector2;
195
+ hasAutoplay: boolean;
196
+ hasLoop: boolean;
197
+ preserveAspectRatio: PreserveAspectRatio;
198
+ }): AnimationConfiguration<RendererType.SVG | RendererType.Canvas | RendererType.HTML>;
172
199
  private _addEventListeners;
173
200
  private _addIntersectionObserver;
174
201
  private _complete;
@@ -190,6 +217,18 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
190
217
  private _toggleSettings;
191
218
  }
192
219
 
193
- declare const tagName = "dotlottie-player";
220
+ declare class DotLottiePlayer extends DotLottiePlayerBase {
221
+ addAnimation: typeof addAnimation;
222
+ convert: typeof convert;
223
+ loadAnimation: typeof _aarsteinmedia_lottie_web.loadAnimation;
224
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }: {
225
+ container?: HTMLElement;
226
+ rendererType: RendererType;
227
+ initialSegment?: Vector2;
228
+ hasAutoplay: boolean;
229
+ hasLoop: boolean;
230
+ preserveAspectRatio: PreserveAspectRatio;
231
+ }): AnimationConfiguration<RendererType>;
232
+ }
194
233
 
195
234
  export { PlayerState, DotLottiePlayer as default, tagName };
@@ -1,7 +1,7 @@
1
1
  import { isServer, PlayMode, PreserveAspectRatio, namespaceSVG, RendererType, createElementID, PlayerEvents, download, getFilename } from '@aarsteinmedia/lottie-web/utils';
2
2
  export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
3
  import Lottie from '@aarsteinmedia/lottie-web';
4
- import { convert, addAnimation, getAnimationData } from '@aarsteinmedia/lottie-web/dotlottie';
4
+ import { convert, getAnimationData, addAnimation } from '@aarsteinmedia/lottie-web/dotlottie';
5
5
 
6
6
  /**
7
7
  * Credit to: Leonardo Favre https://github.com/leofavre/observed-properties.
@@ -156,6 +156,7 @@ var PlayerState = /*#__PURE__*/ function(PlayerState) {
156
156
  PlayerState["Stopped"] = "stopped";
157
157
  return PlayerState;
158
158
  }({});
159
+ const tagName = 'dotlottie-player';
159
160
 
160
161
  /**
161
162
  * Render Controls.
@@ -241,12 +242,12 @@ const pauseIcon = /* HTML */ `
241
242
  /**
242
243
  * Render Player.
243
244
  */ async function renderPlayer() {
244
- if (!this.shadow) {
245
- throw new Error('No Shadow Element');
245
+ if (!this.shadow || !this.template) {
246
+ throw new Error('No Shadow Element or Template');
246
247
  }
247
248
  this.template.innerHTML = /* HTML */ `<div class="animation-container main" data-controls="${this.controls ?? false}" lang="${this.description ? document.documentElement.lang : 'en'}" aria-label="${this.description ?? 'Lottie animation'}" data-loaded="${this._playerState.loaded}"><figure class="animation" style="background:${this.background}">${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>`;
248
249
  this.shadow.adoptedStyleSheets = [
249
- await DotLottiePlayer.styles()
250
+ await DotLottiePlayerBase.styles()
250
251
  ];
251
252
  this.shadow.appendChild(this.template.content.cloneNode(true));
252
253
  }
@@ -293,9 +294,10 @@ const pauseIcon = /* HTML */ `
293
294
  return res;
294
295
  }, frameOutput = (frame)=>((frame ?? 0) + 1).toString().padStart(3, '0');
295
296
 
297
+ const notImplemented = 'Method is not implemented';
296
298
  /**
297
299
  * DotLottie Player Web Component.
298
- */ class DotLottiePlayer extends PropertyCallbackElement {
300
+ */ class DotLottiePlayerBase extends PropertyCallbackElement {
299
301
  /**
300
302
  * Attributes to observe.
301
303
  */ static get observedAttributes() {
@@ -525,7 +527,7 @@ const pauseIcon = /* HTML */ `
525
527
  return Boolean(val === 'true' || val === '' || val === '1');
526
528
  }
527
529
  constructor(){
528
- super(), this.addAnimation = addAnimation, this.convert = convert, /**
530
+ super(), this.isLight = false, /**
529
531
  * Player state.
530
532
  */ this.playerState = PlayerState.Loading, /**
531
533
  * Animation Container.
@@ -579,6 +581,9 @@ const pauseIcon = /* HTML */ `
579
581
  mode: 'open'
580
582
  });
581
583
  }
584
+ addAnimation(_params) {
585
+ throw new Error(notImplemented);
586
+ }
582
587
  /**
583
588
  * Runs when the value of an attribute is changed on the component.
584
589
  */ async attributeChangedCallback(name, _oldValue, value) {
@@ -678,6 +683,9 @@ const pauseIcon = /* HTML */ `
678
683
  this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
679
684
  }
680
685
  }
686
+ convert(_params) {
687
+ throw new Error(notImplemented);
688
+ }
681
689
  /**
682
690
  * Destroy animation and element.
683
691
  */ destroy() {
@@ -766,7 +774,7 @@ const pauseIcon = /* HTML */ `
766
774
  this.playerState = PlayerState.Playing;
767
775
  }
768
776
  // Initialize lottie player and load animation
769
- this._lottieInstance = Lottie.loadAnimation({
777
+ this._lottieInstance = this.loadAnimation({
770
778
  ...this._getOptions(),
771
779
  animationData: animations[this._currentAnimation]
772
780
  });
@@ -803,6 +811,9 @@ const pauseIcon = /* HTML */ `
803
811
  this.dispatchEvent(new CustomEvent(PlayerEvents.Error));
804
812
  }
805
813
  }
814
+ loadAnimation(_config) {
815
+ throw new Error(notImplemented);
816
+ }
806
817
  /**
807
818
  * Skip to next animation.
808
819
  */ next() {
@@ -849,13 +860,13 @@ const pauseIcon = /* HTML */ `
849
860
  if (!this.shadow) {
850
861
  return;
851
862
  }
852
- const togglePlay = this.shadow.querySelector('.togglePlay'), stop = this.shadow.querySelector('.stop'), prev = this.shadow.querySelector('.prev'), next = this.shadow.querySelector('.next'), seeker = this.shadow.querySelector('.seeker'), progress = this.shadow.querySelector('progress'), popover = this.shadow.querySelector('.popover'), convertButton = this.shadow.querySelector('.convert'), snapshot = this.shadow.querySelector('.snapshot');
853
- if (!(togglePlay instanceof HTMLButtonElement) || !(stop instanceof HTMLButtonElement) || !(next instanceof HTMLButtonElement) || !(prev instanceof HTMLButtonElement) || !(seeker instanceof HTMLInputElement) || !(progress instanceof HTMLProgressElement)) {
863
+ const togglePlay = this.shadow.querySelector('.togglePlay'), stopButton = this.shadow.querySelector('.stop'), prevButton = this.shadow.querySelector('.prev'), nextButton = this.shadow.querySelector('.next'), seeker = this.shadow.querySelector('.seeker'), progress = this.shadow.querySelector('progress'), popover = this.shadow.querySelector('.popover'), convertButton = this.shadow.querySelector('.convert'), snapshot = this.shadow.querySelector('.snapshot');
864
+ if (!(togglePlay instanceof HTMLButtonElement) || !(stopButton instanceof HTMLButtonElement) || !(nextButton instanceof HTMLButtonElement) || !(prevButton instanceof HTMLButtonElement) || !(seeker instanceof HTMLInputElement) || !(progress instanceof HTMLProgressElement)) {
854
865
  return;
855
866
  }
856
867
  if (name === 'playerState') {
857
868
  togglePlay.dataset.active = (value === PlayerState.Playing || value === PlayerState.Paused).toString();
858
- stop.dataset.active = (value === PlayerState.Stopped).toString();
869
+ stopButton.dataset.active = (value === PlayerState.Stopped).toString();
859
870
  if (value === PlayerState.Playing) {
860
871
  togglePlay.innerHTML = pauseIcon;
861
872
  } else {
@@ -868,15 +879,15 @@ const pauseIcon = /* HTML */ `
868
879
  progress.value = value;
869
880
  }
870
881
  if (name === '_animations' && Array.isArray(value) && this._currentAnimation + 1 < value.length) {
871
- next.hidden = false;
882
+ nextButton.hidden = false;
872
883
  }
873
884
  if (name === '_currentAnimation' && typeof value === 'number') {
874
- next.hidden = value + 1 >= this._animations.length;
875
- prev.hidden = !value;
885
+ nextButton.hidden = value + 1 >= this._animations.length;
886
+ prevButton.hidden = !value;
876
887
  }
877
888
  if (name === '_isSettingsOpen' && typeof value === 'boolean' && popover instanceof HTMLDivElement && convertButton instanceof HTMLButtonElement && snapshot instanceof HTMLButtonElement) {
878
889
  popover.hidden = !value;
879
- convertButton.hidden = false;
890
+ convertButton.hidden = this.isLight;
880
891
  snapshot.hidden = this.renderer !== RendererType.SVG;
881
892
  }
882
893
  }
@@ -1108,6 +1119,9 @@ const pauseIcon = /* HTML */ `
1108
1119
  target.focus();
1109
1120
  }
1110
1121
  }
1122
+ setOptions(_options) {
1123
+ throw new Error('Method not implemented');
1124
+ }
1111
1125
  /**
1112
1126
  * Add event listeners.
1113
1127
  */ _addEventListeners() {
@@ -1191,7 +1205,6 @@ const pauseIcon = /* HTML */ `
1191
1205
  }
1192
1206
  /**
1193
1207
  * Get options from props.
1194
- *
1195
1208
  */ _getOptions() {
1196
1209
  if (!this._container) {
1197
1210
  throw new Error('Container not rendered');
@@ -1227,47 +1240,14 @@ const pauseIcon = /* HTML */ `
1227
1240
  if (this._segment?.some((val)=>val < 0)) {
1228
1241
  initialSegment = undefined;
1229
1242
  }
1230
- const options = {
1231
- autoplay: hasAutoplay,
1243
+ return this.setOptions({
1232
1244
  container: this._container,
1245
+ hasAutoplay,
1246
+ hasLoop,
1233
1247
  initialSegment,
1234
- loop: hasLoop,
1235
- renderer: this.renderer,
1236
- rendererSettings: {
1237
- imagePreserveAspectRatio: preserveAspectRatio
1238
- }
1239
- };
1240
- switch(this.renderer){
1241
- case RendererType.SVG:
1242
- {
1243
- options.rendererSettings = {
1244
- ...options.rendererSettings,
1245
- hideOnTransparent: true,
1246
- preserveAspectRatio,
1247
- progressiveLoad: true
1248
- };
1249
- break;
1250
- }
1251
- case RendererType.Canvas:
1252
- {
1253
- options.rendererSettings = {
1254
- ...options.rendererSettings,
1255
- // @ts-expect-error TODO:
1256
- clearCanvas: true,
1257
- preserveAspectRatio,
1258
- progressiveLoad: true
1259
- };
1260
- break;
1261
- }
1262
- case RendererType.HTML:
1263
- {
1264
- options.rendererSettings = {
1265
- ...options.rendererSettings,
1266
- hideOnTransparent: true
1267
- };
1268
- }
1269
- }
1270
- return options;
1248
+ preserveAspectRatio,
1249
+ rendererType: this.renderer
1250
+ });
1271
1251
  }
1272
1252
  /**
1273
1253
  * Handle scroll.
@@ -1394,7 +1374,7 @@ const pauseIcon = /* HTML */ `
1394
1374
  this._lottieInstance.destroy();
1395
1375
  }
1396
1376
  // Re-initialize lottie player
1397
- this._lottieInstance = Lottie.loadAnimation({
1377
+ this._lottieInstance = this.loadAnimation({
1398
1378
  ...this._getOptions(),
1399
1379
  animationData: this._animations[this._currentAnimation]
1400
1380
  });
@@ -1466,10 +1446,54 @@ const pauseIcon = /* HTML */ `
1466
1446
  }
1467
1447
  }
1468
1448
 
1449
+ /**
1450
+ * DotLottie Player Web Component.
1451
+ */ class DotLottiePlayer extends DotLottiePlayerBase {
1452
+ setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }) {
1453
+ const options = {
1454
+ autoplay: hasAutoplay,
1455
+ container,
1456
+ initialSegment,
1457
+ loop: hasLoop,
1458
+ renderer: rendererType,
1459
+ rendererSettings: {
1460
+ imagePreserveAspectRatio: preserveAspectRatio
1461
+ }
1462
+ };
1463
+ switch(this.renderer){
1464
+ case RendererType.HTML:
1465
+ case RendererType.SVG:
1466
+ {
1467
+ options.rendererSettings = {
1468
+ ...options.rendererSettings,
1469
+ hideOnTransparent: true,
1470
+ preserveAspectRatio,
1471
+ progressiveLoad: true
1472
+ };
1473
+ break;
1474
+ }
1475
+ case RendererType.Canvas:
1476
+ {
1477
+ options.rendererSettings = {
1478
+ ...options.rendererSettings,
1479
+ // @ts-expect-error TODO:
1480
+ clearCanvas: true,
1481
+ preserveAspectRatio,
1482
+ progressiveLoad: true
1483
+ };
1484
+ break;
1485
+ }
1486
+ }
1487
+ return options;
1488
+ }
1489
+ constructor(...args){
1490
+ super(...args), this.addAnimation = addAnimation, this.convert = convert, this.loadAnimation = Lottie.loadAnimation;
1491
+ }
1492
+ }
1493
+
1469
1494
  /**
1470
1495
  * Expose DotLottiePlayer class as global variable.
1471
1496
  */ globalThis.dotLottiePlayer = ()=>new DotLottiePlayer();
1472
- const tagName = 'dotlottie-player';
1473
1497
  if (!isServer) {
1474
1498
  customElements.define(tagName, DotLottiePlayer);
1475
1499
  }
@@ -0,0 +1,234 @@
1
+ import { RendererType, PreserveAspectRatio, PlayMode } from '@aarsteinmedia/lottie-web/utils';
2
+ export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
+ import * as _aarsteinmedia_lottie_web_light from '@aarsteinmedia/lottie-web/light';
4
+ import * as _aarsteinmedia_lottie_web from '@aarsteinmedia/lottie-web';
5
+ import { Vector2, AnimationConfiguration, AnimationData, AnimationDirection, AddAnimationParams, Result, ConvertParams, AnimationItem, LottieManifest, AnimationSettings } from '@aarsteinmedia/lottie-web';
6
+ import { addAnimation, convert } from '@aarsteinmedia/lottie-web/dotlottie';
7
+
8
+ declare class DotLottiePlayer extends DotLottiePlayerBase {
9
+ addAnimation: typeof addAnimation;
10
+ convert: typeof convert;
11
+ loadAnimation: typeof _aarsteinmedia_lottie_web.loadAnimation;
12
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }: {
13
+ container?: HTMLElement;
14
+ rendererType: RendererType;
15
+ initialSegment?: Vector2;
16
+ hasAutoplay: boolean;
17
+ hasLoop: boolean;
18
+ preserveAspectRatio: PreserveAspectRatio;
19
+ }): AnimationConfiguration<RendererType>;
20
+ }
21
+
22
+ declare enum PlayerState {
23
+ Completed = "completed",
24
+ Destroyed = "destroyed",
25
+ Error = "error",
26
+ Frozen = "frozen",
27
+ Loading = "loading",
28
+ Paused = "paused",
29
+ Playing = "playing",
30
+ Stopped = "stopped"
31
+ }
32
+ declare const tagName = "dotlottie-player";
33
+
34
+ type AnimateOnScroll = boolean | '' | null;
35
+ type Autoplay = boolean | '' | 'autoplay' | null;
36
+ type Controls = boolean | '' | 'controls' | null;
37
+ type Loop = boolean | '' | 'loop' | null;
38
+ type Subframe = boolean | '' | null;
39
+ declare global {
40
+ interface HTMLElementTagNameMap {
41
+ [tagName]: DotLottiePlayer | DotLottiePlayerLight;
42
+ }
43
+ function dotLottiePlayer(): DotLottiePlayer | DotLottiePlayerLight;
44
+ }
45
+ type JSXLottiePlayer = Omit<Partial<DotLottiePlayer | DotLottiePlayerLight>, 'style'> & {
46
+ class?: string;
47
+ ref?: React.RefObject<unknown>;
48
+ style?: React.CSSProperties;
49
+ src: string;
50
+ };
51
+ declare module 'react' {
52
+ namespace JSX {
53
+ interface IntrinsicElements {
54
+ [tagName]: JSXLottiePlayer;
55
+ }
56
+ }
57
+ }
58
+ declare module 'react/jsx-runtime' {
59
+ namespace JSX {
60
+ interface IntrinsicElements {
61
+ [tagName]: JSXLottiePlayer;
62
+ }
63
+ }
64
+ }
65
+ declare module 'react/jsx-dev-runtime' {
66
+ namespace JSX {
67
+ interface IntrinsicElements {
68
+ [tagName]: JSXLottiePlayer;
69
+ }
70
+ }
71
+ }
72
+
73
+ declare abstract class PropertyCallbackElement extends HTMLElement {
74
+ constructor();
75
+ connectedCallback(): void;
76
+ propertyChangedCallback(_name: string, _oldValue: unknown, _value: unknown): void;
77
+ }
78
+
79
+ declare function renderControls(this: DotLottiePlayerBase): void;
80
+
81
+ declare function renderPlayer(this: DotLottiePlayerBase): Promise<void>;
82
+
83
+ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
84
+ static get observedAttributes(): string[];
85
+ static get observedProperties(): string[];
86
+ static get styles(): () => Promise<CSSStyleSheet>;
87
+ isLight: boolean;
88
+ playerState: PlayerState;
89
+ shadow: ShadowRoot | undefined;
90
+ source?: string;
91
+ template?: HTMLTemplateElement;
92
+ set animateOnScroll(value: AnimateOnScroll);
93
+ get animateOnScroll(): AnimateOnScroll;
94
+ get animations(): AnimationData[];
95
+ set autoplay(value: Autoplay);
96
+ get autoplay(): Autoplay;
97
+ set background(value: string);
98
+ get background(): string;
99
+ set controls(value: Controls);
100
+ get controls(): Controls;
101
+ set count(value: number);
102
+ get count(): number;
103
+ get currentAnimation(): number;
104
+ set description(value: string | null);
105
+ get description(): string | null;
106
+ set direction(value: AnimationDirection);
107
+ get direction(): AnimationDirection;
108
+ set hover(value: boolean);
109
+ get hover(): boolean;
110
+ set intermission(value: number);
111
+ get intermission(): number;
112
+ get isDotLottie(): boolean;
113
+ set loop(value: Loop);
114
+ get loop(): Loop;
115
+ set mode(value: PlayMode);
116
+ get mode(): PlayMode;
117
+ set objectfit(value: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down');
118
+ get objectfit(): "contain" | "cover" | "fill" | "none" | "scale-down";
119
+ set preserveAspectRatio(value: PreserveAspectRatio | null);
120
+ get preserveAspectRatio(): PreserveAspectRatio | null;
121
+ set renderer(value: RendererType);
122
+ get renderer(): RendererType;
123
+ set simple(value: boolean);
124
+ get simple(): boolean;
125
+ set speed(value: number);
126
+ get speed(): number;
127
+ set src(value: string | null);
128
+ get src(): string | null;
129
+ set subframe(value: Subframe);
130
+ get subframe(): Subframe;
131
+ protected _container: HTMLElement | null;
132
+ protected _errorMessage: string;
133
+ protected _identifier: string;
134
+ protected _isSettingsOpen: boolean;
135
+ protected _playerState: {
136
+ prev: PlayerState;
137
+ count: number;
138
+ loaded: boolean;
139
+ visible: boolean;
140
+ scrollY: number;
141
+ scrollTimeout: NodeJS.Timeout | null;
142
+ };
143
+ protected _render: typeof renderPlayer;
144
+ protected _renderControls: typeof renderControls;
145
+ protected _seeker: number;
146
+ private _animations;
147
+ private _currentAnimation;
148
+ private _intersectionObserver?;
149
+ private _isBounce;
150
+ private _isDotLottie;
151
+ private _lottieInstance;
152
+ private _manifest?;
153
+ private _multiAnimationSettings;
154
+ private _segment?;
155
+ constructor();
156
+ addAnimation(_params: AddAnimationParams): Promise<Result>;
157
+ attributeChangedCallback(name: string, _oldValue: unknown, value: string): Promise<void>;
158
+ connectedCallback(): void;
159
+ convert(_params: ConvertParams): Promise<Result>;
160
+ destroy(): void;
161
+ disconnectedCallback(): void;
162
+ getLottie(): AnimationItem | null;
163
+ getManifest(): LottieManifest | undefined;
164
+ getMultiAnimationSettings(): AnimationSettings[];
165
+ getSegment(): Vector2 | undefined;
166
+ load(src: string | null): Promise<void>;
167
+ loadAnimation(_config: AnimationConfiguration): AnimationItem;
168
+ next(): void;
169
+ pause(): void;
170
+ play(): void;
171
+ prev(): void;
172
+ propertyChangedCallback(name: string, _oldValue: unknown, value: unknown): void;
173
+ reload(): Promise<void>;
174
+ seek(value: number | string): void;
175
+ setCount(value: number): void;
176
+ setDirection(value: AnimationDirection): void;
177
+ setLoop(value: boolean): void;
178
+ setMultiAnimationSettings(settings: AnimationSettings[]): void;
179
+ setSegment(segment: Vector2): void;
180
+ setSpeed(value?: number): void;
181
+ setSubframe(value: boolean): void;
182
+ snapshot(shouldDownload?: boolean, name?: string): string | null;
183
+ stop(): void;
184
+ toggleBoomerang(): void;
185
+ toggleLoop(): void;
186
+ togglePlay(): void;
187
+ protected _freeze(): void;
188
+ protected _handleBlur(): void;
189
+ protected _handleSeekChange({ target }: Event): void;
190
+ protected _handleSettingsClick({ target }: Event): void;
191
+ protected setOptions(_options: {
192
+ container?: HTMLElement;
193
+ rendererType: RendererType;
194
+ initialSegment?: Vector2;
195
+ hasAutoplay: boolean;
196
+ hasLoop: boolean;
197
+ preserveAspectRatio: PreserveAspectRatio;
198
+ }): AnimationConfiguration<RendererType.SVG | RendererType.Canvas | RendererType.HTML>;
199
+ private _addEventListeners;
200
+ private _addIntersectionObserver;
201
+ private _complete;
202
+ private _dataFailed;
203
+ private _dataReady;
204
+ private _DOMLoaded;
205
+ private _enterFrame;
206
+ private _getOptions;
207
+ private _handleScroll;
208
+ private _handleWindowBlur;
209
+ private _isLottie;
210
+ private _loopComplete;
211
+ private _mouseEnter;
212
+ private _mouseLeave;
213
+ private _onVisibilityChange;
214
+ private _removeEventListeners;
215
+ private _switchInstance;
216
+ private _toggleEventListeners;
217
+ private _toggleSettings;
218
+ }
219
+
220
+ declare class DotLottiePlayerLight extends DotLottiePlayerBase {
221
+ loadAnimation: typeof _aarsteinmedia_lottie_web_light.loadAnimation;
222
+ get renderer(): RendererType;
223
+ constructor();
224
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
225
+ container?: HTMLElement;
226
+ rendererType: RendererType;
227
+ initialSegment?: Vector2;
228
+ hasAutoplay: boolean;
229
+ hasLoop: boolean;
230
+ preserveAspectRatio: PreserveAspectRatio;
231
+ }): AnimationConfiguration<RendererType.SVG>;
232
+ }
233
+
234
+ export { PlayerState, DotLottiePlayerLight as default, tagName };