@depup/lottie-react 2.4.1-depup.0 → 3.0.0-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +4 -10
  3. package/build/_virtual/_rolldown/runtime.cjs +23 -0
  4. package/build/animation/Lottie.cjs +39 -0
  5. package/build/animation/Lottie.d.cts +47 -0
  6. package/build/animation/Lottie.d.ts +47 -0
  7. package/build/animation/Lottie.js +37 -0
  8. package/build/animation/LottieDisplay.cjs +55 -0
  9. package/build/animation/LottieDisplay.d.cts +46 -0
  10. package/build/animation/LottieDisplay.d.ts +46 -0
  11. package/build/animation/LottieDisplay.js +53 -0
  12. package/build/animation/LottieInstanceContext.cjs +16 -0
  13. package/build/animation/LottieInstanceContext.js +17 -0
  14. package/build/animation/LottieLight.cjs +19 -0
  15. package/build/animation/LottieLight.d.cts +23 -0
  16. package/build/animation/LottieLight.d.ts +23 -0
  17. package/build/animation/LottieLight.js +17 -0
  18. package/build/animation/LottieRegistryContext.cjs +36 -0
  19. package/build/animation/LottieRegistryContext.js +35 -0
  20. package/build/animation/LottieSvg.cjs +20 -0
  21. package/build/animation/LottieSvg.d.cts +24 -0
  22. package/build/animation/LottieSvg.d.ts +24 -0
  23. package/build/animation/LottieSvg.js +18 -0
  24. package/build/animation/collectMarkerCrossings.cjs +38 -0
  25. package/build/animation/collectMarkerCrossings.js +38 -0
  26. package/build/animation/createLottieComponent.cjs +131 -0
  27. package/build/animation/createLottieComponent.d.cts +45 -0
  28. package/build/animation/createLottieComponent.d.ts +45 -0
  29. package/build/animation/createLottieComponent.js +131 -0
  30. package/build/animation/hasExpressions.cjs +25 -0
  31. package/build/animation/hasExpressions.js +25 -0
  32. package/build/animation/normalizeAnimationSource.cjs +38 -0
  33. package/build/animation/normalizeAnimationSource.js +38 -0
  34. package/build/animation/polymorphicForwardRef.cjs +18 -0
  35. package/build/animation/polymorphicForwardRef.js +19 -0
  36. package/build/animation/renderStyledElement.cjs +31 -0
  37. package/build/animation/renderStyledElement.js +31 -0
  38. package/build/animation/resolveSeekTarget.cjs +97 -0
  39. package/build/animation/resolveSeekTarget.js +95 -0
  40. package/build/animation/styleLayer.cjs +24 -0
  41. package/build/animation/styleLayer.js +24 -0
  42. package/build/animation/stylePrecedence.cjs +12 -0
  43. package/build/animation/stylePrecedence.js +12 -0
  44. package/build/animation/types.cjs +71 -0
  45. package/build/animation/types.d.cts +461 -0
  46. package/build/animation/types.d.ts +461 -0
  47. package/build/animation/types.js +68 -0
  48. package/build/animation/useLottie.cjs +40 -0
  49. package/build/animation/useLottie.d.cts +36 -0
  50. package/build/animation/useLottie.d.ts +36 -0
  51. package/build/animation/useLottie.js +38 -0
  52. package/build/animation/useLottieAnimation.cjs +434 -0
  53. package/build/animation/useLottieAnimation.d.cts +40 -0
  54. package/build/animation/useLottieAnimation.d.ts +40 -0
  55. package/build/animation/useLottieAnimation.js +434 -0
  56. package/build/animation/useLottieInstance.cjs +20 -0
  57. package/build/animation/useLottieInstance.d.cts +14 -0
  58. package/build/animation/useLottieInstance.d.ts +14 -0
  59. package/build/animation/useLottieInstance.js +20 -0
  60. package/build/animation/useLottieLight.cjs +20 -0
  61. package/build/animation/useLottieLight.d.cts +16 -0
  62. package/build/animation/useLottieLight.d.ts +16 -0
  63. package/build/animation/useLottieLight.js +18 -0
  64. package/build/animation/useLottieSvg.cjs +18 -0
  65. package/build/animation/useLottieSvg.d.cts +14 -0
  66. package/build/animation/useLottieSvg.d.ts +14 -0
  67. package/build/animation/useLottieSvg.js +16 -0
  68. package/build/controls/LottieControls.cjs +180 -0
  69. package/build/controls/LottieControls.d.cts +58 -0
  70. package/build/controls/LottieControls.d.ts +58 -0
  71. package/build/controls/LottieControls.js +178 -0
  72. package/build/controls/LottieDirectionButton.cjs +36 -0
  73. package/build/controls/LottieDirectionButton.js +35 -0
  74. package/build/controls/LottieFullscreenButton.cjs +35 -0
  75. package/build/controls/LottieFullscreenButton.js +34 -0
  76. package/build/controls/LottieLoopButton.cjs +32 -0
  77. package/build/controls/LottieLoopButton.js +31 -0
  78. package/build/controls/LottiePlayButton.cjs +34 -0
  79. package/build/controls/LottiePlayButton.js +33 -0
  80. package/build/controls/LottieReadout.cjs +61 -0
  81. package/build/controls/LottieReadout.d.cts +13 -0
  82. package/build/controls/LottieReadout.d.ts +13 -0
  83. package/build/controls/LottieReadout.js +60 -0
  84. package/build/controls/LottieSeekBar.cjs +87 -0
  85. package/build/controls/LottieSeekBar.js +86 -0
  86. package/build/controls/LottieSpeedSelect.cjs +51 -0
  87. package/build/controls/LottieSpeedSelect.js +50 -0
  88. package/build/controls/LottieStopButton.cjs +29 -0
  89. package/build/controls/LottieStopButton.js +28 -0
  90. package/build/controls/controlIcon.cjs +25 -0
  91. package/build/controls/controlIcon.js +25 -0
  92. package/build/controls/useFullscreen.cjs +46 -0
  93. package/build/controls/useFullscreen.js +46 -0
  94. package/build/controls/useShortcuts.cjs +70 -0
  95. package/build/controls/useShortcuts.js +70 -0
  96. package/build/index.cjs +36 -0
  97. package/build/index.d.cts +19 -0
  98. package/build/index.d.ts +19 -80
  99. package/build/index.js +17 -667
  100. package/build/interactions/LottieInteractions.cjs +41 -0
  101. package/build/interactions/LottieInteractions.d.cts +37 -0
  102. package/build/interactions/LottieInteractions.d.ts +37 -0
  103. package/build/interactions/LottieInteractions.js +41 -0
  104. package/build/interactions/coverProgress.cjs +55 -0
  105. package/build/interactions/coverProgress.js +53 -0
  106. package/build/interactions/lottieInView.cjs +109 -0
  107. package/build/interactions/lottieInView.d.cts +44 -0
  108. package/build/interactions/lottieInView.d.ts +44 -0
  109. package/build/interactions/lottieInView.js +109 -0
  110. package/build/interactions/lottieScrollScrub.cjs +152 -0
  111. package/build/interactions/lottieScrollScrub.d.cts +47 -0
  112. package/build/interactions/lottieScrollScrub.d.ts +47 -0
  113. package/build/interactions/lottieScrollScrub.js +152 -0
  114. package/build/interactions/types.d.cts +46 -0
  115. package/build/interactions/types.d.ts +46 -0
  116. package/build/interactions/useInteractionsRunner.cjs +142 -0
  117. package/build/interactions/useInteractionsRunner.js +141 -0
  118. package/build/interactions/useLottieInteractions.cjs +21 -0
  119. package/build/interactions/useLottieInteractions.d.cts +19 -0
  120. package/build/interactions/useLottieInteractions.d.ts +19 -0
  121. package/build/interactions/useLottieInteractions.js +21 -0
  122. package/build/overlays/LottieError.cjs +74 -0
  123. package/build/overlays/LottieError.d.cts +40 -0
  124. package/build/overlays/LottieError.d.ts +40 -0
  125. package/build/overlays/LottieError.js +72 -0
  126. package/build/overlays/LottieLoading.cjs +89 -0
  127. package/build/overlays/LottieLoading.d.cts +45 -0
  128. package/build/overlays/LottieLoading.d.ts +45 -0
  129. package/build/overlays/LottieLoading.js +87 -0
  130. package/build/overlays/overlayStyles.cjs +33 -0
  131. package/build/overlays/overlayStyles.js +33 -0
  132. package/build/utils/SubscriptionManager.cjs +42 -0
  133. package/build/utils/SubscriptionManager.d.cts +30 -0
  134. package/build/utils/SubscriptionManager.d.ts +30 -0
  135. package/build/utils/SubscriptionManager.js +42 -0
  136. package/build/utils/createLogger.cjs +25 -0
  137. package/build/utils/createLogger.js +25 -0
  138. package/build/utils/isSameJson.cjs +37 -0
  139. package/build/utils/isSameJson.js +37 -0
  140. package/build/utils/mergeRefs.cjs +37 -0
  141. package/build/utils/mergeRefs.js +37 -0
  142. package/build/utils/useStableValue.cjs +26 -0
  143. package/build/utils/useStableValue.js +26 -0
  144. package/changes.json +3 -8
  145. package/package.json +144 -89
  146. package/LICENSE +0 -46
  147. package/build/index.es.js +0 -653
  148. package/build/index.es.js.map +0 -1
  149. package/build/index.es.min.js +0 -3
  150. package/build/index.js.map +0 -1
  151. package/build/index.min.js +0 -3
  152. package/build/index.umd.js +0 -670
  153. package/build/index.umd.js.map +0 -1
  154. package/build/index.umd.min.js +0 -3
