fix: Fix circular dependency in FrameProcessorPlugins.ts
shoutout @bglgwyng
This commit is contained in:
parent
4b009a0053
commit
c88605e230
@ -4,7 +4,6 @@ import type { CameraDevice } from './CameraDevice';
|
|||||||
import type { ErrorWithCause } from './CameraError';
|
import type { ErrorWithCause } from './CameraError';
|
||||||
import { CameraCaptureError, CameraRuntimeError, tryParseNativeCameraError, isErrorWithCause } from './CameraError';
|
import { CameraCaptureError, CameraRuntimeError, tryParseNativeCameraError, isErrorWithCause } from './CameraError';
|
||||||
import type { CameraProps, FrameProcessor } from './CameraProps';
|
import type { CameraProps, FrameProcessor } from './CameraProps';
|
||||||
import { assertJSIAvailable } from './JSIHelper';
|
|
||||||
import { CameraModule } from './NativeCameraModule';
|
import { CameraModule } from './NativeCameraModule';
|
||||||
import type { PhotoFile, TakePhotoOptions } from './PhotoFile';
|
import type { PhotoFile, TakePhotoOptions } from './PhotoFile';
|
||||||
import type { Point } from './Point';
|
import type { Point } from './Point';
|
||||||
@ -259,15 +258,6 @@ export class Camera extends React.PureComponent<CameraProps> {
|
|||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Static Functions (NativeModule)
|
//#region Static Functions (NativeModule)
|
||||||
/**
|
|
||||||
* Install JSI Bindings for Frame Processors
|
|
||||||
*/
|
|
||||||
public static installFrameProcessorBindings(): void {
|
|
||||||
assertJSIAvailable();
|
|
||||||
const result = CameraModule.installFrameProcessorBindings() as unknown;
|
|
||||||
if (result !== true)
|
|
||||||
throw new CameraRuntimeError('system/frame-processors-unavailable', 'Failed to install Frame Processor JSI bindings!');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all available camera devices on the current phone.
|
* Get a list of all available camera devices on the current phone.
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import type { Frame, FrameInternal } from './Frame';
|
import type { Frame, FrameInternal } from './Frame';
|
||||||
import type { FrameProcessor } from './CameraProps';
|
import type { FrameProcessor } from './CameraProps';
|
||||||
import { Camera } from './Camera';
|
|
||||||
import { CameraRuntimeError } from './CameraError';
|
import { CameraRuntimeError } from './CameraError';
|
||||||
|
|
||||||
// only import typescript types
|
// only import typescript types
|
||||||
import type TWorklets from 'react-native-worklets-core';
|
import type TWorklets from 'react-native-worklets-core';
|
||||||
|
import { CameraModule } from './NativeCameraModule';
|
||||||
|
import { assertJSIAvailable } from './JSIHelper';
|
||||||
|
|
||||||
type BasicParameterType = string | number | boolean | undefined;
|
type BasicParameterType = string | number | boolean | undefined;
|
||||||
type ParameterType = BasicParameterType | BasicParameterType[] | Record<string, BasicParameterType | undefined>;
|
type ParameterType = BasicParameterType | BasicParameterType[] | Record<string, BasicParameterType | undefined>;
|
||||||
@ -39,11 +40,16 @@ let runOnAsyncContext = (_frame: Frame, _func: () => void): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
assertJSIAvailable();
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
const { Worklets } = require('react-native-worklets-core') as typeof TWorklets;
|
const { Worklets } = require('react-native-worklets-core') as typeof TWorklets;
|
||||||
|
|
||||||
// Install native Frame Processor Runtime Manager
|
// Install native Frame Processor Runtime Manager
|
||||||
Camera.installFrameProcessorBindings();
|
const result = CameraModule.installFrameProcessorBindings() as unknown;
|
||||||
|
if (result !== true)
|
||||||
|
throw new CameraRuntimeError('system/frame-processors-unavailable', 'Failed to install Frame Processor JSI bindings!');
|
||||||
|
|
||||||
// @ts-expect-error global is untyped, it's a C++ host-object
|
// @ts-expect-error global is untyped, it's a C++ host-object
|
||||||
if (global.VisionCameraProxy == null) {
|
if (global.VisionCameraProxy == null) {
|
||||||
throw new CameraRuntimeError(
|
throw new CameraRuntimeError(
|
||||||
|
Loading…
Reference in New Issue
Block a user