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