@umituz/react-native-photo-editor 2.0.23 → 2.0.24

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-photo-editor",
3
- "version": "2.0.23",
3
+ "version": "2.0.24",
4
4
  "description": "A powerful, generic photo editor for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/ARCHITECTURE.md DELETED
@@ -1,104 +0,0 @@
1
- # Architecture - Photo Editor DDD Design
2
-
3
- ## Overview
4
-
5
- This photo editor is built using **Domain-Driven Design (DDD)** principles, ensuring maintainability, testability, and scalability. Every file is kept under 150 lines for clarity.
6
-
7
- ## Layer Structure
8
-
9
- ```
10
- src/
11
- ├── domain/ # Business logic (pure TypeScript)
12
- │ ├── entities/
13
- │ │ ├── Layer.ts # Layer entities (TextLayer, StickerLayer)
14
- │ │ ├── Transform.ts # Transform value object
15
- │ │ └── Filters.ts # Filters value object
16
- │ └── services/
17
- │ ├── LayerService.ts # Layer business logic
18
- │ └── HistoryService.ts # Undo/redo service
19
-
20
- ├── infrastructure/ # External concerns
21
- │ ├── gesture/
22
- │ │ ├── useTransformGesture.ts # Reusable gesture hook
23
- │ │ └── types.ts # Gesture types
24
- │ └── history/
25
- │ └── HistoryManager.ts # Legacy wrapper
26
-
27
- ├── application/ # Application logic
28
- │ ├── stores/
29
- │ │ └── EditorStore.ts # Zustand state store
30
- │ └── hooks/
31
- │ ├── useEditor.ts # Main editor hook
32
- │ └── useEditorUI.ts # UI-specific hook
33
-
34
- └── presentation/ # UI components
35
- └── components/
36
- ├── DraggableLayer.tsx # Unified draggable (replaces Text + Sticker)
37
- ├── EditorCanvas.tsx
38
- ├── EditorToolbar.tsx
39
- ├── FontControls.tsx
40
- ├── ui/
41
- │ ├── ColorPicker.tsx
42
- │ └── Slider.tsx
43
- └── sheets/
44
- ├── TextEditorSheet.tsx
45
- ├── FilterSheet.tsx
46
- ├── AdjustmentsSheet.tsx
47
- ├── LayerManager.tsx
48
- ├── StickerPicker.tsx
49
- └── AIMagicSheet.tsx
50
- ```
51
-
52
- ## Key Improvements
53
-
54
- ### 1. Eliminated Code Duplication (~180 lines)
55
- - **Before**: `DraggableText.tsx` (182 lines) and `DraggableSticker.tsx` (162 lines) - duplicate gesture logic
56
- - **After**: `DraggableLayer.tsx` (110 lines) + `useTransformGesture.ts` (130 lines) - reusable gesture hook
57
-
58
- ### 2. Domain Entities
59
- - Rich domain models with business logic
60
- - Type-safe layer operations
61
- - Value objects for Transform and Filters
62
-
63
- ### 3. Separated Concerns
64
- - **Domain**: Pure business logic, no framework dependencies
65
- - **Infrastructure**: React Native, gesture handlers
66
- - **Application**: State management, orchestration
67
- - **Presentation**: UI components only
68
-
69
- ### 4. State Management
70
- - Zustand store for global editor state
71
- - History service for undo/redo
72
- - Clean separation between domain and UI state
73
-
74
- ## Usage
75
-
76
- ```tsx
77
- import { PhotoEditor } from "@umituz/react-native-photo-editor";
78
-
79
- <PhotoEditor
80
- imageUri={imageUri}
81
- onSave={(uri, layers, filters) => console.log({ uri, layers, filters })}
82
- onClose={() => navigation.goBack()}
83
- t={(key) => i18n.t(key)}
84
- />
85
- ```
86
-
87
- ## Testing
88
-
89
- Each layer can be tested independently:
90
- - Domain: Pure functions, easy to unit test
91
- - Infrastructure: Gesture hooks with test utils
92
- - Application: Store with test environment
93
- - Presentation: React component testing
94
-
95
- ## Migration from Old Architecture
96
-
97
- The old files have been preserved for backward compatibility:
98
- - Old hooks: `src/hooks/`
99
- - Old components: `src/components/`
100
-
101
- New code should use:
102
- - `useEditor()` instead of `usePhotoEditor()`
103
- - `useEditorUI()` instead of `usePhotoEditorUI()`
104
- - Components from `src/presentation/components/`
package/MIGRATION.md DELETED
@@ -1,100 +0,0 @@
1
- # Migration Guide - Old to New Architecture
2
-
3
- ## What Changed?
4
-
5
- ### Before
6
- ```
7
- src/
8
- ├── hooks/
9
- │ ├── usePhotoEditor.ts # 173 lines - mixed concerns
10
- │ └── usePhotoEditorUI.ts # 163 lines - UI + business logic
11
- ├── components/
12
- │ ├── DraggableText.tsx # 182 lines - gesture + UI
13
- │ ├── DraggableSticker.tsx # 162 lines - DUPLICATE of above
14
- │ └── ...
15
- ├── core/
16
- │ └── HistoryManager.ts # Generic, reusable
17
- └── types.ts # Simple type definitions
18
- ```
19
-
20
- ### After
21
- ```
22
- src/
23
- ├── domain/ # Pure business logic
24
- │ ├── entities/ # Rich domain models
25
- │ └── services/ # Business operations
26
- ├── infrastructure/ # External systems
27
- │ ├── gesture/ # Reusable gestures
28
- │ └── history/
29
- ├── application/ # Orchestration
30
- │ ├── stores/ # State management
31
- │ └── hooks/ # Clean hooks
32
- └── presentation/ # UI only
33
- └── components/
34
- ```
35
-
36
- ## API Changes
37
-
38
- ### Hooks
39
-
40
- **Old:**
41
- ```tsx
42
- import { usePhotoEditor } from "./hooks/usePhotoEditor";
43
- import { usePhotoEditorUI } from "./hooks/usePhotoEditorUI";
44
-
45
- const editor = usePhotoEditor([]);
46
- const ui = usePhotoEditorUI();
47
- ```
48
-
49
- **New:**
50
- ```tsx
51
- import { useEditor } from "./application/hooks/useEditor";
52
- import { useEditorUI } from "./application/hooks/useEditorUI";
53
-
54
- const editor = useEditor();
55
- const ui = useEditorUI();
56
- ```
57
-
58
- ### Components
59
-
60
- **Old:**
61
- ```tsx
62
- import DraggableText from "./components/DraggableText";
63
- import DraggableSticker from "./components/DraggableSticker";
64
- ```
65
-
66
- **New:**
67
- ```tsx
68
- import { DraggableLayer } from "./presentation/components/DraggableLayer";
69
- ```
70
-
71
- ### Types
72
-
73
- **Old:**
74
- ```tsx
75
- import type { Layer, TextLayer, ImageFilters } from "./types";
76
- ```
77
-
78
- **New:**
79
- ```tsx
80
- import type { Layer, TextLayer, FilterValues } from "./domain/entities/Layer";
81
- import { FiltersVO } from "./domain/entities/Filters";
82
- ```
83
-
84
- ## Benefits
85
-
86
- 1. **180 lines less code** - Removed duplication between DraggableText and DraggableSticker
87
- 2. **Clear separation** - Business logic separate from UI
88
- 3. **Testable** - Each layer can be tested independently
89
- 4. **Maintainable** - Files under 150 lines each
90
- 5. **Scalable** - Easy to add new features
91
-
92
- ## Backward Compatibility
93
-
94
- The old API is still exported. Your existing code will continue to work.
95
-
96
- To migrate gradually:
97
- 1. Start using `useEditor()` in new features
98
- 2. Replace `DraggableText` + `DraggableSticker` with `DraggableLayer`
99
- 3. Update imports to new paths
100
- 4. Remove old imports when ready