New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dotlottie/dotlottie-js

Package Overview
Dependencies
Maintainers
3
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotlottie/dotlottie-js - npm Package Compare versions

Comparing version 0.5.2 to 0.6.0

dist/dotlottie-common-5b107af6.d.ts

4

dist/dotlottie.d.ts

@@ -1,3 +0,3 @@

import { D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, C as ConversionOptions } from './dotlottie-common-f3060b14.js';
import { A as AnimationOptions } from './dotlottie-theme-common-8a5aef58.js';
import { D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, C as ConversionOptions } from './dotlottie-common-5b107af6.js';
import { A as AnimationOptions } from './dotlottie-theme-common-5a67e6de.js';
import 'fflate';

@@ -4,0 +4,0 @@ import './dotlottie-state-machine-common-f17570dd.js';

@@ -1,3 +0,3 @@

import { b as LottieImageCommon } from './dotlottie-theme-common-8a5aef58.js';
import { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-6e74f3be.js';
import { b as LottieImageCommon } from './dotlottie-theme-common-5a67e6de.js';
import { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-f5cda8e0.js';
import 'fflate';

@@ -7,3 +7,3 @@ import '@lottiefiles/lottie-types';

import 'valibot';
import './dotlottie-common-f3060b14.js';
import './dotlottie-common-5b107af6.js';
import './dotlottie-state-machine-common-f17570dd.js';

@@ -10,0 +10,0 @@

@@ -793,3 +793,5 @@ import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, minValue, maxValue, tuple } from 'valibot';

svg: "image/svg+xml",
webp: "image/webp"
webp: "image/webp",
mpeg: "audio/mpeg",
mp3: "audio/mp3"
};

@@ -802,3 +804,5 @@ var MIME_CODES = {

webp: [82, 73, 70, 70, 87, 69, 66, 80],
svg: [60, 63, 120]
svg: [60, 63, 120],
mp3: [73, 68, 51, 3, 0, 0, 0, 0],
mpeg: [73, 68, 51, 3, 0, 0, 0, 0]
};

