UNPKG

repoweaver

Version:

A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies

1 lines 7.17 kB
{"ast":null,"code":"\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.getImageSourceSync = exports.getImageSource = void 0;\nvar _reactNative = require(\"react-native-web/dist/index\");\nvar _defaults = require(\"./defaults.js\");\nvar _getImageLibrary = require(\"./get-image-library.js\");\nconst getImageSourceSync = (imageSourceCache, fontReference, glyph, size = _defaults.DEFAULT_ICON_SIZE, color = _defaults.DEFAULT_ICON_COLOR) => {\n const NativeIconAPI = (0, _getImageLibrary.ensureGetImageAvailable)();\n const processedColor = (0, _reactNative.processColor)(color);\n const cacheKey = `${glyph}:${size}:${String(processedColor)}`;\n const maybeCachedValue = imageSourceCache.get(cacheKey);\n if (maybeCachedValue !== undefined) {\n return maybeCachedValue;\n }\n try {\n const imagePath = NativeIconAPI.getImageForFontSync(fontReference, glyph, size, processedColor);\n const value = {\n uri: imagePath,\n scale: _reactNative.PixelRatio.get()\n };\n imageSourceCache.setValue(cacheKey, value);\n return value;\n } catch (error) {\n imageSourceCache.setError(cacheKey, error);\n throw error;\n }\n};\nexports.getImageSourceSync = getImageSourceSync;\nconst getImageSource = async (imageSourceCache, fontReference, glyph, size = _defaults.DEFAULT_ICON_SIZE, color = _defaults.DEFAULT_ICON_COLOR) => {\n const NativeIconAPI = (0, _getImageLibrary.ensureGetImageAvailable)();\n const processedColor = (0, _reactNative.processColor)(color);\n const cacheKey = `${glyph}:${size}:${String(processedColor)}`;\n const maybeCachedValue = imageSourceCache.get(cacheKey);\n if (maybeCachedValue !== undefined) {\n return maybeCachedValue;\n }\n try {\n const imagePath = await NativeIconAPI.getImageForFont(fontReference, glyph, size, processedColor);\n const value = {\n uri: imagePath,\n scale: _reactNative.PixelRatio.get()\n };\n imageSourceCache.setValue(cacheKey, value);\n return value;\n } catch (error) {\n imageSourceCache.setError(cacheKey, error);\n throw error;\n }\n};\nexports.getImageSource = getImageSource;","map":{"version":3,"names":["_defaults","require","_getImageLibrary","getImageSourceSync","imageSourceCache","fontReference","glyph","size","DEFAULT_ICON_SIZE","color","DEFAULT_ICON_COLOR","NativeIconAPI","ensureGetImageAvailable","processedColor","_reactNative","processColor","cacheKey","String","maybeCachedValue","get","undefined","imagePath","getImageForFontSync","value","uri","scale","PixelRatio","setValue","error","setError","exports","getImageSource","getImageForFont"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@react-native-vector-icons/common/src/get-image-source.ts"],"sourcesContent":["import type { TextStyle } from 'react-native';\nimport { PixelRatio, processColor } from 'react-native';\n\nimport type createIconSourceCache from './create-icon-source-cache';\nimport { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from './defaults';\nimport { ensureGetImageAvailable } from './get-image-library';\n\nexport const getImageSourceSync = (\n imageSourceCache: ReturnType<typeof createIconSourceCache>,\n fontReference: string,\n glyph: string,\n size = DEFAULT_ICON_SIZE,\n color: TextStyle['color'] = DEFAULT_ICON_COLOR,\n) => {\n const NativeIconAPI = ensureGetImageAvailable();\n\n const processedColor = processColor(color);\n const cacheKey = `${glyph}:${size}:${String(processedColor)}`;\n\n const maybeCachedValue = imageSourceCache.get(cacheKey);\n if (maybeCachedValue !== undefined) {\n // FIXME: Should this check if it's an error and throw it again?\n return maybeCachedValue;\n }\n\n try {\n const imagePath = NativeIconAPI.getImageForFontSync(\n fontReference,\n glyph,\n size,\n processedColor as number, // FIXME what if a non existent colour was passed in?\n );\n const value = { uri: imagePath, scale: PixelRatio.get() };\n imageSourceCache.setValue(cacheKey, value);\n return value;\n } catch (error) {\n imageSourceCache.setError(cacheKey, error as Error);\n throw error;\n }\n};\n\nexport const getImageSource = async (\n imageSourceCache: ReturnType<typeof createIconSourceCache>,\n fontReference: string,\n glyph: string,\n size = DEFAULT_ICON_SIZE,\n color: TextStyle['color'] = DEFAULT_ICON_COLOR,\n) => {\n const NativeIconAPI = ensureGetImageAvailable();\n\n const processedColor = processColor(color);\n const cacheKey = `${glyph}:${size}:${String(processedColor)}`;\n\n const maybeCachedValue = imageSourceCache.get(cacheKey);\n if (maybeCachedValue !== undefined) {\n // FIXME: Should this check if it's an error and throw it again?\n return maybeCachedValue;\n }\n\n try {\n const imagePath = await NativeIconAPI.getImageForFont(\n fontReference,\n glyph,\n size,\n processedColor as number, // FIXME what if a non existent colour was passed in?\n );\n const value = { uri: imagePath, scale: PixelRatio.get() };\n imageSourceCache.setValue(cacheKey, value);\n return value;\n } catch (error) {\n imageSourceCache.setError(cacheKey, error as Error);\n throw error;\n }\n};\n"],"mappings":";;;;;;;AAIA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAEO,MAAME,kBAAkB,GAAGA,CAChCC,gBAA0D,EAC1DC,aAAqB,EACrBC,KAAa,EACbC,IAAI,GAAGP,SAAA,CAAAQ,iBAAiB,EACxBC,KAAyB,GAAGT,SAAA,CAAAU,kBAAkB,KAC3C;EACH,MAAMC,aAAa,GAAG,IAAAT,gBAAA,CAAAU,uBAAuB,EAAC,CAAC;EAE/C,MAAMC,cAAc,GAAG,IAAAC,YAAA,CAAAC,YAAY,EAACN,KAAK,CAAC;EAC1C,MAAMO,QAAQ,GAAG,GAAGV,KAAK,IAAIC,IAAI,IAAIU,MAAM,CAACJ,cAAc,CAAC,EAAE;EAE7D,MAAMK,gBAAgB,GAAGd,gBAAgB,CAACe,GAAG,CAACH,QAAQ,CAAC;EACvD,IAAIE,gBAAgB,KAAKE,SAAS,EAAE;IAElC,OAAOF,gBAAgB;EACzB;EAEA,IAAI;IACF,MAAMG,SAAS,GAAGV,aAAa,CAACW,mBAAmB,CACjDjB,aAAa,EACbC,KAAK,EACLC,IAAI,EACJM,cACF,CAAC;IACD,MAAMU,KAAK,GAAG;MAAEC,GAAG,EAAEH,SAAS;MAAEI,KAAK,EAAEX,YAAA,CAAAY,UAAU,CAACP,GAAG,CAAC;IAAE,CAAC;IACzDf,gBAAgB,CA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