@symbiote-native/camera 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +56 -2
- package/build/angular/camera-view/index.d.ts +43 -0
- package/build/angular/camera-view/index.js +101 -0
- package/build/angular/index.d.ts +3 -0
- package/build/angular/index.js +4 -0
- package/build/angular/services/camera-permissions.service.d.ts +8 -0
- package/build/angular/services/camera-permissions.service.js +82 -0
- package/build/core/android-barcode.d.ts +50 -0
- package/build/core/android-barcode.js +2 -0
- package/build/core/camera-api.d.ts +35 -0
- package/build/core/camera-api.js +68 -0
- package/build/core/camera-view-events.d.ts +3 -0
- package/build/core/camera-view-events.js +60 -0
- package/build/core/camera-view-handle.d.ts +26 -0
- package/build/core/camera-view-handle.js +40 -0
- package/build/core/camera-view.d.ts +12 -0
- package/build/core/camera-view.js +38 -0
- package/build/core/constants.d.ts +6 -0
- package/build/core/constants.js +7 -0
- package/build/core/index.d.ts +9 -0
- package/build/core/index.js +5 -0
- package/build/core/native-module.d.ts +28 -0
- package/build/core/native-module.js +3 -0
- package/build/core/picture-options.d.ts +9 -0
- package/build/core/picture-options.js +29 -0
- package/build/core/picture-ref.d.ts +2 -0
- package/build/core/picture-ref.js +3 -0
- package/build/core/props.d.ts +4 -0
- package/build/core/props.js +26 -0
- package/build/core/types.d.ts +170 -0
- package/build/core/types.js +1 -0
- package/build/react/camera-view.d.ts +8 -0
- package/build/react/camera-view.js +6 -0
- package/build/react/index.d.ts +5 -0
- package/build/react/index.js +4 -0
- package/build/react/use-camera-permissions.d.ts +9 -0
- package/build/react/use-camera-permissions.js +5 -0
- package/build/solid/camera-view.d.ts +33 -0
- package/build/solid/camera-view.js +4 -0
- package/build/solid/index.d.ts +4 -0
- package/build/solid/index.js +4 -0
- package/build/solid/use-camera-permissions.d.ts +10 -0
- package/build/solid/use-camera-permissions.js +5 -0
- package/build/svelte/camera-view.svelte +32 -0
- package/build/svelte/camera-view.svelte.d.ts +22 -0
- package/build/svelte/index.d.ts +4 -0
- package/build/svelte/index.js +4 -0
- package/build/svelte/use-camera-permissions.svelte.d.ts +9 -0
- package/build/svelte/use-camera-permissions.svelte.js +5 -0
- package/build/vue/camera-view.d.ts +2 -0
- package/build/vue/camera-view.js +4 -0
- package/build/vue/index.d.ts +4 -0
- package/build/vue/index.js +4 -0
- package/build/vue/use-camera-permissions.d.ts +10 -0
- package/build/vue/use-camera-permissions.js +5 -0
- package/build-ngc/angular/camera-view/index.d.ts +46 -0
- package/build-ngc/angular/camera-view/index.js +60 -0
- package/build-ngc/angular/camera-view/index.js.map +1 -0
- package/build-ngc/angular/index.d.ts +3 -0
- package/build-ngc/angular/index.js +5 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/angular/services/camera-permissions.service.d.ts +13 -0
- package/build-ngc/angular/services/camera-permissions.service.js +28 -0
- package/build-ngc/angular/services/camera-permissions.service.js.map +1 -0
- package/build-ngc/core/android-barcode.d.ts +50 -0
- package/build-ngc/core/android-barcode.js +3 -0
- package/build-ngc/core/android-barcode.js.map +1 -0
- package/build-ngc/core/camera-api.d.ts +35 -0
- package/build-ngc/core/camera-api.js +69 -0
- package/build-ngc/core/camera-api.js.map +1 -0
- package/build-ngc/core/camera-view-events.d.ts +3 -0
- package/build-ngc/core/camera-view-events.js +61 -0
- package/build-ngc/core/camera-view-events.js.map +1 -0
- package/build-ngc/core/camera-view-handle.d.ts +26 -0
- package/build-ngc/core/camera-view-handle.js +41 -0
- package/build-ngc/core/camera-view-handle.js.map +1 -0
- package/build-ngc/core/camera-view.d.ts +12 -0
- package/build-ngc/core/camera-view.js +39 -0
- package/build-ngc/core/camera-view.js.map +1 -0
- package/build-ngc/core/constants.d.ts +6 -0
- package/build-ngc/core/constants.js +8 -0
- package/build-ngc/core/constants.js.map +1 -0
- package/build-ngc/core/index.d.ts +9 -0
- package/build-ngc/core/index.js +6 -0
- package/build-ngc/core/index.js.map +1 -0
- package/build-ngc/core/native-module.d.ts +28 -0
- package/build-ngc/core/native-module.js +4 -0
- package/build-ngc/core/native-module.js.map +1 -0
- package/build-ngc/core/picture-options.d.ts +9 -0
- package/build-ngc/core/picture-options.js +30 -0
- package/build-ngc/core/picture-options.js.map +1 -0
- package/build-ngc/core/picture-ref.d.ts +2 -0
- package/build-ngc/core/picture-ref.js +4 -0
- package/build-ngc/core/picture-ref.js.map +1 -0
- package/build-ngc/core/props.d.ts +4 -0
- package/build-ngc/core/props.js +27 -0
- package/build-ngc/core/props.js.map +1 -0
- package/build-ngc/core/types.d.ts +170 -0
- package/build-ngc/core/types.js +2 -0
- package/build-ngc/core/types.js.map +1 -0
- package/native-link.json +22 -0
- package/package.json +144 -3
- package/src/angular/camera-view/index.ts +95 -0
- package/src/angular/index.ts +8 -0
- package/src/angular/services/camera-permissions.service.ts +28 -0
- package/src/core/android-barcode.ts +48 -0
- package/src/core/camera-api.ts +99 -0
- package/src/core/camera-view-events.ts +103 -0
- package/src/core/camera-view-handle.ts +93 -0
- package/src/core/camera-view.ts +56 -0
- package/src/core/constants.ts +11 -0
- package/src/core/index.ts +57 -0
- package/src/core/native-module.ts +57 -0
- package/src/core/picture-options.ts +46 -0
- package/src/core/picture-ref.ts +4 -0
- package/src/core/props.ts +31 -0
- package/src/core/types.ts +223 -0
- package/src/react/camera-view.ts +17 -0
- package/src/react/index.ts +7 -0
- package/src/react/use-camera-permissions.ts +21 -0
- package/src/solid/camera-view.ts +9 -0
- package/src/solid/index.ts +6 -0
- package/src/solid/use-camera-permissions.ts +22 -0
- package/src/svelte/camera-view.svelte +32 -0
- package/src/svelte/index.ts +9 -0
- package/src/svelte/svelte-ambient.d.ts +3 -0
- package/src/svelte/svelte-compile.test-helper.ts +6 -0
- package/src/svelte/use-camera-permissions.svelte.ts +21 -0
- package/src/vue/camera-view.ts +5 -0
- package/src/vue/index.ts +6 -0
- package/src/vue/use-camera-permissions.ts +22 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { EventSubscription, PermissionResponse, SharedRef } from 'expo-modules-core';
|
|
2
|
+
import type { ICameraBarcodeScanningResult, ICameraBarcodeType, ICameraPhotoResult, ICameraSavePictureOptions, ICameraScanningOptions, ICameraScanningResult, ICameraVideoCodec } from './types';
|
|
3
|
+
/** A reference to a native instance of an image, other Expo packages accept it as is */
|
|
4
|
+
export type ICameraPictureRef = SharedRef<'image'> & {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
/** Saves the image into the cache directory */
|
|
8
|
+
savePictureAsync(options?: ICameraSavePictureOptions): Promise<ICameraPhotoResult>;
|
|
9
|
+
};
|
|
10
|
+
export type ICameraPictureRefClass = abstract new (...args: never[]) => ICameraPictureRef;
|
|
11
|
+
export type ICameraNativeModule = {
|
|
12
|
+
Picture: ICameraPictureRefClass;
|
|
13
|
+
readonly isModernBarcodeScannerAvailable: boolean;
|
|
14
|
+
readonly toggleRecordingAsyncAvailable: boolean;
|
|
15
|
+
readonly Type: Record<string, string>;
|
|
16
|
+
readonly FlashMode: Record<string, string>;
|
|
17
|
+
isAvailableAsync?(): Promise<boolean>;
|
|
18
|
+
launchScanner(options?: ICameraScanningOptions): Promise<void>;
|
|
19
|
+
dismissScanner(): Promise<void>;
|
|
20
|
+
scanFromURLAsync(url: string, barcodeTypes?: ICameraBarcodeType[]): Promise<ICameraBarcodeScanningResult[]>;
|
|
21
|
+
getCameraPermissionsAsync(): Promise<PermissionResponse>;
|
|
22
|
+
requestCameraPermissionsAsync(): Promise<PermissionResponse>;
|
|
23
|
+
getMicrophonePermissionsAsync(): Promise<PermissionResponse>;
|
|
24
|
+
requestMicrophonePermissionsAsync(): Promise<PermissionResponse>;
|
|
25
|
+
getAvailableVideoCodecsAsync?(): Promise<ICameraVideoCodec[]>;
|
|
26
|
+
addListener(eventName: string, listener: (event: ICameraScanningResult) => void): EventSubscription;
|
|
27
|
+
};
|
|
28
|
+
export declare const expoCamera: ICameraNativeModule;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-module.js","sourceRoot":"","sources":["../../src/core/native-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAMxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAgDjD,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAC3C,kBAAkB,CACnB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ICameraCapturedPicture, ICameraPictureOptions, ICameraRecordingOptions } from './types';
|
|
2
|
+
export declare function ensurePictureOptions(options?: ICameraPictureOptions): ICameraPictureOptions;
|
|
3
|
+
export declare function ensureRecordingOptions(options?: ICameraRecordingOptions): ICameraRecordingOptions;
|
|
4
|
+
export declare function handlePictureSaved({ nativeEvent, }: {
|
|
5
|
+
nativeEvent: {
|
|
6
|
+
data: ICameraCapturedPicture;
|
|
7
|
+
id: number;
|
|
8
|
+
};
|
|
9
|
+
}): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const MIRROR_DEPRECATED = 'The `mirror` option is deprecated. Please use the `mirror` prop on the `CameraView` instead.';
|
|
2
|
+
// The callbacks wait here for the native event that carries their picture
|
|
3
|
+
const pictureSavedCallbacks = new Map();
|
|
4
|
+
let nextPictureId = 1;
|
|
5
|
+
export function ensurePictureOptions(options) {
|
|
6
|
+
if (!options || typeof options !== 'object')
|
|
7
|
+
return {};
|
|
8
|
+
if (options.mirror)
|
|
9
|
+
console.warn(MIRROR_DEPRECATED);
|
|
10
|
+
const { onPictureSaved, ...rest } = options;
|
|
11
|
+
const withQuality = { ...rest, quality: options.quality ?? 1 };
|
|
12
|
+
if (!onPictureSaved)
|
|
13
|
+
return withQuality;
|
|
14
|
+
const id = nextPictureId++;
|
|
15
|
+
pictureSavedCallbacks.set(id, onPictureSaved);
|
|
16
|
+
return { ...withQuality, id, fastMode: true };
|
|
17
|
+
}
|
|
18
|
+
export function ensureRecordingOptions(options = {}) {
|
|
19
|
+
if (options.mirror)
|
|
20
|
+
console.warn(MIRROR_DEPRECATED);
|
|
21
|
+
return options;
|
|
22
|
+
}
|
|
23
|
+
export function handlePictureSaved({ nativeEvent, }) {
|
|
24
|
+
const callback = pictureSavedCallbacks.get(nativeEvent.id);
|
|
25
|
+
if (!callback)
|
|
26
|
+
return;
|
|
27
|
+
pictureSavedCallbacks.delete(nativeEvent.id);
|
|
28
|
+
callback(nativeEvent.data);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=picture-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picture-options.js","sourceRoot":"","sources":["../../src/core/picture-options.ts"],"names":[],"mappings":"AAMA,MAAM,iBAAiB,GACrB,8FAA8F,CAAC;AAEjG,0EAA0E;AAC1E,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAGlC,CAAC;AACJ,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB,MAAM,UAAU,oBAAoB,CAClC,OAA+B;IAE/B,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IACvD,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACpD,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAC5C,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC;IAC/D,IAAI,CAAC,cAAc;QAAE,OAAO,WAAW,CAAC;IACxC,MAAM,EAAE,GAAG,aAAa,EAAE,CAAC;IAC3B,qBAAqB,CAAC,GAAG,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC9C,OAAO,EAAE,GAAG,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,UAAmC,EAAE;IAErC,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACpD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EACjC,WAAW,GAGZ;IACC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,qBAAqB,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC7C,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picture-ref.js","sourceRoot":"","sources":["../../src/core/picture-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,+FAA+F;AAC/F,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { expoCamera } from './native-module';
|
|
2
|
+
// Values under these keys become native options, the tables come from the native module
|
|
3
|
+
function conversionTableFor(key) {
|
|
4
|
+
if (key === 'type')
|
|
5
|
+
return expoCamera.Type;
|
|
6
|
+
if (key === 'flash')
|
|
7
|
+
return expoCamera.FlashMode;
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
function convertNativeProps(props) {
|
|
11
|
+
return Object.fromEntries(Object.entries(props).map(([key, value]) => {
|
|
12
|
+
const table = conversionTableFor(key);
|
|
13
|
+
return [key, typeof value === 'string' && table ? table[value] : value];
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
/** The props the native view takes, built from the friendly ones of the view */
|
|
17
|
+
export function ensureNativeProps(props) {
|
|
18
|
+
const { poster: _poster, ...native } = convertNativeProps(props);
|
|
19
|
+
return {
|
|
20
|
+
...native,
|
|
21
|
+
barcodeScannerEnabled: Boolean(Reflect.get(props, 'onBarcodeScanned')),
|
|
22
|
+
flashMode: Reflect.get(props, 'flash') ?? 'off',
|
|
23
|
+
mute: Reflect.get(props, 'mute') ?? false,
|
|
24
|
+
autoFocus: Reflect.get(props, 'autofocus') ?? 'off',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/core/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,wFAAwF;AACxF,SAAS,kBAAkB,CAAC,GAAW;IACrC,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAC3C,IAAI,GAAG,KAAK,OAAO;QAAE,OAAO,UAAU,CAAC,SAAS,CAAC;IACjD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa;IACvC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACzC,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,EAAE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1E,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO;QACL,GAAG,MAAM;QACT,qBAAqB,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;QACtE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,KAAK;QAC/C,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,KAAK;QACzC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,KAAK;KACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { IAccessibilityProps, IAriaProps, IResponderProps } from '@symbiote-native/components';
|
|
2
|
+
import type { IStyleProp, ISymbioteEvent, IViewStyle } from '@symbiote-native/engine';
|
|
3
|
+
import type { IAndroidBarcode } from './android-barcode';
|
|
4
|
+
export type ICameraType = 'front' | 'back';
|
|
5
|
+
/**
|
|
6
|
+
* `screen` uses the display as the flash of a front camera, on iOS it maps to `on`
|
|
7
|
+
* and Retina Flash fires
|
|
8
|
+
*/
|
|
9
|
+
export type ICameraFlashMode = 'off' | 'on' | 'auto' | 'screen';
|
|
10
|
+
/** `on` focuses once and locks, `off` focuses whenever needed */
|
|
11
|
+
export type ICameraFocusMode = 'on' | 'off';
|
|
12
|
+
export type ICameraMode = 'picture' | 'video';
|
|
13
|
+
export type ICameraRatio = '4:3' | '16:9' | '1:1';
|
|
14
|
+
/** The codec of a video recording, iOS only */
|
|
15
|
+
export type ICameraVideoCodec = 'avc1' | 'hvc1' | 'jpeg' | 'apcn' | 'ap4h';
|
|
16
|
+
/** On Android all but `off` turn the stabilization on, the device picks the method */
|
|
17
|
+
export type ICameraVideoStabilization = 'off' | 'standard' | 'cinematic' | 'auto';
|
|
18
|
+
export type ICameraVideoQuality = '2160p' | '1080p' | '720p' | '480p' | '4:3';
|
|
19
|
+
export type ICameraOrientation = 'portrait' | 'portraitUpsideDown' | 'landscapeLeft' | 'landscapeRight';
|
|
20
|
+
export type ICameraBarcodeType = 'aztec' | 'ean13' | 'ean8' | 'qr' | 'pdf417' | 'upc_e' | 'datamatrix' | 'code39' | 'code93' | 'itf14' | 'codabar' | 'code128' | 'upc_a';
|
|
21
|
+
export type ICameraCapturedPicture = {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
format: 'jpg' | 'png';
|
|
25
|
+
uri: string;
|
|
26
|
+
/** Base64 of the JPEG data, present when the `base64` option was set */
|
|
27
|
+
base64?: string;
|
|
28
|
+
/** The EXIF tags and their values, present when the `exif` option was set */
|
|
29
|
+
exif?: Record<string, unknown>;
|
|
30
|
+
};
|
|
31
|
+
export type ICameraPictureOptions = {
|
|
32
|
+
/** From `0` (small) to `1` (best), `1` by default */
|
|
33
|
+
quality?: number;
|
|
34
|
+
base64?: boolean;
|
|
35
|
+
exif?: boolean;
|
|
36
|
+
/** Extra EXIF data, takes effect with `exif` */
|
|
37
|
+
additionalExif?: Record<string, unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Called when the picture is saved, the promise then resolves at once with no data
|
|
40
|
+
* and the picture goes to this callback
|
|
41
|
+
*/
|
|
42
|
+
onPictureSaved?: (picture: ICameraCapturedPicture) => void;
|
|
43
|
+
/** Returns the image as it came from the sensor, `quality` is discarded */
|
|
44
|
+
skipProcessing?: boolean;
|
|
45
|
+
/** @deprecated Use the `mirror` prop of the view */
|
|
46
|
+
mirror?: boolean;
|
|
47
|
+
id?: number;
|
|
48
|
+
fastMode?: boolean;
|
|
49
|
+
maxDownsampling?: number;
|
|
50
|
+
/** `true` by default */
|
|
51
|
+
shutterSound?: boolean;
|
|
52
|
+
/** Resolves to a reference to the native image instead of a file */
|
|
53
|
+
pictureRef?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export type ICameraRecordingOptions = {
|
|
56
|
+
/** In seconds */
|
|
57
|
+
maxDuration?: number;
|
|
58
|
+
/** In bytes */
|
|
59
|
+
maxFileSize?: number;
|
|
60
|
+
/** @deprecated Use the `mirror` prop of the view */
|
|
61
|
+
mirror?: boolean;
|
|
62
|
+
/** iOS only */
|
|
63
|
+
codec?: ICameraVideoCodec;
|
|
64
|
+
};
|
|
65
|
+
export type ICameraAvailableLenses = {
|
|
66
|
+
lenses: string[];
|
|
67
|
+
};
|
|
68
|
+
export type ICameraResponsiveOrientation = {
|
|
69
|
+
orientation: ICameraOrientation;
|
|
70
|
+
};
|
|
71
|
+
export type ICameraMountError = {
|
|
72
|
+
message: string;
|
|
73
|
+
};
|
|
74
|
+
export type ICameraBarcodePoint = {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
export type ICameraBarcodeBounds = {
|
|
79
|
+
origin: ICameraBarcodePoint;
|
|
80
|
+
size: {
|
|
81
|
+
height: number;
|
|
82
|
+
width: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export type ICameraBarcodeScanningResult = {
|
|
86
|
+
type: string;
|
|
87
|
+
/** The parsed information encoded in the barcode */
|
|
88
|
+
data: string;
|
|
89
|
+
/** The raw information, Android only */
|
|
90
|
+
raw?: string;
|
|
91
|
+
/** The order of the points differs per platform, and is empty for some types */
|
|
92
|
+
cornerPoints: ICameraBarcodePoint[];
|
|
93
|
+
bounds: ICameraBarcodeBounds;
|
|
94
|
+
/** Extra information of the type of barcode, Android only */
|
|
95
|
+
extra?: IAndroidBarcode;
|
|
96
|
+
};
|
|
97
|
+
export type ICameraScanningResult = Omit<ICameraBarcodeScanningResult, 'bounds' | 'cornerPoints'>;
|
|
98
|
+
export type ICameraBarcodeSettings = {
|
|
99
|
+
barcodeTypes: ICameraBarcodeType[];
|
|
100
|
+
};
|
|
101
|
+
/** The options of the system scanner, iOS 16+ and Google's code scanner on Android */
|
|
102
|
+
export type ICameraScanningOptions = {
|
|
103
|
+
barcodeTypes: ICameraBarcodeType[];
|
|
104
|
+
/** iOS only, `true` by default */
|
|
105
|
+
isPinchToZoomEnabled?: boolean;
|
|
106
|
+
/** iOS only, `true` by default */
|
|
107
|
+
isGuidanceEnabled?: boolean;
|
|
108
|
+
/** iOS only, `false` by default */
|
|
109
|
+
isHighlightingEnabled?: boolean;
|
|
110
|
+
};
|
|
111
|
+
export type ICameraPhotoResult = {
|
|
112
|
+
uri: string;
|
|
113
|
+
width: number;
|
|
114
|
+
height: number;
|
|
115
|
+
base64?: string;
|
|
116
|
+
};
|
|
117
|
+
export type ICameraSavePictureOptions = {
|
|
118
|
+
quality?: number;
|
|
119
|
+
metadata?: Record<string, unknown>;
|
|
120
|
+
base64?: boolean;
|
|
121
|
+
};
|
|
122
|
+
export type ICameraViewProps = IAccessibilityProps & IAriaProps & IResponderProps & {
|
|
123
|
+
/** `back` by default */
|
|
124
|
+
facing?: ICameraType;
|
|
125
|
+
/** `off` by default */
|
|
126
|
+
flash?: ICameraFlashMode;
|
|
127
|
+
/** From `0` to `1`, a share of the maximum zoom of the device */
|
|
128
|
+
zoom?: number;
|
|
129
|
+
/** `picture` by default */
|
|
130
|
+
mode?: ICameraMode;
|
|
131
|
+
/** Records video with no sound */
|
|
132
|
+
mute?: boolean;
|
|
133
|
+
/** Mirrors the image of the front camera */
|
|
134
|
+
mirror?: boolean;
|
|
135
|
+
/** iOS only, `off` by default */
|
|
136
|
+
autofocus?: ICameraFocusMode;
|
|
137
|
+
/** Stops the session while `false`, iOS only, `true` by default */
|
|
138
|
+
active?: boolean;
|
|
139
|
+
videoQuality?: ICameraVideoQuality;
|
|
140
|
+
/** In bits per second, on iOS needs the codec in `recordAsync` */
|
|
141
|
+
videoBitrate?: number;
|
|
142
|
+
animateShutter?: boolean;
|
|
143
|
+
/** Makes `ratio` ignored, the sizes come from `getAvailablePictureSizesAsync` */
|
|
144
|
+
pictureSize?: string;
|
|
145
|
+
/** iOS only, `builtInWideAngleCamera` by default */
|
|
146
|
+
selectedLens?: string;
|
|
147
|
+
enableTorch?: boolean;
|
|
148
|
+
/** `auto` by default */
|
|
149
|
+
videoStabilizationMode?: ICameraVideoStabilization;
|
|
150
|
+
barcodeScannerSettings?: ICameraBarcodeSettings;
|
|
151
|
+
/** Takes landscape pictures of a portrait-locked app when the device turns, iOS only */
|
|
152
|
+
responsiveOrientationWhenOrientationLocked?: boolean;
|
|
153
|
+
/** Android only, switches the preview from fill to fit */
|
|
154
|
+
ratio?: ICameraRatio;
|
|
155
|
+
onCameraReady?: () => void;
|
|
156
|
+
onMountError?: (event: ICameraMountError) => void;
|
|
157
|
+
onBarcodeScanned?: (result: ICameraBarcodeScanningResult) => void;
|
|
158
|
+
/** iOS only */
|
|
159
|
+
onResponsiveOrientationChanged?: (event: ICameraResponsiveOrientation) => void;
|
|
160
|
+
/** iOS only */
|
|
161
|
+
onAvailableLensesChanged?: (event: ICameraAvailableLenses) => void;
|
|
162
|
+
style?: IStyleProp<IViewStyle>;
|
|
163
|
+
testID?: string;
|
|
164
|
+
nativeID?: string;
|
|
165
|
+
onLayout?: (event: ISymbioteEvent) => void;
|
|
166
|
+
};
|
|
167
|
+
export type ICameraSupportedFeatures = {
|
|
168
|
+
isModernBarcodeScannerAvailable: boolean;
|
|
169
|
+
toggleRecordingAsyncAvailable: boolean;
|
|
170
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
package/native-link.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"android": {
|
|
3
|
+
"gradleProjectName": "expo-camera",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"importPath": "expo.modules.camera.CameraViewModule",
|
|
7
|
+
"className": "CameraViewModule",
|
|
8
|
+
"nativeName": "ExpoCamera"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"manifestPermissions": [
|
|
12
|
+
"android.permission.CAMERA",
|
|
13
|
+
"android.permission.RECORD_AUDIO"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
"ios": {
|
|
17
|
+
"infoPlistKeys": {
|
|
18
|
+
"NSCameraUsageDescription": "Allow $(PRODUCT_NAME) to access your camera",
|
|
19
|
+
"NSMicrophoneUsageDescription": "Allow $(PRODUCT_NAME) to access your microphone"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,147 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbiote-native/camera",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "expo-camera wrapped for SymbioteNative — one framework-agnostic core, built once and reachable from the React, Vue, Svelte, Solid, and Angular adapters. The camera preview, pictures, video recording and barcode scanning.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/OneEyed1366/symbiote-native.git",
|
|
9
|
+
"directory": "packages/camera"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/OneEyed1366/symbiote-native/tree/master/packages/camera#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/OneEyed1366/symbiote-native/issues"
|
|
14
|
+
},
|
|
15
|
+
"author": "Andrey Prokopenko <psevdoproger@gmail.com>",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react-native",
|
|
18
|
+
"symbiote-native",
|
|
19
|
+
"expo-camera",
|
|
20
|
+
"react",
|
|
21
|
+
"vue",
|
|
22
|
+
"svelte",
|
|
23
|
+
"solid",
|
|
24
|
+
"angular",
|
|
25
|
+
"camera"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./build/core/index.js",
|
|
29
|
+
"module": "./build/core/index.js",
|
|
30
|
+
"types": "./build/core/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./build/core/index.d.ts",
|
|
34
|
+
"default": "./build/core/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./vue": {
|
|
37
|
+
"types": "./build/vue/index.d.ts",
|
|
38
|
+
"default": "./build/vue/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./react": {
|
|
41
|
+
"types": "./build/react/index.d.ts",
|
|
42
|
+
"default": "./build/react/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./svelte": "./src/svelte/index.ts",
|
|
45
|
+
"./solid": {
|
|
46
|
+
"types": "./build/solid/index.d.ts",
|
|
47
|
+
"default": "./build/solid/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./angular": {
|
|
50
|
+
"types": "./build-ngc/angular/index.d.ts",
|
|
51
|
+
"react-native": "./build-ngc/angular/index.js",
|
|
52
|
+
"default": "./src/angular/index.ts"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"src",
|
|
57
|
+
"build",
|
|
58
|
+
"build-ngc",
|
|
59
|
+
"native-link.json",
|
|
60
|
+
"!src/**/*.test.*",
|
|
61
|
+
"!src/**/*.spec.*",
|
|
62
|
+
"!src/**/*.detox.*"
|
|
63
|
+
],
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"expo-camera": "57.0.6",
|
|
69
|
+
"expo-modules-core": "57.0.20",
|
|
70
|
+
"@symbiote-native/components": "3.1.4"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@angular/core": ">=20",
|
|
74
|
+
"@vue/runtime-core": "^3.5.13",
|
|
75
|
+
"react": ">=19.0.0",
|
|
76
|
+
"react-native": ">=0.86",
|
|
77
|
+
"solid-js": ">=1.9.0",
|
|
78
|
+
"svelte": ">=5.56.0",
|
|
79
|
+
"vue": ">=3.5.0",
|
|
80
|
+
"@symbiote-native/angular": "^3.2.0",
|
|
81
|
+
"@symbiote-native/engine": "^1.5.0",
|
|
82
|
+
"@symbiote-native/react": "^3.2.0",
|
|
83
|
+
"@symbiote-native/svelte": "^3.1.0",
|
|
84
|
+
"@symbiote-native/solid": "^3.1.0",
|
|
85
|
+
"@symbiote-native/vue": "^3.2.0"
|
|
86
|
+
},
|
|
87
|
+
"peerDependenciesMeta": {
|
|
88
|
+
"@symbiote-native/angular": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"@symbiote-native/react": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
94
|
+
"@symbiote-native/solid": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
97
|
+
"@symbiote-native/svelte": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"@symbiote-native/vue": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"@angular/core": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
106
|
+
"@vue/runtime-core": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"react": {
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"solid-js": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
115
|
+
"svelte": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"vue": {
|
|
119
|
+
"optional": true
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"devDependencies": {
|
|
123
|
+
"@angular/compiler": "~22.0.8",
|
|
124
|
+
"@angular/compiler-cli": "~22.0.8",
|
|
125
|
+
"@angular/core": "~22.0.8",
|
|
126
|
+
"@types/node": "^26.0.0",
|
|
127
|
+
"@types/react": "^19.2.0",
|
|
128
|
+
"@vue/runtime-core": "^3.5.13",
|
|
129
|
+
"react": "19.2.3",
|
|
130
|
+
"solid-js": "^1.9.14",
|
|
131
|
+
"svelte": "^5.56.0",
|
|
132
|
+
"typescript": "~6.0.0",
|
|
133
|
+
"@symbiote-native/angular": "3.2.0",
|
|
134
|
+
"@symbiote-native/engine": "1.5.0",
|
|
135
|
+
"@symbiote-native/solid": "3.1.0",
|
|
136
|
+
"@symbiote-native/react": "3.2.0",
|
|
137
|
+
"@symbiote-native/vue": "3.2.0",
|
|
138
|
+
"@symbiote-native/test-utils": "0.4.6",
|
|
139
|
+
"@symbiote-native/svelte": "3.1.0"
|
|
140
|
+
},
|
|
141
|
+
"scripts": {
|
|
142
|
+
"typecheck": "tsc --build",
|
|
143
|
+
"clean": "rm -rf build-ngc",
|
|
144
|
+
"ng:build": "pnpm run clean && ngc -p tsconfig.angular.json",
|
|
145
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\""
|
|
146
|
+
}
|
|
6
147
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { DescriptorOutlet, NativeViewBase } from '@symbiote-native/angular';
|
|
3
|
+
import type { IDescriptor } from '@symbiote-native/components';
|
|
4
|
+
import { createCameraView } from '../../core';
|
|
5
|
+
import type { ICameraViewHandle, ICameraViewProps } from '../../core';
|
|
6
|
+
|
|
7
|
+
// One list is the inputs of the component and the props it hands to the native view
|
|
8
|
+
const CAMERA_VIEW_INPUTS = [
|
|
9
|
+
'facing',
|
|
10
|
+
'flash',
|
|
11
|
+
'zoom',
|
|
12
|
+
'mode',
|
|
13
|
+
'mute',
|
|
14
|
+
'mirror',
|
|
15
|
+
'autofocus',
|
|
16
|
+
'active',
|
|
17
|
+
'videoQuality',
|
|
18
|
+
'videoBitrate',
|
|
19
|
+
'animateShutter',
|
|
20
|
+
'pictureSize',
|
|
21
|
+
'selectedLens',
|
|
22
|
+
'enableTorch',
|
|
23
|
+
'videoStabilizationMode',
|
|
24
|
+
'barcodeScannerSettings',
|
|
25
|
+
'responsiveOrientationWhenOrientationLocked',
|
|
26
|
+
'ratio',
|
|
27
|
+
'onCameraReady',
|
|
28
|
+
'onMountError',
|
|
29
|
+
'onBarcodeScanned',
|
|
30
|
+
'onResponsiveOrientationChanged',
|
|
31
|
+
'onAvailableLensesChanged',
|
|
32
|
+
] as const;
|
|
33
|
+
|
|
34
|
+
/** Angular twin of `expo-camera`'s `CameraView` */
|
|
35
|
+
@Component({
|
|
36
|
+
selector: 'CameraView',
|
|
37
|
+
standalone: true,
|
|
38
|
+
imports: [DescriptorOutlet],
|
|
39
|
+
inputs: [...CAMERA_VIEW_INPUTS],
|
|
40
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
41
|
+
template: `@if (descriptor; as node) {
|
|
42
|
+
<symbiote-descriptor-outlet [node]="node" />
|
|
43
|
+
}`,
|
|
44
|
+
})
|
|
45
|
+
export class CameraView extends NativeViewBase {
|
|
46
|
+
// The inputs are named by `inputs`, these only type them for the template
|
|
47
|
+
declare facing?: ICameraViewProps['facing'];
|
|
48
|
+
declare flash?: ICameraViewProps['flash'];
|
|
49
|
+
declare zoom?: ICameraViewProps['zoom'];
|
|
50
|
+
declare mode?: ICameraViewProps['mode'];
|
|
51
|
+
declare mute?: ICameraViewProps['mute'];
|
|
52
|
+
declare mirror?: ICameraViewProps['mirror'];
|
|
53
|
+
declare autofocus?: ICameraViewProps['autofocus'];
|
|
54
|
+
declare active?: ICameraViewProps['active'];
|
|
55
|
+
declare videoQuality?: ICameraViewProps['videoQuality'];
|
|
56
|
+
declare videoBitrate?: ICameraViewProps['videoBitrate'];
|
|
57
|
+
declare animateShutter?: ICameraViewProps['animateShutter'];
|
|
58
|
+
declare pictureSize?: ICameraViewProps['pictureSize'];
|
|
59
|
+
declare selectedLens?: ICameraViewProps['selectedLens'];
|
|
60
|
+
declare enableTorch?: ICameraViewProps['enableTorch'];
|
|
61
|
+
declare videoStabilizationMode?: ICameraViewProps['videoStabilizationMode'];
|
|
62
|
+
declare barcodeScannerSettings?: ICameraViewProps['barcodeScannerSettings'];
|
|
63
|
+
declare responsiveOrientationWhenOrientationLocked?: ICameraViewProps['responsiveOrientationWhenOrientationLocked'];
|
|
64
|
+
declare ratio?: ICameraViewProps['ratio'];
|
|
65
|
+
declare onCameraReady?: ICameraViewProps['onCameraReady'];
|
|
66
|
+
declare onMountError?: ICameraViewProps['onMountError'];
|
|
67
|
+
declare onBarcodeScanned?: ICameraViewProps['onBarcodeScanned'];
|
|
68
|
+
declare onResponsiveOrientationChanged?: ICameraViewProps['onResponsiveOrientationChanged'];
|
|
69
|
+
declare onAvailableLensesChanged?: ICameraViewProps['onAvailableLensesChanged'];
|
|
70
|
+
|
|
71
|
+
private readonly view = createCameraView(() => this.hostNode());
|
|
72
|
+
|
|
73
|
+
// The functions of the view are copied onto the component, a `@ViewChild` reaches them
|
|
74
|
+
declare readonly takePictureAsync: ICameraViewHandle['takePictureAsync'];
|
|
75
|
+
declare readonly recordAsync: ICameraViewHandle['recordAsync'];
|
|
76
|
+
declare readonly toggleRecordingAsync: ICameraViewHandle['toggleRecordingAsync'];
|
|
77
|
+
declare readonly stopRecording: ICameraViewHandle['stopRecording'];
|
|
78
|
+
declare readonly pausePreview: ICameraViewHandle['pausePreview'];
|
|
79
|
+
declare readonly resumePreview: ICameraViewHandle['resumePreview'];
|
|
80
|
+
declare readonly getAvailablePictureSizesAsync: ICameraViewHandle['getAvailablePictureSizesAsync'];
|
|
81
|
+
declare readonly getAvailableLensesAsync: ICameraViewHandle['getAvailableLensesAsync'];
|
|
82
|
+
declare readonly getSupportedFeatures: ICameraViewHandle['getSupportedFeatures'];
|
|
83
|
+
declare readonly getHostNode: ICameraViewHandle['getHostNode'];
|
|
84
|
+
|
|
85
|
+
constructor() {
|
|
86
|
+
super();
|
|
87
|
+
Object.assign(this, this.view.handle);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
protected override readonly propNames = CAMERA_VIEW_INPUTS;
|
|
91
|
+
|
|
92
|
+
protected override renderView(props: object): IDescriptor | null {
|
|
93
|
+
return this.view.render(props);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @symbiote-native/camera/angular: камера, съёмка, запись видео и сканирование кодов на общем ядре
|
|
2
|
+
|
|
3
|
+
export { CameraView } from './camera-view';
|
|
4
|
+
export {
|
|
5
|
+
CameraPermissionsService,
|
|
6
|
+
MicrophonePermissionsService,
|
|
7
|
+
} from './services/camera-permissions.service';
|
|
8
|
+
export * from '../core';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { PermissionsServiceBase } from '@symbiote-native/angular';
|
|
3
|
+
import {
|
|
4
|
+
cameraPermissionMethods,
|
|
5
|
+
microphonePermissionMethods,
|
|
6
|
+
} from '../../core/camera-api';
|
|
7
|
+
import type { PermissionResponse } from 'expo-modules-core';
|
|
8
|
+
|
|
9
|
+
// Angular twin of `../../react`'s camera permission hooks
|
|
10
|
+
@Injectable({ providedIn: 'root' })
|
|
11
|
+
export class CameraPermissionsService extends PermissionsServiceBase<PermissionResponse> {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(
|
|
14
|
+
cameraPermissionMethods.getMethod,
|
|
15
|
+
cameraPermissionMethods.requestMethod,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Injectable({ providedIn: 'root' })
|
|
21
|
+
export class MicrophonePermissionsService extends PermissionsServiceBase<PermissionResponse> {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(
|
|
24
|
+
microphonePermissionMethods.getMethod,
|
|
25
|
+
microphonePermissionMethods.requestMethod,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|