@@ -805,0 +809,0 @@ var getMimeTypeFromBase64 = (base64) => {

@@ -5,5 +5,5 @@ export { DotLottie } from './dotlottie.js';

export { LottieTheme } from './lottie-theme.js';
export { C as ConversionOptions, D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, G as GetAnimationOptions } from './dotlottie-common-f3060b14.js';
export { c as AnimationData, A as AnimationOptions, E as ExportOptions, I as ImageData, d as ImageOptions, L as LottieAnimationCommon, b as LottieImageCommon, a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-8a5aef58.js';
export { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-6e74f3be.js';
export { C as ConversionOptions, D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, G as GetAnimationOptions } from './dotlottie-common-5b107af6.js';
export { d as AnimationData, A as AnimationOptions, f as AudioData, g as AudioOptions, E as ExportOptions, I as ImageData, e as ImageOptions, L as LottieAnimationCommon, c as LottieAudioCommon, b as LottieImageCommon, a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-5a67e6de.js';
export { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-f5cda8e0.js';
import { Asset, Animation } from '@lottiefiles/lottie-types';

@@ -16,2 +16,3 @@ import { UnzipFileFilter, Unzipped } from 'fflate';

export { v as DotLottieState, B as DotLottieStateMachine, D as DotLottieStateMachineCommon, a as DotLottieStateMachineCommonOptions, z as DotLottieStateMachineDescriptor, y as DotLottieStateMachineDescriptorSchema, A as DotLottieStateMachineSchema, t as DotLottieStatePlaybackSettings, s as DotLottieStatePlaybackSettingsSchema, u as DotLottieStateSchema, r as DotLottieStateTransitionEvents, q as DotLottieStateTransitionEventsSchema, x as DotLottieStates, w as DotLottieStatesSchema, b as PlaybackOptions, P as PlaybackOptionsSchema, f as StateTransitionOnAfter, e as StateTransitionOnAfterSchema, d as StateTransitionOnClick, S as StateTransitionOnClickSchema, n as StateTransitionOnComplete, m as StateTransitionOnCompleteSchema, h as StateTransitionOnEnter, g as StateTransitionOnEnterSchema, j as StateTransitionOnMouseEnter, i as StateTransitionOnMouseEnterSchema, l as StateTransitionOnMouseLeave, k as StateTransitionOnMouseLeaveSchema, p as StateTransitionOnShow, o as StateTransitionOnShowSchema, c as Transitionable, T as TransitionableSchema } from './dotlottie-state-machine-common-f17570dd.js';
export { LottieAudio } from './lottie-audio.js';
import 'valibot';

@@ -178,2 +179,21 @@

/**
* Checks if an asset is an audio asset.
*
* @remarks
* This function accepts an asset object and determines whether it represents an audio asset.
* It returns `true` if it's an audio asset, `false` otherwise.
*
* @param asset - The asset object to check.
* @returns `true` if it's an audio asset, `false` otherwise.
*
* @example
* ```typescript
* const asset = { e: 0, u: 'music/', p: 'audio.mp3' };
* const isAudio = isAudioAsset(asset); // true
* ```
*
* @public
*/
declare function isAudioAsset(asset: Asset.Value): asset is Asset.Image;
/**
* Unzips the .lottie file.

@@ -308,2 +328,66 @@ *

/**
* Retrieves an audio from the given DotLottie object by its filename.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array, the filename of the audio to retrieve, and an optional filter function.
* It returns a Promise that resolves to the audio data URL or `undefined` if not found.
*
* @param dotLottie - The Uint8Array of DotLottie data.
* @param filename - The filename of the image to get.
* @param filter - An optional filter function to apply on the unzipping process.
* @returns A Promise that resolves with the audio data URL or `undefined` if not found.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const filename = 'alarm.mp3';
* const imageData = await getAudio(dotLottie, filename);
* ```
*
* @public
*/
declare function getAudio(dotLottie: Uint8Array, filename: string, filter?: UnzipFileFilter): Promise<string | undefined>;
/**
* Retrieves all audio files from the given DotLottie object.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array and an optional filter function to further refine the extraction.
* It returns a Promise that resolves to a record containing the audio data URLs mapped by their ID.
*
* @param dotLottie - The Uint8Array of DotLottie data.
* @param filter - An optional filter function to apply on the unzipping process.
* @returns A Promise that resolves to a record containing the audio data URLs mapped by their ID.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const allAudio = await getAllAudio(dotLottie);
* ```
*
* @public
*/
declare function getAllAudio(dotLottie: Uint8Array, filter?: UnzipFileFilter): Promise<Record<string, string>>;
/**
* Inlines audio assets for the given animations within a DotLottie object.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array and a record containing the animations to process.
* It identifies the audio used in the animations and replaces their references with the actual audio data.
* This operation is performed asynchronously, and the function returns a Promise that resolves when the operation is complete.
*
* @param dotLottie - The DotLottie object containing the animations.
* @param animations - A record containing the animations to process.
* @returns A Promise that resolves when the operation is complete, returning nothing.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const animations = { animation1: {...}, animation2: {...} };
* await inlineAudioAssets(dotLottie, animations);
* ```
*
* @public
*/
declare function inlineAudioAssets(dotLottie: Uint8Array, animations: Record<string, Animation>): Promise<void>;
/**
* Retrieves an image from the given DotLottie object by its filename.

@@ -497,2 +581,2 @@ *

export { DotLottieError, ErrorCodes, MIME_CODES, MIME_TO_EXTENSION, MIME_TYPES, MimeCodes, MimeToExtension, MimeTypes, base64ToUint8Array, createError, dataUrlFromU8, getAnimation, getAnimations, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, getStateMachine, getStateMachines, getTheme, getThemes, inlineImageAssets, isImageAsset, isValidURL, loadFromArrayBuffer, loadFromURL, unzipDotLottie, unzipDotLottieFile, validateDotLottie };
export { DotLottieError, ErrorCodes, MIME_CODES, MIME_TO_EXTENSION, MIME_TYPES, MimeCodes, MimeToExtension, MimeTypes, base64ToUint8Array, createError, dataUrlFromU8, getAllAudio, getAnimation, getAnimations, getAudio, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, getStateMachine, getStateMachines, getTheme, getThemes, inlineAudioAssets, inlineImageAssets, isAudioAsset, isImageAsset, isValidURL, loadFromArrayBuffer, loadFromURL, unzipDotLottie, unzipDotLottieFile, validateDotLottie };

@@ -1,2 +0,2 @@

import { L as LottieAnimationCommon, A as AnimationOptions } from './dotlottie-theme-common-8a5aef58.js';
import { L as LottieAnimationCommon, A as AnimationOptions } from './dotlottie-theme-common-5a67e6de.js';
import 'fflate';

@@ -28,4 +28,11 @@ import '@lottiefiles/lottie-types';

protected _extractImageAssets(): Promise<boolean>;
/**
*
* Extract audio assets from the animation.
*
* @returns boolean - true on error otherwise false on success
*/
protected _extractAudioAssets(): Promise<boolean>;
}
export { LottieAnimation };

@@ -99,3 +99,5 @@ import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, minValue, maxValue, tuple } from 'valibot';

svg: "image/svg+xml",
webp: "image/webp"
webp: "image/webp",
mpeg: "audio/mpeg",
mp3: "audio/mp3"
};

@@ -108,3 +110,5 @@ var MIME_CODES = {

webp: [82, 73, 70, 70, 87, 69, 66, 80],
svg: [60, 63, 120]
svg: [60, 63, 120],
mp3: [73, 68, 51, 3, 0, 0, 0, 0],
mpeg: [73, 68, 51, 3, 0, 0, 0, 0]
};

@@ -117,3 +121,5 @@ var MIME_TO_EXTENSION = {

"image/svg+xml": "svg",
"image/webp": "webp"
"image/webp": "webp",
"audio/mpeg": "mpeg",
"audio/mp3": "mp3"
};

@@ -155,2 +161,10 @@ var getMimeTypeFromBase64 = (base64) => {

};
var DotLottieError = class extends Error {
constructor(message, code) {
super(message);
__publicField(this, "code");
this.name = "[dotlottie-js]";
this.code = code;
}
};
var createError = (message) => {

@@ -171,2 +185,5 @@ const error = new Error(`[dotlottie-js]: ${message}`);

}
function isAudioAsset(asset) {
return !("h" in asset) && !("w" in asset) && "p" in asset && "e" in asset && "u" in asset && "id" in asset;
}

@@ -189,2 +206,3 @@ // src/common/lottie-animation-common.ts

__publicField(this, "_imageAssets", []);
__publicField(this, "_audioAssets", []);
__publicField(this, "_themesMap", /* @__PURE__ */ new Map());

@@ -247,2 +265,8 @@ __publicField(this, "_defaultTheme");

}
get audioAssets() {
return this._audioAssets;
}
set audioAssets(audioAssets) {
this._audioAssets = audioAssets;
}
get data() {

@@ -323,4 +347,7 @@ return this._data;

async _extractImageAssets() {
throw createError("_extractImageAssets(): Promise<boolean> method not implemented in concrete class");
throw new DotLottieError("_extractImageAssets(): Promise<boolean> method not implemented in concrete class");
}
async _extractAudioAssets() {
throw new DotLottieError("_extractAudioAssets(): Promise<boolean> method not implemented in concrete class");
}
async toBlob(options = {}) {

@@ -337,7 +364,9 @@ const dataJson = await this.toJSON(options);

await this._extractImageAssets();
await this._extractAudioAssets();
if (options.inlineAssets) {
const animationAssets = this.data?.assets;
if (!animationAssets)
throw createError("Failed to inline assets, the animation's assets are undefined.");
throw new DotLottieError("Failed to inline assets, the animation's assets are undefined.");
const images = this.imageAssets;
const audios = this.audioAssets;
for (const asset of animationAssets) {

@@ -352,2 +381,10 @@ if ("w" in asset && "h" in asset && !("xt" in asset) && "p" in asset) {

}
} else if (isAudioAsset(asset)) {
for (const audio of audios) {
if (audio.fileName === asset.p) {
asset.e = 1;
asset.u = "";
asset.p = await audio.toDataURL();
}
}
}

@@ -578,2 +615,142 @@ }

// src/common/lottie-audio-common.ts
var LottieAudioCommon = class {
constructor(options) {
__publicField(this, "_data");
__publicField(this, "_id", "");
__publicField(this, "_url");
__publicField(this, "_fileName", "");
__publicField(this, "_parentAnimations");
__publicField(this, "_zipOptions");
this._requireValidId(options.id);
this._requireValidFileName(options.fileName);
this._zipOptions = options.zipOptions ?? {};
if (options.data) {
this._data = options.data;
}
if (options.id) {
this._id = options.id;
}
if (options.url) {
this._url = options.url;
}
if (options.fileName) {
this._fileName = options.fileName;
}
this._parentAnimations = options.parentAnimations || [];
}
get zipOptions() {
return this._zipOptions;
}
set zipOptions(zipOptions) {
this._zipOptions = zipOptions;
}
get fileName() {
return this._fileName;
}
set fileName(fileName) {
if (!fileName)
throw new DotLottieError("Invalid audio file name", "ASSET_NOT_FOUND" /* ASSET_NOT_FOUND */);
this._fileName = fileName;
}
get id() {
return this._id;
}
set id(id) {
if (!id)
throw new DotLottieError("Invalid audio id", "ASSET_NOT_FOUND" /* ASSET_NOT_FOUND */);
this._id = id;
}
get data() {
return this._data;
}
set data(data) {
if (!data) {
throw new DotLottieError("Invalid data");
}
this._data = data;
}
get parentAnimations() {
return this._parentAnimations;
}
set parentAnimations(parentAnimations) {
this._parentAnimations = parentAnimations;
}
async toDataURL() {
if (this._data && this._isDataURL(this._data))
return this.data;
const arrayBuffer = await this.toArrayBuffer();
return dataUrlFromU8(new Uint8Array(arrayBuffer));
}
renameAudio(newName) {
this.id = newName;
if (this.fileName) {
let fileExt = this.fileName.split(".").pop();
if (!fileExt) {
fileExt = ".png";
}
this.fileName = `${newName}.${fileExt}`;
}
}
async toArrayBuffer() {
const blob = await (await this.toBlob()).arrayBuffer();
return blob;
}
async toBlob() {
if (!this._data && this._url) {
this._data = await this._fromUrlToBlob(this._url);
}
if (!this._data) {
throw new Error("Invalid data");
}
if (this._isDataURL(this._data)) {
const data = this._data;
const [header, base64] = data.split(",");
if ((!header || !base64) && data.length) {
return new Blob([data]);
}
if (!header || !base64) {
throw new Error("Invalid data");
}
const type = header.replace("data:", "").replace(/;base64$/, "");
return new Blob([base64], { type });
}
if (this._isArrayBuffer(this._data)) {
return new Blob([this._data]);
}
if (this._isBlob(this._data)) {
return this._data;
}
throw new Error("Invalid data");
}
async _fromUrlToBlob(url) {
const response = await fetch(url);
return response.blob();
}
_isArrayBuffer(data) {
return data instanceof ArrayBuffer;
}
_isDataURL(data) {
return typeof data === "string" && data.startsWith("data:");
}
_isBlob(data) {
return data instanceof Blob;
}
_requireValidId(id) {
if (!id)
throw new DotLottieError("Invalid audio id");
}
_requireValidFileName(fileName) {
if (!fileName)
throw new DotLottieError("Invalid audio fileName");
}
};
// src/node/lottie-audio.ts
var LottieAudio = class extends LottieAudioCommon {
constructor(options) {
super(options);
}
};
// src/lottie-animation.ts

@@ -621,2 +798,31 @@ var LottieAnimation = class extends LottieAnimationCommon {

}
async _extractAudioAssets() {
if (!this._data)
throw new DotLottieError("Asset extraction failed.");
const animationAssets = this._data.assets;
if (!animationAssets)
throw new DotLottieError("Asset extraction failed.");
for (const asset of animationAssets) {
if (isAudioAsset(asset)) {
const audioData = asset.p.split(",");
if (!audioData.length || !audioData[0] || !audioData[1]) {
break;
}
let extType = null;
const fileType = getExtensionTypeFromBase64(asset.p);
extType = fileType;
const fileName = `${asset.id}.${extType}`;
this._audioAssets.push(new LottieAudio({
data: asset.p,
id: asset.id,
fileName,
parentAnimations: [this]
}));
asset.p = fileName;
asset.u = "/audio/";
asset.e = 0;
}
}
return false;
}
};

@@ -623,0 +829,0 @@

@@ -1,2 +0,2 @@

import { b as LottieImageCommon, d as ImageOptions } from './dotlottie-theme-common-8a5aef58.js';
import { b as LottieImageCommon, e as ImageOptions } from './dotlottie-theme-common-5a67e6de.js';
import 'fflate';

@@ -3,0 +3,0 @@ import '@lottiefiles/lottie-types';

@@ -99,3 +99,5 @@ import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, minValue, maxValue, tuple } from 'valibot';

svg: "image/svg+xml",
webp: "image/webp"
webp: "image/webp",
mpeg: "audio/mpeg",
mp3: "audio/mp3"
};

