panelui-native 0.110.0 → 0.112.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 (31) hide show
  1. package/lib/module/components/avatar-cropper/avatar-cropper-math.js +68 -28
  2. package/lib/module/components/avatar-cropper/avatar-cropper-math.js.map +1 -1
  3. package/lib/module/components/avatar-cropper/index.js +190 -24
  4. package/lib/module/components/avatar-cropper/index.js.map +1 -1
  5. package/lib/module/components/file-upload/file-upload-core.js +317 -0
  6. package/lib/module/components/file-upload/file-upload-core.js.map +1 -0
  7. package/lib/module/components/file-upload/index.js +1214 -0
  8. package/lib/module/components/file-upload/index.js.map +1 -0
  9. package/lib/module/icons/index.js +10 -0
  10. package/lib/module/icons/index.js.map +1 -1
  11. package/lib/module/index.js +2 -1
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/typescript/src/components/avatar-cropper/avatar-cropper-math.d.ts +32 -10
  14. package/lib/typescript/src/components/avatar-cropper/avatar-cropper-math.d.ts.map +1 -1
  15. package/lib/typescript/src/components/avatar-cropper/index.d.ts +30 -3
  16. package/lib/typescript/src/components/avatar-cropper/index.d.ts.map +1 -1
  17. package/lib/typescript/src/components/file-upload/file-upload-core.d.ts +136 -0
  18. package/lib/typescript/src/components/file-upload/file-upload-core.d.ts.map +1 -0
  19. package/lib/typescript/src/components/file-upload/index.d.ts +265 -0
  20. package/lib/typescript/src/components/file-upload/index.d.ts.map +1 -0
  21. package/lib/typescript/src/icons/index.d.ts +2 -0
  22. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  23. package/lib/typescript/src/index.d.ts +2 -1
  24. package/lib/typescript/src/index.d.ts.map +1 -1
  25. package/package.json +5 -1
  26. package/src/components/avatar-cropper/avatar-cropper-math.ts +78 -42
  27. package/src/components/avatar-cropper/index.tsx +251 -23
  28. package/src/components/file-upload/file-upload-core.ts +359 -0
  29. package/src/components/file-upload/index.tsx +1435 -0
  30. package/src/icons/index.tsx +4 -0
  31. package/src/index.ts +24 -0
@@ -6,8 +6,9 @@
6
6
  * The mask stays fixed in the middle of the canvas and the photo moves under
7
7
  * it, so everything here is one question asked different ways: where is the
8
8
  * mask, measured in the photo's own frame? Clamping asks it to keep the mask
9
- * on the photo, and the export asks it to find the same square in the photo's
10
- * pixels.
9
+ * on the photo — or, when the photo may be smaller than the mask, the photo
10
+ * inside the mask — and the export asks it to find the same square in the
11
+ * photo's pixels.
11
12
  *
12
13
  * The photo is drawn at a base size whose short side equals the mask, then
13
14
  * moved by `x`/`y`, turned by `rotation` and scaled by `scale` about its own
@@ -100,13 +101,26 @@ export function maskReach(shape, mask, rotation) {
100
101
  return half * (Math.abs(cos) + Math.abs(sin));
101
102
  }
102
103
 
