interwebsug / photo-editor-sdk-react-native

React Native implementation of the photoeditorsdk (https://www.photoeditorsdk.com/)
The Unlicense
42 stars 24 forks source link

PESDK.openCamera is undefined #18

Open MuhammadUsman786786 opened 4 years ago

MuhammadUsman786786 commented 4 years ago

package.json

{
  "name": "AppName",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/cameraroll": "^1.4.1",
    "@react-native-community/google-signin": "^4.0.0",
    "@react-native-community/masked-view": "^0.1.6",
    "@react-native-firebase/app": "^6.4.0",
    "@react-native-firebase/auth": "^6.4.0",
    "@react-native-firebase/firestore": "^6.4.0",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "prop-types": "^15.7.2",
    "ramda": "^0.27.0",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-actionsheet": "^2.4.2",
    "react-native-camera": "^3.23.1",
    "react-native-fbsdk": "^1.1.2",
    "react-native-gesture-handler": "^1.5.6",
    "react-native-image-crop-picker": "^0.28.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.1",
    "react-native-modal": "^11.5.3",
    "react-native-modalbox": "^2.0.0",
    "react-native-photoeditorsdk": "^2.4.1",
    "react-native-reanimated": "^1.7.0",
    "react-native-root-toast": "^3.2.0",
    "react-native-safe-area-context": "^0.6.4",
    "react-native-safe-area-view": "^1.0.0",
    "react-native-screens": "^2.0.0-beta.1",
    "react-native-size-matters": "^0.3.0",
    "react-native-snap-carousel": "^3.8.4",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "4.0.10",
    "react-navigation-redux-helpers": "^4.0.1",
    "react-navigation-stack": "^2.1.0",
    "react-redux": "6.0.1",
    "redux": "^4.0.4",
    "redux-persist": "5.10.0",
    "redux-saga": "^1.1.3",
    "redux-saga-routines": "^3.2.2",
    "reduxsauce": "^1.1.2"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.5.1",
    "jest": "^24.9.0",
    "jetifier": "^1.6.5",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.9.0",
    "reactotron-react-native": "2.2.0",
    "reactotron-redux": "2.1.3",
    "reactotron-redux-saga": "3.0.0",
    "seamless-immutable": "^7.1.4"
  },
  "jest": {
    "preset": "react-native"
  }
}

I have reviewed the code of the PESEK module. PESEK module file

import { Component } from 'react';
import { Configuration } from './configuration';

declare class PESDK {
  /**
   * Modally present a photo editor.
   * @note EXIF meta data is only preserved in the edited image if and only if the source
   * image is loaded from a local `file://` resource.
   *
   * @param {string | {uri: string} | number} image The source of the image to be edited.
   * Can be either an URI (local, remote, data resource, or any other registered scheme for the
   * React Native image loader), an object with a member `uri`, or an asset reference which can
   * be optained by, e.g., `require('./image.png')` as `number`. If this parameter is `null`,
   * the `serialization` parameter must not be `null` and it must contain an embedded source image.
   * @param {Configuration} configuration The configuration used to initialize the editor.
   * @param {object} serialization The serialization used to initialize the editor. This
   * restores a previous state of the editor by re-applying all modifications to the loaded
   * image.
   *
   * @return {Promise<{image: string, hasChanges: boolean, serialization: object}>} Returns the
   * edited `image`, an indicator (`hasChanges`) whether the input image was modified at all, and
   * all modifications (`serialization`) applied to the input image if `export.serialization.enabled`
   * of the `configuration` was set. If the editor is dismissed without exporting the edited image
   * `null` is returned instead.
   */
  static openEditor(
    image: string | {uri: string} | number,
    configuration: Configuration,
    serialization: object
  ): Promise<{image: string, hasChanges: boolean, serialization: object}>

  /**
   * Unlock PhotoEditor SDK with a license.
   *
   * @param {string | object} license The license used to unlock the SDK. Can be either an URI
   * pointing to a local `file://` resource that contains the license, the license as a string,
   * or the license as an object which can be optained by, e.g., `require('./pesdk_license')`
   * where the required license files must be named `./pesdk_license.ios.json` for the iOS license
   * and `./pesdk_license.android.json` for the Android license file in order to get automatically
   * resolved by the packager.
   */
  static unlockWithLicense(
    license: string | object
  ): void

  /**
   * Creates a configuration object populated with default values for all options.
   * @return {Configuration} The default configuration.
   */
  static createDefaultConfiguration(
  ): Configuration
}

/**
 * Props for the `PhotoEditorModal` component.
 */
interface PhotoEditorModalProps {
  /**
   * This prop determines whether your modal is visible.
   */
  visible: boolean;

  /**
   * This prop determines the source of the image to be edited.
   * Can be either an URI (local, remote, data resource, or any other registered scheme for the
   * React Native image loader), an object with a member `uri`, or an asset reference which can
   * be optained by, e.g., `require('./image.png')` as `number`.
   *
   * If this prop is `null`, the `serialization` prop must not be `null` and it must contain an
   * embedded source image.
   *
   * @note EXIF meta data is only preserved in the edited image if and only if the source
   * image is loaded from a local `file://` resource.
   */
  image?: string | {uri: string} | number;

  /**
   * This prop determines the configuration used to initialize the editor.
   */
  configuration?: Configuration;

  /**
   * This prop determines the serialization used to initialize the editor. This
   * restores a previous state of the editor by re-applying all modifications to the loaded
   * image.
   */
  serialization?: object;

  /**
   * This prop determines the callback function that will be called when the user exported an image.
   *
   * The object passed to this callback includes the edited `image`, an indicator (`hasChanges`) whether
   * the input image was modified at all, and all modifications (`serialization`) applied to the input image
   * if `export.serialization.enabled` of the `configuration` prop was set.
   */
  onExport: ({image: string, hasChanges: boolean, serialization: object}) => void;

  /**
   * This prop determines the callback function that will be called when the user dissmisses the editor without
   * exporting an image.
   */
  onCancel?: () => void;

  /**
   * This prop determines the callback function that will be called when an error occurs.
   */
  onError?: (error: Error) => void;
}

/**
 * State for the `PhotoEditorModal` component.
 */
interface PhotoEditorModalState {
  /**
   * This state determines whether the modal is visible.
   */
  visible: boolean;
}

/**
 * A component that wraps the `PESDK.openEditor` function to modally present a photo editor.
 */
declare class PhotoEditorModal extends Component<PhotoEditorModalProps, PhotoEditorModalState> {}

export { PESDK, PhotoEditorModal };
export * from './configuration';

Issue According to the documentation which is on this link https://github.com/interwebsug/photo-editor-sdk-react-native

PESDK.openCamera method exists But you can see inside the module this method does not exist.

Simulator Screen Shot - iPhone 11 - 2020-04-22 at 06 04 22

vannguyendev96 commented 3 years ago

Hello, have you fixed this error yet?

vannguyendev96 commented 3 years ago

I use react-native-photoeditorsdk in project RN.

I can use funtion openEditor but can't use funtion openCamera.

Error TypeError: _$$_REQUIRE(dependencyMap[5], "react-native-photoeditorsdk").PESDK.openCamera is not a function. (In '$$_REQUIRE(dependencyMap[5], "react-native-photoeditorsdk").PESDK.openCamera(configuration)', '$$_REQUIRE(_dependencyMap[5], "react-native-photoeditorsdk").PESDK.openCamera' is undefined)

How to fix it? Pls