@@ -108,3 +110,5 @@ var MIME_CODES = {

webp: [82, 73, 70, 70, 87, 69, 66, 80],
svg: [60, 63, 120]
svg: [60, 63, 120],
mp3: [73, 68, 51, 3, 0, 0, 0, 0],
mpeg: [73, 68, 51, 3, 0, 0, 0, 0]
};

@@ -111,0 +115,0 @@ var getMimeTypeFromBase64 = (base64) => {

@@ -1,2 +0,2 @@

import { a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-8a5aef58.js';
import { a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-5a67e6de.js';
import 'fflate';

@@ -3,0 +3,0 @@ import '@lottiefiles/lottie-types';

@@ -1,3 +0,3 @@

import { D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, C as ConversionOptions } from './dotlottie-common-ef2ab054.js';
import { A as AnimationOptions } from './dotlottie-theme-common-bb92738d.js';
import { D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, C as ConversionOptions } from './dotlottie-common-0230512e.js';
import { A as AnimationOptions } from './dotlottie-theme-common-64f5005b.js';
import 'fflate';

@@ -4,0 +4,0 @@ import './dotlottie-state-machine-common-e02ef581.js';

@@ -15,3 +15,3 @@ import { strToU8, zip, unzip, strFromU8 } from 'fflate';

name: "@dotlottie/dotlottie-js",
version: "0.5.2",
version: "0.6.0",
type: "module",

@@ -72,10 +72,10 @@ description: "This library helps in creating and modifying .lottie files.",

"browser-image-hash": "0.0.5",
fflate: "0.7.4",
sharp: "0.32.0",
fflate: "0.8.0",
sharp: "0.32.5",
"sharp-phash": "2.1.0",
valibot: "^0.9.0"
valibot: "^0.13.1"
},
devDependencies: {
"@lottiefiles/lottie-types": "^1.1.0",
"@types/jasmine": "4.3.2",
"@lottiefiles/lottie-types": "^1.2.1",
"@types/jasmine": "4.3.5",
"@types/node": "18.0.6",

@@ -85,5 +85,5 @@ "@types/sharp": "0.31.1",

esbuild: "0.14.49",
jasmine: "5.0.0",
"jasmine-browser-runner": "2.0.0",
"jasmine-core": "5.0.0",
jasmine: "5.1.0",
"jasmine-browser-runner": "2.2.0",
"jasmine-core": "5.1.1",
"js-base64": "3.7.5",

@@ -188,3 +188,5 @@ nodemon: "2.0.20",

svg: "image/svg+xml",
webp: "image/webp"
webp: "image/webp",
mpeg: "audio/mpeg",
mp3: "audio/mp3"
};

@@ -197,3 +199,5 @@ var MIME_CODES = {

webp: [82, 73, 70, 70, 87, 69, 66, 80],
svg: [60, 63, 120]
svg: [60, 63, 120],
mp3: [73, 68, 51, 3, 0, 0, 0, 0],
mpeg: [73, 68, 51, 3, 0, 0, 0, 0]
};

@@ -206,3 +210,5 @@ var MIME_TO_EXTENSION = {

"image/svg+xml": "svg",
"image/webp": "webp"
"image/webp": "webp",
"audio/mpeg": "mpeg",
"audio/mp3": "mp3"
};

@@ -284,2 +290,8 @@ var base64ToUint8Array = (base64String) => {

}
function isImageAsset(asset) {
return "w" in asset && "h" in asset && !("xt" in asset) && "p" in asset;
}
function isAudioAsset(asset) {
return !("h" in asset) && !("w" in asset) && "p" in asset && "e" in asset && "u" in asset && "id" in asset;
}

@@ -603,2 +615,43 @@ // src/common/dotlottie-state-machine-common.ts

}
_renameAudio(animation, newName, audioId) {
animation.audioAssets.forEach((audioAsset) => {
if (audioAsset.id === audioId) {
audioAsset.renameAudio(newName);
if (!animation.data)
throw new DotLottieError("No animation data available.");
const animationAssets = animation.data.assets;
if (!animationAssets)
throw new DotLottieError("No audio assets to rename.");
for (const asset of animationAssets) {
if (isAudioAsset(asset)) {
if (asset.id === audioId) {
asset.p = audioAsset.fileName;
}
}
}
}
});
}
_renameAudioAssets() {
const audio = /* @__PURE__ */ new Map();
this.animations.forEach((animation) => {
audio.set(animation.id, animation.audioAssets);
});
let size = 0;
audio.forEach((value) => {
size += value.length;
});
for (let i = this.animations.length - 1; i >= 0; i -= 1) {
const animation = this.animations.at(i);
if (animation) {
for (let j = animation.audioAssets.length - 1; j >= 0; j -= 1) {
const audioAsset = animation.audioAssets.at(j);
if (audioAsset) {
this._renameAudio(animation, `audio_${size}`, audioAsset.id);
size -= 1;
}
}
}
}
}
_addLottieAnimation(animation) {

@@ -611,9 +664,10 @@ if (this._animationsMap.get(animation.id)) {

}
async _findImageAssetAndInline(animation) {
async _findAssetsAndInline(animation) {
const animationAssets = animation.data?.assets;
if (!animationAssets)
throw createError("Failed to inline assets, the animation's assets are undefined.");
throw new DotLottieError("Failed to inline assets, the animation's assets are undefined.");
const images = this.getImages();
const audios = this.getAudio();
for (const asset of animationAssets) {
if ("w" in asset && "h" in asset && !("xt" in asset) && "p" in asset) {
if (isImageAsset(asset)) {
for (const image of images) {

@@ -626,2 +680,10 @@ if (image.fileName === asset.p) {

}
} else if (isAudioAsset(asset)) {
for (const audio of audios) {
if (audio.fileName === asset.p) {
asset.e = 1;
asset.u = "";
asset.p = await audio.toDataURL();
}
}
}

@@ -636,4 +698,4 @@ }

if (!dataWithInlinedImages)
throw createError("Failed to find animation.");
dataWithInlinedImages = await this._findImageAssetAndInline(dataWithInlinedImages);
throw new DotLottieError("Failed to find animation.");
dataWithInlinedImages = await this._findAssetsAndInline(dataWithInlinedImages);
return dataWithInlinedImages;

@@ -665,2 +727,9 @@ }

}
getAudio() {
const audio = [];
this.animations.map((animation) => {
return audio.push(...animation.audioAssets);
});
return audio;
}
getTheme(themeId) {

@@ -716,2 +785,3 @@ return this._themesMap.get(themeId);

this._renameImageAssets();
this._renameAudioAssets();
}

@@ -895,2 +965,3 @@ const parallelPlugins = [];

__publicField(this, "_imageAssets", []);
__publicField(this, "_audioAssets", []);
__publicField(this, "_themesMap", /* @__PURE__ */ new Map());

@@ -953,2 +1024,8 @@ __publicField(this, "_defaultTheme");

}
get audioAssets() {
return this._audioAssets;
}
set audioAssets(audioAssets) {
this._audioAssets = audioAssets;
}
get data() {

@@ -1029,4 +1106,7 @@ return this._data;

async _extractImageAssets() {
throw createError("_extractImageAssets(): Promise<boolean> method not implemented in concrete class");
throw new DotLottieError("_extractImageAssets(): Promise<boolean> method not implemented in concrete class");
}
async _extractAudioAssets() {
throw new DotLottieError("_extractAudioAssets(): Promise<boolean> method not implemented in concrete class");
}
async toBlob(options = {}) {

@@ -1043,7 +1123,9 @@ const dataJson = await this.toJSON(options);

await this._extractImageAssets();
await this._extractAudioAssets();
if (options.inlineAssets) {
const animationAssets = this.data?.assets;
if (!animationAssets)
throw createError("Failed to inline assets, the animation's assets are undefined.");
throw new DotLottieError("Failed to inline assets, the animation's assets are undefined.");
const images = this.imageAssets;
const audios = this.audioAssets;
for (const asset of animationAssets) {

@@ -1058,2 +1140,10 @@ if ("w" in asset && "h" in asset && !("xt" in asset) && "p" in asset) {

}
} else if (isAudioAsset(asset)) {
for (const audio of audios) {
if (audio.fileName === asset.p) {
asset.e = 1;
asset.u = "";
asset.p = await audio.toDataURL();
}
}
}

@@ -1415,2 +1505,135 @@ }

};
// src/common/lottie-audio-common.ts
var LottieAudioCommon = class {
constructor(options) {
__publicField(this, "_data");
__publicField(this, "_id", "");
__publicField(this, "_url");
__publicField(this, "_fileName", "");
__publicField(this, "_parentAnimations");
__publicField(this, "_zipOptions");
this._requireValidId(options.id);
this._requireValidFileName(options.fileName);
this._zipOptions = options.zipOptions ?? {};
if (options.data) {
this._data = options.data;
}
if (options.id) {
this._id = options.id;
}
if (options.url) {
this._url = options.url;
}
if (options.fileName) {
this._fileName = options.fileName;
}
this._parentAnimations = options.parentAnimations || [];
}
get zipOptions() {
return this._zipOptions;
}
set zipOptions(zipOptions) {
this._zipOptions = zipOptions;
}
get fileName() {
return this._fileName;
}
set fileName(fileName) {
if (!fileName)
throw new DotLottieError("Invalid audio file name", "ASSET_NOT_FOUND" /* ASSET_NOT_FOUND */);
this._fileName = fileName;
}
get id() {
return this._id;
}
set id(id) {
if (!id)
throw new DotLottieError("Invalid audio id", "ASSET_NOT_FOUND" /* ASSET_NOT_FOUND */);
this._id = id;
}
get data() {
return this._data;
}
set data(data) {
if (!data) {
throw new DotLottieError("Invalid data");
}
this._data = data;
}
get parentAnimations() {
return this._parentAnimations;
}
set parentAnimations(parentAnimations) {
this._parentAnimations = parentAnimations;
}
async toDataURL() {
if (this._data && this._isDataURL(this._data))
return this.data;
const arrayBuffer = await this.toArrayBuffer();
return dataUrlFromU8(new Uint8Array(arrayBuffer));
}
renameAudio(newName) {
this.id = newName;
if (this.fileName) {
let fileExt = this.fileName.split(".").pop();
if (!fileExt) {
fileExt = ".png";
}
this.fileName = `${newName}.${fileExt}`;
}
}
async toArrayBuffer() {
const blob = await (await this.toBlob()).arrayBuffer();
return blob;
}
async toBlob() {
if (!this._data && this._url) {
this._data = await this._fromUrlToBlob(this._url);
}
if (!this._data) {
throw new Error("Invalid data");
}
if (this._isDataURL(this._data)) {
const data = this._data;
const [header, base64] = data.split(",");
if ((!header || !base64) && data.length) {
return new Blob([data]);
}
if (!header || !base64) {
throw new Error("Invalid data");
}
const type = header.replace("data:", "").replace(/;base64$/, "");
return new Blob([base64], { type });
}
if (this._isArrayBuffer(this._data)) {
return new Blob([this._data]);
}
if (this._isBlob(this._data)) {
return this._data;
}
throw new Error("Invalid data");
}
async _fromUrlToBlob(url) {
const response = await fetch(url);
return response.blob();
}
_isArrayBuffer(data) {
return data instanceof ArrayBuffer;
}
_isDataURL(data) {
return typeof data === "string" && data.startsWith("data:");
}
_isBlob(data) {
return data instanceof Blob;
}
_requireValidId(id) {
if (!id)
throw new DotLottieError("Invalid audio id");
}
_requireValidFileName(fileName) {
if (!fileName)
throw new DotLottieError("Invalid audio fileName");
}
};
var DuplicateImageDetector = class extends DuplicateImageDetectorCommon {

@@ -1436,2 +1659,9 @@ distanceTo(imageHash, targetImageHash) {

// src/node/lottie-audio.ts
var LottieAudio = class extends LottieAudioCommon {
constructor(options) {
super(options);
}
};
// src/node/lottie-image.ts

@@ -1455,6 +1685,6 @@ var LottieImage2 = class extends LottieImageCommon {

if (!this._data)
throw createError("Asset extraction failed.");
throw new DotLottieError("Failed to extract image assets: Animation data does not exist");
const animationAssets = this._data.assets;
if (!animationAssets)
throw createError("Asset extraction failed.");
throw new DotLottieError("Failed to extract image assets: No assets found inside animation");
for (const asset of animationAssets) {

@@ -1483,2 +1713,31 @@ if ("w" in asset && "h" in asset && !("xt" in asset) && "p" in asset) {

}
async _extractAudioAssets() {
if (!this._data)
throw new DotLottieError("Failed to extract audio assets: Animation data does not exist");
const animationAssets = this._data.assets;
if (!animationAssets)
throw new DotLottieError("Failed to extract image assets: No assets found inside animation");
for (const asset of animationAssets) {
if (isAudioAsset(asset)) {
const audioData = asset.p.split(",");
if (!audioData.length || !audioData[0] || !audioData[1]) {
break;
}
let extType = null;
const fileType = getExtensionTypeFromBase64(asset.p);
extType = fileType;
const fileName = `${asset.id}.${extType}`;
this._audioAssets.push(new LottieAudio({
data: asset.p,
id: asset.id,
fileName,
parentAnimations: [this]
}));
asset.p = fileName;
asset.u = "/audio/";
asset.e = 0;
}
}
return false;
}
};

@@ -1536,2 +1795,3 @@

const imageAssets = animation.imageAssets;
const audioAssets = animation.audioAssets;
for (const asset of imageAssets) {

@@ -1541,2 +1801,6 @@ const dataAsString = await asset.toDataURL();

}
for (const asset of audioAssets) {
const dataAsString = await asset.toDataURL();
dotlottie[`audio/${asset.fileName}`] = [base64ToUint8Array(dataAsString), asset.zipOptions];
}
}

@@ -1574,2 +1838,3 @@ for (const theme of this.themes) {

const tmpImages = [];
const tmpAudio = [];
if (contentObj["manifest.json"] instanceof Uint8Array) {

@@ -1633,2 +1898,15 @@ try {

}));
} else if (key.startsWith("audio/")) {
const audioId = /audio\/(.+)\./u.exec(key)?.[1];
if (!audioId) {
throw new DotLottieError("Invalid audio id");
}
const base64 = Buffer.from(decompressedFile).toString("base64");
const ext = getExtensionTypeFromBase64(base64);
const audioDataURL = `data:audio/${ext};base64,${base64}`;
tmpAudio.push(new LottieAudio({
id: audioId,
data: audioDataURL,
fileName: key.split("/")[1] || ""
}));
} else if (key.startsWith("themes/") && key.endsWith(".lss")) {

@@ -1683,11 +1961,28 @@ const themeId = /themes\/(.+)\.lss/u.exec(key)?.[1];

}
for (const audio of tmpAudio) {
for (const parentAnimation of dotlottie.animations) {
if (parentAnimation.data) {
const animationAssets = parentAnimation.data.assets;
if (animationAssets) {
for (const asset of animationAssets) {
if (isAudioAsset(asset)) {
if (asset.p.includes(audio.id)) {
audio.parentAnimations.push(parentAnimation);
parentAnimation.audioAssets.push(audio);
}
}
}
}
}
}
}
} catch (err) {
throw createError(`Invalid manifest inside buffer! ${err.message}`);
throw new DotLottieError(`Invalid manifest inside buffer! ${err.message}`);
}
} else {
throw createError("Invalid buffer");
throw new DotLottieError("Invalid buffer");
}
} catch (err) {
if (err instanceof Error) {
throw createError(err.message);
throw new DotLottieError(err.message);
}

@@ -1694,0 +1989,0 @@ }

@@ -1,3 +0,3 @@

import { b as LottieImageCommon } from './dotlottie-theme-common-bb92738d.js';
import { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-cdc11ffe.js';
import { b as LottieImageCommon } from './dotlottie-theme-common-64f5005b.js';
import { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-0c431fe7.js';
import 'fflate';

@@ -7,3 +7,3 @@ import '@lottiefiles/lottie-types';

import 'valibot';
import './dotlottie-common-ef2ab054.js';
import './dotlottie-common-0230512e.js';
import './dotlottie-state-machine-common-e02ef581.js';

@@ -10,0 +10,0 @@

@@ -100,3 +100,5 @@ import phash from 'sharp-phash';

svg: "image/svg+xml",
webp: "image/webp"
webp: "image/webp",
mpeg: "audio/mpeg",
mp3: "audio/mp3"
};

@@ -109,3 +111,5 @@ var MIME_CODES = {

webp: [82, 73, 70, 70, 87, 69, 66, 80],
svg: [60, 63, 120]
svg: [60, 63, 120],
mp3: [73, 68, 51, 3, 0, 0, 0, 0],
mpeg: [73, 68, 51, 3, 0, 0, 0, 0]
};

@@ -112,0 +116,0 @@ var getMimeTypeFromBase64 = (base64) => {

@@ -5,5 +5,5 @@ export { DotLottie } from './dotlottie.js';

export { LottieTheme } from './lottie-theme.js';
export { C as ConversionOptions, D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, G as GetAnimationOptions } from './dotlottie-common-ef2ab054.js';
export { c as AnimationData, A as AnimationOptions, E as ExportOptions, I as ImageData, d as ImageOptions, L as LottieAnimationCommon, b as LottieImageCommon, a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-bb92738d.js';
export { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-cdc11ffe.js';
export { C as ConversionOptions, D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, G as GetAnimationOptions } from './dotlottie-common-0230512e.js';
export { d as AnimationData, A as AnimationOptions, f as AudioData, g as AudioOptions, E as ExportOptions, I as ImageData, e as ImageOptions, L as LottieAnimationCommon, c as LottieAudioCommon, b as LottieImageCommon, a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-64f5005b.js';
export { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-0c431fe7.js';
import { Asset, Animation } from '@lottiefiles/lottie-types';

@@ -185,2 +185,21 @@ import { UnzipFileFilter, Unzipped } from 'fflate';

/**
* Checks if an asset is an audio asset.
*
* @remarks
* This function accepts an asset object and determines whether it represents an audio asset.
* It returns `true` if it's an audio asset, `false` otherwise.
*
* @param asset - The asset object to check.
* @returns `true` if it's an audio asset, `false` otherwise.
*
* @example
* ```typescript
* const asset = { e: 0, u: 'music/', p: 'audio.mp3' };
* const isAudio = isAudioAsset(asset); // true
* ```
*
* @public
*/
declare function isAudioAsset(asset: Asset.Value): asset is Asset.Image;
/**
* Unzips the .lottie file.

@@ -315,2 +334,66 @@ *

/**
* Retrieves an audio from the given DotLottie object by its filename.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array, the filename of the audio to retrieve, and an optional filter function.
* It returns a Promise that resolves to the audio data URL or `undefined` if not found.
*
* @param dotLottie - The Uint8Array of DotLottie data.
* @param filename - The filename of the image to get.
* @param filter - An optional filter function to apply on the unzipping process.
* @returns A Promise that resolves with the audio data URL or `undefined` if not found.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const filename = 'alarm.mp3';
* const imageData = await getAudio(dotLottie, filename);
* ```
*
* @public
*/
declare function getAudio(dotLottie: Uint8Array, filename: string, filter?: UnzipFileFilter): Promise<string | undefined>;
/**
* Retrieves all audio files from the given DotLottie object.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array and an optional filter function to further refine the extraction.
* It returns a Promise that resolves to a record containing the audio data URLs mapped by their ID.
*
* @param dotLottie - The Uint8Array of DotLottie data.
* @param filter - An optional filter function to apply on the unzipping process.
* @returns A Promise that resolves to a record containing the audio data URLs mapped by their ID.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const allAudio = await getAllAudio(dotLottie);
* ```
*
* @public
*/
declare function getAllAudio(dotLottie: Uint8Array, filter?: UnzipFileFilter): Promise<Record<string, string>>;
/**
* Inlines audio assets for the given animations within a DotLottie object.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array and a record containing the animations to process.
* It identifies the audio used in the animations and replaces their references with the actual audio data.
* This operation is performed asynchronously, and the function returns a Promise that resolves when the operation is complete.
*
* @param dotLottie - The DotLottie object containing the animations.
* @param animations - A record containing the animations to process.
* @returns A Promise that resolves when the operation is complete, returning nothing.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const animations = { animation1: {...}, animation2: {...} };
* await inlineAudioAssets(dotLottie, animations);
* ```
*
* @public
*/
declare function inlineAudioAssets(dotLottie: Uint8Array, animations: Record<string, Animation>): Promise<void>;
/**
* Retrieves an image from the given DotLottie object by its filename.

@@ -504,2 +587,2 @@ *

export { DotLottieError, ErrorCodes, MIME_CODES, MIME_TO_EXTENSION, MIME_TYPES, MimeCodes, MimeToExtension, MimeTypes, base64ToUint8Array, createError, dataUrlFromU8, getAnimation, getAnimations, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, getStateMachine, getStateMachines, getTheme, getThemes, inlineImageAssets, isImageAsset, isValidURL, loadFromArrayBuffer, loadFromURL, unzipDotLottie, unzipDotLottieFile, validateDotLottie };
export { DotLottieError, ErrorCodes, MIME_CODES, MIME_TO_EXTENSION, MIME_TYPES, MimeCodes, MimeToExtension, MimeTypes, base64ToUint8Array, createError, dataUrlFromU8, getAllAudio, getAnimation, getAnimations, getAudio, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, getStateMachine, getStateMachines, getTheme, getThemes, inlineAudioAssets, inlineImageAssets, isAudioAsset, isImageAsset, isValidURL, loadFromArrayBuffer, loadFromURL, unzipDotLottie, unzipDotLottieFile, validateDotLottie };

@@ -1,2 +0,2 @@

import { L as LottieAnimationCommon, A as AnimationOptions } from './dotlottie-theme-common-bb92738d.js';
import { L as LottieAnimationCommon, A as AnimationOptions } from './dotlottie-theme-common-64f5005b.js';
import 'fflate';

@@ -23,3 +23,2 @@ import '@lottiefiles/lottie-types';

/**
* to do : Support more than image assets (fonts...)
*

@@ -31,4 +30,11 @@ * Extract image assets from the animation.

protected _extractImageAssets(): Promise<boolean>;
/**
*
* Extract audio assets from the animation.
*
* @returns boolean - true on error otherwise false on success
*/
protected _extractAudioAssets(): Promise<boolean>;
}
export { LottieAnimation };

@@ -99,3 +99,5 @@ import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, minValue, maxValue, tuple } from 'valibot';

svg: "image/svg+xml",
webp: "image/webp"
webp: "image/webp",
mpeg: "audio/mpeg",
mp3: "audio/mp3"
};

@@ -108,3 +110,5 @@ var MIME_CODES = {

webp: [82, 73, 70, 70, 87, 69, 66, 80],
svg: [60, 63, 120]
svg: [60, 63, 120],
mp3: [73, 68, 51, 3, 0, 0, 0, 0],
mpeg: [73, 68, 51, 3, 0, 0, 0, 0]
};

@@ -117,3 +121,5 @@ var MIME_TO_EXTENSION = {

"image/svg+xml": "svg",
"image/webp": "webp"
"image/webp": "webp",
"audio/mpeg": "mpeg",
"audio/mp3": "mp3"
};

@@ -155,2 +161,10 @@ var getMimeTypeFromBase64 = (base64) => {

};
var DotLottieError = class extends Error {
constructor(message, code) {
super(message);
__publicField(this, "code");
this.name = "[dotlottie-js]";
this.code = code;
}
};
var createError = (message) => {

@@ -171,2 +185,5 @@ const error = new Error(`[dotlottie-js]: ${message}`);

}
function isAudioAsset(asset) {
return !("h" in asset) && !("w" in asset) && "p" in asset && "e" in asset && "u" in asset && "id" in asset;
}

@@ -189,2 +206,3 @@ // src/common/lottie-animation-common.ts

__publicField(this, "_imageAssets", []);
__publicField(this, "_audioAssets", []);
__publicField(this, "_themesMap", /* @__PURE__ */ new Map());

@@ -247,2 +265,8 @@ __publicField(this, "_defaultTheme");

}
get audioAssets() {
return this._audioAssets;
}
set audioAssets(audioAssets) {
this._audioAssets = audioAssets;
}
get data() {

@@ -323,4 +347,7 @@ return this._data;

async _extractImageAssets() {
throw createError("_extractImageAssets(): Promise<boolean> method not implemented in concrete class");
throw new DotLottieError("_extractImageAssets(): Promise<boolean> method not implemented in concrete class");
}
async _extractAudioAssets() {
throw new DotLottieError("_extractAudioAssets(): Promise<boolean> method not implemented in concrete class");
}
async toBlob(options = {}) {

@@ -337,7 +364,9 @@ const dataJson = await this.toJSON(options);

await this._extractImageAssets();
await this._extractAudioAssets();
if (options.inlineAssets) {
const animationAssets = this.data?.assets;
if (!animationAssets)
throw createError("Failed to inline assets, the animation's assets are undefined.");
throw new DotLottieError("Failed to inline assets, the animation's assets are undefined.");
const images = this.imageAssets;
const audios = this.audioAssets;
for (const asset of animationAssets) {

@@ -352,2 +381,10 @@ if ("w" in asset && "h" in asset && !("xt" in asset) && "p" in asset) {

}
} else if (isAudioAsset(asset)) {
for (const audio of audios) {
if (audio.fileName === asset.p) {
asset.e = 1;
asset.u = "";
asset.p = await audio.toDataURL();
}
}
}

@@ -571,2 +608,142 @@ }

// src/common/lottie-audio-common.ts
var LottieAudioCommon = class {
constructor(options) {
__publicField(this, "_data");
__publicField(this, "_id", "");
__publicField(this, "_url");
__publicField(this, "_fileName", "");
__publicField(this, "_parentAnimations");
__publicField(this, "_zipOptions");
this._requireValidId(options.id);
this._requireValidFileName(options.fileName);
this._zipOptions = options.zipOptions ?? {};
if (options.data) {
this._data = options.data;
}
if (options.id) {
this._id = options.id;
}
if (options.url) {
this._url = options.url;
}
if (options.fileName) {
this._fileName = options.fileName;
}
this._parentAnimations = options.parentAnimations || [];
}
get zipOptions() {
return this._zipOptions;
}
set zipOptions(zipOptions) {
this._zipOptions = zipOptions;
}
get fileName() {
return this._fileName;
}
set fileName(fileName) {
if (!fileName)
throw new DotLottieError("Invalid audio file name", "ASSET_NOT_FOUND" /* ASSET_NOT_FOUND */);
this._fileName = fileName;
}
get id() {
return this._id;
}
set id(id) {
if (!id)
throw new DotLottieError("Invalid audio id", "ASSET_NOT_FOUND" /* ASSET_NOT_FOUND */);
this._id = id;
}
get data() {
return this._data;
}
set data(data) {
if (!data) {
throw new DotLottieError("Invalid data");
}
this._data = data;
}
get parentAnimations() {
return this._parentAnimations;
}
set parentAnimations(parentAnimations) {
this._parentAnimations = parentAnimations;
}
async toDataURL() {
if (this._data && this._isDataURL(this._data))
return this.data;
const arrayBuffer = await this.toArrayBuffer();
return dataUrlFromU8(new Uint8Array(arrayBuffer));
}
renameAudio(newName) {
this.id = newName;
if (this.fileName) {
let fileExt = this.fileName.split(".").pop();
if (!fileExt) {
fileExt = ".png";
}
this.fileName = `${newName}.${fileExt}`;
}
}
async toArrayBuffer() {
const blob = await (await this.toBlob()).arrayBuffer();
return blob;
}
async toBlob() {
if (!this._data && this._url) {
this._data = await this._fromUrlToBlob(this._url);
}
if (!this._data) {
throw new Error("Invalid data");
}
if (this._isDataURL(this._data)) {
const data = this._data;
const [header, base64] = data.split(",");
if ((!header || !base64) && data.length) {
return new Blob([data]);
}
if (!header || !base64) {
throw new Error("Invalid data");
}
const type = header.replace("data:", "").replace(/;base64$/, "");
return new Blob([base64], { type });
}
if (this._isArrayBuffer(this._data)) {
return new Blob([this._data]);
}
if (this._isBlob(this._data)) {
return this._data;
}
throw new Error("Invalid data");
}
async _fromUrlToBlob(url) {
const response = await fetch(url);
return response.blob();
}
_isArrayBuffer(data) {
return data instanceof ArrayBuffer;
}
_isDataURL(data) {
return typeof data === "string" && data.startsWith("data:");
}
_isBlob(data) {
return data instanceof Blob;
}
_requireValidId(id) {
if (!id)
throw new DotLottieError("Invalid audio id");
}
_requireValidFileName(fileName) {
if (!fileName)
throw new DotLottieError("Invalid audio fileName");
}
};
// src/node/lottie-audio.ts
var LottieAudio = class extends LottieAudioCommon {
constructor(options) {
super(options);
}
};
// src/node/lottie-image.ts

@@ -590,6 +767,6 @@ var LottieImage2 = class extends LottieImageCommon {

if (!this._data)
throw createError("Asset extraction failed.");
throw new DotLottieError("Failed to extract image assets: Animation data does not exist");
const animationAssets = this._data.assets;
if (!animationAssets)
throw createError("Asset extraction failed.");
throw new DotLottieError("Failed to extract image assets: No assets found inside animation");
for (const asset of animationAssets) {

@@ -618,2 +795,31 @@ if ("w" in asset && "h" in asset && !("xt" in asset) && "p" in asset) {

}
async _extractAudioAssets() {
if (!this._data)
throw new DotLottieError("Failed to extract audio assets: Animation data does not exist");
const animationAssets = this._data.assets;
if (!animationAssets)
throw new DotLottieError("Failed to extract image assets: No assets found inside animation");
for (const asset of animationAssets) {
if (isAudioAsset(asset)) {
const audioData = asset.p.split(",");
if (!audioData.length || !audioData[0] || !audioData[1]) {
break;
}
let extType = null;
const fileType = getExtensionTypeFromBase64(asset.p);
extType = fileType;
const fileName = `${asset.id}.${extType}`;
this._audioAssets.push(new LottieAudio({
data: asset.p,
id: asset.id,
fileName,
parentAnimations: [this]
}));
asset.p = fileName;
asset.u = "/audio/";
asset.e = 0;
}
}
return false;
}
};

@@ -620,0 +826,0 @@

@@ -1,2 +0,2 @@

import { b as LottieImageCommon, d as ImageOptions } from './dotlottie-theme-common-bb92738d.js';
import { b as LottieImageCommon, e as ImageOptions } from './dotlottie-theme-common-64f5005b.js';
import 'fflate';

@@ -3,0 +3,0 @@ import '@lottiefiles/lottie-types';

@@ -99,3 +99,5 @@ import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, minValue, maxValue, tuple } from 'valibot';

svg: "image/svg+xml",
webp: "image/webp"
webp: "image/webp",
mpeg: "audio/mpeg",
mp3: "audio/mp3"
};

@@ -108,3 +110,5 @@ var MIME_CODES = {

webp: [82, 73, 70, 70, 87, 69, 66, 80],
svg: [60, 63, 120]
svg: [60, 63, 120],
mp3: [73, 68, 51, 3, 0, 0, 0, 0],
mpeg: [73, 68, 51, 3, 0, 0, 0, 0]
};

@@ -111,0 +115,0 @@ var getMimeTypeFromBase64 = (base64) => {

@@ -1,2 +0,2 @@

import { a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-bb92738d.js';
import { a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-64f5005b.js';
import 'fflate';

@@ -3,0 +3,0 @@ import '@lottiefiles/lottie-types';

{
"name": "@dotlottie/dotlottie-js",
"version": "0.5.2",
"version": "0.6.0",
"type": "module",

@@ -42,10 +42,10 @@ "description": "This library helps in creating and modifying .lottie files.",

"browser-image-hash": "0.0.5",
"fflate": "0.7.4",
"sharp": "0.32.0",
"fflate": "0.8.0",
"sharp": "0.32.5",
"sharp-phash": "2.1.0",
"valibot": "^0.9.0"
"valibot": "^0.13.1"
},
"devDependencies": {
"@lottiefiles/lottie-types": "^1.1.0",
"@types/jasmine": "4.3.2",
"@lottiefiles/lottie-types": "^1.2.1",
"@types/jasmine": "4.3.5",
"@types/node": "18.0.6",

@@ -55,5 +55,5 @@ "@types/sharp": "0.31.1",

"esbuild": "0.14.49",
"jasmine": "5.0.0",
"jasmine-browser-runner": "2.0.0",
"jasmine-core": "5.0.0",
"jasmine": "5.1.0",
"jasmine-browser-runner": "2.2.0",
"jasmine-core": "5.1.1",
"js-base64": "3.7.5",

@@ -60,0 +60,0 @@ "nodemon": "2.0.20",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc