@aarsteinmedia/dotlottie-player 5.0.4 → 5.1.1
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/CHANGELOG.md +14 -0
- package/dist/index.d.ts +10 -9
- package/dist/index.js +21 -19
- package/dist/unpkg.js +8 -2
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
Changelog was only added since [3.2.3], so it's not exhaustive. [Please report any missing noteable changes to us](https://github.com/aarsteinmedia/dotlottie-player/issues), and we'll add them promptly.
|
|
9
9
|
|
|
10
|
+
## [5.1.1] - 02-06-2025
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Added button to convert dotLottie to JSON. Helpful when debugging animations.
|
|
15
|
+
|
|
16
|
+
## [5.1.0] - 02-06-2025
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Dropped `lottie-web` as dependency in favour of `@aarsteinmedia/lottie-web`. This animation engine is based on `lottie-web`, has the same features + it works better in Node SSR environments, it doesn't rely on `eval()` to execute AE expressions, and it is hopefully easier to maintain and expand.
|
|
21
|
+
|
|
10
22
|
## [5.0.4] - 31-05-2025
|
|
11
23
|
|
|
12
24
|
### Changed
|
|
@@ -223,6 +235,8 @@ Changelog was only added since [3.2.3], so it's not exhaustive. [Please report a
|
|
|
223
235
|
- Removed dependencies
|
|
224
236
|
- `@lit`
|
|
225
237
|
|
|
238
|
+
[5.1.1]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.1.1
|
|
239
|
+
[5.1.0]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.1.0
|
|
226
240
|
[5.0.4]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.0.4
|
|
227
241
|
[5.0.3]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.0.3
|
|
228
242
|
[5.0.1]: https://www.npmjs.com/package/@aarsteinmedia/dotlottie-player/v/5.0.1
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimationSettings,
|
|
1
|
+
import { AnimationSettings, AnimationData, LottieManifest, AnimationDirection, AnimationItem, Vector2 } from '@aarsteinmedia/lottie-web';
|
|
2
2
|
|
|
3
3
|
interface Animation extends AnimationSettings {
|
|
4
4
|
id: string;
|
|
@@ -6,6 +6,14 @@ interface Animation extends AnimationSettings {
|
|
|
6
6
|
interface AnimationAttributes extends Animation {
|
|
7
7
|
url: string;
|
|
8
8
|
}
|
|
9
|
+
interface ConvertParams {
|
|
10
|
+
animations?: AnimationData[];
|
|
11
|
+
fileName?: string;
|
|
12
|
+
manifest?: LottieManifest;
|
|
13
|
+
shouldDownload?: boolean;
|
|
14
|
+
src?: string;
|
|
15
|
+
typeCheck?: boolean;
|
|
16
|
+
}
|
|
9
17
|
type AnimateOnScroll = boolean | '' | null;
|
|
10
18
|
type Autoplay = boolean | '' | 'autoplay' | null;
|
|
11
19
|
type Controls = boolean | '' | 'controls' | null;
|
|
@@ -180,14 +188,7 @@ declare class DotLottiePlayer extends PropertyCallbackElement {
|
|
|
180
188
|
}>;
|
|
181
189
|
attributeChangedCallback(name: string, _oldValue: unknown, value: string): Promise<void>;
|
|
182
190
|
connectedCallback(): Promise<void>;
|
|
183
|
-
convert({ animations: animationsFromProps, fileName, manifest, shouldDownload, src: srcFromProps, typeCheck, }:
|
|
184
|
-
typeCheck?: boolean;
|
|
185
|
-
manifest?: LottieManifest;
|
|
186
|
-
animations?: AnimationData[];
|
|
187
|
-
src?: string;
|
|
188
|
-
fileName?: string;
|
|
189
|
-
shouldDownload?: boolean;
|
|
190
|
-
}): Promise<ArrayBuffer | null | undefined>;
|
|
191
|
+
convert({ animations: animationsFromProps, fileName, manifest, shouldDownload, src: srcFromProps, typeCheck, }: ConvertParams): Promise<ArrayBuffer | null | undefined>;
|
|
191
192
|
destroy(): void;
|
|
192
193
|
disconnectedCallback(): void;
|
|
193
194
|
getLottie(): AnimationItem | null;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { isServer
|
|
2
|
-
import Lottie from 'lottie-web';
|
|
1
|
+
import { isServer, createElementID, PreserveAspectRatio as PreserveAspectRatio$1 } from '@aarsteinmedia/lottie-web/utils';
|
|
2
|
+
import Lottie from '@aarsteinmedia/lottie-web';
|
|
3
3
|
import { strToU8, strFromU8, zip, unzip as unzip$1 } from 'fflate';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Credit to: Leonardo Favre https://github.com/leofavre/observed-properties.
|
|
7
7
|
*/ const updateOnConnected = Symbol('UPDATE_ON_CONNECTED');
|
|
8
|
-
if (isServer
|
|
8
|
+
if (isServer()) {
|
|
9
9
|
// Mock HTMLElement for server-side rendering
|
|
10
10
|
global.HTMLElement = // eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
11
11
|
class EmptyHTMLElement {
|
|
@@ -167,6 +167,10 @@ var css_248z = "* {\n box-sizing: border-box;\n}\n\n:host {\n --lottie-player-
|
|
|
167
167
|
if (convert instanceof HTMLButtonElement) {
|
|
168
168
|
convert.onclick = this.convert;
|
|
169
169
|
}
|
|
170
|
+
// const convertJSON = this.shadow.querySelector('.convert-json')
|
|
171
|
+
// if (convertJSON instanceof HTMLButtonElement) {
|
|
172
|
+
// convertJSON.onclick = this.convertJSON as unknown as () => void
|
|
173
|
+
// }
|
|
170
174
|
const snapshot = this.shadow.querySelector('.snapshot');
|
|
171
175
|
if (snapshot instanceof HTMLButtonElement) {
|
|
172
176
|
snapshot.onclick = ()=>this.snapshot(true);
|
|
@@ -205,7 +209,7 @@ class CustomError extends Error {
|
|
|
205
209
|
throw new Error('No animations listed in manifest');
|
|
206
210
|
}
|
|
207
211
|
return manifest;
|
|
208
|
-
}
|
|
212
|
+
};
|
|
209
213
|
/**
|
|
210
214
|
* Methods used only locally.
|
|
211
215
|
*/ const hasExt = (path)=>{
|
|
@@ -1181,7 +1185,6 @@ const generator = '@aarsteinmedia/dotlottie-player';
|
|
|
1181
1185
|
this.playerState = PlayerState.Playing;
|
|
1182
1186
|
}
|
|
1183
1187
|
// Initialize lottie player and load animation
|
|
1184
|
-
// @ts-expect-error TODO:
|
|
1185
1188
|
this._lottieInstance = Lottie.loadAnimation({
|
|
1186
1189
|
...this._getOptions(),
|
|
1187
1190
|
animationData: animations[this._currentAnimation]
|
|
@@ -1258,7 +1261,7 @@ const generator = '@aarsteinmedia/dotlottie-player';
|
|
|
1258
1261
|
if (!this.shadow) {
|
|
1259
1262
|
return;
|
|
1260
1263
|
}
|
|
1261
|
-
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'), convert = this.shadow.querySelector('.convert');
|
|
1264
|
+
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'), convert = this.shadow.querySelector('.convert'), snapshot = this.shadow.querySelector('.snapshot');
|
|
1262
1265
|
if (!(togglePlay instanceof HTMLButtonElement) || !(stop instanceof HTMLButtonElement) || !(next instanceof HTMLButtonElement) || !(prev instanceof HTMLButtonElement) || !(seeker instanceof HTMLInputElement) || !(progress instanceof HTMLProgressElement)) {
|
|
1263
1266
|
return;
|
|
1264
1267
|
}
|
|
@@ -1280,20 +1283,20 @@ const generator = '@aarsteinmedia/dotlottie-player';
|
|
|
1280
1283
|
next.hidden = false;
|
|
1281
1284
|
}
|
|
1282
1285
|
if (name === '_currentAnimation' && typeof value === 'number') {
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
} else {
|
|
1286
|
-
next.hidden = false;
|
|
1287
|
-
}
|
|
1288
|
-
if (value) {
|
|
1289
|
-
prev.hidden = false;
|
|
1290
|
-
} else {
|
|
1291
|
-
prev.hidden = true;
|
|
1292
|
-
}
|
|
1286
|
+
next.hidden = value + 1 >= this._animations.length;
|
|
1287
|
+
prev.hidden = Boolean(value);
|
|
1293
1288
|
}
|
|
1294
|
-
if (name === '_isSettingsOpen' && typeof value === 'boolean' && popover instanceof HTMLDivElement && convert instanceof HTMLButtonElement) {
|
|
1289
|
+
if (name === '_isSettingsOpen' && typeof value === 'boolean' && popover instanceof HTMLDivElement && convert instanceof HTMLButtonElement && snapshot instanceof HTMLButtonElement) {
|
|
1295
1290
|
popover.hidden = !value;
|
|
1296
|
-
convert.hidden =
|
|
1291
|
+
convert.hidden = false;
|
|
1292
|
+
snapshot.hidden = this.renderer !== RendererType.SVG;
|
|
1293
|
+
if (this._isDotLottie) {
|
|
1294
|
+
convert.ariaLabel = 'Convert dotLottie to JSON';
|
|
1295
|
+
convert.innerHTML = convert.innerHTML.replace('dotLottie', 'JSON');
|
|
1296
|
+
} else {
|
|
1297
|
+
convert.ariaLabel = 'Convert JSON animation to dotLottie format';
|
|
1298
|
+
convert.innerHTML = convert.innerHTML.replace('JSON', 'dotLottie');
|
|
1299
|
+
}
|
|
1297
1300
|
}
|
|
1298
1301
|
}
|
|
1299
1302
|
/**
|
|
@@ -1804,7 +1807,6 @@ const generator = '@aarsteinmedia/dotlottie-player';
|
|
|
1804
1807
|
this._lottieInstance.destroy();
|
|
1805
1808
|
}
|
|
1806
1809
|
// Re-initialize lottie player
|
|
1807
|
-
// @ts-expect-error TODO:
|
|
1808
1810
|
this._lottieInstance = Lottie.loadAnimation({
|
|
1809
1811
|
...this._getOptions(),
|
|
1810
1812
|
animationData: this._animations[this._currentAnimation]
|