aniview 1.0.1 → 1.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 (70) hide show
  1. package/CHANGELOG.md +40 -21
  2. package/README.md +93 -97
  3. package/dist/Aniview.d.ts +1 -0
  4. package/dist/Aniview.d.ts.map +1 -1
  5. package/dist/Aniview.js +24 -682
  6. package/dist/Aniview.js.map +1 -1
  7. package/dist/AniviewPanel.d.ts.map +1 -1
  8. package/dist/aniviewConfig.d.ts +98 -6
  9. package/dist/aniviewConfig.d.ts.map +1 -1
  10. package/dist/aniviewConfig.js +109 -338
  11. package/dist/aniviewConfig.js.map +1 -1
  12. package/dist/aniviewProvider.d.ts +3 -1
  13. package/dist/aniviewProvider.d.ts.map +1 -1
  14. package/dist/aniviewProvider.js +24 -5
  15. package/dist/aniviewProvider.js.map +1 -1
  16. package/dist/core/AniviewBake.d.ts +37 -0
  17. package/dist/core/AniviewBake.d.ts.map +1 -0
  18. package/dist/core/AniviewBake.js +309 -0
  19. package/dist/core/AniviewBake.js.map +1 -0
  20. package/dist/core/AniviewColor.d.ts +62 -0
  21. package/dist/core/AniviewColor.d.ts.map +1 -0
  22. package/dist/core/AniviewColor.js +199 -0
  23. package/dist/core/AniviewColor.js.map +1 -0
  24. package/dist/core/AniviewGesture.d.ts +46 -0
  25. package/dist/core/AniviewGesture.d.ts.map +1 -0
  26. package/dist/core/AniviewGesture.js +344 -0
  27. package/dist/core/AniviewGesture.js.map +1 -0
  28. package/dist/core/AniviewLock.d.ts +8 -0
  29. package/dist/core/AniviewLock.d.ts.map +1 -1
  30. package/dist/core/AniviewLock.js +8 -0
  31. package/dist/core/AniviewLock.js.map +1 -1
  32. package/dist/core/AniviewMath.d.ts +31 -7
  33. package/dist/core/AniviewMath.d.ts.map +1 -1
  34. package/dist/core/AniviewMath.js +31 -7
  35. package/dist/core/AniviewMath.js.map +1 -1
  36. package/dist/core/AniviewStyle.d.ts +34 -0
  37. package/dist/core/AniviewStyle.d.ts.map +1 -0
  38. package/dist/core/AniviewStyle.js +333 -0
  39. package/dist/core/AniviewStyle.js.map +1 -0
  40. package/dist/core/AniviewStyleUtils.d.ts +157 -0
  41. package/dist/core/AniviewStyleUtils.d.ts.map +1 -0
  42. package/dist/core/AniviewStyleUtils.js +44 -0
  43. package/dist/core/AniviewStyleUtils.js.map +1 -0
  44. package/dist/useAniview.js +2 -0
  45. package/dist/useAniview.js.map +1 -1
  46. package/dist/useAniviewContext.d.ts +75 -1
  47. package/dist/useAniviewContext.d.ts.map +1 -1
  48. package/dist/useAniviewContext.js.map +1 -1
  49. package/dist/useAniviewLock.d.ts +2 -5
  50. package/dist/useAniviewLock.d.ts.map +1 -1
  51. package/dist/useAniviewLock.js +13 -5
  52. package/dist/useAniviewLock.js.map +1 -1
  53. package/package.json +6 -5
  54. package/src/Aniview.tsx +43 -704
  55. package/src/__tests__/AniviewBake.test.ts +282 -0
  56. package/src/__tests__/AniviewColor.test.ts +431 -0
  57. package/src/__tests__/AniviewSnapshot.test.tsx +30 -33
  58. package/src/__tests__/__snapshots__/AniviewSnapshot.test.tsx.snap +183 -3
  59. package/src/aniviewConfig.tsx +115 -363
  60. package/src/aniviewProvider.tsx +29 -9
  61. package/src/core/AniviewBake.ts +310 -0
  62. package/src/core/AniviewColor.ts +219 -0
  63. package/src/core/AniviewGesture.ts +433 -0
  64. package/src/core/AniviewLock.ts +31 -23
  65. package/src/core/AniviewMath.ts +31 -7
  66. package/src/core/AniviewStyle.ts +400 -0
  67. package/src/core/AniviewStyleUtils.ts +49 -0
  68. package/src/useAniview.tsx +2 -0
  69. package/src/useAniviewContext.tsx +75 -3
  70. package/src/useAniviewLock.tsx +14 -6
