react-native-img-buffer-save
Version:
Fast React Native JSI library for saving images to the device gallery from binary buffers (Uint8Array or ArrayBuffer).
26 lines (25 loc) • 992 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.saveImageToGallery = void 0;
var _reactNative = require("react-native");
let __saveImageToGallery = global.saveImageToGallery;
if (!__saveImageToGallery) {
if (_reactNative.NativeModules.ImgBufferSave?.install) {
_reactNative.NativeModules.ImgBufferSave.install(); // Вызываем native install метод
__saveImageToGallery = global.saveImageToGallery; // Сохраняем глобальную ссылку на объект SqlDb
console.log('✅ react-native-img-buffer-save initialized successfully');
}
}
const saveImageToGallery = buff => {
if (buff instanceof Uint8Array) {
__saveImageToGallery(buff.buffer);
} else if (buff instanceof ArrayBuffer) {
__saveImageToGallery(buff);
} else {
throw new Error('Invalid argument type; must be ArrayBuffer or Uint8Array');
}
};
exports.saveImageToGallery = saveImageToGallery;
//# sourceMappingURL=index.js.map