Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dotlottie/dotlottie-js

Package Overview
Dependencies
Maintainers
3
Versions
61
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.4.2 to 0.5.0

dist/dotlottie-common-c96bbbae.d.ts

8

dist/dotlottie.d.ts

@@ -1,6 +0,8 @@

import { D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, C as ConversionOptions } from './dotlottie-common-4b1285fb.js';
import { A as AnimationOptions } from './dotlottie-theme-common-c0898cfb.js';
import { D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, C as ConversionOptions } from './dotlottie-common-c96bbbae.js';
import { A as AnimationOptions } from './dotlottie-theme-common-6db03840.js';
import 'fflate';
import './dotlottie-state-machine-common-c1e36f9f.js';
import './manifest-a5e5a634.js';
import 'valibot';
import '@lottiefiles/lottie-types';
import 'valibot';

@@ -7,0 +9,0 @@ /**

@@ -1,7 +0,9 @@

import { b as LottieImageCommon } from './dotlottie-theme-common-c0898cfb.js';
import { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-81b75e37.js';
import { b as LottieImageCommon } from './dotlottie-theme-common-6db03840.js';
import { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-a73b241d.js';
import 'fflate';
import '@lottiefiles/lottie-types';
import './manifest-a5e5a634.js';
import 'valibot';
import './dotlottie-common-4b1285fb.js';
import './dotlottie-common-c96bbbae.js';
import './dotlottie-state-machine-common-c1e36f9f.js';

@@ -8,0 +10,0 @@ /**

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

import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue } from 'valibot';
import 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';

@@ -471,5 +471,5 @@ var __create = Object.create;

};
Hash2.prototype.arrayChunk = function(array2, chunk) {
return __spreadArray2([], __read2(Array(Math.ceil(array2.length / chunk)).keys())).map(function(index) {
return array2.slice(index * chunk, index * chunk + chunk);
Hash2.prototype.arrayChunk = function(array3, chunk) {
return __spreadArray2([], __read2(Array(Math.ceil(array3.length / chunk)).keys())).map(function(index) {
return array3.slice(index * chunk, index * chunk + chunk);
});

@@ -727,2 +727,3 @@ };

});
var StateMachineSchema = array(string());
object({

@@ -738,6 +739,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
record(string(), StateSettingsSchema);
var MIME_TYPES = {

@@ -744,0 +788,0 @@ jpeg: "image/jpeg",

@@ -5,8 +5,12 @@ 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-4b1285fb.js';
import { M as Manifest } from './dotlottie-theme-common-c0898cfb.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, M as Manifest, g as ManifestAnimation, f as ManifestAnimationSchema, j as ManifestSchema, i as ManifestTheme, h as ManifestThemeSchema, P as PlayMode, e as PlayModeSchema, T as ThemeOptions } from './dotlottie-theme-common-c0898cfb.js';
export { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-81b75e37.js';
export { C as ConversionOptions, D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, G as GetAnimationOptions } from './dotlottie-common-c96bbbae.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-6db03840.js';
export { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-a73b241d.js';
import { Asset, Animation } from '@lottiefiles/lottie-types';
import { UnzipFileFilter, Unzipped } from 'fflate';
import { LottieStateMachine } from './lottie-state-machine.js';
export { LottieStateMachine } from './lottie-state-machine.js';
import { M as Manifest } from './manifest-a5e5a634.js';
export { M as Manifest, a as ManifestAnimation, c as ManifestAnimationSchema, g as ManifestSchema, f as ManifestState, e as ManifestTheme, d as ManifestThemeSchema, P as PlayMode, b as PlayModeSchema, S as StateMachineSchema } from './manifest-a5e5a634.js';
export { D as DotLottieStateMachineCommon, a as DotLottieStateMachineCommonOptions, z as DotLottieStates, y as DotLottieStatesSchema, b as PlaybackOptions, P as PlaybackOptionsSchema, c as StateAnimationSettings, S as StateAnimationSettingsSchema, t as StateInfo, s as StateInfoSchema, x as StateSettings, w as StateSettingsSchema, v as StateTransitionEvents, u as StateTransitionEventsSchema, h as StateTransitionOnAfter, g as StateTransitionOnAfterSchema, f as StateTransitionOnClick, e as StateTransitionOnClickSchema, p as StateTransitionOnComplete, o as StateTransitionOnCompleteSchema, j as StateTransitionOnEnter, i as StateTransitionOnEnterSchema, l as StateTransitionOnMouseEnter, k as StateTransitionOnMouseEnterSchema, n as StateTransitionOnMouseLeave, m as StateTransitionOnMouseLeaveSchema, r as StateTransitionOnShow, q as StateTransitionOnShowSchema, d as Transitionable, T as TransitionableSchema } from './dotlottie-state-machine-common-c1e36f9f.js';
import 'valibot';

@@ -87,2 +91,3 @@

INVALID_DOTLOTTIE = "INVALID_DOTLOTTIE",
INVALID_STATEMACHINE = "INVALID_STATEMACHINE",
INVALID_URL = "INVALID_URL"

@@ -451,3 +456,41 @@ }

declare function getTheme(dotLottie: Uint8Array, themeId: string, filter?: UnzipFileFilter): Promise<string | undefined>;
/**
* Retrieves the state machines from the given DotLottie object.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array and an optional filter function to refine the extraction of state machines.
* It returns a Promise that resolves to a record containing the state machines mapped by their ID.
*
* @param dotLottie - The DotLottie object containing the state machines.
* @param filter - An optional function to filter the files to be unzipped.
* @returns A Promise that resolves to a record containing the state machines mapped by their ID.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const machines = await getStateMachines(dotLottie);
* ```
*/
declare function getStateMachines(dotLottie: Uint8Array, filter?: UnzipFileFilter): Promise<Record<string, string>>;
/**
* Retrieves a specific state machine by ID from the given DotLottie object.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array, the state ID to retrieve, and an optional filter function.
* It returns a Promise that resolves to the state machine as a string or `undefined` if not found.
*
* @param dotLottie - The DotLottie object containing the theme.
* @param stateMachineId - The ID of the state machine to retrieve.
* @param filter - An optional function to filter the files to be unzipped.
* @returns A Promise that resolves to the state machine as a string or `undefined` if not found.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const stateMachineId = 'walk';
* const stateMachine = await getState(dotLottie, stateMachineId);
* ```
*/
declare function getStateMachine(dotLottie: Uint8Array, stateMachineId: string, filter?: UnzipFileFilter): Promise<LottieStateMachine | undefined>;
export { DotLottieError, ErrorCodes, MIME_CODES, MIME_TO_EXTENSION, MIME_TYPES, MimeCodes, MimeToExtension, MimeTypes, base64ToUint8Array, createError, dataUrlFromU8, getAnimation, getAnimations, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, 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, getAnimation, getAnimations, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, getStateMachine, getStateMachines, getTheme, getThemes, inlineImageAssets, isImageAsset, isValidURL, loadFromArrayBuffer, loadFromURL, unzipDotLottie, unzipDotLottieFile, validateDotLottie };

@@ -1,4 +0,5 @@

import { L as LottieAnimationCommon, A as AnimationOptions } from './dotlottie-theme-common-c0898cfb.js';
import { L as LottieAnimationCommon, A as AnimationOptions } from './dotlottie-theme-common-6db03840.js';
import 'fflate';
import '@lottiefiles/lottie-types';
import './manifest-a5e5a634.js';
import 'valibot';

@@ -5,0 +6,0 @@

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

import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue } from 'valibot';
import 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';

@@ -32,2 +32,3 @@ var __defProp = Object.defineProperty;

});
var StateMachineSchema = array(string());
object({

@@ -43,6 +44,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
record(string(), StateSettingsSchema);
var MIME_TYPES = {

@@ -49,0 +93,0 @@ jpeg: "image/jpeg",

@@ -1,4 +0,5 @@

import { b as LottieImageCommon, d as ImageOptions } from './dotlottie-theme-common-c0898cfb.js';
import { b as LottieImageCommon, d as ImageOptions } from './dotlottie-theme-common-6db03840.js';
import 'fflate';
import '@lottiefiles/lottie-types';
import './manifest-a5e5a634.js';
import 'valibot';

@@ -5,0 +6,0 @@

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

import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue } from 'valibot';
import 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';

@@ -32,2 +32,3 @@ var __defProp = Object.defineProperty;

});
var StateMachineSchema = array(string());
object({

@@ -43,6 +44,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
record(string(), StateSettingsSchema);
var MIME_TYPES = {

@@ -49,0 +93,0 @@ jpeg: "image/jpeg",

@@ -1,4 +0,5 @@

import { a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-c0898cfb.js';
import { a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-6db03840.js';
import 'fflate';
import '@lottiefiles/lottie-types';
import './manifest-a5e5a634.js';
import 'valibot';

@@ -5,0 +6,0 @@

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

import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue } from 'valibot';
import 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';

@@ -32,2 +32,3 @@ var __defProp = Object.defineProperty;

});
var StateMachineSchema = array(string());
object({

@@ -43,6 +44,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
record(string(), StateSettingsSchema);
var createError = (message) => {

@@ -49,0 +93,0 @@ const error = new Error(`[dotlottie-js]: ${message}`);

@@ -1,6 +0,8 @@

import { D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, C as ConversionOptions } from './dotlottie-common-36257f31.js';
import { A as AnimationOptions } from './dotlottie-theme-common-523bf789.js';
import { D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, C as ConversionOptions } from './dotlottie-common-4634b3b2.js';
import { A as AnimationOptions } from './dotlottie-theme-common-1b7aa184.js';
import 'fflate';
import './dotlottie-state-machine-common-a2841e06.js';
import './manifest-6e5571d4.js';
import 'valibot';
import '@lottiefiles/lottie-types';
import 'valibot';

@@ -7,0 +9,0 @@ /**

import { strToU8, zip, unzip, strFromU8 } from 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue, safeParse, flatten } from 'valibot';
import phash from 'sharp-phash';

@@ -15,3 +15,3 @@

name: "@dotlottie/dotlottie-js",
version: "0.4.2",
version: "0.5.0",
type: "module",

@@ -119,2 +119,3 @@ description: "This library helps in creating and modifying .lottie files.",

});
var StateMachineSchema = array(string());
object({

@@ -130,6 +131,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
var StateInfoSchema = object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
var DotLottieStatesSchema = record(string(), StateSettingsSchema);
var MIME_TYPES = {

@@ -203,2 +247,10 @@ jpeg: "image/jpeg",

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

@@ -228,2 +280,73 @@ const error = new Error(`[dotlottie-js]: ${message}`);

// src/common/dotlottie-state-machine-common.ts
var DotLottieStateMachineCommon = class {
constructor(options) {
__publicField(this, "_descriptor");
__publicField(this, "_zipOptions");
__publicField(this, "_states");
this._requireValidId(options.descriptor.id);
this._requireValidStates(options.states);
this._requireValidDescriptor(options.descriptor);
this._descriptor = options.descriptor;
this._zipOptions = options.zipOptions ?? {};
this._states = options.states;
}
get zipOptions() {
return this._zipOptions;
}
set zipOptions(zipOptions) {
this._zipOptions = zipOptions;
}
get id() {
return this._descriptor.id;
}
set id(id) {
this._requireValidId(id);
this._descriptor.id = id;
}
get states() {
return this._states;
}
set states(states) {
this._states = states;
}
get initial() {
return this._descriptor.initial;
}
set initial(initial) {
this._descriptor.initial = initial;
}
get descriptor() {
return this._descriptor;
}
set descriptor(descriptor) {
this._descriptor = descriptor;
}
toString() {
return JSON.stringify({
descriptor: this._descriptor,
states: this._states
});
}
_requireValidId(id) {
if (!id) {
throw createError("Invalid id.");
}
}
_requireValidDescriptor(descriptor) {
const result = safeParse(StateInfoSchema, descriptor);
if (!result.success) {
const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.error).nested, null, 2)}`;
throw new DotLottieError(`Invalid descriptor: ${error}`, "INVALID_STATEMACHINE" /* INVALID_STATEMACHINE */);
}
}
_requireValidStates(states) {
const result = safeParse(DotLottieStatesSchema, states);
if (!result.success) {
const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.error).nested, null, 2)}`;
throw new DotLottieError(`Invalid states: ${error}`, "INVALID_STATEMACHINE" /* INVALID_STATEMACHINE */);
}
}
};
// src/common/dotlottie-theme-common.ts

@@ -321,2 +444,3 @@ var LottieThemeCommon = class {

__publicField(this, "_themesMap", /* @__PURE__ */ new Map());
__publicField(this, "_stateMachinesMap", /* @__PURE__ */ new Map());
__publicField(this, "_author");

@@ -393,2 +517,5 @@ __publicField(this, "_description");

}
get stateMachines() {
return Array.from(this._stateMachinesMap.values());
}
setCustomData(customData) {

@@ -537,2 +664,3 @@ this._customData = customData ?? {};

const themesList = Array.from(this._themesMap.values());
const stateMachinesList = Array.from(this._stateMachinesMap.keys());
const activeAnimationId = animationsList.find((value) => value.defaultActiveAnimation)?.id ?? "";

@@ -566,2 +694,5 @@ const manifest = {

}
if (stateMachinesList.length > 0) {
manifest.states = stateMachinesList;
}
return manifest;

@@ -651,2 +782,10 @@ }

});
dotlottie.stateMachines.forEach((stateMachine) => {
const stateOption = {
states: stateMachine.states,
descriptor: { id: stateMachine.id, initial: stateMachine.initial },
zipOptions: stateMachine.zipOptions
};
mergedDotlottie.addStateMachine(stateOption);
});
}

@@ -696,2 +835,14 @@ return mergedDotlottie;

}
addStateMachine(stateMachineOptions) {
const newState = new DotLottieStateMachineCommon(stateMachineOptions);
this._stateMachinesMap.set(stateMachineOptions.descriptor.id, newState);
return this;
}
getStateMachine(stateId) {
return this._stateMachinesMap.get(stateId);
}
removeStateMachine(stateMachineId) {
this._stateMachinesMap.delete(stateMachineId);
return this;
}
_requireValidAuthor(author) {

@@ -1380,2 +1531,6 @@ if (!author)

}
for (const state of this.stateMachines) {
const stateData = state.toString();
dotlottie[`states/${state.id}.json`] = [strToU8(stateData), state.zipOptions];
}
const dotlottieArrayBuffer = await new Promise((resolve, reject) => {

@@ -1481,2 +1636,13 @@ zip(dotlottie, options?.zipOptions || {}, (err, data) => {

});
} else if (key.startsWith("states/") && key.endsWith(".json")) {
const stateId = /states\/(.+)\.json/u.exec(key)?.[1];
if (!stateId) {
throw createError("Invalid theme id");
}
manifest.states?.forEach((state) => {
if (state === stateId) {
const decodedStateMachine = JSON.parse(decodedStr);
dotlottie.addStateMachine(decodedStateMachine);
}
});
}

@@ -1502,3 +1668,3 @@ }

} catch (err) {
throw createError("Invalid manifest inside buffer!");
throw createError(`Invalid manifest inside buffer! ${err.message}`);
}

@@ -1505,0 +1671,0 @@ } else {

@@ -1,7 +0,9 @@

import { b as LottieImageCommon } from './dotlottie-theme-common-523bf789.js';
import { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-880dd2a0.js';
import { b as LottieImageCommon } from './dotlottie-theme-common-1b7aa184.js';
import { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-e2921603.js';
import 'fflate';
import '@lottiefiles/lottie-types';
import './manifest-6e5571d4.js';
import 'valibot';
import './dotlottie-common-36257f31.js';
import './dotlottie-common-4634b3b2.js';
import './dotlottie-state-machine-common-a2841e06.js';

@@ -8,0 +10,0 @@ /**

import phash from 'sharp-phash';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue } from 'valibot';
import 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';

@@ -33,2 +33,3 @@ var __defProp = Object.defineProperty;

});
var StateMachineSchema = array(string());
object({

@@ -44,6 +45,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
record(string(), StateSettingsSchema);
var MIME_TYPES = {

@@ -50,0 +94,0 @@ jpeg: "image/jpeg",

@@ -5,8 +5,12 @@ 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-36257f31.js';
import { M as Manifest } from './dotlottie-theme-common-523bf789.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, M as Manifest, g as ManifestAnimation, f as ManifestAnimationSchema, j as ManifestSchema, i as ManifestTheme, h as ManifestThemeSchema, P as PlayMode, e as PlayModeSchema, T as ThemeOptions } from './dotlottie-theme-common-523bf789.js';
export { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-880dd2a0.js';
export { C as ConversionOptions, D as DotLottieCommon, a as DotLottieOptions, b as DotLottiePlugin, G as GetAnimationOptions } from './dotlottie-common-4634b3b2.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-1b7aa184.js';
export { D as DuplicateImageDetectorCommon } from './duplicate-image-detector-common-e2921603.js';
import { Asset, Animation } from '@lottiefiles/lottie-types';
import { UnzipFileFilter, Unzipped } from 'fflate';
import { D as DotLottieStateMachineCommon, a as DotLottieStateMachineCommonOptions } from './dotlottie-state-machine-common-a2841e06.js';
export { D as DotLottieStateMachineCommon, a as DotLottieStateMachineCommonOptions, z as DotLottieStates, y as DotLottieStatesSchema, b as PlaybackOptions, P as PlaybackOptionsSchema, c as StateAnimationSettings, S as StateAnimationSettingsSchema, t as StateInfo, s as StateInfoSchema, x as StateSettings, w as StateSettingsSchema, v as StateTransitionEvents, u as StateTransitionEventsSchema, h as StateTransitionOnAfter, g as StateTransitionOnAfterSchema, f as StateTransitionOnClick, e as StateTransitionOnClickSchema, p as StateTransitionOnComplete, o as StateTransitionOnCompleteSchema, j as StateTransitionOnEnter, i as StateTransitionOnEnterSchema, l as StateTransitionOnMouseEnter, k as StateTransitionOnMouseEnterSchema, n as StateTransitionOnMouseLeave, m as StateTransitionOnMouseLeaveSchema, r as StateTransitionOnShow, q as StateTransitionOnShowSchema, d as Transitionable, T as TransitionableSchema } from './dotlottie-state-machine-common-a2841e06.js';
import { M as Manifest } from './manifest-6e5571d4.js';
export { M as Manifest, a as ManifestAnimation, c as ManifestAnimationSchema, g as ManifestSchema, f as ManifestState, e as ManifestTheme, d as ManifestThemeSchema, P as PlayMode, b as PlayModeSchema, S as StateMachineSchema } from './manifest-6e5571d4.js';
export { LottieStateMachine } from './lottie-state-machine.js';
import 'valibot';

@@ -18,2 +22,10 @@

declare class LottieStateMachine extends DotLottieStateMachineCommon {
constructor(options: DotLottieStateMachineCommonOptions);
}
/**
* Copyright 2023 Design Barn Inc.
*/
interface MimeTypes {

@@ -88,2 +100,3 @@ [key: string]: string;

INVALID_DOTLOTTIE = "INVALID_DOTLOTTIE",
INVALID_STATEMACHINE = "INVALID_STATEMACHINE",
INVALID_URL = "INVALID_URL"

@@ -452,3 +465,41 @@ }

declare function getTheme(dotLottie: Uint8Array, themeId: string, filter?: UnzipFileFilter): Promise<string | undefined>;
/**
* Retrieves the state machines from the given DotLottie object.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array and an optional filter function to refine the extraction of state machines.
* It returns a Promise that resolves to a record containing the state machines mapped by their ID.
*
* @param dotLottie - The DotLottie object containing the state machines.
* @param filter - An optional function to filter the files to be unzipped.
* @returns A Promise that resolves to a record containing the state machines mapped by their ID.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const machines = await getStateMachines(dotLottie);
* ```
*/
declare function getStateMachines(dotLottie: Uint8Array, filter?: UnzipFileFilter): Promise<Record<string, string>>;
/**
* Retrieves a specific state machine by ID from the given DotLottie object.
*
* @remarks
* This function accepts a DotLottie object as a Uint8Array, the state ID to retrieve, and an optional filter function.
* It returns a Promise that resolves to the state machine as a string or `undefined` if not found.
*
* @param dotLottie - The DotLottie object containing the theme.
* @param stateMachineId - The ID of the state machine to retrieve.
* @param filter - An optional function to filter the files to be unzipped.
* @returns A Promise that resolves to the state machine as a string or `undefined` if not found.
*
* @example
* ```typescript
* const dotLottie = new Uint8Array(...);
* const stateMachineId = 'walk';
* const stateMachine = await getState(dotLottie, stateMachineId);
* ```
*/
declare function getStateMachine(dotLottie: Uint8Array, stateMachineId: string, filter?: UnzipFileFilter): Promise<LottieStateMachine | undefined>;
export { DotLottieError, ErrorCodes, MIME_CODES, MIME_TO_EXTENSION, MIME_TYPES, MimeCodes, MimeToExtension, MimeTypes, base64ToUint8Array, createError, dataUrlFromU8, getAnimation, getAnimations, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, 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, getAnimation, getAnimations, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, getStateMachine, getStateMachines, getTheme, getThemes, inlineImageAssets, isImageAsset, isValidURL, loadFromArrayBuffer, loadFromURL, unzipDotLottie, unzipDotLottieFile, validateDotLottie };
import { unzip, strFromU8, strToU8, zip } from 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, safeParse, flatten } from 'valibot';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue, safeParse, flatten } from 'valibot';
import phash from 'sharp-phash';

@@ -15,3 +15,3 @@

name: "@dotlottie/dotlottie-js",
version: "0.4.2",
version: "0.5.0",
type: "module",

@@ -119,2 +119,3 @@ description: "This library helps in creating and modifying .lottie files.",

});
var StateMachineSchema = array(string());
var ManifestSchema = object({

@@ -130,6 +131,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
var StateInfoSchema = object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
var DotLottieStatesSchema = record(string(), StateSettingsSchema);
var MIME_TYPES = {

@@ -206,2 +250,3 @@ jpeg: "image/jpeg",

ErrorCodes2["INVALID_DOTLOTTIE"] = "INVALID_DOTLOTTIE";
ErrorCodes2["INVALID_STATEMACHINE"] = "INVALID_STATEMACHINE";
ErrorCodes2["INVALID_URL"] = "INVALID_URL";

@@ -422,3 +467,98 @@ return ErrorCodes2;

}
async function getStateMachines(dotLottie, filter) {
const statesMap = {};
const unzippedStates = await unzipDotLottie(dotLottie, (file) => {
const name = file.name.replace("states/", "").replace(".json", "");
return file.name.startsWith("states/") && (!filter || filter({ ...file, name }));
});
for (const statePath in unzippedStates) {
const data = unzippedStates[statePath];
if (data instanceof Uint8Array) {
const themeId = statePath.replace("states/", "").replace(".json", "");
statesMap[themeId] = strFromU8(data, false);
}
}
return statesMap;
}
async function getStateMachine(dotLottie, stateMachineId, filter) {
const stateMachineFilename = `states/${stateMachineId}.json`;
const unzippedStateMachine = await unzipDotLottieFile(dotLottie, stateMachineFilename, filter);
if (typeof unzippedStateMachine === "undefined") {
return void 0;
}
const stateMachine = JSON.parse(strFromU8(unzippedStateMachine, false));
return stateMachine;
}
// src/common/dotlottie-state-machine-common.ts
var DotLottieStateMachineCommon = class {
constructor(options) {
__publicField(this, "_descriptor");
__publicField(this, "_zipOptions");
__publicField(this, "_states");
this._requireValidId(options.descriptor.id);
this._requireValidStates(options.states);
this._requireValidDescriptor(options.descriptor);
this._descriptor = options.descriptor;
this._zipOptions = options.zipOptions ?? {};
this._states = options.states;
}
get zipOptions() {
return this._zipOptions;
}
set zipOptions(zipOptions) {
this._zipOptions = zipOptions;
}
get id() {
return this._descriptor.id;
}
set id(id) {
this._requireValidId(id);
this._descriptor.id = id;
}
get states() {
return this._states;
}
set states(states) {
this._states = states;
}
get initial() {
return this._descriptor.initial;
}
set initial(initial) {
this._descriptor.initial = initial;
}
get descriptor() {
return this._descriptor;
}
set descriptor(descriptor) {
this._descriptor = descriptor;
}
toString() {
return JSON.stringify({
descriptor: this._descriptor,
states: this._states
});
}
_requireValidId(id) {
if (!id) {
throw createError("Invalid id.");
}
}
_requireValidDescriptor(descriptor) {
const result = safeParse(StateInfoSchema, descriptor);
if (!result.success) {
const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.error).nested, null, 2)}`;
throw new DotLottieError(`Invalid descriptor: ${error}`, "INVALID_STATEMACHINE" /* INVALID_STATEMACHINE */);
}
}
_requireValidStates(states) {
const result = safeParse(DotLottieStatesSchema, states);
if (!result.success) {
const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.error).nested, null, 2)}`;
throw new DotLottieError(`Invalid states: ${error}`, "INVALID_STATEMACHINE" /* INVALID_STATEMACHINE */);
}
}
};
// src/common/dotlottie-theme-common.ts

@@ -516,2 +656,3 @@ var LottieThemeCommon = class {

__publicField(this, "_themesMap", /* @__PURE__ */ new Map());
__publicField(this, "_stateMachinesMap", /* @__PURE__ */ new Map());
__publicField(this, "_author");

@@ -588,2 +729,5 @@ __publicField(this, "_description");

}
get stateMachines() {
return Array.from(this._stateMachinesMap.values());
}
setCustomData(customData) {

@@ -732,2 +876,3 @@ this._customData = customData ?? {};

const themesList = Array.from(this._themesMap.values());
const stateMachinesList = Array.from(this._stateMachinesMap.keys());
const activeAnimationId = animationsList.find((value) => value.defaultActiveAnimation)?.id ?? "";

@@ -761,2 +906,5 @@ const manifest = {

}
if (stateMachinesList.length > 0) {
manifest.states = stateMachinesList;
}
return manifest;

@@ -846,2 +994,10 @@ }

});
dotlottie.stateMachines.forEach((stateMachine) => {
const stateOption = {
states: stateMachine.states,
descriptor: { id: stateMachine.id, initial: stateMachine.initial },
zipOptions: stateMachine.zipOptions
};
mergedDotlottie.addStateMachine(stateOption);
});
}

@@ -891,2 +1047,14 @@ return mergedDotlottie;

}
addStateMachine(stateMachineOptions) {
const newState = new DotLottieStateMachineCommon(stateMachineOptions);
this._stateMachinesMap.set(stateMachineOptions.descriptor.id, newState);
return this;
}
getStateMachine(stateId) {
return this._stateMachinesMap.get(stateId);
}
removeStateMachine(stateMachineId) {
this._stateMachinesMap.delete(stateMachineId);
return this;
}
_requireValidAuthor(author) {

@@ -1575,2 +1743,6 @@ if (!author)

}
for (const state of this.stateMachines) {
const stateData = state.toString();
dotlottie[`states/${state.id}.json`] = [strToU8(stateData), state.zipOptions];
}
const dotlottieArrayBuffer = await new Promise((resolve, reject) => {

@@ -1676,2 +1848,13 @@ zip(dotlottie, options?.zipOptions || {}, (err, data) => {

});
} else if (key.startsWith("states/") && key.endsWith(".json")) {
const stateId = /states\/(.+)\.json/u.exec(key)?.[1];
if (!stateId) {
throw createError("Invalid theme id");
}
manifest.states?.forEach((state) => {
if (state === stateId) {
const decodedStateMachine = JSON.parse(decodedStr);
dotlottie.addStateMachine(decodedStateMachine);
}
});
}

@@ -1697,3 +1880,3 @@ }

} catch (err) {
throw createError("Invalid manifest inside buffer!");
throw createError(`Invalid manifest inside buffer! ${err.message}`);
}

