UNPKG

@react-native-community/image-editor

Version:

React Native Image Editing native modules for iOS & Android

54 lines (50 loc) 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _reactNative = require("react-native"); var _NativeRNCImageEditor = _interopRequireDefault(require("./NativeRNCImageEditor")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ const LINKING_ERROR = `The package '@react-native-community/image-editor' doesn't seem to be linked. Make sure: \n\n` + _reactNative.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 RNCImageEditor = _NativeRNCImageEditor.default ? _NativeRNCImageEditor.default : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); function toHeadersObject(headers) { return headers instanceof Headers ? Object.fromEntries(headers.entries()) : headers; } class ImageEditor { /** * Crop the image specified by the URI param. If URI points to a remote * image, it will be downloaded automatically. If the image cannot be * loaded/downloaded, the promise will be rejected. On Android, a * downloaded image may be cached in external storage, a publicly accessible * location, if it has more available space than internal storage. * * If the cropping process is successful, the resultant cropped image * will be stored in the Cache Path, and the URI returned in the promise * will point to the image in the cache path. Remember to delete the * cropped image from the cache path when you are done with it. */ // TS overload for better `base64` type inference (see: `src/__typetests__/index.ts`) static cropImage(uri, cropData) { return RNCImageEditor.cropImage(uri, { ...cropData, headers: toHeadersObject(cropData.headers) }); } } var _default = exports.default = ImageEditor; //# sourceMappingURL=index.js.map