package/CHANGELOG.md CHANGED
@@ -1,21 +1,40 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.0.0] - 2026-02-10
9
-
10
- ### Added
11
-
12
- - `Aniview` core animated component with spatial and event-driven keyframes
13
- - `AniviewProvider` context provider with gesture handling and spring physics
14
- - `AniviewConfig` 2D grid layout engine with page mapping, overlaps, and adjacency graphs
15
- - `AniviewPanel` / `PanelFrame` — pre-styled panel components
16
- - `useAniview` — hook to access Aniview context (dimensions, events, config)
17
- - `useAniviewLock` — hook for directional gesture locking
18
- - Smart color interpolation (transparent-aware, no gray artifacts)
19
- - Pre-computed animation grid (zero runtime frame searches)
20
- - Worklet-optimized rendering (UI thread only)
21
- - Full TypeScript type definitions
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.1] - 2026-06-09
9
+
10
+ ### Added
11
+
12
+ - Core animation baking, color interpolation, gesture, and style helpers split into focused modules under `src/core/`.
13
+ - Regression tests for frame baking, color interpolation, lock masks, math helpers, and snapshots.
14
+ - Local development guide for testing Aniview from a consumer React Native app with Metro module de-duplication.
15
+
16
+ ### Changed
17
+
18
+ - Refreshed README, Getting Started, Core Concepts, API Reference, Performance, Testing, Gesture Control, Reporting Issues, and Docusaurus docs to match the current public API.
19
+ - Updated development dependencies for the current React Native/Reanimated test setup.
20
+ - Improved snapshot test setup for the current React test renderer behavior.
21
+ - Clarified `persistent` component mounting versus `eventPersistent` event-frame weighting.
22
+
23
+ ### Fixed
24
+
25
+ - Corrected directional lock-mask handling so `AniviewLock.mask({ left, right, up, down })` matches provider gesture behavior.
26
+ - Removed stale Docusaurus/template documentation language and broken documentation links.
27
+
28
+ ## [1.0.0] - 2026-02-10
29
+
30
+ ### Added
31
+
32
+ - `Aniview` — core animated component with spatial and event-driven keyframes
33
+ - `AniviewProvider` — context provider with gesture handling and spring physics
34
+ - `AniviewConfig` — 2D grid layout engine with page mapping, overlaps, and adjacency graphs
35
+ - `useAniview` — hook to access Aniview context (dimensions, events, config)
36
+ - `useAniviewLock` — hook for directional gesture locking
37
+ - Smart color interpolation (transparent-aware, no gray artifacts)
38
+ - Pre-computed animation grid (zero runtime frame searches)
39
+ - Worklet-optimized rendering (UI thread only)
40
+ - Full TypeScript type definitions
package/README.md CHANGED
@@ -4,127 +4,123 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
5
  [![React Native](https://img.shields.io/badge/React%20Native-%3E%3D0.71-blue)](https://reactnative.dev/)
6
6
 
7
- > A high-performance, coordinate-based animation engine for React Native. Create fluid, multi-dimensional page transitions with spatial and event-driven animations.
7
+ Aniview is a coordinate-based animation and page-navigation engine for React Native. It lets you describe a 2D page world, place components on named pages, and define style frames that interpolate as the camera moves between pages or as custom Reanimated `SharedValue`s change.
8
8
 
9
- ## Features
9
+ ## What it is good for
10
10
 
11
- - **Pre-computed Animation Grid** - Zero runtime frame searches
12
- - **Spatial & Event-Driven** - Animate based on position OR custom events
13
- - **Gesture Coordination** - Built-in lock system for complex UI interactions
14
- - **Smart Color Interpolation** - Transparent-aware color transitions
15
- - **Worklet-Optimized** - Runs entirely on the UI thread
16
- - **2D Layout Engine** - Grid-based page navigation with overlap support
17
- - **TypeScript First** - Full type safety out of the box
11
+ - Swipeable multi-page interfaces that are not just a flat carousel.
12
+ - Components that morph between pages without imperative animation code.
13
+ - Event-driven effects such as scroll, zoom, or progress-linked animation.
14
+ - React Native apps that need gesture coordination between page swipes and nested interactions.
15
+ - Persistent animated surfaces such as video, canvas, or GL content that must not unmount offscreen.
18
16
 
19
- ## Quick Start
17
+ ## Install
18
+
19
+ Aniview expects a working React Native app with Reanimated and React Native Gesture Handler configured.
20
20
 
21
21
  ```bash
22
22
  npm install aniview react-native-reanimated react-native-gesture-handler
23
23
  ```
24
24
 
25
- ### Basic Example
26
-
27
- ```tsx
28
- import { AniviewProvider, Aniview } from "aniview";
29
-
30
- // 1. Define your layout (3x3 grid)
31
- const config = new AniviewConfig(
32
- [
33
- [1, 1, 1],
34
- [1, 1, 1],
35
- [1, 1, 1],
36
- ],
37
- 0, // default page
38
- { HOME: 0, PROFILE: 1, SETTINGS: 2 }, // page map
39
- );
40
-
41
- // 2. Wrap your app
42
- function App() {
43
- return (
44
- <AniviewProvider config={config}>
45
- <Header />
46
- <Content />
47
- </AniviewProvider>
48
- );
49
- }
25
+ For Expo projects, prefer Expo's version resolver for the peer dependencies:
50
26
 
51
- // 3. Animate components
52
- function Header() {
53
- return (
54
- <Aniview
55
- pageId="HOME"
56
- frames={{
57
- profile: {
58
- page: "PROFILE",
59
- style: { backgroundColor: "blue" },
60
- },
61
- }}
62
- style={{ height: 100, backgroundColor: "white" }}
63
- >
64
- <Text>My Header</Text>
65
- </Aniview>
66
- );
67
- }
27
+ ```bash
28
+ npx expo install react-native-reanimated react-native-gesture-handler
29
+ npm install aniview
68
30
  ```
69
31
 
70
- ## Documentation
32
+ Make sure the Reanimated Babel plugin is configured according to the Reanimated docs for your app.
71
33
 
72
- - **[Getting Started](docs/01-getting-started.md)** - Installation and first steps
73
- - **[Core Concepts](docs/02-core-concepts.md)** - Understanding the architecture
74
- - **[API Reference](docs/03-api-reference.md)** - Complete API documentation
75
- - **[Advanced Patterns](docs/04-advanced-patterns.md)** - Composition, Persistence & Virtualization
76
- - **[Examples & Recipes](docs/05-examples.md)** - Full Example App Walkthrough
77
- - **[Performance Guide](docs/06-performance.md)** - Optimization techniques
78
- - **[Testing](docs/07-testing.md)** - How to test Aniview components
79
- - **[Gesture Control](docs/08-gesture-control.md)** - Lock system and gesture coordination
80
- - **[Reporting Issues](docs/09-reporting-issues.md)** - Bug reports and feature requests
34
+ ## Minimal Example
81
35
 
82
- ## Key Concepts
36
+ ```tsx
37
+ import React from "react";
38
+ import { Text, StyleSheet } from "react-native";
39
+ import { GestureHandlerRootView } from "react-native-gesture-handler";
40
+ import { Aniview, AniviewProvider } from "aniview";
83
41
 
84
- ### The Grid System
42
+ const pageMap = {
43
+ HOME: 0,
44
+ PROFILE: 1,
45
+ };
85
46
 
86
- Aniview uses a **2D grid layout** where each cell represents a "page":
47
+ export default function App() {
48
+ return (
49
+ <GestureHandlerRootView style={styles.root}>
50
+ <AniviewProvider layout={[[1, 1]]} pageMap={pageMap} defaultPage="HOME">
51
+ <Aniview pageId="HOME" style={[styles.page, styles.home]}>
52
+ <Text style={styles.title}>Home</Text>
53
+ </Aniview>
54
+
55
+ <Aniview pageId="PROFILE" style={[styles.page, styles.profile]}>
56
+ <Text style={styles.title}>Profile</Text>
57
+ </Aniview>
58
+
59
+ <Aniview
60
+ pageId="HOME"
61
+ style={styles.badge}
62
+ frames={{
63
+ atProfile: {
64
+ page: "PROFILE",
65
+ style: {
66
+ backgroundColor: "#e91e63",
67
+ transform: [{ scale: 1.4 }],
68
+ },
69
+ },
70
+ }}
71
+ />
72
+ </AniviewProvider>
73
+ </GestureHandlerRootView>
74
+ );
75
+ }
87
76
 
77
+ const styles = StyleSheet.create({
78
+ root: { flex: 1 },
79
+ page: {
80
+ width: "100%",
81
+ height: "100%",
82
+ alignItems: "center",
83
+ justifyContent: "center",
84
+ },
85
+ home: { backgroundColor: "#e3f2fd" },
86
+ profile: { backgroundColor: "#fce4ec" },
87
+ title: { fontSize: 32, fontWeight: "700" },
88
+ badge: {
89
+ width: 72,
90
+ height: 72,
91
+ borderRadius: 36,
92
+ backgroundColor: "#2196f3",
93
+ left: 32,
94
+ top: 64,
95
+ },
96
+ });
88
97
  ```
89
- [0, 1, 2] → Pages 0, 1, 2 (horizontal row)
90
- [3, 4, 5] → Pages 3, 4, 5 (second row)
91
- ```
92
-
93
- Components declare where they "live" (`pageId`) and how they transform when navigating to other pages (`frames`).
94
-
95
- ### Animation Types
96
98
 
97
- 1. **Spatial Animations** - Triggered by page navigation (X/Y position)
98
- 2. **Event-Driven Animations** - Triggered by custom SharedValues (scroll, zoom, etc.)
99
+ Swipe horizontally to move between `HOME` and `PROFILE`. The badge belongs to `HOME`, but its frame describes how it should look when the camera reaches `PROFILE`.
99
100
 
100
- ### The Baking Process
101
-
102
- On mount, Aniview:
103
-
104
- 1. Pre-computes a **grid of all possible states**
105
- 2. Organizes them into **horizontal and vertical lanes**
106
- 3. Marks **constant values** to skip interpolation
107
- 4. All this happens **once**, not on every frame
101
+ ## Documentation
108
102
 
109
- ## Platform Support
103
+ - [Getting Started](docs/01-getting-started.md) - Installation and first working app
104
+ - [Core Concepts](docs/02-core-concepts.md) - Coordinate space, pages, frames, baking, and virtualization
105
+ - [API Reference](docs/03-api-reference.md) - Public components, hooks, methods, and types
106
+ - [Advanced Patterns](docs/04-advanced-patterns.md) - Composition, persistence, and event-driven patterns
107
+ - [Examples & Recipes](docs/05-examples.md) - Larger examples and interaction recipes
108
+ - [Performance Guide](docs/06-performance.md) - Optimization techniques
109
+ - [Testing](docs/07-testing.md) - Testing Aniview logic and components
110
+ - [Gesture Control](docs/08-gesture-control.md) - Gesture toggles, locks, and simultaneous handlers
111
+ - [Reporting Issues](docs/09-reporting-issues.md) - Bug reports and feature requests
112
+ - [Local Development](LOCAL_DEV.md) - Using a local checkout from a React Native app
110
113
 
111
- Aniview is designed for **React Native** (iOS and Android). It is compatible with:
114
+ ## Mental Model
112
115
 
113
- - **Expo** managed workflow (SDK 49+)
114
- - **React Native CLI** projects
115
- - **New Architecture** (Fabric) — fully compatible (pure JS/TS + Reanimated worklets)
116
+ Aniview has three moving parts:
116
117
 
117
- ## Contributing
118
+ 1. `AniviewProvider` owns the camera, dimensions, page layout, gesture handler, and custom event shared values.
119
+ 2. `AniviewConfig` maps page IDs to world coordinates and builds gesture/navigation rules.
120
+ 3. `Aniview` components declare a home page plus optional spatial or event frames. On mount, frames are baked into interpolation lanes consumed by Reanimated worklets.
118
121
 
119
- We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
122
+ The important composition rule: use sibling `Aniview` components for world-positioned elements. Nest `Aniview` components only when you intentionally want parent and child transforms to combine.
120
123
 
121
124
  ## License
122
125
 
123
- MIT © Madelyn Cruz Tan
124
-
125
- ## Credits
126
-
127
- Built with:
128
-
129
- - [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated)
130
- - [react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler)
126
+ MIT (c) Madelyn Cruz Tan (TitanicEclair)
package/dist/Aniview.d.ts CHANGED
@@ -40,6 +40,7 @@ import { AniviewProps } from './useAniviewContext';
40
40
  * @param props.persistent - If `true`, stays mounted even when far offscreen. Required for WebGL/Three.js canvases. Default: `false`
41
41
  * @param props.style - Base styles applied when at home position. Numeric and color props here become the interpolation baseline.
42
42
  * @param props.pointerEvents - Standard RN pointer events. Useful for overlay pages that shouldn't block touches.
43
+ * @returns Animated view that interpolates styles from spatial and event lanes.
43
44
  *
44
45
  * @example
45
46
  * ```tsx
@@ -1 +1 @@
1
- {"version":3,"file":"Aniview.d.ts","sourceRoot":"","sources":["../src/Aniview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAUzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAiMnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,4BA6lBlD"}
1
+ {"version":3,"file":"Aniview.d.ts","sourceRoot":"","sources":["../src/Aniview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAOzE,OAAO,EAAE,YAAY,EAAe,MAAM,qBAAqB,CAAC;AAKhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,KAAK,EAAE,YAAY,4BAsIlD"}