react-native-rectangle-doc-scanner 3.94.0 → 3.96.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.
package/dist/FullDocScanner.d.ts
CHANGED
|
@@ -8,8 +8,6 @@ export interface FullDocScannerResult {
|
|
|
8
8
|
base64?: string;
|
|
9
9
|
/** Original captured document info */
|
|
10
10
|
original?: CapturedDocument;
|
|
11
|
-
/** Rotation degrees (0, 90, 180, 270) */
|
|
12
|
-
rotation?: number;
|
|
13
11
|
}
|
|
14
12
|
export interface FullDocScannerStrings {
|
|
15
13
|
captureHint?: string;
|
package/dist/FullDocScanner.js
CHANGED
|
@@ -41,6 +41,7 @@ const react_1 = __importStar(require("react"));
|
|
|
41
41
|
const react_native_1 = require("react-native");
|
|
42
42
|
const react_native_image_picker_1 = require("react-native-image-picker");
|
|
43
43
|
const react_native_image_crop_picker_1 = __importDefault(require("react-native-image-crop-picker"));
|
|
44
|
+
const react_native_image_rotate_1 = __importDefault(require("react-native-image-rotate"));
|
|
44
45
|
const DocScanner_1 = require("./DocScanner");
|
|
45
46
|
const stripFileUri = (value) => value.replace(/^file:\/\//, '');
|
|
46
47
|
const CROPPER_TIMEOUT_MS = 8000;
|
|
@@ -332,11 +333,30 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
332
333
|
const handleRotateImage = (0, react_1.useCallback)((degrees) => {
|
|
333
334
|
if (!croppedImageData)
|
|
334
335
|
return;
|
|
335
|
-
// UI
|
|
336
|
+
// UI 회전 상태 먼저 업데이트 (즉각 반응)
|
|
336
337
|
setRotationDegrees(prev => {
|
|
337
338
|
const newRotation = (prev + degrees + 360) % 360;
|
|
338
339
|
return newRotation;
|
|
339
340
|
});
|
|
341
|
+
console.log('[FullDocScanner] Starting image rotation...');
|
|
342
|
+
// ImageRotate를 사용해서 실제로 이미지 회전 (callback 기반)
|
|
343
|
+
react_native_image_rotate_1.default.rotateImage(croppedImageData.path, degrees, (rotatedImagePath) => {
|
|
344
|
+
console.log('[FullDocScanner] Image rotated successfully:', rotatedImagePath);
|
|
345
|
+
// 회전된 이미지로 교체
|
|
346
|
+
setCroppedImageData({
|
|
347
|
+
path: rotatedImagePath,
|
|
348
|
+
base64: undefined, // base64는 다시 읽어야 함
|
|
349
|
+
});
|
|
350
|
+
// rotation degrees는 0으로 리셋 (이미 실제 파일에 적용되었으므로)
|
|
351
|
+
setRotationDegrees(0);
|
|
352
|
+
}, (error) => {
|
|
353
|
+
console.error('[FullDocScanner] Image rotation error:', error);
|
|
354
|
+
// 에러 발생 시 UI rotation 원복
|
|
355
|
+
setRotationDegrees(prev => {
|
|
356
|
+
const revertRotation = (prev - degrees + 360) % 360;
|
|
357
|
+
return revertRotation;
|
|
358
|
+
});
|
|
359
|
+
});
|
|
340
360
|
}, [croppedImageData]);
|
|
341
361
|
const handleConfirm = (0, react_1.useCallback)(() => {
|
|
342
362
|
if (!croppedImageData)
|
|
@@ -344,9 +364,8 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
344
364
|
onResult({
|
|
345
365
|
path: croppedImageData.path,
|
|
346
366
|
base64: croppedImageData.base64,
|
|
347
|
-
rotation: rotationDegrees !== 0 ? rotationDegrees : undefined,
|
|
348
367
|
});
|
|
349
|
-
}, [croppedImageData,
|
|
368
|
+
}, [croppedImageData, onResult]);
|
|
350
369
|
const handleRetake = (0, react_1.useCallback)(() => {
|
|
351
370
|
console.log('[FullDocScanner] Retake - clearing cropped image and resetting scanner');
|
|
352
371
|
setCroppedImageData(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-rectangle-doc-scanner",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.96.0",
|
|
4
4
|
"description": "Native-backed document scanner for React Native with customizable overlays.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,15 +33,19 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "*",
|
|
35
35
|
"react-native": "*",
|
|
36
|
-
"react-native-image-picker": "*",
|
|
37
36
|
"react-native-image-crop-picker": "*",
|
|
37
|
+
"react-native-image-picker": "*",
|
|
38
|
+
"react-native-image-rotate": "*",
|
|
38
39
|
"react-native-svg": "*"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@types/react": "^18.2.41",
|
|
42
43
|
"@types/react-native": "0.73.0",
|
|
43
|
-
"react-native-image-picker": "^7.1.2",
|
|
44
44
|
"react-native-image-crop-picker": "^0.41.2",
|
|
45
|
+
"react-native-image-picker": "^7.1.2",
|
|
45
46
|
"typescript": "^5.3.3"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"react-native-image-rotate": "^2.1.0"
|
|
46
50
|
}
|
|
47
51
|
}
|
package/src/FullDocScanner.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from 'react-native';
|
|
12
12
|
import { launchImageLibrary } from 'react-native-image-picker';
|
|
13
13
|
import ImageCropPicker from 'react-native-image-crop-picker';
|
|
14
|
+
import ImageRotate from 'react-native-image-rotate';
|
|
14
15
|
import { DocScanner } from './DocScanner';
|
|
15
16
|
import type { CapturedDocument } from './types';
|
|
16
17
|
import type {
|
|
@@ -102,8 +103,6 @@ export interface FullDocScannerResult {
|
|
|
102
103
|
base64?: string;
|
|
103
104
|
/** Original captured document info */
|
|
104
105
|
original?: CapturedDocument;
|
|
105
|
-
/** Rotation degrees (0, 90, 180, 270) */
|
|
106
|
-
rotation?: number;
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
export interface FullDocScannerStrings {
|
|
@@ -445,11 +444,39 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
445
444
|
const handleRotateImage = useCallback((degrees: -90 | 90) => {
|
|
446
445
|
if (!croppedImageData) return;
|
|
447
446
|
|
|
448
|
-
// UI
|
|
447
|
+
// UI 회전 상태 먼저 업데이트 (즉각 반응)
|
|
449
448
|
setRotationDegrees(prev => {
|
|
450
449
|
const newRotation = (prev + degrees + 360) % 360;
|
|
451
450
|
return newRotation;
|
|
452
451
|
});
|
|
452
|
+
|
|
453
|
+
console.log('[FullDocScanner] Starting image rotation...');
|
|
454
|
+
|
|
455
|
+
// ImageRotate를 사용해서 실제로 이미지 회전 (callback 기반)
|
|
456
|
+
ImageRotate.rotateImage(
|
|
457
|
+
croppedImageData.path,
|
|
458
|
+
degrees,
|
|
459
|
+
(rotatedImagePath: string) => {
|
|
460
|
+
console.log('[FullDocScanner] Image rotated successfully:', rotatedImagePath);
|
|
461
|
+
|
|
462
|
+
// 회전된 이미지로 교체
|
|
463
|
+
setCroppedImageData({
|
|
464
|
+
path: rotatedImagePath,
|
|
465
|
+
base64: undefined, // base64는 다시 읽어야 함
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
// rotation degrees는 0으로 리셋 (이미 실제 파일에 적용되었으므로)
|
|
469
|
+
setRotationDegrees(0);
|
|
470
|
+
},
|
|
471
|
+
(error: Error) => {
|
|
472
|
+
console.error('[FullDocScanner] Image rotation error:', error);
|
|
473
|
+
// 에러 발생 시 UI rotation 원복
|
|
474
|
+
setRotationDegrees(prev => {
|
|
475
|
+
const revertRotation = (prev - degrees + 360) % 360;
|
|
476
|
+
return revertRotation;
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
);
|
|
453
480
|
}, [croppedImageData]);
|
|
454
481
|
|
|
455
482
|
const handleConfirm = useCallback(() => {
|
|
@@ -458,9 +485,8 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
458
485
|
onResult({
|
|
459
486
|
path: croppedImageData.path,
|
|
460
487
|
base64: croppedImageData.base64,
|
|
461
|
-
rotation: rotationDegrees !== 0 ? rotationDegrees : undefined,
|
|
462
488
|
});
|
|
463
|
-
}, [croppedImageData,
|
|
489
|
+
}, [croppedImageData, onResult]);
|
|
464
490
|
|
|
465
491
|
const handleRetake = useCallback(() => {
|
|
466
492
|
console.log('[FullDocScanner] Retake - clearing cropped image and resetting scanner');
|