UNPKG

@react-native-vector-icons/common

Version:

Customizable Icons for React Native with support for image source and full styling.

38 lines (37 loc) 1.6 kB
"use strict"; import { processColor } from 'react-native'; import { getIsRenderToImageSupported } from "./dynamicLoading/dynamic-loading-setting.js"; let NativeIconAPI = null; try { NativeIconAPI = require('@react-native-vector-icons/get-image'); } catch { // if this fails, it's likely due to: // "Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'VectorIcons' could not be found. ..." // No warning at this stage. } const globalRef = globalThis; const hasExpoRenderToImage = getIsRenderToImageSupported(globalRef); export const ensureGetImageAvailable = () => { if (NativeIconAPI) { NativeIconAPI.ensureNativeModuleAvailable(); return NativeIconAPI; } if (hasExpoRenderToImage) { const { ExpoFontUtils } = globalRef.expo.modules; return { getImageForFont: async (glyph, options) => { return await ExpoFontUtils.renderToImageAsync(glyph, { ...options, color: processColor(options.color ?? 'black') }); }, getImageForFontSync: () => { throw new Error('You attempted to call `getImageForFontSync`. Expo dev client with `@react-native-vector-icons/get-image` installed is required for this. Alternatively, call `getImageForFont` or generate the image yourself and bundle it with the app.'); } }; } throw new Error('Error in getImageSource / getImageSourceSync: You need to either (1) install `@react-native-vector-icons/get-image` or (2) use Expo SDK 54+ (Expo dev client or Expo Go). Check your setup and rebuild the app.'); }; //# sourceMappingURL=get-image-library.js.map