@michaelyagi/kiri 0.1.0-alpha.6 → 0.1.0-alpha.7
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/README.md +97 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
> **AI-authored.** 100% of the code was written by Claude (Anthropic); I shaped the architecture, scope, and every decision, and did all the testing.
|
|
2
|
+
|
|
3
|
+
# Kiri
|
|
4
|
+
|
|
5
|
+
A dependency-free TypeScript library for interactive image cropping in the browser.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Drag, zoom, rotate, flip** — wheel/trackpad pinch zoom, an optional
|
|
10
|
+
built-in zoom slider (`showZoomer`, placeable on any of the four sides),
|
|
11
|
+
90° rotation, independent horizontal/vertical flip
|
|
12
|
+
- **Rectangle or circle frame** — circle is a real clip on export (transparent
|
|
13
|
+
corners on PNG/WebP), not just a visual overlay
|
|
14
|
+
- **Zero-CSS sizing** — the stage auto-sizes itself to the frame's dimensions
|
|
15
|
+
- **Filters** — brightness/contrast/saturation/grayscale/sepia, applied
|
|
16
|
+
identically to the live preview and the export
|
|
17
|
+
- **Automatic EXIF orientation correction** on load
|
|
18
|
+
- **Resizable frame**, four independent corner handles, with an optional
|
|
19
|
+
`lockAspectRatio` to keep a fixed ratio while resizing
|
|
20
|
+
- **`setOffset()`/`reset()`** for programmatic panning and reverting to the
|
|
21
|
+
post-`load()` state
|
|
22
|
+
- **`getCropRegion()`** — the crop mapped back to the original image's own
|
|
23
|
+
pixel coordinates, for server-side cropping of the full-resolution source
|
|
24
|
+
- **Keyboard-accessible** — the stage is focusable; arrow keys pan, `+`/`-`
|
|
25
|
+
zoom, `0` resets
|
|
26
|
+
- **Export** to base64, Blob, or Canvas — JPEG/PNG/WebP, custom output size
|
|
27
|
+
- **Upload** — a built-in FormData/fetch helper, or plug in your own
|
|
28
|
+
- **Batch cropping** — a documented recipe for stepping one shared cropper
|
|
29
|
+
through a queue of images, no separate class needed
|
|
30
|
+
- **React and Vue wrappers** (`kiri-react`, `kiri-vue`) — thin components, no
|
|
31
|
+
duplicated logic, reactive to prop changes after mount
|
|
32
|
+
- Runtime-validated options (a typo'd setting warns and falls back rather
|
|
33
|
+
than silently misbehaving), a clear error if the container element is
|
|
34
|
+
missing, and a real, CSP-safe stylesheet instead of injected styles
|
|
35
|
+
- Ships as ESM for bundlers and UMD/CJS for a plain `<script>` tag —
|
|
36
|
+
minified and unminified builds of both
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @michaelyagi/kiri
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
[npmjs.com/package/@michaelyagi/kiri](https://www.npmjs.com/package/@michaelyagi/kiri)
|
|
45
|
+
|
|
46
|
+
## Zero-config quickstart
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<link rel="stylesheet" href="node_modules/@michaelyagi/kiri/dist/kiri.min.css" />
|
|
50
|
+
<script src="node_modules/@michaelyagi/kiri/dist/kiri.min.js"></script>
|
|
51
|
+
<div id="cropper"></div>
|
|
52
|
+
<script>
|
|
53
|
+
const cropper = new Kiri(document.getElementById("cropper"), {
|
|
54
|
+
frame: { shape: "circle", width: 200, height: 200 },
|
|
55
|
+
});
|
|
56
|
+
await cropper.load("photo.jpg");
|
|
57
|
+
const blob = await cropper.export({ type: "blob" });
|
|
58
|
+
</script>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
No CSS sizing needed on the container — the stage auto-sizes itself to the
|
|
62
|
+
frame's dimensions. See [Getting started](https://michaelyagi.github.io/kiri/guides/getting-started.html)
|
|
63
|
+
for npm/ESM installation too.
|
|
64
|
+
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
**[michaelyagi.github.io/kiri](https://michaelyagi.github.io/kiri)** —
|
|
68
|
+
getting started, every method/event/setting, guides, real runnable examples,
|
|
69
|
+
an interactive playground, and the full API reference.
|
|
70
|
+
|
|
71
|
+
## Packages
|
|
72
|
+
|
|
73
|
+
| Package | Path | What it is |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| `@michaelyagi/kiri` | `packages/core` | The library itself — framework-agnostic |
|
|
76
|
+
| `kiri-react` | `packages/react` | `<KiriCropper>` React component (unpublished) |
|
|
77
|
+
| `kiri-vue` | `packages/vue` | `<KiriCropper>` Vue component (unpublished) |
|
|
78
|
+
|
|
79
|
+
## Status
|
|
80
|
+
|
|
81
|
+
**`0.1.0-alpha.7`** — see [CHANGELOG.md](./CHANGELOG.md)
|
|
82
|
+
for what's in it. Core publishes to npm automatically on version tags via
|
|
83
|
+
GitHub Actions; `kiri-react`/`kiri-vue` aren't published yet. The public API
|
|
84
|
+
is expected to be mostly stable but may still change before a `0.1.0`
|
|
85
|
+
(non-alpha) release.
|
|
86
|
+
|
|
87
|
+
## Development
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install # installs all workspace packages
|
|
91
|
+
npm run dev # core demo at http://localhost:5173
|
|
92
|
+
npm run build # builds all three packages
|
|
93
|
+
npm test # runs all three packages' test suites
|
|
94
|
+
npm run docs:build # rebuilds the docs/ site (library + API reference + asset sync)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
See [design.md](./design.md) for the full design document.
|
package/package.json
CHANGED