react-native-rectangle-doc-scanner 3.94.0 → 3.95.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;
|
|
@@ -329,14 +330,35 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
329
330
|
const handleFlashToggle = (0, react_1.useCallback)(() => {
|
|
330
331
|
setFlashEnabled(prev => !prev);
|
|
331
332
|
}, []);
|
|
332
|
-
const handleRotateImage = (0, react_1.useCallback)((degrees) => {
|
|
333
|
+
const handleRotateImage = (0, react_1.useCallback)(async (degrees) => {
|
|
333
334
|
if (!croppedImageData)
|
|
334
335
|
return;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
try {
|
|
337
|
+
// UI 회전 상태 먼저 업데이트 (즉각 반응)
|
|
338
|
+
setRotationDegrees(prev => {
|
|
339
|
+
const newRotation = (prev + degrees + 360) % 360;
|
|
340
|
+
return newRotation;
|
|
341
|
+
});
|
|
342
|
+
console.log('[FullDocScanner] Starting image rotation...');
|
|
343
|
+
// ImageRotate를 사용해서 실제로 이미지 회전 (UI 없이)
|
|
344
|
+
const rotatedImagePath = await react_native_image_rotate_1.default.rotateImage(croppedImageData.path, degrees);
|
|
345
|
+
console.log('[FullDocScanner] Image rotated successfully:', rotatedImagePath);
|
|
346
|
+
// 회전된 이미지로 교체
|
|
347
|
+
setCroppedImageData({
|
|
348
|
+
path: rotatedImagePath,
|
|
349
|
+
base64: undefined, // base64는 다시 읽어야 함
|
|
350
|
+
});
|
|
351
|
+
// rotation degrees는 0으로 리셋 (이미 실제 파일에 적용되었으므로)
|
|
352
|
+
setRotationDegrees(0);
|
|
353
|
+
}
|
|
354
|
+
catch (error) {
|
|
355
|
+
console.error('[FullDocScanner] Image rotation error:', error);
|
|
356
|
+
// 에러 발생 시 UI rotation 원복
|
|
357
|
+
setRotationDegrees(prev => {
|
|
358
|
+
const revertRotation = (prev - degrees + 360) % 360;
|
|
359
|
+
return revertRotation;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
340
362
|
}, [croppedImageData]);
|
|
341
363
|
const handleConfirm = (0, react_1.useCallback)(() => {
|
|
342
364
|
if (!croppedImageData)
|
|
@@ -344,9 +366,8 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
344
366
|
onResult({
|
|
345
367
|
path: croppedImageData.path,
|
|
346
368
|
base64: croppedImageData.base64,
|
|
347
|
-
rotation: rotationDegrees !== 0 ? rotationDegrees : undefined,
|
|
348
369
|
});
|
|
349
|
-
}, [croppedImageData,
|
|
370
|
+
}, [croppedImageData, onResult]);
|
|
350
371
|
const handleRetake = (0, react_1.useCallback)(() => {
|
|
351
372
|
console.log('[FullDocScanner] Retake - clearing cropped image and resetting scanner');
|
|
352
373
|
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.95.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 {
|
|
@@ -442,14 +441,42 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
442
441
|
setFlashEnabled(prev => !prev);
|
|
443
442
|
}, []);
|
|
444
443
|
|
|
445
|
-
const handleRotateImage = useCallback((degrees: -90 | 90) => {
|
|
444
|
+
const handleRotateImage = useCallback(async (degrees: -90 | 90) => {
|
|
446
445
|
if (!croppedImageData) return;
|
|
447
446
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
447
|
+
try {
|
|
448
|
+
// UI 회전 상태 먼저 업데이트 (즉각 반응)
|
|
449
|
+
setRotationDegrees(prev => {
|
|
450
|
+
const newRotation = (prev + degrees + 360) % 360;
|
|
451
|
+
return newRotation;
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
console.log('[FullDocScanner] Starting image rotation...');
|
|
455
|
+
|
|
456
|
+
// ImageRotate를 사용해서 실제로 이미지 회전 (UI 없이)
|
|
457
|
+
const rotatedImagePath = await ImageRotate.rotateImage(
|
|
458
|
+
croppedImageData.path,
|
|
459
|
+
degrees,
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
console.log('[FullDocScanner] Image rotated successfully:', rotatedImagePath);
|
|
463
|
+
|
|
464
|
+
// 회전된 이미지로 교체
|
|
465
|
+
setCroppedImageData({
|
|
466
|
+
path: rotatedImagePath,
|
|
467
|
+
base64: undefined, // base64는 다시 읽어야 함
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// rotation degrees는 0으로 리셋 (이미 실제 파일에 적용되었으므로)
|
|
471
|
+
setRotationDegrees(0);
|
|
472
|
+
} catch (error) {
|
|
473
|
+
console.error('[FullDocScanner] Image rotation error:', error);
|
|
474
|
+
// 에러 발생 시 UI rotation 원복
|
|
475
|
+
setRotationDegrees(prev => {
|
|
476
|
+
const revertRotation = (prev - degrees + 360) % 360;
|
|
477
|
+
return revertRotation;
|
|
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');
|