@@ -0,0 +1,461 @@
1
+ import { SubscriptionManager } from "../utils/SubscriptionManager.cjs";
2
+ import { AnimationItem, CanvasRendererConfig, HTMLRendererConfig, SVGRendererConfig } from "lottie-web";
3
+ import { ComponentPropsWithoutRef, JSX, RefCallback } from "react";
4
+ //#region src/animation/types.d.ts
5
+ /**
6
+ * The renderers lottie-web can draw an animation with.
7
+ *
8
+ * `svg` is the default and the only one the smaller builds contain. `canvas`
9
+ * draws to a bitmap, and `html` builds real DOM nodes, which is the only
10
+ * renderer that puts block content inside the display.
11
+ */
12
+ declare const LottieRenderer: {
13
+ readonly svg: "svg";
14
+ readonly canvas: "canvas";
15
+ readonly html: "html";
16
+ };
17
+ type LottieRenderer = (typeof LottieRenderer)[keyof typeof LottieRenderer];
18
+ /**
19
+ * What the animation is doing.
20
+ *
21
+ * `paused` means a person asked it to stop; `frozen` means the library stopped
22
+ * it on the animation's behalf and will start it again. Nothing sets `frozen`
23
+ * yet, and it is declared because adding a member to a union later breaks an
24
+ * exhaustive `switch` in a consumer's code.
25
+ */
26
+ declare const LottieState: {
27
+ readonly loading: "loading";
28
+ readonly playing: "playing";
29
+ readonly paused: "paused";
30
+ readonly stopped: "stopped";
31
+ readonly frozen: "frozen";
32
+ readonly error: "error";
33
+ };
34
+ type LottieState = (typeof LottieState)[keyof typeof LottieState];
35
+ /**
36
+ * Which way the animation plays.
37
+ *
38
+ * lottie-web works in `1` and `-1`, which say nothing to a reader; the
39
+ * translation happens once, where the engine is called.
40
+ */
41
+ declare const LottieDirection: {
42
+ readonly forward: "forward";
43
+ readonly reverse: "reverse";
44
+ };
45
+ type LottieDirection = (typeof LottieDirection)[keyof typeof LottieDirection];
46
+ /**
47
+ * Everything a consumer can subscribe to.
48
+ *
49
+ * `frame` is the only one that fires per frame, and it is deliberately the only
50
+ * route to the current frame, because a value that changes sixty times a second
51
+ * cannot be a value without re-rendering at that rate.
52
+ *
53
+ * `marker` announces the playhead passing a marker the animation's designer
54
+ * placed, while it is travelling: a seek or a scrub puts the playhead somewhere
55
+ * without passing anything, so it announces nothing.
56
+ *
57
+ * `ready` carries no payload. Everything that can subscribe already holds the
58
+ * instance, either as the hook's return value or through `useLottieInstance`,
59
+ * so the values it announces are read from there.
60
+ */
61
+ declare const LottieSubscription: {
62
+ readonly ready: "ready";
63
+ readonly play: "play";
64
+ readonly pause: "pause";
65
+ readonly stop: "stop";
66
+ readonly complete: "complete";
67
+ readonly loopCompleted: "loopCompleted";
68
+ readonly frame: "frame";
69
+ readonly marker: "marker";
70
+ readonly newState: "newState";
71
+ readonly error: "error";
72
+ };
73
+ type LottieSubscription = (typeof LottieSubscription)[keyof typeof LottieSubscription];
74
+ /**
75
+ * The handler each subscription takes.
76
+ *
77
+ * Declared as a `type` rather than an `interface` on purpose: an interface has
78
+ * no implicit index signature, so it cannot satisfy the constraint
79
+ * `SubscriptionManager` puts on the map it is given.
80
+ */
81
+ type LottieSubscriptions = {
82
+ [LottieSubscription.ready]: () => void;
83
+ [LottieSubscription.play]: () => void;
84
+ [LottieSubscription.pause]: () => void;
85
+ [LottieSubscription.stop]: () => void;
86
+ [LottieSubscription.complete]: () => void;
87
+ [LottieSubscription.loopCompleted]: () => void;
88
+ [LottieSubscription.frame]: (event: {
89
+ currentFrame: number;
90
+ }) => void;
91
+ [LottieSubscription.marker]: (event: {
92
+ marker: string;
93
+ }) => void;
94
+ [LottieSubscription.newState]: (event: {
95
+ state: LottieState;
96
+ }) => void;
97
+ [LottieSubscription.error]: (event: {
98
+ error: Error;
99
+ }) => void;
100
+ };
101
+ /**
102
+ * Every fact about a renderer, one row each: what it puts inside the display,
103
+ * which settings bag it accepts, and which of the smaller builds contain it.
104
+ *
105
+ * This is the only place any of those facts is recorded. A second table would
106
+ * be a second place for them to disagree, and the disagreement would be silent.
107
+ *
108
+ * `puts`, `inSvg` and `inLight` are claims about lottie-web's runtime that no
109
+ * type can check, so `types.test.ts` checks them against the real engine.
110
+ */
111
+ interface RendererRows {
112
+ svg: {
113
+ puts: "inline";
114
+ settings: SVGRendererConfig;
115
+ inSvg: true;
116
+ inLight: true;
117
+ };
118
+ canvas: {
119
+ puts: "inline";
120
+ settings: CanvasRendererConfig;
121
+ inSvg: false;
122
+ inLight: false;
123
+ };
124
+ html: {
125
+ puts: "block";
126
+ settings: HTMLRendererConfig;
127
+ inSvg: false;
128
+ inLight: false;
129
+ };
130
+ }
131
+ /**
132
+ * The renderers the svg build of the engine contains.
133
+ *
134
+ * Read off the table rather than written out, so the svg component's surface
135
+ * and the claim `types.test.ts` checks against the real engine can never be two
136
+ * different answers.
137
+ */
138
+ type RendererInSvg = { [K in LottieRenderer]: RendererRows[K]["inSvg"] extends true ? K : never; }[LottieRenderer];
139
+ /**
140
+ * The renderers the light build of the engine contains, read off the table for
141
+ * the same reason {@link RendererInSvg} is.
142
+ */
143
+ type RendererInLight = { [K in LottieRenderer]: RendererRows[K]["inLight"] extends true ? K : never; }[LottieRenderer];
144
+ /**
145
+ * Every HTML tag React will accept as an intrinsic element.
146
+ *
147
+ * The intersection is what drops the SVG tags, which cannot host an animation:
148
+ * canvas and html read `wrapper.offsetWidth` and every renderer tears down with
149
+ * `wrapper.innerText`, and `SVGSVGElement` has neither.
150
+ */
151
+ type AnyTag = Extract<keyof JSX.IntrinsicElements, keyof HTMLElementTagNameMap>;
152
+ /** Void elements. They cannot contain anything, so the animation would never appear. */
153
+ type TagWithoutChildren = "area" | "base" | "br" | "col" | "embed" | "hr" | "img" | "input" | "link" | "meta" | "source" | "track" | "wbr";
154
+ /**
155
+ * Elements whose children already mean something to the parser or to the user
156
+ * agent, so an injected animation is ignored, invalid, or never rendered.
157
+ */
158
+ type TagWithReservedChildren = "audio" | "body" | "canvas" | "colgroup" | "datalist" | "dl" | "head" | "hgroup" | "html" | "iframe" | "map" | "menu" | "noscript" | "object" | "ol" | "optgroup" | "option" | "picture" | "script" | "select" | "slot" | "style" | "table" | "tbody" | "template" | "textarea" | "tfoot" | "thead" | "title" | "tr" | "ul" | "video";
159
+ /**
160
+ * Elements whose content model is phrasing content only. They can hold the
161
+ * `<svg>` or `<canvas>` a renderer appends, because both are embedded content,
162
+ * but they cannot legally hold a `<div>`.
163
+ *
164
+ * `a`, `del` and `ins` are deliberately absent: their content model is
165
+ * transparent, so they may hold whatever their parent may hold, which makes
166
+ * `<a href="..."><div/></a>` valid and is the ordinary card-link pattern.
167
+ */
168
+ type TagWithoutBlockChildren = "abbr" | "b" | "bdi" | "bdo" | "button" | "cite" | "code" | "data" | "dfn" | "em" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "i" | "kbd" | "label" | "legend" | "mark" | "meter" | "output" | "p" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "small" | "span" | "strong" | "sub" | "summary" | "sup" | "time" | "u" | "var";
169
+ /** A tag that may hold the `<svg>` or `<canvas>` a renderer appends. */
170
+ type ContainerTag = Exclude<AnyTag, TagWithoutChildren | TagWithReservedChildren>;
171
+ /** A tag that may additionally hold a `<div>`, which is what `html` appends. */
172
+ type BlockContainerTag = Exclude<ContainerTag, TagWithoutBlockChildren>;
173
+ /**
174
+ * Carries the reason a tag was refused into the diagnostic, so the compiler
175
+ * reports what to use instead rather than only that something failed.
176
+ */
177
+ type Reject<Why extends string> = {
178
+ readonly __lottie: Why;
179
+ };
180
+ /**
181
+ * The one rule that decides `as`: block content is required when the renderer
182
+ * is `html` or when children are present, and inline content is enough
183
+ * otherwise.
184
+ *
185
+ * Written as a single type with the other two values captured as parameters,
186
+ * rather than as a union of prop objects discriminated by them. A union reports
187
+ * the first mismatch it finds, which blames `renderer` when the tag is what is
188
+ * wrong; this shape lands every message on `as`.
189
+ */
190
+ type AllowedAs<As extends AnyTag, Children, R extends LottieRenderer> = [Children] extends [undefined] ? RendererRows[R]["puts"] extends "block" ? As extends BlockContainerTag ? As : Reject<"this renderer puts a <div> inside: use a block container such as div or section"> : As extends ContainerTag ? As : Reject<"this tag cannot hold an animation"> : As extends BlockContainerTag ? As : Reject<"with children this tag must hold a <div>: use a block container such as div or section">;
191
+ /** Every attribute name any tag `as` permits declares. */
192
+ type AllowedTagAttribute = { [T in ContainerTag]: keyof ComponentPropsWithoutRef<T>; }[ContainerTag];
193
+ /**
194
+ * The element's own names a component takes over deliberately, and hands back
195
+ * itself: `children` is rendered, `className` is joined with ours. Every other
196
+ * name a component claims stops reaching the element, which is what
197
+ * {@link ElementProps} refuses.
198
+ */
199
+ type DeliberatelyTaken = "children" | "className";
200
+ /** The attribute names a component would swallow without meaning to. */
201
+ type Swallowed<Own> = Exclude<Extract<keyof Own, AllowedTagAttribute>, DeliberatelyTaken>;
202
+ /**
203
+ * Refuses a set of own props that would silently swallow an attribute.
204
+ *
205
+ * Naming a prop after an attribute costs the consumer that attribute: it lands
206
+ * on our prop, we take it out of the spread, and it never reaches the element.
207
+ * Nothing about that is visible, which is why it is checked here rather than
208
+ * left to the rule in the documentation.
209
+ *
210
+ * The constraint refers to its own parameter so that the diagnostic lands on
211
+ * the props declaration, naming the offending prop, rather than on every call
212
+ * site in a consumer's application.
213
+ */
214
+ type MustNotSwallow<Own> = [Swallowed<Own>] extends [never] ? unknown : Reject<`rename this prop, an element already uses the name: ${Swallowed<Own> & string}`>;
215
+ /**
216
+ * What a component accepts: its own props, plus every attribute of the element
217
+ * `as` names, with `as` itself validated against the tag rules.
218
+ *
219
+ * The element's version of a name the component owns is removed rather than
220
+ * merged with it. Merging is an intersection rather than a choice, so a `src`
221
+ * that accepts an object would narrow to the element's `string` and stop
222
+ * accepting one. That is the fault v2 shipped, and it is why the removal is
223
+ * derived from the own props rather than listed.
224
+ */
225
+ type ElementProps<Own extends MustNotSwallow<Own>, As extends AnyTag, Children, Renderer extends LottieRenderer> = Omit<Own, "as"> & {
226
+ as?: AllowedAs<As, Children, Renderer>;
227
+ } & Omit<ComponentPropsWithoutRef<As>, keyof Own>;
228
+ /**
229
+ * What a component accepts when the element it renders is fixed: its own props,
230
+ * plus every attribute of that element, with the same refusal of a name that
231
+ * would swallow one.
232
+ *
233
+ * The counterpart to {@link ElementProps}, for a component that presents itself
234
+ * as an element without offering a choice of which. It takes no `as`, so it
235
+ * needs none of the tag validation, and the reasons a tag can be refused are
236
+ * written for the animation rather than for anything else.
237
+ */
238
+ type FixedElementProps<Own extends MustNotSwallow<Own>, Tag extends AnyTag> = Own & Omit<ComponentPropsWithoutRef<Tag>, keyof Own>;
239
+ /**
240
+ * Makes one member of a union exclusive, by declaring every key it does not
241
+ * carry as optional-`never`.
242
+ *
243
+ * A plain union of single-key objects does **not** refuse a literal combining
244
+ * two of them: TypeScript's excess-property check against a union admits a
245
+ * property that appears in any member, so `{ marker: "a", seconds: 1 }` passes
246
+ * while `{ nonsense: true }` is still refused. Naming the other keys is what
247
+ * closes that.
248
+ */
249
+ type Only<T, Keys extends PropertyKey> = T & { [K in Exclude<Keys, keyof T>]?: never; };
250
+ /** The units a {@link LottieSeekTarget} can be written in. */
251
+ type Units = "frame" | "marker" | "percent" | "seconds";
252
+ /**
253
+ * Where to move the playhead.
254
+ *
255
+ * A plain number is a frame, which is the common case; every other unit names
256
+ * itself, so nothing collides and a typo is a compile error rather than a
257
+ * runtime guess. Exactly one unit may be given.
258
+ *
259
+ * `percent` and `seconds` are scoped to the currently playable range, like
260
+ * `playableFrames` and `playableDuration`, so a segment moves all three
261
+ * together. A marker
262
+ * resolves to the frame the designer placed it on, which is deliberately not
263
+ * what the engine's own marker seeking does.
264
+ */
265
+ type LottieSeekTarget = number | Only<{
266
+ frame: number;
267
+ }, Units> | Only<{
268
+ marker: string;
269
+ }, Units> | Only<{
270
+ percent: number;
271
+ }, Units> | Only<{
272
+ seconds: number;
273
+ }, Units>;
274
+ /**
275
+ * What may be played as a range: one range, several played in order, or the
276
+ * name of a marker that labels a span.
277
+ *
278
+ * Frames here are absolute positions in the animation, unlike
279
+ * {@link LottieSeekTarget}, whose units are relative to whatever is playable at
280
+ * the time. That difference is why a seek target is not accepted in their
281
+ * place: the same descriptor would mean two different frames.
282
+ *
283
+ * Ranges are only read, never kept or changed, which is why `readonly` tuples
284
+ * are accepted: the natural home for named ranges is an `as const` map.
285
+ */
286
+ type LottieSegments = readonly [number, number] | readonly (readonly [number, number])[] | {
287
+ marker: string;
288
+ };
289
+ /** A setter that takes either the next value or a function of the current one. */
290
+ type Setter<Value> = (next: Value | ((previous: Value) => Value)) => void;
291
+ /**
292
+ * The animation: what it is doing, and how to drive it.
293
+ *
294
+ * This is what the hook returns, what the context carries, and what the child
295
+ * components take. Reading a value from it re-renders when it changes, which is
296
+ * what separates it from the narrower {@link LottieHandle}.
297
+ */
298
+ interface LottieInstance {
299
+ /** What the animation is doing. */
300
+ state: LottieState;
301
+ /**
302
+ * Why the last load failed, or `null` if it did not.
303
+ *
304
+ * Readable whenever you like, unlike the `error` subscription, which is
305
+ * announced once and is therefore missed by anything that starts listening
306
+ * afterwards. Cleared when a load begins.
307
+ */
308
+ error: Error | null;
309
+ /** The current playback rate, where `1` is the animation's own speed. */
310
+ speed: number;
311
+ /** Which way it is playing. */
312
+ direction: LottieDirection;
313
+ /** `false` for none, `true` for forever, or a number of repeats. */
314
+ loop: boolean | number;
315
+ /**
316
+ * How many frames are playable right now.
317
+ *
318
+ * Scoped to the current range rather than to the file, so a segment changes
319
+ * it, which is what a progress bar wants.
320
+ *
321
+ * It is a count and not a frame number, so **the last frame is one less than
322
+ * this**: an animation reporting 32 has frames 0 to 31, and nothing is ever
323
+ * drawn at 32, which the Lottie format requires so that a loop does not show
324
+ * one frame twice. A progress control measured against this rather than
325
+ * against one less stops a frame short of its own end and stays there.
326
+ */
327
+ playableFrames: number;
328
+ /**
329
+ * How long the playable range lasts, in seconds. Scoped like
330
+ * `playableFrames`.
331
+ */
332
+ playableDuration: number;
333
+ /**
334
+ * Throws the animation away and builds it again from the source.
335
+ *
336
+ * Playback starts from the beginning, while the speed, direction and loop in
337
+ * force at the time are kept, and the state returns to `loading` as it does
338
+ * for any other load.
339
+ *
340
+ * A source whose content has not changed is otherwise never fetched twice,
341
+ * which makes this the only way back from a load that failed, and the way to
342
+ * pick up a URL whose contents have been replaced since.
343
+ */
344
+ reload: () => void;
345
+ /** Plays from wherever it is. */
346
+ play: () => void;
347
+ /** Stops where it is. */
348
+ pause: () => void;
349
+ /** Stops and returns to the first frame of the playable range. */
350
+ stop: () => void;
351
+ /**
352
+ * Moves the playhead, without starting or stopping anything.
353
+ *
354
+ * Whatever was true about playback stays true: a playing animation plays on
355
+ * from the new position, and a paused one waits there. A target that cannot
356
+ * be resolved warns while you are developing and does nothing; a position
357
+ * outside the playable range is clamped to its nearest end.
358
+ */
359
+ seek: (target: LottieSeekTarget) => void;
360
+ /**
361
+ * Begins a drag, remembering whether it was playing, and pauses.
362
+ *
363
+ * Calling it again without an end begins a new gesture, so each drag
364
+ * restores what was true when that drag started.
365
+ */
366
+ scrubStart: () => void;
367
+ /** Moves the playhead during a drag. Frames only, clamped to the range. */
368
+ scrubTo: (frame: number) => void;
369
+ /**
370
+ * Ends a drag, resuming playback if it was playing when the drag began.
371
+ *
372
+ * **The only thing that clears the remembered playback state.** A drag that
373
+ * ends somewhere unexpected therefore leaves a call missing, which is visible,
374
+ * rather than a remembered state that quietly changes what a later seek does.
375
+ */
376
+ scrubEnd: () => void;
377
+ /**
378
+ * Plays part of the animation, which becomes what is playable.
379
+ *
380
+ * `playableFrames` and `playableDuration` follow it, so a progress bar
381
+ * measures the range
382
+ * rather than the file. Several ranges play in the order given, and the last
383
+ * one is what a loop repeats. Direction and speed follow the engine, which
384
+ * plays a range whose end is before its start backwards.
385
+ *
386
+ * Pass `{ queue: true }` to wait for whatever is playing to finish first. If
387
+ * nothing is playing there is nothing to wait for, so it starts at once.
388
+ */
389
+ playSegments: (segments: LottieSegments, options?: {
390
+ queue?: boolean;
391
+ }) => void;
392
+ /**
393
+ * Makes the whole animation playable again, and forgets anything queued.
394
+ *
395
+ * Restores the `segment` the animation was loaded with, or the entire file if
396
+ * it was loaded without one. Playback is left as it was.
397
+ */
398
+ resetSegments: () => void;
399
+ /** Changes the playback rate, taking effect immediately. */
400
+ setSpeed: Setter<number>;
401
+ /** Changes the direction, taking effect immediately. */
402
+ setDirection: Setter<LottieDirection>;
403
+ /** Changes the loop behaviour, taking effect on the next loop boundary. */
404
+ setLoop: Setter<boolean | number>;
405
+ /** Listens for one event. Returns the function that stops listening. */
406
+ subscribe: SubscriptionManager<LottieSubscriptions>["subscribe"];
407
+ /**
408
+ * Give this to the element the animation should be drawn inside, which this
409
+ * library calls the display. Nothing loads until an element carries it.
410
+ *
411
+ * `<LottieDisplay>` attaches it for you. Attach it yourself only when you are
412
+ * placing the element, which is what the hook is for.
413
+ */
414
+ setDisplayRef: RefCallback<HTMLElement>;
415
+ /**
416
+ * Give this to the element that should fill the screen when someone asks for
417
+ * fullscreen, which this library calls the root.
418
+ *
419
+ * `<Lottie>` attaches it to the element it renders, so the animation and the
420
+ * controls go together. Attach it yourself only when you are placing that
421
+ * element, which is what the hook is for: without it there is no fullscreen
422
+ * button and no keyboard shortcuts, because nothing says which part of the
423
+ * page belongs to this animation.
424
+ */
425
+ setRootRef: RefCallback<HTMLElement>;
426
+ /**
427
+ * The element carrying {@link LottieInstance.setRootRef}, or `null` until one
428
+ * does.
429
+ *
430
+ * A value as well as a callback, because the controls have to read the
431
+ * element back: fullscreen is asked of it, and a key press is ours only if it
432
+ * happened inside it.
433
+ */
434
+ root: HTMLElement | null;
435
+ /**
436
+ * lottie-web's own animation object, or `null` before it loads.
437
+ *
438
+ * The escape hatch, and **outside the semver promise**: it is the shape of a
439
+ * dependency we do not control, its declarations are wrong in both
440
+ * directions, and anything reached through it can change in a patch release.
441
+ */
442
+ animationItem: AnimationItem | null;
443
+ }
444
+ /**
445
+ * What an imperative ref hands back: {@link LottieInstance} without the parts a
446
+ * ref cannot serve.
447
+ *
448
+ * Derived rather than written out, so the two can never disagree about what
449
+ * they share. The values come off because a ref does not re-render, which would
450
+ * make every one of them silently stale. `subscribe` comes off because from a
451
+ * ref you would have to wait for it to fill, subscribe inside an effect and
452
+ * clean up yourself, all of which the `subscriptions` prop already does.
453
+ * `setDisplayRef` comes off because moving the animation out of the element the
454
+ * component just rendered is not something a caller should be able to do, and
455
+ * `setRootRef` for the same reason. `root` comes off as a value.
456
+ *
457
+ * A consumer writes `useRef<LottieHandle>(null)`; no ref type is exported.
458
+ */
459
+ type LottieHandle = Omit<LottieInstance, "state" | "error" | "speed" | "direction" | "loop" | "playableFrames" | "playableDuration" | "root" | "subscribe" | "setDisplayRef" | "setRootRef">;
460
+ //#endregion
461
+ export { AllowedAs, AnyTag, BlockContainerTag, ContainerTag, ElementProps, FixedElementProps, LottieDirection, LottieHandle, LottieInstance, LottieRenderer, LottieSeekTarget, LottieSegments, LottieState, LottieSubscription, LottieSubscriptions, RendererInLight, RendererInSvg, RendererRows };