UNPKG

react-native-fs-turbo

Version:

React-Native library for working with Android/iOS file system, written using JSI and C++ TurboModules

53 lines (48 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRNFSTurboModule = getRNFSTurboModule; var _reactNative = require("react-native"); var _ModuleNotFoundError = require("./ModuleNotFoundError"); var _NativeRNFSTurboPlatformContextModule = require("./NativeRNFSTurboPlatformContextModule"); /** * Used for configuration of a single RNFSTurbo instance. */ /** * Used for configuration of a single RNFSTurbo instance. */ let _module; let configuration; function getRNFSTurboModule() { try { if (_module == null) { // 1. Load RNFS TurboModule _module = _reactNative.TurboModuleRegistry.getEnforcing("RNFSTurboModule"); // 2. Get the PlatformContext TurboModule as well const platformContext = (0, _NativeRNFSTurboPlatformContextModule.getRNFSTurboPlatformContextTurboModule)(); // 3. Initialize it with the storage directores from platform-specific context configuration = { mainBundlePath: platformContext.getMainBundlePath(), cachesDirectoryPath: platformContext.getCachesDirectoryPath(), documentDirectoryPath: platformContext.getDocumentDirectoryPath(), temporaryDirectoryPath: platformContext.getTemporaryDirectoryPath(), libraryDirectoryPath: platformContext.getLibraryDirectoryPath(), externalDirectoryPath: platformContext.getExternalDirectoryPath(), externalStorageDirectoryPath: platformContext.getExternalStorageDirectoryPath(), externalCachesDirectoryPath: platformContext.getExternalCachesDirectoryPath(), downloadDirectoryPath: platformContext.getDownloadDirectoryPath(), picturesDirectoryPath: platformContext.getPicturesDirectoryPath(), roamingDirectoryPath: platformContext.getRoamingDirectoryPath() }; } return { configuration, module: _module }; } catch { // TurboModule could not be found! throw new _ModuleNotFoundError.ModuleNotFoundError(); } } //# sourceMappingURL=NativeRNFSTurboModule.js.map