expo-barcode-scanner
Advanced tools
Comparing version 10.2.2 to 11.0.0
@@ -1,20 +0,59 @@ | ||
import { PermissionResponse, PermissionStatus } from 'expo-modules-core'; | ||
import { PermissionResponse, PermissionStatus, PermissionHookOptions } from 'expo-modules-core'; | ||
import * as React from 'react'; | ||
import { ViewProps } from 'react-native'; | ||
/** | ||
* Those coordinates are represented in the coordinate space of the barcode source (e.g. when you | ||
* are using the barcode scanner view, these values are adjusted to the dimensions of the view). | ||
*/ | ||
export declare type BarCodePoint = { | ||
/** | ||
* The `x` coordinate value. | ||
*/ | ||
x: number; | ||
/** | ||
* The `y` coordinate value. | ||
*/ | ||
y: number; | ||
}; | ||
export declare type BarCodeSize = { | ||
/** | ||
* The height value. | ||
*/ | ||
height: number; | ||
/** | ||
* The width value. | ||
*/ | ||
width: number; | ||
}; | ||
export declare type BarCodeBounds = { | ||
/** | ||
* The origin point of the bounding box. | ||
*/ | ||
origin: BarCodePoint; | ||
/** | ||
* The size of the bounding box. | ||
*/ | ||
size: BarCodeSize; | ||
}; | ||
/** | ||
* > __Note:__ `bounds` and `cornerPoints` are not always available. On iOS, for `code39` and `pdf417` | ||
* > you don't get those values. Moreover, on iOS, those values don't have to bounds the whole barcode. | ||
* > For some types, they will represent the area used by the scanner. | ||
*/ | ||
export declare type BarCodeScannerResult = { | ||
/** | ||
* The barcode type. | ||
*/ | ||
type: string; | ||
/** | ||
* The information encoded in the bar code. | ||
*/ | ||
data: string; | ||
/** | ||
* The [BarCodeBounds](#barcodebounds) object. | ||
*/ | ||
bounds?: BarCodeBounds; | ||
/** | ||
* Corner points of the bounding box. | ||
*/ | ||
cornerPoints?: BarCodePoint[]; | ||
@@ -29,8 +68,27 @@ }; | ||
export declare type BarCodeScannedCallback = (params: BarCodeEvent) => void; | ||
export { PermissionResponse, PermissionStatus }; | ||
export interface BarCodeScannerProps extends ViewProps { | ||
export declare type BarCodeScannerProps = ViewProps & { | ||
/** | ||
* Camera facing. Use one of `BarCodeScanner.Constants.Type`. Use either `Type.front` or `Type.back`. | ||
* Same as `Camera.Constants.Type`. | ||
* @default Type.back | ||
*/ | ||
type?: 'front' | 'back' | number; | ||
/** | ||
* An array of bar code types. Usage: `BarCodeScanner.Constants.BarCodeType.<codeType>` where | ||
* `codeType` is one of these [listed above](#supported-formats). Defaults to all supported bar | ||
* code types. It is recommended to provide only the bar code formats you expect to scan to | ||
* minimize battery usage. | ||
* | ||
* For example: `barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}`. | ||
*/ | ||
barCodeTypes?: string[]; | ||
/** | ||
* A callback that is invoked when a bar code has been successfully scanned. The callback is | ||
* provided with an [BarCodeScannerResult](#barcodescannerresult). | ||
* > __Note:__ Passing `undefined` to the `onBarCodeScanned` prop will result in no scanning. This | ||
* > can be used to effectively "pause" the scanner so that it doesn't continually scan even after | ||
* > data has been retrieved. | ||
*/ | ||
onBarCodeScanned?: BarCodeScannedCallback; | ||
} | ||
}; | ||
export declare class BarCodeScanner extends React.Component<BarCodeScannerProps> { | ||
@@ -54,12 +112,43 @@ lastEvents: { | ||
}; | ||
/** | ||
* Checks user's permissions for accessing the camera. | ||
* @return Return a promise that fulfills to an object of type [`PermissionResponse`](#permissionresponse). | ||
*/ | ||
static getPermissionsAsync(): Promise<PermissionResponse>; | ||
/** | ||
* Asks the user to grant permissions for accessing the camera. | ||
* | ||
* On iOS this will require apps to specify the `NSCameraUsageDescription` entry in the `Info.plist`. | ||
* @return Return a promise that fulfills to an object of type [`PermissionResponse`](#permissionresponse). | ||
*/ | ||
static requestPermissionsAsync(): Promise<PermissionResponse>; | ||
/** | ||
* Check or request permissions for the barcode scanner. | ||
* This uses both `requestPermissionAsync` and `getPermissionsAsync` to interact with the permissions. | ||
* | ||
* @example | ||
* ```ts | ||
* const [status, requestPermission] = BarCodeScanner.usePermissions(); | ||
* ``` | ||
*/ | ||
static usePermissions: (options?: PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>]; | ||
/** | ||
* Scan bar codes from the image given by the URL. | ||
* @param url URL to get the image from. | ||
* @param barCodeTypes An array of bar code types. Defaults to all supported bar code types on | ||
* the platform. | ||
* > __Note:__ Only QR codes are supported on iOS. | ||
* @return A possibly empty array of objects of the `BarCodeScannerResult` shape, where the type | ||
* refers to the bar code type that was scanned and the data is the information encoded in the bar | ||
* code. | ||
*/ | ||
static scanFromURLAsync(url: string, barCodeTypes?: string[]): Promise<BarCodeScannerResult[]>; | ||
render(): JSX.Element; | ||
onObjectDetected: (callback?: BarCodeScannedCallback | undefined) => ({ nativeEvent, }: BarCodeEventCallbackArguments) => void; | ||
onObjectDetected: (callback?: BarCodeScannedCallback | undefined) => ({ nativeEvent }: BarCodeEventCallbackArguments) => void; | ||
convertNativeProps(props: BarCodeScannerProps): BarCodeScannerProps; | ||
} | ||
export { PermissionResponse, PermissionStatus, PermissionHookOptions }; | ||
export declare const Constants: { | ||
BarCodeType: any; | ||
Type: any; | ||
}, getPermissionsAsync: typeof BarCodeScanner.getPermissionsAsync, requestPermissionsAsync: typeof BarCodeScanner.requestPermissionsAsync; | ||
}, getPermissionsAsync: typeof BarCodeScanner.getPermissionsAsync, requestPermissionsAsync: typeof BarCodeScanner.requestPermissionsAsync, usePermissions: (options?: PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>], scanFromURLAsync: typeof BarCodeScanner.scanFromURLAsync; |
@@ -1,3 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { PermissionStatus } from 'expo-modules-core'; | ||
import { PermissionStatus, createPermissionHook, UnavailabilityError, } from 'expo-modules-core'; | ||
import * as React from 'react'; | ||
@@ -9,29 +8,59 @@ import { Platform } from 'react-native'; | ||
const EVENT_THROTTLE_MS = 500; | ||
export { PermissionStatus }; | ||
export class BarCodeScanner extends React.Component { | ||
constructor() { | ||
super(...arguments); | ||
this.lastEvents = {}; | ||
this.lastEventsTimes = {}; | ||
this.onObjectDetected = (callback) => ({ nativeEvent, }) => { | ||
const { type } = nativeEvent; | ||
if (this.lastEvents[type] && | ||
this.lastEventsTimes[type] && | ||
JSON.stringify(nativeEvent) === this.lastEvents[type] && | ||
Date.now() - this.lastEventsTimes[type] < EVENT_THROTTLE_MS) { | ||
return; | ||
} | ||
if (callback) { | ||
callback(nativeEvent); | ||
this.lastEventsTimes[type] = new Date(); | ||
this.lastEvents[type] = JSON.stringify(nativeEvent); | ||
} | ||
}; | ||
} | ||
lastEvents = {}; | ||
lastEventsTimes = {}; | ||
static Constants = { | ||
BarCodeType, | ||
Type, | ||
}; | ||
static ConversionTables = { | ||
type: Type, | ||
}; | ||
static defaultProps = { | ||
type: Type.back, | ||
barCodeTypes: Object.values(BarCodeType), | ||
}; | ||
// @needsAudit | ||
/** | ||
* Checks user's permissions for accessing the camera. | ||
* @return Return a promise that fulfills to an object of type [`PermissionResponse`](#permissionresponse). | ||
*/ | ||
static async getPermissionsAsync() { | ||
return ExpoBarCodeScannerModule.getPermissionsAsync(); | ||
} | ||
// @needsAudit | ||
/** | ||
* Asks the user to grant permissions for accessing the camera. | ||
* | ||
* On iOS this will require apps to specify the `NSCameraUsageDescription` entry in the `Info.plist`. | ||
* @return Return a promise that fulfills to an object of type [`PermissionResponse`](#permissionresponse). | ||
*/ | ||
static async requestPermissionsAsync() { | ||
return ExpoBarCodeScannerModule.requestPermissionsAsync(); | ||
} | ||
// @needsAudit | ||
/** | ||
* Check or request permissions for the barcode scanner. | ||
* This uses both `requestPermissionAsync` and `getPermissionsAsync` to interact with the permissions. | ||
* | ||
* @example | ||
* ```ts | ||
* const [status, requestPermission] = BarCodeScanner.usePermissions(); | ||
* ``` | ||
*/ | ||
static usePermissions = createPermissionHook({ | ||
getMethod: BarCodeScanner.getPermissionsAsync, | ||
requestMethod: BarCodeScanner.requestPermissionsAsync, | ||
}); | ||
// @needsAudit | ||
/** | ||
* Scan bar codes from the image given by the URL. | ||
* @param url URL to get the image from. | ||
* @param barCodeTypes An array of bar code types. Defaults to all supported bar code types on | ||
* the platform. | ||
* > __Note:__ Only QR codes are supported on iOS. | ||
* @return A possibly empty array of objects of the `BarCodeScannerResult` shape, where the type | ||
* refers to the bar code type that was scanned and the data is the information encoded in the bar | ||
* code. | ||
*/ | ||
static async scanFromURLAsync(url, barCodeTypes = Object.values(BarCodeType)) { | ||
@@ -58,4 +87,18 @@ if (!ExpoBarCodeScannerModule.scanFromURLAsync) { | ||
const { onBarCodeScanned } = this.props; | ||
return (React.createElement(ExpoBarCodeScannerView, Object.assign({}, nativeProps, { onBarCodeScanned: this.onObjectDetected(onBarCodeScanned) }))); | ||
return (React.createElement(ExpoBarCodeScannerView, { ...nativeProps, onBarCodeScanned: this.onObjectDetected(onBarCodeScanned) })); | ||
} | ||
onObjectDetected = (callback) => ({ nativeEvent }) => { | ||
const { type } = nativeEvent; | ||
if (this.lastEvents[type] && | ||
this.lastEventsTimes[type] && | ||
JSON.stringify(nativeEvent) === this.lastEvents[type] && | ||
Date.now() - this.lastEventsTimes[type] < EVENT_THROTTLE_MS) { | ||
return; | ||
} | ||
if (callback) { | ||
callback(nativeEvent); | ||
this.lastEventsTimes[type] = new Date(); | ||
this.lastEvents[type] = JSON.stringify(nativeEvent); | ||
} | ||
}; | ||
convertNativeProps(props) { | ||
@@ -74,14 +117,4 @@ const nativeProps = {}; | ||
} | ||
BarCodeScanner.Constants = { | ||
BarCodeType, | ||
Type, | ||
}; | ||
BarCodeScanner.ConversionTables = { | ||
type: Type, | ||
}; | ||
BarCodeScanner.defaultProps = { | ||
type: Type.back, | ||
barCodeTypes: Object.values(BarCodeType), | ||
}; | ||
export const { Constants, getPermissionsAsync, requestPermissionsAsync } = BarCodeScanner; | ||
export { PermissionStatus }; | ||
export const { Constants, getPermissionsAsync, requestPermissionsAsync, usePermissions, scanFromURLAsync, } = BarCodeScanner; | ||
//# sourceMappingURL=BarCodeScanner.js.map |
@@ -1,2 +0,2 @@ | ||
declare const _default: import("@unimodules/core").ProxyNativeModule; | ||
declare const _default: import("expo-modules-core").ProxyNativeModule; | ||
export default _default; |
@@ -1,3 +0,3 @@ | ||
import { NativeModulesProxy } from '@unimodules/core'; | ||
import { NativeModulesProxy } from 'expo-modules-core'; | ||
export default NativeModulesProxy.ExpoBarCodeScannerModule; | ||
//# sourceMappingURL=ExpoBarCodeScannerModule.js.map |
@@ -1,3 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { PermissionStatus } from 'expo-modules-core'; | ||
import { PermissionStatus, UnavailabilityError } from 'expo-modules-core'; | ||
function getUserMedia(constraints) { | ||
@@ -4,0 +3,0 @@ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { |
@@ -1,2 +0,3 @@ | ||
declare const ExpoBarCodeScannerView: import("react").ComponentType<any>; | ||
import React from 'react'; | ||
declare const ExpoBarCodeScannerView: React.ComponentType<any>; | ||
export default ExpoBarCodeScannerView; |
@@ -1,4 +0,4 @@ | ||
import { requireNativeViewManager } from '@unimodules/core'; | ||
import { requireNativeViewManager } from 'expo-modules-core'; | ||
const ExpoBarCodeScannerView = requireNativeViewManager('ExpoBarCodeScannerView'); | ||
export default ExpoBarCodeScannerView; | ||
//# sourceMappingURL=ExpoBarCodeScannerView.js.map |
@@ -13,10 +13,22 @@ # Changelog | ||
## 10.2.2 — 2021-06-24 | ||
## 11.0.0 — 2021-09-28 | ||
_This version does not introduce any user-facing changes._ | ||
### 🛠 Breaking changes | ||
## 10.2.1 — 2021-06-22 | ||
- Dropped support for iOS 11.0 ([#14383](https://github.com/expo/expo/pull/14383) by [@cruzach](https://github.com/cruzach)) | ||
_This version does not introduce any user-facing changes._ | ||
### 🎉 New features | ||
- Add BarCodeScanner.usePermissions hook from modules factory. ([#13852](https://github.com/expo/expo/pull/13852) by [@bycedric](https://github.com/bycedric)) | ||
### 🐛 Bug fixes | ||
- Fix building errors from use_frameworks! in Podfile. ([#14523](https://github.com/expo/expo/pull/14523) by [@kudo](https://github.com/kudo)) | ||
### 💡 Others | ||
- Migrated from `@unimodules/core` to `expo-modules-core`. ([#13757](https://github.com/expo/expo/pull/13757) by [@tsapeta](https://github.com/tsapeta)) | ||
- Migrated Android codebase from Java to Kotlin. ([#13914](https://github.com/expo/expo/pull/13914) by [@m1st4ke](https://github.com/m1st4ke)) | ||
- Updated `@expo/config-plugins` ([#14443](https://github.com/expo/expo/pull/14443) by [@EvanBacon](https://github.com/EvanBacon)) | ||
## 10.2.0 — 2021-06-16 | ||
@@ -23,0 +35,0 @@ |
{ | ||
"name": "expo-barcode-scanner", | ||
"version": "10.2.2", | ||
"version": "11.0.0", | ||
"description": "Allows scanning variety of supported barcodes both as standalone module and as extension for expo-camera. It also allows scanning barcodes from existing images.", | ||
@@ -33,3 +33,3 @@ "main": "build/BarCodeScanner.js", | ||
"license": "MIT", | ||
"homepage": "https://docs.expo.io/versions/latest/sdk/bar-code-scanner/", | ||
"homepage": "https://docs.expo.dev/versions/latest/sdk/bar-code-scanner/", | ||
"jest": { | ||
@@ -39,4 +39,4 @@ "preset": "expo-module-scripts/ios" | ||
"dependencies": { | ||
"@expo/config-plugins": "^3.0.0", | ||
"expo-modules-core": "~0.2.0" | ||
"@expo/config-plugins": "^3.1.0", | ||
"expo-modules-core": "~0.4.0" | ||
}, | ||
@@ -46,3 +46,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "4fc9d282ff7ab2fa9040b775aeca7c30f5167b17" | ||
"gitHead": "1fffde73411ee7a642b98f1506a8de921805d52b" | ||
} |
@@ -1,3 +0,3 @@ | ||
import { NativeModulesProxy } from '@unimodules/core'; | ||
import { NativeModulesProxy } from 'expo-modules-core'; | ||
export default NativeModulesProxy.ExpoBarCodeScannerModule; |
@@ -1,3 +0,2 @@ | ||
import { UnavailabilityError } from '@unimodules/core'; | ||
import { PermissionResponse, PermissionStatus } from 'expo-modules-core'; | ||
import { PermissionResponse, PermissionStatus, UnavailabilityError } from 'expo-modules-core'; | ||
@@ -18,3 +17,3 @@ function getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream> { | ||
(navigator as any).mozGetUserMedia || | ||
function() { | ||
function () { | ||
const error: any = new Error('Permission unimplemented'); | ||
@@ -21,0 +20,0 @@ error.code = 0; |
@@ -1,5 +0,7 @@ | ||
import { requireNativeViewManager } from '@unimodules/core'; | ||
import { requireNativeViewManager } from 'expo-modules-core'; | ||
import React from 'react'; | ||
const ExpoBarCodeScannerView = requireNativeViewManager('ExpoBarCodeScannerView'); | ||
const ExpoBarCodeScannerView: React.ComponentType<any> = | ||
requireNativeViewManager('ExpoBarCodeScannerView'); | ||
export default ExpoBarCodeScannerView; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
945582
71
884
+ Addedcompare-versions@3.6.0(transitive)
+ Addedexpo-modules-core@0.4.10(transitive)
+ Addedinvariant@2.2.4(transitive)
+ Addedloose-envify@1.4.0(transitive)
- Removedexpo-modules-core@0.2.0(transitive)
Updated@expo/config-plugins@^3.1.0
Updatedexpo-modules-core@~0.4.0