react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
494 lines • 17.7 kB
JavaScript
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
import { AnalyticsEvent } from './analytics/Analytics';
import { BarcodeScannerResult } from './barcode';
import { CheckScanningResult } from './check/CheckScannerTypes';
import { ScanbotBarcodeCameraView } from './components/barcode-camera-view/ScanbotBarcodeCameraView';
import { ScanbotCroppingView } from './components/cropping-view/ScanbotCroppingView';
import { ScanbotDocumentScannerView } from './components/document-scanner-view/ScanbotDocumentScannerView';
import { CreditCardScanningResult } from './credit_card/CreditCardTypes';
import { DocumentDataExtractionResult, DocumentVerificationReport } from './document_data_extractor';
import { DocumentData } from './document_scanner';
import { DocumentQualityAnalyzerResult } from './dqa/DocumentQualityAnalyzerTypes';
import { EuropeanHealthInsuranceCardRecognitionResult } from './ehic/EuropeanHealthInsuranceCardTypes';
import { MedicalCertificateScanningResult } from './medical_certificate/MedicalCertificateTypes';
import { MrzScannerResult } from './mrz/MrzTypes';
import { mapRTUUIResult } from './utils';
import { VinScannerResult } from './vin/VinScannerTypes';
const LINKING_ERROR = `The package 'react-native-scanbot-sdk' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
ios: "- You have run 'pod install'\n",
default: ''
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
const ScanbotSDKImpl = NativeModules.RNScanbotSDK ? NativeModules.RNScanbotSDK : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
const ScanbotSDKUIImpl = NativeModules.RNScanbotRTUUI ? NativeModules.RNScanbotRTUUI : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
const ScanbotDocument = {
/**
* Create a new document.
*/
createDocument(params) {
return ScanbotSDKImpl.createDocument(params).then(result => new DocumentData(result));
},
/**
* Create a new document from legacy pages.
*/
createDocumentFromLegacyPages(params) {
return ScanbotSDKImpl.createDocumentFromLegacyPages(params).then(result => new DocumentData(result));
},
/**
* Create a new document from a PDF file.
*/
createDocumentFromPDF(pdfUri) {
return ScanbotSDKImpl.createDocumentFromPDF(pdfUri).then(result => new DocumentData(result));
},
/**
* Check if a document with the given ID exists.
*/
documentExists(documentID) {
return ScanbotSDKImpl.documentExists(documentID);
},
/**
* Load a document by its ID.
*/
loadDocument(documentID) {
return ScanbotSDKImpl.loadDocument(documentID).then(result => new DocumentData(result));
},
/**
* Gets all stored document IDs.
*/
storedDocumentIDs() {
return ScanbotSDKImpl.storedDocumentIDs();
},
/**
* Clone a document by its ID.
*/
cloneDocument(documentID) {
return ScanbotSDKImpl.cloneDocument(documentID).then(result => new DocumentData(result));
},
/**
* Delete a document by its ID.
*/
deleteDocument(documentID) {
return ScanbotSDKImpl.deleteDocument(documentID);
},
/**
* Delete all documents.
*/
deleteAllDocuments() {
return ScanbotSDKImpl.deleteAllDocuments();
},
/**
* Creates a PDF for the given document.
* Please check the extra options that are part of the input params to modify the created PDF file per your needs.
*/
createPDF(params) {
return ScanbotSDKImpl.createPDFForDocument(params);
},
/**
* Creates a TIFF for the given document.
* Please check the extra options that are part of the input params to modify the created TIFF file per your needs.
*/
createTIFF(params) {
return ScanbotSDKImpl.createTIFFForDocument(params);
},
/**
* Add a new page to a document and return the updated document.
*/
addPage(params) {
return ScanbotSDKImpl.addPage(params).then(result => new DocumentData(result));
},
/**
* Move a page in a document and return the updated document.
*/
movePage(params) {
return ScanbotSDKImpl.movePage(params).then(result => new DocumentData(result));
},
/**
* Modify a page in a document and return the updated document.
*/
modifyPage(params) {
return ScanbotSDKImpl.modifyPage(params).then(result => new DocumentData(result));
},
/**
* Remove a page from a document.
*/
removePage(params) {
return ScanbotSDKImpl.removePageFromDocument(params).then(result => new DocumentData(result));
},
/**
* Remove all pages from a document in one batch operation.
*/
removeAllPages(documentID) {
return ScanbotSDKImpl.removeAllPages(documentID).then(result => new DocumentData(result));
}
};
const ScanbotSDKUI = {
/**
* Opens the Ready-To-Use UI Document Scanner screen with the desired configuration.
*
* @deprecated Use ***startDocumentScanner*** from ***'react-native-scanbot-sdk/ui_v2'*** instead.
*/
startDocumentScanner(configuration) {
return ScanbotSDKUIImpl.startDocumentScanner(configuration);
},
/**
* Forces the Ready-To-Use UI Document Scanner screen to close while it is running.
*
* @deprecated
*/
closeDocumentScanner() {
return ScanbotSDKUIImpl.closeDocumentScanner();
},
/**
* Opens the Ready-To-Use UI Finder Document Scanner screen with the desired configuration.
*
* @deprecated Use ***startDocumentScanner*** from ***'react-native-scanbot-sdk/ui_v2'*** instead.
*/
startFinderDocumentScanner(configuration) {
return ScanbotSDKUIImpl.startFinderDocumentScanner(configuration);
},
/**
* Forces the Ready-To-Use UI Finder Document Scanner screen to close while it is running.
*
* @deprecated
*/
closeFinderDocumentScanner() {
return ScanbotSDKUIImpl.closeFinderDocumentScanner();
},
/**
* Opens the Ready-To-Use UI Cropping screen with the desired configuration.
*
* @deprecated Use ***startCroppingScreen*** from ***'react-native-scanbot-sdk/ui_v2'*** instead.
*/
startCroppingScreen(page, configuration) {
return ScanbotSDKUIImpl.startCroppingScreen(page, configuration);
},
/**
* Forces the Ready-To-Use UI Cropping screen to close while it is running.
*
* @deprecated
*/
closeCroppingScreen() {
return ScanbotSDKUIImpl.closeCroppingScreen();
},
/**
* Opens the Ready-To-Use UI European Health Insurance Card Scanner screen with the desired configuration.
*
* @deprecated Use ***startDocumentDataExtractor*** instead and enable ***DE_HEALTH_INSURANCE_CARD_FRONT*** and ***EU_HEALTH_INSURANCE_CARD*** document formats.
*/
async startEHICScanner(configuration) {
return ScanbotSDKUIImpl.startEHICScanner(configuration).then(result => mapRTUUIResult(result, EuropeanHealthInsuranceCardRecognitionResult));
},
/**
* Forces the Ready-To-Use UI European Health Insurance Card Scanner screen to close while it is running.
*
* @deprecated
*/
closeEHICScanner() {
return ScanbotSDKUIImpl.closeEHICScanner();
},
/**
* Opens the Ready-To-Use UI Medical Certificate Scanner screen with the desired configuration.
*/
async startMedicalCertificateScanner(configuration) {
return ScanbotSDKUIImpl.startMedicalCertificateRecognizer(configuration).then(result => mapRTUUIResult(result, MedicalCertificateScanningResult));
},
/**
* Forces the Ready-To-Use UI Medical Certificate Scanner screen to close while it is running.
*/
closeMedicalCertificateScanner() {
return ScanbotSDKUIImpl.closeMedicalCertificateRecognizer();
},
/**
* Opens the Ready-To-Use UI Check Scanner screen with the desired configuration.
*
* @deprecated Use ***startCheckScanner*** from ***'react-native-scanbot-sdk/ui_v2'*** instead.
*/
async startCheckScanner(configuration) {
return ScanbotSDKUIImpl.startCheckRecognizer(configuration).then(result => mapRTUUIResult(result, CheckScanningResult));
},
/**
* Forces the Ready-To-Use UI Check Scanner screen to close while it is running.
*
* @deprecated
*/
closeCheckScanner() {
return ScanbotSDKUIImpl.closeCheckRecognizer();
},
/**
* Opens the Ready-To-Use UI VIN Scanner screen with the desired configuration.
*
* @deprecated Use ***startVINScanner*** from ***'react-native-scanbot-sdk/ui_v2'*** instead.
*/
async startVinScanner(configuration) {
return ScanbotSDKUIImpl.startVinScanner(configuration).then(result => mapRTUUIResult(result, VinScannerResult));
},
/**
* Forces the Ready-To-Use UI VIN Scanner screen to close while it is running.
*
* @deprecated
*/
closeVinScanner() {
return ScanbotSDKUIImpl.closeVinScanner();
}
};
const ScanbotSDK = {
UI: ScanbotSDKUI,
Document: ScanbotDocument,
/**
* Initializes the Scanbot SDK with the preferred configuration.
*/
initializeSDK(config) {
return ScanbotSDKImpl.initializeSDK(config);
},
/**
* Provides complete information about the current license status.
*/
getLicenseInfo() {
return ScanbotSDKImpl.getLicenseInfo();
},
/**
* Returns the available OCR configs.
*/
getOCRConfigs() {
return ScanbotSDKImpl.getOCRConfigs();
},
/**
* Removes all files generated by this plugin.
*/
cleanup() {
return ScanbotSDKImpl.cleanup();
},
/**
* Recreates the given pages to refresh the Image URIs.
*
* @deprecated Use {@link ScanbotSDK.Document} instead.
*/
refreshImageUris(params) {
return ScanbotSDKImpl.refreshImageUris(params);
},
/**
* Detects barcodes on the image represented by the file URI. The image file URI is part of the input arguments.
*/
async detectBarcodesOnImage(params) {
return ScanbotSDKImpl.detectBarcodesOnImage(params).then(result => new BarcodeScannerResult(result));
},
/**
* Applies the given filters to the given image, and returns its URI.
*/
applyImageFilters(imageFileUri, filters) {
return ScanbotSDKImpl.applyImageFilters(imageFileUri, filters);
},
/**
* Applies the given filters to the given page.
*
* @deprecated Use {@link ScanbotSDK.Document.modifyPage} instead.
*/
applyImageFiltersOnPage(page, filters) {
return ScanbotSDKImpl.applyImageFiltersOnPage(page, filters);
},
/**
* Creates a page with the image located at the given URI.
*
* @deprecated Use {@link ScanbotSDK.Document.createDocument} instead.
*/
createPage(imageUri) {
return ScanbotSDKImpl.createPage(imageUri);
},
/**
* Removes the given page from the storage.
*
* @deprecated Use {@link ScanbotSDK.Document.removePage} instead.
*/
removePage(page) {
return ScanbotSDKImpl.removePage(page);
},
/**
* Rotates the given page for the number of 90 degree counterclockwise rotations. Negative values will rotate clockwise.
*
* @deprecated Use {@link ScanbotSDK.Document.modifyPage} instead.
*/
rotatePage(page, times) {
return ScanbotSDKImpl.rotatePage(page, times);
},
/**
* Applies the given image to the desired page.
*
* @deprecated Use {@link ScanbotSDK.Document} instead.
*/
setDocumentImage(page, imageUri) {
return ScanbotSDKImpl.setDocumentImage(page, imageUri);
},
/**
* Detects a document on the given image and returns the result.
*/
detectDocument(imageFileUri) {
return ScanbotSDKImpl.detectDocument(imageFileUri);
},
/**
* Detects a document on the given page and returns the result.
*
* @deprecated Use {@link ScanbotSDK.Document} instead.
*/
detectDocumentOnPage(page) {
return ScanbotSDKImpl.detectDocumentOnPage(page);
},
/**
* Extracts images from a PDF represented by the file URL. The PDF file URL is part of the input arguments.
*/
extractImagesFromPdf(params) {
return ScanbotSDKImpl.extractImagesFromPdf(params);
},
/**
* Extracts images from a PDF represented by the file URL, creates pages from them and returns the created pages.
* The PDF file URL is part of the input arguments.
*
* @deprecated Use {@link ScanbotSDK.Document.createDocumentFromPDF} instead.
*/
extractPagesFromPdf(params) {
return ScanbotSDKImpl.extractPagesFromPdf(params);
},
/**
* Returns the BASE64 Image Data for the given image.
*/
getImageData(imageFileUri) {
return ScanbotSDKImpl.getImageData(imageFileUri);
},
/**
* Rotates the given image by the specified degrees counterclockwise. Negative values will rotate clockwise.
*/
rotateImage(imageFileUri, degrees) {
return ScanbotSDKImpl.rotateImage(imageFileUri, degrees);
},
/**
* Detects the quality of the document on a still image.
*/
async documentQualityAnalyzer(params) {
return ScanbotSDKImpl.documentQualityAnalyzer(params).then(result => new DocumentQualityAnalyzerResult(result));
},
/**
* Recognizes a Check on the given image.
*/
async recognizeCheck(params) {
return ScanbotSDKImpl.recognizeCheck(params).then(result => new CheckScanningResult(result));
},
/**
* Recognizes an MRZ on the given image.
*/
async recognizeMrz(params) {
return ScanbotSDKImpl.recognizeMrz(params).then(result => new MrzScannerResult(result));
},
/**
* Recognizes a Medical Certificate on the given image.
* Modify the result with extra options that are part of the input arguments.
*/
async recognizeMedicalCertificate(params) {
return ScanbotSDKImpl.recognizeMedicalCertificate(params).then(result => new MedicalCertificateScanningResult(result));
},
/**
* Recognizes a European Health Insurance Card (EHIC) on the given image.
*
* @deprecated Use {@link documentDataExtractor} instead and enable ***EuropeanHealthInsuranceCardConfiguration*** configuration element.
*/
async recognizeEHIC(params) {
return ScanbotSDKImpl.recognizeEHIC(params).then(result => new EuropeanHealthInsuranceCardRecognitionResult(result));
},
/**
* Recognizes a Credit Card on the given image.
* Modify the result with extra options that are part of the configuration.
*/
async recognizeCreditCard(params) {
return ScanbotSDKImpl.recognizeCreditCard(params).then(result => new CreditCardScanningResult(result));
},
/**
* Extract data on the given image.
* Set the expected document formats or leave it empty/undefined to recognize all supported document formats.
*/
async documentDataExtractor(params) {
return ScanbotSDKImpl.documentDataExtractor(params).then(result => new DocumentDataExtractionResult(result));
},
/**
* Performs OCR on given images. Set preferred ***ocrConfiguration*** engine, or leave it undefined to use the default one which is ***OCRScanbotEngineConfiguration***.
* If ***OCRTesseractConfiguration*** is used, the expected ***languages*** need to be set.
*/
performOCR(params) {
return ScanbotSDKImpl.performOCR(params);
},
/**
* Creates a PDF using the given list of image file URIs.
* Please check the extra options that are part of the input arguments to modify the created PDF file per your needs.
*/
createPDF(params) {
return ScanbotSDKImpl.createPDF(params);
},
/**
* Creates a TIFF using the given list of image file URIs.
* Please check the extra options that are part of the input arguments to modify the created TIFF file per your needs.
*/
writeTIFF(params) {
return ScanbotSDKImpl.writeTIFF(params);
},
/**
* Verifies the given document parts using the DocumentDataExtractorConfiguration.
*/
async verifyDocument(params) {
return ScanbotSDKImpl.verifyDocument(params).then(result => new DocumentVerificationReport(result));
},
/**
* Mock camera preview by using static images as a frame source.
* This is useful for testing purposes.
*/
mockCamera(params) {
return ScanbotSDKImpl.mockCamera(params);
},
/**
* Register analytics service callback to receive analytics events.
*/
setAnalyticsSubscriber(subscriber) {
const eventEmitter = new NativeEventEmitter(ScanbotSDKImpl);
if (subscriber === null) {
eventEmitter.removeAllListeners('analyticsEvent');
return ScanbotSDKImpl.removeAnalyticsServiceCallback();
} else {
eventEmitter.removeAllListeners('analyticsEvent');
eventEmitter.addListener('analyticsEvent', event => {
if (event) {
subscriber(new AnalyticsEvent(event));
}
});
return ScanbotSDKImpl.setAnalyticsServiceCallback();
}
}
};
export default ScanbotSDK;
export * from './barcode';
export * from './base';
export * from './check/CheckScannerTypes';
export * from './credit_card/CreditCardTypes';
export * from './document_data_extractor';
export * from './document_scanner';
export * from './documents';
export * from './dqa/DocumentQualityAnalyzerTypes';
export * from './ehic/EuropeanHealthInsuranceCardTypes';
export * from './frame_accumulation/FrameAccumulationTypes';
export * from './imageRef';
export * from './image_filters/ParametricFilters';
export * from './medical_certificate/MedicalCertificateTypes';
export * from './mrz/MrzTypes';
export * from './ocr_renderer/PdfConfigurationTypes';
export * from './text_pattern_scanner/TextPatternScannerTypes';
export * from './tiff_wrapper/TiffTypes';
export * from './utils';
export * from './vin/VinScannerTypes';
export * from './components/CameraViewTypes';
export * from './components/barcode-camera-view/ScanbotBarcodeCameraViewProperties';
export * from './components/cropping-view/ScanbotCroppingViewProperties';
export * from './components/document-scanner-view/ScanbotDocumentScannerViewProperties';
export { ScanbotBarcodeCameraView, ScanbotCroppingView, ScanbotDocumentScannerView };
//# sourceMappingURL=index.js.map