animark-react 0.1.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 (61) hide show
  1. package/dist/Animark.d.ts +17 -0
  2. package/dist/Animark.d.ts.map +1 -0
  3. package/dist/Animark.js +66 -0
  4. package/dist/Animark.js.map +1 -0
  5. package/dist/AnimarkContext.d.ts +25 -0
  6. package/dist/AnimarkContext.d.ts.map +1 -0
  7. package/dist/AnimarkContext.js +75 -0
  8. package/dist/AnimarkContext.js.map +1 -0
  9. package/dist/AnimarkNodeRenderer.d.ts +20 -0
  10. package/dist/AnimarkNodeRenderer.d.ts.map +1 -0
  11. package/dist/AnimarkNodeRenderer.js +23 -0
  12. package/dist/AnimarkNodeRenderer.js.map +1 -0
  13. package/dist/Animarkcontrols.d.ts +15 -0
  14. package/dist/Animarkcontrols.d.ts.map +1 -0
  15. package/dist/Animarkcontrols.js +48 -0
  16. package/dist/Animarkcontrols.js.map +1 -0
  17. package/dist/Animarkplayer.d.ts +29 -0
  18. package/dist/Animarkplayer.d.ts.map +1 -0
  19. package/dist/Animarkplayer.js +24 -0
  20. package/dist/Animarkplayer.js.map +1 -0
  21. package/dist/CSSAnimatedWrapper.d.ts +15 -0
  22. package/dist/CSSAnimatedWrapper.d.ts.map +1 -0
  23. package/dist/CSSAnimatedWrapper.js +39 -0
  24. package/dist/CSSAnimatedWrapper.js.map +1 -0
  25. package/dist/MotionAnimatedWrapper-HT6ZXMNF.mjs +74 -0
  26. package/dist/MotionAnimatedWrapper.d.ts +10 -0
  27. package/dist/MotionAnimatedWrapper.d.ts.map +1 -0
  28. package/dist/MotionAnimatedWrapper.js +73 -0
  29. package/dist/MotionAnimatedWrapper.js.map +1 -0
  30. package/dist/StepBlock.d.ts +16 -0
  31. package/dist/StepBlock.d.ts.map +1 -0
  32. package/dist/StepBlock.js +28 -0
  33. package/dist/StepBlock.js.map +1 -0
  34. package/dist/StepCanvas.d.ts +17 -0
  35. package/dist/StepCanvas.d.ts.map +1 -0
  36. package/dist/StepCanvas.js +58 -0
  37. package/dist/StepCanvas.js.map +1 -0
  38. package/dist/StepContext.d.ts +33 -0
  39. package/dist/StepContext.d.ts.map +1 -0
  40. package/dist/StepContext.js +109 -0
  41. package/dist/StepContext.js.map +1 -0
  42. package/dist/StepControls.d.ts +20 -0
  43. package/dist/StepControls.d.ts.map +1 -0
  44. package/dist/StepControls.js +79 -0
  45. package/dist/StepControls.js.map +1 -0
  46. package/dist/StepPlayer.d.ts +53 -0
  47. package/dist/StepPlayer.d.ts.map +1 -0
  48. package/dist/StepPlayer.js +118 -0
  49. package/dist/StepPlayer.js.map +1 -0
  50. package/dist/canvasTypes.d.ts +28 -0
  51. package/dist/canvasTypes.d.ts.map +1 -0
  52. package/dist/canvasTypes.js +57 -0
  53. package/dist/canvasTypes.js.map +1 -0
  54. package/dist/index.d.mts +72 -0
  55. package/dist/index.d.ts +25 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +22 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/index.mjs +153 -0
  60. package/package.json +48 -0
  61. package/src/animark.css +89 -0
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import ReactMarkdown from "react-markdown";
3
+ import type { RemarkAnimarkOptions } from "animark-core";
4
+ import type { Components } from "react-markdown";
5
+ export interface AnimarkProps {
6
+ children: string;
7
+ useMotion?: boolean;
8
+ pluginOptions?: RemarkAnimarkOptions;
9
+ remarkPlugins?: NonNullable<Parameters<typeof ReactMarkdown>[0]["remarkPlugins"]>;
10
+ rehypePlugins?: NonNullable<Parameters<typeof ReactMarkdown>[0]["rehypePlugins"]>;
11
+ components?: Components;
12
+ className?: string;
13
+ style?: React.CSSProperties;
14
+ }
15
+ export declare const Animark: React.FC<AnimarkProps>;
16
+ export default Animark;
17
+ //# sourceMappingURL=Animark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Animark.d.ts","sourceRoot":"","sources":["../src/Animark.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAK3C,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,cAAc,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,aAAa,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;IAClF,aAAa,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;IAClF,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAOD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAqF1C,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import ReactMarkdown from "react-markdown";
5
+ import remarkDirective from "remark-directive";
6
+ import remarkMath from "remark-math";
7
+ import rehypeKatex from "rehype-katex";
8
+ import { remarkAnimark } from "animark-core";
9
+ import { AnimarkNodeRenderer } from "./AnimarkNodeRenderer";
10
+ // Plugin arrays defined OUTSIDE the component so their references are stable.
11
+ // react-markdown re-runs the entire pipeline whenever plugin array refs change.
12
+ const BASE_REMARK_PLUGINS = [remarkDirective, remarkAnimark, remarkMath];
13
+ const BASE_REHYPE_PLUGINS = [rehypeKatex];
14
+ export const Animark = ({ children, useMotion = false, pluginOptions, remarkPlugins = [], rehypePlugins = [], components = {}, className, style, }) => {
15
+ // Only rebuild when pluginOptions identity changes
16
+ const remarkPluginList = useMemo(() => {
17
+ if (pluginOptions) {
18
+ return [
19
+ remarkDirective,
20
+ [remarkAnimark, pluginOptions],
21
+ remarkMath,
22
+ ...remarkPlugins,
23
+ ];
24
+ }
25
+ return [...BASE_REMARK_PLUGINS, ...remarkPlugins];
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ }, [pluginOptions]);
28
+ const rehypePluginList = useMemo(() => [...BASE_REHYPE_PLUGINS, ...rehypePlugins],
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
+ []);
31
+ const finalComponents = useMemo(() => ({
32
+ ...components,
33
+ // Intercept every <div> and check for the data-animark marker.
34
+ // When found, hand off to the animation layer instead of rendering
35
+ // a plain div. All other divs pass through unchanged.
36
+ div(props) {
37
+ const { children: divChildren, "data-animark": isAnimark, ...rest } = props;
38
+ if (!isAnimark) {
39
+ return _jsx("div", { ...rest, children: divChildren });
40
+ }
41
+ const toNum = (v) => v !== undefined && v !== "" && v !== null ? Number(v) : undefined;
42
+ const animation = {
43
+ type: rest["data-animark-type"] ?? "fade",
44
+ trigger: rest["data-animark-trigger"] ?? "auto",
45
+ ...(toNum(rest["data-animark-delay"]) !== undefined && {
46
+ delay: toNum(rest["data-animark-delay"]),
47
+ }),
48
+ ...(toNum(rest["data-animark-duration"]) !== undefined && {
49
+ duration: toNum(rest["data-animark-duration"]),
50
+ }),
51
+ ...(toNum(rest["data-animark-stagger"]) !== undefined && {
52
+ stagger: toNum(rest["data-animark-stagger"]),
53
+ }),
54
+ ...(rest["data-animark-direction"] && {
55
+ direction: rest["data-animark-direction"],
56
+ }),
57
+ };
58
+ return (_jsx(AnimarkNodeRenderer, { animation: animation, useMotion: useMotion, children: divChildren }));
59
+ },
60
+ }),
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
+ [useMotion]);
63
+ return (_jsx("div", { className: className, style: style, children: _jsx(ReactMarkdown, { remarkPlugins: remarkPluginList, rehypePlugins: rehypePluginList, components: finalComponents, children: children }) }));
64
+ };
65
+ export default Animark;
66
+ //# sourceMappingURL=Animark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Animark.js","sourceRoot":"","sources":["../src/Animark.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAa5D,8EAA8E;AAC9E,gFAAgF;AAChF,MAAM,mBAAmB,GAAG,CAAC,eAAe,EAAE,aAAa,EAAE,UAAU,CAAU,CAAC;AAClF,MAAM,mBAAmB,GAAG,CAAC,WAAW,CAAU,CAAC;AAEnD,MAAM,CAAC,MAAM,OAAO,GAA2B,CAAC,EAC9C,QAAQ,EACR,SAAS,GAAG,KAAK,EACjB,aAAa,EACb,aAAa,GAAG,EAAE,EAClB,aAAa,GAAG,EAAE,EAClB,UAAU,GAAG,EAAE,EACf,SAAS,EACT,KAAK,GACN,EAAE,EAAE;IACH,mDAAmD;IACnD,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE;QACpC,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO;gBACL,eAAe;gBACf,CAAC,aAAa,EAAE,aAAa,CAAiD;gBAC9E,UAAU;gBACV,GAAG,aAAa;aACjB,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,GAAG,mBAAmB,EAAE,GAAG,aAAa,CAAC,CAAC;QACpD,uDAAuD;IACvD,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC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,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAW;iBACvD,CAAC;gBACF,GAAG,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI;oBACpC,SAAS,EAAE,IAAI,CAAC,wBAAwB,CAAC;iBAC1C,CAAC;aACH,CAAC;YAEF,OAAO,CACL,KAAC,mBAAmB,IAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,YAC5D,WAAW,GACQ,CACvB,CAAC;QACJ,CAAC;KACF,CAAC;IACF,uDAAuD;IACvD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,YACrC,KAAC,aAAa,IACZ,aAAa,EAAE,gBAAgB,EAC/B,aAAa,EAAE,gBAAgB,EAC/B,UAAU,EAAE,eAAe,YAE1B,QAAQ,GACK,GACZ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+ export interface AnimarkContextValue {
3
+ /** Increments on every replay — used as React key to remount CSS animations */
4
+ playCount: number;
5
+ /** Whether the timeline is currently playing */
6
+ playing: boolean;
7
+ /** Virtual current time in ms (used for timeline scrubbing) */
8
+ currentTime: number;
9
+ /** Total duration derived from all registered blocks */
10
+ totalDuration: number;
11
+ /** Trigger a full replay from the start */
12
+ replay: () => void;
13
+ /** Register a block's delay+duration so we can compute totalDuration */
14
+ registerBlock: (id: string, delay: number, duration: number) => void;
15
+ /** Unregister on unmount */
16
+ unregisterBlock: (id: string) => void;
17
+ }
18
+ export declare const AnimarkContext: React.Context<AnimarkContextValue>;
19
+ export declare function useAnimarkContext(): AnimarkContextValue;
20
+ interface AnimarkProviderProps {
21
+ children: React.ReactNode;
22
+ }
23
+ export declare function AnimarkProvider({ children }: AnimarkProviderProps): import("react/jsx-runtime").JSX.Element;
24
+ export {};
25
+ //# sourceMappingURL=AnimarkContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimarkContext.d.ts","sourceRoot":"","sources":["../src/AnimarkContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAExF,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,aAAa,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,wEAAwE;IACxE,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,4BAA4B;IAC5B,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAYD,eAAO,MAAM,cAAc,oCAAqD,CAAC;AAEjF,wBAAgB,iBAAiB,wBAEhC;AAED,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE,oBAAoB,2CAwEjE"}
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useState, useCallback, useRef } from "react";
4
+ const defaultContext = {
5
+ playCount: 0,
6
+ playing: false,
7
+ currentTime: 0,
8
+ totalDuration: 0,
9
+ replay: () => { },
10
+ registerBlock: () => { },
11
+ unregisterBlock: () => { },
12
+ };
13
+ export const AnimarkContext = createContext(defaultContext);
14
+ export function useAnimarkContext() {
15
+ return useContext(AnimarkContext);
16
+ }
17
+ export function AnimarkProvider({ children }) {
18
+ const [playCount, setPlayCount] = useState(0);
19
+ const [playing, setPlaying] = useState(false);
20
+ const [currentTime, setCurrentTime] = useState(0);
21
+ const [totalDuration, setTotalDuration] = useState(0);
22
+ // Registry of { delay, duration } per block id
23
+ const blocksRef = useRef(new Map());
24
+ const rafRef = useRef(null);
25
+ const startTimeRef = useRef(0);
26
+ const computeTotal = useCallback(() => {
27
+ let max = 0;
28
+ blocksRef.current.forEach(({ delay, duration }) => {
29
+ max = Math.max(max, delay + duration);
30
+ });
31
+ setTotalDuration(max || 1500);
32
+ }, []);
33
+ const registerBlock = useCallback((id, delay, duration) => {
34
+ blocksRef.current.set(id, { delay, duration });
35
+ computeTotal();
36
+ }, [computeTotal]);
37
+ const unregisterBlock = useCallback((id) => {
38
+ blocksRef.current.delete(id);
39
+ computeTotal();
40
+ }, [computeTotal]);
41
+ const stopRaf = useCallback(() => {
42
+ if (rafRef.current != null) {
43
+ cancelAnimationFrame(rafRef.current);
44
+ rafRef.current = null;
45
+ }
46
+ }, []);
47
+ const replay = useCallback(() => {
48
+ stopRaf();
49
+ setCurrentTime(0);
50
+ setPlaying(true);
51
+ setPlayCount((c) => c + 1);
52
+ startTimeRef.current = performance.now();
53
+ const total = (() => {
54
+ let max = 0;
55
+ blocksRef.current.forEach(({ delay, duration }) => {
56
+ max = Math.max(max, delay + duration);
57
+ });
58
+ return max || 1500;
59
+ })();
60
+ const tick = (now) => {
61
+ const elapsed = now - startTimeRef.current;
62
+ const clamped = Math.min(elapsed, total);
63
+ setCurrentTime(clamped);
64
+ if (clamped < total) {
65
+ rafRef.current = requestAnimationFrame(tick);
66
+ }
67
+ else {
68
+ setPlaying(false);
69
+ }
70
+ };
71
+ rafRef.current = requestAnimationFrame(tick);
72
+ }, [stopRaf]);
73
+ return (_jsx(AnimarkContext.Provider, { value: { playCount, playing, currentTime, totalDuration, replay, registerBlock, unregisterBlock }, children: children }));
74
+ }
75
+ //# sourceMappingURL=AnimarkContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimarkContext.js","sourceRoot":"","sources":["../src/AnimarkContext.tsx"],"names":[],"mappings":"AAA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,GAAG,CAAC,GAAG,EAAE;YAClB,IAAI,GAAG,GAAG,CAAC,CAAC;YACZ,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;gBAChD,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,QAAQ,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,IAAI,IAAI,CAAC;QACrB,CAAC,CAAC,EAAE,CAAC;QAEL,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE;YAC3B,MAAM,OAAO,GAAG,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC;YAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACzC,cAAc,CAAC,OAAO,CAAC,CAAC;YACxB,IAAI,OAAO,GAAG,KAAK,EAAE,CAAC;gBACpB,MAAM,CAAC,OAAO,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACH,CAAC,CAAC;QACF,MAAM,CAAC,OAAO,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,CACL,KAAC,cAAc,CAAC,QAAQ,IACtB,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,YAEhG,QAAQ,GACe,CAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import type { AnimationConfig } from "animark-core";
3
+ interface AnimarkNodeRendererProps {
4
+ /** Animation config extracted from the AST node */
5
+ animation: AnimationConfig;
6
+ children: React.ReactNode;
7
+ /** Use Framer Motion when available. Falls back to CSS otherwise. */
8
+ useMotion?: boolean;
9
+ className?: string;
10
+ }
11
+ /**
12
+ * `AnimarkNodeRenderer` is the bridge between the parsed `animarkWrapper`
13
+ * AST node and the actual animation implementation.
14
+ *
15
+ * It decides whether to use CSS or Framer Motion based on the `useMotion` prop
16
+ * and falls back gracefully in SSR environments.
17
+ */
18
+ export declare const AnimarkNodeRenderer: React.FC<AnimarkNodeRendererProps>;
19
+ export {};
20
+ //# sourceMappingURL=AnimarkNodeRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimarkNodeRenderer.d.ts","sourceRoot":"","sources":["../src/AnimarkNodeRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,UAAU,wBAAwB;IAChC,mDAAmD;IACnD,SAAS,EAAE,eAAe,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA4BlE,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Suspense, lazy } from "react";
4
+ import { CSSAnimatedWrapper } from "./CSSAnimatedWrapper";
5
+ // Lazily import the Motion wrapper so it's tree-shakeable and SSR-safe
6
+ const LazyMotionWrapper = lazy(() => import("./MotionAnimatedWrapper").then((m) => ({
7
+ default: m.MotionAnimatedWrapper,
8
+ })));
9
+ /**
10
+ * `AnimarkNodeRenderer` is the bridge between the parsed `animarkWrapper`
11
+ * AST node and the actual animation implementation.
12
+ *
13
+ * It decides whether to use CSS or Framer Motion based on the `useMotion` prop
14
+ * and falls back gracefully in SSR environments.
15
+ */
16
+ export const AnimarkNodeRenderer = ({ animation, children, useMotion = false, className, }) => {
17
+ if (!useMotion) {
18
+ return (_jsx(CSSAnimatedWrapper, { animation: animation, className: className, children: children }));
19
+ }
20
+ // Framer Motion path — wrapped in Suspense so SSR falls back to CSS version
21
+ return (_jsx(Suspense, { fallback: _jsx(CSSAnimatedWrapper, { animation: animation, className: className, children: children }), children: _jsx(LazyMotionWrapper, { animation: animation, className: className, children: children }) }));
22
+ };
23
+ //# sourceMappingURL=AnimarkNodeRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimarkNodeRenderer.js","sourceRoot":"","sources":["../src/AnimarkNodeRenderer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,QAAQ,EAAE,IAAI,EAAW,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAW1D,uEAAuE;AACvE,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE,CAClC,MAAM,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,CAAC,qBAAqB;CACjC,CAAC,CAAC,CACJ,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,SAAS,EACT,QAAQ,EACR,SAAS,GAAG,KAAK,EACjB,SAAS,GACV,EAAE,EAAE;IACH,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CACL,KAAC,kBAAkB,IAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,YAC3D,QAAQ,GACU,CACtB,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,OAAO,CACL,KAAC,QAAQ,IACP,QAAQ,EACN,KAAC,kBAAkB,IAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,YAC3D,QAAQ,GACU,YAGvB,KAAC,iBAAiB,IAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,YAC1D,QAAQ,GACS,GACX,CACZ,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ export interface AnimarkControlsProps {
3
+ /** Show the timeline scrubber bar. Default: true */
4
+ showTimeline?: boolean;
5
+ /** Custom className for the controls container */
6
+ className?: string;
7
+ /** Custom styles for the controls container */
8
+ style?: React.CSSProperties;
9
+ }
10
+ /**
11
+ * AnimarkControls — play/replay button + optional timeline scrubber.
12
+ * Must be rendered inside an <AnimarkPlayer> (which provides the context).
13
+ */
14
+ export declare function AnimarkControls({ showTimeline, className, style, }: AnimarkControlsProps): import("react/jsx-runtime").JSX.Element;
15
+ //# sourceMappingURL=AnimarkControls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimarkControls.d.ts","sourceRoot":"","sources":["../src/AnimarkControls.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,oBAAoB;IACnC,oDAAoD;IACpD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,YAAmB,EACnB,SAAc,EACd,KAAU,GACX,EAAE,oBAAoB,2CAkFtB"}
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useAnimarkContext } from "./AnimarkContext";
4
+ /**
5
+ * AnimarkControls — play/replay button + optional timeline scrubber.
6
+ * Must be rendered inside an <AnimarkPlayer> (which provides the context).
7
+ */
8
+ export function AnimarkControls({ showTimeline = true, className = "", style = {}, }) {
9
+ const { playing, currentTime, totalDuration, replay } = useAnimarkContext();
10
+ const progress = totalDuration > 0 ? (currentTime / totalDuration) * 100 : 0;
11
+ return (_jsxs("div", { className: `animark-controls ${className}`.trim(), style: {
12
+ display: "flex",
13
+ alignItems: "center",
14
+ gap: 12,
15
+ padding: "10px 0",
16
+ userSelect: "none",
17
+ ...style,
18
+ }, children: [_jsx("button", { onClick: replay, disabled: playing, "aria-label": playing ? "Playing…" : "Replay animations", style: {
19
+ display: "inline-flex",
20
+ alignItems: "center",
21
+ gap: 6,
22
+ padding: "6px 14px",
23
+ border: "1px solid currentColor",
24
+ borderRadius: 6,
25
+ background: "transparent",
26
+ cursor: playing ? "not-allowed" : "pointer",
27
+ opacity: playing ? 0.5 : 1,
28
+ fontSize: 13,
29
+ fontFamily: "inherit",
30
+ transition: "opacity 0.2s",
31
+ whiteSpace: "nowrap",
32
+ }, children: _jsx("span", { "aria-hidden": true, children: playing ? "▶ Playing…" : "↺ Replay" }) }), showTimeline && (_jsx("div", { role: "progressbar", "aria-valuenow": Math.round(progress), "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": "Animation timeline", style: {
33
+ flex: 1,
34
+ height: 4,
35
+ borderRadius: 2,
36
+ background: "rgba(128,128,128,0.2)",
37
+ overflow: "hidden",
38
+ minWidth: 80,
39
+ }, children: _jsx("div", { style: {
40
+ height: "100%",
41
+ width: `${progress}%`,
42
+ background: "currentColor",
43
+ borderRadius: 2,
44
+ transition: playing ? "none" : "width 0.3s ease",
45
+ opacity: 0.7,
46
+ } }) })), showTimeline && (_jsxs("span", { "aria-hidden": true, style: { fontSize: 12, opacity: 0.5, minWidth: 48, textAlign: "right", fontVariantNumeric: "tabular-nums" }, children: [(currentTime / 1000).toFixed(1), "s"] }))] }));
47
+ }
48
+ //# sourceMappingURL=AnimarkControls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimarkControls.js","sourceRoot":"","sources":["../src/AnimarkControls.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,iBAAiB,EAA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,CAAC,UAAU,GAAQ,GACvD,EAGR,YAAY,IAAI,CACf,cACE,IAAI,EAAC,aAAa,mBACH,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,mBACpB,CAAC,mBACD,GAAG,gBACP,oBAAoB,EAC/B,KAAK,EAAE;oBACL,IAAI,EAAE,CAAC;oBACP,MAAM,EAAE,CAAC;oBACT,YAAY,EAAE,CAAC;oBACf,UAAU,EAAE,uBAAuB;oBACnC,QAAQ,EAAE,QAAQ;oBAClB,QAAQ,EAAE,EAAE;iBACb,YAED,cACE,KAAK,EAAE;wBACL,MAAM,EAAE,MAAM;wBACd,KAAK,EAAE,GAAG,QAAQ,GAAG;wBACrB,UAAU,EAAE,cAAc;wBAC1B,YAAY,EAAE,CAAC;wBACf,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB;wBAChD,OAAO,EAAE,GAAG;qBACb,GACD,GACE,CACP,EAGA,YAAY,IAAI,CACf,qCAEE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAE1G,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAC3B,CACR,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type AnimarkProps } from "./Animark";
2
+ import { type AnimarkControlsProps } from "./AnimarkControls";
3
+ export interface AnimarkPlayerProps extends AnimarkProps {
4
+ /**
5
+ * Show the built-in play/replay controls.
6
+ * Pass false to hide them and control playback manually via useAnimarkContext().
7
+ * Default: true
8
+ */
9
+ showControls?: boolean;
10
+ /** Props forwarded to the built-in <AnimarkControls /> */
11
+ controlsProps?: AnimarkControlsProps;
12
+ }
13
+ /**
14
+ * AnimarkPlayer — <Animark> with built-in replay controls and timeline.
15
+ *
16
+ * Wraps content in an AnimarkProvider so all animated blocks share
17
+ * the same play state.
18
+ *
19
+ * Usage:
20
+ * <AnimarkPlayer showControls>{markdown}</AnimarkPlayer>
21
+ *
22
+ * To position controls manually:
23
+ * <AnimarkPlayer showControls={false}>
24
+ * {markdown}
25
+ * <AnimarkControls /> ← place anywhere inside
26
+ * </AnimarkPlayer>
27
+ */
28
+ export declare function AnimarkPlayer({ showControls, controlsProps, children, ...animarkProps }: AnimarkPlayerProps): import("react/jsx-runtime").JSX.Element;
29
+ //# sourceMappingURL=AnimarkPlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimarkPlayer.d.ts","sourceRoot":"","sources":["../src/AnimarkPlayer.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE/E,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,EAC5B,YAAmB,EACnB,aAAkB,EAClB,QAAQ,EACR,GAAG,YAAY,EAChB,EAAE,kBAAkB,2CAOpB"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { AnimarkProvider } from "./AnimarkContext";
4
+ import { Animark } from "./Animark";
5
+ import { AnimarkControls } from "./AnimarkControls";
6
+ /**
7
+ * AnimarkPlayer — <Animark> with built-in replay controls and timeline.
8
+ *
9
+ * Wraps content in an AnimarkProvider so all animated blocks share
10
+ * the same play state.
11
+ *
12
+ * Usage:
13
+ * <AnimarkPlayer showControls>{markdown}</AnimarkPlayer>
14
+ *
15
+ * To position controls manually:
16
+ * <AnimarkPlayer showControls={false}>
17
+ * {markdown}
18
+ * <AnimarkControls /> ← place anywhere inside
19
+ * </AnimarkPlayer>
20
+ */
21
+ export function AnimarkPlayer({ showControls = true, controlsProps = {}, children, ...animarkProps }) {
22
+ return (_jsxs(AnimarkProvider, { children: [showControls && _jsx(AnimarkControls, { ...controlsProps }), _jsx(Animark, { ...animarkProps, children: children })] }));
23
+ }
24
+ //# sourceMappingURL=AnimarkPlayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimarkPlayer.js","sourceRoot":"","sources":["../src/AnimarkPlayer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAqB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,eAAe,EAA6B,MAAM,mBAAmB,CAAC;AAa/E;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAAC,EAC5B,YAAY,GAAG,IAAI,EACnB,aAAa,GAAG,EAAE,EAClB,QAAQ,EACR,GAAG,YAAY,EACI;IACnB,OAAO,CACL,MAAC,eAAe,eACb,YAAY,IAAI,KAAC,eAAe,OAAK,aAAa,GAAI,EACvD,KAAC,OAAO,OAAK,YAAY,YAAG,QAAQ,GAAW,IAC/B,CACnB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import type { AnimationConfig } from "animark-core";
3
+ interface CSSAnimatedWrapperProps {
4
+ animation: AnimationConfig;
5
+ children: React.ReactNode;
6
+ className?: string;
7
+ style?: React.CSSProperties;
8
+ }
9
+ /**
10
+ * Pure CSS animated wrapper.
11
+ * Re-triggers animation on replay by remounting via key={playCount}.
12
+ */
13
+ export declare const CSSAnimatedWrapper: React.FC<CSSAnimatedWrapperProps>;
14
+ export {};
15
+ //# sourceMappingURL=CSSAnimatedWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CSSAnimatedWrapper.d.ts","sourceRoot":"","sources":["../src/CSSAnimatedWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,UAAU,uBAAuB;IAC/B,SAAS,EAAE,eAAe,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAaD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAmChE,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useId } from "react";
4
+ import { useAnimarkContext } from "./AnimarkContext";
5
+ function getAnimationClass(animation) {
6
+ const dir = animation.direction ?? "up";
7
+ switch (animation.type) {
8
+ case "fade": return "animark-fade";
9
+ case "scale": return "animark-scale";
10
+ case "slide": return `animark-slide-${dir}`;
11
+ case "move": return `animark-move-${dir}`;
12
+ default: return "animark-fade";
13
+ }
14
+ }
15
+ /**
16
+ * Pure CSS animated wrapper.
17
+ * Re-triggers animation on replay by remounting via key={playCount}.
18
+ */
19
+ export const CSSAnimatedWrapper = ({ animation, children, className = "", style = {}, }) => {
20
+ const id = useId();
21
+ const { playCount, registerBlock, unregisterBlock } = useAnimarkContext();
22
+ const duration = animation.duration ?? 500;
23
+ const delay = animation.delay ?? 0;
24
+ // Register this block so the timeline knows about it
25
+ useEffect(() => {
26
+ registerBlock(id, delay, duration);
27
+ return () => unregisterBlock(id);
28
+ }, [id, delay, duration, registerBlock, unregisterBlock]);
29
+ const animClass = getAnimationClass(animation);
30
+ return (
31
+ // key={playCount} forces React to remount this element on every replay,
32
+ // which restarts the CSS animation from the beginning.
33
+ _jsx("div", { className: `animark-wrapper ${animClass} ${className}`.trim(), style: {
34
+ animationDuration: `${duration}ms`,
35
+ animationDelay: `${delay}ms`,
36
+ ...style,
37
+ }, children: children }, playCount));
38
+ };
39
+ //# sourceMappingURL=CSSAnimatedWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CSSAnimatedWrapper.js","sourceRoot":"","sources":["../src/CSSAnimatedWrapper.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AASrD,SAAS,iBAAiB,CAAC,SAA0B;IACnD,MAAM,GAAG,GAAG,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC;IACxC,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,CAAE,OAAO,cAAc,CAAC;QACpC,KAAK,OAAO,CAAC,CAAC,OAAO,eAAe,CAAC;QACrC,KAAK,OAAO,CAAC,CAAC,OAAO,iBAAiB,GAAG,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,CAAE,OAAO,gBAAgB,GAAG,EAAE,CAAC;QAC3C,OAAO,CAAC,CAAM,OAAO,cAAc,CAAC;IACtC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAsC,CAAC,EACpE,SAAS,EACT,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,EAAE,GACX,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,iBAAiB,EAAE,CAAC;IAE1E,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,IAAI,GAAG,CAAC;IAC3C,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC;IAEnC,qDAAqD;IACrD,SAAS,CAAC,GAAG,EAAE;QACb,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACnC,OAAO,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;IAE1D,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAE/C,OAAO;IACL,wEAAwE;IACxE,uDAAuD;IACvD,cAEE,SAAS,EAAE,mBAAmB,SAAS,IAAI,SAAS,EAAE,CAAC,IAAI,EAAE,EAC7D,KAAK,EAAE;YACL,iBAAiB,EAAE,GAAG,QAAQ,IAAI;YAClC,cAAc,EAAE,GAAG,KAAK,IAAI;YAC5B,GAAG,KAAK;SACT,YAEA,QAAQ,IARJ,SAAS,CASV,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,74 @@
1
+ "use client";
2
+
3
+ // src/MotionAnimatedWrapper.tsx
4
+ import { motion } from "framer-motion";
5
+ import { jsx } from "react/jsx-runtime";
6
+ function buildVariants(animation) {
7
+ const dir = animation.direction ?? "up";
8
+ const duration = (animation.duration ?? 500) / 1e3;
9
+ switch (animation.type) {
10
+ case "fade":
11
+ return {
12
+ hidden: { opacity: 0 },
13
+ visible: { opacity: 1, transition: { duration } }
14
+ };
15
+ case "slide": {
16
+ const sign = dir === "right" || dir === "down" ? -1 : 1;
17
+ if (dir === "left" || dir === "right") {
18
+ return {
19
+ hidden: { opacity: 0, x: sign * 24 },
20
+ visible: { opacity: 1, x: 0, transition: { duration } }
21
+ };
22
+ }
23
+ return {
24
+ hidden: { opacity: 0, y: sign * 24 },
25
+ visible: { opacity: 1, y: 0, transition: { duration } }
26
+ };
27
+ }
28
+ case "scale":
29
+ return {
30
+ hidden: { opacity: 0, scale: 0.88 },
31
+ visible: { opacity: 1, scale: 1, transition: { duration } }
32
+ };
33
+ case "move": {
34
+ const sign = dir === "right" || dir === "down" ? -1 : 1;
35
+ if (dir === "left" || dir === "right") {
36
+ return {
37
+ hidden: { x: sign * 12 },
38
+ visible: { x: 0, transition: { duration } }
39
+ };
40
+ }
41
+ return {
42
+ hidden: { y: sign * 12 },
43
+ visible: { y: 0, transition: { duration } }
44
+ };
45
+ }
46
+ default:
47
+ return {
48
+ hidden: { opacity: 0 },
49
+ visible: { opacity: 1, transition: { duration } }
50
+ };
51
+ }
52
+ }
53
+ var MotionAnimatedWrapper = ({
54
+ animation,
55
+ children,
56
+ className = ""
57
+ }) => {
58
+ const variants = buildVariants(animation);
59
+ const delaySeconds = (animation.delay ?? 0) / 1e3;
60
+ return /* @__PURE__ */ jsx(
61
+ motion.div,
62
+ {
63
+ className: `animark-wrapper ${className}`.trim(),
64
+ variants,
65
+ initial: "hidden",
66
+ animate: "visible",
67
+ transition: { delay: delaySeconds },
68
+ children
69
+ }
70
+ );
71
+ };
72
+ export {
73
+ MotionAnimatedWrapper
74
+ };
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import type { AnimationConfig } from "animark-core";
3
+ interface MotionWrapperProps {
4
+ animation: AnimationConfig;
5
+ children: React.ReactNode;
6
+ className?: string;
7
+ }
8
+ export declare const MotionAnimatedWrapper: React.FC<MotionWrapperProps>;
9
+ export {};
10
+ //# sourceMappingURL=MotionAnimatedWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MotionAnimatedWrapper.d.ts","sourceRoot":"","sources":["../src/MotionAnimatedWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,UAAU,kBAAkB;IAC1B,SAAS,EAAE,eAAe,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAmDD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsC9D,CAAC"}
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useId } from "react";
4
+ import { motion, useAnimation } from "framer-motion";
5
+ import { useAnimarkContext } from "./AnimarkContext";
6
+ function buildVariants(animation) {
7
+ const dir = animation.direction ?? "up";
8
+ const duration = (animation.duration ?? 500) / 1000;
9
+ switch (animation.type) {
10
+ case "fade":
11
+ return {
12
+ hidden: { opacity: 0 },
13
+ visible: { opacity: 1, transition: { duration } },
14
+ };
15
+ case "slide": {
16
+ const sign = dir === "right" || dir === "down" ? -1 : 1;
17
+ if (dir === "left" || dir === "right") {
18
+ return {
19
+ hidden: { opacity: 0, x: sign * 24 },
20
+ visible: { opacity: 1, x: 0, transition: { duration } },
21
+ };
22
+ }
23
+ return {
24
+ hidden: { opacity: 0, y: sign * 24 },
25
+ visible: { opacity: 1, y: 0, transition: { duration } },
26
+ };
27
+ }
28
+ case "scale":
29
+ return {
30
+ hidden: { opacity: 0, scale: 0.88 },
31
+ visible: { opacity: 1, scale: 1, transition: { duration } },
32
+ };
33
+ case "move": {
34
+ const sign = dir === "right" || dir === "down" ? -1 : 1;
35
+ if (dir === "left" || dir === "right") {
36
+ return {
37
+ hidden: { x: sign * 12 },
38
+ visible: { x: 0, transition: { duration } },
39
+ };
40
+ }
41
+ return {
42
+ hidden: { y: sign * 12 },
43
+ visible: { y: 0, transition: { duration } },
44
+ };
45
+ }
46
+ default:
47
+ return {
48
+ hidden: { opacity: 0 },
49
+ visible: { opacity: 1, transition: { duration } },
50
+ };
51
+ }
52
+ }
53
+ export const MotionAnimatedWrapper = ({ animation, children, className = "", }) => {
54
+ const id = useId();
55
+ const { playCount, registerBlock, unregisterBlock } = useAnimarkContext();
56
+ const controls = useAnimation();
57
+ const duration = animation.duration ?? 500;
58
+ const delay = animation.delay ?? 0;
59
+ const delaySeconds = delay / 1000;
60
+ // Register with the timeline
61
+ useEffect(() => {
62
+ registerBlock(id, delay, duration);
63
+ return () => unregisterBlock(id);
64
+ }, [id, delay, duration, registerBlock, unregisterBlock]);
65
+ // Re-run animation whenever playCount increments (replay triggered)
66
+ useEffect(() => {
67
+ controls.set("hidden");
68
+ controls.start("visible");
69
+ }, [playCount, controls]);
70
+ const variants = buildVariants(animation);
71
+ return (_jsx(motion.div, { className: `animark-wrapper ${className}`.trim(), variants: variants, initial: "hidden", animate: controls, transition: { delay: delaySeconds }, children: children }));
72
+ };
73
+ //# sourceMappingURL=MotionAnimatedWrapper.js.map