@@ -1719,3 +1902,10 @@ } else {

export { DotLottie, DotLottieCommon, DotLottieError, DotLottiePlugin, DuplicateImageDetectorCommon, ErrorCodes, LottieAnimation, LottieAnimationCommon, LottieImage2 as LottieImage, LottieImageCommon, LottieTheme, LottieThemeCommon, MIME_CODES, MIME_TO_EXTENSION, MIME_TYPES, ManifestAnimationSchema, ManifestSchema, ManifestThemeSchema, PlayMode, PlayModeSchema, base64ToUint8Array, createError, dataUrlFromU8, getAnimation, getAnimations, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, getTheme, getThemes, inlineImageAssets, isImageAsset, isValidURL, loadFromArrayBuffer, loadFromURL, unzipDotLottie, unzipDotLottieFile, validateDotLottie };
// src/node/lottie-state-machine.ts
var LottieStateMachine = class extends DotLottieStateMachineCommon {
constructor(options) {
super(options);
}
};
export { DotLottie, DotLottieCommon, DotLottieError, DotLottiePlugin, DotLottieStateMachineCommon, DotLottieStatesSchema, DuplicateImageDetectorCommon, ErrorCodes, LottieAnimation, LottieAnimationCommon, LottieImage2 as LottieImage, LottieImageCommon, LottieStateMachine, LottieTheme, LottieThemeCommon, MIME_CODES, MIME_TO_EXTENSION, MIME_TYPES, ManifestAnimationSchema, ManifestSchema, ManifestThemeSchema, PlayMode, PlayModeSchema, PlaybackOptionsSchema, StateAnimationSettingsSchema, StateInfoSchema, StateMachineSchema, StateSettingsSchema, StateTransitionEventsSchema, StateTransitionOnAfterSchema, StateTransitionOnClickSchema, StateTransitionOnCompleteSchema, StateTransitionOnEnterSchema, StateTransitionOnMouseEnterSchema, StateTransitionOnMouseLeaveSchema, StateTransitionOnShowSchema, TransitionableSchema, base64ToUint8Array, createError, dataUrlFromU8, getAnimation, getAnimations, getExtensionTypeFromBase64, getImage, getImages, getManifest, getMimeTypeFromBase64, getStateMachine, getStateMachines, getTheme, getThemes, inlineImageAssets, isImageAsset, isValidURL, loadFromArrayBuffer, loadFromURL, unzipDotLottie, unzipDotLottieFile, validateDotLottie };
//# sourceMappingURL=index.js.map

@@ -1,4 +0,5 @@

import { L as LottieAnimationCommon, A as AnimationOptions } from './dotlottie-theme-common-523bf789.js';
import { L as LottieAnimationCommon, A as AnimationOptions } from './dotlottie-theme-common-1b7aa184.js';
import 'fflate';
import '@lottiefiles/lottie-types';
import './manifest-6e5571d4.js';
import 'valibot';

@@ -5,0 +6,0 @@

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

import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue } from 'valibot';
import 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';

