hive-react-kit 1.4.8 → 1.4.9

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.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Browser-only image-processing helpers used by the composer's image
3
+ * uploader. Two responsibilities:
4
+ *
5
+ * 1. Auto-downsize: scale a large image so its longest edge falls
6
+ * under `maxDimension` (default 2048px). Big phone photos —
7
+ * 4032×3024 from a modern phone, often 8+ MB — frequently break
8
+ * Ecency / Hive image uploads ("only half the photo arrives").
9
+ * Scaling on the client both fixes the upload and keeps feed
10
+ * pages fast.
11
+ *
12
+ * 2. Cropping: given a source image and a normalised crop rect
13
+ * (0..1 in both axes), render just that rectangle to a fresh
14
+ * canvas and return a new Blob.
15
+ *
16
+ * The helpers always re-encode through `<canvas>.toBlob`. Files that
17
+ * are already small (under `softSizeLimit` *and* within the dimension
18
+ * budget) skip processing entirely so a hand-prepared image isn't
19
+ * silently re-compressed.
20
+ */
21
+ export interface PrepareImageOptions {
22
+ /** Hard cap on the longest edge of the output image. */
23
+ maxDimension?: number;
24
+ /** JPEG quality when the source is re-encoded as JPEG (0..1). */
25
+ jpegQuality?: number;
26
+ /** Files smaller than this are returned untouched if they also fit
27
+ * within `maxDimension`. */
28
+ softSizeLimit?: number;
29
+ }
30
+ /**
31
+ * Downsize a file if its longest edge exceeds `maxDimension`. Files
32
+ * that are already small are returned as-is so we don't burn CPU on a
33
+ * thumbnail-sized image. Animated GIFs are passed through untouched
34
+ * since canvas re-encoding would freeze them on the first frame.
35
+ */
36
+ export declare function prepareImageForUpload(file: File, options?: PrepareImageOptions): Promise<File>;
37
+ export interface CropRect {
38
+ /** All values are 0..1 of the source image's natural dimensions. */
39
+ x: number;
40
+ y: number;
41
+ width: number;
42
+ height: number;
43
+ }
44
+ /**
45
+ * Crop `file` to the normalised `rect` and downsize the result the
46
+ * same way `prepareImageForUpload` does. The crop is applied at the
47
+ * source's native resolution, *then* the downsize step runs — so
48
+ * cropping a tiny region from a huge image still gives you a sharp
49
+ * output without blowing up file size.
50
+ */
51
+ export declare function cropImage(file: File, rect: CropRect, options?: PrepareImageOptions): Promise<File>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hive-react-kit",
3
3
  "private": false,
4
- "version": "1.4.8",
4
+ "version": "1.4.9",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.esm.js",