UNPKG

@react-native-vector-icons/common

Version:

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

39 lines (37 loc) 1.7 kB
"use strict"; import { getIsRenderToImageSupported } from "./dynamicLoading/dynamic-loading-setting.js"; // eslint-disable-next-line import/no-mutable-exports let NativeIconAPI = null; try { // eslint-disable-next-line global-require,import/no-extraneous-dependencies,@typescript-eslint/no-require-imports 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 (fontReference, glyph, size, color) => ExpoFontUtils.renderToImageAsync(glyph, { fontFamily: fontReference, size, color }), 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 53+ (Expo dev client or Expo Go). Check your setup and rebuild the app.'); }; //# sourceMappingURL=get-image-library.js.map