@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
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2022 David Gamote
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -13,16 +13,10 @@ npm install @depup/lottie-react
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [lottie-react](https://www.npmjs.com/package/lottie-react) @ 2.4.1 |
17
- | Processed | 2026-03-18 |
18
- | Smoke test | failed |
19
- | Deps updated | 1 |
20
-
21
- ## Dependency Changes
22
-
23
- | Dependency | From | To |
24
- |------------|------|-----|
25
- | lottie-web | ^5.10.2 | ^5.13.0 |
16
+ | Original | [lottie-react](https://www.npmjs.com/package/lottie-react) @ 3.0.0 |
17
+ | Processed | 2026-08-16 |
18
+ | Smoke test | passed |
19
+ | Deps updated | 0 |
26
20
 
27
21
  ---
28
22
 
@@ -0,0 +1,23 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ exports.__toESM = __toESM;
@@ -0,0 +1,39 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_createLottieComponent = require("./createLottieComponent.cjs");
3
+ let lottie_web = require("lottie-web");
4
+ lottie_web = require_runtime.__toESM(lottie_web, 1);
5
+ //#region src/animation/Lottie.tsx
6
+ /**
7
+ * Renders an animation.
8
+ *
9
+ * With no children it is the animation itself: the element it renders is where
10
+ * the animation is drawn, and `className`, `style` and every other attribute
11
+ * land on that element. Give it a size, since an animation fills whatever box
12
+ * it is in and a box of no height shows nothing.
13
+ *
14
+ * ```jsx
15
+ * <Lottie src={animation} className="h-64" autoplay loop />
16
+ * ```
17
+ *
18
+ * With children it steps back and becomes the box around them, and you say
19
+ * where the animation goes with `<LottieDisplay>`. Anything else you render
20
+ * beside it finds the same animation without being handed it.
21
+ *
22
+ * ```jsx
23
+ * <Lottie src={animation}>
24
+ * <MyCaption />
25
+ * <LottieDisplay />
26
+ * </Lottie>
27
+ * ```
28
+ *
29
+ * `ref` names the element either way. Commands go through `lottieRef`, and
30
+ * anything the animation reports comes back through `subscriptions`.
31
+ *
32
+ * This is the full build, so every renderer is available. Reach for
33
+ * `LottieSvg` instead when only `svg` is needed, or `LottieLight` when the
34
+ * animation uses no expressions either: each carries a smaller copy of the
35
+ * engine.
36
+ */
37
+ const Lottie = require_createLottieComponent.createLottieComponent(lottie_web.default);
38
+ //#endregion
39
+ exports.Lottie = Lottie;
@@ -0,0 +1,47 @@
1
+ import { AnyTag, LottieRenderer } from "./types.cjs";
2
+ import { LottieComponent, LottieComponentProps } from "./createLottieComponent.cjs";
3
+ import { ReactNode } from "react";
4
+ //#region src/animation/Lottie.d.ts
5
+ /**
6
+ * What {@link Lottie} accepts: our own props, plus every attribute of the
7
+ * element it renders.
8
+ *
9
+ * Our props all carry a description, so hovering one at the call site tells you
10
+ * whose it is. Everything else belongs to the element and behaves exactly as it
11
+ * does anywhere else.
12
+ */
13
+ type LottieProps<As extends AnyTag = "div", Children extends ReactNode = undefined, Renderer extends LottieRenderer = typeof LottieRenderer.svg> = LottieComponentProps<As, Children, Renderer>;
14
+ /**
15
+ * Renders an animation.
16
+ *
17
+ * With no children it is the animation itself: the element it renders is where
18
+ * the animation is drawn, and `className`, `style` and every other attribute
19
+ * land on that element. Give it a size, since an animation fills whatever box
20
+ * it is in and a box of no height shows nothing.
21
+ *
22
+ * ```jsx
23
+ * <Lottie src={animation} className="h-64" autoplay loop />
24
+ * ```
25
+ *
26
+ * With children it steps back and becomes the box around them, and you say
27
+ * where the animation goes with `<LottieDisplay>`. Anything else you render
28
+ * beside it finds the same animation without being handed it.
29
+ *
30
+ * ```jsx
31
+ * <Lottie src={animation}>
32
+ * <MyCaption />
33
+ * <LottieDisplay />
34
+ * </Lottie>
35
+ * ```
36
+ *
37
+ * `ref` names the element either way. Commands go through `lottieRef`, and
38
+ * anything the animation reports comes back through `subscriptions`.
39
+ *
40
+ * This is the full build, so every renderer is available. Reach for
41
+ * `LottieSvg` instead when only `svg` is needed, or `LottieLight` when the
42
+ * animation uses no expressions either: each carries a smaller copy of the
43
+ * engine.
44
+ */
45
+ declare const Lottie: LottieComponent<LottieRenderer>;
46
+ //#endregion
47
+ export { Lottie, LottieProps };
@@ -0,0 +1,47 @@
1
+ import { AnyTag, LottieRenderer } from "./types.js";
2
+ import { LottieComponent, LottieComponentProps } from "./createLottieComponent.js";
3
+ import { ReactNode } from "react";
4
+ //#region src/animation/Lottie.d.ts
5
+ /**
6
+ * What {@link Lottie} accepts: our own props, plus every attribute of the
7
+ * element it renders.
8
+ *
9
+ * Our props all carry a description, so hovering one at the call site tells you
10
+ * whose it is. Everything else belongs to the element and behaves exactly as it
11
+ * does anywhere else.
12
+ */
13
+ type LottieProps<As extends AnyTag = "div", Children extends ReactNode = undefined, Renderer extends LottieRenderer = typeof LottieRenderer.svg> = LottieComponentProps<As, Children, Renderer>;
14
+ /**
15
+ * Renders an animation.
16
+ *
17
+ * With no children it is the animation itself: the element it renders is where
18
+ * the animation is drawn, and `className`, `style` and every other attribute
19
+ * land on that element. Give it a size, since an animation fills whatever box
20
+ * it is in and a box of no height shows nothing.
21
+ *
22
+ * ```jsx
23
+ * <Lottie src={animation} className="h-64" autoplay loop />
24
+ * ```
25
+ *
26
+ * With children it steps back and becomes the box around them, and you say
27
+ * where the animation goes with `<LottieDisplay>`. Anything else you render
28
+ * beside it finds the same animation without being handed it.
29
+ *
30
+ * ```jsx
31
+ * <Lottie src={animation}>
32
+ * <MyCaption />
33
+ * <LottieDisplay />
34
+ * </Lottie>
35
+ * ```
36
+ *
37
+ * `ref` names the element either way. Commands go through `lottieRef`, and
38
+ * anything the animation reports comes back through `subscriptions`.
39
+ *
40
+ * This is the full build, so every renderer is available. Reach for
41
+ * `LottieSvg` instead when only `svg` is needed, or `LottieLight` when the
42
+ * animation uses no expressions either: each carries a smaller copy of the
43
+ * engine.
44
+ */
45
+ declare const Lottie: LottieComponent<LottieRenderer>;
46
+ //#endregion
47
+ export { Lottie, LottieProps };
@@ -0,0 +1,37 @@
1
+ import { createLottieComponent } from "./createLottieComponent.js";
2
+ import lottie from "lottie-web";
3
+ //#region src/animation/Lottie.tsx
4
+ /**
5
+ * Renders an animation.
6
+ *
7
+ * With no children it is the animation itself: the element it renders is where
8
+ * the animation is drawn, and `className`, `style` and every other attribute
9
+ * land on that element. Give it a size, since an animation fills whatever box
10
+ * it is in and a box of no height shows nothing.
11
+ *
12
+ * ```jsx
13
+ * <Lottie src={animation} className="h-64" autoplay loop />
14
+ * ```
15
+ *
16
+ * With children it steps back and becomes the box around them, and you say
17
+ * where the animation goes with `<LottieDisplay>`. Anything else you render
18
+ * beside it finds the same animation without being handed it.
19
+ *
20
+ * ```jsx
21
+ * <Lottie src={animation}>
22
+ * <MyCaption />
23
+ * <LottieDisplay />
24
+ * </Lottie>
25
+ * ```
26
+ *
27
+ * `ref` names the element either way. Commands go through `lottieRef`, and
28
+ * anything the animation reports comes back through `subscriptions`.
29
+ *
30
+ * This is the full build, so every renderer is available. Reach for
31
+ * `LottieSvg` instead when only `svg` is needed, or `LottieLight` when the
32
+ * animation uses no expressions either: each carries a smaller copy of the
33
+ * engine.
34
+ */
35
+ const Lottie = createLottieComponent(lottie);
36
+ //#endregion
37
+ export { Lottie };
@@ -0,0 +1,55 @@
1
+ const require_mergeRefs = require("../utils/mergeRefs.cjs");
2
+ const require_polymorphicForwardRef = require("./polymorphicForwardRef.cjs");
3
+ const require_renderStyledElement = require("./renderStyledElement.cjs");
4
+ const require_useLottieInstance = require("./useLottieInstance.cjs");
5
+ let react = require("react");
6
+ //#region src/animation/LottieDisplay.tsx
7
+ /**
8
+ * The class the display carries, and the name React deduplicates its stylesheet
9
+ * by. One string does both, so two components can only collide in the document
10
+ * if they already collide in CSS.
11
+ */
12
+ const lottieDisplayClass = "lottie-display";
13
+ /**
14
+ * The display's own defaults, at zero specificity and inside the library's
15
+ * cascade layer, so that any rule the consumer writes beats them per property.
16
+ *
17
+ * Two of these are required rather than chosen. `position` is what the html
18
+ * renderer needs, because the box it appends is absolutely positioned, and it
19
+ * is what the overlays anchor to. `padding` is a correctness fix: the canvas
20
+ * renderer sizes its bitmap from `offsetWidth`, which includes padding, so a
21
+ * padded display draws at the wrong scale.
22
+ *
23
+ * Every selector stays scoped to the class. An unscoped one would restyle the
24
+ * host page's own elements.
25
+ */
26
+ const lottieDisplayStyles = `:where(.${lottieDisplayClass}){width:100%;height:100%;position:relative;overflow:hidden;border:0;padding:0;background:none;appearance:none}`;
27
+ /**
28
+ * The element the animation is drawn inside.
29
+ *
30
+ * Render it among the children of a component that publishes an animation to
31
+ * say where the animation goes, or on its own with the result of `useLottie` to
32
+ * place it anywhere at all. It takes every attribute of the element it renders,
33
+ * and `ref` names that same element.
34
+ *
35
+ * ```jsx
36
+ * const lottie = useLottie({ src });
37
+ * <LottieDisplay lottie={lottie} as="section" className="h-64" />
38
+ * ```
39
+ */
40
+ const LottieDisplay = require_polymorphicForwardRef.polymorphicForwardRef(function LottieDisplay({ lottie, as, className, ...rest }, ref) {
41
+ const { setDisplayRef } = require_useLottieInstance.useLottieInstance(lottie);
42
+ const attach = (0, react.useMemo)(() => require_mergeRefs.mergeRefs(ref, setDisplayRef), [ref, setDisplayRef]);
43
+ return require_renderStyledElement.renderStyledElement({
44
+ tag: typeof as === "string" ? as : "div",
45
+ styleClass: lottieDisplayClass,
46
+ styles: lottieDisplayStyles,
47
+ className,
48
+ attributes: rest,
49
+ ref: attach
50
+ });
51
+ });
52
+ //#endregion
53
+ exports.LottieDisplay = LottieDisplay;
54
+ exports.lottieDisplayClass = lottieDisplayClass;
55
+ exports.lottieDisplayStyles = lottieDisplayStyles;
@@ -0,0 +1,46 @@
1
+ import { AnyTag, ContainerTag, ElementProps, LottieInstance, LottieRenderer } from "./types.cjs";
2
+ //#region src/animation/LottieDisplay.d.ts
3
+ /** What this component owns. Every other prop belongs to the element. */
4
+ interface LottieDisplayOwnProps {
5
+ /** The animation to draw. Omit it inside a component that publishes one. */
6
+ lottie?: LottieInstance;
7
+ /** Which element to render. A `div` unless you say otherwise. */
8
+ as?: unknown;
9
+ /**
10
+ * Never any: lottie-web owns what is inside the display and rebuilds it on
11
+ * every load, so anything React put there would be wiped without warning.
12
+ */
13
+ children?: never;
14
+ /** Added to the library's class rather than replacing it. */
15
+ className?: string;
16
+ }
17
+ /**
18
+ * What {@link LottieDisplay} accepts for a given element.
19
+ *
20
+ * `as` is checked against the case every renderer allows, an element that may
21
+ * hold the `<svg>` or `<canvas>` two of the three append, because the display
22
+ * takes an animation rather than a source and so cannot see which renderer is
23
+ * in use. With `renderer="html"` a block element is required and nothing here
24
+ * can enforce it.
25
+ */
26
+ type LottieDisplayProps<As extends AnyTag = "div"> = ElementProps<LottieDisplayOwnProps, As, undefined, typeof LottieRenderer.svg>;
27
+ /**
28
+ * The element the animation is drawn inside.
29
+ *
30
+ * Render it among the children of a component that publishes an animation to
31
+ * say where the animation goes, or on its own with the result of `useLottie` to
32
+ * place it anywhere at all. It takes every attribute of the element it renders,
33
+ * and `ref` names that same element.
34
+ *
35
+ * ```jsx
36
+ * const lottie = useLottie({ src });
37
+ * <LottieDisplay lottie={lottie} as="section" className="h-64" />
38
+ * ```
39
+ */
40
+ declare const LottieDisplay: <As extends AnyTag = "div">(props: Omit<LottieDisplayOwnProps, "as"> & {
41
+ as?: (As extends ContainerTag ? As : {
42
+ readonly __lottie: "this tag cannot hold an animation";
43
+ }) | undefined;
44
+ } & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<As>>, keyof LottieDisplayOwnProps> & import("react").RefAttributes<HTMLElement>) => import("react").ReactNode;
45
+ //#endregion
46
+ export { LottieDisplay, LottieDisplayProps };
@@ -0,0 +1,46 @@
1
+ import { AnyTag, ContainerTag, ElementProps, LottieInstance, LottieRenderer } from "./types.js";
2
+ //#region src/animation/LottieDisplay.d.ts
3
+ /** What this component owns. Every other prop belongs to the element. */
4
+ interface LottieDisplayOwnProps {
5
+ /** The animation to draw. Omit it inside a component that publishes one. */
6
+ lottie?: LottieInstance;
7
+ /** Which element to render. A `div` unless you say otherwise. */
8
+ as?: unknown;
9
+ /**
10
+ * Never any: lottie-web owns what is inside the display and rebuilds it on
11
+ * every load, so anything React put there would be wiped without warning.
12
+ */
13
+ children?: never;
14
+ /** Added to the library's class rather than replacing it. */
15
+ className?: string;
16
+ }
17
+ /**
18
+ * What {@link LottieDisplay} accepts for a given element.
19
+ *
20
+ * `as` is checked against the case every renderer allows, an element that may
21
+ * hold the `<svg>` or `<canvas>` two of the three append, because the display
22
+ * takes an animation rather than a source and so cannot see which renderer is
23
+ * in use. With `renderer="html"` a block element is required and nothing here
24
+ * can enforce it.
25
+ */
26
+ type LottieDisplayProps<As extends AnyTag = "div"> = ElementProps<LottieDisplayOwnProps, As, undefined, typeof LottieRenderer.svg>;
27
+ /**
28
+ * The element the animation is drawn inside.
29
+ *
30
+ * Render it among the children of a component that publishes an animation to
31
+ * say where the animation goes, or on its own with the result of `useLottie` to
32
+ * place it anywhere at all. It takes every attribute of the element it renders,
33
+ * and `ref` names that same element.
34
+ *
35
+ * ```jsx
36
+ * const lottie = useLottie({ src });
37
+ * <LottieDisplay lottie={lottie} as="section" className="h-64" />
38
+ * ```
39
+ */
40
+ declare const LottieDisplay: <As extends AnyTag = "div">(props: Omit<LottieDisplayOwnProps, "as"> & {
41
+ as?: (As extends ContainerTag ? As : {
42
+ readonly __lottie: "this tag cannot hold an animation";
43
+ }) | undefined;
44
+ } & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<As>>, keyof LottieDisplayOwnProps> & import("react").RefAttributes<HTMLElement>) => import("react").ReactNode;
45
+ //#endregion
46
+ export { LottieDisplay, LottieDisplayProps };
@@ -0,0 +1,53 @@
1
+ import { mergeRefs } from "../utils/mergeRefs.js";
2
+ import { polymorphicForwardRef } from "./polymorphicForwardRef.js";
3
+ import { renderStyledElement } from "./renderStyledElement.js";
4
+ import { useLottieInstance } from "./useLottieInstance.js";
5
+ import { useMemo } from "react";
6
+ //#region src/animation/LottieDisplay.tsx
7
+ /**
8
+ * The class the display carries, and the name React deduplicates its stylesheet
9
+ * by. One string does both, so two components can only collide in the document
10
+ * if they already collide in CSS.
11
+ */
12
+ const lottieDisplayClass = "lottie-display";
13
+ /**
14
+ * The display's own defaults, at zero specificity and inside the library's
15
+ * cascade layer, so that any rule the consumer writes beats them per property.
16
+ *
17
+ * Two of these are required rather than chosen. `position` is what the html
18
+ * renderer needs, because the box it appends is absolutely positioned, and it
19
+ * is what the overlays anchor to. `padding` is a correctness fix: the canvas
20
+ * renderer sizes its bitmap from `offsetWidth`, which includes padding, so a
21
+ * padded display draws at the wrong scale.
22
+ *
23
+ * Every selector stays scoped to the class. An unscoped one would restyle the
24
+ * host page's own elements.
25
+ */
26
+ const lottieDisplayStyles = `:where(.${lottieDisplayClass}){width:100%;height:100%;position:relative;overflow:hidden;border:0;padding:0;background:none;appearance:none}`;
27
+ /**
28
+ * The element the animation is drawn inside.
29
+ *
30
+ * Render it among the children of a component that publishes an animation to
31
+ * say where the animation goes, or on its own with the result of `useLottie` to
32
+ * place it anywhere at all. It takes every attribute of the element it renders,
33
+ * and `ref` names that same element.
34
+ *
35
+ * ```jsx
36
+ * const lottie = useLottie({ src });
37
+ * <LottieDisplay lottie={lottie} as="section" className="h-64" />
38
+ * ```
39
+ */
40
+ const LottieDisplay = polymorphicForwardRef(function LottieDisplay({ lottie, as, className, ...rest }, ref) {
41
+ const { setDisplayRef } = useLottieInstance(lottie);
42
+ const attach = useMemo(() => mergeRefs(ref, setDisplayRef), [ref, setDisplayRef]);
43
+ return renderStyledElement({
44
+ tag: typeof as === "string" ? as : "div",
45
+ styleClass: lottieDisplayClass,
46
+ styles: lottieDisplayStyles,
47
+ className,
48
+ attributes: rest,
49
+ ref: attach
50
+ });
51
+ });
52
+ //#endregion
53
+ export { LottieDisplay, lottieDisplayClass, lottieDisplayStyles };
@@ -0,0 +1,16 @@
1
+ //#region src/animation/LottieInstanceContext.ts
2
+ /**
3
+ * How a child component reaches the animation it belongs to.
4
+ *
5
+ * Whatever owns the animation publishes it here, and every child prefers its
6
+ * own `lottie` prop and falls back to this, which is what lets one set of
7
+ * children serve both the component path and the hook path. It has to be a
8
+ * context rather than an injected prop: children are wrapped, mapped and
9
+ * conditional in real code, and only a context reaches all three.
10
+ *
11
+ * Read it through `useLottieInstance`, which turns the un-provided case into an
12
+ * error naming both ways to fix it.
13
+ */
14
+ const LottieInstanceContext = (0, require("react").createContext)(null);
15
+ //#endregion
16
+ exports.LottieInstanceContext = LottieInstanceContext;
@@ -0,0 +1,17 @@
1
+ import { createContext } from "react";
2
+ //#region src/animation/LottieInstanceContext.ts
3
+ /**
4
+ * How a child component reaches the animation it belongs to.
5
+ *
6
+ * Whatever owns the animation publishes it here, and every child prefers its
7
+ * own `lottie` prop and falls back to this, which is what lets one set of
8
+ * children serve both the component path and the hook path. It has to be a
9
+ * context rather than an injected prop: children are wrapped, mapped and
10
+ * conditional in real code, and only a context reaches all three.
11
+ *
12
+ * Read it through `useLottieInstance`, which turns the un-provided case into an
13
+ * error naming both ways to fix it.
14
+ */
15
+ const LottieInstanceContext = createContext(null);
16
+ //#endregion
17
+ export { LottieInstanceContext };
@@ -0,0 +1,19 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_createLottieComponent = require("./createLottieComponent.cjs");
3
+ let lottie_web_build_player_lottie_light_js = require("lottie-web/build/player/lottie_light.js");
4
+ lottie_web_build_player_lottie_light_js = require_runtime.__toESM(lottie_web_build_player_lottie_light_js, 1);
5
+ //#region src/animation/LottieLight.tsx
6
+ /**
7
+ * Renders an animation using the light build of the engine.
8
+ *
9
+ * Identical to {@link Lottie} except that `svg` is the only renderer, which the
10
+ * type enforces: the light build does not contain the other two, and asking it
11
+ * for one throws at runtime while its own declarations claim otherwise.
12
+ *
13
+ * It also carries no expression engine, so a property an expression drives is
14
+ * drawn at its static value; {@link LottieSvg} is the smaller build that keeps
15
+ * expressions.
16
+ */
17
+ const LottieLight = require_createLottieComponent.createLottieComponent(lottie_web_build_player_lottie_light_js.default);
18
+ //#endregion
19
+ exports.LottieLight = LottieLight;
@@ -0,0 +1,23 @@
1
+ import { AnyTag, LottieRenderer, RendererInLight } from "./types.cjs";
2
+ import { LottieComponent, LottieComponentProps } from "./createLottieComponent.cjs";
3
+ import { ReactNode } from "react";
4
+ //#region src/animation/LottieLight.d.ts
5
+ /**
6
+ * What {@link LottieLight} accepts. Identical to `LottieProps` except that
7
+ * `renderer` admits only what the light build contains.
8
+ */
9
+ type LottieLightProps<As extends AnyTag = "div", Children extends ReactNode = undefined, Renderer extends RendererInLight = typeof LottieRenderer.svg> = LottieComponentProps<As, Children, Renderer>;
10
+ /**
11
+ * Renders an animation using the light build of the engine.
12
+ *
13
+ * Identical to {@link Lottie} except that `svg` is the only renderer, which the
14
+ * type enforces: the light build does not contain the other two, and asking it
15
+ * for one throws at runtime while its own declarations claim otherwise.
16
+ *
17
+ * It also carries no expression engine, so a property an expression drives is
18
+ * drawn at its static value; {@link LottieSvg} is the smaller build that keeps
19
+ * expressions.
20
+ */
21
+ declare const LottieLight: LottieComponent<"svg">;
22
+ //#endregion
23
+ export { LottieLight, LottieLightProps };
@@ -0,0 +1,23 @@
1
+ import { AnyTag, LottieRenderer, RendererInLight } from "./types.js";
2
+ import { LottieComponent, LottieComponentProps } from "./createLottieComponent.js";
3
+ import { ReactNode } from "react";
4
+ //#region src/animation/LottieLight.d.ts
5
+ /**
6
+ * What {@link LottieLight} accepts. Identical to `LottieProps` except that
7
+ * `renderer` admits only what the light build contains.
8
+ */
9
+ type LottieLightProps<As extends AnyTag = "div", Children extends ReactNode = undefined, Renderer extends RendererInLight = typeof LottieRenderer.svg> = LottieComponentProps<As, Children, Renderer>;
10
+ /**
11
+ * Renders an animation using the light build of the engine.
12
+ *
13
+ * Identical to {@link Lottie} except that `svg` is the only renderer, which the
14
+ * type enforces: the light build does not contain the other two, and asking it
15
+ * for one throws at runtime while its own declarations claim otherwise.
16
+ *
17
+ * It also carries no expression engine, so a property an expression drives is
18
+ * drawn at its static value; {@link LottieSvg} is the smaller build that keeps
19
+ * expressions.
20
+ */
21
+ declare const LottieLight: LottieComponent<"svg">;
22
+ //#endregion
23
+ export { LottieLight, LottieLightProps };
@@ -0,0 +1,17 @@
1
+ import { createLottieComponent } from "./createLottieComponent.js";
2
+ import lottieLight from "lottie-web/build/player/lottie_light.js";
3
+ //#region src/animation/LottieLight.tsx
4
+ /**
5
+ * Renders an animation using the light build of the engine.
6
+ *
7
+ * Identical to {@link Lottie} except that `svg` is the only renderer, which the
8
+ * type enforces: the light build does not contain the other two, and asking it
9
+ * for one throws at runtime while its own declarations claim otherwise.
10
+ *
11
+ * It also carries no expression engine, so a property an expression drives is
12
+ * drawn at its static value; {@link LottieSvg} is the smaller build that keeps
13
+ * expressions.
14
+ */
15
+ const LottieLight = createLottieComponent(lottieLight);
16
+ //#endregion
17
+ export { LottieLight };
@@ -0,0 +1,36 @@
1
+ let react = require("react");
2
+ //#region src/animation/LottieRegistryContext.ts
3
+ function createLottieRegistry() {
4
+ const entries = /* @__PURE__ */ new Set();
5
+ const listeners = /* @__PURE__ */ new Set();
6
+ const emit = () => {
7
+ for (const listener of listeners) listener();
8
+ };
9
+ return {
10
+ register(box) {
11
+ entries.add(box);
12
+ emit();
13
+ return () => {
14
+ entries.delete(box);
15
+ emit();
16
+ };
17
+ },
18
+ bump: emit,
19
+ boxes: () => [...entries],
20
+ subscribe(listener) {
21
+ listeners.add(listener);
22
+ return () => {
23
+ listeners.delete(listener);
24
+ };
25
+ }
26
+ };
27
+ }
28
+ /**
29
+ * How an animation reaches whatever wrapper surrounds it, and `null` in the
30
+ * common case where nothing does, which costs the animation one context read
31
+ * and two no-op effects.
32
+ */
33
+ const LottieRegistryContext = (0, react.createContext)(null);
34
+ //#endregion
35
+ exports.LottieRegistryContext = LottieRegistryContext;
36
+ exports.createLottieRegistry = createLottieRegistry;
@@ -0,0 +1,35 @@
1
+ import { createContext } from "react";
2
+ //#region src/animation/LottieRegistryContext.ts
3
+ function createLottieRegistry() {
4
+ const entries = /* @__PURE__ */ new Set();
5
+ const listeners = /* @__PURE__ */ new Set();
6
+ const emit = () => {
7
+ for (const listener of listeners) listener();
8
+ };
9
+ return {
10
+ register(box) {
11
+ entries.add(box);
12
+ emit();
13
+ return () => {
14
+ entries.delete(box);
15
+ emit();
16
+ };
17
+ },
18
+ bump: emit,
19
+ boxes: () => [...entries],
20
+ subscribe(listener) {
21
+ listeners.add(listener);
22
+ return () => {
23
+ listeners.delete(listener);
24
+ };
25
+ }
26
+ };
27
+ }
28
+ /**
29
+ * How an animation reaches whatever wrapper surrounds it, and `null` in the
30
+ * common case where nothing does, which costs the animation one context read
31
+ * and two no-op effects.
32
+ */
33
+ const LottieRegistryContext = createContext(null);
34
+ //#endregion
35
+ export { LottieRegistryContext, createLottieRegistry };
@@ -0,0 +1,20 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_createLottieComponent = require("./createLottieComponent.cjs");
3
+ let lottie_web_build_player_lottie_svg_js = require("lottie-web/build/player/lottie_svg.js");
4
+ lottie_web_build_player_lottie_svg_js = require_runtime.__toESM(lottie_web_build_player_lottie_svg_js, 1);
5
+ //#region src/animation/LottieSvg.tsx
6
+ /**
7
+ * Renders an animation using the svg build of the engine.
8
+ *
9
+ * Identical to {@link Lottie} except that `svg` is the only renderer, which the
10
+ * type enforces: the svg build does not contain the other two, and asking it
11
+ * for one throws at runtime while its own declarations claim otherwise.
12
+ *
13
+ * It sits between the other two builds: smaller than the full one because it
14
+ * carries a single renderer, and unlike {@link LottieLight} it keeps the
15
+ * expression engine, so an animation whose properties are driven by
16
+ * expressions plays as designed.
17
+ */
18
+ const LottieSvg = require_createLottieComponent.createLottieComponent(lottie_web_build_player_lottie_svg_js.default);
19
+ //#endregion
20
+ exports.LottieSvg = LottieSvg;