103
- /** The smallest scale at which the photo still covers the whole mask. */
104
- export function minScale(shape, rotation) {
104
+ /**
105
+ * The limits a crop is held to.
106
+ *
107
+ * With `cover` on, the photo always fills the mask. With it off, the photo may
108
+ * also be smaller than the mask, down to `minZoom` — its long side as a
109
+ * fraction of the mask's — and a smaller photo is kept inside the mask rather
110
+ * than on it.
111
+ */
112
+
113
+ /** The smallest scale the photo may settle at. */
114
+ export function minScale(bounds, frame, rotation) {
105
115
  'worklet';
106
116
 
107
117
  // The base size's short side is the mask, so covering the reach on the
108
118
  // short side covers it on the long one too.
109
- return maskReach(shape, 2, rotation);
119
+ const covering = maskReach(bounds.shape, 2, rotation);
120
+ if (bounds.cover) return covering;
121
+ const longSide = Math.max(frame.image.width, frame.image.height);
122
+ if (longSide <= 0) return covering;
123
+ return Math.min(covering, bounds.minZoom * frame.mask / longSide);
110
124
  }
111
125
 
112
126
  /** Screen offset → the same offset along the photo's axes, and back. */
@@ -136,44 +150,66 @@ function fromImageAxes(u, v, rotation) {
136
150
  }
137
151
 
138
152
  /**
139
- * How far the photo can move along each of its own axes before the mask
140
- * reaches its edge. Zero when the photo is too small to move at all.
153
+ * How far the photo can move along each of its own axes.
154
+ *
155
+ * On an axis where the photo is larger than the mask's reach, the mask has to
156
+ * stay on the photo. On one where it is smaller — only possible with `cover`
157
+ * off — the photo has to stay inside the reach instead. Both are the gap
158
+ * between the two half-lengths, which is why one expression covers both.
141
159
  */
142
- function travel(state, shape, frame) {
160
+ function travel(state, bounds, frame) {
143
161
  'worklet';
144
162
 
145
- const reach = maskReach(shape, frame.mask, state.rotation);
146
- return {
147
- u: Math.max(0, state.scale * frame.image.width / 2 - reach),
148
- v: Math.max(0, state.scale * frame.image.height / 2 - reach)
163
+ const reach = maskReach(bounds.shape, frame.mask, state.rotation);
164
+ const u = state.scale * frame.image.width / 2 - reach;
165
+ const v = state.scale * frame.image.height / 2 - reach;
166
+ return bounds.cover ? {
167
+ u: Math.max(0, u),
168
+ v: Math.max(0, v)
169
+ } : {
170
+ u: Math.abs(u),
171
+ v: Math.abs(v)
149
172
  };
150
173
  }
151
174
 
152
- /** The nearest translation that keeps the mask on the photo. */
153
- export function clampTranslation(state, shape, frame) {
175
+ /** The nearest translation inside the bounds. */
176
+ export function clampTranslation(state, bounds, frame) {
154
177
  'worklet';
155
178
 
156
- const limit = travel(state, shape, frame);
179
+ const limit = travel(state, bounds, frame);
157
180
  const along = toImageAxes(state.x, state.y, state.rotation);
158
181
  return fromImageAxes(clamp(along.u, -limit.u, limit.u), clamp(along.v, -limit.v, limit.v), state.rotation);
159
182
  }
160
183
 
161
- /** The state a gesture settles into: in range, and covering the mask. */
162
- export function settle(state, shape, frame, maxZoom) {
184
+ /** The state a gesture settles into: in range, and inside the bounds. */
185
+ export function settle(state, bounds, frame) {
163
186
  'worklet';
164
187
 
165
- const lowest = minScale(shape, state.rotation);
166
- const scale = clamp(state.scale, lowest, Math.max(lowest, maxZoom));
188
+ const lowest = minScale(bounds, frame, state.rotation);
189
+ const scale = clamp(state.scale, lowest, Math.max(lowest, bounds.maxZoom));
167
190
  const next = {
168
191
  ...state,
169
192
  scale
170
193
  };
171
194
  return {
172
195
  ...next,
173
- ...clampTranslation(next, shape, frame)
196
+ ...clampTranslation(next, bounds, frame)
174
197
  };
175
198
  }
176
199
 
200
+ /**
201
+ * True when every point of the mask is on the photo — when a crop needs no
202
+ * background at all. Always true with `cover` on, once settled.
203
+ */
204
+ export function coversMask(state, shape, frame) {
205
+ 'worklet';
206
+
207
+ const reach = maskReach(shape, frame.mask, state.rotation);
208
+ const along = toImageAxes(state.x, state.y, state.rotation);
209
+ const slack = 0.5;
210
+ return Math.abs(along.u) <= state.scale * frame.image.width / 2 - reach + slack && Math.abs(along.v) <= state.scale * frame.image.height / 2 - reach + slack;
211
+ }
212
+
177
213
  /** An overshoot past a bound, compressed so it gives but never runs away. */
178
214
  export function rubberBand(overshoot, dimension) {
179
215
  'worklet';
@@ -189,18 +225,18 @@ export function rubberBand(overshoot, dimension) {
189
225
  * past a bound rubber-banded back towards it. At rest the raw state is already
190
226
  * settled and this returns it unchanged.
191
227
  */
192
- export function present(state, shape, frame, maxZoom) {
228
+ export function present(state, bounds, frame) {
193
229
  'worklet';
194
230
 
195
- const lowest = minScale(shape, state.rotation);
196
- const highest = Math.max(lowest, maxZoom);
231
+ const lowest = minScale(bounds, frame, state.rotation);
232
+ const highest = Math.max(lowest, bounds.maxZoom);
197
233
  let scale = state.scale;
198
234
  if (scale < lowest) scale = lowest - rubberBand(lowest - scale, lowest / 2);else if (scale > highest) scale = highest + rubberBand(scale - highest, highest / 2);
199
235
  const next = {
200
236
  ...state,
201
237
  scale
202
238
  };
203
- const limit = travel(next, shape, frame);
239
+ const limit = travel(next, bounds, frame);
204
240
  const along = toImageAxes(state.x, state.y, state.rotation);
205
241
  const u = clamp(along.u, -limit.u, limit.u);
206
242
  const v = clamp(along.v, -limit.v, limit.v);
@@ -264,7 +300,8 @@ export function nextQuarterTurn(rotation, direction) {
264
300
  * after the turn it lands at `−(x, y) / scale` — the rotation cancels, and the
265
301
  * crop is the mask's offset scaled into pixels.
266
302
  */
267
- export function sourceCrop(state, frame, source) {
303
+ export function sourceCrop(state, frame, source, /** Keep the rectangle on the turned image. Off, it can reach past the edges. */
304
+ onImage = true) {
268
305
  'worklet';
269
306
 
270
307
  const rotation = normalizeDegrees(state.rotation);
@@ -279,12 +316,15 @@ export function sourceCrop(state, frame, source) {
279
316
  };
280
317
  // Screen points per source pixel, at the current scale.
281
318
  const pointsPerPixel = frame.image.width / source.width * state.scale;
282
- const side = Math.max(1, Math.min(Math.floor(frame.mask / pointsPerPixel), canvas.width, canvas.height));
319
+ const full = Math.max(1, Math.floor(frame.mask / pointsPerPixel));
320
+ const side = onImage ? Math.max(1, Math.min(full, canvas.width, canvas.height)) : full;
283
321
  const centreX = canvas.width / 2 - state.x / pointsPerPixel;
284
322
  const centreY = canvas.height / 2 - state.y / pointsPerPixel;
323
+ const originX = Math.round(centreX - side / 2);
324
+ const originY = Math.round(centreY - side / 2);
285
325
  return {
286
- originX: clamp(Math.round(centreX - side / 2), 0, canvas.width - side),
287
- originY: clamp(Math.round(centreY - side / 2), 0, canvas.height - side),
326
+ originX: onImage ? clamp(originX, 0, canvas.width - side) : originX,
327
+ originY: onImage ? clamp(originY, 0, canvas.height - side) : originY,
288
328
  width: side,
289
329
  height: side,
290
330
  rotation,
@@ -1 +1 @@
1
- {"version":3,"names":["IDENTITY","x","y","scale","rotation","RUBBER_BAND","EPSILON","clamp","value","min","max","Math","trig","degrees","radians","PI","cos","sin","abs","normalizeDegrees","folded","baseSize","source","mask","shortSide","width","height","factor","maskReach","shape","half","minScale","toImageAxes","u","v","fromImageAxes","travel","state","frame","reach","image","clampTranslation","limit","along","settle","maxZoom","lowest","next","rubberBand","overshoot","dimension","sign","distance","present","highest","offset","zoomAbout","fx","fy","rotateAbout","ax","ay","dx","dy","nextQuarterTurn","direction","quarters","nearest","round","onQuarter","base","floor","ceil","sourceCrop","canvas","pointsPerPixel","side","centreX","centreY","originX","originY","SQUIRCLE_EXPONENT","SQUIRCLE_STEPS","maskPath","cx","cy","r","exponent","path","step","t","toFixed"],"sourceRoot":"../../../../src","sources":["components/avatar-cropper/avatar-cropper-math.ts"],"mappings":";;AAAA;AACA;AACA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"names":["IDENTITY","x","y","scale","rotation","RUBBER_BAND","EPSILON","clamp","value","min","max","Math","trig","degrees","radians","PI","cos","sin","abs","normalizeDegrees","folded","baseSize","source","mask","shortSide","width","height","factor","maskReach","shape","half","minScale","bounds","frame","covering","cover","longSide","image","minZoom","toImageAxes","u","v","fromImageAxes","travel","state","reach","clampTranslation","limit","along","settle","lowest","maxZoom","next","coversMask","slack","rubberBand","overshoot","dimension","sign","distance","present","highest","offset","zoomAbout","fx","fy","rotateAbout","ax","ay","dx","dy","nextQuarterTurn","direction","quarters","nearest","round","onQuarter","base","floor","ceil","sourceCrop","onImage","canvas","pointsPerPixel","full","side","centreX","centreY","originX","originY","SQUIRCLE_EXPONENT","SQUIRCLE_STEPS","maskPath","cx","cy","r","exponent","path","step","t","toFixed"],"sourceRoot":"../../../../src","sources":["components/avatar-cropper/avatar-cropper-math.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;;AAQA;;AAMA;;AAaA,OAAO,MAAMA,QAAmB,GAAG;EAAEC,CAAC,EAAE,CAAC;EAAEC,CAAC,EAAE,CAAC;EAAEC,KAAK,EAAE,CAAC;EAAEC,QAAQ,EAAE;AAAE,CAAC;;AAExE;AACA,MAAMC,WAAW,GAAG,IAAI;;AAExB;AACA,MAAMC,OAAO,GAAG,IAAI;AAEpB,OAAO,SAASC,KAAKA,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,EAAU;EACrE,SAAS;;EACT,OAAOC,IAAI,CAACF,GAAG,CAACE,IAAI,CAACD,GAAG,CAACF,KAAK,EAAEC,GAAG,CAAC,EAAEC,GAAG,CAAC;AAC5C;AAEA,SAASE,IAAIA,CAACC,OAAe,EAAgC;EAC3D,SAAS;;EACT,MAAMC,OAAO,GAAID,OAAO,GAAGF,IAAI,CAACI,EAAE,GAAI,GAAG;EACzC,IAAIC,GAAG,GAAGL,IAAI,CAACK,GAAG,C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,CAAC,UAAUF,EAAE,GAAGE,CAAC,IAAID,EAAE,IAAIC,CAAC,IAAIA,CAAC,UAAUF,EAAE,GAAGE,CAAC,IAAID,EAAE,GAAG;EAC5F;EACA,MAAME,QAAQ,GAAG,CAAC,GAAGN,iBAAiB;EACtC,IAAIO,IAAI,GAAG,EAAE;EACb,KAAK,IAAIC,IAAI,GAAG,CAAC,EAAEA,IAAI,GAAGP,cAAc,EAAEO,IAAI,IAAI,CAAC,EAAE;IACnD,MAAMC,CAAC,GAAID,IAAI,GAAGP,cAAc,GAAIhF,IAAI,CAACI,EAAE,GAAG,CAAC;IAC/C,MAAMC,GAAG,GAAGL,IAAI,CAACK,GAAG,CAACmF,CAAC,CAAC;IACvB,MAAMlF,GAAG,GAAGN,IAAI,CAACM,GAAG,CAACkF,CAAC,CAAC;IACvB,MAAMlG,CAAC,GAAG4F,EAAE,GAAGE,CAAC,GAAGpF,IAAI,CAAC+C,IAAI,CAAC1C,GAAG,CAAC,GAAGL,IAAI,CAACO,GAAG,CAACF,GAAG,CAAC,IAAIgF,QAAQ;IAC7D,MAAM9F,CAAC,GAAG4F,EAAE,GAAGC,CAAC,GAAGpF,IAAI,CAAC+C,IAAI,CAACzC,GAAG,CAAC,GAAGN,IAAI,CAACO,GAAG,CAACD,GAAG,CAAC,IAAI+E,QAAQ;IAC7DC,IAAI,IAAI,GAAGC,IAAI,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,GAAGjG,CAAC,CAACmG,OAAO,CAAC,CAAC,CAAC,IAAIlG,CAAC,CAACkG,OAAO,CAAC,CAAC,CAAC,EAAE;EACpE;EACA,OAAO,GAAGH,IAAI,GAAG;AACnB","ignoreList":[]}
@@ -45,7 +45,7 @@
45
45
  * turn and the cut both work on the raw pixels. `getCrop()` returns the same
46
46
  * rectangle without any dependency, for an app that crops on its server.
47
47
  */
48
- import { createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useState } from 'react';
48
+ import { createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
49
49
  import { Image, View } from 'react-native';
50
50
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
51
51
  import Animated, { cancelAnimation, runOnJS, useAnimatedStyle, useDerivedValue, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
@@ -54,7 +54,7 @@ import { useCSSVariable } from 'uniwind';
54
54
  import { RotateSquareIcon } from "../../icons/index.js";
55
55
  import { cn } from "../../utils/cn.js";
56
56
  import { Button } from "../button/index.js";
57
- import { IDENTITY, baseSize, maskPath, nextQuarterTurn, normalizeDegrees, present, rotateAbout, settle, sourceCrop, zoomAbout } from "./avatar-cropper-math.js";
57
+ import { IDENTITY, baseSize, coversMask, maskPath, nextQuarterTurn, normalizeDegrees, present, rotateAbout, settle, sourceCrop, zoomAbout } from "./avatar-cropper-math.js";
58
58
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
59
59
  /** Where the photo settles after a gesture. Firm, so it lands without drifting. */
60
60
  const SETTLE_SPRING = {
@@ -100,6 +100,17 @@ function loadPicker() {
100
100
  }
101
101
  }
102
102
 
103
+ /** `react-native-view-shot`'s capture function, or null when it is not installed. */
104
+ function loadCapture() {
105
+ try {
106
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
107
+ const mod = require('react-native-view-shot');
108
+ return mod?.captureRef ?? null;
109
+ } catch {
110
+ return null;
111
+ }
112
+ }
113
+
103
114
  /** True when `crop()` can write an image, because `expo-image-manipulator` is installed. */
104
115
  export const hasAvatarCropperExport = loadManipulator()?.ImageManipulator != null;
105
116
 
@@ -166,6 +177,9 @@ function AvatarCropperRoot({
166
177
  source,
167
178
  shape = 'circle',
168
179
  maxZoom = 5,
180
+ cover = true,
181
+ minZoom = 0.5,
182
+ background,
169
183
  inset = 24,
170
184
  className,
171
185
  children,
@@ -178,6 +192,15 @@ function AvatarCropperRoot({
178
192
  const [canvas, setCanvasState] = useState(null);
179
193
  const [measured, setMeasured] = useState(null);
180
194
  const [summary, setSummary] = useState(describe(IDENTITY));
195
+ const [stage, setStage] = useState(null);
196
+ const backgroundToken = useCSSVariable('--color-background');
197
+ const fill = background ?? (typeof backgroundToken === 'string' ? backgroundToken : '#ffffff');
198
+ const bounds = useMemo(() => ({
199
+ shape,
200
+ maxZoom,
201
+ cover,
202
+ minZoom
203
+ }), [shape, maxZoom, cover, minZoom]);
181
204
  const {
182
205
  uri,
183
206
  width,
@@ -231,7 +254,7 @@ function AvatarCropperRoot({
231
254
  /** Animate to a state, settled against the bounds first. */
232
255
  const animateTo = useCallback((target, timed) => {
233
256
  if (!frame) return;
234
- const next = settle(target, shape, frame, maxZoom);
257
+ const next = settle(target, bounds, frame);
235
258
  const run = value => timed ? withTiming(value, {
236
259
  duration: TURN_DURATION
237
260
  }) : withSpring(value, SETTLE_SPRING);
@@ -240,7 +263,7 @@ function AvatarCropperRoot({
240
263
  scale.value = run(next.scale);
241
264
  rotation.value = run(next.rotation);
242
265
  setSummary(describe(next));
243
- }, [frame, shape, maxZoom, x, y, scale, rotation]);
266
+ }, [frame, bounds, x, y, scale, rotation]);
244
267
  const settleNow = useCallback(() => animateTo(read(), false), [animateTo, read]);
245
268
  const rotate = useCallback((direction = 1) => {
246
269
  const current = read();
@@ -258,27 +281,59 @@ function AvatarCropperRoot({
258
281
  }, true);
259
282
  }, [animateTo, rotation]);
260
283
  const zoomBy = useCallback(factor => animateTo(zoomAbout(read(), factor, 0, 0), false), [animateTo, read]);
284
+ const settled = useCallback(() => frame ? settle(read(), bounds, frame) : null, [frame, bounds, read]);
261
285
  const getCrop = useCallback(() => {
262
- if (!frame || !sourceSize) return null;
263
- return sourceCrop(settle(read(), shape, frame, maxZoom), frame, sourceSize);
264
- }, [frame, sourceSize, read, shape, maxZoom]);
286
+ const state = settled();
287
+ if (!state || !frame || !sourceSize) return null;
288
+ return sourceCrop(state, frame, sourceSize, coversMask(state, shape, frame));
289
+ }, [settled, frame, sourceSize, shape]);
265
290
  useImperativeHandle(ref, () => ({
266
291
  getCrop,
267
292
  rotate,
268
293
  reset,
269
294
  async crop({
270
295
  size = 1024,
271
- format = 'jpeg',
296
+ format,
272
297
  compress = 0.9
273
298
  } = {}) {
299
+ const state = settled();
300
+ const rect = getCrop();
301
+ if (!state || !frame || !rect || !sourceSize) {
302
+ throw new Error('AvatarCropper.crop: the photo has not been measured and laid out yet.');
303
+ }
304
+ const transparent = fill === 'transparent';
305
+ const output = format ?? (transparent ? 'png' : 'jpeg');
306
+ const side = Math.min(size, rect.width);
307
+ if (!coversMask(state, shape, frame)) {
308
+ // Part of the outline is background, which the manipulator cannot
309
+ // paint on a phone. Draw the crop as the screen does, off to one
310
+ // side, and capture that instead.
311
+ const capture = loadCapture();
312
+ if (!capture) {
313
+ throw new Error('AvatarCropper.crop: a photo smaller than the outline is written with ' + 'react-native-view-shot. Install it with: npx expo install react-native-view-shot');
314
+ }
315
+ return new Promise((resolve, reject) => {
316
+ setStage({
317
+ state,
318
+ side,
319
+ format: output === 'jpeg' ? 'jpg' : 'png',
320
+ compress,
321
+ capture,
322
+ resolve: result => {
323
+ setStage(null);
324
+ resolve(result);
325
+ },
326
+ reject: error => {
327
+ setStage(null);
328
+ reject(error);
329
+ }
330
+ });
331
+ });
332
+ }
274
333
  const manipulator = loadManipulator()?.ImageManipulator;
275
334
  if (!manipulator) {
276
335
  throw new Error('AvatarCropper.crop needs expo-image-manipulator. Install it with: ' + 'npx expo install expo-image-manipulator — or use getCrop() to crop elsewhere.');
277
336
  }
278
- const rect = getCrop();
279
- if (!rect || !sourceSize) {
280
- throw new Error('AvatarCropper.crop: the photo has not been measured and laid out yet.');
281
- }
282
337
  // Redraw upright first. The turn and the cut both read raw pixels,
283
338
  // and a camera photo often keeps its orientation in a flag instead.
284
339
  const context = manipulator.manipulate(uri).resize({
@@ -291,20 +346,22 @@ function AvatarCropperRoot({
291
346
  width: rect.width,
292
347
  height: rect.height
293
348
  });
294
- if (size < rect.width) context.resize({
295
- width: size,
296
- height: size
349
+ if (side < rect.width) context.resize({
350
+ width: side,
351
+ height: side
297
352
  });
298
353
  const rendered = await context.renderAsync();
299
354
  return rendered.saveAsync({
300
- format,
355
+ format: output,
301
356
  compress
302
357
  });
303
358
  }
304
- }), [getCrop, rotate, reset, sourceSize, uri]);
359
+ }), [getCrop, settled, rotate, reset, sourceSize, uri, frame, shape, fill]);
305
360
  const value = {
306
361
  shape,
307
- maxZoom,
362
+ bounds,
363
+ fill,
364
+ stage,
308
365
  inset,
309
366
  source,
310
367
  sourceSize,
@@ -332,6 +389,95 @@ function AvatarCropperRoot({
332
389
  }
333
390
  const AvatarCropperForwarded = /*#__PURE__*/forwardRef(AvatarCropperRoot);
334
391
  AvatarCropperForwarded.displayName = 'AvatarCropper';
392
+ /**
393
+ * The crop drawn on its own, for capture: a square of the background with the
394
+ * photo placed in it exactly as the canvas places it under the outline.
395
+ *
396
+ * It sits directly under the outline, at the outline's size, beneath the
397
+ * canvas's own drawing of the same thing — so it is never seen, whatever
398
+ * surrounds the cropper. The capture reads the view's own drawing, not what is
399
+ * on screen above it, and scales it to the size asked for.
400
+ */
401
+ function ExportStage({
402
+ job,
403
+ frame,
404
+ uri,
405
+ fill,
406
+ left,
407
+ top
408
+ }) {
409
+ const ref = useRef(null);
410
+ const started = useRef(false);
411
+ const side = frame.mask;
412
+ const {
413
+ width,
414
+ height
415
+ } = frame.image;
416
+ const {
417
+ state
418
+ } = job;
419
+ const capture = () => {
420
+ if (started.current) return;
421
+ started.current = true;
422
+ job.capture(ref.current, {
423
+ format: job.format,
424
+ quality: job.compress,
425
+ result: 'tmpfile',
426
+ width: job.side,
427
+ height: job.side
428
+ }).then(uri => job.resolve({
429
+ uri,
430
+ width: job.side,
431
+ height: job.side
432
+ })).catch(job.reject);
433
+ };
434
+ return /*#__PURE__*/_jsx(View, {
435
+ ref: ref,
436
+ collapsable: false,
437
+ pointerEvents: "none",
438
+ importantForAccessibility: "no-hide-descendants",
439
+ accessibilityElementsHidden: true,
440
+ style: {
441
+ position: 'absolute',
442
+ left,
443
+ top,
444
+ width: side,
445
+ height: side,
446
+ overflow: 'hidden',
447
+ backgroundColor: fill
448
+ },
449
+ children: /*#__PURE__*/_jsx(View, {
450
+ style: {
451
+ position: 'absolute',
452
+ left: (side - width) / 2,
453
+ top: (side - height) / 2,
454
+ width,
455
+ height,
456
+ transform: [{
457
+ translateX: state.x
458
+ }, {
459
+ translateY: state.y
460
+ }, {
461
+ rotate: `${state.rotation}deg`
462
+ }, {
463
+ scale: state.scale
464
+ }]
465
+ },
466
+ children: /*#__PURE__*/_jsx(Image, {
467
+ source: {
468
+ uri
469
+ },
470
+ style: {
471
+ width,
472
+ height
473
+ },
474
+ resizeMode: "cover",
475
+ onLoad: () => requestAnimationFrame(capture),
476
+ onError: () => job.reject(new Error('AvatarCropper.crop: the photo failed to load.'))
477
+ })
478
+ })
479
+ });
480
+ }
335
481
 
336
482
  // ---------------------------------------------------------------------------
337
483
  // Canvas
@@ -350,7 +496,9 @@ function AvatarCropperCanvas({
350
496
  }) {
351
497
  const {
352
498
  shape,
353
- maxZoom,
499
+ bounds,
500
+ fill,
501
+ stage,
354
502
  source,
355
503
  frame,
356
504
  canvas,
@@ -386,7 +534,7 @@ function AvatarCropperCanvas({
386
534
  scale: scale.value,
387
535
  rotation: rotation.value
388
536
  };
389
- return frame ? present(raw, shape, frame, maxZoom) : raw;
537
+ return frame ? present(raw, bounds, frame) : raw;
390
538
  });
391
539
  const imageStyle = useAnimatedStyle(() => ({
392
540
  transform: [{
@@ -422,10 +570,11 @@ function AvatarCropperCanvas({
422
570
  'worklet';
423
571
 
424
572
  if (!frame) return state;
425
- const lowest = 1 / OVERSHOOT / 2;
573
+ // A guard against running away, not a bound: `present` does the bounding.
574
+ const lowest = 0.05;
426
575
  const next = {
427
576
  ...state,
428
- scale: Math.min(Math.max(state.scale, lowest), maxZoom * OVERSHOOT)
577
+ scale: Math.min(Math.max(state.scale, lowest), bounds.maxZoom * OVERSHOOT)
429
578
  };
430
579
  const limit = Math.max(image.width, image.height) * next.scale;
431
580
  next.x = Math.min(Math.max(next.x, -limit), limit);
@@ -496,7 +645,7 @@ function AvatarCropperCanvas({
496
645
  end();
497
646
  });
498
647
  return Gesture.Simultaneous(pan, pinch, turn);
499
- }, [active, x, y, scale, rotation, settleNow, frame, image.width, image.height, maxZoom, W, H]);
648
+ }, [active, x, y, scale, rotation, settleNow, frame, image.width, image.height, bounds, W, H]);
500
649
  const onAccessibilityAction = useCallback(event => {
501
650
  switch (event.nativeEvent.actionName) {
502
651
  case 'increment':
@@ -546,7 +695,24 @@ function AvatarCropperCanvas({
546
695
  }],
547
696
  onAccessibilityAction: onAccessibilityAction,
548
697
  ...props,
549
- children: [frame && W > 0 ? /*#__PURE__*/_jsx(Animated.View, {
698
+ children: [stage && frame && W > 0 ? /*#__PURE__*/_jsx(ExportStage, {
699
+ job: stage,
700
+ frame: frame,
701
+ uri: source.uri,
702
+ fill: fill,
703
+ left: (W - mask) / 2,
704
+ top: (H - mask) / 2
705
+ }) : null, !bounds.cover && frame && W > 0 && fill !== 'transparent' ? /*#__PURE__*/_jsx(View, {
706
+ pointerEvents: "none",
707
+ style: {
708
+ position: 'absolute',
709
+ left: (W - mask) / 2,
710
+ top: (H - mask) / 2,
711
+ width: mask,
712
+ height: mask,
713
+ backgroundColor: fill
714
+ }
715
+ }) : null, frame && W > 0 ? /*#__PURE__*/_jsx(Animated.View, {
550
716
  pointerEvents: "none",
551
717
  style: [{
552
718
  position: 'absolute',