@retouchjs/core 0.0.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.
- package/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/index.cjs +1873 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +102 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +1870 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<br />
|
|
3
|
+
<img src=".github/retouch-logo-dark.svg" width="240" alt="Rétouch" />
|
|
4
|
+
<br />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h3 align="center">
|
|
8
|
+
A drop-in image editor that feels like part of your app.
|
|
9
|
+
</h3>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
Drop files, browse, click to edit — three states, one component.<br/>
|
|
13
|
+
Zero dependencies. Canvas-native. Framework-agnostic.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="#install">Install</a> ·
|
|
18
|
+
<a href="#quick-start">Quick Start</a> ·
|
|
19
|
+
<a href="#how-it-works">How It Works</a> ·
|
|
20
|
+
<a href="#api">API</a> ·
|
|
21
|
+
<a href="#tools">Tools</a> ·
|
|
22
|
+
<a href="#development">Development</a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<br />
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Why Rétouch?
|
|
30
|
+
|
|
31
|
+
Most image editors bolt onto your app like an afterthought. Rétouch was designed the other way around — to feel native from day one. No iframes, no external services, no heavy runtime. Just a canvas element that does exactly what your users expect.
|
|
32
|
+
|
|
33
|
+
- **Tiny footprint** — zero runtime dependencies, tree-shakeable
|
|
34
|
+
- **Three-state UX** — drop zone, gallery, editor — all handled for you
|
|
35
|
+
- **Canvas-native** — all processing happens on an HTML Canvas, no server round-trips
|
|
36
|
+
- **Framework-agnostic** — vanilla JS core with a React wrapper available
|
|
37
|
+
|
|
38
|
+
<br />
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install @retouchjs/core
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm add @retouchjs/core
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
yarn add @retouchjs/core
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<br />
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
### Vanilla JS
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { Retouch } from "@retouchjs/core";
|
|
62
|
+
|
|
63
|
+
const editor = new Retouch({
|
|
64
|
+
target: "#editor",
|
|
65
|
+
width: 800,
|
|
66
|
+
height: 600,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// When done:
|
|
70
|
+
editor.destroy();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### React
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { RetouchEditor } from "@@retouchjs/core/react";
|
|
77
|
+
|
|
78
|
+
function App() {
|
|
79
|
+
return (
|
|
80
|
+
<RetouchEditor
|
|
81
|
+
multiple
|
|
82
|
+
maxFiles={10}
|
|
83
|
+
accept="image/*"
|
|
84
|
+
tools={["crop", "adjust", "filters", "draw"]}
|
|
85
|
+
gallery="grid"
|
|
86
|
+
onDone={(files) => {
|
|
87
|
+
console.log("Edited files:", files);
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
<br />
|
|
95
|
+
|
|
96
|
+
## How It Works
|
|
97
|
+
|
|
98
|
+
Rétouch lives in **three states**. No complex routing, no page transitions — just one component that adapts.
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────┐
|
|
102
|
+
│ Drop Zone │ ───→ │ Gallery │ ───→ │ Editor │ ───→ │ Done │
|
|
103
|
+
│ │ │ │ │ │ │ │
|
|
104
|
+
│ Drag & drop │ │ Grid / List │ │ Crop, draw, │ │ Blob │
|
|
105
|
+
│ or browse │ │ view, manage│ │ adjust, etc │ │ File │
|
|
106
|
+
└─────────────┘ └─────────────┘ └─────────────┘ └──────┘
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 1. Drop Zone
|
|
110
|
+
|
|
111
|
+
The initial state. Accepts drag & drop, file browse, paste, and URLs. Minimal and inviting — transitions to the gallery the moment files land.
|
|
112
|
+
|
|
113
|
+
> PNG, JPG, WebP — up to 20 MB each
|
|
114
|
+
|
|
115
|
+
### 2. Gallery
|
|
116
|
+
|
|
117
|
+
Once images are loaded they appear in a responsive grid (or list). Each thumbnail reveals an edit button on hover. A green dot marks images that have already been edited. Add more files anytime.
|
|
118
|
+
|
|
119
|
+
### 3. Editor
|
|
120
|
+
|
|
121
|
+
Opens as a modal overlay with dark chrome to keep focus on the image. Tool sidebar on the left, properties panel on the right, canvas center stage. Everything from cropping to drawing to filters — all non-destructive until you hit **Done**.
|
|
122
|
+
|
|
123
|
+
<br />
|
|
124
|
+
|
|
125
|
+
## Tools
|
|
126
|
+
|
|
127
|
+
| Tool | Description |
|
|
128
|
+
|------|-------------|
|
|
129
|
+
| **Crop** | Free-form or fixed aspect ratio (16:9, 4:3, 1:1, 3:2, 9:16). Rule-of-thirds grid overlay. Rotation control. |
|
|
130
|
+
| **Adjust** | Brightness, contrast, saturation sliders with real-time preview. |
|
|
131
|
+
| **Filters** | Quick presets — Warm, Cool, B&W, and more. One-tap application with live thumbnails. |
|
|
132
|
+
| **Draw** | Freehand drawing and annotation directly on the canvas. |
|
|
133
|
+
| **Text** | Add and position text overlays with font and color controls. |
|
|
134
|
+
| **Sticker** | Place image overlays and shapes onto the canvas. |
|
|
135
|
+
|
|
136
|
+
<br />
|
|
137
|
+
|
|
138
|
+
## API
|
|
139
|
+
|
|
140
|
+
### `RetouchEditor` Props
|
|
141
|
+
|
|
142
|
+
| Prop | Type | Default | Description |
|
|
143
|
+
|------|------|---------|-------------|
|
|
144
|
+
| `target` | `string \| HTMLElement` | — | CSS selector or DOM element to mount into |
|
|
145
|
+
| `width` | `number` | `800` | Canvas width in pixels |
|
|
146
|
+
| `height` | `number` | `600` | Canvas height in pixels |
|
|
147
|
+
| `multiple` | `boolean` | `false` | Allow multiple image uploads |
|
|
148
|
+
| `maxFiles` | `number` | `10` | Maximum number of files when `multiple` is enabled |
|
|
149
|
+
| `accept` | `string` | `"image/*"` | Accepted file types |
|
|
150
|
+
| `aspectRatio` | `string` | `"free"` | Default crop aspect ratio |
|
|
151
|
+
| `tools` | `string[]` | All tools | Which editor tools to enable |
|
|
152
|
+
| `gallery` | `"grid" \| "list"` | `"grid"` | Default gallery view mode |
|
|
153
|
+
| `onDone` | `(files: Blob[]) => void` | — | Callback when editing is complete |
|
|
154
|
+
|
|
155
|
+
### Instance Methods
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const editor = new Retouch({ target: "#editor" });
|
|
159
|
+
|
|
160
|
+
editor.state; // "idle" | "mounted" | "destroyed"
|
|
161
|
+
editor.canvasElement; // The underlying HTMLCanvasElement
|
|
162
|
+
editor.render(); // Force a re-render
|
|
163
|
+
editor.destroy(); // Tear down and clean up (idempotent)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
<br />
|
|
167
|
+
|
|
168
|
+
## Development
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pnpm install # Install dependencies
|
|
172
|
+
pnpm dev # Start dev server with live demo
|
|
173
|
+
pnpm test # Run tests
|
|
174
|
+
pnpm test:watch # Run tests in watch mode
|
|
175
|
+
pnpm build # Build for production
|
|
176
|
+
pnpm check # Lint and format check
|
|
177
|
+
pnpm typecheck # Type check
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Project Structure
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
src/
|
|
184
|
+
├── index.ts # Public API exports
|
|
185
|
+
├── retouch.ts # Core Retouch class
|
|
186
|
+
├── types.ts # TypeScript interfaces
|
|
187
|
+
├── constants.ts # Defaults and version
|
|
188
|
+
└── utils/
|
|
189
|
+
└── canvas.ts # Canvas helper functions
|
|
190
|
+
tests/
|
|
191
|
+
└── retouch.test.ts # Test suite
|
|
192
|
+
demo/
|
|
193
|
+
├── index.html # Dev playground
|
|
194
|
+
└── main.ts # Demo entry point
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
<br />
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
[MIT](LICENSE) — use it however you want.
|