@@ -32,2 +32,3 @@ var __defProp = Object.defineProperty;

});
var StateMachineSchema = array(string());
object({

@@ -43,6 +44,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
record(string(), StateSettingsSchema);
var MIME_TYPES = {

@@ -49,0 +93,0 @@ jpeg: "image/jpeg",

@@ -1,4 +0,5 @@

import { b as LottieImageCommon, d as ImageOptions } from './dotlottie-theme-common-523bf789.js';
import { b as LottieImageCommon, d as ImageOptions } from './dotlottie-theme-common-1b7aa184.js';
import 'fflate';
import '@lottiefiles/lottie-types';
import './manifest-6e5571d4.js';
import 'valibot';

@@ -5,0 +6,0 @@

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

import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue } from 'valibot';
import 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';

@@ -32,2 +32,3 @@ var __defProp = Object.defineProperty;

});
var StateMachineSchema = array(string());
object({

@@ -43,6 +44,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
record(string(), StateSettingsSchema);
var MIME_TYPES = {

@@ -49,0 +93,0 @@ jpeg: "image/jpeg",

@@ -1,4 +0,5 @@

import { a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-523bf789.js';
import { a as LottieThemeCommon, T as ThemeOptions } from './dotlottie-theme-common-1b7aa184.js';
import 'fflate';
import '@lottiefiles/lottie-types';
import './manifest-6e5571d4.js';
import 'valibot';

@@ -5,0 +6,0 @@

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

import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any, omit, merge, tuple, minValue, maxValue } from 'valibot';
import 'fflate';
import { nativeEnum, object, optional, boolean, string, union, literal, number, array, record, any } from 'valibot';

@@ -32,2 +32,3 @@ var __defProp = Object.defineProperty;

});
var StateMachineSchema = array(string());
object({

@@ -43,6 +44,49 @@ activeAnimationId: optional(string()),

themes: optional(array(ManifestThemeSchema)),
states: optional(StateMachineSchema),
version: optional(string())
});
// src/common/utils.ts
// src/common/dotlottie-state.ts
var PlaybackOptionsSchema = omit(ManifestAnimationSchema, ["id"]);
var StateAnimationSettingsSchema = merge([
PlaybackOptionsSchema,
object({
playOnScroll: optional(tuple([number([minValue(0), maxValue(1)]), number([minValue(0), maxValue(1)])])),
segments: optional(union([array(number()), string()]))
})
]);
var TransitionableSchema = object({
state: string()
});
var StateTransitionOnClickSchema = TransitionableSchema;
var StateTransitionOnAfterSchema = merge([TransitionableSchema, object({ ms: number() })]);
var StateTransitionOnEnterSchema = merge([TransitionableSchema, object({ count: number() })]);
var StateTransitionOnMouseEnterSchema = TransitionableSchema;
var StateTransitionOnMouseLeaveSchema = TransitionableSchema;
var StateTransitionOnCompleteSchema = TransitionableSchema;
var StateTransitionOnShowSchema = merge([
TransitionableSchema,
object({ threshold: optional(array(number([minValue(0), maxValue(1)]))) })
]);
object({
id: string(),
initial: string()
});
var StateTransitionEventsSchema = object({
onAfter: optional(StateTransitionOnAfterSchema),
onClick: optional(StateTransitionOnClickSchema),
onComplete: optional(StateTransitionOnCompleteSchema),
onEnter: optional(StateTransitionOnEnterSchema),
onMouseEnter: optional(StateTransitionOnMouseEnterSchema),
onMouseLeave: optional(StateTransitionOnMouseLeaveSchema),
onShow: optional(StateTransitionOnShowSchema)
});
var StateSettingsSchema = merge([
StateTransitionEventsSchema,
object({
animationId: optional(string()),
playbackSettings: StateAnimationSettingsSchema
})
]);
record(string(), StateSettingsSchema);
var createError = (message) => {

@@ -49,0 +93,0 @@ const error = new Error(`[dotlottie-js]: ${message}`);

{
"name": "@dotlottie/dotlottie-js",
"version": "0.4.2",
"version": "0.5.0",
"type": "module",

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

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 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