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,28 @@
1
+ export type CanvasPreset = "full-screen" | "16:9" | "4:3" | "custom";
2
+ export type VerticalAlign = "top" | "center" | "bottom" | "stretch";
3
+ export type HorizontalAlign = "left" | "center" | "right" | "stretch";
4
+ export interface CanvasSize {
5
+ width?: number | string;
6
+ height?: number | string;
7
+ preset?: CanvasPreset;
8
+ /** Background color for the canvas area */
9
+ background?: string;
10
+ /** Padding inside the canvas */
11
+ padding?: number | string;
12
+ /** Overflow behavior. Default: "hidden" */
13
+ overflow?: "hidden" | "auto" | "scroll" | "visible";
14
+ /** Vertical alignment of content. Default: "top" */
15
+ verticalAlign?: VerticalAlign;
16
+ /** Horizontal alignment of content. Default: "left" */
17
+ horizontalAlign?: HorizontalAlign;
18
+ }
19
+ export interface ResolvedCanvasSize {
20
+ width: string;
21
+ height: string;
22
+ background: string;
23
+ padding: string;
24
+ verticalAlign: VerticalAlign;
25
+ horizontalAlign: HorizontalAlign;
26
+ }
27
+ export declare function resolveCanvasSize(size?: CanvasSize): ResolvedCanvasSize | null;
28
+ //# sourceMappingURL=canvasTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvasTypes.d.ts","sourceRoot":"","sources":["../src/canvasTypes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AACpE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAEtE,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACpD,oDAAoD;IACpD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,uDAAuD;IACvD,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,eAAe,EAAE,eAAe,CAAC;CAClC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,kBAAkB,GAAG,IAAI,CAgE9E"}
@@ -0,0 +1,57 @@
1
+ export function resolveCanvasSize(size) {
2
+ if (!size)
3
+ return null;
4
+ const { preset, width, height, background = "#ffffff", padding = "48px", verticalAlign = "top", horizontalAlign = "left" } = size;
5
+ switch (preset) {
6
+ case "full-screen":
7
+ return {
8
+ width: "100vw",
9
+ height: "100vh",
10
+ background,
11
+ padding: typeof padding === "number" ? `${padding}px` : padding,
12
+ verticalAlign,
13
+ horizontalAlign,
14
+ };
15
+ case "16:9":
16
+ return {
17
+ width: "100%",
18
+ height: "0", // Will use aspect-ratio CSS
19
+ background,
20
+ padding: typeof padding === "number" ? `${padding}px` : padding,
21
+ verticalAlign,
22
+ horizontalAlign,
23
+ };
24
+ case "4:3":
25
+ return {
26
+ width: "100%",
27
+ height: "0",
28
+ background,
29
+ padding: typeof padding === "number" ? `${padding}px` : padding,
30
+ verticalAlign,
31
+ horizontalAlign,
32
+ };
33
+ case "custom":
34
+ return {
35
+ width: width ? (typeof width === "number" ? `${width}px` : width) : "800px",
36
+ height: height ? (typeof height === "number" ? `${height}px` : height) : "600px",
37
+ background,
38
+ padding: typeof padding === "number" ? `${padding}px` : padding,
39
+ verticalAlign,
40
+ horizontalAlign,
41
+ };
42
+ default:
43
+ // No preset, use provided dimensions
44
+ if (width && height) {
45
+ return {
46
+ width: typeof width === "number" ? `${width}px` : width,
47
+ height: typeof height === "number" ? `${height}px` : height,
48
+ background,
49
+ padding: typeof padding === "number" ? `${padding}px` : padding,
50
+ verticalAlign,
51
+ horizontalAlign,
52
+ };
53
+ }
54
+ return null;
55
+ }
56
+ }
57
+ //# sourceMappingURL=canvasTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvasTypes.js","sourceRoot":"","sources":["../src/canvasTypes.ts"],"names":[],"mappings":"AA8BA,MAAM,UAAU,iBAAiB,CAAC,IAAiB;IACjD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,MAAM,EACJ,MAAM,EACN,KAAK,EACL,MAAM,EACN,UAAU,GAAG,SAAS,EACtB,OAAO,GAAG,MAAM,EAChB,aAAa,GAAG,KAAK,EACrB,eAAe,GAAG,MAAM,EACzB,GAAG,IAAI,CAAC;IAET,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,aAAa;YAChB,OAAO;gBACL,KAAK,EAAE,OAAO;gBACd,MAAM,EAAE,OAAO;gBACf,UAAU;gBACV,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO;gBAC/D,aAAa;gBACb,eAAe;aAChB,CAAC;QACJ,KAAK,MAAM;YACT,OAAO;gBACL,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,GAAG,EAAE,4BAA4B;gBACzC,UAAU;gBACV,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO;gBAC/D,aAAa;gBACb,eAAe;aAChB,CAAC;QACJ,KAAK,KAAK;YACR,OAAO;gBACL,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,GAAG;gBACX,UAAU;gBACV,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO;gBAC/D,aAAa;gBACb,eAAe;aAChB,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO;gBACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO;gBAC3E,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO;gBAChF,UAAU;gBACV,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO;gBAC/D,aAAa;gBACb,eAAe;aAChB,CAAC;QACJ;YACE,qCAAqC;YACrC,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;gBACpB,OAAO;oBACL,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK;oBACvD,MAAM,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,MAAM;oBAC3D,UAAU;oBACV,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO;oBAC/D,aAAa;oBACb,eAAe;iBAChB,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import ReactMarkdown, { Components } from 'react-markdown';
3
+ import { RemarkAnimarkOptions, AnimationConfig } from 'animark-core';
4
+ export { AnimarkWrapperNode, AnimationConfig, AnimationDirection, AnimationTrigger, AnimationType, RemarkAnimarkOptions, remarkAnimark } from 'animark-core';
5
+
6
+ interface AnimarkProps {
7
+ /** The Markdown string to render */
8
+ children: string;
9
+ /**
10
+ * Use Framer Motion for animations.
11
+ * Requires `framer-motion` to be installed.
12
+ * Falls back to CSS animations when false (default) — safe for SSR.
13
+ */
14
+ useMotion?: boolean;
15
+ /**
16
+ * Options forwarded to the `remarkAnimark` plugin.
17
+ * Use to add custom animation types or set default configs.
18
+ */
19
+ pluginOptions?: RemarkAnimarkOptions;
20
+ /**
21
+ * Additional remark plugins to include.
22
+ * remark-directive and remarkAnimark are always injected automatically.
23
+ */
24
+ remarkPlugins?: NonNullable<Parameters<typeof ReactMarkdown>[0]["remarkPlugins"]>;
25
+ /**
26
+ * Additional rehype plugins to include.
27
+ * rehype-katex is always injected automatically.
28
+ */
29
+ rehypePlugins?: NonNullable<Parameters<typeof ReactMarkdown>[0]["rehypePlugins"]>;
30
+ /**
31
+ * Override react-markdown component renderers.
32
+ * The `animark-wrapper` component is reserved and cannot be overridden here.
33
+ */
34
+ components?: Omit<Components, "animark-wrapper">;
35
+ /** CSS class name applied to the root wrapper div */
36
+ className?: string;
37
+ /** Inline styles for the root wrapper div */
38
+ style?: React.CSSProperties;
39
+ }
40
+ declare const Animark: React.FC<AnimarkProps>;
41
+
42
+ interface AnimarkNodeRendererProps {
43
+ /** Animation config extracted from the AST node */
44
+ animation: AnimationConfig;
45
+ children: React.ReactNode;
46
+ /** Use Framer Motion when available. Falls back to CSS otherwise. */
47
+ useMotion?: boolean;
48
+ className?: string;
49
+ }
50
+ /**
51
+ * `AnimarkNodeRenderer` is the bridge between the parsed `animarkWrapper`
52
+ * AST node and the actual animation implementation.
53
+ *
54
+ * It decides whether to use CSS or Framer Motion based on the `useMotion` prop
55
+ * and falls back gracefully in SSR environments.
56
+ */
57
+ declare const AnimarkNodeRenderer: React.FC<AnimarkNodeRendererProps>;
58
+
59
+ interface CSSAnimatedWrapperProps {
60
+ animation: AnimationConfig;
61
+ children: React.ReactNode;
62
+ className?: string;
63
+ style?: React.CSSProperties;
64
+ }
65
+ /**
66
+ * Pure CSS animated wrapper.
67
+ * Works in SSR, does not require Framer Motion.
68
+ * Respects `prefers-reduced-motion` via CSS.
69
+ */
70
+ declare const CSSAnimatedWrapper: React.FC<CSSAnimatedWrapperProps>;
71
+
72
+ export { Animark, AnimarkNodeRenderer, type AnimarkProps, CSSAnimatedWrapper, Animark as default };
@@ -0,0 +1,25 @@
1
+ export { Animark, default } from "./Animark";
2
+ export type { AnimarkProps } from "./Animark";
3
+ export { AnimarkPlayer } from "./AnimarkPlayer";
4
+ export type { AnimarkPlayerProps } from "./AnimarkPlayer";
5
+ export { AnimarkControls } from "./AnimarkControls";
6
+ export type { AnimarkControlsProps } from "./AnimarkControls";
7
+ export { AnimarkProvider, AnimarkContext, useAnimarkContext, } from "./AnimarkContext";
8
+ export type { AnimarkContextValue } from "./AnimarkContext";
9
+ export { AnimarkNodeRenderer } from "./AnimarkNodeRenderer";
10
+ export { CSSAnimatedWrapper } from "./CSSAnimatedWrapper";
11
+ export type { AnimationConfig, AnimationType, AnimationDirection, AnimationTrigger, AnimarkWrapperNode, RemarkAnimarkOptions, } from "animark-core";
12
+ export { remarkAnimark } from "animark-core";
13
+ export { StepPlayer } from "./StepPlayer";
14
+ export type { StepPlayerProps } from "./StepPlayer";
15
+ export { StepControls } from "./StepControls";
16
+ export type { StepControlsProps } from "./StepControls";
17
+ export { StepBlock } from "./StepBlock";
18
+ export { StepCanvas } from "./StepCanvas";
19
+ export { StepProvider, useStepContext } from "./StepContext";
20
+ export type { StepContextValue } from "./StepContext";
21
+ export type { CanvasSize, CanvasPreset, ResolvedCanvasSize, } from "./canvasTypes";
22
+ export { resolveCanvasSize, VerticalAlign, HorizontalAlign, } from "./canvasTypes";
23
+ export { remarkStep } from "animark-core";
24
+ export type { StepWrapperNode } from "animark-core";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,YAAY,EACV,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ // ─── Main components ──────────────────────────────────────────────────────────
2
+ export { Animark, default } from "./Animark";
3
+ // ─── Player (Animark + controls + timeline) ───────────────────────────────────
4
+ export { AnimarkPlayer } from "./AnimarkPlayer";
5
+ // ─── Controls (use inside your own AnimarkProvider layout) ────────────────────
6
+ export { AnimarkControls } from "./AnimarkControls";
7
+ // ─── Context (for advanced / headless usage) ──────────────────────────────────
8
+ export { AnimarkProvider, AnimarkContext, useAnimarkContext, } from "./AnimarkContext";
9
+ // ─── Primitives ───────────────────────────────────────────────────────────────
10
+ export { AnimarkNodeRenderer } from "./AnimarkNodeRenderer";
11
+ export { CSSAnimatedWrapper } from "./CSSAnimatedWrapper";
12
+ export { remarkAnimark } from "animark-core";
13
+ // ─── Step / Presentation mode ─────────────────────────────────────────────────
14
+ export { StepPlayer } from "./StepPlayer";
15
+ export { StepControls } from "./StepControls";
16
+ export { StepBlock } from "./StepBlock";
17
+ export { StepCanvas } from "./StepCanvas";
18
+ export { StepProvider, useStepContext } from "./StepContext";
19
+ export { resolveCanvasSize, } from "./canvasTypes";
20
+ // ─── Core step re-exports ─────────────────────────────────────────────────────
21
+ export { remarkStep } from "animark-core";
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG7C,iFAAiF;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,iFAAiF;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,iFAAiF;AACjF,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,iFAAiF;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAW1D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,iFAAiF;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAS7D,OAAO,EACL,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AAEvB,iFAAiF;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,153 @@
1
+ // src/Animark.tsx
2
+ import { useMemo as useMemo2 } from "react";
3
+ import ReactMarkdown from "react-markdown";
4
+ import remarkDirective from "remark-directive";
5
+ import remarkMath from "remark-math";
6
+ import rehypeKatex from "rehype-katex";
7
+ import { remarkAnimark } from "animark-core";
8
+
9
+ // src/AnimarkNodeRenderer.tsx
10
+ import { Suspense, lazy } from "react";
11
+
12
+ // src/CSSAnimatedWrapper.tsx
13
+ import { jsx } from "react/jsx-runtime";
14
+ function getAnimationClass(animation) {
15
+ const dir = animation.direction ?? "up";
16
+ switch (animation.type) {
17
+ case "fade":
18
+ return "animark-fade";
19
+ case "scale":
20
+ return "animark-scale";
21
+ case "slide":
22
+ return `animark-slide-${dir}`;
23
+ case "move":
24
+ return `animark-move-${dir}`;
25
+ default:
26
+ return "animark-fade";
27
+ }
28
+ }
29
+ var CSSAnimatedWrapper = ({
30
+ animation,
31
+ children,
32
+ className = "",
33
+ style = {}
34
+ }) => {
35
+ const animClass = getAnimationClass(animation);
36
+ const duration = animation.duration ?? 500;
37
+ const delay = animation.delay ?? 0;
38
+ const inlineStyle = {
39
+ animationDuration: `${duration}ms`,
40
+ animationDelay: `${delay}ms`,
41
+ ...style
42
+ };
43
+ return /* @__PURE__ */ jsx(
44
+ "div",
45
+ {
46
+ className: `animark-wrapper ${animClass} ${className}`.trim(),
47
+ style: inlineStyle,
48
+ children
49
+ }
50
+ );
51
+ };
52
+
53
+ // src/AnimarkNodeRenderer.tsx
54
+ import { jsx as jsx2 } from "react/jsx-runtime";
55
+ var LazyMotionWrapper = lazy(
56
+ () => import("./MotionAnimatedWrapper-HT6ZXMNF.mjs").then((m) => ({
57
+ default: m.MotionAnimatedWrapper
58
+ }))
59
+ );
60
+ var AnimarkNodeRenderer = ({
61
+ animation,
62
+ children,
63
+ useMotion = false,
64
+ className
65
+ }) => {
66
+ if (!useMotion) {
67
+ return /* @__PURE__ */ jsx2(CSSAnimatedWrapper, { animation, className, children });
68
+ }
69
+ return /* @__PURE__ */ jsx2(
70
+ Suspense,
71
+ {
72
+ fallback: /* @__PURE__ */ jsx2(CSSAnimatedWrapper, { animation, className, children }),
73
+ children: /* @__PURE__ */ jsx2(LazyMotionWrapper, { animation, className, children })
74
+ }
75
+ );
76
+ };
77
+
78
+ // src/Animark.tsx
79
+ import { jsx as jsx3 } from "react/jsx-runtime";
80
+ var Animark = ({
81
+ children,
82
+ useMotion = false,
83
+ pluginOptions = {},
84
+ remarkPlugins = [],
85
+ rehypePlugins = [],
86
+ components = {},
87
+ className,
88
+ style
89
+ }) => {
90
+ const finalRemarkPlugins = useMemo2(
91
+ () => [
92
+ remarkDirective,
93
+ [remarkAnimark, pluginOptions],
94
+ remarkMath,
95
+ ...remarkPlugins
96
+ ],
97
+ // eslint-disable-next-line react-hooks/exhaustive-deps
98
+ [pluginOptions, ...remarkPlugins]
99
+ );
100
+ const finalRehypePlugins = useMemo2(
101
+ () => [rehypeKatex, ...rehypePlugins],
102
+ // eslint-disable-next-line react-hooks/exhaustive-deps
103
+ [...rehypePlugins]
104
+ );
105
+ const finalComponents = useMemo2(
106
+ () => ({
107
+ ...components,
108
+ // react-markdown maps hName → component key
109
+ // Our remarkAnimark plugin sets hName: "animark-wrapper"
110
+ "animark-wrapper": (props) => {
111
+ const { children: wrapperChildren } = props;
112
+ const toNum = (v) => v !== void 0 && v !== "" ? Number(v) : void 0;
113
+ const animation = {
114
+ type: props["data-animark-type"] ?? "fade",
115
+ trigger: props["data-animark-trigger"] ?? "auto",
116
+ ...toNum(props["data-animark-delay"]) !== void 0 && { delay: toNum(props["data-animark-delay"]) },
117
+ ...toNum(props["data-animark-duration"]) !== void 0 && { duration: toNum(props["data-animark-duration"]) },
118
+ ...toNum(props["data-animark-stagger"]) !== void 0 && { stagger: toNum(props["data-animark-stagger"]) },
119
+ ...props["data-animark-direction"] && { direction: props["data-animark-direction"] }
120
+ };
121
+ return /* @__PURE__ */ jsx3(
122
+ AnimarkNodeRenderer,
123
+ {
124
+ animation,
125
+ useMotion,
126
+ children: wrapperChildren
127
+ }
128
+ );
129
+ }
130
+ }),
131
+ [components, useMotion]
132
+ );
133
+ return /* @__PURE__ */ jsx3("div", { className, style, children: /* @__PURE__ */ jsx3(
134
+ ReactMarkdown,
135
+ {
136
+ remarkPlugins: finalRemarkPlugins,
137
+ rehypePlugins: finalRehypePlugins,
138
+ components: finalComponents,
139
+ children
140
+ }
141
+ ) });
142
+ };
143
+ var Animark_default = Animark;
144
+
145
+ // src/index.ts
146
+ import { remarkAnimark as remarkAnimark2 } from "animark-core";
147
+ export {
148
+ Animark,
149
+ AnimarkNodeRenderer,
150
+ CSSAnimatedWrapper,
151
+ Animark_default as default,
152
+ remarkAnimark2 as remarkAnimark
153
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "animark-react",
3
+ "version": "0.1.0",
4
+ "description": "React renderer for animark — animated Markdown components",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./styles": "./src/animark.css"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src/animark.css"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.json",
24
+ "dev": "tsc -p tsconfig.json --watch",
25
+ "test": "vitest run"
26
+ },
27
+ "keywords": ["react", "markdown", "animation", "animark", "remark"],
28
+ "license": "MIT",
29
+ "dependencies": {
30
+ "animark-core": "^0.1.0",
31
+ "framer-motion": "^11.0.0",
32
+ "react-markdown": "^9.0.0",
33
+ "remark-directive": "^3.0.0",
34
+ "remark-gfm": "^4.0.0",
35
+ "remark-math": "^6.0.0",
36
+ "rehype-katex": "^7.0.0"
37
+ },
38
+ "peerDependencies": {
39
+ "react": "^18.0.0",
40
+ "react-dom": "^18.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/react": "^18.0.0",
44
+ "@types/react-dom": "^18.0.0",
45
+ "tsup": "^8.0.0",
46
+ "vitest": "^1.0.0"
47
+ }
48
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * animark — CSS animation keyframes and utility classes.
3
+ *
4
+ * These styles are the fallback when Framer Motion is not available and
5
+ * are also used as the SSR-safe baseline (no JS required for initial paint).
6
+ *
7
+ * Import in your app root:
8
+ * import "animark-react/styles";
9
+ */
10
+
11
+ @keyframes animark-fade-in {
12
+ from { opacity: 0; }
13
+ to { opacity: 1; }
14
+ }
15
+
16
+ @keyframes animark-slide-up {
17
+ from { opacity: 0; transform: translateY(24px); }
18
+ to { opacity: 1; transform: translateY(0); }
19
+ }
20
+
21
+ @keyframes animark-slide-down {
22
+ from { opacity: 0; transform: translateY(-24px); }
23
+ to { opacity: 1; transform: translateY(0); }
24
+ }
25
+
26
+ @keyframes animark-slide-left {
27
+ from { opacity: 0; transform: translateX(24px); }
28
+ to { opacity: 1; transform: translateX(0); }
29
+ }
30
+
31
+ @keyframes animark-slide-right {
32
+ from { opacity: 0; transform: translateX(-24px); }
33
+ to { opacity: 1; transform: translateX(0); }
34
+ }
35
+
36
+ @keyframes animark-scale-in {
37
+ from { opacity: 0; transform: scale(0.88); }
38
+ to { opacity: 1; transform: scale(1); }
39
+ }
40
+
41
+ @keyframes animark-move-up {
42
+ from { transform: translateY(12px); }
43
+ to { transform: translateY(0); }
44
+ }
45
+
46
+ @keyframes animark-move-down {
47
+ from { transform: translateY(-12px); }
48
+ to { transform: translateY(0); }
49
+ }
50
+
51
+ @keyframes animark-move-left {
52
+ from { transform: translateX(12px); }
53
+ to { transform: translateX(0); }
54
+ }
55
+
56
+ @keyframes animark-move-right {
57
+ from { transform: translateX(-12px); }
58
+ to { transform: translateX(0); }
59
+ }
60
+
61
+ /* ─── Base ─────────────────────────────────────────────────────────────────── */
62
+
63
+ .animark-wrapper {
64
+ animation-fill-mode: both;
65
+ animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
66
+ }
67
+
68
+ /* Disable animations for users who prefer reduced motion */
69
+ @media (prefers-reduced-motion: reduce) {
70
+ .animark-wrapper {
71
+ animation: none !important;
72
+ transition: none !important;
73
+ }
74
+ }
75
+
76
+ /* ─── Type classes ──────────────────────────────────────────────────────────── */
77
+
78
+ .animark-fade { animation-name: animark-fade-in; }
79
+ .animark-scale { animation-name: animark-scale-in; }
80
+
81
+ .animark-slide-up { animation-name: animark-slide-up; }
82
+ .animark-slide-down { animation-name: animark-slide-down; }
83
+ .animark-slide-left { animation-name: animark-slide-left; }
84
+ .animark-slide-right { animation-name: animark-slide-right; }
85
+
86
+ .animark-move-up { animation-name: animark-move-up; }
87
+ .animark-move-down { animation-name: animark-move-down; }
88
+ .animark-move-left { animation-name: animark-move-left; }
89
+ .animark-move-right { animation-name: animark-move-right; }