@mihirsarya/manim-scroll 0.2.0 → 0.2.1

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 (2) hide show
  1. package/README.md +151 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # @mihirsarya/manim-scroll
2
+
3
+ Unified package for scroll-driven Manim animations. Pre-render mathematical animations with Manim and play them back smoothly as users scroll.
4
+
5
+ This is the recommended package for most users—it re-exports everything from the runtime, React, and Next.js packages.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @mihirsarya/manim-scroll
11
+ ```
12
+
13
+ ## Requirements
14
+
15
+ - React 18+
16
+ - Next.js 13+ (for the build plugin)
17
+ - Python 3.8+ with [Manim](https://www.manim.community/) installed
18
+
19
+ ## Quick Start
20
+
21
+ ### 1. Configure Next.js
22
+
23
+ ```js
24
+ // next.config.js
25
+ const { withManimScroll } = require("@mihirsarya/manim-scroll/next");
26
+
27
+ module.exports = withManimScroll({
28
+ manimScroll: {
29
+ pythonPath: "python3",
30
+ quality: "h",
31
+ },
32
+ });
33
+ ```
34
+
35
+ ### 2. Use the Component
36
+
37
+ ```tsx
38
+ import { ManimScroll } from "@mihirsarya/manim-scroll";
39
+
40
+ export default function Page() {
41
+ return (
42
+ <ManimScroll
43
+ scene="TextScene"
44
+ fontSize={72}
45
+ color="#ffffff"
46
+ scrollRange="viewport"
47
+ >
48
+ Welcome to my site
49
+ </ManimScroll>
50
+ );
51
+ }
52
+ ```
53
+
54
+ The plugin automatically scans your source files, extracts `<ManimScroll>` components, and renders animations at build time with smart caching.
55
+
56
+ ## Exports
57
+
58
+ ### From the main entry (`@mihirsarya/manim-scroll`)
59
+
60
+ **React Components & Hooks:**
61
+ - `ManimScroll` - Scroll-driven animation component
62
+ - `useManimScroll` - Hook for custom integrations with pre-rendered assets
63
+ - `useNativeAnimation` - Hook for native SVG text animation
64
+
65
+ **Runtime:**
66
+ - `registerScrollAnimation` - Register scroll animation (vanilla JS)
67
+ - `registerNativeAnimation` - Register native text animation (vanilla JS)
68
+ - `NativeTextPlayer` - Native text animation player class
69
+
70
+ **Types:**
71
+ - `ManimScrollProps`, `ManimAnimationProps`
72
+ - `UseManimScrollOptions`, `UseManimScrollResult`
73
+ - `UseNativeAnimationOptions`, `UseNativeAnimationResult`
74
+ - `RenderManifest`, `ScrollAnimationOptions`, `ScrollRange`, `ScrollRangePreset`, `ScrollRangeValue`
75
+ - `NativeAnimationOptions`
76
+
77
+ ### From Next.js entry (`@mihirsarya/manim-scroll/next`)
78
+
79
+ - `withManimScroll` - Next.js config wrapper
80
+ - `ManimScrollConfig` - Configuration type
81
+ - `extractAnimations` - Extract animations from source files
82
+ - `renderAnimations` - Render animations with Manim CLI
83
+ - `computePropsHash`, `isCached`, `getCacheEntry`, etc.
84
+
85
+ ## Component Props
86
+
87
+ | Prop | Type | Description |
88
+ |------|------|-------------|
89
+ | `scene` | `string` | Scene name (default: `"TextScene"`) |
90
+ | `fontSize` | `number` | Font size for text animations |
91
+ | `color` | `string` | Color as hex string (e.g., `"#ffffff"`) |
92
+ | `font` | `string` | Font family for text |
93
+ | `inline` | `boolean` | Enable inline mode for text that flows with content |
94
+ | `mode` | `"auto" \| "video" \| "frames" \| "native"` | Playback mode |
95
+ | `scrollRange` | `ScrollRangeValue` | Scroll range configuration |
96
+ | `manifestUrl` | `string` | Explicit manifest URL (overrides auto-resolution) |
97
+ | `onReady` | `() => void` | Called when animation is loaded |
98
+ | `onProgress` | `(progress: number) => void` | Called on scroll progress |
99
+ | `children` | `ReactNode` | Text content for the animation |
100
+
101
+ ## Scroll Range Configuration
102
+
103
+ ```tsx
104
+ // Presets
105
+ <ManimScroll scrollRange="viewport">...</ManimScroll>
106
+ <ManimScroll scrollRange="element">...</ManimScroll>
107
+ <ManimScroll scrollRange="full">...</ManimScroll>
108
+
109
+ // Relative units
110
+ <ManimScroll scrollRange={["100vh", "-50%"]}>...</ManimScroll>
111
+
112
+ // Pixel values
113
+ <ManimScroll scrollRange={[800, -400]}>...</ManimScroll>
114
+ ```
115
+
116
+ ## Next.js Plugin Options
117
+
118
+ | Option | Default | Description |
119
+ |--------|---------|-------------|
120
+ | `pythonPath` | `"python3"` | Path to Python executable |
121
+ | `quality` | `"h"` | Manim quality preset (l, m, h, k) |
122
+ | `fps` | `30` | Frames per second |
123
+ | `resolution` | `"1920x1080"` | Output resolution |
124
+ | `format` | `"both"` | Output format (frames, video, both) |
125
+ | `concurrency` | CPU count - 1 | Max parallel renders |
126
+ | `verbose` | `false` | Enable verbose logging |
127
+ | `cleanOrphans` | `true` | Remove unused cached assets |
128
+
129
+ ## Native Mode
130
+
131
+ For text animations without pre-rendered assets, use native mode:
132
+
133
+ ```tsx
134
+ <ManimScroll mode="native" fontSize={48} color="#ffffff">
135
+ Animate this text
136
+ </ManimScroll>
137
+ ```
138
+
139
+ Native mode renders directly in the browser using SVG, replicating Manim's Write/DrawBorderThenFill effect.
140
+
141
+ ## Related Packages
142
+
143
+ | Package | npm | Description |
144
+ |---------|-----|-------------|
145
+ | `@mihirsarya/manim-scroll-react` | React component and hooks |
146
+ | `@mihirsarya/manim-scroll-next` | Next.js build plugin |
147
+ | `@mihirsarya/manim-scroll-runtime` | Core scroll runtime |
148
+
149
+ ## License
150
+
151
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mihirsarya/manim-scroll",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Unified package for scroll-driven Manim animations - includes runtime, React components, and Next.js plugin.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,9 +28,9 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@mihirsarya/manim-scroll-react": "0.2.0",
32
- "@mihirsarya/manim-scroll-runtime": "0.2.0",
33
- "@mihirsarya/manim-scroll-next": "0.2.0"
31
+ "@mihirsarya/manim-scroll-runtime": "0.2.1",
32
+ "@mihirsarya/manim-scroll-react": "0.2.1",
33
+ "@mihirsarya/manim-scroll-next": "0.2.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/react": "^18.2.61",